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")]
16 pub struct Stream(Object<ffi::GstStream, ffi::GstStreamClass>) @extends Object;
17
18 match fn {
19 type_ => || ffi::gst_stream_get_type(),
20 }
21}
22
23impl Stream {
24 #[doc(alias = "gst_stream_new")]
25 pub fn new(
26 stream_id: Option<&str>,
27 caps: Option<&Caps>,
28 type_: StreamType,
29 flags: StreamFlags,
30 ) -> Stream {
31 assert_initialized_main_thread!();
32 unsafe {
33 from_glib_full(ffi::gst_stream_new(
34 stream_id.to_glib_none().0,
35 caps.to_glib_none().0,
36 type_.into_glib(),
37 flags.into_glib(),
38 ))
39 }
40 }
41
42 #[doc(alias = "gst_stream_get_caps")]
43 #[doc(alias = "get_caps")]
44 pub fn caps(&self) -> Option<Caps> {
45 unsafe { from_glib_full(ffi::gst_stream_get_caps(self.to_glib_none().0)) }
46 }
47
48 #[doc(alias = "gst_stream_get_stream_flags")]
49 #[doc(alias = "get_stream_flags")]
50 #[doc(alias = "stream-flags")]
51 pub fn stream_flags(&self) -> StreamFlags {
52 unsafe { from_glib(ffi::gst_stream_get_stream_flags(self.to_glib_none().0)) }
53 }
54
55 #[doc(alias = "gst_stream_get_stream_id")]
56 #[doc(alias = "get_stream_id")]
57 #[doc(alias = "stream-id")]
58 pub fn stream_id(&self) -> Option<glib::GString> {
59 unsafe { from_glib_none(ffi::gst_stream_get_stream_id(self.to_glib_none().0)) }
60 }
61
62 #[doc(alias = "gst_stream_get_stream_type")]
63 #[doc(alias = "get_stream_type")]
64 #[doc(alias = "stream-type")]
65 pub fn stream_type(&self) -> StreamType {
66 unsafe { from_glib(ffi::gst_stream_get_stream_type(self.to_glib_none().0)) }
67 }
68
69 #[doc(alias = "gst_stream_get_tags")]
70 #[doc(alias = "get_tags")]
71 pub fn tags(&self) -> Option<TagList> {
72 unsafe { from_glib_full(ffi::gst_stream_get_tags(self.to_glib_none().0)) }
73 }
74
75 #[doc(alias = "gst_stream_set_caps")]
76 #[doc(alias = "caps")]
77 pub fn set_caps(&self, caps: Option<&Caps>) {
78 unsafe {
79 ffi::gst_stream_set_caps(self.to_glib_none().0, caps.to_glib_none().0);
80 }
81 }
82
83 #[doc(alias = "gst_stream_set_stream_flags")]
84 #[doc(alias = "stream-flags")]
85 pub fn set_stream_flags(&self, flags: StreamFlags) {
86 unsafe {
87 ffi::gst_stream_set_stream_flags(self.to_glib_none().0, flags.into_glib());
88 }
89 }
90
91 #[doc(alias = "gst_stream_set_stream_type")]
92 #[doc(alias = "stream-type")]
93 pub fn set_stream_type(&self, stream_type: StreamType) {
94 unsafe {
95 ffi::gst_stream_set_stream_type(self.to_glib_none().0, stream_type.into_glib());
96 }
97 }
98
99 #[doc(alias = "gst_stream_set_tags")]
100 #[doc(alias = "tags")]
101 pub fn set_tags(&self, tags: Option<&TagList>) {
102 unsafe {
103 ffi::gst_stream_set_tags(self.to_glib_none().0, tags.to_glib_none().0);
104 }
105 }
106
107 #[doc(alias = "caps")]
108 pub fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(
109 &self,
110 f: F,
111 ) -> SignalHandlerId {
112 unsafe extern "C" fn notify_caps_trampoline<F: Fn(&Stream) + Send + Sync + 'static>(
113 this: *mut ffi::GstStream,
114 _param_spec: glib::ffi::gpointer,
115 f: glib::ffi::gpointer,
116 ) {
117 let f: &F = &*(f as *const F);
118 f(&from_glib_borrow(this))
119 }
120 unsafe {
121 let f: Box_<F> = Box_::new(f);
122 connect_raw(
123 self.as_ptr() as *mut _,
124 b"notify::caps\0".as_ptr() as *const _,
125 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
126 notify_caps_trampoline::<F> as *const (),
127 )),
128 Box_::into_raw(f),
129 )
130 }
131 }
132
133 #[doc(alias = "stream-flags")]
134 pub fn connect_stream_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
135 &self,
136 f: F,
137 ) -> SignalHandlerId {
138 unsafe extern "C" fn notify_stream_flags_trampoline<
139 F: Fn(&Stream) + Send + Sync + 'static,
140 >(
141 this: *mut ffi::GstStream,
142 _param_spec: glib::ffi::gpointer,
143 f: glib::ffi::gpointer,
144 ) {
145 let f: &F = &*(f as *const F);
146 f(&from_glib_borrow(this))
147 }
148 unsafe {
149 let f: Box_<F> = Box_::new(f);
150 connect_raw(
151 self.as_ptr() as *mut _,
152 b"notify::stream-flags\0".as_ptr() as *const _,
153 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
154 notify_stream_flags_trampoline::<F> as *const (),
155 )),
156 Box_::into_raw(f),
157 )
158 }
159 }
160
161 #[doc(alias = "stream-type")]
162 pub fn connect_stream_type_notify<F: Fn(&Self) + Send + Sync + 'static>(
163 &self,
164 f: F,
165 ) -> SignalHandlerId {
166 unsafe extern "C" fn notify_stream_type_trampoline<
167 F: Fn(&Stream) + Send + Sync + 'static,
168 >(
169 this: *mut ffi::GstStream,
170 _param_spec: glib::ffi::gpointer,
171 f: glib::ffi::gpointer,
172 ) {
173 let f: &F = &*(f as *const F);
174 f(&from_glib_borrow(this))
175 }
176 unsafe {
177 let f: Box_<F> = Box_::new(f);
178 connect_raw(
179 self.as_ptr() as *mut _,
180 b"notify::stream-type\0".as_ptr() as *const _,
181 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
182 notify_stream_type_trampoline::<F> as *const (),
183 )),
184 Box_::into_raw(f),
185 )
186 }
187 }
188
189 #[doc(alias = "tags")]
190 pub fn connect_tags_notify<F: Fn(&Self) + Send + Sync + 'static>(
191 &self,
192 f: F,
193 ) -> SignalHandlerId {
194 unsafe extern "C" fn notify_tags_trampoline<F: Fn(&Stream) + Send + Sync + 'static>(
195 this: *mut ffi::GstStream,
196 _param_spec: glib::ffi::gpointer,
197 f: glib::ffi::gpointer,
198 ) {
199 let f: &F = &*(f as *const F);
200 f(&from_glib_borrow(this))
201 }
202 unsafe {
203 let f: Box_<F> = Box_::new(f);
204 connect_raw(
205 self.as_ptr() as *mut _,
206 b"notify::tags\0".as_ptr() as *const _,
207 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
208 notify_tags_trampoline::<F> as *const (),
209 )),
210 Box_::into_raw(f),
211 )
212 }
213 }
214}
215
216unsafe impl Send for Stream {}
217unsafe impl Sync for Stream {}