防止rtmp打包不支持的编码类型时频繁打印警告日志

This commit is contained in:
xia-chu 2024-12-01 10:20:01 +08:00
parent aa56576b0e
commit 8cf8e4ed5f

View File

@ -178,8 +178,9 @@ RtmpCodec::Ptr Factory::getRtmpDecoderByTrack(const Track::Ptr &track) {
RtmpCodec::Ptr Factory::getRtmpEncoderByTrack(const Track::Ptr &track) { RtmpCodec::Ptr Factory::getRtmpEncoderByTrack(const Track::Ptr &track) {
auto it = s_plugins.find(track->getCodecId()); auto it = s_plugins.find(track->getCodecId());
if (it == s_plugins.end()) { if (it == s_plugins.end()) {
WarnL << "Unsupported codec: " << track->getCodecName() << ", use CommonRtmpEncoder"; auto amf = Factory::getAmfByCodecId(track->getCodecId());
return std::make_shared<CommonRtmpEncoder>(track); WarnL << "Unsupported codec: " << track->getCodecName() << (amf ? ", use CommonRtmpEncoder" : "");
return amf ? std::make_shared<CommonRtmpEncoder>(track) : nullptr;
} }
return it->second->getRtmpEncoderByTrack(track); return it->second->getRtmpEncoderByTrack(track);
} }