From 80b0b378fcdd208f5691ddbe5488b7888640f50c Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 4 May 2022 00:04:08 +0200 Subject: [PATCH] base classes: expose accessors for static pads Part-of: --- gstreamer-audio/src/audio_decoder.rs | 18 ++++++++++++++++++ gstreamer-audio/src/audio_encoder.rs | 18 ++++++++++++++++++ gstreamer-base/src/aggregator.rs | 10 ++++++++++ gstreamer-base/src/base_sink.rs | 10 ++++++++++ gstreamer-base/src/base_src.rs | 10 ++++++++++ gstreamer-base/src/base_transform.rs | 18 ++++++++++++++++++ gstreamer-rtp/src/rtp_base_depayload.rs | 18 ++++++++++++++++++ gstreamer-rtp/src/rtp_base_payload.rs | 18 ++++++++++++++++++ gstreamer-video/src/video_decoder.rs | 18 ++++++++++++++++++ gstreamer-video/src/video_encoder.rs | 18 ++++++++++++++++++ 10 files changed, 156 insertions(+) diff --git a/gstreamer-audio/src/audio_decoder.rs b/gstreamer-audio/src/audio_decoder.rs index 2a22db7a1..c50e5a46b 100644 --- a/gstreamer-audio/src/audio_decoder.rs +++ b/gstreamer-audio/src/audio_decoder.rs @@ -57,6 +57,10 @@ pub trait AudioDecoderExtManual: 'static { function: &str, line: u32, ) -> Result; + + fn sink_pad(&self) -> gst::Pad; + + fn src_pad(&self) -> gst::Pad; } impl> AudioDecoderExtManual for O { @@ -173,6 +177,20 @@ impl> 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] diff --git a/gstreamer-audio/src/audio_encoder.rs b/gstreamer-audio/src/audio_encoder.rs index ae0f9df9b..55496cbdd 100644 --- a/gstreamer-audio/src/audio_encoder.rs +++ b/gstreamer-audio/src/audio_encoder.rs @@ -23,6 +23,10 @@ pub trait AudioEncoderExtManual: 'static { #[doc(alias = "get_allocator")] #[doc(alias = "gst_audio_encoder_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams); + + fn sink_pad(&self) -> gst::Pad; + + fn src_pad(&self) -> gst::Pad; } impl> AudioEncoderExtManual for O { @@ -79,4 +83,18 @@ impl> 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) + } + } } diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index 88727004b..cf919bdb7 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -84,6 +84,8 @@ pub trait AggregatorExtManual: 'static { &self, f: F, ) -> SignalHandlerId; + + fn src_pad(&self) -> gst::Pad; } impl> AggregatorExtManual for O { @@ -267,6 +269,14 @@ impl> 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"))] diff --git a/gstreamer-base/src/base_sink.rs b/gstreamer-base/src/base_sink.rs index 052e7fc3b..4abd84ab8 100644 --- a/gstreamer-base/src/base_sink.rs +++ b/gstreamer-base/src/base_sink.rs @@ -13,6 +13,8 @@ pub trait BaseSinkExtManual: 'static { fn query_latency( &self, ) -> Result<(bool, bool, Option, Option), glib::BoolError>; + + fn sink_pad(&self) -> gst::Pad; } impl> BaseSinkExtManual for O { @@ -55,4 +57,12 @@ impl> BaseSinkExtManual for O { } } } + + fn sink_pad(&self) -> gst::Pad { + unsafe { + let ptr: &ffi::GstBaseSink = &*(self.as_ptr() as *const _); + + from_glib_none(ptr.sinkpad) + } + } } diff --git a/gstreamer-base/src/base_src.rs b/gstreamer-base/src/base_src.rs index e2c3eae54..00dbbc7e8 100644 --- a/gstreamer-base/src/base_src.rs +++ b/gstreamer-base/src/base_src.rs @@ -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> BaseSrcExtManual for O { @@ -92,4 +94,12 @@ impl> BaseSrcExtManual for O { } } } + + fn src_pad(&self) -> gst::Pad { + unsafe { + let ptr: &ffi::GstBaseSrc = &*(self.as_ptr() as *const _); + + from_glib_none(ptr.srcpad) + } + } } diff --git a/gstreamer-base/src/base_transform.rs b/gstreamer-base/src/base_transform.rs index a3abfa043..389ec645a 100644 --- a/gstreamer-base/src/base_transform.rs +++ b/gstreamer-base/src/base_transform.rs @@ -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> BaseTransformExtManual for O { @@ -36,4 +40,18 @@ impl> 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) + } + } } diff --git a/gstreamer-rtp/src/rtp_base_depayload.rs b/gstreamer-rtp/src/rtp_base_depayload.rs index 24985c60f..26d8f99fa 100644 --- a/gstreamer-rtp/src/rtp_base_depayload.rs +++ b/gstreamer-rtp/src/rtp_base_depayload.rs @@ -8,6 +8,10 @@ pub trait RTPBaseDepayloadExtManual: 'static { #[doc(alias = "gst_rtp_base_depayload_push_list")] fn push_list(&self, list: gst::BufferList) -> Result; + + fn sink_pad(&self) -> gst::Pad; + + fn src_pad(&self) -> gst::Pad; } impl> RTPBaseDepayloadExtManual for O { @@ -28,4 +32,18 @@ impl> 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) + } + } } diff --git a/gstreamer-rtp/src/rtp_base_payload.rs b/gstreamer-rtp/src/rtp_base_payload.rs index e5e537a78..934120f07 100644 --- a/gstreamer-rtp/src/rtp_base_payload.rs +++ b/gstreamer-rtp/src/rtp_base_payload.rs @@ -15,6 +15,10 @@ pub trait RTPBasePayloadExtManual: 'static { #[doc(alias = "gst_rtp_base_payload_push_list")] fn push_list(&self, list: gst::BufferList) -> Result; + + fn sink_pad(&self) -> gst::Pad; + + fn src_pad(&self) -> gst::Pad; } impl> RTPBasePayloadExtManual for O { @@ -51,4 +55,18 @@ impl> 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) + } + } } diff --git a/gstreamer-video/src/video_decoder.rs b/gstreamer-video/src/video_decoder.rs index ade5cbba6..b03215109 100644 --- a/gstreamer-video/src/video_decoder.rs +++ b/gstreamer-video/src/video_decoder.rs @@ -109,6 +109,10 @@ pub trait VideoDecoderExtManual: 'static { function: &str, line: u32, ) -> Result; + + fn sink_pad(&self) -> gst::Pad; + + fn src_pad(&self) -> gst::Pad; } impl> VideoDecoderExtManual for O { @@ -405,6 +409,20 @@ impl> 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 { diff --git a/gstreamer-video/src/video_encoder.rs b/gstreamer-video/src/video_encoder.rs index fbcd98d99..96a490616 100644 --- a/gstreamer-video/src/video_encoder.rs +++ b/gstreamer-video/src/video_encoder.rs @@ -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> VideoEncoderExtManual for O { @@ -248,6 +252,20 @@ impl> 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 {