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    /// 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            unsafe {
266                let buffer = from_glib_borrow(buffer);
267                let callback: &(P, Q) = &*(user_data as *mut _);
268                let callback = &callback.0;
269                (*callback)(&buffer, channel).into_glib()
270            }
271        }
272        let send_rtp = Some(send_rtp_func::<P, Q> as _);
273        let send_rtcp_data: Q = send_rtcp;
274        unsafe extern "C" fn send_rtcp_func<
275            P: Fn(&gst::Buffer, u8) -> bool + 'static,
276            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
277        >(
278            buffer: *mut gst::ffi::GstBuffer,
279            channel: u8,
280            user_data: glib::ffi::gpointer,
281        ) -> glib::ffi::gboolean {
282            unsafe {
283                let buffer = from_glib_borrow(buffer);
284                let callback: &(P, Q) = &*(user_data as *mut _);
285                let callback = &callback.1;
286                (*callback)(&buffer, channel).into_glib()
287            }
288        }
289        let send_rtcp = Some(send_rtcp_func::<P, Q> as _);
290        unsafe extern "C" fn notify_func<
291            P: Fn(&gst::Buffer, u8) -> bool + 'static,
292            Q: Fn(&gst::Buffer, u8) -> bool + 'static,
293        >(
294            data: glib::ffi::gpointer,
295        ) {
296            unsafe {
297                let _callback: Box_<(P, Q)> = Box_::from_raw(data as *mut _);
298            }
299        }
300        let destroy_call4 = Some(notify_func::<P, Q> as _);
301        let super_callback0: Box_<(P, Q)> = Box_::new((send_rtp_data, send_rtcp_data));
302        unsafe {
303            ffi::gst_rtsp_stream_transport_set_callbacks(
304                self.as_ref().to_glib_none().0,
305                send_rtp,
306                send_rtcp,
307                Box_::into_raw(super_callback0) as *mut _,
308                destroy_call4,
309            );
310        }
311    }
312
313    /// Install callbacks that will be called when RTCP packets are received from the
314    /// receiver of `self`.
315    /// ## `keep_alive`
316    /// a callback called when the receiver is active
317    /// ## `notify`
318    /// called with the user_data when no longer needed.
319    #[doc(alias = "gst_rtsp_stream_transport_set_keepalive")]
320    fn set_keepalive<P: Fn() + 'static>(&self, keep_alive: P) {
321        let keep_alive_data: Box_<P> = Box_::new(keep_alive);
322        unsafe extern "C" fn keep_alive_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
323            unsafe {
324                let callback = &*(user_data as *mut P);
325                (*callback)()
326            }
327        }
328        let keep_alive = Some(keep_alive_func::<P> as _);
329        unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
330            unsafe {
331                let _callback = Box_::from_raw(data as *mut P);
332            }
333        }
334        let destroy_call3 = Some(notify_func::<P> as _);
335        let super_callback0: Box_<P> = keep_alive_data;
336        unsafe {
337            ffi::gst_rtsp_stream_transport_set_keepalive(
338                self.as_ref().to_glib_none().0,
339                keep_alive,
340                Box_::into_raw(super_callback0) as *mut _,
341                destroy_call3,
342            );
343        }
344    }
345
346    //#[cfg(feature = "v1_16")]
347    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
348    //#[doc(alias = "gst_rtsp_stream_transport_set_list_callbacks")]
349    //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>) {
350    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_set_list_callbacks() }
351    //}
352
353    /// Install a callback that will be called when a message has been sent on `self`.
354    /// ## `message_sent`
355    /// a callback called when a message has been sent
356    /// ## `notify`
357    /// called with the user_data when no longer needed
358    #[doc(alias = "gst_rtsp_stream_transport_set_message_sent")]
359    fn set_message_sent<P: Fn() + 'static>(&self, message_sent: P) {
360        let message_sent_data: Box_<P> = Box_::new(message_sent);
361        unsafe extern "C" fn message_sent_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
362            unsafe {
363                let callback = &*(user_data as *mut P);
364                (*callback)()
365            }
366        }
367        let message_sent = Some(message_sent_func::<P> as _);
368        unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
369            unsafe {
370                let _callback = Box_::from_raw(data as *mut P);
371            }
372        }
373        let destroy_call3 = Some(notify_func::<P> as _);
374        let super_callback0: Box_<P> = message_sent_data;
375        unsafe {
376            ffi::gst_rtsp_stream_transport_set_message_sent(
377                self.as_ref().to_glib_none().0,
378                message_sent,
379                Box_::into_raw(super_callback0) as *mut _,
380                destroy_call3,
381            );
382        }
383    }
384
385    /// Install a callback that will be called when a message has been sent on `self`.
386    /// ## `message_sent`
387    /// a callback called when a message has been sent
388    /// ## `notify`
389    /// called with the user_data when no longer needed
390    #[cfg(feature = "v1_18")]
391    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
392    #[doc(alias = "gst_rtsp_stream_transport_set_message_sent_full")]
393    fn set_message_sent_full<P: Fn(&RTSPStreamTransport) + 'static>(&self, message_sent: P) {
394        let message_sent_data: Box_<P> = Box_::new(message_sent);
395        unsafe extern "C" fn message_sent_func<P: Fn(&RTSPStreamTransport) + 'static>(
396            trans: *mut ffi::GstRTSPStreamTransport,
397            user_data: glib::ffi::gpointer,
398        ) {
399            unsafe {
400                let trans = from_glib_borrow(trans);
401                let callback = &*(user_data as *mut P);
402                (*callback)(&trans)
403            }
404        }
405        let message_sent = Some(message_sent_func::<P> as _);
406        unsafe extern "C" fn notify_func<P: Fn(&RTSPStreamTransport) + 'static>(
407            data: glib::ffi::gpointer,
408        ) {
409            unsafe {
410                let _callback = Box_::from_raw(data as *mut P);
411            }
412        }
413        let destroy_call3 = Some(notify_func::<P> as _);
414        let super_callback0: Box_<P> = message_sent_data;
415        unsafe {
416            ffi::gst_rtsp_stream_transport_set_message_sent_full(
417                self.as_ref().to_glib_none().0,
418                message_sent,
419                Box_::into_raw(super_callback0) as *mut _,
420                destroy_call3,
421            );
422        }
423    }
424
425    /// Set the timed out state of `self` to `timedout`
426    /// ## `timedout`
427    /// timed out value
428    #[doc(alias = "gst_rtsp_stream_transport_set_timed_out")]
429    fn set_timed_out(&self, timedout: bool) {
430        unsafe {
431            ffi::gst_rtsp_stream_transport_set_timed_out(
432                self.as_ref().to_glib_none().0,
433                timedout.into_glib(),
434            );
435        }
436    }
437
438    //#[doc(alias = "gst_rtsp_stream_transport_set_transport")]
439    //fn set_transport(&self, tr: /*Ignored*/gst_rtsp::RTSPTransport) {
440    //    unsafe { TODO: call ffi:gst_rtsp_stream_transport_set_transport() }
441    //}
442
443    /// Set `url` as the client url.
444    /// ## `url`
445    /// a client [`gst_rtsp::RTSPUrl`][crate::gst_rtsp::RTSPUrl]
446    #[doc(alias = "gst_rtsp_stream_transport_set_url")]
447    fn set_url(&self, url: Option<&gst_rtsp::RTSPUrl>) {
448        unsafe {
449            ffi::gst_rtsp_stream_transport_set_url(
450                self.as_ref().to_glib_none().0,
451                url.to_glib_none().0,
452            );
453        }
454    }
455
456    #[cfg(feature = "v1_28")]
457    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
458    #[doc(alias = "timed-out")]
459    fn connect_timed_out_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
460        unsafe extern "C" fn notify_timed_out_trampoline<
461            P: IsA<RTSPStreamTransport>,
462            F: Fn(&P) + 'static,
463        >(
464            this: *mut ffi::GstRTSPStreamTransport,
465            _param_spec: glib::ffi::gpointer,
466            f: glib::ffi::gpointer,
467        ) {
468            unsafe {
469                let f: &F = &*(f as *const F);
470                f(RTSPStreamTransport::from_glib_borrow(this).unsafe_cast_ref())
471            }
472        }
473        unsafe {
474            let f: Box_<F> = Box_::new(f);
475            connect_raw(
476                self.as_ptr() as *mut _,
477                c"notify::timed-out".as_ptr(),
478                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
479                    notify_timed_out_trampoline::<Self, F> as *const (),
480                )),
481                Box_::into_raw(f),
482            )
483        }
484    }
485}
486
487impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExt for O {}