Skip to main content

gstreamer_rtsp_server/auto/
rtsp_stream_transport.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::{RTSPStream, ffi};
7#[cfg(feature = "v1_28")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
9use glib::signal::{SignalHandlerId, connect_raw};
10use glib::{prelude::*, translate::*};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GstRTSPStreamTransport")]
15    pub struct RTSPStreamTransport(Object<ffi::GstRTSPStreamTransport, ffi::GstRTSPStreamTransportClass>);
16
17    match fn {
18        type_ => || ffi::gst_rtsp_stream_transport_get_type(),
19    }
20}
21
22impl RTSPStreamTransport {
23    pub const NONE: Option<&'static RTSPStreamTransport> = None;
24
25    //#[doc(alias = "gst_rtsp_stream_transport_new")]
26    //pub fn new(stream: &impl IsA<RTSPStream>, tr: /*Ignored*/gst_rtsp::RTSPTransport) -> RTSPStreamTransport {
27    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_new() }
28    //}
29}
30
31pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
32    #[doc(alias = "gst_rtsp_stream_transport_get_rtpinfo")]
33    #[doc(alias = "get_rtpinfo")]
34    fn rtpinfo(&self, start_time: impl Into<Option<gst::ClockTime>>) -> Option<glib::GString> {
35        unsafe {
36            from_glib_full(ffi::gst_rtsp_stream_transport_get_rtpinfo(
37                self.as_ref().to_glib_none().0,
38                start_time.into().into_glib(),
39            ))
40        }
41    }
42
43    #[doc(alias = "gst_rtsp_stream_transport_get_stream")]
44    #[doc(alias = "get_stream")]
45    fn stream(&self) -> Option<RTSPStream> {
46        unsafe {
47            from_glib_none(ffi::gst_rtsp_stream_transport_get_stream(
48                self.as_ref().to_glib_none().0,
49            ))
50        }
51    }
52
53    //#[doc(alias = "gst_rtsp_stream_transport_get_transport")]
54    //#[doc(alias = "get_transport")]
55    //fn transport(&self) -> /*Ignored*/Option<gst_rtsp::RTSPTransport> {
56    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_get_transport() }
57    //}
58
59    #[doc(alias = "gst_rtsp_stream_transport_get_url")]
60    #[doc(alias = "get_url")]
61    fn url(&self) -> Option<gst_rtsp::RTSPUrl> {
62        unsafe {
63            from_glib_none(ffi::gst_rtsp_stream_transport_get_url(
64                self.as_ref().to_glib_none().0,
65            ))
66        }
67    }
68
69    #[doc(alias = "gst_rtsp_stream_transport_is_timed_out")]
70    #[doc(alias = "timed-out")]
71    fn is_timed_out(&self) -> bool {
72        unsafe {
73            from_glib(ffi::gst_rtsp_stream_transport_is_timed_out(
74                self.as_ref().to_glib_none().0,
75            ))
76        }
77    }
78
79    #[doc(alias = "gst_rtsp_stream_transport_keep_alive")]
80    fn keep_alive(&self) {
81        unsafe {
82            ffi::gst_rtsp_stream_transport_keep_alive(self.as_ref().to_glib_none().0);
83        }
84    }
85
86    #[cfg(feature = "v1_16")]
87    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
88    #[doc(alias = "gst_rtsp_stream_transport_message_sent")]
89    fn message_sent(&self) {
90        unsafe {
91            ffi::gst_rtsp_stream_transport_message_sent(self.as_ref().to_glib_none().0);
92        }
93    }
94
95    #[doc(alias = "gst_rtsp_stream_transport_recv_data")]
96    fn recv_data(
97        &self,
98        channel: u32,
99        buffer: gst::Buffer,
100    ) -> Result<gst::FlowSuccess, gst::FlowError> {
101        unsafe {
102            try_from_glib(ffi::gst_rtsp_stream_transport_recv_data(
103                self.as_ref().to_glib_none().0,
104                channel,
105                buffer.into_glib_ptr(),
106            ))
107        }
108    }
109
110    #[doc(alias = "gst_rtsp_stream_transport_send_rtcp")]
111    fn send_rtcp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
112        unsafe {
113            glib::result_from_gboolean!(
114                ffi::gst_rtsp_stream_transport_send_rtcp(
115                    self.as_ref().to_glib_none().0,
116                    buffer.to_glib_none().0
117                ),
118                "Failed to send rtcp"
119            )
120        }
121    }
122
123    //#[cfg(feature = "v1_16")]
124    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
125    //#[doc(alias = "gst_rtsp_stream_transport_send_rtcp_list")]
126    //fn send_rtcp_list(&self, buffer_list: /*Ignored*/&gst::BufferList) -> bool {
127    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_send_rtcp_list() }
128    //}
129
130    #[doc(alias = "gst_rtsp_stream_transport_send_rtp")]
131    fn send_rtp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
132        unsafe {
133            glib::result_from_gboolean!(
134                ffi::gst_rtsp_stream_transport_send_rtp(
135                    self.as_ref().to_glib_none().0,
136                    buffer.to_glib_none().0
137                ),
138                "Failed to send rtp"
139            )
140        }
141    }
142
143    //#[cfg(feature = "v1_16")]
144    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
145    //#[doc(alias = "gst_rtsp_stream_transport_send_rtp_list")]
146    //fn send_rtp_list(&self, buffer_list: /*Ignored*/&gst::BufferList) -> bool {
147    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_send_rtp_list() }
148    //}
149
150    #[doc(alias = "gst_rtsp_stream_transport_set_active")]
151    fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> {
152        unsafe {
153            glib::result_from_gboolean!(
154                ffi::gst_rtsp_stream_transport_set_active(
155                    self.as_ref().to_glib_none().0,
156                    active.into_glib()
157                ),
158                "Failed to set active"
159            )
160        }
161    }
162
163    #[doc(alias = "gst_rtsp_stream_transport_set_callbacks")]
164    fn set_callbacks<
165        P: Fn(&gst::Buffer, u8) -> bool + 'static,
166        Q: Fn(&gst::Buffer, u8) -> bool + 'static,
167    >(
168        &self,
169        send_rtp: P,
170        send_rtcp: Q,
171    ) {
172        let send_rtp_data: P = send_rtp;
173        unsafe extern "C" fn send_rtp_func<
174            P: Fn(&gst::Buffer, u8) -> bool + 'static,
175            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
176        >(
177            buffer: *mut gst::ffi::GstBuffer,
178            channel: u8,
179            user_data: glib::ffi::gpointer,
180        ) -> glib::ffi::gboolean {
181            unsafe {
182                let buffer = from_glib_borrow(buffer);
183                let callback: &(P, Q) = &*(user_data as *mut _);
184                let callback = &callback.0;
185                (*callback)(&buffer, channel).into_glib()
186            }
187        }
188        let send_rtp = Some(send_rtp_func::<P, Q> as _);
189        let send_rtcp_data: Q = send_rtcp;
190        unsafe extern "C" fn send_rtcp_func<
191            P: Fn(&gst::Buffer, u8) -> bool + 'static,
192            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
193        >(
194            buffer: *mut gst::ffi::GstBuffer,
195            channel: u8,
196            user_data: glib::ffi::gpointer,
197        ) -> glib::ffi::gboolean {
198            unsafe {
199                let buffer = from_glib_borrow(buffer);
200                let callback: &(P, Q) = &*(user_data as *mut _);
201                let callback = &callback.1;
202                (*callback)(&buffer, channel).into_glib()
203            }
204        }
205        let send_rtcp = Some(send_rtcp_func::<P, Q> as _);
206        unsafe extern "C" fn notify_func<
207            P: Fn(&gst::Buffer, u8) -> bool + 'static,
208            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
209        >(
210            data: glib::ffi::gpointer,
211        ) {
212            unsafe {
213                let _callback: Box_<(P, Q)> = Box_::from_raw(data as *mut _);
214            }
215        }
216        let destroy_call4 = Some(notify_func::<P, Q> as _);
217        let super_callback0: Box_<(P, Q)> = Box_::new((send_rtp_data, send_rtcp_data));
218        unsafe {
219            ffi::gst_rtsp_stream_transport_set_callbacks(
220                self.as_ref().to_glib_none().0,
221                send_rtp,
222                send_rtcp,
223                Box_::into_raw(super_callback0) as *mut _,
224                destroy_call4,
225            );
226        }
227    }
228
229    #[doc(alias = "gst_rtsp_stream_transport_set_keepalive")]
230    fn set_keepalive<P: Fn() + 'static>(&self, keep_alive: P) {
231        let keep_alive_data: Box_<P> = Box_::new(keep_alive);
232        unsafe extern "C" fn keep_alive_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
233            unsafe {
234                let callback = &*(user_data as *mut P);
235                (*callback)()
236            }
237        }
238        let keep_alive = Some(keep_alive_func::<P> as _);
239        unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
240            unsafe {
241                let _callback = Box_::from_raw(data as *mut P);
242            }
243        }
244        let destroy_call3 = Some(notify_func::<P> as _);
245        let super_callback0: Box_<P> = keep_alive_data;
246        unsafe {
247            ffi::gst_rtsp_stream_transport_set_keepalive(
248                self.as_ref().to_glib_none().0,
249                keep_alive,
250                Box_::into_raw(super_callback0) as *mut _,
251                destroy_call3,
252            );
253        }
254    }
255
256    //#[cfg(feature = "v1_16")]
257    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
258    //#[doc(alias = "gst_rtsp_stream_transport_set_list_callbacks")]
259    //fn set_list_callbacks(&self, send_rtp_list: /*Unimplemented*/Fn(/*Ignored*/gst::BufferList, u8) -> bool, send_rtcp_list: /*Unimplemented*/Fn(/*Ignored*/gst::BufferList, u8) -> bool, user_data: /*Unimplemented*/Option<Basic: Pointer>) {
260    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_set_list_callbacks() }
261    //}
262
263    #[doc(alias = "gst_rtsp_stream_transport_set_message_sent")]
264    fn set_message_sent<P: Fn() + 'static>(&self, message_sent: P) {
265        let message_sent_data: Box_<P> = Box_::new(message_sent);
266        unsafe extern "C" fn message_sent_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
267            unsafe {
268                let callback = &*(user_data as *mut P);
269                (*callback)()
270            }
271        }
272        let message_sent = Some(message_sent_func::<P> as _);
273        unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
274            unsafe {
275                let _callback = Box_::from_raw(data as *mut P);
276            }
277        }
278        let destroy_call3 = Some(notify_func::<P> as _);
279        let super_callback0: Box_<P> = message_sent_data;
280        unsafe {
281            ffi::gst_rtsp_stream_transport_set_message_sent(
282                self.as_ref().to_glib_none().0,
283                message_sent,
284                Box_::into_raw(super_callback0) as *mut _,
285                destroy_call3,
286            );
287        }
288    }
289
290    #[cfg(feature = "v1_18")]
291    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
292    #[doc(alias = "gst_rtsp_stream_transport_set_message_sent_full")]
293    fn set_message_sent_full<P: Fn(&RTSPStreamTransport) + 'static>(&self, message_sent: P) {
294        let message_sent_data: Box_<P> = Box_::new(message_sent);
295        unsafe extern "C" fn message_sent_func<P: Fn(&RTSPStreamTransport) + 'static>(
296            trans: *mut ffi::GstRTSPStreamTransport,
297            user_data: glib::ffi::gpointer,
298        ) {
299            unsafe {
300                let trans = from_glib_borrow(trans);
301                let callback = &*(user_data as *mut P);
302                (*callback)(&trans)
303            }
304        }
305        let message_sent = Some(message_sent_func::<P> as _);
306        unsafe extern "C" fn notify_func<P: Fn(&RTSPStreamTransport) + 'static>(
307            data: glib::ffi::gpointer,
308        ) {
309            unsafe {
310                let _callback = Box_::from_raw(data as *mut P);
311            }
312        }
313        let destroy_call3 = Some(notify_func::<P> as _);
314        let super_callback0: Box_<P> = message_sent_data;
315        unsafe {
316            ffi::gst_rtsp_stream_transport_set_message_sent_full(
317                self.as_ref().to_glib_none().0,
318                message_sent,
319                Box_::into_raw(super_callback0) as *mut _,
320                destroy_call3,
321            );
322        }
323    }
324
325    #[doc(alias = "gst_rtsp_stream_transport_set_timed_out")]
326    fn set_timed_out(&self, timedout: bool) {
327        unsafe {
328            ffi::gst_rtsp_stream_transport_set_timed_out(
329                self.as_ref().to_glib_none().0,
330                timedout.into_glib(),
331            );
332        }
333    }
334
335    //#[doc(alias = "gst_rtsp_stream_transport_set_transport")]
336    //fn set_transport(&self, tr: /*Ignored*/gst_rtsp::RTSPTransport) {
337    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_set_transport() }
338    //}
339
340    #[doc(alias = "gst_rtsp_stream_transport_set_url")]
341    fn set_url(&self, url: Option<&gst_rtsp::RTSPUrl>) {
342        unsafe {
343            ffi::gst_rtsp_stream_transport_set_url(
344                self.as_ref().to_glib_none().0,
345                url.to_glib_none().0,
346            );
347        }
348    }
349
350    #[cfg(feature = "v1_28")]
351    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
352    #[doc(alias = "timed-out")]
353    fn connect_timed_out_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
354        unsafe extern "C" fn notify_timed_out_trampoline<
355            P: IsA<RTSPStreamTransport>,
356            F: Fn(&P) + 'static,
357        >(
358            this: *mut ffi::GstRTSPStreamTransport,
359            _param_spec: glib::ffi::gpointer,
360            f: glib::ffi::gpointer,
361        ) {
362            unsafe {
363                let f: &F = &*(f as *const F);
364                f(RTSPStreamTransport::from_glib_borrow(this).unsafe_cast_ref())
365            }
366        }
367        unsafe {
368            let f: Box_<F> = Box_::new(f);
369            connect_raw(
370                self.as_ptr() as *mut _,
371                c"notify::timed-out".as_ptr(),
372                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
373                    notify_timed_out_trampoline::<Self, F> as *const (),
374                )),
375                Box_::into_raw(f),
376            )
377        }
378    }
379}
380
381impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExt for O {}