mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +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;
|
||||
}
|
||||
|
||||
if (!_last_dts) {
|
||||
//记录第一个时间戳
|
||||
_last_dts = rtppack->timeStamp;
|
||||
}
|
||||
|
||||
//每个audio unit时间戳增量
|
||||
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;
|
||||
}
|
||||
|
||||
@ -112,6 +117,8 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
||||
//数据不够
|
||||
break;
|
||||
}
|
||||
|
||||
if (size) {
|
||||
//设置aac数据
|
||||
_frame->_buffer.assign((char *) ptr, size);
|
||||
//设置当前audio unit时间戳
|
||||
@ -120,17 +127,13 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
||||
au_header_ptr += 2;
|
||||
flushData();
|
||||
}
|
||||
}
|
||||
//记录上次时间戳
|
||||
_last_dts = rtppack->timeStamp;
|
||||
return false;
|
||||
}
|
||||
|
||||
void AACRtpDecoder::flushData() {
|
||||
if (_frame->_buffer.empty()) {
|
||||
//没有有效数据
|
||||
return;
|
||||
}
|
||||
|
||||
//插入adts头
|
||||
char adts_header[32] = {0};
|
||||
auto size = dumpAacConfig(_aac_cfg, _frame->_buffer.size(), (uint8_t *) adts_header, sizeof(adts_header));
|
||||
|
Loading…
Reference in New Issue
Block a user