media: Switch to workspace dependencies and minor cleanup (#44428)

This PR makes minor cleanup in the media crates:
- Switch dependencies to workspace dependencies if they are already
included in the main Cargo.toml
- Switch from crate serde_derive to serde with feature flag derive.
- Switch from the separate crate for OnceCell to the std provided
LazyLock.
- Update num_complex

Testing: The only functional changes are either slight version bumps,
the replacement to LazyLock which is conservative and the num_complex
update which also shouldn't have any behavior changes.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
Narfinger
2026-04-22 23:56:59 +09:00
committed by GitHub
parent 6934a65e5c
commit c2b88ff7f5
22 changed files with 87 additions and 91 deletions

24
Cargo.lock generated
View File

@@ -3527,8 +3527,6 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [ dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.2.0", "foldhash 0.2.0",
] ]
@@ -3537,6 +3535,11 @@ name = "hashbrown"
version = "0.17.0" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.2.0",
]
[[package]] [[package]]
name = "hashlink" name = "hashlink"
@@ -4843,11 +4846,11 @@ dependencies = [
[[package]] [[package]]
name = "lru" name = "lru"
version = "0.16.4" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" checksum = "0e0b564323a0fb6d54b864f625ae139de9612e27edb944dda37c109f05aac531"
dependencies = [ dependencies = [
"hashbrown 0.16.1", "hashbrown 0.17.0",
] ]
[[package]] [[package]]
@@ -5311,11 +5314,10 @@ dependencies = [
[[package]] [[package]]
name = "num-complex" name = "num-complex"
version = "0.2.4" version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [ dependencies = [
"autocfg",
"num-traits", "num-traits",
] ]
@@ -8111,7 +8113,6 @@ dependencies = [
name = "servo-media" name = "servo-media"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"once_cell",
"servo-media-audio", "servo-media-audio",
"servo-media-player", "servo-media-player",
"servo-media-streams", "servo-media-streams",
@@ -8131,7 +8132,6 @@ dependencies = [
"num-traits", "num-traits",
"petgraph", "petgraph",
"serde", "serde",
"serde_derive",
"servo-malloc-size-of", "servo-malloc-size-of",
"servo-media-derive", "servo-media-derive",
"servo-media-player", "servo-media-player",
@@ -8202,7 +8202,6 @@ dependencies = [
"ipc-channel", "ipc-channel",
"log", "log",
"mime", "mime",
"once_cell",
"servo-media", "servo-media",
"servo-media-audio", "servo-media-audio",
"servo-media-gstreamer-render", "servo-media-gstreamer-render",
@@ -8265,7 +8264,6 @@ dependencies = [
"ohos-media-sys", "ohos-media-sys",
"ohos-sys-opaque-types", "ohos-sys-opaque-types",
"ohos-window-sys", "ohos-window-sys",
"once_cell",
"rangemap", "rangemap",
"serde_json", "serde_json",
"servo-media", "servo-media",
@@ -8284,7 +8282,6 @@ dependencies = [
"ipc-channel", "ipc-channel",
"malloc_size_of_derive", "malloc_size_of_derive",
"serde", "serde",
"serde_derive",
"servo-malloc-size-of", "servo-malloc-size-of",
"servo-media-streams", "servo-media-streams",
"servo-media-traits", "servo-media-traits",
@@ -12044,6 +12041,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47d3a7e2cda3061858987ee2fb028f61695f5ee13f9490d75be6c3900df9a4ea" checksum = "47d3a7e2cda3061858987ee2fb028f61695f5ee13f9490d75be6c3900df9a4ea"
dependencies = [ dependencies = [
"num-traits", "num-traits",
"rayon",
] ]
[[package]] [[package]]

View File

@@ -47,6 +47,7 @@ brotli = "8.0.2"
bytemuck = "1" bytemuck = "1"
byteorder = "1.5" byteorder = "1.5"
bytes = "1.0" bytes = "1.0"
byte-slice-cast = "1.2.3"
cbc = "0.1.2" cbc = "0.1.2"
cfg-if = "1.0.4" cfg-if = "1.0.4"
chacha20poly1305 = "0.10" chacha20poly1305 = "0.10"
@@ -114,6 +115,7 @@ js = { package = "mozjs", version = "=0.15.8", default-features = false, feature
keyboard-types = { version = "0.8.3", features = ["serde", "webdriver"] } keyboard-types = { version = "0.8.3", features = ["serde", "webdriver"] }
kurbo = { version = "0.12", features = ["euclid"] } kurbo = { version = "0.12", features = ["euclid"] }
libc = "0.2" libc = "0.2"
lru = "0.17"
log = "0.4.29" log = "0.4.29"
mach2 = "0.6" mach2 = "0.6"
malloc_size_of_derive = "0.1" malloc_size_of_derive = "0.1"
@@ -129,6 +131,7 @@ nix = "0.30"
nom = "8.0.0" nom = "8.0.0"
nom-rfc8288 = "0.4.0" nom-rfc8288 = "0.4.0"
num-bigint-dig = "0.8" num-bigint-dig = "0.8"
num-complex = "0.4.6"
num-derive = "0.4.2" num-derive = "0.4.2"
num-traits = "0.2" num-traits = "0.2"
num_cpus = "1.17.0" num_cpus = "1.17.0"
@@ -149,6 +152,7 @@ postcard = { version = "1.1.3", default-features = false, features = ["use-std"]
proc-macro2 = "1" proc-macro2 = "1"
quote = "1" quote = "1"
rand = "0.9" rand = "0.9"
rangemap = "1.7.1"
raw-window-handle = "0.6" raw-window-handle = "0.6"
rayon = "1" rayon = "1"
read-fonts = "0.35.0" read-fonts = "0.35.0"
@@ -171,6 +175,7 @@ servo_arc = { git = "https://github.com/servo/stylo", rev = "a556f4cbd15fc289039
sha1 = "0.10" sha1 = "0.10"
sha2 = "0.10" sha2 = "0.10"
sha3 = "0.10" sha3 = "0.10"
speexdsp-resampler = "0.1.0"
skrifa = "0.37.0" skrifa = "0.37.0"
smallvec = { version = "1.15", features = ["serde", "union"] } smallvec = { version = "1.15", features = ["serde", "union"] }
string_cache = "0.9" string_cache = "0.9"
@@ -223,6 +228,7 @@ wio = "0.2"
wr_malloc_size_of = "0.2.2" wr_malloc_size_of = "0.2.2"
x25519-dalek = { version = "2.0.1", features = ["static_secrets"] } x25519-dalek = { version = "2.0.1", features = ["static_secrets"] }
xml5ever = "0.39" xml5ever = "0.39"
yuv = { version = "0.8.13", features = ["rayon"] }
############################################################################################ ############################################################################################
## Workspace-local dependencies ## Workspace-local dependencies

View File

@@ -14,19 +14,18 @@ name = "servo_media_audio"
path = "lib.rs" path = "lib.rs"
[dependencies] [dependencies]
euclid = "0.22" euclid = { workspace = true }
log = "0.4" log = { workspace = true }
serde_derive = "1.0.66" serde = { workspace = true, features = ["derive"] }
serde = "1.0.66"
servo-media-derive = { workspace = true } servo-media-derive = { workspace = true }
servo-media-player = { workspace = true } servo-media-player = { workspace = true }
servo-media-traits = { workspace = true } servo-media-traits = { workspace = true }
servo-media-streams = { workspace = true } servo-media-streams = { workspace = true }
smallvec = "1" smallvec = { workspace = true }
speexdsp-resampler = "0.1.0" speexdsp-resampler = { workspace = true }
malloc_size_of = { workspace = true } malloc_size_of = { workspace = true }
malloc_size_of_derive = { workspace = true } malloc_size_of_derive = { workspace = true }
num-complex = "0.2.4" num-complex = { workspace = true }
[dependencies.petgraph] [dependencies.petgraph]
version = "0.4.12" version = "0.4.12"

View File

@@ -8,6 +8,7 @@ use std::ops::*;
use byte_slice_cast::*; use byte_slice_cast::*;
use euclid::default::Vector3D; use euclid::default::Vector3D;
use serde::{Deserialize, Serialize};
use smallvec::{SmallVec, smallvec}; use smallvec::{SmallVec, smallvec};
use crate::graph::{PortIndex, PortKind}; use crate::graph::{PortIndex, PortKind};

View File

@@ -2,9 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#[macro_use]
extern crate serde_derive;
#[macro_use] #[macro_use]
extern crate servo_media_derive; extern crate servo_media_derive;

View File

@@ -18,7 +18,7 @@ glx = ["servo-media-gstreamer-render-unix/gl-x11"]
wayland = ["servo-media-gstreamer-render-unix/gl-wayland"] wayland = ["servo-media-gstreamer-render-unix/gl-wayland"]
[dependencies] [dependencies]
byte-slice-cast = "1" byte-slice-cast = { workspace = true }
glib = { workspace = true } glib = { workspace = true }
glib-sys = { workspace = true } glib-sys = { workspace = true }
gstreamer = { workspace = true } gstreamer = { workspace = true }
@@ -31,9 +31,8 @@ gstreamer-webrtc = { workspace = true }
gstreamer-sdp = { workspace = true } gstreamer-sdp = { workspace = true }
gstreamer-sys = { workspace = true } gstreamer-sys = { workspace = true }
ipc-channel = { workspace = true } ipc-channel = { workspace = true }
log = "0.4" log = { workspace = true }
mime = "0.3.13" mime = { workspace = true }
once_cell = "1.18.0"
servo-media = { workspace = true } servo-media = { workspace = true }
servo-media-audio = { workspace = true } servo-media-audio = { workspace = true }
servo-media-gstreamer-render = { workspace = true } servo-media-gstreamer-render = { workspace = true }
@@ -41,7 +40,7 @@ servo-media-player = { workspace = true }
servo-media-streams = { workspace = true } servo-media-streams = { workspace = true }
servo-media-traits = { workspace = true } servo-media-traits = { workspace = true }
servo-media-webrtc = { workspace = true } servo-media-webrtc = { workspace = true }
url = "2.0" url = { workspace = true }
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies] [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
servo-media-gstreamer-render-unix = { workspace = true, features = [ servo-media-gstreamer-render-unix = { workspace = true, features = [

View File

@@ -20,7 +20,7 @@ use std::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::mpsc::{self, Sender}; use std::sync::mpsc::{self, Sender};
use std::sync::{Arc, Mutex, Weak}; use std::sync::{Arc, LazyLock, Mutex, OnceLock, Weak};
use std::thread; use std::thread;
use std::vec::Vec; use std::vec::Vec;
@@ -30,7 +30,6 @@ use ipc_channel::ipc::IpcSender;
use log::warn; use log::warn;
use media_stream::GStreamerMediaStream; use media_stream::GStreamerMediaStream;
use mime::Mime; use mime::Mime;
use once_cell::sync::{Lazy, OnceCell};
use registry_scanner::GSTREAMER_REGISTRY_SCANNER; use registry_scanner::GSTREAMER_REGISTRY_SCANNER;
use servo_media::{Backend, BackendDeInit, BackendInit, MediaInstanceError, SupportsMediaType}; use servo_media::{Backend, BackendDeInit, BackendInit, MediaInstanceError, SupportsMediaType};
use servo_media_audio::context::{AudioContext, AudioContextOptions}; use servo_media_audio::context::{AudioContext, AudioContextOptions};
@@ -48,10 +47,10 @@ use servo_media_streams::{MediaOutput, MediaSocket, MediaStreamType};
use servo_media_traits::{BackendMsg, ClientContextId, MediaInstance}; use servo_media_traits::{BackendMsg, ClientContextId, MediaInstance};
use servo_media_webrtc::{WebRtcBackend, WebRtcController, WebRtcSignaller}; use servo_media_webrtc::{WebRtcBackend, WebRtcController, WebRtcSignaller};
static BACKEND_BASE_TIME: Lazy<gstreamer::ClockTime> = static BACKEND_BASE_TIME: LazyLock<gstreamer::ClockTime> =
Lazy::new(|| gstreamer::SystemClock::obtain().time()); LazyLock::new(|| gstreamer::SystemClock::obtain().time());
static BACKEND_THREAD: OnceCell<bool> = OnceCell::new(); static BACKEND_THREAD: OnceLock<bool> = OnceLock::new();
pub type WeakMediaInstance = Weak<Mutex<dyn MediaInstance>>; pub type WeakMediaInstance = Weak<Mutex<dyn MediaInstance>>;
pub type WeakMediaInstanceHashMap = HashMap<ClientContextId, Vec<(usize, WeakMediaInstance)>>; pub type WeakMediaInstanceHashMap = HashMap<ClientContextId, Vec<(usize, WeakMediaInstance)>>;

View File

@@ -3,12 +3,11 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::any::Any; use std::any::Any;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, LazyLock, Mutex};
use glib::BoolError; use glib::BoolError;
use gstreamer; use gstreamer;
use gstreamer::prelude::*; use gstreamer::prelude::*;
use once_cell::sync::Lazy;
use servo_media_streams::registry::{ use servo_media_streams::registry::{
MediaStreamId, get_stream, register_stream, unregister_stream, MediaStreamId, get_stream, register_stream, unregister_stream,
}; };
@@ -16,14 +15,14 @@ use servo_media_streams::{MediaOutput, MediaSocket, MediaStream, MediaStreamType
use super::BACKEND_BASE_TIME; use super::BACKEND_BASE_TIME;
pub static RTP_CAPS_OPUS: Lazy<gstreamer::Caps> = Lazy::new(|| { pub static RTP_CAPS_OPUS: LazyLock<gstreamer::Caps> = LazyLock::new(|| {
gstreamer::Caps::builder("application/x-rtp") gstreamer::Caps::builder("application/x-rtp")
.field("media", "audio") .field("media", "audio")
.field("encoding-name", "OPUS") .field("encoding-name", "OPUS")
.build() .build()
}); });
pub static RTP_CAPS_VP8: Lazy<gstreamer::Caps> = Lazy::new(|| { pub static RTP_CAPS_VP8: LazyLock<gstreamer::Caps> = LazyLock::new(|| {
gstreamer::Caps::builder("application/x-rtp") gstreamer::Caps::builder("application/x-rtp")
.field("media", "video") .field("media", "video")
.field("encoding-name", "VP8") .field("encoding-name", "VP8")

View File

@@ -3,13 +3,12 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, LazyLock, Mutex};
use glib::subclass::prelude::*; use glib::subclass::prelude::*;
use gstreamer::prelude::*; use gstreamer::prelude::*;
use gstreamer::subclass::prelude::*; use gstreamer::subclass::prelude::*;
use gstreamer_base::UniqueFlowCombiner; use gstreamer_base::UniqueFlowCombiner;
use once_cell::sync::Lazy;
use servo_media_player::PlayerError; use servo_media_player::PlayerError;
use servo_media_streams::{MediaStream, MediaStreamType}; use servo_media_streams::{MediaStream, MediaStreamType};
use url::Url; use url::Url;
@@ -18,9 +17,10 @@ use crate::media_stream::{GStreamerMediaStream, RTP_CAPS_OPUS, RTP_CAPS_VP8};
// Implementation sub-module of the GObject // Implementation sub-module of the GObject
mod imp { mod imp {
use super::*; use super::*;
static AUDIO_SRC_PAD_TEMPLATE: Lazy<gstreamer::PadTemplate> = Lazy::new(|| { static AUDIO_SRC_PAD_TEMPLATE: LazyLock<gstreamer::PadTemplate> = LazyLock::new(|| {
gstreamer::PadTemplate::new( gstreamer::PadTemplate::new(
"audio_src", "audio_src",
gstreamer::PadDirection::Src, gstreamer::PadDirection::Src,
@@ -30,7 +30,7 @@ mod imp {
.expect("Could not create audio src pad template") .expect("Could not create audio src pad template")
}); });
static VIDEO_SRC_PAD_TEMPLATE: Lazy<gstreamer::PadTemplate> = Lazy::new(|| { static VIDEO_SRC_PAD_TEMPLATE: LazyLock<gstreamer::PadTemplate> = LazyLock::new(|| {
gstreamer::PadTemplate::new( gstreamer::PadTemplate::new(
"video_src", "video_src",
gstreamer::PadDirection::Src, gstreamer::PadDirection::Src,
@@ -226,7 +226,7 @@ mod imp {
// corresponding values of the properties. // corresponding values of the properties.
impl ObjectImpl for ServoMediaStreamSrc { impl ObjectImpl for ServoMediaStreamSrc {
fn properties() -> &'static [glib::ParamSpec] { fn properties() -> &'static [glib::ParamSpec] {
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { static PROPERTIES: LazyLock<Vec<glib::ParamSpec>> = LazyLock::new(|| {
vec![ vec![
// Let playbin3 know we are a live source. // Let playbin3 know we are a live source.
glib::ParamSpecBoolean::builder("is-live") glib::ParamSpecBoolean::builder("is-live")
@@ -254,20 +254,21 @@ mod imp {
// Implementation of gstreamer::Element virtual methods // Implementation of gstreamer::Element virtual methods
impl ElementImpl for ServoMediaStreamSrc { impl ElementImpl for ServoMediaStreamSrc {
fn metadata() -> Option<&'static gstreamer::subclass::ElementMetadata> { fn metadata() -> Option<&'static gstreamer::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gstreamer::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: LazyLock<gstreamer::subclass::ElementMetadata> =
gstreamer::subclass::ElementMetadata::new( LazyLock::new(|| {
"Servo Media Stream Source", gstreamer::subclass::ElementMetadata::new(
"Source/Audio/Video", "Servo Media Stream Source",
"Feed player with media stream data", "Source/Audio/Video",
"Servo developers", "Feed player with media stream data",
) "Servo developers",
}); )
});
Some(&*ELEMENT_METADATA) Some(&*ELEMENT_METADATA)
} }
fn pad_templates() -> &'static [gstreamer::PadTemplate] { fn pad_templates() -> &'static [gstreamer::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gstreamer::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: LazyLock<Vec<gstreamer::PadTemplate>> = LazyLock::new(|| {
// Add pad templates for our audio and video source pads. // Add pad templates for our audio and video source pads.
// These are later used for actually creating the pads and beforehand // These are later used for actually creating the pads and beforehand
// already provide information to GStreamer about all possible // already provide information to GStreamer about all possible

View File

@@ -4,14 +4,13 @@
use std::collections::HashSet; use std::collections::HashSet;
use std::str::FromStr; use std::str::FromStr;
use std::sync::LazyLock;
use once_cell::sync::Lazy;
// The GStreamer registry holds the metadata of the set of plugins available in the host. // The GStreamer registry holds the metadata of the set of plugins available in the host.
// This scanner is used to lazily analyze the registry and to provide information about // This scanner is used to lazily analyze the registry and to provide information about
// the set of supported mime types and codecs that the backend is able to deal with. // the set of supported mime types and codecs that the backend is able to deal with.
pub static GSTREAMER_REGISTRY_SCANNER: Lazy<GStreamerRegistryScanner> = pub static GSTREAMER_REGISTRY_SCANNER: LazyLock<GStreamerRegistryScanner> =
Lazy::new(GStreamerRegistryScanner::new); LazyLock::new(GStreamerRegistryScanner::new);
pub struct GStreamerRegistryScanner { pub struct GStreamerRegistryScanner {
supported_mime_types: HashSet<&'static str>, supported_mime_types: HashSet<&'static str>,

View File

@@ -9,13 +9,14 @@ use std::sync::atomic::{AtomicBool, Ordering};
use glib::subclass::prelude::*; use glib::subclass::prelude::*;
use gstreamer::prelude::*; use gstreamer::prelude::*;
use gstreamer::subclass::prelude::*; use gstreamer::subclass::prelude::*;
use once_cell::sync::Lazy;
use url::Url; use url::Url;
const MAX_SRC_QUEUE_SIZE: u64 = 50 * 1024 * 1024; // 50 MB. const MAX_SRC_QUEUE_SIZE: u64 = 50 * 1024 * 1024; // 50 MB.
// Implementation sub-module of the GObject // Implementation sub-module of the GObject
mod imp { mod imp {
use std::sync::LazyLock;
use super::*; use super::*;
macro_rules! inner_appsrc_proxy { macro_rules! inner_appsrc_proxy {
@@ -316,20 +317,21 @@ mod imp {
// Implementation of gstreamer::Element virtual methods // Implementation of gstreamer::Element virtual methods
impl ElementImpl for ServoSrc { impl ElementImpl for ServoSrc {
fn metadata() -> Option<&'static gstreamer::subclass::ElementMetadata> { fn metadata() -> Option<&'static gstreamer::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gstreamer::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: LazyLock<gstreamer::subclass::ElementMetadata> =
gstreamer::subclass::ElementMetadata::new( LazyLock::new(|| {
"Servo Media Source", gstreamer::subclass::ElementMetadata::new(
"Source/Audio/Video", "Servo Media Source",
"Feed player with media data", "Source/Audio/Video",
"Servo developers", "Feed player with media data",
) "Servo developers",
}); )
});
Some(&*ELEMENT_METADATA) Some(&*ELEMENT_METADATA)
} }
fn pad_templates() -> &'static [gstreamer::PadTemplate] { fn pad_templates() -> &'static [gstreamer::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gstreamer::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: LazyLock<Vec<gstreamer::PadTemplate>> = LazyLock::new(|| {
let caps = gstreamer::Caps::new_any(); let caps = gstreamer::Caps::new_any();
let src_pad_template = gstreamer::PadTemplate::new( let src_pad_template = gstreamer::PadTemplate::new(
"src", "src",

View File

@@ -20,18 +20,17 @@ servo-media-player = { workspace = true }
servo-media-streams = { workspace = true } servo-media-streams = { workspace = true }
servo-media-traits = { workspace = true } servo-media-traits = { workspace = true }
servo-media-webrtc = { workspace = true } servo-media-webrtc = { workspace = true }
mime = "0.3.13" mime = { workspace = true }
once_cell = "1.18.0" log = { workspace = true }
log = "0.4"
ohos-media-sys = { version = "0.0.5", features = ["api-21"] } ohos-media-sys = { version = "0.0.5", features = ["api-21"] }
ohos-window-sys = { version = "0.1.3", features = ["api-13"] } ohos-window-sys = { version = "0.1.3", features = ["api-13"] }
ohos-sys-opaque-types = { version = "0.1.7" } ohos-sys-opaque-types = { version = "0.1.7" }
ipc-channel = { workspace = true } ipc-channel = { workspace = true }
crossbeam-channel = { workspace = true } crossbeam-channel = { workspace = true }
lru = "0.16.3" lru = { workspace = true }
rangemap = "1.6.0" rangemap = { workspace = true }
libc = "0.2" libc = { workspace = true }
yuv = "0.8.11" yuv = { workspace = true }
[build-dependencies] [build-dependencies]
serde_json.workspace = true serde_json.workspace = true

View File

@@ -3,10 +3,10 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::LazyLock;
use once_cell::sync::Lazy; pub static OHOS_REGISTRY_SCANNER: LazyLock<OhosRegistryScanner> =
LazyLock::new(OhosRegistryScanner::new);
pub static OHOS_REGISTRY_SCANNER: Lazy<OhosRegistryScanner> = Lazy::new(OhosRegistryScanner::new);
// Should be a combination of mime/codecs // Should be a combination of mime/codecs
// If the type we are matching only contain mime, then we only match the container. // If the type we are matching only contain mime, then we only match the container.

View File

@@ -14,8 +14,7 @@ name = "servo_media_player"
path = "lib.rs" path = "lib.rs"
[dependencies] [dependencies]
serde = "1.0.66" serde = { workspace = true, features = ["derive"] }
serde_derive = "1.0.66"
ipc-channel = { workspace = true } ipc-channel = { workspace = true }
malloc_size_of = { workspace = true } malloc_size_of = { workspace = true }
malloc_size_of_derive = { workspace = true } malloc_size_of_derive = { workspace = true }

View File

@@ -12,6 +12,7 @@
//! trait object to its `player` instance. //! trait object to its `player` instance.
use malloc_size_of_derive::MallocSizeOf; use malloc_size_of_derive::MallocSizeOf;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)] #[derive(Clone, Debug, Deserialize, Serialize, MallocSizeOf)]
pub enum GlContext { pub enum GlContext {

View File

@@ -6,8 +6,6 @@ use std::ops::Range;
use std::time::Duration; use std::time::Duration;
pub extern crate ipc_channel; pub extern crate ipc_channel;
#[macro_use]
extern crate serde_derive;
extern crate servo_media_streams as streams; extern crate servo_media_streams as streams;
extern crate servo_media_traits; extern crate servo_media_traits;
@@ -17,6 +15,7 @@ pub mod metadata;
pub mod video; pub mod video;
use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::ipc::{self, IpcSender};
use serde::{Deserialize, Serialize};
use servo_media_traits::MediaInstance; use servo_media_traits::MediaInstance;
use streams::registry::MediaStreamId; use streams::registry::MediaStreamId;

View File

@@ -4,6 +4,8 @@
use std::time; use std::time;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct Metadata { pub struct Metadata {
pub duration: Option<time::Duration>, pub duration: Option<time::Duration>,

View File

@@ -15,6 +15,6 @@ proc-macro = true
path = "lib.rs" path = "lib.rs"
[dependencies] [dependencies]
syn = "2" syn = { workspace = true }
quote = "1" quote = { workspace = true }
proc-macro2 = "1" proc-macro2 = { workspace = true }

View File

@@ -14,7 +14,6 @@ name = "servo_media"
path = "lib.rs" path = "lib.rs"
[dependencies] [dependencies]
once_cell = "1.18.0"
servo-media-audio = { workspace = true } servo-media-audio = { workspace = true }
servo-media-player = { workspace = true } servo-media-player = { workspace = true }
servo-media-streams = { workspace = true } servo-media-streams = { workspace = true }

View File

@@ -8,15 +8,12 @@ pub extern crate servo_media_streams as streams;
pub extern crate servo_media_traits as traits; pub extern crate servo_media_traits as traits;
pub extern crate servo_media_webrtc as webrtc; pub extern crate servo_media_webrtc as webrtc;
extern crate once_cell;
use std::ops::Deref; use std::ops::Deref;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex, OnceLock};
use std::thread; use std::thread;
use audio::context::{AudioContext, AudioContextOptions}; use audio::context::{AudioContext, AudioContextOptions};
use audio::sink::AudioSinkError; use audio::sink::AudioSinkError;
use once_cell::sync::OnceCell;
use player::audio::AudioRenderer; use player::audio::AudioRenderer;
use player::context::PlayerGLContext; use player::context::PlayerGLContext;
use player::ipc_channel::ipc::IpcSender; use player::ipc_channel::ipc::IpcSender;
@@ -31,7 +28,7 @@ use webrtc::{WebRtcController, WebRtcSignaller};
pub struct ServoMedia(Box<dyn Backend>); pub struct ServoMedia(Box<dyn Backend>);
static INSTANCE: OnceCell<Arc<ServoMedia>> = OnceCell::new(); static INSTANCE: OnceLock<Arc<ServoMedia>> = OnceLock::new();
pub trait BackendInit { pub trait BackendInit {
fn init() -> Box<dyn Backend>; fn init() -> Box<dyn Backend>;

View File

@@ -16,4 +16,4 @@ path = "lib.rs"
[dependencies] [dependencies]
malloc_size_of = { workspace = true } malloc_size_of = { workspace = true }
malloc_size_of_derive = { workspace = true } malloc_size_of_derive = { workspace = true }
uuid = { version = "1.4", features = ["v4"] } uuid = { workspace = true, features = ["v4"] }

View File

@@ -13,6 +13,6 @@ description.workspace = true
path = "lib.rs" path = "lib.rs"
[dependencies] [dependencies]
log = "0.4" log = { workspace = true }
servo-media-streams = { workspace = true } servo-media-streams = { workspace = true }
uuid = { version = "1.4", features = ["v4"] } uuid = { workspace = true, features = ["v4"] }