ZLMediaKit/src/Extension/H265Rtmp.h

96 lines
2.2 KiB
C++
Raw Normal View History

2020-04-04 22:55:06 +08:00
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
2020-04-04 22:55:06 +08:00
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ZLMEDIAKIT_H265RTMPCODEC_H
#define ZLMEDIAKIT_H265RTMPCODEC_H
#include "Rtmp/RtmpCodec.h"
#include "Extension/Track.h"
#include "Extension/H265.h"
namespace mediakit{
/**
* h265 Rtmp解码类
* h265 over rtmp h265-Frame
*/
2021-02-05 11:51:16 +08:00
class H265RtmpDecoder : public RtmpCodec {
2020-04-04 22:55:06 +08:00
public:
2022-12-02 14:43:06 +08:00
using Ptr = std::shared_ptr<H265RtmpDecoder>;
2020-04-04 22:55:06 +08:00
H265RtmpDecoder();
~H265RtmpDecoder() {}
/**
* 265 Rtmp包
* @param rtmp Rtmp包
*/
void inputRtmp(const RtmpPacket::Ptr &rtmp) override;
2020-04-04 22:55:06 +08:00
CodecId getCodecId() const override{
return CodecH265;
}
2020-04-04 22:55:06 +08:00
protected:
void onGetH265(const char *pcData, size_t iLen, uint32_t dts,uint32_t pts);
2020-04-04 22:55:06 +08:00
H265Frame::Ptr obtainFrame();
2020-04-04 22:55:06 +08:00
protected:
H265Frame::Ptr _h265frame;
};
/**
* 265 Rtmp打包类
*/
2021-02-04 17:58:51 +08:00
class H265RtmpEncoder : public H265RtmpDecoder{
2020-04-04 22:55:06 +08:00
public:
2022-12-02 14:43:06 +08:00
using Ptr = std::shared_ptr<H265RtmpEncoder>;
2020-04-04 22:55:06 +08:00
/**
* track可以为空inputFrame时输入sps pps
* track不为空且包含sps pps信息
* inputFrame时可以不输入sps pps
* @param track
*/
H265RtmpEncoder(const Track::Ptr &track);
2022-10-16 19:49:56 +08:00
~H265RtmpEncoder() = default;
2020-04-04 22:55:06 +08:00
/**
* 265sps pps
* @param frame
*/
bool inputFrame(const Frame::Ptr &frame) override;
2020-04-04 22:55:06 +08:00
2022-10-16 19:49:56 +08:00
/**
* frame缓存
*/
void flush() override;
2020-04-04 22:55:06 +08:00
/**
* config包
*/
void makeConfigPacket() override;
2020-04-04 22:55:06 +08:00
private:
void makeVideoConfigPkt();
2020-04-04 22:55:06 +08:00
private:
2021-06-28 10:35:08 +08:00
bool _got_config_frame = false;
std::string _vps;
std::string _sps;
std::string _pps;
2020-04-04 22:55:06 +08:00
H265Track::Ptr _track;
2021-06-28 10:35:08 +08:00
RtmpPacket::Ptr _rtmp_packet;
FrameMerger _merger{FrameMerger::mp4_nal_size};
2020-04-04 22:55:06 +08:00
};
}//namespace mediakit
#endif //ZLMEDIAKIT_H265RTMPCODEC_H