diff --git a/Gir_GstPlayer.toml b/Gir_GstPlayer.toml index 3a0fa0a59..01d9debce 100644 --- a/Gir_GstPlayer.toml +++ b/Gir_GstPlayer.toml @@ -78,6 +78,8 @@ trait = false [[object.signal]] name = "duration-changed" concurrency = "send" + # Pass ClockTime instead of u64 + ignore = true [[object.signal]] name = "end-of-stream" @@ -96,12 +98,16 @@ trait = false concurrency = "send" [[object.signal]] - name = "position-changed" + name = "position-updated" concurrency = "send" + # Pass ClockTime instead of u64 + ignore = true [[object.signal]] name = "seek-done" concurrency = "send" + # Pass ClockTime instead of u64 + ignore = true [[object.signal]] name = "state-changed" diff --git a/gstreamer-player/src/auto/player.rs b/gstreamer-player/src/auto/player.rs index 052133c7d..e8be24415 100644 --- a/gstreamer-player/src/auto/player.rs +++ b/gstreamer-player/src/auto/player.rs @@ -396,14 +396,6 @@ impl Player { } } - pub fn connect_duration_changed(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "duration-changed", - transmute(duration_changed_trampoline as usize), Box_::into_raw(f) as *mut _) - } - } - pub fn connect_end_of_stream(&self, f: F) -> SignalHandlerId { unsafe { let f: Box_> = Box_::new(Box_::new(f)); @@ -436,22 +428,6 @@ impl Player { } } - pub fn connect_position_updated(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "position-updated", - transmute(position_updated_trampoline as usize), Box_::into_raw(f) as *mut _) - } - } - - pub fn connect_seek_done(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "seek-done", - transmute(seek_done_trampoline as usize), Box_::into_raw(f) as *mut _) - } - } - pub fn connect_state_changed(&self, f: F) -> SignalHandlerId { unsafe { let f: Box_> = Box_::new(Box_::new(f)); @@ -638,12 +614,6 @@ unsafe extern "C" fn buffering_trampoline(this: *mut ffi::GstPlayer, object: lib f(&from_glib_borrow(this), object) } -unsafe extern "C" fn duration_changed_trampoline(this: *mut ffi::GstPlayer, object: u64, f: glib_ffi::gpointer) { - callback_guard!(); - let f: &&(Fn(&Player, u64) + Send + 'static) = transmute(f); - f(&from_glib_borrow(this), object) -} - unsafe extern "C" fn end_of_stream_trampoline(this: *mut ffi::GstPlayer, f: glib_ffi::gpointer) { callback_guard!(); let f: &&(Fn(&Player) + Send + 'static) = transmute(f); @@ -668,18 +638,6 @@ unsafe extern "C" fn mute_changed_trampoline(this: *mut ffi::GstPlayer, f: glib_ f(&from_glib_borrow(this)) } -unsafe extern "C" fn position_updated_trampoline(this: *mut ffi::GstPlayer, object: u64, f: glib_ffi::gpointer) { - callback_guard!(); - let f: &&(Fn(&Player, u64) + Send + Sync + 'static) = transmute(f); - f(&from_glib_borrow(this), object) -} - -unsafe extern "C" fn seek_done_trampoline(this: *mut ffi::GstPlayer, object: u64, f: glib_ffi::gpointer) { - callback_guard!(); - let f: &&(Fn(&Player, u64) + Send + 'static) = transmute(f); - f(&from_glib_borrow(this), object) -} - unsafe extern "C" fn state_changed_trampoline(this: *mut ffi::GstPlayer, object: ffi::GstPlayerState, f: glib_ffi::gpointer) { callback_guard!(); let f: &&(Fn(&Player, PlayerState) + Send + 'static) = transmute(f); diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index 1de123ed6..db2757c34 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -10,8 +10,13 @@ use Player; use PlayerSignalDispatcher; use PlayerVideoRenderer; use ffi; +use glib_ffi; +use glib::signal::SignalHandlerId; +use glib::signal::connect; use glib::translate::*; use gst; +use std::boxed::Box as Box_; +use std::mem::transmute; impl Player { pub fn new( @@ -40,4 +45,48 @@ impl Player { )) } } + + pub fn connect_duration_changed(&self, f: F) -> SignalHandlerId { + unsafe { + let f: Box_> = Box_::new(Box_::new(f)); + connect(self.to_glib_none().0, "duration-changed", + transmute(duration_changed_trampoline as usize), Box_::into_raw(f) as *mut _) + } + } + + pub fn connect_position_updated(&self, f: F) -> SignalHandlerId { + unsafe { + let f: Box_> = Box_::new(Box_::new(f)); + connect(self.to_glib_none().0, "position-updated", + transmute(position_updated_trampoline as usize), Box_::into_raw(f) as *mut _) + } + } + + + pub fn connect_seek_done(&self, f: F) -> SignalHandlerId { + unsafe { + let f: Box_> = Box_::new(Box_::new(f)); + connect(self.to_glib_none().0, "seek-done", + transmute(seek_done_trampoline as usize), Box_::into_raw(f) as *mut _) + } + } + +} + +unsafe extern "C" fn duration_changed_trampoline(this: *mut ffi::GstPlayer, object: u64, f: glib_ffi::gpointer) { + callback_guard!(); + let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f); + f(&from_glib_borrow(this), gst::ClockTime(Some(object))) +} + +unsafe extern "C" fn position_updated_trampoline(this: *mut ffi::GstPlayer, object: u64, f: glib_ffi::gpointer) { + callback_guard!(); + let f: &&(Fn(&Player, gst::ClockTime) + Send + Sync + 'static) = transmute(f); + f(&from_glib_borrow(this), gst::ClockTime(Some(object))) +} + +unsafe extern "C" fn seek_done_trampoline(this: *mut ffi::GstPlayer, object: u64, f: glib_ffi::gpointer) { + callback_guard!(); + let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f); + f(&from_glib_borrow(this), gst::ClockTime(Some(object))) }