gstreamer-rs/gstreamer-video/src/auto/video_encoder.rs

241 lines
8 KiB
Rust
Raw Normal View History

// 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
2020-11-22 09:50:37 +00:00
use crate::VideoCodecFrame;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, mem::transmute};
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GstVideoEncoder")]
2020-11-22 09:50:37 +00:00
pub struct VideoEncoder(Object<ffi::GstVideoEncoder, ffi::GstVideoEncoderClass>) @extends gst::Element, gst::Object;
match fn {
type_ => || ffi::gst_video_encoder_get_type(),
}
}
2021-11-03 17:28:46 +00:00
impl VideoEncoder {
pub const NONE: Option<&'static VideoEncoder> = None;
}
2021-11-16 14:02:58 +00:00
unsafe impl Send for VideoEncoder {}
unsafe impl Sync for VideoEncoder {}
pub trait VideoEncoderExt: 'static {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_allocate_output_buffer")]
fn allocate_output_buffer(&self, size: usize) -> gst::Buffer;
#[doc(alias = "gst_video_encoder_finish_frame")]
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_get_max_encode_time")]
#[doc(alias = "get_max_encode_time")]
2021-04-19 20:13:58 +00:00
fn max_encode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff;
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_get_min_force_key_unit_interval")]
#[doc(alias = "get_min_force_key_unit_interval")]
fn min_force_key_unit_interval(&self) -> Option<gst::ClockTime>;
2020-07-06 08:37:14 +00:00
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_is_qos_enabled")]
fn is_qos_enabled(&self) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_merge_tags")]
fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_proxy_getcaps")]
fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps;
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_set_min_force_key_unit_interval")]
fn set_min_force_key_unit_interval(&self, interval: impl Into<Option<gst::ClockTime>>);
2020-07-06 08:37:14 +00:00
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_set_min_pts")]
fn set_min_pts(&self, min_pts: impl Into<Option<gst::ClockTime>>);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_video_encoder_set_qos_enabled")]
fn set_qos_enabled(&self, enabled: bool);
2021-04-11 19:38:18 +00:00
fn is_qos(&self) -> bool;
2021-04-11 19:38:18 +00:00
fn set_qos(&self, qos: bool);
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[doc(alias = "min-force-key-unit-interval")]
fn connect_min_force_key_unit_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
2020-07-06 08:37:14 +00:00
&self,
f: F,
) -> SignalHandlerId;
#[doc(alias = "qos")]
fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<VideoEncoder>> VideoEncoderExt for O {
fn allocate_output_buffer(&self, size: usize) -> gst::Buffer {
unsafe {
from_glib_full(ffi::gst_video_encoder_allocate_output_buffer(
self.as_ref().to_glib_none().0,
size,
))
}
}
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
try_from_glib(ffi::gst_video_encoder_finish_frame(
self.as_ref().to_glib_none().0,
frame.into_glib_ptr(),
))
}
}
2021-04-19 20:13:58 +00:00
fn max_encode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff {
unsafe {
2020-11-22 09:50:37 +00:00
ffi::gst_video_encoder_get_max_encode_time(
self.as_ref().to_glib_none().0,
frame.to_glib_none().0,
)
}
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn min_force_key_unit_interval(&self) -> Option<gst::ClockTime> {
2020-07-06 08:37:14 +00:00
unsafe {
2020-11-22 09:50:37 +00:00
from_glib(ffi::gst_video_encoder_get_min_force_key_unit_interval(
self.as_ref().to_glib_none().0,
))
2020-07-06 08:37:14 +00:00
}
}
fn is_qos_enabled(&self) -> bool {
unsafe {
2020-11-22 09:50:37 +00:00
from_glib(ffi::gst_video_encoder_is_qos_enabled(
self.as_ref().to_glib_none().0,
))
}
}
fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
unsafe {
2020-11-22 09:50:37 +00:00
ffi::gst_video_encoder_merge_tags(
self.as_ref().to_glib_none().0,
tags.to_glib_none().0,
mode.into_glib(),
);
}
}
fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
unsafe {
2020-11-22 09:50:37 +00:00
from_glib_full(ffi::gst_video_encoder_proxy_getcaps(
self.as_ref().to_glib_none().0,
caps.to_glib_none().0,
filter.to_glib_none().0,
))
}
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn set_min_force_key_unit_interval(&self, interval: impl Into<Option<gst::ClockTime>>) {
2020-07-06 08:37:14 +00:00
unsafe {
2020-11-22 09:50:37 +00:00
ffi::gst_video_encoder_set_min_force_key_unit_interval(
2020-07-06 08:37:14 +00:00
self.as_ref().to_glib_none().0,
interval.into().into_glib(),
2020-07-06 08:37:14 +00:00
);
}
}
fn set_min_pts(&self, min_pts: impl Into<Option<gst::ClockTime>>) {
unsafe {
ffi::gst_video_encoder_set_min_pts(
self.as_ref().to_glib_none().0,
min_pts.into().into_glib(),
);
}
}
fn set_qos_enabled(&self, enabled: bool) {
unsafe {
2020-11-22 09:50:37 +00:00
ffi::gst_video_encoder_set_qos_enabled(
self.as_ref().to_glib_none().0,
enabled.into_glib(),
);
}
}
2021-04-11 19:38:18 +00:00
fn is_qos(&self) -> bool {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self.as_ref(), "qos")
}
2021-04-11 19:38:18 +00:00
fn set_qos(&self, qos: bool) {
glib::ObjectExt::set_property(self.as_ref(), "qos", qos)
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn connect_min_force_key_unit_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
2020-07-06 08:37:14 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_min_force_key_unit_interval_trampoline<
P: IsA<VideoEncoder>,
2020-07-06 08:37:14 +00:00
F: Fn(&P) + Send + Sync + 'static,
>(
2020-11-22 09:50:37 +00:00
this: *mut ffi::GstVideoEncoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
2020-07-06 08:37:14 +00:00
let f: &F = &*(f as *const F);
2021-06-21 21:07:45 +00:00
f(VideoEncoder::from_glib_borrow(this).unsafe_cast_ref())
2020-07-06 08:37:14 +00:00
}
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(transmute::<_, unsafe extern "C" fn()>(
notify_min_force_key_unit_interval_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_qos_trampoline<
P: IsA<VideoEncoder>,
F: Fn(&P) + Send + Sync + 'static,
>(
2020-11-22 09:50:37 +00:00
this: *mut ffi::GstVideoEncoder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
2021-06-21 21:07:45 +00:00
f(VideoEncoder::from_glib_borrow(this).unsafe_cast_ref())
2019-06-18 10:10:46 +00:00
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::qos\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
notify_qos_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}