mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-26 03:42:21 +08:00
完善ertmp相关代码 (#4505)
增加多种Codec支持,并修复一些bug: - opus 非标准实现,不输出config frame,与旧的实现保持一致 - 添加RTMP_CODEC_MAP宏,精简代码
This commit is contained in:
@@ -55,6 +55,33 @@ AudioMeta::AudioMeta(const AudioTrack::Ptr &audio) {
|
||||
_metadata.set("audiocodecid", Factory::getAmfByCodecId(audio->getCodecId()));
|
||||
}
|
||||
|
||||
uint8_t getCodecFlags(CodecId cid) {
|
||||
switch(cid) {
|
||||
#define XX(a, b, c) case a: return static_cast<uint8_t>(b);
|
||||
RTMP_CODEC_MAP(XX)
|
||||
#undef XX
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t getCodecFourCC(CodecId cid) {
|
||||
switch(cid) {
|
||||
#define XX(a, b, c) case a: return static_cast<uint32_t>(c);
|
||||
RTMP_CODEC_MAP(XX)
|
||||
#undef XX
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CodecId getFourccCodec(uint32_t id) {
|
||||
switch(id) {
|
||||
#define XX(a, b, c) case (uint32_t)c: return a;
|
||||
RTMP_CODEC_MAP(XX)
|
||||
#undef XX
|
||||
}
|
||||
return CodecInvalid;
|
||||
}
|
||||
|
||||
uint8_t getAudioRtmpFlags(const Track::Ptr &track) {
|
||||
track->update();
|
||||
switch (track->getTrackType()) {
|
||||
@@ -167,7 +194,13 @@ bool RtmpPacket::isVideoKeyFrame() const {
|
||||
bool RtmpPacket::isConfigFrame() const {
|
||||
switch (type_id) {
|
||||
case MSG_AUDIO: {
|
||||
return (RtmpAudioCodec)getRtmpCodecId() == RtmpAudioCodec::aac && (RtmpAACPacketType)buffer[1] == RtmpAACPacketType::aac_config_header;
|
||||
switch ((RtmpAudioCodec)getRtmpCodecId()) {
|
||||
case RtmpAudioCodec::aac:
|
||||
return (RtmpAACPacketType)buffer[1] == RtmpAACPacketType::aac_config_header;
|
||||
case RtmpAudioCodec::ex_header:
|
||||
return (RtmpPacketType)(buffer[0] & 0x0f) == RtmpPacketType::PacketTypeSequenceStart;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case MSG_VIDEO: {
|
||||
if (!isVideoKeyFrame()) {
|
||||
|
||||
Reference in New Issue
Block a user