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")]
15 pub struct RTSPStreamTransport(Object<ffi::GstRTSPStreamTransport, ffi::GstRTSPStreamTransportClass>);
16
17 match fn {
18 type_ => || ffi::gst_rtsp_stream_transport_get_type(),
19 }
20}
21
22impl RTSPStreamTransport {
23 pub const NONE: Option<&'static RTSPStreamTransport> = None;
24
25 }
30
31pub trait RTSPStreamTransportExt: IsA<RTSPStreamTransport> + 'static {
32 #[doc(alias = "gst_rtsp_stream_transport_get_rtpinfo")]
33 #[doc(alias = "get_rtpinfo")]
34 fn rtpinfo(&self, start_time: impl Into<Option<gst::ClockTime>>) -> Option<glib::GString> {
35 unsafe {
36 from_glib_full(ffi::gst_rtsp_stream_transport_get_rtpinfo(
37 self.as_ref().to_glib_none().0,
38 start_time.into().into_glib(),
39 ))
40 }
41 }
42
43 #[doc(alias = "gst_rtsp_stream_transport_get_stream")]
44 #[doc(alias = "get_stream")]
45 fn stream(&self) -> Option<RTSPStream> {
46 unsafe {
47 from_glib_none(ffi::gst_rtsp_stream_transport_get_stream(
48 self.as_ref().to_glib_none().0,
49 ))
50 }
51 }
52
53 #[doc(alias = "gst_rtsp_stream_transport_get_url")]
60 #[doc(alias = "get_url")]
61 fn url(&self) -> Option<gst_rtsp::RTSPUrl> {
62 unsafe {
63 from_glib_none(ffi::gst_rtsp_stream_transport_get_url(
64 self.as_ref().to_glib_none().0,
65 ))
66 }
67 }
68
69 #[doc(alias = "gst_rtsp_stream_transport_is_timed_out")]
70 #[doc(alias = "timed-out")]
71 fn is_timed_out(&self) -> bool {
72 unsafe {
73 from_glib(ffi::gst_rtsp_stream_transport_is_timed_out(
74 self.as_ref().to_glib_none().0,
75 ))
76 }
77 }
78
79 #[doc(alias = "gst_rtsp_stream_transport_keep_alive")]
80 fn keep_alive(&self) {
81 unsafe {
82 ffi::gst_rtsp_stream_transport_keep_alive(self.as_ref().to_glib_none().0);
83 }
84 }
85
86 #[cfg(feature = "v1_16")]
87 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
88 #[doc(alias = "gst_rtsp_stream_transport_message_sent")]
89 fn message_sent(&self) {
90 unsafe {
91 ffi::gst_rtsp_stream_transport_message_sent(self.as_ref().to_glib_none().0);
92 }
93 }
94
95 #[doc(alias = "gst_rtsp_stream_transport_recv_data")]
96 fn recv_data(
97 &self,
98 channel: u32,
99 buffer: gst::Buffer,
100 ) -> Result<gst::FlowSuccess, gst::FlowError> {
101 unsafe {
102 try_from_glib(ffi::gst_rtsp_stream_transport_recv_data(
103 self.as_ref().to_glib_none().0,
104 channel,
105 buffer.into_glib_ptr(),
106 ))
107 }
108 }
109
110 #[doc(alias = "gst_rtsp_stream_transport_send_rtcp")]
111 fn send_rtcp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
112 unsafe {
113 glib::result_from_gboolean!(
114 ffi::gst_rtsp_stream_transport_send_rtcp(
115 self.as_ref().to_glib_none().0,
116 buffer.to_glib_none().0
117 ),
118 "Failed to send rtcp"
119 )
120 }
121 }
122
123 #[doc(alias = "gst_rtsp_stream_transport_send_rtp")]
131 fn send_rtp(&self, buffer: &gst::Buffer) -> Result<(), glib::error::BoolError> {
132 unsafe {
133 glib::result_from_gboolean!(
134 ffi::gst_rtsp_stream_transport_send_rtp(
135 self.as_ref().to_glib_none().0,
136 buffer.to_glib_none().0
137 ),
138 "Failed to send rtp"
139 )
140 }
141 }
142
143 #[doc(alias = "gst_rtsp_stream_transport_set_active")]
151 fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> {
152 unsafe {
153 glib::result_from_gboolean!(
154 ffi::gst_rtsp_stream_transport_set_active(
155 self.as_ref().to_glib_none().0,
156 active.into_glib()
157 ),
158 "Failed to set active"
159 )
160 }
161 }
162
163 #[doc(alias = "gst_rtsp_stream_transport_set_callbacks")]
164 fn set_callbacks<
165 P: Fn(&gst::Buffer, u8) -> bool + 'static,
166 Q: Fn(&gst::Buffer, u8) -> bool + 'static,
167 >(
168 &self,
169 send_rtp: P,
170 send_rtcp: Q,
171 ) {
172 let send_rtp_data: P = send_rtp;
173 unsafe extern "C" fn send_rtp_func<
174 P: Fn(&gst::Buffer, u8) -> bool + 'static,
175 Q: Fn(&gst::Buffer, u8) -> bool + 'static,
176 >(
177 buffer: *mut gst::ffi::GstBuffer,
178 channel: u8,
179 user_data: glib::ffi::gpointer,
180 ) -> glib::ffi::gboolean {
181 let buffer = from_glib_borrow(buffer);
182 let callback: &(P, Q) = &*(user_data as *mut _);
183 let callback = &callback.0;
184 (*callback)(&buffer, channel).into_glib()
185 }
186 let send_rtp = Some(send_rtp_func::<P, Q> as _);
187 let send_rtcp_data: Q = send_rtcp;
188 unsafe extern "C" fn send_rtcp_func<
189 P: Fn(&gst::Buffer, u8) -> bool + 'static,
190 Q: Fn(&gst::Buffer, u8) -> bool + 'static,
191 >(
192 buffer: *mut gst::ffi::GstBuffer,
193 channel: u8,
194 user_data: glib::ffi::gpointer,
195 ) -> glib::ffi::gboolean {
196 let buffer = from_glib_borrow(buffer);
197 let callback: &(P, Q) = &*(user_data as *mut _);
198 let callback = &callback.1;
199 (*callback)(&buffer, channel).into_glib()
200 }
201 let send_rtcp = Some(send_rtcp_func::<P, Q> as _);
202 unsafe extern "C" fn notify_func<
203 P: Fn(&gst::Buffer, u8) -> bool + 'static,
204 Q: Fn(&gst::Buffer, u8) -> bool + 'static,
205 >(
206 data: glib::ffi::gpointer,
207 ) {
208 let _callback: Box_<(P, Q)> = Box_::from_raw(data as *mut _);
209 }
210 let destroy_call4 = Some(notify_func::<P, Q> as _);
211 let super_callback0: Box_<(P, Q)> = Box_::new((send_rtp_data, send_rtcp_data));
212 unsafe {
213 ffi::gst_rtsp_stream_transport_set_callbacks(
214 self.as_ref().to_glib_none().0,
215 send_rtp,
216 send_rtcp,
217 Box_::into_raw(super_callback0) as *mut _,
218 destroy_call4,
219 );
220 }
221 }
222
223 #[doc(alias = "gst_rtsp_stream_transport_set_keepalive")]
224 fn set_keepalive<P: Fn() + 'static>(&self, keep_alive: P) {
225 let keep_alive_data: Box_<P> = Box_::new(keep_alive);
226 unsafe extern "C" fn keep_alive_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
227 let callback = &*(user_data as *mut P);
228 (*callback)()
229 }
230 let keep_alive = Some(keep_alive_func::<P> as _);
231 unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
232 let _callback = Box_::from_raw(data as *mut P);
233 }
234 let destroy_call3 = Some(notify_func::<P> as _);
235 let super_callback0: Box_<P> = keep_alive_data;
236 unsafe {
237 ffi::gst_rtsp_stream_transport_set_keepalive(
238 self.as_ref().to_glib_none().0,
239 keep_alive,
240 Box_::into_raw(super_callback0) as *mut _,
241 destroy_call3,
242 );
243 }
244 }
245
246 #[doc(alias = "gst_rtsp_stream_transport_set_message_sent")]
254 fn set_message_sent<P: Fn() + 'static>(&self, message_sent: P) {
255 let message_sent_data: Box_<P> = Box_::new(message_sent);
256 unsafe extern "C" fn message_sent_func<P: Fn() + 'static>(user_data: glib::ffi::gpointer) {
257 let callback = &*(user_data as *mut P);
258 (*callback)()
259 }
260 let message_sent = Some(message_sent_func::<P> as _);
261 unsafe extern "C" fn notify_func<P: Fn() + 'static>(data: glib::ffi::gpointer) {
262 let _callback = Box_::from_raw(data as *mut P);
263 }
264 let destroy_call3 = Some(notify_func::<P> as _);
265 let super_callback0: Box_<P> = message_sent_data;
266 unsafe {
267 ffi::gst_rtsp_stream_transport_set_message_sent(
268 self.as_ref().to_glib_none().0,
269 message_sent,
270 Box_::into_raw(super_callback0) as *mut _,
271 destroy_call3,
272 );
273 }
274 }
275
276 #[cfg(feature = "v1_18")]
277 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
278 #[doc(alias = "gst_rtsp_stream_transport_set_message_sent_full")]
279 fn set_message_sent_full<P: Fn(&RTSPStreamTransport) + 'static>(&self, message_sent: P) {
280 let message_sent_data: Box_<P> = Box_::new(message_sent);
281 unsafe extern "C" fn message_sent_func<P: Fn(&RTSPStreamTransport) + 'static>(
282 trans: *mut ffi::GstRTSPStreamTransport,
283 user_data: glib::ffi::gpointer,
284 ) {
285 let trans = from_glib_borrow(trans);
286 let callback = &*(user_data as *mut P);
287 (*callback)(&trans)
288 }
289 let message_sent = Some(message_sent_func::<P> as _);
290 unsafe extern "C" fn notify_func<P: Fn(&RTSPStreamTransport) + 'static>(
291 data: glib::ffi::gpointer,
292 ) {
293 let _callback = Box_::from_raw(data as *mut P);
294 }
295 let destroy_call3 = Some(notify_func::<P> as _);
296 let super_callback0: Box_<P> = message_sent_data;
297 unsafe {
298 ffi::gst_rtsp_stream_transport_set_message_sent_full(
299 self.as_ref().to_glib_none().0,
300 message_sent,
301 Box_::into_raw(super_callback0) as *mut _,
302 destroy_call3,
303 );
304 }
305 }
306
307 #[doc(alias = "gst_rtsp_stream_transport_set_timed_out")]
308 fn set_timed_out(&self, timedout: bool) {
309 unsafe {
310 ffi::gst_rtsp_stream_transport_set_timed_out(
311 self.as_ref().to_glib_none().0,
312 timedout.into_glib(),
313 );
314 }
315 }
316
317 #[doc(alias = "gst_rtsp_stream_transport_set_url")]
323 fn set_url(&self, url: Option<&gst_rtsp::RTSPUrl>) {
324 unsafe {
325 ffi::gst_rtsp_stream_transport_set_url(
326 self.as_ref().to_glib_none().0,
327 url.to_glib_none().0,
328 );
329 }
330 }
331
332 #[cfg(feature = "v1_28")]
333 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
334 #[doc(alias = "timed-out")]
335 fn connect_timed_out_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
336 unsafe extern "C" fn notify_timed_out_trampoline<
337 P: IsA<RTSPStreamTransport>,
338 F: Fn(&P) + 'static,
339 >(
340 this: *mut ffi::GstRTSPStreamTransport,
341 _param_spec: glib::ffi::gpointer,
342 f: glib::ffi::gpointer,
343 ) {
344 let f: &F = &*(f as *const F);
345 f(RTSPStreamTransport::from_glib_borrow(this).unsafe_cast_ref())
346 }
347 unsafe {
348 let f: Box_<F> = Box_::new(f);
349 connect_raw(
350 self.as_ptr() as *mut _,
351 c"notify::timed-out".as_ptr() as *const _,
352 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
353 notify_timed_out_trampoline::<Self, F> as *const (),
354 )),
355 Box_::into_raw(f),
356 )
357 }
358 }
359}
360
361impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExt for O {}