summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/api/video_codecs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/libwebrtc/api/video_codecs
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--third_party/libwebrtc/api/video_codecs/BUILD.gn5
-rw-r--r--third_party/libwebrtc/api/video_codecs/av1_profile.cc6
-rw-r--r--third_party/libwebrtc/api/video_codecs/av1_profile.h3
-rw-r--r--third_party/libwebrtc/api/video_codecs/sdp_video_format.cc42
-rw-r--r--third_party/libwebrtc/api/video_codecs/test/BUILD.gn3
-rw-r--r--third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc15
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_codec.cc30
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_codec.h4
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build1
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc45
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_factory.h31
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h2
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc23
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h8
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc18
15 files changed, 195 insertions, 41 deletions
diff --git a/third_party/libwebrtc/api/video_codecs/BUILD.gn b/third_party/libwebrtc/api/video_codecs/BUILD.gn
index 3865f4fee7..9f7022ca67 100644
--- a/third_party/libwebrtc/api/video_codecs/BUILD.gn
+++ b/third_party/libwebrtc/api/video_codecs/BUILD.gn
@@ -58,6 +58,7 @@ rtc_library("video_codecs_api") {
"video_codec.h",
"video_decoder.cc",
"video_decoder.h",
+ "video_decoder_factory.cc",
"video_decoder_factory.h",
"video_encoder.cc",
"video_encoder.h",
@@ -84,6 +85,7 @@ rtc_library("video_codecs_api") {
"..:scoped_refptr",
"../../api:array_view",
"../../api:rtp_parameters",
+ "../../media:media_constants",
"../../modules/video_coding:codec_globals_headers",
"../../rtc_base:checks",
"../../rtc_base:logging",
@@ -91,6 +93,7 @@ rtc_library("video_codecs_api") {
"../../rtc_base:refcount",
"../../rtc_base:stringutils",
"../../rtc_base/system:rtc_export",
+ "../environment",
"../units:data_rate",
"../video:encoded_image",
"../video:render_resolution",
@@ -302,6 +305,8 @@ rtc_library("rtc_software_fallback_wrappers") {
deps = [
":video_codecs_api",
"..:fec_controller_api",
+ "../../api:field_trials_view",
+ "../../api/environment",
"../../api/transport:field_trial_based_config",
"../../api/video:video_frame",
"../../media:rtc_media_base",
diff --git a/third_party/libwebrtc/api/video_codecs/av1_profile.cc b/third_party/libwebrtc/api/video_codecs/av1_profile.cc
index 59d7b13e51..1a953a0c53 100644
--- a/third_party/libwebrtc/api/video_codecs/av1_profile.cc
+++ b/third_party/libwebrtc/api/video_codecs/av1_profile.cc
@@ -13,13 +13,11 @@
#include <map>
#include <utility>
+#include "media/base/media_constants.h"
#include "rtc_base/string_to_number.h"
namespace webrtc {
-// Parameter name in the format parameter map for AV1 video.
-const char kAV1FmtpProfile[] = "profile";
-
absl::string_view AV1ProfileToString(AV1Profile profile) {
switch (profile) {
case AV1Profile::kProfile0:
@@ -51,7 +49,7 @@ absl::optional<AV1Profile> StringToAV1Profile(absl::string_view str) {
absl::optional<AV1Profile> ParseSdpForAV1Profile(
const CodecParameterMap& params) {
- const auto profile_it = params.find(kAV1FmtpProfile);
+ const auto profile_it = params.find(cricket::kAv1FmtpProfile);
if (profile_it == params.end())
return AV1Profile::kProfile0;
const std::string& profile_str = profile_it->second;
diff --git a/third_party/libwebrtc/api/video_codecs/av1_profile.h b/third_party/libwebrtc/api/video_codecs/av1_profile.h
index bc9767631c..4651d93ef4 100644
--- a/third_party/libwebrtc/api/video_codecs/av1_profile.h
+++ b/third_party/libwebrtc/api/video_codecs/av1_profile.h
@@ -20,9 +20,6 @@
namespace webrtc {
-// Profile information for AV1 video.
-extern RTC_EXPORT const char kAV1FmtpProfile[];
-
// Profiles can be found at:
// https://aomedia.org/av1/specification/annex-a/#profiles
// The enum values match the number specified in the SDP.
diff --git a/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc b/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc
index 0f313e84a9..5abde8fbb0 100644
--- a/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc
+++ b/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc
@@ -20,6 +20,7 @@
#endif
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/vp9_profile.h"
+#include "media/base/media_constants.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
@@ -28,15 +29,21 @@ namespace webrtc {
namespace {
-std::string H264GetPacketizationModeOrDefault(const CodecParameterMap& params) {
- constexpr char kH264FmtpPacketizationMode[] = "packetization-mode";
- const auto it = params.find(kH264FmtpPacketizationMode);
+std::string GetFmtpParameterOrDefault(const CodecParameterMap& params,
+ const std::string& name,
+ const std::string& default_value) {
+ const auto it = params.find(name);
if (it != params.end()) {
return it->second;
}
+ return default_value;
+}
+
+std::string H264GetPacketizationModeOrDefault(const CodecParameterMap& params) {
// If packetization-mode is not present, default to "0".
// https://tools.ietf.org/html/rfc6184#section-6.2
- return "0";
+ return GetFmtpParameterOrDefault(params, cricket::kH264FmtpPacketizationMode,
+ "0");
}
bool H264IsSamePacketizationMode(const CodecParameterMap& left,
@@ -45,6 +52,28 @@ bool H264IsSamePacketizationMode(const CodecParameterMap& left,
H264GetPacketizationModeOrDefault(right);
}
+std::string AV1GetTierOrDefault(const CodecParameterMap& params) {
+ // If the parameter is not present, the tier MUST be inferred to be 0.
+ // https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters
+ return GetFmtpParameterOrDefault(params, cricket::kAv1FmtpTier, "0");
+}
+
+bool AV1IsSameTier(const CodecParameterMap& left,
+ const CodecParameterMap& right) {
+ return AV1GetTierOrDefault(left) == AV1GetTierOrDefault(right);
+}
+
+std::string AV1GetLevelIdxOrDefault(const CodecParameterMap& params) {
+ // If the parameter is not present, it MUST be inferred to be 5 (level 3.1).
+ // https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters
+ return GetFmtpParameterOrDefault(params, cricket::kAv1FmtpLevelIdx, "5");
+}
+
+bool AV1IsSameLevelIdx(const CodecParameterMap& left,
+ const CodecParameterMap& right) {
+ return AV1GetLevelIdxOrDefault(left) == AV1GetLevelIdxOrDefault(right);
+}
+
// Some (video) codecs are actually families of codecs and rely on parameters
// to distinguish different incompatible family members.
bool IsSameCodecSpecific(const SdpVideoFormat& format1,
@@ -62,7 +91,9 @@ bool IsSameCodecSpecific(const SdpVideoFormat& format1,
case kVideoCodecVP9:
return VP9IsSameProfile(format1.parameters, format2.parameters);
case kVideoCodecAV1:
- return AV1IsSameProfile(format1.parameters, format2.parameters);
+ return AV1IsSameProfile(format1.parameters, format2.parameters) &&
+ AV1IsSameTier(format1.parameters, format2.parameters) &&
+ AV1IsSameLevelIdx(format1.parameters, format2.parameters);
#ifdef RTC_ENABLE_H265
case kVideoCodecH265:
return H265IsSameProfileTierLevel(format1.parameters, format2.parameters);
@@ -71,6 +102,7 @@ bool IsSameCodecSpecific(const SdpVideoFormat& format1,
return true;
}
}
+
} // namespace
SdpVideoFormat::SdpVideoFormat(const std::string& name) : name(name) {}
diff --git a/third_party/libwebrtc/api/video_codecs/test/BUILD.gn b/third_party/libwebrtc/api/video_codecs/test/BUILD.gn
index 7bfe86e9f4..be897ae124 100644
--- a/third_party/libwebrtc/api/video_codecs/test/BUILD.gn
+++ b/third_party/libwebrtc/api/video_codecs/test/BUILD.gn
@@ -39,10 +39,13 @@ if (rtc_include_tests) {
"../../../modules/video_coding:webrtc_vp8",
"../../../rtc_base:checks",
"../../../rtc_base:rtc_base_tests_utils",
+ "../../../test:explicit_key_value_config",
"../../../test:fake_video_codecs",
"../../../test:field_trial",
"../../../test:test_support",
"../../../test:video_test_common",
+ "../../environment",
+ "../../environment:environment_factory",
"../../video:encoded_image",
"../../video:video_bitrate_allocation",
"../../video:video_frame",
diff --git a/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc b/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
index 97be6250db..bd837605b0 100644
--- a/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
+++ b/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
@@ -13,6 +13,8 @@
#include <stdint.h>
#include "absl/types/optional.h"
+#include "api/environment/environment.h"
+#include "api/environment/environment_factory.h"
#include "api/video/encoded_image.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/video_decoder.h"
@@ -20,7 +22,7 @@
#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/include/video_error_codes.h"
#include "rtc_base/checks.h"
-#include "test/field_trial.h"
+#include "test/explicit_key_value_config.h"
#include "test/gtest.h"
namespace webrtc {
@@ -31,10 +33,12 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test {
: VideoDecoderSoftwareFallbackWrapperTest("") {}
explicit VideoDecoderSoftwareFallbackWrapperTest(
const std::string& field_trials)
- : override_field_trials_(field_trials),
+ : field_trials_(field_trials),
+ env_(CreateEnvironment(&field_trials_)),
fake_decoder_(new CountingFakeDecoder()),
fallback_wrapper_(CreateVideoDecoderSoftwareFallbackWrapper(
- std::unique_ptr<VideoDecoder>(VP8Decoder::Create()),
+ env_,
+ CreateVp8Decoder(env_),
std::unique_ptr<VideoDecoder>(fake_decoder_))) {}
class CountingFakeDecoder : public VideoDecoder {
@@ -71,7 +75,8 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test {
int release_count_ = 0;
int reset_count_ = 0;
};
- test::ScopedFieldTrials override_field_trials_;
+ test::ExplicitKeyValueConfig field_trials_;
+ const Environment env_;
// `fake_decoder_` is owned and released by `fallback_wrapper_`.
CountingFakeDecoder* fake_decoder_;
std::unique_ptr<VideoDecoder> fallback_wrapper_;
@@ -275,7 +280,7 @@ class ForcedSoftwareDecoderFallbackTest
fake_decoder_ = new CountingFakeDecoder();
sw_fallback_decoder_ = new CountingFakeDecoder();
fallback_wrapper_ = CreateVideoDecoderSoftwareFallbackWrapper(
- std::unique_ptr<VideoDecoder>(sw_fallback_decoder_),
+ env_, std::unique_ptr<VideoDecoder>(sw_fallback_decoder_),
std::unique_ptr<VideoDecoder>(fake_decoder_));
}
diff --git a/third_party/libwebrtc/api/video_codecs/video_codec.cc b/third_party/libwebrtc/api/video_codecs/video_codec.cc
index 39a345d699..82c9bfc8ea 100644
--- a/third_party/libwebrtc/api/video_codecs/video_codec.cc
+++ b/third_party/libwebrtc/api/video_codecs/video_codec.cc
@@ -16,6 +16,7 @@
#include "absl/strings/match.h"
#include "rtc_base/checks.h"
+#include "rtc_base/strings/string_builder.h"
namespace webrtc {
namespace {
@@ -73,6 +74,35 @@ VideoCodec::VideoCodec()
codec_specific_(),
complexity_(VideoCodecComplexity::kComplexityNormal) {}
+std::string VideoCodec::ToString() const {
+ char string_buf[2048];
+ rtc::SimpleStringBuilder ss(string_buf);
+
+ ss << "VideoCodec {" << "type: " << CodecTypeToPayloadString(codecType)
+ << ", mode: "
+ << (mode == VideoCodecMode::kRealtimeVideo ? "RealtimeVideo"
+ : "Screensharing");
+ if (IsSinglecast()) {
+ absl::optional<ScalabilityMode> scalability_mode = GetScalabilityMode();
+ if (scalability_mode.has_value()) {
+ ss << ", Singlecast: {" << width << "x" << height << " "
+ << ScalabilityModeToString(*scalability_mode)
+ << (active ? ", active" : ", inactive") << "}";
+ }
+ } else {
+ ss << ", Simulcast: {";
+ for (size_t i = 0; i < numberOfSimulcastStreams; ++i) {
+ const SimulcastStream stream = simulcastStream[i];
+ ss << "[" << stream.width << "x" << stream.height << " "
+ << ScalabilityModeToString(stream.GetScalabilityMode())
+ << (stream.active ? ", active" : ", inactive") << "]";
+ }
+ ss << "}";
+ }
+ ss << "}";
+ return ss.str();
+}
+
VideoCodecVP8* VideoCodec::VP8() {
RTC_DCHECK_EQ(codecType, kVideoCodecVP8);
return &codec_specific_.VP8;
diff --git a/third_party/libwebrtc/api/video_codecs/video_codec.h b/third_party/libwebrtc/api/video_codecs/video_codec.h
index a596af1528..e48ffd4b5f 100644
--- a/third_party/libwebrtc/api/video_codecs/video_codec.h
+++ b/third_party/libwebrtc/api/video_codecs/video_codec.h
@@ -141,6 +141,9 @@ class RTC_EXPORT VideoCodec {
bool GetFrameDropEnabled() const;
void SetFrameDropEnabled(bool enabled);
+ bool IsSinglecast() const { return numberOfSimulcastStreams <= 1; }
+ bool IsSimulcast() const { return !IsSinglecast(); }
+
// Public variables. TODO(hta): Make them private with accessors.
VideoCodecType codecType;
@@ -193,6 +196,7 @@ class RTC_EXPORT VideoCodec {
bool operator==(const VideoCodec& other) const = delete;
bool operator!=(const VideoCodec& other) const = delete;
+ std::string ToString() const;
// Accessors for codec specific information.
// There is a const version of each that returns a reference,
diff --git a/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build b/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
index c6c127e5b6..13a1c027cf 100644
--- a/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
+++ b/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
@@ -38,6 +38,7 @@ UNIFIED_SOURCES += [
"/third_party/libwebrtc/api/video_codecs/spatial_layer.cc",
"/third_party/libwebrtc/api/video_codecs/video_codec.cc",
"/third_party/libwebrtc/api/video_codecs/video_decoder.cc",
+ "/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc",
"/third_party/libwebrtc/api/video_codecs/video_encoder.cc",
"/third_party/libwebrtc/api/video_codecs/vp8_frame_config.cc",
"/third_party/libwebrtc/api/video_codecs/vp8_temporal_layers.cc",
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc
new file mode 100644
index 0000000000..60fe92bf38
--- /dev/null
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "api/video_codecs/video_decoder_factory.h"
+
+#include <memory>
+
+#include "api/video_codecs/sdp_video_format.h"
+#include "api/video_codecs/video_decoder.h"
+#include "rtc_base/checks.h"
+
+namespace webrtc {
+
+VideoDecoderFactory::CodecSupport VideoDecoderFactory::QueryCodecSupport(
+ const SdpVideoFormat& format,
+ bool reference_scaling) const {
+ // Default implementation, query for supported formats and check if the
+ // specified format is supported. Returns false if `reference_scaling` is
+ // true.
+ return {.is_supported = !reference_scaling &&
+ format.IsCodecInList(GetSupportedFormats())};
+}
+
+std::unique_ptr<VideoDecoder> VideoDecoderFactory::Create(
+ const Environment& env,
+ const SdpVideoFormat& format) {
+ return CreateVideoDecoder(format);
+}
+
+std::unique_ptr<VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(
+ const SdpVideoFormat& format) {
+ // Newer code shouldn't call this function,
+ // Older code should implement it in derived classes.
+ RTC_CHECK_NOTREACHED();
+ return nullptr;
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h
index 7e1d2ee883..6048cb27fb 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h
@@ -12,17 +12,15 @@
#define API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_
#include <memory>
-#include <string>
#include <vector>
-#include "absl/types/optional.h"
+#include "api/environment/environment.h"
#include "api/video_codecs/sdp_video_format.h"
+#include "api/video_codecs/video_decoder.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
-class VideoDecoder;
-
// A factory that creates VideoDecoders.
// NOTE: This class is still under development and may change without notice.
class RTC_EXPORT VideoDecoderFactory {
@@ -32,6 +30,8 @@ class RTC_EXPORT VideoDecoderFactory {
bool is_power_efficient = false;
};
+ virtual ~VideoDecoderFactory() = default;
+
// Returns a list of supported video formats in order of preference, to use
// for signaling etc.
virtual std::vector<SdpVideoFormat> GetSupportedFormats() const = 0;
@@ -47,21 +47,18 @@ class RTC_EXPORT VideoDecoderFactory {
// different scalabilty modes. NOTE: QueryCodecSupport is currently an
// experimental feature that is subject to change without notice.
virtual CodecSupport QueryCodecSupport(const SdpVideoFormat& format,
- bool reference_scaling) const {
- // Default implementation, query for supported formats and check if the
- // specified format is supported. Returns false if `reference_scaling` is
- // true.
- CodecSupport codec_support;
- codec_support.is_supported =
- !reference_scaling && format.IsCodecInList(GetSupportedFormats());
- return codec_support;
- }
+ bool reference_scaling) const;
- // Creates a VideoDecoder for the specified format.
- virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder(
- const SdpVideoFormat& format) = 0;
+ // Creates a VideoDecoder for the specified `format`.
+ // TODO: bugs.webrtc.org/15791 - Make pure virtual when implemented in all
+ // derived classes.
+ virtual std::unique_ptr<VideoDecoder> Create(const Environment& env,
+ const SdpVideoFormat& format);
- virtual ~VideoDecoderFactory() {}
+ // TODO: bugs.webrtc.org/15791 - Make private or delete when all callers are
+ // migrated to `Create`.
+ virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder(
+ const SdpVideoFormat& format);
};
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h b/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h
index bffbdc43d3..f38d46994b 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h
@@ -23,7 +23,7 @@ struct Dav1dDecoderTemplateAdapter {
static std::vector<SdpVideoFormat> SupportedFormats() {
return {SdpVideoFormat("AV1"),
SdpVideoFormat(
- "AV1", {{kAV1FmtpProfile,
+ "AV1", {{"profile",
AV1ProfileToString(AV1Profile::kProfile1).data()}})};
}
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc
index 2af4d39b3a..623888b9e2 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc
@@ -16,6 +16,7 @@
#include <string>
#include <utility>
+#include "api/field_trials_view.h"
#include "api/video/encoded_image.h"
#include "api/video_codecs/video_decoder.h"
#include "modules/video_coding/include/video_error_codes.h"
@@ -35,7 +36,8 @@ class VideoDecoderSoftwareFallbackWrapper final : public VideoDecoder {
public:
VideoDecoderSoftwareFallbackWrapper(
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
- std::unique_ptr<VideoDecoder> hw_decoder);
+ std::unique_ptr<VideoDecoder> hw_decoder,
+ bool force_sw_decoder_fallback);
~VideoDecoderSoftwareFallbackWrapper() override;
bool Configure(const Settings& settings) override;
@@ -67,6 +69,7 @@ class VideoDecoderSoftwareFallbackWrapper final : public VideoDecoder {
} decoder_type_;
std::unique_ptr<VideoDecoder> hw_decoder_;
+ const bool force_sw_decoder_fallback_;
Settings decoder_settings_;
const std::unique_ptr<VideoDecoder> fallback_decoder_;
const std::string fallback_implementation_name_;
@@ -77,9 +80,11 @@ class VideoDecoderSoftwareFallbackWrapper final : public VideoDecoder {
VideoDecoderSoftwareFallbackWrapper::VideoDecoderSoftwareFallbackWrapper(
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
- std::unique_ptr<VideoDecoder> hw_decoder)
+ std::unique_ptr<VideoDecoder> hw_decoder,
+ bool force_sw_decoder_fallback)
: decoder_type_(DecoderType::kNone),
hw_decoder_(std::move(hw_decoder)),
+ force_sw_decoder_fallback_(force_sw_decoder_fallback),
fallback_decoder_(std::move(sw_fallback_decoder)),
fallback_implementation_name_(
fallback_decoder_->GetDecoderInfo().implementation_name +
@@ -94,7 +99,7 @@ VideoDecoderSoftwareFallbackWrapper::~VideoDecoderSoftwareFallbackWrapper() =
bool VideoDecoderSoftwareFallbackWrapper::Configure(const Settings& settings) {
decoder_settings_ = settings;
- if (webrtc::field_trial::IsEnabled("WebRTC-Video-ForcedSwDecoderFallback")) {
+ if (force_sw_decoder_fallback_) {
RTC_LOG(LS_INFO) << "Forced software decoder fallback enabled.";
RTC_DCHECK(decoder_type_ == DecoderType::kNone);
return InitFallbackDecoder();
@@ -276,10 +281,20 @@ VideoDecoder& VideoDecoderSoftwareFallbackWrapper::active_decoder() const {
} // namespace
std::unique_ptr<VideoDecoder> CreateVideoDecoderSoftwareFallbackWrapper(
+ const Environment& env,
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
std::unique_ptr<VideoDecoder> hw_decoder) {
return std::make_unique<VideoDecoderSoftwareFallbackWrapper>(
- std::move(sw_fallback_decoder), std::move(hw_decoder));
+ std::move(sw_fallback_decoder), std::move(hw_decoder),
+ env.field_trials().IsEnabled("WebRTC-Video-ForcedSwDecoderFallback"));
+}
+
+std::unique_ptr<VideoDecoder> CreateVideoDecoderSoftwareFallbackWrapper(
+ std::unique_ptr<VideoDecoder> sw_fallback_decoder,
+ std::unique_ptr<VideoDecoder> hw_decoder) {
+ return std::make_unique<VideoDecoderSoftwareFallbackWrapper>(
+ std::move(sw_fallback_decoder), std::move(hw_decoder),
+ webrtc::field_trial::IsEnabled("WebRTC-Video-ForcedSwDecoderFallback"));
}
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h
index 3f44e02b26..4fbc9a0048 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h
@@ -13,6 +13,7 @@
#include <memory>
+#include "api/environment/environment.h"
#include "api/video_codecs/video_decoder.h"
#include "rtc_base/system/rtc_export.h"
@@ -23,6 +24,13 @@ namespace webrtc {
// hardware restrictions, such as max resolution.
RTC_EXPORT std::unique_ptr<VideoDecoder>
CreateVideoDecoderSoftwareFallbackWrapper(
+ const Environment& env,
+ std::unique_ptr<VideoDecoder> sw_fallback_decoder,
+ std::unique_ptr<VideoDecoder> hw_decoder);
+
+// TODO: bugs.webrtc.org/15791 - Deprecated, remove when not used by chromium.
+RTC_EXPORT std::unique_ptr<VideoDecoder>
+CreateVideoDecoderSoftwareFallbackWrapper(
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
std::unique_ptr<VideoDecoder> hw_decoder);
diff --git a/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc b/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc
index d35c9f9950..e50b5086e8 100644
--- a/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc
+++ b/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc
@@ -28,6 +28,7 @@
#include "api/video_codecs/video_encoder.h"
#include "media/base/video_common.h"
#include "modules/video_coding/include/video_error_codes.h"
+#include "modules/video_coding/include/video_error_codes_utils.h"
#include "modules/video_coding/utility/simulcast_utility.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
@@ -264,14 +265,17 @@ void VideoEncoderSoftwareFallbackWrapper::PrimeEncoder(
}
bool VideoEncoderSoftwareFallbackWrapper::InitFallbackEncoder(bool is_forced) {
- RTC_LOG(LS_WARNING) << "Encoder falling back to software encoding.";
+ RTC_LOG(LS_WARNING) << "[VESFW] " << __func__
+ << "(is_forced=" << (is_forced ? "true" : "false") << ")";
RTC_DCHECK(encoder_settings_.has_value());
const int ret = fallback_encoder_->InitEncode(&codec_settings_,
encoder_settings_.value());
if (ret != WEBRTC_VIDEO_CODEC_OK) {
- RTC_LOG(LS_ERROR) << "Failed to initialize software-encoder fallback.";
+ RTC_LOG(LS_ERROR)
+ << "[VESFW] software-encoder fallback initialization failed with"
+ << " error code: " << WebRtcVideoCodecErrorToString(ret);
fallback_encoder_->Release();
return false;
}
@@ -305,6 +309,12 @@ void VideoEncoderSoftwareFallbackWrapper::SetFecControllerOverride(
int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode(
const VideoCodec* codec_settings,
const VideoEncoder::Settings& settings) {
+ RTC_LOG(LS_INFO) << "[VESFW] " << __func__
+ << "(codec=" << codec_settings->ToString()
+ << ", settings={number_of_cores: "
+ << settings.number_of_cores
+ << ", max_payload_size: " << settings.max_payload_size
+ << "})";
// Store settings, in case we need to dynamically switch to the fallback
// encoder after a failed Encode call.
codec_settings_ = *codec_settings;
@@ -327,6 +337,8 @@ int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode(
PrimeEncoder(current_encoder());
return ret;
}
+ RTC_LOG(LS_WARNING) << "[VESFW] Hardware encoder initialization failed with"
+ << " error code: " << WebRtcVideoCodecErrorToString(ret);
// Try to instantiate software codec.
if (InitFallbackEncoder(/*is_forced=*/false)) {
@@ -335,6 +347,8 @@ int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode(
}
// Software encoder failed too, use original return code.
+ RTC_LOG(LS_WARNING)
+ << "[VESFW] Software fallback encoder initialization also failed.";
encoder_state_ = EncoderState::kUninitialized;
return ret;
}