mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
rtmp解复用支持无内存拷贝
hls生成支持输入无0x 00 00 01的H264/H265数据
This commit is contained in:
parent
d2a889b463
commit
6922d82c65
@ -1 +1 @@
|
||||
Subproject commit 0e726dd4e06ab4ed3723deaf3f73386e100bb10d
|
||||
Subproject commit e399b93802610dcf574ff64bcb7677572cd028c1
|
@ -92,6 +92,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 防止内存拷贝的H264类
|
||||
* 用户可以通过该类型快速把一个指针无拷贝的包装成Frame类
|
||||
* 该类型在DevChannel中有使用
|
||||
*/
|
||||
class H264FrameNoCacheAble : public FrameNoCacheAble {
|
||||
public:
|
||||
typedef std::shared_ptr<H264FrameNoCacheAble> Ptr;
|
||||
@ -117,17 +122,26 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 一个H264Frame类中可以有多个帧,他们通过 0x 00 00 01 分隔
|
||||
* ZLMediaKit会先把这种复合帧split成单个帧然后再处理
|
||||
* 一个复合帧可以通过无内存拷贝的方式切割成多个H264FrameSubFrame
|
||||
* 提供该类的目的是切换复合帧时防止内存拷贝,提高性能
|
||||
*/
|
||||
class H264FrameSubFrame : public H264FrameNoCacheAble{
|
||||
public:
|
||||
typedef std::shared_ptr<H264FrameSubFrame> Ptr;
|
||||
H264FrameSubFrame(const Frame::Ptr &strongRef,
|
||||
H264FrameSubFrame(const Frame::Ptr &parent_frame,
|
||||
char *ptr,
|
||||
uint32_t size,
|
||||
int prefixeSize) : H264FrameNoCacheAble(ptr,size,strongRef->dts(),strongRef->pts(),prefixeSize){
|
||||
_strongRef = strongRef;
|
||||
int prefixeSize) : H264FrameNoCacheAble(ptr,size,parent_frame->dts(),parent_frame->pts(),prefixeSize){
|
||||
_parent_frame = parent_frame;
|
||||
}
|
||||
bool cacheAble() const override {
|
||||
return _parent_frame->cacheAble();
|
||||
}
|
||||
private:
|
||||
Frame::Ptr _strongRef;
|
||||
Frame::Ptr _parent_frame;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -108,6 +108,7 @@ inline void H264RtmpDecoder::onGetH264_l(const char* pcData, int iLen, uint32_t
|
||||
}
|
||||
}
|
||||
inline void H264RtmpDecoder::onGetH264(const char* pcData, int iLen, uint32_t dts,uint32_t pts) {
|
||||
#if 0
|
||||
_h264frame->type = H264_TYPE(pcData[0]);
|
||||
_h264frame->timeStamp = dts;
|
||||
_h264frame->ptsStamp = pts;
|
||||
@ -117,6 +118,11 @@ inline void H264RtmpDecoder::onGetH264(const char* pcData, int iLen, uint32_t dt
|
||||
//写入环形缓存
|
||||
RtmpCodec::inputFrame(_h264frame);
|
||||
_h264frame = obtainFrame();
|
||||
#else
|
||||
//防止内存拷贝,这样产生的264帧不会有0x00 00 01头
|
||||
auto frame = std::make_shared<H264FrameNoCacheAble>((char *)pcData,iLen,dts,pts,0);
|
||||
RtmpCodec::inputFrame(frame);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +70,12 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) {
|
||||
if(_frameCached.size() != 1){
|
||||
string merged;
|
||||
_frameCached.for_each([&](const Frame::Ptr &frame){
|
||||
merged.append(frame->data(),frame->size());
|
||||
if(frame->prefixSize()){
|
||||
merged.append(frame->data(),frame->size());
|
||||
} else{
|
||||
merged.append("\x00\x00\x00\x01",4);
|
||||
merged.append(frame->data(),frame->size());
|
||||
}
|
||||
});
|
||||
merged_frame = std::make_shared<BufferString>(std::move(merged));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user