mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 08:39:34 +08:00
优化DevChannel内存拷贝问题
This commit is contained in:
parent
9cdbe4c4ef
commit
57c5d2963a
@ -104,7 +104,13 @@ void DevChannel::inputH264(const char* pcData, int iDataLen, uint32_t dts,uint32
|
||||
} else {
|
||||
prefixeSize = 0;
|
||||
}
|
||||
inputFrame(std::make_shared<H264FrameNoCacheAble>((char *)pcData,iDataLen,dts,pts,prefixeSize));
|
||||
|
||||
H264Frame::Ptr frame = std::make_shared<H264Frame>();
|
||||
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<H265FrameNoCacheAble>((char *)pcData,iDataLen,dts,pts,prefixeSize));
|
||||
|
||||
H265Frame::Ptr frame = std::make_shared<H265Frame>();
|
||||
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) {
|
||||
|
@ -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;
|
||||
} ;
|
||||
|
@ -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);
|
||||
|
@ -222,13 +222,23 @@ public:
|
||||
auto iAudioIndex = frame->stamp() / MUTE_ADTS_DATA_MS;
|
||||
if(_iAudioIndex != iAudioIndex){
|
||||
_iAudioIndex = iAudioIndex;
|
||||
auto aacFrame = std::make_shared<AACFrameNoCacheAble>((char *)MUTE_ADTS_DATA,
|
||||
MUTE_ADTS_DATA_LEN,
|
||||
_iAudioIndex * MUTE_ADTS_DATA_MS);
|
||||
auto aacFrame = std::make_shared<AACFrameCacheAble>((char *)MUTE_ADTS_DATA, MUTE_ADTS_DATA_LEN, _iAudioIndex * MUTE_ADTS_DATA_MS);
|
||||
FrameDispatcher::inputFrame(aacFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
class AACFrameCacheAble : public AACFrameNoCacheAble{
|
||||
public:
|
||||
template <typename ... ARGS>
|
||||
AACFrameCacheAble(ARGS && ...args) : AACFrameNoCacheAble(std::forward<ARGS>(args)...){};
|
||||
virtual ~AACFrameCacheAble() = default;
|
||||
|
||||
bool cacheAble() const override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
private:
|
||||
int _iAudioIndex = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user