1#![allow(deprecated)]
6
7use crate::ffi;
8use glib::{
9 prelude::*,
10 signal::{SignalHandlerId, connect_raw},
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 unsafe {
250 let f: &F = &*(f as *const F);
251 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
252 }
253 }
254 unsafe {
255 let f: Box_<F> = Box_::new(f);
256 connect_raw(
257 self.as_ptr() as *mut _,
258 c"notify::automatic-eos".as_ptr() as *const _,
259 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
260 notify_automatic_eos_trampoline::<Self, F> as *const (),
261 )),
262 Box_::into_raw(f),
263 )
264 }
265 }
266
267 #[doc(alias = "blocksize")]
268 fn connect_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(
269 &self,
270 f: F,
271 ) -> SignalHandlerId {
272 unsafe extern "C" fn notify_blocksize_trampoline<
273 P: IsA<BaseSrc>,
274 F: Fn(&P) + Send + Sync + 'static,
275 >(
276 this: *mut ffi::GstBaseSrc,
277 _param_spec: glib::ffi::gpointer,
278 f: glib::ffi::gpointer,
279 ) {
280 unsafe {
281 let f: &F = &*(f as *const F);
282 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
283 }
284 }
285 unsafe {
286 let f: Box_<F> = Box_::new(f);
287 connect_raw(
288 self.as_ptr() as *mut _,
289 c"notify::blocksize".as_ptr() as *const _,
290 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
291 notify_blocksize_trampoline::<Self, F> as *const (),
292 )),
293 Box_::into_raw(f),
294 )
295 }
296 }
297
298 #[doc(alias = "do-timestamp")]
299 fn connect_do_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(
300 &self,
301 f: F,
302 ) -> SignalHandlerId {
303 unsafe extern "C" fn notify_do_timestamp_trampoline<
304 P: IsA<BaseSrc>,
305 F: Fn(&P) + Send + Sync + 'static,
306 >(
307 this: *mut ffi::GstBaseSrc,
308 _param_spec: glib::ffi::gpointer,
309 f: glib::ffi::gpointer,
310 ) {
311 unsafe {
312 let f: &F = &*(f as *const F);
313 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
314 }
315 }
316 unsafe {
317 let f: Box_<F> = Box_::new(f);
318 connect_raw(
319 self.as_ptr() as *mut _,
320 c"notify::do-timestamp".as_ptr() as *const _,
321 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
322 notify_do_timestamp_trampoline::<Self, F> as *const (),
323 )),
324 Box_::into_raw(f),
325 )
326 }
327 }
328
329 #[doc(alias = "num-buffers")]
330 fn connect_num_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
331 &self,
332 f: F,
333 ) -> SignalHandlerId {
334 unsafe extern "C" fn notify_num_buffers_trampoline<
335 P: IsA<BaseSrc>,
336 F: Fn(&P) + Send + Sync + 'static,
337 >(
338 this: *mut ffi::GstBaseSrc,
339 _param_spec: glib::ffi::gpointer,
340 f: glib::ffi::gpointer,
341 ) {
342 unsafe {
343 let f: &F = &*(f as *const F);
344 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
345 }
346 }
347 unsafe {
348 let f: Box_<F> = Box_::new(f);
349 connect_raw(
350 self.as_ptr() as *mut _,
351 c"notify::num-buffers".as_ptr() as *const _,
352 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
353 notify_num_buffers_trampoline::<Self, F> as *const (),
354 )),
355 Box_::into_raw(f),
356 )
357 }
358 }
359
360 #[doc(alias = "typefind")]
361 fn connect_typefind_notify<F: Fn(&Self) + Send + Sync + 'static>(
362 &self,
363 f: F,
364 ) -> SignalHandlerId {
365 unsafe extern "C" fn notify_typefind_trampoline<
366 P: IsA<BaseSrc>,
367 F: Fn(&P) + Send + Sync + 'static,
368 >(
369 this: *mut ffi::GstBaseSrc,
370 _param_spec: glib::ffi::gpointer,
371 f: glib::ffi::gpointer,
372 ) {
373 unsafe {
374 let f: &F = &*(f as *const F);
375 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
376 }
377 }
378 unsafe {
379 let f: Box_<F> = Box_::new(f);
380 connect_raw(
381 self.as_ptr() as *mut _,
382 c"notify::typefind".as_ptr() as *const _,
383 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
384 notify_typefind_trampoline::<Self, F> as *const (),
385 )),
386 Box_::into_raw(f),
387 )
388 }
389 }
390}
391
392impl<O: IsA<BaseSrc>> BaseSrcExt for O {}