forked from mirrors/gstreamer-rs
Compile out GStreamer version checks if a high enough version is configured at build time
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1184>
This commit is contained in:
parent
277d63601c
commit
89326c7e7c
4 changed files with 101 additions and 61 deletions
|
@ -277,13 +277,17 @@ impl AppSink {
|
|||
|
||||
#[doc(alias = "gst_app_sink_set_callbacks")]
|
||||
pub fn set_callbacks(&self, callbacks: AppSinkCallbacks) {
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
use once_cell::sync::Lazy;
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
||||
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-app-sink-callbacks"));
|
||||
|
||||
unsafe {
|
||||
let sink = self.to_glib_none().0;
|
||||
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
{
|
||||
// This is not thread-safe before 1.16.3, see
|
||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||
if gst::version() < (1, 16, 3, 0) {
|
||||
|
@ -302,6 +306,7 @@ impl AppSink {
|
|||
1 as *mut _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ffi::gst_app_sink_set_callbacks(
|
||||
sink,
|
||||
|
@ -1166,6 +1171,8 @@ impl AppSinkStream {
|
|||
|
||||
impl Drop for AppSinkStream {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
{
|
||||
// This is not thread-safe before 1.16.3, see
|
||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||
if gst::version() >= (1, 16, 3, 0) {
|
||||
|
@ -1174,6 +1181,7 @@ impl Drop for AppSinkStream {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Stream for AppSinkStream {
|
||||
|
|
|
@ -222,16 +222,23 @@ impl AppSrc {
|
|||
|
||||
#[doc(alias = "gst_app_src_set_callbacks")]
|
||||
pub fn set_callbacks(&self, callbacks: AppSrcCallbacks) {
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
use once_cell::sync::Lazy;
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
||||
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-app-src-callbacks"));
|
||||
|
||||
unsafe {
|
||||
let src = self.to_glib_none().0;
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
{
|
||||
// This is not thread-safe before 1.16.3, see
|
||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||
if gst::version() < (1, 16, 3, 0) {
|
||||
if !glib::gobject_ffi::g_object_get_qdata(src as *mut _, SET_ONCE_QUARK.into_glib())
|
||||
if !glib::gobject_ffi::g_object_get_qdata(
|
||||
src as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
panic!("AppSrc callbacks can only be set once");
|
||||
|
@ -243,6 +250,7 @@ impl AppSrc {
|
|||
1 as *mut _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ffi::gst_app_src_set_callbacks(
|
||||
src,
|
||||
|
@ -600,6 +608,8 @@ impl AppSrcSink {
|
|||
|
||||
impl Drop for AppSrcSink {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
{
|
||||
// This is not thread-safe before 1.16.3, see
|
||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||
if gst::version() >= (1, 16, 3, 0) {
|
||||
|
@ -608,6 +618,7 @@ impl Drop for AppSrcSink {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Sink<gst::Sample> for AppSrcSink {
|
||||
|
|
|
@ -9,6 +9,8 @@ impl Allocator {
|
|||
pub fn register(name: &str, allocator: impl IsA<Allocator>) {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
#[cfg(not(feature = "v1_22"))]
|
||||
{
|
||||
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364
|
||||
if crate::version() < (1, 20, 5, 0) {
|
||||
ffi::gst_allocator_register(
|
||||
|
@ -22,5 +24,13 @@ impl Allocator {
|
|||
);
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "v1_22")]
|
||||
{
|
||||
ffi::gst_allocator_register(
|
||||
name.to_glib_none().0,
|
||||
allocator.upcast().into_glib_ptr(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,17 +189,24 @@ impl Bus {
|
|||
where
|
||||
F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static,
|
||||
{
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
use once_cell::sync::Lazy;
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
||||
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-sync-handler"));
|
||||
|
||||
unsafe {
|
||||
let bus = self.to_glib_none().0;
|
||||
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
{
|
||||
// This is not thread-safe before 1.16.3, see
|
||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416
|
||||
if crate::version() < (1, 16, 3, 0) {
|
||||
if !glib::gobject_ffi::g_object_get_qdata(bus as *mut _, SET_ONCE_QUARK.into_glib())
|
||||
if !glib::gobject_ffi::g_object_get_qdata(
|
||||
bus as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
panic!("Bus sync handler can only be set once");
|
||||
|
@ -211,6 +218,7 @@ impl Bus {
|
|||
1 as *mut _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ffi::gst_bus_set_sync_handler(
|
||||
bus,
|
||||
|
@ -222,11 +230,14 @@ impl Bus {
|
|||
}
|
||||
|
||||
pub fn unset_sync_handler(&self) {
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
{
|
||||
// This is not thread-safe before 1.16.3, see
|
||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416
|
||||
if crate::version() < (1, 16, 3, 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use std::ptr;
|
||||
|
|
Loading…
Reference in a new issue