mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
gst-player: add PlayerVideoRenderer subclassing support
This commit is contained in:
parent
ec2a287842
commit
01b16fe6c0
3 changed files with 45 additions and 0 deletions
|
@ -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::*;
|
||||
|
|
7
gstreamer-player/src/subclass/mod.rs
Normal file
7
gstreamer-player/src/subclass/mod.rs
Normal file
|
@ -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;
|
||||
}
|
36
gstreamer-player/src/subclass/player_video_renderer.rs
Normal file
36
gstreamer-player/src/subclass/player_video_renderer.rs
Normal file
|
@ -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<T: PlayerVideoRendererImpl> IsImplementable<T> 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::<T>);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_renderer_create_video_sink<T: PlayerVideoRendererImpl>(
|
||||
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()
|
||||
}
|
Loading…
Reference in a new issue