Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demuxer fails to parse complex PMT with multiple tables #25

Open
tmm1 opened this issue Apr 6, 2021 · 0 comments
Open

demuxer fails to parse complex PMT with multiple tables #25

tmm1 opened this issue Apr 6, 2021 · 0 comments

Comments

@tmm1
Copy link
Contributor

tmm1 commented Apr 6, 2021

The PMT in https://s3.amazonaws.com/tmm1/combined-pmt-tids.ts cannot be parsed by go-astits.

For reference, see my fixes for the same bug in ffmpeg and in gots

(FYI this contains another variant where some PMT payloads don't contain the program map table).

func TestDemuxerNextDataPMTMutipleTables(t *testing.T) {
	// pmt with two tables in one packet, with 0xc0 preceeding the 0x2 program map
	pmt := hexToBytes(`47403b1e00c000150000010061000000000000010000000045491be065
f0050e030004b00fe066f0060a04656e670086e06ef0007f
c9ad32ffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffff`)
	r := bytes.NewReader(pmt)
	assert.Equal(t, 188, 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 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)
}
@tmm1 tmm1 changed the title demuxer fails to parse complex PMT spanning multiple packets demuxer fails to parse complex PMT with multiple tables Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant