diff --git a/gstreamer-player/src/lib.rs b/gstreamer-player/src/lib.rs index 510b693aa..a7a89b47d 100644 --- a/gstreamer-player/src/lib.rs +++ b/gstreamer-player/src/lib.rs @@ -23,6 +23,8 @@ macro_rules! assert_initialized_main_thread { mod auto; pub use crate::auto::*; +pub mod subclass; + mod config; mod player; pub use crate::config::*; diff --git a/gstreamer-player/src/subclass/mod.rs b/gstreamer-player/src/subclass/mod.rs new file mode 100644 index 000000000..fc3098edd --- /dev/null +++ b/gstreamer-player/src/subclass/mod.rs @@ -0,0 +1,7 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +mod player_video_renderer; + +pub mod prelude { + pub use super::player_video_renderer::PlayerVideoRendererImpl; +} diff --git a/gstreamer-player/src/subclass/player_video_renderer.rs b/gstreamer-player/src/subclass/player_video_renderer.rs new file mode 100644 index 000000000..af4217cd8 --- /dev/null +++ b/gstreamer-player/src/subclass/player_video_renderer.rs @@ -0,0 +1,36 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use crate::{Player, PlayerVideoRenderer}; + +use glib::subclass::prelude::*; +use glib::translate::*; +use glib::Cast; + +pub trait PlayerVideoRendererImpl: ObjectImpl { + fn create_video_sink(&self, video_renderer: &Self::Type, player: &Player) -> gst::Element; +} + +unsafe impl IsImplementable for PlayerVideoRenderer { + unsafe extern "C" fn interface_init( + iface: glib::ffi::gpointer, + _iface_data: glib::ffi::gpointer, + ) { + let video_renderer_iface = &mut *(iface as *mut ffi::GstPlayerVideoRendererInterface); + + video_renderer_iface.create_video_sink = Some(video_renderer_create_video_sink::); + } +} + +unsafe extern "C" fn video_renderer_create_video_sink( + video_renderer: *mut ffi::GstPlayerVideoRenderer, + player: *mut ffi::GstPlayer, +) -> *mut gst::ffi::GstElement { + let instance = &*(video_renderer as *mut T::Instance); + let imp = instance.get_impl(); + + imp.create_video_sink( + from_glib_borrow::<_, PlayerVideoRenderer>(video_renderer).unsafe_cast_ref(), + &Player::from_glib_borrow(player), + ) + .to_glib_full() +}