Skip to content

Commit

Permalink
psi: ReadPMT skips over packets without a program map table (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 authored and Guy J Grigsby committed Jun 15, 2018
1 parent 81aae44 commit 2ca0dae
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions psi/pmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ func ReadPMT(r io.Reader, pid uint16) (PMT, error) {
if err != nil {
return nil, err
}
if len(pmt.Pids()) == 0 {
done = false
pmtAcc = packet.NewAccumulator(PmtAccumulatorDoneFunc)
}
}
}
return pmt, nil
Expand Down
29 changes: 29 additions & 0 deletions psi/pmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ func TestReadPMTForSmoke(t *testing.T) {
pmt, err := ReadPMT(r, pid)
if err != nil {
t.Errorf("Unexpected error reading PMT: %v", err)
return
}
// sanity check (tests integration a bit)
if len(pmt.ElementaryStreams()) != 2 {
Expand All @@ -703,6 +704,34 @@ func TestReadPMTIncomplete(t *testing.T) {
}
}

func TestReadPMTSCTE(t *testing.T) {
bs, _ := hex.DecodeString("47403b1b00c0001500000100810000000000000100000000002f832c69ff" +
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" +
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" +
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" +
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" +
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" +
"ffffffffffffffff47403b1c0002b0b20001cb0000f13df01809044749e1" +
"0b050441432d330504454143330504435545491bf13df0102a027e1f9700" +
"e9080c001f418507d04181f13ef00f810706380fff1f003f0a04656e6700" +
"81f13ff00f8107061003ff1f003f0a047370610086f140f00f8a01009700" +
"e9080c001f418507d041c0f141f012050445545631a100e9080c001f4185" +
"07d041c0f142f013050445545631a20100e9080c001f418507d041c0f164" +
"f008bf06496e766964690bcfa64bffff") // two PMT packets, first with SCTE 0xc0 table only
r := bytes.NewReader(bs)

pid := uint16(59)
pmt, err := ReadPMT(r, pid)
if err != nil {
t.Errorf("Unexpected error reading PMT: %v", err)
return
}
// sanity check (tests integration a bit)
if len(pmt.ElementaryStreams()) != 7 {
t.Errorf("PMT read is invalid, did not have expected number of streams")
}
}

func TestIsDolbyATMOS(t *testing.T) {
d, _ := hex.DecodeString("00ff")
desc := &pmtDescriptor{tag: uint8(204), data: d}
Expand Down

0 comments on commit 2ca0dae

Please sign in to comment.