Skip to main content

Crate dvb_si

Crate dvb_si 

Source
Expand description

ETSI EN 300 468 v1.19.1 DVB Service Information parser and builder.

dvb-si turns a raw MPEG-TS into typed, decoded DVB tables: feed packets in, get back PAT/PMT/SDT/EIT/… structs whose text fields decode to UTF-8 and whose descriptor loops walk into typed descriptors. Every layout is cited to the ETSI spec and round-trip tested; the same types serialize back to bytes.

§30-second quickstart

Build a demux::SiDemux, feed it TS packets, match on tables::AnyTable, walk the descriptor loop with descriptors::DescriptorLoop::iter, and print decoded text via text::DvbText::decode:

use dvb_si::demux::SiDemux;
use dvb_si::descriptors::AnyDescriptor;
use dvb_si::tables::AnyTable;

let mut demux = SiDemux::builder().build();

// In real code, `packet` is each aligned 188-byte packet from your TS source
// (file, UDP, tuner). Here we hand-build one PAT packet to keep the doctest
// self-contained — see `examples/si_dump.rs` for the file-reading loop.
for event in demux.feed(&packet) {
    match event.table() {
        Ok(AnyTable::Sdt(sdt)) => {
            for service in &sdt.services {
                for item in service.descriptors.iter().flatten() {
                    if let AnyDescriptor::Service(svc) = item {
                        // DvbText decodes EN 300 468 Annex A → UTF-8.
                        println!("service: {}", svc.service_name.decode());
                    }
                }
            }
        }
        Ok(AnyTable::Pat(pat)) => {
            println!("PAT v{} on {}", event.version().unwrap_or(0), event.pid());
            assert_eq!(pat.entries.len(), 1);
        }
        Ok(other) => { let _ = other; }
        Err(_) => {} // malformed section
    }
}

§Layer map

TS packets ─▶ demux::SiDemux ─▶ SectionEvent
                                   │ .table()
                                   ▼
                             tables::AnyTable  (PAT, PMT, SDT, EIT, …)
                                   │ table.<loop field> : &[u8]
                                   ▼
                         descriptors::parse_loop ─▶ AnyDescriptor
                                   │ field : DvbText / LangCode
                                   ▼
                             text::DvbText::decode() ─▶ UTF-8 String

Each layer is independently usable: a caller who already has complete section bytes can skip demux and call tables::AnyTable::parse directly; a caller with a bare descriptor loop can call descriptors::parse_loop on it.

§Features

FeatureDefaultEnables
chronoonMJD + BCD time fields decode to chrono::DateTime<Utc> (EIT start_time(), TDT/TOT). Off → raw bytes.
tsondemux::SiDemux, ts::SectionReassembler, TS packet parsing. Off → bring your own complete section bytes.
serdeonSerialize-only — for display/export (JSON via serde_json); parsing FROM JSON is deliberately unsupported, re-parse from wire bytes. Serialize on every table/descriptor; text::DvbText serializes as its decoded UTF-8 string (camelCase JSON).
yokeoffyoke::Yokeable on every zero-copy view type + the owned::Owned wrapper — own a parsed view past the input buffer’s borrow (store/cache/send across threads) without re-parsing or a mirror type.
dvb-si = { version = "3.1", default-features = false }  # tight, no_std-ish build

§Entry points

See the crate README and docs/ for the structured spec reference, and MIGRATION-2.0.md for the 1.x → 2.0 upgrade guide.

Re-exports§

pub use descriptor_tag::DescriptorTag;
pub use error::Error;
pub use error::Result;
pub use table_id::TableId;

Modules§

carousel
DSM-CC data-carousel download protocol — ISO/IEC 13818-6 §7.2/§7.3 as profiled by DVB (TR 101 202 §4.6/§4.7.5, TS 102 006 SSU, TS 102 809).
demux
SiDemux — PID-filtered, version-gated SI section pump.
descriptor_tag
DescriptorTag enum — typed descriptor tag byte values.
descriptors
DVB + MPEG-2 descriptors. Each descriptor tag gets its own submodule file.
error
Error type returned by every parser in this crate.
owned
Own a parsed view past the input buffer’s borrow (feature yoke).
pid
Reserved DVB/MPEG-2 PIDs.
section
Generic PSI/SI section framing — ETSI EN 300 468 §5.1.1.
table_id
TableId enum — typed table_id byte values.
tables
SI + PSI tables.
text
DVB-SI text decoding — ETSI EN 300 468 Annex A.
traits
SI-specific traits. Parse / Serialize are provided by dvb_common and imported directly at call sites.
ts
MPEG-TS packet parser + section reassembler. Feature-gated under ts.