From fb9b511e1508e8289b7018f8526bcba665930f79 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 3 Nov 2023 15:04:06 +1100 Subject: [PATCH] closedcaption: move 708 service writing to shared file Part-of: --- video/closedcaption/src/cea608tocea708/imp.rs | 4 +-- video/closedcaption/src/cea608tocea708/mod.rs | 1 - .../{cea608tocea708/fmt.rs => cea708utils.rs} | 32 +++++++++++-------- video/closedcaption/src/lib.rs | 1 + 4 files changed, 22 insertions(+), 16 deletions(-) rename video/closedcaption/src/{cea608tocea708/fmt.rs => cea708utils.rs} (89%) diff --git a/video/closedcaption/src/cea608tocea708/imp.rs b/video/closedcaption/src/cea608tocea708/imp.rs index f512dba5..414ea5cd 100644 --- a/video/closedcaption/src/cea608tocea708/imp.rs +++ b/video/closedcaption/src/cea608tocea708/imp.rs @@ -13,8 +13,8 @@ use gst::subclass::prelude::*; use atomic_refcell::AtomicRefCell; -use crate::cea608tocea708::fmt::Cea708ServiceWriter; use crate::cea608utils::*; +use crate::cea708utils::Cea708ServiceWriter; use gst::glib::once_cell::sync::Lazy; @@ -545,7 +545,7 @@ pub struct Cea608ToCea708 { state: AtomicRefCell, } -pub(crate) static CAT: Lazy = Lazy::new(|| { +static CAT: Lazy = Lazy::new(|| { gst::DebugCategory::new( "cea608tocea708", gst::DebugColorFlags::empty(), diff --git a/video/closedcaption/src/cea608tocea708/mod.rs b/video/closedcaption/src/cea608tocea708/mod.rs index 41d1e4a1..36ec1498 100644 --- a/video/closedcaption/src/cea608tocea708/mod.rs +++ b/video/closedcaption/src/cea608tocea708/mod.rs @@ -9,7 +9,6 @@ use gst::glib; use gst::prelude::*; -mod fmt; mod imp; glib::wrapper! { diff --git a/video/closedcaption/src/cea608tocea708/fmt.rs b/video/closedcaption/src/cea708utils.rs similarity index 89% rename from video/closedcaption/src/cea608tocea708/fmt.rs rename to video/closedcaption/src/cea708utils.rs index 0131a41d..a6071798 100644 --- a/video/closedcaption/src/cea608tocea708/fmt.rs +++ b/video/closedcaption/src/cea708utils.rs @@ -8,6 +8,16 @@ use cea708_types::{tables::*, Service}; +use gst::glib::once_cell::sync::Lazy; + +static CAT: Lazy = Lazy::new(|| { + gst::DebugCategory::new( + "cea708utils", + gst::DebugColorFlags::empty(), + Some("CEA-708 Utilities"), + ) +}); + #[derive(Debug)] pub enum WriteError { // returns the number of characters/bytes written @@ -42,7 +52,7 @@ impl Cea708ServiceWriter { } pub fn popon_preamble(&mut self) -> Result { - gst::trace!(super::imp::CAT, "popon_preamble"); + gst::trace!(CAT, "popon_preamble"); let window = match self.hidden_window { // switch up the newly defined window WindowBits::ZERO => 0, @@ -64,7 +74,7 @@ impl Cea708ServiceWriter { 1, 1, ); - gst::trace!(super::imp::CAT, "active window {:?}", self.active_window); + gst::trace!(CAT, "active window {:?}", self.active_window); let codes = [ Code::DeleteWindows(!self.active_window), Code::DefineWindow(args), @@ -73,30 +83,26 @@ impl Cea708ServiceWriter { } pub fn clear_current_window(&mut self) -> Result { - gst::trace!( - super::imp::CAT, - "clear_current_window {:?}", - self.active_window - ); + gst::trace!(CAT, "clear_current_window {:?}", self.active_window); self.push_codes(&[Code::ClearWindows(self.active_window)]) } pub fn clear_hidden_window(&mut self) -> Result { - gst::trace!(super::imp::CAT, "clear_hidden_window"); + gst::trace!(CAT, "clear_hidden_window"); self.push_codes(&[Code::ClearWindows(self.hidden_window)]) } pub fn end_of_caption(&mut self) -> Result { - gst::trace!(super::imp::CAT, "end_of_caption"); + gst::trace!(CAT, "end_of_caption"); let ret = self.push_codes(&[Code::ToggleWindows(self.active_window | self.hidden_window)])?; std::mem::swap(&mut self.active_window, &mut self.hidden_window); - gst::trace!(super::imp::CAT, "active window {:?}", self.active_window); + gst::trace!(CAT, "active window {:?}", self.active_window); Ok(ret) } pub fn paint_on_preamble(&mut self) -> Result { - gst::trace!(super::imp::CAT, "paint_on_preamble"); + gst::trace!(CAT, "paint_on_preamble"); let window = match self.active_window { WindowBits::ZERO => 0, WindowBits::ONE => 1, @@ -126,7 +132,7 @@ impl Cea708ServiceWriter { let base_row = std::cmp::max(rollup_count, base_row); let anchor_vertical = (base_row as u32 * 100 / 15) as u8; gst::trace!( - super::imp::CAT, + CAT, "rollup_preamble base {base_row} count {rollup_count}, anchor-v {anchor_vertical}" ); let codes = [ @@ -170,7 +176,7 @@ impl Cea708ServiceWriter { } for code in codes.iter() { gst::trace!( - super::imp::CAT, + CAT, "pushing for service:{} code: {code:?}", service.number() ); diff --git a/video/closedcaption/src/lib.rs b/video/closedcaption/src/lib.rs index 6fd22a6a..6b691d6d 100644 --- a/video/closedcaption/src/lib.rs +++ b/video/closedcaption/src/lib.rs @@ -30,6 +30,7 @@ mod cea608tocea708; mod cea608tojson; mod cea608tott; mod cea608utils; +mod cea708utils; mod jsontovtt; mod line_reader; mod mcc_enc;