Rewrite enums to use libvlc-sys symbols
parent
28fafc02f5
commit
c52205075c
|
@ -154,7 +154,7 @@ unsafe extern "C" fn logging_cb(
|
||||||
|
|
||||||
vsnprintf(buf.as_mut_ptr(), BUF_SIZE, fmt, args);
|
vsnprintf(buf.as_mut_ptr(), BUF_SIZE, fmt, args);
|
||||||
|
|
||||||
f(::std::mem::transmute(level), Log{ptr: ctx}, from_cstr_ref(buf.as_ptr()).unwrap());
|
f((level as u32).into(), Log{ptr: ctx}, from_cstr_ref(buf.as_ptr()).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of module description.
|
/// List of module description.
|
||||||
|
@ -349,7 +349,7 @@ unsafe extern "C" fn event_manager_callback(pe: *const sys::libvlc_event_t, data
|
||||||
|
|
||||||
// Convert c-style libvlc_event_t to Event
|
// Convert c-style libvlc_event_t to Event
|
||||||
fn conv_event(pe: *const sys::libvlc_event_t) -> Event {
|
fn conv_event(pe: *const sys::libvlc_event_t) -> Event {
|
||||||
let event_type: EventType = unsafe{ ::std::mem::transmute((*pe)._type) };
|
let event_type: EventType = (unsafe{ (*pe)._type } as u32).into();
|
||||||
|
|
||||||
match event_type {
|
match event_type {
|
||||||
EventType::MediaMetaChanged => {
|
EventType::MediaMetaChanged => {
|
||||||
|
|
296
src/enums.rs
296
src/enums.rs
|
@ -2,158 +2,170 @@
|
||||||
// This file is part of vlc-rs.
|
// This file is part of vlc-rs.
|
||||||
// Licensed under the MIT license, see the LICENSE file.
|
// Licensed under the MIT license, see the LICENSE file.
|
||||||
|
|
||||||
#[repr(C)]
|
use libvlc_sys as sys;
|
||||||
|
|
||||||
|
macro_rules! define_enum {
|
||||||
|
($enum_name:ident, $original_type:ident; $($value:ident = $c_value:ident,)*) => {
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||||
pub enum LogLevel {
|
|
||||||
Debug = 0,
|
|
||||||
Notice = 2,
|
|
||||||
Warning = 3,
|
|
||||||
Error = 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
pub enum $enum_name {
|
||||||
pub enum Meta {
|
$(
|
||||||
Title,
|
$value = sys::$c_value as isize,
|
||||||
Artist,
|
)*
|
||||||
Genre,
|
|
||||||
Copyright,
|
|
||||||
Album,
|
|
||||||
TrackNumber,
|
|
||||||
Description,
|
|
||||||
Rating,
|
|
||||||
Date,
|
|
||||||
Setting,
|
|
||||||
URL,
|
|
||||||
Language,
|
|
||||||
NowPlaying,
|
|
||||||
Publisher,
|
|
||||||
EncodedBy,
|
|
||||||
ArtworkURL,
|
|
||||||
TrackID,
|
|
||||||
TrackTotal,
|
|
||||||
Director,
|
|
||||||
Season,
|
|
||||||
Episode,
|
|
||||||
ShowName,
|
|
||||||
Actors
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
impl From<sys::$original_type> for $enum_name {
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
fn from(a: sys::$original_type) -> Self {
|
||||||
pub enum State {
|
match a {
|
||||||
NothingSpecial = 0,
|
$(
|
||||||
Opening,
|
sys::$c_value => Self::$value,
|
||||||
Buffering,
|
)*
|
||||||
Playing,
|
_ => unreachable!(),
|
||||||
Paused,
|
}
|
||||||
Stopped,
|
}
|
||||||
Ended,
|
}
|
||||||
Error
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
define_enum!(
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
LogLevel, libvlc_log_level;
|
||||||
pub enum TrackType {
|
Debug = libvlc_log_level_LIBVLC_DEBUG,
|
||||||
Unknown = -1,
|
Dotice = libvlc_log_level_LIBVLC_NOTICE,
|
||||||
Audio = 0,
|
Warning = libvlc_log_level_LIBVLC_WARNING,
|
||||||
Video = 1,
|
Error = libvlc_log_level_LIBVLC_ERROR,
|
||||||
Text = 2
|
);
|
||||||
}
|
|
||||||
|
|
||||||
#[repr(C)]
|
define_enum!(
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
Meta, libvlc_meta_t;
|
||||||
pub enum Position {
|
Title = libvlc_meta_t_libvlc_meta_Title,
|
||||||
Disable = -1,
|
Artist = libvlc_meta_t_libvlc_meta_Artist,
|
||||||
Center,
|
Genre = libvlc_meta_t_libvlc_meta_Genre,
|
||||||
Left,
|
Copyright = libvlc_meta_t_libvlc_meta_Copyright,
|
||||||
Right,
|
Album = libvlc_meta_t_libvlc_meta_Album,
|
||||||
Top,
|
TrackNumber = libvlc_meta_t_libvlc_meta_TrackNumber,
|
||||||
TopLeft,
|
Description = libvlc_meta_t_libvlc_meta_Description,
|
||||||
TopRight,
|
Rating = libvlc_meta_t_libvlc_meta_Rating,
|
||||||
Bottom,
|
Date = libvlc_meta_t_libvlc_meta_Date,
|
||||||
BottomLeft,
|
Setting = libvlc_meta_t_libvlc_meta_Setting,
|
||||||
BottomRight,
|
URL = libvlc_meta_t_libvlc_meta_URL,
|
||||||
}
|
Language = libvlc_meta_t_libvlc_meta_Language,
|
||||||
|
NowPlaying = libvlc_meta_t_libvlc_meta_NowPlaying,
|
||||||
|
Publisher = libvlc_meta_t_libvlc_meta_Publisher,
|
||||||
|
EncodedBy = libvlc_meta_t_libvlc_meta_EncodedBy,
|
||||||
|
ArtworkURL = libvlc_meta_t_libvlc_meta_ArtworkURL,
|
||||||
|
TrackID = libvlc_meta_t_libvlc_meta_TrackID,
|
||||||
|
TrackTotal = libvlc_meta_t_libvlc_meta_TrackTotal,
|
||||||
|
Director = libvlc_meta_t_libvlc_meta_Director,
|
||||||
|
Season = libvlc_meta_t_libvlc_meta_Season,
|
||||||
|
Episode = libvlc_meta_t_libvlc_meta_Episode,
|
||||||
|
ShowName = libvlc_meta_t_libvlc_meta_ShowName,
|
||||||
|
Actors = libvlc_meta_t_libvlc_meta_Actors,
|
||||||
|
);
|
||||||
|
|
||||||
#[repr(C)]
|
define_enum!(
|
||||||
#[derive(Clone, Copy, Debug)]
|
State, libvlc_state_t;
|
||||||
pub enum VideoAdjustOption {
|
NothingSpecial = libvlc_state_t_libvlc_NothingSpecial,
|
||||||
Enable = 0,
|
Opening = libvlc_state_t_libvlc_Opening,
|
||||||
Contrast,
|
Buffering = libvlc_state_t_libvlc_Buffering,
|
||||||
Brightness,
|
Playing = libvlc_state_t_libvlc_Playing,
|
||||||
Hue,
|
Paused = libvlc_state_t_libvlc_Paused,
|
||||||
Saturation,
|
Stopped = libvlc_state_t_libvlc_Stopped,
|
||||||
Gamma
|
Ended = libvlc_state_t_libvlc_Ended,
|
||||||
}
|
Error = libvlc_state_t_libvlc_Error,
|
||||||
|
);
|
||||||
|
|
||||||
// #[repr(C)]
|
define_enum!(
|
||||||
// #[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
TrackType, libvlc_track_type_t;
|
||||||
// pub enum ParseFlag {
|
Unknown = libvlc_track_type_t_libvlc_track_unknown,
|
||||||
// ParseLocal,
|
Audio = libvlc_track_type_t_libvlc_track_audio,
|
||||||
// ParseNetwork,
|
Video = libvlc_track_type_t_libvlc_track_video,
|
||||||
// FetchLocal,
|
Text = libvlc_track_type_t_libvlc_track_text,
|
||||||
// FetchNetwork,
|
);
|
||||||
// }
|
|
||||||
|
|
||||||
#[repr(C)]
|
define_enum!(
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
Position, libvlc_position_t;
|
||||||
pub enum EventType {
|
Disable = libvlc_position_t_libvlc_position_disable,
|
||||||
MediaMetaChanged = 0,
|
Center = libvlc_position_t_libvlc_position_center,
|
||||||
MediaSubItemAdded,
|
Left = libvlc_position_t_libvlc_position_left,
|
||||||
MediaDurationChanged,
|
Right = libvlc_position_t_libvlc_position_right,
|
||||||
MediaParsedChanged,
|
Top = libvlc_position_t_libvlc_position_top,
|
||||||
MediaFreed,
|
TopLeft = libvlc_position_t_libvlc_position_top_left,
|
||||||
MediaStateChanged,
|
TopRight = libvlc_position_t_libvlc_position_top_right,
|
||||||
MediaSubItemTreeAdded,
|
Bottom = libvlc_position_t_libvlc_position_bottom,
|
||||||
|
BottomLeft = libvlc_position_t_libvlc_position_bottom_left,
|
||||||
|
BottomRight = libvlc_position_t_libvlc_position_bottom_right,
|
||||||
|
);
|
||||||
|
|
||||||
MediaPlayerMediaChanged = 0x100,
|
define_enum!(
|
||||||
MediaPlayerNothingSpecial,
|
VideoAdjustOption, libvlc_video_adjust_option_t;
|
||||||
MediaPlayerOpening,
|
Enable = libvlc_video_adjust_option_t_libvlc_adjust_Enable,
|
||||||
MediaPlayerBuffering,
|
Contrast = libvlc_video_adjust_option_t_libvlc_adjust_Contrast,
|
||||||
MediaPlayerPlaying,
|
Brightness = libvlc_video_adjust_option_t_libvlc_adjust_Brightness,
|
||||||
MediaPlayerPaused,
|
Hue = libvlc_video_adjust_option_t_libvlc_adjust_Hue,
|
||||||
MediaPlayerStopped,
|
Saturation = libvlc_video_adjust_option_t_libvlc_adjust_Saturation,
|
||||||
MediaPlayerForward,
|
Gamma = libvlc_video_adjust_option_t_libvlc_adjust_Gamma,
|
||||||
MediaPlayerBackward,
|
);
|
||||||
MediaPlayerEndReached,
|
|
||||||
MediaPlayerEncounteredError,
|
|
||||||
MediaPlayerTimeChanged,
|
|
||||||
MediaPlayerPositionChanged,
|
|
||||||
MediaPlayerSeekableChanged,
|
|
||||||
MediaPlayerPausableChanged,
|
|
||||||
MediaPlayerTitleChanged,
|
|
||||||
MediaPlayerSnapshotTaken,
|
|
||||||
MediaPlayerLengthChanged,
|
|
||||||
MediaPlayerVout,
|
|
||||||
MediaPlayerScrambledChanged,
|
|
||||||
|
|
||||||
MediaListItemAdded = 0x200,
|
define_enum!(
|
||||||
MediaListWillAddItem,
|
ParseFlag, libvlc_media_parse_flag_t;
|
||||||
MediaListItemDeleted,
|
DoInteract = libvlc_media_parse_flag_t_libvlc_media_do_interact,
|
||||||
MediaListWillDeleteItem,
|
FetchLocal = libvlc_media_parse_flag_t_libvlc_media_fetch_local,
|
||||||
|
FetchNetwork = libvlc_media_parse_flag_t_libvlc_media_fetch_network,
|
||||||
|
ParseLocal = libvlc_media_parse_flag_t_libvlc_media_parse_local,
|
||||||
|
ParseNetwork = libvlc_media_parse_flag_t_libvlc_media_parse_network,
|
||||||
|
);
|
||||||
|
|
||||||
MediaListViewItemAdded = 0x300,
|
define_enum!(
|
||||||
MediaListViewWillAddItem,
|
EventType, libvlc_event_e;
|
||||||
MediaListViewItemDeleted,
|
MediaMetaChanged = libvlc_event_e_libvlc_MediaMetaChanged,
|
||||||
MediaListViewWillDeleteItem,
|
MediaSubItemAdded = libvlc_event_e_libvlc_MediaSubItemAdded,
|
||||||
|
MediaDurationChanged = libvlc_event_e_libvlc_MediaDurationChanged,
|
||||||
MediaListPlayerPlayed = 0x400,
|
MediaParsedChanged = libvlc_event_e_libvlc_MediaParsedChanged,
|
||||||
MediaListPlayerNextItemSet,
|
MediaFreed = libvlc_event_e_libvlc_MediaFreed,
|
||||||
MediaListPlayerStopped,
|
MediaStateChanged = libvlc_event_e_libvlc_MediaStateChanged,
|
||||||
|
MediaSubItemTreeAdded = libvlc_event_e_libvlc_MediaSubItemTreeAdded,
|
||||||
MediaDiscovererStarted = 0x500,
|
MediaPlayerMediaChanged = libvlc_event_e_libvlc_MediaPlayerMediaChanged,
|
||||||
MediaDiscovererEnded,
|
MediaPlayerNothingSpecial = libvlc_event_e_libvlc_MediaPlayerNothingSpecial,
|
||||||
|
MediaPlayerOpening = libvlc_event_e_libvlc_MediaPlayerOpening,
|
||||||
VlmMediaAdded = 0x600,
|
MediaPlayerBuffering = libvlc_event_e_libvlc_MediaPlayerBuffering,
|
||||||
VlmMediaRemoved,
|
MediaPlayerPlaying = libvlc_event_e_libvlc_MediaPlayerPlaying,
|
||||||
VlmMediaChanged,
|
MediaPlayerPaused = libvlc_event_e_libvlc_MediaPlayerPaused,
|
||||||
VlmMediaInstanceStarted,
|
MediaPlayerStopped = libvlc_event_e_libvlc_MediaPlayerStopped,
|
||||||
VlmMediaInstanceStopped,
|
MediaPlayerForward = libvlc_event_e_libvlc_MediaPlayerForward,
|
||||||
VlmMediaInstanceStatusInit,
|
MediaPlayerBackward = libvlc_event_e_libvlc_MediaPlayerBackward,
|
||||||
VlmMediaInstanceStatusOpening,
|
MediaPlayerEndReached = libvlc_event_e_libvlc_MediaPlayerEndReached,
|
||||||
VlmMediaInstanceStatusPlaying,
|
MediaPlayerEncounteredError = libvlc_event_e_libvlc_MediaPlayerEncounteredError,
|
||||||
VlmMediaInstanceStatusPause,
|
MediaPlayerTimeChanged = libvlc_event_e_libvlc_MediaPlayerTimeChanged,
|
||||||
VlmMediaInstanceStatusEnd,
|
MediaPlayerPositionChanged = libvlc_event_e_libvlc_MediaPlayerPositionChanged,
|
||||||
VlmMediaInstanceStatusError
|
MediaPlayerSeekableChanged = libvlc_event_e_libvlc_MediaPlayerSeekableChanged,
|
||||||
}
|
MediaPlayerPausableChanged = libvlc_event_e_libvlc_MediaPlayerPausableChanged,
|
||||||
|
MediaPlayerTitleChanged = libvlc_event_e_libvlc_MediaPlayerTitleChanged,
|
||||||
|
MediaPlayerSnapshotTaken = libvlc_event_e_libvlc_MediaPlayerSnapshotTaken,
|
||||||
|
MediaPlayerLengthChanged = libvlc_event_e_libvlc_MediaPlayerLengthChanged,
|
||||||
|
MediaPlayerVout = libvlc_event_e_libvlc_MediaPlayerVout,
|
||||||
|
MediaPlayerScrambledChanged = libvlc_event_e_libvlc_MediaPlayerScrambledChanged,
|
||||||
|
MediaListItemAdded = libvlc_event_e_libvlc_MediaListItemAdded,
|
||||||
|
MediaListWillAddItem = libvlc_event_e_libvlc_MediaListWillAddItem,
|
||||||
|
MediaListItemDeleted = libvlc_event_e_libvlc_MediaListItemDeleted,
|
||||||
|
MediaListWillDeleteItem = libvlc_event_e_libvlc_MediaListWillDeleteItem,
|
||||||
|
MediaListViewItemAdded = libvlc_event_e_libvlc_MediaListViewItemAdded,
|
||||||
|
MediaListViewWillAddItem = libvlc_event_e_libvlc_MediaListViewWillAddItem,
|
||||||
|
MediaListViewItemDeleted = libvlc_event_e_libvlc_MediaListViewItemDeleted,
|
||||||
|
MediaListViewWillDeleteItem = libvlc_event_e_libvlc_MediaListViewWillDeleteItem,
|
||||||
|
MediaListPlayerPlayed = libvlc_event_e_libvlc_MediaListPlayerPlayed,
|
||||||
|
MediaListPlayerNextItemSet = libvlc_event_e_libvlc_MediaListPlayerNextItemSet,
|
||||||
|
MediaListPlayerStopped = libvlc_event_e_libvlc_MediaListPlayerStopped,
|
||||||
|
MediaDiscovererStarted = libvlc_event_e_libvlc_MediaDiscovererStarted,
|
||||||
|
MediaDiscovererEnded = libvlc_event_e_libvlc_MediaDiscovererEnded,
|
||||||
|
VlmMediaAdded = libvlc_event_e_libvlc_VlmMediaAdded,
|
||||||
|
VlmMediaRemoved = libvlc_event_e_libvlc_VlmMediaRemoved,
|
||||||
|
VlmMediaChanged = libvlc_event_e_libvlc_VlmMediaChanged,
|
||||||
|
VlmMediaInstanceStarted = libvlc_event_e_libvlc_VlmMediaInstanceStarted,
|
||||||
|
VlmMediaInstanceStopped = libvlc_event_e_libvlc_VlmMediaInstanceStopped,
|
||||||
|
VlmMediaInstanceStatusInit = libvlc_event_e_libvlc_VlmMediaInstanceStatusInit,
|
||||||
|
VlmMediaInstanceStatusOpening = libvlc_event_e_libvlc_VlmMediaInstanceStatusOpening,
|
||||||
|
VlmMediaInstanceStatusPlaying = libvlc_event_e_libvlc_VlmMediaInstanceStatusPlaying,
|
||||||
|
VlmMediaInstanceStatusPause = libvlc_event_e_libvlc_VlmMediaInstanceStatusPause,
|
||||||
|
VlmMediaInstanceStatusEnd = libvlc_event_e_libvlc_VlmMediaInstanceStatusEnd,
|
||||||
|
VlmMediaInstanceStatusError = libvlc_event_e_libvlc_VlmMediaInstanceStatusError,
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue