mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +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,6 +117,8 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
|||||||
//数据不够
|
//数据不够
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size) {
|
||||||
//设置aac数据
|
//设置aac数据
|
||||||
_frame->_buffer.assign((char *) ptr, size);
|
_frame->_buffer.assign((char *) ptr, size);
|
||||||
//设置当前audio unit时间戳
|
//设置当前audio unit时间戳
|
||||||
@ -120,17 +127,13 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
|||||||
au_header_ptr += 2;
|
au_header_ptr += 2;
|
||||||
flushData();
|
flushData();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//记录上次时间戳
|
//记录上次时间戳
|
||||||
_last_dts = rtppack->timeStamp;
|
_last_dts = rtppack->timeStamp;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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