gstreamer_rtsp_server/subclass/
rtsp_mount_points.rs
1use glib::{prelude::*, subclass::prelude::*, translate::*};
4use gst_rtsp::ffi::GstRTSPUrl;
5
6use crate::{ffi, RTSPMountPoints};
7
8pub trait RTSPMountPointsImpl: RTSPMountPointsImplExt + ObjectImpl + Send + Sync {
9 fn make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
17 self.parent_make_path(url)
18 }
19}
20
21mod sealed {
22 pub trait Sealed {}
23 impl<T: super::RTSPMountPointsImplExt> Sealed for T {}
24}
25
26pub trait RTSPMountPointsImplExt: sealed::Sealed + ObjectSubclass {
27 fn parent_make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
28 unsafe {
29 let data = Self::type_data();
30 let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMountPointsClass;
31 let f = (*parent_class)
32 .make_path
33 .expect("No `make_path` virtual method implementation in parent class");
34 from_glib_full(f(
35 self.obj()
36 .unsafe_cast_ref::<RTSPMountPoints>()
37 .to_glib_none()
38 .0,
39 url.to_glib_none().0,
40 ))
41 }
42 }
43}
44
45impl<T: RTSPMountPointsImpl> RTSPMountPointsImplExt for T {}
46
47unsafe impl<T: RTSPMountPointsImpl> IsSubclassable<T> for RTSPMountPoints {
48 fn class_init(klass: &mut glib::Class<Self>) {
49 Self::parent_class_init::<T>(klass);
50 let klass = klass.as_mut();
51 klass.make_path = Some(mount_points_make_path::<T>);
52 }
53}
54
55unsafe extern "C" fn mount_points_make_path<T: RTSPMountPointsImpl>(
56 ptr: *mut ffi::GstRTSPMountPoints,
57 url: *const GstRTSPUrl,
58) -> *mut std::os::raw::c_char {
59 let instance = &*(ptr as *mut T::Instance);
60 let imp = instance.imp();
61
62 imp.make_path(&from_glib_borrow(url)).into_glib_ptr()
63}