提升浏览器webrtc g711音频播放效果 (#4280 #4282)

For chrome (136.0.7103.93)
This commit is contained in:
xiongguangjie 2025-05-11 11:18:34 +08:00 committed by GitHub
parent 7a7f618a73
commit a050f38cc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,7 +38,8 @@ bool G711RtpEncoder::inputFrame(const Frame::Ptr &frame) {
_buffer.append(ptr, size);
while (_buffer.size() >= _pkt_bytes) {
RtpCodec::inputRtp(getRtpInfo().makeRtp(TrackAudio, _buffer.data(), _pkt_bytes, false, in_pts), false);
auto tmp = (in_pts+_pkt_dur_ms-1)/_pkt_dur_ms*_pkt_dur_ms;
RtpCodec::inputRtp(getRtpInfo().makeRtp(TrackAudio, _buffer.data(), _pkt_bytes, false, tmp), false);
in_pts += _pkt_dur_ms;
_buffer.erase(0, _pkt_bytes);
}