gstreamer_rtsp_server/subclass/rtsp_onvif_media_factory.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{prelude::*, subclass::prelude::*, translate::*};
4
5use super::prelude::*;
6use crate::{ffi, RTSPOnvifMediaFactory};
7
8pub trait RTSPOnvifMediaFactoryImpl:
9 RTSPMediaFactoryImpl + ObjectSubclass<Type: IsA<RTSPOnvifMediaFactory>> + Send + Sync
10{
11 fn has_backchannel_support(&self) -> bool {
12 self.parent_has_backchannel_support()
13 }
14}
15
16pub trait RTSPOnvifMediaFactoryImplExt: RTSPOnvifMediaFactoryImpl {
17 fn parent_has_backchannel_support(&self) -> bool {
18 unsafe {
19 let data = Self::type_data();
20 let parent_class =
21 data.as_ref().parent_class() as *mut ffi::GstRTSPOnvifMediaFactoryClass;
22 (*parent_class)
23 .has_backchannel_support
24 .map(|f| {
25 from_glib(f(self
26 .obj()
27 .unsafe_cast_ref::<RTSPOnvifMediaFactory>()
28 .to_glib_none()
29 .0))
30 })
31 .unwrap_or(false)
32 }
33 }
34}
35
36impl<T: RTSPOnvifMediaFactoryImpl> RTSPOnvifMediaFactoryImplExt for T {}
37
38unsafe impl<T: RTSPOnvifMediaFactoryImpl> IsSubclassable<T> for RTSPOnvifMediaFactory {
39 fn class_init(klass: &mut glib::Class<Self>) {
40 Self::parent_class_init::<T>(klass);
41 let klass = klass.as_mut();
42 klass.has_backchannel_support = Some(factory_has_backchannel_support::<T>);
43 }
44}
45
46unsafe extern "C" fn factory_has_backchannel_support<T: RTSPOnvifMediaFactoryImpl>(
47 ptr: *mut ffi::GstRTSPOnvifMediaFactory,
48) -> glib::ffi::gboolean {
49 let instance = &*(ptr as *mut T::Instance);
50 let imp = instance.imp();
51
52 imp.has_backchannel_support().into_glib()
53}