gtk4/auto/media_stream.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// DO NOT EDIT
4#![allow(deprecated)]
5
6use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// The integration point for media playback inside GTK.
16 ///
17 /// GTK provides an implementation of the [`MediaStream`][crate::MediaStream] interface that
18 /// is called [`MediaFile`][crate::MediaFile].
19 ///
20 /// Apart from application-facing API for stream playback, [`MediaStream`][crate::MediaStream]
21 /// has a number of APIs that are only useful for implementations and should
22 /// not be used in applications:
23 /// [`MediaStreamExt::prepared()`][crate::prelude::MediaStreamExt::prepared()],
24 /// [`MediaStreamExt::unprepared()`][crate::prelude::MediaStreamExt::unprepared()],
25 /// [`MediaStreamExt::update()`][crate::prelude::MediaStreamExt::update()],
26 /// [`MediaStreamExt::ended()`][crate::prelude::MediaStreamExt::ended()],
27 /// [`MediaStreamExt::seek_success()`][crate::prelude::MediaStreamExt::seek_success()],
28 /// [`MediaStreamExt::seek_failed()`][crate::prelude::MediaStreamExt::seek_failed()],
29 /// [`MediaStreamExtManual::set_error()`][crate::prelude::MediaStreamExtManual::set_error()],
30 /// `Gtk::MediaStream::error()`,
31 /// `Gtk::MediaStream::error_valist()`.
32 ///
33 /// This is an Abstract Base Class, you cannot instantiate it.
34 ///
35 /// ## Properties
36 ///
37 ///
38 /// #### `duration`
39 /// The stream's duration in microseconds or 0 if unknown.
40 ///
41 /// Readable
42 ///
43 ///
44 /// #### `ended`
45 /// Set when playback has finished.
46 ///
47 /// Readable
48 ///
49 ///
50 /// #### `error`
51 /// [`None`] for a properly working stream or the `GError`
52 /// that the stream is in.
53 ///
54 /// Readable
55 ///
56 ///
57 /// #### `has-audio`
58 /// Whether the stream contains audio.
59 ///
60 /// Readable
61 ///
62 ///
63 /// #### `has-video`
64 /// Whether the stream contains video.
65 ///
66 /// Readable
67 ///
68 ///
69 /// #### `loop`
70 /// Try to restart the media from the beginning once it ended.
71 ///
72 /// Readable | Writeable
73 ///
74 ///
75 /// #### `muted`
76 /// Whether the audio stream should be muted.
77 ///
78 /// Readable | Writeable
79 ///
80 ///
81 /// #### `playing`
82 /// Whether the stream is currently playing.
83 ///
84 /// Readable | Writeable
85 ///
86 ///
87 /// #### `prepared`
88 /// Whether the stream has finished initializing and existence of
89 /// audio and video is known.
90 ///
91 /// Readable
92 ///
93 ///
94 /// #### `seekable`
95 /// Set unless the stream is known to not support seeking.
96 ///
97 /// Readable
98 ///
99 ///
100 /// #### `seeking`
101 /// Set while a seek is in progress.
102 ///
103 /// Readable
104 ///
105 ///
106 /// #### `timestamp`
107 /// The current presentation timestamp in microseconds.
108 ///
109 /// Readable
110 ///
111 ///
112 /// #### `volume`
113 /// Volume of the audio stream.
114 ///
115 /// Readable | Writeable
116 ///
117 /// # Implements
118 ///
119 /// [`MediaStreamExt`][trait@crate::prelude::MediaStreamExt], [`trait@glib::ObjectExt`], [`trait@gdk::prelude::PaintableExt`], [`MediaStreamExtManual`][trait@crate::prelude::MediaStreamExtManual]
120 #[doc(alias = "GtkMediaStream")]
121 pub struct MediaStream(Object<ffi::GtkMediaStream, ffi::GtkMediaStreamClass>) @implements gdk::Paintable;
122
123 match fn {
124 type_ => || ffi::gtk_media_stream_get_type(),
125 }
126}
127
128impl MediaStream {
129 pub const NONE: Option<&'static MediaStream> = None;
130}
131
132/// Trait containing all [`struct@MediaStream`] methods.
133///
134/// # Implementors
135///
136/// [`MediaFile`][struct@crate::MediaFile], [`MediaStream`][struct@crate::MediaStream]
137pub trait MediaStreamExt: IsA<MediaStream> + 'static {
138 /// Pauses the media stream and marks it as ended.
139 ///
140 /// This is a hint only, calls to [`play()`][Self::play()]
141 /// may still happen.
142 ///
143 /// The media stream must be prepared when this function is called.
144 ///
145 /// # Deprecated since 4.4
146 ///
147 /// Use [`stream_ended()`][Self::stream_ended()] instead
148 #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
149 #[allow(deprecated)]
150 #[doc(alias = "gtk_media_stream_ended")]
151 fn ended(&self) {
152 unsafe {
153 ffi::gtk_media_stream_ended(self.as_ref().to_glib_none().0);
154 }
155 }
156
157 /// Gets the duration of the stream.
158 ///
159 /// If the duration is not known, 0 will be returned.
160 ///
161 /// # Returns
162 ///
163 /// the duration of the stream or 0 if not known.
164 #[doc(alias = "gtk_media_stream_get_duration")]
165 #[doc(alias = "get_duration")]
166 fn duration(&self) -> i64 {
167 unsafe { ffi::gtk_media_stream_get_duration(self.as_ref().to_glib_none().0) }
168 }
169
170 /// Returns whether the streams playback is finished.
171 ///
172 /// # Returns
173 ///
174 /// [`true`] if playback is finished
175 #[doc(alias = "gtk_media_stream_get_ended")]
176 #[doc(alias = "get_ended")]
177 #[doc(alias = "ended")]
178 fn is_ended(&self) -> bool {
179 unsafe {
180 from_glib(ffi::gtk_media_stream_get_ended(
181 self.as_ref().to_glib_none().0,
182 ))
183 }
184 }
185
186 /// If the stream is in an error state, returns the `GError`
187 /// explaining that state.
188 ///
189 /// Any type of error can be reported here depending on the
190 /// implementation of the media stream.
191 ///
192 /// A media stream in an error cannot be operated on, calls
193 /// like [`play()`][Self::play()] or
194 /// [`seek()`][Self::seek()] will not have any effect.
195 ///
196 /// [`MediaStream`][crate::MediaStream] itself does not provide a way to unset
197 /// an error, but implementations may provide options. For example,
198 /// a [`MediaFile`][crate::MediaFile] will unset errors when a new source is
199 /// set, e.g. with [`MediaFileExt::set_file()`][crate::prelude::MediaFileExt::set_file()].
200 ///
201 /// # Returns
202 ///
203 /// [`None`] if not in an
204 /// error state or the `GError` of the stream
205 #[doc(alias = "gtk_media_stream_get_error")]
206 #[doc(alias = "get_error")]
207 fn error(&self) -> Option<glib::Error> {
208 unsafe {
209 from_glib_none(ffi::gtk_media_stream_get_error(
210 self.as_ref().to_glib_none().0,
211 ))
212 }
213 }
214
215 /// Returns whether the stream is set to loop.
216 ///
217 /// See [`set_loop()`][Self::set_loop()] for details.
218 ///
219 /// # Returns
220 ///
221 /// [`true`] if the stream should loop
222 #[doc(alias = "gtk_media_stream_get_loop")]
223 #[doc(alias = "get_loop")]
224 #[doc(alias = "loop")]
225 fn is_loop(&self) -> bool {
226 unsafe {
227 from_glib(ffi::gtk_media_stream_get_loop(
228 self.as_ref().to_glib_none().0,
229 ))
230 }
231 }
232
233 /// Returns whether the audio for the stream is muted.
234 ///
235 /// See [`set_muted()`][Self::set_muted()] for details.
236 ///
237 /// # Returns
238 ///
239 /// [`true`] if the stream is muted
240 #[doc(alias = "gtk_media_stream_get_muted")]
241 #[doc(alias = "get_muted")]
242 #[doc(alias = "muted")]
243 fn is_muted(&self) -> bool {
244 unsafe {
245 from_glib(ffi::gtk_media_stream_get_muted(
246 self.as_ref().to_glib_none().0,
247 ))
248 }
249 }
250
251 /// Return whether the stream is currently playing.
252 ///
253 /// # Returns
254 ///
255 /// [`true`] if the stream is playing
256 #[doc(alias = "gtk_media_stream_get_playing")]
257 #[doc(alias = "get_playing")]
258 #[doc(alias = "playing")]
259 fn is_playing(&self) -> bool {
260 unsafe {
261 from_glib(ffi::gtk_media_stream_get_playing(
262 self.as_ref().to_glib_none().0,
263 ))
264 }
265 }
266
267 /// Returns the current presentation timestamp in microseconds.
268 ///
269 /// # Returns
270 ///
271 /// the timestamp in microseconds
272 #[doc(alias = "gtk_media_stream_get_timestamp")]
273 #[doc(alias = "get_timestamp")]
274 fn timestamp(&self) -> i64 {
275 unsafe { ffi::gtk_media_stream_get_timestamp(self.as_ref().to_glib_none().0) }
276 }
277
278 /// Returns the volume of the audio for the stream.
279 ///
280 /// See [`set_volume()`][Self::set_volume()] for details.
281 ///
282 /// # Returns
283 ///
284 /// volume of the stream from 0.0 to 1.0
285 #[doc(alias = "gtk_media_stream_get_volume")]
286 #[doc(alias = "get_volume")]
287 fn volume(&self) -> f64 {
288 unsafe { ffi::gtk_media_stream_get_volume(self.as_ref().to_glib_none().0) }
289 }
290
291 /// Returns whether the stream has audio.
292 ///
293 /// # Returns
294 ///
295 /// [`true`] if the stream has audio
296 #[doc(alias = "gtk_media_stream_has_audio")]
297 #[doc(alias = "has-audio")]
298 fn has_audio(&self) -> bool {
299 unsafe {
300 from_glib(ffi::gtk_media_stream_has_audio(
301 self.as_ref().to_glib_none().0,
302 ))
303 }
304 }
305
306 /// Returns whether the stream has video.
307 ///
308 /// # Returns
309 ///
310 /// [`true`] if the stream has video
311 #[doc(alias = "gtk_media_stream_has_video")]
312 #[doc(alias = "has-video")]
313 fn has_video(&self) -> bool {
314 unsafe {
315 from_glib(ffi::gtk_media_stream_has_video(
316 self.as_ref().to_glib_none().0,
317 ))
318 }
319 }
320
321 /// Returns whether the stream has finished initializing.
322 ///
323 /// At this point the existence of audio and video is known.
324 ///
325 /// # Returns
326 ///
327 /// [`true`] if the stream is prepared
328 #[doc(alias = "gtk_media_stream_is_prepared")]
329 #[doc(alias = "prepared")]
330 fn is_prepared(&self) -> bool {
331 unsafe {
332 from_glib(ffi::gtk_media_stream_is_prepared(
333 self.as_ref().to_glib_none().0,
334 ))
335 }
336 }
337
338 /// Checks if a stream may be seekable.
339 ///
340 /// This is meant to be a hint. Streams may not allow seeking even if
341 /// this function returns [`true`]. However, if this function returns
342 /// [`false`], streams are guaranteed to not be seekable and user interfaces
343 /// may hide controls that allow seeking.
344 ///
345 /// It is allowed to call [`seek()`][Self::seek()] on a non-seekable
346 /// stream, though it will not do anything.
347 ///
348 /// # Returns
349 ///
350 /// [`true`] if the stream may support seeking
351 #[doc(alias = "gtk_media_stream_is_seekable")]
352 #[doc(alias = "seekable")]
353 fn is_seekable(&self) -> bool {
354 unsafe {
355 from_glib(ffi::gtk_media_stream_is_seekable(
356 self.as_ref().to_glib_none().0,
357 ))
358 }
359 }
360
361 /// Checks if there is currently a seek operation going on.
362 ///
363 /// # Returns
364 ///
365 /// [`true`] if a seek operation is ongoing.
366 #[doc(alias = "gtk_media_stream_is_seeking")]
367 #[doc(alias = "seeking")]
368 fn is_seeking(&self) -> bool {
369 unsafe {
370 from_glib(ffi::gtk_media_stream_is_seeking(
371 self.as_ref().to_glib_none().0,
372 ))
373 }
374 }
375
376 /// Pauses playback of the stream.
377 ///
378 /// If the stream is not playing, do nothing.
379 #[doc(alias = "gtk_media_stream_pause")]
380 fn pause(&self) {
381 unsafe {
382 ffi::gtk_media_stream_pause(self.as_ref().to_glib_none().0);
383 }
384 }
385
386 /// Starts playing the stream.
387 ///
388 /// If the stream is in error or already playing, do nothing.
389 #[doc(alias = "gtk_media_stream_play")]
390 fn play(&self) {
391 unsafe {
392 ffi::gtk_media_stream_play(self.as_ref().to_glib_none().0);
393 }
394 }
395
396 /// Same as gtk_media_stream_stream_prepared().
397 ///
398 /// # Deprecated since 4.4
399 ///
400 /// Use [`stream_prepared()`][Self::stream_prepared()] instead.
401 /// ## `has_audio`
402 /// [`true`] if the stream should advertise audio support
403 /// ## `has_video`
404 /// [`true`] if the stream should advertise video support
405 /// ## `seekable`
406 /// [`true`] if the stream should advertise seekability
407 /// ## `duration`
408 /// The duration of the stream or 0 if unknown
409 #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
410 #[allow(deprecated)]
411 #[doc(alias = "gtk_media_stream_prepared")]
412 fn prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64) {
413 unsafe {
414 ffi::gtk_media_stream_prepared(
415 self.as_ref().to_glib_none().0,
416 has_audio.into_glib(),
417 has_video.into_glib(),
418 seekable.into_glib(),
419 duration,
420 );
421 }
422 }
423
424 /// Called by users to attach the media stream to a [`gdk::Surface`][crate::gdk::Surface] they manage.
425 ///
426 /// The stream can then access the resources of @surface for its
427 /// rendering purposes. In particular, media streams might want to
428 /// create a [`gdk::GLContext`][crate::gdk::GLContext] or sync to the [`gdk::FrameClock`][crate::gdk::FrameClock].
429 ///
430 /// Whoever calls this function is responsible for calling
431 /// [`unrealize()`][Self::unrealize()] before either the stream
432 /// or @surface get destroyed.
433 ///
434 /// Multiple calls to this function may happen from different
435 /// users of the video, even with the same @surface. Each of these
436 /// calls must be followed by its own call to
437 /// [`unrealize()`][Self::unrealize()].
438 ///
439 /// It is not required to call this function to make a media stream work.
440 /// ## `surface`
441 /// a [`gdk::Surface`][crate::gdk::Surface]
442 #[doc(alias = "gtk_media_stream_realize")]
443 fn realize(&self, surface: &impl IsA<gdk::Surface>) {
444 unsafe {
445 ffi::gtk_media_stream_realize(
446 self.as_ref().to_glib_none().0,
447 surface.as_ref().to_glib_none().0,
448 );
449 }
450 }
451
452 /// Start a seek operation on @self to @timestamp.
453 ///
454 /// If @timestamp is out of range, it will be clamped.
455 ///
456 /// Seek operations may not finish instantly. While a
457 /// seek operation is in process, the [`seeking`][struct@crate::MediaStream#seeking]
458 /// property will be set.
459 ///
460 /// When calling gtk_media_stream_seek() during an
461 /// ongoing seek operation, the new seek will override
462 /// any pending seek.
463 /// ## `timestamp`
464 /// timestamp to seek to.
465 #[doc(alias = "gtk_media_stream_seek")]
466 fn seek(&self, timestamp: i64) {
467 unsafe {
468 ffi::gtk_media_stream_seek(self.as_ref().to_glib_none().0, timestamp);
469 }
470 }
471
472 /// Ends a seek operation started via GtkMediaStream.seek() as a failure.
473 ///
474 /// This will not cause an error on the stream and will assume that
475 /// playback continues as if no seek had happened.
476 ///
477 /// See [`seek_success()`][Self::seek_success()] for the other way of
478 /// ending a seek.
479 #[doc(alias = "gtk_media_stream_seek_failed")]
480 fn seek_failed(&self) {
481 unsafe {
482 ffi::gtk_media_stream_seek_failed(self.as_ref().to_glib_none().0);
483 }
484 }
485
486 /// Ends a seek operation started via GtkMediaStream.seek() successfully.
487 ///
488 /// This function will unset the GtkMediaStream:ended property
489 /// if it was set.
490 ///
491 /// See [`seek_failed()`][Self::seek_failed()] for the other way of
492 /// ending a seek.
493 #[doc(alias = "gtk_media_stream_seek_success")]
494 fn seek_success(&self) {
495 unsafe {
496 ffi::gtk_media_stream_seek_success(self.as_ref().to_glib_none().0);
497 }
498 }
499
500 /// Sets whether the stream should loop.
501 ///
502 /// In this case, it will attempt to restart playback
503 /// from the beginning instead of stopping at the end.
504 ///
505 /// Not all streams may support looping, in particular
506 /// non-seekable streams. Those streams will ignore the
507 /// loop setting and just end.
508 /// ## `loop_`
509 /// [`true`] if the stream should loop
510 #[doc(alias = "gtk_media_stream_set_loop")]
511 #[doc(alias = "loop")]
512 fn set_loop(&self, loop_: bool) {
513 unsafe {
514 ffi::gtk_media_stream_set_loop(self.as_ref().to_glib_none().0, loop_.into_glib());
515 }
516 }
517
518 /// Sets whether the audio stream should be muted.
519 ///
520 /// Muting a stream will cause no audio to be played, but it
521 /// does not modify the volume. This means that muting and
522 /// then unmuting the stream will restore the volume settings.
523 ///
524 /// If the stream has no audio, calling this function will
525 /// still work but it will not have an audible effect.
526 /// ## `muted`
527 /// [`true`] if the stream should be muted
528 #[doc(alias = "gtk_media_stream_set_muted")]
529 #[doc(alias = "muted")]
530 fn set_muted(&self, muted: bool) {
531 unsafe {
532 ffi::gtk_media_stream_set_muted(self.as_ref().to_glib_none().0, muted.into_glib());
533 }
534 }
535
536 /// Starts or pauses playback of the stream.
537 /// ## `playing`
538 /// whether to start or pause playback
539 #[doc(alias = "gtk_media_stream_set_playing")]
540 #[doc(alias = "playing")]
541 fn set_playing(&self, playing: bool) {
542 unsafe {
543 ffi::gtk_media_stream_set_playing(self.as_ref().to_glib_none().0, playing.into_glib());
544 }
545 }
546
547 /// Sets the volume of the audio stream.
548 ///
549 /// This function call will work even if the stream is muted.
550 ///
551 /// The given @volume should range from 0.0 for silence to 1.0
552 /// for as loud as possible. Values outside of this range will
553 /// be clamped to the nearest value.
554 ///
555 /// If the stream has no audio or is muted, calling this function
556 /// will still work but it will not have an immediate audible effect.
557 /// When the stream is unmuted, the new volume setting will take effect.
558 /// ## `volume`
559 /// New volume of the stream from 0.0 to 1.0
560 #[doc(alias = "gtk_media_stream_set_volume")]
561 #[doc(alias = "volume")]
562 fn set_volume(&self, volume: f64) {
563 unsafe {
564 ffi::gtk_media_stream_set_volume(self.as_ref().to_glib_none().0, volume);
565 }
566 }
567
568 /// Pauses the media stream and marks it as ended.
569 ///
570 /// This is a hint only, calls to [`play()`][Self::play()]
571 /// may still happen.
572 ///
573 /// The media stream must be prepared when this function is called.
574 #[cfg(feature = "v4_4")]
575 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
576 #[doc(alias = "gtk_media_stream_stream_ended")]
577 fn stream_ended(&self) {
578 unsafe {
579 ffi::gtk_media_stream_stream_ended(self.as_ref().to_glib_none().0);
580 }
581 }
582
583 /// Called by [`MediaStream`][crate::MediaStream] implementations to advertise the stream
584 /// being ready to play and providing details about the stream.
585 ///
586 /// Note that the arguments are hints. If the stream implementation
587 /// cannot determine the correct values, it is better to err on the
588 /// side of caution and return [`true`]. User interfaces will use those
589 /// values to determine what controls to show.
590 ///
591 /// This function may not be called again until the stream has been
592 /// reset via [`stream_unprepared()`][Self::stream_unprepared()].
593 /// ## `has_audio`
594 /// [`true`] if the stream should advertise audio support
595 /// ## `has_video`
596 /// [`true`] if the stream should advertise video support
597 /// ## `seekable`
598 /// [`true`] if the stream should advertise seekability
599 /// ## `duration`
600 /// The duration of the stream or 0 if unknown
601 #[cfg(feature = "v4_4")]
602 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
603 #[doc(alias = "gtk_media_stream_stream_prepared")]
604 fn stream_prepared(&self, has_audio: bool, has_video: bool, seekable: bool, duration: i64) {
605 unsafe {
606 ffi::gtk_media_stream_stream_prepared(
607 self.as_ref().to_glib_none().0,
608 has_audio.into_glib(),
609 has_video.into_glib(),
610 seekable.into_glib(),
611 duration,
612 );
613 }
614 }
615
616 /// Resets a given media stream implementation.
617 ///
618 /// [`stream_prepared()`][Self::stream_prepared()] can then be called again.
619 ///
620 /// This function will also reset any error state the stream was in.
621 #[cfg(feature = "v4_4")]
622 #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
623 #[doc(alias = "gtk_media_stream_stream_unprepared")]
624 fn stream_unprepared(&self) {
625 unsafe {
626 ffi::gtk_media_stream_stream_unprepared(self.as_ref().to_glib_none().0);
627 }
628 }
629
630 /// Same as gtk_media_stream_stream_unprepared().
631 ///
632 /// # Deprecated since 4.4
633 ///
634 /// Use [`stream_unprepared()`][Self::stream_unprepared()] instead.
635 #[cfg_attr(feature = "v4_4", deprecated = "Since 4.4")]
636 #[allow(deprecated)]
637 #[doc(alias = "gtk_media_stream_unprepared")]
638 fn unprepared(&self) {
639 unsafe {
640 ffi::gtk_media_stream_unprepared(self.as_ref().to_glib_none().0);
641 }
642 }
643
644 /// Undoes a previous call to gtk_media_stream_realize().
645 ///
646 /// This causes the stream to release all resources it had
647 /// allocated from @surface.
648 /// ## `surface`
649 /// the [`gdk::Surface`][crate::gdk::Surface] the stream was realized with
650 #[doc(alias = "gtk_media_stream_unrealize")]
651 fn unrealize(&self, surface: &impl IsA<gdk::Surface>) {
652 unsafe {
653 ffi::gtk_media_stream_unrealize(
654 self.as_ref().to_glib_none().0,
655 surface.as_ref().to_glib_none().0,
656 );
657 }
658 }
659
660 /// Media stream implementations should regularly call this
661 /// function to update the timestamp reported by the stream.
662 ///
663 /// It is up to implementations to call this at the frequency
664 /// they deem appropriate.
665 ///
666 /// The media stream must be prepared when this function is called.
667 /// ## `timestamp`
668 /// the new timestamp
669 #[doc(alias = "gtk_media_stream_update")]
670 fn update(&self, timestamp: i64) {
671 unsafe {
672 ffi::gtk_media_stream_update(self.as_ref().to_glib_none().0, timestamp);
673 }
674 }
675
676 #[doc(alias = "duration")]
677 fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
678 unsafe extern "C" fn notify_duration_trampoline<
679 P: IsA<MediaStream>,
680 F: Fn(&P) + 'static,
681 >(
682 this: *mut ffi::GtkMediaStream,
683 _param_spec: glib::ffi::gpointer,
684 f: glib::ffi::gpointer,
685 ) {
686 let f: &F = &*(f as *const F);
687 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
688 }
689 unsafe {
690 let f: Box_<F> = Box_::new(f);
691 connect_raw(
692 self.as_ptr() as *mut _,
693 c"notify::duration".as_ptr() as *const _,
694 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
695 notify_duration_trampoline::<Self, F> as *const (),
696 )),
697 Box_::into_raw(f),
698 )
699 }
700 }
701
702 #[doc(alias = "ended")]
703 fn connect_ended_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
704 unsafe extern "C" fn notify_ended_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
705 this: *mut ffi::GtkMediaStream,
706 _param_spec: glib::ffi::gpointer,
707 f: glib::ffi::gpointer,
708 ) {
709 let f: &F = &*(f as *const F);
710 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
711 }
712 unsafe {
713 let f: Box_<F> = Box_::new(f);
714 connect_raw(
715 self.as_ptr() as *mut _,
716 c"notify::ended".as_ptr() as *const _,
717 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
718 notify_ended_trampoline::<Self, F> as *const (),
719 )),
720 Box_::into_raw(f),
721 )
722 }
723 }
724
725 #[doc(alias = "error")]
726 fn connect_error_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
727 unsafe extern "C" fn notify_error_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
728 this: *mut ffi::GtkMediaStream,
729 _param_spec: glib::ffi::gpointer,
730 f: glib::ffi::gpointer,
731 ) {
732 let f: &F = &*(f as *const F);
733 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
734 }
735 unsafe {
736 let f: Box_<F> = Box_::new(f);
737 connect_raw(
738 self.as_ptr() as *mut _,
739 c"notify::error".as_ptr() as *const _,
740 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
741 notify_error_trampoline::<Self, F> as *const (),
742 )),
743 Box_::into_raw(f),
744 )
745 }
746 }
747
748 #[doc(alias = "has-audio")]
749 fn connect_has_audio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
750 unsafe extern "C" fn notify_has_audio_trampoline<
751 P: IsA<MediaStream>,
752 F: Fn(&P) + 'static,
753 >(
754 this: *mut ffi::GtkMediaStream,
755 _param_spec: glib::ffi::gpointer,
756 f: glib::ffi::gpointer,
757 ) {
758 let f: &F = &*(f as *const F);
759 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
760 }
761 unsafe {
762 let f: Box_<F> = Box_::new(f);
763 connect_raw(
764 self.as_ptr() as *mut _,
765 c"notify::has-audio".as_ptr() as *const _,
766 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
767 notify_has_audio_trampoline::<Self, F> as *const (),
768 )),
769 Box_::into_raw(f),
770 )
771 }
772 }
773
774 #[doc(alias = "has-video")]
775 fn connect_has_video_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
776 unsafe extern "C" fn notify_has_video_trampoline<
777 P: IsA<MediaStream>,
778 F: Fn(&P) + 'static,
779 >(
780 this: *mut ffi::GtkMediaStream,
781 _param_spec: glib::ffi::gpointer,
782 f: glib::ffi::gpointer,
783 ) {
784 let f: &F = &*(f as *const F);
785 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
786 }
787 unsafe {
788 let f: Box_<F> = Box_::new(f);
789 connect_raw(
790 self.as_ptr() as *mut _,
791 c"notify::has-video".as_ptr() as *const _,
792 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
793 notify_has_video_trampoline::<Self, F> as *const (),
794 )),
795 Box_::into_raw(f),
796 )
797 }
798 }
799
800 #[doc(alias = "loop")]
801 fn connect_loop_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
802 unsafe extern "C" fn notify_loop_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
803 this: *mut ffi::GtkMediaStream,
804 _param_spec: glib::ffi::gpointer,
805 f: glib::ffi::gpointer,
806 ) {
807 let f: &F = &*(f as *const F);
808 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
809 }
810 unsafe {
811 let f: Box_<F> = Box_::new(f);
812 connect_raw(
813 self.as_ptr() as *mut _,
814 c"notify::loop".as_ptr() as *const _,
815 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
816 notify_loop_trampoline::<Self, F> as *const (),
817 )),
818 Box_::into_raw(f),
819 )
820 }
821 }
822
823 #[doc(alias = "muted")]
824 fn connect_muted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
825 unsafe extern "C" fn notify_muted_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
826 this: *mut ffi::GtkMediaStream,
827 _param_spec: glib::ffi::gpointer,
828 f: glib::ffi::gpointer,
829 ) {
830 let f: &F = &*(f as *const F);
831 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
832 }
833 unsafe {
834 let f: Box_<F> = Box_::new(f);
835 connect_raw(
836 self.as_ptr() as *mut _,
837 c"notify::muted".as_ptr() as *const _,
838 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
839 notify_muted_trampoline::<Self, F> as *const (),
840 )),
841 Box_::into_raw(f),
842 )
843 }
844 }
845
846 #[doc(alias = "playing")]
847 fn connect_playing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
848 unsafe extern "C" fn notify_playing_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
849 this: *mut ffi::GtkMediaStream,
850 _param_spec: glib::ffi::gpointer,
851 f: glib::ffi::gpointer,
852 ) {
853 let f: &F = &*(f as *const F);
854 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
855 }
856 unsafe {
857 let f: Box_<F> = Box_::new(f);
858 connect_raw(
859 self.as_ptr() as *mut _,
860 c"notify::playing".as_ptr() as *const _,
861 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
862 notify_playing_trampoline::<Self, F> as *const (),
863 )),
864 Box_::into_raw(f),
865 )
866 }
867 }
868
869 #[doc(alias = "prepared")]
870 fn connect_prepared_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
871 unsafe extern "C" fn notify_prepared_trampoline<
872 P: IsA<MediaStream>,
873 F: Fn(&P) + 'static,
874 >(
875 this: *mut ffi::GtkMediaStream,
876 _param_spec: glib::ffi::gpointer,
877 f: glib::ffi::gpointer,
878 ) {
879 let f: &F = &*(f as *const F);
880 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
881 }
882 unsafe {
883 let f: Box_<F> = Box_::new(f);
884 connect_raw(
885 self.as_ptr() as *mut _,
886 c"notify::prepared".as_ptr() as *const _,
887 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
888 notify_prepared_trampoline::<Self, F> as *const (),
889 )),
890 Box_::into_raw(f),
891 )
892 }
893 }
894
895 #[doc(alias = "seekable")]
896 fn connect_seekable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
897 unsafe extern "C" fn notify_seekable_trampoline<
898 P: IsA<MediaStream>,
899 F: Fn(&P) + 'static,
900 >(
901 this: *mut ffi::GtkMediaStream,
902 _param_spec: glib::ffi::gpointer,
903 f: glib::ffi::gpointer,
904 ) {
905 let f: &F = &*(f as *const F);
906 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
907 }
908 unsafe {
909 let f: Box_<F> = Box_::new(f);
910 connect_raw(
911 self.as_ptr() as *mut _,
912 c"notify::seekable".as_ptr() as *const _,
913 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
914 notify_seekable_trampoline::<Self, F> as *const (),
915 )),
916 Box_::into_raw(f),
917 )
918 }
919 }
920
921 #[doc(alias = "seeking")]
922 fn connect_seeking_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
923 unsafe extern "C" fn notify_seeking_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
924 this: *mut ffi::GtkMediaStream,
925 _param_spec: glib::ffi::gpointer,
926 f: glib::ffi::gpointer,
927 ) {
928 let f: &F = &*(f as *const F);
929 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
930 }
931 unsafe {
932 let f: Box_<F> = Box_::new(f);
933 connect_raw(
934 self.as_ptr() as *mut _,
935 c"notify::seeking".as_ptr() as *const _,
936 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
937 notify_seeking_trampoline::<Self, F> as *const (),
938 )),
939 Box_::into_raw(f),
940 )
941 }
942 }
943
944 #[doc(alias = "timestamp")]
945 fn connect_timestamp_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
946 unsafe extern "C" fn notify_timestamp_trampoline<
947 P: IsA<MediaStream>,
948 F: Fn(&P) + 'static,
949 >(
950 this: *mut ffi::GtkMediaStream,
951 _param_spec: glib::ffi::gpointer,
952 f: glib::ffi::gpointer,
953 ) {
954 let f: &F = &*(f as *const F);
955 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
956 }
957 unsafe {
958 let f: Box_<F> = Box_::new(f);
959 connect_raw(
960 self.as_ptr() as *mut _,
961 c"notify::timestamp".as_ptr() as *const _,
962 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
963 notify_timestamp_trampoline::<Self, F> as *const (),
964 )),
965 Box_::into_raw(f),
966 )
967 }
968 }
969
970 #[doc(alias = "volume")]
971 fn connect_volume_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
972 unsafe extern "C" fn notify_volume_trampoline<P: IsA<MediaStream>, F: Fn(&P) + 'static>(
973 this: *mut ffi::GtkMediaStream,
974 _param_spec: glib::ffi::gpointer,
975 f: glib::ffi::gpointer,
976 ) {
977 let f: &F = &*(f as *const F);
978 f(MediaStream::from_glib_borrow(this).unsafe_cast_ref())
979 }
980 unsafe {
981 let f: Box_<F> = Box_::new(f);
982 connect_raw(
983 self.as_ptr() as *mut _,
984 c"notify::volume".as_ptr() as *const _,
985 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
986 notify_volume_trampoline::<Self, F> as *const (),
987 )),
988 Box_::into_raw(f),
989 )
990 }
991 }
992}
993
994impl<O: IsA<MediaStream>> MediaStreamExt for O {}