Skip to main content

Cea608CueExtractor

Struct Cea608CueExtractor 

Source
pub struct Cea608CueExtractor { /* private fields */ }
Available on crate feature cc-data only.
Expand description

Extracts Cues from a single CEA-608 data channel (CTA-608-E), wrapping a cc-data cc_data::decode::Cea608Decoder.

Feed it one access unit’s CEA-608 triplets at a time, tagged with that access unit’s raw (non-unrolled) 33-bit PTS, via push_frame; call finalize at end of stream to close any still-open cue.

use timed_metadata::webvtt::Cea608CueExtractor;
use cc_data::{CcTriplet, CcType};
use cc_data::decode::Cea608Channel;

fn pair(pts: u64, b1: u8, b2: u8) -> (u64, CcTriplet) {
    (
        pts,
        CcTriplet { cc_valid: true, cc_type: CcType::Ntsc608Field1, cc_data_1: b1, cc_data_2: b2 },
    )
}

let mut ex = Cea608CueExtractor::new(Cea608Channel::Cc1);
let frames = [
    pair(0, 0x14, 0x20),       // RCL
    pair(1, 0x14, 0x70),       // PAC row 15
    pair(2, b'H', b'I'),       // "HI"
    pair(3, 0x14, 0x2F),       // EOC -> commits "HI"
    pair(4, 0x14, 0x2C),       // EDM -> erases
];
for (pts, t) in frames {
    ex.push_frame(pts, core::slice::from_ref(&t));
}
let cues = ex.cues();
assert_eq!(cues.len(), 1);
assert_eq!(cues[0].text, "HI");

Implementations§

Source§

impl Cea608CueExtractor

Source

pub fn new(channel: Cea608Channel) -> Self

A new extractor tracking the given CEA-608 data channel (e.g. Cc1).

Source

pub fn push_frame(&mut self, pts33: u64, triplets: &[CcTriplet])

Feed one access unit’s CEA-608 triplets (already demuxed from its cc_data()), tagged with that access unit’s raw 33-bit PTS. Non-608 triplets in triplets are ignored.

Source

pub fn finalize(&mut self, end_pts33: u64)

Close any still-open cue at end of stream, at end_pts33.

Source

pub fn cues(&self) -> &[Cue]

The cues extracted so far, in order.

Source

pub fn into_cues(self) -> Vec<Cue>

Consume the extractor, returning the extracted cues.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.