mirror of https://bitbucket.org/ausocean/av.git
mts/mpegts.go: FindPMT now also returns index
This commit is contained in:
parent
1ec23badcc
commit
ba209a1d7c
|
@ -129,18 +129,18 @@ type Packet struct {
|
|||
|
||||
// FindPMT will take a clip of mpegts and try to find a PMT table - if one
|
||||
// is found, then it is returned, otherwise nil and an error is returned.
|
||||
func FindPMT(d []byte) (p []byte, err error) {
|
||||
func FindPMT(d []byte) (p []byte, i int, err error) {
|
||||
if len(d) < PacketSize {
|
||||
return nil, errors.New("Mmpegts data not of valid length")
|
||||
return nil, -1, errors.New("Mmpegts data not of valid length")
|
||||
}
|
||||
for i := 0; i < len(d); i += PacketSize {
|
||||
for i = 0; i < len(d); i += PacketSize {
|
||||
pid := (uint16(d[i+1]&0x1f) << 8) | uint16(d[i+2])
|
||||
if pid == pmtPid {
|
||||
p = d[i+4 : i+PacketSize]
|
||||
return
|
||||
}
|
||||
}
|
||||
return nil, errors.New("Could not find pmt table in mpegts data")
|
||||
return nil, -1, errors.New("Could not find pmt table in mpegts data")
|
||||
}
|
||||
|
||||
// FillPayload takes a channel and fills the packets Payload field until the
|
||||
|
|
Loading…
Reference in New Issue