Skip to content

Commit

Permalink
Merge pull request #42 from joestarzxh/master
Browse files Browse the repository at this point in the history
[fix]aac解析出现问题偶尔产生异常的情况
  • Loading branch information
ZSC714725 authored Oct 31, 2023
2 parents 68ef8b5 + 11be4a1 commit d85fd80
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 d85fd80

Please sign in to comment.