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