Skip to main content

cc_data/
lib.rs

1//! Closed-caption `cc_data()` carriage (CEA-608/708), per ETSI TS 101 154 §B.5, Table B.9.
2//!
3//! Parses the closed-caption carriage structure carried in MPEG-2 / AVC / HEVC
4//! picture `user_data` (the DVB-native, normative form of the ATSC/CEA `cc_data()`).
5//! Exposes the typed caption triplets (`cc_valid`, `cc_type`, `cc_data_1/2`) and a
6//! CEA-608 vs CEA-708 split by `cc_type`.
7//!
8//! Feed it the `cc_data()` bytes (the caller extracts them from the picture
9//! user_data / SEI). Depends only on `dvb-common`, `#![no_std]` (+ `alloc`).
10//!
11//! # Caption decode (`decode` feature)
12//!
13//! With the default `decode` feature, this crate also *interprets* the demuxed
14//! caption byte pairs — the [`decode`] module's [`Cea608Decoder`](decode::Cea608Decoder)
15//! (line-21 pop-on / roll-up / paint-on, PACs, mid-row codes, the standard /
16//! special / extended character sets, channels CC1–CC4) and
17//! [`Cea708Decoder`](decode::Cea708Decoder) (DTVCC packet / service-block
18//! reassembly + the C0/C1/G0/G1/G2/G3 window / pen command interpreter, services
19//! 1–6) — and exposes the decoded caption screen / window text. Grounded in
20//! ANSI/CTA-608-E, ANSI/CTA-708-E and 47 CFR §79.102 (see `cc-data/docs/decode/`).
21#![no_std]
22#![cfg_attr(docsrs, feature(doc_cfg))]
23#![warn(missing_docs)]
24// Runnable examples, embedded so they render on docs.rs and stay in sync with
25// the actual `examples/*.rs` files (shown, not compiled).
26#![doc = "\n# Examples\n"]
27#![doc = "Runnable examples ship with this crate (`cargo run -p cc-data --example <name>`).\n"]
28#![doc = "\n## `parse_cc_data`\n\n```rust,ignore"]
29#![doc = include_str!("../examples/parse_cc_data.rs")]
30#![doc = "```\n\n## `build_cc_data`\n\n```rust,ignore"]
31#![doc = include_str!("../examples/build_cc_data.rs")]
32#![cfg_attr(
33    feature = "decode",
34    doc = "```\n\n## `decode_cea608`\n\n```rust,ignore"
35)]
36#![cfg_attr(feature = "decode", doc = include_str!("../examples/decode_cea608.rs"))]
37#![cfg_attr(
38    feature = "decode",
39    doc = "```\n\n## `decode_cea708`\n\n```rust,ignore"
40)]
41#![cfg_attr(feature = "decode", doc = include_str!("../examples/decode_cea708.rs"))]
42#![doc = "```"]
43
44extern crate alloc;
45
46mod cc_data;
47#[cfg(feature = "decode")]
48#[cfg_attr(docsrs, doc(cfg(feature = "decode")))]
49pub mod decode;
50mod error;
51
52pub use cc_data::{CcData, CcTriplet, CcType};
53pub use error::{Error, Result};