Cleanup SimulcastEncoderAdapter - require webrtc::Environment at construction time
Bug: webrtc:15860
Change-Id: I1a786fb4b04112197e49c883884fc4b30f8d13f4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/343182
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41937}
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index ddfdc37..dbdc23a 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -151,7 +151,6 @@
"../../media:rtc_simulcast_encoder_adapter",
"../../rtc_base/system:rtc_export",
"../environment",
- "../transport:field_trial_based_config",
]
absl_deps = [
"//third_party/abseil-cpp/absl/strings",
diff --git a/api/video_codecs/builtin_video_encoder_factory.cc b/api/video_codecs/builtin_video_encoder_factory.cc
index 77a6d65..bbd5222 100644
--- a/api/video_codecs/builtin_video_encoder_factory.cc
+++ b/api/video_codecs/builtin_video_encoder_factory.cc
@@ -16,7 +16,6 @@
#include "absl/types/optional.h"
#include "api/environment/environment.h"
-#include "api/transport/field_trial_based_config.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_factory.h"
@@ -33,22 +32,6 @@
BuiltinVideoEncoderFactory()
: internal_encoder_factory_(new InternalEncoderFactory()) {}
- std::unique_ptr<VideoEncoder> CreateVideoEncoder(
- const SdpVideoFormat& format) override {
- // Try creating an InternalEncoderFactory-backed SimulcastEncoderAdapter.
- // The adapter has a passthrough mode for the case that simulcast is not
- // used, so all responsibility can be delegated to it.
- std::unique_ptr<VideoEncoder> encoder;
- if (format.IsCodecInList(
- internal_encoder_factory_->GetSupportedFormats())) {
- encoder = std::make_unique<SimulcastEncoderAdapter>(
- /*primary_factory=*/internal_encoder_factory_.get(),
- /*fallback_factory=*/nullptr, format, FieldTrialBasedConfig());
- }
-
- return encoder;
- }
-
std::unique_ptr<VideoEncoder> Create(const Environment& env,
const SdpVideoFormat& format) override {
// Try creating an InternalEncoderFactory-backed SimulcastEncoderAdapter.
diff --git a/media/BUILD.gn b/media/BUILD.gn
index a1a3603..2a8f28a 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -465,7 +465,6 @@
"../api:scoped_refptr",
"../api:sequence_checker",
"../api/environment",
- "../api/transport:field_trial_based_config",
"../api/video:video_codec_constants",
"../api/video:video_frame",
"../api/video:video_rtp_headers",
diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc
index d274c85..f95ccb0 100644
--- a/media/engine/simulcast_encoder_adapter.cc
+++ b/media/engine/simulcast_encoder_adapter.cc
@@ -22,7 +22,6 @@
#include "absl/types/optional.h"
#include "api/field_trials_view.h"
#include "api/scoped_refptr.h"
-#include "api/transport/field_trial_based_config.h"
#include "api/video/i420_buffer.h"
#include "api/video/video_codec_constants.h"
#include "api/video/video_frame_buffer.h"
@@ -251,38 +250,7 @@
absl::Nonnull<VideoEncoderFactory*> primary_factory,
absl::Nullable<VideoEncoderFactory*> fallback_factory,
const SdpVideoFormat& format)
- : SimulcastEncoderAdapter(&env,
- primary_factory,
- fallback_factory,
- format,
- env.field_trials()) {}
-
-SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory,
- const SdpVideoFormat& format)
- : SimulcastEncoderAdapter(/*env=*/nullptr,
- /*primary_factory=*/factory,
- /*fallback_factory=*/nullptr,
- format,
- FieldTrialBasedConfig()) {}
-
-SimulcastEncoderAdapter::SimulcastEncoderAdapter(
- VideoEncoderFactory* primary_factory,
- VideoEncoderFactory* fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials)
- : SimulcastEncoderAdapter(/*env=*/nullptr,
- primary_factory,
- fallback_factory,
- format,
- field_trials) {}
-
-SimulcastEncoderAdapter::SimulcastEncoderAdapter(
- absl::Nullable<const Environment*> env,
- absl::Nonnull<VideoEncoderFactory*> primary_factory,
- absl::Nullable<VideoEncoderFactory*> fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials)
- : env_(env != nullptr ? absl::make_optional(*env) : absl::nullopt),
+ : env_(env),
inited_(0),
primary_encoder_factory_(primary_factory),
fallback_encoder_factory_(fallback_factory),
@@ -291,11 +259,11 @@
bypass_mode_(false),
encoded_complete_callback_(nullptr),
experimental_boosted_screenshare_qp_(
- GetScreenshareBoostedQpValue(field_trials)),
+ GetScreenshareBoostedQpValue(env_.field_trials())),
boost_base_layer_quality_(
- RateControlSettings::ParseFromKeyValueConfig(&field_trials)
+ RateControlSettings::ParseFromKeyValueConfig(&env_.field_trials())
.Vp8BoostBaseLayerQuality()),
- prefer_temporal_support_on_base_layer_(field_trials.IsEnabled(
+ prefer_temporal_support_on_base_layer_(env_.field_trials().IsEnabled(
"WebRTC-Video-PreferTemporalSupportOnBaseLayer")),
per_layer_pli_(SupportsPerLayerPictureLossIndication(format.parameters)) {
RTC_DCHECK(primary_factory);
@@ -769,16 +737,11 @@
cached_encoder_contexts_.erase(encoder_context_iter);
} else {
std::unique_ptr<VideoEncoder> primary_encoder =
- env_.has_value()
- ? primary_encoder_factory_->Create(*env_, video_format_)
- : primary_encoder_factory_->CreateVideoEncoder(video_format_);
+ primary_encoder_factory_->Create(env_, video_format_);
std::unique_ptr<VideoEncoder> fallback_encoder;
if (fallback_encoder_factory_ != nullptr) {
- fallback_encoder =
- env_.has_value()
- ? fallback_encoder_factory_->Create(*env_, video_format_)
- : fallback_encoder_factory_->CreateVideoEncoder(video_format_);
+ fallback_encoder = fallback_encoder_factory_->Create(env_, video_format_);
}
std::unique_ptr<VideoEncoder> encoder;
diff --git a/media/engine/simulcast_encoder_adapter.h b/media/engine/simulcast_encoder_adapter.h
index 8732270..951eb85 100644
--- a/media/engine/simulcast_encoder_adapter.h
+++ b/media/engine/simulcast_encoder_adapter.h
@@ -51,15 +51,6 @@
absl::Nullable<VideoEncoderFactory*> fallback_factory,
const SdpVideoFormat& format);
- [[deprecated("bugs.webrtc.org/15860")]] SimulcastEncoderAdapter(
- VideoEncoderFactory* primarty_factory,
- const SdpVideoFormat& format);
-
- // TODO: bugs.webrtc.org/15860 - Deprecate or delete when not used by chromium
- SimulcastEncoderAdapter(VideoEncoderFactory* primary_factory,
- VideoEncoderFactory* fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials);
~SimulcastEncoderAdapter() override;
// Implements VideoEncoder.
@@ -153,12 +144,6 @@
bool is_paused_;
};
- SimulcastEncoderAdapter(absl::Nullable<const Environment*> env,
- absl::Nonnull<VideoEncoderFactory*> primary_factory,
- absl::Nullable<VideoEncoderFactory*> fallback_factory,
- const SdpVideoFormat& format,
- const FieldTrialsView& field_trials);
-
bool Initialized() const;
void DestroyStoredEncoders();
@@ -184,9 +169,7 @@
void OverrideFromFieldTrial(VideoEncoder::EncoderInfo* info) const;
- // TODO: bugs.webrtc.org/15860 - Make env_ non optional when deprecated
- // constructors are deleted.
- const absl::optional<Environment> env_;
+ const Environment env_;
std::atomic<int> inited_;
VideoEncoderFactory* const primary_encoder_factory_;
VideoEncoderFactory* const fallback_encoder_factory_;