forked from mirrors/gstreamer-rs
Switch everything from lazy_static to once_cell::Lazy
Fewer macros, faster compile-time and the Lazy type will likely end up in the standard library in a similar form to this.
This commit is contained in:
parent
2b5f16391d
commit
7230aee069
19 changed files with 178 additions and 180 deletions
|
@ -30,7 +30,7 @@ pango = { git = "https://github.com/gtk-rs/pango", optional = true }
|
||||||
pangocairo = { git = "https://github.com/gtk-rs/pangocairo", optional = true }
|
pangocairo = { git = "https://github.com/gtk-rs/pangocairo", optional = true }
|
||||||
glutin = { version = "0.21", optional = true }
|
glutin = { version = "0.21", optional = true }
|
||||||
winit = { version = "0.19", optional = true }
|
winit = { version = "0.19", optional = true }
|
||||||
lazy_static = "1.0"
|
once_cell = "1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gl_generator = { version = "0.14", optional = true }
|
gl_generator = { version = "0.14", optional = true }
|
||||||
|
|
|
@ -42,16 +42,16 @@ mod fir_filter {
|
||||||
extern crate byte_slice_cast;
|
extern crate byte_slice_cast;
|
||||||
use byte_slice_cast::*;
|
use byte_slice_cast::*;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
// The debug category we use below for our filter
|
// The debug category we use below for our filter
|
||||||
lazy_static! {
|
pub static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
||||||
pub static ref CAT: gst::DebugCategory = gst::DebugCategory::new(
|
gst::DebugCategory::new(
|
||||||
"rsfirfilter",
|
"rsfirfilter",
|
||||||
gst::DebugColorFlags::empty(),
|
gst::DebugColorFlags::empty(),
|
||||||
Some("Rust FIR Filter"),
|
Some("Rust FIR Filter"),
|
||||||
);
|
)
|
||||||
}
|
});
|
||||||
|
|
||||||
// In the imp submodule we include the actual implementation
|
// In the imp submodule we include the actual implementation
|
||||||
mod imp {
|
mod imp {
|
||||||
|
|
|
@ -17,7 +17,7 @@ build = "build.rs"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
lazy_static = "1.0"
|
once_cell = "1.0"
|
||||||
glib-sys = { git = "https://github.com/gtk-rs/sys" }
|
glib-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||||
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
|
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||||
gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys", features = ["v1_14"] }
|
gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys", features = ["v1_14"] }
|
||||||
|
|
|
@ -10,12 +10,12 @@ use gst::CapsFeatures;
|
||||||
use gst_gl_sys;
|
use gst_gl_sys;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
lazy_static! {
|
use once_cell::sync::Lazy;
|
||||||
pub static ref CAPS_FEATURE_MEMORY_GL_MEMORY: &'static str = unsafe {
|
|
||||||
|
pub static CAPS_FEATURE_MEMORY_GL_MEMORY: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_gl_sys::GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
|
CStr::from_ptr(gst_gl_sys::GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref CAPS_FEATURES_MEMORY_GL_MEMORY: CapsFeatures =
|
pub static CAPS_FEATURES_MEMORY_GL_MEMORY: Lazy<CapsFeatures> =
|
||||||
CapsFeatures::new(&[*CAPS_FEATURE_MEMORY_GL_MEMORY]);
|
Lazy::new(|| CapsFeatures::new(&[*CAPS_FEATURE_MEMORY_GL_MEMORY]));
|
||||||
}
|
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
use gst_gl_sys;
|
use gst_gl_sys;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
lazy_static! {
|
use once_cell::sync::Lazy;
|
||||||
pub static ref GL_DISPLAY_CONTEXT_TYPE: &'static str = unsafe {
|
|
||||||
|
pub static GL_DISPLAY_CONTEXT_TYPE: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_gl_sys::GST_GL_DISPLAY_CONTEXT_TYPE)
|
CStr::from_ptr(gst_gl_sys::GST_GL_DISPLAY_CONTEXT_TYPE)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
extern crate once_cell;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
extern crate glib_sys;
|
extern crate glib_sys;
|
||||||
|
|
|
@ -15,7 +15,7 @@ build = "build.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
lazy_static = "1.0"
|
once_cell = "1.0"
|
||||||
glib-sys = { git = "https://github.com/gtk-rs/sys" }
|
glib-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||||
gio-sys = { git = "https://github.com/gtk-rs/sys" }
|
gio-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||||
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
|
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
extern crate once_cell;
|
||||||
|
|
||||||
extern crate gio;
|
extern crate gio;
|
||||||
extern crate gio_sys as gio_sys;
|
extern crate gio_sys as gio_sys;
|
||||||
|
@ -71,63 +70,63 @@ pub use rtsp_stream_transport::RTSPStreamTransportExtManual;
|
||||||
pub use rtsp_context::*;
|
pub use rtsp_context::*;
|
||||||
pub use rtsp_token::*;
|
pub use rtsp_token::*;
|
||||||
|
|
||||||
lazy_static! {
|
use once_cell::sync::Lazy;
|
||||||
pub static ref RTSP_ADDRESS_POOL_ANY_IPV4: &'static str = unsafe {
|
|
||||||
|
pub static RTSP_ADDRESS_POOL_ANY_IPV4: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_ADDRESS_POOL_ANY_IPV4)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_ADDRESS_POOL_ANY_IPV4)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_ADDRESS_POOL_ANY_IPV6: &'static str = unsafe {
|
pub static RTSP_ADDRESS_POOL_ANY_IPV6: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_ADDRESS_POOL_ANY_IPV6)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_ADDRESS_POOL_ANY_IPV6)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_AUTH_CHECK_CONNECT: &'static str = unsafe {
|
pub static RTSP_AUTH_CHECK_CONNECT: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_CONNECT)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_CONNECT)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS: &'static str = unsafe {
|
pub static RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT: &'static str = unsafe {
|
pub static RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS: &'static str = unsafe {
|
pub static RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_AUTH_CHECK_URL: &'static str = unsafe {
|
pub static RTSP_AUTH_CHECK_URL: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_URL)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_AUTH_CHECK_URL)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_PERM_MEDIA_FACTORY_ACCESS: &'static str = unsafe {
|
pub static RTSP_PERM_MEDIA_FACTORY_ACCESS: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_PERM_MEDIA_FACTORY_ACCESS)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_PERM_MEDIA_FACTORY_ACCESS)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_PERM_MEDIA_FACTORY_CONSTRUCT: &'static str = unsafe {
|
pub static RTSP_PERM_MEDIA_FACTORY_CONSTRUCT: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_TOKEN_MEDIA_FACTORY_ROLE: &'static str = unsafe {
|
pub static RTSP_TOKEN_MEDIA_FACTORY_ROLE: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS: &'static str = unsafe {
|
pub static RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS)
|
CStr::from_ptr(gst_rtsp_server_sys::GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// 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::prelude::*" without getting conflicts
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
|
|
@ -23,7 +23,7 @@ gstreamer-video-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreame
|
||||||
glib = { git = "https://github.com/gtk-rs/glib" }
|
glib = { git = "https://github.com/gtk-rs/glib" }
|
||||||
gstreamer = { path = "../gstreamer" }
|
gstreamer = { path = "../gstreamer" }
|
||||||
gstreamer-base = { path = "../gstreamer-base" }
|
gstreamer-base = { path = "../gstreamer-base" }
|
||||||
lazy_static = "1.0"
|
once_cell = "1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
rustdoc-stripper = { version = "0.1", optional = true }
|
rustdoc-stripper = { version = "0.1", optional = true }
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
extern crate once_cell;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
|
|
|
@ -12,28 +12,30 @@ use std::mem;
|
||||||
|
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
lazy_static! {
|
use once_cell::sync::Lazy;
|
||||||
pub static ref BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META: &'static str = unsafe {
|
|
||||||
|
pub static BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META: Lazy<&'static str> =
|
||||||
|
Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META)
|
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref BUFFER_POOL_OPTION_VIDEO_ALIGNMENT: &'static str = unsafe {
|
pub static BUFFER_POOL_OPTION_VIDEO_ALIGNMENT: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT)
|
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META: &'static str = unsafe {
|
pub static BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META: Lazy<&'static str> =
|
||||||
|
Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META)
|
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref BUFFER_POOL_OPTION_VIDEO_META: &'static str = unsafe {
|
pub static BUFFER_POOL_OPTION_VIDEO_META: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_META)
|
CStr::from_ptr(gst_video_sys::GST_BUFFER_POOL_OPTION_VIDEO_META)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct VideoAlignment(pub(crate) gst_video_sys::GstVideoAlignment);
|
pub struct VideoAlignment(pub(crate) gst_video_sys::GstVideoAlignment);
|
||||||
|
|
|
@ -21,7 +21,7 @@ gobject-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||||
gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys", features = ["v1_8"] }
|
gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys", features = ["v1_8"] }
|
||||||
glib = { git = "https://github.com/gtk-rs/glib" }
|
glib = { git = "https://github.com/gtk-rs/glib" }
|
||||||
num-rational = { version = "0.2", default-features = false, features = [] }
|
num-rational = { version = "0.2", default-features = false, features = [] }
|
||||||
lazy_static = "1.0"
|
once_cell = "1.0"
|
||||||
futures-core = "0.3"
|
futures-core = "0.3"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
futures-channel = "0.3"
|
futures-channel = "0.3"
|
||||||
|
|
|
@ -878,12 +878,10 @@ impl<T> Eq for MappedBuffer<T> {}
|
||||||
unsafe impl<T> Send for MappedBuffer<T> {}
|
unsafe impl<T> Send for MappedBuffer<T> {}
|
||||||
unsafe impl<T> Sync for MappedBuffer<T> {}
|
unsafe impl<T> Sync for MappedBuffer<T> {}
|
||||||
|
|
||||||
lazy_static! {
|
pub const BUFFER_COPY_METADATA: ::BufferCopyFlags =
|
||||||
pub static ref BUFFER_COPY_METADATA: ::BufferCopyFlags =
|
::BufferCopyFlags::from_bits_truncate(gst_sys::GST_BUFFER_COPY_METADATA);
|
||||||
::BufferCopyFlags::FLAGS | ::BufferCopyFlags::TIMESTAMPS | ::BufferCopyFlags::META;
|
pub const BUFFER_COPY_ALL: ::BufferCopyFlags =
|
||||||
pub static ref BUFFER_COPY_ALL: ::BufferCopyFlags =
|
::BufferCopyFlags::from_bits_truncate(gst_sys::GST_BUFFER_COPY_ALL);
|
||||||
*BUFFER_COPY_METADATA | ::BufferCopyFlags::MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
|
@ -15,6 +15,8 @@ use std::ops::{Deref, DerefMut};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{
|
use glib::translate::{
|
||||||
from_glib, from_glib_full, from_glib_none, FromGlibPtrFull, FromGlibPtrNone, GlibPtrDefault,
|
from_glib, from_glib_full, from_glib_none, FromGlibPtrFull, FromGlibPtrNone, GlibPtrDefault,
|
||||||
|
@ -461,15 +463,13 @@ impl ToOwned for CapsFeaturesRef {
|
||||||
unsafe impl Sync for CapsFeaturesRef {}
|
unsafe impl Sync for CapsFeaturesRef {}
|
||||||
unsafe impl Send for CapsFeaturesRef {}
|
unsafe impl Send for CapsFeaturesRef {}
|
||||||
|
|
||||||
lazy_static! {
|
pub static CAPS_FEATURE_MEMORY_SYSTEM_MEMORY: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
pub static ref CAPS_FEATURE_MEMORY_SYSTEM_MEMORY: &'static str = unsafe {
|
|
||||||
CStr::from_ptr(gst_sys::GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY)
|
CStr::from_ptr(gst_sys::GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref CAPS_FEATURES_MEMORY_SYSTEM_MEMORY: CapsFeatures =
|
pub static CAPS_FEATURES_MEMORY_SYSTEM_MEMORY: Lazy<CapsFeatures> =
|
||||||
CapsFeatures::new(&[*CAPS_FEATURE_MEMORY_SYSTEM_MEMORY]);
|
Lazy::new(|| CapsFeatures::new(&[*CAPS_FEATURE_MEMORY_SYSTEM_MEMORY]));
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
use Element;
|
use Element;
|
||||||
use ElementClass;
|
use ElementClass;
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
||||||
use glib::object::Cast;
|
use glib::object::Cast;
|
||||||
|
@ -845,38 +847,36 @@ impl ElementClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
pub static ELEMENT_METADATA_AUTHOR: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
pub static ref ELEMENT_METADATA_AUTHOR: &'static str = unsafe {
|
|
||||||
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_AUTHOR)
|
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_AUTHOR)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref ELEMENT_METADATA_DESCRIPTION: &'static str = unsafe {
|
pub static ELEMENT_METADATA_DESCRIPTION: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_DESCRIPTION)
|
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_DESCRIPTION)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref ELEMENT_METADATA_DOC_URI: &'static str = unsafe {
|
pub static ELEMENT_METADATA_DOC_URI: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_DOC_URI)
|
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_DOC_URI)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref ELEMENT_METADATA_ICON_NAME: &'static str = unsafe {
|
pub static ELEMENT_METADATA_ICON_NAME: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_ICON_NAME)
|
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_ICON_NAME)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref ELEMENT_METADATA_KLASS: &'static str = unsafe {
|
pub static ELEMENT_METADATA_KLASS: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_KLASS)
|
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_KLASS)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
pub static ref ELEMENT_METADATA_LONGNAME: &'static str = unsafe {
|
pub static ELEMENT_METADATA_LONGNAME: Lazy<&'static str> = Lazy::new(|| unsafe {
|
||||||
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_LONGNAME)
|
CStr::from_ptr(gst_sys::GST_ELEMENT_METADATA_LONGNAME)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_element_error(
|
macro_rules! gst_element_error(
|
||||||
|
|
|
@ -12,9 +12,8 @@ extern crate bitflags;
|
||||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate cfg_if;
|
extern crate cfg_if;
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
extern crate once_cell;
|
||||||
extern crate thiserror;
|
extern crate thiserror;
|
||||||
|
|
||||||
// Re-exported for the subclass gst_plugin_define! macro
|
// Re-exported for the subclass gst_plugin_define! macro
|
||||||
|
|
|
@ -14,6 +14,8 @@ use std::ffi::CStr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use gobject_sys;
|
use gobject_sys;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
|
||||||
|
@ -167,20 +169,18 @@ impl fmt::Debug for DebugCategory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
pub static CAT_RUST: Lazy<DebugCategory> = Lazy::new(|| {
|
||||||
pub static ref CAT_RUST: DebugCategory = DebugCategory::new(
|
DebugCategory::new(
|
||||||
"GST_RUST",
|
"GST_RUST",
|
||||||
::DebugColorFlags::UNDERLINE,
|
::DebugColorFlags::UNDERLINE,
|
||||||
Some("GStreamer's Rust binding core"),
|
Some("GStreamer's Rust binding core"),
|
||||||
);
|
)
|
||||||
}
|
});
|
||||||
|
|
||||||
macro_rules! declare_debug_category_from_name(
|
macro_rules! declare_debug_category_from_name(
|
||||||
($cat:ident, $cat_name:expr) => (
|
($cat:ident, $cat_name:expr) => (
|
||||||
lazy_static! {
|
pub static $cat: Lazy<DebugCategory> = Lazy::new(|| DebugCategory::get($cat_name)
|
||||||
pub static ref $cat: DebugCategory = DebugCategory::get($cat_name)
|
.expect(&format!("Unable to find `DebugCategory` with name {}", $cat_name)));
|
||||||
.expect(&format!("Unable to find `DebugCategory` with name {}", $cat_name));
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ use std::fmt;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{
|
use glib::translate::{
|
||||||
from_glib, from_glib_full, FromGlibPtrFull, ToGlib, ToGlibPtr, ToGlibPtrMut,
|
from_glib, from_glib_full, FromGlibPtrFull, ToGlib, ToGlibPtr, ToGlibPtrMut,
|
||||||
|
@ -42,10 +44,8 @@ macro_rules! impl_tag(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
pub(crate) static $rust_tag: Lazy<&'static str> = Lazy::new(||
|
||||||
pub(crate) static ref $rust_tag: &'static str =
|
unsafe { CStr::from_ptr(gst_sys::$gst_tag).to_str().unwrap() });
|
||||||
unsafe { CStr::from_ptr(gst_sys::$gst_tag).to_str().unwrap() };
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ use serde::ser::{Serialize, SerializeTuple, Serializer};
|
||||||
|
|
||||||
use std::{fmt, mem};
|
use std::{fmt, mem};
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use Buffer;
|
use Buffer;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Sample;
|
use Sample;
|
||||||
|
@ -32,20 +34,20 @@ fn get_other_type_id<T: StaticType>() -> usize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
pub(crate) static ARRAY_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Array>);
|
||||||
pub(crate) static ref ARRAY_OTHER_TYPE_ID: usize = get_other_type_id::<Array>();
|
pub(crate) static BITMASK_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Bitmask>);
|
||||||
pub(crate) static ref BITMASK_OTHER_TYPE_ID: usize = get_other_type_id::<Bitmask>();
|
pub(crate) static DATE_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Date>);
|
||||||
pub(crate) static ref DATE_OTHER_TYPE_ID: usize = get_other_type_id::<Date>();
|
pub(crate) static DATE_TIME_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<DateTime>);
|
||||||
pub(crate) static ref DATE_TIME_OTHER_TYPE_ID: usize = get_other_type_id::<DateTime>();
|
pub(crate) static FRACTION_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Fraction>);
|
||||||
pub(crate) static ref FRACTION_OTHER_TYPE_ID: usize = get_other_type_id::<Fraction>();
|
pub(crate) static FRACTION_RANGE_OTHER_TYPE_ID: Lazy<usize> =
|
||||||
pub(crate) static ref FRACTION_RANGE_OTHER_TYPE_ID: usize =
|
Lazy::new(get_other_type_id::<FractionRange>);
|
||||||
get_other_type_id::<FractionRange>();
|
pub(crate) static INT_RANGE_I32_OTHER_TYPE_ID: Lazy<usize> =
|
||||||
pub(crate) static ref INT_RANGE_I32_OTHER_TYPE_ID: usize = get_other_type_id::<IntRange<i32>>();
|
Lazy::new(get_other_type_id::<IntRange<i32>>);
|
||||||
pub(crate) static ref INT_RANGE_I64_OTHER_TYPE_ID: usize = get_other_type_id::<IntRange<i64>>();
|
pub(crate) static INT_RANGE_I64_OTHER_TYPE_ID: Lazy<usize> =
|
||||||
pub(crate) static ref LIST_OTHER_TYPE_ID: usize = get_other_type_id::<List>();
|
Lazy::new(get_other_type_id::<IntRange<i64>>);
|
||||||
pub(crate) static ref SAMPLE_OTHER_TYPE_ID: usize = get_other_type_id::<Sample>();
|
pub(crate) static LIST_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<List>);
|
||||||
pub(crate) static ref BUFFER_OTHER_TYPE_ID: usize = get_other_type_id::<Buffer>();
|
pub(crate) static SAMPLE_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Sample>);
|
||||||
}
|
pub(crate) static BUFFER_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Buffer>);
|
||||||
|
|
||||||
impl<'a> Serialize for Fraction {
|
impl<'a> Serialize for Fraction {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
|
|
Loading…
Reference in a new issue