Skip to main content

gstreamer_video/auto/
video_overlay.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// app, SLOT(quit ()));
11    ///
12    ///  // prepare the pipeline
13    ///
14    ///  GstElement *pipeline = gst_pipeline_new ("xvoverlay");
15    ///  GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
16    ///  GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);
17    ///  gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
18    ///  gst_element_link (src, sink);
19    ///
20    ///  // prepare the ui
21    ///
22    ///  QWidget window;
23    ///  window.resize(320, 240);
24    ///  `window.show()`;
25    ///
26    ///  WId xwinid = window.winId();
27    ///  gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid);
28    ///
29    ///  // run the pipeline
30    ///
31    ///  GstStateChangeReturn sret = gst_element_set_state (pipeline,
32    ///  GST_STATE_PLAYING);
33    ///  if (sret == GST_STATE_CHANGE_FAILURE) {
34    ///  gst_element_set_state (pipeline, GST_STATE_NULL);
35    ///  gst_object_unref (pipeline);
36    ///  // Exit application
37    ///  QTimer::singleShot(0, QApplication::activeWindow(), SLOT(`quit()`));
38    ///  }
39    ///
40    ///  int ret = `app.exec()`;
41    ///
42    ///  `window.hide()`;
43    ///  gst_element_set_state (pipeline, GST_STATE_NULL);
44    ///  gst_object_unref (pipeline);
45    ///
46    ///  return ret;
47    /// }
48    /// ]|
49    ///
50    /// # Implements
51    ///
52    /// [`VideoOverlayExt`][trait@crate::prelude::VideoOverlayExt], [`VideoOverlayExtManual`][trait@crate::prelude::VideoOverlayExtManual]
53    #[doc(alias = "GstVideoOverlay")]
54    pub struct VideoOverlay(Interface<ffi::GstVideoOverlay, ffi::GstVideoOverlayInterface>);
55
56    match fn {
57        type_ => || ffi::gst_video_overlay_get_type(),
58    }
59}
60
61impl VideoOverlay {
62    pub const NONE: Option<&'static VideoOverlay> = None;
63
64    //#[doc(alias = "gst_video_overlay_install_properties")]
65    //pub fn install_properties(oclass: /*Ignored*/&mut glib::ObjectClass, last_prop_id: i32) {
66    //    unsafe { TODO: call ffi:gst_video_overlay_install_properties() }
67    //}
68}
69
70unsafe impl Send for VideoOverlay {}
71unsafe impl Sync for VideoOverlay {}
72
73/// Trait containing all [`struct@VideoOverlay`] methods.
74///
75/// # Implementors
76///
77/// [`VideoOverlay`][struct@crate::VideoOverlay]
78pub trait VideoOverlayExt: IsA<VideoOverlay> + 'static {
79    /// Tell an overlay that it has been exposed. This will redraw the current frame
80    /// in the drawable even if the pipeline is PAUSED.
81    #[doc(alias = "gst_video_overlay_expose")]
82    fn expose(&self) {
83        unsafe {
84            ffi::gst_video_overlay_expose(self.as_ref().to_glib_none().0);
85        }
86    }
87
88    //#[doc(alias = "gst_video_overlay_got_window_handle")]
89    //fn got_window_handle(&self, handle: /*Unimplemented*/Basic: UIntPtr) {
90    //    unsafe { TODO: call ffi:gst_video_overlay_got_window_handle() }
91    //}
92
93    /// Tell an overlay that it should handle events from the window system. These
94    /// events are forwarded upstream as navigation events. In some window system,
95    /// events are not propagated in the window hierarchy if a client is listening
96    /// for them. This method allows you to disable events handling completely
97    /// from the [`VideoOverlay`][crate::VideoOverlay].
98    /// ## `handle_events`
99    /// a `gboolean` indicating if events should be handled or not.
100    #[doc(alias = "gst_video_overlay_handle_events")]
101    fn handle_events(&self, handle_events: bool) {
102        unsafe {
103            ffi::gst_video_overlay_handle_events(
104                self.as_ref().to_glib_none().0,
105                handle_events.into_glib(),
106            );
107        }
108    }
109
110    /// This will post a "prepare-window-handle" element message on the bus
111    /// to give applications an opportunity to call
112    /// [`VideoOverlayExtManual::set_window_handle()`][crate::prelude::VideoOverlayExtManual::set_window_handle()] before a plugin creates its own
113    /// window.
114    ///
115    /// This function should only be used by video overlay plugin developers.
116    #[doc(alias = "gst_video_overlay_prepare_window_handle")]
117    fn prepare_window_handle(&self) {
118        unsafe {
119            ffi::gst_video_overlay_prepare_window_handle(self.as_ref().to_glib_none().0);
120        }
121    }
122
123    /// Configure a subregion as a video target within the window set by
124    /// [`VideoOverlayExtManual::set_window_handle()`][crate::prelude::VideoOverlayExtManual::set_window_handle()]. If this is not used or not supported
125    /// the video will fill the area of the window set as the overlay to 100%.
126    /// By specifying the rectangle, the video can be overlayed to a specific region
127    /// of that window only. After setting the new rectangle one should call
128    /// [`expose()`][Self::expose()] to force a redraw. To unset the region pass -1 for
129    /// the `width` and `height` parameters.
130    ///
131    /// This method is needed for non fullscreen video overlay in UI toolkits that
132    /// do not support subwindows.
133    /// ## `x`
134    /// the horizontal offset of the render area inside the window
135    /// ## `y`
136    /// the vertical offset of the render area inside the window
137    /// ## `width`
138    /// the width of the render area inside the window
139    /// ## `height`
140    /// the height of the render area inside the window
141    ///
142    /// # Returns
143    ///
144    /// [`false`] if not supported by the sink.
145    #[doc(alias = "gst_video_overlay_set_render_rectangle")]
146    fn set_render_rectangle(
147        &self,
148        x: i32,
149        y: i32,
150        width: i32,
151        height: i32,
152    ) -> Result<(), glib::error::BoolError> {
153        unsafe {
154            glib::result_from_gboolean!(
155                ffi::gst_video_overlay_set_render_rectangle(
156                    self.as_ref().to_glib_none().0,
157                    x,
158                    y,
159                    width,
160                    height
161                ),
162                "Failed to set render rectangle"
163            )
164        }
165    }
166}
167
168impl<O: IsA<VideoOverlay>> VideoOverlayExt for O {}