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