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,30 +277,35 @@ 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;
|
||||
|
||||
// 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(
|
||||
sink as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
panic!("AppSink callbacks can only be set once");
|
||||
}
|
||||
#[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(
|
||||
sink as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
panic!("AppSink callbacks can only be set once");
|
||||
}
|
||||
|
||||
glib::gobject_ffi::g_object_set_qdata(
|
||||
sink as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
1 as *mut _,
|
||||
);
|
||||
glib::gobject_ffi::g_object_set_qdata(
|
||||
sink as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
1 as *mut _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ffi::gst_app_sink_set_callbacks(
|
||||
|
@ -1166,11 +1171,14 @@ impl AppSinkStream {
|
|||
|
||||
impl Drop for AppSinkStream {
|
||||
fn drop(&mut self) {
|
||||
// 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 let Some(app_sink) = self.app_sink.upgrade() {
|
||||
app_sink.set_callbacks(AppSinkCallbacks::builder().build());
|
||||
#[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 let Some(app_sink) = self.app_sink.upgrade() {
|
||||
app_sink.set_callbacks(AppSinkCallbacks::builder().build());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,26 +222,34 @@ 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;
|
||||
// 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())
|
||||
#[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(),
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
panic!("AppSrc callbacks can only be set once");
|
||||
}
|
||||
{
|
||||
panic!("AppSrc callbacks can only be set once");
|
||||
}
|
||||
|
||||
glib::gobject_ffi::g_object_set_qdata(
|
||||
src as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
1 as *mut _,
|
||||
);
|
||||
glib::gobject_ffi::g_object_set_qdata(
|
||||
src as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
1 as *mut _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ffi::gst_app_src_set_callbacks(
|
||||
|
@ -600,11 +608,14 @@ impl AppSrcSink {
|
|||
|
||||
impl Drop for AppSrcSink {
|
||||
fn drop(&mut self) {
|
||||
// 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 let Some(app_src) = self.app_src.upgrade() {
|
||||
app_src.set_callbacks(AppSrcCallbacks::builder().build());
|
||||
#[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 let Some(app_src) = self.app_src.upgrade() {
|
||||
app_src.set_callbacks(AppSrcCallbacks::builder().build());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,23 @@ impl Allocator {
|
|||
pub fn register(name: &str, allocator: impl IsA<Allocator>) {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364
|
||||
if crate::version() < (1, 20, 5, 0) {
|
||||
ffi::gst_allocator_register(
|
||||
name.to_glib_full(),
|
||||
allocator.upcast().into_glib_ptr(),
|
||||
);
|
||||
} else {
|
||||
#[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(
|
||||
name.to_glib_full(),
|
||||
allocator.upcast().into_glib_ptr(),
|
||||
);
|
||||
} else {
|
||||
ffi::gst_allocator_register(
|
||||
name.to_glib_none().0,
|
||||
allocator.upcast().into_glib_ptr(),
|
||||
);
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "v1_22")]
|
||||
{
|
||||
ffi::gst_allocator_register(
|
||||
name.to_glib_none().0,
|
||||
allocator.upcast().into_glib_ptr(),
|
||||
|
|
|
@ -189,27 +189,35 @@ 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;
|
||||
|
||||
// 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())
|
||||
#[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(),
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
panic!("Bus sync handler can only be set once");
|
||||
}
|
||||
{
|
||||
panic!("Bus sync handler can only be set once");
|
||||
}
|
||||
|
||||
glib::gobject_ffi::g_object_set_qdata(
|
||||
bus as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
1 as *mut _,
|
||||
);
|
||||
glib::gobject_ffi::g_object_set_qdata(
|
||||
bus as *mut _,
|
||||
SET_ONCE_QUARK.into_glib(),
|
||||
1 as *mut _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ffi::gst_bus_set_sync_handler(
|
||||
|
@ -222,10 +230,13 @@ impl Bus {
|
|||
}
|
||||
|
||||
pub fn unset_sync_handler(&self) {
|
||||
// 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;
|
||||
#[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 {
|
||||
|
|
Loading…
Reference in a new issue