From b451f692cfe340fd54e0f204a5383cffd4406d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 18 Feb 2022 13:48:34 +0200 Subject: [PATCH] rtsp-server: Add subclassing support for Onvif-specific client/media/media-factory/server --- gstreamer-rtsp-server/src/subclass/mod.rs | 27 +++++++++ .../src/subclass/rtsp_onvif_client.rs | 10 ++++ .../src/subclass/rtsp_onvif_media.rs | 10 ++++ .../src/subclass/rtsp_onvif_media_factory.rs | 58 +++++++++++++++++++ .../src/subclass/rtsp_onvif_server.rs | 10 ++++ 5 files changed, 115 insertions(+) create mode 100644 gstreamer-rtsp-server/src/subclass/rtsp_onvif_client.rs create mode 100644 gstreamer-rtsp-server/src/subclass/rtsp_onvif_media.rs create mode 100644 gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs create mode 100644 gstreamer-rtsp-server/src/subclass/rtsp_onvif_server.rs diff --git a/gstreamer-rtsp-server/src/subclass/mod.rs b/gstreamer-rtsp-server/src/subclass/mod.rs index a866e94d2..468bfb36b 100644 --- a/gstreamer-rtsp-server/src/subclass/mod.rs +++ b/gstreamer-rtsp-server/src/subclass/mod.rs @@ -8,6 +8,19 @@ mod rtsp_media_factory; mod rtsp_mount_points; mod rtsp_server; +#[cfg(any(feature = "v1_14", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] +mod rtsp_onvif_client; +#[cfg(any(feature = "v1_14", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] +mod rtsp_onvif_media; +#[cfg(any(feature = "v1_14", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] +mod rtsp_onvif_media_factory; +#[cfg(any(feature = "v1_14", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] +mod rtsp_onvif_server; + pub use self::rtsp_media::SDPInfo; pub mod prelude { @@ -18,5 +31,19 @@ pub mod prelude { pub use super::rtsp_media::{RTSPMediaImpl, RTSPMediaImplExt}; pub use super::rtsp_media_factory::{RTSPMediaFactoryImpl, RTSPMediaFactoryImplExt}; pub use super::rtsp_mount_points::{RTSPMountPointsImpl, RTSPMountPointsImplExt}; + #[cfg(any(feature = "v1_14", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] + pub use super::rtsp_onvif_client::RTSPOnvifClientImpl; + #[cfg(any(feature = "v1_14", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] + pub use super::rtsp_onvif_media::RTSPOnvifMediaImpl; + #[cfg(any(feature = "v1_14", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] + pub use super::rtsp_onvif_media_factory::{ + RTSPOnvifMediaFactoryImpl, RTSPOnvifMediaFactoryImplExt, + }; + #[cfg(any(feature = "v1_14", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] + pub use super::rtsp_onvif_server::RTSPOnvifServerImpl; pub use super::rtsp_server::{RTSPServerImpl, RTSPServerImplExt}; } diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_onvif_client.rs b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_client.rs new file mode 100644 index 000000000..b0007da4a --- /dev/null +++ b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_client.rs @@ -0,0 +1,10 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use glib::subclass::prelude::*; + +use super::prelude::*; +use crate::RTSPOnvifClient; + +pub trait RTSPOnvifClientImpl: RTSPClientImpl + Send + Sync {} + +unsafe impl IsSubclassable for RTSPOnvifClient {} diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media.rs b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media.rs new file mode 100644 index 000000000..cfec2f9a4 --- /dev/null +++ b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media.rs @@ -0,0 +1,10 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use glib::subclass::prelude::*; + +use super::prelude::*; +use crate::RTSPOnvifMedia; + +pub trait RTSPOnvifMediaImpl: RTSPMediaImpl + Send + Sync {} + +unsafe impl IsSubclassable for RTSPOnvifMedia {} diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs new file mode 100644 index 000000000..623915ac4 --- /dev/null +++ b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_media_factory.rs @@ -0,0 +1,58 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use glib::prelude::*; +use glib::subclass::prelude::*; +use glib::translate::*; + +use super::prelude::*; +use crate::RTSPOnvifMediaFactory; + +pub trait RTSPOnvifMediaFactoryImpl: + RTSPMediaFactoryImplExt + RTSPMediaFactoryImpl + Send + Sync +{ + fn has_backchannel_support(&self, factory: &Self::Type) -> bool { + self.parent_has_backchannel_support(factory) + } +} + +pub trait RTSPOnvifMediaFactoryImplExt: ObjectSubclass { + fn parent_has_backchannel_support(&self, factory: &Self::Type) -> bool; +} + +impl RTSPOnvifMediaFactoryImplExt for T { + fn parent_has_backchannel_support(&self, factory: &Self::Type) -> bool { + unsafe { + let data = Self::type_data(); + let parent_class = + data.as_ref().parent_class() as *mut ffi::GstRTSPOnvifMediaFactoryClass; + (*parent_class) + .has_backchannel_support + .map(|f| { + from_glib(f(factory + .unsafe_cast_ref::() + .to_glib_none() + .0)) + }) + .unwrap_or(false) + } + } +} + +unsafe impl IsSubclassable for RTSPOnvifMediaFactory { + fn class_init(klass: &mut glib::Class) { + Self::parent_class_init::(klass); + let klass = klass.as_mut(); + klass.has_backchannel_support = Some(factory_has_backchannel_support::); + } +} + +unsafe extern "C" fn factory_has_backchannel_support( + ptr: *mut ffi::GstRTSPOnvifMediaFactory, +) -> glib::ffi::gboolean { + let instance = &*(ptr as *mut T::Instance); + let imp = instance.imp(); + let wrap: Borrowed = from_glib_borrow(ptr); + + imp.has_backchannel_support(wrap.unsafe_cast_ref()) + .into_glib() +} diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_onvif_server.rs b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_server.rs new file mode 100644 index 000000000..96d0ae423 --- /dev/null +++ b/gstreamer-rtsp-server/src/subclass/rtsp_onvif_server.rs @@ -0,0 +1,10 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use glib::subclass::prelude::*; + +use super::prelude::*; +use crate::RTSPOnvifServer; + +pub trait RTSPOnvifServerImpl: RTSPServerImpl + Send + Sync {} + +unsafe impl IsSubclassable for RTSPOnvifServer {}