gstreamer_rtsp_server/
rtsp_session.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::mem;
4
5use glib::{prelude::*, translate::*};
6
7use crate::{ffi, RTSPSession, RTSPSessionMedia};
8
9mod sealed {
10    pub trait Sealed {}
11    impl<T: super::IsA<super::RTSPSession>> Sealed for T {}
12}
13
14pub trait RTSPSessionExtManual: sealed::Sealed + IsA<super::RTSPSession> + 'static {
15    /// Gets the session media for `path`. `matched` will contain the number of matched
16    /// characters of `path`.
17    /// ## `path`
18    /// the path for the media
19    ///
20    /// # Returns
21    ///
22    /// the configuration for `path` in `self`.
23    ///
24    /// ## `matched`
25    /// the amount of matched characters
26    #[doc(alias = "gst_rtsp_session_dup_media")]
27    #[doc(alias = "gst_rtsp_session_get_media")]
28    fn media(&self, path: &str) -> (Option<RTSPSessionMedia>, i32) {
29        #[cfg(feature = "v1_20")]
30        unsafe {
31            let mut matched = mem::MaybeUninit::uninit();
32            let ret = from_glib_full(ffi::gst_rtsp_session_dup_media(
33                self.as_ref().to_glib_none().0,
34                path.to_glib_none().0,
35                matched.as_mut_ptr(),
36            ));
37            (ret, matched.assume_init())
38        }
39        #[cfg(not(any(feature = "v1_20", docsrs)))]
40        unsafe {
41            let mut matched = mem::MaybeUninit::uninit();
42            let ret = from_glib_none(ffi::gst_rtsp_session_get_media(
43                self.as_ref().to_glib_none().0,
44                path.to_glib_none().0,
45                matched.as_mut_ptr(),
46            ));
47            (ret, matched.assume_init())
48        }
49    }
50}
51
52impl<O: IsA<RTSPSession>> RTSPSessionExtManual for O {}