From 91b61ac12f436e2996f91959bb79d69f0929f8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 22 Oct 2024 16:24:15 +0300 Subject: [PATCH] closedcaption: Switch from once_cell to std for new ST2038 elements Part-of: --- video/closedcaption/src/cctost2038anc/imp.rs | 12 +++++------- video/closedcaption/src/st2038ancdemux/imp.rs | 11 ++++------- video/closedcaption/src/st2038ancmux/imp.rs | 16 ++++++++-------- video/closedcaption/src/st2038anctocc/imp.rs | 10 ++++------ 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/video/closedcaption/src/cctost2038anc/imp.rs b/video/closedcaption/src/cctost2038anc/imp.rs index 7f777258..bb0e7f99 100644 --- a/video/closedcaption/src/cctost2038anc/imp.rs +++ b/video/closedcaption/src/cctost2038anc/imp.rs @@ -6,7 +6,7 @@ // // SPDX-License-Identifier: MPL-2.0 -use std::sync::Mutex; +use std::sync::{LazyLock, Mutex}; use gst::glib; use gst::prelude::*; @@ -14,8 +14,6 @@ use gst::subclass::prelude::*; use atomic_refcell::AtomicRefCell; -use once_cell::sync::Lazy; - use crate::st2038anc_utils::convert_to_st2038_buffer; #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -54,7 +52,7 @@ pub struct CcToSt2038Anc { settings: Mutex, } -static CAT: Lazy = Lazy::new(|| { +static CAT: LazyLock = LazyLock::new(|| { gst::DebugCategory::new( "cctost2038anc", gst::DebugColorFlags::empty(), @@ -197,7 +195,7 @@ impl ObjectSubclass for CcToSt2038Anc { impl ObjectImpl for CcToSt2038Anc { fn properties() -> &'static [glib::ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { + static PROPERTIES: LazyLock> = LazyLock::new(|| { vec![ glib::ParamSpecBoolean::builder("c-not-y-channel") .nick("Y Not C Channel") @@ -278,7 +276,7 @@ impl GstObjectImpl for CcToSt2038Anc {} impl ElementImpl for CcToSt2038Anc { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { - static ELEMENT_METADATA: Lazy = Lazy::new(|| { + static ELEMENT_METADATA: LazyLock = LazyLock::new(|| { gst::subclass::ElementMetadata::new( "CC to ST-2038 ANC", "Generic", @@ -291,7 +289,7 @@ impl ElementImpl for CcToSt2038Anc { } fn pad_templates() -> &'static [gst::PadTemplate] { - static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + static PAD_TEMPLATES: LazyLock> = LazyLock::new(|| { let src_pad_template = gst::PadTemplate::new( "src", gst::PadDirection::Src, diff --git a/video/closedcaption/src/st2038ancdemux/imp.rs b/video/closedcaption/src/st2038ancdemux/imp.rs index 25ff5880..8c6cdce1 100644 --- a/video/closedcaption/src/st2038ancdemux/imp.rs +++ b/video/closedcaption/src/st2038ancdemux/imp.rs @@ -15,14 +15,11 @@ use gst_base::UniqueFlowCombiner; use atomic_refcell::AtomicRefCell; -use once_cell::sync::Lazy; - -use std::collections::HashMap; -use std::mem; +use std::{collections::HashMap, mem, sync::LazyLock}; use crate::st2038anc_utils::AncDataHeader; -static CAT: Lazy = Lazy::new(|| { +static CAT: LazyLock = LazyLock::new(|| { gst::DebugCategory::new( "st2038ancdemux", gst::DebugColorFlags::empty(), @@ -325,7 +322,7 @@ impl GstObjectImpl for St2038AncDemux {} impl ElementImpl for St2038AncDemux { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { - static ELEMENT_METADATA: Lazy = Lazy::new(|| { + static ELEMENT_METADATA: LazyLock = LazyLock::new(|| { gst::subclass::ElementMetadata::new( "SMPTE ST-2038 ancillary metadata demuxer", "Metadata/Video/Demuxer", @@ -338,7 +335,7 @@ impl ElementImpl for St2038AncDemux { } fn pad_templates() -> &'static [gst::PadTemplate] { - static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + static PAD_TEMPLATES: LazyLock> = LazyLock::new(|| { let caps = gst::Caps::builder("meta/x-st-2038").build(); let caps_aligned = gst::Caps::builder("meta/x-st-2038") .field("alignment", "packet") diff --git a/video/closedcaption/src/st2038ancmux/imp.rs b/video/closedcaption/src/st2038ancmux/imp.rs index 97fe7b91..6a7f89e6 100644 --- a/video/closedcaption/src/st2038ancmux/imp.rs +++ b/video/closedcaption/src/st2038ancmux/imp.rs @@ -6,9 +6,11 @@ // // SPDX-License-Identifier: MPL-2.0 -use std::collections::BTreeMap; -use std::ops::ControlFlow; -use std::sync::Mutex; +use std::{ + collections::BTreeMap, + ops::ControlFlow, + sync::{LazyLock, Mutex}, +}; use gst::glib; use gst::prelude::*; @@ -16,8 +18,6 @@ use gst::subclass::prelude::*; use gst_base::prelude::*; use gst_base::subclass::prelude::*; -use once_cell::sync::Lazy; - use crate::st2038anc_utils::AncDataHeader; #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] @@ -38,7 +38,7 @@ pub struct St2038AncMux { state: Mutex, } -pub(crate) static CAT: Lazy = Lazy::new(|| { +pub(crate) static CAT: LazyLock = LazyLock::new(|| { gst::DebugCategory::new( "st2038ancmux", gst::DebugColorFlags::empty(), @@ -572,7 +572,7 @@ impl AggregatorImpl for St2038AncMux { impl ElementImpl for St2038AncMux { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { - static ELEMENT_METADATA: Lazy = Lazy::new(|| { + static ELEMENT_METADATA: LazyLock = LazyLock::new(|| { gst::subclass::ElementMetadata::new( "ST2038 Anc Mux", "Muxer", @@ -585,7 +585,7 @@ impl ElementImpl for St2038AncMux { } fn pad_templates() -> &'static [gst::PadTemplate] { - static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + static PAD_TEMPLATES: LazyLock> = LazyLock::new(|| { let caps = gst::Caps::builder("meta/x-st-2038") .field("alignment", gst::List::new(["packet", "line"])) .build(); diff --git a/video/closedcaption/src/st2038anctocc/imp.rs b/video/closedcaption/src/st2038anctocc/imp.rs index c5c06c04..9fac6171 100644 --- a/video/closedcaption/src/st2038anctocc/imp.rs +++ b/video/closedcaption/src/st2038anctocc/imp.rs @@ -6,7 +6,7 @@ // // SPDX-License-Identifier: MPL-2.0 -use std::mem; +use std::{mem, sync::LazyLock}; use gst::glib; use gst::prelude::*; @@ -14,8 +14,6 @@ use gst::subclass::prelude::*; use atomic_refcell::AtomicRefCell; -use once_cell::sync::Lazy; - use crate::st2038anc_utils::AncDataHeader; #[derive(Default)] @@ -31,7 +29,7 @@ pub struct St2038AncToCc { state: AtomicRefCell, } -static CAT: Lazy = Lazy::new(|| { +static CAT: LazyLock = LazyLock::new(|| { gst::DebugCategory::new( "st2038anctocc", gst::DebugColorFlags::empty(), @@ -261,7 +259,7 @@ impl GstObjectImpl for St2038AncToCc {} impl ElementImpl for St2038AncToCc { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { - static ELEMENT_METADATA: Lazy = Lazy::new(|| { + static ELEMENT_METADATA: LazyLock = LazyLock::new(|| { gst::subclass::ElementMetadata::new( "ST-2038 ANC to CC", "Generic", @@ -274,7 +272,7 @@ impl ElementImpl for St2038AncToCc { } fn pad_templates() -> &'static [gst::PadTemplate] { - static PAD_TEMPLATES: Lazy> = Lazy::new(|| { + static PAD_TEMPLATES: LazyLock> = LazyLock::new(|| { let src_cea608_pad_template = gst::PadTemplate::new( "src_cea608", gst::PadDirection::Src,