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