Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
matsuuram committed Dec 1, 2023
1 parent e5083af commit c5981b7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tsparser/mpeg_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func BufferPsi(file *os.File, pos *int64, pid uint16, mpegPacket MpegPacket, opt
if err == io.EOF {
break
} else if err != nil || size != tsPacketSize {
return fmt.Errorf("File read error: %s", err)
return fmt.Errorf("file read error: %s", err)
}
if size < tsPacketSize {
break
Expand Down Expand Up @@ -83,7 +83,7 @@ func BufferPes(file *os.File, pos *int64, pcrPid uint16, programInfos []ProgramI
if err == io.EOF {
break
} else if err != nil || size != tsPacketSize {
return fmt.Errorf("File read error: %s", err)
return fmt.Errorf("file read error: %s", err)
}
if size < tsPacketSize {
break
Expand Down
2 changes: 1 addition & 1 deletion tsparser/pat.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// Pat Program Map Table.
type Pat struct {
startFlag bool
// startFlag bool
continuityCounter uint8
buf []byte
pmtPid uint16
Expand Down
2 changes: 1 addition & 1 deletion tsparser/pmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// Pmt Progran Map Table
type Pmt struct {
startFlag bool
// startFlag bool
continuityCounter uint8
buf []byte

Expand Down
26 changes: 14 additions & 12 deletions tsparser/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func ParseTsFile(filename string, options options.Options) error {
file, err := os.Open(filename)
if err != nil {
return fmt.Errorf("File open error: %s %s", filename, err)
return fmt.Errorf("file open error: %s %s", filename, err)
}
fmt.Println("Input file: ", filename)

Expand All @@ -27,43 +27,45 @@ func ParseTsFile(filename string, options options.Options) error {
if err == io.EOF {
break
} else if err != nil {
return fmt.Errorf("File read error: %s", err)
return fmt.Errorf("file read error: %s", err)
}
if pos, err = findPat(buf); err != nil {
continue
}

if _, err = file.Seek(pos, 0); err != nil {
return fmt.Errorf("File seek error: %s", err)
return fmt.Errorf("file seek error: %s", err)
}

// Parse PAT
err = BufferPsi(file, &pos, patPid, pat, options)
err = pat.Parse()
if err != nil {
if err = BufferPsi(file, &pos, patPid, pat, options); err != nil {
return err
}
if err = pat.Parse(); err != nil {
continue
}
pmtPid := pat.PmtPid()

if _, err = file.Seek(pos, 0); err != nil {
return fmt.Errorf("File seek error: %s", err)
return fmt.Errorf("file seek error: %s", err)
}
fmt.Printf("Detected PAT: PMT pid = 0x%02x\n", pmtPid)
if options.DumpPsi() {
pat.Dump()
}

// Parse PMT
err = BufferPsi(file, &pos, pmtPid, pmt, options)
err = pmt.Parse()
if err != nil {
if err = BufferPsi(file, &pos, pmtPid, pmt, options); err != nil {
return err
}
if err = pmt.Parse(); err != nil {
continue
}
programs := pmt.ProgramInfos()
pcrPid := pmt.PcrPid()

if _, err = file.Seek(pos, 0); err != nil {
return fmt.Errorf("File seek error: %s", err)
return fmt.Errorf("file seek error: %s", err)
}
fmt.Println("Detected PMT")
if options.DumpPsi() {
Expand Down Expand Up @@ -92,5 +94,5 @@ func findPat(data []byte) (int64, error) {
}
}
}
return 0, fmt.Errorf("Cannot find pat")
return 0, fmt.Errorf("cannot find pat")
}
2 changes: 1 addition & 1 deletion tsparser/ts_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (tp *TsPacket) Pcr() uint64 { return tp.adaptationField.Pcr() }
// Parse parse TsPacket header.
func (tp *TsPacket) Parse() error {
if len(tp.buf) < 188 {
return fmt.Errorf("Buffer is short of length: %d", len(tp.buf))
return fmt.Errorf("buffer is short of length: %d", len(tp.buf))
}
bb := new(bitbuffer.BitBuffer)
bb.Set(tp.buf)
Expand Down

0 comments on commit c5981b7

Please sign in to comment.