mirror of https://bitbucket.org/ausocean/av.git
Fix IndexPid.
This commit is contained in:
parent
4b57407e36
commit
c8a0b7df07
|
@ -221,7 +221,7 @@ func LastPid(d []byte, pid uint16) (pkt []byte, i int, err error) {
|
|||
// along with optional metadata if present. Commonly used to find a
|
||||
// PAT immediately followed by a PMT.
|
||||
func IndexPid(d []byte, pids ...uint16) (idx int, m map[string]string, err error) {
|
||||
prev := 0
|
||||
idx = -1
|
||||
for _, pid := range pids {
|
||||
pkt, i, _err := FindPid(d, pid)
|
||||
if err != nil {
|
||||
|
@ -231,16 +231,13 @@ func IndexPid(d []byte, pids ...uint16) (idx int, m map[string]string, err error
|
|||
if pid == PmtPid {
|
||||
m, _ = metaFromPMT(pkt)
|
||||
}
|
||||
if prev == 0 {
|
||||
if idx == -1 {
|
||||
idx = i
|
||||
prev = i
|
||||
continue
|
||||
}
|
||||
if i != prev+PacketSize {
|
||||
} else if i != 0 {
|
||||
err = errors.New("PIDs not consecutive")
|
||||
return
|
||||
}
|
||||
prev = i
|
||||
d = d[i+PacketSize:]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue