asticode / go-astits

Demux and mux MPEG Transport Streams (.ts) natively in GO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

demuxer.NextData returns (nil, nil) on unknown data types

tmm1 opened this issue · comments

This was a bit unexpected and I'm not sure if it was the desired/designed behavior?

I would have expected perhaps to receive a special error for unknown data, or simply have it skipped.

For example, SCTE35 tables are not understood and so this returns (nil, nil):

func TestDemuxerNextDataSCTE35(t *testing.T) {
	scte35 := hexToBytes(`4741f61900fc302500000003289800fff01405000002547fefff4fc614f8
fe00a4e9f50000000000000c1324f6ffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffff`)
	r := bytes.NewReader(scte35)
	assert.Equal(t, 188, r.Len())

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

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

Similar behavior is also seen on #25 for PMT tables other than program_map

Just realized that this is fixed by #32