mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-10-31 22:59:14 +00:00
gstreamer: audiofilter: Add parent_allowed_caps()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1356>
This commit is contained in:
parent
ceed45cfd7
commit
84ca72a833
1 changed files with 25 additions and 2 deletions
|
@ -1,12 +1,14 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use glib::translate::*;
|
||||
use glib::{once_cell::sync::Lazy, translate::*};
|
||||
use gst_base::{prelude::*, subclass::prelude::*};
|
||||
|
||||
use crate::{AudioFilter, AudioInfo};
|
||||
|
||||
pub trait AudioFilterImpl: AudioFilterImplExt + BaseTransformImpl {
|
||||
fn allowed_caps() -> &'static gst::Caps;
|
||||
fn allowed_caps() -> &'static gst::Caps {
|
||||
Self::parent_allowed_caps()
|
||||
}
|
||||
|
||||
fn setup(&self, info: &AudioInfo) -> Result<(), gst::LoggableError> {
|
||||
self.parent_setup(info)
|
||||
|
@ -38,6 +40,27 @@ pub trait AudioFilterImplExt: sealed::Sealed + ObjectSubclass {
|
|||
.unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_allowed_caps() -> &'static gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut gst::ffi::GstElementClass;
|
||||
|
||||
let templ = gst::ffi::gst_element_class_get_pad_template(
|
||||
parent_class,
|
||||
glib::gstr!("sink").to_glib_none().0,
|
||||
);
|
||||
|
||||
if templ.is_null() {
|
||||
static ANY_AUDIO_CAPS: Lazy<gst::Caps> =
|
||||
Lazy::new(|| crate::AudioCapsBuilder::new().build());
|
||||
|
||||
return &ANY_AUDIO_CAPS;
|
||||
}
|
||||
|
||||
&*(&(*templ).caps as *const *mut gst::ffi::GstCaps as *const gst::Caps)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: AudioFilterImpl> AudioFilterImplExt for T {}
|
||||
|
|
Loading…
Reference in a new issue