mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-02-13 01:25:30 +00:00
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")]
|
#[doc(alias = "gst_app_sink_set_callbacks")]
|
||||||
pub fn set_callbacks(&self, callbacks: AppSinkCallbacks) {
|
pub fn set_callbacks(&self, callbacks: AppSinkCallbacks) {
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
||||||
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-app-sink-callbacks"));
|
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-app-sink-callbacks"));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let sink = self.to_glib_none().0;
|
let sink = self.to_glib_none().0;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
|
{
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||||
if gst::version() < (1, 16, 3, 0) {
|
if gst::version() < (1, 16, 3, 0) {
|
||||||
|
@ -302,6 +306,7 @@ impl AppSink {
|
||||||
1 as *mut _,
|
1 as *mut _,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ffi::gst_app_sink_set_callbacks(
|
ffi::gst_app_sink_set_callbacks(
|
||||||
sink,
|
sink,
|
||||||
|
@ -1166,6 +1171,8 @@ impl AppSinkStream {
|
||||||
|
|
||||||
impl Drop for AppSinkStream {
|
impl Drop for AppSinkStream {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
|
{
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||||
if gst::version() >= (1, 16, 3, 0) {
|
if gst::version() >= (1, 16, 3, 0) {
|
||||||
|
@ -1175,6 +1182,7 @@ impl Drop for AppSinkStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Stream for AppSinkStream {
|
impl Stream for AppSinkStream {
|
||||||
type Item = gst::Sample;
|
type Item = gst::Sample;
|
||||||
|
|
|
@ -222,16 +222,23 @@ impl AppSrc {
|
||||||
|
|
||||||
#[doc(alias = "gst_app_src_set_callbacks")]
|
#[doc(alias = "gst_app_src_set_callbacks")]
|
||||||
pub fn set_callbacks(&self, callbacks: AppSrcCallbacks) {
|
pub fn set_callbacks(&self, callbacks: AppSrcCallbacks) {
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
||||||
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-app-src-callbacks"));
|
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-app-src-callbacks"));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let src = self.to_glib_none().0;
|
let src = self.to_glib_none().0;
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
|
{
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||||
if gst::version() < (1, 16, 3, 0) {
|
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()
|
.is_null()
|
||||||
{
|
{
|
||||||
panic!("AppSrc callbacks can only be set once");
|
panic!("AppSrc callbacks can only be set once");
|
||||||
|
@ -243,6 +250,7 @@ impl AppSrc {
|
||||||
1 as *mut _,
|
1 as *mut _,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ffi::gst_app_src_set_callbacks(
|
ffi::gst_app_src_set_callbacks(
|
||||||
src,
|
src,
|
||||||
|
@ -600,6 +608,8 @@ impl AppSrcSink {
|
||||||
|
|
||||||
impl Drop for AppSrcSink {
|
impl Drop for AppSrcSink {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
|
{
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||||
if gst::version() >= (1, 16, 3, 0) {
|
if gst::version() >= (1, 16, 3, 0) {
|
||||||
|
@ -609,6 +619,7 @@ impl Drop for AppSrcSink {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Sink<gst::Sample> for AppSrcSink {
|
impl Sink<gst::Sample> for AppSrcSink {
|
||||||
type Error = gst::FlowError;
|
type Error = gst::FlowError;
|
||||||
|
|
|
@ -9,6 +9,8 @@ impl Allocator {
|
||||||
pub fn register(name: &str, allocator: impl IsA<Allocator>) {
|
pub fn register(name: &str, allocator: impl IsA<Allocator>) {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
#[cfg(not(feature = "v1_22"))]
|
||||||
|
{
|
||||||
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364
|
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364
|
||||||
if crate::version() < (1, 20, 5, 0) {
|
if crate::version() < (1, 20, 5, 0) {
|
||||||
ffi::gst_allocator_register(
|
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
|
where
|
||||||
F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static,
|
F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
static SET_ONCE_QUARK: Lazy<glib::Quark> =
|
||||||
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-sync-handler"));
|
Lazy::new(|| glib::Quark::from_str("gstreamer-rs-sync-handler"));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let bus = self.to_glib_none().0;
|
let bus = self.to_glib_none().0;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
|
{
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416
|
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416
|
||||||
if crate::version() < (1, 16, 3, 0) {
|
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()
|
.is_null()
|
||||||
{
|
{
|
||||||
panic!("Bus sync handler can only be set once");
|
panic!("Bus sync handler can only be set once");
|
||||||
|
@ -211,6 +218,7 @@ impl Bus {
|
||||||
1 as *mut _,
|
1 as *mut _,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ffi::gst_bus_set_sync_handler(
|
ffi::gst_bus_set_sync_handler(
|
||||||
bus,
|
bus,
|
||||||
|
@ -222,11 +230,14 @@ impl Bus {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unset_sync_handler(&self) {
|
pub fn unset_sync_handler(&self) {
|
||||||
|
#[cfg(not(feature = "v1_18"))]
|
||||||
|
{
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416
|
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/416
|
||||||
if crate::version() < (1, 16, 3, 0) {
|
if crate::version() < (1, 16, 3, 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
Loading…
Reference in a new issue