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
33mod sealed {
34 pub trait Sealed {}
35 impl<T: super::IsA<super::RTSPStreamTransport>> Sealed for T {}
36}
37
38pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + sealed::Sealed + 'static {
44 #[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 #[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_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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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_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 {}