1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! Internal operation abstraction — NOT part of the public API.
//!
//! The public API surfaces operations exclusively through [`crate::TsFixBuilder`]
//! builder methods (e.g. `repair_continuity()`, `filter_pids()`, …). There is
//! intentionally **no** public `enum Operation` or `trait Operation` — adding a new
//! operation in v0.2/v0.3 is a purely additive builder-method change and can never
//! cause a breaking change for callers who pattern-match on a public Operation enum.
//!
//! # Extension contract
//!
//! To add a new operation:
//! 1. Create `ops/<name>.rs` and implement `Op` for a private struct.
//! 2. Add a builder method to [`crate::TsFixBuilder`] that pushes the boxed op.
//! 3. Register the op in [`crate::engine`]'s fixed ordering table if it has a
//! positional relationship with existing ops.
//!
//! No existing public signatures change.
use Box;
pub
pub
pub
pub
pub
pub
pub
/// Observable state built up as the engine processes packets.
///
/// Repair operations receive a shared `&mut StreamModel` reference on every
/// `process` call. v0.1 is a stub; later tasks add PAT/PMT programme state,
/// PID set, and the [`TimingContext`].
pub
// — TimingContext ───────────────────────────────────────────────────────────
/// Forward-compat timing model for TS-level clock reconstruction.
///
/// Holds the 27 MHz clock state and last-anchor information needed by PCR
/// restamp (v0.1) and, in v0.2+, PTS/DTS wrap-around repair.
///
/// # Design rationale
///
/// This is deliberately NOT PCR-specific — it lives in `StreamModel` and stores
/// the stream's 27 MHz clock model. v0.2's PTS/DTS-wrap op will read and
/// update the same context to unroll 33-bit wrap on presentation timestamps
/// without duplicating clock state.
///
/// PCR-specific configuration (mode, target bitrate) lives in
/// [`super::pcr_restamp::PcrRestamp`], not here.
pub
/// Private operation trait — sealed inside this module.
///
/// `process` is called once per incoming packet. The op may:
/// - emit the packet unchanged (identity / pass-through),
/// - emit a modified copy,
/// - suppress the packet entirely (return without calling `out`), or
/// - emit additional packets (e.g. null stuffing).
///
/// `flush` is called once at end-of-stream; the op may emit buffered output.
///
/// # Why `alloc::vec::Vec<u8>` rather than `&[u8]`?
///
/// Packet mutation (CC renumbering, PCR restamping) requires an owned buffer.
/// Passing `[u8; 188]` by value would fix the size at the trait boundary, which
/// would prevent future PES-level ops that need to reassemble across packets.
/// Using `Vec<u8>` keeps the boundary general while remaining cheap (each call
/// pushes at most a handful of 188-byte chunks).
pub
/// A boxed, heap-allocated operation. The engine holds an ordered `Vec<BoxedOp>`.
pub type BoxedOp = ;
/// Canonical operation-kind discriminant used by the builder to enforce
/// engine ordering (filter → regen_psi → cc_repair → pcr_restamp/pcr_honor →
/// stuffing).
pub
// ── Identity pass-through (the v0.1 no-op) ──────────────────────────────────
/// Identity operation: forwards every packet unchanged and emits nothing on flush.
///
/// Used by the engine when no ops have been registered so that `TsFix` built
/// with `TsFixBuilder::build()` is a pure pass-through. This also serves as a
/// reference implementation for the `Op` trait.
pub ;