1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
use crate::VideoDecoderRequestSyncPointFlags;
use crate::{ffi, VideoCodecFrame};
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
use glib::signal::{connect_raw, SignalHandlerId};
use glib::{prelude::*, translate::*};
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
use std::boxed::Box as Box_;
glib::wrapper! {
/// This base class is for video decoders turning encoded data into raw video
/// frames.
///
/// The GstVideoDecoder base class and derived subclasses should cooperate as
/// follows:
///
/// ## Configuration
///
/// * Initially, GstVideoDecoder calls `start` when the decoder element
/// is activated, which allows the subclass to perform any global setup.
///
/// * GstVideoDecoder calls `set_format` to inform the subclass of caps
/// describing input video data that it is about to receive, including
/// possibly configuration data.
/// While unlikely, it might be called more than once, if changing input
/// parameters require reconfiguration.
///
/// * Incoming data buffers are processed as needed, described in Data
/// Processing below.
///
/// * GstVideoDecoder calls `stop` at end of all processing.
///
/// ## Data processing
///
/// * The base class gathers input data, and optionally allows subclass
/// to parse this into subsequently manageable chunks, typically
/// corresponding to and referred to as 'frames'.
///
/// * Each input frame is provided in turn to the subclass' `handle_frame`
/// callback.
/// * When the subclass enables the subframe mode with `gst_video_decoder_set_subframe_mode`,
/// the base class will provide to the subclass the same input frame with
/// different input buffers to the subclass `handle_frame`
/// callback. During this call, the subclass needs to take
/// ownership of the input_buffer as [`VideoCodecFrame`][crate::VideoCodecFrame]
/// will have been changed before the next subframe buffer is received.
/// The subclass will call `gst_video_decoder_have_last_subframe`
/// when a new input frame can be created by the base class.
/// Every subframe will share the same [`VideoCodecFrame`][crate::VideoCodecFrame]
/// to write the decoding result. The subclass is responsible to protect
/// its access.
///
/// * If codec processing results in decoded data, the subclass should call
/// [`VideoDecoderExt::finish_frame()`][crate::prelude::VideoDecoderExt::finish_frame()] to have decoded data pushed
/// downstream. In subframe mode
/// the subclass should call [`VideoDecoderExt::finish_subframe()`][crate::prelude::VideoDecoderExt::finish_subframe()] until the
/// last subframe where it should call [`VideoDecoderExt::finish_frame()`][crate::prelude::VideoDecoderExt::finish_frame()].
/// The subclass can detect the last subframe using GST_VIDEO_BUFFER_FLAG_MARKER
/// on buffers or using its own logic to collect the subframes.
/// In case of decoding failure, the subclass must call
/// [`VideoDecoderExt::drop_frame()`][crate::prelude::VideoDecoderExt::drop_frame()] or [`VideoDecoderExt::drop_subframe()`][crate::prelude::VideoDecoderExt::drop_subframe()],
/// to allow the base class to do timestamp and offset tracking, and possibly
/// to requeue the frame for a later attempt in the case of reverse playback.
///
/// ## Shutdown phase
///
/// * The GstVideoDecoder class calls `stop` to inform the subclass that data
/// parsing will be stopped.
///
/// ## Additional Notes
///
/// * Seeking/Flushing
///
/// * When the pipeline is seeked or otherwise flushed, the subclass is
/// informed via a call to its `reset` callback, with the hard parameter
/// set to true. This indicates the subclass should drop any internal data
/// queues and timestamps and prepare for a fresh set of buffers to arrive
/// for parsing and decoding.
///
/// * End Of Stream
///
/// * At end-of-stream, the subclass `parse` function may be called some final
/// times with the at_eos parameter set to true, indicating that the element
/// should not expect any more data to be arriving, and it should parse and
/// remaining frames and call [`VideoDecoderExt::have_frame()`][crate::prelude::VideoDecoderExt::have_frame()] if possible.
///
/// The subclass is responsible for providing pad template caps for
/// source and sink pads. The pads need to be named "sink" and "src". It also
/// needs to provide information about the output caps, when they are known.
/// This may be when the base class calls the subclass' `set_format` function,
/// though it might be during decoding, before calling
/// [`VideoDecoderExt::finish_frame()`][crate::prelude::VideoDecoderExt::finish_frame()]. This is done via
/// [`VideoDecoderExtManual::set_output_state()`][crate::prelude::VideoDecoderExtManual::set_output_state()]
///
/// The subclass is also responsible for providing (presentation) timestamps
/// (likely based on corresponding input ones). If that is not applicable
/// or possible, the base class provides limited framerate based interpolation.
///
/// Similarly, the base class provides some limited (legacy) seeking support
/// if specifically requested by the subclass, as full-fledged support
/// should rather be left to upstream demuxer, parser or alike. This simple
/// approach caters for seeking and duration reporting using estimated input
/// bitrates. To enable it, a subclass should call
/// [`VideoDecoderExt::set_estimate_rate()`][crate::prelude::VideoDecoderExt::set_estimate_rate()] to enable handling of incoming
/// byte-streams.
///
/// The base class provides some support for reverse playback, in particular
/// in case incoming data is not packetized or upstream does not provide
/// fragments on keyframe boundaries. However, the subclass should then be
/// prepared for the parsing and frame processing stage to occur separately
/// (in normal forward processing, the latter immediately follows the former),
/// The subclass also needs to ensure the parsing stage properly marks
/// keyframes, unless it knows the upstream elements will do so properly for
/// incoming data.
///
/// The bare minimum that a functional subclass needs to implement is:
///
/// * Provide pad templates
/// * Inform the base class of output caps via
/// [`VideoDecoderExtManual::set_output_state()`][crate::prelude::VideoDecoderExtManual::set_output_state()]
///
/// * Parse input data, if it is not considered packetized from upstream
/// Data will be provided to `parse` which should invoke
/// [`VideoDecoderExt::add_to_frame()`][crate::prelude::VideoDecoderExt::add_to_frame()] and [`VideoDecoderExt::have_frame()`][crate::prelude::VideoDecoderExt::have_frame()] to
/// separate the data belonging to each video frame.
///
/// * Accept data in `handle_frame` and provide decoded results to
/// [`VideoDecoderExt::finish_frame()`][crate::prelude::VideoDecoderExt::finish_frame()], or call [`VideoDecoderExt::drop_frame()`][crate::prelude::VideoDecoderExt::drop_frame()].
///
/// This is an Abstract Base Class, you cannot instantiate it.
///
/// ## Properties
///
///
/// #### `automatic-request-sync-point-flags`
/// GstVideoDecoderRequestSyncPointFlags to use for the automatically
/// requested sync points if `automatic-request-sync-points` is enabled.
///
/// Readable | Writeable
///
///
/// #### `automatic-request-sync-points`
/// If set to [`true`] the decoder will automatically request sync points when
/// it seems like a good idea, e.g. if the first frames are not key frames or
/// if packet loss was reported by upstream.
///
/// Readable | Writeable
///
///
/// #### `discard-corrupted-frames`
/// If set to [`true`] the decoder will discard frames that are marked as
/// corrupted instead of outputting them.
///
/// Readable | Writeable
///
///
/// #### `max-errors`
/// Maximum number of tolerated consecutive decode errors. See
/// [`VideoDecoderExt::set_max_errors()`][crate::prelude::VideoDecoderExt::set_max_errors()] for more details.
///
/// Readable | Writeable
///
///
/// #### `min-force-key-unit-interval`
/// Minimum interval between force-key-unit events sent upstream by the
/// decoder. Setting this to 0 will cause every event to be handled, setting
/// this to `GST_CLOCK_TIME_NONE` will cause every event to be ignored.
///
/// See `gst_video_event_new_upstream_force_key_unit()` for more details about
/// force-key-unit events.
///
/// Readable | Writeable
///
///
/// #### `qos`
/// If set to [`true`] the decoder will handle QoS events received
/// from downstream elements.
/// This includes dropping output frames which are detected as late
/// using the metrics reported by those events.
///
/// Readable | Writeable
/// <details><summary><h4>Object</h4></summary>
///
///
/// #### `name`
/// Readable | Writeable | Construct
///
///
/// #### `parent`
/// The parent of the object. Please note, that when changing the 'parent'
/// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
/// signals due to locking issues. In some cases one can use
/// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
/// achieve a similar effect.
///
/// Readable | Writeable
/// </details>
///
/// # Implements
///
/// [`VideoDecoderExt`][trait@crate::prelude::VideoDecoderExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`VideoDecoderExtManual`][trait@crate::prelude::VideoDecoderExtManual]
#[doc(alias = "GstVideoDecoder")]
pub struct VideoDecoder(Object<ffi::GstVideoDecoder, ffi::GstVideoDecoderClass>) @extends gst::Element, gst::Object;
match fn {
type_ => || ffi::gst_video_decoder_get_type(),
}
}
impl VideoDecoder {
pub const NONE: Option<&'static VideoDecoder> = None;
}
unsafe impl Send for VideoDecoder {}
unsafe impl Sync for VideoDecoder {}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::VideoDecoder>> Sealed for T {}
}
/// Trait containing all [`struct@VideoDecoder`] methods.
///
/// # Implementors
///
/// [`VideoDecoder`][struct@crate::VideoDecoder]
pub trait VideoDecoderExt: IsA<VideoDecoder> + sealed::Sealed + 'static {
/// Removes next `n_bytes` of input data and adds it to currently parsed frame.
/// ## `n_bytes`
/// the number of bytes to add
#[doc(alias = "gst_video_decoder_add_to_frame")]
fn add_to_frame(&self, n_bytes: i32) {
unsafe {
ffi::gst_video_decoder_add_to_frame(self.as_ref().to_glib_none().0, n_bytes);
}
}
/// Helper function that allocates a buffer to hold a video frame for `self`'s
/// current [`VideoCodecState`][crate::VideoCodecState].
///
/// You should use [`VideoDecoderExtManual::allocate_output_frame()`][crate::prelude::VideoDecoderExtManual::allocate_output_frame()] instead of this
/// function, if possible at all.
///
/// # Returns
///
/// allocated buffer, or NULL if no buffer could be
/// allocated (e.g. when downstream is flushing or shutting down)
#[doc(alias = "gst_video_decoder_allocate_output_buffer")]
fn allocate_output_buffer(&self) -> Result<gst::Buffer, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::gst_video_decoder_allocate_output_buffer(
self.as_ref().to_glib_none().0,
))
.ok_or_else(|| glib::bool_error!("Failed to allocate output buffer"))
}
}
/// Similar to [`finish_frame()`][Self::finish_frame()], but drops `frame` in any
/// case and posts a QoS message with the frame's details on the bus.
/// In any case, the frame is considered finished and released.
/// ## `frame`
/// the [`VideoCodecFrame`][crate::VideoCodecFrame] to drop
///
/// # Returns
///
/// a [`gst::FlowReturn`][crate::gst::FlowReturn], usually GST_FLOW_OK.
#[doc(alias = "gst_video_decoder_drop_frame")]
fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
try_from_glib(ffi::gst_video_decoder_drop_frame(
self.as_ref().to_glib_none().0,
frame.into_glib_ptr(),
))
}
}
/// Drops input data.
/// The frame is not considered finished until the whole frame
/// is finished or dropped by the subclass.
/// ## `frame`
/// the [`VideoCodecFrame`][crate::VideoCodecFrame]
///
/// # Returns
///
/// a [`gst::FlowReturn`][crate::gst::FlowReturn], usually GST_FLOW_OK.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_drop_subframe")]
fn drop_subframe(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
try_from_glib(ffi::gst_video_decoder_drop_subframe(
self.as_ref().to_glib_none().0,
frame.into_glib_ptr(),
))
}
}
/// `frame` should have a valid decoded data buffer, whose metadata fields
/// are then appropriately set according to frame data and pushed downstream.
/// If no output data is provided, `frame` is considered skipped.
/// In any case, the frame is considered finished and released.
///
/// After calling this function the output buffer of the frame is to be
/// considered read-only. This function will also change the metadata
/// of the buffer.
/// ## `frame`
/// a decoded [`VideoCodecFrame`][crate::VideoCodecFrame]
///
/// # Returns
///
/// a [`gst::FlowReturn`][crate::gst::FlowReturn] resulting from sending data downstream
#[doc(alias = "gst_video_decoder_finish_frame")]
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
try_from_glib(ffi::gst_video_decoder_finish_frame(
self.as_ref().to_glib_none().0,
frame.into_glib_ptr(),
))
}
}
/// Indicate that a subframe has been finished to be decoded
/// by the subclass. This method should be called for all subframes
/// except the last subframe where [`finish_frame()`][Self::finish_frame()]
/// should be called instead.
/// ## `frame`
/// the [`VideoCodecFrame`][crate::VideoCodecFrame]
///
/// # Returns
///
/// a [`gst::FlowReturn`][crate::gst::FlowReturn], usually GST_FLOW_OK.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_finish_subframe")]
fn finish_subframe(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
try_from_glib(ffi::gst_video_decoder_finish_subframe(
self.as_ref().to_glib_none().0,
frame.into_glib_ptr(),
))
}
}
///
/// # Returns
///
/// the instance of the [`gst::BufferPool`][crate::gst::BufferPool] used
/// by the decoder; free it after use it
#[doc(alias = "gst_video_decoder_get_buffer_pool")]
#[doc(alias = "get_buffer_pool")]
fn buffer_pool(&self) -> Option<gst::BufferPool> {
unsafe {
from_glib_full(ffi::gst_video_decoder_get_buffer_pool(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// currently configured byte to time conversion setting
#[doc(alias = "gst_video_decoder_get_estimate_rate")]
#[doc(alias = "get_estimate_rate")]
fn estimate_rate(&self) -> i32 {
unsafe { ffi::gst_video_decoder_get_estimate_rate(self.as_ref().to_glib_none().0) }
}
/// Determines maximum possible decoding time for `frame` that will
/// allow it to decode and arrive in time (as determined by QoS events).
/// In particular, a negative result means decoding in time is no longer possible
/// and should therefore occur as soon/skippy as possible.
/// ## `frame`
/// a [`VideoCodecFrame`][crate::VideoCodecFrame]
///
/// # Returns
///
/// max decoding time.
#[doc(alias = "gst_video_decoder_get_max_decode_time")]
#[doc(alias = "get_max_decode_time")]
fn max_decode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff {
unsafe {
ffi::gst_video_decoder_get_max_decode_time(
self.as_ref().to_glib_none().0,
frame.to_glib_none().0,
)
}
}
///
/// # Returns
///
/// currently configured decoder tolerated error count.
#[doc(alias = "gst_video_decoder_get_max_errors")]
#[doc(alias = "get_max_errors")]
#[doc(alias = "max-errors")]
fn max_errors(&self) -> i32 {
unsafe { ffi::gst_video_decoder_get_max_errors(self.as_ref().to_glib_none().0) }
}
/// Queries decoder required format handling.
///
/// # Returns
///
/// [`true`] if required format handling is enabled.
#[doc(alias = "gst_video_decoder_get_needs_format")]
#[doc(alias = "get_needs_format")]
fn needs_format(&self) -> bool {
unsafe {
from_glib(ffi::gst_video_decoder_get_needs_format(
self.as_ref().to_glib_none().0,
))
}
}
/// Queries if the decoder requires a sync point before it starts outputting
/// data in the beginning.
///
/// # Returns
///
/// [`true`] if a sync point is required in the beginning.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_get_needs_sync_point")]
#[doc(alias = "get_needs_sync_point")]
fn needs_sync_point(&self) -> bool {
unsafe {
from_glib(ffi::gst_video_decoder_get_needs_sync_point(
self.as_ref().to_glib_none().0,
))
}
}
/// Queries whether input data is considered packetized or not by the
/// base class.
///
/// # Returns
///
/// TRUE if input data is considered packetized.
#[doc(alias = "gst_video_decoder_get_packetized")]
#[doc(alias = "get_packetized")]
fn is_packetized(&self) -> bool {
unsafe {
from_glib(ffi::gst_video_decoder_get_packetized(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns the number of bytes previously added to the current frame
/// by calling [`add_to_frame()`][Self::add_to_frame()].
///
/// # Returns
///
/// The number of bytes pending for the current frame
#[doc(alias = "gst_video_decoder_get_pending_frame_size")]
#[doc(alias = "get_pending_frame_size")]
fn pending_frame_size(&self) -> usize {
unsafe { ffi::gst_video_decoder_get_pending_frame_size(self.as_ref().to_glib_none().0) }
}
///
/// # Returns
///
/// The current QoS proportion.
#[doc(alias = "gst_video_decoder_get_qos_proportion")]
#[doc(alias = "get_qos_proportion")]
fn qos_proportion(&self) -> f64 {
unsafe { ffi::gst_video_decoder_get_qos_proportion(self.as_ref().to_glib_none().0) }
}
/// Queries whether input data is considered as subframes or not by the
/// base class. If FALSE, each input buffer will be considered as a full
/// frame.
///
/// # Returns
///
/// TRUE if input data is considered as sub frames.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_get_subframe_mode")]
#[doc(alias = "get_subframe_mode")]
fn is_subframe_mode(&self) -> bool {
unsafe {
from_glib(ffi::gst_video_decoder_get_subframe_mode(
self.as_ref().to_glib_none().0,
))
}
}
/// Gathers all data collected for currently parsed frame, gathers corresponding
/// metadata and passes it along for further processing, i.e. `handle_frame`.
///
/// # Returns
///
/// a [`gst::FlowReturn`][crate::gst::FlowReturn]
#[doc(alias = "gst_video_decoder_have_frame")]
fn have_frame(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
try_from_glib(ffi::gst_video_decoder_have_frame(
self.as_ref().to_glib_none().0,
))
}
}
/// Indicates that the last subframe has been processed by the decoder
/// in `frame`. This will release the current frame in video decoder
/// allowing to receive new frames from upstream elements. This method
/// must be called in the subclass `handle_frame` callback.
/// ## `frame`
/// the [`VideoCodecFrame`][crate::VideoCodecFrame] to update
///
/// # Returns
///
/// a [`gst::FlowReturn`][crate::gst::FlowReturn], usually GST_FLOW_OK.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_have_last_subframe")]
fn have_last_subframe(
&self,
frame: &VideoCodecFrame,
) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
try_from_glib(ffi::gst_video_decoder_have_last_subframe(
self.as_ref().to_glib_none().0,
frame.to_glib_none().0,
))
}
}
/// Sets the audio decoder tags and how they should be merged with any
/// upstream stream tags. This will override any tags previously-set
/// with `gst_audio_decoder_merge_tags()`.
///
/// Note that this is provided for convenience, and the subclass is
/// not required to use this and can still do tag handling on its own.
///
/// MT safe.
/// ## `tags`
/// a [`gst::TagList`][crate::gst::TagList] to merge, or NULL to unset
/// previously-set tags
/// ## `mode`
/// the [`gst::TagMergeMode`][crate::gst::TagMergeMode] to use, usually [`gst::TagMergeMode::Replace`][crate::gst::TagMergeMode::Replace]
#[doc(alias = "gst_video_decoder_merge_tags")]
fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
unsafe {
ffi::gst_video_decoder_merge_tags(
self.as_ref().to_glib_none().0,
tags.to_glib_none().0,
mode.into_glib(),
);
}
}
/// Returns caps that express `caps` (or sink template caps if `caps` == NULL)
/// restricted to resolution/format/... combinations supported by downstream
/// elements.
/// ## `caps`
/// initial caps
/// ## `filter`
/// filter caps
///
/// # Returns
///
/// a [`gst::Caps`][crate::gst::Caps] owned by caller
#[doc(alias = "gst_video_decoder_proxy_getcaps")]
fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
unsafe {
from_glib_full(ffi::gst_video_decoder_proxy_getcaps(
self.as_ref().to_glib_none().0,
caps.to_glib_none().0,
filter.to_glib_none().0,
))
}
}
/// Similar to [`drop_frame()`][Self::drop_frame()], but simply releases `frame`
/// without any processing other than removing it from list of pending frames,
/// after which it is considered finished and released.
/// ## `frame`
/// the [`VideoCodecFrame`][crate::VideoCodecFrame] to release
#[doc(alias = "gst_video_decoder_release_frame")]
fn release_frame(&self, frame: VideoCodecFrame) {
unsafe {
ffi::gst_video_decoder_release_frame(
self.as_ref().to_glib_none().0,
frame.into_glib_ptr(),
);
}
}
/// Allows the [`VideoDecoder`][crate::VideoDecoder] subclass to request from the base class that
/// a new sync should be requested from upstream, and that `frame` was the frame
/// when the subclass noticed that a new sync point is required. A reason for
/// the subclass to do this could be missing reference frames, for example.
///
/// The base class will then request a new sync point from upstream as long as
/// the time that passed since the last one is exceeding
/// [`min-force-key-unit-interval`][struct@crate::VideoDecoder#min-force-key-unit-interval].
///
/// The subclass can signal via `flags` how the frames until the next sync point
/// should be handled:
///
/// * If [`VideoDecoderRequestSyncPointFlags::DISCARD_INPUT`][crate::VideoDecoderRequestSyncPointFlags::DISCARD_INPUT] is selected then
/// all following input frames until the next sync point are discarded.
/// This can be useful if the lack of a sync point will prevent all further
/// decoding and the decoder implementation is not very robust in handling
/// missing references frames.
/// * If [`VideoDecoderRequestSyncPointFlags::CORRUPT_OUTPUT`][crate::VideoDecoderRequestSyncPointFlags::CORRUPT_OUTPUT] is selected
/// then all output frames following `frame` are marked as corrupted via
/// `GST_BUFFER_FLAG_CORRUPTED`. Corrupted frames can be automatically
/// dropped by the base class, see [`discard-corrupted-frames`][struct@crate::VideoDecoder#discard-corrupted-frames].
/// Subclasses can manually mark frames as corrupted via [`VideoCodecFrameFlags::CORRUPTED`][crate::VideoCodecFrameFlags::CORRUPTED]
/// before calling [`finish_frame()`][Self::finish_frame()].
/// ## `frame`
/// a [`VideoCodecFrame`][crate::VideoCodecFrame]
/// ## `flags`
/// [`VideoDecoderRequestSyncPointFlags`][crate::VideoDecoderRequestSyncPointFlags]
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_request_sync_point")]
fn request_sync_point(
&self,
frame: &VideoCodecFrame,
flags: VideoDecoderRequestSyncPointFlags,
) {
unsafe {
ffi::gst_video_decoder_request_sync_point(
self.as_ref().to_glib_none().0,
frame.to_glib_none().0,
flags.into_glib(),
);
}
}
/// Allows baseclass to perform byte to time estimated conversion.
/// ## `enabled`
/// whether to enable byte to time conversion
#[doc(alias = "gst_video_decoder_set_estimate_rate")]
fn set_estimate_rate(&self, enabled: bool) {
unsafe {
ffi::gst_video_decoder_set_estimate_rate(
self.as_ref().to_glib_none().0,
enabled.into_glib(),
);
}
}
/// Sets numbers of tolerated decoder errors, where a tolerated one is then only
/// warned about, but more than tolerated will lead to fatal error. You can set
/// -1 for never returning fatal errors. Default is set to
/// GST_VIDEO_DECODER_MAX_ERRORS.
///
/// The '-1' option was added in 1.4
/// ## `num`
/// max tolerated errors
#[doc(alias = "gst_video_decoder_set_max_errors")]
#[doc(alias = "max-errors")]
fn set_max_errors(&self, num: i32) {
unsafe {
ffi::gst_video_decoder_set_max_errors(self.as_ref().to_glib_none().0, num);
}
}
/// Configures decoder format needs. If enabled, subclass needs to be
/// negotiated with format caps before it can process any data. It will then
/// never be handed any data before it has been configured.
/// Otherwise, it might be handed data without having been configured and
/// is then expected being able to do so either by default
/// or based on the input data.
/// ## `enabled`
/// new state
#[doc(alias = "gst_video_decoder_set_needs_format")]
fn set_needs_format(&self, enabled: bool) {
unsafe {
ffi::gst_video_decoder_set_needs_format(
self.as_ref().to_glib_none().0,
enabled.into_glib(),
);
}
}
/// Configures whether the decoder requires a sync point before it starts
/// outputting data in the beginning. If enabled, the base class will discard
/// all non-sync point frames in the beginning and after a flush and does not
/// pass it to the subclass.
///
/// If the first frame is not a sync point, the base class will request a sync
/// point via the force-key-unit event.
/// ## `enabled`
/// new state
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_set_needs_sync_point")]
fn set_needs_sync_point(&self, enabled: bool) {
unsafe {
ffi::gst_video_decoder_set_needs_sync_point(
self.as_ref().to_glib_none().0,
enabled.into_glib(),
);
}
}
/// Allows baseclass to consider input data as packetized or not. If the
/// input is packetized, then the `parse` method will not be called.
/// ## `packetized`
/// whether the input data should be considered as packetized.
#[doc(alias = "gst_video_decoder_set_packetized")]
fn set_packetized(&self, packetized: bool) {
unsafe {
ffi::gst_video_decoder_set_packetized(
self.as_ref().to_glib_none().0,
packetized.into_glib(),
);
}
}
/// If this is set to TRUE, it informs the base class that the subclass
/// can receive the data at a granularity lower than one frame.
///
/// Note that in this mode, the subclass has two options. It can either
/// require the presence of a GST_VIDEO_BUFFER_FLAG_MARKER to mark the
/// end of a frame. Or it can operate in such a way that it will decode
/// a single frame at a time. In this second case, every buffer that
/// arrives to the element is considered part of the same frame until
/// [`finish_frame()`][Self::finish_frame()] is called.
///
/// In either case, the same [`VideoCodecFrame`][crate::VideoCodecFrame] will be passed to the
/// GstVideoDecoderClass:handle_frame vmethod repeatedly with a
/// different GstVideoCodecFrame:input_buffer every time until the end of the
/// frame has been signaled using either method.
/// This method must be called during the decoder subclass `set_format` call.
/// ## `subframe_mode`
/// whether the input data should be considered as subframes.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "gst_video_decoder_set_subframe_mode")]
fn set_subframe_mode(&self, subframe_mode: bool) {
unsafe {
ffi::gst_video_decoder_set_subframe_mode(
self.as_ref().to_glib_none().0,
subframe_mode.into_glib(),
);
}
}
/// Lets [`VideoDecoder`][crate::VideoDecoder] sub-classes decide if they want the sink pad
/// to use the default pad query handler to reply to accept-caps queries.
///
/// By setting this to true it is possible to further customize the default
/// handler with `GST_PAD_SET_ACCEPT_INTERSECT` and
/// `GST_PAD_SET_ACCEPT_TEMPLATE`
/// ## `use_`
/// if the default pad accept-caps query handling should be used
#[doc(alias = "gst_video_decoder_set_use_default_pad_acceptcaps")]
fn set_use_default_pad_acceptcaps(&self, use_: bool) {
unsafe {
ffi::gst_video_decoder_set_use_default_pad_acceptcaps(
self.as_ref().to_glib_none().0,
use_.into_glib(),
);
}
}
/// GstVideoDecoderRequestSyncPointFlags to use for the automatically
/// requested sync points if `automatic-request-sync-points` is enabled.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "automatic-request-sync-point-flags")]
fn automatic_request_sync_point_flags(&self) -> VideoDecoderRequestSyncPointFlags {
ObjectExt::property(self.as_ref(), "automatic-request-sync-point-flags")
}
/// GstVideoDecoderRequestSyncPointFlags to use for the automatically
/// requested sync points if `automatic-request-sync-points` is enabled.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "automatic-request-sync-point-flags")]
fn set_automatic_request_sync_point_flags(
&self,
automatic_request_sync_point_flags: VideoDecoderRequestSyncPointFlags,
) {
ObjectExt::set_property(
self.as_ref(),
"automatic-request-sync-point-flags",
automatic_request_sync_point_flags,
)
}
/// If set to [`true`] the decoder will automatically request sync points when
/// it seems like a good idea, e.g. if the first frames are not key frames or
/// if packet loss was reported by upstream.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "automatic-request-sync-points")]
fn is_automatic_request_sync_points(&self) -> bool {
ObjectExt::property(self.as_ref(), "automatic-request-sync-points")
}
/// If set to [`true`] the decoder will automatically request sync points when
/// it seems like a good idea, e.g. if the first frames are not key frames or
/// if packet loss was reported by upstream.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "automatic-request-sync-points")]
fn set_automatic_request_sync_points(&self, automatic_request_sync_points: bool) {
ObjectExt::set_property(
self.as_ref(),
"automatic-request-sync-points",
automatic_request_sync_points,
)
}
/// If set to [`true`] the decoder will discard frames that are marked as
/// corrupted instead of outputting them.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "discard-corrupted-frames")]
fn is_discard_corrupted_frames(&self) -> bool {
ObjectExt::property(self.as_ref(), "discard-corrupted-frames")
}
/// If set to [`true`] the decoder will discard frames that are marked as
/// corrupted instead of outputting them.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "discard-corrupted-frames")]
fn set_discard_corrupted_frames(&self, discard_corrupted_frames: bool) {
ObjectExt::set_property(
self.as_ref(),
"discard-corrupted-frames",
discard_corrupted_frames,
)
}
/// Minimum interval between force-key-unit events sent upstream by the
/// decoder. Setting this to 0 will cause every event to be handled, setting
/// this to `GST_CLOCK_TIME_NONE` will cause every event to be ignored.
///
/// See `gst_video_event_new_upstream_force_key_unit()` for more details about
/// force-key-unit events.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "min-force-key-unit-interval")]
fn min_force_key_unit_interval(&self) -> u64 {
ObjectExt::property(self.as_ref(), "min-force-key-unit-interval")
}
/// Minimum interval between force-key-unit events sent upstream by the
/// decoder. Setting this to 0 will cause every event to be handled, setting
/// this to `GST_CLOCK_TIME_NONE` will cause every event to be ignored.
///
/// See `gst_video_event_new_upstream_force_key_unit()` for more details about
/// force-key-unit events.
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "min-force-key-unit-interval")]
fn set_min_force_key_unit_interval(&self, min_force_key_unit_interval: u64) {
ObjectExt::set_property(
self.as_ref(),
"min-force-key-unit-interval",
min_force_key_unit_interval,
)
}
/// If set to [`true`] the decoder will handle QoS events received
/// from downstream elements.
/// This includes dropping output frames which are detected as late
/// using the metrics reported by those events.
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
fn is_qos(&self) -> bool {
ObjectExt::property(self.as_ref(), "qos")
}
/// If set to [`true`] the decoder will handle QoS events received
/// from downstream elements.
/// This includes dropping output frames which are detected as late
/// using the metrics reported by those events.
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
fn set_qos(&self, qos: bool) {
ObjectExt::set_property(self.as_ref(), "qos", qos)
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "automatic-request-sync-point-flags")]
fn connect_automatic_request_sync_point_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_automatic_request_sync_point_flags_trampoline<
P: IsA<VideoDecoder>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoDecoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::automatic-request-sync-point-flags\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_automatic_request_sync_point_flags_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "automatic-request-sync-points")]
fn connect_automatic_request_sync_points_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_automatic_request_sync_points_trampoline<
P: IsA<VideoDecoder>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoDecoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::automatic-request-sync-points\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_automatic_request_sync_points_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "discard-corrupted-frames")]
fn connect_discard_corrupted_frames_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_discard_corrupted_frames_trampoline<
P: IsA<VideoDecoder>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoDecoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::discard-corrupted-frames\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_discard_corrupted_frames_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "max-errors")]
fn connect_max_errors_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_max_errors_trampoline<
P: IsA<VideoDecoder>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoDecoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::max-errors\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_max_errors_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "min-force-key-unit-interval")]
fn connect_min_force_key_unit_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_min_force_key_unit_interval_trampoline<
P: IsA<VideoDecoder>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoDecoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::min-force-key-unit-interval\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_min_force_key_unit_interval_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "qos")]
fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_qos_trampoline<
P: IsA<VideoDecoder>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoDecoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoDecoder::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::qos\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_qos_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<VideoDecoder>> VideoDecoderExt for O {}