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")]
23 pub struct WebRTCRTPTransceiver(Object<ffi::GstWebRTCRTPTransceiver, ffi::GstWebRTCRTPTransceiverClass>);
24
25 match fn {
26 type_ => || ffi::gst_webrtc_rtp_transceiver_get_type(),
27 }
28}
29
30impl WebRTCRTPTransceiver {
31 #[cfg(feature = "v1_20")]
32 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
33 #[doc(alias = "codec-preferences")]
34 pub fn codec_preferences(&self) -> Option<gst::Caps> {
35 ObjectExt::property(self, "codec-preferences")
36 }
37
38 #[cfg(feature = "v1_20")]
39 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
40 #[doc(alias = "codec-preferences")]
41 pub fn set_codec_preferences(&self, codec_preferences: Option<&gst::Caps>) {
42 ObjectExt::set_property(self, "codec-preferences", codec_preferences)
43 }
44
45 #[cfg(feature = "v1_20")]
46 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
47 #[doc(alias = "current-direction")]
48 pub fn current_direction(&self) -> WebRTCRTPTransceiverDirection {
49 ObjectExt::property(self, "current-direction")
50 }
51
52 #[cfg(feature = "v1_18")]
53 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
54 pub fn direction(&self) -> WebRTCRTPTransceiverDirection {
55 ObjectExt::property(self, "direction")
56 }
57
58 #[cfg(feature = "v1_18")]
59 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
60 pub fn set_direction(&self, direction: WebRTCRTPTransceiverDirection) {
61 ObjectExt::set_property(self, "direction", direction)
62 }
63
64 #[cfg(feature = "v1_20")]
65 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
66 pub fn kind(&self) -> WebRTCKind {
67 ObjectExt::property(self, "kind")
68 }
69
70 #[cfg(feature = "v1_20")]
71 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
72 pub fn mid(&self) -> Option<glib::GString> {
73 ObjectExt::property(self, "mid")
74 }
75
76 pub fn mlineindex(&self) -> u32 {
77 ObjectExt::property(self, "mlineindex")
78 }
79
80 pub fn receiver(&self) -> Option<WebRTCRTPReceiver> {
81 ObjectExt::property(self, "receiver")
82 }
83
84 pub fn sender(&self) -> Option<WebRTCRTPSender> {
85 ObjectExt::property(self, "sender")
86 }
87
88 #[cfg(feature = "v1_20")]
89 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
90 #[doc(alias = "codec-preferences")]
91 pub fn connect_codec_preferences_notify<F: Fn(&Self) + Send + Sync + 'static>(
92 &self,
93 f: F,
94 ) -> SignalHandlerId {
95 unsafe extern "C" fn notify_codec_preferences_trampoline<
96 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
97 >(
98 this: *mut ffi::GstWebRTCRTPTransceiver,
99 _param_spec: glib::ffi::gpointer,
100 f: glib::ffi::gpointer,
101 ) {
102 let f: &F = &*(f as *const F);
103 f(&from_glib_borrow(this))
104 }
105 unsafe {
106 let f: Box_<F> = Box_::new(f);
107 connect_raw(
108 self.as_ptr() as *mut _,
109 b"notify::codec-preferences\0".as_ptr() as *const _,
110 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
111 notify_codec_preferences_trampoline::<F> as *const (),
112 )),
113 Box_::into_raw(f),
114 )
115 }
116 }
117
118 #[cfg(feature = "v1_20")]
119 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
120 #[doc(alias = "current-direction")]
121 pub fn connect_current_direction_notify<F: Fn(&Self) + Send + Sync + 'static>(
122 &self,
123 f: F,
124 ) -> SignalHandlerId {
125 unsafe extern "C" fn notify_current_direction_trampoline<
126 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
127 >(
128 this: *mut ffi::GstWebRTCRTPTransceiver,
129 _param_spec: glib::ffi::gpointer,
130 f: glib::ffi::gpointer,
131 ) {
132 let f: &F = &*(f as *const F);
133 f(&from_glib_borrow(this))
134 }
135 unsafe {
136 let f: Box_<F> = Box_::new(f);
137 connect_raw(
138 self.as_ptr() as *mut _,
139 b"notify::current-direction\0".as_ptr() as *const _,
140 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
141 notify_current_direction_trampoline::<F> as *const (),
142 )),
143 Box_::into_raw(f),
144 )
145 }
146 }
147
148 #[cfg(feature = "v1_18")]
149 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
150 #[doc(alias = "direction")]
151 pub fn connect_direction_notify<F: Fn(&Self) + Send + Sync + 'static>(
152 &self,
153 f: F,
154 ) -> SignalHandlerId {
155 unsafe extern "C" fn notify_direction_trampoline<
156 F: Fn(&WebRTCRTPTransceiver) + Send + Sync + 'static,
157 >(
158 this: *mut ffi::GstWebRTCRTPTransceiver,
159 _param_spec: glib::ffi::gpointer,
160 f: glib::ffi::gpointer,
161 ) {
162 let f: &F = &*(f as *const F);
163 f(&from_glib_borrow(this))
164 }
165 unsafe {
166 let f: Box_<F> = Box_::new(f);
167 connect_raw(
168 self.as_ptr() as *mut _,
169 b"notify::direction\0".as_ptr() as *const _,
170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
171 notify_direction_trampoline::<F> as *const (),
172 )),
173 Box_::into_raw(f),
174 )
175 }
176 }
177
178 #[cfg(feature = "v1_20")]
179 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
180 #[doc(alias = "kind")]
181 pub fn connect_kind_notify<F: Fn(&Self) + Send + Sync + 'static>(
182 &self,
183 f: F,
184 ) -> SignalHandlerId {
185 unsafe extern "C" fn notify_kind_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 b"notify::kind\0".as_ptr() as *const _,
200 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201 notify_kind_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 = "mid")]
211 pub fn connect_mid_notify<F: Fn(&Self) + Send + Sync + 'static>(
212 &self,
213 f: F,
214 ) -> SignalHandlerId {
215 unsafe extern "C" fn notify_mid_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 b"notify::mid\0".as_ptr() as *const _,
230 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
231 notify_mid_trampoline::<F> as *const (),
232 )),
233 Box_::into_raw(f),
234 )
235 }
236 }
237}
238
239unsafe impl Send for WebRTCRTPTransceiver {}
240unsafe impl Sync for WebRTCRTPTransceiver {}