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