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