Skip to main content

Crate ts_fix

Crate ts_fix 

Source
Expand description

MPEG-2 TS repair / remux — container-layer operations, no codec parsing.

ts-fix provides a builder-driven streaming engine that feeds 188-byte TS packets in and emits repaired packets out. Repair operations are opt-in via builder methods; the engine owns and enforces the canonical ordering.

§Operations

OperationBuilder methodWhat it does
Continuity repairrepair_continuityRenumber per-PID continuity counters (§2.4.3.3).
PID filter / service extractfilter_pidsKeep specified PIDs or extract a single programme by program_number.
PAT/PMT regenerationregen_psiRebuild PAT from observed PMT PIDs on flush.
PCR restamprestamp_pcrRecompute PCR values on the PCR PID (§2.4.3.5).
PCR-discontinuity honorhonor_pcr_discontinuitySet discontinuity_indicator on genuine, unflagged PCR breaks (TR 101 290 §5.2.2 2.3b) without rewriting values.
StuffingstuffingDrop null packets or pad to a target packet rate.

§Forward compatibility

The public API is designed so that adding a new repair operation in a future minor release is a purely additive change:

  • There is no public enum Operation (adding a variant is breaking).
  • There is no public trait Operation (locking the contract before all ops’ needs are known).
  • Operations are exposed exclusively through TsFixBuilder methods.
  • All configuration and error enums are #[non_exhaustive].

§Quick start

use ts_fix::{PcrRestamp, PidFilter, Stuffing, TsFix};

let mut engine = TsFix::builder()
    .repair_continuity()
    .filter_pids(PidFilter::keep([0x0100, 0x0101]))
    .regen_psi()
    .restamp_pcr(PcrRestamp::interpolate())
    .stuffing(Stuffing::drop_nulls())
    .build()
    .unwrap();

§Spec

ISO/IEC 13818-1 (= ITU-T H.222.0) — §2.4.3.2 (TS packet), §2.4.3.3 (adaptation field / continuity counter), §2.4.3.4 (PCR), §2.4.4 (PSI).

Re-exports§

pub use error::Error;

Modules§

discontinuity
PCR-discontinuity detection (#562) — a standalone analysis pass over a buffer of concatenated 188-byte TS packets.
error
Error type for the ts-fix crate.
pes
PES access-unit reconstruction from TS payloads — framing only, no codec bitstream parsing (ISO/IEC 13818-1 §2.4.3.6).

Structs§

TsFix
A repair / remux engine for MPEG-2 TS byte streams.
TsFixBuilder
Builder for TsFix.

Enums§

PcrRestamp
PCR restamp mode.
PidFilter
Configuration for TsFixBuilder::filter_pids.
Stuffing
Configuration for TsFixBuilder::stuffing.