mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-15 04:25:58 +08:00
完善ertmp相关代码 (#4505)
增加多种Codec支持,并修复一些bug: - opus 非标准实现,不输出config frame,与旧的实现保持一致 - 添加RTMP_CODEC_MAP宏,精简代码
This commit is contained in:
@@ -87,12 +87,7 @@ bool VpxRtmpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
auto header = (RtmpVideoHeaderEnhanced *)buff;
|
||||
header->enhanced = 1;
|
||||
header->frame_type = frame->keyFrame() ? (int)RtmpFrameType::key_frame : (int)RtmpFrameType::inter_frame;
|
||||
switch (frame->getCodecId()) {
|
||||
case CodecVP8: header->fourcc = htonl((uint32_t)RtmpVideoCodec::fourcc_vp8); break;
|
||||
case CodecVP9: header->fourcc = htonl((uint32_t)RtmpVideoCodec::fourcc_vp9); break;
|
||||
case CodecAV1: header->fourcc = htonl((uint32_t)RtmpVideoCodec::fourcc_av1); break;
|
||||
default: break;
|
||||
}
|
||||
header->fourcc = htonl(getCodecFourCC(frame->getCodecId()));
|
||||
buff += RtmpPacketInfo::kEnhancedRtmpHeaderSize;
|
||||
if (cts) {
|
||||
header->pkt_type = (uint8_t)RtmpPacketType::PacketTypeCodedFrames;
|
||||
@@ -103,13 +98,7 @@ bool VpxRtmpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
}
|
||||
} else {
|
||||
// flags
|
||||
uint8_t flags = 0;
|
||||
switch (getTrack()->getCodecId()) {
|
||||
case CodecVP8: flags = (uint8_t)RtmpVideoCodec::vp8; break;
|
||||
case CodecVP9: flags = (uint8_t)RtmpVideoCodec::vp9; break;
|
||||
case CodecAV1: flags = (uint8_t)RtmpVideoCodec::av1; break;
|
||||
default: break;
|
||||
}
|
||||
uint8_t flags = getCodecFlags(frame->getCodecId());
|
||||
flags |= (uint8_t)(frame->keyFrame() ? RtmpFrameType::key_frame : RtmpFrameType::inter_frame) << 4;
|
||||
|
||||
buff[0] = flags;
|
||||
@@ -144,20 +133,9 @@ void VpxRtmpEncoder::makeConfigPacket() {
|
||||
header->enhanced = 1;
|
||||
header->pkt_type = (int)RtmpPacketType::PacketTypeSequenceStart;
|
||||
header->frame_type = (int)RtmpFrameType::key_frame;
|
||||
switch (getTrack()->getCodecId()) {
|
||||
case CodecVP8: header->fourcc = htonl((uint32_t)RtmpVideoCodec::fourcc_vp8); break;
|
||||
case CodecVP9: header->fourcc = htonl((uint32_t)RtmpVideoCodec::fourcc_vp9); break;
|
||||
case CodecAV1: header->fourcc = htonl((uint32_t)RtmpVideoCodec::fourcc_av1); break;
|
||||
default: break;
|
||||
}
|
||||
header->fourcc = htonl(getCodecFourCC(getTrack()->getCodecId()));
|
||||
} else {
|
||||
uint8_t flags = 0;
|
||||
switch (getTrack()->getCodecId()) {
|
||||
case CodecVP8: flags = (uint8_t)RtmpVideoCodec::vp8; break;
|
||||
case CodecVP9: flags = (uint8_t)RtmpVideoCodec::vp9; break;
|
||||
case CodecAV1: flags = (uint8_t)RtmpVideoCodec::av1; break;
|
||||
default: break;
|
||||
}
|
||||
uint8_t flags = getCodecFlags(getTrack()->getCodecId());
|
||||
flags |= ((uint8_t)RtmpFrameType::key_frame << 4);
|
||||
buff[0] = flags;
|
||||
buff[1] = (uint8_t)RtmpH264PacketType::h264_config_header;
|
||||
|
||||
Reference in New Issue
Block a user