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
|
// along with optional metadata if present. Commonly used to find a
|
||||||
// PAT immediately followed by a PMT.
|
// PAT immediately followed by a PMT.
|
||||||
func IndexPid(d []byte, pids ...uint16) (idx int, m map[string]string, err error) {
|
func IndexPid(d []byte, pids ...uint16) (idx int, m map[string]string, err error) {
|
||||||
prev := 0
|
idx = -1
|
||||||
for _, pid := range pids {
|
for _, pid := range pids {
|
||||||
pkt, i, _err := FindPid(d, pid)
|
pkt, i, _err := FindPid(d, pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -231,16 +231,13 @@ func IndexPid(d []byte, pids ...uint16) (idx int, m map[string]string, err error
|
||||||
if pid == PmtPid {
|
if pid == PmtPid {
|
||||||
m, _ = metaFromPMT(pkt)
|
m, _ = metaFromPMT(pkt)
|
||||||
}
|
}
|
||||||
if prev == 0 {
|
if idx == -1 {
|
||||||
idx = i
|
idx = i
|
||||||
prev = i
|
} else if i != 0 {
|
||||||
continue
|
|
||||||
}
|
|
||||||
if i != prev+PacketSize {
|
|
||||||
err = errors.New("PIDs not consecutive")
|
err = errors.New("PIDs not consecutive")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
prev = i
|
d = d[i+PacketSize:]
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue