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