Skip to content

Commit

Permalink
fix ContinuityCounter bug
Browse files Browse the repository at this point in the history
  • Loading branch information
deepch committed Jul 16, 2022
1 parent 37a9a86 commit 31d128e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions format/ts/muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,24 @@ func (self *Muxer) newStream(idx int, codec av.CodecData) (err error) {
return
}

func (self *Muxer) writePaddingTSPackets(tsw *tsio.TSWriter) (err error) {
for tsw.ContinuityCounter&0xf != 0x0 {
if err = tsw.WritePackets(self.w, self.datav[:1], 0, false, true); err != nil {
func (self *Muxer) writePaddingTSPackets(streamW *Stream) (err error) {
for streamW.tsw.ContinuityCounter&0xf != 0x0 {
header := tsio.TSHeader{
PID: uint(streamW.pid),
ContinuityCounter: streamW.tsw.ContinuityCounter,
}
if _, err = tsio.WriteTSHeader(self.w, header, 0); err != nil {
return
}
streamW.tsw.ContinuityCounter++
}
return
}

func (self *Muxer) WriteTrailer() (err error) {
if self.PaddingToMakeCounterCont {
for _, stream := range self.streams {
if err = self.writePaddingTSPackets(stream.tsw); err != nil {
if err = self.writePaddingTSPackets(stream); err != nil {
return
}
}
Expand Down

0 comments on commit 31d128e

Please sign in to comment.