gstreamer_play/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, PlayMediaInfo};
7use glib::{prelude::*, translate::*, GStr};
8
9#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
10#[non_exhaustive]
11#[doc(alias = "GstPlayColorBalanceType")]
12pub enum PlayColorBalanceType {
13    #[doc(alias = "GST_PLAY_COLOR_BALANCE_HUE")]
14    Hue,
15    #[doc(alias = "GST_PLAY_COLOR_BALANCE_BRIGHTNESS")]
16    Brightness,
17    #[doc(alias = "GST_PLAY_COLOR_BALANCE_SATURATION")]
18    Saturation,
19    #[doc(alias = "GST_PLAY_COLOR_BALANCE_CONTRAST")]
20    Contrast,
21    #[doc(hidden)]
22    __Unknown(i32),
23}
24
25impl PlayColorBalanceType {
26    pub fn name<'a>(self) -> &'a GStr {
27        unsafe {
28            GStr::from_ptr(
29                ffi::gst_play_color_balance_type_get_name(self.into_glib())
30                    .as_ref()
31                    .expect("gst_play_color_balance_type_get_name returned NULL"),
32            )
33        }
34    }
35}
36
37impl std::fmt::Display for PlayColorBalanceType {
38    #[inline]
39    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
40        f.write_str(&self.name())
41    }
42}
43
44#[doc(hidden)]
45impl IntoGlib for PlayColorBalanceType {
46    type GlibType = ffi::GstPlayColorBalanceType;
47
48    #[inline]
49    fn into_glib(self) -> ffi::GstPlayColorBalanceType {
50        match self {
51            Self::Hue => ffi::GST_PLAY_COLOR_BALANCE_HUE,
52            Self::Brightness => ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS,
53            Self::Saturation => ffi::GST_PLAY_COLOR_BALANCE_SATURATION,
54            Self::Contrast => ffi::GST_PLAY_COLOR_BALANCE_CONTRAST,
55            Self::__Unknown(value) => value,
56        }
57    }
58}
59
60#[doc(hidden)]
61impl FromGlib<ffi::GstPlayColorBalanceType> for PlayColorBalanceType {
62    #[inline]
63    unsafe fn from_glib(value: ffi::GstPlayColorBalanceType) -> Self {
64        skip_assert_initialized!();
65
66        match value {
67            ffi::GST_PLAY_COLOR_BALANCE_HUE => Self::Hue,
68            ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS => Self::Brightness,
69            ffi::GST_PLAY_COLOR_BALANCE_SATURATION => Self::Saturation,
70            ffi::GST_PLAY_COLOR_BALANCE_CONTRAST => Self::Contrast,
71            value => Self::__Unknown(value),
72        }
73    }
74}
75
76impl StaticType for PlayColorBalanceType {
77    #[inline]
78    #[doc(alias = "gst_play_color_balance_type_get_type")]
79    fn static_type() -> glib::Type {
80        unsafe { from_glib(ffi::gst_play_color_balance_type_get_type()) }
81    }
82}
83
84impl glib::HasParamSpec for PlayColorBalanceType {
85    type ParamSpec = glib::ParamSpecEnum;
86    type SetValue = Self;
87    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
88
89    fn param_spec_builder() -> Self::BuilderFn {
90        Self::ParamSpec::builder_with_default
91    }
92}
93
94impl glib::value::ValueType for PlayColorBalanceType {
95    type Type = Self;
96}
97
98unsafe impl<'a> glib::value::FromValue<'a> for PlayColorBalanceType {
99    type Checker = glib::value::GenericValueTypeChecker<Self>;
100
101    #[inline]
102    unsafe fn from_value(value: &'a glib::Value) -> Self {
103        skip_assert_initialized!();
104        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
105    }
106}
107
108impl ToValue for PlayColorBalanceType {
109    #[inline]
110    fn to_value(&self) -> glib::Value {
111        let mut value = glib::Value::for_value_type::<Self>();
112        unsafe {
113            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
114        }
115        value
116    }
117
118    #[inline]
119    fn value_type(&self) -> glib::Type {
120        Self::static_type()
121    }
122}
123
124impl From<PlayColorBalanceType> for glib::Value {
125    #[inline]
126    fn from(v: PlayColorBalanceType) -> Self {
127        skip_assert_initialized!();
128        ToValue::to_value(&v)
129    }
130}
131
132#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
133#[non_exhaustive]
134#[doc(alias = "GstPlayError")]
135pub enum PlayError {
136    #[doc(alias = "GST_PLAY_ERROR_FAILED")]
137    Failed,
138    #[doc(hidden)]
139    __Unknown(i32),
140}
141
142impl PlayError {
143    pub fn name<'a>(self) -> &'a GStr {
144        unsafe {
145            GStr::from_ptr(
146                ffi::gst_play_error_get_name(self.into_glib())
147                    .as_ref()
148                    .expect("gst_play_error_get_name returned NULL"),
149            )
150        }
151    }
152}
153
154impl std::fmt::Display for PlayError {
155    #[inline]
156    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
157        f.write_str(&self.name())
158    }
159}
160
161#[doc(hidden)]
162impl IntoGlib for PlayError {
163    type GlibType = ffi::GstPlayError;
164
165    #[inline]
166    fn into_glib(self) -> ffi::GstPlayError {
167        match self {
168            Self::Failed => ffi::GST_PLAY_ERROR_FAILED,
169            Self::__Unknown(value) => value,
170        }
171    }
172}
173
174#[doc(hidden)]
175impl FromGlib<ffi::GstPlayError> for PlayError {
176    #[inline]
177    unsafe fn from_glib(value: ffi::GstPlayError) -> Self {
178        skip_assert_initialized!();
179
180        match value {
181            ffi::GST_PLAY_ERROR_FAILED => Self::Failed,
182            value => Self::__Unknown(value),
183        }
184    }
185}
186
187impl glib::error::ErrorDomain for PlayError {
188    #[inline]
189    fn domain() -> glib::Quark {
190        skip_assert_initialized!();
191
192        unsafe { from_glib(ffi::gst_play_error_quark()) }
193    }
194
195    #[inline]
196    fn code(self) -> i32 {
197        self.into_glib()
198    }
199
200    #[inline]
201    #[allow(clippy::match_single_binding)]
202    fn from(code: i32) -> Option<Self> {
203        skip_assert_initialized!();
204        match unsafe { from_glib(code) } {
205            Self::__Unknown(_) => Some(Self::Failed),
206            value => Some(value),
207        }
208    }
209}
210
211impl StaticType for PlayError {
212    #[inline]
213    #[doc(alias = "gst_play_error_get_type")]
214    fn static_type() -> glib::Type {
215        unsafe { from_glib(ffi::gst_play_error_get_type()) }
216    }
217}
218
219impl glib::HasParamSpec for PlayError {
220    type ParamSpec = glib::ParamSpecEnum;
221    type SetValue = Self;
222    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
223
224    fn param_spec_builder() -> Self::BuilderFn {
225        Self::ParamSpec::builder_with_default
226    }
227}
228
229impl glib::value::ValueType for PlayError {
230    type Type = Self;
231}
232
233unsafe impl<'a> glib::value::FromValue<'a> for PlayError {
234    type Checker = glib::value::GenericValueTypeChecker<Self>;
235
236    #[inline]
237    unsafe fn from_value(value: &'a glib::Value) -> Self {
238        skip_assert_initialized!();
239        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
240    }
241}
242
243impl ToValue for PlayError {
244    #[inline]
245    fn to_value(&self) -> glib::Value {
246        let mut value = glib::Value::for_value_type::<Self>();
247        unsafe {
248            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
249        }
250        value
251    }
252
253    #[inline]
254    fn value_type(&self) -> glib::Type {
255        Self::static_type()
256    }
257}
258
259impl From<PlayError> for glib::Value {
260    #[inline]
261    fn from(v: PlayError) -> Self {
262        skip_assert_initialized!();
263        ToValue::to_value(&v)
264    }
265}
266
267#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
268#[non_exhaustive]
269#[doc(alias = "GstPlayMessage")]
270pub(crate) enum PlayMessage {
271    #[doc(alias = "GST_PLAY_MESSAGE_URI_LOADED")]
272    UriLoaded,
273    #[doc(alias = "GST_PLAY_MESSAGE_POSITION_UPDATED")]
274    PositionUpdated,
275    #[doc(alias = "GST_PLAY_MESSAGE_DURATION_CHANGED")]
276    DurationChanged,
277    #[doc(alias = "GST_PLAY_MESSAGE_STATE_CHANGED")]
278    StateChanged,
279    #[doc(alias = "GST_PLAY_MESSAGE_BUFFERING")]
280    Buffering,
281    #[doc(alias = "GST_PLAY_MESSAGE_END_OF_STREAM")]
282    EndOfStream,
283    #[doc(alias = "GST_PLAY_MESSAGE_ERROR")]
284    Error,
285    #[doc(alias = "GST_PLAY_MESSAGE_WARNING")]
286    Warning,
287    #[doc(alias = "GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED")]
288    VideoDimensionsChanged,
289    #[doc(alias = "GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED")]
290    MediaInfoUpdated,
291    #[doc(alias = "GST_PLAY_MESSAGE_VOLUME_CHANGED")]
292    VolumeChanged,
293    #[doc(alias = "GST_PLAY_MESSAGE_MUTE_CHANGED")]
294    MuteChanged,
295    #[doc(alias = "GST_PLAY_MESSAGE_SEEK_DONE")]
296    SeekDone,
297    #[doc(hidden)]
298    __Unknown(i32),
299}
300
301impl PlayMessage {
302    pub fn name<'a>(self) -> &'a GStr {
303        unsafe {
304            GStr::from_ptr(
305                ffi::gst_play_message_get_name(self.into_glib())
306                    .as_ref()
307                    .expect("gst_play_message_get_name returned NULL"),
308            )
309        }
310    }
311
312    #[cfg(feature = "v1_26")]
313    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
314    #[doc(alias = "gst_play_message_parse_buffering")]
315    pub fn parse_buffering(msg: &gst::Message) -> u32 {
316        assert_initialized_main_thread!();
317        unsafe {
318            let mut percent = std::mem::MaybeUninit::uninit();
319            ffi::gst_play_message_parse_buffering(msg.to_glib_none().0, percent.as_mut_ptr());
320            percent.assume_init()
321        }
322    }
323
324    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
325    #[allow(deprecated)]
326    #[doc(alias = "gst_play_message_parse_buffering_percent")]
327    pub fn parse_buffering_percent(msg: &gst::Message) -> u32 {
328        assert_initialized_main_thread!();
329        unsafe {
330            let mut percent = std::mem::MaybeUninit::uninit();
331            ffi::gst_play_message_parse_buffering_percent(
332                msg.to_glib_none().0,
333                percent.as_mut_ptr(),
334            );
335            percent.assume_init()
336        }
337    }
338
339    #[cfg(feature = "v1_26")]
340    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
341    #[doc(alias = "gst_play_message_parse_duration_changed")]
342    pub fn parse_duration_changed(msg: &gst::Message) -> Option<gst::ClockTime> {
343        assert_initialized_main_thread!();
344        unsafe {
345            let mut duration = std::mem::MaybeUninit::uninit();
346            ffi::gst_play_message_parse_duration_changed(
347                msg.to_glib_none().0,
348                duration.as_mut_ptr(),
349            );
350            from_glib(duration.assume_init())
351        }
352    }
353
354    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
355    #[allow(deprecated)]
356    #[doc(alias = "gst_play_message_parse_duration_updated")]
357    pub fn parse_duration_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
358        assert_initialized_main_thread!();
359        unsafe {
360            let mut duration = std::mem::MaybeUninit::uninit();
361            ffi::gst_play_message_parse_duration_updated(
362                msg.to_glib_none().0,
363                duration.as_mut_ptr(),
364            );
365            from_glib(duration.assume_init())
366        }
367    }
368
369    #[doc(alias = "gst_play_message_parse_error")]
370    pub fn parse_error(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
371        assert_initialized_main_thread!();
372        unsafe {
373            let mut error = std::ptr::null_mut();
374            let mut details = std::ptr::null_mut();
375            ffi::gst_play_message_parse_error(msg.to_glib_none().0, &mut error, &mut details);
376            (from_glib_full(error), from_glib_full(details))
377        }
378    }
379
380    #[doc(alias = "gst_play_message_parse_media_info_updated")]
381    pub fn parse_media_info_updated(msg: &gst::Message) -> PlayMediaInfo {
382        assert_initialized_main_thread!();
383        unsafe {
384            let mut info = std::ptr::null_mut();
385            ffi::gst_play_message_parse_media_info_updated(msg.to_glib_none().0, &mut info);
386            from_glib_full(info)
387        }
388    }
389
390    #[doc(alias = "gst_play_message_parse_muted_changed")]
391    pub fn parse_muted_changed(msg: &gst::Message) -> bool {
392        assert_initialized_main_thread!();
393        unsafe {
394            let mut muted = std::mem::MaybeUninit::uninit();
395            ffi::gst_play_message_parse_muted_changed(msg.to_glib_none().0, muted.as_mut_ptr());
396            from_glib(muted.assume_init())
397        }
398    }
399
400    #[doc(alias = "gst_play_message_parse_position_updated")]
401    pub fn parse_position_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
402        assert_initialized_main_thread!();
403        unsafe {
404            let mut position = std::mem::MaybeUninit::uninit();
405            ffi::gst_play_message_parse_position_updated(
406                msg.to_glib_none().0,
407                position.as_mut_ptr(),
408            );
409            from_glib(position.assume_init())
410        }
411    }
412
413    #[cfg(feature = "v1_26")]
414    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
415    #[doc(alias = "gst_play_message_parse_seek_done")]
416    pub fn parse_seek_done(msg: &gst::Message) -> Option<gst::ClockTime> {
417        assert_initialized_main_thread!();
418        unsafe {
419            let mut position = std::mem::MaybeUninit::uninit();
420            ffi::gst_play_message_parse_seek_done(msg.to_glib_none().0, position.as_mut_ptr());
421            from_glib(position.assume_init())
422        }
423    }
424
425    #[doc(alias = "gst_play_message_parse_state_changed")]
426    pub fn parse_state_changed(msg: &gst::Message) -> PlayState {
427        assert_initialized_main_thread!();
428        unsafe {
429            let mut state = std::mem::MaybeUninit::uninit();
430            ffi::gst_play_message_parse_state_changed(msg.to_glib_none().0, state.as_mut_ptr());
431            from_glib(state.assume_init())
432        }
433    }
434
435    #[doc(alias = "gst_play_message_parse_type")]
436    pub fn parse_type(msg: &gst::Message) -> PlayMessage {
437        assert_initialized_main_thread!();
438        unsafe {
439            let mut type_ = std::mem::MaybeUninit::uninit();
440            ffi::gst_play_message_parse_type(msg.to_glib_none().0, type_.as_mut_ptr());
441            from_glib(type_.assume_init())
442        }
443    }
444
445    #[cfg(feature = "v1_26")]
446    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
447    #[doc(alias = "gst_play_message_parse_uri_loaded")]
448    pub fn parse_uri_loaded(msg: &gst::Message) -> glib::GString {
449        assert_initialized_main_thread!();
450        unsafe {
451            let mut uri = std::ptr::null_mut();
452            ffi::gst_play_message_parse_uri_loaded(msg.to_glib_none().0, &mut uri);
453            from_glib_full(uri)
454        }
455    }
456
457    #[doc(alias = "gst_play_message_parse_video_dimensions_changed")]
458    pub fn parse_video_dimensions_changed(msg: &gst::Message) -> (u32, u32) {
459        assert_initialized_main_thread!();
460        unsafe {
461            let mut width = std::mem::MaybeUninit::uninit();
462            let mut height = std::mem::MaybeUninit::uninit();
463            ffi::gst_play_message_parse_video_dimensions_changed(
464                msg.to_glib_none().0,
465                width.as_mut_ptr(),
466                height.as_mut_ptr(),
467            );
468            (width.assume_init(), height.assume_init())
469        }
470    }
471
472    #[doc(alias = "gst_play_message_parse_volume_changed")]
473    pub fn parse_volume_changed(msg: &gst::Message) -> f64 {
474        assert_initialized_main_thread!();
475        unsafe {
476            let mut volume = std::mem::MaybeUninit::uninit();
477            ffi::gst_play_message_parse_volume_changed(msg.to_glib_none().0, volume.as_mut_ptr());
478            volume.assume_init()
479        }
480    }
481
482    #[doc(alias = "gst_play_message_parse_warning")]
483    pub fn parse_warning(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
484        assert_initialized_main_thread!();
485        unsafe {
486            let mut error = std::ptr::null_mut();
487            let mut details = std::ptr::null_mut();
488            ffi::gst_play_message_parse_warning(msg.to_glib_none().0, &mut error, &mut details);
489            (from_glib_full(error), from_glib_full(details))
490        }
491    }
492}
493
494impl std::fmt::Display for PlayMessage {
495    #[inline]
496    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
497        f.write_str(&self.name())
498    }
499}
500
501#[doc(hidden)]
502impl IntoGlib for PlayMessage {
503    type GlibType = ffi::GstPlayMessage;
504
505    fn into_glib(self) -> ffi::GstPlayMessage {
506        match self {
507            Self::UriLoaded => ffi::GST_PLAY_MESSAGE_URI_LOADED,
508            Self::PositionUpdated => ffi::GST_PLAY_MESSAGE_POSITION_UPDATED,
509            Self::DurationChanged => ffi::GST_PLAY_MESSAGE_DURATION_CHANGED,
510            Self::StateChanged => ffi::GST_PLAY_MESSAGE_STATE_CHANGED,
511            Self::Buffering => ffi::GST_PLAY_MESSAGE_BUFFERING,
512            Self::EndOfStream => ffi::GST_PLAY_MESSAGE_END_OF_STREAM,
513            Self::Error => ffi::GST_PLAY_MESSAGE_ERROR,
514            Self::Warning => ffi::GST_PLAY_MESSAGE_WARNING,
515            Self::VideoDimensionsChanged => ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED,
516            Self::MediaInfoUpdated => ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED,
517            Self::VolumeChanged => ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED,
518            Self::MuteChanged => ffi::GST_PLAY_MESSAGE_MUTE_CHANGED,
519            Self::SeekDone => ffi::GST_PLAY_MESSAGE_SEEK_DONE,
520            Self::__Unknown(value) => value,
521        }
522    }
523}
524
525#[doc(hidden)]
526impl FromGlib<ffi::GstPlayMessage> for PlayMessage {
527    unsafe fn from_glib(value: ffi::GstPlayMessage) -> Self {
528        skip_assert_initialized!();
529
530        match value {
531            ffi::GST_PLAY_MESSAGE_URI_LOADED => Self::UriLoaded,
532            ffi::GST_PLAY_MESSAGE_POSITION_UPDATED => Self::PositionUpdated,
533            ffi::GST_PLAY_MESSAGE_DURATION_CHANGED => Self::DurationChanged,
534            ffi::GST_PLAY_MESSAGE_STATE_CHANGED => Self::StateChanged,
535            ffi::GST_PLAY_MESSAGE_BUFFERING => Self::Buffering,
536            ffi::GST_PLAY_MESSAGE_END_OF_STREAM => Self::EndOfStream,
537            ffi::GST_PLAY_MESSAGE_ERROR => Self::Error,
538            ffi::GST_PLAY_MESSAGE_WARNING => Self::Warning,
539            ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED => Self::VideoDimensionsChanged,
540            ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED => Self::MediaInfoUpdated,
541            ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED => Self::VolumeChanged,
542            ffi::GST_PLAY_MESSAGE_MUTE_CHANGED => Self::MuteChanged,
543            ffi::GST_PLAY_MESSAGE_SEEK_DONE => Self::SeekDone,
544            value => Self::__Unknown(value),
545        }
546    }
547}
548
549impl StaticType for PlayMessage {
550    #[inline]
551    #[doc(alias = "gst_play_message_get_type")]
552    fn static_type() -> glib::Type {
553        unsafe { from_glib(ffi::gst_play_message_get_type()) }
554    }
555}
556
557impl glib::HasParamSpec for PlayMessage {
558    type ParamSpec = glib::ParamSpecEnum;
559    type SetValue = Self;
560    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
561
562    fn param_spec_builder() -> Self::BuilderFn {
563        Self::ParamSpec::builder_with_default
564    }
565}
566
567impl glib::value::ValueType for PlayMessage {
568    type Type = Self;
569}
570
571unsafe impl<'a> glib::value::FromValue<'a> for PlayMessage {
572    type Checker = glib::value::GenericValueTypeChecker<Self>;
573
574    #[inline]
575    unsafe fn from_value(value: &'a glib::Value) -> Self {
576        skip_assert_initialized!();
577        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
578    }
579}
580
581impl ToValue for PlayMessage {
582    #[inline]
583    fn to_value(&self) -> glib::Value {
584        let mut value = glib::Value::for_value_type::<Self>();
585        unsafe {
586            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
587        }
588        value
589    }
590
591    #[inline]
592    fn value_type(&self) -> glib::Type {
593        Self::static_type()
594    }
595}
596
597impl From<PlayMessage> for glib::Value {
598    #[inline]
599    fn from(v: PlayMessage) -> Self {
600        skip_assert_initialized!();
601        ToValue::to_value(&v)
602    }
603}
604
605#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
606#[non_exhaustive]
607#[doc(alias = "GstPlaySnapshotFormat")]
608pub enum PlaySnapshotFormat {
609    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_NATIVE")]
610    RawNative,
611    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_xRGB")]
612    RawXrgb,
613    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_BGRx")]
614    RawBgrx,
615    #[doc(alias = "GST_PLAY_THUMBNAIL_JPG")]
616    Jpg,
617    #[doc(alias = "GST_PLAY_THUMBNAIL_PNG")]
618    Png,
619    #[doc(hidden)]
620    __Unknown(i32),
621}
622
623#[doc(hidden)]
624impl IntoGlib for PlaySnapshotFormat {
625    type GlibType = ffi::GstPlaySnapshotFormat;
626
627    #[inline]
628    fn into_glib(self) -> ffi::GstPlaySnapshotFormat {
629        match self {
630            Self::RawNative => ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE,
631            Self::RawXrgb => ffi::GST_PLAY_THUMBNAIL_RAW_xRGB,
632            Self::RawBgrx => ffi::GST_PLAY_THUMBNAIL_RAW_BGRx,
633            Self::Jpg => ffi::GST_PLAY_THUMBNAIL_JPG,
634            Self::Png => ffi::GST_PLAY_THUMBNAIL_PNG,
635            Self::__Unknown(value) => value,
636        }
637    }
638}
639
640#[doc(hidden)]
641impl FromGlib<ffi::GstPlaySnapshotFormat> for PlaySnapshotFormat {
642    #[inline]
643    unsafe fn from_glib(value: ffi::GstPlaySnapshotFormat) -> Self {
644        skip_assert_initialized!();
645
646        match value {
647            ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE => Self::RawNative,
648            ffi::GST_PLAY_THUMBNAIL_RAW_xRGB => Self::RawXrgb,
649            ffi::GST_PLAY_THUMBNAIL_RAW_BGRx => Self::RawBgrx,
650            ffi::GST_PLAY_THUMBNAIL_JPG => Self::Jpg,
651            ffi::GST_PLAY_THUMBNAIL_PNG => Self::Png,
652            value => Self::__Unknown(value),
653        }
654    }
655}
656
657#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
658#[non_exhaustive]
659#[doc(alias = "GstPlayState")]
660pub enum PlayState {
661    #[doc(alias = "GST_PLAY_STATE_STOPPED")]
662    Stopped,
663    #[doc(alias = "GST_PLAY_STATE_BUFFERING")]
664    Buffering,
665    #[doc(alias = "GST_PLAY_STATE_PAUSED")]
666    Paused,
667    #[doc(alias = "GST_PLAY_STATE_PLAYING")]
668    Playing,
669    #[doc(hidden)]
670    __Unknown(i32),
671}
672
673impl PlayState {
674    pub fn name<'a>(self) -> &'a GStr {
675        unsafe {
676            GStr::from_ptr(
677                ffi::gst_play_state_get_name(self.into_glib())
678                    .as_ref()
679                    .expect("gst_play_state_get_name returned NULL"),
680            )
681        }
682    }
683}
684
685impl std::fmt::Display for PlayState {
686    #[inline]
687    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
688        f.write_str(&self.name())
689    }
690}
691
692#[doc(hidden)]
693impl IntoGlib for PlayState {
694    type GlibType = ffi::GstPlayState;
695
696    #[inline]
697    fn into_glib(self) -> ffi::GstPlayState {
698        match self {
699            Self::Stopped => ffi::GST_PLAY_STATE_STOPPED,
700            Self::Buffering => ffi::GST_PLAY_STATE_BUFFERING,
701            Self::Paused => ffi::GST_PLAY_STATE_PAUSED,
702            Self::Playing => ffi::GST_PLAY_STATE_PLAYING,
703            Self::__Unknown(value) => value,
704        }
705    }
706}
707
708#[doc(hidden)]
709impl FromGlib<ffi::GstPlayState> for PlayState {
710    #[inline]
711    unsafe fn from_glib(value: ffi::GstPlayState) -> Self {
712        skip_assert_initialized!();
713
714        match value {
715            ffi::GST_PLAY_STATE_STOPPED => Self::Stopped,
716            ffi::GST_PLAY_STATE_BUFFERING => Self::Buffering,
717            ffi::GST_PLAY_STATE_PAUSED => Self::Paused,
718            ffi::GST_PLAY_STATE_PLAYING => Self::Playing,
719            value => Self::__Unknown(value),
720        }
721    }
722}
723
724impl StaticType for PlayState {
725    #[inline]
726    #[doc(alias = "gst_play_state_get_type")]
727    fn static_type() -> glib::Type {
728        unsafe { from_glib(ffi::gst_play_state_get_type()) }
729    }
730}
731
732impl glib::HasParamSpec for PlayState {
733    type ParamSpec = glib::ParamSpecEnum;
734    type SetValue = Self;
735    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
736
737    fn param_spec_builder() -> Self::BuilderFn {
738        Self::ParamSpec::builder_with_default
739    }
740}
741
742impl glib::value::ValueType for PlayState {
743    type Type = Self;
744}
745
746unsafe impl<'a> glib::value::FromValue<'a> for PlayState {
747    type Checker = glib::value::GenericValueTypeChecker<Self>;
748
749    #[inline]
750    unsafe fn from_value(value: &'a glib::Value) -> Self {
751        skip_assert_initialized!();
752        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
753    }
754}
755
756impl ToValue for PlayState {
757    #[inline]
758    fn to_value(&self) -> glib::Value {
759        let mut value = glib::Value::for_value_type::<Self>();
760        unsafe {
761            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
762        }
763        value
764    }
765
766    #[inline]
767    fn value_type(&self) -> glib::Type {
768        Self::static_type()
769    }
770}
771
772impl From<PlayState> for glib::Value {
773    #[inline]
774    fn from(v: PlayState) -> Self {
775        skip_assert_initialized!();
776        ToValue::to_value(&v)
777    }
778}