diff --git a/src/Common/Device.cpp b/src/Common/Device.cpp index a04dba72..450ed9e3 100644 --- a/src/Common/Device.cpp +++ b/src/Common/Device.cpp @@ -104,7 +104,13 @@ void DevChannel::inputH264(const char* pcData, int iDataLen, uint32_t dts,uint32 } else { prefixeSize = 0; } - inputFrame(std::make_shared((char *)pcData,iDataLen,dts,pts,prefixeSize)); + + H264Frame::Ptr frame = std::make_shared(); + frame->timeStamp = dts; + frame->ptsStamp = pts; + frame->buffer.assign("\x00\x00\x00\x01",4); + frame->buffer.append(pcData + prefixeSize, iDataLen - prefixeSize); + inputFrame(frame); } void DevChannel::inputH265(const char* pcData, int iDataLen, uint32_t dts,uint32_t pts) { @@ -122,7 +128,13 @@ void DevChannel::inputH265(const char* pcData, int iDataLen, uint32_t dts,uint32 } else { prefixeSize = 0; } - inputFrame(std::make_shared((char *)pcData,iDataLen,dts,pts,prefixeSize)); + + H265Frame::Ptr frame = std::make_shared(); + frame->timeStamp = dts; + frame->ptsStamp = pts; + frame->buffer.assign("\x00\x00\x00\x01",4); + frame->buffer.append(pcData + prefixeSize, iDataLen - prefixeSize); + inputFrame(frame); } void DevChannel::inputAAC(const char* pcData, int iDataLen, uint32_t uiStamp,bool withAdtsHeader) { diff --git a/src/Extension/AAC.h b/src/Extension/AAC.h index fe78509e..063756f6 100644 --- a/src/Extension/AAC.h +++ b/src/Extension/AAC.h @@ -104,7 +104,6 @@ public: //表示说ADTS帧中有一个AAC数据块并不是说没有。(一个AAC原始帧包含一段时间内1024个采样及相关数据) unsigned int no_raw_data_blocks_in_frame; //2 uimsfb unsigned char buffer[2 * 1024 + 7]; - uint16_t sequence; uint32_t timeStamp; uint32_t iPrefixSize = 7; } ; diff --git a/src/Extension/AACRtp.cpp b/src/Extension/AACRtp.cpp index 2f001959..7b436fb0 100644 --- a/src/Extension/AACRtp.cpp +++ b/src/Extension/AACRtp.cpp @@ -149,7 +149,6 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) { memcpy(_adts->buffer + _adts->aac_frame_length, rtp_packet_payload + next_aac_payload_offset, cur_aac_payload_len); _adts->aac_frame_length += (cur_aac_payload_len); if (rtppack->mark == true) { - _adts->sequence = rtppack->sequence; _adts->timeStamp = rtppack->timeStamp; writeAdtsHeader(*_adts, _adts->buffer); onGetAAC(_adts); diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index 5badcce0..250ea932 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -222,13 +222,23 @@ public: auto iAudioIndex = frame->stamp() / MUTE_ADTS_DATA_MS; if(_iAudioIndex != iAudioIndex){ _iAudioIndex = iAudioIndex; - auto aacFrame = std::make_shared((char *)MUTE_ADTS_DATA, - MUTE_ADTS_DATA_LEN, - _iAudioIndex * MUTE_ADTS_DATA_MS); + auto aacFrame = std::make_shared((char *)MUTE_ADTS_DATA, MUTE_ADTS_DATA_LEN, _iAudioIndex * MUTE_ADTS_DATA_MS); FrameDispatcher::inputFrame(aacFrame); } } } + +private: + class AACFrameCacheAble : public AACFrameNoCacheAble{ + public: + template + AACFrameCacheAble(ARGS && ...args) : AACFrameNoCacheAble(std::forward(args)...){}; + virtual ~AACFrameCacheAble() = default; + + bool cacheAble() const override { + return true; + } + }; private: int _iAudioIndex = 0; };