gstreamer_video/auto/
video_decoder.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
6#[cfg(feature = "v1_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
8use crate::VideoDecoderRequestSyncPointFlags;
9use crate::{ffi, VideoCodecFrame};
10#[cfg(feature = "v1_18")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
12use glib::signal::{connect_raw, SignalHandlerId};
13use glib::{prelude::*, translate::*};
14#[cfg(feature = "v1_18")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    #[doc(alias = "GstVideoDecoder")]
20    pub struct VideoDecoder(Object<ffi::GstVideoDecoder, ffi::GstVideoDecoderClass>) @extends gst::Element, gst::Object;
21
22    match fn {
23        type_ => || ffi::gst_video_decoder_get_type(),
24    }
25}
26
27impl VideoDecoder {
28    pub const NONE: Option<&'static VideoDecoder> = None;
29}
30
31unsafe impl Send for VideoDecoder {}
32unsafe impl Sync for VideoDecoder {}
33
34pub trait VideoDecoderExt: IsA<VideoDecoder> + 'static {
35    #[doc(alias = "gst_video_decoder_add_to_frame")]
36    fn add_to_frame(&self, n_bytes: i32) {
37        unsafe {
38            ffi::gst_video_decoder_add_to_frame(self.as_ref().to_glib_none().0, n_bytes);
39        }
40    }
41
42    #[doc(alias = "gst_video_decoder_allocate_output_buffer")]
43    fn allocate_output_buffer(&self) -> Result<gst::Buffer, glib::BoolError> {
44        unsafe {
45            Option::<_>::from_glib_full(ffi::gst_video_decoder_allocate_output_buffer(
46                self.as_ref().to_glib_none().0,
47            ))
48            .ok_or_else(|| glib::bool_error!("Failed to allocate output buffer"))
49        }
50    }
51
52    #[doc(alias = "gst_video_decoder_drop_frame")]
53    fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
54        unsafe {
55            try_from_glib(ffi::gst_video_decoder_drop_frame(
56                self.as_ref().to_glib_none().0,
57                frame.into_glib_ptr(),
58            ))
59        }
60    }
61
62    #[cfg(feature = "v1_20")]
63    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
64    #[doc(alias = "gst_video_decoder_drop_subframe")]
65    fn drop_subframe(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
66        unsafe {
67            try_from_glib(ffi::gst_video_decoder_drop_subframe(
68                self.as_ref().to_glib_none().0,
69                frame.into_glib_ptr(),
70            ))
71        }
72    }
73
74    #[doc(alias = "gst_video_decoder_finish_frame")]
75    fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
76        unsafe {
77            try_from_glib(ffi::gst_video_decoder_finish_frame(
78                self.as_ref().to_glib_none().0,
79                frame.into_glib_ptr(),
80            ))
81        }
82    }
83
84    #[cfg(feature = "v1_20")]
85    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
86    #[doc(alias = "gst_video_decoder_finish_subframe")]
87    fn finish_subframe(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
88        unsafe {
89            try_from_glib(ffi::gst_video_decoder_finish_subframe(
90                self.as_ref().to_glib_none().0,
91                frame.into_glib_ptr(),
92            ))
93        }
94    }
95
96    #[doc(alias = "gst_video_decoder_get_buffer_pool")]
97    #[doc(alias = "get_buffer_pool")]
98    fn buffer_pool(&self) -> Option<gst::BufferPool> {
99        unsafe {
100            from_glib_full(ffi::gst_video_decoder_get_buffer_pool(
101                self.as_ref().to_glib_none().0,
102            ))
103        }
104    }
105
106    #[doc(alias = "gst_video_decoder_get_estimate_rate")]
107    #[doc(alias = "get_estimate_rate")]
108    fn estimate_rate(&self) -> i32 {
109        unsafe { ffi::gst_video_decoder_get_estimate_rate(self.as_ref().to_glib_none().0) }
110    }
111
112    #[doc(alias = "gst_video_decoder_get_max_decode_time")]
113    #[doc(alias = "get_max_decode_time")]
114    fn max_decode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff {
115        unsafe {
116            ffi::gst_video_decoder_get_max_decode_time(
117                self.as_ref().to_glib_none().0,
118                frame.to_glib_none().0,
119            )
120        }
121    }
122
123    #[doc(alias = "gst_video_decoder_get_max_errors")]
124    #[doc(alias = "get_max_errors")]
125    #[doc(alias = "max-errors")]
126    fn max_errors(&self) -> i32 {
127        unsafe { ffi::gst_video_decoder_get_max_errors(self.as_ref().to_glib_none().0) }
128    }
129
130    #[doc(alias = "gst_video_decoder_get_needs_format")]
131    #[doc(alias = "get_needs_format")]
132    fn needs_format(&self) -> bool {
133        unsafe {
134            from_glib(ffi::gst_video_decoder_get_needs_format(
135                self.as_ref().to_glib_none().0,
136            ))
137        }
138    }
139
140    #[cfg(feature = "v1_20")]
141    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
142    #[doc(alias = "gst_video_decoder_get_needs_sync_point")]
143    #[doc(alias = "get_needs_sync_point")]
144    fn needs_sync_point(&self) -> bool {
145        unsafe {
146            from_glib(ffi::gst_video_decoder_get_needs_sync_point(
147                self.as_ref().to_glib_none().0,
148            ))
149        }
150    }
151
152    #[doc(alias = "gst_video_decoder_get_packetized")]
153    #[doc(alias = "get_packetized")]
154    fn is_packetized(&self) -> bool {
155        unsafe {
156            from_glib(ffi::gst_video_decoder_get_packetized(
157                self.as_ref().to_glib_none().0,
158            ))
159        }
160    }
161
162    #[doc(alias = "gst_video_decoder_get_pending_frame_size")]
163    #[doc(alias = "get_pending_frame_size")]
164    fn pending_frame_size(&self) -> usize {
165        unsafe { ffi::gst_video_decoder_get_pending_frame_size(self.as_ref().to_glib_none().0) }
166    }
167
168    #[doc(alias = "gst_video_decoder_get_qos_proportion")]
169    #[doc(alias = "get_qos_proportion")]
170    fn qos_proportion(&self) -> f64 {
171        unsafe { ffi::gst_video_decoder_get_qos_proportion(self.as_ref().to_glib_none().0) }
172    }
173
174    #[cfg(feature = "v1_20")]
175    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
176    #[doc(alias = "gst_video_decoder_get_subframe_mode")]
177    #[doc(alias = "get_subframe_mode")]
178    fn is_subframe_mode(&self) -> bool {
179        unsafe {
180            from_glib(ffi::gst_video_decoder_get_subframe_mode(
181                self.as_ref().to_glib_none().0,
182            ))
183        }
184    }
185
186    #[doc(alias = "gst_video_decoder_have_frame")]
187    fn have_frame(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
188        unsafe {
189            try_from_glib(ffi::gst_video_decoder_have_frame(
190                self.as_ref().to_glib_none().0,
191            ))
192        }
193    }
194
195    #[cfg(feature = "v1_20")]
196    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
197    #[doc(alias = "gst_video_decoder_have_last_subframe")]
198    fn have_last_subframe(
199        &self,
200        frame: &VideoCodecFrame,
201    ) -> Result<gst::FlowSuccess, gst::FlowError> {
202        unsafe {
203            try_from_glib(ffi::gst_video_decoder_have_last_subframe(
204                self.as_ref().to_glib_none().0,
205                frame.to_glib_none().0,
206            ))
207        }
208    }
209
210    #[doc(alias = "gst_video_decoder_merge_tags")]
211    fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
212        unsafe {
213            ffi::gst_video_decoder_merge_tags(
214                self.as_ref().to_glib_none().0,
215                tags.to_glib_none().0,
216                mode.into_glib(),
217            );
218        }
219    }
220
221    #[doc(alias = "gst_video_decoder_proxy_getcaps")]
222    fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
223        unsafe {
224            from_glib_full(ffi::gst_video_decoder_proxy_getcaps(
225                self.as_ref().to_glib_none().0,
226                caps.to_glib_none().0,
227                filter.to_glib_none().0,
228            ))
229        }
230    }
231
232    #[doc(alias = "gst_video_decoder_release_frame")]
233    fn release_frame(&self, frame: VideoCodecFrame) {
234        unsafe {
235            ffi::gst_video_decoder_release_frame(
236                self.as_ref().to_glib_none().0,
237                frame.into_glib_ptr(),
238            );
239        }
240    }
241
242    #[cfg(feature = "v1_20")]
243    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
244    #[doc(alias = "gst_video_decoder_request_sync_point")]
245    fn request_sync_point(
246        &self,
247        frame: &VideoCodecFrame,
248        flags: VideoDecoderRequestSyncPointFlags,
249    ) {
250        unsafe {
251            ffi::gst_video_decoder_request_sync_point(
252                self.as_ref().to_glib_none().0,
253                frame.to_glib_none().0,
254                flags.into_glib(),
255            );
256        }
257    }
258
259    #[doc(alias = "gst_video_decoder_set_estimate_rate")]
260    fn set_estimate_rate(&self, enabled: bool) {
261        unsafe {
262            ffi::gst_video_decoder_set_estimate_rate(
263                self.as_ref().to_glib_none().0,
264                enabled.into_glib(),
265            );
266        }
267    }
268
269    #[doc(alias = "gst_video_decoder_set_max_errors")]
270    #[doc(alias = "max-errors")]
271    fn set_max_errors(&self, num: i32) {
272        unsafe {
273            ffi::gst_video_decoder_set_max_errors(self.as_ref().to_glib_none().0, num);
274        }
275    }
276
277    #[doc(alias = "gst_video_decoder_set_needs_format")]
278    fn set_needs_format(&self, enabled: bool) {
279        unsafe {
280            ffi::gst_video_decoder_set_needs_format(
281                self.as_ref().to_glib_none().0,
282                enabled.into_glib(),
283            );
284        }
285    }
286
287    #[cfg(feature = "v1_20")]
288    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
289    #[doc(alias = "gst_video_decoder_set_needs_sync_point")]
290    fn set_needs_sync_point(&self, enabled: bool) {
291        unsafe {
292            ffi::gst_video_decoder_set_needs_sync_point(
293                self.as_ref().to_glib_none().0,
294                enabled.into_glib(),
295            );
296        }
297    }
298
299    #[doc(alias = "gst_video_decoder_set_packetized")]
300    fn set_packetized(&self, packetized: bool) {
301        unsafe {
302            ffi::gst_video_decoder_set_packetized(
303                self.as_ref().to_glib_none().0,
304                packetized.into_glib(),
305            );
306        }
307    }
308
309    #[cfg(feature = "v1_20")]
310    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
311    #[doc(alias = "gst_video_decoder_set_subframe_mode")]
312    fn set_subframe_mode(&self, subframe_mode: bool) {
313        unsafe {
314            ffi::gst_video_decoder_set_subframe_mode(
315                self.as_ref().to_glib_none().0,
316                subframe_mode.into_glib(),
317            );
318        }
319    }
320
321    #[doc(alias = "gst_video_decoder_set_use_default_pad_acceptcaps")]
322    fn set_use_default_pad_acceptcaps(&self, use_: bool) {
323        unsafe {
324            ffi::gst_video_decoder_set_use_default_pad_acceptcaps(
325                self.as_ref().to_glib_none().0,
326                use_.into_glib(),
327            );
328        }
329    }
330
331    #[cfg(feature = "v1_20")]
332    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
333    #[doc(alias = "automatic-request-sync-point-flags")]
334    fn automatic_request_sync_point_flags(&self) -> VideoDecoderRequestSyncPointFlags {
335        ObjectExt::property(self.as_ref(), "automatic-request-sync-point-flags")
336    }
337
338    #[cfg(feature = "v1_20")]
339    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
340    #[doc(alias = "automatic-request-sync-point-flags")]
341    fn set_automatic_request_sync_point_flags(
342        &self,
343        automatic_request_sync_point_flags: VideoDecoderRequestSyncPointFlags,
344    ) {
345        ObjectExt::set_property(
346            self.as_ref(),
347            "automatic-request-sync-point-flags",
348            automatic_request_sync_point_flags,
349        )
350    }
351
352    #[cfg(feature = "v1_20")]
353    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
354    #[doc(alias = "automatic-request-sync-points")]
355    fn is_automatic_request_sync_points(&self) -> bool {
356        ObjectExt::property(self.as_ref(), "automatic-request-sync-points")
357    }
358
359    #[cfg(feature = "v1_20")]
360    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
361    #[doc(alias = "automatic-request-sync-points")]
362    fn set_automatic_request_sync_points(&self, automatic_request_sync_points: bool) {
363        ObjectExt::set_property(
364            self.as_ref(),
365            "automatic-request-sync-points",
366            automatic_request_sync_points,
367        )
368    }
369
370    #[cfg(feature = "v1_20")]
371    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
372    #[doc(alias = "discard-corrupted-frames")]
373    fn is_discard_corrupted_frames(&self) -> bool {
374        ObjectExt::property(self.as_ref(), "discard-corrupted-frames")
375    }
376
377    #[cfg(feature = "v1_20")]
378    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
379    #[doc(alias = "discard-corrupted-frames")]
380    fn set_discard_corrupted_frames(&self, discard_corrupted_frames: bool) {
381        ObjectExt::set_property(
382            self.as_ref(),
383            "discard-corrupted-frames",
384            discard_corrupted_frames,
385        )
386    }
387
388    #[cfg(feature = "v1_20")]
389    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
390    #[doc(alias = "min-force-key-unit-interval")]
391    fn min_force_key_unit_interval(&self) -> u64 {
392        ObjectExt::property(self.as_ref(), "min-force-key-unit-interval")
393    }
394
395    #[cfg(feature = "v1_20")]
396    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
397    #[doc(alias = "min-force-key-unit-interval")]
398    fn set_min_force_key_unit_interval(&self, min_force_key_unit_interval: u64) {
399        ObjectExt::set_property(
400            self.as_ref(),
401            "min-force-key-unit-interval",
402            min_force_key_unit_interval,
403        )
404    }
405
406    #[cfg(feature = "v1_18")]
407    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
408    fn is_qos(&self) -> bool {
409        ObjectExt::property(self.as_ref(), "qos")
410    }
411
412    #[cfg(feature = "v1_18")]
413    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
414    fn set_qos(&self, qos: bool) {
415        ObjectExt::set_property(self.as_ref(), "qos", qos)
416    }
417
418    #[cfg(feature = "v1_20")]
419    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
420    #[doc(alias = "automatic-request-sync-point-flags")]
421    fn connect_automatic_request_sync_point_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
422        &self,
423        f: F,
424    ) -> SignalHandlerId {
425        unsafe extern "C" fn notify_automatic_request_sync_point_flags_trampoline<
426            P: IsA<VideoDecoder>,
427            F: Fn(&P) + Send + Sync + 'static,
428        >(
429            this: *mut ffi::GstVideoDecoder,
430            _param_spec: glib::ffi::gpointer,
431            f: glib::ffi::gpointer,
432        ) {
433            let f: &F = &*(f as *const F);
434            f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
435        }
436        unsafe {
437            let f: Box_<F> = Box_::new(f);
438            connect_raw(
439                self.as_ptr() as *mut _,
440                c"notify::automatic-request-sync-point-flags".as_ptr() as *const _,
441                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
442                    notify_automatic_request_sync_point_flags_trampoline::<Self, F> as *const (),
443                )),
444                Box_::into_raw(f),
445            )
446        }
447    }
448
449    #[cfg(feature = "v1_20")]
450    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
451    #[doc(alias = "automatic-request-sync-points")]
452    fn connect_automatic_request_sync_points_notify<F: Fn(&Self) + Send + Sync + 'static>(
453        &self,
454        f: F,
455    ) -> SignalHandlerId {
456        unsafe extern "C" fn notify_automatic_request_sync_points_trampoline<
457            P: IsA<VideoDecoder>,
458            F: Fn(&P) + Send + Sync + 'static,
459        >(
460            this: *mut ffi::GstVideoDecoder,
461            _param_spec: glib::ffi::gpointer,
462            f: glib::ffi::gpointer,
463        ) {
464            let f: &F = &*(f as *const F);
465            f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
466        }
467        unsafe {
468            let f: Box_<F> = Box_::new(f);
469            connect_raw(
470                self.as_ptr() as *mut _,
471                c"notify::automatic-request-sync-points".as_ptr() as *const _,
472                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
473                    notify_automatic_request_sync_points_trampoline::<Self, F> as *const (),
474                )),
475                Box_::into_raw(f),
476            )
477        }
478    }
479
480    #[cfg(feature = "v1_20")]
481    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
482    #[doc(alias = "discard-corrupted-frames")]
483    fn connect_discard_corrupted_frames_notify<F: Fn(&Self) + Send + Sync + 'static>(
484        &self,
485        f: F,
486    ) -> SignalHandlerId {
487        unsafe extern "C" fn notify_discard_corrupted_frames_trampoline<
488            P: IsA<VideoDecoder>,
489            F: Fn(&P) + Send + Sync + 'static,
490        >(
491            this: *mut ffi::GstVideoDecoder,
492            _param_spec: glib::ffi::gpointer,
493            f: glib::ffi::gpointer,
494        ) {
495            let f: &F = &*(f as *const F);
496            f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
497        }
498        unsafe {
499            let f: Box_<F> = Box_::new(f);
500            connect_raw(
501                self.as_ptr() as *mut _,
502                c"notify::discard-corrupted-frames".as_ptr() as *const _,
503                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
504                    notify_discard_corrupted_frames_trampoline::<Self, F> as *const (),
505                )),
506                Box_::into_raw(f),
507            )
508        }
509    }
510
511    #[cfg(feature = "v1_18")]
512    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
513    #[doc(alias = "max-errors")]
514    fn connect_max_errors_notify<F: Fn(&Self) + Send + Sync + 'static>(
515        &self,
516        f: F,
517    ) -> SignalHandlerId {
518        unsafe extern "C" fn notify_max_errors_trampoline<
519            P: IsA<VideoDecoder>,
520            F: Fn(&P) + Send + Sync + 'static,
521        >(
522            this: *mut ffi::GstVideoDecoder,
523            _param_spec: glib::ffi::gpointer,
524            f: glib::ffi::gpointer,
525        ) {
526            let f: &F = &*(f as *const F);
527            f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
528        }
529        unsafe {
530            let f: Box_<F> = Box_::new(f);
531            connect_raw(
532                self.as_ptr() as *mut _,
533                c"notify::max-errors".as_ptr() as *const _,
534                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
535                    notify_max_errors_trampoline::<Self, F> as *const (),
536                )),
537                Box_::into_raw(f),
538            )
539        }
540    }
541
542    #[cfg(feature = "v1_20")]
543    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
544    #[doc(alias = "min-force-key-unit-interval")]
545    fn connect_min_force_key_unit_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
546        &self,
547        f: F,
548    ) -> SignalHandlerId {
549        unsafe extern "C" fn notify_min_force_key_unit_interval_trampoline<
550            P: IsA<VideoDecoder>,
551            F: Fn(&P) + Send + Sync + 'static,
552        >(
553            this: *mut ffi::GstVideoDecoder,
554            _param_spec: glib::ffi::gpointer,
555            f: glib::ffi::gpointer,
556        ) {
557            let f: &F = &*(f as *const F);
558            f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
559        }
560        unsafe {
561            let f: Box_<F> = Box_::new(f);
562            connect_raw(
563                self.as_ptr() as *mut _,
564                c"notify::min-force-key-unit-interval".as_ptr() as *const _,
565                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
566                    notify_min_force_key_unit_interval_trampoline::<Self, F> as *const (),
567                )),
568                Box_::into_raw(f),
569            )
570        }
571    }
572
573    #[cfg(feature = "v1_18")]
574    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
575    #[doc(alias = "qos")]
576    fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
577        unsafe extern "C" fn notify_qos_trampoline<
578            P: IsA<VideoDecoder>,
579            F: Fn(&P) + Send + Sync + 'static,
580        >(
581            this: *mut ffi::GstVideoDecoder,
582            _param_spec: glib::ffi::gpointer,
583            f: glib::ffi::gpointer,
584        ) {
585            let f: &F = &*(f as *const F);
586            f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
587        }
588        unsafe {
589            let f: Box_<F> = Box_::new(f);
590            connect_raw(
591                self.as_ptr() as *mut _,
592                c"notify::qos".as_ptr() as *const _,
593                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
594                    notify_qos_trampoline::<Self, F> as *const (),
595                )),
596                Box_::into_raw(f),
597            )
598        }
599    }
600}
601
602impl<O: IsA<VideoDecoder>> VideoDecoderExt for O {}