mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 19:41:09 +00:00
webrtc: Work around WebRTCICE::add_candidate()
API breakage in 1.24
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1245>
This commit is contained in:
parent
87a70b16ba
commit
64bc1f7625
2 changed files with 52 additions and 0 deletions
|
@ -22,10 +22,16 @@ pub use crate::auto::*;
|
||||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||||
mod web_rtc_ice_candidate_stats;
|
mod web_rtc_ice_candidate_stats;
|
||||||
mod web_rtc_session_description;
|
mod web_rtc_session_description;
|
||||||
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||||
|
mod web_rtcice;
|
||||||
|
|
||||||
// Re-export all the traits in a prelude module, so that applications
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
// can always "use gst_webrtc::prelude::*" without getting conflicts
|
// can always "use gst_webrtc::prelude::*" without getting conflicts
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||||
|
pub use crate::web_rtcice::WebRTCICEExtManual;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use gst_sdp::prelude::*;
|
pub use gst_sdp::prelude::*;
|
||||||
}
|
}
|
||||||
|
|
46
gstreamer-webrtc/src/web_rtcice.rs
Normal file
46
gstreamer-webrtc/src/web_rtcice.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||||
|
|
||||||
|
use glib::{prelude::*, translate::*};
|
||||||
|
|
||||||
|
use crate::{WebRTCICE, WebRTCICEStream};
|
||||||
|
|
||||||
|
pub trait WebRTCICEExtManual: 'static {
|
||||||
|
#[doc(alias = "gst_webrtc_ice_add_candidate")]
|
||||||
|
fn add_candidate(&self, stream: &impl IsA<WebRTCICEStream>, candidate: &str);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<O: IsA<WebRTCICE>> WebRTCICEExtManual for O {
|
||||||
|
fn add_candidate(&self, stream: &impl IsA<WebRTCICEStream>, candidate: &str) {
|
||||||
|
unsafe {
|
||||||
|
use std::{mem, ptr};
|
||||||
|
|
||||||
|
if gst::version() >= (1, 23, 0, 0) {
|
||||||
|
let func = mem::transmute::<
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
*mut ffi::GstWebRTCICE,
|
||||||
|
*mut ffi::GstWebRTCICEStream,
|
||||||
|
*const std::os::raw::c_char,
|
||||||
|
),
|
||||||
|
unsafe extern "C" fn(
|
||||||
|
*mut ffi::GstWebRTCICE,
|
||||||
|
*mut ffi::GstWebRTCICEStream,
|
||||||
|
*const std::os::raw::c_char,
|
||||||
|
*mut gst::ffi::GstPromise,
|
||||||
|
),
|
||||||
|
>(ffi::gst_webrtc_ice_add_candidate);
|
||||||
|
func(
|
||||||
|
self.as_ref().to_glib_none().0,
|
||||||
|
stream.as_ref().to_glib_none().0,
|
||||||
|
candidate.to_glib_none().0,
|
||||||
|
ptr::null_mut(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ffi::gst_webrtc_ice_add_candidate(
|
||||||
|
self.as_ref().to_glib_none().0,
|
||||||
|
stream.as_ref().to_glib_none().0,
|
||||||
|
candidate.to_glib_none().0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue