mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
修复aac rtp解码兼容性相关bug
This commit is contained in:
parent
170ec3c830
commit
720d6304d2
@ -87,26 +87,25 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) {
|
|||||||
|
|
||||||
// 每个audio unit时间戳增量
|
// 每个audio unit时间戳增量
|
||||||
auto dts_inc = (stamp - _last_dts) / au_header_count;
|
auto dts_inc = (stamp - _last_dts) / au_header_count;
|
||||||
if (dts_inc < 0 && dts_inc > 100) {
|
if (dts_inc < 0 || dts_inc > 100) {
|
||||||
// 时间戳增量异常,忽略
|
// 时间戳增量异常,忽略
|
||||||
dts_inc = 0;
|
dts_inc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < au_header_count; ++i) {
|
for (auto i = 0u; i < (size_t)au_header_count; ++i) {
|
||||||
// 之后的2字节是AU_HEADER,其中高13位表示一帧AAC负载的字节长度,低3位无用
|
// 之后的2字节是AU_HEADER,其中高13位表示一帧AAC负载的字节长度,低3位无用
|
||||||
uint16_t size = ((au_header_ptr[0] << 8) | au_header_ptr[1]) >> 3;
|
auto size = ((au_header_ptr[0] << 8) | au_header_ptr[1]) >> 3;
|
||||||
if (ptr + size > end) {
|
auto len = std::min<int>(size, end - ptr);
|
||||||
//数据不够
|
if (len <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
_frame->_buffer.append((char *)ptr, len);
|
||||||
|
ptr += len;
|
||||||
|
au_header_ptr += 2;
|
||||||
|
|
||||||
if (size) {
|
if (_frame->size() == (size_t)size) {
|
||||||
//设置aac数据
|
|
||||||
_frame->_buffer.assign((char *) ptr, size);
|
|
||||||
// 设置当前audio unit时间戳
|
// 设置当前audio unit时间戳
|
||||||
_frame->_dts = _last_dts + i * dts_inc;
|
_frame->_dts = _last_dts + i * dts_inc;
|
||||||
ptr += size;
|
|
||||||
au_header_ptr += 2;
|
|
||||||
flushData();
|
flushData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user