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