gstreamer_webrtc/auto/
web_rtcice_transport.rs1#[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 #[doc(alias = "GstWebRTCICETransport")]
20 pub struct WebRTCICETransport(Object<ffi::GstWebRTCICETransport, ffi::GstWebRTCICETransportClass>) @extends gst::Object;
21
22 match fn {
23 type_ => || ffi::gst_webrtc_ice_transport_get_type(),
24 }
25}
26
27impl WebRTCICETransport {
28 #[doc(alias = "gst_webrtc_ice_transport_connection_state_change")]
29 pub fn connection_state_change(&self, new_state: WebRTCICEConnectionState) {
30 unsafe {
31 ffi::gst_webrtc_ice_transport_connection_state_change(
32 self.to_glib_none().0,
33 new_state.into_glib(),
34 );
35 }
36 }
37
38 #[doc(alias = "gst_webrtc_ice_transport_gathering_state_change")]
39 pub fn gathering_state_change(&self, new_state: WebRTCICEGatheringState) {
40 unsafe {
41 ffi::gst_webrtc_ice_transport_gathering_state_change(
42 self.to_glib_none().0,
43 new_state.into_glib(),
44 );
45 }
46 }
47
48 #[cfg(feature = "v1_28")]
49 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
50 #[doc(alias = "gst_webrtc_ice_transport_get_selected_candidate_pair")]
51 #[doc(alias = "get_selected_candidate_pair")]
52 pub fn selected_candidate_pair(&self) -> Option<WebRTCICECandidatePair> {
53 unsafe {
54 from_glib_full(ffi::gst_webrtc_ice_transport_get_selected_candidate_pair(
55 self.to_glib_none().0,
56 ))
57 }
58 }
59
60 #[doc(alias = "gst_webrtc_ice_transport_new_candidate")]
61 pub fn new_candidate(&self, stream_id: u32, component: WebRTCICEComponent, attr: &str) {
62 unsafe {
63 ffi::gst_webrtc_ice_transport_new_candidate(
64 self.to_glib_none().0,
65 stream_id,
66 component.into_glib(),
67 attr.to_glib_none().0,
68 );
69 }
70 }
71
72 #[doc(alias = "gst_webrtc_ice_transport_selected_pair_change")]
73 pub fn selected_pair_change(&self) {
74 unsafe {
75 ffi::gst_webrtc_ice_transport_selected_pair_change(self.to_glib_none().0);
76 }
77 }
78
79 pub fn component(&self) -> WebRTCICEComponent {
80 ObjectExt::property(self, "component")
81 }
82
83 #[doc(alias = "gathering-state")]
84 pub fn gathering_state(&self) -> WebRTCICEGatheringState {
85 ObjectExt::property(self, "gathering-state")
86 }
87
88 pub fn state(&self) -> WebRTCICEConnectionState {
89 ObjectExt::property(self, "state")
90 }
91
92 #[doc(alias = "on-new-candidate")]
93 pub fn connect_on_new_candidate<F: Fn(&Self, &str) + Send + Sync + 'static>(
94 &self,
95 f: F,
96 ) -> SignalHandlerId {
97 unsafe extern "C" fn on_new_candidate_trampoline<
98 F: Fn(&WebRTCICETransport, &str) + Send + Sync + 'static,
99 >(
100 this: *mut ffi::GstWebRTCICETransport,
101 object: *mut std::ffi::c_char,
102 f: glib::ffi::gpointer,
103 ) {
104 unsafe {
105 let f: &F = &*(f as *const F);
106 f(
107 &from_glib_borrow(this),
108 &glib::GString::from_glib_borrow(object),
109 )
110 }
111 }
112 unsafe {
113 let f: Box_<F> = Box_::new(f);
114 connect_raw(
115 self.as_ptr() as *mut _,
116 c"on-new-candidate".as_ptr(),
117 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
118 on_new_candidate_trampoline::<F> as *const (),
119 )),
120 Box_::into_raw(f),
121 )
122 }
123 }
124
125 #[doc(alias = "on-selected-candidate-pair-change")]
126 pub fn connect_on_selected_candidate_pair_change<F: Fn(&Self) + Send + Sync + 'static>(
127 &self,
128 f: F,
129 ) -> SignalHandlerId {
130 unsafe extern "C" fn on_selected_candidate_pair_change_trampoline<
131 F: Fn(&WebRTCICETransport) + Send + Sync + 'static,
132 >(
133 this: *mut ffi::GstWebRTCICETransport,
134 f: glib::ffi::gpointer,
135 ) {
136 unsafe {
137 let f: &F = &*(f as *const F);
138 f(&from_glib_borrow(this))
139 }
140 }
141 unsafe {
142 let f: Box_<F> = Box_::new(f);
143 connect_raw(
144 self.as_ptr() as *mut _,
145 c"on-selected-candidate-pair-change".as_ptr(),
146 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
147 on_selected_candidate_pair_change_trampoline::<F> as *const (),
148 )),
149 Box_::into_raw(f),
150 )
151 }
152 }
153
154 #[doc(alias = "gathering-state")]
155 pub fn connect_gathering_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
156 &self,
157 f: F,
158 ) -> SignalHandlerId {
159 unsafe extern "C" fn notify_gathering_state_trampoline<
160 F: Fn(&WebRTCICETransport) + Send + Sync + 'static,
161 >(
162 this: *mut ffi::GstWebRTCICETransport,
163 _param_spec: glib::ffi::gpointer,
164 f: glib::ffi::gpointer,
165 ) {
166 unsafe {
167 let f: &F = &*(f as *const F);
168 f(&from_glib_borrow(this))
169 }
170 }
171 unsafe {
172 let f: Box_<F> = Box_::new(f);
173 connect_raw(
174 self.as_ptr() as *mut _,
175 c"notify::gathering-state".as_ptr(),
176 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
177 notify_gathering_state_trampoline::<F> as *const (),
178 )),
179 Box_::into_raw(f),
180 )
181 }
182 }
183
184 #[doc(alias = "state")]
185 pub fn connect_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
186 &self,
187 f: F,
188 ) -> SignalHandlerId {
189 unsafe extern "C" fn notify_state_trampoline<
190 F: Fn(&WebRTCICETransport) + Send + Sync + 'static,
191 >(
192 this: *mut ffi::GstWebRTCICETransport,
193 _param_spec: glib::ffi::gpointer,
194 f: glib::ffi::gpointer,
195 ) {
196 unsafe {
197 let f: &F = &*(f as *const F);
198 f(&from_glib_borrow(this))
199 }
200 }
201 unsafe {
202 let f: Box_<F> = Box_::new(f);
203 connect_raw(
204 self.as_ptr() as *mut _,
205 c"notify::state".as_ptr(),
206 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
207 notify_state_trampoline::<F> as *const (),
208 )),
209 Box_::into_raw(f),
210 )
211 }
212 }
213}
214
215unsafe impl Send for WebRTCICETransport {}
216unsafe impl Sync for WebRTCICETransport {}