@@ -27,7 +27,6 @@ package psi
27
27
import (
28
28
"bytes"
29
29
"encoding/binary"
30
- "errors"
31
30
"fmt"
32
31
"io"
33
32
@@ -258,17 +257,19 @@ func FilterPMTPacketsToPids(packets []*packet.Packet, pids []uint16) ([]*packet.
258
257
// Determine if any of the given PIDs aren't in the PMT.
259
258
unfilteredPMT , _ := NewPMT (pmtPayload )
260
259
260
+ pmtPid := packet .Pid (packets [0 ])
261
261
var missingPids []uint16
262
262
for _ , pid := range pids {
263
- if ! unfilteredPMT .PIDExists (pid ) {
263
+ // Ignore PAT and PMT PIDS if they are included.
264
+ if ! unfilteredPMT .PIDExists (pid ) && pid != PatPid && pid != pmtPid {
264
265
missingPids = append (missingPids , pid )
265
266
}
266
267
}
267
268
268
269
// Return an error if any of the given PIDs is not present in the PMT.
269
270
var returnError error
270
271
if len (missingPids ) > 0 {
271
- returnError = errors . New ( fmt .Sprintf (gots .ErrPIDNotInPMT .Error (), missingPids ) )
272
+ returnError = fmt .Errorf (gots .ErrPIDNotInPMT .Error (), missingPids )
272
273
}
273
274
274
275
// Return nil packets and an error if none of the PIDs being filtered exist in the PMT.
@@ -358,8 +359,8 @@ func IsPMT(pkt *packet.Packet, pat PAT) (bool, error) {
358
359
pmtMap := pat .ProgramMap ()
359
360
pid := packet .Pid (pkt )
360
361
361
- for _ , map_pid := range pmtMap {
362
- if pid == map_pid {
362
+ for _ , mapPID := range pmtMap {
363
+ if pid == mapPID {
363
364
return true , nil
364
365
}
365
366
}
0 commit comments