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    /// hue or color balance.
14    #[doc(alias = "GST_PLAY_COLOR_BALANCE_HUE")]
15    Hue,
16    /// brightness or black level.
17    #[doc(alias = "GST_PLAY_COLOR_BALANCE_BRIGHTNESS")]
18    Brightness,
19    /// color saturation or chroma
20    /// gain.
21    #[doc(alias = "GST_PLAY_COLOR_BALANCE_SATURATION")]
22    Saturation,
23    /// contrast or luma gain.
24    #[doc(alias = "GST_PLAY_COLOR_BALANCE_CONTRAST")]
25    Contrast,
26    #[doc(hidden)]
27    __Unknown(i32),
28}
29
30impl PlayColorBalanceType {
31    pub fn name<'a>(self) -> &'a GStr {
32        unsafe {
33            GStr::from_ptr(
34                ffi::gst_play_color_balance_type_get_name(self.into_glib())
35                    .as_ref()
36                    .expect("gst_play_color_balance_type_get_name returned NULL"),
37            )
38        }
39    }
40}
41
42impl std::fmt::Display for PlayColorBalanceType {
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 PlayColorBalanceType {
51    type GlibType = ffi::GstPlayColorBalanceType;
52
53    #[inline]
54    fn into_glib(self) -> ffi::GstPlayColorBalanceType {
55        match self {
56            Self::Hue => ffi::GST_PLAY_COLOR_BALANCE_HUE,
57            Self::Brightness => ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS,
58            Self::Saturation => ffi::GST_PLAY_COLOR_BALANCE_SATURATION,
59            Self::Contrast => ffi::GST_PLAY_COLOR_BALANCE_CONTRAST,
60            Self::__Unknown(value) => value,
61        }
62    }
63}
64
65#[doc(hidden)]
66impl FromGlib<ffi::GstPlayColorBalanceType> for PlayColorBalanceType {
67    #[inline]
68    unsafe fn from_glib(value: ffi::GstPlayColorBalanceType) -> Self {
69        skip_assert_initialized!();
70
71        match value {
72            ffi::GST_PLAY_COLOR_BALANCE_HUE => Self::Hue,
73            ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS => Self::Brightness,
74            ffi::GST_PLAY_COLOR_BALANCE_SATURATION => Self::Saturation,
75            ffi::GST_PLAY_COLOR_BALANCE_CONTRAST => Self::Contrast,
76            value => Self::__Unknown(value),
77        }
78    }
79}
80
81impl StaticType for PlayColorBalanceType {
82    #[inline]
83    #[doc(alias = "gst_play_color_balance_type_get_type")]
84    fn static_type() -> glib::Type {
85        unsafe { from_glib(ffi::gst_play_color_balance_type_get_type()) }
86    }
87}
88
89impl glib::HasParamSpec for PlayColorBalanceType {
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 PlayColorBalanceType {
100    type Type = Self;
101}
102
103unsafe impl<'a> glib::value::FromValue<'a> for PlayColorBalanceType {
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 PlayColorBalanceType {
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<PlayColorBalanceType> for glib::Value {
130    #[inline]
131    fn from(v: PlayColorBalanceType) -> 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 = "GstPlayError")]
140pub enum PlayError {
141    /// generic error.
142    #[doc(alias = "GST_PLAY_ERROR_FAILED")]
143    Failed,
144    #[doc(hidden)]
145    __Unknown(i32),
146}
147
148impl PlayError {
149    pub fn name<'a>(self) -> &'a GStr {
150        unsafe {
151            GStr::from_ptr(
152                ffi::gst_play_error_get_name(self.into_glib())
153                    .as_ref()
154                    .expect("gst_play_error_get_name returned NULL"),
155            )
156        }
157    }
158}
159
160impl std::fmt::Display for PlayError {
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 PlayError {
169    type GlibType = ffi::GstPlayError;
170
171    #[inline]
172    fn into_glib(self) -> ffi::GstPlayError {
173        match self {
174            Self::Failed => ffi::GST_PLAY_ERROR_FAILED,
175            Self::__Unknown(value) => value,
176        }
177    }
178}
179
180#[doc(hidden)]
181impl FromGlib<ffi::GstPlayError> for PlayError {
182    #[inline]
183    unsafe fn from_glib(value: ffi::GstPlayError) -> Self {
184        skip_assert_initialized!();
185
186        match value {
187            ffi::GST_PLAY_ERROR_FAILED => Self::Failed,
188            value => Self::__Unknown(value),
189        }
190    }
191}
192
193impl glib::error::ErrorDomain for PlayError {
194    #[inline]
195    fn domain() -> glib::Quark {
196        skip_assert_initialized!();
197
198        unsafe { from_glib(ffi::gst_play_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 PlayError {
218    #[inline]
219    #[doc(alias = "gst_play_error_get_type")]
220    fn static_type() -> glib::Type {
221        unsafe { from_glib(ffi::gst_play_error_get_type()) }
222    }
223}
224
225impl glib::HasParamSpec for PlayError {
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 PlayError {
236    type Type = Self;
237}
238
239unsafe impl<'a> glib::value::FromValue<'a> for PlayError {
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 PlayError {
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<PlayError> for glib::Value {
266    #[inline]
267    fn from(v: PlayError) -> 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 = "GstPlayMessage")]
276pub(crate) enum PlayMessage {
277    /// Source element was initalized for set URI
278    #[doc(alias = "GST_PLAY_MESSAGE_URI_LOADED")]
279    UriLoaded,
280    /// Sink position changed
281    #[doc(alias = "GST_PLAY_MESSAGE_POSITION_UPDATED")]
282    PositionUpdated,
283    /// Duration of stream changed
284    #[doc(alias = "GST_PLAY_MESSAGE_DURATION_CHANGED")]
285    DurationChanged,
286    /// State changed, see [`PlayState`][crate::PlayState]
287    #[doc(alias = "GST_PLAY_MESSAGE_STATE_CHANGED")]
288    StateChanged,
289    /// Pipeline is in buffering state, message contains the percentage value of the decoding buffer
290    #[doc(alias = "GST_PLAY_MESSAGE_BUFFERING")]
291    Buffering,
292    /// Sink has received EOS
293    #[doc(alias = "GST_PLAY_MESSAGE_END_OF_STREAM")]
294    EndOfStream,
295    /// Message contains an error
296    #[doc(alias = "GST_PLAY_MESSAGE_ERROR")]
297    Error,
298    /// Message contains an error
299    #[doc(alias = "GST_PLAY_MESSAGE_WARNING")]
300    Warning,
301    /// Video sink received format in different dimensions than before
302    #[doc(alias = "GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED")]
303    VideoDimensionsChanged,
304    /// A media-info property has changed, message contains current [`PlayMediaInfo`][crate::PlayMediaInfo]
305    #[doc(alias = "GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED")]
306    MediaInfoUpdated,
307    /// The volume of the audio ouput has changed
308    #[doc(alias = "GST_PLAY_MESSAGE_VOLUME_CHANGED")]
309    VolumeChanged,
310    /// Audio muting flag has been toggled
311    #[doc(alias = "GST_PLAY_MESSAGE_MUTE_CHANGED")]
312    MuteChanged,
313    /// Any pending seeking operation has been completed
314    #[doc(alias = "GST_PLAY_MESSAGE_SEEK_DONE")]
315    SeekDone,
316    #[doc(hidden)]
317    __Unknown(i32),
318}
319
320impl PlayMessage {
321    pub fn name<'a>(self) -> &'a GStr {
322        unsafe {
323            GStr::from_ptr(
324                ffi::gst_play_message_get_name(self.into_glib())
325                    .as_ref()
326                    .expect("gst_play_message_get_name returned NULL"),
327            )
328        }
329    }
330
331    #[cfg(feature = "v1_26")]
332    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
333    #[doc(alias = "gst_play_message_parse_buffering")]
334    pub fn parse_buffering(msg: &gst::Message) -> u32 {
335        assert_initialized_main_thread!();
336        unsafe {
337            let mut percent = std::mem::MaybeUninit::uninit();
338            ffi::gst_play_message_parse_buffering(msg.to_glib_none().0, percent.as_mut_ptr());
339            percent.assume_init()
340        }
341    }
342
343    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
344    #[allow(deprecated)]
345    #[doc(alias = "gst_play_message_parse_buffering_percent")]
346    pub fn parse_buffering_percent(msg: &gst::Message) -> u32 {
347        assert_initialized_main_thread!();
348        unsafe {
349            let mut percent = std::mem::MaybeUninit::uninit();
350            ffi::gst_play_message_parse_buffering_percent(
351                msg.to_glib_none().0,
352                percent.as_mut_ptr(),
353            );
354            percent.assume_init()
355        }
356    }
357
358    #[cfg(feature = "v1_26")]
359    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
360    #[doc(alias = "gst_play_message_parse_duration_changed")]
361    pub fn parse_duration_changed(msg: &gst::Message) -> Option<gst::ClockTime> {
362        assert_initialized_main_thread!();
363        unsafe {
364            let mut duration = std::mem::MaybeUninit::uninit();
365            ffi::gst_play_message_parse_duration_changed(
366                msg.to_glib_none().0,
367                duration.as_mut_ptr(),
368            );
369            from_glib(duration.assume_init())
370        }
371    }
372
373    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
374    #[allow(deprecated)]
375    #[doc(alias = "gst_play_message_parse_duration_updated")]
376    pub fn parse_duration_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
377        assert_initialized_main_thread!();
378        unsafe {
379            let mut duration = std::mem::MaybeUninit::uninit();
380            ffi::gst_play_message_parse_duration_updated(
381                msg.to_glib_none().0,
382                duration.as_mut_ptr(),
383            );
384            from_glib(duration.assume_init())
385        }
386    }
387
388    #[doc(alias = "gst_play_message_parse_error")]
389    pub fn parse_error(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
390        assert_initialized_main_thread!();
391        unsafe {
392            let mut error = std::ptr::null_mut();
393            let mut details = std::ptr::null_mut();
394            ffi::gst_play_message_parse_error(msg.to_glib_none().0, &mut error, &mut details);
395            (from_glib_full(error), from_glib_full(details))
396        }
397    }
398
399    #[doc(alias = "gst_play_message_parse_media_info_updated")]
400    pub fn parse_media_info_updated(msg: &gst::Message) -> PlayMediaInfo {
401        assert_initialized_main_thread!();
402        unsafe {
403            let mut info = std::ptr::null_mut();
404            ffi::gst_play_message_parse_media_info_updated(msg.to_glib_none().0, &mut info);
405            from_glib_full(info)
406        }
407    }
408
409    #[doc(alias = "gst_play_message_parse_muted_changed")]
410    pub fn parse_muted_changed(msg: &gst::Message) -> bool {
411        assert_initialized_main_thread!();
412        unsafe {
413            let mut muted = std::mem::MaybeUninit::uninit();
414            ffi::gst_play_message_parse_muted_changed(msg.to_glib_none().0, muted.as_mut_ptr());
415            from_glib(muted.assume_init())
416        }
417    }
418
419    #[doc(alias = "gst_play_message_parse_position_updated")]
420    pub fn parse_position_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
421        assert_initialized_main_thread!();
422        unsafe {
423            let mut position = std::mem::MaybeUninit::uninit();
424            ffi::gst_play_message_parse_position_updated(
425                msg.to_glib_none().0,
426                position.as_mut_ptr(),
427            );
428            from_glib(position.assume_init())
429        }
430    }
431
432    #[cfg(feature = "v1_26")]
433    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
434    #[doc(alias = "gst_play_message_parse_seek_done")]
435    pub fn parse_seek_done(msg: &gst::Message) -> Option<gst::ClockTime> {
436        assert_initialized_main_thread!();
437        unsafe {
438            let mut position = std::mem::MaybeUninit::uninit();
439            ffi::gst_play_message_parse_seek_done(msg.to_glib_none().0, position.as_mut_ptr());
440            from_glib(position.assume_init())
441        }
442    }
443
444    #[doc(alias = "gst_play_message_parse_state_changed")]
445    pub fn parse_state_changed(msg: &gst::Message) -> PlayState {
446        assert_initialized_main_thread!();
447        unsafe {
448            let mut state = std::mem::MaybeUninit::uninit();
449            ffi::gst_play_message_parse_state_changed(msg.to_glib_none().0, state.as_mut_ptr());
450            from_glib(state.assume_init())
451        }
452    }
453
454    #[doc(alias = "gst_play_message_parse_type")]
455    pub fn parse_type(msg: &gst::Message) -> PlayMessage {
456        assert_initialized_main_thread!();
457        unsafe {
458            let mut type_ = std::mem::MaybeUninit::uninit();
459            ffi::gst_play_message_parse_type(msg.to_glib_none().0, type_.as_mut_ptr());
460            from_glib(type_.assume_init())
461        }
462    }
463
464    #[cfg(feature = "v1_26")]
465    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
466    #[doc(alias = "gst_play_message_parse_uri_loaded")]
467    pub fn parse_uri_loaded(msg: &gst::Message) -> glib::GString {
468        assert_initialized_main_thread!();
469        unsafe {
470            let mut uri = std::ptr::null_mut();
471            ffi::gst_play_message_parse_uri_loaded(msg.to_glib_none().0, &mut uri);
472            from_glib_full(uri)
473        }
474    }
475
476    #[doc(alias = "gst_play_message_parse_video_dimensions_changed")]
477    pub fn parse_video_dimensions_changed(msg: &gst::Message) -> (u32, u32) {
478        assert_initialized_main_thread!();
479        unsafe {
480            let mut width = std::mem::MaybeUninit::uninit();
481            let mut height = std::mem::MaybeUninit::uninit();
482            ffi::gst_play_message_parse_video_dimensions_changed(
483                msg.to_glib_none().0,
484                width.as_mut_ptr(),
485                height.as_mut_ptr(),
486            );
487            (width.assume_init(), height.assume_init())
488        }
489    }
490
491    #[doc(alias = "gst_play_message_parse_volume_changed")]
492    pub fn parse_volume_changed(msg: &gst::Message) -> f64 {
493        assert_initialized_main_thread!();
494        unsafe {
495            let mut volume = std::mem::MaybeUninit::uninit();
496            ffi::gst_play_message_parse_volume_changed(msg.to_glib_none().0, volume.as_mut_ptr());
497            volume.assume_init()
498        }
499    }
500
501    #[doc(alias = "gst_play_message_parse_warning")]
502    pub fn parse_warning(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
503        assert_initialized_main_thread!();
504        unsafe {
505            let mut error = std::ptr::null_mut();
506            let mut details = std::ptr::null_mut();
507            ffi::gst_play_message_parse_warning(msg.to_glib_none().0, &mut error, &mut details);
508            (from_glib_full(error), from_glib_full(details))
509        }
510    }
511}
512
513impl std::fmt::Display for PlayMessage {
514    #[inline]
515    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
516        f.write_str(&self.name())
517    }
518}
519
520#[doc(hidden)]
521impl IntoGlib for PlayMessage {
522    type GlibType = ffi::GstPlayMessage;
523
524    fn into_glib(self) -> ffi::GstPlayMessage {
525        match self {
526            Self::UriLoaded => ffi::GST_PLAY_MESSAGE_URI_LOADED,
527            Self::PositionUpdated => ffi::GST_PLAY_MESSAGE_POSITION_UPDATED,
528            Self::DurationChanged => ffi::GST_PLAY_MESSAGE_DURATION_CHANGED,
529            Self::StateChanged => ffi::GST_PLAY_MESSAGE_STATE_CHANGED,
530            Self::Buffering => ffi::GST_PLAY_MESSAGE_BUFFERING,
531            Self::EndOfStream => ffi::GST_PLAY_MESSAGE_END_OF_STREAM,
532            Self::Error => ffi::GST_PLAY_MESSAGE_ERROR,
533            Self::Warning => ffi::GST_PLAY_MESSAGE_WARNING,
534            Self::VideoDimensionsChanged => ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED,
535            Self::MediaInfoUpdated => ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED,
536            Self::VolumeChanged => ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED,
537            Self::MuteChanged => ffi::GST_PLAY_MESSAGE_MUTE_CHANGED,
538            Self::SeekDone => ffi::GST_PLAY_MESSAGE_SEEK_DONE,
539            Self::__Unknown(value) => value,
540        }
541    }
542}
543
544#[doc(hidden)]
545impl FromGlib<ffi::GstPlayMessage> for PlayMessage {
546    unsafe fn from_glib(value: ffi::GstPlayMessage) -> Self {
547        skip_assert_initialized!();
548
549        match value {
550            ffi::GST_PLAY_MESSAGE_URI_LOADED => Self::UriLoaded,
551            ffi::GST_PLAY_MESSAGE_POSITION_UPDATED => Self::PositionUpdated,
552            ffi::GST_PLAY_MESSAGE_DURATION_CHANGED => Self::DurationChanged,
553            ffi::GST_PLAY_MESSAGE_STATE_CHANGED => Self::StateChanged,
554            ffi::GST_PLAY_MESSAGE_BUFFERING => Self::Buffering,
555            ffi::GST_PLAY_MESSAGE_END_OF_STREAM => Self::EndOfStream,
556            ffi::GST_PLAY_MESSAGE_ERROR => Self::Error,
557            ffi::GST_PLAY_MESSAGE_WARNING => Self::Warning,
558            ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED => Self::VideoDimensionsChanged,
559            ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED => Self::MediaInfoUpdated,
560            ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED => Self::VolumeChanged,
561            ffi::GST_PLAY_MESSAGE_MUTE_CHANGED => Self::MuteChanged,
562            ffi::GST_PLAY_MESSAGE_SEEK_DONE => Self::SeekDone,
563            value => Self::__Unknown(value),
564        }
565    }
566}
567
568impl StaticType for PlayMessage {
569    #[inline]
570    #[doc(alias = "gst_play_message_get_type")]
571    fn static_type() -> glib::Type {
572        unsafe { from_glib(ffi::gst_play_message_get_type()) }
573    }
574}
575
576impl glib::HasParamSpec for PlayMessage {
577    type ParamSpec = glib::ParamSpecEnum;
578    type SetValue = Self;
579    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
580
581    fn param_spec_builder() -> Self::BuilderFn {
582        Self::ParamSpec::builder_with_default
583    }
584}
585
586impl glib::value::ValueType for PlayMessage {
587    type Type = Self;
588}
589
590unsafe impl<'a> glib::value::FromValue<'a> for PlayMessage {
591    type Checker = glib::value::GenericValueTypeChecker<Self>;
592
593    #[inline]
594    unsafe fn from_value(value: &'a glib::Value) -> Self {
595        skip_assert_initialized!();
596        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
597    }
598}
599
600impl ToValue for PlayMessage {
601    #[inline]
602    fn to_value(&self) -> glib::Value {
603        let mut value = glib::Value::for_value_type::<Self>();
604        unsafe {
605            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
606        }
607        value
608    }
609
610    #[inline]
611    fn value_type(&self) -> glib::Type {
612        Self::static_type()
613    }
614}
615
616impl From<PlayMessage> for glib::Value {
617    #[inline]
618    fn from(v: PlayMessage) -> Self {
619        skip_assert_initialized!();
620        ToValue::to_value(&v)
621    }
622}
623
624#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
625#[non_exhaustive]
626#[doc(alias = "GstPlaySnapshotFormat")]
627pub enum PlaySnapshotFormat {
628    /// raw native format.
629    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_NATIVE")]
630    RawNative,
631    /// raw xRGB format.
632    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_xRGB")]
633    RawXrgb,
634    /// raw BGRx format.
635    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_BGRx")]
636    RawBgrx,
637    /// jpeg format.
638    #[doc(alias = "GST_PLAY_THUMBNAIL_JPG")]
639    Jpg,
640    /// png format.
641    #[doc(alias = "GST_PLAY_THUMBNAIL_PNG")]
642    Png,
643    #[doc(hidden)]
644    __Unknown(i32),
645}
646
647#[doc(hidden)]
648impl IntoGlib for PlaySnapshotFormat {
649    type GlibType = ffi::GstPlaySnapshotFormat;
650
651    #[inline]
652    fn into_glib(self) -> ffi::GstPlaySnapshotFormat {
653        match self {
654            Self::RawNative => ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE,
655            Self::RawXrgb => ffi::GST_PLAY_THUMBNAIL_RAW_xRGB,
656            Self::RawBgrx => ffi::GST_PLAY_THUMBNAIL_RAW_BGRx,
657            Self::Jpg => ffi::GST_PLAY_THUMBNAIL_JPG,
658            Self::Png => ffi::GST_PLAY_THUMBNAIL_PNG,
659            Self::__Unknown(value) => value,
660        }
661    }
662}
663
664#[doc(hidden)]
665impl FromGlib<ffi::GstPlaySnapshotFormat> for PlaySnapshotFormat {
666    #[inline]
667    unsafe fn from_glib(value: ffi::GstPlaySnapshotFormat) -> Self {
668        skip_assert_initialized!();
669
670        match value {
671            ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE => Self::RawNative,
672            ffi::GST_PLAY_THUMBNAIL_RAW_xRGB => Self::RawXrgb,
673            ffi::GST_PLAY_THUMBNAIL_RAW_BGRx => Self::RawBgrx,
674            ffi::GST_PLAY_THUMBNAIL_JPG => Self::Jpg,
675            ffi::GST_PLAY_THUMBNAIL_PNG => Self::Png,
676            value => Self::__Unknown(value),
677        }
678    }
679}
680
681#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
682#[non_exhaustive]
683#[doc(alias = "GstPlayState")]
684pub enum PlayState {
685    /// the play is stopped.
686    #[doc(alias = "GST_PLAY_STATE_STOPPED")]
687    Stopped,
688    /// the play is buffering.
689    #[doc(alias = "GST_PLAY_STATE_BUFFERING")]
690    Buffering,
691    /// the play is paused.
692    #[doc(alias = "GST_PLAY_STATE_PAUSED")]
693    Paused,
694    /// the play is currently playing a
695    /// stream.
696    #[doc(alias = "GST_PLAY_STATE_PLAYING")]
697    Playing,
698    #[doc(hidden)]
699    __Unknown(i32),
700}
701
702impl PlayState {
703    pub fn name<'a>(self) -> &'a GStr {
704        unsafe {
705            GStr::from_ptr(
706                ffi::gst_play_state_get_name(self.into_glib())
707                    .as_ref()
708                    .expect("gst_play_state_get_name returned NULL"),
709            )
710        }
711    }
712}
713
714impl std::fmt::Display for PlayState {
715    #[inline]
716    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
717        f.write_str(&self.name())
718    }
719}
720
721#[doc(hidden)]
722impl IntoGlib for PlayState {
723    type GlibType = ffi::GstPlayState;
724
725    #[inline]
726    fn into_glib(self) -> ffi::GstPlayState {
727        match self {
728            Self::Stopped => ffi::GST_PLAY_STATE_STOPPED,
729            Self::Buffering => ffi::GST_PLAY_STATE_BUFFERING,
730            Self::Paused => ffi::GST_PLAY_STATE_PAUSED,
731            Self::Playing => ffi::GST_PLAY_STATE_PLAYING,
732            Self::__Unknown(value) => value,
733        }
734    }
735}
736
737#[doc(hidden)]
738impl FromGlib<ffi::GstPlayState> for PlayState {
739    #[inline]
740    unsafe fn from_glib(value: ffi::GstPlayState) -> Self {
741        skip_assert_initialized!();
742
743        match value {
744            ffi::GST_PLAY_STATE_STOPPED => Self::Stopped,
745            ffi::GST_PLAY_STATE_BUFFERING => Self::Buffering,
746            ffi::GST_PLAY_STATE_PAUSED => Self::Paused,
747            ffi::GST_PLAY_STATE_PLAYING => Self::Playing,
748            value => Self::__Unknown(value),
749        }
750    }
751}
752
753impl StaticType for PlayState {
754    #[inline]
755    #[doc(alias = "gst_play_state_get_type")]
756    fn static_type() -> glib::Type {
757        unsafe { from_glib(ffi::gst_play_state_get_type()) }
758    }
759}
760
761impl glib::HasParamSpec for PlayState {
762    type ParamSpec = glib::ParamSpecEnum;
763    type SetValue = Self;
764    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
765
766    fn param_spec_builder() -> Self::BuilderFn {
767        Self::ParamSpec::builder_with_default
768    }
769}
770
771impl glib::value::ValueType for PlayState {
772    type Type = Self;
773}
774
775unsafe impl<'a> glib::value::FromValue<'a> for PlayState {
776    type Checker = glib::value::GenericValueTypeChecker<Self>;
777
778    #[inline]
779    unsafe fn from_value(value: &'a glib::Value) -> Self {
780        skip_assert_initialized!();
781        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
782    }
783}
784
785impl ToValue for PlayState {
786    #[inline]
787    fn to_value(&self) -> glib::Value {
788        let mut value = glib::Value::for_value_type::<Self>();
789        unsafe {
790            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
791        }
792        value
793    }
794
795    #[inline]
796    fn value_type(&self) -> glib::Type {
797        Self::static_type()
798    }
799}
800
801impl From<PlayState> for glib::Value {
802    #[inline]
803    fn from(v: PlayState) -> Self {
804        skip_assert_initialized!();
805        ToValue::to_value(&v)
806    }
807}