gstreamer_rtsp_server/auto/
rtsp_session_media.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, RTSPMedia, RTSPStreamTransport};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// State of a client session regarding a specific media identified by path.
11    ///
12    /// # Implements
13    ///
14    /// [`RTSPSessionMediaExt`][trait@crate::prelude::RTSPSessionMediaExt], [`trait@glib::ObjectExt`]
15    #[doc(alias = "GstRTSPSessionMedia")]
16    pub struct RTSPSessionMedia(Object<ffi::GstRTSPSessionMedia, ffi::GstRTSPSessionMediaClass>);
17
18    match fn {
19        type_ => || ffi::gst_rtsp_session_media_get_type(),
20    }
21}
22
23impl RTSPSessionMedia {
24    pub const NONE: Option<&'static RTSPSessionMedia> = None;
25
26    /// Create a new [`RTSPSessionMedia`][crate::RTSPSessionMedia] that manages the streams
27    /// in `media` for `path`. `media` should be prepared.
28    ///
29    /// Ownership is taken of `media`.
30    /// ## `path`
31    /// the path
32    /// ## `media`
33    /// the [`RTSPMedia`][crate::RTSPMedia]
34    ///
35    /// # Returns
36    ///
37    /// a new [`RTSPSessionMedia`][crate::RTSPSessionMedia].
38    #[doc(alias = "gst_rtsp_session_media_new")]
39    pub fn new(path: &str, media: impl IsA<RTSPMedia>) -> RTSPSessionMedia {
40        skip_assert_initialized!();
41        unsafe {
42            from_glib_full(ffi::gst_rtsp_session_media_new(
43                path.to_glib_none().0,
44                media.upcast().into_glib_ptr(),
45            ))
46        }
47    }
48}
49
50unsafe impl Send for RTSPSessionMedia {}
51unsafe impl Sync for RTSPSessionMedia {}
52
53mod sealed {
54    pub trait Sealed {}
55    impl<T: super::IsA<super::RTSPSessionMedia>> Sealed for T {}
56}
57
58/// Trait containing all [`struct@RTSPSessionMedia`] methods.
59///
60/// # Implementors
61///
62/// [`RTSPSessionMedia`][struct@crate::RTSPSessionMedia]
63pub trait RTSPSessionMediaExt: IsA<RTSPSessionMedia> + sealed::Sealed + 'static {
64    //#[doc(alias = "gst_rtsp_session_media_alloc_channels")]
65    //fn alloc_channels(&self, range: /*Ignored*/gst_rtsp::RTSPRange) -> bool {
66    //    unsafe { TODO: call ffi:gst_rtsp_session_media_alloc_channels() }
67    //}
68
69    /// Get the base_time of the [`RTSPMedia`][crate::RTSPMedia] in `self`
70    ///
71    /// # Returns
72    ///
73    /// the base_time of the media.
74    #[doc(alias = "gst_rtsp_session_media_get_base_time")]
75    #[doc(alias = "get_base_time")]
76    fn base_time(&self) -> Option<gst::ClockTime> {
77        unsafe {
78            from_glib(ffi::gst_rtsp_session_media_get_base_time(
79                self.as_ref().to_glib_none().0,
80            ))
81        }
82    }
83
84    /// Get the [`RTSPMedia`][crate::RTSPMedia] that was used when constructing `self`
85    ///
86    /// # Returns
87    ///
88    /// the [`RTSPMedia`][crate::RTSPMedia] of `self`.
89    /// Remains valid as long as `self` is valid.
90    #[doc(alias = "gst_rtsp_session_media_get_media")]
91    #[doc(alias = "get_media")]
92    fn media(&self) -> Option<RTSPMedia> {
93        unsafe {
94            from_glib_none(ffi::gst_rtsp_session_media_get_media(
95                self.as_ref().to_glib_none().0,
96            ))
97        }
98    }
99
100    /// Retrieve the RTP-Info header string for all streams in `self`
101    /// with configured transports.
102    ///
103    /// # Returns
104    ///
105    /// The RTP-Info as a string or
106    /// [`None`] when no RTP-Info could be generated, `g_free()` after usage.
107    #[doc(alias = "gst_rtsp_session_media_get_rtpinfo")]
108    #[doc(alias = "get_rtpinfo")]
109    fn rtpinfo(&self) -> Option<glib::GString> {
110        unsafe {
111            from_glib_full(ffi::gst_rtsp_session_media_get_rtpinfo(
112                self.as_ref().to_glib_none().0,
113            ))
114        }
115    }
116
117    //#[doc(alias = "gst_rtsp_session_media_get_rtsp_state")]
118    //#[doc(alias = "get_rtsp_state")]
119    //fn rtsp_state(&self) -> /*Ignored*/gst_rtsp::RTSPState {
120    //    unsafe { TODO: call ffi:gst_rtsp_session_media_get_rtsp_state() }
121    //}
122
123    /// Get a previously created [`RTSPStreamTransport`][crate::RTSPStreamTransport] for the stream at `idx`.
124    /// ## `idx`
125    /// the stream index
126    ///
127    /// # Returns
128    ///
129    /// a [`RTSPStreamTransport`][crate::RTSPStreamTransport] that is
130    /// valid until the session of `self` is unreffed.
131    #[doc(alias = "gst_rtsp_session_media_get_transport")]
132    #[doc(alias = "get_transport")]
133    fn transport(&self, idx: u32) -> Option<RTSPStreamTransport> {
134        unsafe {
135            from_glib_none(ffi::gst_rtsp_session_media_get_transport(
136                self.as_ref().to_glib_none().0,
137                idx,
138            ))
139        }
140    }
141
142    /// Get a list of all available [`RTSPStreamTransport`][crate::RTSPStreamTransport] in this session.
143    ///
144    /// # Returns
145    ///
146    /// a
147    /// list of [`RTSPStreamTransport`][crate::RTSPStreamTransport], g_ptr_array_unref () after usage.
148    #[doc(alias = "gst_rtsp_session_media_get_transports")]
149    #[doc(alias = "get_transports")]
150    fn transports(&self) -> Vec<RTSPStreamTransport> {
151        unsafe {
152            FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_media_get_transports(
153                self.as_ref().to_glib_none().0,
154            ))
155        }
156    }
157
158    /// Check if the path of `self` matches `path`. It `path` matches, the amount of
159    /// matched characters is returned in `matched`.
160    /// ## `path`
161    /// a path
162    ///
163    /// # Returns
164    ///
165    /// [`true`] when `path` matches the path of `self`.
166    ///
167    /// ## `matched`
168    /// the amount of matched characters of `path`
169    #[doc(alias = "gst_rtsp_session_media_matches")]
170    fn matches(&self, path: &str) -> Option<i32> {
171        unsafe {
172            let mut matched = std::mem::MaybeUninit::uninit();
173            let ret = from_glib(ffi::gst_rtsp_session_media_matches(
174                self.as_ref().to_glib_none().0,
175                path.to_glib_none().0,
176                matched.as_mut_ptr(),
177            ));
178            if ret {
179                Some(matched.assume_init())
180            } else {
181                None
182            }
183        }
184    }
185
186    //#[doc(alias = "gst_rtsp_session_media_set_rtsp_state")]
187    //fn set_rtsp_state(&self, state: /*Ignored*/gst_rtsp::RTSPState) {
188    //    unsafe { TODO: call ffi:gst_rtsp_session_media_set_rtsp_state() }
189    //}
190
191    /// Tell the media object `self` to change to `state`.
192    /// ## `state`
193    /// the new state
194    ///
195    /// # Returns
196    ///
197    /// [`true`] on success.
198    #[doc(alias = "gst_rtsp_session_media_set_state")]
199    fn set_state(&self, state: gst::State) -> Result<(), glib::error::BoolError> {
200        unsafe {
201            glib::result_from_gboolean!(
202                ffi::gst_rtsp_session_media_set_state(
203                    self.as_ref().to_glib_none().0,
204                    state.into_glib()
205                ),
206                "Failed to set state of session media"
207            )
208        }
209    }
210
211    //#[doc(alias = "gst_rtsp_session_media_set_transport")]
212    //fn set_transport(&self, stream: &impl IsA<RTSPStream>, tr: /*Ignored*/gst_rtsp::RTSPTransport) -> RTSPStreamTransport {
213    //    unsafe { TODO: call ffi:gst_rtsp_session_media_set_transport() }
214    //}
215}
216
217impl<O: IsA<RTSPSessionMedia>> RTSPSessionMediaExt for O {}