Introduce NetEqFactory::Create taking Environment instead of the Clock
To propagate field trials into the NetEq and further towards Audio Decoders
Bug: webrtc:356878416
Change-Id: Ia7cf18451aef70441ca958bf652f492138c6051a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/358620
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42739}
diff --git a/api/neteq/BUILD.gn b/api/neteq/BUILD.gn
index b995b22..63881ae 100644
--- a/api/neteq/BUILD.gn
+++ b/api/neteq/BUILD.gn
@@ -21,9 +21,11 @@
"..:rtp_headers",
"..:rtp_packet_info",
"..:scoped_refptr",
+ "../../rtc_base:checks",
"../../rtc_base:stringutils",
"../../system_wrappers:system_wrappers",
"../audio_codecs:audio_codecs_api",
+ "../environment",
"../units:timestamp",
"//third_party/abseil-cpp/absl/types:optional",
]
diff --git a/api/neteq/neteq_factory.h b/api/neteq/neteq_factory.h
index 526a128..8ee3680 100644
--- a/api/neteq/neteq_factory.h
+++ b/api/neteq/neteq_factory.h
@@ -14,7 +14,10 @@
#include <memory>
#include "api/audio_codecs/audio_decoder_factory.h"
+#include "api/environment/environment.h"
#include "api/neteq/neteq.h"
+#include "api/scoped_refptr.h"
+#include "rtc_base/checks.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
@@ -27,10 +30,21 @@
// Creates a new NetEq object, with parameters set in `config`. The `config`
// object will only have to be valid for the duration of the call to this
// method.
+ virtual std::unique_ptr<NetEq> Create(
+ const Environment& env,
+ const NetEq::Config& config,
+ scoped_refptr<AudioDecoderFactory> decoder_factory) const {
+ return CreateNetEq(config, decoder_factory, &env.clock());
+ }
+
virtual std::unique_ptr<NetEq> CreateNetEq(
const NetEq::Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
- Clock* clock) const = 0;
+ Clock* clock) const {
+ // TODO: b/356878416 - Delete this function when all callers are migrated
+ // to `Create` function above.
+ RTC_CHECK_NOTREACHED();
+ }
};
} // namespace webrtc
diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc
index 13ad1a3..ca79a57 100644
--- a/modules/audio_coding/acm2/acm_receiver.cc
+++ b/modules/audio_coding/acm2/acm_receiver.cc
@@ -39,12 +39,12 @@
std::unique_ptr<NetEq> CreateNetEq(
NetEqFactory* neteq_factory,
const NetEq::Config& config,
- Clock* clock,
- const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
+ const Environment& env,
+ scoped_refptr<AudioDecoderFactory> decoder_factory) {
if (neteq_factory) {
- return neteq_factory->CreateNetEq(config, decoder_factory, clock);
+ return neteq_factory->Create(env, config, std::move(decoder_factory));
}
- return DefaultNetEqFactory().CreateNetEq(config, decoder_factory, clock);
+ return DefaultNetEqFactory().Create(env, config, std::move(decoder_factory));
}
} // namespace
@@ -60,8 +60,8 @@
: env_(env),
neteq_(CreateNetEq(config.neteq_factory,
config.neteq_config,
- &env_.clock(),
- config.decoder_factory)),
+ env_,
+ std::move(config.decoder_factory))),
resampled_last_output_frame_(true) {
ClearSamples(last_audio_buffer_);
}