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::{ffi, WebRTCRTPReceiver, WebRTCRTPSender};
13#[cfg(feature = "v1_18")]
14#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
15use glib::signal::{connect_raw, SignalHandlerId};
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            let f: &F = &*(f as *const F);
193            f(&from_glib_borrow(this))
194        }
195        unsafe {
196            let f: Box_<F> = Box_::new(f);
197            connect_raw(
198                self.as_ptr() as *mut _,
199                c"notify::codec-preferences".as_ptr() as *const _,
200                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201                    notify_codec_preferences_trampoline::<F> as *const (),
202                )),
203                Box_::into_raw(f),
204            )
205        }
206    }
207
208    #[cfg(feature = "v1_20")]
209    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
210    #[doc(alias = "current-direction")]
211    pub fn connect_current_direction_notify<F: Fn(&Self) + Send + Sync + 'static>(
212        &self,
213        f: F,
214    ) -> SignalHandlerId {
215        unsafe extern "C" fn notify_current_direction_trampoline<
216            F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
217        >(
218            this: *mut ffi::GstWebRTCRTPTransceiver,
219            _param_spec: glib::ffi::gpointer,
220            f: glib::ffi::gpointer,
221        ) {
222            let f: &F = &*(f as *const F);
223            f(&from_glib_borrow(this))
224        }
225        unsafe {
226            let f: Box_<F> = Box_::new(f);
227            connect_raw(
228                self.as_ptr() as *mut _,
229                c"notify::current-direction".as_ptr() as *const _,
230                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
231                    notify_current_direction_trampoline::<F> as *const (),
232                )),
233                Box_::into_raw(f),
234            )
235        }
236    }
237
238    #[cfg(feature = "v1_18")]
239    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
240    #[doc(alias = "direction")]
241    pub fn connect_direction_notify<F: Fn(&Self) + Send + Sync + 'static>(
242        &self,
243        f: F,
244    ) -> SignalHandlerId {
245        unsafe extern "C" fn notify_direction_trampoline<
246            F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
247        >(
248            this: *mut ffi::GstWebRTCRTPTransceiver,
249            _param_spec: glib::ffi::gpointer,
250            f: glib::ffi::gpointer,
251        ) {
252            let f: &F = &*(f as *const F);
253            f(&from_glib_borrow(this))
254        }
255        unsafe {
256            let f: Box_<F> = Box_::new(f);
257            connect_raw(
258                self.as_ptr() as *mut _,
259                c"notify::direction".as_ptr() as *const _,
260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
261                    notify_direction_trampoline::<F> as *const (),
262                )),
263                Box_::into_raw(f),
264            )
265        }
266    }
267
268    #[cfg(feature = "v1_20")]
269    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
270    #[doc(alias = "kind")]
271    pub fn connect_kind_notify<F: Fn(&Self) + Send + Sync + 'static>(
272        &self,
273        f: F,
274    ) -> SignalHandlerId {
275        unsafe extern "C" fn notify_kind_trampoline<
276            F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
277        >(
278            this: *mut ffi::GstWebRTCRTPTransceiver,
279            _param_spec: glib::ffi::gpointer,
280            f: glib::ffi::gpointer,
281        ) {
282            let f: &F = &*(f as *const F);
283            f(&from_glib_borrow(this))
284        }
285        unsafe {
286            let f: Box_<F> = Box_::new(f);
287            connect_raw(
288                self.as_ptr() as *mut _,
289                c"notify::kind".as_ptr() as *const _,
290                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
291                    notify_kind_trampoline::<F> as *const (),
292                )),
293                Box_::into_raw(f),
294            )
295        }
296    }
297
298    #[cfg(feature = "v1_20")]
299    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
300    #[doc(alias = "mid")]
301    pub fn connect_mid_notify<F: Fn(&Self) + Send + Sync + 'static>(
302        &self,
303        f: F,
304    ) -> SignalHandlerId {
305        unsafe extern "C" fn notify_mid_trampoline<
306            F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
307        >(
308            this: *mut ffi::GstWebRTCRTPTransceiver,
309            _param_spec: glib::ffi::gpointer,
310            f: glib::ffi::gpointer,
311        ) {
312            let f: &F = &*(f as *const F);
313            f(&from_glib_borrow(this))
314        }
315        unsafe {
316            let f: Box_<F> = Box_::new(f);
317            connect_raw(
318                self.as_ptr() as *mut _,
319                c"notify::mid".as_ptr() as *const _,
320                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
321                    notify_mid_trampoline::<F> as *const (),
322                )),
323                Box_::into_raw(f),
324            )
325        }
326    }
327}
328
329unsafe impl Send for WebRTCRTPTransceiver {}
330unsafe impl Sync for WebRTCRTPTransceiver {}