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::{ffi, RTSPStream};
7#[cfg(feature = "v1_28")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
9use glib::signal::{connect_raw, SignalHandlerId};
10use glib::{prelude::*, translate::*};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// A Transport description for a stream
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `timed-out`
20    ///  Whether this transport is timed out
21    ///
22    /// Readable
23    ///
24    /// # Implements
25    ///
26    /// [`RTSPStreamTransportExt`][trait@crate::prelude::RTSPStreamTransportExt], [`trait@glib::ObjectExt`]
27    #[doc(alias = "GstRTSPStreamTransport")]
28    pub struct RTSPStreamTransport(Object<ffi::GstRTSPStreamTransport, ffi::GstRTSPStreamTransportClass>);
29
30    match fn {
31        type_ => || ffi::gst_rtsp_stream_transport_get_type(),
32    }
33}
34
35impl RTSPStreamTransport {
36    pub const NONE: Option<&'static RTSPStreamTransport> = None;
37
38    //#[doc(alias = "gst_rtsp_stream_transport_new")]
39    //pub fn new(stream: &impl IsA<RTSPStream>, tr: /*Ignored*/gst_rtsp::RTSPTransport) -> RTSPStreamTransport {
40    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_new() }
41    //}
42}
43
44/// Trait containing all [`struct@RTSPStreamTransport`] methods.
45///
46/// # Implementors
47///
48/// [`RTSPStreamTransport`][struct@crate::RTSPStreamTransport]
49pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
50    /// Get the RTP-Info string for `self` and `start_time`.
51    /// ## `start_time`
52    /// a star time
53    ///
54    /// # Returns
55    ///
56    /// the RTPInfo string for `self`
57    /// and `start_time` or [`None`] when the RTP-Info could not be
58    /// determined. `g_free()` after usage.
59    #[doc(alias = "gst_rtsp_stream_transport_get_rtpinfo")]
60    #[doc(alias = "get_rtpinfo")]
61    fn rtpinfo(&self, start_time: impl Into<Option<gst::ClockTime>>) -> Option<glib::GString> {
62        unsafe {
63            from_glib_full(ffi::gst_rtsp_stream_transport_get_rtpinfo(
64                self.as_ref().to_glib_none().0,
65                start_time.into().into_glib(),
66            ))
67        }
68    }
69
70    /// Get the [`RTSPStream`][crate::RTSPStream] used when constructing `self`.
71    ///
72    /// # Returns
73    ///
74    /// the stream used when constructing `self`.
75    #[doc(alias = "gst_rtsp_stream_transport_get_stream")]
76    #[doc(alias = "get_stream")]
77    fn stream(&self) -> Option<RTSPStream> {
78        unsafe {
79            from_glib_none(ffi::gst_rtsp_stream_transport_get_stream(
80                self.as_ref().to_glib_none().0,
81            ))
82        }
83    }
84
85    //#[doc(alias = "gst_rtsp_stream_transport_get_transport")]
86    //#[doc(alias = "get_transport")]
87    //fn transport(&self) -> /*Ignored*/Option<gst_rtsp::RTSPTransport> {
88    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_get_transport() }
89    //}
90
91    /// Get the url configured in `self`.
92    ///
93    /// # Returns
94    ///
95    /// the url configured in `self`.
96    /// It remains valid for as long as `self` is valid.
97    #[doc(alias = "gst_rtsp_stream_transport_get_url")]
98    #[doc(alias = "get_url")]
99    fn url(&self) -> Option<gst_rtsp::RTSPUrl> {
100        unsafe {
101            from_glib_none(ffi::gst_rtsp_stream_transport_get_url(
102                self.as_ref().to_glib_none().0,
103            ))
104        }
105    }
106
107    /// Check if `self` is timed out.
108    ///
109    /// # Returns
110    ///
111    /// [`true`] if `self` timed out.
112    #[doc(alias = "gst_rtsp_stream_transport_is_timed_out")]
113    #[doc(alias = "timed-out")]
114    fn is_timed_out(&self) -> bool {
115        unsafe {
116            from_glib(ffi::gst_rtsp_stream_transport_is_timed_out(
117                self.as_ref().to_glib_none().0,
118            ))
119        }
120    }
121
122    /// Signal the installed keep_alive callback for `self`.
123    #[doc(alias = "gst_rtsp_stream_transport_keep_alive")]
124    fn keep_alive(&self) {
125        unsafe {
126            ffi::gst_rtsp_stream_transport_keep_alive(self.as_ref().to_glib_none().0);
127        }
128    }
129
130    /// Signal the installed message_sent / message_sent_full callback for `self`.
131    #[cfg(feature = "v1_16")]
132    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
133    #[doc(alias = "gst_rtsp_stream_transport_message_sent")]
134    fn message_sent(&self) {
135        unsafe {
136            ffi::gst_rtsp_stream_transport_message_sent(self.as_ref().to_glib_none().0);
137        }
138    }
139
140    /// Receive `buffer` on `channel` `self`.
141    /// ## `channel`
142    /// a channel
143    /// ## `buffer`
144    /// a [`gst::Buffer`][crate::gst::Buffer]
145    ///
146    /// # Returns
147    ///
148    /// a [`gst::FlowReturn`][crate::gst::FlowReturn]. Returns GST_FLOW_NOT_LINKED when `channel` is not
149    ///  configured in the transport of `self`.
150    #[doc(alias = "gst_rtsp_stream_transport_recv_data")]
151    fn recv_data(
152        &self,
153        channel: u32,
154        buffer: gst::Buffer,
155    ) -> Result<gst::FlowSuccess, gst::FlowError> {
156        unsafe {
157            try_from_glib(ffi::gst_rtsp_stream_transport_recv_data(
158                self.as_ref().to_glib_none().0,
159                channel,
160                buffer.into_glib_ptr(),
161            ))
162        }
163    }
164
165    /// Send `buffer` to the installed RTCP callback for `self`.
166    /// ## `buffer`
167    /// a [`gst::Buffer`][crate::gst::Buffer]
168    ///
169    /// # Returns
170    ///
171    /// [`true`] on success
172    #[doc(alias = "gst_rtsp_stream_transport_send_rtcp")]
173    fn send_rtcp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
174        unsafe {
175            glib::result_from_gboolean!(
176                ffi::gst_rtsp_stream_transport_send_rtcp(
177                    self.as_ref().to_glib_none().0,
178                    buffer.to_glib_none().0
179                ),
180                "Failed to send rtcp"
181            )
182        }
183    }
184
185    //#[cfg(feature = "v1_16")]
186    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
187    //#[doc(alias = "gst_rtsp_stream_transport_send_rtcp_list")]
188    //fn send_rtcp_list(&self, buffer_list: /*Ignored*/&gst::BufferList) -> bool {
189    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_send_rtcp_list() }
190    //}
191
192    /// Send `buffer` to the installed RTP callback for `self`.
193    /// ## `buffer`
194    /// a [`gst::Buffer`][crate::gst::Buffer]
195    ///
196    /// # Returns
197    ///
198    /// [`true`] on success
199    #[doc(alias = "gst_rtsp_stream_transport_send_rtp")]
200    fn send_rtp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
201        unsafe {
202            glib::result_from_gboolean!(
203                ffi::gst_rtsp_stream_transport_send_rtp(
204                    self.as_ref().to_glib_none().0,
205                    buffer.to_glib_none().0
206                ),
207                "Failed to send rtp"
208            )
209        }
210    }
211
212    //#[cfg(feature = "v1_16")]
213    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
214    //#[doc(alias = "gst_rtsp_stream_transport_send_rtp_list")]
215    //fn send_rtp_list(&self, buffer_list: /*Ignored*/&gst::BufferList) -> bool {
216    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_send_rtp_list() }
217    //}
218
219    /// Activate or deactivate datatransfer configured in `self`.
220    /// ## `active`
221    /// new state of `self`
222    ///
223    /// # Returns
224    ///
225    /// [`true`] when the state was changed.
226    #[doc(alias = "gst_rtsp_stream_transport_set_active")]
227    fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> {
228        unsafe {
229            glib::result_from_gboolean!(
230                ffi::gst_rtsp_stream_transport_set_active(
231                    self.as_ref().to_glib_none().0,
232                    active.into_glib()
233                ),
234                "Failed to set active"
235            )
236        }
237    }
238
239    /// Install callbacks that will be called when data for a stream should be sent
240    /// to a client. This is usually used when sending RTP/RTCP over TCP.
241    /// ## `send_rtp`
242    /// a callback called when RTP should be sent
243    /// ## `send_rtcp`
244    /// a callback called when RTCP should be sent
245    /// ## `notify`
246    /// called with the user_data when no longer needed.
247    #[doc(alias = "gst_rtsp_stream_transport_set_callbacks")]
248    fn set_callbacks<
249        P: Fn(&gst::Buffer, u8) -> bool + 'static,
250        Q: Fn(&gst::Buffer, u8) -> bool + 'static,
251    >(
252        &self,
253        send_rtp: P,
254        send_rtcp: Q,
255    ) {
256        let send_rtp_data: P = send_rtp;
257        unsafe extern "C" fn send_rtp_func<
258            P: Fn(&gst::Buffer, u8) -> bool + 'static,
259            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
260        >(
261            buffer: *mut gst::ffi::GstBuffer,
262            channel: u8,
263            user_data: glib::ffi::gpointer,
264        ) -> glib::ffi::gboolean {
265            let buffer = from_glib_borrow(buffer);
266            let callback: &(P, Q) = &*(user_data as *mut _);
267            let callback = &callback.0;
268            (*callback)(&buffer, channel).into_glib()
269        }
270        let send_rtp = Some(send_rtp_func::<P, Q> as _);
271        let send_rtcp_data: Q = send_rtcp;
272        unsafe extern "C" fn send_rtcp_func<
273            P: Fn(&gst::Buffer, u8) -> bool + 'static,
274            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
275        >(
276            buffer: *mut gst::ffi::GstBuffer,
277            channel: u8,
278            user_data: glib::ffi::gpointer,
279        ) -> glib::ffi::gboolean {
280            let buffer = from_glib_borrow(buffer);
281            let callback: &(P, Q) = &*(user_data as *mut _);
282            let callback = &callback.1;
283            (*callback)(&buffer, channel).into_glib()
284        }
285        let send_rtcp = Some(send_rtcp_func::<P, Q> as _);
286        unsafe extern "C" fn notify_func<
287            P: Fn(&gst::Buffer, u8) -> bool + 'static,
288            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
289        >(
290            data: glib::ffi::gpointer,
291        ) {
292            let _callback: Box_<(P, Q)> = Box_::from_raw(data as *mut _);
293        }
294        let destroy_call4 = Some(notify_func::<P, Q> as _);
295        let super_callback0: Box_<(P, Q)> = Box_::new((send_rtp_data, send_rtcp_data));
296        unsafe {
297            ffi::gst_rtsp_stream_transport_set_callbacks(
298                self.as_ref().to_glib_none().0,
299                send_rtp,
300                send_rtcp,
301                Box_::into_raw(super_callback0) as *mut _,
302                destroy_call4,
303            );
304        }
305    }
306
307    /// Install callbacks that will be called when RTCP packets are received from the
308    /// receiver of `self`.
309    /// ## `keep_alive`
310    /// a callback called when the receiver is active
311    /// ## `notify`
312    /// called with the user_data when no longer needed.
313    #[doc(alias = "gst_rtsp_stream_transport_set_keepalive")]
314    fn set_keepalive<P: Fn() + 'static>(&self, keep_alive: P) {
315        let keep_alive_data: Box_<P> = Box_::new(keep_alive);
316        unsafe extern "C" fn keep_alive_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
317            let callback = &*(user_data as *mut P);
318            (*callback)()
319        }
320        let keep_alive = Some(keep_alive_func::<P> as _);
321        unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
322            let _callback = Box_::from_raw(data as *mut P);
323        }
324        let destroy_call3 = Some(notify_func::<P> as _);
325        let super_callback0: Box_<P> = keep_alive_data;
326        unsafe {
327            ffi::gst_rtsp_stream_transport_set_keepalive(
328                self.as_ref().to_glib_none().0,
329                keep_alive,
330                Box_::into_raw(super_callback0) as *mut _,
331                destroy_call3,
332            );
333        }
334    }
335
336    //#[cfg(feature = "v1_16")]
337    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
338    //#[doc(alias = "gst_rtsp_stream_transport_set_list_callbacks")]
339    //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>) {
340    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_set_list_callbacks() }
341    //}
342
343    /// Install a callback that will be called when a message has been sent on `self`.
344    /// ## `message_sent`
345    /// a callback called when a message has been sent
346    /// ## `notify`
347    /// called with the user_data when no longer needed
348    #[doc(alias = "gst_rtsp_stream_transport_set_message_sent")]
349    fn set_message_sent<P: Fn() + 'static>(&self, message_sent: P) {
350        let message_sent_data: Box_<P> = Box_::new(message_sent);
351        unsafe extern "C" fn message_sent_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
352            let callback = &*(user_data as *mut P);
353            (*callback)()
354        }
355        let message_sent = Some(message_sent_func::<P> as _);
356        unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
357            let _callback = Box_::from_raw(data as *mut P);
358        }
359        let destroy_call3 = Some(notify_func::<P> as _);
360        let super_callback0: Box_<P> = message_sent_data;
361        unsafe {
362            ffi::gst_rtsp_stream_transport_set_message_sent(
363                self.as_ref().to_glib_none().0,
364                message_sent,
365                Box_::into_raw(super_callback0) as *mut _,
366                destroy_call3,
367            );
368        }
369    }
370
371    /// Install a callback that will be called when a message has been sent on `self`.
372    /// ## `message_sent`
373    /// a callback called when a message has been sent
374    /// ## `notify`
375    /// called with the user_data when no longer needed
376    #[cfg(feature = "v1_18")]
377    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
378    #[doc(alias = "gst_rtsp_stream_transport_set_message_sent_full")]
379    fn set_message_sent_full<P: Fn(&RTSPStreamTransport) + 'static>(&self, message_sent: P) {
380        let message_sent_data: Box_<P> = Box_::new(message_sent);
381        unsafe extern "C" fn message_sent_func<P: Fn(&RTSPStreamTransport) + 'static>(
382            trans: *mut ffi::GstRTSPStreamTransport,
383            user_data: glib::ffi::gpointer,
384        ) {
385            let trans = from_glib_borrow(trans);
386            let callback = &*(user_data as *mut P);
387            (*callback)(&trans)
388        }
389        let message_sent = Some(message_sent_func::<P> as _);
390        unsafe extern "C" fn notify_func<P: Fn(&RTSPStreamTransport) + 'static>(
391            data: glib::ffi::gpointer,
392        ) {
393            let _callback = Box_::from_raw(data as *mut P);
394        }
395        let destroy_call3 = Some(notify_func::<P> as _);
396        let super_callback0: Box_<P> = message_sent_data;
397        unsafe {
398            ffi::gst_rtsp_stream_transport_set_message_sent_full(
399                self.as_ref().to_glib_none().0,
400                message_sent,
401                Box_::into_raw(super_callback0) as *mut _,
402                destroy_call3,
403            );
404        }
405    }
406
407    /// Set the timed out state of `self` to `timedout`
408    /// ## `timedout`
409    /// timed out value
410    #[doc(alias = "gst_rtsp_stream_transport_set_timed_out")]
411    fn set_timed_out(&self, timedout: bool) {
412        unsafe {
413            ffi::gst_rtsp_stream_transport_set_timed_out(
414                self.as_ref().to_glib_none().0,
415                timedout.into_glib(),
416            );
417        }
418    }
419
420    //#[doc(alias = "gst_rtsp_stream_transport_set_transport")]
421    //fn set_transport(&self, tr: /*Ignored*/gst_rtsp::RTSPTransport) {
422    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_set_transport() }
423    //}
424
425    /// Set `url` as the client url.
426    /// ## `url`
427    /// a client [`gst_rtsp::RTSPUrl`][crate::gst_rtsp::RTSPUrl]
428    #[doc(alias = "gst_rtsp_stream_transport_set_url")]
429    fn set_url(&self, url: Option<&gst_rtsp::RTSPUrl>) {
430        unsafe {
431            ffi::gst_rtsp_stream_transport_set_url(
432                self.as_ref().to_glib_none().0,
433                url.to_glib_none().0,
434            );
435        }
436    }
437
438    #[cfg(feature = "v1_28")]
439    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
440    #[doc(alias = "timed-out")]
441    fn connect_timed_out_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
442        unsafe extern "C" fn notify_timed_out_trampoline<
443            P: IsA<RTSPStreamTransport>,
444            F: Fn(&P) + 'static,
445        >(
446            this: *mut ffi::GstRTSPStreamTransport,
447            _param_spec: glib::ffi::gpointer,
448            f: glib::ffi::gpointer,
449        ) {
450            let f: &F = &*(f as *const F);
451            f(RTSPStreamTransport::from_glib_borrow(this).unsafe_cast_ref())
452        }
453        unsafe {
454            let f: Box_<F> = Box_::new(f);
455            connect_raw(
456                self.as_ptr() as *mut _,
457                c"notify::timed-out".as_ptr() as *const _,
458                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
459                    notify_timed_out_trampoline::<Self, F> as *const (),
460                )),
461                Box_::into_raw(f),
462            )
463        }
464    }
465}
466
467impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExt for O {}