Skip to main content

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    MediaSourceEOSError, MediaSourceRange, MediaSourceReadyState, MseSrc, SourceBuffer,
8    SourceBufferList, ffi,
9};
10use glib::{
11    object::ObjectType as _,
12    prelude::*,
13    signal::{SignalHandlerId, connect_raw},
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            unsafe {
482                let f: &F = &*(f as *const F);
483                f(&from_glib_borrow(this))
484            }
485        }
486        unsafe {
487            let f: Box_<F> = Box_::new(f);
488            connect_raw(
489                self.as_ptr() as *mut _,
490                c"on-source-close".as_ptr(),
491                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
492                    on_source_close_trampoline::<F> as *const (),
493                )),
494                Box_::into_raw(f),
495            )
496        }
497    }
498
499    /// Emitted when `self_` has ended, normally through
500    /// [`end_of_stream()`][Self::end_of_stream()].
501    ///
502    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-onsourceended)
503    #[doc(alias = "on-source-ended")]
504    pub fn connect_on_source_ended<F: Fn(&Self) + Send + Sync + 'static>(
505        &self,
506        f: F,
507    ) -> SignalHandlerId {
508        unsafe extern "C" fn on_source_ended_trampoline<
509            F: Fn(&MediaSource) + Send + Sync + 'static,
510        >(
511            this: *mut ffi::GstMediaSource,
512            f: glib::ffi::gpointer,
513        ) {
514            unsafe {
515                let f: &F = &*(f as *const F);
516                f(&from_glib_borrow(this))
517            }
518        }
519        unsafe {
520            let f: Box_<F> = Box_::new(f);
521            connect_raw(
522                self.as_ptr() as *mut _,
523                c"on-source-ended".as_ptr(),
524                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
525                    on_source_ended_trampoline::<F> as *const (),
526                )),
527                Box_::into_raw(f),
528            )
529        }
530    }
531
532    /// Emitted when `self_` has been opened.
533    ///
534    /// [Specification](https://www.w3.org/TR/media-source-2/`dom`-mediasource-onsourceopen)
535    #[doc(alias = "on-source-open")]
536    pub fn connect_on_source_open<F: Fn(&Self) + Send + Sync + 'static>(
537        &self,
538        f: F,
539    ) -> SignalHandlerId {
540        unsafe extern "C" fn on_source_open_trampoline<
541            F: Fn(&MediaSource) + Send + Sync + 'static,
542        >(
543            this: *mut ffi::GstMediaSource,
544            f: glib::ffi::gpointer,
545        ) {
546            unsafe {
547                let f: &F = &*(f as *const F);
548                f(&from_glib_borrow(this))
549            }
550        }
551        unsafe {
552            let f: Box_<F> = Box_::new(f);
553            connect_raw(
554                self.as_ptr() as *mut _,
555                c"on-source-open".as_ptr(),
556                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
557                    on_source_open_trampoline::<F> as *const (),
558                )),
559                Box_::into_raw(f),
560            )
561        }
562    }
563
564    #[doc(alias = "active-source-buffers")]
565    pub fn connect_active_source_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
566        &self,
567        f: F,
568    ) -> SignalHandlerId {
569        unsafe extern "C" fn notify_active_source_buffers_trampoline<
570            F: Fn(&MediaSource) + Send + Sync + 'static,
571        >(
572            this: *mut ffi::GstMediaSource,
573            _param_spec: glib::ffi::gpointer,
574            f: glib::ffi::gpointer,
575        ) {
576            unsafe {
577                let f: &F = &*(f as *const F);
578                f(&from_glib_borrow(this))
579            }
580        }
581        unsafe {
582            let f: Box_<F> = Box_::new(f);
583            connect_raw(
584                self.as_ptr() as *mut _,
585                c"notify::active-source-buffers".as_ptr(),
586                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
587                    notify_active_source_buffers_trampoline::<F> as *const (),
588                )),
589                Box_::into_raw(f),
590            )
591        }
592    }
593
594    #[doc(alias = "duration")]
595    pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
596        &self,
597        f: F,
598    ) -> SignalHandlerId {
599        unsafe extern "C" fn notify_duration_trampoline<
600            F: Fn(&MediaSource) + Send + Sync + 'static,
601        >(
602            this: *mut ffi::GstMediaSource,
603            _param_spec: glib::ffi::gpointer,
604            f: glib::ffi::gpointer,
605        ) {
606            unsafe {
607                let f: &F = &*(f as *const F);
608                f(&from_glib_borrow(this))
609            }
610        }
611        unsafe {
612            let f: Box_<F> = Box_::new(f);
613            connect_raw(
614                self.as_ptr() as *mut _,
615                c"notify::duration".as_ptr(),
616                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
617                    notify_duration_trampoline::<F> as *const (),
618                )),
619                Box_::into_raw(f),
620            )
621        }
622    }
623
624    #[doc(alias = "position")]
625    pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
626        &self,
627        f: F,
628    ) -> SignalHandlerId {
629        unsafe extern "C" fn notify_position_trampoline<
630            F: Fn(&MediaSource) + Send + Sync + 'static,
631        >(
632            this: *mut ffi::GstMediaSource,
633            _param_spec: glib::ffi::gpointer,
634            f: glib::ffi::gpointer,
635        ) {
636            unsafe {
637                let f: &F = &*(f as *const F);
638                f(&from_glib_borrow(this))
639            }
640        }
641        unsafe {
642            let f: Box_<F> = Box_::new(f);
643            connect_raw(
644                self.as_ptr() as *mut _,
645                c"notify::position".as_ptr(),
646                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
647                    notify_position_trampoline::<F> as *const (),
648                )),
649                Box_::into_raw(f),
650            )
651        }
652    }
653
654    #[doc(alias = "ready-state")]
655    pub fn connect_ready_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
656        &self,
657        f: F,
658    ) -> SignalHandlerId {
659        unsafe extern "C" fn notify_ready_state_trampoline<
660            F: Fn(&MediaSource) + Send + Sync + 'static,
661        >(
662            this: *mut ffi::GstMediaSource,
663            _param_spec: glib::ffi::gpointer,
664            f: glib::ffi::gpointer,
665        ) {
666            unsafe {
667                let f: &F = &*(f as *const F);
668                f(&from_glib_borrow(this))
669            }
670        }
671        unsafe {
672            let f: Box_<F> = Box_::new(f);
673            connect_raw(
674                self.as_ptr() as *mut _,
675                c"notify::ready-state".as_ptr(),
676                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
677                    notify_ready_state_trampoline::<F> as *const (),
678                )),
679                Box_::into_raw(f),
680            )
681        }
682    }
683
684    #[doc(alias = "source-buffers")]
685    pub fn connect_source_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
686        &self,
687        f: F,
688    ) -> SignalHandlerId {
689        unsafe extern "C" fn notify_source_buffers_trampoline<
690            F: Fn(&MediaSource) + Send + Sync + 'static,
691        >(
692            this: *mut ffi::GstMediaSource,
693            _param_spec: glib::ffi::gpointer,
694            f: glib::ffi::gpointer,
695        ) {
696            unsafe {
697                let f: &F = &*(f as *const F);
698                f(&from_glib_borrow(this))
699            }
700        }
701        unsafe {
702            let f: Box_<F> = Box_::new(f);
703            connect_raw(
704                self.as_ptr() as *mut _,
705                c"notify::source-buffers".as_ptr(),
706                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
707                    notify_source_buffers_trampoline::<F> as *const (),
708                )),
709                Box_::into_raw(f),
710            )
711        }
712    }
713}
714
715impl Default for MediaSource {
716    fn default() -> Self {
717        Self::new()
718    }
719}
720
721unsafe impl Send for MediaSource {}
722unsafe impl Sync for MediaSource {}