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
9pub trait RTSPSessionExtManual: IsA<super::RTSPSession> + 'static {
10    /// Gets the session media for `path`. `matched` will contain the number of matched
11    /// characters of `path`.
12    /// ## `path`
13    /// the path for the media
14    ///
15    /// # Returns
16    ///
17    /// the configuration for `path` in `self`.
18    ///
19    /// ## `matched`
20    /// the amount of matched characters
21    #[doc(alias = "gst_rtsp_session_dup_media")]
22    #[doc(alias = "gst_rtsp_session_get_media")]
23    fn media(&self, path: &str) -> (Option<RTSPSessionMedia>, i32) {
24        #[cfg(feature = "v1_20")]
25        unsafe {
26            let mut matched = mem::MaybeUninit::uninit();
27            let ret = from_glib_full(ffi::gst_rtsp_session_dup_media(
28                self.as_ref().to_glib_none().0,
29                path.to_glib_none().0,
30                matched.as_mut_ptr(),
31            ));
32            (ret, matched.assume_init())
33        }
34        #[cfg(not(any(feature = "v1_20", docsrs)))]
35        unsafe {
36            let mut matched = mem::MaybeUninit::uninit();
37            let ret = from_glib_none(ffi::gst_rtsp_session_get_media(
38                self.as_ref().to_glib_none().0,
39                path.to_glib_none().0,
40                matched.as_mut_ptr(),
41            ));
42            (ret, matched.assume_init())
43        }
44    }
45}
46
47impl<O: IsA<RTSPSession>> RTSPSessionExtManual for O {}