1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use glib::object::IsA;
use glib::translate::*;
use std::mem;

glib::wrapper! {
    /// The interface allows unified access to control flipping and autocenter
    /// operation of video-sources or operators.
    ///
    /// # Implements
    ///
    /// [`VideoOrientationExt`][trait@crate::prelude::VideoOrientationExt]
    #[doc(alias = "GstVideoOrientation")]
    pub struct VideoOrientation(Interface<ffi::GstVideoOrientation, ffi::GstVideoOrientationInterface>);

    match fn {
        type_ => || ffi::gst_video_orientation_get_type(),
    }
}

unsafe impl Send for VideoOrientation {}
unsafe impl Sync for VideoOrientation {}

pub const NONE_VIDEO_ORIENTATION: Option<&VideoOrientation> = None;

/// Trait containing all [`struct@VideoOrientation`] methods.
///
/// # Implementors
///
/// [`VideoOrientation`][struct@crate::VideoOrientation]
pub trait VideoOrientationExt: 'static {
    /// Get the horizontal centering offset from the given object.
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports centering
    ///
    /// ## `center`
    /// return location for the result
    #[doc(alias = "gst_video_orientation_get_hcenter")]
    #[doc(alias = "get_hcenter")]
    fn hcenter(&self) -> Option<i32>;

    /// Get the horizontal flipping state ([`true`] for flipped) from the given object.
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports flipping
    ///
    /// ## `flip`
    /// return location for the result
    #[doc(alias = "gst_video_orientation_get_hflip")]
    #[doc(alias = "get_hflip")]
    fn hflip(&self) -> Option<bool>;

    /// Get the vertical centering offset from the given object.
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports centering
    ///
    /// ## `center`
    /// return location for the result
    #[doc(alias = "gst_video_orientation_get_vcenter")]
    #[doc(alias = "get_vcenter")]
    fn vcenter(&self) -> Option<i32>;

    /// Get the vertical flipping state ([`true`] for flipped) from the given object.
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports flipping
    ///
    /// ## `flip`
    /// return location for the result
    #[doc(alias = "gst_video_orientation_get_vflip")]
    #[doc(alias = "get_vflip")]
    fn vflip(&self) -> Option<bool>;

    /// Set the horizontal centering offset for the given object.
    /// ## `center`
    /// centering offset
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports centering
    #[doc(alias = "gst_video_orientation_set_hcenter")]
    fn set_hcenter(&self, center: i32) -> Result<(), glib::error::BoolError>;

    /// Set the horizontal flipping state ([`true`] for flipped) for the given object.
    /// ## `flip`
    /// use flipping
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports flipping
    #[doc(alias = "gst_video_orientation_set_hflip")]
    fn set_hflip(&self, flip: bool) -> Result<(), glib::error::BoolError>;

    /// Set the vertical centering offset for the given object.
    /// ## `center`
    /// centering offset
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports centering
    #[doc(alias = "gst_video_orientation_set_vcenter")]
    fn set_vcenter(&self, center: i32) -> Result<(), glib::error::BoolError>;

    /// Set the vertical flipping state ([`true`] for flipped) for the given object.
    /// ## `flip`
    /// use flipping
    ///
    /// # Returns
    ///
    /// [`true`] in case the element supports flipping
    #[doc(alias = "gst_video_orientation_set_vflip")]
    fn set_vflip(&self, flip: bool) -> Result<(), glib::error::BoolError>;
}

impl<O: IsA<VideoOrientation>> VideoOrientationExt for O {
    fn hcenter(&self) -> Option<i32> {
        unsafe {
            let mut center = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gst_video_orientation_get_hcenter(
                self.as_ref().to_glib_none().0,
                center.as_mut_ptr(),
            ));
            let center = center.assume_init();
            if ret {
                Some(center)
            } else {
                None
            }
        }
    }

    fn hflip(&self) -> Option<bool> {
        unsafe {
            let mut flip = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gst_video_orientation_get_hflip(
                self.as_ref().to_glib_none().0,
                flip.as_mut_ptr(),
            ));
            let flip = flip.assume_init();
            if ret {
                Some(from_glib(flip))
            } else {
                None
            }
        }
    }

    fn vcenter(&self) -> Option<i32> {
        unsafe {
            let mut center = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gst_video_orientation_get_vcenter(
                self.as_ref().to_glib_none().0,
                center.as_mut_ptr(),
            ));
            let center = center.assume_init();
            if ret {
                Some(center)
            } else {
                None
            }
        }
    }

    fn vflip(&self) -> Option<bool> {
        unsafe {
            let mut flip = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gst_video_orientation_get_vflip(
                self.as_ref().to_glib_none().0,
                flip.as_mut_ptr(),
            ));
            let flip = flip.assume_init();
            if ret {
                Some(from_glib(flip))
            } else {
                None
            }
        }
    }

    fn set_hcenter(&self, center: i32) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_video_orientation_set_hcenter(self.as_ref().to_glib_none().0, center),
                "Failed to set horizontal centering"
            )
        }
    }

    fn set_hflip(&self, flip: bool) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_video_orientation_set_hflip(
                    self.as_ref().to_glib_none().0,
                    flip.into_glib()
                ),
                "Failed to set horizontal flipping"
            )
        }
    }

    fn set_vcenter(&self, center: i32) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_video_orientation_set_vcenter(self.as_ref().to_glib_none().0, center),
                "Failed to set vertical centering"
            )
        }
    }

    fn set_vflip(&self, flip: bool) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_video_orientation_set_vflip(
                    self.as_ref().to_glib_none().0,
                    flip.into_glib()
                ),
                "Failed to set vertical flipping"
            )
        }
    }
}