gstreamer_rtsp_server/auto/
rtsp_session.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, 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")]
16    pub struct RTSPSession(Object<ffi::GstRTSPSession, ffi::GstRTSPSessionClass>);
17
18    match fn {
19        type_ => || ffi::gst_rtsp_session_get_type(),
20    }
21}
22
23impl RTSPSession {
24    pub const NONE: Option<&'static RTSPSession> = None;
25
26    #[doc(alias = "gst_rtsp_session_new")]
27    pub fn new(sessionid: &str) -> RTSPSession {
28        assert_initialized_main_thread!();
29        unsafe { from_glib_full(ffi::gst_rtsp_session_new(sessionid.to_glib_none().0)) }
30    }
31}
32
33unsafe impl Send for RTSPSession {}
34unsafe impl Sync for RTSPSession {}
35
36pub trait RTSPSessionExt: IsA<RTSPSession> + 'static {
37    #[doc(alias = "gst_rtsp_session_allow_expire")]
38    fn allow_expire(&self) {
39        unsafe {
40            ffi::gst_rtsp_session_allow_expire(self.as_ref().to_glib_none().0);
41        }
42    }
43
44    #[doc(alias = "gst_rtsp_session_filter")]
45    fn filter(
46        &self,
47        func: Option<&mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult>,
48    ) -> Vec<RTSPSessionMedia> {
49        let mut func_data: Option<
50            &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
51        > = func;
52        unsafe extern "C" fn func_func(
53            sess: *mut ffi::GstRTSPSession,
54            media: *mut ffi::GstRTSPSessionMedia,
55            user_data: glib::ffi::gpointer,
56        ) -> ffi::GstRTSPFilterResult {
57            let sess = from_glib_borrow(sess);
58            let media = from_glib_borrow(media);
59            let callback = user_data
60                as *mut Option<&mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult>;
61            if let Some(ref mut callback) = *callback {
62                callback(&sess, &media)
63            } else {
64                panic!("cannot get closure...")
65            }
66            .into_glib()
67        }
68        let func = if func_data.is_some() {
69            Some(func_func as _)
70        } else {
71            None
72        };
73        let super_callback0: &mut Option<
74            &mut dyn FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult,
75        > = &mut func_data;
76        unsafe {
77            FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_filter(
78                self.as_ref().to_glib_none().0,
79                func,
80                super_callback0 as *mut _ as *mut _,
81            ))
82        }
83    }
84
85    #[doc(alias = "gst_rtsp_session_get_header")]
86    #[doc(alias = "get_header")]
87    fn header(&self) -> Option<glib::GString> {
88        unsafe {
89            from_glib_full(ffi::gst_rtsp_session_get_header(
90                self.as_ref().to_glib_none().0,
91            ))
92        }
93    }
94
95    #[doc(alias = "gst_rtsp_session_get_sessionid")]
96    #[doc(alias = "get_sessionid")]
97    fn sessionid(&self) -> Option<glib::GString> {
98        unsafe {
99            from_glib_none(ffi::gst_rtsp_session_get_sessionid(
100                self.as_ref().to_glib_none().0,
101            ))
102        }
103    }
104
105    #[doc(alias = "gst_rtsp_session_get_timeout")]
106    #[doc(alias = "get_timeout")]
107    fn timeout(&self) -> u32 {
108        unsafe { ffi::gst_rtsp_session_get_timeout(self.as_ref().to_glib_none().0) }
109    }
110
111    //#[doc(alias = "gst_rtsp_session_is_expired")]
112    //fn is_expired(&self, now: /*Ignored*/&mut glib::TimeVal) -> bool {
113    //    unsafe { TODO: call ffi:gst_rtsp_session_is_expired() }
114    //}
115
116    #[doc(alias = "gst_rtsp_session_is_expired_usec")]
117    fn is_expired_usec(&self, now: i64) -> bool {
118        unsafe {
119            from_glib(ffi::gst_rtsp_session_is_expired_usec(
120                self.as_ref().to_glib_none().0,
121                now,
122            ))
123        }
124    }
125
126    #[doc(alias = "gst_rtsp_session_manage_media")]
127    fn manage_media(&self, path: &str, media: impl IsA<RTSPMedia>) -> RTSPSessionMedia {
128        unsafe {
129            from_glib_none(ffi::gst_rtsp_session_manage_media(
130                self.as_ref().to_glib_none().0,
131                path.to_glib_none().0,
132                media.upcast().into_glib_ptr(),
133            ))
134        }
135    }
136
137    //#[doc(alias = "gst_rtsp_session_next_timeout")]
138    //fn next_timeout(&self, now: /*Ignored*/&mut glib::TimeVal) -> i32 {
139    //    unsafe { TODO: call ffi:gst_rtsp_session_next_timeout() }
140    //}
141
142    #[doc(alias = "gst_rtsp_session_next_timeout_usec")]
143    fn next_timeout_usec(&self, now: i64) -> i32 {
144        unsafe { ffi::gst_rtsp_session_next_timeout_usec(self.as_ref().to_glib_none().0, now) }
145    }
146
147    #[doc(alias = "gst_rtsp_session_prevent_expire")]
148    fn prevent_expire(&self) {
149        unsafe {
150            ffi::gst_rtsp_session_prevent_expire(self.as_ref().to_glib_none().0);
151        }
152    }
153
154    #[doc(alias = "gst_rtsp_session_release_media")]
155    fn release_media(&self, media: &impl IsA<RTSPSessionMedia>) -> bool {
156        unsafe {
157            from_glib(ffi::gst_rtsp_session_release_media(
158                self.as_ref().to_glib_none().0,
159                media.as_ref().to_glib_none().0,
160            ))
161        }
162    }
163
164    #[doc(alias = "gst_rtsp_session_set_timeout")]
165    #[doc(alias = "timeout")]
166    fn set_timeout(&self, timeout: u32) {
167        unsafe {
168            ffi::gst_rtsp_session_set_timeout(self.as_ref().to_glib_none().0, timeout);
169        }
170    }
171
172    #[doc(alias = "gst_rtsp_session_touch")]
173    fn touch(&self) {
174        unsafe {
175            ffi::gst_rtsp_session_touch(self.as_ref().to_glib_none().0);
176        }
177    }
178
179    #[doc(alias = "extra-timeout")]
180    fn extra_timeout(&self) -> u32 {
181        ObjectExt::property(self.as_ref(), "extra-timeout")
182    }
183
184    #[doc(alias = "extra-timeout")]
185    fn set_extra_timeout(&self, extra_timeout: u32) {
186        ObjectExt::set_property(self.as_ref(), "extra-timeout", extra_timeout)
187    }
188
189    #[doc(alias = "timeout-always-visible")]
190    fn is_timeout_always_visible(&self) -> bool {
191        ObjectExt::property(self.as_ref(), "timeout-always-visible")
192    }
193
194    #[doc(alias = "timeout-always-visible")]
195    fn set_timeout_always_visible(&self, timeout_always_visible: bool) {
196        ObjectExt::set_property(
197            self.as_ref(),
198            "timeout-always-visible",
199            timeout_always_visible,
200        )
201    }
202
203    #[doc(alias = "extra-timeout")]
204    fn connect_extra_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
205        &self,
206        f: F,
207    ) -> SignalHandlerId {
208        unsafe extern "C" fn notify_extra_timeout_trampoline<
209            P: IsA<RTSPSession>,
210            F: Fn(&P) + Send + Sync + 'static,
211        >(
212            this: *mut ffi::GstRTSPSession,
213            _param_spec: glib::ffi::gpointer,
214            f: glib::ffi::gpointer,
215        ) {
216            let f: &F = &*(f as *const F);
217            f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
218        }
219        unsafe {
220            let f: Box_<F> = Box_::new(f);
221            connect_raw(
222                self.as_ptr() as *mut _,
223                c"notify::extra-timeout".as_ptr() as *const _,
224                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
225                    notify_extra_timeout_trampoline::<Self, F> as *const (),
226                )),
227                Box_::into_raw(f),
228            )
229        }
230    }
231
232    #[doc(alias = "timeout")]
233    fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
234        &self,
235        f: F,
236    ) -> SignalHandlerId {
237        unsafe extern "C" fn notify_timeout_trampoline<
238            P: IsA<RTSPSession>,
239            F: Fn(&P) + Send + Sync + 'static,
240        >(
241            this: *mut ffi::GstRTSPSession,
242            _param_spec: glib::ffi::gpointer,
243            f: glib::ffi::gpointer,
244        ) {
245            let f: &F = &*(f as *const F);
246            f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
247        }
248        unsafe {
249            let f: Box_<F> = Box_::new(f);
250            connect_raw(
251                self.as_ptr() as *mut _,
252                c"notify::timeout".as_ptr() as *const _,
253                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
254                    notify_timeout_trampoline::<Self, F> as *const (),
255                )),
256                Box_::into_raw(f),
257            )
258        }
259    }
260
261    #[doc(alias = "timeout-always-visible")]
262    fn connect_timeout_always_visible_notify<F: Fn(&Self) + Send + Sync + 'static>(
263        &self,
264        f: F,
265    ) -> SignalHandlerId {
266        unsafe extern "C" fn notify_timeout_always_visible_trampoline<
267            P: IsA<RTSPSession>,
268            F: Fn(&P) + Send + Sync + 'static,
269        >(
270            this: *mut ffi::GstRTSPSession,
271            _param_spec: glib::ffi::gpointer,
272            f: glib::ffi::gpointer,
273        ) {
274            let f: &F = &*(f as *const F);
275            f(RTSPSession::from_glib_borrow(this).unsafe_cast_ref())
276        }
277        unsafe {
278            let f: Box_<F> = Box_::new(f);
279            connect_raw(
280                self.as_ptr() as *mut _,
281                c"notify::timeout-always-visible".as_ptr() as *const _,
282                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
283                    notify_timeout_always_visible_trampoline::<Self, F> as *const (),
284                )),
285                Box_::into_raw(f),
286            )
287        }
288    }
289}
290
291impl<O: IsA<RTSPSession>> RTSPSessionExt for O {}