1use mpeg_ts::ts::{SectionReassembler, TsPacket};
9
10const PAT_PACKET: [u8; 188] = [
13 0x47, 0x40, 0x00, 0x10, 0x00, 0x00, 0xb0, 0x0d, 0x00, 0x01, 0xc1, 0x00, 0x00, 0x04, 0x01, 0xe0,
14 0x64, 0xf9, 0xb4, 0x63, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
15 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
16 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
17 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
18 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
19 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
20 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
21 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
22 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
23 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
25];
26
27fn main() {
28 let pkt = TsPacket::parse(&PAT_PACKET).expect("hardcoded packet must parse");
29 println!(
30 "TS packet: pid=0x{:04X} pusi={} has_payload={}",
31 pkt.header.pid, pkt.header.pusi, pkt.header.has_payload
32 );
33
34 let mut reasm = SectionReassembler::default();
35
36 if let Some(payload) = pkt.payload {
37 reasm.feed(payload, pkt.header.pusi);
38 }
39
40 while let Some(section) = reasm.pop_section() {
41 println!(
42 "section: {} bytes, table_id=0x{:02X}",
43 section.len(),
44 section[0]
45 );
46 if section.len() >= 5 {
48 let ts_id = u16::from_be_bytes([section[3], section[4]]);
49 println!(" transport_stream_id={}", ts_id);
50 }
51 }
52}