Reland "Enable using a custom NetEqFactory in simulations"
This is a reland of 2a11b2451a4068746fa0c55fa210efd4a15e4423
There are no changes compared to the first attempt.
Original change's description:
> Enable using a custom NetEqFactory in simulations
>
> Bug: webrtc:11005
> Change-Id: I8a15f77953cbd3c29a75c7cfc77f926b138994b9
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165580
> Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#30286}
TBR=kwiberg
Bug: webrtc:11005
Change-Id: I4aa377e05916bd23f8f63aece9d0e27731c80d3e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166465
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30319}
diff --git a/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc b/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc
index 49eb1cc..daf81f2 100644
--- a/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc
@@ -186,8 +186,10 @@
NetEqTest::Callbacks callbacks;
NetEqTest neteq_test(
- config, new rtc::RefCountedObject<test::AudioDecoderProxyFactory>(&dec),
- decoders, nullptr, std::move(lossy_input), std::move(output), callbacks);
+ config, /*decoder_factory=*/
+ new rtc::RefCountedObject<test::AudioDecoderProxyFactory>(&dec),
+ /*codecs=*/decoders, /*text_log=*/nullptr, /*neteq_factory=*/nullptr,
+ /*input=*/std::move(lossy_input), std::move(output), callbacks);
EXPECT_LE(kRunTimeMs, neteq_test.Run());
auto lifetime_stats = neteq_test.LifetimeStats();
diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc
index 098bcc2..e284ddb 100644
--- a/modules/audio_coding/neteq/neteq_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_unittest.cc
@@ -1084,8 +1084,10 @@
new TimeLimitedNetEqInput(std::move(input), 20000));
std::unique_ptr<AudioSink> output(new VoidAudioSink);
NetEqTest::Callbacks callbacks;
- NetEqTest test(config, CreateBuiltinAudioDecoderFactory(), codecs, nullptr,
- std::move(input_time_limit), std::move(output), callbacks);
+ NetEqTest test(config, CreateBuiltinAudioDecoderFactory(), codecs,
+ /*text_log=*/nullptr, /*neteq_factory=*/nullptr,
+ /*input=*/std::move(input_time_limit), std::move(output),
+ callbacks);
test.Run();
const auto stats = test.SimulationStats();
EXPECT_EQ(0, stats.accelerate_rate);
diff --git a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
index b37bea1..16a789f 100644
--- a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
+++ b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
@@ -397,7 +397,8 @@
}
std::unique_ptr<webrtc::test::NetEqTest> test =
- factory.InitializeTestFromFile(/*input_filename=*/args[1], config);
+ factory.InitializeTestFromFile(/*input_filename=*/args[1],
+ /*factory=*/nullptr, config);
RTC_CHECK(test) << "ERROR: Unable to run test";
test->Run();
return 0;
diff --git a/modules/audio_coding/neteq/tools/neteq_test.cc b/modules/audio_coding/neteq/tools/neteq_test.cc
index a775453..f8b6161 100644
--- a/modules/audio_coding/neteq/tools/neteq_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_test.cc
@@ -63,11 +63,14 @@
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
const DecoderMap& codecs,
std::unique_ptr<std::ofstream> text_log,
+ NetEqFactory* neteq_factory,
std::unique_ptr<NetEqInput> input,
std::unique_ptr<AudioSink> output,
Callbacks callbacks)
: clock_(0),
- neteq_(CreateNetEq(config, &clock_, decoder_factory)),
+ neteq_(neteq_factory
+ ? neteq_factory->CreateNetEq(config, decoder_factory, &clock_)
+ : CreateNetEq(config, &clock_, decoder_factory)),
input_(std::move(input)),
output_(std::move(output)),
callbacks_(callbacks),
diff --git a/modules/audio_coding/neteq/tools/neteq_test.h b/modules/audio_coding/neteq/tools/neteq_test.h
index c6dbca7..afcc077 100644
--- a/modules/audio_coding/neteq/tools/neteq_test.h
+++ b/modules/audio_coding/neteq/tools/neteq_test.h
@@ -20,6 +20,7 @@
#include "absl/types/optional.h"
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/neteq/neteq.h"
+#include "api/neteq/neteq_factory.h"
#include "api/test/neteq_simulator.h"
#include "modules/audio_coding/neteq/tools/audio_sink.h"
#include "modules/audio_coding/neteq/tools/neteq_input.h"
@@ -83,6 +84,7 @@
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
const DecoderMap& codecs,
std::unique_ptr<std::ofstream> text_log,
+ NetEqFactory* neteq_factory,
std::unique_ptr<NetEqInput> input,
std::unique_ptr<AudioSink> output,
Callbacks callbacks);
diff --git a/modules/audio_coding/neteq/tools/neteq_test_factory.cc b/modules/audio_coding/neteq/tools/neteq_test_factory.cc
index f590091..f8ec36b 100644
--- a/modules/audio_coding/neteq/tools/neteq_test_factory.cc
+++ b/modules/audio_coding/neteq/tools/neteq_test_factory.cc
@@ -110,6 +110,7 @@
std::unique_ptr<NetEqTest> NetEqTestFactory::InitializeTestFromString(
const std::string& input_string,
+ NetEqFactory* factory,
const Config& config) {
std::unique_ptr<NetEqInput> input(
NetEqEventLogInput::CreateFromString(input_string, config.ssrc_filter));
@@ -117,11 +118,12 @@
std::cerr << "Error: Cannot parse input string" << std::endl;
return nullptr;
}
- return InitializeTest(std::move(input), config);
+ return InitializeTest(std::move(input), factory, config);
}
std::unique_ptr<NetEqTest> NetEqTestFactory::InitializeTestFromFile(
const std::string& input_file_name,
+ NetEqFactory* factory,
const Config& config) {
// Gather RTP header extensions in a map.
NetEqPacketSourceInput::RtpHeaderExtensionMap rtp_ext_map = {
@@ -146,11 +148,12 @@
std::cerr << "Error: Cannot open input file" << std::endl;
return nullptr;
}
- return InitializeTest(std::move(input), config);
+ return InitializeTest(std::move(input), factory, config);
}
std::unique_ptr<NetEqTest> NetEqTestFactory::InitializeTest(
std::unique_ptr<NetEqInput> input,
+ NetEqFactory* factory,
const Config& config) {
if (input->ended()) {
std::cerr << "Error: Input is empty" << std::endl;
@@ -330,9 +333,9 @@
neteq_config.sample_rate_hz = *sample_rate_hz;
neteq_config.max_packets_in_buffer = config.max_nr_packets_in_buffer;
neteq_config.enable_fast_accelerate = config.enable_fast_accelerate;
- return std::make_unique<NetEqTest>(neteq_config, decoder_factory, codecs,
- std::move(text_log), std::move(input),
- std::move(output), callbacks);
+ return std::make_unique<NetEqTest>(
+ neteq_config, decoder_factory, codecs, std::move(text_log), factory,
+ std::move(input), std::move(output), callbacks);
}
} // namespace test
diff --git a/modules/audio_coding/neteq/tools/neteq_test_factory.h b/modules/audio_coding/neteq/tools/neteq_test_factory.h
index 5fd55a7..b8ba8cc 100644
--- a/modules/audio_coding/neteq/tools/neteq_test_factory.h
+++ b/modules/audio_coding/neteq/tools/neteq_test_factory.h
@@ -147,13 +147,16 @@
std::unique_ptr<NetEqTest> InitializeTestFromFile(
const std::string& input_filename,
+ NetEqFactory* neteq_factory,
const Config& config);
std::unique_ptr<NetEqTest> InitializeTestFromString(
const std::string& input_string,
+ NetEqFactory* neteq_factory,
const Config& config);
private:
std::unique_ptr<NetEqTest> InitializeTest(std::unique_ptr<NetEqInput> input,
+ NetEqFactory* neteq_factory,
const Config& config);
std::unique_ptr<SsrcSwitchDetector> ssrc_switch_detector_;
std::unique_ptr<NetEqStatsPlotter> stats_plotter_;