From 8cf099f0ab3ff8eea098674ff94cc7f0a33360a5 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 5 Jul 2023 22:21:43 +0200 Subject: [PATCH] Seal manual traits Part-of: --- gstreamer-audio/src/audio_aggregator.rs | 35 +- .../src/audio_aggregator_convert_pad.rs | 24 +- gstreamer-audio/src/audio_aggregator_pad.rs | 9 +- gstreamer-audio/src/audio_decoder.rs | 36 +- gstreamer-audio/src/audio_encoder.rs | 29 +- .../src/subclass/audio_aggregator.rs | 20 +- .../src/subclass/audio_aggregator_pad.rs | 16 +- gstreamer-audio/src/subclass/audio_decoder.rs | 50 +-- gstreamer-audio/src/subclass/audio_encoder.rs | 48 +-- gstreamer-audio/src/subclass/audio_filter.rs | 9 +- gstreamer-audio/src/subclass/audio_sink.rs | 15 +- gstreamer-audio/src/subclass/audio_src.rs | 18 +- gstreamer-base/src/aggregator.rs | 80 +--- gstreamer-base/src/aggregator_pad.rs | 11 +- gstreamer-base/src/base_parse.rs | 41 +- gstreamer-base/src/base_sink.rs | 19 +- gstreamer-base/src/base_src.rs | 25 +- gstreamer-base/src/base_transform.rs | 21 +- gstreamer-base/src/subclass/aggregator.rs | 96 +---- gstreamer-base/src/subclass/aggregator_pad.rs | 11 +- gstreamer-base/src/subclass/base_parse.rs | 24 +- gstreamer-base/src/subclass/base_sink.rs | 134 +++---- gstreamer-base/src/subclass/base_src.rs | 59 +-- gstreamer-base/src/subclass/base_transform.rs | 115 +----- gstreamer-base/src/subclass/push_src.rs | 16 +- gstreamer-editing-services/src/formatter.rs | 21 +- .../src/subclass/formatter.rs | 22 +- gstreamer-gl/src/gl_context.rs | 19 +- gstreamer-gl/src/gl_display.rs | 19 +- gstreamer-gl/src/subclass/gl_base_filter.rs | 13 +- gstreamer-gl/src/subclass/gl_base_src.rs | 13 +- gstreamer-gl/src/subclass/gl_filter.rs | 26 +- gstreamer-pbutils/src/audio_visualizer.rs | 27 +- .../src/discoverer_stream_info.rs | 12 +- gstreamer-pbutils/src/encoding_profile.rs | 15 +- .../src/subclass/audio_visualizer.rs | 20 +- .../src/subclass/play_video_renderer.rs | 9 +- .../src/subclass/player_video_renderer.rs | 9 +- gstreamer-rtp/src/rtp_base_depayload.rs | 11 +- gstreamer-rtp/src/rtp_base_payload.rs | 19 +- gstreamer-rtp/src/rtp_header_extension.rs | 38 +- .../src/subclass/rtp_base_depayload.rs | 18 +- .../src/subclass/rtp_base_payload.rs | 20 +- .../src/subclass/rtp_header_extension.rs | 37 +- .../src/rtsp_address_pool.rs | 17 +- gstreamer-rtsp-server/src/rtsp_auth.rs | 26 +- gstreamer-rtsp-server/src/rtsp_client.rs | 11 +- gstreamer-rtsp-server/src/rtsp_media.rs | 11 +- .../src/rtsp_media_factory.rs | 11 +- .../src/rtsp_onvif_media_factory.rs | 13 +- gstreamer-rtsp-server/src/rtsp_server.rs | 14 +- gstreamer-rtsp-server/src/rtsp_session.rs | 13 +- .../src/rtsp_session_pool.rs | 13 +- .../src/subclass/rtsp_client.rs | 101 +---- .../src/subclass/rtsp_media.rs | 33 +- .../src/subclass/rtsp_media_factory.rs | 20 +- .../src/subclass/rtsp_mount_points.rs | 9 +- .../src/subclass/rtsp_onvif_media_factory.rs | 9 +- .../src/subclass/rtsp_server.rs | 7 +- gstreamer-video/src/subclass/navigation.rs | 17 +- .../src/subclass/video_aggregator.rs | 23 +- .../src/subclass/video_aggregator_pad.rs | 23 +- gstreamer-video/src/subclass/video_decoder.rs | 70 +--- gstreamer-video/src/subclass/video_encoder.rs | 51 +-- gstreamer-video/src/subclass/video_filter.rs | 31 +- gstreamer-video/src/subclass/video_sink.rs | 9 +- gstreamer-video/src/video_aggregator.rs | 9 +- .../src/video_aggregator_convert_pad.rs | 24 +- gstreamer-video/src/video_aggregator_pad.rs | 24 +- gstreamer-video/src/video_decoder.rs | 172 +++------ gstreamer-video/src/video_encoder.rs | 196 ++++------ gstreamer-video/src/video_overlay.rs | 10 +- gstreamer-webrtc/src/web_rtcice.rs | 22 +- gstreamer/src/bin.rs | 86 ++--- gstreamer/src/buffer_pool.rs | 25 +- gstreamer/src/child_proxy.rs | 29 +- gstreamer/src/clock.rs | 40 +- gstreamer/src/control_binding.rs | 18 +- gstreamer/src/control_source.rs | 18 +- gstreamer/src/device_monitor.rs | 27 +- gstreamer/src/device_provider.rs | 19 +- gstreamer/src/element.rs | 298 ++++----------- gstreamer/src/gobject.rs | 11 +- gstreamer/src/object.rs | 42 +- gstreamer/src/pad.rs | 359 +++++------------- gstreamer/src/pipeline.rs | 15 +- gstreamer/src/plugin_feature.rs | 19 +- gstreamer/src/subclass/allocator.rs | 15 +- gstreamer/src/subclass/bin.rs | 15 +- gstreamer/src/subclass/buffer_pool.rs | 33 +- gstreamer/src/subclass/child_proxy.rs | 15 +- gstreamer/src/subclass/clock.rs | 67 ++-- gstreamer/src/subclass/device.rs | 11 +- gstreamer/src/subclass/device_provider.rs | 13 +- gstreamer/src/subclass/element.rs | 45 +-- gstreamer/src/subclass/pad.rs | 11 +- gstreamer/src/subclass/uri_handler.rs | 11 +- gstreamer/src/tag_setter.rs | 11 +- gstreamer/src/task_pool.rs | 15 +- 99 files changed, 1115 insertions(+), 2471 deletions(-) diff --git a/gstreamer-audio/src/audio_aggregator.rs b/gstreamer-audio/src/audio_aggregator.rs index 801323e7f..e0b07b14f 100644 --- a/gstreamer-audio/src/audio_aggregator.rs +++ b/gstreamer-audio/src/audio_aggregator.rs @@ -10,33 +10,13 @@ use gst::prelude::*; use crate::auto::{AudioAggregator, AudioAggregatorPad}; -pub trait AudioAggregatorExtManual: 'static { - #[doc(alias = "gst_audio_aggregator_set_sink_caps")] - fn set_sink_caps(&self, pad: &impl IsA, caps: &gst::CapsRef); - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - #[doc(alias = "output-buffer-duration-fraction")] - fn output_buffer_duration_fraction(&self) -> gst::Fraction; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - #[doc(alias = "output-buffer-duration-fraction")] - fn set_output_buffer_duration_fraction(&self, output_buffer_duration_fraction: gst::Fraction); - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - #[doc(alias = "output-buffer-duration-fraction")] - fn connect_output_buffer_duration_fraction_notify( - &self, - f: F, - ) -> SignalHandlerId; - - fn current_caps(&self) -> Option; - fn current_audio_info(&self) -> Option; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> AudioAggregatorExtManual for O { +pub trait AudioAggregatorExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_audio_aggregator_set_sink_caps")] fn set_sink_caps(&self, pad: &impl IsA, caps: &gst::CapsRef) { unsafe { ffi::gst_audio_aggregator_set_sink_caps( @@ -49,12 +29,14 @@ impl> AudioAggregatorExtManual for O { #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[doc(alias = "output-buffer-duration-fraction")] fn output_buffer_duration_fraction(&self) -> gst::Fraction { glib::ObjectExt::property(self.as_ref(), "output-buffer-duration-fraction") } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[doc(alias = "output-buffer-duration-fraction")] fn set_output_buffer_duration_fraction(&self, output_buffer_duration_fraction: gst::Fraction) { glib::ObjectExt::set_property( self.as_ref(), @@ -65,6 +47,7 @@ impl> AudioAggregatorExtManual for O { #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[doc(alias = "output-buffer-duration-fraction")] fn connect_output_buffer_duration_fraction_notify( &self, f: F, @@ -106,3 +89,5 @@ impl> AudioAggregatorExtManual for O { .and_then(|caps| crate::AudioInfo::from_caps(&caps).ok()) } } + +impl> AudioAggregatorExtManual for O {} diff --git a/gstreamer-audio/src/audio_aggregator_convert_pad.rs b/gstreamer-audio/src/audio_aggregator_convert_pad.rs index 63fd0d149..463eeafd2 100644 --- a/gstreamer-audio/src/audio_aggregator_convert_pad.rs +++ b/gstreamer-audio/src/audio_aggregator_convert_pad.rs @@ -9,26 +9,21 @@ use glib::{ use crate::auto::AudioAggregatorConvertPad; -pub trait AudioAggregatorConvertPadExtManual: 'static { - #[doc(alias = "converter-config")] - fn converter_config(&self) -> Option; - - #[doc(alias = "converter-config")] - fn set_converter_config(&self, converter_config: Option<&crate::AudioConverterConfig>); - - #[doc(alias = "converter-config")] - fn connect_converter_config_notify( - &self, - f: F, - ) -> SignalHandlerId; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> AudioAggregatorConvertPadExtManual for O { +pub trait AudioAggregatorConvertPadExtManual: + sealed::Sealed + IsA + 'static +{ + #[doc(alias = "converter-config")] fn converter_config(&self) -> Option { glib::ObjectExt::property::>(self.as_ref(), "converter-config") .map(|c| c.try_into().unwrap()) } + #[doc(alias = "converter-config")] fn set_converter_config(&self, converter_config: Option<&crate::AudioConverterConfig>) { glib::ObjectExt::set_property( self.as_ref(), @@ -37,6 +32,7 @@ impl> AudioAggregatorConvertPadExtManual for O ) } + #[doc(alias = "converter-config")] fn connect_converter_config_notify( &self, f: F, @@ -65,3 +61,5 @@ impl> AudioAggregatorConvertPadExtManual for O } } } + +impl> AudioAggregatorConvertPadExtManual for O {} diff --git a/gstreamer-audio/src/audio_aggregator_pad.rs b/gstreamer-audio/src/audio_aggregator_pad.rs index 4190b5b61..cf3910e62 100644 --- a/gstreamer-audio/src/audio_aggregator_pad.rs +++ b/gstreamer-audio/src/audio_aggregator_pad.rs @@ -3,11 +3,12 @@ use gst::prelude::*; use crate::auto::AudioAggregatorPad; -pub trait AudioAggregatorPadExtManual: 'static { - fn audio_info(&self) -> Option; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> AudioAggregatorPadExtManual for O { +pub trait AudioAggregatorPadExtManual: sealed::Sealed + IsA + 'static { fn audio_info(&self) -> Option { unsafe { let ptr = self.as_ptr() as *mut ffi::GstAudioAggregatorPad; @@ -25,3 +26,5 @@ impl> AudioAggregatorPadExtManual for O { } } } + +impl> AudioAggregatorPadExtManual for O {} diff --git a/gstreamer-audio/src/audio_decoder.rs b/gstreamer-audio/src/audio_decoder.rs index ff862d3dd..17b928998 100644 --- a/gstreamer-audio/src/audio_decoder.rs +++ b/gstreamer-audio/src/audio_decoder.rs @@ -20,36 +20,12 @@ extern "C" { ) -> gst::ffi::GstFlowReturn; } -pub trait AudioDecoderExtManual: 'static { - fn negotiate(&self) -> Result<(), gst::FlowError>; - - #[cfg(feature = "v1_16")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] - fn set_output_caps(&self, caps: &gst::Caps) -> Result<(), gst::FlowError>; - - fn set_output_format(&self, info: &AudioInfo) -> Result<(), gst::FlowError>; - - #[doc(alias = "get_allocator")] - fn allocator(&self) -> (Option, gst::AllocationParams); - - #[allow(clippy::too_many_arguments)] - fn error( - &self, - weight: i32, - code: T, - message: Option<&str>, - debug: Option<&str>, - file: &str, - function: &str, - line: u32, - ) -> Result; - - fn sink_pad(&self) -> &gst::Pad; - - fn src_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> AudioDecoderExtManual for O { +pub trait AudioDecoderExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gst_audio_decoder_negotiate")] fn negotiate(&self) -> Result<(), gst::FlowError> { unsafe { @@ -96,6 +72,7 @@ impl> AudioDecoderExtManual for O { } } + #[doc(alias = "get_allocator")] #[doc(alias = "gst_audio_decoder_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { @@ -110,6 +87,7 @@ impl> AudioDecoderExtManual for O { } } + #[allow(clippy::too_many_arguments)] fn error( &self, weight: i32, @@ -150,6 +128,8 @@ impl> AudioDecoderExtManual for O { } } +impl> AudioDecoderExtManual for O {} + #[macro_export] macro_rules! audio_decoder_error( ($obj:expr, $weight:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { diff --git a/gstreamer-audio/src/audio_encoder.rs b/gstreamer-audio/src/audio_encoder.rs index 9281761c5..65fdcfa40 100644 --- a/gstreamer-audio/src/audio_encoder.rs +++ b/gstreamer-audio/src/audio_encoder.rs @@ -6,26 +6,13 @@ use glib::{prelude::*, translate::*}; use crate::AudioEncoder; -pub trait AudioEncoderExtManual: 'static { - #[doc(alias = "gst_audio_encoder_negotiate")] - fn negotiate(&self) -> Result<(), gst::FlowError>; - - #[doc(alias = "gst_audio_encoder_set_output_format")] - fn set_output_format(&self, caps: &gst::Caps) -> Result<(), gst::FlowError>; - - #[doc(alias = "get_allocator")] - #[doc(alias = "gst_audio_encoder_get_allocator")] - fn allocator(&self) -> (Option, gst::AllocationParams); - - #[doc(alias = "gst_audio_encoder_set_headers")] - fn set_headers(&self, headers: impl IntoIterator); - - fn sink_pad(&self) -> &gst::Pad; - - fn src_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> AudioEncoderExtManual for O { +pub trait AudioEncoderExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_audio_encoder_negotiate")] fn negotiate(&self) -> Result<(), gst::FlowError> { unsafe { let ret = from_glib(ffi::gst_audio_encoder_negotiate( @@ -39,6 +26,7 @@ impl> AudioEncoderExtManual for O { } } + #[doc(alias = "gst_audio_encoder_set_output_format")] fn set_output_format(&self, caps: &gst::Caps) -> Result<(), gst::FlowError> { unsafe { let ret = from_glib(ffi::gst_audio_encoder_set_output_format( @@ -53,6 +41,8 @@ impl> AudioEncoderExtManual for O { } } + #[doc(alias = "get_allocator")] + #[doc(alias = "gst_audio_encoder_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { let mut allocator = ptr::null_mut(); @@ -66,6 +56,7 @@ impl> AudioEncoderExtManual for O { } } + #[doc(alias = "gst_audio_encoder_set_headers")] fn set_headers(&self, headers: impl IntoIterator) { unsafe { ffi::gst_audio_encoder_set_headers( @@ -92,3 +83,5 @@ impl> AudioEncoderExtManual for O { } } } + +impl> AudioEncoderExtManual for O {} diff --git a/gstreamer-audio/src/subclass/audio_aggregator.rs b/gstreamer-audio/src/subclass/audio_aggregator.rs index abb838e1c..6c6f67a1e 100644 --- a/gstreamer-audio/src/subclass/audio_aggregator.rs +++ b/gstreamer-audio/src/subclass/audio_aggregator.rs @@ -26,22 +26,12 @@ pub trait AudioAggregatorImpl: AudioAggregatorImplExt + AggregatorImpl { } } -pub trait AudioAggregatorImplExt: ObjectSubclass { - fn parent_create_output_buffer(&self, num_frames: u32) -> Option; - - #[allow(clippy::too_many_arguments)] - fn parent_aggregate_one_buffer( - &self, - pad: &AudioAggregatorPad, - inbuf: &gst::BufferRef, - in_offset: u32, - outbuf: &mut gst::BufferRef, - out_offset: u32, - num_frames: u32, - ) -> bool; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioAggregatorImplExt for T { +pub trait AudioAggregatorImplExt: sealed::Sealed + ObjectSubclass { fn parent_create_output_buffer(&self, num_frames: u32) -> Option { unsafe { let data = Self::type_data(); @@ -92,6 +82,8 @@ impl AudioAggregatorImplExt for T { } } +impl AudioAggregatorImplExt for T {} + unsafe impl IsSubclassable for AudioAggregator { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-audio/src/subclass/audio_aggregator_pad.rs b/gstreamer-audio/src/subclass/audio_aggregator_pad.rs index 01b5ce693..0d021dad3 100644 --- a/gstreamer-audio/src/subclass/audio_aggregator_pad.rs +++ b/gstreamer-audio/src/subclass/audio_aggregator_pad.rs @@ -24,18 +24,12 @@ pub trait AudioAggregatorPadImpl: AudioAggregatorPadImplExt + AggregatorPadImpl } } -pub trait AudioAggregatorPadImplExt: ObjectSubclass { - fn parent_update_conversion_info(&self); - - fn parent_convert_buffer( - &self, - in_info: &crate::AudioInfo, - out_info: &crate::AudioInfo, - buffer: &gst::Buffer, - ) -> Option; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioAggregatorPadImplExt for T { +pub trait AudioAggregatorPadImplExt: sealed::Sealed + ObjectSubclass { fn parent_update_conversion_info(&self) { unsafe { let data = Self::type_data(); @@ -75,6 +69,8 @@ impl AudioAggregatorPadImplExt for T { } } +impl AudioAggregatorPadImplExt for T {} + unsafe impl IsSubclassable for AudioAggregatorPad { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index cd9b9caa8..568c9f2d8 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -86,52 +86,12 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl { } } -pub trait AudioDecoderImplExt: ObjectSubclass { - fn parent_open(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_close(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_set_format(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - - fn parent_parse(&self, adapter: &gst_base::Adapter) -> Result<(u32, u32), gst::FlowError>; - - fn parent_handle_frame( - &self, - buffer: Option<&gst::Buffer>, - ) -> Result; - - fn parent_pre_push(&self, buffer: gst::Buffer) -> Result, gst::FlowError>; - - fn parent_flush(&self, hard: bool); - - fn parent_negotiate(&self) -> Result<(), gst::LoggableError>; - - fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps; - - fn parent_sink_event(&self, event: gst::Event) -> bool; - - fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_src_event(&self, event: gst::Event) -> bool; - - fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_propose_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioDecoderImplExt for T { +pub trait AudioDecoderImplExt: sealed::Sealed + ObjectSubclass { fn parent_open(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -513,6 +473,8 @@ impl AudioDecoderImplExt for T { } } +impl AudioDecoderImplExt for T {} + unsafe impl IsSubclassable for AudioDecoder { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index ffd7992d6..8888ab33b 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -82,50 +82,12 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl { } } -pub trait AudioEncoderImplExt: ObjectSubclass { - fn parent_open(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_close(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_set_format(&self, info: &AudioInfo) -> Result<(), gst::LoggableError>; - - fn parent_handle_frame( - &self, - buffer: Option<&gst::Buffer>, - ) -> Result; - - fn parent_pre_push(&self, buffer: gst::Buffer) -> Result, gst::FlowError>; - - fn parent_flush(&self); - - fn parent_negotiate(&self) -> Result<(), gst::LoggableError>; - - fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps; - - fn parent_sink_event(&self, event: gst::Event) -> bool; - - fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_src_event(&self, event: gst::Event) -> bool; - - fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_propose_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioEncoderImplExt for T { +pub trait AudioEncoderImplExt: sealed::Sealed + ObjectSubclass { fn parent_open(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -475,6 +437,8 @@ impl AudioEncoderImplExt for T { } } +impl AudioEncoderImplExt for T {} + unsafe impl IsSubclassable for AudioEncoder { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-audio/src/subclass/audio_filter.rs b/gstreamer-audio/src/subclass/audio_filter.rs index c03de3b38..80f445b64 100644 --- a/gstreamer-audio/src/subclass/audio_filter.rs +++ b/gstreamer-audio/src/subclass/audio_filter.rs @@ -13,11 +13,12 @@ pub trait AudioFilterImpl: AudioFilterImplExt + BaseTransformImpl { } } -pub trait AudioFilterImplExt: ObjectSubclass { - fn parent_setup(&self, info: &AudioInfo) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioFilterImplExt for T { +pub trait AudioFilterImplExt: sealed::Sealed + ObjectSubclass { fn parent_setup(&self, info: &AudioInfo) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); @@ -39,6 +40,8 @@ impl AudioFilterImplExt for T { } } +impl AudioFilterImplExt for T {} + unsafe impl IsSubclassable for AudioFilter { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-audio/src/subclass/audio_sink.rs b/gstreamer-audio/src/subclass/audio_sink.rs index 49b6f7599..825c3d3de 100644 --- a/gstreamer-audio/src/subclass/audio_sink.rs +++ b/gstreamer-audio/src/subclass/audio_sink.rs @@ -37,17 +37,12 @@ pub trait AudioSinkImpl: AudioSinkImplExt + AudioBaseSinkImpl { } } -pub trait AudioSinkImplExt: ObjectSubclass { - fn parent_close(&self) -> Result<(), LoggableError>; - fn parent_delay(&self) -> u32; - fn parent_open(&self) -> Result<(), LoggableError>; - fn parent_prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError>; - fn parent_unprepare(&self) -> Result<(), LoggableError>; - fn parent_write(&self, audio_data: &[u8]) -> Result; - fn parent_reset(&self); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioSinkImplExt for T { +pub trait AudioSinkImplExt: sealed::Sealed + ObjectSubclass { fn parent_close(&self) -> Result<(), LoggableError> { unsafe { let data = Self::type_data(); @@ -168,6 +163,8 @@ impl AudioSinkImplExt for T { } } +impl AudioSinkImplExt for T {} + unsafe impl IsSubclassable for AudioSink { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-audio/src/subclass/audio_src.rs b/gstreamer-audio/src/subclass/audio_src.rs index 112f7be3c..eb3c46acf 100644 --- a/gstreamer-audio/src/subclass/audio_src.rs +++ b/gstreamer-audio/src/subclass/audio_src.rs @@ -39,20 +39,12 @@ pub trait AudioSrcImpl: AudioSrcImplExt + AudioBaseSrcImpl { } } -pub trait AudioSrcImplExt: ObjectSubclass { - fn parent_close(&self) -> Result<(), LoggableError>; - fn parent_delay(&self) -> u32; - fn parent_open(&self) -> Result<(), LoggableError>; - fn parent_prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError>; - fn parent_unprepare(&self) -> Result<(), LoggableError>; - fn parent_read( - &self, - audio_data: &mut [u8], - ) -> Result<(u32, Option), LoggableError>; - fn parent_reset(&self); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioSrcImplExt for T { +pub trait AudioSrcImplExt: sealed::Sealed + ObjectSubclass { fn parent_close(&self) -> Result<(), LoggableError> { unsafe { let data = Self::type_data(); @@ -178,6 +170,8 @@ impl AudioSrcImplExt for T { } } +impl AudioSrcImplExt for T {} + unsafe impl IsSubclassable for AudioSrc { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index 6af06910b..9b588a4ae 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -17,71 +17,14 @@ use gst::{format::FormattedValue, prelude::*}; use crate::Aggregator; use crate::AggregatorPad; -pub trait AggregatorExtManual: 'static { - #[doc(alias = "get_allocator")] - #[doc(alias = "gst_aggregator_get_allocator")] - fn allocator(&self) -> (Option, gst::AllocationParams); - - #[cfg(feature = "v1_16")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] - #[doc(alias = "min-upstream-latency")] - fn min_upstream_latency(&self) -> gst::ClockTime; - - #[cfg(feature = "v1_16")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] - #[doc(alias = "min-upstream-latency")] - fn set_min_upstream_latency(&self, min_upstream_latency: gst::ClockTime); - - #[cfg(feature = "v1_16")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] - #[doc(alias = "min-upstream-latency")] - fn connect_min_upstream_latency_notify( - &self, - f: F, - ) -> SignalHandlerId; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - #[doc(alias = "gst_aggregator_update_segment")] - fn update_segment( - &self, - segment: &gst::FormattedSegment, - ); - - fn set_position(&self, position: impl FormattedValue); - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - #[doc(alias = "gst_aggregator_selected_samples")] - fn selected_samples( - &self, - pts: impl Into>, - dts: impl Into>, - duration: impl Into>, - info: Option<&gst::StructureRef>, - ); - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - fn connect_samples_selected< - F: Fn( - &Self, - &gst::Segment, - Option, - Option, - Option, - Option<&gst::StructureRef>, - ) + Send - + 'static, - >( - &self, - f: F, - ) -> SignalHandlerId; - - fn src_pad(&self) -> &AggregatorPad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> AggregatorExtManual for O { +pub trait AggregatorExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_allocator")] + #[doc(alias = "gst_aggregator_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { let mut allocator = ptr::null_mut(); @@ -97,12 +40,14 @@ impl> AggregatorExtManual for O { #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] + #[doc(alias = "min-upstream-latency")] fn min_upstream_latency(&self) -> gst::ClockTime { self.as_ref().property("min-upstream-latency") } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] + #[doc(alias = "min-upstream-latency")] fn set_min_upstream_latency(&self, min_upstream_latency: gst::ClockTime) { self.as_ref() .set_property("min-upstream-latency", min_upstream_latency); @@ -110,6 +55,7 @@ impl> AggregatorExtManual for O { #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] + #[doc(alias = "min-upstream-latency")] fn connect_min_upstream_latency_notify( &self, f: F, @@ -126,8 +72,10 @@ impl> AggregatorExtManual for O { ) } } + #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[doc(alias = "gst_aggregator_update_segment")] fn update_segment( &self, segment: &gst::FormattedSegment, @@ -157,6 +105,7 @@ impl> AggregatorExtManual for O { #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[doc(alias = "gst_aggregator_selected_samples")] fn selected_samples( &self, pts: impl Into>, @@ -177,8 +126,7 @@ impl> AggregatorExtManual for O { } } - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[cfg(any(feature = "v1_18", feature = "dox"))] fn connect_samples_selected< F: Fn( &Self, @@ -251,6 +199,8 @@ impl> AggregatorExtManual for O { } } +impl> AggregatorExtManual for O {} + #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] unsafe extern "C" fn notify_min_upstream_latency_trampoline( diff --git a/gstreamer-base/src/aggregator_pad.rs b/gstreamer-base/src/aggregator_pad.rs index 65ccc0e9b..3456eab8a 100644 --- a/gstreamer-base/src/aggregator_pad.rs +++ b/gstreamer-base/src/aggregator_pad.rs @@ -5,12 +5,13 @@ use gst::prelude::*; use crate::AggregatorPad; -pub trait AggregatorPadExtManual: 'static { - #[doc(alias = "get_segment")] - fn segment(&self) -> gst::Segment; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> AggregatorPadExtManual for O { +pub trait AggregatorPadExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let ptr: &ffi::GstAggregatorPad = &*(self.as_ptr() as *const _); @@ -19,3 +20,5 @@ impl> AggregatorPadExtManual for O { } } } + +impl> AggregatorPadExtManual for O {} diff --git a/gstreamer-base/src/base_parse.rs b/gstreamer-base/src/base_parse.rs index d327d9d71..d8166cb61 100644 --- a/gstreamer-base/src/base_parse.rs +++ b/gstreamer-base/src/base_parse.rs @@ -7,37 +7,13 @@ use gst::format::{FormattedValue, SpecificFormattedValueFullRange}; use crate::{BaseParse, BaseParseFrame}; -pub trait BaseParseExtManual: 'static { - #[doc(alias = "get_sink_pad")] - fn sink_pad(&self) -> &gst::Pad; - #[doc(alias = "get_src_pad")] - fn src_pad(&self) -> &gst::Pad; - - #[doc(alias = "gst_base_parse_set_duration")] - fn set_duration(&self, duration: impl FormattedValue, interval: u32); - #[doc(alias = "gst_base_parse_set_frame_rate")] - fn set_frame_rate(&self, fps: gst::Fraction, lead_in: u32, lead_out: u32); - - #[doc(alias = "gst_base_parse_convert_default")] - fn convert_default( - &self, - src_val: impl FormattedValue, - ) -> Option; - fn convert_default_generic( - &self, - src_val: impl FormattedValue, - dest_format: gst::Format, - ) -> Option; - - #[doc(alias = "gst_base_parse_finish_frame")] - fn finish_frame( - &self, - frame: BaseParseFrame, - size: u32, - ) -> Result; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> BaseParseExtManual for O { +pub trait BaseParseExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_sink_pad")] fn sink_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseParse); @@ -45,6 +21,7 @@ impl> BaseParseExtManual for O { } } + #[doc(alias = "get_src_pad")] fn src_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseParse); @@ -52,6 +29,7 @@ impl> BaseParseExtManual for O { } } + #[doc(alias = "gst_base_parse_set_duration")] fn set_duration(&self, duration: impl FormattedValue, interval: u32) { unsafe { ffi::gst_base_parse_set_duration( @@ -63,6 +41,7 @@ impl> BaseParseExtManual for O { } } + #[doc(alias = "gst_base_parse_set_frame_rate")] fn set_frame_rate(&self, fps: gst::Fraction, lead_in: u32, lead_out: u32) { let (fps_num, fps_den) = fps.into(); unsafe { @@ -76,6 +55,7 @@ impl> BaseParseExtManual for O { } } + #[doc(alias = "gst_base_parse_convert_default")] fn convert_default( &self, src_val: impl FormattedValue, @@ -122,6 +102,7 @@ impl> BaseParseExtManual for O { } } + #[doc(alias = "gst_base_parse_finish_frame")] fn finish_frame( &self, frame: BaseParseFrame, @@ -136,3 +117,5 @@ impl> BaseParseExtManual for O { } } } + +impl> BaseParseExtManual for O {} diff --git a/gstreamer-base/src/base_sink.rs b/gstreamer-base/src/base_sink.rs index 2668b36e8..5b4c6ab99 100644 --- a/gstreamer-base/src/base_sink.rs +++ b/gstreamer-base/src/base_sink.rs @@ -7,19 +7,13 @@ use gst::prelude::*; use crate::BaseSink; -pub trait BaseSinkExtManual: 'static { - #[doc(alias = "get_segment")] - fn segment(&self) -> gst::Segment; - - #[doc(alias = "gst_base_sink_query_latency")] - fn query_latency( - &self, - ) -> Result<(bool, bool, Option, Option), glib::BoolError>; - - fn sink_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> BaseSinkExtManual for O { +pub trait BaseSinkExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let sink: &ffi::GstBaseSink = &*(self.as_ptr() as *const _); @@ -28,6 +22,7 @@ impl> BaseSinkExtManual for O { } } + #[doc(alias = "gst_base_sink_query_latency")] fn query_latency( &self, ) -> Result<(bool, bool, Option, Option), glib::BoolError> { @@ -67,3 +62,5 @@ impl> BaseSinkExtManual for O { } } } + +impl> BaseSinkExtManual for O {} diff --git a/gstreamer-base/src/base_src.rs b/gstreamer-base/src/base_src.rs index 5cc3fe549..d1c290e95 100644 --- a/gstreamer-base/src/base_src.rs +++ b/gstreamer-base/src/base_src.rs @@ -7,23 +7,14 @@ use gst::prelude::*; use crate::BaseSrc; -pub trait BaseSrcExtManual: 'static { - #[doc(alias = "get_allocator")] - #[doc(alias = "gst_base_src_get_allocator")] - fn allocator(&self) -> (Option, gst::AllocationParams); - - #[doc(alias = "get_segment")] - fn segment(&self) -> gst::Segment; - - #[doc(alias = "gst_base_src_query_latency")] - fn query_latency( - &self, - ) -> Result<(bool, Option, Option), glib::BoolError>; - - fn src_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> BaseSrcExtManual for O { +pub trait BaseSrcExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_allocator")] + #[doc(alias = "gst_base_src_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { let mut allocator = ptr::null_mut(); @@ -37,6 +28,7 @@ impl> BaseSrcExtManual for O { } } + #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let src: &ffi::GstBaseSrc = &*(self.as_ptr() as *const _); @@ -45,6 +37,7 @@ impl> BaseSrcExtManual for O { } } + #[doc(alias = "gst_base_src_query_latency")] fn query_latency( &self, ) -> Result<(bool, Option, Option), glib::BoolError> { @@ -80,3 +73,5 @@ impl> BaseSrcExtManual for O { } } } + +impl> BaseSrcExtManual for O {} diff --git a/gstreamer-base/src/base_transform.rs b/gstreamer-base/src/base_transform.rs index 4be23b748..a960f9542 100644 --- a/gstreamer-base/src/base_transform.rs +++ b/gstreamer-base/src/base_transform.rs @@ -7,20 +7,14 @@ use gst::prelude::*; use crate::BaseTransform; -pub trait BaseTransformExtManual: 'static { - #[doc(alias = "get_allocator")] - #[doc(alias = "gst_base_transform_get_allocator")] - fn allocator(&self) -> (Option, gst::AllocationParams); - - #[doc(alias = "get_segment")] - fn segment(&self) -> gst::Segment; - - fn sink_pad(&self) -> &gst::Pad; - - fn src_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> BaseTransformExtManual for O { +pub trait BaseTransformExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_allocator")] + #[doc(alias = "gst_base_transform_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { let mut allocator = ptr::null_mut(); @@ -34,6 +28,7 @@ impl> BaseTransformExtManual for O { } } + #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let trans: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _); @@ -56,3 +51,5 @@ impl> BaseTransformExtManual for O { } } } + +impl> BaseTransformExtManual for O {} diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index 9b099d72e..d891fe95e 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -135,98 +135,12 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl { } } -pub trait AggregatorImplExt: ObjectSubclass { - fn parent_flush(&self) -> Result; - - fn parent_clip( - &self, - aggregator_pad: &AggregatorPad, - buffer: gst::Buffer, - ) -> Option; - - fn parent_finish_buffer(&self, buffer: gst::Buffer) - -> Result; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - fn parent_finish_buffer_list( - &self, - buffer_list: gst::BufferList, - ) -> Result; - - fn parent_sink_event(&self, aggregator_pad: &AggregatorPad, event: gst::Event) -> bool; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - fn parent_sink_event_pre_queue( - &self, - aggregator_pad: &AggregatorPad, - event: gst::Event, - ) -> Result; - - fn parent_sink_query(&self, aggregator_pad: &AggregatorPad, query: &mut gst::QueryRef) -> bool; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - fn parent_sink_query_pre_queue( - &self, - aggregator_pad: &AggregatorPad, - query: &mut gst::QueryRef, - ) -> bool; - - fn parent_src_event(&self, event: gst::Event) -> bool; - - fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_src_activate( - &self, - mode: gst::PadMode, - active: bool, - ) -> Result<(), gst::LoggableError>; - - fn parent_aggregate(&self, timeout: bool) -> Result; - - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_next_time(&self) -> Option; - - fn parent_create_new_pad( - &self, - templ: &gst::PadTemplate, - req_name: Option<&str>, - caps: Option<&gst::Caps>, - ) -> Option; - - fn parent_update_src_caps(&self, caps: &gst::Caps) -> Result; - - fn parent_fixate_src_caps(&self, caps: gst::Caps) -> gst::Caps; - - fn parent_negotiated_src_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - - fn parent_propose_allocation( - &self, - pad: &AggregatorPad, - decide_query: Option<&gst::query::Allocation>, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - fn parent_negotiate(&self) -> bool; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - fn parent_peek_next_sample(&self, pad: &AggregatorPad) -> Option; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AggregatorImplExt for T { +pub trait AggregatorImplExt: sealed::Sealed + ObjectSubclass { fn parent_flush(&self) -> Result { unsafe { let data = Self::type_data(); @@ -668,6 +582,8 @@ impl AggregatorImplExt for T { } } +impl AggregatorImplExt for T {} + unsafe impl IsSubclassable for Aggregator { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-base/src/subclass/aggregator_pad.rs b/gstreamer-base/src/subclass/aggregator_pad.rs index ca7c9f0f3..b4b14bf51 100644 --- a/gstreamer-base/src/subclass/aggregator_pad.rs +++ b/gstreamer-base/src/subclass/aggregator_pad.rs @@ -15,13 +15,12 @@ pub trait AggregatorPadImpl: AggregatorPadImplExt + PadImpl { } } -pub trait AggregatorPadImplExt: ObjectSubclass { - fn parent_flush(&self, aggregator: &Aggregator) -> Result; - - fn parent_skip_buffer(&self, aggregator: &Aggregator, buffer: &gst::Buffer) -> bool; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AggregatorPadImplExt for T { +pub trait AggregatorPadImplExt: sealed::Sealed + ObjectSubclass { fn parent_flush(&self, aggregator: &Aggregator) -> Result { unsafe { let data = Self::type_data(); @@ -61,6 +60,8 @@ impl AggregatorPadImplExt for T { } } } + +impl AggregatorPadImplExt for T {} unsafe impl IsSubclassable for AggregatorPad { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-base/src/subclass/base_parse.rs b/gstreamer-base/src/subclass/base_parse.rs index dd9ede2cd..9f145dd44 100644 --- a/gstreamer-base/src/subclass/base_parse.rs +++ b/gstreamer-base/src/subclass/base_parse.rs @@ -36,26 +36,12 @@ pub trait BaseParseImpl: BaseParseImplExt + ElementImpl { } } -pub trait BaseParseImplExt: ObjectSubclass { - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_set_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - - fn parent_handle_frame( - &self, - frame: BaseParseFrame, - ) -> Result<(gst::FlowSuccess, u32), gst::FlowError>; - - fn parent_convert( - &self, - src_val: impl gst::format::FormattedValue, - dest_format: gst::Format, - ) -> Option; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl BaseParseImplExt for T { +pub trait BaseParseImplExt: sealed::Sealed + ObjectSubclass { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -180,6 +166,8 @@ impl BaseParseImplExt for T { } } +impl BaseParseImplExt for T {} + unsafe impl IsSubclassable for BaseParse { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-base/src/subclass/base_sink.rs b/gstreamer-base/src/subclass/base_sink.rs index 416b6229b..0f3cc01ae 100644 --- a/gstreamer-base/src/subclass/base_sink.rs +++ b/gstreamer-base/src/subclass/base_sink.rs @@ -68,46 +68,12 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl { } } -pub trait BaseSinkImplExt: ObjectSubclass { - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_render(&self, buffer: &gst::Buffer) -> Result; - - fn parent_prepare(&self, buffer: &gst::Buffer) -> Result; - - fn parent_render_list( - &self, - list: &gst::BufferList, - ) -> Result; - - fn parent_prepare_list( - &self, - list: &gst::BufferList, - ) -> Result; - - fn parent_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_event(&self, event: gst::Event) -> bool; - - fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option; - - fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - - fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps; - - fn parent_unlock(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_propose_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl BaseSinkImplExt for T { +pub trait BaseSinkImplExt: sealed::Sealed + ObjectSubclass { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -183,50 +149,12 @@ impl BaseSinkImplExt for T { fn parent_render_list( &self, list: &gst::BufferList, - ) -> Result { - unsafe { - let data = Self::type_data(); - let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; - (*parent_class) - .render_list - .map(|f| { - try_from_glib(f( - self.obj().unsafe_cast_ref::().to_glib_none().0, - list.to_glib_none().0, - )) - }) - .unwrap_or_else(|| { - for buffer in list.iter() { - self.render(&from_glib_borrow(buffer.as_ptr()))?; - } - Ok(gst::FlowSuccess::Ok) - }) - } - } + ) -> Result; fn parent_prepare_list( &self, list: &gst::BufferList, - ) -> Result { - unsafe { - let data = Self::type_data(); - let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; - (*parent_class) - .prepare_list - .map(|f| { - try_from_glib(f( - self.obj().unsafe_cast_ref::().to_glib_none().0, - list.to_glib_none().0, - )) - }) - .unwrap_or_else(|| { - for buffer in list.iter() { - self.prepare(&from_glib_borrow(buffer.as_ptr()))?; - } - Ok(gst::FlowSuccess::Ok) - }) - } - } + ) -> Result; fn parent_query(&self, query: &mut gst::QueryRef) -> bool { unsafe { @@ -376,6 +304,56 @@ impl BaseSinkImplExt for T { } } +impl BaseSinkImplExt for T { + fn parent_render_list( + &self, + list: &gst::BufferList, + ) -> Result { + unsafe { + let data = Self::type_data(); + let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; + (*parent_class) + .render_list + .map(|f| { + try_from_glib(f( + self.obj().unsafe_cast_ref::().to_glib_none().0, + list.to_glib_none().0, + )) + }) + .unwrap_or_else(|| { + for buffer in list.iter() { + self.render(&from_glib_borrow(buffer.as_ptr()))?; + } + Ok(gst::FlowSuccess::Ok) + }) + } + } + + fn parent_prepare_list( + &self, + list: &gst::BufferList, + ) -> Result { + unsafe { + let data = Self::type_data(); + let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; + (*parent_class) + .prepare_list + .map(|f| { + try_from_glib(f( + self.obj().unsafe_cast_ref::().to_glib_none().0, + list.to_glib_none().0, + )) + }) + .unwrap_or_else(|| { + for buffer in list.iter() { + self.prepare(&from_glib_borrow(buffer.as_ptr()))?; + } + Ok(gst::FlowSuccess::Ok) + }) + } + } +} + unsafe impl IsSubclassable for BaseSink { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-base/src/subclass/base_src.rs b/gstreamer-base/src/subclass/base_src.rs index fe94f73a7..1f0e74622 100644 --- a/gstreamer-base/src/subclass/base_src.rs +++ b/gstreamer-base/src/subclass/base_src.rs @@ -108,61 +108,12 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl { } } -pub trait BaseSrcImplExt: ObjectSubclass { - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_is_seekable(&self) -> bool; - - fn parent_size(&self) -> Option; - - fn parent_times( - &self, - buffer: &gst::BufferRef, - ) -> (Option, Option); - - fn parent_fill( - &self, - offset: u64, - length: u32, - buffer: &mut gst::BufferRef, - ) -> Result; - - fn parent_alloc(&self, offset: u64, length: u32) -> Result; - - fn parent_create( - &self, - offset: u64, - buffer: Option<&mut gst::BufferRef>, - length: u32, - ) -> Result; - - fn parent_do_seek(&self, segment: &mut gst::Segment) -> bool; - - fn parent_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_event(&self, event: &gst::Event) -> bool; - - fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option; - - fn parent_negotiate(&self) -> Result<(), gst::LoggableError>; - - fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - - fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps; - - fn parent_unlock(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl BaseSrcImplExt for T { +pub trait BaseSrcImplExt: sealed::Sealed + ObjectSubclass { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -607,6 +558,8 @@ impl BaseSrcImplExt for T { } } +impl BaseSrcImplExt for T {} + unsafe impl IsSubclassable for BaseSrc { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-base/src/subclass/base_transform.rs b/gstreamer-base/src/subclass/base_transform.rs index c59d51d65..b1255951b 100644 --- a/gstreamer-base/src/subclass/base_transform.rs +++ b/gstreamer-base/src/subclass/base_transform.rs @@ -154,117 +154,12 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl { } } -pub trait BaseTransformImplExt: ObjectSubclass { - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_transform_caps( - &self, - direction: gst::PadDirection, - caps: &gst::Caps, - filter: Option<&gst::Caps>, - ) -> Option; - - fn parent_fixate_caps( - &self, - direction: gst::PadDirection, - caps: &gst::Caps, - othercaps: gst::Caps, - ) -> gst::Caps; - - fn parent_set_caps( - &self, - incaps: &gst::Caps, - outcaps: &gst::Caps, - ) -> Result<(), gst::LoggableError>; - - fn parent_accept_caps(&self, direction: gst::PadDirection, caps: &gst::Caps) -> bool; - - fn parent_query(&self, direction: gst::PadDirection, query: &mut gst::QueryRef) -> bool; - - fn parent_transform_size( - &self, - direction: gst::PadDirection, - caps: &gst::Caps, - size: usize, - othercaps: &gst::Caps, - ) -> Option; - - fn parent_unit_size(&self, caps: &gst::Caps) -> Option; - - fn parent_sink_event(&self, event: gst::Event) -> bool; - - fn parent_src_event(&self, event: gst::Event) -> bool; - - fn parent_prepare_output_buffer( - &self, - inbuf: InputBuffer, - ) -> Result; - - fn parent_transform( - &self, - inbuf: &gst::Buffer, - outbuf: &mut gst::BufferRef, - ) -> Result; - - fn parent_transform_ip( - &self, - buf: &mut gst::BufferRef, - ) -> Result; - - fn parent_transform_ip_passthrough( - &self, - buf: &gst::Buffer, - ) -> Result; - - fn parent_propose_allocation( - &self, - decide_query: Option<&gst::query::Allocation>, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - fn parent_copy_metadata( - &self, - inbuf: &gst::BufferRef, - outbuf: &mut gst::BufferRef, - ) -> Result<(), gst::LoggableError>; - - fn parent_transform_meta<'a>( - &self, - outbuf: &mut gst::BufferRef, - meta: gst::MetaRef<'a, gst::Meta>, - inbuf: &'a gst::BufferRef, - ) -> bool; - - fn parent_before_transform(&self, inbuf: &gst::BufferRef); - - fn parent_submit_input_buffer( - &self, - is_discont: bool, - inbuf: gst::Buffer, - ) -> Result; - - fn parent_generate_output(&self) -> Result; - - fn take_queued_buffer(&self) -> Option - where - Self: ObjectSubclass, - ::ParentType: IsA; - - #[doc(alias = "get_queued_buffer")] - fn queued_buffer(&self) -> Option - where - Self: ObjectSubclass, - ::ParentType: IsA; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl BaseTransformImplExt for T { +pub trait BaseTransformImplExt: sealed::Sealed + ObjectSubclass { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -887,6 +782,8 @@ impl BaseTransformImplExt for T { } } +impl BaseTransformImplExt for T {} + unsafe impl IsSubclassable for BaseTransform { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-base/src/subclass/push_src.rs b/gstreamer-base/src/subclass/push_src.rs index 284483fd7..5616cba45 100644 --- a/gstreamer-base/src/subclass/push_src.rs +++ b/gstreamer-base/src/subclass/push_src.rs @@ -22,18 +22,12 @@ pub trait PushSrcImpl: PushSrcImplExt + BaseSrcImpl { } } -pub trait PushSrcImplExt: ObjectSubclass { - fn parent_fill(&self, buffer: &mut gst::BufferRef) -> Result; - - fn parent_alloc(&self) -> Result; - - fn parent_create( - &self, - buffer: Option<&mut gst::BufferRef>, - ) -> Result; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl PushSrcImplExt for T { +pub trait PushSrcImplExt: sealed::Sealed + ObjectSubclass { fn parent_fill(&self, buffer: &mut gst::BufferRef) -> Result { unsafe { let data = Self::type_data(); @@ -186,6 +180,8 @@ impl PushSrcImplExt for T { } } +impl PushSrcImplExt for T {} + unsafe impl IsSubclassable for PushSrc { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-editing-services/src/formatter.rs b/gstreamer-editing-services/src/formatter.rs index f8cdca8b0..fc5444ae3 100644 --- a/gstreamer-editing-services/src/formatter.rs +++ b/gstreamer-editing-services/src/formatter.rs @@ -1,22 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::prelude::*; +use crate::{prelude::*, Formatter}; use gst::glib::translate::*; -pub trait FormatterExtManual: 'static { - fn can_load_uri(&self, uri: &str) -> Result<(), glib::Error>; - #[doc(alias = "ges_formatter_class_register_metas")] - fn register( - type_: glib::types::Type, - name: &str, - description: Option<&str>, - extensions: Option<&str>, - caps: Option<&str>, - version: f64, - rank: gst::Rank, - ); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> FormatterExtManual for O { +pub trait FormatterExtManual: sealed::Sealed + IsA + 'static { fn can_load_uri(&self, uri: &str) -> Result<(), glib::Error> { unsafe { let klass = self.class_of::().unwrap(); @@ -71,3 +62,5 @@ impl> FormatterExtManual for O { } } } + +impl> FormatterExtManual for O {} diff --git a/gstreamer-editing-services/src/subclass/formatter.rs b/gstreamer-editing-services/src/subclass/formatter.rs index 744867e79..47582723b 100644 --- a/gstreamer-editing-services/src/subclass/formatter.rs +++ b/gstreamer-editing-services/src/subclass/formatter.rs @@ -23,24 +23,12 @@ pub trait FormatterImpl: FormatterImplExt + ObjectImpl + Send + Sync { } } -pub trait FormatterImplExt: ObjectSubclass { - fn parent_can_load_uri(&self, uri: &str) -> Result<(), glib::Error>; - - fn parent_load_from_uri( - &self, - timeline: &crate::Timeline, - uri: &str, - ) -> Result<(), glib::Error>; - - fn parent_save_to_uri( - &self, - timeline: &crate::Timeline, - uri: &str, - overwrite: bool, - ) -> Result<(), glib::Error>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl FormatterImplExt for T { +pub trait FormatterImplExt: sealed::Sealed + ObjectSubclass { fn parent_can_load_uri(&self, uri: &str) -> Result<(), glib::Error> { unsafe { let data = Self::type_data(); @@ -161,6 +149,8 @@ impl FormatterImplExt for T { } } +impl FormatterImplExt for T {} + unsafe impl IsSubclassable for Formatter { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-gl/src/gl_context.rs b/gstreamer-gl/src/gl_context.rs index 86d7fa0a8..046d8af78 100644 --- a/gstreamer-gl/src/gl_context.rs +++ b/gstreamer-gl/src/gl_context.rs @@ -45,21 +45,20 @@ impl GLContext { } } -pub trait GLContextExtManual: 'static { - #[doc(alias = "get_gl_context")] - #[doc(alias = "gst_gl_context_get_gl_context")] - fn gl_context(&self) -> uintptr_t; - - #[doc(alias = "get_proc_address")] - #[doc(alias = "gst_gl_context_get_proc_address")] - fn proc_address(&self, name: &str) -> uintptr_t; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> GLContextExtManual for O { +pub trait GLContextExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_gl_context")] + #[doc(alias = "gst_gl_context_get_gl_context")] fn gl_context(&self) -> uintptr_t { unsafe { ffi::gst_gl_context_get_gl_context(self.as_ref().to_glib_none().0) as uintptr_t } } + #[doc(alias = "get_proc_address")] + #[doc(alias = "gst_gl_context_get_proc_address")] fn proc_address(&self, name: &str) -> uintptr_t { unsafe { ffi::gst_gl_context_get_proc_address( @@ -69,3 +68,5 @@ impl> GLContextExtManual for O { } } } + +impl> GLContextExtManual for O {} diff --git a/gstreamer-gl/src/gl_display.rs b/gstreamer-gl/src/gl_display.rs index 9344ab200..edcb8ff35 100644 --- a/gstreamer-gl/src/gl_display.rs +++ b/gstreamer-gl/src/gl_display.rs @@ -3,20 +3,15 @@ use crate::{GLContext, GLDisplay}; use glib::prelude::*; use glib::translate::*; -pub trait GLDisplayExtManual: 'static { +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait GLDisplayExtManual: sealed::Sealed + IsA + 'static { #[cfg(feature = "v1_24")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] #[doc(alias = "gst_gl_display_ensure_context")] - fn ensure_context( - &self, - other_context: Option<&impl IsA>, - context: &mut Option, - ) -> Result<(), glib::Error>; -} - -impl> GLDisplayExtManual for O { - #[cfg(feature = "v1_24")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] fn ensure_context( &self, other_context: Option<&impl IsA>, @@ -43,6 +38,8 @@ impl> GLDisplayExtManual for O { } } +impl> GLDisplayExtManual for O {} + impl GLDisplay { #[doc(alias = "gst_gl_display_get_gl_context_for_thread")] pub fn get_gl_context_for_current_thread( diff --git a/gstreamer-gl/src/subclass/gl_base_filter.rs b/gstreamer-gl/src/subclass/gl_base_filter.rs index 08e7338a3..070019863 100644 --- a/gstreamer-gl/src/subclass/gl_base_filter.rs +++ b/gstreamer-gl/src/subclass/gl_base_filter.rs @@ -19,15 +19,12 @@ pub trait GLBaseFilterImpl: GLBaseFilterImplExt + BaseTransformImpl { } } -pub trait GLBaseFilterImplExt: ObjectSubclass { - fn parent_gl_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError>; - - fn parent_gl_start(&self) -> Result<(), LoggableError>; - - fn parent_gl_stop(&self); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl GLBaseFilterImplExt for T { +pub trait GLBaseFilterImplExt: sealed::Sealed + ObjectSubclass { fn parent_gl_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError> { unsafe { let data = Self::type_data(); @@ -91,6 +88,8 @@ impl GLBaseFilterImplExt for T { } } +impl GLBaseFilterImplExt for T {} + unsafe impl IsSubclassable for GLBaseFilter { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-gl/src/subclass/gl_base_src.rs b/gstreamer-gl/src/subclass/gl_base_src.rs index 313f68cf1..38a4c625b 100644 --- a/gstreamer-gl/src/subclass/gl_base_src.rs +++ b/gstreamer-gl/src/subclass/gl_base_src.rs @@ -21,15 +21,12 @@ pub trait GLBaseSrcImpl: GLBaseSrcImplExt + PushSrcImpl { } } -pub trait GLBaseSrcImplExt: ObjectSubclass { - fn parent_gl_start(&self) -> Result<(), LoggableError>; - - fn parent_gl_stop(&self); - - fn parent_fill_gl_memory(&self, memory: &GLMemory) -> Result<(), LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl GLBaseSrcImplExt for T { +pub trait GLBaseSrcImplExt: sealed::Sealed + ObjectSubclass { fn parent_gl_start(&self) -> Result<(), LoggableError> { unsafe { let data = Self::type_data(); @@ -81,6 +78,8 @@ impl GLBaseSrcImplExt for T { } } +impl GLBaseSrcImplExt for T {} + unsafe impl IsSubclassable for GLBaseSrc { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-gl/src/subclass/gl_filter.rs b/gstreamer-gl/src/subclass/gl_filter.rs index 2368a7f0b..504436fb0 100644 --- a/gstreamer-gl/src/subclass/gl_filter.rs +++ b/gstreamer-gl/src/subclass/gl_filter.rs @@ -46,28 +46,12 @@ pub trait GLFilterImpl: GLFilterImplExt + GLBaseFilterImpl { } } -pub trait GLFilterImplExt: ObjectSubclass { - fn parent_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError>; - - fn parent_filter(&self, input: &Buffer, output: &Buffer) -> Result<(), LoggableError>; - - fn parent_filter_texture( - &self, - input: &GLMemory, - output: &GLMemory, - ) -> Result<(), LoggableError>; - - fn parent_init_fbo(&self) -> Result<(), LoggableError>; - - fn parent_transform_internal_caps( - &self, - direction: PadDirection, - caps: &Caps, - filter_caps: Option<&Caps>, - ) -> Option; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl GLFilterImplExt for T { +pub trait GLFilterImplExt: sealed::Sealed + ObjectSubclass { fn parent_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError> { unsafe { let data = Self::type_data(); @@ -179,6 +163,8 @@ impl GLFilterImplExt for T { } } +impl GLFilterImplExt for T {} + unsafe impl IsSubclassable for GLFilter { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-pbutils/src/audio_visualizer.rs b/gstreamer-pbutils/src/audio_visualizer.rs index 9bb07d3ca..56ee22dde 100644 --- a/gstreamer-pbutils/src/audio_visualizer.rs +++ b/gstreamer-pbutils/src/audio_visualizer.rs @@ -5,22 +5,16 @@ use gst::prelude::*; use crate::{auto::AudioVisualizer, subclass::AudioVisualizerSetupToken}; -pub trait AudioVisualizerExtManual: 'static { - // rustdoc-stripper-ignore-next - /// Returns the number of samples per frame required before calling the render method - fn req_spf(&self) -> u32; - - // rustdoc-stripper-ignore-next - /// Modify the request of samples per frame required to be present in buffer before calling - /// the render method - fn set_req_spf(&self, spf: u32, token: &AudioVisualizerSetupToken); - - fn audio_info(&self) -> gst_audio::AudioInfo; - - fn video_info(&self) -> gst_video::VideoInfo; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl + ElementExt> AudioVisualizerExtManual for O { +pub trait AudioVisualizerExtManual: + sealed::Sealed + IsA + IsA + 'static +{ + // rustdoc-stripper-ignore-next + /// Returns the number of samples per frame required before calling the render method fn req_spf(&self) -> u32 { let sinkpad = self.static_pad("sink").expect("sink pad presence"); let _stream_lock = sinkpad.stream_lock(); @@ -29,6 +23,9 @@ impl + ElementExt> AudioVisualizerExtManual for O { unsafe { (*ptr).req_spf } } + // rustdoc-stripper-ignore-next + /// Modify the request of samples per frame required to be present in buffer before calling + /// the render method fn set_req_spf(&self, spf: u32, token: &AudioVisualizerSetupToken) { assert_eq!( self.as_ptr() as *mut ffi::GstAudioVisualizer, @@ -70,3 +67,5 @@ impl + ElementExt> AudioVisualizerExtManual for O { } } } + +impl + IsA> AudioVisualizerExtManual for O {} diff --git a/gstreamer-pbutils/src/discoverer_stream_info.rs b/gstreamer-pbutils/src/discoverer_stream_info.rs index a23474c9e..2e135d9a5 100644 --- a/gstreamer-pbutils/src/discoverer_stream_info.rs +++ b/gstreamer-pbutils/src/discoverer_stream_info.rs @@ -31,12 +31,14 @@ impl Iterator for Iter { impl std::iter::FusedIterator for Iter {} -pub trait DiscovererStreamInfoExtManual: 'static { - fn next_iter(&self) -> Iter; - fn previous_iter(&self) -> Iter; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> DiscovererStreamInfoExtManual for O { +pub trait DiscovererStreamInfoExtManual: + sealed::Sealed + IsA + 'static +{ fn next_iter(&self) -> Iter { Iter { stream_info: self.next(), @@ -52,6 +54,8 @@ impl> DiscovererStreamInfoExtManual for O { } } +impl> DiscovererStreamInfoExtManual for O {} + pub struct Debug<'a>(&'a DiscovererStreamInfo); impl<'a> fmt::Debug for Debug<'a> { diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index c5bdedeae..baf49aa01 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -8,17 +8,16 @@ use crate::auto::{ #[cfg(feature = "v1_20")] use crate::ElementProperties; -pub trait EncodingProfileExtManual { +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait EncodingProfileExtManual: sealed::Sealed + IsA + 'static { #[cfg(feature = "v1_20")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] #[doc(alias = "gst_encoding_profile_get_element_properties")] #[doc(alias = "get_element_properties")] - fn element_properties(&self) -> Option; -} - -impl> EncodingProfileExtManual for O { - #[cfg(feature = "v1_20")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] fn element_properties(&self) -> Option { unsafe { from_glib_full::<_, Option<_>>(ffi::gst_encoding_profile_get_element_properties( @@ -29,6 +28,8 @@ impl> EncodingProfileExtManual for O { } } +impl> EncodingProfileExtManual for O {} + trait EncodingProfileBuilderCommon { fn set_allow_dynamic_output(&self, allow_dynamic_output: bool); diff --git a/gstreamer-pbutils/src/subclass/audio_visualizer.rs b/gstreamer-pbutils/src/subclass/audio_visualizer.rs index 5d4b1c1e4..f3bf82eb1 100644 --- a/gstreamer-pbutils/src/subclass/audio_visualizer.rs +++ b/gstreamer-pbutils/src/subclass/audio_visualizer.rs @@ -28,22 +28,12 @@ pub trait AudioVisualizerImpl: AudioVisualizerImplExt + ElementImpl { } } -pub trait AudioVisualizerImplExt: ObjectSubclass { - fn parent_setup(&self, token: &AudioVisualizerSetupToken) -> Result<(), LoggableError>; - - fn parent_render( - &self, - audio_buffer: &gst::BufferRef, - video_frame: &mut gst_video::VideoFrameRef<&mut gst::BufferRef>, - ) -> Result<(), LoggableError>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AudioVisualizerImplExt for T { +pub trait AudioVisualizerImplExt: sealed::Sealed + ObjectSubclass { fn parent_setup(&self, token: &AudioVisualizerSetupToken) -> Result<(), LoggableError> { assert_eq!( self.obj().as_ptr() as *mut ffi::GstAudioVisualizer, @@ -125,6 +115,8 @@ impl AudioVisualizerImplExt for T { } } +impl AudioVisualizerImplExt for T {} + unsafe impl IsSubclassable for AudioVisualizer { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-play/src/subclass/play_video_renderer.rs b/gstreamer-play/src/subclass/play_video_renderer.rs index 5b96b1f41..793b94a8c 100644 --- a/gstreamer-play/src/subclass/play_video_renderer.rs +++ b/gstreamer-play/src/subclass/play_video_renderer.rs @@ -16,11 +16,12 @@ unsafe impl IsImplementable for PlayVideoRenderer { } } -pub trait PlayVideoRendererImplExt: ObjectSubclass { - fn parent_create_video_sink(&self, play: &Play) -> gst::Element; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl PlayVideoRendererImplExt for T { +pub trait PlayVideoRendererImplExt: sealed::Sealed + ObjectSubclass { fn parent_create_video_sink(&self, play: &Play) -> gst::Element { unsafe { let type_data = Self::type_data(); @@ -42,6 +43,8 @@ impl PlayVideoRendererImplExt for T { } } +impl PlayVideoRendererImplExt for T {} + unsafe extern "C" fn video_renderer_create_video_sink( video_renderer: *mut ffi::GstPlayVideoRenderer, play: *mut ffi::GstPlay, diff --git a/gstreamer-player/src/subclass/player_video_renderer.rs b/gstreamer-player/src/subclass/player_video_renderer.rs index a2ec0740a..915179f29 100644 --- a/gstreamer-player/src/subclass/player_video_renderer.rs +++ b/gstreamer-player/src/subclass/player_video_renderer.rs @@ -16,11 +16,12 @@ unsafe impl IsImplementable for PlayerVideoRender } } -pub trait PlayerVideoRendererImplExt: ObjectSubclass { - fn parent_create_video_sink(&self, player: &Player) -> gst::Element; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl PlayerVideoRendererImplExt for T { +pub trait PlayerVideoRendererImplExt: sealed::Sealed + ObjectSubclass { fn parent_create_video_sink(&self, player: &Player) -> gst::Element { unsafe { let type_data = Self::type_data(); @@ -42,6 +43,8 @@ impl PlayerVideoRendererImplExt for T { } } +impl PlayerVideoRendererImplExt for T {} + unsafe extern "C" fn video_renderer_create_video_sink( video_renderer: *mut ffi::GstPlayerVideoRenderer, player: *mut ffi::GstPlayer, diff --git a/gstreamer-rtp/src/rtp_base_depayload.rs b/gstreamer-rtp/src/rtp_base_depayload.rs index 1ed72030e..f30d7f341 100644 --- a/gstreamer-rtp/src/rtp_base_depayload.rs +++ b/gstreamer-rtp/src/rtp_base_depayload.rs @@ -2,13 +2,12 @@ use glib::object::IsA; use crate::RTPBaseDepayload; -pub trait RTPBaseDepayloadExtManual: 'static { - fn sink_pad(&self) -> &gst::Pad; - - fn src_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTPBaseDepayloadExtManual for O { +pub trait RTPBaseDepayloadExtManual: sealed::Sealed + IsA + 'static { fn sink_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstRTPBaseDepayload); @@ -23,3 +22,5 @@ impl> RTPBaseDepayloadExtManual for O { } } } + +impl> RTPBaseDepayloadExtManual for O {} diff --git a/gstreamer-rtp/src/rtp_base_payload.rs b/gstreamer-rtp/src/rtp_base_payload.rs index 34d176e92..ed9e93fff 100644 --- a/gstreamer-rtp/src/rtp_base_payload.rs +++ b/gstreamer-rtp/src/rtp_base_payload.rs @@ -4,21 +4,16 @@ use glib::{object::IsA, translate::*}; use crate::RTPBasePayload; -pub trait RTPBasePayloadExtManual: 'static { +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait RTPBasePayloadExtManual: sealed::Sealed + IsA + 'static { #[cfg(feature = "v1_20")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] #[doc(alias = "gst_rtp_base_payload_set_outcaps_structure")] #[doc(alias = "gst_rtp_base_payload_set_outcaps")] - fn set_outcaps(&self, s: Option<&gst::StructureRef>) -> Result<(), glib::error::BoolError>; - - fn sink_pad(&self) -> &gst::Pad; - - fn src_pad(&self) -> &gst::Pad; -} - -impl> RTPBasePayloadExtManual for O { - #[cfg(feature = "v1_20")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] fn set_outcaps(&self, s: Option<&gst::StructureRef>) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( @@ -47,3 +42,5 @@ impl> RTPBasePayloadExtManual for O { } } } + +impl> RTPBasePayloadExtManual for O {} diff --git a/gstreamer-rtp/src/rtp_header_extension.rs b/gstreamer-rtp/src/rtp_header_extension.rs index 04d154dae..4621411f0 100644 --- a/gstreamer-rtp/src/rtp_header_extension.rs +++ b/gstreamer-rtp/src/rtp_header_extension.rs @@ -2,35 +2,13 @@ use glib::{object::IsA, translate::*}; use crate::{RTPHeaderExtension, RTPHeaderExtensionFlags}; -pub trait RTPHeaderExtensionExtManual: 'static { - #[doc(alias = "gst_rtp_header_extension_read")] - fn read( - &self, - read_flags: RTPHeaderExtensionFlags, - data: &[u8], - buffer: &mut gst::BufferRef, - ) -> bool; - - #[doc(alias = "gst_rtp_header_extension_write")] - fn write( - &self, - input_meta: &gst::Buffer, - write_flags: RTPHeaderExtensionFlags, - output: &mut gst::BufferRef, - data: &mut [u8], - ) -> Result; - - #[doc(alias = "gst_rtp_header_extension_set_caps_from_attributes")] - fn set_caps_from_attributes(&self, caps: &mut gst::CapsRef) -> bool; - - #[doc(alias = "gst_rtp_header_extension_set_caps_from_attributes_helper")] - fn set_caps_from_attributes_helper(&self, caps: &mut gst::CapsRef, attributes: &str) -> bool; - - #[doc(alias = "gst_rtp_header_extension_update_non_rtp_src_caps")] - fn update_non_rtp_src_caps(&self, caps: &mut gst::CapsRef) -> bool; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTPHeaderExtensionExtManual for O { +pub trait RTPHeaderExtensionExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtp_header_extension_read")] fn read( &self, read_flags: RTPHeaderExtensionFlags, @@ -49,6 +27,7 @@ impl> RTPHeaderExtensionExtManual for O { } } + #[doc(alias = "gst_rtp_header_extension_write")] fn write( &self, input_meta: &gst::Buffer, @@ -75,6 +54,7 @@ impl> RTPHeaderExtensionExtManual for O { } } + #[doc(alias = "gst_rtp_header_extension_set_caps_from_attributes")] fn set_caps_from_attributes(&self, caps: &mut gst::CapsRef) -> bool { unsafe { from_glib(ffi::gst_rtp_header_extension_set_caps_from_attributes( @@ -84,6 +64,7 @@ impl> RTPHeaderExtensionExtManual for O { } } + #[doc(alias = "gst_rtp_header_extension_set_caps_from_attributes_helper")] fn set_caps_from_attributes_helper(&self, caps: &mut gst::CapsRef, attributes: &str) -> bool { unsafe { from_glib( @@ -96,6 +77,7 @@ impl> RTPHeaderExtensionExtManual for O { } } + #[doc(alias = "gst_rtp_header_extension_update_non_rtp_src_caps")] fn update_non_rtp_src_caps(&self, caps: &mut gst::CapsRef) -> bool { unsafe { from_glib(ffi::gst_rtp_header_extension_update_non_rtp_src_caps( @@ -105,3 +87,5 @@ impl> RTPHeaderExtensionExtManual for O { } } } + +impl> RTPHeaderExtensionExtManual for O {} diff --git a/gstreamer-rtp/src/subclass/rtp_base_depayload.rs b/gstreamer-rtp/src/subclass/rtp_base_depayload.rs index 1bb525d8a..380638655 100644 --- a/gstreamer-rtp/src/subclass/rtp_base_depayload.rs +++ b/gstreamer-rtp/src/subclass/rtp_base_depayload.rs @@ -28,20 +28,12 @@ pub trait RTPBaseDepayloadImpl: RTPBaseDepayloadImplExt + ElementImpl { } } -pub trait RTPBaseDepayloadImplExt: ObjectSubclass { - fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - - fn parent_handle_event(&self, event: gst::Event) -> bool; - - fn parent_packet_lost(&self, event: &gst::EventRef) -> bool; - - fn parent_process_rtp_packet( - &self, - rtp_buffer: &crate::RTPBuffer, - ) -> Option; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTPBaseDepayloadImplExt for T { +pub trait RTPBaseDepayloadImplExt: sealed::Sealed + ObjectSubclass { fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); @@ -126,6 +118,8 @@ impl RTPBaseDepayloadImplExt for T { } } +impl RTPBaseDepayloadImplExt for T {} + unsafe impl IsSubclassable for RTPBaseDepayload { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtp/src/subclass/rtp_base_payload.rs b/gstreamer-rtp/src/subclass/rtp_base_payload.rs index 5a6ac07ef..50407058b 100644 --- a/gstreamer-rtp/src/subclass/rtp_base_payload.rs +++ b/gstreamer-rtp/src/subclass/rtp_base_payload.rs @@ -31,22 +31,12 @@ pub trait RTPBasePayloadImpl: RTPBasePayloadImplExt + ElementImpl { } } -pub trait RTPBasePayloadImplExt: ObjectSubclass { - fn parent_caps(&self, pad: &gst::Pad, filter: Option<&gst::Caps>) -> gst::Caps; - - fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - - fn parent_handle_buffer(&self, buffer: gst::Buffer) - -> Result; - - fn parent_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool; - - fn parent_sink_event(&self, event: gst::Event) -> bool; - - fn parent_src_event(&self, event: gst::Event) -> bool; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTPBasePayloadImplExt for T { +pub trait RTPBasePayloadImplExt: sealed::Sealed + ObjectSubclass { fn parent_caps(&self, pad: &gst::Pad, filter: Option<&gst::Caps>) -> gst::Caps { unsafe { let data = Self::type_data(); @@ -175,6 +165,8 @@ impl RTPBasePayloadImplExt for T { } } +impl RTPBasePayloadImplExt for T {} + unsafe impl IsSubclassable for RTPBasePayload { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtp/src/subclass/rtp_header_extension.rs b/gstreamer-rtp/src/subclass/rtp_header_extension.rs index 1ba3bee90..006620451 100644 --- a/gstreamer-rtp/src/subclass/rtp_header_extension.rs +++ b/gstreamer-rtp/src/subclass/rtp_header_extension.rs @@ -55,39 +55,12 @@ pub trait RTPHeaderExtensionImpl: RTPHeaderExtensionImplExt + ElementImpl { } } -pub trait RTPHeaderExtensionImplExt: ObjectSubclass { - fn parent_supported_flags(&self) -> crate::RTPHeaderExtensionFlags; - fn parent_max_size(&self, input: &gst::BufferRef) -> usize; - fn parent_write( - &self, - input: &gst::BufferRef, - write_flags: crate::RTPHeaderExtensionFlags, - output: &mut gst::BufferRef, - output_data: &mut [u8], - ) -> Result; - fn parent_read( - &self, - read_flags: crate::RTPHeaderExtensionFlags, - input_data: &[u8], - output: &mut gst::BufferRef, - ) -> Result<(), gst::LoggableError>; - fn parent_set_non_rtp_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>; - fn parent_update_non_rtp_src_caps( - &self, - caps: &mut gst::CapsRef, - ) -> Result<(), gst::LoggableError>; - fn parent_set_attributes( - &self, - direction: crate::RTPHeaderExtensionDirection, - attributes: &str, - ) -> Result<(), gst::LoggableError>; - fn parent_set_caps_from_attributes( - &self, - caps: &mut gst::CapsRef, - ) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTPHeaderExtensionImplExt for T { +pub trait RTPHeaderExtensionImplExt: sealed::Sealed + ObjectSubclass { fn parent_supported_flags(&self) -> crate::RTPHeaderExtensionFlags { unsafe { let data = Self::type_data(); @@ -287,6 +260,8 @@ impl RTPHeaderExtensionImplExt for T { } } +impl RTPHeaderExtensionImplExt for T {} + unsafe impl IsSubclassable for crate::RTPHeaderExtension { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtsp-server/src/rtsp_address_pool.rs b/gstreamer-rtsp-server/src/rtsp_address_pool.rs index 4ee82fe62..e690a98eb 100644 --- a/gstreamer-rtsp-server/src/rtsp_address_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_address_pool.rs @@ -6,18 +6,13 @@ use glib::{prelude::*, translate::*}; use crate::{RTSPAddress, RTSPAddressPool, RTSPAddressPoolResult}; -pub trait RTSPAddressPoolExtManual: 'static { - #[doc(alias = "gst_rtsp_address_pool_reserve_address")] - fn reserve_address( - &self, - ip_address: &str, - port: u32, - n_ports: u32, - ttl: u32, - ) -> Result; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPAddressPoolExtManual for O { +pub trait RTSPAddressPoolExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_address_pool_reserve_address")] fn reserve_address( &self, ip_address: &str, @@ -42,3 +37,5 @@ impl> RTSPAddressPoolExtManual for O { } } } + +impl> RTSPAddressPoolExtManual for O {} diff --git a/gstreamer-rtsp-server/src/rtsp_auth.rs b/gstreamer-rtsp-server/src/rtsp_auth.rs index 3b02973ac..8a6a38a66 100644 --- a/gstreamer-rtsp-server/src/rtsp_auth.rs +++ b/gstreamer-rtsp-server/src/rtsp_auth.rs @@ -10,27 +10,13 @@ use glib::{ use crate::{RTSPAuth, RTSPToken}; -pub trait RTSPAuthExtManual: 'static { - #[doc(alias = "gst_rtsp_auth_set_default_token")] - fn set_default_token(&self, token: Option<&mut RTSPToken>); - - fn connect_accept_certificate< - F: Fn( - &Self, - &gio::TlsConnection, - &gio::TlsCertificate, - gio::TlsCertificateFlags, - ) -> Result<(), gst::LoggableError> - + Send - + Sync - + 'static, - >( - &self, - f: F, - ) -> SignalHandlerId; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPAuthExtManual for O { +pub trait RTSPAuthExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_auth_set_default_token")] fn set_default_token(&self, mut token: Option<&mut RTSPToken>) { unsafe { ffi::gst_rtsp_auth_set_default_token( @@ -68,6 +54,8 @@ impl> RTSPAuthExtManual for O { } } +impl> RTSPAuthExtManual for O {} + unsafe extern "C" fn accept_certificate_trampoline< P, F: Fn( diff --git a/gstreamer-rtsp-server/src/rtsp_client.rs b/gstreamer-rtsp-server/src/rtsp_client.rs index a243c876e..25168d454 100644 --- a/gstreamer-rtsp-server/src/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/rtsp_client.rs @@ -4,12 +4,13 @@ use glib::{prelude::*, source::SourceId, translate::*}; use crate::RTSPClient; -pub trait RTSPClientExtManual: 'static { - #[doc(alias = "gst_rtsp_client_attach")] - fn attach(&self, context: Option<&glib::MainContext>) -> SourceId; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPClientExtManual for O { +pub trait RTSPClientExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_client_attach")] fn attach(&self, context: Option<&glib::MainContext>) -> SourceId { unsafe { from_glib(ffi::gst_rtsp_client_attach( @@ -19,3 +20,5 @@ impl> RTSPClientExtManual for O { } } } + +impl> RTSPClientExtManual for O {} diff --git a/gstreamer-rtsp-server/src/rtsp_media.rs b/gstreamer-rtsp-server/src/rtsp_media.rs index 65c26890e..809c9274e 100644 --- a/gstreamer-rtsp-server/src/rtsp_media.rs +++ b/gstreamer-rtsp-server/src/rtsp_media.rs @@ -4,12 +4,13 @@ use glib::{prelude::*, translate::*}; use crate::RTSPMedia; -pub trait RTSPMediaExtManual: 'static { - #[doc(alias = "gst_rtsp_media_take_pipeline")] - fn take_pipeline(&self, pipeline: impl IsA); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPMediaExtManual for O { +pub trait RTSPMediaExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_media_take_pipeline")] fn take_pipeline(&self, pipeline: impl IsA) { unsafe { let pipeline = pipeline.upcast().into_glib_ptr(); @@ -22,3 +23,5 @@ impl> RTSPMediaExtManual for O { } } } + +impl> RTSPMediaExtManual for O {} diff --git a/gstreamer-rtsp-server/src/rtsp_media_factory.rs b/gstreamer-rtsp-server/src/rtsp_media_factory.rs index cb96441ed..03279e920 100644 --- a/gstreamer-rtsp-server/src/rtsp_media_factory.rs +++ b/gstreamer-rtsp-server/src/rtsp_media_factory.rs @@ -4,12 +4,13 @@ use glib::{prelude::*, translate::*}; use crate::RTSPMediaFactory; -pub trait RTSPMediaFactoryExtManual: 'static { - #[doc(alias = "gst_rtsp_media_factory_add_role_from_structure")] - fn add_role_from_structure(&self, structure: &gst::StructureRef); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPMediaFactoryExtManual for O { +pub trait RTSPMediaFactoryExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_media_factory_add_role_from_structure")] fn add_role_from_structure(&self, structure: &gst::StructureRef) { unsafe { ffi::gst_rtsp_media_factory_add_role_from_structure( @@ -19,3 +20,5 @@ impl> RTSPMediaFactoryExtManual for O { } } } + +impl> RTSPMediaFactoryExtManual for O {} diff --git a/gstreamer-rtsp-server/src/rtsp_onvif_media_factory.rs b/gstreamer-rtsp-server/src/rtsp_onvif_media_factory.rs index f0c38b104..204b17ab8 100644 --- a/gstreamer-rtsp-server/src/rtsp_onvif_media_factory.rs +++ b/gstreamer-rtsp-server/src/rtsp_onvif_media_factory.rs @@ -4,12 +4,15 @@ use glib::{prelude::*, translate::*}; use crate::{RTSPContext, RTSPOnvifMediaFactory}; -pub trait RTSPOnvifMediaFactoryExtManual: 'static { - #[doc(alias = "gst_rtsp_onvif_media_factory_requires_backchannel")] - fn requires_backchannel(&self, ctx: &RTSPContext) -> bool; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPOnvifMediaFactoryExtManual for O { +pub trait RTSPOnvifMediaFactoryExtManual: + sealed::Sealed + IsA + 'static +{ + #[doc(alias = "gst_rtsp_onvif_media_factory_requires_backchannel")] fn requires_backchannel(&self, ctx: &RTSPContext) -> bool { skip_assert_initialized!(); unsafe { @@ -23,3 +26,5 @@ impl> RTSPOnvifMediaFactoryExtManual for O { } } } + +impl> RTSPOnvifMediaFactoryExtManual for O {} diff --git a/gstreamer-rtsp-server/src/rtsp_server.rs b/gstreamer-rtsp-server/src/rtsp_server.rs index 27db437f8..9305a1d5d 100644 --- a/gstreamer-rtsp-server/src/rtsp_server.rs +++ b/gstreamer-rtsp-server/src/rtsp_server.rs @@ -4,15 +4,13 @@ use glib::{prelude::*, source::SourceId, translate::*}; use crate::RTSPServer; -pub trait RTSPServerExtManual: 'static { - #[doc(alias = "gst_rtsp_server_attach")] - fn attach( - &self, - context: Option<&glib::MainContext>, - ) -> Result; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPServerExtManual for O { +pub trait RTSPServerExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_server_attach")] fn attach( &self, context: Option<&glib::MainContext>, @@ -30,3 +28,5 @@ impl> RTSPServerExtManual for O { } } } + +impl> RTSPServerExtManual for O {} diff --git a/gstreamer-rtsp-server/src/rtsp_session.rs b/gstreamer-rtsp-server/src/rtsp_session.rs index bce08806e..387ae09ad 100644 --- a/gstreamer-rtsp-server/src/rtsp_session.rs +++ b/gstreamer-rtsp-server/src/rtsp_session.rs @@ -6,13 +6,14 @@ use glib::{prelude::*, translate::*}; use crate::{RTSPSession, RTSPSessionMedia}; -pub trait RTSPSessionExtManual: 'static { - #[doc(alias = "gst_rtsp_session_dup_media")] - #[doc(alias = "gst_rtsp_session_get_media")] - fn media(&self, path: &str) -> (Option, i32); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPSessionExtManual for O { +pub trait RTSPSessionExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_session_dup_media")] + #[doc(alias = "gst_rtsp_session_get_media")] fn media(&self, path: &str) -> (Option, i32) { #[cfg(feature = "v1_20")] unsafe { @@ -36,3 +37,5 @@ impl> RTSPSessionExtManual for O { } } } + +impl> RTSPSessionExtManual for O {} diff --git a/gstreamer-rtsp-server/src/rtsp_session_pool.rs b/gstreamer-rtsp-server/src/rtsp_session_pool.rs index e0083cbc8..52b9fe4ab 100644 --- a/gstreamer-rtsp-server/src/rtsp_session_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_session_pool.rs @@ -33,14 +33,13 @@ fn into_raw_watch Continue + Send + 'static>(func: Box::into_raw(func) as gpointer } -pub trait RTSPSessionPoolExtManual: 'static { - #[doc(alias = "gst_rtsp_session_pool_create_watch")] - fn create_watch(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source - where - F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> RTSPSessionPoolExtManual for O { +pub trait RTSPSessionPoolExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_rtsp_session_pool_create_watch")] fn create_watch(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source where F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static, @@ -67,3 +66,5 @@ impl> RTSPSessionPoolExtManual for O { } } } + +impl> RTSPSessionPoolExtManual for O {} diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs index 98f26dcb8..2d279a5b0 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs @@ -155,102 +155,12 @@ pub trait RTSPClientImpl: RTSPClientImplExt + ObjectImpl + Send + Sync { } } -pub trait RTSPClientImplExt: ObjectSubclass { - fn parent_create_sdp(&self, media: &crate::RTSPMedia) -> Option; - - fn parent_configure_client_media( - &self, - media: &crate::RTSPMedia, - stream: &crate::RTSPStream, - ctx: &crate::RTSPContext, - ) -> Result<(), gst::LoggableError>; - - // TODO: configure_client_transport - - fn parent_params_set(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPResult; - - fn parent_params_get(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPResult; - - fn parent_make_path_from_uri(&self, url: &gst_rtsp::RTSPUrl) -> Option; - - fn parent_closed(&self); - - fn parent_new_session(&self, session: &crate::RTSPSession); - - fn parent_options_request(&self, ctx: &crate::RTSPContext); - - fn parent_describe_request(&self, ctx: &crate::RTSPContext); - - fn parent_setup_request(&self, ctx: &crate::RTSPContext); - - fn parent_play_request(&self, ctx: &crate::RTSPContext); - - fn parent_pause_request(&self, ctx: &crate::RTSPContext); - - fn parent_teardown_request(&self, ctx: &crate::RTSPContext); - - fn parent_set_parameter_request(&self, ctx: &crate::RTSPContext); - - fn parent_parameter_request(&self, ctx: &crate::RTSPContext); - - fn parent_announce_request(&self, ctx: &crate::RTSPContext); - - fn parent_record_request(&self, ctx: &crate::RTSPContext); - - fn parent_handle_response(&self, ctx: &crate::RTSPContext); - - // TODO: tunnel_http_response - // TODO: send_message - - fn parent_handle_sdp( - &self, - ctx: &crate::RTSPContext, - media: &crate::RTSPMedia, - sdp: &gst_sdp::SDPMessageRef, - ) -> Result<(), gst::LoggableError>; - - fn parent_check_requirements( - &self, - ctx: &crate::RTSPContext, - arr: &[String], - ) -> Option; - - fn parent_pre_options_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_describe_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_setup_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_play_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_pause_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_teardown_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_set_parameter_request( - &self, - ctx: &crate::RTSPContext, - ) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_get_parameter_request( - &self, - ctx: &crate::RTSPContext, - ) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_announce_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - fn parent_pre_record_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; - - #[cfg(feature = "v1_22")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] - fn parent_adjust_error_code( - &self, - ctx: &crate::RTSPContext, - status_code: gst_rtsp::RTSPStatusCode, - ) -> gst_rtsp::RTSPStatusCode; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTSPClientImplExt for T { +pub trait RTSPClientImplExt: sealed::Sealed + ObjectSubclass { fn parent_create_sdp(&self, media: &crate::RTSPMedia) -> Option { unsafe { let data = Self::type_data(); @@ -732,6 +642,9 @@ impl RTSPClientImplExt for T { } } } + +impl RTSPClientImplExt for T {} + unsafe impl IsSubclassable for RTSPClient { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media.rs index 132931996..d15c1a18d 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media.rs @@ -98,33 +98,12 @@ pub trait RTSPMediaImpl: RTSPMediaImplExt + ObjectImpl + Send + Sync { } } -pub trait RTSPMediaImplExt: ObjectSubclass { - fn parent_handle_message(&self, message: &gst::MessageRef) -> bool; - fn parent_prepare(&self, thread: &RTSPThread) -> Result<(), gst::LoggableError>; - fn parent_unprepare(&self) -> Result<(), gst::LoggableError>; - fn parent_suspend(&self) -> Result<(), gst::LoggableError>; - fn parent_unsuspend(&self) -> Result<(), gst::LoggableError>; - // TODO missing: convert_range - - fn parent_query_position(&self) -> Option; - fn parent_query_stop(&self) -> Option; - fn parent_create_rtpbin(&self) -> Option; - fn parent_setup_rtpbin(&self, rtpbin: &gst::Element) -> Result<(), gst::LoggableError>; - fn parent_setup_sdp( - &self, - sdp: &mut gst_sdp::SDPMessageRef, - info: &SDPInfo, - ) -> Result<(), gst::LoggableError>; - fn parent_new_stream(&self, stream: &crate::RTSPStream); - fn parent_removed_stream(&self, stream: &crate::RTSPStream); - fn parent_prepared(&self); - fn parent_unprepared(&self); - fn parent_target_state(&self, state: gst::State); - fn parent_new_state(&self, state: gst::State); - fn parent_handle_sdp(&self, sdp: &gst_sdp::SDPMessageRef) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTSPMediaImplExt for T { +pub trait RTSPMediaImplExt: sealed::Sealed + ObjectSubclass { fn parent_handle_message(&self, message: &gst::MessageRef) -> bool { unsafe { let data = Self::type_data(); @@ -208,7 +187,6 @@ impl RTSPMediaImplExt for T { } // TODO missing: convert_range - fn parent_query_position(&self) -> Option { unsafe { use std::mem; @@ -419,6 +397,9 @@ impl RTSPMediaImplExt for T { } } } + +impl RTSPMediaImplExt for T {} + unsafe impl IsSubclassable for RTSPMedia { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs index bc2ae465b..0f298dee0 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs @@ -36,22 +36,12 @@ pub trait RTSPMediaFactoryImpl: RTSPMediaFactoryImplExt + ObjectImpl + Send + Sy } } -pub trait RTSPMediaFactoryImplExt: ObjectSubclass { - fn parent_gen_key(&self, url: &gst_rtsp::RTSPUrl) -> Option; - - fn parent_create_element(&self, url: &gst_rtsp::RTSPUrl) -> Option; - - fn parent_construct(&self, url: &gst_rtsp::RTSPUrl) -> Option; - - fn parent_create_pipeline(&self, media: &crate::RTSPMedia) -> Option; - - fn parent_configure(&self, media: &crate::RTSPMedia); - - fn parent_media_constructed(&self, media: &crate::RTSPMedia); - fn parent_media_configure(&self, media: &crate::RTSPMedia); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTSPMediaFactoryImplExt for T { +pub trait RTSPMediaFactoryImplExt: sealed::Sealed + ObjectSubclass { fn parent_gen_key(&self, url: &gst_rtsp::RTSPUrl) -> Option { unsafe { let data = Self::type_data(); @@ -182,6 +172,8 @@ impl RTSPMediaFactoryImplExt for T { } } } + +impl RTSPMediaFactoryImplExt for T {} unsafe impl IsSubclassable for RTSPMediaFactory { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs b/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs index 75e1fb59f..923d0fcd5 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_mount_points.rs @@ -11,11 +11,12 @@ pub trait RTSPMountPointsImpl: RTSPMountPointsImplExt + ObjectImpl + Send + Sync } } -pub trait RTSPMountPointsImplExt: ObjectSubclass { - fn parent_make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTSPMountPointsImplExt for T { +pub trait RTSPMountPointsImplExt: sealed::Sealed + ObjectSubclass { fn parent_make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option { unsafe { let data = Self::type_data(); @@ -34,6 +35,8 @@ impl RTSPMountPointsImplExt for T { } } +impl RTSPMountPointsImplExt for T {} + unsafe impl IsSubclassable for RTSPMountPoints { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs index 35c309524..f2e751580 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs @@ -13,11 +13,12 @@ pub trait RTSPOnvifMediaFactoryImpl: } } -pub trait RTSPOnvifMediaFactoryImplExt: ObjectSubclass { - fn parent_has_backchannel_support(&self) -> bool; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl RTSPOnvifMediaFactoryImplExt for T { +pub trait RTSPOnvifMediaFactoryImplExt: sealed::Sealed + ObjectSubclass { fn parent_has_backchannel_support(&self) -> bool { unsafe { let data = Self::type_data(); @@ -37,6 +38,8 @@ impl RTSPOnvifMediaFactoryImplExt for T { } } +impl RTSPOnvifMediaFactoryImplExt for T {} + unsafe impl IsSubclassable for RTSPOnvifMediaFactory { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_server.rs b/gstreamer-rtsp-server/src/subclass/rtsp_server.rs index 2e33d2c9d..949aece67 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_server.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_server.rs @@ -14,7 +14,12 @@ pub trait RTSPServerImpl: RTSPServerImplExt + ObjectImpl + Send + Sync { } } -pub trait RTSPServerImplExt: ObjectSubclass { +mod sealed { + pub trait Sealed {} + impl Sealed for T {} +} + +pub trait RTSPServerImplExt: sealed::Sealed + ObjectSubclass { fn parent_create_client(&self) -> Option; fn parent_client_connected(&self, client: &crate::RTSPClient); diff --git a/gstreamer-video/src/subclass/navigation.rs b/gstreamer-video/src/subclass/navigation.rs index 7a23aa485..333f3e08e 100644 --- a/gstreamer-video/src/subclass/navigation.rs +++ b/gstreamer-video/src/subclass/navigation.rs @@ -16,19 +16,12 @@ pub trait NavigationImpl: ObjectImpl { } } -pub trait NavigationImplExt: ObjectSubclass { - fn parent_send_event(&self, structure: gst::Structure); - - #[cfg(feature = "v1_22")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] - fn parent_send_event_simple(&self, event: gst::Event) { - if let Some(structure) = event.structure() { - self.parent_send_event(structure.to_owned()); - } - } +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl NavigationImplExt for T { +pub trait NavigationImplExt: sealed::Sealed + ObjectSubclass { fn parent_send_event(&self, structure: gst::Structure) { unsafe { let type_data = Self::type_data(); @@ -68,6 +61,8 @@ impl NavigationImplExt for T { } } +impl NavigationImplExt for T {} + unsafe impl IsImplementable for Navigation { #[cfg(not(any(feature = "v1_22", docsrs)))] fn interface_init(iface: &mut glib::Interface) { diff --git a/gstreamer-video/src/subclass/video_aggregator.rs b/gstreamer-video/src/subclass/video_aggregator.rs index 6c16c79f0..88be6ad41 100644 --- a/gstreamer-video/src/subclass/video_aggregator.rs +++ b/gstreamer-video/src/subclass/video_aggregator.rs @@ -30,25 +30,12 @@ pub trait VideoAggregatorImpl: VideoAggregatorImplExt + AggregatorImpl { self.parent_find_best_format(downstream_caps) } } - -pub trait VideoAggregatorImplExt: ObjectSubclass { - fn parent_update_caps(&self, caps: &gst::Caps) -> Result; - - fn parent_aggregate_frames( - &self, - token: &AggregateFramesToken, - outbuf: &mut gst::BufferRef, - ) -> Result; - - fn parent_create_output_buffer(&self) -> Result, gst::FlowError>; - - fn parent_find_best_format( - &self, - downstream_caps: &gst::Caps, - ) -> Option<(crate::VideoInfo, bool)>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl VideoAggregatorImplExt for T { +pub trait VideoAggregatorImplExt: sealed::Sealed + ObjectSubclass { fn parent_update_caps(&self, caps: &gst::Caps) -> Result { unsafe { let data = Self::type_data(); @@ -155,6 +142,8 @@ impl VideoAggregatorImplExt for T { } } +impl VideoAggregatorImplExt for T {} + unsafe impl IsSubclassable for VideoAggregator { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-video/src/subclass/video_aggregator_pad.rs b/gstreamer-video/src/subclass/video_aggregator_pad.rs index c1c9f6cbb..52d325d68 100644 --- a/gstreamer-video/src/subclass/video_aggregator_pad.rs +++ b/gstreamer-video/src/subclass/video_aggregator_pad.rs @@ -31,25 +31,12 @@ pub trait VideoAggregatorPadImpl: VideoAggregatorPadImplExt + AggregatorPadImpl } } -pub trait VideoAggregatorPadImplExt: ObjectSubclass { - fn parent_update_conversion_info(&self); - - fn parent_prepare_frame( - &self, - aggregator: &crate::VideoAggregator, - token: &AggregateFramesToken, - buffer: &gst::Buffer, - ) -> Option>; - - fn parent_clean_frame( - &self, - aggregator: &crate::VideoAggregator, - token: &AggregateFramesToken, - frame: Option>, - ); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl VideoAggregatorPadImplExt for T { +pub trait VideoAggregatorPadImplExt: ObjectSubclass { fn parent_update_conversion_info(&self) { unsafe { let data = Self::type_data(); @@ -137,6 +124,8 @@ impl VideoAggregatorPadImplExt for T { } } +impl VideoAggregatorPadImplExt for T {} + unsafe impl IsSubclassable for VideoAggregatorPad { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index 8206b0d3e..3758bef79 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -106,71 +106,11 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl { self.parent_handle_missing_data(timestamp, duration) } } - -pub trait VideoDecoderImplExt: ObjectSubclass { - fn parent_open(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_close(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_finish(&self) -> Result; - - fn parent_drain(&self) -> Result; - - fn parent_set_format( - &self, - state: &VideoCodecState<'static, Readable>, - ) -> Result<(), gst::LoggableError>; - - fn parent_parse( - &self, - frame: &VideoCodecFrame, - adapter: &gst_base::Adapter, - at_eos: bool, - ) -> Result; - - fn parent_handle_frame( - &self, - frame: VideoCodecFrame, - ) -> Result; - - fn parent_flush(&self) -> bool; - - fn parent_negotiate(&self) -> Result<(), gst::LoggableError>; - - fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps; - - fn parent_sink_event(&self, event: gst::Event) -> bool; - - fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_src_event(&self, event: gst::Event) -> bool; - - fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_propose_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - #[cfg(feature = "v1_20")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] - fn parent_handle_missing_data( - &self, - timestamp: gst::ClockTime, - duration: Option, - ) -> bool; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } - -impl VideoDecoderImplExt for T { +pub trait VideoDecoderImplExt: sealed::Sealed + ObjectSubclass { fn parent_open(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -587,6 +527,8 @@ impl VideoDecoderImplExt for T { } } +impl VideoDecoderImplExt for T {} + unsafe impl IsSubclassable for VideoDecoder { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index 8c3c240a0..8fd9ff335 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -84,53 +84,12 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl { } } -pub trait VideoEncoderImplExt: ObjectSubclass { - fn parent_open(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_close(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_start(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_stop(&self) -> Result<(), gst::ErrorMessage>; - - fn parent_finish(&self) -> Result; - - fn parent_set_format( - &self, - state: &VideoCodecState<'static, Readable>, - ) -> Result<(), gst::LoggableError>; - - fn parent_handle_frame( - &self, - frame: VideoCodecFrame, - ) -> Result; - - fn parent_flush(&self) -> bool; - - fn parent_negotiate(&self) -> Result<(), gst::LoggableError>; - - fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps; - - fn parent_sink_event(&self, event: gst::Event) -> bool; - - fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_src_event(&self, event: gst::Event) -> bool; - - fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool; - - fn parent_propose_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; - - fn parent_decide_allocation( - &self, - query: &mut gst::query::Allocation, - ) -> Result<(), gst::LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl VideoEncoderImplExt for T { +pub trait VideoEncoderImplExt: sealed::Sealed + ObjectSubclass { fn parent_open(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); @@ -478,6 +437,8 @@ impl VideoEncoderImplExt for T { } } +impl VideoEncoderImplExt for T {} + unsafe impl IsSubclassable for VideoEncoder { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-video/src/subclass/video_filter.rs b/gstreamer-video/src/subclass/video_filter.rs index d3f277ec1..a9b91d454 100644 --- a/gstreamer-video/src/subclass/video_filter.rs +++ b/gstreamer-video/src/subclass/video_filter.rs @@ -39,33 +39,12 @@ pub trait VideoFilterImpl: VideoFilterImplExt + BaseTransformImpl { } } -pub trait VideoFilterImplExt: ObjectSubclass { - fn parent_set_info( - &self, - incaps: &gst::Caps, - in_info: &VideoInfo, - outcaps: &gst::Caps, - out_info: &VideoInfo, - ) -> Result<(), gst::LoggableError>; - - fn parent_transform_frame( - &self, - inframe: &VideoFrameRef<&gst::BufferRef>, - outframe: &mut VideoFrameRef<&mut gst::BufferRef>, - ) -> Result; - - fn parent_transform_frame_ip( - &self, - frame: &mut VideoFrameRef<&mut gst::BufferRef>, - ) -> Result; - - fn parent_transform_frame_ip_passthrough( - &self, - frame: &VideoFrameRef<&gst::BufferRef>, - ) -> Result; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl VideoFilterImplExt for T { +pub trait VideoFilterImplExt: sealed::Sealed + ObjectSubclass { fn parent_set_info( &self, incaps: &gst::Caps, @@ -192,6 +171,8 @@ impl VideoFilterImplExt for T { } } +impl VideoFilterImplExt for T {} + unsafe impl IsSubclassable for VideoFilter { fn class_init(klass: &mut glib::Class) { use gst_base::subclass::base_transform::BaseTransformMode; diff --git a/gstreamer-video/src/subclass/video_sink.rs b/gstreamer-video/src/subclass/video_sink.rs index 9683397d7..805169c6f 100644 --- a/gstreamer-video/src/subclass/video_sink.rs +++ b/gstreamer-video/src/subclass/video_sink.rs @@ -11,11 +11,12 @@ pub trait VideoSinkImpl: VideoSinkImplExt + BaseSinkImpl + ElementImpl { } } -pub trait VideoSinkImplExt: ObjectSubclass { - fn parent_show_frame(&self, buffer: &gst::Buffer) -> Result; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl VideoSinkImplExt for T { +pub trait VideoSinkImplExt: sealed::Sealed + ObjectSubclass { fn parent_show_frame(&self, buffer: &gst::Buffer) -> Result { unsafe { let data = Self::type_data(); @@ -33,6 +34,8 @@ impl VideoSinkImplExt for T { } } +impl VideoSinkImplExt for T {} + unsafe impl IsSubclassable for VideoSink { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer-video/src/video_aggregator.rs b/gstreamer-video/src/video_aggregator.rs index 6ae4f3817..306b49dab 100644 --- a/gstreamer-video/src/video_aggregator.rs +++ b/gstreamer-video/src/video_aggregator.rs @@ -3,11 +3,12 @@ use gst::prelude::*; use crate::auto::VideoAggregator; -pub trait VideoAggregatorExtManual: 'static { - fn video_info(&self) -> Option; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> VideoAggregatorExtManual for O { +pub trait VideoAggregatorExtManual: sealed::Sealed + IsA + 'static { fn video_info(&self) -> Option { unsafe { let ptr = self.as_ptr() as *mut ffi::GstVideoAggregator; @@ -25,3 +26,5 @@ impl> VideoAggregatorExtManual for O { } } } + +impl> VideoAggregatorExtManual for O {} diff --git a/gstreamer-video/src/video_aggregator_convert_pad.rs b/gstreamer-video/src/video_aggregator_convert_pad.rs index 9dbf4d356..1b66c4819 100644 --- a/gstreamer-video/src/video_aggregator_convert_pad.rs +++ b/gstreamer-video/src/video_aggregator_convert_pad.rs @@ -9,26 +9,21 @@ use glib::{ use crate::auto::VideoAggregatorConvertPad; -pub trait VideoAggregatorConvertPadExtManual: 'static { - #[doc(alias = "converter-config")] - fn converter_config(&self) -> Option; - - #[doc(alias = "converter-config")] - fn set_converter_config(&self, converter_config: Option<&crate::VideoConverterConfig>); - - #[doc(alias = "converter-config")] - fn connect_converter_config_notify( - &self, - f: F, - ) -> SignalHandlerId; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> VideoAggregatorConvertPadExtManual for O { +pub trait VideoAggregatorConvertPadExtManual: + sealed::Sealed + IsA + 'static +{ + #[doc(alias = "converter-config")] fn converter_config(&self) -> Option { glib::ObjectExt::property::>(self.as_ref(), "converter-config") .map(|c| c.try_into().unwrap()) } + #[doc(alias = "converter-config")] fn set_converter_config(&self, converter_config: Option<&crate::VideoConverterConfig>) { glib::ObjectExt::set_property( self.as_ref(), @@ -37,6 +32,7 @@ impl> VideoAggregatorConvertPadExtManual for O ) } + #[doc(alias = "converter-config")] fn connect_converter_config_notify( &self, f: F, @@ -65,3 +61,5 @@ impl> VideoAggregatorConvertPadExtManual for O } } } + +impl> VideoAggregatorConvertPadExtManual for O {} diff --git a/gstreamer-video/src/video_aggregator_pad.rs b/gstreamer-video/src/video_aggregator_pad.rs index 500e41438..db3317f08 100644 --- a/gstreamer-video/src/video_aggregator_pad.rs +++ b/gstreamer-video/src/video_aggregator_pad.rs @@ -3,23 +3,13 @@ use gst::prelude::*; use crate::{auto::VideoAggregatorPad, subclass::AggregateFramesToken}; -pub trait VideoAggregatorPadExtManual: 'static { - #[doc(alias = "gst_video_aggregator_pad_has_current_buffer")] - fn has_current_buffer(&self, token: &AggregateFramesToken) -> bool; - - #[doc(alias = "gst_video_aggregator_pad_get_current_buffer")] - fn current_buffer(&self, token: &AggregateFramesToken) -> Option; - - #[doc(alias = "gst_video_aggregator_pad_get_prepared_frame")] - fn prepared_frame<'a>( - &self, - token: &'a AggregateFramesToken, - ) -> Option>; - - fn video_info(&self) -> Option; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> VideoAggregatorPadExtManual for O { +pub trait VideoAggregatorPadExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_video_aggregator_pad_has_current_buffer")] fn has_current_buffer(&self, _token: &AggregateFramesToken) -> bool { unsafe { from_glib(ffi::gst_video_aggregator_pad_has_current_buffer( @@ -28,6 +18,7 @@ impl> VideoAggregatorPadExtManual for O { } } + #[doc(alias = "gst_video_aggregator_pad_get_current_buffer")] fn current_buffer(&self, _token: &AggregateFramesToken) -> Option { unsafe { from_glib_none(ffi::gst_video_aggregator_pad_get_current_buffer( @@ -36,6 +27,7 @@ impl> VideoAggregatorPadExtManual for O { } } + #[doc(alias = "gst_video_aggregator_pad_get_prepared_frame")] fn prepared_frame<'a>( &self, _token: &'a AggregateFramesToken, @@ -69,3 +61,5 @@ impl> VideoAggregatorPadExtManual for O { } } } + +impl> VideoAggregatorPadExtManual for O {} diff --git a/gstreamer-video/src/video_decoder.rs b/gstreamer-video/src/video_decoder.rs index 480b85d42..68b77f08c 100644 --- a/gstreamer-video/src/video_decoder.rs +++ b/gstreamer-video/src/video_decoder.rs @@ -27,75 +27,12 @@ extern "C" { ) -> gst::ffi::GstFlowReturn; } -pub trait VideoDecoderExtManual: 'static { - #[doc(alias = "gst_video_decoder_allocate_output_frame")] - fn allocate_output_frame( - &self, - frame: &mut VideoCodecFrame, - params: Option<&gst::BufferPoolAcquireParams>, - ) -> Result; - - #[doc(alias = "get_frame")] - fn frame(&self, frame_number: i32) -> Option; - #[doc(alias = "get_frames")] - fn frames(&self) -> Vec; - #[doc(alias = "get_oldest_frame")] - fn oldest_frame(&self) -> Option; - - #[doc(alias = "get_allocator")] - fn allocator(&self) -> (Option, gst::AllocationParams); - - #[doc(alias = "get_latency")] - fn latency(&self) -> (gst::ClockTime, Option); - fn set_latency( - &self, - min_latency: gst::ClockTime, - max_latency: impl Into>, - ); - - #[doc(alias = "get_output_state")] - fn output_state(&self) -> Option>; - fn set_output_state( - &self, - fmt: VideoFormat, - width: u32, - height: u32, - reference: Option<&VideoCodecState>, - ) -> Result, gst::FlowError>; - #[cfg(feature = "v1_16")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] - fn set_interlaced_output_state( - &self, - fmt: VideoFormat, - mode: VideoInterlaceMode, - width: u32, - height: u32, - reference: Option<&VideoCodecState>, - ) -> Result, gst::FlowError>; - - fn negotiate<'a>( - &'a self, - output_state: VideoCodecState<'a, InNegotiation<'a>>, - ) -> Result<(), gst::FlowError>; - - #[allow(clippy::too_many_arguments)] - fn error( - &self, - weight: i32, - code: T, - message: Option<&str>, - debug: Option<&str>, - file: &str, - function: &str, - line: u32, - ) -> Result; - - fn sink_pad(&self) -> &gst::Pad; - - fn src_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> VideoDecoderExtManual for O { +pub trait VideoDecoderExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gst_video_decoder_allocate_output_frame")] fn allocate_output_frame( &self, @@ -112,6 +49,55 @@ impl> VideoDecoderExtManual for O { } } + #[doc(alias = "get_frame")] + #[doc(alias = "gst_video_decoder_get_frame")] + fn frame(&self, frame_number: i32) -> Option { + let frame = unsafe { + ffi::gst_video_decoder_get_frame(self.as_ref().to_glib_none().0, frame_number) + }; + + if frame.is_null() { + None + } else { + unsafe { Some(VideoCodecFrame::new(frame, self.as_ref())) } + } + } + + #[doc(alias = "get_frames")] + #[doc(alias = "gst_video_decoder_get_frames")] + fn frames(&self) -> Vec { + unsafe { + let frames = ffi::gst_video_decoder_get_frames(self.as_ref().to_glib_none().0); + let mut iter: *const glib::ffi::GList = frames; + let mut vec = Vec::new(); + + while !iter.is_null() { + let frame_ptr = Ptr::from((*iter).data); + /* transfer ownership of the frame */ + let frame = VideoCodecFrame::new(frame_ptr, self.as_ref()); + vec.push(frame); + iter = (*iter).next; + } + + glib::ffi::g_list_free(frames); + vec + } + } + + #[doc(alias = "get_oldest_frame")] + #[doc(alias = "gst_video_decoder_get_oldest_frame")] + fn oldest_frame(&self) -> Option { + let frame = + unsafe { ffi::gst_video_decoder_get_oldest_frame(self.as_ref().to_glib_none().0) }; + + if frame.is_null() { + None + } else { + unsafe { Some(VideoCodecFrame::new(frame, self.as_ref())) } + } + } + + #[doc(alias = "get_allocator")] #[doc(alias = "gst_video_decoder_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { @@ -125,7 +111,7 @@ impl> VideoDecoderExtManual for O { (from_glib_full(allocator), params.assume_init().into()) } } - + #[doc(alias = "get_latency")] #[doc(alias = "gst_video_decoder_get_latency")] fn latency(&self) -> (gst::ClockTime, Option) { let mut min_latency = gst::ffi::GST_CLOCK_TIME_NONE; @@ -160,51 +146,7 @@ impl> VideoDecoderExtManual for O { } } - #[doc(alias = "gst_video_decoder_get_frame")] - fn frame(&self, frame_number: i32) -> Option { - let frame = unsafe { - ffi::gst_video_decoder_get_frame(self.as_ref().to_glib_none().0, frame_number) - }; - - if frame.is_null() { - None - } else { - unsafe { Some(VideoCodecFrame::new(frame, self.as_ref())) } - } - } - - #[doc(alias = "gst_video_decoder_get_frames")] - fn frames(&self) -> Vec { - unsafe { - let frames = ffi::gst_video_decoder_get_frames(self.as_ref().to_glib_none().0); - let mut iter: *const glib::ffi::GList = frames; - let mut vec = Vec::new(); - - while !iter.is_null() { - let frame_ptr = Ptr::from((*iter).data); - /* transfer ownership of the frame */ - let frame = VideoCodecFrame::new(frame_ptr, self.as_ref()); - vec.push(frame); - iter = (*iter).next; - } - - glib::ffi::g_list_free(frames); - vec - } - } - - #[doc(alias = "gst_video_decoder_get_oldest_frame")] - fn oldest_frame(&self) -> Option { - let frame = - unsafe { ffi::gst_video_decoder_get_oldest_frame(self.as_ref().to_glib_none().0) }; - - if frame.is_null() { - None - } else { - unsafe { Some(VideoCodecFrame::new(frame, self.as_ref())) } - } - } - + #[doc(alias = "get_output_state")] #[doc(alias = "gst_video_decoder_get_output_state")] fn output_state(&self) -> Option> { let state = @@ -299,6 +241,8 @@ impl> VideoDecoderExtManual for O { Err(gst::FlowError::NotNegotiated) } } + + #[allow(clippy::too_many_arguments)] fn error( &self, weight: i32, @@ -339,6 +283,8 @@ impl> VideoDecoderExtManual for O { } } +impl> VideoDecoderExtManual for O {} + impl HasStreamLock for VideoDecoder { fn stream_lock(&self) -> *mut glib::ffi::GRecMutex { let decoder_sys: *const ffi::GstVideoDecoder = self.to_glib_none().0; diff --git a/gstreamer-video/src/video_encoder.rs b/gstreamer-video/src/video_encoder.rs index e48b7f9cd..362b66e73 100644 --- a/gstreamer-video/src/video_encoder.rs +++ b/gstreamer-video/src/video_encoder.rs @@ -9,69 +9,13 @@ use crate::{ video_codec_state::{InNegotiation, Readable, VideoCodecState, VideoCodecStateContext}, VideoCodecFrame, VideoEncoder, }; - -pub trait VideoEncoderExtManual: 'static { - #[doc(alias = "gst_video_encoder_allocate_output_frame")] - fn allocate_output_frame( - &self, - frame: &mut VideoCodecFrame, - size: usize, - ) -> Result; - - #[doc(alias = "get_frame")] - #[doc(alias = "gst_video_encoder_get_frame")] - fn frame(&self, frame_number: i32) -> Option; - #[doc(alias = "get_frames")] - #[doc(alias = "gst_video_encoder_get_frames")] - fn frames(&self) -> Vec; - #[doc(alias = "get_oldest_frame")] - #[doc(alias = "gst_video_encoder_get_oldest_frame")] - fn oldest_frame(&self) -> Option; - - #[doc(alias = "get_allocator")] - #[doc(alias = "gst_video_encoder_get_allocator")] - fn allocator(&self) -> (Option, gst::AllocationParams); - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - #[doc(alias = "gst_video_encoder_finish_subframe")] - fn finish_subframe(&self, frame: &VideoCodecFrame) -> Result; - - #[doc(alias = "get_latency")] - #[doc(alias = "gst_video_encoder_get_latency")] - fn latency(&self) -> (gst::ClockTime, Option); - #[doc(alias = "gst_video_encoder_set_latency")] - fn set_latency( - &self, - min_latency: gst::ClockTime, - max_latency: impl Into>, - ); - - #[doc(alias = "get_output_state")] - #[doc(alias = "gst_video_encoder_get_output_state")] - fn output_state(&self) -> Option>; - #[doc(alias = "gst_video_encoder_set_output_state")] - fn set_output_state( - &self, - caps: gst::Caps, - reference: Option<&VideoCodecState>, - ) -> Result, gst::FlowError>; - - #[doc(alias = "gst_video_encoder_negotiate")] - fn negotiate<'a>( - &'a self, - output_state: VideoCodecState<'a, InNegotiation<'a>>, - ) -> Result<(), gst::FlowError>; - - #[doc(alias = "gst_video_encoder_set_headers")] - fn set_headers(&self, headers: impl IntoIterator); - - fn sink_pad(&self) -> &gst::Pad; - - fn src_pad(&self) -> &gst::Pad; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> VideoEncoderExtManual for O { +pub trait VideoEncoderExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_video_encoder_allocate_output_frame")] fn allocate_output_frame( &self, frame: &mut VideoCodecFrame, @@ -86,62 +30,8 @@ impl> VideoEncoderExtManual for O { } } - fn allocator(&self) -> (Option, gst::AllocationParams) { - unsafe { - let mut allocator = ptr::null_mut(); - let mut params = mem::MaybeUninit::uninit(); - ffi::gst_video_encoder_get_allocator( - self.as_ref().to_glib_none().0, - &mut allocator, - params.as_mut_ptr(), - ); - (from_glib_full(allocator), params.assume_init().into()) - } - } - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - fn finish_subframe(&self, frame: &VideoCodecFrame) -> Result { - unsafe { - try_from_glib(ffi::gst_video_encoder_finish_subframe( - self.as_ref().to_glib_none().0, - frame.to_glib_none().0, - )) - } - } - - fn latency(&self) -> (gst::ClockTime, Option) { - let mut min_latency = gst::ffi::GST_CLOCK_TIME_NONE; - let mut max_latency = gst::ffi::GST_CLOCK_TIME_NONE; - - unsafe { - ffi::gst_video_encoder_get_latency( - self.as_ref().to_glib_none().0, - &mut min_latency, - &mut max_latency, - ); - - ( - try_from_glib(min_latency).expect("undefined min_latency"), - from_glib(max_latency), - ) - } - } - - fn set_latency( - &self, - min_latency: gst::ClockTime, - max_latency: impl Into>, - ) { - unsafe { - ffi::gst_video_encoder_set_latency( - self.as_ref().to_glib_none().0, - min_latency.into_glib(), - max_latency.into().into_glib(), - ); - } - } - + #[doc(alias = "get_frame")] + #[doc(alias = "gst_video_encoder_get_frame")] fn frame(&self, frame_number: i32) -> Option { let frame = unsafe { ffi::gst_video_encoder_get_frame(self.as_ref().to_glib_none().0, frame_number) @@ -154,6 +44,8 @@ impl> VideoEncoderExtManual for O { } } + #[doc(alias = "get_frames")] + #[doc(alias = "gst_video_encoder_get_frames")] fn frames(&self) -> Vec { unsafe { let frames = ffi::gst_video_encoder_get_frames(self.as_ref().to_glib_none().0); @@ -173,6 +65,8 @@ impl> VideoEncoderExtManual for O { } } + #[doc(alias = "get_oldest_frame")] + #[doc(alias = "gst_video_encoder_get_oldest_frame")] fn oldest_frame(&self) -> Option { let frame = unsafe { ffi::gst_video_encoder_get_oldest_frame(self.as_ref().to_glib_none().0) }; @@ -184,6 +78,69 @@ impl> VideoEncoderExtManual for O { } } + #[doc(alias = "get_allocator")] + #[doc(alias = "gst_video_encoder_get_allocator")] + fn allocator(&self) -> (Option, gst::AllocationParams) { + unsafe { + let mut allocator = ptr::null_mut(); + let mut params = mem::MaybeUninit::uninit(); + ffi::gst_video_encoder_get_allocator( + self.as_ref().to_glib_none().0, + &mut allocator, + params.as_mut_ptr(), + ); + (from_glib_full(allocator), params.assume_init().into()) + } + } + + #[cfg(feature = "v1_18")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[doc(alias = "gst_video_encoder_finish_subframe")] + fn finish_subframe(&self, frame: &VideoCodecFrame) -> Result { + unsafe { + try_from_glib(ffi::gst_video_encoder_finish_subframe( + self.as_ref().to_glib_none().0, + frame.to_glib_none().0, + )) + } + } + + #[doc(alias = "get_latency")] + #[doc(alias = "gst_video_encoder_get_latency")] + fn latency(&self) -> (gst::ClockTime, Option) { + let mut min_latency = gst::ffi::GST_CLOCK_TIME_NONE; + let mut max_latency = gst::ffi::GST_CLOCK_TIME_NONE; + + unsafe { + ffi::gst_video_encoder_get_latency( + self.as_ref().to_glib_none().0, + &mut min_latency, + &mut max_latency, + ); + + ( + try_from_glib(min_latency).expect("undefined min_latency"), + from_glib(max_latency), + ) + } + } + + #[doc(alias = "gst_video_encoder_set_latency")] + fn set_latency( + &self, + min_latency: gst::ClockTime, + max_latency: impl Into>, + ) { + unsafe { + ffi::gst_video_encoder_set_latency( + self.as_ref().to_glib_none().0, + min_latency.into_glib(), + max_latency.into().into_glib(), + ); + } + } + #[doc(alias = "get_output_state")] + #[doc(alias = "gst_video_encoder_get_output_state")] fn output_state(&self) -> Option> { let state = unsafe { ffi::gst_video_encoder_get_output_state(self.as_ref().to_glib_none().0) }; @@ -195,6 +152,7 @@ impl> VideoEncoderExtManual for O { } } + #[doc(alias = "gst_video_encoder_set_output_state")] fn set_output_state( &self, caps: gst::Caps, @@ -219,6 +177,7 @@ impl> VideoEncoderExtManual for O { } } + #[doc(alias = "gst_video_encoder_negotiate")] fn negotiate<'a>( &'a self, output_state: VideoCodecState<'a, InNegotiation<'a>>, @@ -239,6 +198,7 @@ impl> VideoEncoderExtManual for O { } } + #[doc(alias = "gst_video_encoder_set_headers")] fn set_headers(&self, headers: impl IntoIterator) { unsafe { ffi::gst_video_encoder_set_headers( @@ -266,6 +226,8 @@ impl> VideoEncoderExtManual for O { } } +impl> VideoEncoderExtManual for O {} + impl HasStreamLock for VideoEncoder { fn stream_lock(&self) -> *mut glib::ffi::GRecMutex { let encoder_sys: *const ffi::GstVideoEncoder = self.to_glib_none().0; diff --git a/gstreamer-video/src/video_overlay.rs b/gstreamer-video/src/video_overlay.rs index 1bb333a03..6e27c9a25 100644 --- a/gstreamer-video/src/video_overlay.rs +++ b/gstreamer-video/src/video_overlay.rs @@ -5,12 +5,12 @@ use libc::uintptr_t; use crate::VideoOverlay; -pub trait VideoOverlayExtManual: 'static { - unsafe fn set_window_handle(&self, handle: uintptr_t); - unsafe fn got_window_handle(&self, handle: uintptr_t); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> VideoOverlayExtManual for O { +pub trait VideoOverlayExtManual: sealed::Sealed + IsA + 'static { unsafe fn set_window_handle(&self, handle: uintptr_t) { ffi::gst_video_overlay_set_window_handle(self.as_ref().to_glib_none().0, handle) } @@ -20,6 +20,8 @@ impl> VideoOverlayExtManual for O { } } +impl> VideoOverlayExtManual for O {} + #[doc(alias = "gst_is_video_overlay_prepare_window_handle_message")] pub fn is_video_overlay_prepare_window_handle_message(msg: &gst::MessageRef) -> bool { skip_assert_initialized!(); diff --git a/gstreamer-webrtc/src/web_rtcice.rs b/gstreamer-webrtc/src/web_rtcice.rs index 4e7381047..a213c91d9 100644 --- a/gstreamer-webrtc/src/web_rtcice.rs +++ b/gstreamer-webrtc/src/web_rtcice.rs @@ -4,22 +4,13 @@ use glib::{prelude::*, translate::*}; use crate::{WebRTCICE, WebRTCICEStream}; -pub trait WebRTCICEExtManual: 'static { - #[doc(alias = "gst_webrtc_ice_add_candidate")] - fn add_candidate(&self, stream: &impl IsA, candidate: &str); - - #[cfg(feature = "v1_24")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] - #[doc(alias = "gst_webrtc_ice_add_candidate")] - fn add_candidate_full( - &self, - stream: &impl IsA, - candidate: &str, - promise: Option<&gst::Promise>, - ); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> WebRTCICEExtManual for O { +pub trait WebRTCICEExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_webrtc_ice_add_candidate")] fn add_candidate(&self, stream: &impl IsA, candidate: &str) { #[cfg(not(feature = "v1_24"))] unsafe { @@ -61,6 +52,7 @@ impl> WebRTCICEExtManual for O { #[cfg(feature = "v1_24")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + #[doc(alias = "gst_webrtc_ice_add_candidate")] fn add_candidate_full( &self, stream: &impl IsA, @@ -77,3 +69,5 @@ impl> WebRTCICEExtManual for O { } } } + +impl> WebRTCICEExtManual for O {} diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index f520eaf39..ac22484bd 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -42,70 +42,13 @@ impl Bin { } } -pub trait GstBinExtManual: 'static { - #[doc(alias = "gst_bin_add_many")] - fn add_many( - &self, - elements: impl IntoIterator>, - ) -> Result<(), glib::BoolError>; - - #[doc(alias = "gst_bin_remove_many")] - fn remove_many( - &self, - elements: impl IntoIterator>, - ) -> Result<(), glib::BoolError>; - - #[doc(alias = "do-latency")] - fn connect_do_latency Result<(), LoggableError> + Send + Sync + 'static>( - &self, - f: F, - ) -> SignalHandlerId; - - #[cfg(feature = "v1_18")] - #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] - #[doc(alias = "gst_bin_iterate_all_by_element_factory_name")] - fn iterate_all_by_element_factory_name(&self, factory_name: &str) -> crate::Iterator; - #[doc(alias = "gst_bin_iterate_all_by_interface")] - fn iterate_all_by_interface(&self, iface: glib::types::Type) -> crate::Iterator; - #[doc(alias = "gst_bin_iterate_elements")] - fn iterate_elements(&self) -> crate::Iterator; - #[doc(alias = "gst_bin_iterate_recurse")] - fn iterate_recurse(&self) -> crate::Iterator; - #[doc(alias = "gst_bin_iterate_sinks")] - fn iterate_sinks(&self) -> crate::Iterator; - #[doc(alias = "gst_bin_iterate_sorted")] - fn iterate_sorted(&self) -> crate::Iterator; - #[doc(alias = "gst_bin_iterate_sources")] - fn iterate_sources(&self) -> crate::Iterator; - #[doc(alias = "get_children")] - fn children(&self) -> Vec; - - #[doc(alias = "gst_debug_bin_to_dot_data")] - fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString; - #[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE")] - #[doc(alias = "gst_debug_bin_to_dot_file")] - fn debug_to_dot_file( - &self, - details: crate::DebugGraphDetails, - file_name: impl AsRef, - ); - #[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS")] - #[doc(alias = "gst_debug_bin_to_dot_file_with_ts")] - fn debug_to_dot_file_with_ts( - &self, - details: crate::DebugGraphDetails, - file_name: impl AsRef, - ); - - fn set_bin_flags(&self, flags: BinFlags); - - fn unset_bin_flags(&self, flags: BinFlags); - - #[doc(alias = "get_bin_flags")] - fn bin_flags(&self) -> BinFlags; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> GstBinExtManual for O { +pub trait GstBinExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_bin_add_many")] fn add_many( &self, elements: impl IntoIterator>, @@ -122,6 +65,7 @@ impl> GstBinExtManual for O { Ok(()) } + #[doc(alias = "gst_bin_remove_many")] fn remove_many( &self, elements: impl IntoIterator>, @@ -141,6 +85,7 @@ impl> GstBinExtManual for O { Ok(()) } + #[doc(alias = "do-latency")] fn connect_do_latency Result<(), LoggableError> + Send + Sync + 'static>( &self, f: F, @@ -160,6 +105,7 @@ impl> GstBinExtManual for O { #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] + #[doc(alias = "gst_bin_iterate_all_by_element_factory_name")] fn iterate_all_by_element_factory_name(&self, factory_name: &str) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_bin_iterate_all_by_element_factory_name( @@ -168,7 +114,7 @@ impl> GstBinExtManual for O { )) } } - + #[doc(alias = "gst_bin_iterate_all_by_interface")] fn iterate_all_by_interface(&self, iface: glib::types::Type) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_bin_iterate_all_by_interface( @@ -178,6 +124,7 @@ impl> GstBinExtManual for O { } } + #[doc(alias = "gst_bin_iterate_elements")] fn iterate_elements(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_bin_iterate_elements( @@ -186,22 +133,27 @@ impl> GstBinExtManual for O { } } + #[doc(alias = "gst_bin_iterate_recurse")] fn iterate_recurse(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_bin_iterate_recurse(self.as_ref().to_glib_none().0)) } } + #[doc(alias = "gst_bin_iterate_sinks")] fn iterate_sinks(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_bin_iterate_sinks(self.as_ref().to_glib_none().0)) } } + #[doc(alias = "gst_bin_iterate_sorted")] fn iterate_sorted(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_bin_iterate_sorted(self.as_ref().to_glib_none().0)) } } + #[doc(alias = "gst_bin_iterate_sources")] fn iterate_sources(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_bin_iterate_sources(self.as_ref().to_glib_none().0)) } } + #[doc(alias = "get_children")] fn children(&self) -> Vec { unsafe { let bin: &ffi::GstBin = &*(self.as_ptr() as *const _); @@ -210,10 +162,13 @@ impl> GstBinExtManual for O { } } + #[doc(alias = "gst_debug_bin_to_dot_data")] fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString { crate::debug_bin_to_dot_data(self, details) } + #[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE")] + #[doc(alias = "gst_debug_bin_to_dot_file")] fn debug_to_dot_file( &self, details: crate::DebugGraphDetails, @@ -222,6 +177,8 @@ impl> GstBinExtManual for O { crate::debug_bin_to_dot_file(self, details, file_name) } + #[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS")] + #[doc(alias = "gst_debug_bin_to_dot_file_with_ts")] fn debug_to_dot_file_with_ts( &self, details: crate::DebugGraphDetails, @@ -246,6 +203,7 @@ impl> GstBinExtManual for O { } } + #[doc(alias = "get_bin_flags")] fn bin_flags(&self) -> BinFlags { unsafe { let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; @@ -255,6 +213,8 @@ impl> GstBinExtManual for O { } } +impl> GstBinExtManual for O {} + impl Default for Bin { fn default() -> Self { glib::object::Object::new() diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index 473e616f8..50216a6dc 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -345,23 +345,14 @@ impl FromGlibPtrNone<*mut ffi::GstBufferPoolAcquireParams> for BufferPoolAcquire } } -pub trait BufferPoolExtManual: 'static { - #[doc(alias = "get_config")] - #[doc(alias = "gst_buffer_pool_get_config")] - fn config(&self) -> BufferPoolConfig; - #[doc(alias = "gst_buffer_pool_set_config")] - fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError>; - - fn is_flushing(&self) -> bool; - - #[doc(alias = "gst_buffer_pool_acquire_buffer")] - fn acquire_buffer( - &self, - params: Option<&BufferPoolAcquireParams>, - ) -> Result; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> BufferPoolExtManual for O { +pub trait BufferPoolExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_config")] + #[doc(alias = "gst_buffer_pool_get_config")] fn config(&self) -> BufferPoolConfig { unsafe { let ptr = ffi::gst_buffer_pool_get_config(self.as_ref().to_glib_none().0); @@ -369,6 +360,7 @@ impl> BufferPoolExtManual for O { } } + #[doc(alias = "gst_buffer_pool_set_config")] fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( @@ -390,6 +382,7 @@ impl> BufferPoolExtManual for O { } } + #[doc(alias = "gst_buffer_pool_acquire_buffer")] fn acquire_buffer( &self, params: Option<&BufferPoolAcquireParams>, @@ -408,6 +401,8 @@ impl> BufferPoolExtManual for O { } } +impl> BufferPoolExtManual for O {} + #[cfg(test)] mod tests { use super::*; diff --git a/gstreamer/src/child_proxy.rs b/gstreamer/src/child_proxy.rs index e4b4cd2a1..d6b732566 100644 --- a/gstreamer/src/child_proxy.rs +++ b/gstreamer/src/child_proxy.rs @@ -6,24 +6,13 @@ use glib::{prelude::*, translate::*}; use crate::ChildProxy; -pub trait ChildProxyExtManual: 'static { - #[doc(alias = "gst_child_proxy_lookup")] - fn lookup(&self, name: &str) -> Result<(glib::Object, glib::ParamSpec), glib::BoolError>; - - #[doc(alias = "get_child_property")] - #[doc(alias = "gst_child_proxy_get")] - fn child_property glib::value::FromValue<'b> + 'static>(&self, name: &str) -> V; - #[doc(alias = "get_child_property")] - #[doc(alias = "gst_child_proxy_get")] - fn child_property_value(&self, name: &str) -> glib::Value; - - #[doc(alias = "gst_child_proxy_set")] - fn set_child_property(&self, name: &str, value: impl Into); - #[doc(alias = "gst_child_proxy_set_property")] - fn set_child_property_from_value(&self, name: &str, value: &glib::Value); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> ChildProxyExtManual for O { +pub trait ChildProxyExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_child_proxy_lookup")] fn lookup(&self, name: &str) -> Result<(glib::Object, glib::ParamSpec), glib::BoolError> { unsafe { let mut target = ptr::null_mut(); @@ -42,27 +31,35 @@ impl> ChildProxyExtManual for O { } } + #[doc(alias = "get_child_property")] + #[doc(alias = "gst_child_proxy_get")] #[track_caller] fn child_property glib::value::FromValue<'b> + 'static>(&self, name: &str) -> V { let (child, pspec) = self.lookup(name).unwrap(); child.property(pspec.name()) } + #[doc(alias = "get_child_property")] + #[doc(alias = "gst_child_proxy_get")] #[track_caller] fn child_property_value(&self, name: &str) -> glib::Value { let (child, pspec) = self.lookup(name).unwrap(); child.property_value(pspec.name()) } + #[doc(alias = "gst_child_proxy_set")] #[track_caller] fn set_child_property(&self, name: &str, value: impl Into) { let (child, pspec) = self.lookup(name).unwrap(); child.set_property(pspec.name(), value) } + #[doc(alias = "gst_child_proxy_set_property")] #[track_caller] fn set_child_property_from_value(&self, name: &str, value: &glib::Value) { let (child, pspec) = self.lookup(name).unwrap(); child.set_property_from_value(pspec.name(), value) } } + +impl> ChildProxyExtManual for O {} diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 28f7fc249..fd1bd8649 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -420,37 +420,13 @@ impl Clock { } } -pub trait ClockExtManual: 'static { - #[doc(alias = "gst_clock_new_periodic_id")] - fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> PeriodicClockId; - - #[doc(alias = "gst_clock_periodic_id_reinit")] - fn periodic_id_reinit( - &self, - id: &PeriodicClockId, - start_time: ClockTime, - interval: ClockTime, - ) -> Result<(), glib::BoolError>; - - #[doc(alias = "gst_clock_new_single_shot_id")] - fn new_single_shot_id(&self, time: ClockTime) -> SingleShotClockId; - - #[doc(alias = "gst_clock_single_shot_id_reinit")] - fn single_shot_id_reinit( - &self, - id: &SingleShotClockId, - time: ClockTime, - ) -> Result<(), glib::BoolError>; - - fn set_clock_flags(&self, flags: ClockFlags); - - fn unset_clock_flags(&self, flags: ClockFlags); - - #[doc(alias = "get_clock_flags")] - fn clock_flags(&self) -> ClockFlags; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> ClockExtManual for O { +pub trait ClockExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_clock_new_periodic_id")] fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> PeriodicClockId { assert_ne!(interval, ClockTime::ZERO); @@ -463,6 +439,7 @@ impl> ClockExtManual for O { } } + #[doc(alias = "gst_clock_periodic_id_reinit")] fn periodic_id_reinit( &self, id: &PeriodicClockId, @@ -484,6 +461,7 @@ impl> ClockExtManual for O { } } + #[doc(alias = "gst_clock_new_single_shot_id")] fn new_single_shot_id(&self, time: ClockTime) -> SingleShotClockId { unsafe { SingleShotClockId(from_glib_full(ffi::gst_clock_new_single_shot_id( @@ -493,6 +471,7 @@ impl> ClockExtManual for O { } } + #[doc(alias = "gst_clock_single_shot_id_reinit")] fn single_shot_id_reinit( &self, id: &SingleShotClockId, @@ -528,6 +507,7 @@ impl> ClockExtManual for O { } } + #[doc(alias = "get_clock_flags")] fn clock_flags(&self) -> ClockFlags { unsafe { let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; @@ -537,6 +517,8 @@ impl> ClockExtManual for O { } } +impl> ClockExtManual for O {} + #[cfg(test)] mod tests { use std::sync::mpsc::channel; diff --git a/gstreamer/src/control_binding.rs b/gstreamer/src/control_binding.rs index 4c0fa1532..e02adbc3c 100644 --- a/gstreamer/src/control_binding.rs +++ b/gstreamer/src/control_binding.rs @@ -4,18 +4,14 @@ use glib::{prelude::*, translate::*}; use crate::{ClockTime, ControlBinding}; -pub trait ControlBindingExtManual: 'static { - #[doc(alias = "get_g_value_array")] - #[doc(alias = "gst_control_binding_get_g_value_array")] - fn g_value_array( - &self, - timestamp: ClockTime, - interval: ClockTime, - values: &mut [glib::Value], - ) -> Result<(), glib::error::BoolError>; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> ControlBindingExtManual for O { +pub trait ControlBindingExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_g_value_array")] + #[doc(alias = "gst_control_binding_get_g_value_array")] fn g_value_array( &self, timestamp: ClockTime, @@ -37,3 +33,5 @@ impl> ControlBindingExtManual for O { } } } + +impl> ControlBindingExtManual for O {} diff --git a/gstreamer/src/control_source.rs b/gstreamer/src/control_source.rs index 58d3a59c6..2b516ed6c 100644 --- a/gstreamer/src/control_source.rs +++ b/gstreamer/src/control_source.rs @@ -4,18 +4,14 @@ use glib::{prelude::*, translate::*}; use crate::{ClockTime, ControlSource}; -pub trait ControlSourceExtManual: 'static { - #[doc(alias = "get_value_array")] - #[doc(alias = "gst_control_source_get_value_array")] - fn value_array( - &self, - timestamp: ClockTime, - interval: ClockTime, - values: &mut [f64], - ) -> Result<(), glib::error::BoolError>; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> ControlSourceExtManual for O { +pub trait ControlSourceExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_value_array")] + #[doc(alias = "gst_control_source_get_value_array")] fn value_array( &self, timestamp: ClockTime, @@ -37,3 +33,5 @@ impl> ControlSourceExtManual for O { } } } + +impl> ControlSourceExtManual for O {} diff --git a/gstreamer/src/device_monitor.rs b/gstreamer/src/device_monitor.rs index 90a9cdd76..d225469d0 100644 --- a/gstreamer/src/device_monitor.rs +++ b/gstreamer/src/device_monitor.rs @@ -26,25 +26,13 @@ impl FromGlib for DeviceMonitorFilterId { DeviceMonitorFilterId(NonZeroU32::new_unchecked(val)) } } - -pub trait DeviceMonitorExtManual: 'static { - #[doc(alias = "gst_device_monitor_add_filter")] - fn add_filter( - &self, - classes: Option<&str>, - caps: Option<&Caps>, - ) -> Option; - - #[doc(alias = "gst_device_monitor_remove_filter")] - fn remove_filter(&self, filter_id: DeviceMonitorFilterId) - -> Result<(), glib::error::BoolError>; - - #[doc(alias = "gst_device_monitor_get_devices")] - #[doc(alias = "get_devices")] - fn devices(&self) -> glib::List; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> DeviceMonitorExtManual for O { +pub trait DeviceMonitorExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_device_monitor_add_filter")] fn add_filter( &self, classes: Option<&str>, @@ -65,6 +53,7 @@ impl> DeviceMonitorExtManual for O { } } + #[doc(alias = "gst_device_monitor_remove_filter")] fn remove_filter( &self, filter_id: DeviceMonitorFilterId, @@ -80,6 +69,8 @@ impl> DeviceMonitorExtManual for O { } } + #[doc(alias = "gst_device_monitor_get_devices")] + #[doc(alias = "get_devices")] fn devices(&self) -> glib::List { unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_device_monitor_get_devices( @@ -88,3 +79,5 @@ impl> DeviceMonitorExtManual for O { } } } + +impl> DeviceMonitorExtManual for O {} diff --git a/gstreamer/src/device_provider.rs b/gstreamer/src/device_provider.rs index 9689b0c76..6b361bde1 100644 --- a/gstreamer/src/device_provider.rs +++ b/gstreamer/src/device_provider.rs @@ -29,17 +29,14 @@ impl DeviceProvider { } } -pub trait DeviceProviderExtManual: 'static { - #[doc(alias = "get_metadata")] - #[doc(alias = "gst_device_provider_class_get_metadata")] - fn metadata<'a>(&self, key: &str) -> Option<&'a str>; - - #[doc(alias = "gst_device_provider_get_devices")] - #[doc(alias = "get_devices")] - fn devices(&self) -> glib::List; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> DeviceProviderExtManual for O { +pub trait DeviceProviderExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_metadata")] + #[doc(alias = "gst_device_provider_class_get_metadata")] fn metadata<'a>(&self, key: &str) -> Option<&'a str> { unsafe { let klass = (*(self.as_ptr() as *mut glib::gobject_ffi::GTypeInstance)).g_class @@ -55,6 +52,8 @@ impl> DeviceProviderExtManual for O { } } + #[doc(alias = "gst_device_provider_get_devices")] + #[doc(alias = "get_devices")] fn devices(&self) -> glib::List { unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_devices( @@ -63,3 +62,5 @@ impl> DeviceProviderExtManual for O { } } } + +impl> DeviceProviderExtManual for O {} diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 22b62e21b..999c0075b 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -101,203 +101,13 @@ impl FromGlib for NotifyWatchId { } } -pub trait ElementExtManual: 'static { - #[doc(alias = "get_element_class")] - fn element_class(&self) -> &glib::Class; - - #[doc(alias = "get_current_state")] - fn current_state(&self) -> State; - - #[doc(alias = "get_pending_state")] - fn pending_state(&self) -> State; - - #[doc(alias = "gst_element_query")] - fn query(&self, query: &mut QueryRef) -> bool; - - #[doc(alias = "gst_element_send_event")] - fn send_event(&self, event: impl Into) -> bool; - - #[doc(alias = "get_metadata")] - fn metadata<'a>(&self, key: &str) -> Option<&'a str>; - - #[doc(alias = "get_pad_template")] - fn pad_template(&self, name: &str) -> Option; - #[doc(alias = "get_pad_template_list")] - fn pad_template_list(&self) -> glib::List; - - #[allow(clippy::too_many_arguments)] - #[doc(alias = "gst_element_message_full")] - fn message_full( - &self, - type_: ElementMessageType, - code: T, - message: Option<&str>, - debug: Option<&str>, - file: &str, - function: &str, - line: u32, - ); - - fn set_element_flags(&self, flags: ElementFlags); - - fn unset_element_flags(&self, flags: ElementFlags); - - #[doc(alias = "get_element_flags")] - fn element_flags(&self) -> ElementFlags; - - #[allow(clippy::too_many_arguments)] - #[doc(alias = "gst_element_message_full_with_details")] - fn message_full_with_details( - &self, - type_: ElementMessageType, - code: T, - message: Option<&str>, - debug: Option<&str>, - file: &str, - function: &str, - line: u32, - structure: crate::Structure, - ); - - fn post_error_message(&self, msg: crate::ErrorMessage); - - #[doc(alias = "gst_element_iterate_pads")] - fn iterate_pads(&self) -> crate::Iterator; - #[doc(alias = "gst_element_iterate_sink_pads")] - fn iterate_sink_pads(&self) -> crate::Iterator; - #[doc(alias = "gst_element_iterate_src_pads")] - fn iterate_src_pads(&self) -> crate::Iterator; - - #[doc(alias = "get_pads")] - #[doc(alias = "gst_element_foreach_pad")] - fn pads(&self) -> Vec; - #[doc(alias = "get_sink_pads")] - #[doc(alias = "gst_element_foreach_sink_pad")] - fn sink_pads(&self) -> Vec; - #[doc(alias = "get_src_pads")] - #[doc(alias = "gst_element_foreach_src_pad")] - fn src_pads(&self) -> Vec; - - fn num_pads(&self) -> u16; - fn num_sink_pads(&self) -> u16; - fn num_src_pads(&self) -> u16; - - #[doc(alias = "gst_element_add_property_deep_notify_watch")] - fn add_property_deep_notify_watch( - &self, - property_name: Option<&str>, - include_value: bool, - ) -> NotifyWatchId; - - #[doc(alias = "gst_element_add_property_notify_watch")] - fn add_property_notify_watch( - &self, - property_name: Option<&str>, - include_value: bool, - ) -> NotifyWatchId; - - #[doc(alias = "gst_element_remove_property_notify_watch")] - fn remove_property_notify_watch(&self, watch_id: NotifyWatchId); - - #[doc(alias = "gst_element_query_convert")] - fn query_convert( - &self, - src_val: impl FormattedValue, - ) -> Option; - fn query_convert_generic( - &self, - src_val: impl FormattedValue, - dest_format: Format, - ) -> Option; - - #[doc(alias = "gst_element_query_duration")] - fn query_duration(&self) -> Option; - #[doc(alias = "gst_element_query_duration")] - fn query_duration_generic(&self, format: Format) -> Option; - - #[doc(alias = "gst_element_query_position")] - fn query_position(&self) -> Option; - #[doc(alias = "gst_element_query_position")] - fn query_position_generic(&self, format: Format) -> Option; - - #[doc(alias = "gst_element_seek")] - fn seek( - &self, - rate: f64, - flags: crate::SeekFlags, - start_type: crate::SeekType, - start: V, - stop_type: crate::SeekType, - stop: impl CompatibleFormattedValue, - ) -> Result<(), glib::error::BoolError>; - #[doc(alias = "gst_element_seek_simple")] - fn seek_simple( - &self, - seek_flags: crate::SeekFlags, - seek_pos: impl FormattedValue, - ) -> Result<(), glib::error::BoolError>; - - #[doc(alias = "gst_element_call_async")] - fn call_async(&self, func: F) - where - F: FnOnce(&Self) + Send + 'static; - - fn call_async_future(&self, func: F) -> Pin + Send + 'static>> - where - F: FnOnce(&Self) -> T + Send + 'static, - T: Send + 'static; - - #[doc(alias = "get_current_running_time")] - #[doc(alias = "gst_element_get_current_running_time")] - fn current_running_time(&self) -> Option; - - #[doc(alias = "get_current_clock_time")] - #[doc(alias = "gst_element_get_current_clock_time")] - fn current_clock_time(&self) -> Option; - - #[doc(alias = "gst_element_get_request_pad")] - #[doc(alias = "get_request_pad")] - #[doc(alias = "gst_element_request_pad_simple")] - fn request_pad_simple(&self, name: &str) -> Option; - - #[doc(alias = "gst_element_link")] - fn link(&self, dest: &impl IsA) -> Result<(), glib::error::BoolError>; - - #[doc(alias = "gst_element_link_filtered")] - fn link_filtered( - &self, - dest: &impl IsA, - filter: &crate::Caps, - ) -> Result<(), glib::error::BoolError>; - - #[doc(alias = "gst_element_link_pads")] - fn link_pads( - &self, - srcpadname: Option<&str>, - dest: &impl IsA, - destpadname: Option<&str>, - ) -> Result<(), glib::error::BoolError>; - - #[doc(alias = "gst_element_link_pads_filtered")] - fn link_pads_filtered( - &self, - srcpadname: Option<&str>, - dest: &impl IsA, - destpadname: Option<&str>, - filter: &crate::Caps, - ) -> Result<(), glib::error::BoolError>; - - #[doc(alias = "gst_element_link_pads_full")] - fn link_pads_full( - &self, - srcpadname: Option<&str>, - dest: &impl IsA, - destpadname: Option<&str>, - flags: crate::PadLinkCheck, - ) -> Result<(), glib::error::BoolError>; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> ElementExtManual for O { +pub trait ElementExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "get_element_class")] #[inline] fn element_class(&self) -> &glib::Class { unsafe { @@ -307,14 +117,17 @@ impl> ElementExtManual for O { } } + #[doc(alias = "get_current_state")] fn current_state(&self) -> State { self.state(Some(ClockTime::ZERO)).1 } + #[doc(alias = "get_pending_state")] fn pending_state(&self) -> State { self.state(Some(ClockTime::ZERO)).2 } + #[doc(alias = "gst_element_query")] fn query(&self, query: &mut QueryRef) -> bool { unsafe { from_glib(ffi::gst_element_query( @@ -324,6 +137,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_send_event")] fn send_event(&self, event: impl Into) -> bool { unsafe { from_glib(ffi::gst_element_send_event( @@ -333,42 +147,26 @@ impl> ElementExtManual for O { } } + #[doc(alias = "get_metadata")] + #[doc(alias = "gst_element_class_get_metadata")] fn metadata<'a>(&self, key: &str) -> Option<&'a str> { self.element_class().metadata(key) } + #[doc(alias = "get_pad_template")] + #[doc(alias = "gst_element_class_get_pad_template")] fn pad_template(&self, name: &str) -> Option { self.element_class().pad_template(name) } + #[doc(alias = "get_pad_template_list")] + #[doc(alias = "gst_element_class_get_pad_template_list")] fn pad_template_list(&self) -> glib::List { self.element_class().pad_template_list() } - fn set_element_flags(&self, flags: ElementFlags) { - unsafe { - let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; - let _guard = self.as_ref().object_lock(); - (*ptr).flags |= flags.into_glib(); - } - } - - fn unset_element_flags(&self, flags: ElementFlags) { - unsafe { - let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; - let _guard = self.as_ref().object_lock(); - (*ptr).flags &= !flags.into_glib(); - } - } - - fn element_flags(&self) -> ElementFlags { - unsafe { - let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; - let _guard = self.as_ref().object_lock(); - from_glib((*ptr).flags) - } - } - + #[allow(clippy::too_many_arguments)] + #[doc(alias = "gst_element_message_full")] fn message_full( &self, type_: ElementMessageType, @@ -400,6 +198,33 @@ impl> ElementExtManual for O { } } + fn set_element_flags(&self, flags: ElementFlags) { + unsafe { + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = self.as_ref().object_lock(); + (*ptr).flags |= flags.into_glib(); + } + } + + fn unset_element_flags(&self, flags: ElementFlags) { + unsafe { + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = self.as_ref().object_lock(); + (*ptr).flags &= !flags.into_glib(); + } + } + + #[doc(alias = "get_element_flags")] + fn element_flags(&self) -> ElementFlags { + unsafe { + let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; + let _guard = self.as_ref().object_lock(); + from_glib((*ptr).flags) + } + } + + #[allow(clippy::too_many_arguments)] + #[doc(alias = "gst_element_message_full_with_details")] fn message_full_with_details( &self, type_: ElementMessageType, @@ -459,6 +284,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_iterate_pads")] fn iterate_pads(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_element_iterate_pads( @@ -467,6 +293,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_iterate_sink_pads")] fn iterate_sink_pads(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_element_iterate_sink_pads( @@ -475,6 +302,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_iterate_src_pads")] fn iterate_src_pads(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_element_iterate_src_pads( @@ -483,6 +311,8 @@ impl> ElementExtManual for O { } } + #[doc(alias = "get_pads")] + #[doc(alias = "gst_element_foreach_pad")] fn pads(&self) -> Vec { unsafe { let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); @@ -491,6 +321,8 @@ impl> ElementExtManual for O { } } + #[doc(alias = "get_sink_pads")] + #[doc(alias = "gst_element_foreach_sink_pad")] fn sink_pads(&self) -> Vec { unsafe { let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); @@ -499,6 +331,8 @@ impl> ElementExtManual for O { } } + #[doc(alias = "get_src_pads")] + #[doc(alias = "gst_element_foreach_src_pad")] fn src_pads(&self) -> Vec { unsafe { let elt: &ffi::GstElement = &*(self.as_ptr() as *const _); @@ -531,6 +365,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_add_property_deep_notify_watch")] fn add_property_deep_notify_watch( &self, property_name: Option<&str>, @@ -546,6 +381,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_add_property_notify_watch")] fn add_property_notify_watch( &self, property_name: Option<&str>, @@ -561,6 +397,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_remove_property_notify_watch")] fn remove_property_notify_watch(&self, watch_id: NotifyWatchId) { unsafe { ffi::gst_element_remove_property_notify_watch( @@ -570,6 +407,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_query_convert")] fn query_convert( &self, src_val: impl FormattedValue, @@ -591,6 +429,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_query_convert")] fn query_convert_generic( &self, src_val: impl FormattedValue, @@ -616,6 +455,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_query_duration")] fn query_duration(&self) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); @@ -632,6 +472,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_query_duration")] fn query_duration_generic(&self, format: Format) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); @@ -648,6 +489,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_query_position")] fn query_position(&self) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); @@ -664,6 +506,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_query_position")] fn query_position_generic(&self, format: Format) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); @@ -680,6 +523,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_seek")] fn seek( &self, rate: f64, @@ -708,6 +552,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_seek_simple")] fn seek_simple( &self, seek_flags: crate::SeekFlags, @@ -726,6 +571,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_call_async")] fn call_async(&self, func: F) where F: FnOnce(&Self) + Send + 'static, @@ -774,6 +620,8 @@ impl> ElementExtManual for O { Box::pin(async move { receiver.await.expect("sender dropped") }) } + #[doc(alias = "get_current_running_time")] + #[doc(alias = "gst_element_get_current_running_time")] fn current_running_time(&self) -> Option { let base_time = self.base_time(); let clock_time = self.current_clock_time(); @@ -783,6 +631,8 @@ impl> ElementExtManual for O { .and_then(|(ct, bt)| ct.checked_sub(bt)) } + #[doc(alias = "get_current_clock_time")] + #[doc(alias = "gst_element_get_current_clock_time")] fn current_clock_time(&self) -> Option { if let Some(clock) = self.clock() { clock.time() @@ -791,6 +641,9 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_get_request_pad")] + #[doc(alias = "get_request_pad")] + #[doc(alias = "gst_element_request_pad_simple")] fn request_pad_simple(&self, name: &str) -> Option { unsafe { #[cfg(feature = "v1_20")] @@ -810,6 +663,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_link")] fn link(&self, dest: &impl IsA) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( @@ -824,6 +678,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_link_filtered")] fn link_filtered( &self, dest: &impl IsA, @@ -844,6 +699,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_link_pads")] fn link_pads( &self, srcpadname: Option<&str>, @@ -873,6 +729,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_link_pads_filtered")] fn link_pads_filtered( &self, srcpadname: Option<&str>, @@ -905,6 +762,7 @@ impl> ElementExtManual for O { } } + #[doc(alias = "gst_element_link_pads_full")] fn link_pads_full( &self, srcpadname: Option<&str>, @@ -938,6 +796,8 @@ impl> ElementExtManual for O { } } +impl> ElementExtManual for O {} + pub unsafe trait ElementClassExt { #[doc(alias = "get_metadata")] #[doc(alias = "gst_element_class_get_metadata")] diff --git a/gstreamer/src/gobject.rs b/gstreamer/src/gobject.rs index cb8ff40f1..1041a3c5c 100644 --- a/gstreamer/src/gobject.rs +++ b/gstreamer/src/gobject.rs @@ -4,12 +4,13 @@ use glib::prelude::*; use crate::value::GstValueExt; -pub trait GObjectExtManualGst: 'static { - #[doc(alias = "gst_util_set_object_arg")] - fn set_property_from_str(&self, name: &str, value: &str); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> GObjectExtManualGst for O { +pub trait GObjectExtManualGst: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_util_set_object_arg")] #[track_caller] fn set_property_from_str(&self, name: &str, value: &str) { let pspec = self.find_property(name).unwrap_or_else(|| { @@ -49,6 +50,8 @@ impl> GObjectExtManualGst for O { } } +impl> GObjectExtManualGst for O {} + #[cfg(test)] mod tests { use super::*; diff --git a/gstreamer/src/object.rs b/gstreamer/src/object.rs index 1a4c80a38..09ba94921 100644 --- a/gstreamer/src/object.rs +++ b/gstreamer/src/object.rs @@ -2,37 +2,15 @@ use glib::{prelude::*, signal::SignalHandlerId, translate::*}; -use crate::{ClockTime, ObjectFlags}; +use crate::{ClockTime, Object, ObjectFlags}; -pub trait GstObjectExtManual: 'static { - #[doc(alias = "deep-notify")] - fn connect_deep_notify( - &self, - name: Option<&str>, - f: F, - ) -> SignalHandlerId; - - fn set_object_flags(&self, flags: ObjectFlags); - - fn unset_object_flags(&self, flags: ObjectFlags); - - #[doc(alias = "get_object_flags")] - fn object_flags(&self) -> ObjectFlags; - - #[doc(alias = "get_g_value_array")] - #[doc(alias = "gst_object_get_g_value_array")] - fn g_value_array( - &self, - property_name: &str, - timestamp: ClockTime, - interval: ClockTime, - values: &mut [glib::Value], - ) -> Result<(), glib::error::BoolError>; - - fn object_lock(&self) -> crate::utils::ObjectLockGuard; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> GstObjectExtManual for O { +pub trait GstObjectExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "deep-notify")] fn connect_deep_notify< F: Fn(&Self, &crate::Object, &glib::ParamSpec) + Send + Sync + 'static, >( @@ -53,7 +31,7 @@ impl> GstObjectExtManual for O { // It would be nice to display the actual signal name in the panic messages below, // but that would require to copy `signal_name` so as to move it into the closure // which seems too much for the messages of development errors - let obj: O = unsafe { + let obj: Self = unsafe { values[0] .get::() .unwrap_or_else(|err| panic!("Object signal \"deep-notify\": values[0]: {err}")) @@ -90,6 +68,7 @@ impl> GstObjectExtManual for O { } } + #[doc(alias = "get_object_flags")] fn object_flags(&self) -> ObjectFlags { unsafe { let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; @@ -98,6 +77,9 @@ impl> GstObjectExtManual for O { } } + #[doc(alias = "get_g_value_array")] + #[doc(alias = "gst_object_get_g_value_array")] + fn g_value_array( &self, property_name: &str, @@ -127,6 +109,8 @@ impl> GstObjectExtManual for O { } } +impl> GstObjectExtManual for O {} + #[cfg(test)] mod tests { use std::sync::{Arc, Mutex}; diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 1f898ad6c..195cc826f 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -95,217 +95,13 @@ pub enum EventForeachAction { Replace(Event), } -pub trait PadExtManual: 'static { - #[doc(alias = "gst_pad_add_probe")] - fn add_probe(&self, mask: PadProbeType, func: F) -> Option - where - F: Fn(&Self, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static; - #[doc(alias = "gst_pad_remove_probe")] - fn remove_probe(&self, id: PadProbeId); - - #[doc(alias = "gst_pad_pull_range")] - fn pull_range(&self, offset: u64, size: u32) -> Result; - fn pull_range_fill( - &self, - offset: u64, - buffer: &mut crate::BufferRef, - size: u32, - ) -> Result<(), FlowError>; - #[doc(alias = "get_range")] - #[doc(alias = "gst_pad_get_range")] - fn range(&self, offset: u64, size: u32) -> Result; - #[doc(alias = "get_range_fill")] - fn range_fill( - &self, - offset: u64, - buffer: &mut crate::BufferRef, - size: u32, - ) -> Result<(), FlowError>; - - #[doc(alias = "gst_pad_peer_query")] - fn peer_query(&self, query: &mut QueryRef) -> bool; - #[doc(alias = "gst_pad_query")] - fn query(&self, query: &mut QueryRef) -> bool; - fn proxy_query_caps(&self, query: &mut QueryRef) -> bool; - #[doc(alias = "gst_pad_proxy_query_accept_caps")] - fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool; - - #[doc(alias = "gst_pad_push_event")] - fn push_event(&self, event: impl Into) -> bool; - #[doc(alias = "gst_pad_send_event")] - fn send_event(&self, event: impl Into) -> bool; - - #[doc(alias = "gst_pad_iterate_internal_links")] - fn iterate_internal_links(&self) -> crate::Iterator; - - fn stream_lock(&self) -> StreamLock; - - #[doc(alias = "gst_pad_set_activate_function")] - #[doc(alias = "gst_pad_set_activate_function_full")] - unsafe fn set_activate_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static; - - #[doc(alias = "gst_pad_set_activatemode_function")] - #[doc(alias = "gst_pad_set_activatemode_function_full")] - unsafe fn set_activatemode_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError> - + Send - + Sync - + 'static; - - #[doc(alias = "gst_pad_set_chain_function")] - #[doc(alias = "gst_pad_set_chain_function_full")] - unsafe fn set_chain_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>, crate::Buffer) -> Result - + Send - + Sync - + 'static; - - #[doc(alias = "gst_pad_set_chain_list_function")] - #[doc(alias = "gst_pad_set_chain_list_function_full")] - unsafe fn set_chain_list_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>, crate::BufferList) -> Result - + Send - + Sync - + 'static; - - #[doc(alias = "gst_pad_set_event_function")] - #[doc(alias = "gst_pad_set_event_function_full")] - unsafe fn set_event_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static; - - #[doc(alias = "gst_pad_set_event_full_function")] - #[doc(alias = "gst_pad_set_event_full_function_full")] - unsafe fn set_event_full_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>, crate::Event) -> Result - + Send - + Sync - + 'static; - - #[doc(alias = "gst_pad_set_getrange_function")] - #[doc(alias = "gst_pad_set_getrange_function_full")] - unsafe fn set_getrange_function(&self, func: F) - where - F: Fn( - &Self, - Option<&crate::Object>, - u64, - Option<&mut crate::BufferRef>, - u32, - ) -> Result - + Send - + Sync - + 'static; - - #[doc(alias = "gst_pad_set_iterate_internal_links_function")] - #[doc(alias = "gst_pad_set_iterate_internal_links_function_full")] - unsafe fn set_iterate_internal_links_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>) -> crate::Iterator + Send + Sync + 'static; - - #[doc(alias = "gst_pad_set_link_function")] - #[doc(alias = "gst_pad_set_link_function_full")] - unsafe fn set_link_function(&self, func: F) - where - F: Fn( - &Self, - Option<&crate::Object>, - &Pad, - ) -> Result - + Send - + Sync - + 'static; - - #[doc(alias = "gst_pad_set_query_function")] - #[doc(alias = "gst_pad_set_query_function_full")] - unsafe fn set_query_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static; - - #[doc(alias = "gst_pad_set_unlink_function")] - #[doc(alias = "gst_pad_set_unlink_function_full")] - unsafe fn set_unlink_function(&self, func: F) - where - F: Fn(&Self, Option<&crate::Object>) + Send + Sync + 'static; - - #[doc(alias = "gst_pad_start_task")] - fn start_task(&self, func: F) -> Result<(), glib::BoolError>; - - #[doc(alias = "gst_pad_peer_query_convert")] - fn peer_query_convert( - &self, - src_val: impl FormattedValue, - ) -> Option; - #[doc(alias = "gst_pad_peer_query_convert")] - fn peer_query_convert_generic( - &self, - src_val: impl FormattedValue, - dest_format: Format, - ) -> Option; - - #[doc(alias = "gst_pad_peer_query_duration")] - fn peer_query_duration(&self) -> Option; - #[doc(alias = "gst_pad_peer_query_duration")] - fn peer_query_duration_generic(&self, format: Format) -> Option; - - #[doc(alias = "gst_pad_peer_query_position")] - fn peer_query_position(&self) -> Option; - #[doc(alias = "gst_pad_peer_query_position")] - fn peer_query_position_generic(&self, format: Format) -> Option; - - #[doc(alias = "gst_pad_query_convert")] - fn query_convert( - &self, - src_val: impl FormattedValue, - ) -> Option; - #[doc(alias = "gst_pad_query_convert")] - fn query_convert_generic( - &self, - src_val: impl FormattedValue, - dest_format: Format, - ) -> Option; - - #[doc(alias = "gst_pad_query_duration")] - fn query_duration(&self) -> Option; - #[doc(alias = "gst_pad_query_duration")] - fn query_duration_generic(&self, format: Format) -> Option; - - #[doc(alias = "gst_pad_query_position")] - fn query_position(&self) -> Option; - #[doc(alias = "gst_pad_query_position")] - fn query_position_generic(&self, format: Format) -> Option; - - #[doc(alias = "get_mode")] - #[doc(alias = "GST_PAD_MODE")] - fn mode(&self) -> crate::PadMode; - - #[doc(alias = "gst_pad_sticky_events_foreach")] - fn sticky_events_foreach< - F: FnMut(&Event) -> ControlFlow, - >( - &self, - func: F, - ); - - #[doc(alias = "gst_pad_get_sticky_event")] - #[doc(alias = "get_sticky_event")] - fn sticky_event(&self, idx: u32) -> Option; - - fn set_pad_flags(&self, flags: PadFlags); - - fn unset_pad_flags(&self, flags: PadFlags); - - #[doc(alias = "get_pad_flags")] - fn pad_flags(&self) -> PadFlags; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> PadExtManual for O { +pub trait PadExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_pad_add_probe")] fn add_probe(&self, mask: PadProbeType, func: F) -> Option where F: Fn(&Self, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static, @@ -328,52 +124,14 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_remove_probe")] fn remove_probe(&self, id: PadProbeId) { unsafe { ffi::gst_pad_remove_probe(self.as_ref().to_glib_none().0, id.into_glib()); } } - fn range(&self, offset: u64, size: u32) -> Result { - unsafe { - let mut buffer = ptr::null_mut(); - FlowSuccess::try_from_glib(ffi::gst_pad_get_range( - self.as_ref().to_glib_none().0, - offset, - size, - &mut buffer, - )) - .map(|_| from_glib_full(buffer)) - } - } - - fn range_fill( - &self, - offset: u64, - buffer: &mut crate::BufferRef, - size: u32, - ) -> Result<(), FlowError> { - assert!(buffer.size() >= size as usize); - - unsafe { - let mut buffer_ref = buffer.as_mut_ptr(); - FlowSuccess::try_from_glib(ffi::gst_pad_get_range( - self.as_ref().to_glib_none().0, - offset, - size, - &mut buffer_ref, - )) - .and_then(|_| { - if buffer.as_mut_ptr() != buffer_ref { - ffi::gst_mini_object_unref(buffer_ref as *mut _); - Err(crate::FlowError::Error) - } else { - Ok(()) - } - }) - } - } - + #[doc(alias = "gst_pad_pull_range")] fn pull_range(&self, offset: u64, size: u32) -> Result { unsafe { let mut buffer = ptr::null_mut(); @@ -414,15 +172,50 @@ impl> PadExtManual for O { } } - fn query(&self, query: &mut QueryRef) -> bool { + #[doc(alias = "get_range")] + #[doc(alias = "gst_pad_get_range")] + fn range(&self, offset: u64, size: u32) -> Result { unsafe { - from_glib(ffi::gst_pad_query( + let mut buffer = ptr::null_mut(); + FlowSuccess::try_from_glib(ffi::gst_pad_get_range( self.as_ref().to_glib_none().0, - query.as_mut_ptr(), + offset, + size, + &mut buffer, )) + .map(|_| from_glib_full(buffer)) } } + #[doc(alias = "get_range_fill")] + fn range_fill( + &self, + offset: u64, + buffer: &mut crate::BufferRef, + size: u32, + ) -> Result<(), FlowError> { + assert!(buffer.size() >= size as usize); + + unsafe { + let mut buffer_ref = buffer.as_mut_ptr(); + FlowSuccess::try_from_glib(ffi::gst_pad_get_range( + self.as_ref().to_glib_none().0, + offset, + size, + &mut buffer_ref, + )) + .and_then(|_| { + if buffer.as_mut_ptr() != buffer_ref { + ffi::gst_mini_object_unref(buffer_ref as *mut _); + Err(crate::FlowError::Error) + } else { + Ok(()) + } + }) + } + } + + #[doc(alias = "gst_pad_peer_query")] fn peer_query(&self, query: &mut QueryRef) -> bool { unsafe { from_glib(ffi::gst_pad_peer_query( @@ -432,9 +225,10 @@ impl> PadExtManual for O { } } - fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool { + #[doc(alias = "gst_pad_query")] + fn query(&self, query: &mut QueryRef) -> bool { unsafe { - from_glib(ffi::gst_pad_proxy_query_accept_caps( + from_glib(ffi::gst_pad_query( self.as_ref().to_glib_none().0, query.as_mut_ptr(), )) @@ -450,6 +244,17 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_proxy_query_accept_caps")] + fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool { + unsafe { + from_glib(ffi::gst_pad_proxy_query_accept_caps( + self.as_ref().to_glib_none().0, + query.as_mut_ptr(), + )) + } + } + + #[doc(alias = "gst_pad_push_event")] fn push_event(&self, event: impl Into) -> bool { unsafe { from_glib(ffi::gst_pad_push_event( @@ -459,6 +264,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_send_event")] fn send_event(&self, event: impl Into) -> bool { unsafe { from_glib(ffi::gst_pad_send_event( @@ -468,6 +274,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_iterate_internal_links")] fn iterate_internal_links(&self) -> crate::Iterator { unsafe { from_glib_full(ffi::gst_pad_iterate_internal_links( @@ -484,6 +291,8 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_set_activate_function")] + #[doc(alias = "gst_pad_set_activate_function_full")] unsafe fn set_activate_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, @@ -497,6 +306,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_activatemode_function")] + #[doc(alias = "gst_pad_set_activatemode_function_full")] unsafe fn set_activatemode_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError> @@ -513,6 +324,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_chain_function")] + #[doc(alias = "gst_pad_set_chain_function_full")] unsafe fn set_chain_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>, crate::Buffer) -> Result @@ -529,6 +342,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_chain_list_function")] + #[doc(alias = "gst_pad_set_chain_list_function_full")] unsafe fn set_chain_list_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>, crate::BufferList) -> Result @@ -545,6 +360,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_event_function")] + #[doc(alias = "gst_pad_set_event_function_full")] unsafe fn set_event_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static, @@ -558,6 +375,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_event_full_function")] + #[doc(alias = "gst_pad_set_event_full_function_full")] unsafe fn set_event_full_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>, crate::Event) -> Result @@ -574,6 +393,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_getrange_function")] + #[doc(alias = "gst_pad_set_getrange_function_full")] unsafe fn set_getrange_function(&self, func: F) where F: Fn( @@ -596,6 +417,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_iterate_internal_links_function")] + #[doc(alias = "gst_pad_set_iterate_internal_links_function_full")] unsafe fn set_iterate_internal_links_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>) -> crate::Iterator + Send + Sync + 'static, @@ -609,6 +432,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_link_function")] + #[doc(alias = "gst_pad_set_link_function_full")] unsafe fn set_link_function(&self, func: F) where F: Fn( @@ -629,6 +454,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_query_function")] + #[doc(alias = "gst_pad_set_query_function_full")] unsafe fn set_query_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static, @@ -642,6 +469,8 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_set_unlink_function")] + #[doc(alias = "gst_pad_set_unlink_function_full")] unsafe fn set_unlink_function(&self, func: F) where F: Fn(&Self, Option<&crate::Object>) + Send + Sync + 'static, @@ -655,6 +484,7 @@ impl> PadExtManual for O { ); } + #[doc(alias = "gst_pad_start_task")] fn start_task(&self, func: F) -> Result<(), glib::BoolError> { unsafe extern "C" fn trampoline_pad_task(func: gpointer) { let (func, pad) = &mut *(func as *mut (F, *mut ffi::GstPad)); @@ -700,7 +530,7 @@ impl> PadExtManual for O { ) } } - + #[doc(alias = "gst_pad_peer_query_convert")] fn peer_query_convert( &self, src_val: impl FormattedValue, @@ -722,6 +552,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_peer_query_convert")] fn peer_query_convert_generic( &self, src_val: impl FormattedValue, @@ -747,6 +578,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_peer_query_duration")] fn peer_query_duration(&self) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); @@ -763,6 +595,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_peer_query_duration")] fn peer_query_duration_generic(&self, format: Format) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); @@ -779,6 +612,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_peer_query_position")] fn peer_query_position(&self) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); @@ -795,6 +629,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_peer_query_position")] fn peer_query_position_generic(&self, format: Format) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); @@ -811,6 +646,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_query_convert")] fn query_convert( &self, src_val: impl FormattedValue, @@ -832,6 +668,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_query_convert")] fn query_convert_generic( &self, src_val: impl FormattedValue, @@ -857,6 +694,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_query_duration")] fn query_duration(&self) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); @@ -873,6 +711,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_query_duration")] fn query_duration_generic(&self, format: Format) -> Option { unsafe { let mut duration = mem::MaybeUninit::uninit(); @@ -889,6 +728,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_query_position")] fn query_position(&self) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); @@ -905,6 +745,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_query_position")] fn query_position_generic(&self, format: Format) -> Option { unsafe { let mut cur = mem::MaybeUninit::uninit(); @@ -921,6 +762,8 @@ impl> PadExtManual for O { } } + #[doc(alias = "get_mode")] + #[doc(alias = "GST_PAD_MODE")] fn mode(&self) -> crate::PadMode { unsafe { let ptr: &ffi::GstPad = &*(self.as_ptr() as *const _); @@ -928,6 +771,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_sticky_events_foreach")] fn sticky_events_foreach< F: FnMut(&Event) -> ControlFlow, >( @@ -978,6 +822,8 @@ impl> PadExtManual for O { } } + #[doc(alias = "gst_pad_get_sticky_event")] + #[doc(alias = "get_sticky_event")] fn sticky_event(&self, idx: u32) -> Option { unsafe { let ptr = ffi::gst_pad_get_sticky_event( @@ -1010,6 +856,7 @@ impl> PadExtManual for O { } } + #[doc(alias = "get_pad_flags")] fn pad_flags(&self) -> PadFlags { unsafe { let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; @@ -1019,6 +866,8 @@ impl> PadExtManual for O { } } +impl> PadExtManual for O {} + unsafe fn create_probe_info<'a>( info: *mut ffi::GstPadProbeInfo, ) -> (PadProbeInfo<'a>, Option) { diff --git a/gstreamer/src/pipeline.rs b/gstreamer/src/pipeline.rs index 097740a04..c93b6b3f1 100644 --- a/gstreamer/src/pipeline.rs +++ b/gstreamer/src/pipeline.rs @@ -40,16 +40,12 @@ impl Pipeline { } } -pub trait GstPipelineExtManual: 'static { - fn set_pipeline_flags(&self, flags: PipelineFlags); - - fn unset_pipeline_flags(&self, flags: PipelineFlags); - - #[doc(alias = "get_pipeline_flags")] - fn pipeline_flags(&self) -> PipelineFlags; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> GstPipelineExtManual for O { +pub trait GstPipelineExtManual: sealed::Sealed + IsA + 'static { fn set_pipeline_flags(&self, flags: PipelineFlags) { unsafe { let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; @@ -66,6 +62,7 @@ impl> GstPipelineExtManual for O { } } + #[doc(alias = "get_pipeline_flags")] fn pipeline_flags(&self) -> PipelineFlags { unsafe { let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _; @@ -75,6 +72,8 @@ impl> GstPipelineExtManual for O { } } +impl> GstPipelineExtManual for O {} + impl Default for Pipeline { fn default() -> Self { glib::object::Object::new() diff --git a/gstreamer/src/plugin_feature.rs b/gstreamer/src/plugin_feature.rs index ed62d00e0..3b8cb97a1 100644 --- a/gstreamer/src/plugin_feature.rs +++ b/gstreamer/src/plugin_feature.rs @@ -7,17 +7,14 @@ use glib::{ use crate::{PluginFeature, Rank}; -pub trait PluginFeatureExtManual: Sized + 'static { - #[doc(alias = "get_rank")] - #[doc(alias = "gst_plugin_feature_get_rank")] - fn rank(&self) -> Rank; - #[doc(alias = "gst_plugin_feature_set_rank")] - fn set_rank(&self, rank: Rank); - #[doc(alias = "gst_plugin_feature_load")] - fn load(&self) -> Result; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> PluginFeatureExtManual for O { +pub trait PluginFeatureExtManual: sealed::Sealed + IsA + Sized + 'static { + #[doc(alias = "get_rank")] + #[doc(alias = "gst_plugin_feature_get_rank")] fn rank(&self) -> Rank { unsafe { let rank = ffi::gst_plugin_feature_get_rank(self.as_ref().to_glib_none().0); @@ -25,6 +22,7 @@ impl> PluginFeatureExtManual for O { } } + #[doc(alias = "gst_plugin_feature_set_rank")] fn set_rank(&self, rank: Rank) { unsafe { ffi::gst_plugin_feature_set_rank( @@ -34,6 +32,7 @@ impl> PluginFeatureExtManual for O { } } + #[doc(alias = "gst_plugin_feature_load")] fn load(&self) -> Result { unsafe { let loaded = Option::::from_glib_full(ffi::gst_plugin_feature_load( @@ -45,6 +44,8 @@ impl> PluginFeatureExtManual for O { } } +impl> PluginFeatureExtManual for O {} + #[cfg(test)] mod tests { use super::*; diff --git a/gstreamer/src/subclass/allocator.rs b/gstreamer/src/subclass/allocator.rs index c24f77998..0d149c180 100644 --- a/gstreamer/src/subclass/allocator.rs +++ b/gstreamer/src/subclass/allocator.rs @@ -17,17 +17,12 @@ pub trait AllocatorImpl: AllocatorImplExt + GstObjectImpl + Send + Sync { } } -pub trait AllocatorImplExt: ObjectSubclass { - fn parent_alloc( - &self, - size: usize, - params: Option<&AllocationParams>, - ) -> Result; - - fn parent_free(&self, memory: Memory); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl AllocatorImplExt for T { +pub trait AllocatorImplExt: sealed::Sealed + ObjectSubclass { fn parent_alloc( &self, size: usize, @@ -65,6 +60,8 @@ impl AllocatorImplExt for T { } } +impl AllocatorImplExt for T {} + unsafe impl IsSubclassable for Allocator { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index 3b5cbb42a..bb6fb3343 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -23,17 +23,12 @@ pub trait BinImpl: BinImplExt + ElementImpl { } } -pub trait BinImplExt: ObjectSubclass { - fn parent_add_element(&self, element: &Element) -> Result<(), LoggableError>; - - fn parent_remove_element(&self, element: &Element) -> Result<(), LoggableError>; - - fn parent_do_latency(&self) -> Result<(), LoggableError>; - - fn parent_handle_message(&self, message: Message); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl BinImplExt for T { +pub trait BinImplExt: sealed::Sealed + ObjectSubclass { fn parent_add_element(&self, element: &Element) -> Result<(), LoggableError> { unsafe { let data = Self::type_data(); @@ -108,6 +103,8 @@ impl BinImplExt for T { } } +impl BinImplExt for T {} + unsafe impl IsSubclassable for Bin { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/buffer_pool.rs b/gstreamer/src/subclass/buffer_pool.rs index 9cf58c92f..1d44b5dcf 100644 --- a/gstreamer/src/subclass/buffer_pool.rs +++ b/gstreamer/src/subclass/buffer_pool.rs @@ -64,35 +64,12 @@ pub trait BufferPoolImpl: BufferPoolImplExt + GstObjectImpl + Send + Sync { } } -pub trait BufferPoolImplExt: ObjectSubclass { - fn parent_acquire_buffer( - &self, - params: Option<&BufferPoolAcquireParams>, - ) -> Result; - - fn parent_alloc_buffer( - &self, - params: Option<&BufferPoolAcquireParams>, - ) -> Result; - - fn parent_free_buffer(&self, buffer: crate::Buffer); - - fn parent_release_buffer(&self, buffer: crate::Buffer); - - fn parent_reset_buffer(&self, buffer: &mut crate::BufferRef); - - fn parent_start(&self) -> bool; - - fn parent_stop(&self) -> bool; - - fn parent_set_config(&self, config: &mut BufferPoolConfigRef) -> bool; - - fn parent_flush_start(&self); - - fn parent_flush_stop(&self); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl BufferPoolImplExt for T { +pub trait BufferPoolImplExt: sealed::Sealed + ObjectSubclass { fn parent_acquire_buffer( &self, params: Option<&BufferPoolAcquireParams>, @@ -280,6 +257,8 @@ impl BufferPoolImplExt for T { } } +impl BufferPoolImplExt for T {} + unsafe impl IsSubclassable for BufferPool { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/child_proxy.rs b/gstreamer/src/subclass/child_proxy.rs index cedcac877..79159301f 100644 --- a/gstreamer/src/subclass/child_proxy.rs +++ b/gstreamer/src/subclass/child_proxy.rs @@ -21,17 +21,12 @@ pub trait ChildProxyImpl: GstObjectImpl + Send + Sync { } } -pub trait ChildProxyImplExt: ObjectSubclass { - fn parent_child_by_name(&self, name: &str) -> Option; - - fn parent_child_by_index(&self, index: u32) -> Option; - fn parent_children_count(&self) -> u32; - - fn parent_child_added(&self, _child: &glib::Object, _name: &str); - fn parent_child_removed(&self, _child: &glib::Object, _name: &str); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl ChildProxyImplExt for T { +pub trait ChildProxyImplExt: sealed::Sealed + ObjectSubclass { fn parent_child_by_name(&self, name: &str) -> Option { unsafe { let type_data = Self::type_data(); @@ -112,6 +107,8 @@ impl ChildProxyImplExt for T { } } +impl ChildProxyImplExt for T {} + unsafe impl IsImplementable for ChildProxy { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); diff --git a/gstreamer/src/subclass/clock.rs b/gstreamer/src/subclass/clock.rs index 6d3bbe924..3d72e7d41 100644 --- a/gstreamer/src/subclass/clock.rs +++ b/gstreamer/src/subclass/clock.rs @@ -31,49 +31,18 @@ pub trait ClockImpl: ClockImplExt + GstObjectImpl + Send + Sync { } } -pub trait ClockImplExt: ObjectSubclass { +mod sealed { + pub trait Sealed {} + impl Sealed for T {} +} + +pub trait ClockImplExt: sealed::Sealed + ObjectSubclass { fn parent_change_resolution( &self, old_resolution: ClockTime, new_resolution: ClockTime, ) -> ClockTime; - fn parent_resolution(&self) -> ClockTime; - - fn parent_internal_time(&self) -> ClockTime; - - fn parent_wait(&self, id: &ClockId) -> (Result, ClockTimeDiff); - - fn parent_wait_async(&self, id: &ClockId) -> Result; - - fn parent_unschedule(&self, id: &ClockId); - - fn wake_id(&self, id: &ClockId); -} - -impl ClockImplExt for T { - fn parent_change_resolution( - &self, - old_resolution: ClockTime, - new_resolution: ClockTime, - ) -> ClockTime { - unsafe { - let data = Self::type_data(); - let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass; - - if let Some(func) = (*parent_class).change_resolution { - try_from_glib(func( - self.obj().unsafe_cast_ref::().to_glib_none().0, - old_resolution.into_glib(), - new_resolution.into_glib(), - )) - .expect("undefined resolution") - } else { - self.resolution() - } - } - } - fn parent_resolution(&self) -> ClockTime { unsafe { let data = Self::type_data(); @@ -191,6 +160,30 @@ impl ClockImplExt for T { } } +impl ClockImplExt for T { + fn parent_change_resolution( + &self, + old_resolution: ClockTime, + new_resolution: ClockTime, + ) -> ClockTime { + unsafe { + let data = Self::type_data(); + let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass; + + if let Some(func) = (*parent_class).change_resolution { + try_from_glib(func( + self.obj().unsafe_cast_ref::().to_glib_none().0, + old_resolution.into_glib(), + new_resolution.into_glib(), + )) + .expect("undefined resolution") + } else { + self.resolution() + } + } + } +} + unsafe impl IsSubclassable for Clock { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/device.rs b/gstreamer/src/subclass/device.rs index 3123e9938..1772e9b11 100644 --- a/gstreamer/src/subclass/device.rs +++ b/gstreamer/src/subclass/device.rs @@ -17,13 +17,12 @@ pub trait DeviceImpl: DeviceImplExt + GstObjectImpl + Send + Sync { } } -pub trait DeviceImplExt: ObjectSubclass { - fn parent_create_element(&self, name: Option<&str>) -> Result; - - fn parent_reconfigure_element(&self, element: &Element) -> Result<(), LoggableError>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl DeviceImplExt for T { +pub trait DeviceImplExt: sealed::Sealed + ObjectSubclass { fn parent_create_element(&self, name: Option<&str>) -> Result { unsafe { let data = Self::type_data(); @@ -72,6 +71,8 @@ impl DeviceImplExt for T { } } +impl DeviceImplExt for T {} + unsafe impl IsSubclassable for Device { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/device_provider.rs b/gstreamer/src/subclass/device_provider.rs index c84919ec4..9cc70180d 100644 --- a/gstreamer/src/subclass/device_provider.rs +++ b/gstreamer/src/subclass/device_provider.rs @@ -82,15 +82,12 @@ pub trait DeviceProviderImpl: DeviceProviderImplExt + GstObjectImpl + Send + Syn } } -pub trait DeviceProviderImplExt: ObjectSubclass { - fn parent_probe(&self) -> Vec; - - fn parent_start(&self) -> Result<(), LoggableError>; - - fn parent_stop(&self); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl DeviceProviderImplExt for T { +pub trait DeviceProviderImplExt: sealed::Sealed + ObjectSubclass { fn parent_probe(&self) -> Vec { unsafe { let data = Self::type_data(); @@ -141,6 +138,8 @@ impl DeviceProviderImplExt for T { } } +impl DeviceProviderImplExt for T {} + unsafe impl IsSubclassable for DeviceProvider { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index d28e00151..b13f9ce30 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -121,47 +121,12 @@ pub trait ElementImpl: ElementImplExt + GstObjectImpl + Send + Sync { } } -pub trait ElementImplExt: ObjectSubclass { - fn parent_change_state( - &self, - transition: StateChange, - ) -> Result; - - fn parent_request_new_pad( - &self, - templ: &crate::PadTemplate, - name: Option<&str>, - caps: Option<&crate::Caps>, - ) -> Option; - - fn parent_release_pad(&self, pad: &crate::Pad); - - fn parent_send_event(&self, event: Event) -> bool; - - fn parent_query(&self, query: &mut QueryRef) -> bool; - - fn parent_set_context(&self, context: &crate::Context); - - fn parent_set_clock(&self, clock: Option<&crate::Clock>) -> bool; - - fn parent_provide_clock(&self) -> Option; - - fn parent_post_message(&self, msg: crate::Message) -> bool; - - fn panicked(&self) -> &atomic::AtomicBool; - - fn catch_panic R, G: FnOnce() -> R>(&self, fallback: G, f: F) -> R; - - fn catch_panic_pad_function R, G: FnOnce() -> R>( - parent: Option<&crate::Object>, - fallback: G, - f: F, - ) -> R; - - fn post_error_message(&self, msg: crate::ErrorMessage); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl ElementImplExt for T { +pub trait ElementImplExt: sealed::Sealed + ObjectSubclass { fn parent_change_state( &self, transition: StateChange, @@ -349,6 +314,8 @@ impl ElementImplExt for T { } } +impl ElementImplExt for T {} + unsafe impl IsSubclassable for Element { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/pad.rs b/gstreamer/src/subclass/pad.rs index 6bfbd9eeb..0b23883b3 100644 --- a/gstreamer/src/subclass/pad.rs +++ b/gstreamer/src/subclass/pad.rs @@ -15,13 +15,12 @@ pub trait PadImpl: PadImplExt + GstObjectImpl + Send + Sync { } } -pub trait PadImplExt: ObjectSubclass { - fn parent_linked(&self, peer: &Pad); - - fn parent_unlinked(&self, peer: &Pad); +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl PadImplExt for T { +pub trait PadImplExt: sealed::Sealed + ObjectSubclass { fn parent_linked(&self, peer: &Pad) { unsafe { let data = Self::type_data(); @@ -57,6 +56,8 @@ impl PadImplExt for T { } } +impl PadImplExt for T {} + unsafe impl IsSubclassable for Pad { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); diff --git a/gstreamer/src/subclass/uri_handler.rs b/gstreamer/src/subclass/uri_handler.rs index ca6239020..a6769c5dd 100644 --- a/gstreamer/src/subclass/uri_handler.rs +++ b/gstreamer/src/subclass/uri_handler.rs @@ -13,13 +13,12 @@ pub trait URIHandlerImpl: super::element::ElementImpl { fn set_uri(&self, uri: &str) -> Result<(), glib::Error>; } -pub trait URIHandlerImplExt: ObjectSubclass { - fn parent_protocols() -> Vec; - fn parent_uri(&self) -> Option; - fn parent_set_uri(&self, uri: &str) -> Result<(), glib::Error>; +mod sealed { + pub trait Sealed {} + impl Sealed for T {} } -impl URIHandlerImplExt for T { +pub trait URIHandlerImplExt: sealed::Sealed + ObjectSubclass { fn parent_protocols() -> Vec { unsafe { let type_data = Self::type_data(); @@ -74,6 +73,8 @@ impl URIHandlerImplExt for T { } } +impl URIHandlerImplExt for T {} + unsafe impl IsImplementable for URIHandler { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); diff --git a/gstreamer/src/tag_setter.rs b/gstreamer/src/tag_setter.rs index e98ea6a5f..15aa9ce87 100644 --- a/gstreamer/src/tag_setter.rs +++ b/gstreamer/src/tag_setter.rs @@ -4,12 +4,13 @@ use glib::{prelude::*, translate::*}; use crate::{tags::*, TagMergeMode, TagSetter}; -pub trait TagSetterExtManual: 'static { - #[doc(alias = "gst_tag_setter_add_tag_value")] - fn add_tag<'a, T: Tag<'a>>(&self, value: &T::TagType, mode: TagMergeMode); +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> TagSetterExtManual for O { +pub trait TagSetterExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_tag_setter_add_tag_value")] fn add_tag<'a, T: Tag<'a>>(&self, value: &T::TagType, mode: TagMergeMode) { unsafe { let v = value.to_send_value(); @@ -23,3 +24,5 @@ impl> TagSetterExtManual for O { } } } + +impl> TagSetterExtManual for O {} diff --git a/gstreamer/src/task_pool.rs b/gstreamer/src/task_pool.rs index 2d9fd896a..64d6eae54 100644 --- a/gstreamer/src/task_pool.rs +++ b/gstreamer/src/task_pool.rs @@ -10,16 +10,13 @@ unsafe extern "C" fn task_pool_trampoline(data: gp let func = Box::from_raw(data as *mut P); func() } - -pub trait TaskPoolExtManual: 'static { - #[doc(alias = "gst_task_pool_push")] - fn push( - &self, - func: P, - ) -> Result, glib::Error>; +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl> TaskPoolExtManual for O { +pub trait TaskPoolExtManual: sealed::Sealed + IsA + 'static { + #[doc(alias = "gst_task_pool_push")] fn push( &self, func: P, @@ -56,6 +53,8 @@ impl> TaskPoolExtManual for O { } } +impl> TaskPoolExtManual for O {} + impl TaskPool { unsafe fn join(&self, id: ptr::NonNull) { ffi::gst_task_pool_join(self.to_glib_none().0, id.as_ptr())