gstreamer_player/auto/
enums.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::*, GStr};
8
9#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
10#[non_exhaustive]
11#[doc(alias = "GstPlayerColorBalanceType")]
12pub enum PlayerColorBalanceType {
13    /// hue or color balance.
14    #[doc(alias = "GST_PLAYER_COLOR_BALANCE_HUE")]
15    Hue,
16    /// brightness or black level.
17    #[doc(alias = "GST_PLAYER_COLOR_BALANCE_BRIGHTNESS")]
18    Brightness,
19    /// color saturation or chroma
20    /// gain.
21    #[doc(alias = "GST_PLAYER_COLOR_BALANCE_SATURATION")]
22    Saturation,
23    /// contrast or luma gain.
24    #[doc(alias = "GST_PLAYER_COLOR_BALANCE_CONTRAST")]
25    Contrast,
26    #[doc(hidden)]
27    __Unknown(i32),
28}
29
30impl PlayerColorBalanceType {
31    pub fn name<'a>(self) -> &'a GStr {
32        unsafe {
33            GStr::from_ptr(
34                ffi::gst_player_color_balance_type_get_name(self.into_glib())
35                    .as_ref()
36                    .expect("gst_player_color_balance_type_get_name returned NULL"),
37            )
38        }
39    }
40}
41
42impl std::fmt::Display for PlayerColorBalanceType {
43    #[inline]
44    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
45        f.write_str(&self.name())
46    }
47}
48
49#[doc(hidden)]
50impl IntoGlib for PlayerColorBalanceType {
51    type GlibType = ffi::GstPlayerColorBalanceType;
52
53    #[inline]
54    fn into_glib(self) -> ffi::GstPlayerColorBalanceType {
55        match self {
56            Self::Hue => ffi::GST_PLAYER_COLOR_BALANCE_HUE,
57            Self::Brightness => ffi::GST_PLAYER_COLOR_BALANCE_BRIGHTNESS,
58            Self::Saturation => ffi::GST_PLAYER_COLOR_BALANCE_SATURATION,
59            Self::Contrast => ffi::GST_PLAYER_COLOR_BALANCE_CONTRAST,
60            Self::__Unknown(value) => value,
61        }
62    }
63}
64
65#[doc(hidden)]
66impl FromGlib<ffi::GstPlayerColorBalanceType> for PlayerColorBalanceType {
67    #[inline]
68    unsafe fn from_glib(value: ffi::GstPlayerColorBalanceType) -> Self {
69        skip_assert_initialized!();
70
71        match value {
72            ffi::GST_PLAYER_COLOR_BALANCE_HUE => Self::Hue,
73            ffi::GST_PLAYER_COLOR_BALANCE_BRIGHTNESS => Self::Brightness,
74            ffi::GST_PLAYER_COLOR_BALANCE_SATURATION => Self::Saturation,
75            ffi::GST_PLAYER_COLOR_BALANCE_CONTRAST => Self::Contrast,
76            value => Self::__Unknown(value),
77        }
78    }
79}
80
81impl StaticType for PlayerColorBalanceType {
82    #[inline]
83    #[doc(alias = "gst_player_color_balance_type_get_type")]
84    fn static_type() -> glib::Type {
85        unsafe { from_glib(ffi::gst_player_color_balance_type_get_type()) }
86    }
87}
88
89impl glib::HasParamSpec for PlayerColorBalanceType {
90    type ParamSpec = glib::ParamSpecEnum;
91    type SetValue = Self;
92    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
93
94    fn param_spec_builder() -> Self::BuilderFn {
95        Self::ParamSpec::builder_with_default
96    }
97}
98
99impl glib::value::ValueType for PlayerColorBalanceType {
100    type Type = Self;
101}
102
103unsafe impl<'a> glib::value::FromValue<'a> for PlayerColorBalanceType {
104    type Checker = glib::value::GenericValueTypeChecker<Self>;
105
106    #[inline]
107    unsafe fn from_value(value: &'a glib::Value) -> Self {
108        skip_assert_initialized!();
109        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
110    }
111}
112
113impl ToValue for PlayerColorBalanceType {
114    #[inline]
115    fn to_value(&self) -> glib::Value {
116        let mut value = glib::Value::for_value_type::<Self>();
117        unsafe {
118            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
119        }
120        value
121    }
122
123    #[inline]
124    fn value_type(&self) -> glib::Type {
125        Self::static_type()
126    }
127}
128
129impl From<PlayerColorBalanceType> for glib::Value {
130    #[inline]
131    fn from(v: PlayerColorBalanceType) -> Self {
132        skip_assert_initialized!();
133        ToValue::to_value(&v)
134    }
135}
136
137#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
138#[non_exhaustive]
139#[doc(alias = "GstPlayerError")]
140pub enum PlayerError {
141    /// generic error.
142    #[doc(alias = "GST_PLAYER_ERROR_FAILED")]
143    Failed,
144    #[doc(hidden)]
145    __Unknown(i32),
146}
147
148impl PlayerError {
149    pub fn name<'a>(self) -> &'a GStr {
150        unsafe {
151            GStr::from_ptr(
152                ffi::gst_player_error_get_name(self.into_glib())
153                    .as_ref()
154                    .expect("gst_player_error_get_name returned NULL"),
155            )
156        }
157    }
158}
159
160impl std::fmt::Display for PlayerError {
161    #[inline]
162    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
163        f.write_str(&self.name())
164    }
165}
166
167#[doc(hidden)]
168impl IntoGlib for PlayerError {
169    type GlibType = ffi::GstPlayerError;
170
171    #[inline]
172    fn into_glib(self) -> ffi::GstPlayerError {
173        match self {
174            Self::Failed => ffi::GST_PLAYER_ERROR_FAILED,
175            Self::__Unknown(value) => value,
176        }
177    }
178}
179
180#[doc(hidden)]
181impl FromGlib<ffi::GstPlayerError> for PlayerError {
182    #[inline]
183    unsafe fn from_glib(value: ffi::GstPlayerError) -> Self {
184        skip_assert_initialized!();
185
186        match value {
187            ffi::GST_PLAYER_ERROR_FAILED => Self::Failed,
188            value => Self::__Unknown(value),
189        }
190    }
191}
192
193impl glib::error::ErrorDomain for PlayerError {
194    #[inline]
195    fn domain() -> glib::Quark {
196        skip_assert_initialized!();
197
198        unsafe { from_glib(ffi::gst_player_error_quark()) }
199    }
200
201    #[inline]
202    fn code(self) -> i32 {
203        self.into_glib()
204    }
205
206    #[inline]
207    #[allow(clippy::match_single_binding)]
208    fn from(code: i32) -> Option<Self> {
209        skip_assert_initialized!();
210        match unsafe { from_glib(code) } {
211            Self::__Unknown(_) => Some(Self::Failed),
212            value => Some(value),
213        }
214    }
215}
216
217impl StaticType for PlayerError {
218    #[inline]
219    #[doc(alias = "gst_player_error_get_type")]
220    fn static_type() -> glib::Type {
221        unsafe { from_glib(ffi::gst_player_error_get_type()) }
222    }
223}
224
225impl glib::HasParamSpec for PlayerError {
226    type ParamSpec = glib::ParamSpecEnum;
227    type SetValue = Self;
228    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
229
230    fn param_spec_builder() -> Self::BuilderFn {
231        Self::ParamSpec::builder_with_default
232    }
233}
234
235impl glib::value::ValueType for PlayerError {
236    type Type = Self;
237}
238
239unsafe impl<'a> glib::value::FromValue<'a> for PlayerError {
240    type Checker = glib::value::GenericValueTypeChecker<Self>;
241
242    #[inline]
243    unsafe fn from_value(value: &'a glib::Value) -> Self {
244        skip_assert_initialized!();
245        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
246    }
247}
248
249impl ToValue for PlayerError {
250    #[inline]
251    fn to_value(&self) -> glib::Value {
252        let mut value = glib::Value::for_value_type::<Self>();
253        unsafe {
254            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
255        }
256        value
257    }
258
259    #[inline]
260    fn value_type(&self) -> glib::Type {
261        Self::static_type()
262    }
263}
264
265impl From<PlayerError> for glib::Value {
266    #[inline]
267    fn from(v: PlayerError) -> Self {
268        skip_assert_initialized!();
269        ToValue::to_value(&v)
270    }
271}
272
273#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
274#[non_exhaustive]
275#[doc(alias = "GstPlayerSnapshotFormat")]
276pub enum PlayerSnapshotFormat {
277    #[doc(alias = "GST_PLAYER_THUMBNAIL_RAW_NATIVE")]
278    RawNative,
279    #[doc(alias = "GST_PLAYER_THUMBNAIL_RAW_xRGB")]
280    RawXrgb,
281    #[doc(alias = "GST_PLAYER_THUMBNAIL_RAW_BGRx")]
282    RawBgrx,
283    #[doc(alias = "GST_PLAYER_THUMBNAIL_JPG")]
284    Jpg,
285    #[doc(alias = "GST_PLAYER_THUMBNAIL_PNG")]
286    Png,
287    #[doc(hidden)]
288    __Unknown(i32),
289}
290
291#[doc(hidden)]
292impl IntoGlib for PlayerSnapshotFormat {
293    type GlibType = ffi::GstPlayerSnapshotFormat;
294
295    #[inline]
296    fn into_glib(self) -> ffi::GstPlayerSnapshotFormat {
297        match self {
298            Self::RawNative => ffi::GST_PLAYER_THUMBNAIL_RAW_NATIVE,
299            Self::RawXrgb => ffi::GST_PLAYER_THUMBNAIL_RAW_xRGB,
300            Self::RawBgrx => ffi::GST_PLAYER_THUMBNAIL_RAW_BGRx,
301            Self::Jpg => ffi::GST_PLAYER_THUMBNAIL_JPG,
302            Self::Png => ffi::GST_PLAYER_THUMBNAIL_PNG,
303            Self::__Unknown(value) => value,
304        }
305    }
306}
307
308#[doc(hidden)]
309impl FromGlib<ffi::GstPlayerSnapshotFormat> for PlayerSnapshotFormat {
310    #[inline]
311    unsafe fn from_glib(value: ffi::GstPlayerSnapshotFormat) -> Self {
312        skip_assert_initialized!();
313
314        match value {
315            ffi::GST_PLAYER_THUMBNAIL_RAW_NATIVE => Self::RawNative,
316            ffi::GST_PLAYER_THUMBNAIL_RAW_xRGB => Self::RawXrgb,
317            ffi::GST_PLAYER_THUMBNAIL_RAW_BGRx => Self::RawBgrx,
318            ffi::GST_PLAYER_THUMBNAIL_JPG => Self::Jpg,
319            ffi::GST_PLAYER_THUMBNAIL_PNG => Self::Png,
320            value => Self::__Unknown(value),
321        }
322    }
323}
324
325#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
326#[non_exhaustive]
327#[doc(alias = "GstPlayerState")]
328pub enum PlayerState {
329    /// the player is stopped.
330    #[doc(alias = "GST_PLAYER_STATE_STOPPED")]
331    Stopped,
332    /// the player is buffering.
333    #[doc(alias = "GST_PLAYER_STATE_BUFFERING")]
334    Buffering,
335    /// the player is paused.
336    #[doc(alias = "GST_PLAYER_STATE_PAUSED")]
337    Paused,
338    /// the player is currently playing a
339    /// stream.
340    #[doc(alias = "GST_PLAYER_STATE_PLAYING")]
341    Playing,
342    #[doc(hidden)]
343    __Unknown(i32),
344}
345
346impl PlayerState {
347    pub fn name<'a>(self) -> &'a GStr {
348        unsafe {
349            GStr::from_ptr(
350                ffi::gst_player_state_get_name(self.into_glib())
351                    .as_ref()
352                    .expect("gst_player_state_get_name returned NULL"),
353            )
354        }
355    }
356}
357
358impl std::fmt::Display for PlayerState {
359    #[inline]
360    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
361        f.write_str(&self.name())
362    }
363}
364
365#[doc(hidden)]
366impl IntoGlib for PlayerState {
367    type GlibType = ffi::GstPlayerState;
368
369    #[inline]
370    fn into_glib(self) -> ffi::GstPlayerState {
371        match self {
372            Self::Stopped => ffi::GST_PLAYER_STATE_STOPPED,
373            Self::Buffering => ffi::GST_PLAYER_STATE_BUFFERING,
374            Self::Paused => ffi::GST_PLAYER_STATE_PAUSED,
375            Self::Playing => ffi::GST_PLAYER_STATE_PLAYING,
376            Self::__Unknown(value) => value,
377        }
378    }
379}
380
381#[doc(hidden)]
382impl FromGlib<ffi::GstPlayerState> for PlayerState {
383    #[inline]
384    unsafe fn from_glib(value: ffi::GstPlayerState) -> Self {
385        skip_assert_initialized!();
386
387        match value {
388            ffi::GST_PLAYER_STATE_STOPPED => Self::Stopped,
389            ffi::GST_PLAYER_STATE_BUFFERING => Self::Buffering,
390            ffi::GST_PLAYER_STATE_PAUSED => Self::Paused,
391            ffi::GST_PLAYER_STATE_PLAYING => Self::Playing,
392            value => Self::__Unknown(value),
393        }
394    }
395}
396
397impl StaticType for PlayerState {
398    #[inline]
399    #[doc(alias = "gst_player_state_get_type")]
400    fn static_type() -> glib::Type {
401        unsafe { from_glib(ffi::gst_player_state_get_type()) }
402    }
403}
404
405impl glib::HasParamSpec for PlayerState {
406    type ParamSpec = glib::ParamSpecEnum;
407    type SetValue = Self;
408    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
409
410    fn param_spec_builder() -> Self::BuilderFn {
411        Self::ParamSpec::builder_with_default
412    }
413}
414
415impl glib::value::ValueType for PlayerState {
416    type Type = Self;
417}
418
419unsafe impl<'a> glib::value::FromValue<'a> for PlayerState {
420    type Checker = glib::value::GenericValueTypeChecker<Self>;
421
422    #[inline]
423    unsafe fn from_value(value: &'a glib::Value) -> Self {
424        skip_assert_initialized!();
425        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
426    }
427}
428
429impl ToValue for PlayerState {
430    #[inline]
431    fn to_value(&self) -> glib::Value {
432        let mut value = glib::Value::for_value_type::<Self>();
433        unsafe {
434            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
435        }
436        value
437    }
438
439    #[inline]
440    fn value_type(&self) -> glib::Type {
441        Self::static_type()
442    }
443}
444
445impl From<PlayerState> for glib::Value {
446    #[inline]
447    fn from(v: PlayerState) -> Self {
448        skip_assert_initialized!();
449        ToValue::to_value(&v)
450    }
451}