1#![allow(deprecated)]
6
7use crate::ffi;
8use glib::{
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 #[doc(alias = "GstBaseSrc")]
17 pub struct BaseSrc(Object<ffi::GstBaseSrc, ffi::GstBaseSrcClass>) @extends gst::Element, gst::Object;
18
19 match fn {
20 type_ => || ffi::gst_base_src_get_type(),
21 }
22}
23
24impl BaseSrc {
25 pub const NONE: Option<&'static BaseSrc> = None;
26}
27
28unsafe impl Send for BaseSrc {}
29unsafe impl Sync for BaseSrc {}
30
31pub trait BaseSrcExt: IsA<BaseSrc> + 'static {
32 #[doc(alias = "gst_base_src_get_blocksize")]
33 #[doc(alias = "get_blocksize")]
34 fn blocksize(&self) -> u32 {
35 unsafe { ffi::gst_base_src_get_blocksize(self.as_ref().to_glib_none().0) }
36 }
37
38 #[doc(alias = "gst_base_src_get_buffer_pool")]
39 #[doc(alias = "get_buffer_pool")]
40 fn buffer_pool(&self) -> Option<gst::BufferPool> {
41 unsafe {
42 from_glib_full(ffi::gst_base_src_get_buffer_pool(
43 self.as_ref().to_glib_none().0,
44 ))
45 }
46 }
47
48 #[doc(alias = "gst_base_src_get_do_timestamp")]
49 #[doc(alias = "get_do_timestamp")]
50 #[doc(alias = "do-timestamp")]
51 fn does_timestamp(&self) -> bool {
52 unsafe {
53 from_glib(ffi::gst_base_src_get_do_timestamp(
54 self.as_ref().to_glib_none().0,
55 ))
56 }
57 }
58
59 #[doc(alias = "gst_base_src_is_async")]
60 fn is_async(&self) -> bool {
61 unsafe { from_glib(ffi::gst_base_src_is_async(self.as_ref().to_glib_none().0)) }
62 }
63
64 #[doc(alias = "gst_base_src_is_live")]
65 fn is_live(&self) -> bool {
66 unsafe { from_glib(ffi::gst_base_src_is_live(self.as_ref().to_glib_none().0)) }
67 }
68
69 #[cfg(feature = "v1_18")]
70 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
71 #[doc(alias = "gst_base_src_negotiate")]
72 fn negotiate(&self) -> bool {
73 unsafe { from_glib(ffi::gst_base_src_negotiate(self.as_ref().to_glib_none().0)) }
74 }
75
76 #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
77 #[allow(deprecated)]
78 #[doc(alias = "gst_base_src_new_seamless_segment")]
79 fn new_seamless_segment(&self, start: i64, stop: i64, time: i64) -> bool {
80 unsafe {
81 from_glib(ffi::gst_base_src_new_seamless_segment(
82 self.as_ref().to_glib_none().0,
83 start,
84 stop,
85 time,
86 ))
87 }
88 }
89
90 #[cfg(feature = "v1_18")]
91 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
92 #[doc(alias = "gst_base_src_new_segment")]
93 fn new_segment(&self, segment: &gst::Segment) -> Result<(), glib::error::BoolError> {
94 unsafe {
95 glib::result_from_gboolean!(
96 ffi::gst_base_src_new_segment(
97 self.as_ref().to_glib_none().0,
98 segment.to_glib_none().0
99 ),
100 "Failed to update segment"
101 )
102 }
103 }
104
105 #[cfg(feature = "v1_24")]
106 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
107 #[doc(alias = "gst_base_src_push_segment")]
108 fn push_segment(&self, segment: &gst::Segment) -> bool {
109 unsafe {
110 from_glib(ffi::gst_base_src_push_segment(
111 self.as_ref().to_glib_none().0,
112 segment.to_glib_none().0,
113 ))
114 }
115 }
116
117 #[doc(alias = "gst_base_src_set_async")]
118 fn set_async(&self, async_: bool) {
119 unsafe {
120 ffi::gst_base_src_set_async(self.as_ref().to_glib_none().0, async_.into_glib());
121 }
122 }
123
124 #[doc(alias = "gst_base_src_set_automatic_eos")]
125 #[doc(alias = "automatic-eos")]
126 fn set_automatic_eos(&self, automatic_eos: bool) {
127 unsafe {
128 ffi::gst_base_src_set_automatic_eos(
129 self.as_ref().to_glib_none().0,
130 automatic_eos.into_glib(),
131 );
132 }
133 }
134
135 #[doc(alias = "gst_base_src_set_blocksize")]
136 #[doc(alias = "blocksize")]
137 fn set_blocksize(&self, blocksize: u32) {
138 unsafe {
139 ffi::gst_base_src_set_blocksize(self.as_ref().to_glib_none().0, blocksize);
140 }
141 }
142
143 #[doc(alias = "gst_base_src_set_caps")]
144 fn set_caps(&self, caps: &gst::Caps) -> Result<(), glib::error::BoolError> {
145 unsafe {
146 glib::result_from_gboolean!(
147 ffi::gst_base_src_set_caps(self.as_ref().to_glib_none().0, caps.to_glib_none().0),
148 "Failed to set caps"
149 )
150 }
151 }
152
153 #[doc(alias = "gst_base_src_set_do_timestamp")]
154 #[doc(alias = "do-timestamp")]
155 fn set_do_timestamp(&self, timestamp: bool) {
156 unsafe {
157 ffi::gst_base_src_set_do_timestamp(
158 self.as_ref().to_glib_none().0,
159 timestamp.into_glib(),
160 );
161 }
162 }
163
164 #[doc(alias = "gst_base_src_set_dynamic_size")]
165 fn set_dynamic_size(&self, dynamic: bool) {
166 unsafe {
167 ffi::gst_base_src_set_dynamic_size(self.as_ref().to_glib_none().0, dynamic.into_glib());
168 }
169 }
170
171 #[doc(alias = "gst_base_src_set_format")]
172 fn set_format(&self, format: gst::Format) {
173 unsafe {
174 ffi::gst_base_src_set_format(self.as_ref().to_glib_none().0, format.into_glib());
175 }
176 }
177
178 #[doc(alias = "gst_base_src_set_live")]
179 fn set_live(&self, live: bool) {
180 unsafe {
181 ffi::gst_base_src_set_live(self.as_ref().to_glib_none().0, live.into_glib());
182 }
183 }
184
185 #[doc(alias = "gst_base_src_start_complete")]
186 fn start_complete(&self, ret: impl Into<gst::FlowReturn>) {
187 unsafe {
188 ffi::gst_base_src_start_complete(
189 self.as_ref().to_glib_none().0,
190 ret.into().into_glib(),
191 );
192 }
193 }
194
195 #[doc(alias = "gst_base_src_start_wait")]
196 fn start_wait(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
197 unsafe { try_from_glib(ffi::gst_base_src_start_wait(self.as_ref().to_glib_none().0)) }
198 }
199
200 #[doc(alias = "gst_base_src_wait_playing")]
201 fn wait_playing(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
202 unsafe {
203 try_from_glib(ffi::gst_base_src_wait_playing(
204 self.as_ref().to_glib_none().0,
205 ))
206 }
207 }
208
209 #[cfg(feature = "v1_24")]
210 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
211 #[doc(alias = "automatic-eos")]
212 fn is_automatic_eos(&self) -> bool {
213 ObjectExt::property(self.as_ref(), "automatic-eos")
214 }
215
216 #[doc(alias = "num-buffers")]
217 fn num_buffers(&self) -> i32 {
218 ObjectExt::property(self.as_ref(), "num-buffers")
219 }
220
221 #[doc(alias = "num-buffers")]
222 fn set_num_buffers(&self, num_buffers: i32) {
223 ObjectExt::set_property(self.as_ref(), "num-buffers", num_buffers)
224 }
225
226 fn is_typefind(&self) -> bool {
227 ObjectExt::property(self.as_ref(), "typefind")
228 }
229
230 fn set_typefind(&self, typefind: bool) {
231 ObjectExt::set_property(self.as_ref(), "typefind", typefind)
232 }
233
234 #[cfg(feature = "v1_24")]
235 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
236 #[doc(alias = "automatic-eos")]
237 fn connect_automatic_eos_notify<F: Fn(&Self) + Send + Sync + 'static>(
238 &self,
239 f: F,
240 ) -> SignalHandlerId {
241 unsafe extern "C" fn notify_automatic_eos_trampoline<
242 P: IsA<BaseSrc>,
243 F: Fn(&P) + Send + Sync + 'static,
244 >(
245 this: *mut ffi::GstBaseSrc,
246 _param_spec: glib::ffi::gpointer,
247 f: glib::ffi::gpointer,
248 ) {
249 let f: &F = &*(f as *const F);
250 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
251 }
252 unsafe {
253 let f: Box_<F> = Box_::new(f);
254 connect_raw(
255 self.as_ptr() as *mut _,
256 c"notify::automatic-eos".as_ptr() as *const _,
257 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
258 notify_automatic_eos_trampoline::<Self, F> as *const (),
259 )),
260 Box_::into_raw(f),
261 )
262 }
263 }
264
265 #[doc(alias = "blocksize")]
266 fn connect_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(
267 &self,
268 f: F,
269 ) -> SignalHandlerId {
270 unsafe extern "C" fn notify_blocksize_trampoline<
271 P: IsA<BaseSrc>,
272 F: Fn(&P) + Send + Sync + 'static,
273 >(
274 this: *mut ffi::GstBaseSrc,
275 _param_spec: glib::ffi::gpointer,
276 f: glib::ffi::gpointer,
277 ) {
278 let f: &F = &*(f as *const F);
279 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
280 }
281 unsafe {
282 let f: Box_<F> = Box_::new(f);
283 connect_raw(
284 self.as_ptr() as *mut _,
285 c"notify::blocksize".as_ptr() as *const _,
286 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
287 notify_blocksize_trampoline::<Self, F> as *const (),
288 )),
289 Box_::into_raw(f),
290 )
291 }
292 }
293
294 #[doc(alias = "do-timestamp")]
295 fn connect_do_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(
296 &self,
297 f: F,
298 ) -> SignalHandlerId {
299 unsafe extern "C" fn notify_do_timestamp_trampoline<
300 P: IsA<BaseSrc>,
301 F: Fn(&P) + Send + Sync + 'static,
302 >(
303 this: *mut ffi::GstBaseSrc,
304 _param_spec: glib::ffi::gpointer,
305 f: glib::ffi::gpointer,
306 ) {
307 let f: &F = &*(f as *const F);
308 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
309 }
310 unsafe {
311 let f: Box_<F> = Box_::new(f);
312 connect_raw(
313 self.as_ptr() as *mut _,
314 c"notify::do-timestamp".as_ptr() as *const _,
315 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
316 notify_do_timestamp_trampoline::<Self, F> as *const (),
317 )),
318 Box_::into_raw(f),
319 )
320 }
321 }
322
323 #[doc(alias = "num-buffers")]
324 fn connect_num_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
325 &self,
326 f: F,
327 ) -> SignalHandlerId {
328 unsafe extern "C" fn notify_num_buffers_trampoline<
329 P: IsA<BaseSrc>,
330 F: Fn(&P) + Send + Sync + 'static,
331 >(
332 this: *mut ffi::GstBaseSrc,
333 _param_spec: glib::ffi::gpointer,
334 f: glib::ffi::gpointer,
335 ) {
336 let f: &F = &*(f as *const F);
337 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
338 }
339 unsafe {
340 let f: Box_<F> = Box_::new(f);
341 connect_raw(
342 self.as_ptr() as *mut _,
343 c"notify::num-buffers".as_ptr() as *const _,
344 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
345 notify_num_buffers_trampoline::<Self, F> as *const (),
346 )),
347 Box_::into_raw(f),
348 )
349 }
350 }
351
352 #[doc(alias = "typefind")]
353 fn connect_typefind_notify<F: Fn(&Self) + Send + Sync + 'static>(
354 &self,
355 f: F,
356 ) -> SignalHandlerId {
357 unsafe extern "C" fn notify_typefind_trampoline<
358 P: IsA<BaseSrc>,
359 F: Fn(&P) + Send + Sync + 'static,
360 >(
361 this: *mut ffi::GstBaseSrc,
362 _param_spec: glib::ffi::gpointer,
363 f: glib::ffi::gpointer,
364 ) {
365 let f: &F = &*(f as *const F);
366 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
367 }
368 unsafe {
369 let f: Box_<F> = Box_::new(f);
370 connect_raw(
371 self.as_ptr() as *mut _,
372 c"notify::typefind".as_ptr() as *const _,
373 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
374 notify_typefind_trampoline::<Self, F> as *const (),
375 )),
376 Box_::into_raw(f),
377 )
378 }
379 }
380}
381
382impl<O: IsA<BaseSrc>> BaseSrcExt for O {}