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
53/// Trait containing all [`struct@RTSPSessionMedia`] methods.
54///
55/// # Implementors
56///
57/// [`RTSPSessionMedia`][struct@crate::RTSPSessionMedia]
58pub trait RTSPSessionMediaExt: IsA<RTSPSessionMedia> + 'static {
59 //#[doc(alias = "gst_rtsp_session_media_alloc_channels")]
60 //fn alloc_channels(&self, range: /*Ignored*/gst_rtsp::RTSPRange) -> bool {
61 // unsafe { TODO: call ffi:gst_rtsp_session_media_alloc_channels() }
62 //}
63
64 /// Get the base_time of the [`RTSPMedia`][crate::RTSPMedia] in `self`
65 ///
66 /// # Returns
67 ///
68 /// the base_time of the media.
69 #[doc(alias = "gst_rtsp_session_media_get_base_time")]
70 #[doc(alias = "get_base_time")]
71 fn base_time(&self) -> Option<gst::ClockTime> {
72 unsafe {
73 from_glib(ffi::gst_rtsp_session_media_get_base_time(
74 self.as_ref().to_glib_none().0,
75 ))
76 }
77 }
78
79 /// Get the [`RTSPMedia`][crate::RTSPMedia] that was used when constructing `self`
80 ///
81 /// # Returns
82 ///
83 /// the [`RTSPMedia`][crate::RTSPMedia] of `self`.
84 /// Remains valid as long as `self` is valid.
85 #[doc(alias = "gst_rtsp_session_media_get_media")]
86 #[doc(alias = "get_media")]
87 fn media(&self) -> Option<RTSPMedia> {
88 unsafe {
89 from_glib_none(ffi::gst_rtsp_session_media_get_media(
90 self.as_ref().to_glib_none().0,
91 ))
92 }
93 }
94
95 /// Retrieve the RTP-Info header string for all streams in `self`
96 /// with configured transports.
97 ///
98 /// # Returns
99 ///
100 /// The RTP-Info as a string or
101 /// [`None`] when no RTP-Info could be generated, `g_free()` after usage.
102 #[doc(alias = "gst_rtsp_session_media_get_rtpinfo")]
103 #[doc(alias = "get_rtpinfo")]
104 fn rtpinfo(&self) -> Option<glib::GString> {
105 unsafe {
106 from_glib_full(ffi::gst_rtsp_session_media_get_rtpinfo(
107 self.as_ref().to_glib_none().0,
108 ))
109 }
110 }
111
112 //#[doc(alias = "gst_rtsp_session_media_get_rtsp_state")]
113 //#[doc(alias = "get_rtsp_state")]
114 //fn rtsp_state(&self) -> /*Ignored*/gst_rtsp::RTSPState {
115 // unsafe { TODO: call ffi:gst_rtsp_session_media_get_rtsp_state() }
116 //}
117
118 /// Get a previously created [`RTSPStreamTransport`][crate::RTSPStreamTransport] for the stream at `idx`.
119 /// ## `idx`
120 /// the stream index
121 ///
122 /// # Returns
123 ///
124 /// a [`RTSPStreamTransport`][crate::RTSPStreamTransport] that is
125 /// valid until the session of `self` is unreffed.
126 #[doc(alias = "gst_rtsp_session_media_get_transport")]
127 #[doc(alias = "get_transport")]
128 fn transport(&self, idx: u32) -> Option<RTSPStreamTransport> {
129 unsafe {
130 from_glib_none(ffi::gst_rtsp_session_media_get_transport(
131 self.as_ref().to_glib_none().0,
132 idx,
133 ))
134 }
135 }
136
137 /// Get a list of all available [`RTSPStreamTransport`][crate::RTSPStreamTransport] in this session.
138 ///
139 /// # Returns
140 ///
141 /// a
142 /// list of [`RTSPStreamTransport`][crate::RTSPStreamTransport], g_ptr_array_unref () after usage.
143 #[doc(alias = "gst_rtsp_session_media_get_transports")]
144 #[doc(alias = "get_transports")]
145 fn transports(&self) -> Vec<RTSPStreamTransport> {
146 unsafe {
147 FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_media_get_transports(
148 self.as_ref().to_glib_none().0,
149 ))
150 }
151 }
152
153 /// Check if the path of `self` matches `path`. It `path` matches, the amount of
154 /// matched characters is returned in `matched`.
155 /// ## `path`
156 /// a path
157 ///
158 /// # Returns
159 ///
160 /// [`true`] when `path` matches the path of `self`.
161 ///
162 /// ## `matched`
163 /// the amount of matched characters of `path`
164 #[doc(alias = "gst_rtsp_session_media_matches")]
165 fn matches(&self, path: &str) -> Option<i32> {
166 unsafe {
167 let mut matched = std::mem::MaybeUninit::uninit();
168 let ret = from_glib(ffi::gst_rtsp_session_media_matches(
169 self.as_ref().to_glib_none().0,
170 path.to_glib_none().0,
171 matched.as_mut_ptr(),
172 ));
173 if ret {
174 Some(matched.assume_init())
175 } else {
176 None
177 }
178 }
179 }
180
181 //#[doc(alias = "gst_rtsp_session_media_set_rtsp_state")]
182 //fn set_rtsp_state(&self, state: /*Ignored*/gst_rtsp::RTSPState) {
183 // unsafe { TODO: call ffi:gst_rtsp_session_media_set_rtsp_state() }
184 //}
185
186 /// Tell the media object `self` to change to `state`.
187 /// ## `state`
188 /// the new state
189 ///
190 /// # Returns
191 ///
192 /// [`true`] on success.
193 #[doc(alias = "gst_rtsp_session_media_set_state")]
194 fn set_state(&self, state: gst::State) -> Result<(), glib::error::BoolError> {
195 unsafe {
196 glib::result_from_gboolean!(
197 ffi::gst_rtsp_session_media_set_state(
198 self.as_ref().to_glib_none().0,
199 state.into_glib()
200 ),
201 "Failed to set state of session media"
202 )
203 }
204 }
205
206 //#[doc(alias = "gst_rtsp_session_media_set_transport")]
207 //fn set_transport(&self, stream: &impl IsA<RTSPStream>, tr: /*Ignored*/gst_rtsp::RTSPTransport) -> RTSPStreamTransport {
208 // unsafe { TODO: call ffi:gst_rtsp_session_media_set_transport() }
209 //}
210}
211
212impl<O: IsA<RTSPSessionMedia>> RTSPSessionMediaExt for O {}