closedcaption: Switch from once_cell to std for new ST2038 elements

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1777>
This commit is contained in:
Sebastian Dröge 2024-10-22 16:24:15 +03:00 committed by GStreamer Marge Bot
parent 5864a1368f
commit 91b61ac12f
4 changed files with 21 additions and 28 deletions

View file

@ -6,7 +6,7 @@
// //
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use std::sync::Mutex; use std::sync::{LazyLock, Mutex};
use gst::glib; use gst::glib;
use gst::prelude::*; use gst::prelude::*;
@ -14,8 +14,6 @@ use gst::subclass::prelude::*;
use atomic_refcell::AtomicRefCell; use atomic_refcell::AtomicRefCell;
use once_cell::sync::Lazy;
use crate::st2038anc_utils::convert_to_st2038_buffer; use crate::st2038anc_utils::convert_to_st2038_buffer;
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
@ -54,7 +52,7 @@ pub struct CcToSt2038Anc {
settings: Mutex<Settings>, settings: Mutex<Settings>,
} }
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new( gst::DebugCategory::new(
"cctost2038anc", "cctost2038anc",
gst::DebugColorFlags::empty(), gst::DebugColorFlags::empty(),
@ -197,7 +195,7 @@ impl ObjectSubclass for CcToSt2038Anc {
impl ObjectImpl for CcToSt2038Anc { impl ObjectImpl for CcToSt2038Anc {
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![
glib::ParamSpecBoolean::builder("c-not-y-channel") glib::ParamSpecBoolean::builder("c-not-y-channel")
.nick("Y Not C Channel") .nick("Y Not C Channel")
@ -278,7 +276,7 @@ impl GstObjectImpl for CcToSt2038Anc {}
impl ElementImpl for CcToSt2038Anc { impl ElementImpl for CcToSt2038Anc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: LazyLock<gst::subclass::ElementMetadata> = LazyLock::new(|| {
gst::subclass::ElementMetadata::new( gst::subclass::ElementMetadata::new(
"CC to ST-2038 ANC", "CC to ST-2038 ANC",
"Generic", "Generic",
@ -291,7 +289,7 @@ impl ElementImpl for CcToSt2038Anc {
} }
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: LazyLock<Vec<gst::PadTemplate>> = LazyLock::new(|| {
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -15,14 +15,11 @@ use gst_base::UniqueFlowCombiner;
use atomic_refcell::AtomicRefCell; use atomic_refcell::AtomicRefCell;
use once_cell::sync::Lazy; use std::{collections::HashMap, mem, sync::LazyLock};
use std::collections::HashMap;
use std::mem;
use crate::st2038anc_utils::AncDataHeader; use crate::st2038anc_utils::AncDataHeader;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new( gst::DebugCategory::new(
"st2038ancdemux", "st2038ancdemux",
gst::DebugColorFlags::empty(), gst::DebugColorFlags::empty(),
@ -325,7 +322,7 @@ impl GstObjectImpl for St2038AncDemux {}
impl ElementImpl for St2038AncDemux { impl ElementImpl for St2038AncDemux {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: LazyLock<gst::subclass::ElementMetadata> = LazyLock::new(|| {
gst::subclass::ElementMetadata::new( gst::subclass::ElementMetadata::new(
"SMPTE ST-2038 ancillary metadata demuxer", "SMPTE ST-2038 ancillary metadata demuxer",
"Metadata/Video/Demuxer", "Metadata/Video/Demuxer",
@ -338,7 +335,7 @@ impl ElementImpl for St2038AncDemux {
} }
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: LazyLock<Vec<gst::PadTemplate>> = LazyLock::new(|| {
let caps = gst::Caps::builder("meta/x-st-2038").build(); let caps = gst::Caps::builder("meta/x-st-2038").build();
let caps_aligned = gst::Caps::builder("meta/x-st-2038") let caps_aligned = gst::Caps::builder("meta/x-st-2038")
.field("alignment", "packet") .field("alignment", "packet")

View file

@ -6,9 +6,11 @@
// //
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use std::collections::BTreeMap; use std::{
use std::ops::ControlFlow; collections::BTreeMap,
use std::sync::Mutex; ops::ControlFlow,
sync::{LazyLock, Mutex},
};
use gst::glib; use gst::glib;
use gst::prelude::*; use gst::prelude::*;
@ -16,8 +18,6 @@ use gst::subclass::prelude::*;
use gst_base::prelude::*; use gst_base::prelude::*;
use gst_base::subclass::prelude::*; use gst_base::subclass::prelude::*;
use once_cell::sync::Lazy;
use crate::st2038anc_utils::AncDataHeader; use crate::st2038anc_utils::AncDataHeader;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
@ -38,7 +38,7 @@ pub struct St2038AncMux {
state: Mutex<State>, state: Mutex<State>,
} }
pub(crate) static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { pub(crate) static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new( gst::DebugCategory::new(
"st2038ancmux", "st2038ancmux",
gst::DebugColorFlags::empty(), gst::DebugColorFlags::empty(),
@ -572,7 +572,7 @@ impl AggregatorImpl for St2038AncMux {
impl ElementImpl for St2038AncMux { impl ElementImpl for St2038AncMux {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: LazyLock<gst::subclass::ElementMetadata> = LazyLock::new(|| {
gst::subclass::ElementMetadata::new( gst::subclass::ElementMetadata::new(
"ST2038 Anc Mux", "ST2038 Anc Mux",
"Muxer", "Muxer",
@ -585,7 +585,7 @@ impl ElementImpl for St2038AncMux {
} }
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: LazyLock<Vec<gst::PadTemplate>> = LazyLock::new(|| {
let caps = gst::Caps::builder("meta/x-st-2038") let caps = gst::Caps::builder("meta/x-st-2038")
.field("alignment", gst::List::new(["packet", "line"])) .field("alignment", gst::List::new(["packet", "line"]))
.build(); .build();

View file

@ -6,7 +6,7 @@
// //
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use std::mem; use std::{mem, sync::LazyLock};
use gst::glib; use gst::glib;
use gst::prelude::*; use gst::prelude::*;
@ -14,8 +14,6 @@ use gst::subclass::prelude::*;
use atomic_refcell::AtomicRefCell; use atomic_refcell::AtomicRefCell;
use once_cell::sync::Lazy;
use crate::st2038anc_utils::AncDataHeader; use crate::st2038anc_utils::AncDataHeader;
#[derive(Default)] #[derive(Default)]
@ -31,7 +29,7 @@ pub struct St2038AncToCc {
state: AtomicRefCell<State>, state: AtomicRefCell<State>,
} }
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new( gst::DebugCategory::new(
"st2038anctocc", "st2038anctocc",
gst::DebugColorFlags::empty(), gst::DebugColorFlags::empty(),
@ -261,7 +259,7 @@ impl GstObjectImpl for St2038AncToCc {}
impl ElementImpl for St2038AncToCc { impl ElementImpl for St2038AncToCc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: LazyLock<gst::subclass::ElementMetadata> = LazyLock::new(|| {
gst::subclass::ElementMetadata::new( gst::subclass::ElementMetadata::new(
"ST-2038 ANC to CC", "ST-2038 ANC to CC",
"Generic", "Generic",
@ -274,7 +272,7 @@ impl ElementImpl for St2038AncToCc {
} }
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: LazyLock<Vec<gst::PadTemplate>> = LazyLock::new(|| {
let src_cea608_pad_template = gst::PadTemplate::new( let src_cea608_pad_template = gst::PadTemplate::new(
"src_cea608", "src_cea608",
gst::PadDirection::Src, gst::PadDirection::Src,