gstreamer_rtsp_server/auto/
rtsp_stream_transport.rs
1use crate::{ffi, RTSPStream};
7use glib::{prelude::*, translate::*};
8use std::boxed::Box as Box_;
9
10glib::wrapper! {
11 #[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 }
32
33pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
39 #[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 #[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_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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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_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 {}