mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-23 09:22:21 +08:00
各协议全面支持vp8/vp9/av1编码,ertmp新增支持opus编码 (#4498)
实现功能: - rtp 增加vp8,vp9和av1编码支持 - 实现MP4录像所需的extra_data接口 - 扩展rtmp增加对opus、vp8、vp9和av1的支持 已知问题: - 开启enhance rtmp后,ffmpeg暂时不支持播放vp8编码格式,其他格式的支持 - vp9和av1开始播放时容易遇到卡顿情况,过几秒后好了,原因暂时未知 --------- Co-authored-by: xia-chu <771730766@qq.com>
This commit is contained in:
49
ext-codec/VP8.h
Normal file
49
ext-codec/VP8.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef ZLMEDIAKIT_VP8_H
|
||||
#define ZLMEDIAKIT_VP8_H
|
||||
|
||||
#include "Extension/Frame.h"
|
||||
#include "Extension/Track.h"
|
||||
#include "webm-vpx.h"
|
||||
namespace mediakit {
|
||||
template <typename Parent>
|
||||
class VP8FrameHelper : public Parent {
|
||||
public:
|
||||
friend class FrameImp;
|
||||
//friend class toolkit::ResourcePool_l<VP8FrameHelper>;
|
||||
using Ptr = std::shared_ptr<VP8FrameHelper>;
|
||||
|
||||
template <typename... ARGS>
|
||||
VP8FrameHelper(ARGS &&...args)
|
||||
: Parent(std::forward<ARGS>(args)...) {
|
||||
this->_codec_id = CodecVP8;
|
||||
}
|
||||
|
||||
bool keyFrame() const override {
|
||||
auto ptr = (uint8_t *) this->data() + this->prefixSize();
|
||||
return !(*ptr & 0x01);
|
||||
}
|
||||
bool configFrame() const override { return false; }
|
||||
bool dropAble() const override { return false; }
|
||||
bool decodeAble() const override { return true; }
|
||||
};
|
||||
|
||||
/// VP8 帧类
|
||||
using VP8Frame = VP8FrameHelper<FrameImp>;
|
||||
using VP8FrameNoCacheAble = VP8FrameHelper<FrameFromPtr>;
|
||||
|
||||
class VP8Track : public VideoTrackImp {
|
||||
public:
|
||||
VP8Track() : VideoTrackImp(CodecVP8) {}
|
||||
|
||||
Track::Ptr clone() const override { return std::make_shared<VP8Track>(*this); }
|
||||
|
||||
bool inputFrame(const Frame::Ptr &frame) override;
|
||||
toolkit::Buffer::Ptr getExtraData() const override;
|
||||
void setExtraData(const uint8_t *data, size_t size) override;
|
||||
private:
|
||||
webm_vpx_t _vpx = {0};
|
||||
};
|
||||
|
||||
} // namespace mediakit
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user