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