diff --git a/gstreamer-player/src/lib.rs b/gstreamer-player/src/lib.rs index 15258b9a5..158bbaa7b 100644 --- a/gstreamer-player/src/lib.rs +++ b/gstreamer-player/src/lib.rs @@ -44,3 +44,6 @@ pub use auto::*; pub use auto::traits::*; mod player; + +mod player_video_overlay_video_renderer; +pub use player_video_overlay_video_renderer::PlayerVideoOverlayVideoRendererExtManual; diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index 9154b64a8..9a84e4dde 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -34,7 +34,6 @@ impl Player { } - #[allow(dead_code)] pub fn set_config(&self, config: gst::Structure) -> bool { unsafe { from_glib(ffi::gst_player_set_config( diff --git a/gstreamer-player/src/player_video_overlay_video_renderer.rs b/gstreamer-player/src/player_video_overlay_video_renderer.rs new file mode 100644 index 000000000..1e7e69cba --- /dev/null +++ b/gstreamer-player/src/player_video_overlay_video_renderer.rs @@ -0,0 +1,75 @@ +// Copyright (C) 2017 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use PlayerVideoOverlayVideoRenderer; +use ffi; +use glib; +use glib::IsA; +use glib::translate::*; +use gst; + +use std::ptr; + +use libc::uintptr_t; + +impl PlayerVideoOverlayVideoRenderer { + pub unsafe fn new(window_handle: uintptr_t) -> PlayerVideoOverlayVideoRenderer { + assert_initialized_main_thread!(); + + from_glib_full(ffi::gst_player_video_overlay_video_renderer_new( + window_handle as *mut _, + ) as *mut _) + } + + pub unsafe fn new_with_handle_and_sink>( + window_handle: uintptr_t, + video_sink: &P, + ) -> PlayerVideoOverlayVideoRenderer { + assert_initialized_main_thread!(); + + from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink( + window_handle as *mut _, + video_sink.to_glib_none().0, + ) as + *mut _) + } + + pub fn new_with_sink>(video_sink: &P) -> PlayerVideoOverlayVideoRenderer { + assert_initialized_main_thread!(); + + unsafe { + from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink( + ptr::null_mut(), + video_sink.to_glib_none().0, + ) as + *mut _) + } + } +} + +pub trait PlayerVideoOverlayVideoRendererExtManual { + unsafe fn get_window_handle(&self) -> uintptr_t; + + unsafe fn set_window_handle(&self, window_handle: uintptr_t); +} + +impl< + O: IsA + IsA, +> PlayerVideoOverlayVideoRendererExtManual for O { + unsafe fn get_window_handle(&self) -> uintptr_t { + ffi::gst_player_video_overlay_video_renderer_get_window_handle(self.to_glib_none().0) as + uintptr_t + } + + unsafe fn set_window_handle(&self, window_handle: uintptr_t) { + ffi::gst_player_video_overlay_video_renderer_set_window_handle( + self.to_glib_none().0, + window_handle as *mut _, + ) + } +}