gstreamer_video/auto/
video_orientation.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    /// The interface allows unified access to control flipping and autocenter
11    /// operation of video-sources or operators.
12    ///
13    /// # Implements
14    ///
15    /// [`VideoOrientationExt`][trait@crate::prelude::VideoOrientationExt]
16    #[doc(alias = "GstVideoOrientation")]
17    pub struct VideoOrientation(Interface<ffi::GstVideoOrientation, ffi::GstVideoOrientationInterface>);
18
19    match fn {
20        type_ => || ffi::gst_video_orientation_get_type(),
21    }
22}
23
24impl VideoOrientation {
25    pub const NONE: Option<&'static VideoOrientation> = None;
26}
27
28unsafe impl Send for VideoOrientation {}
29unsafe impl Sync for VideoOrientation {}
30
31mod sealed {
32    pub trait Sealed {}
33    impl<T: super::IsA<super::VideoOrientation>> Sealed for T {}
34}
35
36/// Trait containing all [`struct@VideoOrientation`] methods.
37///
38/// # Implementors
39///
40/// [`VideoOrientation`][struct@crate::VideoOrientation]
41pub trait VideoOrientationExt: IsA<VideoOrientation> + sealed::Sealed + 'static {
42    /// Get the horizontal centering offset from the given object.
43    ///
44    /// # Returns
45    ///
46    /// [`true`] in case the element supports centering
47    ///
48    /// ## `center`
49    /// return location for the result
50    #[doc(alias = "gst_video_orientation_get_hcenter")]
51    #[doc(alias = "get_hcenter")]
52    fn hcenter(&self) -> Option<i32> {
53        unsafe {
54            let mut center = std::mem::MaybeUninit::uninit();
55            let ret = from_glib(ffi::gst_video_orientation_get_hcenter(
56                self.as_ref().to_glib_none().0,
57                center.as_mut_ptr(),
58            ));
59            if ret {
60                Some(center.assume_init())
61            } else {
62                None
63            }
64        }
65    }
66
67    /// Get the horizontal flipping state ([`true`] for flipped) from the given object.
68    ///
69    /// # Returns
70    ///
71    /// [`true`] in case the element supports flipping
72    ///
73    /// ## `flip`
74    /// return location for the result
75    #[doc(alias = "gst_video_orientation_get_hflip")]
76    #[doc(alias = "get_hflip")]
77    fn hflip(&self) -> Option<bool> {
78        unsafe {
79            let mut flip = std::mem::MaybeUninit::uninit();
80            let ret = from_glib(ffi::gst_video_orientation_get_hflip(
81                self.as_ref().to_glib_none().0,
82                flip.as_mut_ptr(),
83            ));
84            if ret {
85                Some(from_glib(flip.assume_init()))
86            } else {
87                None
88            }
89        }
90    }
91
92    /// Get the vertical centering offset from the given object.
93    ///
94    /// # Returns
95    ///
96    /// [`true`] in case the element supports centering
97    ///
98    /// ## `center`
99    /// return location for the result
100    #[doc(alias = "gst_video_orientation_get_vcenter")]
101    #[doc(alias = "get_vcenter")]
102    fn vcenter(&self) -> Option<i32> {
103        unsafe {
104            let mut center = std::mem::MaybeUninit::uninit();
105            let ret = from_glib(ffi::gst_video_orientation_get_vcenter(
106                self.as_ref().to_glib_none().0,
107                center.as_mut_ptr(),
108            ));
109            if ret {
110                Some(center.assume_init())
111            } else {
112                None
113            }
114        }
115    }
116
117    /// Get the vertical flipping state ([`true`] for flipped) from the given object.
118    ///
119    /// # Returns
120    ///
121    /// [`true`] in case the element supports flipping
122    ///
123    /// ## `flip`
124    /// return location for the result
125    #[doc(alias = "gst_video_orientation_get_vflip")]
126    #[doc(alias = "get_vflip")]
127    fn vflip(&self) -> Option<bool> {
128        unsafe {
129            let mut flip = std::mem::MaybeUninit::uninit();
130            let ret = from_glib(ffi::gst_video_orientation_get_vflip(
131                self.as_ref().to_glib_none().0,
132                flip.as_mut_ptr(),
133            ));
134            if ret {
135                Some(from_glib(flip.assume_init()))
136            } else {
137                None
138            }
139        }
140    }
141
142    /// Set the horizontal centering offset for the given object.
143    /// ## `center`
144    /// centering offset
145    ///
146    /// # Returns
147    ///
148    /// [`true`] in case the element supports centering
149    #[doc(alias = "gst_video_orientation_set_hcenter")]
150    fn set_hcenter(&self, center: i32) -> Result<(), glib::error::BoolError> {
151        unsafe {
152            glib::result_from_gboolean!(
153                ffi::gst_video_orientation_set_hcenter(self.as_ref().to_glib_none().0, center),
154                "Failed to set horizontal centering"
155            )
156        }
157    }
158
159    /// Set the horizontal flipping state ([`true`] for flipped) for the given object.
160    /// ## `flip`
161    /// use flipping
162    ///
163    /// # Returns
164    ///
165    /// [`true`] in case the element supports flipping
166    #[doc(alias = "gst_video_orientation_set_hflip")]
167    fn set_hflip(&self, flip: bool) -> Result<(), glib::error::BoolError> {
168        unsafe {
169            glib::result_from_gboolean!(
170                ffi::gst_video_orientation_set_hflip(
171                    self.as_ref().to_glib_none().0,
172                    flip.into_glib()
173                ),
174                "Failed to set horizontal flipping"
175            )
176        }
177    }
178
179    /// Set the vertical centering offset for the given object.
180    /// ## `center`
181    /// centering offset
182    ///
183    /// # Returns
184    ///
185    /// [`true`] in case the element supports centering
186    #[doc(alias = "gst_video_orientation_set_vcenter")]
187    fn set_vcenter(&self, center: i32) -> Result<(), glib::error::BoolError> {
188        unsafe {
189            glib::result_from_gboolean!(
190                ffi::gst_video_orientation_set_vcenter(self.as_ref().to_glib_none().0, center),
191                "Failed to set vertical centering"
192            )
193        }
194    }
195
196    /// Set the vertical flipping state ([`true`] for flipped) for the given object.
197    /// ## `flip`
198    /// use flipping
199    ///
200    /// # Returns
201    ///
202    /// [`true`] in case the element supports flipping
203    #[doc(alias = "gst_video_orientation_set_vflip")]
204    fn set_vflip(&self, flip: bool) -> Result<(), glib::error::BoolError> {
205        unsafe {
206            glib::result_from_gboolean!(
207                ffi::gst_video_orientation_set_vflip(
208                    self.as_ref().to_glib_none().0,
209                    flip.into_glib()
210                ),
211                "Failed to set vertical flipping"
212            )
213        }
214    }
215}
216
217impl<O: IsA<VideoOrientation>> VideoOrientationExt for O {}