ziutek / dvb

DVB/MPEG-TS library (pure Go)
BSD 3-Clause "New" or "Revised" License
99 stars 17 forks source link

PSI table examples #3

Closed zignig closed 8 years ago

zignig commented 8 years ago

Is it possible to get an example for decoding tables ?

I have some ts streams that I am trying to the the PAT , PMT out.

ts.NewPacketReader -> get PID 0 -> PktQueue -> SectionDecoder -> tables.

ziutek commented 8 years ago

I have no time to write and test one now. If you have working section decoder d (i.e. you can read sections from it) try this:

var pat psi.PAT
checkErr(pat.Update(d, true))
pl := pat.ProgramList()
for !pl.IsEmpty() {
    sid, pmtpid, pl := pl.Pop()
    // ...
}

PMT table is always one section so if you can read sections from decoder simply use:

pmt = PMT(s)

to access it.

I'm not entirely satisfied with the current API for handling tables, but I use this code in production and it works well.

ziutek commented 8 years ago

Better way for PMT:

pmt, err = psi.AsPMT(s)
zignig commented 8 years ago

Thanks for your reply,

I understand how you use the (item,remaining list ... ) construct now :).

And thanks for a cool DVB lib.

Simon