1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::{ffi, PlayMediaInfo};
use glib::{prelude::*, translate::*, GStr};

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GstPlayColorBalanceType")]
pub enum PlayColorBalanceType {
    /// hue or color balance.
    #[doc(alias = "GST_PLAY_COLOR_BALANCE_HUE")]
    Hue,
    /// brightness or black level.
    #[doc(alias = "GST_PLAY_COLOR_BALANCE_BRIGHTNESS")]
    Brightness,
    /// color saturation or chroma
    /// gain.
    #[doc(alias = "GST_PLAY_COLOR_BALANCE_SATURATION")]
    Saturation,
    /// contrast or luma gain.
    #[doc(alias = "GST_PLAY_COLOR_BALANCE_CONTRAST")]
    Contrast,
    #[doc(hidden)]
    __Unknown(i32),
}

impl PlayColorBalanceType {
    pub fn name<'a>(self) -> &'a GStr {
        unsafe {
            GStr::from_ptr(
                ffi::gst_play_color_balance_type_get_name(self.into_glib())
                    .as_ref()
                    .expect("gst_play_color_balance_type_get_name returned NULL"),
            )
        }
    }
}

impl std::fmt::Display for PlayColorBalanceType {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.name())
    }
}

#[doc(hidden)]
impl IntoGlib for PlayColorBalanceType {
    type GlibType = ffi::GstPlayColorBalanceType;

    #[inline]
    fn into_glib(self) -> ffi::GstPlayColorBalanceType {
        match self {
            Self::Hue => ffi::GST_PLAY_COLOR_BALANCE_HUE,
            Self::Brightness => ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS,
            Self::Saturation => ffi::GST_PLAY_COLOR_BALANCE_SATURATION,
            Self::Contrast => ffi::GST_PLAY_COLOR_BALANCE_CONTRAST,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GstPlayColorBalanceType> for PlayColorBalanceType {
    #[inline]
    unsafe fn from_glib(value: ffi::GstPlayColorBalanceType) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::GST_PLAY_COLOR_BALANCE_HUE => Self::Hue,
            ffi::GST_PLAY_COLOR_BALANCE_BRIGHTNESS => Self::Brightness,
            ffi::GST_PLAY_COLOR_BALANCE_SATURATION => Self::Saturation,
            ffi::GST_PLAY_COLOR_BALANCE_CONTRAST => Self::Contrast,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for PlayColorBalanceType {
    #[inline]
    #[doc(alias = "gst_play_color_balance_type_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::gst_play_color_balance_type_get_type()) }
    }
}

impl glib::HasParamSpec for PlayColorBalanceType {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

impl glib::value::ValueType for PlayColorBalanceType {
    type Type = Self;
}

unsafe impl<'a> glib::value::FromValue<'a> for PlayColorBalanceType {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    #[inline]
    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for PlayColorBalanceType {
    #[inline]
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

impl From<PlayColorBalanceType> for glib::Value {
    #[inline]
    fn from(v: PlayColorBalanceType) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GstPlayError")]
pub enum PlayError {
    /// generic error.
    #[doc(alias = "GST_PLAY_ERROR_FAILED")]
    Failed,
    #[doc(hidden)]
    __Unknown(i32),
}

impl PlayError {
    pub fn name<'a>(self) -> &'a GStr {
        unsafe {
            GStr::from_ptr(
                ffi::gst_play_error_get_name(self.into_glib())
                    .as_ref()
                    .expect("gst_play_error_get_name returned NULL"),
            )
        }
    }
}

impl std::fmt::Display for PlayError {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.name())
    }
}

#[doc(hidden)]
impl IntoGlib for PlayError {
    type GlibType = ffi::GstPlayError;

    #[inline]
    fn into_glib(self) -> ffi::GstPlayError {
        match self {
            Self::Failed => ffi::GST_PLAY_ERROR_FAILED,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GstPlayError> for PlayError {
    #[inline]
    unsafe fn from_glib(value: ffi::GstPlayError) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::GST_PLAY_ERROR_FAILED => Self::Failed,
            value => Self::__Unknown(value),
        }
    }
}

impl glib::error::ErrorDomain for PlayError {
    #[inline]
    fn domain() -> glib::Quark {
        skip_assert_initialized!();

        unsafe { from_glib(ffi::gst_play_error_quark()) }
    }

    #[inline]
    fn code(self) -> i32 {
        self.into_glib()
    }

    #[inline]
    #[allow(clippy::match_single_binding)]
    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match unsafe { from_glib(code) } {
            Self::__Unknown(_) => Some(Self::Failed),
            value => Some(value),
        }
    }
}

impl StaticType for PlayError {
    #[inline]
    #[doc(alias = "gst_play_error_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::gst_play_error_get_type()) }
    }
}

impl glib::HasParamSpec for PlayError {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

impl glib::value::ValueType for PlayError {
    type Type = Self;
}

unsafe impl<'a> glib::value::FromValue<'a> for PlayError {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    #[inline]
    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for PlayError {
    #[inline]
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

impl From<PlayError> for glib::Value {
    #[inline]
    fn from(v: PlayError) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GstPlayMessage")]
pub(crate) enum PlayMessage {
    /// Source element was initalized for set URI
    #[doc(alias = "GST_PLAY_MESSAGE_URI_LOADED")]
    UriLoaded,
    /// Sink position changed
    #[doc(alias = "GST_PLAY_MESSAGE_POSITION_UPDATED")]
    PositionUpdated,
    /// Duration of stream changed
    #[doc(alias = "GST_PLAY_MESSAGE_DURATION_CHANGED")]
    DurationChanged,
    /// State changed, see [`PlayState`][crate::PlayState]
    #[doc(alias = "GST_PLAY_MESSAGE_STATE_CHANGED")]
    StateChanged,
    /// Pipeline is in buffering state, message contains the percentage value of the decoding buffer
    #[doc(alias = "GST_PLAY_MESSAGE_BUFFERING")]
    Buffering,
    /// Sink has received EOS
    #[doc(alias = "GST_PLAY_MESSAGE_END_OF_STREAM")]
    EndOfStream,
    /// Message contains an error
    #[doc(alias = "GST_PLAY_MESSAGE_ERROR")]
    Error,
    /// Message contains an error
    #[doc(alias = "GST_PLAY_MESSAGE_WARNING")]
    Warning,
    /// Video sink received format in different dimensions than before
    #[doc(alias = "GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED")]
    VideoDimensionsChanged,
    /// A media-info property has changed, message contains current [`PlayMediaInfo`][crate::PlayMediaInfo]
    #[doc(alias = "GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED")]
    MediaInfoUpdated,
    /// The volume of the audio ouput has changed
    #[doc(alias = "GST_PLAY_MESSAGE_VOLUME_CHANGED")]
    VolumeChanged,
    /// Audio muting flag has been toggled
    #[doc(alias = "GST_PLAY_MESSAGE_MUTE_CHANGED")]
    MuteChanged,
    /// Any pending seeking operation has been completed
    #[doc(alias = "GST_PLAY_MESSAGE_SEEK_DONE")]
    SeekDone,
    #[doc(hidden)]
    __Unknown(i32),
}

impl PlayMessage {
    pub fn name<'a>(self) -> &'a GStr {
        unsafe {
            GStr::from_ptr(
                ffi::gst_play_message_get_name(self.into_glib())
                    .as_ref()
                    .expect("gst_play_message_get_name returned NULL"),
            )
        }
    }

    #[doc(alias = "gst_play_message_parse_buffering_percent")]
    pub fn parse_buffering_percent(msg: &gst::Message) -> u32 {
        assert_initialized_main_thread!();
        unsafe {
            let mut percent = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_buffering_percent(
                msg.to_glib_none().0,
                percent.as_mut_ptr(),
            );
            percent.assume_init()
        }
    }

    #[doc(alias = "gst_play_message_parse_duration_updated")]
    pub fn parse_duration_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
        assert_initialized_main_thread!();
        unsafe {
            let mut duration = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_duration_updated(
                msg.to_glib_none().0,
                duration.as_mut_ptr(),
            );
            from_glib(duration.assume_init())
        }
    }

    #[doc(alias = "gst_play_message_parse_error")]
    pub fn parse_error(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
        assert_initialized_main_thread!();
        unsafe {
            let mut error = std::ptr::null_mut();
            let mut details = std::ptr::null_mut();
            ffi::gst_play_message_parse_error(msg.to_glib_none().0, &mut error, &mut details);
            (from_glib_full(error), from_glib_full(details))
        }
    }

    #[doc(alias = "gst_play_message_parse_media_info_updated")]
    pub fn parse_media_info_updated(msg: &gst::Message) -> PlayMediaInfo {
        assert_initialized_main_thread!();
        unsafe {
            let mut info = std::ptr::null_mut();
            ffi::gst_play_message_parse_media_info_updated(msg.to_glib_none().0, &mut info);
            from_glib_full(info)
        }
    }

    #[doc(alias = "gst_play_message_parse_muted_changed")]
    pub fn parse_muted_changed(msg: &gst::Message) -> bool {
        assert_initialized_main_thread!();
        unsafe {
            let mut muted = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_muted_changed(msg.to_glib_none().0, muted.as_mut_ptr());
            from_glib(muted.assume_init())
        }
    }

    #[doc(alias = "gst_play_message_parse_position_updated")]
    pub fn parse_position_updated(msg: &gst::Message) -> Option<gst::ClockTime> {
        assert_initialized_main_thread!();
        unsafe {
            let mut position = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_position_updated(
                msg.to_glib_none().0,
                position.as_mut_ptr(),
            );
            from_glib(position.assume_init())
        }
    }

    #[doc(alias = "gst_play_message_parse_state_changed")]
    pub fn parse_state_changed(msg: &gst::Message) -> PlayState {
        assert_initialized_main_thread!();
        unsafe {
            let mut state = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_state_changed(msg.to_glib_none().0, state.as_mut_ptr());
            from_glib(state.assume_init())
        }
    }

    #[doc(alias = "gst_play_message_parse_type")]
    pub fn parse_type(msg: &gst::Message) -> PlayMessage {
        assert_initialized_main_thread!();
        unsafe {
            let mut type_ = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_type(msg.to_glib_none().0, type_.as_mut_ptr());
            from_glib(type_.assume_init())
        }
    }

    #[doc(alias = "gst_play_message_parse_video_dimensions_changed")]
    pub fn parse_video_dimensions_changed(msg: &gst::Message) -> (u32, u32) {
        assert_initialized_main_thread!();
        unsafe {
            let mut width = std::mem::MaybeUninit::uninit();
            let mut height = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_video_dimensions_changed(
                msg.to_glib_none().0,
                width.as_mut_ptr(),
                height.as_mut_ptr(),
            );
            (width.assume_init(), height.assume_init())
        }
    }

    #[doc(alias = "gst_play_message_parse_volume_changed")]
    pub fn parse_volume_changed(msg: &gst::Message) -> f64 {
        assert_initialized_main_thread!();
        unsafe {
            let mut volume = std::mem::MaybeUninit::uninit();
            ffi::gst_play_message_parse_volume_changed(msg.to_glib_none().0, volume.as_mut_ptr());
            volume.assume_init()
        }
    }

    #[doc(alias = "gst_play_message_parse_warning")]
    pub fn parse_warning(msg: &gst::Message) -> (glib::Error, Option<gst::Structure>) {
        assert_initialized_main_thread!();
        unsafe {
            let mut error = std::ptr::null_mut();
            let mut details = std::ptr::null_mut();
            ffi::gst_play_message_parse_warning(msg.to_glib_none().0, &mut error, &mut details);
            (from_glib_full(error), from_glib_full(details))
        }
    }
}

impl std::fmt::Display for PlayMessage {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.name())
    }
}

#[doc(hidden)]
impl IntoGlib for PlayMessage {
    type GlibType = ffi::GstPlayMessage;

    fn into_glib(self) -> ffi::GstPlayMessage {
        match self {
            Self::UriLoaded => ffi::GST_PLAY_MESSAGE_URI_LOADED,
            Self::PositionUpdated => ffi::GST_PLAY_MESSAGE_POSITION_UPDATED,
            Self::DurationChanged => ffi::GST_PLAY_MESSAGE_DURATION_CHANGED,
            Self::StateChanged => ffi::GST_PLAY_MESSAGE_STATE_CHANGED,
            Self::Buffering => ffi::GST_PLAY_MESSAGE_BUFFERING,
            Self::EndOfStream => ffi::GST_PLAY_MESSAGE_END_OF_STREAM,
            Self::Error => ffi::GST_PLAY_MESSAGE_ERROR,
            Self::Warning => ffi::GST_PLAY_MESSAGE_WARNING,
            Self::VideoDimensionsChanged => ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED,
            Self::MediaInfoUpdated => ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED,
            Self::VolumeChanged => ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED,
            Self::MuteChanged => ffi::GST_PLAY_MESSAGE_MUTE_CHANGED,
            Self::SeekDone => ffi::GST_PLAY_MESSAGE_SEEK_DONE,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GstPlayMessage> for PlayMessage {
    unsafe fn from_glib(value: ffi::GstPlayMessage) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::GST_PLAY_MESSAGE_URI_LOADED => Self::UriLoaded,
            ffi::GST_PLAY_MESSAGE_POSITION_UPDATED => Self::PositionUpdated,
            ffi::GST_PLAY_MESSAGE_DURATION_CHANGED => Self::DurationChanged,
            ffi::GST_PLAY_MESSAGE_STATE_CHANGED => Self::StateChanged,
            ffi::GST_PLAY_MESSAGE_BUFFERING => Self::Buffering,
            ffi::GST_PLAY_MESSAGE_END_OF_STREAM => Self::EndOfStream,
            ffi::GST_PLAY_MESSAGE_ERROR => Self::Error,
            ffi::GST_PLAY_MESSAGE_WARNING => Self::Warning,
            ffi::GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED => Self::VideoDimensionsChanged,
            ffi::GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED => Self::MediaInfoUpdated,
            ffi::GST_PLAY_MESSAGE_VOLUME_CHANGED => Self::VolumeChanged,
            ffi::GST_PLAY_MESSAGE_MUTE_CHANGED => Self::MuteChanged,
            ffi::GST_PLAY_MESSAGE_SEEK_DONE => Self::SeekDone,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for PlayMessage {
    #[inline]
    #[doc(alias = "gst_play_message_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::gst_play_message_get_type()) }
    }
}

impl glib::HasParamSpec for PlayMessage {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

impl glib::value::ValueType for PlayMessage {
    type Type = Self;
}

unsafe impl<'a> glib::value::FromValue<'a> for PlayMessage {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    #[inline]
    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for PlayMessage {
    #[inline]
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

impl From<PlayMessage> for glib::Value {
    #[inline]
    fn from(v: PlayMessage) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GstPlaySnapshotFormat")]
pub enum PlaySnapshotFormat {
    /// raw native format.
    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_NATIVE")]
    RawNative,
    /// raw xRGB format.
    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_xRGB")]
    RawXrgb,
    /// raw BGRx format.
    #[doc(alias = "GST_PLAY_THUMBNAIL_RAW_BGRx")]
    RawBgrx,
    /// jpeg format.
    #[doc(alias = "GST_PLAY_THUMBNAIL_JPG")]
    Jpg,
    /// png format.
    #[doc(alias = "GST_PLAY_THUMBNAIL_PNG")]
    Png,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl IntoGlib for PlaySnapshotFormat {
    type GlibType = ffi::GstPlaySnapshotFormat;

    #[inline]
    fn into_glib(self) -> ffi::GstPlaySnapshotFormat {
        match self {
            Self::RawNative => ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE,
            Self::RawXrgb => ffi::GST_PLAY_THUMBNAIL_RAW_xRGB,
            Self::RawBgrx => ffi::GST_PLAY_THUMBNAIL_RAW_BGRx,
            Self::Jpg => ffi::GST_PLAY_THUMBNAIL_JPG,
            Self::Png => ffi::GST_PLAY_THUMBNAIL_PNG,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GstPlaySnapshotFormat> for PlaySnapshotFormat {
    #[inline]
    unsafe fn from_glib(value: ffi::GstPlaySnapshotFormat) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::GST_PLAY_THUMBNAIL_RAW_NATIVE => Self::RawNative,
            ffi::GST_PLAY_THUMBNAIL_RAW_xRGB => Self::RawXrgb,
            ffi::GST_PLAY_THUMBNAIL_RAW_BGRx => Self::RawBgrx,
            ffi::GST_PLAY_THUMBNAIL_JPG => Self::Jpg,
            ffi::GST_PLAY_THUMBNAIL_PNG => Self::Png,
            value => Self::__Unknown(value),
        }
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GstPlayState")]
pub enum PlayState {
    /// the play is stopped.
    #[doc(alias = "GST_PLAY_STATE_STOPPED")]
    Stopped,
    /// the play is buffering.
    #[doc(alias = "GST_PLAY_STATE_BUFFERING")]
    Buffering,
    /// the play is paused.
    #[doc(alias = "GST_PLAY_STATE_PAUSED")]
    Paused,
    /// the play is currently playing a
    /// stream.
    #[doc(alias = "GST_PLAY_STATE_PLAYING")]
    Playing,
    #[doc(hidden)]
    __Unknown(i32),
}

impl PlayState {
    pub fn name<'a>(self) -> &'a GStr {
        unsafe {
            GStr::from_ptr(
                ffi::gst_play_state_get_name(self.into_glib())
                    .as_ref()
                    .expect("gst_play_state_get_name returned NULL"),
            )
        }
    }
}

impl std::fmt::Display for PlayState {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(&self.name())
    }
}

#[doc(hidden)]
impl IntoGlib for PlayState {
    type GlibType = ffi::GstPlayState;

    #[inline]
    fn into_glib(self) -> ffi::GstPlayState {
        match self {
            Self::Stopped => ffi::GST_PLAY_STATE_STOPPED,
            Self::Buffering => ffi::GST_PLAY_STATE_BUFFERING,
            Self::Paused => ffi::GST_PLAY_STATE_PAUSED,
            Self::Playing => ffi::GST_PLAY_STATE_PLAYING,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GstPlayState> for PlayState {
    #[inline]
    unsafe fn from_glib(value: ffi::GstPlayState) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::GST_PLAY_STATE_STOPPED => Self::Stopped,
            ffi::GST_PLAY_STATE_BUFFERING => Self::Buffering,
            ffi::GST_PLAY_STATE_PAUSED => Self::Paused,
            ffi::GST_PLAY_STATE_PLAYING => Self::Playing,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for PlayState {
    #[inline]
    #[doc(alias = "gst_play_state_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::gst_play_state_get_type()) }
    }
}

impl glib::HasParamSpec for PlayState {
    type ParamSpec = glib::ParamSpecEnum;
    type SetValue = Self;
    type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder_with_default
    }
}

impl glib::value::ValueType for PlayState {
    type Type = Self;
}

unsafe impl<'a> glib::value::FromValue<'a> for PlayState {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    #[inline]
    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for PlayState {
    #[inline]
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

impl From<PlayState> for glib::Value {
    #[inline]
    fn from(v: PlayState) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}