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
//! PCR-discontinuity detection (#562) — a standalone analysis pass over a
//! buffer of concatenated 188-byte TS packets.
//!
//! [`detect_pcr_discontinuities`] finds every PCR jump on every PCR-bearing
//! PID and classifies each one as:
//!
//! - **flagged** — the packet carrying the post-break PCR has
//! `discontinuity_indicator == 1` (ISO/IEC 13818-1 §2.4.3.5): a legal
//! system-time-base change.
//! - **unflagged** — the jump exceeds the ETSI TR 101 290 v1.4.1 §5.2.2
//! Table 5.0b indicator 2.3b (`PCR_discontinuity_indicator_error`)
//! threshold with no `discontinuity_indicator` set: a genuine defect. The
//! 2.3b check is reused verbatim from
//! [`dvb_conformance::ConformanceMonitor`] — the 100 ms threshold is never
//! re-derived in this crate.
//!
//! This is a read-only query, independent of the repair operations
//! ([`crate::TsFixBuilder::restamp_pcr`] / `.honor_pcr_discontinuity()`) —
//! useful for auditing a stream before deciding how (or whether) to repair
//! it. The repair ops perform the same classification internally as they
//! stream packets through.
use Vec;
use ;
use cratePcrDiscDetector;
/// One detected PCR discontinuity.
///
/// `#[non_exhaustive]` — future fields (e.g. the measured delta) may be added
/// without a breaking change.
/// Scan `ts_bytes` (concatenated 188-byte TS packets) for PCR discontinuities
/// on every PCR-bearing PID.
///
/// Trailing bytes that do not form a complete 188-byte packet are ignored.
///
/// # Example
///
/// ```rust,no_run
/// use ts_fix::discontinuity::detect_pcr_discontinuities;
///
/// let bytes = std::fs::read("capture.ts").unwrap();
/// for d in detect_pcr_discontinuities(&bytes) {
/// if !d.flagged {
/// println!(
/// "unflagged PCR break on PID 0x{:04X} at packet {}",
/// d.pid, d.packet_index
/// );
/// }
/// }
/// ```
///
/// # Spec
///
/// ISO/IEC 13818-1 (= ITU-T H.222.0) §2.4.3.5; ETSI TR 101 290 v1.4.1 §5.2.2,
/// Table 5.0b, indicator 2.3b.