generic: Update to 2018 edition

This commit is contained in:
Sebastian Dröge 2020-11-22 16:24:55 +02:00
parent 684f52b7d4
commit 1c9c22df0c
34 changed files with 202 additions and 244 deletions

View file

@ -5,13 +5,14 @@ authors = ["Sebastian Dröge <sebastian@centricular.com>"]
repository = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs"
license = "MIT/Apache-2.0"
description = "Rust File Plugin"
edition = "2018"
[dependencies]
url = "2"
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gstreamer-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
lazy_static = "1.0"
gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst-base = { package = "gstreamer-base", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
once_cell = "1.0"
[lib]
name = "gstrsfile"

View file

@ -1,5 +1,3 @@
use glib;
use gst;
use url::Url;
use std::convert::AsRef;

View file

@ -8,13 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib;
use glib::subclass;
use glib::subclass::prelude::*;
use gst;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst_base;
use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_info, gst_trace};
use gst_base::subclass::prelude::*;
use std::fs::File;
@ -66,13 +64,14 @@ pub struct FileSink {
state: Mutex<State>,
}
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(
"rsfilesink",
gst::DebugColorFlags::empty(),
Some("File Sink"),
);
}
)
});
impl FileSink {
fn set_location(
@ -124,7 +123,7 @@ impl ObjectSubclass for FileSink {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn new() -> Self {
Self {

View file

@ -12,7 +12,7 @@ use glib::prelude::*;
mod imp;
glib_wrapper! {
glib::glib_wrapper! {
pub struct FileSink(ObjectSubclass<imp::FileSink>) @extends gst_base::BaseSink, gst::Element, gst::Object, @implements gst::URIHandler;
}

View file

@ -7,13 +7,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib;
use glib::subclass;
use glib::subclass::prelude::*;
use gst;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst_base;
use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_info};
use gst_base::prelude::*;
use gst_base::subclass::prelude::*;
@ -66,13 +64,14 @@ pub struct FileSrc {
state: Mutex<State>,
}
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(
"rsfilesrc",
gst::DebugColorFlags::empty(),
Some("File Source"),
);
}
)
});
impl FileSrc {
fn set_location(
@ -138,7 +137,7 @@ impl ObjectSubclass for FileSrc {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn new() -> Self {
Self {

View file

@ -11,7 +11,7 @@ use glib::prelude::*;
mod imp;
glib_wrapper! {
glib::glib_wrapper! {
pub struct FileSrc(ObjectSubclass<imp::FileSrc>) @extends gst_base::BaseSrc, gst::Element, gst::Object, @implements gst::URIHandler;
}

View file

@ -6,15 +6,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate glib;
#[macro_use]
extern crate gstreamer as gst;
extern crate gstreamer_base as gst_base;
extern crate url;
#[macro_use]
extern crate lazy_static;
mod file_location;
mod filesink;
mod filesrc;
@ -25,7 +16,7 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
Ok(())
}
gst_plugin_define!(
gst::gst_plugin_define!(
rsfile,
env!("CARGO_PKG_DESCRIPTION"),
plugin_init,

View file

@ -12,7 +12,7 @@ glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gst = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_14"], package="gstreamer" }
gst-base = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_14"], package = "gstreamer-base" }
sodiumoxide = "0.2.1"
lazy_static = "1.3.0"
once_cell = "1.3.0"
hex = "0.4"
smallvec = "1.0"

View file

@ -27,19 +27,19 @@ use glib::subclass;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_log, gst_loggable_error};
use sodiumoxide::crypto::box_;
use std::sync::Mutex;
lazy_static! {
static ref CAT: gst::DebugCategory = {
gst::DebugCategory::new(
"sodiumdecrypter",
gst::DebugColorFlags::empty(),
Some("Decrypter Element"),
)
};
}
use once_cell::sync::Lazy;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"sodiumdecrypter",
gst::DebugColorFlags::empty(),
Some("Decrypter Element"),
)
});
static PROPERTIES: [subclass::Property; 2] = [
subclass::Property("receiver-key", |name| {
@ -565,7 +565,7 @@ impl ObjectSubclass for Decrypter {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -26,7 +26,7 @@ use glib::prelude::*;
mod imp;
glib_wrapper! {
glib::glib_wrapper! {
pub struct Decrypter(ObjectSubclass<imp::Decrypter>) @extends gst::Element, gst::Object;
}

View file

@ -27,6 +27,7 @@ use glib::subclass;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg, gst_log};
use smallvec::SmallVec;
use sodiumoxide::crypto::box_;
@ -34,15 +35,14 @@ type BufferVec = SmallVec<[gst::Buffer; 16]>;
use std::sync::Mutex;
lazy_static! {
static ref CAT: gst::DebugCategory = {
gst::DebugCategory::new(
"sodiumencrypter",
gst::DebugColorFlags::empty(),
Some("Encrypter Element"),
)
};
}
use once_cell::sync::Lazy;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"sodiumencrypter",
gst::DebugColorFlags::empty(),
Some("Encrypter Element"),
)
});
static PROPERTIES: [subclass::Property; 3] = [
subclass::Property("receiver-key", |name| {
@ -395,7 +395,7 @@ impl ObjectSubclass for Encrypter {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -26,7 +26,7 @@ use glib::prelude::*;
mod imp;
glib_wrapper! {
glib::glib_wrapper! {
pub struct Encrypter(ObjectSubclass<imp::Encrypter>) @extends gst::Element, gst::Object;
}

View file

@ -20,13 +20,6 @@
//
// SPDX-License-Identifier: MIT
#[macro_use]
extern crate glib;
#[macro_use]
extern crate gst;
#[macro_use]
extern crate lazy_static;
const TYPEFIND_HEADER: &[u8; 12] = b"gst-sodium10";
// `core::slice::<impl [T]>::len` is not yet stable as a const fn
// const TYPEFIND_HEADER_SIZE: usize = TYPEFIND_HEADER.len();
@ -68,7 +61,7 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
Ok(())
}
gst_plugin_define!(
gst::gst_plugin_define!(
sodium,
env!("CARGO_PKG_DESCRIPTION"),
plugin_init,

View file

@ -22,13 +22,6 @@
//
// SPDX-License-Identifier: MIT
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate pretty_assertions;
extern crate gstsodium;
use glib::prelude::*;
use gst::prelude::*;
@ -36,22 +29,23 @@ use std::sync::{Arc, Mutex};
use std::path::PathBuf;
lazy_static! {
static ref SENDER_PUBLIC: glib::Bytes = {
let public = [
66, 248, 199, 74, 216, 55, 228, 116, 52, 17, 147, 56, 65, 130, 134, 148, 157, 153, 235,
171, 179, 147, 120, 71, 100, 243, 133, 120, 160, 14, 111, 65,
];
glib::Bytes::from_owned(public)
};
static ref RECEIVER_PRIVATE: glib::Bytes = {
let secret = [
54, 221, 217, 54, 94, 235, 167, 2, 187, 249, 71, 31, 59, 27, 19, 166, 78, 236, 102, 48,
29, 142, 41, 189, 22, 146, 218, 69, 147, 165, 240, 235,
];
glib::Bytes::from_owned(secret)
};
}
use pretty_assertions::assert_eq;
use once_cell::sync::Lazy;
static SENDER_PUBLIC: Lazy<glib::Bytes> = Lazy::new(|| {
let public = [
66, 248, 199, 74, 216, 55, 228, 116, 52, 17, 147, 56, 65, 130, 134, 148, 157, 153, 235,
171, 179, 147, 120, 71, 100, 243, 133, 120, 160, 14, 111, 65,
];
glib::Bytes::from_owned(public)
});
static RECEIVER_PRIVATE: Lazy<glib::Bytes> = Lazy::new(|| {
let secret = [
54, 221, 217, 54, 94, 235, 167, 2, 187, 249, 71, 31, 59, 27, 19, 166, 78, 236, 102, 48, 29,
142, 41, 189, 22, 146, 218, 69, 147, 165, 240, 235,
];
glib::Bytes::from_owned(secret)
});
fn init() {
use std::sync::Once;

View file

@ -22,37 +22,35 @@
//
// SPDX-License-Identifier: MIT
#[macro_use]
extern crate lazy_static;
extern crate gstsodium;
use glib::prelude::*;
use gst::prelude::*;
lazy_static! {
static ref RECEIVER_PUBLIC: glib::Bytes = {
let public = [
28, 95, 33, 124, 28, 103, 80, 78, 7, 28, 234, 40, 226, 179, 253, 166, 169, 64, 78, 5,
57, 92, 151, 179, 221, 89, 68, 70, 44, 225, 219, 19,
];
use once_cell::sync::Lazy;
glib::Bytes::from_owned(public)
};
static ref SENDER_PRIVATE: glib::Bytes = {
let secret = [
154, 227, 90, 239, 206, 184, 202, 234, 176, 161, 14, 91, 218, 98, 142, 13, 145, 223,
210, 222, 224, 240, 98, 51, 142, 165, 255, 1, 159, 100, 242, 162,
];
glib::Bytes::from_owned(secret)
};
static ref NONCE: glib::Bytes = {
let nonce = [
144, 187, 179, 230, 15, 4, 241, 15, 37, 133, 22, 30, 50, 106, 70, 159, 243, 218, 173,
22, 18, 36, 4, 45,
];
glib::Bytes::from_owned(nonce)
};
}
use pretty_assertions::assert_eq;
static RECEIVER_PUBLIC: Lazy<glib::Bytes> = Lazy::new(|| {
let public = [
28, 95, 33, 124, 28, 103, 80, 78, 7, 28, 234, 40, 226, 179, 253, 166, 169, 64, 78, 5, 57,
92, 151, 179, 221, 89, 68, 70, 44, 225, 219, 19,
];
glib::Bytes::from_owned(public)
});
static SENDER_PRIVATE: Lazy<glib::Bytes> = Lazy::new(|| {
let secret = [
154, 227, 90, 239, 206, 184, 202, 234, 176, 161, 14, 91, 218, 98, 142, 13, 145, 223, 210,
222, 224, 240, 98, 51, 142, 165, 255, 1, 159, 100, 242, 162,
];
glib::Bytes::from_owned(secret)
});
static NONCE: Lazy<glib::Bytes> = Lazy::new(|| {
let nonce = [
144, 187, 179, 230, 15, 4, 241, 15, 37, 133, 22, 30, 50, 106, 70, 159, 243, 218, 173, 22,
18, 36, 4, 45,
];
glib::Bytes::from_owned(nonce)
});
fn init() {
use std::sync::Once;

View file

@ -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"]

View file

@ -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 {

View file

@ -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 {

View file

@ -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<(), ()> {

View file

@ -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,

View file

@ -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) {

View file

@ -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")));
}

View file

@ -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));
}
}
}

View file

@ -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> {

View file

@ -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

View file

@ -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));

View file

@ -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"),
);
}
)
});

View file

@ -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 _);
}
}
}

View file

@ -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> {

View file

@ -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| {

View file

@ -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> {

View file

@ -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;

View file

@ -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";

View file

@ -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;