I'm writing a MPEG-TS file parser and I'm stuck on getting program_numbers and PIDs from the PAT section. I'm using a packet analyser to compare my results.
For example, here's a PAT packet
47 40 00 16 00 00 B0 31 00 14 D7 00 00 00 00 E0
10 00 01 E0 24 00 02 E0 25 00 03 E0 30 00 04 E0
31 00 1A E0 67 00 1C E0 6F 43 9D E3 F1 43 A3 E3
F7 43 AC E4 00 C3 69 A6 D8 FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF
First I began comparing the analyser's results to the bytes to see the connection. It paired bytes in the following way: [00 10][01 24][02 25][03 30] etc. I noticed a pattern (for i = 14; i < end; i+=4) but that quickly turned wrong because after the "0x6F" byte it started reading 16 bits, not 8, so the program_number was 0x439D.
I'm seriously confused and I hope that someone can explain to me how to parse the example PAT from above.