Skip to main content

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::{MseSrcReadyState, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
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            unsafe {
195                let f: &F = &*(f as *const F);
196                f(&from_glib_borrow(this))
197            }
198        }
199        unsafe {
200            let f: Box_<F> = Box_::new(f);
201            connect_raw(
202                self.as_ptr() as *mut _,
203                c"notify::duration".as_ptr(),
204                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
205                    notify_duration_trampoline::<F> as *const (),
206                )),
207                Box_::into_raw(f),
208            )
209        }
210    }
211
212    #[doc(alias = "n-audio")]
213    pub fn connect_n_audio_notify<F: Fn(&Self) + Send + Sync + 'static>(
214        &self,
215        f: F,
216    ) -> SignalHandlerId {
217        unsafe extern "C" fn notify_n_audio_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
218            this: *mut ffi::GstMseSrc,
219            _param_spec: glib::ffi::gpointer,
220            f: glib::ffi::gpointer,
221        ) {
222            unsafe {
223                let f: &F = &*(f as *const F);
224                f(&from_glib_borrow(this))
225            }
226        }
227        unsafe {
228            let f: Box_<F> = Box_::new(f);
229            connect_raw(
230                self.as_ptr() as *mut _,
231                c"notify::n-audio".as_ptr(),
232                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
233                    notify_n_audio_trampoline::<F> as *const (),
234                )),
235                Box_::into_raw(f),
236            )
237        }
238    }
239
240    #[doc(alias = "n-text")]
241    pub fn connect_n_text_notify<F: Fn(&Self) + Send + Sync + 'static>(
242        &self,
243        f: F,
244    ) -> SignalHandlerId {
245        unsafe extern "C" fn notify_n_text_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
246            this: *mut ffi::GstMseSrc,
247            _param_spec: glib::ffi::gpointer,
248            f: glib::ffi::gpointer,
249        ) {
250            unsafe {
251                let f: &F = &*(f as *const F);
252                f(&from_glib_borrow(this))
253            }
254        }
255        unsafe {
256            let f: Box_<F> = Box_::new(f);
257            connect_raw(
258                self.as_ptr() as *mut _,
259                c"notify::n-text".as_ptr(),
260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
261                    notify_n_text_trampoline::<F> as *const (),
262                )),
263                Box_::into_raw(f),
264            )
265        }
266    }
267
268    #[doc(alias = "n-video")]
269    pub fn connect_n_video_notify<F: Fn(&Self) + Send + Sync + 'static>(
270        &self,
271        f: F,
272    ) -> SignalHandlerId {
273        unsafe extern "C" fn notify_n_video_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
274            this: *mut ffi::GstMseSrc,
275            _param_spec: glib::ffi::gpointer,
276            f: glib::ffi::gpointer,
277        ) {
278            unsafe {
279                let f: &F = &*(f as *const F);
280                f(&from_glib_borrow(this))
281            }
282        }
283        unsafe {
284            let f: Box_<F> = Box_::new(f);
285            connect_raw(
286                self.as_ptr() as *mut _,
287                c"notify::n-video".as_ptr(),
288                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
289                    notify_n_video_trampoline::<F> as *const (),
290                )),
291                Box_::into_raw(f),
292            )
293        }
294    }
295
296    #[doc(alias = "position")]
297    pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
298        &self,
299        f: F,
300    ) -> SignalHandlerId {
301        unsafe extern "C" fn notify_position_trampoline<F: Fn(&MseSrc) + Send + Sync + 'static>(
302            this: *mut ffi::GstMseSrc,
303            _param_spec: glib::ffi::gpointer,
304            f: glib::ffi::gpointer,
305        ) {
306            unsafe {
307                let f: &F = &*(f as *const F);
308                f(&from_glib_borrow(this))
309            }
310        }
311        unsafe {
312            let f: Box_<F> = Box_::new(f);
313            connect_raw(
314                self.as_ptr() as *mut _,
315                c"notify::position".as_ptr(),
316                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
317                    notify_position_trampoline::<F> as *const (),
318                )),
319                Box_::into_raw(f),
320            )
321        }
322    }
323
324    #[doc(alias = "ready-state")]
325    pub fn connect_ready_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
326        &self,
327        f: F,
328    ) -> SignalHandlerId {
329        unsafe extern "C" fn notify_ready_state_trampoline<
330            F: Fn(&MseSrc) + Send + Sync + 'static,
331        >(
332            this: *mut ffi::GstMseSrc,
333            _param_spec: glib::ffi::gpointer,
334            f: glib::ffi::gpointer,
335        ) {
336            unsafe {
337                let f: &F = &*(f as *const F);
338                f(&from_glib_borrow(this))
339            }
340        }
341        unsafe {
342            let f: Box_<F> = Box_::new(f);
343            connect_raw(
344                self.as_ptr() as *mut _,
345                c"notify::ready-state".as_ptr(),
346                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347                    notify_ready_state_trampoline::<F> as *const (),
348                )),
349                Box_::into_raw(f),
350            )
351        }
352    }
353}
354
355unsafe impl Send for MseSrc {}
356unsafe impl Sync for MseSrc {}