修复AAC rtp解码相关的bug

This commit is contained in:
xiongziliang
2019-01-24 12:21:29 +08:00
parent 22962a407e
commit a646640580
6 changed files with 40 additions and 20 deletions

View File

@@ -82,7 +82,7 @@ public:
return false;
}
public:
unsigned int syncword; //12 bslbf 同步字The bit string 1111 1111 1111说明一个ADTS帧的开始
unsigned int syncword = 0; //12 bslbf 同步字The bit string 1111 1111 1111说明一个ADTS帧的开始
unsigned int id; //1 bslbf MPEG 标示符, 设置为1
unsigned int layer; //2 uimsbf Indicates which layer is used. Set to 00
unsigned int protection_absent; //1 bslbf 表示是否误码校验
@@ -234,10 +234,15 @@ public:
* @param frame 数据帧
*/
void inputFrame(const Frame::Ptr &frame) override{
if(_cfg.empty() && frame->prefixSize() >= 7){
//7个字节的adts头
_cfg = makeAdtsConfig(reinterpret_cast<const uint8_t *>(frame->data()));
onReady();
if(_cfg.empty()){
//未获取到aac_cfg信息
if(frame->prefixSize() >= 7) {
//7个字节的adts头
_cfg = makeAdtsConfig(reinterpret_cast<const uint8_t *>(frame->data()));
onReady();
}else{
WarnL << "无法获取adts头!";
}
}
AudioTrack::inputFrame(frame);
}

View File

@@ -181,16 +181,16 @@ RtpCodec::Ptr Factory::getRtpEncoderById(CodecId codecId,
}
}
RtpCodec::Ptr Factory::getRtpDecoderById(CodecId codecId) {
switch (codecId){
RtpCodec::Ptr Factory::getRtpDecoderByTrack(const Track::Ptr &track) {
switch (track->getCodecId()){
case CodecH264:
return std::make_shared<H264RtpDecoder>();
case CodecH265:
return std::make_shared<H265RtpDecoder>();
case CodecAAC:
return std::make_shared<AACRtpDecoder>();
return std::make_shared<AACRtpDecoder>(track->clone());
default:
WarnL << "暂不支持该CodecId:" << codecId;
WarnL << "暂不支持该CodecId:" << track->getCodecId();
return nullptr;
}
}

View File

@@ -81,12 +81,11 @@ public:
uint8_t ui8Interleaved);
/**
* 根据CodecId生成Rtp解包器
* @param codecId
* @param ui32SampleRate
* 根据Track生成Rtp解包器
* @param track
* @return
*/
static RtpCodec::Ptr getRtpDecoderById(CodecId codecId);
static RtpCodec::Ptr getRtpDecoderByTrack(const Track::Ptr &track);
////////////////////////////////rtmp相关//////////////////////////////////