ProxyPad: impl ExtManual functions as trait functions, not associated functions

This commit is contained in:
François Laignel 2020-11-17 16:26:48 +01:00
parent 09f1a87dc9
commit 9fb0c4937b
2 changed files with 41 additions and 13 deletions

View file

@ -209,6 +209,7 @@ mod control_binding;
mod control_source;
mod parse_context;
mod proxy_pad;
pub use proxy_pad::ProxyPadExtManual;
mod tag_setter;
pub use bin::GstBinExtManual;
pub use element::{ElementExtManual, ElementMessageType, NotifyWatchId};
@ -370,6 +371,7 @@ pub mod prelude {
pub use pipeline::GstPipelineExtManual;
pub use plugin::GstPluginExtManual;
pub use plugin_feature::PluginFeatureExtManual;
pub use proxy_pad::ProxyPadExtManual;
pub use tag_setter::TagSetterExtManual;
pub use typefind::TypeFindImpl;
pub use value::GstValueExt;

View file

@ -21,16 +21,42 @@ use glib::translate::{from_glib, from_glib_full, ToGlibPtr};
use gst_sys;
impl ProxyPad {
pub fn chain_default<O: IsA<ProxyPad>, P: IsA<Object>>(
pad: &O,
pub trait ProxyPadExtManual: 'static {
fn chain_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
buffer: Buffer,
) -> Result<FlowSuccess, FlowError>;
fn chain_list_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
list: BufferList,
) -> Result<FlowSuccess, FlowError>;
fn getrange_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
offset: u64,
size: u32,
) -> Result<Buffer, FlowError>;
fn iterate_internal_links_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
) -> Option<::Iterator<Pad>>;
}
impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
fn chain_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
buffer: Buffer,
) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!();
let ret: FlowReturn = unsafe {
from_glib(gst_sys::gst_proxy_pad_chain_default(
pad.as_ptr() as *mut gst_sys::GstPad,
self.as_ptr() as *mut gst_sys::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
buffer.into_ptr(),
))
@ -38,15 +64,15 @@ impl ProxyPad {
ret.into_result()
}
pub fn chain_list_default<O: IsA<ProxyPad>, P: IsA<Object>>(
pad: &O,
fn chain_list_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
list: BufferList,
) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!();
let ret: FlowReturn = unsafe {
from_glib(gst_sys::gst_proxy_pad_chain_list_default(
pad.as_ptr() as *mut gst_sys::GstPad,
self.as_ptr() as *mut gst_sys::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
list.into_ptr(),
))
@ -54,8 +80,8 @@ impl ProxyPad {
ret.into_result()
}
pub fn getrange_default<O: IsA<ProxyPad>, P: IsA<Object>>(
pad: &O,
fn getrange_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
offset: u64,
size: u32,
@ -64,7 +90,7 @@ impl ProxyPad {
unsafe {
let mut buffer = ptr::null_mut();
let ret: FlowReturn = from_glib(gst_sys::gst_proxy_pad_getrange_default(
pad.as_ptr() as *mut gst_sys::GstPad,
self.as_ptr() as *mut gst_sys::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
offset,
size,
@ -74,14 +100,14 @@ impl ProxyPad {
}
}
pub fn iterate_internal_links_default<O: IsA<ProxyPad>, P: IsA<Object>>(
pad: &O,
fn iterate_internal_links_default<P: IsA<Object>>(
&self,
parent: Option<&P>,
) -> Option<::Iterator<Pad>> {
skip_assert_initialized!();
unsafe {
from_glib_full(gst_sys::gst_proxy_pad_iterate_internal_links_default(
pad.as_ptr() as *mut gst_sys::GstPad,
self.as_ptr() as *mut gst_sys::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
))
}