Skip to main content

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::{PlayMediaInfo, ffi};
7use glib::{GStr, prelude::*, translate::*};
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        unsafe { 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        unsafe { 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#[cfg(feature = "v1_28")]
268#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
269#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
270#[non_exhaustive]
271#[doc(alias = "GstPlayLoop")]
272pub enum PlayLoop {
273    #[doc(alias = "GST_PLAY_LOOP_NONE")]
274    None,
275    #[doc(alias = "GST_PLAY_LOOP_TRACK")]
276    Track,
277    #[doc(hidden)]
278    __Unknown(i32),
279}
280
281#[cfg(feature = "v1_28")]
282#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
283impl PlayLoop {
284    pub fn name<'a>(self) -> &'a GStr {
285        unsafe {
286            GStr::from_ptr(
287                ffi::gst_play_loop_get_name(self.into_glib())
288                    .as_ref()
289                    .expect("gst_play_loop_get_name returned NULL"),
290            )
291        }
292    }
293}
294
295#[cfg(feature = "v1_28")]
296#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
297impl std::fmt::Display for PlayLoop {
298    #[inline]
299    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
300        f.write_str(&self.name())
301    }
302}
303
304#[cfg(feature = "v1_28")]
305#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
306#[doc(hidden)]
307impl IntoGlib for PlayLoop {
308    type GlibType = ffi::GstPlayLoop;
309
310    #[inline]
311    fn into_glib(self) -> ffi::GstPlayLoop {
312        match self {
313            Self::None => ffi::GST_PLAY_LOOP_NONE,
314            Self::Track => ffi::GST_PLAY_LOOP_TRACK,
315            Self::__Unknown(value) => value,
316        }
317    }
318}
319
320#[cfg(feature = "v1_28")]
321#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
322#[doc(hidden)]
323impl FromGlib<ffi::GstPlayLoop> for PlayLoop {
324    #[inline]
325    unsafe fn from_glib(value: ffi::GstPlayLoop) -> Self {
326        skip_assert_initialized!();
327
328        match value {
329            ffi::GST_PLAY_LOOP_NONE => Self::None,
330            ffi::GST_PLAY_LOOP_TRACK => Self::Track,
331            value => Self::__Unknown(value),
332        }
333    }
334}
335
336#[cfg(feature = "v1_28")]
337#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
338impl StaticType for PlayLoop {
339    #[inline]
340    #[doc(alias = "gst_play_loop_get_type")]
341    fn static_type() -> glib::Type {
342        unsafe { from_glib(ffi::gst_play_loop_get_type()) }
343    }
344}
345
346#[cfg(feature = "v1_28")]
347#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
348impl glib::HasParamSpec for PlayLoop {
349    type ParamSpec = glib::ParamSpecEnum;
350    type SetValue = Self;
351    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
352
353    fn param_spec_builder() -> Self::BuilderFn {
354        Self::ParamSpec::builder_with_default
355    }
356}
357
358#[cfg(feature = "v1_28")]
359#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
360impl glib::value::ValueType for PlayLoop {
361    type Type = Self;
362}
363
364#[cfg(feature = "v1_28")]
365#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
366unsafe impl<'a> glib::value::FromValue<'a> for PlayLoop {
367    type Checker = glib::value::GenericValueTypeChecker<Self>;
368
369    #[inline]
370    unsafe fn from_value(value: &'a glib::Value) -> Self {
371        skip_assert_initialized!();
372        unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
373    }
374}
375
376#[cfg(feature = "v1_28")]
377#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
378impl ToValue for PlayLoop {
379    #[inline]
380    fn to_value(&self) -> glib::Value {
381        let mut value = glib::Value::for_value_type::<Self>();
382        unsafe {
383            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
384        }
385        value
386    }
387
388    #[inline]
389    fn value_type(&self) -> glib::Type {
390        Self::static_type()
391    }
392}
393
394#[cfg(feature = "v1_28")]
395#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
396impl From<PlayLoop> for glib::Value {
397    #[inline]
398    fn from(v: PlayLoop) -> Self {
399        skip_assert_initialized!();
400        ToValue::to_value(&v)
401    }
402}
403
404#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
405#[non_exhaustive]
406#[doc(alias = "GstPlayMessage")]
407pub(crate) enum PlayMessage {
408    #[doc(alias = "GST_PLAY_MESSAGE_URI_LOADED")]
409    UriLoaded,
410    #[doc(alias = "GST_PLAY_MESSAGE_POSITION_UPDATED")]
411    PositionUpdated,
412    #[doc(alias = "GST_PLAY_MESSAGE_DURATION_CHANGED")]
413    DurationChanged,
414    #[doc(alias = "GST_PLAY_MESSAGE_STATE_CHANGED")]
415    StateChanged,
416    #[doc(alias = "GST_PLAY_MESSAGE_BUFFERING")]
417    Buffering,
418    #[doc(alias = "GST_PLAY_MESSAGE_END_OF_STREAM")]
419    EndOfStream,
420    #[doc(alias = "GST_PLAY_MESSAGE_ERROR")]
421    Error,
422    #[doc(alias = "GST_PLAY_MESSAGE_WARNING")]
423    Warning,
424    #[doc(alias = "GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED")]
425    VideoDimensionsChanged,
426    #[doc(alias = "GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED")]
427    MediaInfoUpdated,
428    #[doc(alias = "GST_PLAY_MESSAGE_VOLUME_CHANGED")]
429    VolumeChanged,
430    #[doc(alias = "GST_PLAY_MESSAGE_MUTE_CHANGED")]
431    MuteChanged,
432    #[doc(alias = "GST_PLAY_MESSAGE_SEEK_DONE")]
433    SeekDone,
434    #[cfg(feature = "v1_30")]
435    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
436    #[doc(alias = "GST_PLAY_MESSAGE_TRACKS_SELECTED")]
437    TracksSelected,
438    #[doc(hidden)]
439    __Unknown(i32),
440}
441
442impl PlayMessage {
443    pub fn name<'a>(self) -> &'a GStr {
444        unsafe {
445            GStr::from_ptr(
446                ffi::gst_play_message_get_name(self.into_glib())
447                    .as_ref()
448                    .expect("gst_play_message_get_name returned NULL"),
449            )
450        }
451    }
452
453    #[cfg(feature = "v1_26")]
454    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
455    #[doc(alias = "gst_play_message_parse_buffering")]
456    pub fn parse_buffering(msg: &gst::Message) -> u32 {
457        assert_initialized_main_thread!();
458        unsafe {
459            let mut percent = std::mem::MaybeUninit::uninit();
460            ffi::gst_play_message_parse_buffering(msg.to_glib_none().0, percent.as_mut_ptr());
461            percent.assume_init()
462        }
463    }
464
465    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
466    #[allow(deprecated)]
467    #[doc(alias = "gst_play_message_parse_buffering_percent")]
468    pub fn parse_buffering_percent(msg: &gst::Message) -> u32 {
469        assert_initialized_main_thread!();
470        unsafe {
471            let mut percent = std::mem::MaybeUninit::uninit();
472            ffi::gst_play_message_parse_buffering_percent(
473                msg.to_glib_none().0,
474                percent.as_mut_ptr(),
475            );
476            percent.assume_init()
477        }
478    }
479
480    #[cfg(feature = "v1_26")]
481    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
482    #[doc(alias = "gst_play_message_parse_duration_changed")]
483    pub fn parse_duration_changed(msg: &gst::Message) -> Option<gst::ClockTime> {
484        assert_initialized_main_thread!();
485        unsafe {
486            let mut duration = std::mem::MaybeUninit::uninit();
487            ffi::gst_play_message_parse_duration_changed(
488                msg.to_glib_none().0,
489                duration.as_mut_ptr(),
490            );
491            from_glib(duration.assume_init())
492        }
493    }
494
495    #[cfg_attr(feature = "v1_26", deprecated = "Since 1.26")]
496    #[allow(deprecated)]
497    #[doc(alias = "gst_play_message_parse_duration_updated")]
498    pub fn parse_duration_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
499        assert_initialized_main_thread!();
500        unsafe {
501            let mut duration = std::mem::MaybeUninit::uninit();
502            ffi::gst_play_message_parse_duration_updated(
503                msg.to_glib_none().0,
504                duration.as_mut_ptr(),
505            );
506            from_glib(duration.assume_init())
507        }
508    }
509
510    #[doc(alias = "gst_play_message_parse_error")]
511    pub fn parse_error(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
512        assert_initialized_main_thread!();
513        unsafe {
514            let mut error = std::ptr::null_mut();
515            let mut details = std::ptr::null_mut();
516            ffi::gst_play_message_parse_error(msg.to_glib_none().0, &mut error, &mut details);
517            (from_glib_full(error), from_glib_full(details))
518        }
519    }
520
521    #[doc(alias = "gst_play_message_parse_media_info_updated")]
522    pub fn parse_media_info_updated(msg: &gst::Message) -> PlayMediaInfo {
523        assert_initialized_main_thread!();
524        unsafe {
525            let mut info = std::ptr::null_mut();
526            ffi::gst_play_message_parse_media_info_updated(msg.to_glib_none().0, &mut info);
527            from_glib_full(info)
528        }
529    }
530
531    #[doc(alias = "gst_play_message_parse_muted_changed")]
532    pub fn parse_muted_changed(msg: &gst::Message) -> bool {
533        assert_initialized_main_thread!();
534        unsafe {
535            let mut muted = std::mem::MaybeUninit::uninit();
536            ffi::gst_play_message_parse_muted_changed(msg.to_glib_none().0, muted.as_mut_ptr());
537            from_glib(muted.assume_init())
538        }
539    }
540
541    #[doc(alias = "gst_play_message_parse_position_updated")]
542    pub fn parse_position_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
543        assert_initialized_main_thread!();
544        unsafe {
545            let mut position = std::mem::MaybeUninit::uninit();
546            ffi::gst_play_message_parse_position_updated(
547                msg.to_glib_none().0,
548                position.as_mut_ptr(),
549            );
550            from_glib(position.assume_init())
551        }
552    }
553
554    #[cfg(feature = "v1_26")]
555    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
556    #[doc(alias = "gst_play_message_parse_seek_done")]
557    pub fn parse_seek_done(msg: &gst::Message) -> Option<gst::ClockTime> {
558        assert_initialized_main_thread!();
559        unsafe {
560            let mut position = std::mem::MaybeUninit::uninit();
561            ffi::gst_play_message_parse_seek_done(msg.to_glib_none().0, position.as_mut_ptr());
562            from_glib(position.assume_init())
563        }
564    }
565
566    #[doc(alias = "gst_play_message_parse_state_changed")]
567    pub fn parse_state_changed(msg: &gst::Message) -> PlayState {
568        assert_initialized_main_thread!();
569        unsafe {
570            let mut state = std::mem::MaybeUninit::uninit();
571            ffi::gst_play_message_parse_state_changed(msg.to_glib_none().0, state.as_mut_ptr());
572            from_glib(state.assume_init())
573        }
574    }
575
576    #[doc(alias = "gst_play_message_parse_type")]
577    pub fn parse_type(msg: &gst::Message) -> PlayMessage {
578        assert_initialized_main_thread!();
579        unsafe {
580            let mut type_ = std::mem::MaybeUninit::uninit();
581            ffi::gst_play_message_parse_type(msg.to_glib_none().0, type_.as_mut_ptr());
582            from_glib(type_.assume_init())
583        }
584    }
585
586    #[cfg(feature = "v1_26")]
587    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
588    #[doc(alias = "gst_play_message_parse_uri_loaded")]
589    pub fn parse_uri_loaded(msg: &gst::Message) -> glib::GString {
590        assert_initialized_main_thread!();
591        unsafe {
592            let mut uri = std::ptr::null_mut();
593            ffi::gst_play_message_parse_uri_loaded(msg.to_glib_none().0, &mut uri);
594            from_glib_full(uri)
595        }
596    }
597
598    #[doc(alias = "gst_play_message_parse_video_dimensions_changed")]
599    pub fn parse_video_dimensions_changed(msg: &gst::Message) -> (u32, u32) {
600        assert_initialized_main_thread!();
601        unsafe {
602            let mut width = std::mem::MaybeUninit::uninit();
603            let mut height = std::mem::MaybeUninit::uninit();
604            ffi::gst_play_message_parse_video_dimensions_changed(
605                msg.to_glib_none().0,
606                width.as_mut_ptr(),
607                height.as_mut_ptr(),
608            );
609            (width.assume_init(), height.assume_init())
610        }
611    }
612
613    #[doc(alias = "gst_play_message_parse_volume_changed")]
614    pub fn parse_volume_changed(msg: &gst::Message) -> f64 {
615        assert_initialized_main_thread!();
616        unsafe {
617            let mut volume = std::mem::MaybeUninit::uninit();
618            ffi::gst_play_message_parse_volume_changed(msg.to_glib_none().0, volume.as_mut_ptr());
619            volume.assume_init()
620        }
621    }
622
623    #[doc(alias = "gst_play_message_parse_warning")]
624    pub fn parse_warning(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
625        assert_initialized_main_thread!();
626        unsafe {
627            let mut error = std::ptr::null_mut();
628            let mut details = std::ptr::null_mut();
629            ffi::gst_play_message_parse_warning(msg.to_glib_none().0, &mut error, &mut details);
630            (from_glib_full(error), from_glib_full(details))
631        }
632    }
633}
634
635impl std::fmt::Display for PlayMessage {
636    #[inline]
637    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
638        f.write_str(&self.name())
639    }
640}
641
642#[doc(hidden)]
643impl IntoGlib for PlayMessage {
644    type GlibType = ffi::GstPlayMessage;
645
646    fn into_glib(self) -> ffi::GstPlayMessage {
647        match self {
648            Self::UriLoaded => ffi::GST_PLAY_MESSAGE_URI_LOADED,
649            Self::PositionUpdated => ffi::GST_PLAY_MESSAGE_POSITION_UPDATED,
650            Self::DurationChanged => ffi::GST_PLAY_MESSAGE_DURATION_CHANGED,
651            Self::StateChanged => ffi::GST_PLAY_MESSAGE_STATE_CHANGED,
652            Self::Buffering => ffi::GST_PLAY_MESSAGE_BUFFERING,
653            Self::EndOfStream => ffi::GST_PLAY_MESSAGE_END_OF_STREAM,
654            Self::Error => ffi::GST_PLAY_MESSAGE_ERROR,
655            Self::Warning => ffi::GST_PLAY_MESSAGE_WARNING,
656            Self::VideoDimensionsChanged => ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED,
657            Self::MediaInfoUpdated => ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED,
658            Self::VolumeChanged => ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED,
659            Self::MuteChanged => ffi::GST_PLAY_MESSAGE_MUTE_CHANGED,
660            Self::SeekDone => ffi::GST_PLAY_MESSAGE_SEEK_DONE,
661            #[cfg(feature = "v1_30")]
662            Self::TracksSelected => ffi::GST_PLAY_MESSAGE_TRACKS_SELECTED,
663            Self::__Unknown(value) => value,
664        }
665    }
666}
667
668#[doc(hidden)]
669impl FromGlib<ffi::GstPlayMessage> for PlayMessage {
670    unsafe fn from_glib(value: ffi::GstPlayMessage) -> Self {
671        skip_assert_initialized!();
672
673        match value {
674            ffi::GST_PLAY_MESSAGE_URI_LOADED => Self::UriLoaded,
675            ffi::GST_PLAY_MESSAGE_POSITION_UPDATED => Self::PositionUpdated,
676            ffi::GST_PLAY_MESSAGE_DURATION_CHANGED => Self::DurationChanged,
677            ffi::GST_PLAY_MESSAGE_STATE_CHANGED => Self::StateChanged,
678            ffi::GST_PLAY_MESSAGE_BUFFERING => Self::Buffering,
679            ffi::GST_PLAY_MESSAGE_END_OF_STREAM => Self::EndOfStream,
680            ffi::GST_PLAY_MESSAGE_ERROR => Self::Error,
681            ffi::GST_PLAY_MESSAGE_WARNING => Self::Warning,
682            ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED => Self::VideoDimensionsChanged,
683            ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED => Self::MediaInfoUpdated,
684            ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED => Self::VolumeChanged,
685            ffi::GST_PLAY_MESSAGE_MUTE_CHANGED => Self::MuteChanged,
686            ffi::GST_PLAY_MESSAGE_SEEK_DONE => Self::SeekDone,
687            #[cfg(feature = "v1_30")]
688            ffi::GST_PLAY_MESSAGE_TRACKS_SELECTED => Self::TracksSelected,
689            value => Self::__Unknown(value),
690        }
691    }
692}
693
694impl StaticType for PlayMessage {
695    #[inline]
696    #[doc(alias = "gst_play_message_get_type")]
697    fn static_type() -> glib::Type {
698        unsafe { from_glib(ffi::gst_play_message_get_type()) }
699    }
700}
701
702impl glib::HasParamSpec for PlayMessage {
703    type ParamSpec = glib::ParamSpecEnum;
704    type SetValue = Self;
705    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
706
707    fn param_spec_builder() -> Self::BuilderFn {
708        Self::ParamSpec::builder_with_default
709    }
710}
711
712impl glib::value::ValueType for PlayMessage {
713    type Type = Self;
714}
715
716unsafe impl<'a> glib::value::FromValue<'a> for PlayMessage {
717    type Checker = glib::value::GenericValueTypeChecker<Self>;
718
719    #[inline]
720    unsafe fn from_value(value: &'a glib::Value) -> Self {
721        skip_assert_initialized!();
722        unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
723    }
724}
725
726impl ToValue for PlayMessage {
727    #[inline]
728    fn to_value(&self) -> glib::Value {
729        let mut value = glib::Value::for_value_type::<Self>();
730        unsafe {
731            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
732        }
733        value
734    }
735
736    #[inline]
737    fn value_type(&self) -> glib::Type {
738        Self::static_type()
739    }
740}
741
742impl From<PlayMessage> for glib::Value {
743    #[inline]
744    fn from(v: PlayMessage) -> Self {
745        skip_assert_initialized!();
746        ToValue::to_value(&v)
747    }
748}
749
750#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
751#[non_exhaustive]
752#[doc(alias = "GstPlaySnapshotFormat")]
753pub enum PlaySnapshotFormat {
754    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_NATIVE")]
755    RawNative,
756    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_xRGB")]
757    RawXrgb,
758    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_BGRx")]
759    RawBgrx,
760    #[doc(alias = "GST_PLAY_THUMBNAIL_JPG")]
761    Jpg,
762    #[doc(alias = "GST_PLAY_THUMBNAIL_PNG")]
763    Png,
764    #[doc(hidden)]
765    __Unknown(i32),
766}
767
768#[doc(hidden)]
769impl IntoGlib for PlaySnapshotFormat {
770    type GlibType = ffi::GstPlaySnapshotFormat;
771
772    #[inline]
773    fn into_glib(self) -> ffi::GstPlaySnapshotFormat {
774        match self {
775            Self::RawNative => ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE,
776            Self::RawXrgb => ffi::GST_PLAY_THUMBNAIL_RAW_xRGB,
777            Self::RawBgrx => ffi::GST_PLAY_THUMBNAIL_RAW_BGRx,
778            Self::Jpg => ffi::GST_PLAY_THUMBNAIL_JPG,
779            Self::Png => ffi::GST_PLAY_THUMBNAIL_PNG,
780            Self::__Unknown(value) => value,
781        }
782    }
783}
784
785#[doc(hidden)]
786impl FromGlib<ffi::GstPlaySnapshotFormat> for PlaySnapshotFormat {
787    #[inline]
788    unsafe fn from_glib(value: ffi::GstPlaySnapshotFormat) -> Self {
789        skip_assert_initialized!();
790
791        match value {
792            ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE => Self::RawNative,
793            ffi::GST_PLAY_THUMBNAIL_RAW_xRGB => Self::RawXrgb,
794            ffi::GST_PLAY_THUMBNAIL_RAW_BGRx => Self::RawBgrx,
795            ffi::GST_PLAY_THUMBNAIL_JPG => Self::Jpg,
796            ffi::GST_PLAY_THUMBNAIL_PNG => Self::Png,
797            value => Self::__Unknown(value),
798        }
799    }
800}
801
802#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
803#[non_exhaustive]
804#[doc(alias = "GstPlayState")]
805pub enum PlayState {
806    #[doc(alias = "GST_PLAY_STATE_STOPPED")]
807    Stopped,
808    #[doc(alias = "GST_PLAY_STATE_BUFFERING")]
809    Buffering,
810    #[doc(alias = "GST_PLAY_STATE_PAUSED")]
811    Paused,
812    #[doc(alias = "GST_PLAY_STATE_PLAYING")]
813    Playing,
814    #[doc(hidden)]
815    __Unknown(i32),
816}
817
818impl PlayState {
819    pub fn name<'a>(self) -> &'a GStr {
820        unsafe {
821            GStr::from_ptr(
822                ffi::gst_play_state_get_name(self.into_glib())
823                    .as_ref()
824                    .expect("gst_play_state_get_name returned NULL"),
825            )
826        }
827    }
828}
829
830impl std::fmt::Display for PlayState {
831    #[inline]
832    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
833        f.write_str(&self.name())
834    }
835}
836
837#[doc(hidden)]
838impl IntoGlib for PlayState {
839    type GlibType = ffi::GstPlayState;
840
841    #[inline]
842    fn into_glib(self) -> ffi::GstPlayState {
843        match self {
844            Self::Stopped => ffi::GST_PLAY_STATE_STOPPED,
845            Self::Buffering => ffi::GST_PLAY_STATE_BUFFERING,
846            Self::Paused => ffi::GST_PLAY_STATE_PAUSED,
847            Self::Playing => ffi::GST_PLAY_STATE_PLAYING,
848            Self::__Unknown(value) => value,
849        }
850    }
851}
852
853#[doc(hidden)]
854impl FromGlib<ffi::GstPlayState> for PlayState {
855    #[inline]
856    unsafe fn from_glib(value: ffi::GstPlayState) -> Self {
857        skip_assert_initialized!();
858
859        match value {
860            ffi::GST_PLAY_STATE_STOPPED => Self::Stopped,
861            ffi::GST_PLAY_STATE_BUFFERING => Self::Buffering,
862            ffi::GST_PLAY_STATE_PAUSED => Self::Paused,
863            ffi::GST_PLAY_STATE_PLAYING => Self::Playing,
864            value => Self::__Unknown(value),
865        }
866    }
867}
868
869impl StaticType for PlayState {
870    #[inline]
871    #[doc(alias = "gst_play_state_get_type")]
872    fn static_type() -> glib::Type {
873        unsafe { from_glib(ffi::gst_play_state_get_type()) }
874    }
875}
876
877impl glib::HasParamSpec for PlayState {
878    type ParamSpec = glib::ParamSpecEnum;
879    type SetValue = Self;
880    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
881
882    fn param_spec_builder() -> Self::BuilderFn {
883        Self::ParamSpec::builder_with_default
884    }
885}
886
887impl glib::value::ValueType for PlayState {
888    type Type = Self;
889}
890
891unsafe impl<'a> glib::value::FromValue<'a> for PlayState {
892    type Checker = glib::value::GenericValueTypeChecker<Self>;
893
894    #[inline]
895    unsafe fn from_value(value: &'a glib::Value) -> Self {
896        skip_assert_initialized!();
897        unsafe { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) }
898    }
899}
900
901impl ToValue for PlayState {
902    #[inline]
903    fn to_value(&self) -> glib::Value {
904        let mut value = glib::Value::for_value_type::<Self>();
905        unsafe {
906            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
907        }
908        value
909    }
910
911    #[inline]
912    fn value_type(&self) -> glib::Type {
913        Self::static_type()
914    }
915}
916
917impl From<PlayState> for glib::Value {
918    #[inline]
919    fn from(v: PlayState) -> Self {
920        skip_assert_initialized!();
921        ToValue::to_value(&v)
922    }
923}