gstreamer_webrtc/auto/
web_rtcrtp_transceiver.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6#[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    /// Mostly matches the WebRTC RTCRtpTransceiver interface.
23    ///
24    /// This is an Abstract Base Class, you cannot instantiate it.
25    ///
26    /// ## Properties
27    ///
28    ///
29    /// #### `codec-preferences`
30    ///  Caps representing the codec preferences.
31    ///
32    /// Readable | Writeable
33    ///
34    ///
35    /// #### `current-direction`
36    ///  The transceiver's current directionality, or none if the
37    /// transceiver is stopped or has never participated in an exchange
38    /// of offers and answers. To change the transceiver's
39    /// directionality, set the value of the direction property.
40    ///
41    /// Readable
42    ///
43    ///
44    /// #### `direction`
45    ///  Direction of the transceiver.
46    ///
47    /// Readable | Writeable
48    ///
49    ///
50    /// #### `kind`
51    ///  The kind of media this transceiver transports
52    ///
53    /// Readable
54    ///
55    ///
56    /// #### `mid`
57    ///  The media ID of the m-line associated with this transceiver. This
58    /// association is established, when possible, whenever either a
59    /// local or remote description is applied. This field is null if
60    /// neither a local or remote description has been applied, or if its
61    /// associated m-line is rejected by either a remote offer or any
62    /// answer.
63    ///
64    /// Readable
65    ///
66    ///
67    /// #### `mlineindex`
68    ///  Readable | Writeable | Construct Only
69    ///
70    ///
71    /// #### `receiver`
72    ///  Readable | Writeable | Construct Only
73    ///
74    ///
75    /// #### `sender`
76    ///  Readable | Writeable | Construct Only
77    /// <details><summary><h4>Object</h4></summary>
78    ///
79    ///
80    /// #### `name`
81    ///  Readable | Writeable | Construct
82    ///
83    ///
84    /// #### `parent`
85    ///  The parent of the object. Please note, that when changing the 'parent'
86    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and `GstObject::deep-notify`
87    /// signals due to locking issues. In some cases one can use
88    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
89    /// achieve a similar effect.
90    ///
91    /// Readable | Writeable
92    /// </details>
93    ///
94    /// # Implements
95    ///
96    /// [`trait@glib::ObjectExt`]
97    #[doc(alias = "GstWebRTCRTPTransceiver")]
98    pub struct WebRTCRTPTransceiver(Object<ffi::GstWebRTCRTPTransceiver, ffi::GstWebRTCRTPTransceiverClass>);
99
100    match fn {
101        type_ => || ffi::gst_webrtc_rtp_transceiver_get_type(),
102    }
103}
104
105impl WebRTCRTPTransceiver {
106    /// Caps representing the codec preferences.
107    #[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    /// Caps representing the codec preferences.
115    #[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    /// The transceiver's current directionality, or none if the
123    /// transceiver is stopped or has never participated in an exchange
124    /// of offers and answers. To change the transceiver's
125    /// directionality, set the value of the direction property.
126    #[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    /// Direction of the transceiver.
134    #[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    /// Direction of the transceiver.
141    #[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    /// The kind of media this transceiver transports
148    #[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    /// The media ID of the m-line associated with this transceiver. This
155    /// association is established, when possible, whenever either a
156    /// local or remote description is applied. This field is null if
157    /// neither a local or remote description has been applied, or if its
158    /// associated m-line is rejected by either a remote offer or any
159    /// answer.
160    #[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 {}