Skip to content

Commit

Permalink
add higher level test to ensure PMT is parsed out as well
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Apr 7, 2021
1 parent d0a1f65 commit 64c4e19
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions demuxer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,37 @@ func TestDemuxerNextData(t *testing.T) {
assert.EqualError(t, err, ErrNoMorePackets.Error())
}

func TestDemuxerNextDataPMTComplex(t *testing.T) {
// complex pmt with two tables (0xc0 and 0x2) split across two packets
pmt := hexToBytes(`47403b1e00c0001500000100610000000000000100000000
0035e3e2d702b0b20001c50000eefdf01809044749e10b05
0441432d330504454143330504435545491beefdf0102a02
7e1f9700e9080c001f418507d04181eefef00f810706380f
ff1f003f0a04656e670081eefff00f8107061003ff1f003f
0a047370610086ef00f00f8a01009700e9080c001f418507
d041c0ef01f012050445545631a100e9080c001f418507d0
41c0ef02f013050445545631a20100e9080c001f47003b1f
418507d041c0ef03f008bf06496e76696469a5cff3afffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffff`)
r := bytes.NewReader(pmt)
assert.Equal(t, 188*2, r.Len())

dmx := NewDemuxer(context.Background(), r, DemuxerOptPacketSize(188))
dmx.programMap.set(59, 1)

d, err := dmx.NextData()
assert.NoError(t, err)
assert.NotNil(t, d)
assert.Equal(t, uint16(59), d.FirstPacket.Header.PID)
assert.NotNil(t, d.PMT)
}

func TestDemuxerRewind(t *testing.T) {
r := bytes.NewReader([]byte("content"))
dmx := NewDemuxer(context.Background(), r)
Expand Down

0 comments on commit 64c4e19

Please sign in to comment.