1#[cfg(feature = "v1_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
8use crate::WebRTCKind;
9#[cfg(feature = "v1_18")]
10#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
11use crate::WebRTCRTPTransceiverDirection;
12use crate::{WebRTCRTPReceiver, WebRTCRTPSender, ffi};
13#[cfg(feature = "v1_18")]
14#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
15use glib::signal::{SignalHandlerId, connect_raw};
16use glib::{prelude::*, translate::*};
17#[cfg(feature = "v1_18")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22 #[doc(alias = "GstWebRTCRTPTransceiver")]
98 pub struct WebRTCRTPTransceiver(Object<ffi::GstWebRTCRTPTransceiver, ffi::GstWebRTCRTPTransceiverClass>) @extends gst::Object;
99
100 match fn {
101 type_ => || ffi::gst_webrtc_rtp_transceiver_get_type(),
102 }
103}
104
105impl WebRTCRTPTransceiver {
106 #[cfg(feature = "v1_20")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
109 #[doc(alias = "codec-preferences")]
110 pub fn codec_preferences(&self) -> Option<gst::Caps> {
111 ObjectExt::property(self, "codec-preferences")
112 }
113
114 #[cfg(feature = "v1_20")]
116 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
117 #[doc(alias = "codec-preferences")]
118 pub fn set_codec_preferences(&self, codec_preferences: Option<&gst::Caps>) {
119 ObjectExt::set_property(self, "codec-preferences", codec_preferences)
120 }
121
122 #[cfg(feature = "v1_20")]
127 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
128 #[doc(alias = "current-direction")]
129 pub fn current_direction(&self) -> WebRTCRTPTransceiverDirection {
130 ObjectExt::property(self, "current-direction")
131 }
132
133 #[cfg(feature = "v1_18")]
135 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
136 pub fn direction(&self) -> WebRTCRTPTransceiverDirection {
137 ObjectExt::property(self, "direction")
138 }
139
140 #[cfg(feature = "v1_18")]
142 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
143 pub fn set_direction(&self, direction: WebRTCRTPTransceiverDirection) {
144 ObjectExt::set_property(self, "direction", direction)
145 }
146
147 #[cfg(feature = "v1_20")]
149 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
150 pub fn kind(&self) -> WebRTCKind {
151 ObjectExt::property(self, "kind")
152 }
153
154 #[cfg(feature = "v1_20")]
161 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
162 pub fn mid(&self) -> Option<glib::GString> {
163 ObjectExt::property(self, "mid")
164 }
165
166 pub fn mlineindex(&self) -> u32 {
167 ObjectExt::property(self, "mlineindex")
168 }
169
170 pub fn receiver(&self) -> Option<WebRTCRTPReceiver> {
171 ObjectExt::property(self, "receiver")
172 }
173
174 pub fn sender(&self) -> Option<WebRTCRTPSender> {
175 ObjectExt::property(self, "sender")
176 }
177
178 #[cfg(feature = "v1_20")]
179 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
180 #[doc(alias = "codec-preferences")]
181 pub fn connect_codec_preferences_notify<F: Fn(&Self) + Send + Sync + 'static>(
182 &self,
183 f: F,
184 ) -> SignalHandlerId {
185 unsafe extern "C" fn notify_codec_preferences_trampoline<
186 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
187 >(
188 this: *mut ffi::GstWebRTCRTPTransceiver,
189 _param_spec: glib::ffi::gpointer,
190 f: glib::ffi::gpointer,
191 ) {
192 unsafe {
193 let f: &F = &*(f as *const F);
194 f(&from_glib_borrow(this))
195 }
196 }
197 unsafe {
198 let f: Box_<F> = Box_::new(f);
199 connect_raw(
200 self.as_ptr() as *mut _,
201 c"notify::codec-preferences".as_ptr(),
202 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
203 notify_codec_preferences_trampoline::<F> as *const (),
204 )),
205 Box_::into_raw(f),
206 )
207 }
208 }
209
210 #[cfg(feature = "v1_20")]
211 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
212 #[doc(alias = "current-direction")]
213 pub fn connect_current_direction_notify<F: Fn(&Self) + Send + Sync + 'static>(
214 &self,
215 f: F,
216 ) -> SignalHandlerId {
217 unsafe extern "C" fn notify_current_direction_trampoline<
218 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
219 >(
220 this: *mut ffi::GstWebRTCRTPTransceiver,
221 _param_spec: glib::ffi::gpointer,
222 f: glib::ffi::gpointer,
223 ) {
224 unsafe {
225 let f: &F = &*(f as *const F);
226 f(&from_glib_borrow(this))
227 }
228 }
229 unsafe {
230 let f: Box_<F> = Box_::new(f);
231 connect_raw(
232 self.as_ptr() as *mut _,
233 c"notify::current-direction".as_ptr(),
234 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
235 notify_current_direction_trampoline::<F> as *const (),
236 )),
237 Box_::into_raw(f),
238 )
239 }
240 }
241
242 #[cfg(feature = "v1_18")]
243 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
244 #[doc(alias = "direction")]
245 pub fn connect_direction_notify<F: Fn(&Self) + Send + Sync + 'static>(
246 &self,
247 f: F,
248 ) -> SignalHandlerId {
249 unsafe extern "C" fn notify_direction_trampoline<
250 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
251 >(
252 this: *mut ffi::GstWebRTCRTPTransceiver,
253 _param_spec: glib::ffi::gpointer,
254 f: glib::ffi::gpointer,
255 ) {
256 unsafe {
257 let f: &F = &*(f as *const F);
258 f(&from_glib_borrow(this))
259 }
260 }
261 unsafe {
262 let f: Box_<F> = Box_::new(f);
263 connect_raw(
264 self.as_ptr() as *mut _,
265 c"notify::direction".as_ptr(),
266 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
267 notify_direction_trampoline::<F> as *const (),
268 )),
269 Box_::into_raw(f),
270 )
271 }
272 }
273
274 #[cfg(feature = "v1_20")]
275 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
276 #[doc(alias = "kind")]
277 pub fn connect_kind_notify<F: Fn(&Self) + Send + Sync + 'static>(
278 &self,
279 f: F,
280 ) -> SignalHandlerId {
281 unsafe extern "C" fn notify_kind_trampoline<
282 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
283 >(
284 this: *mut ffi::GstWebRTCRTPTransceiver,
285 _param_spec: glib::ffi::gpointer,
286 f: glib::ffi::gpointer,
287 ) {
288 unsafe {
289 let f: &F = &*(f as *const F);
290 f(&from_glib_borrow(this))
291 }
292 }
293 unsafe {
294 let f: Box_<F> = Box_::new(f);
295 connect_raw(
296 self.as_ptr() as *mut _,
297 c"notify::kind".as_ptr(),
298 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
299 notify_kind_trampoline::<F> as *const (),
300 )),
301 Box_::into_raw(f),
302 )
303 }
304 }
305
306 #[cfg(feature = "v1_20")]
307 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
308 #[doc(alias = "mid")]
309 pub fn connect_mid_notify<F: Fn(&Self) + Send + Sync + 'static>(
310 &self,
311 f: F,
312 ) -> SignalHandlerId {
313 unsafe extern "C" fn notify_mid_trampoline<
314 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
315 >(
316 this: *mut ffi::GstWebRTCRTPTransceiver,
317 _param_spec: glib::ffi::gpointer,
318 f: glib::ffi::gpointer,
319 ) {
320 unsafe {
321 let f: &F = &*(f as *const F);
322 f(&from_glib_borrow(this))
323 }
324 }
325 unsafe {
326 let f: Box_<F> = Box_::new(f);
327 connect_raw(
328 self.as_ptr() as *mut _,
329 c"notify::mid".as_ptr(),
330 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
331 notify_mid_trampoline::<F> as *const (),
332 )),
333 Box_::into_raw(f),
334 )
335 }
336 }
337}
338
339unsafe impl Send for WebRTCRTPTransceiver {}
340unsafe impl Sync for WebRTCRTPTransceiver {}