Skip to main content

gstreamer_webrtc/auto/
web_rtcice_transport.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_28")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
8use crate::WebRTCICECandidatePair;
9use crate::{WebRTCICEComponent, WebRTCICEConnectionState, WebRTCICEGatheringState, ffi};
10use glib::{
11    object::ObjectType as _,
12    prelude::*,
13    signal::{SignalHandlerId, connect_raw},
14    translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    ///
20    ///
21    /// This is an Abstract Base Class, you cannot instantiate it.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `component`
27    ///  Readable | Writeable | Construct Only
28    ///
29    ///
30    /// #### `gathering-state`
31    ///  Readable
32    ///
33    ///
34    /// #### `state`
35    ///  Readable
36    /// <details><summary><h4>Object</h4></summary>
37    ///
38    ///
39    /// #### `name`
40    ///  Readable | Writeable | Construct
41    ///
42    ///
43    /// #### `parent`
44    ///  The parent of the object. Please note, that when changing the 'parent'
45    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
46    /// signals due to locking issues. In some cases one can use
47    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
48    /// achieve a similar effect.
49    ///
50    /// Readable | Writeable
51    /// </details>
52    ///
53    /// ## Signals
54    ///
55    ///
56    /// #### `on-new-candidate`
57    ///
58    ///
59    ///
60    /// #### `on-selected-candidate-pair-change`
61    ///
62    /// <details><summary><h4>Object</h4></summary>
63    ///
64    ///
65    /// #### `deep-notify`
66    ///  The deep notify signal is used to be notified of property changes. It is
67    /// typically attached to the toplevel bin to receive notifications from all
68    /// the elements contained in that bin.
69    ///
70    /// Detailed
71    /// </details>
72    ///
73    /// # Implements
74    ///
75    /// [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
76    #[doc(alias = "GstWebRTCICETransport")]
77    pub struct WebRTCICETransport(Object<ffi::GstWebRTCICETransport, ffi::GstWebRTCICETransportClass>) @extends gst::Object;
78
79    match fn {
80        type_ => || ffi::gst_webrtc_ice_transport_get_type(),
81    }
82}
83
84impl WebRTCICETransport {
85    #[doc(alias = "gst_webrtc_ice_transport_connection_state_change")]
86    pub fn connection_state_change(&self, new_state: WebRTCICEConnectionState) {
87        unsafe {
88            ffi::gst_webrtc_ice_transport_connection_state_change(
89                self.to_glib_none().0,
90                new_state.into_glib(),
91            );
92        }
93    }
94
95    #[doc(alias = "gst_webrtc_ice_transport_gathering_state_change")]
96    pub fn gathering_state_change(&self, new_state: WebRTCICEGatheringState) {
97        unsafe {
98            ffi::gst_webrtc_ice_transport_gathering_state_change(
99                self.to_glib_none().0,
100                new_state.into_glib(),
101            );
102        }
103    }
104
105    /// See also
106    /// https://w3c.github.io/webrtc-pc/`dom`-rtcicetransport-getselectedcandidatepair
107    ///
108    /// # Returns
109    ///
110    /// A [`WebRTCICECandidatePair`][crate::WebRTCICECandidatePair]
111    #[cfg(feature = "v1_28")]
112    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
113    #[doc(alias = "gst_webrtc_ice_transport_get_selected_candidate_pair")]
114    #[doc(alias = "get_selected_candidate_pair")]
115    pub fn selected_candidate_pair(&self) -> Option<WebRTCICECandidatePair> {
116        unsafe {
117            from_glib_full(ffi::gst_webrtc_ice_transport_get_selected_candidate_pair(
118                self.to_glib_none().0,
119            ))
120        }
121    }
122
123    #[doc(alias = "gst_webrtc_ice_transport_new_candidate")]
124    pub fn new_candidate(&self, stream_id: u32, component: WebRTCICEComponent, attr: &str) {
125        unsafe {
126            ffi::gst_webrtc_ice_transport_new_candidate(
127                self.to_glib_none().0,
128                stream_id,
129                component.into_glib(),
130                attr.to_glib_none().0,
131            );
132        }
133    }
134
135    #[doc(alias = "gst_webrtc_ice_transport_selected_pair_change")]
136    pub fn selected_pair_change(&self) {
137        unsafe {
138            ffi::gst_webrtc_ice_transport_selected_pair_change(self.to_glib_none().0);
139        }
140    }
141
142    pub fn component(&self) -> WebRTCICEComponent {
143        ObjectExt::property(self, "component")
144    }
145
146    #[doc(alias = "gathering-state")]
147    pub fn gathering_state(&self) -> WebRTCICEGatheringState {
148        ObjectExt::property(self, "gathering-state")
149    }
150
151    pub fn state(&self) -> WebRTCICEConnectionState {
152        ObjectExt::property(self, "state")
153    }
154
155    #[doc(alias = "on-new-candidate")]
156    pub fn connect_on_new_candidate<F: Fn(&Self, &str) + Send + Sync + 'static>(
157        &self,
158        f: F,
159    ) -> SignalHandlerId {
160        unsafe extern "C" fn on_new_candidate_trampoline<
161            F: Fn(&WebRTCICETransport, &str) + Send + Sync + 'static,
162        >(
163            this: *mut ffi::GstWebRTCICETransport,
164            object: *mut std::ffi::c_char,
165            f: glib::ffi::gpointer,
166        ) {
167            unsafe {
168                let f: &F = &*(f as *const F);
169                f(
170                    &from_glib_borrow(this),
171                    &glib::GString::from_glib_borrow(object),
172                )
173            }
174        }
175        unsafe {
176            let f: Box_<F> = Box_::new(f);
177            connect_raw(
178                self.as_ptr() as *mut _,
179                c"on-new-candidate".as_ptr(),
180                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
181                    on_new_candidate_trampoline::<F> as *const (),
182                )),
183                Box_::into_raw(f),
184            )
185        }
186    }
187
188    #[doc(alias = "on-selected-candidate-pair-change")]
189    pub fn connect_on_selected_candidate_pair_change<F: Fn(&Self) + Send + Sync + 'static>(
190        &self,
191        f: F,
192    ) -> SignalHandlerId {
193        unsafe extern "C" fn on_selected_candidate_pair_change_trampoline<
194            F: Fn(&WebRTCICETransport) + Send + Sync + 'static,
195        >(
196            this: *mut ffi::GstWebRTCICETransport,
197            f: glib::ffi::gpointer,
198        ) {
199            unsafe {
200                let f: &F = &*(f as *const F);
201                f(&from_glib_borrow(this))
202            }
203        }
204        unsafe {
205            let f: Box_<F> = Box_::new(f);
206            connect_raw(
207                self.as_ptr() as *mut _,
208                c"on-selected-candidate-pair-change".as_ptr(),
209                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210                    on_selected_candidate_pair_change_trampoline::<F> as *const (),
211                )),
212                Box_::into_raw(f),
213            )
214        }
215    }
216
217    #[doc(alias = "gathering-state")]
218    pub fn connect_gathering_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
219        &self,
220        f: F,
221    ) -> SignalHandlerId {
222        unsafe extern "C" fn notify_gathering_state_trampoline<
223            F: Fn(&WebRTCICETransport) + Send + Sync + 'static,
224        >(
225            this: *mut ffi::GstWebRTCICETransport,
226            _param_spec: glib::ffi::gpointer,
227            f: glib::ffi::gpointer,
228        ) {
229            unsafe {
230                let f: &F = &*(f as *const F);
231                f(&from_glib_borrow(this))
232            }
233        }
234        unsafe {
235            let f: Box_<F> = Box_::new(f);
236            connect_raw(
237                self.as_ptr() as *mut _,
238                c"notify::gathering-state".as_ptr(),
239                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
240                    notify_gathering_state_trampoline::<F> as *const (),
241                )),
242                Box_::into_raw(f),
243            )
244        }
245    }
246
247    #[doc(alias = "state")]
248    pub fn connect_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
249        &self,
250        f: F,
251    ) -> SignalHandlerId {
252        unsafe extern "C" fn notify_state_trampoline<
253            F: Fn(&WebRTCICETransport) + Send + Sync + 'static,
254        >(
255            this: *mut ffi::GstWebRTCICETransport,
256            _param_spec: glib::ffi::gpointer,
257            f: glib::ffi::gpointer,
258        ) {
259            unsafe {
260                let f: &F = &*(f as *const F);
261                f(&from_glib_borrow(this))
262            }
263        }
264        unsafe {
265            let f: Box_<F> = Box_::new(f);
266            connect_raw(
267                self.as_ptr() as *mut _,
268                c"notify::state".as_ptr(),
269                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
270                    notify_state_trampoline::<F> as *const (),
271                )),
272                Box_::into_raw(f),
273            )
274        }
275    }
276}
277
278unsafe impl Send for WebRTCICETransport {}
279unsafe impl Sync for WebRTCICETransport {}