diff options
Diffstat (limited to 'generic/threadshare')
-rw-r--r-- | generic/threadshare/Cargo.toml | 11 | ||||
-rw-r--r-- | generic/threadshare/src/appsrc/imp.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/dataqueue.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/inputselector/imp.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/jitterbuffer/ffi.rs | 8 | ||||
-rw-r--r-- | generic/threadshare/src/jitterbuffer/imp.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/jitterbuffer/jitterbuffer.rs | 23 | ||||
-rw-r--r-- | generic/threadshare/src/lib.rs | 12 | ||||
-rw-r--r-- | generic/threadshare/src/proxy/imp.rs | 32 | ||||
-rw-r--r-- | generic/threadshare/src/queue/imp.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/runtime/executor.rs | 7 | ||||
-rw-r--r-- | generic/threadshare/src/runtime/mod.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/socket.rs | 22 | ||||
-rw-r--r-- | generic/threadshare/src/tcpclientsrc/imp.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/udpsink/imp.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/src/udpsrc/imp.rs | 10 | ||||
-rw-r--r-- | generic/threadshare/tests/jitterbuffer.rs | 12 | ||||
-rw-r--r-- | generic/threadshare/tests/pad.rs | 18 | ||||
-rw-r--r-- | generic/threadshare/tests/pipeline.rs | 10 |
19 files changed, 115 insertions, 130 deletions
diff --git a/generic/threadshare/Cargo.toml b/generic/threadshare/Cargo.toml index 531225689..14ebe5102 100644 --- a/generic/threadshare/Cargo.toml +++ b/generic/threadshare/Cargo.toml @@ -9,22 +9,15 @@ edition = "2018" [dependencies] libc = "0.2" -glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" } -gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" } -gio-sys = { git = "https://github.com/gtk-rs/gtk-rs" } glib = { git = "https://github.com/gtk-rs/gtk-rs" } gio = { git = "https://github.com/gtk-rs/gtk-rs" } gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features=["v1_10"] } -gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } -gst-check = { package = "gstreamer-check", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } gst-net = { package = "gstreamer-net", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } gst-rtp = { package = "gstreamer-rtp", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } -gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } pin-project = "1" once_cell = "1" tokio = { git = "https://github.com/fengalin/tokio", tag = "tokio-0.2.13-throttling", features = ["io-util", "macros", "rt-core", "sync", "stream", "time", "tcp", "udp", "rt-util"] } futures = { version = "0.3", features = ["thread-pool"] } -lazy_static = "1.0" rand = "0.7" socket2 = "0.3" @@ -34,6 +27,10 @@ winapi = { version = "0.3", features = ["winsock2", "processthreadsapi"] } [target.'cfg(unix)'.dependencies] socket2 = { version = "0.3", features = ["reuseport"] } +[dev-dependencies] +gst-check = { package = "gstreamer-check", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } +gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" } + [lib] name = "gstthreadshare" crate-type = ["cdylib", "rlib", "staticlib"] diff --git a/generic/threadshare/src/appsrc/imp.rs b/generic/threadshare/src/appsrc/imp.rs index 9ab686dae..73c9276f5 100644 --- a/generic/threadshare/src/appsrc/imp.rs +++ b/generic/threadshare/src/appsrc/imp.rs @@ -30,7 +30,7 @@ use gst::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_log, gst_trace}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::convert::TryInto; use std::sync::Arc; @@ -119,13 +119,13 @@ static PROPERTIES: [subclass::Property; 5] = [ }), ]; -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-appsrc", gst::DebugColorFlags::empty(), Some("Thread-sharing app source"), - ); -} + ) +}); #[derive(Debug)] enum StreamItem { diff --git a/generic/threadshare/src/dataqueue.rs b/generic/threadshare/src/dataqueue.rs index 9d206061a..4f4fc6a0a 100644 --- a/generic/threadshare/src/dataqueue.rs +++ b/generic/threadshare/src/dataqueue.rs @@ -20,20 +20,20 @@ use futures::future::{self, abortable, AbortHandle}; use gst::gst_debug; use gst::prelude::*; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::collections::VecDeque; use std::sync::Arc; use std::sync::Mutex as StdMutex; use std::{u32, u64}; -lazy_static! { - static ref DATA_QUEUE_CAT: gst::DebugCategory = gst::DebugCategory::new( +static DATA_QUEUE_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-dataqueue", gst::DebugColorFlags::empty(), Some("Thread-sharing queue"), - ); -} + ) +}); #[derive(Debug)] pub enum DataQueueItem { diff --git a/generic/threadshare/src/inputselector/imp.rs b/generic/threadshare/src/inputselector/imp.rs index b7c6c8c33..fe861b84e 100644 --- a/generic/threadshare/src/inputselector/imp.rs +++ b/generic/threadshare/src/inputselector/imp.rs @@ -28,7 +28,7 @@ use gst::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_log, gst_trace}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::collections::HashMap; use std::sync::{Arc, Mutex}; @@ -407,13 +407,13 @@ pub struct InputSelector { pads: Mutex<Pads>, } -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-input-selector", gst::DebugColorFlags::empty(), Some("Thread-sharing input selector"), - ); -} + ) +}); impl InputSelector { fn unprepare(&self, element: &super::InputSelector) -> Result<(), ()> { diff --git a/generic/threadshare/src/jitterbuffer/ffi.rs b/generic/threadshare/src/jitterbuffer/ffi.rs index 46424fa14..cc1eb41d2 100644 --- a/generic/threadshare/src/jitterbuffer/ffi.rs +++ b/generic/threadshare/src/jitterbuffer/ffi.rs @@ -15,11 +15,9 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib_ffi::{gboolean, gpointer, GList, GType}; -use glib_sys as glib_ffi; +use glib::ffi::{gboolean, gpointer, GList, GType}; -use gst_ffi::GstClockTime; -use gstreamer_sys as gst_ffi; +use gst::ffi::GstClockTime; use libc::{c_int, c_uint, c_ulonglong, c_ushort, c_void}; #[repr(C)] @@ -70,7 +68,7 @@ extern "C" { pub fn rtp_jitter_buffer_get_clock_rate(jbuf: *mut RTPJitterBuffer) -> c_uint; pub fn rtp_jitter_buffer_reset_skew(jbuf: *mut RTPJitterBuffer); - pub fn rtp_jitter_buffer_flush(jbuf: *mut RTPJitterBuffer, free_func: glib_ffi::GFunc); + pub fn rtp_jitter_buffer_flush(jbuf: *mut RTPJitterBuffer, free_func: glib::ffi::GFunc); pub fn rtp_jitter_buffer_find_earliest( jbuf: *mut RTPJitterBuffer, pts: *mut GstClockTime, diff --git a/generic/threadshare/src/jitterbuffer/imp.rs b/generic/threadshare/src/jitterbuffer/imp.rs index b92aa66fe..e9dbdd6ec 100644 --- a/generic/threadshare/src/jitterbuffer/imp.rs +++ b/generic/threadshare/src/jitterbuffer/imp.rs @@ -29,7 +29,7 @@ use gst::subclass::prelude::*; use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_info, gst_log, gst_trace}; use gst_rtp::RTPBuffer; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::cmp::{max, min, Ordering}; use std::collections::{BTreeSet, VecDeque}; @@ -1347,13 +1347,13 @@ pub struct JitterBuffer { settings: StdMutex<Settings>, } -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-jitterbuffer", gst::DebugColorFlags::empty(), Some("Thread-sharing jitterbuffer"), - ); -} + ) +}); impl JitterBuffer { fn clear_pt_map(&self, element: &super::JitterBuffer) { diff --git a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs index 5984db98f..d240e3e24 100644 --- a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs +++ b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs @@ -19,9 +19,6 @@ use super::ffi; use std::ptr; -use glib_sys as glib_ffi; -use gstreamer_sys as gst_ffi; - use glib::glib_wrapper; use glib::prelude::*; use glib::translate::*; @@ -81,7 +78,7 @@ impl RTPJitterBufferItem { rtptime: u32, ) -> RTPJitterBufferItem { unsafe { - let ptr = ptr::NonNull::new(glib_sys::g_slice_alloc0(mem::size_of::< + let ptr = ptr::NonNull::new(glib::ffi::g_slice_alloc0(mem::size_of::< ffi::RTPJitterBufferItem, >()) as *mut ffi::RTPJitterBufferItem) .expect("Allocation failed"); @@ -107,8 +104,8 @@ impl RTPJitterBufferItem { pub fn into_buffer(mut self) -> gst::Buffer { unsafe { let item = self.0.take().expect("Invalid wrapper"); - let buf = item.as_ref().data as *mut gst_ffi::GstBuffer; - glib_sys::g_slice_free1( + let buf = item.as_ref().data as *mut gst::ffi::GstBuffer; + glib::ffi::g_slice_free1( mem::size_of::<ffi::RTPJitterBufferItem>(), item.as_ptr() as *mut _, ); @@ -119,7 +116,7 @@ impl RTPJitterBufferItem { pub fn get_dts(&self) -> gst::ClockTime { unsafe { let item = self.0.as_ref().expect("Invalid wrapper"); - if item.as_ref().dts == gst_ffi::GST_CLOCK_TIME_NONE { + if item.as_ref().dts == gst::ffi::GST_CLOCK_TIME_NONE { gst::CLOCK_TIME_NONE } else { gst::ClockTime(Some(item.as_ref().dts)) @@ -130,7 +127,7 @@ impl RTPJitterBufferItem { pub fn get_pts(&self) -> gst::ClockTime { unsafe { let item = self.0.as_ref().expect("Invalid wrapper"); - if item.as_ref().pts == gst_ffi::GST_CLOCK_TIME_NONE { + if item.as_ref().pts == gst::ffi::GST_CLOCK_TIME_NONE { gst::CLOCK_TIME_NONE } else { gst::ClockTime(Some(item.as_ref().pts)) @@ -163,10 +160,10 @@ impl Drop for RTPJitterBufferItem { unsafe { if let Some(ref item) = self.0 { if !item.as_ref().data.is_null() { - gst_ffi::gst_mini_object_unref(item.as_ref().data as *mut _); + gst::ffi::gst_mini_object_unref(item.as_ref().data as *mut _); } - glib_sys::g_slice_free1( + glib::ffi::g_slice_free1( mem::size_of::<ffi::RTPJitterBufferItem>(), item.as_ptr() as *mut _, ); @@ -274,7 +271,7 @@ impl RTPJitterBuffer { is_rtx.to_glib(), ); - if pts == gst_ffi::GST_CLOCK_TIME_NONE { + if pts == gst::ffi::GST_CLOCK_TIME_NONE { gst::CLOCK_TIME_NONE } else { pts.into() @@ -319,7 +316,7 @@ impl RTPJitterBuffer { Some(seqnum as u16) }; - if pts == gst_ffi::GST_CLOCK_TIME_NONE { + if pts == gst::ffi::GST_CLOCK_TIME_NONE { (gst::CLOCK_TIME_NONE, seqnum) } else { (pts.into(), seqnum) @@ -361,7 +358,7 @@ impl RTPJitterBuffer { } pub fn flush(&self) { - unsafe extern "C" fn free_item(item: glib_ffi::gpointer, _: glib_ffi::gpointer) { + unsafe extern "C" fn free_item(item: glib::ffi::gpointer, _: glib::ffi::gpointer) { let _ = RTPJitterBufferItem(Some(ptr::NonNull::new(item as *mut _).expect("NULL item"))); } diff --git a/generic/threadshare/src/lib.rs b/generic/threadshare/src/lib.rs index 1264cbf56..438d36c2e 100644 --- a/generic/threadshare/src/lib.rs +++ b/generic/threadshare/src/lib.rs @@ -41,10 +41,8 @@ mod proxy; mod queue; use glib::translate::*; -use glib_sys as glib_ffi; use gst::gst_plugin_define; -use gstreamer_sys as gst_ffi; fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { udpsrc::register(plugin)?; @@ -76,19 +74,19 @@ pub fn set_element_flags<T: glib::IsA<gst::Object> + glib::IsA<gst::Element>>( flags: gst::ElementFlags, ) { unsafe { - let ptr: *mut gst_ffi::GstObject = element.as_ptr() as *mut _; + let ptr: *mut gst::ffi::GstObject = element.as_ptr() as *mut _; let _guard = MutexGuard::lock(&(*ptr).lock); (*ptr).flags |= flags.to_glib(); } } #[must_use = "if unused the Mutex will immediately unlock"] -struct MutexGuard<'a>(&'a glib_ffi::GMutex); +struct MutexGuard<'a>(&'a glib::ffi::GMutex); impl<'a> MutexGuard<'a> { - pub fn lock(mutex: &'a glib_ffi::GMutex) -> Self { + pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self { unsafe { - glib_ffi::g_mutex_lock(mut_override(mutex)); + glib::ffi::g_mutex_lock(mut_override(mutex)); } MutexGuard(mutex) } @@ -97,7 +95,7 @@ impl<'a> MutexGuard<'a> { impl<'a> Drop for MutexGuard<'a> { fn drop(&mut self) { unsafe { - glib_ffi::g_mutex_unlock(mut_override(self.0)); + glib::ffi::g_mutex_unlock(mut_override(self.0)); } } } diff --git a/generic/threadshare/src/proxy/imp.rs b/generic/threadshare/src/proxy/imp.rs index d4b22aca9..84062b6c3 100644 --- a/generic/threadshare/src/proxy/imp.rs +++ b/generic/threadshare/src/proxy/imp.rs @@ -28,7 +28,7 @@ use gst::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_log, gst_trace}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::collections::{HashMap, VecDeque}; use std::sync::Mutex as StdMutex; @@ -43,14 +43,12 @@ use crate::runtime::{ use crate::dataqueue::{DataQueue, DataQueueItem}; -lazy_static! { - static ref PROXY_CONTEXTS: StdMutex<HashMap<String, Weak<StdMutex<ProxyContextInner>>>> = - StdMutex::new(HashMap::new()); - static ref PROXY_SRC_PADS: StdMutex<HashMap<String, PadSrcWeak>> = - StdMutex::new(HashMap::new()); - static ref PROXY_SINK_PADS: StdMutex<HashMap<String, PadSinkWeak>> = - StdMutex::new(HashMap::new()); -} +static PROXY_CONTEXTS: Lazy<StdMutex<HashMap<String, Weak<StdMutex<ProxyContextInner>>>>> = + Lazy::new(|| StdMutex::new(HashMap::new())); +static PROXY_SRC_PADS: Lazy<StdMutex<HashMap<String, PadSrcWeak>>> = + Lazy::new(|| StdMutex::new(HashMap::new())); +static PROXY_SINK_PADS: Lazy<StdMutex<HashMap<String, PadSinkWeak>>> = + Lazy::new(|| StdMutex::new(HashMap::new())); const DEFAULT_PROXY_CONTEXT: &str = ""; @@ -412,13 +410,13 @@ pub struct ProxySink { settings: StdMutex<SettingsSink>, } -lazy_static! { - static ref SINK_CAT: gst::DebugCategory = gst::DebugCategory::new( +static SINK_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-proxysink", gst::DebugColorFlags::empty(), Some("Thread-sharing proxy sink"), - ); -} + ) +}); impl ProxySink { async fn schedule_pending_queue(&self, element: &super::ProxySink) { @@ -1051,13 +1049,13 @@ pub struct ProxySrc { settings: StdMutex<SettingsSrc>, } -lazy_static! { - static ref SRC_CAT: gst::DebugCategory = gst::DebugCategory::new( +static SRC_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-proxysrc", gst::DebugColorFlags::empty(), Some("Thread-sharing proxy source"), - ); -} + ) +}); impl ProxySrc { fn prepare(&self, element: &super::ProxySrc) -> Result<(), gst::ErrorMessage> { diff --git a/generic/threadshare/src/queue/imp.rs b/generic/threadshare/src/queue/imp.rs index fb9ee8f22..9d53b7a59 100644 --- a/generic/threadshare/src/queue/imp.rs +++ b/generic/threadshare/src/queue/imp.rs @@ -28,7 +28,7 @@ use gst::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_log, gst_trace}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::collections::VecDeque; use std::sync::Mutex as StdMutex; @@ -513,13 +513,13 @@ pub struct Queue { settings: StdMutex<Settings>, } -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-queue", gst::DebugColorFlags::empty(), Some("Thread-sharing queue"), - ); -} + ) +}); impl Queue { /* Try transfering all the items from the pending queue to the DataQueue, then diff --git a/generic/threadshare/src/runtime/executor.rs b/generic/threadshare/src/runtime/executor.rs index b8c2e01f6..fe3552904 100644 --- a/generic/threadshare/src/runtime/executor.rs +++ b/generic/threadshare/src/runtime/executor.rs @@ -40,7 +40,7 @@ use futures::prelude::*; use gst::{gst_debug, gst_log, gst_trace, gst_warning}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::cell::RefCell; use std::collections::{HashMap, VecDeque}; @@ -66,9 +66,8 @@ use super::RUNTIME_CAT; // // Also, we want to be able to `acquire` a `Context` outside of an `async` context. // These `Mutex`es must be `lock`ed for a short period. -lazy_static! { - static ref CONTEXTS: Mutex<HashMap<String, Weak<ContextInner>>> = Mutex::new(HashMap::new()); -} +static CONTEXTS: Lazy<Mutex<HashMap<String, Weak<ContextInner>>>> = + Lazy::new(|| Mutex::new(HashMap::new())); thread_local!(static CURRENT_THREAD_CONTEXT: RefCell<Option<ContextWeak>> = RefCell::new(None)); diff --git a/generic/threadshare/src/runtime/mod.rs b/generic/threadshare/src/runtime/mod.rs index 80f01d8d2..d22fe802c 100644 --- a/generic/threadshare/src/runtime/mod.rs +++ b/generic/threadshare/src/runtime/mod.rs @@ -59,12 +59,12 @@ pub mod prelude { pub mod time; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; -lazy_static! { - static ref RUNTIME_CAT: gst::DebugCategory = gst::DebugCategory::new( +static RUNTIME_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-runtime", gst::DebugColorFlags::empty(), Some("Thread-sharing Runtime"), - ); -} + ) +}); diff --git a/generic/threadshare/src/socket.rs b/generic/threadshare/src/socket.rs index dca8dc982..a2ada2999 100644 --- a/generic/threadshare/src/socket.rs +++ b/generic/threadshare/src/socket.rs @@ -21,13 +21,11 @@ use futures::future::BoxFuture; use gst::prelude::*; use gst::{gst_debug, gst_error, gst_error_msg, gst_log}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::io; use gio::prelude::*; -use gio_sys as gio_ffi; -use gobject_sys as gobject_ffi; use std::error; use std::fmt; @@ -38,13 +36,13 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}; -lazy_static! { - static ref SOCKET_CAT: gst::DebugCategory = gst::DebugCategory::new( +static SOCKET_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-socket", gst::DebugColorFlags::empty(), Some("Thread-sharing Socket"), - ); -} + ) +}); pub trait SocketRead: Send + Unpin { const DO_TIMESTAMP: bool; @@ -193,7 +191,7 @@ impl<T: SocketRead> Drop for Socket<T> { // fd is safe though, as is receiving/sending from two different threads #[derive(Debug)] pub struct GioSocketWrapper { - socket: *mut gio_ffi::GSocket, + socket: *mut gio::ffi::GSocket, } unsafe impl Send for GioSocketWrapper {} @@ -240,14 +238,14 @@ impl GioSocketWrapper { #[cfg(unix)] pub fn get<T: FromRawFd>(&self) -> T { - unsafe { FromRawFd::from_raw_fd(libc::dup(gio_ffi::g_socket_get_fd(self.socket))) } + unsafe { FromRawFd::from_raw_fd(libc::dup(gio::ffi::g_socket_get_fd(self.socket))) } } #[cfg(windows)] pub fn get<T: FromRawSocket>(&self) -> T { unsafe { FromRawSocket::from_raw_socket( - dup_socket(gio_ffi::g_socket_get_fd(self.socket) as _) as _ + dup_socket(gio::ffi::g_socket_get_fd(self.socket) as _) as _ ) } } @@ -256,7 +254,7 @@ impl GioSocketWrapper { impl Clone for GioSocketWrapper { fn clone(&self) -> Self { Self { - socket: unsafe { gobject_ffi::g_object_ref(self.socket as *mut _) as *mut _ }, + socket: unsafe { glib::gobject_ffi::g_object_ref(self.socket as *mut _) as *mut _ }, } } } @@ -264,7 +262,7 @@ impl Clone for GioSocketWrapper { impl Drop for GioSocketWrapper { fn drop(&mut self) { unsafe { - gobject_ffi::g_object_unref(self.socket as *mut _); + glib::gobject_ffi::g_object_unref(self.socket as *mut _); } } } diff --git a/generic/threadshare/src/tcpclientsrc/imp.rs b/generic/threadshare/src/tcpclientsrc/imp.rs index 8a7136b3b..f3ef2fbfb 100644 --- a/generic/threadshare/src/tcpclientsrc/imp.rs +++ b/generic/threadshare/src/tcpclientsrc/imp.rs @@ -29,7 +29,7 @@ use gst::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_log, gst_trace}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::io; use std::net::{IpAddr, SocketAddr}; @@ -503,13 +503,13 @@ pub struct TcpClientSrc { settings: StdMutex<Settings>, } -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-tcpclientsrc", gst::DebugColorFlags::empty(), Some("Thread-sharing TCP Client source"), - ); -} + ) +}); impl TcpClientSrc { fn prepare(&self, element: &super::TcpClientSrc) -> Result<(), gst::ErrorMessage> { diff --git a/generic/threadshare/src/udpsink/imp.rs b/generic/threadshare/src/udpsink/imp.rs index 39c10a412..4472efeb2 100644 --- a/generic/threadshare/src/udpsink/imp.rs +++ b/generic/threadshare/src/udpsink/imp.rs @@ -33,7 +33,7 @@ use gst::{ gst_warning, }; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use crate::runtime::prelude::*; use crate::runtime::{self, Context, PadSink, PadSinkRef, Task}; @@ -112,13 +112,13 @@ impl Default for Settings { } } -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-udpsink", gst::DebugColorFlags::empty(), Some("Thread-sharing UDP sink"), - ); -} + ) +}); static PROPERTIES: [subclass::Property; 17] = [ subclass::Property("sync", |name| { diff --git a/generic/threadshare/src/udpsrc/imp.rs b/generic/threadshare/src/udpsrc/imp.rs index b536e2361..009ce43d6 100644 --- a/generic/threadshare/src/udpsrc/imp.rs +++ b/generic/threadshare/src/udpsrc/imp.rs @@ -29,7 +29,7 @@ use gst::subclass::prelude::*; use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_log, gst_trace}; use gst_net::*; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::i32; use std::io; @@ -517,13 +517,13 @@ pub struct UdpSrc { settings: StdMutex<Settings>, } -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-udpsrc", gst::DebugColorFlags::empty(), Some("Thread-sharing UDP source"), - ); -} + ) +}); impl UdpSrc { fn prepare(&self, element: &super::UdpSrc) -> Result<(), gst::ErrorMessage> { diff --git a/generic/threadshare/tests/jitterbuffer.rs b/generic/threadshare/tests/jitterbuffer.rs index 58bb0a2c2..431dddf89 100644 --- a/generic/threadshare/tests/jitterbuffer.rs +++ b/generic/threadshare/tests/jitterbuffer.rs @@ -18,17 +18,17 @@ use gst::gst_debug; use gst::prelude::*; -use lazy_static::lazy_static; - use std::sync::mpsc; -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +use once_cell::sync::Lazy; + +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-test", gst::DebugColorFlags::empty(), Some("Thread-sharing test"), - ); -} + ) +}); fn init() { use std::sync::Once; diff --git a/generic/threadshare/tests/pad.rs b/generic/threadshare/tests/pad.rs index fa22175de..4fe33c555 100644 --- a/generic/threadshare/tests/pad.rs +++ b/generic/threadshare/tests/pad.rs @@ -29,7 +29,7 @@ use gst::subclass::prelude::*; use gst::EventView; use gst::{gst_debug, gst_error_msg, gst_info, gst_log}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::boxed::Box; use std::sync::atomic::{AtomicBool, Ordering}; @@ -86,13 +86,13 @@ mod imp_src { context: String, } - lazy_static! { - pub static ref SRC_CAT: gst::DebugCategory = gst::DebugCategory::new( + pub static SRC_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-element-src-test", gst::DebugColorFlags::empty(), Some("Thread-sharing Test Src Element"), - ); - } + ) + }); #[derive(Clone, Debug)] struct PadSrcTestHandler; @@ -623,13 +623,13 @@ mod imp_sink { } } - lazy_static! { - static ref SINK_CAT: gst::DebugCategory = gst::DebugCategory::new( + static SINK_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-element-sink-test", gst::DebugColorFlags::empty(), Some("Thread-sharing Test Sink Element"), - ); - } + ) + }); impl ObjectSubclass for ElementSinkTest { const NAME: &'static str = "TsElementSinkTest"; diff --git a/generic/threadshare/tests/pipeline.rs b/generic/threadshare/tests/pipeline.rs index 1e97b0869..3b85012d0 100644 --- a/generic/threadshare/tests/pipeline.rs +++ b/generic/threadshare/tests/pipeline.rs @@ -18,17 +18,17 @@ use gst::prelude::*; use gst::{gst_debug, gst_error}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::sync::mpsc; -lazy_static! { - static ref CAT: gst::DebugCategory = gst::DebugCategory::new( +static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { + gst::DebugCategory::new( "ts-test", gst::DebugColorFlags::empty(), Some("Thread-sharing test"), - ); -} + ) +}); fn init() { use std::sync::Once; |