gstreamer_webrtc/
web_rtcice.rs
1use glib::{prelude::*, translate::*};
4
5use crate::{ffi, WebRTCICE, WebRTCICEStream};
6
7mod sealed {
8 pub trait Sealed {}
9 impl<T: super::IsA<super::WebRTCICE>> Sealed for T {}
10}
11
12pub trait WebRTCICEExtManual: sealed::Sealed + IsA<WebRTCICE> + 'static {
13 #[doc(alias = "gst_webrtc_ice_add_candidate")]
20 fn add_candidate(&self, stream: &impl IsA<WebRTCICEStream>, candidate: &str) {
21 #[cfg(not(feature = "v1_24"))]
22 unsafe {
23 use std::{mem, ptr};
24
25 if gst::version() < (1, 23, 0, 0) {
26 let func = mem::transmute::<
27 unsafe extern "C" fn(
28 *mut ffi::GstWebRTCICE,
29 *mut ffi::GstWebRTCICEStream,
30 *const std::os::raw::c_char,
31 *mut gst::ffi::GstPromise,
32 ),
33 unsafe extern "C" fn(
34 *mut ffi::GstWebRTCICE,
35 *mut ffi::GstWebRTCICEStream,
36 *const std::os::raw::c_char,
37 ),
38 >(ffi::gst_webrtc_ice_add_candidate);
39 func(
40 self.as_ref().to_glib_none().0,
41 stream.as_ref().to_glib_none().0,
42 candidate.to_glib_none().0,
43 );
44 } else {
45 ffi::gst_webrtc_ice_add_candidate(
46 self.as_ref().to_glib_none().0,
47 stream.as_ref().to_glib_none().0,
48 candidate.to_glib_none().0,
49 ptr::null_mut(),
50 );
51 }
52 }
53 #[cfg(feature = "v1_24")]
54 {
55 self.add_candidate_full(stream, candidate, None);
56 }
57 }
58
59 #[cfg(feature = "v1_24")]
60 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
61 #[doc(alias = "gst_webrtc_ice_add_candidate")]
62 fn add_candidate_full(
63 &self,
64 stream: &impl IsA<WebRTCICEStream>,
65 candidate: &str,
66 promise: Option<&gst::Promise>,
67 ) {
68 unsafe {
69 ffi::gst_webrtc_ice_add_candidate(
70 self.as_ref().to_glib_none().0,
71 stream.as_ref().to_glib_none().0,
72 candidate.to_glib_none().0,
73 promise.to_glib_none().0,
74 );
75 }
76 }
77}
78
79impl<O: IsA<WebRTCICE>> WebRTCICEExtManual for O {}