From b438ecb88cdc92729dbc7ecba9274593701f70cf Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Wed, 27 Oct 2021 13:23:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B8=8D=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E7=9A=84aac=20rtsp=E6=8E=A8=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/AACRtp.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Extension/AACRtp.cpp b/src/Extension/AACRtp.cpp index c64f2039..3c55da7e 100644 --- a/src/Extension/AACRtp.cpp +++ b/src/Extension/AACRtp.cpp @@ -132,13 +132,19 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) { } void AACRtpDecoder::flushData() { - //插入adts头 - char adts_header[32] = {0}; - auto size = dumpAacConfig(_aac_cfg, _frame->_buffer.size(), (uint8_t *) adts_header, sizeof(adts_header)); - if (size > 0) { - //插入adts头 - _frame->_buffer.insert(0, adts_header, size); - _frame->_prefix_size = size; + auto ptr = reinterpret_cast(_frame->_buffer.data()); + if ((ptr[0] == 0xFF && (ptr[1] & 0xF0) == 0xF0)) { + //adts头打入了rtp包,不符合规范,兼容EasyPusher的bug + _frame->_prefix_size = ADTS_HEADER_LEN; + } else { + //没有adts头则插入adts头 + char adts_header[32] = {0}; + auto size = dumpAacConfig(_aac_cfg, _frame->_buffer.size(), (uint8_t *) adts_header, sizeof(adts_header)); + if (size > 0) { + //插入adts头 + _frame->_buffer.insert(0, adts_header, size); + _frame->_prefix_size = size; + } } RtpCodec::inputFrame(_frame); obtainFrame();