Skip to content

Commit

Permalink
[fix]aac解析出现问题偶尔产生异常的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
joestarzxh committed Oct 30, 2023
1 parent 68ef8b5 commit 11be4a1
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions srt/pub.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,17 @@ func (p *Publisher) Run() {
PayloadType: base.AvPacketPtAac,
Pts: int64(preAudioDts),
}
Payload := frame[aac.AdtsHeaderLength:ctx.AdtsLength]
frame = frame[ctx.AdtsLength:]
aacPacket.Payload = Payload
p.ss.FeedAvPacket(aacPacket)
if len(frame) >= int(ctx.AdtsLength) {
Payload := frame[aac.AdtsHeaderLength:ctx.AdtsLength]
if len(frame) > int(ctx.AdtsLength) {
frame = frame[ctx.AdtsLength:]
} else {
frame = frame[0:0]
}
aacPacket.Payload = Payload
p.ss.FeedAvPacket(aacPacket)
}

}
} else if cid == ts.TS_STREAM_H264 {
pkt.Payload = frame
Expand All @@ -94,20 +101,9 @@ func (p *Publisher) Run() {
p.ss.FeedAvPacket(pkt)
}
}

for {
select {
case <-p.ctx.Done():
return
default:

}

err := p.demuxer.Input(bufio.NewReader(p.conn))
if err != nil {
nazalog.Infof("stream [%s] disconnected", p.streamName)
break
}
return
err := p.demuxer.Input(bufio.NewReader(p.conn))
if err != nil {
nazalog.Infof("stream [%s] disconnected", p.streamName)
}
return
}

0 comments on commit 11be4a1

Please sign in to comment.