mpeg_ts/lib.rs
1//! MPEG-2 Transport Stream framing — ITU-T H.222.0 / ISO/IEC 13818-1.
2//!
3//! Parses and serializes the MPEG-TS packet layer: 188-byte TS packets,
4//! adaptation fields, PCR, PSI section reassembly and packetization, byte-stream
5//! resynchronisation, and a scheduler-mux for SI tables.
6//!
7//! # Primary types
8//!
9//! | Module | Type | Description |
10//! |---|---|---|
11//! | [`ts`] | [`ts::TsPacket`] | Zero-copy borrowed view of a 188-byte TS packet (ITU-T H.222.0 §2.4.3.2) |
12//! | [`owned`] | [`owned::OwnedTsPacket`] | Owned 188-byte TS packet — for queuing, cloning, and in-place mutation |
13//! | [`ts`] | [`ts::SectionReassembler`] | Per-PID PSI section assembly from TS payloads (§2.4.4) |
14//! | [`mux`] | [`mux::SectionPacketizer`] | Packetize PSI sections back into TS packets with correct CC and padding |
15//! | [`mux`] | [`mux::SiMux`] | Rate-scheduled SI table mux: upsert per-PID section sets, poll for TS packets |
16//! | [`resync`] | [`resync::TsResync`] | Byte-stream resynchroniser — recovers 188/204-byte packet alignment from raw bytes |
17//! | [`pid`] | [`pid::Pid`] | Typed 13-bit PID newtype with well-known constants |
18//! | [`section`] | [`section::Section`] | Generic PSI/SI section header parser (table_id, section_length, version, CRC) |
19//!
20//! # `no_std` + embedded
21//!
22//! `mpeg-ts` is `#![no_std]` + `alloc`. It runs on bare-metal targets with a
23//! heap (e.g. `thumbv7em-none-eabi`). Enable the `std` feature for
24//! `std::error::Error` impls.
25//!
26//! # Feature flags
27//!
28//! | Feature | Default | Description |
29//! |---|---|---|
30//! | `std` | yes | `std::error::Error` impls; disable for embedded |
31//! | `serde` | yes | `serde::Serialize` for packet/section types |
32//!
33//! # Spec
34//!
35//! - **ITU-T H.222.0** (= ISO/IEC 13818-1): §2.4.3.2 (TS packet), §2.4.3.3
36//! (adaptation field), §2.4.3.4 (PCR), §2.4.4 (PSI section).
37//! All wire layouts are cited by clause in the module-level doc comments.
38#![no_std]
39#![forbid(unsafe_code)]
40extern crate alloc;
41
42pub mod error;
43pub mod mux;
44pub mod owned;
45pub mod pid;
46pub mod pusi;
47pub mod resync;
48pub mod section;
49pub mod ts;
50
51pub use error::{Error, Result};
52pub use owned::OwnedTsPacket;
53pub use ts::{
54 AdaptationField, AdaptationFieldControl, AdaptationFieldExtension, Ltw, Pcr, ScramblingControl,
55 SeamlessSplice, TsHeader, TsPacket,
56};