From 027de8434900ebb115bfc3274c8e72d3f8b27504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 5 Nov 2020 15:18:19 +0200 Subject: [PATCH] Update for class struct handling changes in the glib bindings See https://github.com/gtk-rs/gtk-rs/pull/10 --- gstreamer-audio/src/subclass/audio_decoder.rs | 9 ++++----- gstreamer-audio/src/subclass/audio_encoder.rs | 9 ++++----- gstreamer-audio/src/subclass/audio_sink.rs | 9 ++++----- gstreamer-audio/src/subclass/audio_src.rs | 9 ++++----- gstreamer-base/src/subclass/aggregator.rs | 9 ++++----- gstreamer-base/src/subclass/aggregator_pad.rs | 9 ++++----- gstreamer-base/src/subclass/base_parse.rs | 9 ++++----- gstreamer-base/src/subclass/base_sink.rs | 9 ++++----- gstreamer-base/src/subclass/base_src.rs | 9 ++++----- gstreamer-base/src/subclass/base_transform.rs | 9 ++++----- gstreamer-base/src/subclass/push_src.rs | 9 ++++----- gstreamer-rtsp-server/src/subclass/rtsp_client.rs | 9 ++++----- gstreamer-rtsp-server/src/subclass/rtsp_media.rs | 9 ++++----- .../src/subclass/rtsp_media_factory.rs | 9 ++++----- gstreamer-rtsp-server/src/subclass/rtsp_server.rs | 9 ++++----- gstreamer-video/src/subclass/video_decoder.rs | 9 ++++----- gstreamer-video/src/subclass/video_encoder.rs | 9 ++++----- gstreamer-video/src/subclass/video_sink.rs | 9 ++++----- gstreamer/src/element.rs | 10 ++++++---- gstreamer/src/lib.rs | 2 +- gstreamer/src/subclass/bin.rs | 9 ++++----- gstreamer/src/subclass/clock.rs | 9 ++++----- gstreamer/src/subclass/device.rs | 9 ++++----- gstreamer/src/subclass/device_provider.rs | 8 ++++---- gstreamer/src/subclass/element.rs | 8 ++++---- gstreamer/src/subclass/ghost_pad.rs | 10 +++++----- gstreamer/src/subclass/pad.rs | 9 ++++----- gstreamer/src/subclass/pipeline.rs | 10 +++++----- gstreamer/src/subclass/system_clock.rs | 10 +++++----- 29 files changed, 118 insertions(+), 138 deletions(-) diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index 820ecc9ba..2beb5ce26 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -23,7 +23,6 @@ use std::ptr; use crate::prelude::*; use AudioDecoder; -use AudioDecoderClass; pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl { fn open(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> { @@ -510,14 +509,14 @@ impl AudioDecoderImplExt for T { } } -unsafe impl IsSubclassable for AudioDecoderClass +unsafe impl IsSubclassable for AudioDecoder where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_audio_sys::GstAudioDecoderClass); + let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioDecoderClass); klass.open = Some(audio_decoder_open::); klass.close = Some(audio_decoder_close::); klass.start = Some(audio_decoder_start::); diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index 013166b36..bfe403fbe 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -21,7 +21,6 @@ use std::ptr; use crate::prelude::*; use AudioEncoder; -use AudioEncoderClass; use AudioInfo; pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl { @@ -459,14 +458,14 @@ impl AudioEncoderImplExt for T { } } -unsafe impl IsSubclassable for AudioEncoderClass +unsafe impl IsSubclassable for AudioEncoder where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_audio_sys::GstAudioEncoderClass); + let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioEncoderClass); klass.open = Some(audio_encoder_open::); klass.close = Some(audio_encoder_close::); klass.start = Some(audio_encoder_start::); diff --git a/gstreamer-audio/src/subclass/audio_sink.rs b/gstreamer-audio/src/subclass/audio_sink.rs index 03c987bb0..c0e3bceaa 100644 --- a/gstreamer-audio/src/subclass/audio_sink.rs +++ b/gstreamer-audio/src/subclass/audio_sink.rs @@ -10,7 +10,6 @@ use gst_base::subclass::prelude::*; use AudioRingBufferSpec; use AudioSink; -use AudioSinkClass; pub trait AudioSinkImpl: AudioSinkImplExt + BaseSinkImpl { fn close(&self, sink: &AudioSink) -> Result<(), LoggableError> { @@ -185,14 +184,14 @@ impl AudioSinkImplExt for T { } } -unsafe impl IsSubclassable for AudioSinkClass +unsafe impl IsSubclassable for AudioSink where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_audio_sys::GstAudioSinkClass); + let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioSinkClass); klass.close = Some(audiosink_close::); klass.delay = Some(audiosink_delay::); klass.open = Some(audiosink_open::); diff --git a/gstreamer-audio/src/subclass/audio_src.rs b/gstreamer-audio/src/subclass/audio_src.rs index 1a595a87b..3b2db239d 100644 --- a/gstreamer-audio/src/subclass/audio_src.rs +++ b/gstreamer-audio/src/subclass/audio_src.rs @@ -12,7 +12,6 @@ use gst_base::subclass::prelude::*; use AudioRingBufferSpec; use AudioSrc; -use AudioSrcClass; pub trait AudioSrcImpl: AudioSrcImplExt + BaseSrcImpl { fn close(&self, src: &AudioSrc) -> Result<(), LoggableError> { @@ -201,14 +200,14 @@ impl AudioSrcImplExt for T { } } -unsafe impl IsSubclassable for AudioSrcClass +unsafe impl IsSubclassable for AudioSrc where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_audio_sys::GstAudioSrcClass); + let klass = &mut *(klass.as_mut() as *mut gst_audio_sys::GstAudioSrcClass); klass.close = Some(audiosrc_close::); klass.delay = Some(audiosrc_delay::); klass.open = Some(audiosrc_open::); diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index 7dcf758aa..72972a2cf 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -21,7 +21,6 @@ use gst::subclass::prelude::*; use std::ptr; use Aggregator; -use AggregatorClass; use AggregatorPad; pub trait AggregatorImpl: AggregatorImplExt + ElementImpl { @@ -673,14 +672,14 @@ impl AggregatorImplExt for T { } } -unsafe impl IsSubclassable for AggregatorClass +unsafe impl IsSubclassable for Aggregator where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstAggregatorClass); + let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstAggregatorClass); klass.flush = Some(aggregator_flush::); klass.clip = Some(aggregator_clip::); klass.finish_buffer = Some(aggregator_finish_buffer::); diff --git a/gstreamer-base/src/subclass/aggregator_pad.rs b/gstreamer-base/src/subclass/aggregator_pad.rs index d54d3be0d..00481f706 100644 --- a/gstreamer-base/src/subclass/aggregator_pad.rs +++ b/gstreamer-base/src/subclass/aggregator_pad.rs @@ -18,7 +18,6 @@ use gst::subclass::prelude::*; use Aggregator; use AggregatorPad; -use AggregatorPadClass; pub trait AggregatorPadImpl: AggregatorPadImplExt + PadImpl { fn flush( @@ -100,11 +99,11 @@ impl AggregatorPadImplExt for T { } } } -unsafe impl IsSubclassable for AggregatorPadClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for AggregatorPad { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstAggregatorPadClass); + let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstAggregatorPadClass); klass.flush = Some(aggregator_pad_flush::); klass.skip_buffer = Some(aggregator_pad_skip_buffer::); } diff --git a/gstreamer-base/src/subclass/base_parse.rs b/gstreamer-base/src/subclass/base_parse.rs index 2bf787100..770b45566 100644 --- a/gstreamer-base/src/subclass/base_parse.rs +++ b/gstreamer-base/src/subclass/base_parse.rs @@ -20,7 +20,6 @@ use gst; use gst::subclass::prelude::*; use BaseParse; -use BaseParseClass; use BaseParseFrame; pub trait BaseParseImpl: BaseParseImplExt + ElementImpl { @@ -215,14 +214,14 @@ impl BaseParseImplExt for T { } } -unsafe impl IsSubclassable for BaseParseClass +unsafe impl IsSubclassable for BaseParse where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstBaseParseClass); + let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseParseClass); klass.start = Some(base_parse_start::); klass.stop = Some(base_parse_stop::); klass.set_sink_caps = Some(base_parse_set_sink_caps::); diff --git a/gstreamer-base/src/subclass/base_sink.rs b/gstreamer-base/src/subclass/base_sink.rs index 5a0c2ba07..fa91075f2 100644 --- a/gstreamer-base/src/subclass/base_sink.rs +++ b/gstreamer-base/src/subclass/base_sink.rs @@ -19,7 +19,6 @@ use gst::subclass::prelude::*; use std::ptr; use BaseSink; -use BaseSinkClass; pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl { fn start(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage> { @@ -381,14 +380,14 @@ impl BaseSinkImplExt for T { } } -unsafe impl IsSubclassable for BaseSinkClass +unsafe impl IsSubclassable for BaseSink where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstBaseSinkClass); + let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseSinkClass); klass.start = Some(base_sink_start::); klass.stop = Some(base_sink_stop::); klass.render = Some(base_sink_render::); diff --git a/gstreamer-base/src/subclass/base_src.rs b/gstreamer-base/src/subclass/base_src.rs index be999ef66..c5a1f8edb 100644 --- a/gstreamer-base/src/subclass/base_src.rs +++ b/gstreamer-base/src/subclass/base_src.rs @@ -20,7 +20,6 @@ use std::mem; use std::ptr; use BaseSrc; -use BaseSrcClass; #[derive(Debug)] pub enum CreateSuccess { @@ -570,14 +569,14 @@ impl BaseSrcImplExt for T { } } -unsafe impl IsSubclassable for BaseSrcClass +unsafe impl IsSubclassable for BaseSrc where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstBaseSrcClass); + let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseSrcClass); klass.start = Some(base_src_start::); klass.stop = Some(base_src_stop::); klass.is_seekable = Some(base_src_is_seekable::); diff --git a/gstreamer-base/src/subclass/base_transform.rs b/gstreamer-base/src/subclass/base_transform.rs index 2703ffc6d..14b020cec 100644 --- a/gstreamer-base/src/subclass/base_transform.rs +++ b/gstreamer-base/src/subclass/base_transform.rs @@ -21,7 +21,6 @@ use std::mem; use std::ptr; use BaseTransform; -use BaseTransformClass; pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl { fn start(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage> { @@ -827,14 +826,14 @@ pub enum BaseTransformMode { Both, } -unsafe impl IsSubclassable for BaseTransformClass +unsafe impl IsSubclassable for BaseTransform where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstBaseTransformClass); + let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstBaseTransformClass); klass.start = Some(base_transform_start::); klass.stop = Some(base_transform_stop::); klass.transform_caps = Some(base_transform_transform_caps::); diff --git a/gstreamer-base/src/subclass/push_src.rs b/gstreamer-base/src/subclass/push_src.rs index b56ed3704..d802cf522 100644 --- a/gstreamer-base/src/subclass/push_src.rs +++ b/gstreamer-base/src/subclass/push_src.rs @@ -19,7 +19,6 @@ use std::ptr; use super::base_src::BaseSrcImpl; use PushSrc; -use PushSrcClass; pub trait PushSrcImpl: PushSrcImplExt + BaseSrcImpl { fn fill( @@ -114,14 +113,14 @@ impl PushSrcImplExt for T { } } -unsafe impl IsSubclassable for PushSrcClass +unsafe impl IsSubclassable for PushSrc where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - <::BaseSrcClass as IsSubclassable>::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + <::BaseSrc as IsSubclassable>::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstPushSrcClass); + let klass = &mut *(klass.as_mut() as *mut gst_base_sys::GstPushSrcClass); klass.fill = Some(push_src_fill::); klass.alloc = Some(push_src_alloc::); klass.create = Some(push_src_create::); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs index f990ea1b6..f5caa0080 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs @@ -14,7 +14,6 @@ use glib::translate::*; use std::mem; use RTSPClient; -use RTSPClientClass; pub trait RTSPClientImpl: RTSPClientImplExt + ObjectImpl + Send + Sync { fn create_sdp(&self, client: &RTSPClient, media: &::RTSPMedia) -> Option { @@ -793,11 +792,11 @@ impl RTSPClientImplExt for T { } } } -unsafe impl IsSubclassable for RTSPClientClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for RTSPClient { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_rtsp_server_sys::GstRTSPClientClass); + let klass = &mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPClientClass); klass.create_sdp = Some(client_create_sdp::); klass.configure_client_media = Some(client_configure_client_media::); klass.params_set = Some(client_params_set::); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media.rs index 674f299ea..91b4faa4c 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media.rs @@ -14,7 +14,6 @@ use glib::translate::*; use std::ptr; use RTSPMedia; -use RTSPMediaClass; use RTSPThread; #[derive(Debug)] @@ -449,11 +448,11 @@ impl RTSPMediaImplExt for T { } } } -unsafe impl IsSubclassable for RTSPMediaClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for RTSPMedia { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_rtsp_server_sys::GstRTSPMediaClass); + let klass = &mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPMediaClass); klass.handle_message = Some(media_handle_message::); klass.prepare = Some(media_prepare::); klass.unprepare = Some(media_unprepare::); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs index 46e3e738e..5067f27fe 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs @@ -14,7 +14,6 @@ use gst_rtsp; use glib::subclass::prelude::*; use RTSPMediaFactory; -use RTSPMediaFactoryClass; use std::mem::transmute; @@ -202,12 +201,12 @@ impl RTSPMediaFactoryImplExt for T { } } } -unsafe impl IsSubclassable for RTSPMediaFactoryClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for RTSPMediaFactory { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { let klass = - &mut *(self as *mut Self as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass); + &mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass); klass.gen_key = Some(factory_gen_key::); klass.create_element = Some(factory_create_element::); klass.construct = Some(factory_construct::); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_server.rs b/gstreamer-rtsp-server/src/subclass/rtsp_server.rs index 7df648f10..7bd36ca60 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_server.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_server.rs @@ -12,7 +12,6 @@ use glib::subclass::prelude::*; use glib::translate::*; use RTSPServer; -use RTSPServerClass; pub trait RTSPServerImpl: RTSPServerImplExt + ObjectImpl + Send + Sync { fn create_client(&self, server: &RTSPServer) -> Option<::RTSPClient> { @@ -54,11 +53,11 @@ impl RTSPServerImplExt for T { } } } -unsafe impl IsSubclassable for RTSPServerClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for RTSPServer { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_rtsp_server_sys::GstRTSPServerClass); + let klass = &mut *(klass.as_mut() as *mut gst_rtsp_server_sys::GstRTSPServerClass); klass.create_client = Some(server_create_client::); klass.client_connected = Some(server_client_connected::); } diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index a948447cb..3ac85ee0b 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -22,7 +22,6 @@ use crate::prelude::*; use video_codec_state::{Readable, VideoCodecState}; use VideoCodecFrame; use VideoDecoder; -use VideoDecoderClass; pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl { fn open(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> { @@ -499,14 +498,14 @@ impl VideoDecoderImplExt for T { } } -unsafe impl IsSubclassable for VideoDecoderClass +unsafe impl IsSubclassable for VideoDecoder where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_video_sys::GstVideoDecoderClass); + let klass = &mut *(klass.as_mut() as *mut gst_video_sys::GstVideoDecoderClass); klass.open = Some(video_decoder_open::); klass.close = Some(video_decoder_close::); klass.start = Some(video_decoder_start::); diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index 4325e18eb..1266a6bfc 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -21,7 +21,6 @@ use crate::prelude::*; use video_codec_state::{Readable, VideoCodecState}; use VideoCodecFrame; use VideoEncoder; -use VideoEncoderClass; pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl { fn open(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> { @@ -435,14 +434,14 @@ impl VideoEncoderImplExt for T { } } -unsafe impl IsSubclassable for VideoEncoderClass +unsafe impl IsSubclassable for VideoEncoder where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_video_sys::GstVideoEncoderClass); + let klass = &mut *(klass.as_mut() as *mut gst_video_sys::GstVideoEncoderClass); klass.open = Some(video_encoder_open::); klass.close = Some(video_encoder_close::); klass.start = Some(video_encoder_start::); diff --git a/gstreamer-video/src/subclass/video_sink.rs b/gstreamer-video/src/subclass/video_sink.rs index ac00c1e92..15ec81458 100644 --- a/gstreamer-video/src/subclass/video_sink.rs +++ b/gstreamer-video/src/subclass/video_sink.rs @@ -17,7 +17,6 @@ use gst::subclass::prelude::*; use gst_base::subclass::prelude::*; use VideoSink; -use VideoSinkClass; pub trait VideoSinkImpl: VideoSinkImplExt + BaseSinkImpl + ElementImpl { fn show_frame( @@ -58,14 +57,14 @@ impl VideoSinkImplExt for T { } } -unsafe impl IsSubclassable for VideoSinkClass +unsafe impl IsSubclassable for VideoSink where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_video_sys::GstVideoSinkClass); + let klass = &mut *(klass.as_mut() as *mut gst_video_sys::GstVideoSinkClass); klass.show_frame = Some(video_sink_show_frame::); } } diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index bc9d9ded4..799c0697c 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -844,8 +844,8 @@ impl> ElementExtManual for O { } } -impl ElementClass { - pub fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { +pub unsafe trait ElementClassExt { + fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { unsafe { let klass = self as *const _ as *const gst_sys::GstElementClass; @@ -860,7 +860,7 @@ impl ElementClass { } } - pub fn get_pad_template(&self, name: &str) -> Option { + fn get_pad_template(&self, name: &str) -> Option { unsafe { let klass = self as *const _ as *const gst_sys::GstElementClass; @@ -871,7 +871,7 @@ impl ElementClass { } } - pub fn get_pad_template_list(&self) -> Vec { + fn get_pad_template_list(&self) -> Vec { unsafe { let klass = self as *const _ as *const gst_sys::GstElementClass; @@ -882,6 +882,8 @@ impl ElementClass { } } +unsafe impl> ElementClassExt for glib::object::Class {} + pub static ELEMENT_METADATA_AUTHOR: Lazy<&'static str> = Lazy::new(|| unsafe { CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_AUTHOR) .to_str() diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 1230edbe4..ae35f5b8c 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -341,7 +341,7 @@ pub mod prelude { pub use allocator::AllocatorExtManual; pub use bin::GstBinExtManual; - pub use element::ElementExtManual; + pub use element::{ElementClassExt, ElementExtManual}; // OS dependent Bus extensions (also import the other plateform trait for doc) #[cfg(any(feature = "v1_14", feature = "dox"))] diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index a56563788..04f806a7c 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -15,7 +15,6 @@ use super::prelude::*; use glib::subclass::prelude::*; use Bin; -use BinClass; use Element; use LoggableError; use Message; @@ -87,14 +86,14 @@ impl BinImplExt for T { } } -unsafe impl IsSubclassable for BinClass +unsafe impl IsSubclassable for Bin where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - <::ElementClass as IsSubclassable>::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + <::Element as IsSubclassable>::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_sys::GstBinClass); + let klass = &mut *(klass.as_mut() as *mut gst_sys::GstBinClass); klass.add_element = Some(bin_add_element::); klass.remove_element = Some(bin_remove_element::); klass.handle_message = Some(bin_handle_message::); diff --git a/gstreamer/src/subclass/clock.rs b/gstreamer/src/subclass/clock.rs index 7c98cd885..a9ca50c30 100644 --- a/gstreamer/src/subclass/clock.rs +++ b/gstreamer/src/subclass/clock.rs @@ -14,7 +14,6 @@ use glib::subclass::prelude::*; use glib::translate::*; use Clock; -use ClockClass; use ClockError; use ClockId; use ClockReturn; @@ -233,12 +232,12 @@ impl ClockImplExt for T { } } -unsafe impl IsSubclassable for ClockClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for Clock { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_sys::GstClockClass); + let klass = &mut *(klass.as_mut() as *mut gst_sys::GstClockClass); klass.change_resolution = Some(clock_change_resolution::); klass.get_resolution = Some(clock_get_resolution::); klass.get_internal_time = Some(clock_get_internal_time::); diff --git a/gstreamer/src/subclass/device.rs b/gstreamer/src/subclass/device.rs index f26864f01..6e0e74693 100644 --- a/gstreamer/src/subclass/device.rs +++ b/gstreamer/src/subclass/device.rs @@ -14,7 +14,6 @@ use glib::translate::*; use glib::subclass::prelude::*; use Device; -use DeviceClass; use Element; use LoggableError; @@ -99,11 +98,11 @@ impl DeviceImplExt for T { } } -unsafe impl IsSubclassable for DeviceClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for Device { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_sys::GstDeviceClass); + let klass = &mut *(klass.as_mut() as *mut gst_sys::GstDeviceClass); klass.create_element = Some(device_create_element::); klass.reconfigure_element = Some(device_reconfigure_element::); } diff --git a/gstreamer/src/subclass/device_provider.rs b/gstreamer/src/subclass/device_provider.rs index 95511159a..626e79328 100644 --- a/gstreamer/src/subclass/device_provider.rs +++ b/gstreamer/src/subclass/device_provider.rs @@ -114,11 +114,11 @@ pub unsafe trait DeviceProviderClassSubclassExt: Sized + 'static { unsafe impl DeviceProviderClassSubclassExt for DeviceProviderClass {} -unsafe impl IsSubclassable for DeviceProviderClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for DeviceProvider { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_sys::GstDeviceProviderClass); + let klass = &mut *(klass.as_mut() as *mut gst_sys::GstDeviceProviderClass); klass.probe = Some(device_provider_probe::); klass.start = Some(device_provider_start::); klass.stop = Some(device_provider_stop::); diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index 21ff67a45..d1762a985 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -338,15 +338,15 @@ pub unsafe trait ElementClassSubclassExt: Sized + 'static { unsafe impl ElementClassSubclassExt for ElementClass {} -unsafe impl IsSubclassable for ElementClass +unsafe impl IsSubclassable for Element where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_sys::GstElementClass); + let klass = &mut *(klass.as_mut() as *mut gst_sys::GstElementClass); klass.change_state = Some(element_change_state::); klass.request_new_pad = Some(element_request_new_pad::); klass.release_pad = Some(element_release_pad::); diff --git a/gstreamer/src/subclass/ghost_pad.rs b/gstreamer/src/subclass/ghost_pad.rs index 2d0dc1f16..f40652504 100644 --- a/gstreamer/src/subclass/ghost_pad.rs +++ b/gstreamer/src/subclass/ghost_pad.rs @@ -11,15 +11,15 @@ use gst_sys; use super::prelude::*; use glib::subclass::prelude::*; -use GhostPadClass; +use GhostPad; pub trait GhostPadImpl: PadImpl {} -unsafe impl IsSubclassable for GhostPadClass { - fn override_vfuncs(&mut self) { - <::PadClass as IsSubclassable>::override_vfuncs(self); +unsafe impl IsSubclassable for GhostPad { + fn override_vfuncs(klass: &mut glib::object::Class) { + <::Pad as IsSubclassable>::override_vfuncs(klass); unsafe { - let _klass = &mut *(self as *mut Self as *mut gst_sys::GstGhostPadClass); + let _klass = &mut *(klass.as_mut() as *mut gst_sys::GstGhostPadClass); // Nothing to do here } } diff --git a/gstreamer/src/subclass/pad.rs b/gstreamer/src/subclass/pad.rs index 250070e57..fad7f6b93 100644 --- a/gstreamer/src/subclass/pad.rs +++ b/gstreamer/src/subclass/pad.rs @@ -14,7 +14,6 @@ use glib::translate::*; use glib::subclass::prelude::*; use Pad; -use PadClass; pub trait PadImpl: PadImplExt + ObjectImpl + Send + Sync { fn linked(&self, pad: &Pad, peer: &Pad) { @@ -58,12 +57,12 @@ impl PadImplExt for T { } } -unsafe impl IsSubclassable for PadClass { - fn override_vfuncs(&mut self) { - >::override_vfuncs(self); +unsafe impl IsSubclassable for Pad { + fn override_vfuncs(klass: &mut glib::object::Class) { + >::override_vfuncs(klass); unsafe { - let klass = &mut *(self as *mut Self as *mut gst_sys::GstPadClass); + let klass = &mut *(klass.as_mut() as *mut gst_sys::GstPadClass); klass.linked = Some(pad_linked::); klass.unlinked = Some(pad_unlinked::); } diff --git a/gstreamer/src/subclass/pipeline.rs b/gstreamer/src/subclass/pipeline.rs index bdba50e85..3af922639 100644 --- a/gstreamer/src/subclass/pipeline.rs +++ b/gstreamer/src/subclass/pipeline.rs @@ -11,18 +11,18 @@ use gst_sys; use super::prelude::*; use glib::subclass::prelude::*; -use PipelineClass; +use Pipeline; pub trait PipelineImpl: BinImpl {} -unsafe impl IsSubclassable for PipelineClass +unsafe impl IsSubclassable for Pipeline where ::Instance: PanicPoison, { - fn override_vfuncs(&mut self) { - <::BinClass as IsSubclassable>::override_vfuncs(self); + fn override_vfuncs(klass: &mut glib::object::Class) { + <::Bin as IsSubclassable>::override_vfuncs(klass); unsafe { - let _klass = &mut *(self as *mut Self as *mut gst_sys::GstPipelineClass); + let _klass = &mut *(klass.as_mut() as *mut gst_sys::GstPipelineClass); // Nothing to do here } } diff --git a/gstreamer/src/subclass/system_clock.rs b/gstreamer/src/subclass/system_clock.rs index 381713acf..f2220d644 100644 --- a/gstreamer/src/subclass/system_clock.rs +++ b/gstreamer/src/subclass/system_clock.rs @@ -11,15 +11,15 @@ use gst_sys; use super::prelude::*; use glib::subclass::prelude::*; -use SystemClockClass; +use SystemClock; pub trait SystemClockImpl: ClockImpl {} -unsafe impl IsSubclassable for SystemClockClass { - fn override_vfuncs(&mut self) { - <::ClockClass as IsSubclassable>::override_vfuncs(self); +unsafe impl IsSubclassable for SystemClock { + fn override_vfuncs(klass: &mut glib::object::Class) { + <::Clock as IsSubclassable>::override_vfuncs(klass); unsafe { - let _klass = &mut *(self as *mut Self as *mut gst_sys::GstSystemClockClass); + let _klass = &mut *(klass.as_mut() as *mut gst_sys::GstSystemClockClass); // Nothing to do here } }