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