新增支持enhanced-rtmp h265 推流 (#2694)

This commit is contained in:
夏楚
2023-07-22 17:31:39 +08:00
committed by GitHub
parent b44ca8fd6f
commit 47add54465
11 changed files with 325 additions and 111 deletions

View File

@@ -269,5 +269,72 @@ private:
//根据音频track获取flags
uint8_t getAudioRtmpFlags(const Track::Ptr &track);
enum class RtmpFrameType : uint8_t {
reserved = 0,
key_frame = 1, // key frame (for AVC, a seekable frame)
inter_frame = 2, // inter frame (for AVC, a non-seekable frame)
disposable_inter_frame = 3, // disposable inter frame (H.263 only)
generated_key_frame = 4, // generated key frame (reserved for server use only)
video_info_frame = 5, // video info/command frame
};
enum class RtmpVideoCodec : uint8_t {
h263 = 2, // Sorenson H.263
screen_video = 3, // Screen video
vp6 = 4, // On2 VP6
vp6_alpha = 5, // On2 VP6 with alpha channel
screen_video2 = 6, // Screen video version 2
h264 = 7, // avc
h265 = 12, // 国内扩展
};
enum class RtmpH264PacketType : uint8_t {
h264_config_header = 0, // AVC sequence header(sps/pps)
h264_nalu = 1, // AVC NALU
h264_end_seq = 2, // AVC end of sequence (lower level NALU sequence ender is not REQUIRED or supported)
};
enum class RtmpPacketType : uint8_t {
PacketTypeSequenceStart = 0,
PacketTypeCodedFrames = 1,
PacketTypeSequenceEnd = 2,
// CompositionTime Offset is implied to equal zero. This is
// an optimization to save putting SI24 composition time value of zero on
// the wire. See pseudo code below in the VideoTagBody section
PacketTypeCodedFramesX = 3,
// VideoTagBody does not contain video data. VideoTagBody
// instead contains an AMF encoded metadata. See Metadata Frame
// section for an illustration of its usage. As an example, the metadata
// can be HDR information. This is a good way to signal HDR
// information. This also opens up future ways to express additional
// metadata that is meant for the next video sequence.
//
// note: presence of PacketTypeMetadata means that FrameType
// flags at the top of this table should be ignored
PacketTypeMetadata = 4,
// Carriage of bitstream in MPEG-2 TS format
// note: PacketTypeSequenceStart and PacketTypeMPEG2TSSequenceStart
// are mutually exclusive
PacketTypeMPEG2TSSequenceStart = 5,
};
struct RtmpPacketInfo {
CodecId codec = CodecInvalid;
bool is_enhanced;
union {
struct {
RtmpFrameType frame_type;
RtmpVideoCodec rtmp_codec;
RtmpPacketType pkt_type;
RtmpH264PacketType h264_pkt_type;
} video;
};
};
// https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
CodecId parseVideoRtmpPacket(const uint8_t *data, size_t size, RtmpPacketInfo *info = nullptr);
}//namespace mediakit
#endif//__rtmp_h