Skip to main content

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