1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Take a look at the license at the top of the repository in the LICENSE file.

use std::mem;

use glib::{prelude::*, translate::*};

use crate::{RTSPSession, RTSPSessionMedia};

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::RTSPSession>> Sealed for T {}
}

pub trait RTSPSessionExtManual: sealed::Sealed + IsA<super::RTSPSession> + 'static {
    /// Gets the session media for `path`. `matched` will contain the number of matched
    /// characters of `path`.
    /// ## `path`
    /// the path for the media
    ///
    /// # Returns
    ///
    /// the configuration for `path` in `self`.
    ///
    /// ## `matched`
    /// the amount of matched characters
    #[doc(alias = "gst_rtsp_session_dup_media")]
    #[doc(alias = "gst_rtsp_session_get_media")]
    fn media(&self, path: &str) -> (Option<RTSPSessionMedia>, i32) {
        #[cfg(feature = "v1_20")]
        unsafe {
            let mut matched = mem::MaybeUninit::uninit();
            let ret = from_glib_full(ffi::gst_rtsp_session_dup_media(
                self.as_ref().to_glib_none().0,
                path.to_glib_none().0,
                matched.as_mut_ptr(),
            ));
            (ret, matched.assume_init())
        }
        #[cfg(not(any(feature = "v1_20", docsrs)))]
        unsafe {
            let mut matched = mem::MaybeUninit::uninit();
            let ret = from_glib_none(ffi::gst_rtsp_session_get_media(
                self.as_ref().to_glib_none().0,
                path.to_glib_none().0,
                matched.as_mut_ptr(),
            ));
            (ret, matched.assume_init())
        }
    }
}

impl<O: IsA<RTSPSession>> RTSPSessionExtManual for O {}