Add gst::GstObjectImpl, gst::ProxyPadImpl, gst_audio::AudioBaseSrc, gst_audio::AudioBaseSink subclassing traits

These were missing from the type hierarchy previously and are now
required because of more strict checks in the GLib bindings.
This commit is contained in:
Sebastian Dröge 2021-08-24 09:12:27 +03:00
parent 12fec484c7
commit 7f0ca0011c
19 changed files with 69 additions and 11 deletions

View file

@ -117,6 +117,7 @@ mod mirror {
}
impl ElementImpl for GLMirrorFilter {}
impl GstObjectImpl for GLMirrorFilter {}
impl ObjectImpl for GLMirrorFilter {}
impl BaseTransformImpl for GLMirrorFilter {
const MODE: BaseTransformMode = BaseTransformMode::NeverInPlace;

View file

@ -61,6 +61,8 @@ mod fir_filter {
// Implementation of glib::Object virtual methods
impl ObjectImpl for FirFilter {}
impl GstObjectImpl for FirFilter {}
// Implementation of gst::Element virtual methods
impl ElementImpl for FirFilter {
// The element specific metadata. This information is what is visible from

View file

@ -0,0 +1,9 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use gst_base::subclass::prelude::*;
use crate::AudioBaseSink;
pub trait AudioBaseSinkImpl: BaseSinkImpl {}
unsafe impl<T: AudioBaseSinkImpl> IsSubclassable<T> for AudioBaseSink {}

View file

@ -0,0 +1,9 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use gst_base::subclass::prelude::*;
use crate::AudioBaseSrc;
pub trait AudioBaseSrcImpl: BaseSrcImpl {}
unsafe impl<T: AudioBaseSrcImpl> IsSubclassable<T> for AudioBaseSrc {}

View file

@ -3,13 +3,14 @@
use glib::prelude::*;
use glib::translate::*;
use super::prelude::*;
use gst::LoggableError;
use gst_base::subclass::prelude::*;
use crate::AudioRingBufferSpec;
use crate::AudioSink;
pub trait AudioSinkImpl: AudioSinkImplExt + BaseSinkImpl {
pub trait AudioSinkImpl: AudioSinkImplExt + AudioBaseSinkImpl {
fn close(&self, sink: &Self::Type) -> Result<(), LoggableError> {
self.parent_close(sink)
}

View file

@ -5,13 +5,14 @@ use std::mem;
use glib::prelude::*;
use glib::translate::*;
use super::prelude::*;
use gst::LoggableError;
use gst_base::subclass::prelude::*;
use crate::AudioRingBufferSpec;
use crate::AudioSrc;
pub trait AudioSrcImpl: AudioSrcImplExt + BaseSrcImpl {
pub trait AudioSrcImpl: AudioSrcImplExt + AudioBaseSrcImpl {
fn close(&self, src: &Self::Type) -> Result<(), LoggableError> {
self.parent_close(src)
}

View file

@ -2,6 +2,8 @@
#![allow(clippy::cast_ptr_alignment)]
mod audio_base_sink;
mod audio_base_src;
mod audio_decoder;
mod audio_encoder;
mod audio_sink;
@ -11,6 +13,8 @@ pub mod prelude {
#[doc(hidden)]
pub use gst_base::subclass::prelude::*;
pub use super::audio_base_sink::AudioBaseSinkImpl;
pub use super::audio_base_src::AudioBaseSrcImpl;
pub use super::audio_decoder::{AudioDecoderImpl, AudioDecoderImplExt};
pub use super::audio_encoder::{AudioEncoderImpl, AudioEncoderImplExt};
pub use super::audio_sink::{AudioSinkImpl, AudioSinkImplExt};

View file

@ -8,7 +8,6 @@ use glib::translate::*;
use gst::{result_from_gboolean, Buffer, Caps, LoggableError, PadDirection, CAT_RUST};
use crate::GLBaseFilter;
use crate::GLFilter;
use crate::GLMemory;

View file

@ -1,12 +1,13 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use crate::ChildProxy;
pub trait ChildProxyImpl: ObjectImpl + Send + Sync {
pub trait ChildProxyImpl: GstObjectImpl + Send + Sync {
fn child_by_name(&self, object: &Self::Type, name: &str) -> Option<glib::Object> {
self.parent_child_by_name(object, name)
}

View file

@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
@ -12,7 +13,7 @@ use crate::ClockSuccess;
use crate::ClockTime;
use crate::ClockTimeDiff;
pub trait ClockImpl: ClockImplExt + ObjectImpl + Send + Sync {
pub trait ClockImpl: ClockImplExt + GstObjectImpl + Send + Sync {
fn change_resolution(
&self,
clock: &Self::Type,

View file

@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
@ -10,7 +11,7 @@ use crate::LoggableError;
use std::ptr;
pub trait DeviceImpl: DeviceImplExt + ObjectImpl + Send + Sync {
pub trait DeviceImpl: DeviceImplExt + GstObjectImpl + Send + Sync {
fn create_element(
&self,
device: &Self::Type,

View file

@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
@ -67,7 +68,7 @@ impl DeviceProviderMetadata {
}
}
pub trait DeviceProviderImpl: DeviceProviderImplExt + ObjectImpl + Send + Sync {
pub trait DeviceProviderImpl: DeviceProviderImplExt + GstObjectImpl + Send + Sync {
fn metadata() -> Option<&'static DeviceProviderMetadata> {
None
}

View file

@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use crate::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
@ -73,7 +74,7 @@ impl ElementMetadata {
}
}
pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync {
pub trait ElementImpl: ElementImplExt + GstObjectImpl + Send + Sync {
fn metadata() -> Option<&'static ElementMetadata> {
None
}
@ -717,6 +718,8 @@ mod tests {
}
}
impl GstObjectImpl for TestElement {}
impl ElementImpl for TestElement {
fn metadata() -> Option<&'static ElementMetadata> {
use once_cell::sync::Lazy;

View file

@ -5,6 +5,6 @@ use glib::subclass::prelude::*;
use crate::GhostPad;
pub trait GhostPadImpl: PadImpl {}
pub trait GhostPadImpl: ProxyPadImpl {}
unsafe impl<T: GhostPadImpl> IsSubclassable<T> for GhostPad {}

View file

@ -19,8 +19,10 @@ mod bin;
mod child_proxy;
mod element;
mod ghost_pad;
mod object;
mod pad;
mod pipeline;
mod proxy_pad;
mod tracer;
mod device;
@ -50,9 +52,11 @@ pub mod prelude {
pub use super::device_provider::{DeviceProviderImpl, DeviceProviderImplExt};
pub use super::element::{ElementImpl, ElementImplExt};
pub use super::ghost_pad::GhostPadImpl;
pub use super::object::GstObjectImpl;
pub use super::pad::{PadImpl, PadImplExt};
pub use super::pipeline::PipelineImpl;
pub use super::preset::PresetImpl;
pub use super::proxy_pad::ProxyPadImpl;
pub use super::system_clock::SystemClockImpl;
pub use super::tag_setter::TagSetterImpl;
pub use super::tracer::{TracerHook, TracerImpl, TracerImplExt};

View file

@ -0,0 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use glib::subclass::prelude::*;
pub trait GstObjectImpl: ObjectImpl {}
unsafe impl<T: GstObjectImpl> IsSubclassable<T> for crate::Object {}

View file

@ -1,12 +1,13 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use crate::Pad;
pub trait PadImpl: PadImplExt + ObjectImpl + Send + Sync {
pub trait PadImpl: PadImplExt + GstObjectImpl + Send + Sync {
fn linked(&self, pad: &Self::Type, peer: &Pad) {
self.parent_linked(pad, peer)
}
@ -109,6 +110,8 @@ mod tests {
impl ObjectImpl for TestPad {}
impl GstObjectImpl for TestPad {}
impl PadImpl for TestPad {
fn linked(&self, pad: &Self::Type, peer: &Pad) {
self.linked.store(true, atomic::Ordering::SeqCst);

View file

@ -0,0 +1,10 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use glib::subclass::prelude::*;
use crate::ProxyPad;
pub trait ProxyPadImpl: PadImpl {}
unsafe impl<T: ProxyPadImpl> IsSubclassable<T> for ProxyPad {}

View file

@ -1,5 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use super::prelude::*;
use crate::ffi;
use crate::{
Bin, Buffer, BufferList, Element, Event, FlowReturn, Message, MiniObject, Object, Pad,
@ -8,7 +9,7 @@ use crate::{
use glib::{prelude::*, subclass::prelude::*, translate::*};
#[allow(unused_variables)]
pub trait TracerImpl: TracerImplExt + ObjectImpl + Send + Sync {
pub trait TracerImpl: TracerImplExt + GstObjectImpl + Send + Sync {
fn bin_add_post(&self, ts: u64, bin: &Bin, element: &Element, success: bool) {}
fn bin_add_pre(&self, ts: u64, bin: &Bin, element: &Element) {}
fn bin_remove_post(&self, ts: u64, bin: &Bin, success: bool) {}