gstreamer_app/auto/
app_sink.rs

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
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstAppSink")]
16    pub struct AppSink(Object<ffi::GstAppSink, ffi::GstAppSinkClass>) @extends gst::Element, gst::Object, @implements gst::URIHandler;
17
18    match fn {
19        type_ => || ffi::gst_app_sink_get_type(),
20    }
21}
22
23impl AppSink {
24    #[doc(alias = "gst_app_sink_get_buffer_list_support")]
25    #[doc(alias = "get_buffer_list_support")]
26    pub fn is_buffer_list_support(&self) -> bool {
27        unsafe {
28            from_glib(ffi::gst_app_sink_get_buffer_list_support(
29                self.to_glib_none().0,
30            ))
31        }
32    }
33
34    #[doc(alias = "gst_app_sink_get_caps")]
35    #[doc(alias = "get_caps")]
36    pub fn caps(&self) -> Option<gst::Caps> {
37        unsafe { from_glib_full(ffi::gst_app_sink_get_caps(self.to_glib_none().0)) }
38    }
39
40    #[doc(alias = "gst_app_sink_get_drop")]
41    #[doc(alias = "get_drop")]
42    #[doc(alias = "drop")]
43    pub fn is_drop(&self) -> bool {
44        unsafe { from_glib(ffi::gst_app_sink_get_drop(self.to_glib_none().0)) }
45    }
46
47    #[doc(alias = "gst_app_sink_get_max_buffers")]
48    #[doc(alias = "get_max_buffers")]
49    #[doc(alias = "max-buffers")]
50    pub fn max_buffers(&self) -> u32 {
51        unsafe { ffi::gst_app_sink_get_max_buffers(self.to_glib_none().0) }
52    }
53
54    #[cfg(feature = "v1_24")]
55    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
56    #[doc(alias = "gst_app_sink_get_max_bytes")]
57    #[doc(alias = "get_max_bytes")]
58    #[doc(alias = "max-bytes")]
59    pub fn max_bytes(&self) -> u64 {
60        unsafe { ffi::gst_app_sink_get_max_bytes(self.to_glib_none().0) }
61    }
62
63    #[cfg(feature = "v1_24")]
64    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
65    #[doc(alias = "gst_app_sink_get_max_time")]
66    #[doc(alias = "get_max_time")]
67    #[doc(alias = "max-time")]
68    pub fn max_time(&self) -> Option<gst::ClockTime> {
69        unsafe { from_glib(ffi::gst_app_sink_get_max_time(self.to_glib_none().0)) }
70    }
71
72    #[doc(alias = "gst_app_sink_get_wait_on_eos")]
73    #[doc(alias = "get_wait_on_eos")]
74    #[doc(alias = "wait-on-eos")]
75    pub fn is_wait_on_eos(&self) -> bool {
76        unsafe { from_glib(ffi::gst_app_sink_get_wait_on_eos(self.to_glib_none().0)) }
77    }
78
79    #[doc(alias = "gst_app_sink_is_eos")]
80    #[doc(alias = "eos")]
81    pub fn is_eos(&self) -> bool {
82        unsafe { from_glib(ffi::gst_app_sink_is_eos(self.to_glib_none().0)) }
83    }
84
85    #[cfg(feature = "v1_20")]
86    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
87    #[doc(alias = "gst_app_sink_pull_object")]
88    pub fn pull_object(&self) -> Result<gst::MiniObject, glib::BoolError> {
89        unsafe {
90            Option::<_>::from_glib_full(ffi::gst_app_sink_pull_object(self.to_glib_none().0))
91                .ok_or_else(|| glib::bool_error!("Failed to pull object"))
92        }
93    }
94
95    #[doc(alias = "gst_app_sink_pull_preroll")]
96    pub fn pull_preroll(&self) -> Result<gst::Sample, glib::BoolError> {
97        unsafe {
98            Option::<_>::from_glib_full(ffi::gst_app_sink_pull_preroll(self.to_glib_none().0))
99                .ok_or_else(|| glib::bool_error!("Failed to pull preroll sample"))
100        }
101    }
102
103    #[doc(alias = "gst_app_sink_pull_sample")]
104    pub fn pull_sample(&self) -> Result<gst::Sample, glib::BoolError> {
105        unsafe {
106            Option::<_>::from_glib_full(ffi::gst_app_sink_pull_sample(self.to_glib_none().0))
107                .ok_or_else(|| glib::bool_error!("Failed to pull sample"))
108        }
109    }
110
111    #[doc(alias = "gst_app_sink_set_buffer_list_support")]
112    pub fn set_buffer_list_support(&self, enable_lists: bool) {
113        unsafe {
114            ffi::gst_app_sink_set_buffer_list_support(
115                self.to_glib_none().0,
116                enable_lists.into_glib(),
117            );
118        }
119    }
120
121    //#[doc(alias = "gst_app_sink_set_callbacks")]
122    //pub fn set_callbacks(&self, callbacks: /*Ignored*/&mut AppSinkCallbacks, user_data: /*Unimplemented*/Option<Basic: Pointer>) {
123    //    unsafe { TODO: call ffi:gst_app_sink_set_callbacks() }
124    //}
125
126    #[doc(alias = "gst_app_sink_set_caps")]
127    #[doc(alias = "caps")]
128    pub fn set_caps(&self, caps: Option<&gst::Caps>) {
129        unsafe {
130            ffi::gst_app_sink_set_caps(self.to_glib_none().0, caps.to_glib_none().0);
131        }
132    }
133
134    #[doc(alias = "gst_app_sink_set_drop")]
135    #[doc(alias = "drop")]
136    pub fn set_drop(&self, drop: bool) {
137        unsafe {
138            ffi::gst_app_sink_set_drop(self.to_glib_none().0, drop.into_glib());
139        }
140    }
141
142    #[doc(alias = "gst_app_sink_set_max_buffers")]
143    #[doc(alias = "max-buffers")]
144    pub fn set_max_buffers(&self, max: u32) {
145        unsafe {
146            ffi::gst_app_sink_set_max_buffers(self.to_glib_none().0, max);
147        }
148    }
149
150    #[cfg(feature = "v1_24")]
151    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
152    #[doc(alias = "gst_app_sink_set_max_bytes")]
153    #[doc(alias = "max-bytes")]
154    pub fn set_max_bytes(&self, max: u64) {
155        unsafe {
156            ffi::gst_app_sink_set_max_bytes(self.to_glib_none().0, max);
157        }
158    }
159
160    #[cfg(feature = "v1_24")]
161    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
162    #[doc(alias = "gst_app_sink_set_max_time")]
163    #[doc(alias = "max-time")]
164    pub fn set_max_time(&self, max: impl Into<Option<gst::ClockTime>>) {
165        unsafe {
166            ffi::gst_app_sink_set_max_time(self.to_glib_none().0, max.into().into_glib());
167        }
168    }
169
170    #[doc(alias = "gst_app_sink_set_wait_on_eos")]
171    #[doc(alias = "wait-on-eos")]
172    pub fn set_wait_on_eos(&self, wait: bool) {
173        unsafe {
174            ffi::gst_app_sink_set_wait_on_eos(self.to_glib_none().0, wait.into_glib());
175        }
176    }
177
178    #[cfg(feature = "v1_20")]
179    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
180    #[doc(alias = "gst_app_sink_try_pull_object")]
181    pub fn try_pull_object(
182        &self,
183        timeout: impl Into<Option<gst::ClockTime>>,
184    ) -> Option<gst::MiniObject> {
185        unsafe {
186            from_glib_full(ffi::gst_app_sink_try_pull_object(
187                self.to_glib_none().0,
188                timeout.into().into_glib(),
189            ))
190        }
191    }
192
193    #[doc(alias = "gst_app_sink_try_pull_preroll")]
194    pub fn try_pull_preroll(
195        &self,
196        timeout: impl Into<Option<gst::ClockTime>>,
197    ) -> Option<gst::Sample> {
198        unsafe {
199            from_glib_full(ffi::gst_app_sink_try_pull_preroll(
200                self.to_glib_none().0,
201                timeout.into().into_glib(),
202            ))
203        }
204    }
205
206    #[doc(alias = "gst_app_sink_try_pull_sample")]
207    pub fn try_pull_sample(
208        &self,
209        timeout: impl Into<Option<gst::ClockTime>>,
210    ) -> Option<gst::Sample> {
211        unsafe {
212            from_glib_full(ffi::gst_app_sink_try_pull_sample(
213                self.to_glib_none().0,
214                timeout.into().into_glib(),
215            ))
216        }
217    }
218
219    #[doc(alias = "buffer-list")]
220    pub fn is_buffer_list(&self) -> bool {
221        ObjectExt::property(self, "buffer-list")
222    }
223
224    #[doc(alias = "buffer-list")]
225    pub fn set_buffer_list(&self, buffer_list: bool) {
226        ObjectExt::set_property(self, "buffer-list", buffer_list)
227    }
228
229    #[doc(alias = "buffer-list")]
230    pub fn connect_buffer_list_notify<F: Fn(&Self) + Send + Sync + 'static>(
231        &self,
232        f: F,
233    ) -> SignalHandlerId {
234        unsafe extern "C" fn notify_buffer_list_trampoline<
235            F: Fn(&AppSink) + Send + Sync + 'static,
236        >(
237            this: *mut ffi::GstAppSink,
238            _param_spec: glib::ffi::gpointer,
239            f: glib::ffi::gpointer,
240        ) {
241            let f: &F = &*(f as *const F);
242            f(&from_glib_borrow(this))
243        }
244        unsafe {
245            let f: Box_<F> = Box_::new(f);
246            connect_raw(
247                self.as_ptr() as *mut _,
248                b"notify::buffer-list\0".as_ptr() as *const _,
249                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
250                    notify_buffer_list_trampoline::<F> as *const (),
251                )),
252                Box_::into_raw(f),
253            )
254        }
255    }
256
257    #[doc(alias = "caps")]
258    pub fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(
259        &self,
260        f: F,
261    ) -> SignalHandlerId {
262        unsafe extern "C" fn notify_caps_trampoline<F: Fn(&AppSink) + Send + Sync + 'static>(
263            this: *mut ffi::GstAppSink,
264            _param_spec: glib::ffi::gpointer,
265            f: glib::ffi::gpointer,
266        ) {
267            let f: &F = &*(f as *const F);
268            f(&from_glib_borrow(this))
269        }
270        unsafe {
271            let f: Box_<F> = Box_::new(f);
272            connect_raw(
273                self.as_ptr() as *mut _,
274                b"notify::caps\0".as_ptr() as *const _,
275                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
276                    notify_caps_trampoline::<F> as *const (),
277                )),
278                Box_::into_raw(f),
279            )
280        }
281    }
282
283    #[doc(alias = "drop")]
284    pub fn connect_drop_notify<F: Fn(&Self) + Send + Sync + 'static>(
285        &self,
286        f: F,
287    ) -> SignalHandlerId {
288        unsafe extern "C" fn notify_drop_trampoline<F: Fn(&AppSink) + Send + Sync + 'static>(
289            this: *mut ffi::GstAppSink,
290            _param_spec: glib::ffi::gpointer,
291            f: glib::ffi::gpointer,
292        ) {
293            let f: &F = &*(f as *const F);
294            f(&from_glib_borrow(this))
295        }
296        unsafe {
297            let f: Box_<F> = Box_::new(f);
298            connect_raw(
299                self.as_ptr() as *mut _,
300                b"notify::drop\0".as_ptr() as *const _,
301                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
302                    notify_drop_trampoline::<F> as *const (),
303                )),
304                Box_::into_raw(f),
305            )
306        }
307    }
308
309    #[doc(alias = "eos")]
310    pub fn connect_eos_notify<F: Fn(&Self) + Send + Sync + 'static>(
311        &self,
312        f: F,
313    ) -> SignalHandlerId {
314        unsafe extern "C" fn notify_eos_trampoline<F: Fn(&AppSink) + Send + Sync + 'static>(
315            this: *mut ffi::GstAppSink,
316            _param_spec: glib::ffi::gpointer,
317            f: glib::ffi::gpointer,
318        ) {
319            let f: &F = &*(f as *const F);
320            f(&from_glib_borrow(this))
321        }
322        unsafe {
323            let f: Box_<F> = Box_::new(f);
324            connect_raw(
325                self.as_ptr() as *mut _,
326                b"notify::eos\0".as_ptr() as *const _,
327                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
328                    notify_eos_trampoline::<F> as *const (),
329                )),
330                Box_::into_raw(f),
331            )
332        }
333    }
334
335    #[doc(alias = "max-buffers")]
336    pub fn connect_max_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
337        &self,
338        f: F,
339    ) -> SignalHandlerId {
340        unsafe extern "C" fn notify_max_buffers_trampoline<
341            F: Fn(&AppSink) + Send + Sync + 'static,
342        >(
343            this: *mut ffi::GstAppSink,
344            _param_spec: glib::ffi::gpointer,
345            f: glib::ffi::gpointer,
346        ) {
347            let f: &F = &*(f as *const F);
348            f(&from_glib_borrow(this))
349        }
350        unsafe {
351            let f: Box_<F> = Box_::new(f);
352            connect_raw(
353                self.as_ptr() as *mut _,
354                b"notify::max-buffers\0".as_ptr() as *const _,
355                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
356                    notify_max_buffers_trampoline::<F> as *const (),
357                )),
358                Box_::into_raw(f),
359            )
360        }
361    }
362
363    #[cfg(feature = "v1_24")]
364    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
365    #[doc(alias = "max-bytes")]
366    pub fn connect_max_bytes_notify<F: Fn(&Self) + Send + Sync + 'static>(
367        &self,
368        f: F,
369    ) -> SignalHandlerId {
370        unsafe extern "C" fn notify_max_bytes_trampoline<
371            F: Fn(&AppSink) + Send + Sync + 'static,
372        >(
373            this: *mut ffi::GstAppSink,
374            _param_spec: glib::ffi::gpointer,
375            f: glib::ffi::gpointer,
376        ) {
377            let f: &F = &*(f as *const F);
378            f(&from_glib_borrow(this))
379        }
380        unsafe {
381            let f: Box_<F> = Box_::new(f);
382            connect_raw(
383                self.as_ptr() as *mut _,
384                b"notify::max-bytes\0".as_ptr() as *const _,
385                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
386                    notify_max_bytes_trampoline::<F> as *const (),
387                )),
388                Box_::into_raw(f),
389            )
390        }
391    }
392
393    #[cfg(feature = "v1_24")]
394    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
395    #[doc(alias = "max-time")]
396    pub fn connect_max_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
397        &self,
398        f: F,
399    ) -> SignalHandlerId {
400        unsafe extern "C" fn notify_max_time_trampoline<F: Fn(&AppSink) + Send + Sync + 'static>(
401            this: *mut ffi::GstAppSink,
402            _param_spec: glib::ffi::gpointer,
403            f: glib::ffi::gpointer,
404        ) {
405            let f: &F = &*(f as *const F);
406            f(&from_glib_borrow(this))
407        }
408        unsafe {
409            let f: Box_<F> = Box_::new(f);
410            connect_raw(
411                self.as_ptr() as *mut _,
412                b"notify::max-time\0".as_ptr() as *const _,
413                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
414                    notify_max_time_trampoline::<F> as *const (),
415                )),
416                Box_::into_raw(f),
417            )
418        }
419    }
420
421    #[doc(alias = "wait-on-eos")]
422    pub fn connect_wait_on_eos_notify<F: Fn(&Self) + Send + Sync + 'static>(
423        &self,
424        f: F,
425    ) -> SignalHandlerId {
426        unsafe extern "C" fn notify_wait_on_eos_trampoline<
427            F: Fn(&AppSink) + Send + Sync + 'static,
428        >(
429            this: *mut ffi::GstAppSink,
430            _param_spec: glib::ffi::gpointer,
431            f: glib::ffi::gpointer,
432        ) {
433            let f: &F = &*(f as *const F);
434            f(&from_glib_borrow(this))
435        }
436        unsafe {
437            let f: Box_<F> = Box_::new(f);
438            connect_raw(
439                self.as_ptr() as *mut _,
440                b"notify::wait-on-eos\0".as_ptr() as *const _,
441                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
442                    notify_wait_on_eos_trampoline::<F> as *const (),
443                )),
444                Box_::into_raw(f),
445            )
446        }
447    }
448}
449
450unsafe impl Send for AppSink {}
451unsafe impl Sync for AppSink {}