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
68pub trait RTSPSessionExt: IsA<RTSPSession> + 'static {
74 #[doc(alias = "gst_rtsp_session_allow_expire")]
77 fn allow_expire(&self) {
78 unsafe {
79 ffi::gst_rtsp_session_allow_expire(self.as_ref().to_glib_none().0);
80 }
81 }
82
83 #[doc(alias = "gst_rtsp_session_filter")]
106 fn filter(
107 &self,
108 func: Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)>,
109 ) -> Vec<RTSPSessionMedia> {
110 let mut func_data: Option<
111 &mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult),
112 > = func;
113 unsafe extern "C" fn func_func(
114 sess: *mut ffi::GstRTSPSession,
115 media: *mut ffi::GstRTSPSessionMedia,
116 user_data: glib::ffi::gpointer,
117 ) -> ffi::GstRTSPFilterResult {
118 let sess = from_glib_borrow(sess);
119 let media = from_glib_borrow(media);
120 let callback = user_data
121 as *mut Option<
122 &mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult),
123 >;
124 if let Some(ref mut callback) = *callback {
125 callback(&sess, &media)
126 } else {
127 panic!("cannot get closure...")
128 }
129 .into_glib()
130 }
131 let func = if func_data.is_some() {
132 Some(func_func as _)
133 } else {
134 None
135 };
136 let super_callback0: &mut Option<
137 &mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult),
138 > = &mut func_data;
139 unsafe {
140 FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_filter(
141 self.as_ref().to_glib_none().0,
142 func,
143 super_callback0 as *mut _ as *mut _,
144 ))
145 }
146 }
147
148 #[doc(alias = "gst_rtsp_session_get_header")]
155 #[doc(alias = "get_header")]
156 fn header(&self) -> Option<glib::GString> {
157 unsafe {
158 from_glib_full(ffi::gst_rtsp_session_get_header(
159 self.as_ref().to_glib_none().0,
160 ))
161 }
162 }
163
164 #[doc(alias = "gst_rtsp_session_get_sessionid")]
171 #[doc(alias = "get_sessionid")]
172 fn sessionid(&self) -> Option<glib::GString> {
173 unsafe {
174 from_glib_none(ffi::gst_rtsp_session_get_sessionid(
175 self.as_ref().to_glib_none().0,
176 ))
177 }
178 }
179
180 #[doc(alias = "gst_rtsp_session_get_timeout")]
186 #[doc(alias = "get_timeout")]
187 fn timeout(&self) -> u32 {
188 unsafe { ffi::gst_rtsp_session_get_timeout(self.as_ref().to_glib_none().0) }
189 }
190
191 #[doc(alias = "gst_rtsp_session_is_expired_usec")]
204 fn is_expired_usec(&self, now: i64) -> bool {
205 unsafe {
206 from_glib(ffi::gst_rtsp_session_is_expired_usec(
207 self.as_ref().to_glib_none().0,
208 now,
209 ))
210 }
211 }
212
213 #[doc(alias = "gst_rtsp_session_manage_media")]
226 fn manage_media(&self, path: &str, media: impl IsA<RTSPMedia>) -> RTSPSessionMedia {
227 unsafe {
228 from_glib_none(ffi::gst_rtsp_session_manage_media(
229 self.as_ref().to_glib_none().0,
230 path.to_glib_none().0,
231 media.upcast().into_glib_ptr(),
232 ))
233 }
234 }
235
236 #[doc(alias = "gst_rtsp_session_next_timeout_usec")]
249 fn next_timeout_usec(&self, now: i64) -> i32 {
250 unsafe { ffi::gst_rtsp_session_next_timeout_usec(self.as_ref().to_glib_none().0, now) }
251 }
252
253 #[doc(alias = "gst_rtsp_session_prevent_expire")]
255 fn prevent_expire(&self) {
256 unsafe {
257 ffi::gst_rtsp_session_prevent_expire(self.as_ref().to_glib_none().0);
258 }
259 }
260
261 #[doc(alias = "gst_rtsp_session_release_media")]
269 fn release_media(&self, media: &impl IsA<RTSPSessionMedia>) -> bool {
270 unsafe {
271 from_glib(ffi::gst_rtsp_session_release_media(
272 self.as_ref().to_glib_none().0,
273 media.as_ref().to_glib_none().0,
274 ))
275 }
276 }
277
278 #[doc(alias = "gst_rtsp_session_set_timeout")]
283 #[doc(alias = "timeout")]
284 fn set_timeout(&self, timeout: u32) {
285 unsafe {
286 ffi::gst_rtsp_session_set_timeout(self.as_ref().to_glib_none().0, timeout);
287 }
288 }
289
290 #[doc(alias = "gst_rtsp_session_touch")]
292 fn touch(&self) {
293 unsafe {
294 ffi::gst_rtsp_session_touch(self.as_ref().to_glib_none().0);
295 }
296 }
297
298 #[doc(alias = "extra-timeout")]
299 fn extra_timeout(&self) -> u32 {
300 ObjectExt::property(self.as_ref(), "extra-timeout")
301 }
302
303 #[doc(alias = "extra-timeout")]
304 fn set_extra_timeout(&self, extra_timeout: u32) {
305 ObjectExt::set_property(self.as_ref(), "extra-timeout", extra_timeout)
306 }
307
308 #[doc(alias = "timeout-always-visible")]
309 fn is_timeout_always_visible(&self) -> bool {
310 ObjectExt::property(self.as_ref(), "timeout-always-visible")
311 }
312
313 #[doc(alias = "timeout-always-visible")]
314 fn set_timeout_always_visible(&self, timeout_always_visible: bool) {
315 ObjectExt::set_property(
316 self.as_ref(),
317 "timeout-always-visible",
318 timeout_always_visible,
319 )
320 }
321
322 #[doc(alias = "extra-timeout")]
323 fn connect_extra_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
324 &self,
325 f: F,
326 ) -> SignalHandlerId {
327 unsafe extern "C" fn notify_extra_timeout_trampoline<
328 P: IsA<RTSPSession>,
329 F: Fn(&P) + Send + Sync + 'static,
330 >(
331 this: *mut ffi::GstRTSPSession,
332 _param_spec: glib::ffi::gpointer,
333 f: glib::ffi::gpointer,
334 ) {
335 let f: &F = &*(f as *const F);
336 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
337 }
338 unsafe {
339 let f: Box_<F> = Box_::new(f);
340 connect_raw(
341 self.as_ptr() as *mut _,
342 c"notify::extra-timeout".as_ptr() as *const _,
343 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
344 notify_extra_timeout_trampoline::<Self, F> as *const (),
345 )),
346 Box_::into_raw(f),
347 )
348 }
349 }
350
351 #[doc(alias = "timeout")]
352 fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
353 &self,
354 f: F,
355 ) -> SignalHandlerId {
356 unsafe extern "C" fn notify_timeout_trampoline<
357 P: IsA<RTSPSession>,
358 F: Fn(&P) + Send + Sync + 'static,
359 >(
360 this: *mut ffi::GstRTSPSession,
361 _param_spec: glib::ffi::gpointer,
362 f: glib::ffi::gpointer,
363 ) {
364 let f: &F = &*(f as *const F);
365 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
366 }
367 unsafe {
368 let f: Box_<F> = Box_::new(f);
369 connect_raw(
370 self.as_ptr() as *mut _,
371 c"notify::timeout".as_ptr() as *const _,
372 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
373 notify_timeout_trampoline::<Self, F> as *const (),
374 )),
375 Box_::into_raw(f),
376 )
377 }
378 }
379
380 #[doc(alias = "timeout-always-visible")]
381 fn connect_timeout_always_visible_notify<F: Fn(&Self) + Send + Sync + 'static>(
382 &self,
383 f: F,
384 ) -> SignalHandlerId {
385 unsafe extern "C" fn notify_timeout_always_visible_trampoline<
386 P: IsA<RTSPSession>,
387 F: Fn(&P) + Send + Sync + 'static,
388 >(
389 this: *mut ffi::GstRTSPSession,
390 _param_spec: glib::ffi::gpointer,
391 f: glib::ffi::gpointer,
392 ) {
393 let f: &F = &*(f as *const F);
394 f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
395 }
396 unsafe {
397 let f: Box_<F> = Box_::new(f);
398 connect_raw(
399 self.as_ptr() as *mut _,
400 c"notify::timeout-always-visible".as_ptr() as *const _,
401 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
402 notify_timeout_always_visible_trampoline::<Self, F> as *const (),
403 )),
404 Box_::into_raw(f),
405 )
406 }
407 }
408}
409
410impl<O: IsA<RTSPSession>> RTSPSessionExt for O {}