Skip to main content

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::{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    /// 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 [`deep-notify`][struct@crate::gst::Object#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@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
97    #[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    /// 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            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 {}