gstreamer_rtsp_server/auto/
rtsp_stream_transport.rs1use crate::{ffi, RTSPStream};
7#[cfg(feature = "v1_28")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
9use glib::signal::{connect_raw, SignalHandlerId};
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 let buffer = from_glib_borrow(buffer);
266 let callback: &(P, Q) = &*(user_data as *mut _);
267 let callback = &callback.0;
268 (*callback)(&buffer, channel).into_glib()
269 }
270 let send_rtp = Some(send_rtp_func::<P, Q> as _);
271 let send_rtcp_data: Q = send_rtcp;
272 unsafe extern "C" fn send_rtcp_func<
273 P: Fn(&gst::Buffer, u8) -> bool + 'static,
274 Q: Fn(&gst::Buffer, u8) -> bool + 'static,
275 >(
276 buffer: *mut gst::ffi::GstBuffer,
277 channel: u8,
278 user_data: glib::ffi::gpointer,
279 ) -> glib::ffi::gboolean {
280 let buffer = from_glib_borrow(buffer);
281 let callback: &(P, Q) = &*(user_data as *mut _);
282 let callback = &callback.1;
283 (*callback)(&buffer, channel).into_glib()
284 }
285 let send_rtcp = Some(send_rtcp_func::<P, Q> as _);
286 unsafe extern "C" fn notify_func<
287 P: Fn(&gst::Buffer, u8) -> bool + 'static,
288 Q: Fn(&gst::Buffer, u8) -> bool + 'static,
289 >(
290 data: glib::ffi::gpointer,
291 ) {
292 let _callback: Box_<(P, Q)> = Box_::from_raw(data as *mut _);
293 }
294 let destroy_call4 = Some(notify_func::<P, Q> as _);
295 let super_callback0: Box_<(P, Q)> = Box_::new((send_rtp_data, send_rtcp_data));
296 unsafe {
297 ffi::gst_rtsp_stream_transport_set_callbacks(
298 self.as_ref().to_glib_none().0,
299 send_rtp,
300 send_rtcp,
301 Box_::into_raw(super_callback0) as *mut _,
302 destroy_call4,
303 );
304 }
305 }
306
307 #[doc(alias = "gst_rtsp_stream_transport_set_keepalive")]
314 fn set_keepalive<P: Fn() + 'static>(&self, keep_alive: P) {
315 let keep_alive_data: Box_<P> = Box_::new(keep_alive);
316 unsafe extern "C" fn keep_alive_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
317 let callback = &*(user_data as *mut P);
318 (*callback)()
319 }
320 let keep_alive = Some(keep_alive_func::<P> as _);
321 unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
322 let _callback = Box_::from_raw(data as *mut P);
323 }
324 let destroy_call3 = Some(notify_func::<P> as _);
325 let super_callback0: Box_<P> = keep_alive_data;
326 unsafe {
327 ffi::gst_rtsp_stream_transport_set_keepalive(
328 self.as_ref().to_glib_none().0,
329 keep_alive,
330 Box_::into_raw(super_callback0) as *mut _,
331 destroy_call3,
332 );
333 }
334 }
335
336 #[doc(alias = "gst_rtsp_stream_transport_set_message_sent")]
349 fn set_message_sent<P: Fn() + 'static>(&self, message_sent: P) {
350 let message_sent_data: Box_<P> = Box_::new(message_sent);
351 unsafe extern "C" fn message_sent_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
352 let callback = &*(user_data as *mut P);
353 (*callback)()
354 }
355 let message_sent = Some(message_sent_func::<P> as _);
356 unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
357 let _callback = Box_::from_raw(data as *mut P);
358 }
359 let destroy_call3 = Some(notify_func::<P> as _);
360 let super_callback0: Box_<P> = message_sent_data;
361 unsafe {
362 ffi::gst_rtsp_stream_transport_set_message_sent(
363 self.as_ref().to_glib_none().0,
364 message_sent,
365 Box_::into_raw(super_callback0) as *mut _,
366 destroy_call3,
367 );
368 }
369 }
370
371 #[cfg(feature = "v1_18")]
377 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
378 #[doc(alias = "gst_rtsp_stream_transport_set_message_sent_full")]
379 fn set_message_sent_full<P: Fn(&RTSPStreamTransport) + 'static>(&self, message_sent: P) {
380 let message_sent_data: Box_<P> = Box_::new(message_sent);
381 unsafe extern "C" fn message_sent_func<P: Fn(&RTSPStreamTransport) + 'static>(
382 trans: *mut ffi::GstRTSPStreamTransport,
383 user_data: glib::ffi::gpointer,
384 ) {
385 let trans = from_glib_borrow(trans);
386 let callback = &*(user_data as *mut P);
387 (*callback)(&trans)
388 }
389 let message_sent = Some(message_sent_func::<P> as _);
390 unsafe extern "C" fn notify_func<P: Fn(&RTSPStreamTransport) + 'static>(
391 data: glib::ffi::gpointer,
392 ) {
393 let _callback = Box_::from_raw(data as *mut P);
394 }
395 let destroy_call3 = Some(notify_func::<P> as _);
396 let super_callback0: Box_<P> = message_sent_data;
397 unsafe {
398 ffi::gst_rtsp_stream_transport_set_message_sent_full(
399 self.as_ref().to_glib_none().0,
400 message_sent,
401 Box_::into_raw(super_callback0) as *mut _,
402 destroy_call3,
403 );
404 }
405 }
406
407 #[doc(alias = "gst_rtsp_stream_transport_set_timed_out")]
411 fn set_timed_out(&self, timedout: bool) {
412 unsafe {
413 ffi::gst_rtsp_stream_transport_set_timed_out(
414 self.as_ref().to_glib_none().0,
415 timedout.into_glib(),
416 );
417 }
418 }
419
420 #[doc(alias = "gst_rtsp_stream_transport_set_url")]
429 fn set_url(&self, url: Option<&gst_rtsp::RTSPUrl>) {
430 unsafe {
431 ffi::gst_rtsp_stream_transport_set_url(
432 self.as_ref().to_glib_none().0,
433 url.to_glib_none().0,
434 );
435 }
436 }
437
438 #[cfg(feature = "v1_28")]
439 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
440 #[doc(alias = "timed-out")]
441 fn connect_timed_out_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
442 unsafe extern "C" fn notify_timed_out_trampoline<
443 P: IsA<RTSPStreamTransport>,
444 F: Fn(&P) + 'static,
445 >(
446 this: *mut ffi::GstRTSPStreamTransport,
447 _param_spec: glib::ffi::gpointer,
448 f: glib::ffi::gpointer,
449 ) {
450 let f: &F = &*(f as *const F);
451 f(RTSPStreamTransport::from_glib_borrow(this).unsafe_cast_ref())
452 }
453 unsafe {
454 let f: Box_<F> = Box_::new(f);
455 connect_raw(
456 self.as_ptr() as *mut _,
457 c"notify::timed-out".as_ptr() as *const _,
458 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
459 notify_timed_out_trampoline::<Self, F> as *const (),
460 )),
461 Box_::into_raw(f),
462 )
463 }
464 }
465}
466
467impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExt for O {}