base classes: expose accessors for static pads

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1023>
This commit is contained in:
Mathieu Duponchelle 2022-05-04 00:04:08 +02:00
parent ba955a22bd
commit 80b0b378fc
10 changed files with 156 additions and 0 deletions

View file

@ -57,6 +57,10 @@ pub trait AudioDecoderExtManual: 'static {
function: &str,
line: u32,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn sink_pad(&self) -> gst::Pad;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
@ -173,6 +177,20 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
))
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstAudioDecoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstAudioDecoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
}
#[macro_export]

View file

@ -23,6 +23,10 @@ pub trait AudioEncoderExtManual: 'static {
#[doc(alias = "get_allocator")]
#[doc(alias = "gst_audio_encoder_get_allocator")]
fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
fn sink_pad(&self) -> gst::Pad;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
@ -79,4 +83,18 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
(from_glib_full(allocator), params.into())
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstAudioEncoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstAudioEncoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
}

View file

@ -84,6 +84,8 @@ pub trait AggregatorExtManual: 'static {
&self,
f: F,
) -> SignalHandlerId;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<Aggregator>> AggregatorExtManual for O {
@ -267,6 +269,14 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let ptr: &ffi::GstAggregator = &*(self.as_ptr() as *const _);
from_glib_none(ptr.srcpad)
}
}
}
#[cfg(any(feature = "v1_16", feature = "dox"))]

View file

@ -13,6 +13,8 @@ pub trait BaseSinkExtManual: 'static {
fn query_latency(
&self,
) -> Result<(bool, bool, Option<gst::ClockTime>, Option<gst::ClockTime>), glib::BoolError>;
fn sink_pad(&self) -> gst::Pad;
}
impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
@ -55,4 +57,12 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
}
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let ptr: &ffi::GstBaseSink = &*(self.as_ptr() as *const _);
from_glib_none(ptr.sinkpad)
}
}
}

View file

@ -24,6 +24,8 @@ pub trait BaseSrcExtManual: 'static {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[doc(alias = "gst_base_src_new_segment")]
fn new_segment(&self, segment: &gst::Segment) -> Result<(), glib::BoolError>;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
@ -92,4 +94,12 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
}
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let ptr: &ffi::GstBaseSrc = &*(self.as_ptr() as *const _);
from_glib_none(ptr.srcpad)
}
}
}

View file

@ -13,6 +13,10 @@ pub trait BaseTransformExtManual: 'static {
#[doc(alias = "get_segment")]
fn segment(&self) -> gst::Segment;
fn sink_pad(&self) -> gst::Pad;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {
@ -36,4 +40,18 @@ impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {
from_glib_none(&trans.segment as *const _)
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
}

View file

@ -8,6 +8,10 @@ pub trait RTPBaseDepayloadExtManual: 'static {
#[doc(alias = "gst_rtp_base_depayload_push_list")]
fn push_list(&self, list: gst::BufferList) -> Result<gst::FlowSuccess, gst::FlowError>;
fn sink_pad(&self) -> gst::Pad;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<RTPBaseDepayload>> RTPBaseDepayloadExtManual for O {
@ -28,4 +32,18 @@ impl<O: IsA<RTPBaseDepayload>> RTPBaseDepayloadExtManual for O {
))
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstRTPBaseDepayload = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstRTPBaseDepayload = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
}

View file

@ -15,6 +15,10 @@ pub trait RTPBasePayloadExtManual: 'static {
#[doc(alias = "gst_rtp_base_payload_push_list")]
fn push_list(&self, list: gst::BufferList) -> Result<gst::FlowSuccess, gst::FlowError>;
fn sink_pad(&self) -> gst::Pad;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<RTPBasePayload>> RTPBasePayloadExtManual for O {
@ -51,4 +55,18 @@ impl<O: IsA<RTPBasePayload>> RTPBasePayloadExtManual for O {
))
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstRTPBasePayload = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstRTPBasePayload = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
}

View file

@ -109,6 +109,10 @@ pub trait VideoDecoderExtManual: 'static {
function: &str,
line: u32,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn sink_pad(&self) -> gst::Pad;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
@ -405,6 +409,20 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
))
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstVideoDecoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstVideoDecoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
}
impl HasStreamLock for VideoDecoder {

View file

@ -67,6 +67,10 @@ pub trait VideoEncoderExtManual: 'static {
&'a self,
output_state: VideoCodecState<'a, InNegotiation<'a>>,
) -> Result<(), gst::FlowError>;
fn sink_pad(&self) -> gst::Pad;
fn src_pad(&self) -> gst::Pad;
}
impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
@ -248,6 +252,20 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
Err(gst::FlowError::NotNegotiated)
}
}
fn sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstVideoEncoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn src_pad(&self) -> gst::Pad {
unsafe {
let elt: &ffi::GstVideoEncoder = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
}
impl HasStreamLock for VideoEncoder {