mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
完善aac rtp解析
This commit is contained in:
parent
4281a1272e
commit
c0fde62480
@ -98,10 +98,15 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_last_dts) {
|
||||||
|
//记录第一个时间戳
|
||||||
|
_last_dts = rtppack->timeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
//每个audio unit时间戳增量
|
//每个audio unit时间戳增量
|
||||||
auto dts_inc = (rtppack->timeStamp - _last_dts) / au_header_count;
|
auto dts_inc = (rtppack->timeStamp - _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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,13 +117,16 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
|||||||
//数据不够
|
//数据不够
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//设置aac数据
|
|
||||||
_frame->_buffer.assign((char *) ptr, size);
|
if (size) {
|
||||||
//设置当前audio unit时间戳
|
//设置aac数据
|
||||||
_frame->_dts = _last_dts + i * dts_inc;
|
_frame->_buffer.assign((char *) ptr, size);
|
||||||
ptr += size;
|
//设置当前audio unit时间戳
|
||||||
au_header_ptr += 2;
|
_frame->_dts = _last_dts + i * dts_inc;
|
||||||
flushData();
|
ptr += size;
|
||||||
|
au_header_ptr += 2;
|
||||||
|
flushData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//记录上次时间戳
|
//记录上次时间戳
|
||||||
_last_dts = rtppack->timeStamp;
|
_last_dts = rtppack->timeStamp;
|
||||||
@ -126,11 +134,6 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AACRtpDecoder::flushData() {
|
void AACRtpDecoder::flushData() {
|
||||||
if (_frame->_buffer.empty()) {
|
|
||||||
//没有有效数据
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//插入adts头
|
//插入adts头
|
||||||
char adts_header[32] = {0};
|
char adts_header[32] = {0};
|
||||||
auto size = dumpAacConfig(_aac_cfg, _frame->_buffer.size(), (uint8_t *) adts_header, sizeof(adts_header));
|
auto size = dumpAacConfig(_aac_cfg, _frame->_buffer.size(), (uint8_t *) adts_header, sizeof(adts_header));
|
||||||
|
Loading…
Reference in New Issue
Block a user