gstreamer_rtsp_server/auto/
rtsp_stream_transport.rs1use 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 #[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 }
43
44pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
50 #[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 #[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_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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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_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 {}