Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2020-11-22 17:24:55 +0300
committerSebastian Dröge <sebastian@centricular.com>2020-11-23 11:28:33 +0300
commit1c9c22df0c6a6aeb7071f52efbba03d8f1d9a2cd (patch)
treeec5781a5940259a9f443fa5d12424b54a9cea220 /generic/sodium
parent684f52b7d4b262079d819bf61ddc287ae325151c (diff)
generic: Update to 2018 edition
Diffstat (limited to 'generic/sodium')
-rw-r--r--generic/sodium/Cargo.toml2
-rw-r--r--generic/sodium/src/decrypter/imp.rs20
-rw-r--r--generic/sodium/src/decrypter/mod.rs2
-rw-r--r--generic/sodium/src/encrypter/imp.rs20
-rw-r--r--generic/sodium/src/encrypter/mod.rs2
-rw-r--r--generic/sodium/src/lib.rs9
-rw-r--r--generic/sodium/tests/decrypter.rs40
-rw-r--r--generic/sodium/tests/encrypter.rs54
8 files changed, 67 insertions, 82 deletions
diff --git a/generic/sodium/Cargo.toml b/generic/sodium/Cargo.toml
index bb8119011..c1d2216b7 100644
--- a/generic/sodium/Cargo.toml
+++ b/generic/sodium/Cargo.toml
@@ -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"
diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs
index 779c92deb..f058ddfde 100644
--- a/generic/sodium/src/decrypter/imp.rs
+++ b/generic/sodium/src/decrypter/imp.rs
@@ -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();
diff --git a/generic/sodium/src/decrypter/mod.rs b/generic/sodium/src/decrypter/mod.rs
index 4bee6635c..1bf5dbe1e 100644
--- a/generic/sodium/src/decrypter/mod.rs
+++ b/generic/sodium/src/decrypter/mod.rs
@@ -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;
}
diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs
index d23fc15da..cc30a453d 100644
--- a/generic/sodium/src/encrypter/imp.rs
+++ b/generic/sodium/src/encrypter/imp.rs
@@ -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();
diff --git a/generic/sodium/src/encrypter/mod.rs b/generic/sodium/src/encrypter/mod.rs
index b71dd3f91..f9eb39ffe 100644
--- a/generic/sodium/src/encrypter/mod.rs
+++ b/generic/sodium/src/encrypter/mod.rs
@@ -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;
}
diff --git a/generic/sodium/src/lib.rs b/generic/sodium/src/lib.rs
index 5e5470f89..bdccccd64 100644
--- a/generic/sodium/src/lib.rs
+++ b/generic/sodium/src/lib.rs
@@ -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,
diff --git a/generic/sodium/tests/decrypter.rs b/generic/sodium/tests/decrypter.rs
index d9a34e4a1..cab580dd2 100644
--- a/generic/sodium/tests/decrypter.rs
+++ b/generic/sodium/tests/decrypter.rs
@@ -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;
diff --git a/generic/sodium/tests/encrypter.rs b/generic/sodium/tests/encrypter.rs
index beb1414a2..cbb653925 100644
--- a/generic/sodium/tests/encrypter.rs
+++ b/generic/sodium/tests/encrypter.rs
@@ -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,
- ];
-
- 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 once_cell::sync::Lazy;
+
+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;