video: Add bindings for VideoAggregator

This commit is contained in:
Sebastian Dröge 2022-03-21 19:18:54 +02:00
parent 215cdfd548
commit fbe0728da5
12 changed files with 536 additions and 1 deletions

View file

@ -24,6 +24,7 @@ generate = [
"GstVideo.NavigationQueryType",
"GstVideo.VideoAFDSpec",
"GstVideo.VideoAFDValue",
"GstVideo.VideoAggregator",
"GstVideo.VideoAggregatorParallelConvertPad",
"GstVideo.VideoAlphaMode",
"GstVideo.VideoBufferPool",
@ -59,10 +60,13 @@ manual = [
"Gst.Memory",
"Gst.Message",
"Gst.Object",
"Gst.Pad",
"Gst.Pipeline",
"Gst.State",
"Gst.TagList",
"Gst.TagMergeMode",
"GstBase.Aggregator",
"GstBase.AggregatorPad",
"GstBase.BaseSink",
"GstBase.BaseTransform",
"GstVideo.VideoCodecFrame",
@ -236,6 +240,30 @@ status = "generate"
name = "mouse_scroll"
version = "1.18"
[[object]]
name = "GstVideo.VideoAggregatorConvertPad"
status = "generate"
[[object.property]]
name = "converter-config"
# wrong type
manual = true
[[object]]
name = "GstVideo.VideoAggregatorPad"
status = "generate"
[[object.function]]
name = "get_current_buffer"
# needs special considerations
manual = true
[[object.function]]
name = "get_prepared_frame"
# needs special considerations
manual = true
[[object.function]]
name = "has_current_buffer"
# needs special considerations
manual = true
[[object]]
name = "GstVideo.VideoBufferFlags"
status = "generate"

View file

@ -12,6 +12,27 @@ pub use self::color_balance_channel::ColorBalanceChannel;
mod navigation;
pub use self::navigation::Navigation;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
mod video_aggregator;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use self::video_aggregator::VideoAggregator;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
mod video_aggregator_convert_pad;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use self::video_aggregator_convert_pad::VideoAggregatorConvertPad;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
mod video_aggregator_pad;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use self::video_aggregator_pad::VideoAggregatorPad;
#[cfg(any(feature = "v1_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
mod video_aggregator_parallel_convert_pad;
@ -99,6 +120,15 @@ pub mod traits {
pub use super::color_balance::ColorBalanceExt;
pub use super::color_balance_channel::ColorBalanceChannelExt;
pub use super::navigation::NavigationExt;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use super::video_aggregator::VideoAggregatorExt;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use super::video_aggregator_convert_pad::VideoAggregatorConvertPadExt;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use super::video_aggregator_pad::VideoAggregatorPadExt;
pub use super::video_decoder::VideoDecoderExt;
pub use super::video_encoder::VideoEncoderExt;
pub use super::video_orientation::VideoOrientationExt;

View file

@ -0,0 +1,38 @@
// 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
use glib::object::IsA;
glib::wrapper! {
#[doc(alias = "GstVideoAggregator")]
pub struct VideoAggregator(Object<ffi::GstVideoAggregator, ffi::GstVideoAggregatorClass>) @extends gst_base::Aggregator, gst::Element, gst::Object;
match fn {
type_ => || ffi::gst_video_aggregator_get_type(),
}
}
impl VideoAggregator {
pub const NONE: Option<&'static VideoAggregator> = None;
}
unsafe impl Send for VideoAggregator {}
unsafe impl Sync for VideoAggregator {}
pub trait VideoAggregatorExt: 'static {
//#[cfg(any(feature = "v1_20", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
//#[doc(alias = "gst_video_aggregator_get_execution_task_pool")]
//#[doc(alias = "get_execution_task_pool")]
//fn execution_task_pool(&self) -> /*Ignored*/Option<gst::TaskPool>;
}
impl<O: IsA<VideoAggregator>> VideoAggregatorExt for O {
//#[cfg(any(feature = "v1_20", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
//fn execution_task_pool(&self) -> /*Ignored*/Option<gst::TaskPool> {
// unsafe { TODO: call ffi:gst_video_aggregator_get_execution_task_pool() }
//}
}

View file

@ -0,0 +1,39 @@
// 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
use crate::VideoAggregatorPad;
use glib::object::IsA;
use glib::translate::*;
glib::wrapper! {
#[doc(alias = "GstVideoAggregatorConvertPad")]
pub struct VideoAggregatorConvertPad(Object<ffi::GstVideoAggregatorConvertPad, ffi::GstVideoAggregatorConvertPadClass>) @extends VideoAggregatorPad, gst_base::AggregatorPad, gst::Pad, gst::Object;
match fn {
type_ => || ffi::gst_video_aggregator_convert_pad_get_type(),
}
}
impl VideoAggregatorConvertPad {
pub const NONE: Option<&'static VideoAggregatorConvertPad> = None;
}
unsafe impl Send for VideoAggregatorConvertPad {}
unsafe impl Sync for VideoAggregatorConvertPad {}
pub trait VideoAggregatorConvertPadExt: 'static {
#[doc(alias = "gst_video_aggregator_convert_pad_update_conversion_info")]
fn update_conversion_info(&self);
}
impl<O: IsA<VideoAggregatorConvertPad>> VideoAggregatorConvertPadExt for O {
fn update_conversion_info(&self) {
unsafe {
ffi::gst_video_aggregator_convert_pad_update_conversion_info(
self.as_ref().to_glib_none().0,
);
}
}
}

View file

@ -0,0 +1,186 @@
// 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
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib::wrapper! {
#[doc(alias = "GstVideoAggregatorPad")]
pub struct VideoAggregatorPad(Object<ffi::GstVideoAggregatorPad, ffi::GstVideoAggregatorPadClass>) @extends gst_base::AggregatorPad, gst::Pad, gst::Object;
match fn {
type_ => || ffi::gst_video_aggregator_pad_get_type(),
}
}
impl VideoAggregatorPad {
pub const NONE: Option<&'static VideoAggregatorPad> = None;
}
unsafe impl Send for VideoAggregatorPad {}
unsafe impl Sync for VideoAggregatorPad {}
pub trait VideoAggregatorPadExt: 'static {
#[doc(alias = "gst_video_aggregator_pad_set_needs_alpha")]
fn set_needs_alpha(&self, needs_alpha: bool);
#[doc(alias = "max-last-buffer-repeat")]
fn max_last_buffer_repeat(&self) -> u64;
#[doc(alias = "max-last-buffer-repeat")]
fn set_max_last_buffer_repeat(&self, max_last_buffer_repeat: u64);
#[doc(alias = "repeat-after-eos")]
fn is_repeat_after_eos(&self) -> bool;
#[doc(alias = "repeat-after-eos")]
fn set_repeat_after_eos(&self, repeat_after_eos: bool);
fn zorder(&self) -> u32;
fn set_zorder(&self, zorder: u32);
#[doc(alias = "max-last-buffer-repeat")]
fn connect_max_last_buffer_repeat_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
#[doc(alias = "repeat-after-eos")]
fn connect_repeat_after_eos_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
#[doc(alias = "zorder")]
fn connect_zorder_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<VideoAggregatorPad>> VideoAggregatorPadExt for O {
fn set_needs_alpha(&self, needs_alpha: bool) {
unsafe {
ffi::gst_video_aggregator_pad_set_needs_alpha(
self.as_ref().to_glib_none().0,
needs_alpha.into_glib(),
);
}
}
fn max_last_buffer_repeat(&self) -> u64 {
glib::ObjectExt::property(self.as_ref(), "max-last-buffer-repeat")
}
fn set_max_last_buffer_repeat(&self, max_last_buffer_repeat: u64) {
glib::ObjectExt::set_property(
self.as_ref(),
"max-last-buffer-repeat",
&max_last_buffer_repeat,
)
}
fn is_repeat_after_eos(&self) -> bool {
glib::ObjectExt::property(self.as_ref(), "repeat-after-eos")
}
fn set_repeat_after_eos(&self, repeat_after_eos: bool) {
glib::ObjectExt::set_property(self.as_ref(), "repeat-after-eos", &repeat_after_eos)
}
fn zorder(&self) -> u32 {
glib::ObjectExt::property(self.as_ref(), "zorder")
}
fn set_zorder(&self, zorder: u32) {
glib::ObjectExt::set_property(self.as_ref(), "zorder", &zorder)
}
fn connect_max_last_buffer_repeat_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_max_last_buffer_repeat_trampoline<
P: IsA<VideoAggregatorPad>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoAggregatorPad,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoAggregatorPad::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-last-buffer-repeat\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_max_last_buffer_repeat_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_repeat_after_eos_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_repeat_after_eos_trampoline<
P: IsA<VideoAggregatorPad>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoAggregatorPad,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoAggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::repeat-after-eos\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_repeat_after_eos_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_zorder_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_zorder_trampoline<
P: IsA<VideoAggregatorPad>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoAggregatorPad,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoAggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::zorder\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_zorder_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}

View file

@ -3,9 +3,12 @@
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
use crate::VideoAggregatorConvertPad;
use crate::VideoAggregatorPad;
glib::wrapper! {
#[doc(alias = "GstVideoAggregatorParallelConvertPad")]
pub struct VideoAggregatorParallelConvertPad(Object<ffi::GstVideoAggregatorParallelConvertPad, ffi::GstVideoAggregatorParallelConvertPadClass>) @extends gst::Object;
pub struct VideoAggregatorParallelConvertPad(Object<ffi::GstVideoAggregatorParallelConvertPad, ffi::GstVideoAggregatorParallelConvertPadClass>) @extends VideoAggregatorConvertPad, VideoAggregatorPad, gst_base::AggregatorPad, gst::Pad, gst::Object;
match fn {
type_ => || ffi::gst_video_aggregator_parallel_convert_pad_get_type(),

View file

@ -125,6 +125,16 @@ pub use crate::video_hdr::*;
mod color_balance_channel;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
mod video_aggregator;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
mod video_aggregator_convert_pad;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
mod video_aggregator_pad;
pub const VIDEO_ENCODER_FLOW_NEED_DATA: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess;
pub const VIDEO_DECODER_FLOW_NEED_DATA: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess;
@ -136,6 +146,15 @@ pub mod prelude {
pub use crate::auto::traits::*;
pub use crate::navigation::NavigationExtManual;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use crate::video_aggregator::VideoAggregatorExtManual;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use crate::video_aggregator_convert_pad::VideoAggregatorConvertPadExtManual;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use crate::video_aggregator_pad::VideoAggregatorPadExtManual;
pub use crate::video_buffer_pool::VideoBufferPoolConfig;
pub use crate::video_decoder::VideoDecoderExtManual;
pub use crate::video_encoder::VideoEncoderExtManual;

View file

@ -8,6 +8,10 @@ mod video_encoder;
mod video_filter;
mod video_sink;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
pub use video_aggregator::AggregateFramesToken;
pub mod prelude {
#[doc(hidden)]
pub use gst_base::subclass::prelude::*;

View file

@ -1,8 +1,35 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use glib::translate::mut_override;
pub trait HasStreamLock {
#[doc(alias = "get_stream_lock")]
fn stream_lock(&self) -> *mut glib::ffi::GRecMutex;
#[doc(alias = "get_element_as_ptr")]
fn element_as_ptr(&self) -> *const gst::ffi::GstElement;
}
#[must_use = "if unused the Mutex will immediately unlock"]
#[doc(alias = "GMutex")]
pub struct MutexGuard<'a>(&'a glib::ffi::GMutex);
impl<'a> MutexGuard<'a> {
#[allow(clippy::trivially_copy_pass_by_ref)]
#[allow(dead_code)]
#[doc(alias = "g_mutex_lock")]
pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self {
skip_assert_initialized!();
unsafe {
glib::ffi::g_mutex_lock(mut_override(mutex));
}
MutexGuard(mutex)
}
}
impl<'a> Drop for MutexGuard<'a> {
fn drop(&mut self) {
unsafe {
glib::ffi::g_mutex_unlock(mut_override(self.0));
}
}
}

View file

@ -0,0 +1,26 @@
use crate::auto::VideoAggregator;
use glib::object::IsA;
use glib::translate::*;
pub trait VideoAggregatorExtManual: 'static {
fn video_info(&self) -> Option<crate::VideoInfo>;
}
impl<O: IsA<VideoAggregator>> VideoAggregatorExtManual for O {
fn video_info(&self) -> Option<crate::VideoInfo> {
unsafe {
let ptr = self.as_ptr() as *mut ffi::GstVideoAggregator;
let _guard = crate::utils::MutexGuard::lock(&(*(ptr as *mut gst::ffi::GstObject)).lock);
let info = &(*ptr).info;
if info.finfo.is_null() || info.width <= 0 || info.height <= 0 {
return None;
}
Some(from_glib_none(mut_override(
info as *const ffi::GstVideoInfo,
)))
}
}
}

View file

@ -0,0 +1,64 @@
use crate::auto::VideoAggregatorConvertPad;
use glib::object::IsA;
use glib::signal::{connect_raw, SignalHandlerId};
use glib::translate::*;
use glib::Cast;
use std::mem::transmute;
pub trait VideoAggregatorConvertPadExtManual: 'static {
#[doc(alias = "converter-config")]
fn converter_config(&self) -> Option<crate::VideoConverterConfig>;
#[doc(alias = "converter-config")]
fn set_converter_config(&self, converter_config: Option<&crate::VideoConverterConfig>);
#[doc(alias = "converter-config")]
fn connect_converter_config_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
}
impl<O: IsA<VideoAggregatorConvertPad>> VideoAggregatorConvertPadExtManual for O {
fn converter_config(&self) -> Option<crate::VideoConverterConfig> {
glib::ObjectExt::property::<Option<gst::Structure>>(self.as_ref(), "converter-config")
.map(|c| c.try_into().unwrap())
}
fn set_converter_config(&self, converter_config: Option<&crate::VideoConverterConfig>) {
glib::ObjectExt::set_property(
self.as_ref(),
"converter-config",
converter_config.map(|s| s.as_ref()),
)
}
fn connect_converter_config_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_converter_config_trampoline<
P: IsA<VideoAggregatorConvertPad>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstVideoAggregatorConvertPad,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(VideoAggregatorConvertPad::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box<F> = Box::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::converter-config\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_converter_config_trampoline::<Self, F> as *const (),
)),
Box::into_raw(f),
)
}
}
}

View file

@ -0,0 +1,71 @@
use crate::auto::VideoAggregatorPad;
use crate::subclass::AggregateFramesToken;
use glib::object::IsA;
use glib::translate::*;
pub trait VideoAggregatorPadExtManual: 'static {
#[doc(alias = "gst_video_aggregator_pad_has_current_buffer")]
fn has_current_buffer(&self, token: &AggregateFramesToken) -> bool;
#[doc(alias = "gst_video_aggregator_pad_get_current_buffer")]
fn current_buffer(&self, token: &AggregateFramesToken) -> Option<gst::Buffer>;
#[doc(alias = "gst_video_aggregator_pad_get_prepared_frame")]
fn prepared_frame<'a>(
&self,
token: &'a AggregateFramesToken,
) -> Option<crate::VideoFrameRef<&'a gst::BufferRef>>;
fn video_info(&self) -> Option<crate::VideoInfo>;
}
impl<O: IsA<VideoAggregatorPad>> VideoAggregatorPadExtManual for O {
fn has_current_buffer(&self, _token: &AggregateFramesToken) -> bool {
unsafe {
from_glib(ffi::gst_video_aggregator_pad_has_current_buffer(
self.as_ref().to_glib_none().0,
))
}
}
fn current_buffer(&self, _token: &AggregateFramesToken) -> Option<gst::Buffer> {
unsafe {
from_glib_none(ffi::gst_video_aggregator_pad_get_current_buffer(
self.as_ref().to_glib_none().0,
))
}
}
fn prepared_frame<'a>(
&self,
_token: &'a AggregateFramesToken,
) -> Option<crate::VideoFrameRef<&'a gst::BufferRef>> {
unsafe {
let ptr =
ffi::gst_video_aggregator_pad_get_prepared_frame(self.as_ref().to_glib_none().0);
if ptr.is_null() {
None
} else {
Some(crate::VideoFrameRef::from_glib_borrow(ptr).into_inner())
}
}
}
fn video_info(&self) -> Option<crate::VideoInfo> {
unsafe {
let ptr = self.as_ptr() as *mut ffi::GstVideoAggregatorPad;
let _guard = crate::utils::MutexGuard::lock(&(*(ptr as *mut gst::ffi::GstObject)).lock);
let info = &(*ptr).info;
if info.finfo.is_null() || info.width <= 0 || info.height <= 0 {
return None;
}
Some(from_glib_none(mut_override(
info as *const ffi::GstVideoInfo,
)))
}
}
}