diff --git a/src/core.rs b/src/core.rs index 5f39c3d..eb9f924 100644 --- a/src/core.rs +++ b/src/core.rs @@ -25,7 +25,7 @@ pub fn compiler() -> String { } pub struct Instance { - pub ptr: *mut sys::libvlc_instance_t, + pub(crate) ptr: *mut sys::libvlc_instance_t, } impl Instance { @@ -102,6 +102,11 @@ impl Instance { sys::libvlc_log_set(self.ptr, logging_cb, Box::into_raw(cb) as *mut _); } } + + /// Returns raw pointer + pub fn raw(&self) -> *mut sys::libvlc_instance_t { + self.ptr + } } impl Drop for Instance { @@ -132,6 +137,13 @@ pub struct ModuleDescriptionList { ptr: *mut sys::libvlc_module_description_t, } +impl ModuleDescriptionList { + /// Returns raw pointer + pub fn raw(&self) -> *mut sys::libvlc_module_description_t { + self.ptr + } +} + impl Drop for ModuleDescriptionList { fn drop(&mut self) { unsafe{ sys::libvlc_module_description_list_release(self.ptr) }; @@ -273,8 +285,8 @@ pub enum Event { } pub struct EventManager<'a> { - pub ptr: *mut sys::libvlc_event_manager_t, - pub _phantomdata: ::std::marker::PhantomData<&'a sys::libvlc_event_manager_t>, + pub(crate) ptr: *mut sys::libvlc_event_manager_t, + pub(crate) _phantomdata: ::std::marker::PhantomData<&'a sys::libvlc_event_manager_t>, } impl<'a> EventManager<'a> { @@ -297,12 +309,17 @@ impl<'a> EventManager<'a> { Err(()) } } + + /// Returns raw pointer + pub fn raw(&self) -> *mut sys::libvlc_event_manager_t { + self.ptr + } } unsafe extern "C" fn event_manager_callback(pe: *const sys::libvlc_event_t, data: *mut c_void) { let f: &Box = ::std::mem::transmute(data); - f(conv_event(pe), VLCObject{_ptr: (*pe).p_obj}); + f(conv_event(pe), VLCObject{ ptr: (*pe).p_obj }); } // Convert c-style libvlc_event_t to Event @@ -479,10 +496,24 @@ fn conv_event(pe: *const sys::libvlc_event_t) -> Event { } pub struct VLCObject { - _ptr: *mut c_void, + ptr: *mut c_void, +} + +impl VLCObject { + /// Returns raw pointer + pub fn raw(&self) -> *mut c_void { + self.ptr + } } pub struct Log { - pub ptr: *const sys::libvlc_log_t + pub(crate) ptr: *const sys::libvlc_log_t +} + +impl Log { + /// Returns raw pointer + pub fn raw(&self) -> *const sys::libvlc_log_t { + self.ptr + } } diff --git a/src/media.rs b/src/media.rs index aa19291..60e4656 100644 --- a/src/media.rs +++ b/src/media.rs @@ -9,7 +9,7 @@ use ::tools::{to_cstr, from_cstr, path_to_cstr}; use std::path::Path; pub struct Media { - pub ptr: *mut sys::libvlc_media_t, + pub(crate) ptr: *mut sys::libvlc_media_t, } impl Media { @@ -181,6 +181,11 @@ impl Media { Some(track) } } + + /// Returns raw pointer + pub fn raw(&self) -> *mut sys::libvlc_media_t { + self.ptr + } } impl Drop for Media { diff --git a/src/media_library.rs b/src/media_library.rs index 5000452..e79da20 100644 --- a/src/media_library.rs +++ b/src/media_library.rs @@ -6,7 +6,7 @@ use sys; use ::{Instance, MediaList}; pub struct MediaLibrary { - pub ptr: *mut sys::libvlc_media_library_t, + pub(crate) ptr: *mut sys::libvlc_media_library_t, } impl MediaLibrary { @@ -32,6 +32,11 @@ impl MediaLibrary { if p.is_null() { None }else{ Some(MediaList{ptr: p}) } } } + + /// Returns raw pointer + pub fn raw(&self) -> *mut sys::libvlc_media_library_t { + self.ptr + } } impl Drop for MediaLibrary { diff --git a/src/media_list.rs b/src/media_list.rs index 03a58e0..2b84125 100644 --- a/src/media_list.rs +++ b/src/media_list.rs @@ -6,7 +6,7 @@ use sys; use ::{Instance, Media, EventManager}; pub struct MediaList { - pub ptr: *mut sys::libvlc_media_list_t, + pub(crate) ptr: *mut sys::libvlc_media_list_t, } impl MediaList { @@ -104,6 +104,11 @@ impl MediaList { EventManager{ptr: p, _phantomdata: ::std::marker::PhantomData} } } + + /// Returns raw pointer + pub fn raw(&self) -> *mut sys::libvlc_media_list_t { + self.ptr + } } impl Drop for MediaList { diff --git a/src/media_player.rs b/src/media_player.rs index 3b95f77..15aebf0 100644 --- a/src/media_player.rs +++ b/src/media_player.rs @@ -12,7 +12,7 @@ use std::mem::transmute; /// A LibVLC media player plays one media (usually in a custom drawable). pub struct MediaPlayer { - pub ptr: *mut sys::libvlc_media_player_t, + pub(crate) ptr: *mut sys::libvlc_media_player_t, } impl MediaPlayer { @@ -311,6 +311,11 @@ impl MediaPlayer { pub fn set_video_title_display(&self, position: Position, timeout: u32) { unsafe{ sys::libvlc_media_player_set_video_title_display(self.ptr, position, timeout); } } + + /// Returns raw pointer + pub fn raw(&self) -> *mut sys::libvlc_media_player_t { + self.ptr + } } impl Drop for MediaPlayer {