gstreamer_mse/auto/
media_source.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{
7    ffi, MediaSourceEOSError, MediaSourceRange, MediaSourceReadyState, MseSrc, SourceBuffer,
8    SourceBufferList,
9};
10use glib::{
11    object::ObjectType as _,
12    prelude::*,
13    signal::{connect_raw, SignalHandlerId},
14    translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    /// [`MediaSource`][crate::MediaSource] is the entry point into the W3C Media Source API. It offers
20    /// functionality similar to `GstAppSrc` for client-side web or JavaScript
21    /// applications decoupling the source of media from its processing and playback.
22    ///
23    /// To interact with a Media Source, connect it to a [`MseSrc`][crate::MseSrc] that is in some
24    /// `GstPipeline` using [`attach()`][Self::attach()]. Then create at least one
25    /// [`SourceBuffer`][crate::SourceBuffer] using [`add_source_buffer()`][Self::add_source_buffer()]. Finally, feed
26    /// some media data to the Source Buffer(s) using
27    /// [`SourceBuffer::append_buffer()`][crate::SourceBuffer::append_buffer()] and play the pipeline.
28    ///
29    /// ## Properties
30    ///
31    ///
32    /// #### `active-source-buffers`
33    ///  A [`SourceBufferList`][crate::SourceBufferList] of every [`SourceBuffer`][crate::SourceBuffer] in this Media Source that
34    /// is considered active
35    ///
36    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-activesourcebuffers)
37    ///
38    /// Readable
39    ///
40    ///
41    /// #### `duration`
42    ///  The Duration of the Media Source as a `GstClockTime`
43    ///
44    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-duration)
45    ///
46    /// Readable | Writeable
47    ///
48    ///
49    /// #### `position`
50    ///  The position of the player consuming from the Media Source
51    ///
52    /// Readable | Writeable
53    ///
54    ///
55    /// #### `ready-state`
56    ///  The Ready State of the Media Source
57    ///
58    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-readystate)
59    ///
60    /// Readable
61    ///
62    ///
63    /// #### `source-buffers`
64    ///  A [`SourceBufferList`][crate::SourceBufferList] of every [`SourceBuffer`][crate::SourceBuffer] in this Media Source
65    ///
66    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-sourcebuffers)
67    ///
68    /// Readable
69    /// <details><summary><h4>Object</h4></summary>
70    ///
71    ///
72    /// #### `name`
73    ///  Readable | Writeable | Construct
74    ///
75    ///
76    /// #### `parent`
77    ///  The parent of the object. Please note, that when changing the 'parent'
78    /// property, we don't emit `GObject::notify` and [`deep-notify`][struct@crate::gst::Object#deep-notify]
79    /// signals due to locking issues. In some cases one can use
80    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
81    /// achieve a similar effect.
82    ///
83    /// Readable | Writeable
84    /// </details>
85    ///
86    /// ## Signals
87    ///
88    ///
89    /// #### `on-source-close`
90    ///
91    ///
92    ///
93    /// #### `on-source-ended`
94    ///  Emitted when `self_` has ended, normally through
95    /// [`MediaSource::end_of_stream()`][crate::MediaSource::end_of_stream()].
96    ///
97    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-onsourceended)
98    ///
99    ///
100    ///
101    ///
102    /// #### `on-source-open`
103    ///  Emitted when `self_` has been opened.
104    ///
105    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-onsourceopen)
106    ///
107    ///
108    /// <details><summary><h4>Object</h4></summary>
109    ///
110    ///
111    /// #### `deep-notify`
112    ///  The deep notify signal is used to be notified of property changes. It is
113    /// typically attached to the toplevel bin to receive notifications from all
114    /// the elements contained in that bin.
115    ///
116    /// Detailed
117    /// </details>
118    ///
119    /// # Implements
120    ///
121    /// [`trait@gst::prelude::ObjectExt`]
122    #[doc(alias = "GstMediaSource")]
123    pub struct MediaSource(Object<ffi::GstMediaSource, ffi::GstMediaSourceClass>) @extends gst::Object;
124
125    match fn {
126        type_ => || ffi::gst_media_source_get_type(),
127    }
128}
129
130impl MediaSource {
131    /// Creates a new [`MediaSource`][crate::MediaSource] instance. The instance is in the
132    /// [`MediaSourceReadyState::Closed`][crate::MediaSourceReadyState::Closed] state and is not associated with any
133    /// media player.
134    ///
135    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-constructor)
136    ///
137    /// # Returns
138    ///
139    /// a new [`MediaSource`][crate::MediaSource] instance
140    #[doc(alias = "gst_media_source_new")]
141    pub fn new() -> MediaSource {
142        assert_initialized_main_thread!();
143        unsafe { from_glib_full(ffi::gst_media_source_new()) }
144    }
145
146    /// Add a [`SourceBuffer`][crate::SourceBuffer] to this [`MediaSource`][crate::MediaSource] of the specified media type.
147    /// The Media Source must be in the [`MediaSourceReadyState`][crate::MediaSourceReadyState] [`MediaSourceReadyState::Open`][crate::MediaSourceReadyState::Open].
148    ///
149    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-addsourcebuffer)
150    /// ## `type_`
151    /// A MIME type describing the format of the incoming media
152    ///
153    /// # Returns
154    ///
155    /// a new [`SourceBuffer`][crate::SourceBuffer] instance on success, otherwise `NULL`
156    #[doc(alias = "gst_media_source_add_source_buffer")]
157    pub fn add_source_buffer(&self, type_: &str) -> Result<SourceBuffer, glib::Error> {
158        unsafe {
159            let mut error = std::ptr::null_mut();
160            let ret = ffi::gst_media_source_add_source_buffer(
161                self.to_glib_none().0,
162                type_.to_glib_none().0,
163                &mut error,
164            );
165            if error.is_null() {
166                Ok(from_glib_full(ret))
167            } else {
168                Err(from_glib_full(error))
169            }
170        }
171    }
172
173    /// Associates `self` with `element`.
174    /// Normally, the Element will be part of a `GstPipeline` that plays back the data
175    /// submitted to the Media Source's Source Buffers.
176    ///
177    /// [`MseSrc`][crate::MseSrc] is a special source element that is designed to consume media from
178    /// a [`MediaSource`][crate::MediaSource].
179    ///
180    /// [Specification](https://www.w3.org/TR/media-source-2/`dfn`-attaching-to-a-media-element)
181    /// ## `element`
182    /// [`MseSrc`][crate::MseSrc] source Element
183    #[doc(alias = "gst_media_source_attach")]
184    pub fn attach(&self, element: &MseSrc) {
185        unsafe {
186            ffi::gst_media_source_attach(self.to_glib_none().0, element.to_glib_none().0);
187        }
188    }
189
190    /// Clear the live seekable range for `self`. This will inform the component
191    /// playing this Media Source that there is no seekable time range.
192    ///
193    /// If the ready state is not [`MediaSourceReadyState::Open`][crate::MediaSourceReadyState::Open], it will fail
194    /// and set an error.
195    ///
196    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-clearliveseekablerange)
197    ///
198    /// # Returns
199    ///
200    /// `TRUE` on success, `FALSE` otherwise
201    #[doc(alias = "gst_media_source_clear_live_seekable_range")]
202    pub fn clear_live_seekable_range(&self) -> Result<(), glib::Error> {
203        unsafe {
204            let mut error = std::ptr::null_mut();
205            let is_ok =
206                ffi::gst_media_source_clear_live_seekable_range(self.to_glib_none().0, &mut error);
207            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
208            if error.is_null() {
209                Ok(())
210            } else {
211                Err(from_glib_full(error))
212            }
213        }
214    }
215
216    /// Detaches `self` from any [`MseSrc`][crate::MseSrc] element that it may be associated with.
217    #[doc(alias = "gst_media_source_detach")]
218    pub fn detach(&self) {
219        unsafe {
220            ffi::gst_media_source_detach(self.to_glib_none().0);
221        }
222    }
223
224    /// Mark `self` as reaching the end of stream, disallowing new data inputs.
225    ///
226    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-endofstream)
227    /// ## `eos_error`
228    /// The error type, if any
229    ///
230    /// # Returns
231    ///
232    /// `TRUE` on success, `FALSE` otherwise
233    #[doc(alias = "gst_media_source_end_of_stream")]
234    pub fn end_of_stream(&self, eos_error: MediaSourceEOSError) -> Result<(), glib::Error> {
235        unsafe {
236            let mut error = std::ptr::null_mut();
237            let is_ok = ffi::gst_media_source_end_of_stream(
238                self.to_glib_none().0,
239                eos_error.into_glib(),
240                &mut error,
241            );
242            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
243            if error.is_null() {
244                Ok(())
245            } else {
246                Err(from_glib_full(error))
247            }
248        }
249    }
250
251    /// Gets a [`SourceBufferList`][crate::SourceBufferList] containing all the Source Buffers currently
252    /// associated with this Media Source that are considered "active."
253    /// For a Source Buffer to be considered active, either its video track is
254    /// selected, its audio track is enabled, or its text track is visible or hidden.
255    /// This object will reflect any future changes to the parent Media Source as
256    /// well.
257    ///
258    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-activesourcebuffers)
259    ///
260    /// # Returns
261    ///
262    /// a new [`SourceBufferList`][crate::SourceBufferList] instance
263    #[doc(alias = "gst_media_source_get_active_source_buffers")]
264    #[doc(alias = "get_active_source_buffers")]
265    #[doc(alias = "active-source-buffers")]
266    pub fn active_source_buffers(&self) -> SourceBufferList {
267        unsafe {
268            from_glib_full(ffi::gst_media_source_get_active_source_buffers(
269                self.to_glib_none().0,
270            ))
271        }
272    }
273
274    /// Gets the current duration of `self`.
275    ///
276    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-duration)
277    ///
278    /// # Returns
279    ///
280    /// the current duration as a `GstClockTime`
281    #[doc(alias = "gst_media_source_get_duration")]
282    #[doc(alias = "get_duration")]
283    pub fn duration(&self) -> Option<gst::ClockTime> {
284        unsafe { from_glib(ffi::gst_media_source_get_duration(self.to_glib_none().0)) }
285    }
286
287    /// Get the live seekable range of `self`. Will fill in the supplied `range` with
288    /// the current live seekable range.
289    ///
290    /// # Returns
291    ///
292    ///
293    /// ## `range`
294    /// time range
295    #[doc(alias = "gst_media_source_get_live_seekable_range")]
296    #[doc(alias = "get_live_seekable_range")]
297    pub fn live_seekable_range(&self) -> MediaSourceRange {
298        unsafe {
299            let mut range = MediaSourceRange::uninitialized();
300            ffi::gst_media_source_get_live_seekable_range(
301                self.to_glib_none().0,
302                range.to_glib_none_mut().0,
303            );
304            range
305        }
306    }
307
308    /// Gets the current playback position of the Media Source.
309    ///
310    /// # Returns
311    ///
312    /// the current playback position as a `GstClockTime`
313    #[doc(alias = "gst_media_source_get_position")]
314    #[doc(alias = "get_position")]
315    pub fn position(&self) -> Option<gst::ClockTime> {
316        unsafe { from_glib(ffi::gst_media_source_get_position(self.to_glib_none().0)) }
317    }
318
319    /// Gets the current Ready State of the Media Source.
320    ///
321    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-readystate)
322    ///
323    /// # Returns
324    ///
325    /// the current [`MediaSourceReadyState`][crate::MediaSourceReadyState] value
326    #[doc(alias = "gst_media_source_get_ready_state")]
327    #[doc(alias = "get_ready_state")]
328    #[doc(alias = "ready-state")]
329    pub fn ready_state(&self) -> MediaSourceReadyState {
330        unsafe { from_glib(ffi::gst_media_source_get_ready_state(self.to_glib_none().0)) }
331    }
332
333    /// Gets a [`SourceBufferList`][crate::SourceBufferList] containing all the Source Buffers currently
334    /// associated with this Media Source. This object will reflect any future
335    /// changes to the parent Media Source as well.
336    ///
337    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-sourcebuffers)
338    ///
339    /// # Returns
340    ///
341    /// a [`SourceBufferList`][crate::SourceBufferList] instance
342    #[doc(alias = "gst_media_source_get_source_buffers")]
343    #[doc(alias = "get_source_buffers")]
344    #[doc(alias = "source-buffers")]
345    pub fn source_buffers(&self) -> SourceBufferList {
346        unsafe {
347            from_glib_full(ffi::gst_media_source_get_source_buffers(
348                self.to_glib_none().0,
349            ))
350        }
351    }
352
353    /// Remove `buffer` from `self`.
354    ///
355    /// `buffer` must have been created as a child of `self` and `self` must be in the
356    /// [`MediaSourceReadyState`][crate::MediaSourceReadyState] [`MediaSourceReadyState::Open`][crate::MediaSourceReadyState::Open].
357    ///
358    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-removesourcebuffer)
359    /// ## `buffer`
360    /// [`SourceBuffer`][crate::SourceBuffer] instance
361    ///
362    /// # Returns
363    ///
364    /// `TRUE` on success, `FALSE` otherwise
365    #[doc(alias = "gst_media_source_remove_source_buffer")]
366    pub fn remove_source_buffer(&self, buffer: &SourceBuffer) -> Result<(), glib::Error> {
367        unsafe {
368            let mut error = std::ptr::null_mut();
369            let is_ok = ffi::gst_media_source_remove_source_buffer(
370                self.to_glib_none().0,
371                buffer.to_glib_none().0,
372                &mut error,
373            );
374            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
375            if error.is_null() {
376                Ok(())
377            } else {
378                Err(from_glib_full(error))
379            }
380        }
381    }
382
383    /// Sets the duration of `self`.
384    ///
385    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-duration)
386    /// ## `duration`
387    /// The new duration to apply to `self`.
388    ///
389    /// # Returns
390    ///
391    /// `TRUE` on success, `FALSE` otherwise
392    #[doc(alias = "gst_media_source_set_duration")]
393    #[doc(alias = "duration")]
394    pub fn set_duration(
395        &self,
396        duration: impl Into<Option<gst::ClockTime>>,
397    ) -> Result<(), glib::Error> {
398        unsafe {
399            let mut error = std::ptr::null_mut();
400            let is_ok = ffi::gst_media_source_set_duration(
401                self.to_glib_none().0,
402                duration.into().into_glib(),
403                &mut error,
404            );
405            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
406            if error.is_null() {
407                Ok(())
408            } else {
409                Err(from_glib_full(error))
410            }
411        }
412    }
413
414    /// Set the live seekable range for `self`. This range informs the component
415    /// playing this Media Source what it can allow the user to seek through.
416    ///
417    /// If the ready state is not [`MediaSourceReadyState::Open`][crate::MediaSourceReadyState::Open], or the supplied
418    /// `start` time is later than `end` it will fail and set an error.
419    ///
420    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-setliveseekablerange)
421    /// ## `start`
422    /// The earliest point in the stream considered seekable
423    /// ## `end`
424    /// The latest point in the stream considered seekable
425    ///
426    /// # Returns
427    ///
428    /// `TRUE` on success, `FALSE` otherwise
429    #[doc(alias = "gst_media_source_set_live_seekable_range")]
430    pub fn set_live_seekable_range(
431        &self,
432        start: impl Into<Option<gst::ClockTime>>,
433        end: impl Into<Option<gst::ClockTime>>,
434    ) -> Result<(), glib::Error> {
435        unsafe {
436            let mut error = std::ptr::null_mut();
437            let is_ok = ffi::gst_media_source_set_live_seekable_range(
438                self.to_glib_none().0,
439                start.into().into_glib(),
440                end.into().into_glib(),
441                &mut error,
442            );
443            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
444            if error.is_null() {
445                Ok(())
446            } else {
447                Err(from_glib_full(error))
448            }
449        }
450    }
451
452    /// Determines whether the current Media Source configuration can process media
453    /// of the supplied `type_`.
454    /// ## `type_`
455    /// A MIME type value
456    ///
457    /// # Returns
458    ///
459    /// `TRUE` when supported, `FALSE` otherwise
460    #[doc(alias = "gst_media_source_is_type_supported")]
461    pub fn is_type_supported(type_: &str) -> bool {
462        assert_initialized_main_thread!();
463        unsafe {
464            from_glib(ffi::gst_media_source_is_type_supported(
465                type_.to_glib_none().0,
466            ))
467        }
468    }
469
470    #[doc(alias = "on-source-close")]
471    pub fn connect_on_source_close<F: Fn(&Self) + Send + Sync + 'static>(
472        &self,
473        f: F,
474    ) -> SignalHandlerId {
475        unsafe extern "C" fn on_source_close_trampoline<
476            F: Fn(&MediaSource) + Send + Sync + 'static,
477        >(
478            this: *mut ffi::GstMediaSource,
479            f: glib::ffi::gpointer,
480        ) {
481            let f: &F = &*(f as *const F);
482            f(&from_glib_borrow(this))
483        }
484        unsafe {
485            let f: Box_<F> = Box_::new(f);
486            connect_raw(
487                self.as_ptr() as *mut _,
488                c"on-source-close".as_ptr() as *const _,
489                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
490                    on_source_close_trampoline::<F> as *const (),
491                )),
492                Box_::into_raw(f),
493            )
494        }
495    }
496
497    /// Emitted when `self_` has ended, normally through
498    /// [`end_of_stream()`][Self::end_of_stream()].
499    ///
500    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-onsourceended)
501    #[doc(alias = "on-source-ended")]
502    pub fn connect_on_source_ended<F: Fn(&Self) + Send + Sync + 'static>(
503        &self,
504        f: F,
505    ) -> SignalHandlerId {
506        unsafe extern "C" fn on_source_ended_trampoline<
507            F: Fn(&MediaSource) + Send + Sync + 'static,
508        >(
509            this: *mut ffi::GstMediaSource,
510            f: glib::ffi::gpointer,
511        ) {
512            let f: &F = &*(f as *const F);
513            f(&from_glib_borrow(this))
514        }
515        unsafe {
516            let f: Box_<F> = Box_::new(f);
517            connect_raw(
518                self.as_ptr() as *mut _,
519                c"on-source-ended".as_ptr() as *const _,
520                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
521                    on_source_ended_trampoline::<F> as *const (),
522                )),
523                Box_::into_raw(f),
524            )
525        }
526    }
527
528    /// Emitted when `self_` has been opened.
529    ///
530    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-onsourceopen)
531    #[doc(alias = "on-source-open")]
532    pub fn connect_on_source_open<F: Fn(&Self) + Send + Sync + 'static>(
533        &self,
534        f: F,
535    ) -> SignalHandlerId {
536        unsafe extern "C" fn on_source_open_trampoline<
537            F: Fn(&MediaSource) + Send + Sync + 'static,
538        >(
539            this: *mut ffi::GstMediaSource,
540            f: glib::ffi::gpointer,
541        ) {
542            let f: &F = &*(f as *const F);
543            f(&from_glib_borrow(this))
544        }
545        unsafe {
546            let f: Box_<F> = Box_::new(f);
547            connect_raw(
548                self.as_ptr() as *mut _,
549                c"on-source-open".as_ptr() as *const _,
550                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
551                    on_source_open_trampoline::<F> as *const (),
552                )),
553                Box_::into_raw(f),
554            )
555        }
556    }
557
558    #[doc(alias = "active-source-buffers")]
559    pub fn connect_active_source_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
560        &self,
561        f: F,
562    ) -> SignalHandlerId {
563        unsafe extern "C" fn notify_active_source_buffers_trampoline<
564            F: Fn(&MediaSource) + Send + Sync + 'static,
565        >(
566            this: *mut ffi::GstMediaSource,
567            _param_spec: glib::ffi::gpointer,
568            f: glib::ffi::gpointer,
569        ) {
570            let f: &F = &*(f as *const F);
571            f(&from_glib_borrow(this))
572        }
573        unsafe {
574            let f: Box_<F> = Box_::new(f);
575            connect_raw(
576                self.as_ptr() as *mut _,
577                c"notify::active-source-buffers".as_ptr() as *const _,
578                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
579                    notify_active_source_buffers_trampoline::<F> as *const (),
580                )),
581                Box_::into_raw(f),
582            )
583        }
584    }
585
586    #[doc(alias = "duration")]
587    pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
588        &self,
589        f: F,
590    ) -> SignalHandlerId {
591        unsafe extern "C" fn notify_duration_trampoline<
592            F: Fn(&MediaSource) + Send + Sync + 'static,
593        >(
594            this: *mut ffi::GstMediaSource,
595            _param_spec: glib::ffi::gpointer,
596            f: glib::ffi::gpointer,
597        ) {
598            let f: &F = &*(f as *const F);
599            f(&from_glib_borrow(this))
600        }
601        unsafe {
602            let f: Box_<F> = Box_::new(f);
603            connect_raw(
604                self.as_ptr() as *mut _,
605                c"notify::duration".as_ptr() as *const _,
606                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
607                    notify_duration_trampoline::<F> as *const (),
608                )),
609                Box_::into_raw(f),
610            )
611        }
612    }
613
614    #[doc(alias = "position")]
615    pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
616        &self,
617        f: F,
618    ) -> SignalHandlerId {
619        unsafe extern "C" fn notify_position_trampoline<
620            F: Fn(&MediaSource) + Send + Sync + 'static,
621        >(
622            this: *mut ffi::GstMediaSource,
623            _param_spec: glib::ffi::gpointer,
624            f: glib::ffi::gpointer,
625        ) {
626            let f: &F = &*(f as *const F);
627            f(&from_glib_borrow(this))
628        }
629        unsafe {
630            let f: Box_<F> = Box_::new(f);
631            connect_raw(
632                self.as_ptr() as *mut _,
633                c"notify::position".as_ptr() as *const _,
634                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
635                    notify_position_trampoline::<F> as *const (),
636                )),
637                Box_::into_raw(f),
638            )
639        }
640    }
641
642    #[doc(alias = "ready-state")]
643    pub fn connect_ready_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
644        &self,
645        f: F,
646    ) -> SignalHandlerId {
647        unsafe extern "C" fn notify_ready_state_trampoline<
648            F: Fn(&MediaSource) + Send + Sync + 'static,
649        >(
650            this: *mut ffi::GstMediaSource,
651            _param_spec: glib::ffi::gpointer,
652            f: glib::ffi::gpointer,
653        ) {
654            let f: &F = &*(f as *const F);
655            f(&from_glib_borrow(this))
656        }
657        unsafe {
658            let f: Box_<F> = Box_::new(f);
659            connect_raw(
660                self.as_ptr() as *mut _,
661                c"notify::ready-state".as_ptr() as *const _,
662                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
663                    notify_ready_state_trampoline::<F> as *const (),
664                )),
665                Box_::into_raw(f),
666            )
667        }
668    }
669
670    #[doc(alias = "source-buffers")]
671    pub fn connect_source_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
672        &self,
673        f: F,
674    ) -> SignalHandlerId {
675        unsafe extern "C" fn notify_source_buffers_trampoline<
676            F: Fn(&MediaSource) + Send + Sync + 'static,
677        >(
678            this: *mut ffi::GstMediaSource,
679            _param_spec: glib::ffi::gpointer,
680            f: glib::ffi::gpointer,
681        ) {
682            let f: &F = &*(f as *const F);
683            f(&from_glib_borrow(this))
684        }
685        unsafe {
686            let f: Box_<F> = Box_::new(f);
687            connect_raw(
688                self.as_ptr() as *mut _,
689                c"notify::source-buffers".as_ptr() as *const _,
690                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
691                    notify_source_buffers_trampoline::<F> as *const (),
692                )),
693                Box_::into_raw(f),
694            )
695        }
696    }
697}
698
699impl Default for MediaSource {
700    fn default() -> Self {
701        Self::new()
702    }
703}
704
705unsafe impl Send for MediaSource {}
706unsafe impl Sync for MediaSource {}