gstreamer: Implement pad default functions as associated functions

Making them associated functions clearer that special care is required
and avoid conflicts with the same functions in ghostpad/proxypad.
This commit is contained in:
Sebastian Dröge 2022-10-12 17:27:04 +03:00
parent 69f05a1577
commit 734afa998b
4 changed files with 70 additions and 112 deletions

View file

@ -5,7 +5,6 @@ use crate::FlowError;
use crate::FlowSuccess;
use crate::GhostPad;
use crate::LoggableError;
use crate::Object;
use crate::Pad;
use crate::PadBuilder;
use crate::PadFlags;
@ -16,9 +15,9 @@ use glib::translate::*;
impl GhostPad {
#[doc(alias = "gst_ghost_pad_activate_mode_default")]
pub fn activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>(
pub fn activate_mode_default<P: IsA<GhostPad>>(
pad: &P,
parent: Option<&Q>,
parent: Option<&impl IsA<crate::Object>>,
mode: PadMode,
active: bool,
) -> Result<(), glib::BoolError> {
@ -37,9 +36,9 @@ impl GhostPad {
}
#[doc(alias = "gst_ghost_pad_internal_activate_mode_default")]
pub fn internal_activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>(
pub fn internal_activate_mode_default<P: IsA<GhostPad>>(
pad: &P,
parent: Option<&Q>,
parent: Option<&impl IsA<crate::Object>>,
mode: PadMode,
active: bool,
) -> Result<(), glib::BoolError> {

View file

@ -324,7 +324,6 @@ pub mod prelude {
pub use crate::pipeline::GstPipelineExtManual;
pub use crate::plugin::GstPluginExtManual;
pub use crate::plugin_feature::PluginFeatureExtManual;
pub use crate::proxy_pad::ProxyPadExtManual;
pub use crate::tag_setter::TagSetterExtManual;
pub use crate::task_pool::{TaskHandle, TaskPoolExtManual};
pub use crate::typefind::TypeFindImpl;

View file

@ -143,22 +143,10 @@ pub trait PadExtManual: 'static {
fn peer_query(&self, query: &mut QueryRef) -> bool;
#[doc(alias = "gst_pad_query")]
fn query(&self, query: &mut QueryRef) -> bool;
#[doc(alias = "gst_pad_query_default")]
fn query_default<P: IsA<crate::Object>>(
&self,
parent: Option<&P>,
query: &mut QueryRef,
) -> bool;
fn proxy_query_caps(&self, query: &mut QueryRef) -> bool;
#[doc(alias = "gst_pad_proxy_query_accept_caps")]
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool;
#[doc(alias = "gst_pad_event_default")]
fn event_default<P: IsA<crate::Object>>(
&self,
parent: Option<&P>,
event: impl Into<Event>,
) -> bool;
#[doc(alias = "gst_pad_push_event")]
fn push_event(&self, event: impl Into<Event>) -> bool;
#[doc(alias = "gst_pad_send_event")]
@ -166,11 +154,6 @@ pub trait PadExtManual: 'static {
#[doc(alias = "gst_pad_iterate_internal_links")]
fn iterate_internal_links(&self) -> crate::Iterator<Pad>;
#[doc(alias = "gst_pad_iterate_internal_links_default")]
fn iterate_internal_links_default<P: IsA<crate::Object>>(
&self,
parent: Option<&P>,
) -> crate::Iterator<Pad>;
fn stream_lock(&self) -> StreamLock;
@ -502,21 +485,6 @@ impl<O: IsA<Pad>> PadExtManual for O {
}
}
fn query_default<P: IsA<crate::Object>>(
&self,
parent: Option<&P>,
query: &mut QueryRef,
) -> bool {
skip_assert_initialized!();
unsafe {
from_glib(ffi::gst_pad_query_default(
self.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
query.as_mut_ptr(),
))
}
}
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_proxy_query_accept_caps(
@ -535,21 +503,6 @@ impl<O: IsA<Pad>> PadExtManual for O {
}
}
fn event_default<P: IsA<crate::Object>>(
&self,
parent: Option<&P>,
event: impl Into<Event>,
) -> bool {
skip_assert_initialized!();
unsafe {
from_glib(ffi::gst_pad_event_default(
self.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
event.into().into_glib_ptr(),
))
}
}
fn push_event(&self, event: impl Into<Event>) -> bool {
unsafe {
from_glib(ffi::gst_pad_push_event(
@ -576,18 +529,6 @@ impl<O: IsA<Pad>> PadExtManual for O {
}
}
fn iterate_internal_links_default<P: IsA<crate::Object>>(
&self,
parent: Option<&P>,
) -> crate::Iterator<Pad> {
unsafe {
from_glib_full(ffi::gst_pad_iterate_internal_links_default(
self.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
))
}
}
fn stream_lock(&self) -> StreamLock {
unsafe {
let ptr: &mut ffi::GstPad = &mut *(self.as_ptr() as *mut _);
@ -1652,6 +1593,52 @@ impl Pad {
skip_assert_initialized!();
PadBuilder::from_template(templ, name)
}
#[doc(alias = "gst_pad_query_default")]
pub fn query_default<O: IsA<Pad>>(
pad: &O,
parent: Option<&impl IsA<crate::Object>>,
query: &mut QueryRef,
) -> bool {
skip_assert_initialized!();
unsafe {
from_glib(ffi::gst_pad_query_default(
pad.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
query.as_mut_ptr(),
))
}
}
#[doc(alias = "gst_pad_event_default")]
pub fn event_default<O: IsA<Pad>>(
pad: &O,
parent: Option<&impl IsA<crate::Object>>,
event: impl Into<Event>,
) -> bool {
skip_assert_initialized!();
unsafe {
from_glib(ffi::gst_pad_event_default(
pad.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
event.into().into_glib_ptr(),
))
}
}
#[doc(alias = "gst_pad_iterate_internal_links_default")]
pub fn iterate_internal_links_default<O: IsA<Pad>>(
pad: &O,
parent: Option<&impl IsA<crate::Object>>,
) -> crate::Iterator<Pad> {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_pad_iterate_internal_links_default(
pad.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
))
}
}
}
#[must_use = "The builder must be built to be used"]

View file

@ -4,7 +4,6 @@ use crate::Buffer;
use crate::BufferList;
use crate::FlowError;
use crate::FlowSuccess;
use crate::Object;
use crate::Pad;
use crate::ProxyPad;
use std::ptr;
@ -12,70 +11,43 @@ use std::ptr;
use glib::prelude::*;
use glib::translate::*;
pub trait ProxyPadExtManual: 'static {
impl ProxyPad {
#[doc(alias = "gst_proxy_pad_chain_default")]
fn chain_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
buffer: Buffer,
) -> Result<FlowSuccess, FlowError>;
#[doc(alias = "gst_proxy_pad_chain_list_default")]
fn chain_list_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
list: BufferList,
) -> Result<FlowSuccess, FlowError>;
#[doc(alias = "gst_proxy_pad_getrange_default")]
fn getrange_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
offset: u64,
size: u32,
) -> Result<Buffer, FlowError>;
#[doc(alias = "gst_proxy_pad_iterate_internal_links_default")]
fn iterate_internal_links_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
) -> Option<crate::Iterator<Pad>>;
}
impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
fn chain_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
pub fn chain_default<O: IsA<ProxyPad>>(
pad: &O,
parent: Option<&impl IsA<crate::Object>>,
buffer: Buffer,
) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!();
unsafe {
try_from_glib(ffi::gst_proxy_pad_chain_default(
self.as_ptr() as *mut ffi::GstPad,
pad.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
buffer.into_glib_ptr(),
))
}
}
fn chain_list_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
#[doc(alias = "gst_proxy_pad_chain_list_default")]
pub fn chain_list_default<O: IsA<ProxyPad>>(
pad: &O,
parent: Option<&impl IsA<crate::Object>>,
list: BufferList,
) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!();
unsafe {
try_from_glib(ffi::gst_proxy_pad_chain_list_default(
self.as_ptr() as *mut ffi::GstPad,
pad.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
list.into_glib_ptr(),
))
}
}
fn getrange_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
#[doc(alias = "gst_proxy_pad_getrange_default")]
pub fn getrange_default<O: IsA<ProxyPad>>(
pad: &O,
parent: Option<&impl IsA<crate::Object>>,
offset: u64,
size: u32,
) -> Result<Buffer, FlowError> {
@ -83,7 +55,7 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
unsafe {
let mut buffer = ptr::null_mut();
FlowSuccess::try_from_glib(ffi::gst_proxy_pad_getrange_default(
self.as_ptr() as *mut ffi::GstPad,
pad.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
offset,
size,
@ -93,14 +65,15 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
}
}
fn iterate_internal_links_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
#[doc(alias = "gst_proxy_pad_iterate_internal_links_default")]
pub fn iterate_internal_links_default<O: IsA<ProxyPad>>(
pad: &O,
parent: Option<&impl IsA<crate::Object>>,
) -> Option<crate::Iterator<Pad>> {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_proxy_pad_iterate_internal_links_default(
self.as_ptr() as *mut ffi::GstPad,
pad.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
))
}