gstreamer/auto/
stream.rs
1use crate::{ffi, Caps, Object, StreamFlags, StreamType, TagList};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 let f: &F = &*(f as *const F);
234 f(&from_glib_borrow(this))
235 }
236 unsafe {
237 let f: Box_<F> = Box_::new(f);
238 connect_raw(
239 self.as_ptr() as *mut _,
240 c"notify::caps".as_ptr() as *const _,
241 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
242 notify_caps_trampoline::<F> as *const (),
243 )),
244 Box_::into_raw(f),
245 )
246 }
247 }
248
249 #[doc(alias = "stream-flags")]
250 pub fn connect_stream_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
251 &self,
252 f: F,
253 ) -> SignalHandlerId {
254 unsafe extern "C" fn notify_stream_flags_trampoline<
255 F: Fn(&Stream) + Send + Sync + 'static,
256 >(
257 this: *mut ffi::GstStream,
258 _param_spec: glib::ffi::gpointer,
259 f: glib::ffi::gpointer,
260 ) {
261 let f: &F = &*(f as *const F);
262 f(&from_glib_borrow(this))
263 }
264 unsafe {
265 let f: Box_<F> = Box_::new(f);
266 connect_raw(
267 self.as_ptr() as *mut _,
268 c"notify::stream-flags".as_ptr() as *const _,
269 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
270 notify_stream_flags_trampoline::<F> as *const (),
271 )),
272 Box_::into_raw(f),
273 )
274 }
275 }
276
277 #[doc(alias = "stream-type")]
278 pub fn connect_stream_type_notify<F: Fn(&Self) + Send + Sync + 'static>(
279 &self,
280 f: F,
281 ) -> SignalHandlerId {
282 unsafe extern "C" fn notify_stream_type_trampoline<
283 F: Fn(&Stream) + Send + Sync + 'static,
284 >(
285 this: *mut ffi::GstStream,
286 _param_spec: glib::ffi::gpointer,
287 f: glib::ffi::gpointer,
288 ) {
289 let f: &F = &*(f as *const F);
290 f(&from_glib_borrow(this))
291 }
292 unsafe {
293 let f: Box_<F> = Box_::new(f);
294 connect_raw(
295 self.as_ptr() as *mut _,
296 c"notify::stream-type".as_ptr() as *const _,
297 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
298 notify_stream_type_trampoline::<F> as *const (),
299 )),
300 Box_::into_raw(f),
301 )
302 }
303 }
304
305 #[doc(alias = "tags")]
306 pub fn connect_tags_notify<F: Fn(&Self) + Send + Sync + 'static>(
307 &self,
308 f: F,
309 ) -> SignalHandlerId {
310 unsafe extern "C" fn notify_tags_trampoline<F: Fn(&Stream) + Send + Sync + 'static>(
311 this: *mut ffi::GstStream,
312 _param_spec: glib::ffi::gpointer,
313 f: glib::ffi::gpointer,
314 ) {
315 let f: &F = &*(f as *const F);
316 f(&from_glib_borrow(this))
317 }
318 unsafe {
319 let f: Box_<F> = Box_::new(f);
320 connect_raw(
321 self.as_ptr() as *mut _,
322 c"notify::tags".as_ptr() as *const _,
323 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
324 notify_tags_trampoline::<F> as *const (),
325 )),
326 Box_::into_raw(f),
327 )
328 }
329 }
330}
331
332unsafe impl Send for Stream {}
333unsafe impl Sync for Stream {}