Add AV1 to default video encoder factory

while checking for software supported codecs avoid creating encoder
factory to avoid linking av1 encoder and libaom.

Bug: webrtc:11404
Change-Id: I32771696efb59d98ba08592a20eb691b56622deb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172625
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30973}
This commit is contained in:
Danil Chapovalov
2020-04-01 18:15:32 +02:00
committed by Commit Bot
parent cfa0e8ffe2
commit 4553f45d2a
4 changed files with 15 additions and 4 deletions

View File

@ -247,6 +247,7 @@ rtc_library("rtc_internal_video_codecs") {
"../modules/video_coding:webrtc_vp8", "../modules/video_coding:webrtc_vp8",
"../modules/video_coding:webrtc_vp9", "../modules/video_coding:webrtc_vp9",
"../modules/video_coding/codecs/av1:libaom_av1_decoder", "../modules/video_coding/codecs/av1:libaom_av1_decoder",
"../modules/video_coding/codecs/av1:libaom_av1_encoder",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:deprecation", "../rtc_base:deprecation",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",

View File

@ -16,6 +16,7 @@
#include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/sdp_video_format.h"
#include "media/base/codec.h" #include "media/base/codec.h"
#include "media/base/media_constants.h" #include "media/base/media_constants.h"
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
#include "modules/video_coding/codecs/h264/include/h264.h" #include "modules/video_coding/codecs/h264/include/h264.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h" #include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "modules/video_coding/codecs/vp9/include/vp9.h" #include "modules/video_coding/codecs/vp9/include/vp9.h"
@ -23,17 +24,23 @@
namespace webrtc { namespace webrtc {
std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats() std::vector<SdpVideoFormat> InternalEncoderFactory::SupportedFormats() {
const {
std::vector<SdpVideoFormat> supported_codecs; std::vector<SdpVideoFormat> supported_codecs;
supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName)); supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName));
for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs()) for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs())
supported_codecs.push_back(format); supported_codecs.push_back(format);
for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs()) for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs())
supported_codecs.push_back(format); supported_codecs.push_back(format);
if (kIsLibaomAv1EncoderSupported)
supported_codecs.push_back(SdpVideoFormat(cricket::kAv1CodecName));
return supported_codecs; return supported_codecs;
} }
std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
const {
return SupportedFormats();
}
VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder( VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder(
const SdpVideoFormat& format) const { const SdpVideoFormat& format) const {
CodecInfo info; CodecInfo info;
@ -50,6 +57,9 @@ std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
return VP9Encoder::Create(cricket::VideoCodec(format)); return VP9Encoder::Create(cricket::VideoCodec(format));
if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName))
return H264Encoder::Create(cricket::VideoCodec(format)); return H264Encoder::Create(cricket::VideoCodec(format));
if (kIsLibaomAv1EncoderSupported &&
absl::EqualsIgnoreCase(format.name, cricket::kAv1CodecName))
return CreateLibaomAv1Encoder();
RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format " RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format "
<< format.name; << format.name;
return nullptr; return nullptr;

View File

@ -23,6 +23,7 @@ namespace webrtc {
class RTC_EXPORT InternalEncoderFactory : public VideoEncoderFactory { class RTC_EXPORT InternalEncoderFactory : public VideoEncoderFactory {
public: public:
static std::vector<SdpVideoFormat> SupportedFormats();
std::vector<SdpVideoFormat> GetSupportedFormats() const override; std::vector<SdpVideoFormat> GetSupportedFormats() const override;
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override; CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;

View File

@ -438,8 +438,7 @@ bool IsFormatSupported(const std::vector<SdpVideoFormat>& supported_formats,
bool MediaCodecVideoEncoder::ProcessHWError( bool MediaCodecVideoEncoder::ProcessHWError(
bool reset_if_fallback_unavailable) { bool reset_if_fallback_unavailable) {
ALOGE << "ProcessHWError"; ALOGE << "ProcessHWError";
if (IsFormatSupported(InternalEncoderFactory().GetSupportedFormats(), if (IsFormatSupported(InternalEncoderFactory::SupportedFormats(), format_)) {
format_)) {
ALOGE << "Fallback to SW encoder."; ALOGE << "Fallback to SW encoder.";
sw_fallback_required_ = true; sw_fallback_required_ = true;
return false; return false;