2020-04-04 22:55:06 +08:00
|
|
|
|
/*
|
2023-12-09 16:23:51 +08:00
|
|
|
|
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
2020-04-04 22:55:06 +08:00
|
|
|
|
*
|
2023-12-09 16:23:51 +08:00
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
2020-04-04 22:55:06 +08:00
|
|
|
|
*
|
2023-12-09 16:23:51 +08:00
|
|
|
|
* Use of this source code is governed by MIT-like license that can be found in the
|
2020-04-04 22:55:06 +08:00
|
|
|
|
* 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
|
|
|
|
|
|
2023-12-10 10:21:40 +08:00
|
|
|
|
#include "H265.h"
|
2020-04-04 22:55:06 +08:00
|
|
|
|
#include "Rtmp/RtmpCodec.h"
|
|
|
|
|
#include "Extension/Track.h"
|
|
|
|
|
|
2023-07-22 17:31:39 +08:00
|
|
|
|
namespace mediakit {
|
2020-04-04 22:55:06 +08:00
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
2023-12-09 16:23:51 +08:00
|
|
|
|
H265RtmpDecoder(const Track::Ptr &track) : RtmpCodec(track) {}
|
2020-04-04 22:55:06 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 输入265 Rtmp包
|
|
|
|
|
* @param rtmp Rtmp包
|
|
|
|
|
*/
|
2020-09-06 18:22:04 +08:00
|
|
|
|
void inputRtmp(const RtmpPacket::Ptr &rtmp) override;
|
2020-04-04 22:55:06 +08:00
|
|
|
|
|
|
|
|
|
protected:
|
2023-12-09 16:23:51 +08:00
|
|
|
|
void outputFrame(const char *data, size_t size, uint32_t dts, uint32_t pts);
|
2023-07-22 17:31:39 +08:00
|
|
|
|
void splitFrame(const uint8_t *data, size_t size, uint32_t dts, uint32_t pts);
|
|
|
|
|
|
2020-04-04 22:55:06 +08:00
|
|
|
|
protected:
|
2023-07-22 17:31:39 +08:00
|
|
|
|
RtmpPacketInfo _info;
|
2020-04-04 22:55:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 265 Rtmp打包类
|
|
|
|
|
*/
|
2023-12-09 16:23:51 +08:00
|
|
|
|
class H265RtmpEncoder : public RtmpCodec {
|
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
|
|
|
|
|
*/
|
2023-12-09 16:23:51 +08:00
|
|
|
|
H265RtmpEncoder(const Track::Ptr &track) : RtmpCodec(track) {}
|
2020-04-04 22:55:06 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 输入265帧,可以不带sps pps
|
|
|
|
|
* @param frame 帧数据
|
|
|
|
|
*/
|
2021-09-27 13:12:53 +08:00
|
|
|
|
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;
|
2021-01-17 18:31:50 +08:00
|
|
|
|
|
2020-04-04 22:55:06 +08:00
|
|
|
|
private:
|
2021-06-28 10:35:08 +08:00
|
|
|
|
RtmpPacket::Ptr _rtmp_packet;
|
2023-07-22 17:31:39 +08:00
|
|
|
|
FrameMerger _merger { FrameMerger::mp4_nal_size };
|
2020-04-04 22:55:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
2023-07-22 17:31:39 +08:00
|
|
|
|
} // namespace mediakit
|
2020-04-04 22:55:06 +08:00
|
|
|
|
|
2023-07-22 17:31:39 +08:00
|
|
|
|
#endif // ZLMEDIAKIT_H265RTMPCODEC_H
|