gstreamer_rtsp_server/auto/
rtsp_session.rs
1use crate::{ffi, RTSPFilterResult, RTSPMedia, RTSPSessionMedia};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstRTSPSession")]
41 pub struct RTSPSession(Object<ffi::GstRTSPSession, ffi::GstRTSPSessionClass>);
42
43 match fn {
44 type_ => || ffi::gst_rtsp_session_get_type(),
45 }
46}
47
48impl RTSPSession {
49 pub const NONE: Option<&'static RTSPSession> = None;
50
51 #[doc(alias = "gst_rtsp_session_new")]
59 pub fn new(sessionid: &str) -> RTSPSession {
60 assert_initialized_main_thread!();
61 unsafe { from_glib_full(ffi::gst_rtsp_session_new(sessionid.to_glib_none().0)) }
62 }
63}
64
65unsafe impl Send for RTSPSession {}
66unsafe impl Sync for RTSPSession {}
67
68mod sealed {
69 pub trait Sealed {}
70 impl<T: super::IsA<super::RTSPSession>> Sealed for T {}
71}
72
73pub trait RTSPSessionExt: IsA<RTSPSession> + sealed::Sealed + 'static {
79 #[doc(alias = "gst_rtsp_session_allow_expire")]
82 fn allow_expire(&self) {
83 unsafe {
84 ffi::gst_rtsp_session_allow_expire(self.as_ref().to_glib_none().0);
85 }
86 }
87
88 #[doc(alias = "gst_rtsp_session_filter")]
111 fn filter(
112 &self,
113 func: Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)>,
114 ) -> Vec<RTSPSessionMedia> {
115 let mut func_data: Option<
116 &mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult),
117 > = func;
118 unsafe extern "C" fn func_func(
119 sess: *mut ffi::GstRTSPSession,
120 media: *mut ffi::GstRTSPSessionMedia,
121 user_data: glib::ffi::gpointer,
122 ) -> ffi::GstRTSPFilterResult {
123 let sess = from_glib_borrow(sess);
124 let media = from_glib_borrow(media);
125 let callback = user_data
126 as *mut Option<
127 &mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult),
128 >;
129 if let Some(ref mut callback) = *callback {
130 callback(&sess, &media)
131 } else {
132 panic!("cannot get closure...")
133 }
134 .into_glib()
135 }
136 let func = if func_data.is_some() {
137 Some(func_func as _)
138 } else {
139 None
140 };
141 let super_callback0: &mut Option<
142 &mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult),
143 > = &mut func_data;
144 unsafe {
145 FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_filter(
146 self.as_ref().to_glib_none().0,
147 func,
148 super_callback0 as *mut _ as *mut _,
149 ))
150 }
151 }
152
153 #[doc(alias = "gst_rtsp_session_get_header")]
160 #[doc(alias = "get_header")]
161 fn header(&self) -> Option<glib::GString> {
162 unsafe {
163 from_glib_full(ffi::gst_rtsp_session_get_header(
164 self.as_ref().to_glib_none().0,
165 ))
166 }
167 }
168
169 #[doc(alias = "gst_rtsp_session_get_sessionid")]
176 #[doc(alias = "get_sessionid")]
177 fn sessionid(&self) -> Option<glib::GString> {
178 unsafe {
179 from_glib_none(ffi::gst_rtsp_session_get_sessionid(
180 self.as_ref().to_glib_none().0,
181 ))
182 }
183 }
184
185 #[doc(alias = "gst_rtsp_session_get_timeout")]
191 #[doc(alias = "get_timeout")]
192 fn timeout(&self) -> u32 {
193 unsafe { ffi::gst_rtsp_session_get_timeout(self.as_ref().to_glib_none().0) }
194 }
195
196 #[doc(alias = "gst_rtsp_session_is_expired_usec")]
209 fn is_expired_usec(&self, now: i64) -> bool {
210 unsafe {
211 from_glib(ffi::gst_rtsp_session_is_expired_usec(
212 self.as_ref().to_glib_none().0,
213 now,
214 ))
215 }
216 }
217
218 #[doc(alias = "gst_rtsp_session_manage_media")]
231 fn manage_media(&self, path: &str, media: impl IsA<RTSPMedia>) -> RTSPSessionMedia {
232 unsafe {
233 from_glib_none(ffi::gst_rtsp_session_manage_media(
234 self.as_ref().to_glib_none().0,
235 path.to_glib_none().0,
236 media.upcast().into_glib_ptr(),
237 ))
238 }
239 }
240
241 #[doc(alias = "gst_rtsp_session_next_timeout_usec")]
254 fn next_timeout_usec(&self, now: i64) -> i32 {
255 unsafe { ffi::gst_rtsp_session_next_timeout_usec(self.as_ref().to_glib_none().0, now) }
256 }
257
258 #[doc(alias = "gst_rtsp_session_prevent_expire")]
260 fn prevent_expire(&self) {
261 unsafe {
262 ffi::gst_rtsp_session_prevent_expire(self.as_ref().to_glib_none().0);
263 }
264 }
265
266 #[doc(alias = "gst_rtsp_session_release_media")]
274 fn release_media(&self, media: &impl IsA<RTSPSessionMedia>) -> bool {
275 unsafe {
276 from_glib(ffi::gst_rtsp_session_release_media(
277 self.as_ref().to_glib_none().0,
278 media.as_ref().to_glib_none().0,
279 ))
280 }
281 }
282
283 #[doc(alias = "gst_rtsp_session_set_timeout")]
288 #[doc(alias = "timeout")]
289 fn set_timeout(&self, timeout: u32) {
290 unsafe {
291 ffi::gst_rtsp_session_set_timeout(self.as_ref().to_glib_none().0, timeout);
292 }
293 }
294
295 #[doc(alias = "gst_rtsp_session_touch")]
297 fn touch(&self) {
298 unsafe {
299 ffi::gst_rtsp_session_touch(self.as_ref().to_glib_none().0);
300 }
301 }
302
303 #[doc(alias = "extra-timeout")]
304 fn extra_timeout(&self) -> u32 {
305 ObjectExt::property(self.as_ref(), "extra-timeout")
306 }
307
308 #[doc(alias = "extra-timeout")]
309 fn set_extra_timeout(&self, extra_timeout: u32) {
310 ObjectExt::set_property(self.as_ref(), "extra-timeout", extra_timeout)
311 }
312
313 #[doc(alias = "timeout-always-visible")]
314 fn is_timeout_always_visible(&self) -> bool {
315 ObjectExt::property(self.as_ref(), "timeout-always-visible")
316 }
317
318 #[doc(alias = "timeout-always-visible")]
319 fn set_timeout_always_visible(&self, timeout_always_visible: bool) {
320 ObjectExt::set_property(
321 self.as_ref(),
322 "timeout-always-visible",
323 timeout_always_visible,
324 )
325 }
326
327 #[doc(alias = "extra-timeout")]
328 fn connect_extra_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
329 &self,
330 f: F,
331 ) -> SignalHandlerId {
332 unsafe extern "C" fn notify_extra_timeout_trampoline<
333 P: IsA<RTSPSession>,
334 F: Fn(&P) + Send + Sync + 'static,
335 >(
336 this: *mut ffi::GstRTSPSession,
337 _param_spec: glib::ffi::gpointer,
338 f: glib::ffi::gpointer,
339 ) {
340 let f: &F = &*(f as *const F);
341 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
342 }
343 unsafe {
344 let f: Box_<F> = Box_::new(f);
345 connect_raw(
346 self.as_ptr() as *mut _,
347 b"notify::extra-timeout\0".as_ptr() as *const _,
348 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
349 notify_extra_timeout_trampoline::<Self, F> as *const (),
350 )),
351 Box_::into_raw(f),
352 )
353 }
354 }
355
356 #[doc(alias = "timeout")]
357 fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
358 &self,
359 f: F,
360 ) -> SignalHandlerId {
361 unsafe extern "C" fn notify_timeout_trampoline<
362 P: IsA<RTSPSession>,
363 F: Fn(&P) + Send + Sync + 'static,
364 >(
365 this: *mut ffi::GstRTSPSession,
366 _param_spec: glib::ffi::gpointer,
367 f: glib::ffi::gpointer,
368 ) {
369 let f: &F = &*(f as *const F);
370 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
371 }
372 unsafe {
373 let f: Box_<F> = Box_::new(f);
374 connect_raw(
375 self.as_ptr() as *mut _,
376 b"notify::timeout\0".as_ptr() as *const _,
377 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
378 notify_timeout_trampoline::<Self, F> as *const (),
379 )),
380 Box_::into_raw(f),
381 )
382 }
383 }
384
385 #[doc(alias = "timeout-always-visible")]
386 fn connect_timeout_always_visible_notify<F: Fn(&Self) + Send + Sync + 'static>(
387 &self,
388 f: F,
389 ) -> SignalHandlerId {
390 unsafe extern "C" fn notify_timeout_always_visible_trampoline<
391 P: IsA<RTSPSession>,
392 F: Fn(&P) + Send + Sync + 'static,
393 >(
394 this: *mut ffi::GstRTSPSession,
395 _param_spec: glib::ffi::gpointer,
396 f: glib::ffi::gpointer,
397 ) {
398 let f: &F = &*(f as *const F);
399 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
400 }
401 unsafe {
402 let f: Box_<F> = Box_::new(f);
403 connect_raw(
404 self.as_ptr() as *mut _,
405 b"notify::timeout-always-visible\0".as_ptr() as *const _,
406 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
407 notify_timeout_always_visible_trampoline::<Self, F> as *const (),
408 )),
409 Box_::into_raw(f),
410 )
411 }
412 }
413}
414
415impl<O: IsA<RTSPSession>> RTSPSessionExt for O {}