gstreamer_webrtc/auto/
web_rtcice.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
6use crate::{
7    ffi, WebRTCICECandidateStats, WebRTCICEComponent, WebRTCICEStream, WebRTCICETransport,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    ///
19    ///
20    /// This is an Abstract Base Class, you cannot instantiate it.
21    ///
22    /// ## Properties
23    ///
24    ///
25    /// #### `max-rtp-port`
26    ///  Maximum port for local rtp port range.
27    /// min-rtp-port must be <= max-rtp-port
28    ///
29    /// Readable | Writeable | Construct
30    ///
31    ///
32    /// #### `min-rtp-port`
33    ///  Minimum port for local rtp port range.
34    /// min-rtp-port must be <= max-rtp-port
35    ///
36    /// Readable | Writeable | Construct
37    /// <details><summary><h4>Object</h4></summary>
38    ///
39    ///
40    /// #### `name`
41    ///  Readable | Writeable | Construct
42    ///
43    ///
44    /// #### `parent`
45    ///  The parent of the object. Please note, that when changing the 'parent'
46    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and `GstObject::deep-notify`
47    /// signals due to locking issues. In some cases one can use
48    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
49    /// achieve a similar effect.
50    ///
51    /// Readable | Writeable
52    /// </details>
53    ///
54    /// ## Signals
55    ///
56    ///
57    /// #### `add-local-ip-address`
58    ///  Add a local IP address to use for ICE candidate gathering. If none
59    /// are supplied, they will be discovered automatically. Calling this signal
60    /// stops automatic ICE gathering.
61    ///
62    /// Action
63    /// <details><summary><h4>Object</h4></summary>
64    ///
65    ///
66    /// #### `deep-notify`
67    ///  The deep notify signal is used to be notified of property changes. It is
68    /// typically attached to the toplevel bin to receive notifications from all
69    /// the elements contained in that bin.
70    ///
71    /// Detailed
72    /// </details>
73    ///
74    /// # Implements
75    ///
76    /// [`WebRTCICEExt`][trait@crate::prelude::WebRTCICEExt], [`trait@glib::ObjectExt`]
77    #[doc(alias = "GstWebRTCICE")]
78    pub struct WebRTCICE(Object<ffi::GstWebRTCICE, ffi::GstWebRTCICEClass>);
79
80    match fn {
81        type_ => || ffi::gst_webrtc_ice_get_type(),
82    }
83}
84
85impl WebRTCICE {
86    pub const NONE: Option<&'static WebRTCICE> = None;
87}
88
89unsafe impl Send for WebRTCICE {}
90unsafe impl Sync for WebRTCICE {}
91
92/// Trait containing all [`struct@WebRTCICE`] methods.
93///
94/// # Implementors
95///
96/// [`WebRTCICE`][struct@crate::WebRTCICE]
97pub trait WebRTCICEExt: IsA<WebRTCICE> + 'static {
98    /// ## `session_id`
99    /// The session id
100    ///
101    /// # Returns
102    ///
103    /// The [`WebRTCICEStream`][crate::WebRTCICEStream], or [`None`]
104    #[doc(alias = "gst_webrtc_ice_add_stream")]
105    fn add_stream(&self, session_id: u32) -> Option<WebRTCICEStream> {
106        unsafe {
107            from_glib_full(ffi::gst_webrtc_ice_add_stream(
108                self.as_ref().to_glib_none().0,
109                session_id,
110            ))
111        }
112    }
113
114    /// ## `uri`
115    /// URI of the TURN server
116    ///
117    /// # Returns
118    ///
119    /// FALSE on error, TRUE otherwise
120    #[doc(alias = "gst_webrtc_ice_add_turn_server")]
121    fn add_turn_server(&self, uri: &str) -> bool {
122        unsafe {
123            from_glib(ffi::gst_webrtc_ice_add_turn_server(
124                self.as_ref().to_glib_none().0,
125                uri.to_glib_none().0,
126            ))
127        }
128    }
129
130    /// ## `stream`
131    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
132    /// ## `component`
133    /// The [`WebRTCICEComponent`][crate::WebRTCICEComponent]
134    ///
135    /// # Returns
136    ///
137    /// The [`WebRTCICETransport`][crate::WebRTCICETransport], or [`None`]
138    #[doc(alias = "gst_webrtc_ice_find_transport")]
139    fn find_transport(
140        &self,
141        stream: &impl IsA<WebRTCICEStream>,
142        component: WebRTCICEComponent,
143    ) -> Option<WebRTCICETransport> {
144        unsafe {
145            from_glib_full(ffi::gst_webrtc_ice_find_transport(
146                self.as_ref().to_glib_none().0,
147                stream.as_ref().to_glib_none().0,
148                component.into_glib(),
149            ))
150        }
151    }
152
153    /// ## `stream`
154    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
155    ///
156    /// # Returns
157    ///
158    /// FALSE on error, TRUE otherwise
159    #[doc(alias = "gst_webrtc_ice_gather_candidates")]
160    fn gather_candidates(&self, stream: &impl IsA<WebRTCICEStream>) -> bool {
161        unsafe {
162            from_glib(ffi::gst_webrtc_ice_gather_candidates(
163                self.as_ref().to_glib_none().0,
164                stream.as_ref().to_glib_none().0,
165            ))
166        }
167    }
168
169    ///
170    /// # Returns
171    ///
172    /// URI of the HTTP proxy of the form
173    ///  http://[username:password@]hostname[:port][?alpn=`<alpn>`]
174    ///
175    /// Get HTTP Proxy to be used when connecting to TURN server.
176    #[doc(alias = "gst_webrtc_ice_get_http_proxy")]
177    #[doc(alias = "get_http_proxy")]
178    fn http_proxy(&self) -> glib::GString {
179        unsafe {
180            from_glib_full(ffi::gst_webrtc_ice_get_http_proxy(
181                self.as_ref().to_glib_none().0,
182            ))
183        }
184    }
185
186    ///
187    /// # Returns
188    ///
189    /// TRUE if set as controller, FALSE otherwise
190    #[doc(alias = "gst_webrtc_ice_get_is_controller")]
191    #[doc(alias = "get_is_controller")]
192    fn is_controller(&self) -> bool {
193        unsafe {
194            from_glib(ffi::gst_webrtc_ice_get_is_controller(
195                self.as_ref().to_glib_none().0,
196            ))
197        }
198    }
199
200    /// ## `stream`
201    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
202    ///
203    /// # Returns
204    ///
205    /// List of local candidates
206    #[doc(alias = "gst_webrtc_ice_get_local_candidates")]
207    #[doc(alias = "get_local_candidates")]
208    fn local_candidates(&self, stream: &impl IsA<WebRTCICEStream>) -> Vec<WebRTCICECandidateStats> {
209        unsafe {
210            FromGlibPtrContainer::from_glib_full(ffi::gst_webrtc_ice_get_local_candidates(
211                self.as_ref().to_glib_none().0,
212                stream.as_ref().to_glib_none().0,
213            ))
214        }
215    }
216
217    /// ## `stream`
218    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
219    ///
220    /// # Returns
221    ///
222    /// List of remote candidates
223    #[doc(alias = "gst_webrtc_ice_get_remote_candidates")]
224    #[doc(alias = "get_remote_candidates")]
225    fn remote_candidates(
226        &self,
227        stream: &impl IsA<WebRTCICEStream>,
228    ) -> Vec<WebRTCICECandidateStats> {
229        unsafe {
230            FromGlibPtrContainer::from_glib_full(ffi::gst_webrtc_ice_get_remote_candidates(
231                self.as_ref().to_glib_none().0,
232                stream.as_ref().to_glib_none().0,
233            ))
234        }
235    }
236
237    /// ## `stream`
238    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
239    ///
240    /// # Returns
241    ///
242    /// FALSE on failure, otherwise `local_stats` `remote_stats` will be set
243    ///
244    /// ## `local_stats`
245    /// A pointer to [`WebRTCICECandidateStats`][crate::WebRTCICECandidateStats] for local candidate
246    ///
247    /// ## `remote_stats`
248    /// pointer to [`WebRTCICECandidateStats`][crate::WebRTCICECandidateStats] for remote candidate
249    #[doc(alias = "gst_webrtc_ice_get_selected_pair")]
250    #[doc(alias = "get_selected_pair")]
251    fn selected_pair(
252        &self,
253        stream: &impl IsA<WebRTCICEStream>,
254    ) -> Option<(WebRTCICECandidateStats, WebRTCICECandidateStats)> {
255        unsafe {
256            let mut local_stats = std::ptr::null_mut();
257            let mut remote_stats = std::ptr::null_mut();
258            let ret = from_glib(ffi::gst_webrtc_ice_get_selected_pair(
259                self.as_ref().to_glib_none().0,
260                stream.as_ref().to_glib_none().0,
261                &mut local_stats,
262                &mut remote_stats,
263            ));
264            if ret {
265                Some((from_glib_full(local_stats), from_glib_full(remote_stats)))
266            } else {
267                None
268            }
269        }
270    }
271
272    ///
273    /// # Returns
274    ///
275    /// URI of the STUN sever
276    #[doc(alias = "gst_webrtc_ice_get_stun_server")]
277    #[doc(alias = "get_stun_server")]
278    fn stun_server(&self) -> Option<glib::GString> {
279        unsafe {
280            from_glib_full(ffi::gst_webrtc_ice_get_stun_server(
281                self.as_ref().to_glib_none().0,
282            ))
283        }
284    }
285
286    ///
287    /// # Returns
288    ///
289    /// URI of the TURN sever
290    #[doc(alias = "gst_webrtc_ice_get_turn_server")]
291    #[doc(alias = "get_turn_server")]
292    fn turn_server(&self) -> Option<glib::GString> {
293        unsafe {
294            from_glib_full(ffi::gst_webrtc_ice_get_turn_server(
295                self.as_ref().to_glib_none().0,
296            ))
297        }
298    }
299
300    /// ## `force_relay`
301    /// TRUE to enable force relay
302    #[doc(alias = "gst_webrtc_ice_set_force_relay")]
303    fn set_force_relay(&self, force_relay: bool) {
304        unsafe {
305            ffi::gst_webrtc_ice_set_force_relay(
306                self.as_ref().to_glib_none().0,
307                force_relay.into_glib(),
308            );
309        }
310    }
311
312    /// Set HTTP Proxy to be used when connecting to TURN server.
313    /// ## `uri`
314    /// URI of the HTTP proxy of the form
315    ///  http://[username:password@]hostname[:port][?alpn=`<alpn>`]
316    #[doc(alias = "gst_webrtc_ice_set_http_proxy")]
317    fn set_http_proxy(&self, uri: &str) {
318        unsafe {
319            ffi::gst_webrtc_ice_set_http_proxy(
320                self.as_ref().to_glib_none().0,
321                uri.to_glib_none().0,
322            );
323        }
324    }
325
326    /// ## `controller`
327    /// TRUE to set as controller
328    #[doc(alias = "gst_webrtc_ice_set_is_controller")]
329    fn set_is_controller(&self, controller: bool) {
330        unsafe {
331            ffi::gst_webrtc_ice_set_is_controller(
332                self.as_ref().to_glib_none().0,
333                controller.into_glib(),
334            );
335        }
336    }
337
338    /// ## `stream`
339    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
340    /// ## `ufrag`
341    /// ICE username
342    /// ## `pwd`
343    /// ICE password
344    ///
345    /// # Returns
346    ///
347    /// FALSE on error, TRUE otherwise
348    #[doc(alias = "gst_webrtc_ice_set_local_credentials")]
349    fn set_local_credentials(
350        &self,
351        stream: &impl IsA<WebRTCICEStream>,
352        ufrag: &str,
353        pwd: &str,
354    ) -> bool {
355        unsafe {
356            from_glib(ffi::gst_webrtc_ice_set_local_credentials(
357                self.as_ref().to_glib_none().0,
358                stream.as_ref().to_glib_none().0,
359                ufrag.to_glib_none().0,
360                pwd.to_glib_none().0,
361            ))
362        }
363    }
364
365    /// ## `func`
366    /// The `GstWebRTCICEOnCandidateFunc` callback function
367    /// ## `notify`
368    /// a `GDestroyNotify` when the candidate is no longer needed
369    #[doc(alias = "gst_webrtc_ice_set_on_ice_candidate")]
370    fn set_on_ice_candidate<P: Fn(&WebRTCICE, u32, &str) + Send + Sync + 'static>(&self, func: P) {
371        let func_data: Box_<P> = Box_::new(func);
372        unsafe extern "C" fn func_func<P: Fn(&WebRTCICE, u32, &str) + Send + Sync + 'static>(
373            ice: *mut ffi::GstWebRTCICE,
374            stream_id: std::ffi::c_uint,
375            candidate: *const std::ffi::c_char,
376            user_data: glib::ffi::gpointer,
377        ) {
378            let ice = from_glib_borrow(ice);
379            let candidate: Borrowed<glib::GString> = from_glib_borrow(candidate);
380            let callback = &*(user_data as *mut P);
381            (*callback)(&ice, stream_id, candidate.as_str())
382        }
383        let func = Some(func_func::<P> as _);
384        unsafe extern "C" fn notify_func<P: Fn(&WebRTCICE, u32, &str) + Send + Sync + 'static>(
385            data: glib::ffi::gpointer,
386        ) {
387            let _callback = Box_::from_raw(data as *mut P);
388        }
389        let destroy_call3 = Some(notify_func::<P> as _);
390        let super_callback0: Box_<P> = func_data;
391        unsafe {
392            ffi::gst_webrtc_ice_set_on_ice_candidate(
393                self.as_ref().to_glib_none().0,
394                func,
395                Box_::into_raw(super_callback0) as *mut _,
396                destroy_call3,
397            );
398        }
399    }
400
401    /// ## `stream`
402    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
403    /// ## `ufrag`
404    /// ICE username
405    /// ## `pwd`
406    /// ICE password
407    ///
408    /// # Returns
409    ///
410    /// FALSE on error, TRUE otherwise
411    #[doc(alias = "gst_webrtc_ice_set_remote_credentials")]
412    fn set_remote_credentials(
413        &self,
414        stream: &impl IsA<WebRTCICEStream>,
415        ufrag: &str,
416        pwd: &str,
417    ) -> bool {
418        unsafe {
419            from_glib(ffi::gst_webrtc_ice_set_remote_credentials(
420                self.as_ref().to_glib_none().0,
421                stream.as_ref().to_glib_none().0,
422                ufrag.to_glib_none().0,
423                pwd.to_glib_none().0,
424            ))
425        }
426    }
427
428    /// ## `uri`
429    /// URI of the STUN server
430    #[doc(alias = "gst_webrtc_ice_set_stun_server")]
431    fn set_stun_server(&self, uri: Option<&str>) {
432        unsafe {
433            ffi::gst_webrtc_ice_set_stun_server(
434                self.as_ref().to_glib_none().0,
435                uri.to_glib_none().0,
436            );
437        }
438    }
439
440    /// ## `stream`
441    /// The [`WebRTCICEStream`][crate::WebRTCICEStream]
442    /// ## `tos`
443    /// ToS to be set
444    #[doc(alias = "gst_webrtc_ice_set_tos")]
445    fn set_tos(&self, stream: &impl IsA<WebRTCICEStream>, tos: u32) {
446        unsafe {
447            ffi::gst_webrtc_ice_set_tos(
448                self.as_ref().to_glib_none().0,
449                stream.as_ref().to_glib_none().0,
450                tos,
451            );
452        }
453    }
454
455    /// ## `uri`
456    /// URI of the TURN sever
457    #[doc(alias = "gst_webrtc_ice_set_turn_server")]
458    fn set_turn_server(&self, uri: Option<&str>) {
459        unsafe {
460            ffi::gst_webrtc_ice_set_turn_server(
461                self.as_ref().to_glib_none().0,
462                uri.to_glib_none().0,
463            );
464        }
465    }
466
467    /// Maximum port for local rtp port range.
468    /// min-rtp-port must be <= max-rtp-port
469    #[cfg(feature = "v1_20")]
470    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
471    #[doc(alias = "max-rtp-port")]
472    fn max_rtp_port(&self) -> u32 {
473        ObjectExt::property(self.as_ref(), "max-rtp-port")
474    }
475
476    /// Maximum port for local rtp port range.
477    /// min-rtp-port must be <= max-rtp-port
478    #[cfg(feature = "v1_20")]
479    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
480    #[doc(alias = "max-rtp-port")]
481    fn set_max_rtp_port(&self, max_rtp_port: u32) {
482        ObjectExt::set_property(self.as_ref(), "max-rtp-port", max_rtp_port)
483    }
484
485    /// Minimum port for local rtp port range.
486    /// min-rtp-port must be <= max-rtp-port
487    #[cfg(feature = "v1_20")]
488    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
489    #[doc(alias = "min-rtp-port")]
490    fn min_rtp_port(&self) -> u32 {
491        ObjectExt::property(self.as_ref(), "min-rtp-port")
492    }
493
494    /// Minimum port for local rtp port range.
495    /// min-rtp-port must be <= max-rtp-port
496    #[cfg(feature = "v1_20")]
497    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
498    #[doc(alias = "min-rtp-port")]
499    fn set_min_rtp_port(&self, min_rtp_port: u32) {
500        ObjectExt::set_property(self.as_ref(), "min-rtp-port", min_rtp_port)
501    }
502
503    /// Add a local IP address to use for ICE candidate gathering. If none
504    /// are supplied, they will be discovered automatically. Calling this signal
505    /// stops automatic ICE gathering.
506    /// ## `address`
507    /// The local IP address
508    ///
509    /// # Returns
510    ///
511    /// whether the address could be added.
512    #[doc(alias = "add-local-ip-address")]
513    fn connect_add_local_ip_address<F: Fn(&Self, &str) -> bool + Send + Sync + 'static>(
514        &self,
515        f: F,
516    ) -> SignalHandlerId {
517        unsafe extern "C" fn add_local_ip_address_trampoline<
518            P: IsA<WebRTCICE>,
519            F: Fn(&P, &str) -> bool + Send + Sync + 'static,
520        >(
521            this: *mut ffi::GstWebRTCICE,
522            address: *mut std::ffi::c_char,
523            f: glib::ffi::gpointer,
524        ) -> glib::ffi::gboolean {
525            let f: &F = &*(f as *const F);
526            f(
527                WebRTCICE::from_glib_borrow(this).unsafe_cast_ref(),
528                &glib::GString::from_glib_borrow(address),
529            )
530            .into_glib()
531        }
532        unsafe {
533            let f: Box_<F> = Box_::new(f);
534            connect_raw(
535                self.as_ptr() as *mut _,
536                c"add-local-ip-address".as_ptr() as *const _,
537                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
538                    add_local_ip_address_trampoline::<Self, F> as *const (),
539                )),
540                Box_::into_raw(f),
541            )
542        }
543    }
544
545    fn emit_add_local_ip_address(&self, address: &str) -> bool {
546        self.emit_by_name("add-local-ip-address", &[&address])
547    }
548
549    #[cfg(feature = "v1_20")]
550    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
551    #[doc(alias = "max-rtp-port")]
552    fn connect_max_rtp_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
553        &self,
554        f: F,
555    ) -> SignalHandlerId {
556        unsafe extern "C" fn notify_max_rtp_port_trampoline<
557            P: IsA<WebRTCICE>,
558            F: Fn(&P) + Send + Sync + 'static,
559        >(
560            this: *mut ffi::GstWebRTCICE,
561            _param_spec: glib::ffi::gpointer,
562            f: glib::ffi::gpointer,
563        ) {
564            let f: &F = &*(f as *const F);
565            f(WebRTCICE::from_glib_borrow(this).unsafe_cast_ref())
566        }
567        unsafe {
568            let f: Box_<F> = Box_::new(f);
569            connect_raw(
570                self.as_ptr() as *mut _,
571                c"notify::max-rtp-port".as_ptr() as *const _,
572                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
573                    notify_max_rtp_port_trampoline::<Self, F> as *const (),
574                )),
575                Box_::into_raw(f),
576            )
577        }
578    }
579
580    #[cfg(feature = "v1_20")]
581    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
582    #[doc(alias = "min-rtp-port")]
583    fn connect_min_rtp_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
584        &self,
585        f: F,
586    ) -> SignalHandlerId {
587        unsafe extern "C" fn notify_min_rtp_port_trampoline<
588            P: IsA<WebRTCICE>,
589            F: Fn(&P) + Send + Sync + 'static,
590        >(
591            this: *mut ffi::GstWebRTCICE,
592            _param_spec: glib::ffi::gpointer,
593            f: glib::ffi::gpointer,
594        ) {
595            let f: &F = &*(f as *const F);
596            f(WebRTCICE::from_glib_borrow(this).unsafe_cast_ref())
597        }
598        unsafe {
599            let f: Box_<F> = Box_::new(f);
600            connect_raw(
601                self.as_ptr() as *mut _,
602                c"notify::min-rtp-port".as_ptr() as *const _,
603                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
604                    notify_min_rtp_port_trampoline::<Self, F> as *const (),
605                )),
606                Box_::into_raw(f),
607            )
608        }
609    }
610}
611
612impl<O: IsA<WebRTCICE>> WebRTCICEExt for O {}