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