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 glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::{boxed::Box as Box_, mem::transmute};
13
14glib::wrapper! {
15 #[doc(alias = "GstBaseSrc")]
16 pub struct BaseSrc(Object<ffi::GstBaseSrc, ffi::GstBaseSrcClass>) @extends gst::Element, gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_base_src_get_type(),
20 }
21}
22
23impl BaseSrc {
24 pub const NONE: Option<&'static BaseSrc> = None;
25}
26
27unsafe impl Send for BaseSrc {}
28unsafe impl Sync for BaseSrc {}
29
30mod sealed {
31 pub trait Sealed {}
32 impl<T: super::IsA<super::BaseSrc>> Sealed for T {}
33}
34
35pub trait BaseSrcExt: IsA<BaseSrc> + sealed::Sealed + 'static {
36 #[doc(alias = "gst_base_src_get_blocksize")]
37 #[doc(alias = "get_blocksize")]
38 fn blocksize(&self) -> u32 {
39 unsafe { ffi::gst_base_src_get_blocksize(self.as_ref().to_glib_none().0) }
40 }
41
42 #[doc(alias = "gst_base_src_get_buffer_pool")]
43 #[doc(alias = "get_buffer_pool")]
44 fn buffer_pool(&self) -> Option<gst::BufferPool> {
45 unsafe {
46 from_glib_full(ffi::gst_base_src_get_buffer_pool(
47 self.as_ref().to_glib_none().0,
48 ))
49 }
50 }
51
52 #[doc(alias = "gst_base_src_get_do_timestamp")]
53 #[doc(alias = "get_do_timestamp")]
54 fn does_timestamp(&self) -> bool {
55 unsafe {
56 from_glib(ffi::gst_base_src_get_do_timestamp(
57 self.as_ref().to_glib_none().0,
58 ))
59 }
60 }
61
62 #[doc(alias = "gst_base_src_is_async")]
63 fn is_async(&self) -> bool {
64 unsafe { from_glib(ffi::gst_base_src_is_async(self.as_ref().to_glib_none().0)) }
65 }
66
67 #[doc(alias = "gst_base_src_is_live")]
68 fn is_live(&self) -> bool {
69 unsafe { from_glib(ffi::gst_base_src_is_live(self.as_ref().to_glib_none().0)) }
70 }
71
72 #[cfg(feature = "v1_18")]
73 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
74 #[doc(alias = "gst_base_src_negotiate")]
75 fn negotiate(&self) -> bool {
76 unsafe { from_glib(ffi::gst_base_src_negotiate(self.as_ref().to_glib_none().0)) }
77 }
78
79 #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
80 #[allow(deprecated)]
81 #[doc(alias = "gst_base_src_new_seamless_segment")]
82 fn new_seamless_segment(&self, start: i64, stop: i64, time: i64) -> bool {
83 unsafe {
84 from_glib(ffi::gst_base_src_new_seamless_segment(
85 self.as_ref().to_glib_none().0,
86 start,
87 stop,
88 time,
89 ))
90 }
91 }
92
93 #[cfg(feature = "v1_18")]
94 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
95 #[doc(alias = "gst_base_src_new_segment")]
96 fn new_segment(&self, segment: &gst::Segment) -> Result<(), glib::error::BoolError> {
97 unsafe {
98 glib::result_from_gboolean!(
99 ffi::gst_base_src_new_segment(
100 self.as_ref().to_glib_none().0,
101 segment.to_glib_none().0
102 ),
103 "Failed to update segment"
104 )
105 }
106 }
107
108 #[cfg(feature = "v1_24")]
109 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
110 #[doc(alias = "gst_base_src_push_segment")]
111 fn push_segment(&self, segment: &gst::Segment) -> bool {
112 unsafe {
113 from_glib(ffi::gst_base_src_push_segment(
114 self.as_ref().to_glib_none().0,
115 segment.to_glib_none().0,
116 ))
117 }
118 }
119
120 #[doc(alias = "gst_base_src_set_async")]
121 fn set_async(&self, async_: bool) {
122 unsafe {
123 ffi::gst_base_src_set_async(self.as_ref().to_glib_none().0, async_.into_glib());
124 }
125 }
126
127 #[doc(alias = "gst_base_src_set_automatic_eos")]
128 fn set_automatic_eos(&self, automatic_eos: bool) {
129 unsafe {
130 ffi::gst_base_src_set_automatic_eos(
131 self.as_ref().to_glib_none().0,
132 automatic_eos.into_glib(),
133 );
134 }
135 }
136
137 #[doc(alias = "gst_base_src_set_blocksize")]
138 fn set_blocksize(&self, blocksize: u32) {
139 unsafe {
140 ffi::gst_base_src_set_blocksize(self.as_ref().to_glib_none().0, blocksize);
141 }
142 }
143
144 #[doc(alias = "gst_base_src_set_caps")]
145 fn set_caps(&self, caps: &gst::Caps) -> Result<(), glib::error::BoolError> {
146 unsafe {
147 glib::result_from_gboolean!(
148 ffi::gst_base_src_set_caps(self.as_ref().to_glib_none().0, caps.to_glib_none().0),
149 "Failed to set caps"
150 )
151 }
152 }
153
154 #[doc(alias = "gst_base_src_set_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 #[doc(alias = "num-buffers")]
210 fn num_buffers(&self) -> i32 {
211 ObjectExt::property(self.as_ref(), "num-buffers")
212 }
213
214 #[doc(alias = "num-buffers")]
215 fn set_num_buffers(&self, num_buffers: i32) {
216 ObjectExt::set_property(self.as_ref(), "num-buffers", num_buffers)
217 }
218
219 fn is_typefind(&self) -> bool {
220 ObjectExt::property(self.as_ref(), "typefind")
221 }
222
223 fn set_typefind(&self, typefind: bool) {
224 ObjectExt::set_property(self.as_ref(), "typefind", typefind)
225 }
226
227 #[doc(alias = "blocksize")]
228 fn connect_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(
229 &self,
230 f: F,
231 ) -> SignalHandlerId {
232 unsafe extern "C" fn notify_blocksize_trampoline<
233 P: IsA<BaseSrc>,
234 F: Fn(&P) + Send + Sync + 'static,
235 >(
236 this: *mut ffi::GstBaseSrc,
237 _param_spec: glib::ffi::gpointer,
238 f: glib::ffi::gpointer,
239 ) {
240 let f: &F = &*(f as *const F);
241 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
242 }
243 unsafe {
244 let f: Box_<F> = Box_::new(f);
245 connect_raw(
246 self.as_ptr() as *mut _,
247 b"notify::blocksize\0".as_ptr() as *const _,
248 Some(transmute::<_, unsafe extern "C" fn()>(
249 notify_blocksize_trampoline::<Self, F> as *const (),
250 )),
251 Box_::into_raw(f),
252 )
253 }
254 }
255
256 #[doc(alias = "do-timestamp")]
257 fn connect_do_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(
258 &self,
259 f: F,
260 ) -> SignalHandlerId {
261 unsafe extern "C" fn notify_do_timestamp_trampoline<
262 P: IsA<BaseSrc>,
263 F: Fn(&P) + Send + Sync + 'static,
264 >(
265 this: *mut ffi::GstBaseSrc,
266 _param_spec: glib::ffi::gpointer,
267 f: glib::ffi::gpointer,
268 ) {
269 let f: &F = &*(f as *const F);
270 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
271 }
272 unsafe {
273 let f: Box_<F> = Box_::new(f);
274 connect_raw(
275 self.as_ptr() as *mut _,
276 b"notify::do-timestamp\0".as_ptr() as *const _,
277 Some(transmute::<_, unsafe extern "C" fn()>(
278 notify_do_timestamp_trampoline::<Self, F> as *const (),
279 )),
280 Box_::into_raw(f),
281 )
282 }
283 }
284
285 #[doc(alias = "num-buffers")]
286 fn connect_num_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
287 &self,
288 f: F,
289 ) -> SignalHandlerId {
290 unsafe extern "C" fn notify_num_buffers_trampoline<
291 P: IsA<BaseSrc>,
292 F: Fn(&P) + Send + Sync + 'static,
293 >(
294 this: *mut ffi::GstBaseSrc,
295 _param_spec: glib::ffi::gpointer,
296 f: glib::ffi::gpointer,
297 ) {
298 let f: &F = &*(f as *const F);
299 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
300 }
301 unsafe {
302 let f: Box_<F> = Box_::new(f);
303 connect_raw(
304 self.as_ptr() as *mut _,
305 b"notify::num-buffers\0".as_ptr() as *const _,
306 Some(transmute::<_, unsafe extern "C" fn()>(
307 notify_num_buffers_trampoline::<Self, F> as *const (),
308 )),
309 Box_::into_raw(f),
310 )
311 }
312 }
313
314 #[doc(alias = "typefind")]
315 fn connect_typefind_notify<F: Fn(&Self) + Send + Sync + 'static>(
316 &self,
317 f: F,
318 ) -> SignalHandlerId {
319 unsafe extern "C" fn notify_typefind_trampoline<
320 P: IsA<BaseSrc>,
321 F: Fn(&P) + Send + Sync + 'static,
322 >(
323 this: *mut ffi::GstBaseSrc,
324 _param_spec: glib::ffi::gpointer,
325 f: glib::ffi::gpointer,
326 ) {
327 let f: &F = &*(f as *const F);
328 f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
329 }
330 unsafe {
331 let f: Box_<F> = Box_::new(f);
332 connect_raw(
333 self.as_ptr() as *mut _,
334 b"notify::typefind\0".as_ptr() as *const _,
335 Some(transmute::<_, unsafe extern "C" fn()>(
336 notify_typefind_trampoline::<Self, F> as *const (),
337 )),
338 Box_::into_raw(f),
339 )
340 }
341 }
342}
343
344impl<O: IsA<BaseSrc>> BaseSrcExt for O {}
345