Skip to main content

gstreamer/auto/
stream.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::{Caps, Object, StreamFlags, StreamType, TagList, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// A high-level object representing a single stream. It might be backed, or
16    /// not, by an actual flow of data in a pipeline ([`Pad`][crate::Pad]).
17    ///
18    /// A [`Stream`][crate::Stream] does not care about data changes (such as decoding, encoding,
19    /// parsing,...) as long as the underlying data flow corresponds to the same
20    /// high-level flow (ex: a certain audio track).
21    ///
22    /// A [`Stream`][crate::Stream] contains all the information pertinent to a stream, such as
23    /// stream-id, tags, caps, type, ...
24    ///
25    /// Elements can subclass a [`Stream`][crate::Stream] for internal usage (to contain information
26    /// pertinent to streams of data).
27    ///
28    /// ## Properties
29    ///
30    ///
31    /// #### `caps`
32    ///  The [`Caps`][crate::Caps] of the [`Stream`][crate::Stream].
33    ///
34    /// Readable | Writeable
35    ///
36    ///
37    /// #### `stream-flags`
38    ///  Readable | Writeable | Construct
39    ///
40    ///
41    /// #### `stream-id`
42    ///  The unique identifier of the [`Stream`][crate::Stream]. Can only be set at construction
43    /// time.
44    ///
45    /// Readable | Writeable | Construct Only
46    ///
47    ///
48    /// #### `stream-type`
49    ///  The [`StreamType`][crate::StreamType] of the [`Stream`][crate::Stream]. Can only be set at construction time.
50    ///
51    /// Readable | Writeable | Construct
52    ///
53    ///
54    /// #### `tags`
55    ///  The [`TagList`][crate::TagList] of the [`Stream`][crate::Stream].
56    ///
57    /// Readable | Writeable
58    /// <details><summary><h4>Object</h4></summary>
59    ///
60    ///
61    /// #### `name`
62    ///  Readable | Writeable | Construct
63    ///
64    ///
65    /// #### `parent`
66    ///  The parent of the object. Please note, that when changing the 'parent'
67    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
68    /// signals due to locking issues. In some cases one can use
69    /// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
70    /// achieve a similar effect.
71    ///
72    /// Readable | Writeable
73    /// </details>
74    ///
75    /// # Implements
76    ///
77    /// [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`]
78    #[doc(alias = "GstStream")]
79    pub struct Stream(Object<ffi::GstStream, ffi::GstStreamClass>) @extends Object;
80
81    match fn {
82        type_ => || ffi::gst_stream_get_type(),
83    }
84}
85
86impl Stream {
87    /// Create a new [`Stream`][crate::Stream] for the given `stream_id`, `caps`, `type_`
88    /// and `flags`
89    /// ## `stream_id`
90    /// the id for the new stream. If [`None`],
91    /// a new one will be automatically generated
92    /// ## `caps`
93    /// the [`Caps`][crate::Caps] of the stream
94    /// ## `type_`
95    /// the [`StreamType`][crate::StreamType] of the stream
96    /// ## `flags`
97    /// the [`StreamFlags`][crate::StreamFlags] of the stream
98    ///
99    /// # Returns
100    ///
101    /// The new [`Stream`][crate::Stream]
102    #[doc(alias = "gst_stream_new")]
103    pub fn new(
104        stream_id: Option<&str>,
105        caps: Option<&Caps>,
106        type_: StreamType,
107        flags: StreamFlags,
108    ) -> Stream {
109        assert_initialized_main_thread!();
110        unsafe {
111            from_glib_full(ffi::gst_stream_new(
112                stream_id.to_glib_none().0,
113                caps.to_glib_none().0,
114                type_.into_glib(),
115                flags.into_glib(),
116            ))
117        }
118    }
119
120    /// Retrieve the caps for `self`, if any
121    ///
122    /// # Returns
123    ///
124    /// The [`Caps`][crate::Caps] for `self`
125    #[doc(alias = "gst_stream_get_caps")]
126    #[doc(alias = "get_caps")]
127    pub fn caps(&self) -> Option<Caps> {
128        unsafe { from_glib_full(ffi::gst_stream_get_caps(self.to_glib_none().0)) }
129    }
130
131    /// Retrieve the current stream flags for `self`
132    ///
133    /// # Returns
134    ///
135    /// The [`StreamFlags`][crate::StreamFlags] for `self`
136    #[doc(alias = "gst_stream_get_stream_flags")]
137    #[doc(alias = "get_stream_flags")]
138    #[doc(alias = "stream-flags")]
139    pub fn stream_flags(&self) -> StreamFlags {
140        unsafe { from_glib(ffi::gst_stream_get_stream_flags(self.to_glib_none().0)) }
141    }
142
143    /// Returns the stream ID of `self`.
144    ///
145    /// # Returns
146    ///
147    /// the stream ID of `self`. Only valid
148    /// during the lifetime of `self`.
149    #[doc(alias = "gst_stream_get_stream_id")]
150    #[doc(alias = "get_stream_id")]
151    #[doc(alias = "stream-id")]
152    pub fn stream_id(&self) -> Option<glib::GString> {
153        unsafe { from_glib_none(ffi::gst_stream_get_stream_id(self.to_glib_none().0)) }
154    }
155
156    /// Retrieve the stream type for `self`
157    ///
158    /// # Returns
159    ///
160    /// The [`StreamType`][crate::StreamType] for `self`
161    #[doc(alias = "gst_stream_get_stream_type")]
162    #[doc(alias = "get_stream_type")]
163    #[doc(alias = "stream-type")]
164    pub fn stream_type(&self) -> StreamType {
165        unsafe { from_glib(ffi::gst_stream_get_stream_type(self.to_glib_none().0)) }
166    }
167
168    /// Retrieve the tags for `self`, if any
169    ///
170    /// # Returns
171    ///
172    /// The [`TagList`][crate::TagList] for `self`
173    #[doc(alias = "gst_stream_get_tags")]
174    #[doc(alias = "get_tags")]
175    pub fn tags(&self) -> Option<TagList> {
176        unsafe { from_glib_full(ffi::gst_stream_get_tags(self.to_glib_none().0)) }
177    }
178
179    /// Set the caps for the [`Stream`][crate::Stream]
180    /// ## `caps`
181    /// a [`Caps`][crate::Caps]
182    #[doc(alias = "gst_stream_set_caps")]
183    #[doc(alias = "caps")]
184    pub fn set_caps(&self, caps: Option<&Caps>) {
185        unsafe {
186            ffi::gst_stream_set_caps(self.to_glib_none().0, caps.to_glib_none().0);
187        }
188    }
189
190    /// Set the `flags` for the `self`.
191    /// ## `flags`
192    /// the flags to set on `self`
193    #[doc(alias = "gst_stream_set_stream_flags")]
194    #[doc(alias = "stream-flags")]
195    pub fn set_stream_flags(&self, flags: StreamFlags) {
196        unsafe {
197            ffi::gst_stream_set_stream_flags(self.to_glib_none().0, flags.into_glib());
198        }
199    }
200
201    /// Set the stream type of `self`
202    /// ## `stream_type`
203    /// the type to set on `self`
204    #[doc(alias = "gst_stream_set_stream_type")]
205    #[doc(alias = "stream-type")]
206    pub fn set_stream_type(&self, stream_type: StreamType) {
207        unsafe {
208            ffi::gst_stream_set_stream_type(self.to_glib_none().0, stream_type.into_glib());
209        }
210    }
211
212    /// Set the tags for the [`Stream`][crate::Stream]
213    /// ## `tags`
214    /// a [`TagList`][crate::TagList]
215    #[doc(alias = "gst_stream_set_tags")]
216    #[doc(alias = "tags")]
217    pub fn set_tags(&self, tags: Option<&TagList>) {
218        unsafe {
219            ffi::gst_stream_set_tags(self.to_glib_none().0, tags.to_glib_none().0);
220        }
221    }
222
223    #[doc(alias = "caps")]
224    pub fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(
225        &self,
226        f: F,
227    ) -> SignalHandlerId {
228        unsafe extern "C" fn notify_caps_trampoline<F: Fn(&Stream) + Send + Sync + 'static>(
229            this: *mut ffi::GstStream,
230            _param_spec: glib::ffi::gpointer,
231            f: glib::ffi::gpointer,
232        ) {
233            unsafe {
234                let f: &F = &*(f as *const F);
235                f(&from_glib_borrow(this))
236            }
237        }
238        unsafe {
239            let f: Box_<F> = Box_::new(f);
240            connect_raw(
241                self.as_ptr() as *mut _,
242                c"notify::caps".as_ptr(),
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244                    notify_caps_trampoline::<F> as *const (),
245                )),
246                Box_::into_raw(f),
247            )
248        }
249    }
250
251    #[doc(alias = "stream-flags")]
252    pub fn connect_stream_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
253        &self,
254        f: F,
255    ) -> SignalHandlerId {
256        unsafe extern "C" fn notify_stream_flags_trampoline<
257            F: Fn(&Stream) + Send + Sync + 'static,
258        >(
259            this: *mut ffi::GstStream,
260            _param_spec: glib::ffi::gpointer,
261            f: glib::ffi::gpointer,
262        ) {
263            unsafe {
264                let f: &F = &*(f as *const F);
265                f(&from_glib_borrow(this))
266            }
267        }
268        unsafe {
269            let f: Box_<F> = Box_::new(f);
270            connect_raw(
271                self.as_ptr() as *mut _,
272                c"notify::stream-flags".as_ptr(),
273                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
274                    notify_stream_flags_trampoline::<F> as *const (),
275                )),
276                Box_::into_raw(f),
277            )
278        }
279    }
280
281    #[doc(alias = "stream-type")]
282    pub fn connect_stream_type_notify<F: Fn(&Self) + Send + Sync + 'static>(
283        &self,
284        f: F,
285    ) -> SignalHandlerId {
286        unsafe extern "C" fn notify_stream_type_trampoline<
287            F: Fn(&Stream) + Send + Sync + 'static,
288        >(
289            this: *mut ffi::GstStream,
290            _param_spec: glib::ffi::gpointer,
291            f: glib::ffi::gpointer,
292        ) {
293            unsafe {
294                let f: &F = &*(f as *const F);
295                f(&from_glib_borrow(this))
296            }
297        }
298        unsafe {
299            let f: Box_<F> = Box_::new(f);
300            connect_raw(
301                self.as_ptr() as *mut _,
302                c"notify::stream-type".as_ptr(),
303                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
304                    notify_stream_type_trampoline::<F> as *const (),
305                )),
306                Box_::into_raw(f),
307            )
308        }
309    }
310
311    #[doc(alias = "tags")]
312    pub fn connect_tags_notify<F: Fn(&Self) + Send + Sync + 'static>(
313        &self,
314        f: F,
315    ) -> SignalHandlerId {
316        unsafe extern "C" fn notify_tags_trampoline<F: Fn(&Stream) + Send + Sync + 'static>(
317            this: *mut ffi::GstStream,
318            _param_spec: glib::ffi::gpointer,
319            f: glib::ffi::gpointer,
320        ) {
321            unsafe {
322                let f: &F = &*(f as *const F);
323                f(&from_glib_borrow(this))
324            }
325        }
326        unsafe {
327            let f: Box_<F> = Box_::new(f);
328            connect_raw(
329                self.as_ptr() as *mut _,
330                c"notify::tags".as_ptr(),
331                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
332                    notify_tags_trampoline::<F> as *const (),
333                )),
334                Box_::into_raw(f),
335            )
336        }
337    }
338}
339
340unsafe impl Send for Stream {}
341unsafe impl Sync for Stream {}