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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    /// [`MediaStream`][crate::MediaStream] is the integration point for media playback inside GTK.
    ///
    /// GTK provides an implementation of the [`MediaStream`][crate::MediaStream] interface that
    /// is called [`MediaFile`][crate::MediaFile].
    ///
    /// Apart from application-facing API for stream playback, [`MediaStream`][crate::MediaStream]
    /// has a number of APIs that are only useful for implementations and should
    /// not be used in applications:
    /// [`MediaStreamExt::prepared()`][crate::prelude::MediaStreamExt::prepared()],
    /// [`MediaStreamExt::unprepared()`][crate::prelude::MediaStreamExt::unprepared()],
    /// [`MediaStreamExt::update()`][crate::prelude::MediaStreamExt::update()],
    /// [`MediaStreamExt::ended()`][crate::prelude::MediaStreamExt::ended()],
    /// [`MediaStreamExt::seek_success()`][crate::prelude::MediaStreamExt::seek_success()],
    /// [`MediaStreamExt::seek_failed()`][crate::prelude::MediaStreamExt::seek_failed()],
    /// [`MediaStreamExtManual::set_error()`][crate::prelude::MediaStreamExtManual::set_error()],
    /// `Gtk::MediaStream::error()`,
    /// `Gtk::MediaStream::error_valist()`.
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// # Implements
    ///
    /// [`MediaStreamExt`][trait@crate::prelude::MediaStreamExt], [`trait@glib::ObjectExt`], [`trait@gdk::prelude::PaintableExt`], [`MediaStreamExtManual`][trait@crate::prelude::MediaStreamExtManual]
    #[doc(alias = "GtkMediaStream")]
    pub struct MediaStream(Object<ffi::GtkMediaStream, ffi::GtkMediaStreamClass>) @implements gdk::Paintable;

    match fn {
        type_ => || ffi::gtk_media_stream_get_type(),
    }
}

impl MediaStream {
    pub const NONE: Option<&'static MediaStream> = None;
}

/// Trait containing all [`struct@MediaStream`] methods.
///
/// # Implementors
///
/// [`MediaFile`][struct@crate::MediaFile], [`MediaStream`][struct@crate::MediaStream]
pub trait MediaStreamExt: 'static {
    /// Pauses the media stream and marks it as ended.
    ///
    /// This is a hint only, calls to [`play()`][Self::play()]
    /// may still happen.
    ///
    /// The media stream must be prepared when this function is called.
    ///
    /// # Deprecated since 4.4
    ///
    /// Use [`stream_ended()`][Self::stream_ended()] instead
    #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
    #[doc(alias = "gtk_media_stream_ended")]
    fn ended(&self);

    /// Gets the duration of the stream.
    ///
    /// If the duration is not known, 0 will be returned.
    ///
    /// # Returns
    ///
    /// the duration of the stream or 0 if not known.
    #[doc(alias = "gtk_media_stream_get_duration")]
    #[doc(alias = "get_duration")]
    fn duration(&self) -> i64;

    /// Returns whether the streams playback is finished.
    ///
    /// # Returns
    ///
    /// [`true`] if playback is finished
    #[doc(alias = "gtk_media_stream_get_ended")]
    #[doc(alias = "get_ended")]
    fn is_ended(&self) -> bool;

    /// Sets @self into an error state using a printf()-style format string.
    ///
    /// This is a utility function that calls [`MediaStreamExtManual::set_error()`][crate::prelude::MediaStreamExtManual::set_error()].
    /// See that function for details.
    /// ## `domain`
    /// error domain
    /// ## `code`
    /// error code
    /// ## `format`
    /// printf()-style format for error message
    #[doc(alias = "gtk_media_stream_get_error")]
    #[doc(alias = "get_error")]
    fn error(&self) -> Option<glib::Error>;

    /// Returns whether the stream is set to loop.
    ///
    /// See [`set_loop()`][Self::set_loop()] for details.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream should loop
    #[doc(alias = "gtk_media_stream_get_loop")]
    #[doc(alias = "get_loop")]
    fn is_loop(&self) -> bool;

    /// Returns whether the audio for the stream is muted.
    ///
    /// See [`set_muted()`][Self::set_muted()] for details.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream is muted
    #[doc(alias = "gtk_media_stream_get_muted")]
    #[doc(alias = "get_muted")]
    fn is_muted(&self) -> bool;

    /// Return whether the stream is currently playing.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream is playing
    #[doc(alias = "gtk_media_stream_get_playing")]
    #[doc(alias = "get_playing")]
    fn is_playing(&self) -> bool;

    /// Returns the current presentation timestamp in microseconds.
    ///
    /// # Returns
    ///
    /// the timestamp in microseconds
    #[doc(alias = "gtk_media_stream_get_timestamp")]
    #[doc(alias = "get_timestamp")]
    fn timestamp(&self) -> i64;

    /// Returns the volume of the audio for the stream.
    ///
    /// See [`set_volume()`][Self::set_volume()] for details.
    ///
    /// # Returns
    ///
    /// volume of the stream from 0.0 to 1.0
    #[doc(alias = "gtk_media_stream_get_volume")]
    #[doc(alias = "get_volume")]
    fn volume(&self) -> f64;

    /// Returns whether the stream has audio.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream has audio
    #[doc(alias = "gtk_media_stream_has_audio")]
    fn has_audio(&self) -> bool;

    /// Returns whether the stream has video.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream has video
    #[doc(alias = "gtk_media_stream_has_video")]
    fn has_video(&self) -> bool;

    /// Returns whether the stream has finished initializing.
    ///
    /// At this point the existence of audio and video is known.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream is prepared
    #[doc(alias = "gtk_media_stream_is_prepared")]
    fn is_prepared(&self) -> bool;

    /// Checks if a stream may be seekable.
    ///
    /// This is meant to be a hint. Streams may not allow seeking even if
    /// this function returns [`true`]. However, if this function returns
    /// [`false`], streams are guaranteed to not be seekable and user interfaces
    /// may hide controls that allow seeking.
    ///
    /// It is allowed to call [`seek()`][Self::seek()] on a non-seekable
    /// stream, though it will not do anything.
    ///
    /// # Returns
    ///
    /// [`true`] if the stream may support seeking
    #[doc(alias = "gtk_media_stream_is_seekable")]
    fn is_seekable(&self) -> bool;

    /// Checks if there is currently a seek operation going on.
    ///
    /// # Returns
    ///
    /// [`true`] if a seek operation is ongoing.
    #[doc(alias = "gtk_media_stream_is_seeking")]
    fn is_seeking(&self) -> bool;

    /// Pauses playback of the stream.
    ///
    /// If the stream is not playing, do nothing.
    #[doc(alias = "gtk_media_stream_pause")]
    fn pause(&self);

    /// Starts playing the stream.
    ///
    /// If the stream is in error or already playing, do nothing.
    #[doc(alias = "gtk_media_stream_play")]
    fn play(&self);

    /// Same as gtk_media_stream_stream_prepared().
    ///
    /// # Deprecated since 4.4
    ///
    /// Use [`stream_prepared()`][Self::stream_prepared()] instead.
    /// ## `has_audio`
    /// [`true`] if the stream should advertise audio support
    /// ## `has_video`
    /// [`true`] if the stream should advertise video support
    /// ## `seekable`
    /// [`true`] if the stream should advertise seekability
    /// ## `duration`
    /// The duration of the stream or 0 if unknown
    #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
    #[doc(alias = "gtk_media_stream_prepared")]
    fn prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64);

    /// Called by users to attach the media stream to a [`gdk::Surface`][crate::gdk::Surface] they manage.
    ///
    /// The stream can then access the resources of @surface for its
    /// rendering purposes. In particular, media streams might want to
    /// create a [`gdk::GLContext`][crate::gdk::GLContext] or sync to the [`gdk::FrameClock`][crate::gdk::FrameClock].
    ///
    /// Whoever calls this function is responsible for calling
    /// [`unrealize()`][Self::unrealize()] before either the stream
    /// or @surface get destroyed.
    ///
    /// Multiple calls to this function may happen from different
    /// users of the video, even with the same @surface. Each of these
    /// calls must be followed by its own call to
    /// [`unrealize()`][Self::unrealize()].
    ///
    /// It is not required to call this function to make a media stream work.
    /// ## `surface`
    /// a [`gdk::Surface`][crate::gdk::Surface]
    #[doc(alias = "gtk_media_stream_realize")]
    fn realize(&self, surface: &impl IsA<gdk::Surface>);

    /// Start a seek operation on @self to @timestamp.
    ///
    /// If @timestamp is out of range, it will be clamped.
    ///
    /// Seek operations may not finish instantly. While a
    /// seek operation is in process, the `property::MediaStream::seeking`
    /// property will be set.
    ///
    /// When calling gtk_media_stream_seek() during an
    /// ongoing seek operation, the new seek will override
    /// any pending seek.
    /// ## `timestamp`
    /// timestamp to seek to.
    #[doc(alias = "gtk_media_stream_seek")]
    fn seek(&self, timestamp: i64);

    /// Ends a seek operation started via GtkMediaStream.seek() as a failure.
    ///
    /// This will not cause an error on the stream and will assume that
    /// playback continues as if no seek had happened.
    ///
    /// See [`seek_success()`][Self::seek_success()] for the other way of
    /// ending a seek.
    #[doc(alias = "gtk_media_stream_seek_failed")]
    fn seek_failed(&self);

    /// Ends a seek operation started via GtkMediaStream.seek() successfully.
    ///
    /// This function will unset the GtkMediaStream:ended property
    /// if it was set.
    ///
    /// See [`seek_failed()`][Self::seek_failed()] for the other way of
    /// ending a seek.
    #[doc(alias = "gtk_media_stream_seek_success")]
    fn seek_success(&self);

    /// Sets whether the stream should loop.
    ///
    /// In this case, it will attempt to restart playback
    /// from the beginning instead of stopping at the end.
    ///
    /// Not all streams may support looping, in particular
    /// non-seekable streams. Those streams will ignore the
    /// loop setting and just end.
    /// ## `loop_`
    /// [`true`] if the stream should loop
    #[doc(alias = "gtk_media_stream_set_loop")]
    fn set_loop(&self, loop_: bool);

    /// Sets whether the audio stream should be muted.
    ///
    /// Muting a stream will cause no audio to be played, but it
    /// does not modify the volume. This means that muting and
    /// then unmuting the stream will restore the volume settings.
    ///
    /// If the stream has no audio, calling this function will
    /// still work but it will not have an audible effect.
    /// ## `muted`
    /// [`true`] if the stream should be muted
    #[doc(alias = "gtk_media_stream_set_muted")]
    fn set_muted(&self, muted: bool);

    /// Starts or pauses playback of the stream.
    /// ## `playing`
    /// whether to start or pause playback
    #[doc(alias = "gtk_media_stream_set_playing")]
    fn set_playing(&self, playing: bool);

    /// Sets the volume of the audio stream.
    ///
    /// This function call will work even if the stream is muted.
    ///
    /// The given @volume should range from 0.0 for silence to 1.0
    /// for as loud as possible. Values outside of this range will
    /// be clamped to the nearest value.
    ///
    /// If the stream has no audio or is muted, calling this function
    /// will still work but it will not have an immediate audible effect.
    /// When the stream is unmuted, the new volume setting will take effect.
    /// ## `volume`
    /// New volume of the stream from 0.0 to 1.0
    #[doc(alias = "gtk_media_stream_set_volume")]
    fn set_volume(&self, volume: f64);

    /// Pauses the media stream and marks it as ended.
    ///
    /// This is a hint only, calls to [`play()`][Self::play()]
    /// may still happen.
    ///
    /// The media stream must be prepared when this function is called.
    #[cfg(any(feature = "v4_4", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v4_4")))]
    #[doc(alias = "gtk_media_stream_stream_ended")]
    fn stream_ended(&self);

    /// Called by [`MediaStream`][crate::MediaStream] implementations to advertise the stream
    /// being ready to play and providing details about the stream.
    ///
    /// Note that the arguments are hints. If the stream implementation
    /// cannot determine the correct values, it is better to err on the
    /// side of caution and return [`true`]. User interfaces will use those
    /// values to determine what controls to show.
    ///
    /// This function may not be called again until the stream has been
    /// reset via [`stream_unprepared()`][Self::stream_unprepared()].
    /// ## `has_audio`
    /// [`true`] if the stream should advertise audio support
    /// ## `has_video`
    /// [`true`] if the stream should advertise video support
    /// ## `seekable`
    /// [`true`] if the stream should advertise seekability
    /// ## `duration`
    /// The duration of the stream or 0 if unknown
    #[cfg(any(feature = "v4_4", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v4_4")))]
    #[doc(alias = "gtk_media_stream_stream_prepared")]
    fn stream_prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64);

    /// Resets a given media stream implementation.
    ///
    /// [`stream_prepared()`][Self::stream_prepared()] can then be called again.
    ///
    /// This function will also reset any error state the stream was in.
    #[cfg(any(feature = "v4_4", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v4_4")))]
    #[doc(alias = "gtk_media_stream_stream_unprepared")]
    fn stream_unprepared(&self);

    /// Same as gtk_media_stream_stream_unprepared().
    ///
    /// # Deprecated since 4.4
    ///
    /// Use [`stream_unprepared()`][Self::stream_unprepared()] instead.
    #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
    #[doc(alias = "gtk_media_stream_unprepared")]
    fn unprepared(&self);

    /// Undoes a previous call to gtk_media_stream_realize().
    ///
    /// This causes the stream to release all resources it had
    /// allocated from @surface.
    /// ## `surface`
    /// the [`gdk::Surface`][crate::gdk::Surface] the stream was realized with
    #[doc(alias = "gtk_media_stream_unrealize")]
    fn unrealize(&self, surface: &impl IsA<gdk::Surface>);

    /// Media stream implementations should regularly call this
    /// function to update the timestamp reported by the stream.
    ///
    /// It is up to implementations to call this at the frequency
    /// they deem appropriate.
    ///
    /// The media stream must be prepared when this function is called.
    /// ## `timestamp`
    /// the new timestamp
    #[doc(alias = "gtk_media_stream_update")]
    fn update(&self, timestamp: i64);

    /// Whether the stream has finished initializing and existence of
    /// audio and video is known.
    fn set_prepared(&self, prepared: bool);

    #[doc(alias = "duration")]
    fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "ended")]
    fn connect_ended_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "error")]
    fn connect_error_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "has-audio")]
    fn connect_has_audio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "has-video")]
    fn connect_has_video_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "loop")]
    fn connect_loop_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "muted")]
    fn connect_muted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "playing")]
    fn connect_playing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "prepared")]
    fn connect_prepared_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "seekable")]
    fn connect_seekable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "seeking")]
    fn connect_seeking_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "timestamp")]
    fn connect_timestamp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "volume")]
    fn connect_volume_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<MediaStream>> MediaStreamExt for O {
    fn ended(&self) {
        unsafe {
            ffi::gtk_media_stream_ended(self.as_ref().to_glib_none().0);
        }
    }

    fn duration(&self) -> i64 {
        unsafe { ffi::gtk_media_stream_get_duration(self.as_ref().to_glib_none().0) }
    }

    fn is_ended(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_get_ended(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn error(&self) -> Option<glib::Error> {
        unsafe {
            from_glib_none(ffi::gtk_media_stream_get_error(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_loop(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_get_loop(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_muted(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_get_muted(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_playing(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_get_playing(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn timestamp(&self) -> i64 {
        unsafe { ffi::gtk_media_stream_get_timestamp(self.as_ref().to_glib_none().0) }
    }

    fn volume(&self) -> f64 {
        unsafe { ffi::gtk_media_stream_get_volume(self.as_ref().to_glib_none().0) }
    }

    fn has_audio(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_has_audio(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn has_video(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_has_video(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_prepared(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_is_prepared(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_seekable(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_is_seekable(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_seeking(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_media_stream_is_seeking(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn pause(&self) {
        unsafe {
            ffi::gtk_media_stream_pause(self.as_ref().to_glib_none().0);
        }
    }

    fn play(&self) {
        unsafe {
            ffi::gtk_media_stream_play(self.as_ref().to_glib_none().0);
        }
    }

    fn prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64) {
        unsafe {
            ffi::gtk_media_stream_prepared(
                self.as_ref().to_glib_none().0,
                has_audio.into_glib(),
                has_video.into_glib(),
                seekable.into_glib(),
                duration,
            );
        }
    }

    fn realize(&self, surface: &impl IsA<gdk::Surface>) {
        unsafe {
            ffi::gtk_media_stream_realize(
                self.as_ref().to_glib_none().0,
                surface.as_ref().to_glib_none().0,
            );
        }
    }

    fn seek(&self, timestamp: i64) {
        unsafe {
            ffi::gtk_media_stream_seek(self.as_ref().to_glib_none().0, timestamp);
        }
    }

    fn seek_failed(&self) {
        unsafe {
            ffi::gtk_media_stream_seek_failed(self.as_ref().to_glib_none().0);
        }
    }

    fn seek_success(&self) {
        unsafe {
            ffi::gtk_media_stream_seek_success(self.as_ref().to_glib_none().0);
        }
    }

    fn set_loop(&self, loop_: bool) {
        unsafe {
            ffi::gtk_media_stream_set_loop(self.as_ref().to_glib_none().0, loop_.into_glib());
        }
    }

    fn set_muted(&self, muted: bool) {
        unsafe {
            ffi::gtk_media_stream_set_muted(self.as_ref().to_glib_none().0, muted.into_glib());
        }
    }

    fn set_playing(&self, playing: bool) {
        unsafe {
            ffi::gtk_media_stream_set_playing(self.as_ref().to_glib_none().0, playing.into_glib());
        }
    }

    fn set_volume(&self, volume: f64) {
        unsafe {
            ffi::gtk_media_stream_set_volume(self.as_ref().to_glib_none().0, volume);
        }
    }

    #[cfg(any(feature = "v4_4", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v4_4")))]
    fn stream_ended(&self) {
        unsafe {
            ffi::gtk_media_stream_stream_ended(self.as_ref().to_glib_none().0);
        }
    }

    #[cfg(any(feature = "v4_4", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v4_4")))]
    fn stream_prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64) {
        unsafe {
            ffi::gtk_media_stream_stream_prepared(
                self.as_ref().to_glib_none().0,
                has_audio.into_glib(),
                has_video.into_glib(),
                seekable.into_glib(),
                duration,
            );
        }
    }

    #[cfg(any(feature = "v4_4", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v4_4")))]
    fn stream_unprepared(&self) {
        unsafe {
            ffi::gtk_media_stream_stream_unprepared(self.as_ref().to_glib_none().0);
        }
    }

    fn unprepared(&self) {
        unsafe {
            ffi::gtk_media_stream_unprepared(self.as_ref().to_glib_none().0);
        }
    }

    fn unrealize(&self, surface: &impl IsA<gdk::Surface>) {
        unsafe {
            ffi::gtk_media_stream_unrealize(
                self.as_ref().to_glib_none().0,
                surface.as_ref().to_glib_none().0,
            );
        }
    }

    fn update(&self, timestamp: i64) {
        unsafe {
            ffi::gtk_media_stream_update(self.as_ref().to_glib_none().0, timestamp);
        }
    }

    fn set_prepared(&self, prepared: bool) {
        glib::ObjectExt::set_property(self.as_ref(), "prepared", &prepared)
    }

    fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_duration_trampoline<
            P: IsA<MediaStream>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::duration\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_duration_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_ended_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_ended_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::ended\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_ended_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_error_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_error_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::error\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_error_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_has_audio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_has_audio_trampoline<
            P: IsA<MediaStream>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::has-audio\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_has_audio_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_has_video_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_has_video_trampoline<
            P: IsA<MediaStream>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::has-video\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_has_video_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_loop_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_loop_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::loop\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_loop_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_muted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_muted_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::muted\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_muted_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_playing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_playing_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::playing\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_playing_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_prepared_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_prepared_trampoline<
            P: IsA<MediaStream>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::prepared\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_prepared_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_seekable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_seekable_trampoline<
            P: IsA<MediaStream>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::seekable\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_seekable_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_seeking_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_seeking_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::seeking\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_seeking_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_timestamp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_timestamp_trampoline<
            P: IsA<MediaStream>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::timestamp\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_timestamp_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_volume_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_volume_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
            this: *mut ffi::GtkMediaStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::volume\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_volume_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for MediaStream {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("MediaStream")
    }
}