forked from mirrors/gstreamer-rs
gstreamer: audiofilter: Add parent_allowed_caps()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1366>
This commit is contained in:
parent
9f3ae6aa77
commit
02f4e7dad0
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