gstreamer_mse/auto/
mse_src.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::{ffi, MseSrcReadyState};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// [`MseSrc`][crate::MseSrc] is a source Element that interacts with a [`MediaSource`][crate::MediaSource] to
16    /// consume `GstSample`<!-- -->s processed by the Media Source and supplies them
17    /// to the containing `GstPipeline`. In the perspective of the Media Source API,
18    /// this element fulfills the basis of the Media Element's role relating to
19    /// working with a Media Source. The remaining responsibilities are meant to be
20    /// fulfilled by the application and `GstPlay` can be used to satisfy many of
21    /// them.
22    ///
23    /// Once added to a Pipeline, this element should be attached to a Media Source
24    /// using [`MediaSource::attach()`][crate::MediaSource::attach()].
25    ///
26    /// ## Properties
27    ///
28    ///
29    /// #### `duration`
30    ///  The duration of the stream as a `GstClockTime`
31    ///
32    /// [Specification](https://html.spec.whatwg.org/multipage/media.html`dom`-media-duration)
33    ///
34    /// Readable | Writeable
35    ///
36    ///
37    /// #### `n-audio`
38    ///  The number of audio tracks in the Media Source
39    ///
40    /// Readable
41    ///
42    ///
43    /// #### `n-text`
44    ///  The number of text tracks in the Media Source
45    ///
46    /// Readable
47    ///
48    ///
49    /// #### `n-video`
50    ///  The number of video tracks in the Media Source
51    ///
52    /// Readable
53    ///
54    ///
55    /// #### `position`
56    ///  The playback position as a `GstClockTime`
57    ///
58    /// [Specification](https://html.spec.whatwg.org/multipage/media.html`current`-playback-position)
59    ///
60    /// Readable
61    ///
62    ///
63    /// #### `ready-state`
64    ///  The Ready State of this element, describing to what level it can supply
65    /// content for the current [`position`][struct@crate::MseSrc#position]. This is a separate concept
66    /// from [`ready-state`][struct@crate::MediaSource#ready-state]: and corresponds to the HTML Media
67    /// Element's Ready State.
68    ///
69    /// [Specification](https://html.spec.whatwg.org/multipage/media.html`ready`-states)
70    ///
71    /// Readable
72    /// <details><summary><h4>Object</h4></summary>
73    ///
74    ///
75    /// #### `name`
76    ///  Readable | Writeable | Construct
77    ///
78    ///
79    /// #### `parent`
80    ///  The parent of the object. Please note, that when changing the 'parent'
81    /// property, we don't emit `GObject::notify` and [`deep-notify`][struct@crate::gst::Object#deep-notify]
82    /// signals due to locking issues. In some cases one can use
83    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
84    /// achieve a similar effect.
85    ///
86    /// Readable | Writeable
87    /// </details>
88    ///
89    /// # Implements
90    ///
91    /// [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`]
92    #[doc(alias = "GstMseSrc")]
93    pub struct MseSrc(Object<ffi::GstMseSrc, ffi::GstMseSrcClass>) @extends gst::Element, gst::Object;
94
95    match fn {
96        type_ => || ffi::gst_mse_src_get_type(),
97    }
98}
99
100impl MseSrc {
101    /// Gets the duration of `self`.
102    ///
103    /// [Specification](https://html.spec.whatwg.org/multipage/media.html`dom`-media-duration)
104    ///
105    /// # Returns
106    ///
107    /// The duration of this stream as a `GstClockTime`
108    #[doc(alias = "gst_mse_src_get_duration")]
109    #[doc(alias = "get_duration")]
110    pub fn duration(&self) -> Option<gst::ClockTime> {
111        unsafe { from_glib(ffi::gst_mse_src_get_duration(self.to_glib_none().0)) }
112    }
113
114    ///
115    /// # Returns
116    ///
117    /// the number of audio tracks available from this source
118    #[doc(alias = "gst_mse_src_get_n_audio")]
119    #[doc(alias = "get_n_audio")]
120    #[doc(alias = "n-audio")]
121    pub fn n_audio(&self) -> u32 {
122        unsafe { ffi::gst_mse_src_get_n_audio(self.to_glib_none().0) }
123    }
124
125    ///
126    /// # Returns
127    ///
128    /// the number of text tracks available from this source
129    #[doc(alias = "gst_mse_src_get_n_text")]
130    #[doc(alias = "get_n_text")]
131    #[doc(alias = "n-text")]
132    pub fn n_text(&self) -> u32 {
133        unsafe { ffi::gst_mse_src_get_n_text(self.to_glib_none().0) }
134    }
135
136    ///
137    /// # Returns
138    ///
139    /// the number of video tracks available from this source
140    #[doc(alias = "gst_mse_src_get_n_video")]
141    #[doc(alias = "get_n_video")]
142    #[doc(alias = "n-video")]
143    pub fn n_video(&self) -> u32 {
144        unsafe { ffi::gst_mse_src_get_n_video(self.to_glib_none().0) }
145    }
146
147    /// Gets the current playback position of `self`.
148    ///
149    /// [Specification](https://html.spec.whatwg.org/multipage/media.html`current`-playback-position)
150    ///
151    /// # Returns
152    ///
153    /// The playback position of this Element as a `GstClockTime`
154    #[doc(alias = "gst_mse_src_get_position")]
155    #[doc(alias = "get_position")]
156    pub fn position(&self) -> Option<gst::ClockTime> {
157        unsafe { from_glib(ffi::gst_mse_src_get_position(self.to_glib_none().0)) }
158    }
159
160    /// The Ready State of `self`, describing to what level it can supply content for
161    /// the current [`position`][struct@crate::MseSrc#position]. This is a separate concept from
162    /// [`ready-state`][struct@crate::MediaSource#ready-state]: and corresponds to the HTML Media Element's
163    /// Ready State.
164    ///
165    /// [Specification](https://html.spec.whatwg.org/multipage/media.html`ready`-states)
166    ///
167    /// # Returns
168    ///
169    /// the current [`MseSrcReadyState`][crate::MseSrcReadyState]
170    #[doc(alias = "gst_mse_src_get_ready_state")]
171    #[doc(alias = "get_ready_state")]
172    #[doc(alias = "ready-state")]
173    pub fn ready_state(&self) -> MseSrcReadyState {
174        unsafe { from_glib(ffi::gst_mse_src_get_ready_state(self.to_glib_none().0)) }
175    }
176
177    /// The duration of the stream as a `GstClockTime`
178    ///
179    /// [Specification](https://html.spec.whatwg.org/multipage/media.html`dom`-media-duration)
180    pub fn set_duration(&self, duration: u64) {
181        ObjectExt::set_property(self, "duration", duration)
182    }
183
184    #[doc(alias = "duration")]
185    pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
186        &self,
187        f: F,
188    ) -> SignalHandlerId {
189        unsafe extern "C" fn notify_duration_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
190            this: *mut ffi::GstMseSrc,
191            _param_spec: glib::ffi::gpointer,
192            f: glib::ffi::gpointer,
193        ) {
194            let f: &F = &*(f as *const F);
195            f(&from_glib_borrow(this))
196        }
197        unsafe {
198            let f: Box_<F> = Box_::new(f);
199            connect_raw(
200                self.as_ptr() as *mut _,
201                c"notify::duration".as_ptr() as *const _,
202                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
203                    notify_duration_trampoline::<F> as *const (),
204                )),
205                Box_::into_raw(f),
206            )
207        }
208    }
209
210    #[doc(alias = "n-audio")]
211    pub fn connect_n_audio_notify<F: Fn(&Self) + Send + Sync + 'static>(
212        &self,
213        f: F,
214    ) -> SignalHandlerId {
215        unsafe extern "C" fn notify_n_audio_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
216            this: *mut ffi::GstMseSrc,
217            _param_spec: glib::ffi::gpointer,
218            f: glib::ffi::gpointer,
219        ) {
220            let f: &F = &*(f as *const F);
221            f(&from_glib_borrow(this))
222        }
223        unsafe {
224            let f: Box_<F> = Box_::new(f);
225            connect_raw(
226                self.as_ptr() as *mut _,
227                c"notify::n-audio".as_ptr() as *const _,
228                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
229                    notify_n_audio_trampoline::<F> as *const (),
230                )),
231                Box_::into_raw(f),
232            )
233        }
234    }
235
236    #[doc(alias = "n-text")]
237    pub fn connect_n_text_notify<F: Fn(&Self) + Send + Sync + 'static>(
238        &self,
239        f: F,
240    ) -> SignalHandlerId {
241        unsafe extern "C" fn notify_n_text_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
242            this: *mut ffi::GstMseSrc,
243            _param_spec: glib::ffi::gpointer,
244            f: glib::ffi::gpointer,
245        ) {
246            let f: &F = &*(f as *const F);
247            f(&from_glib_borrow(this))
248        }
249        unsafe {
250            let f: Box_<F> = Box_::new(f);
251            connect_raw(
252                self.as_ptr() as *mut _,
253                c"notify::n-text".as_ptr() as *const _,
254                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
255                    notify_n_text_trampoline::<F> as *const (),
256                )),
257                Box_::into_raw(f),
258            )
259        }
260    }
261
262    #[doc(alias = "n-video")]
263    pub fn connect_n_video_notify<F: Fn(&Self) + Send + Sync + 'static>(
264        &self,
265        f: F,
266    ) -> SignalHandlerId {
267        unsafe extern "C" fn notify_n_video_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
268            this: *mut ffi::GstMseSrc,
269            _param_spec: glib::ffi::gpointer,
270            f: glib::ffi::gpointer,
271        ) {
272            let f: &F = &*(f as *const F);
273            f(&from_glib_borrow(this))
274        }
275        unsafe {
276            let f: Box_<F> = Box_::new(f);
277            connect_raw(
278                self.as_ptr() as *mut _,
279                c"notify::n-video".as_ptr() as *const _,
280                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
281                    notify_n_video_trampoline::<F> as *const (),
282                )),
283                Box_::into_raw(f),
284            )
285        }
286    }
287
288    #[doc(alias = "position")]
289    pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
290        &self,
291        f: F,
292    ) -> SignalHandlerId {
293        unsafe extern "C" fn notify_position_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
294            this: *mut ffi::GstMseSrc,
295            _param_spec: glib::ffi::gpointer,
296            f: glib::ffi::gpointer,
297        ) {
298            let f: &F = &*(f as *const F);
299            f(&from_glib_borrow(this))
300        }
301        unsafe {
302            let f: Box_<F> = Box_::new(f);
303            connect_raw(
304                self.as_ptr() as *mut _,
305                c"notify::position".as_ptr() as *const _,
306                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
307                    notify_position_trampoline::<F> as *const (),
308                )),
309                Box_::into_raw(f),
310            )
311        }
312    }
313
314    #[doc(alias = "ready-state")]
315    pub fn connect_ready_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
316        &self,
317        f: F,
318    ) -> SignalHandlerId {
319        unsafe extern "C" fn notify_ready_state_trampoline<
320            F: Fn(&MseSrc) + Send + Sync + 'static,
321        >(
322            this: *mut ffi::GstMseSrc,
323            _param_spec: glib::ffi::gpointer,
324            f: glib::ffi::gpointer,
325        ) {
326            let f: &F = &*(f as *const F);
327            f(&from_glib_borrow(this))
328        }
329        unsafe {
330            let f: Box_<F> = Box_::new(f);
331            connect_raw(
332                self.as_ptr() as *mut _,
333                c"notify::ready-state".as_ptr() as *const _,
334                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
335                    notify_ready_state_trampoline::<F> as *const (),
336                )),
337                Box_::into_raw(f),
338            )
339        }
340    }
341}
342
343unsafe impl Send for MseSrc {}
344unsafe impl Sync for MseSrc {}