diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn index 10f78be23c..b77d67145c 100644 --- a/rtc_tools/BUILD.gn +++ b/rtc_tools/BUILD.gn @@ -238,7 +238,6 @@ if (!build_with_chromium) { rtc_static_library("event_log_visualizer_utils") { visibility = [ "*" ] - testonly = true sources = [ "event_log_visualizer/analyzer.cc", "event_log_visualizer/analyzer.h", @@ -283,8 +282,8 @@ if (!build_with_chromium) { "../rtc_base:rtc_base_approved", "../rtc_base:rtc_numerics", "../rtc_base:stringutils", - "../test:audio_codec_mocks", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", ] } } diff --git a/rtc_tools/event_log_visualizer/analyzer.cc b/rtc_tools/event_log_visualizer/analyzer.cc index 1f3ad7457b..13b46ac24f 100644 --- a/rtc_tools/event_log_visualizer/analyzer.cc +++ b/rtc_tools/event_log_visualizer/analyzer.cc @@ -18,6 +18,7 @@ #include #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "api/transport/goog_cc_factory.h" #include "call/audio_receive_stream.h" #include "call/audio_send_stream.h" @@ -57,7 +58,6 @@ #include "rtc_base/numerics/sequence_number_util.h" #include "rtc_base/rate_statistics.h" #include "rtc_base/strings/string_builder.h" -#include "test/function_audio_decoder_factory.h" #ifndef BWE_TEST_LOGGING_COMPILE_TIME_ENABLE #define BWE_TEST_LOGGING_COMPILE_TIME_ENABLE 0 @@ -1695,6 +1695,40 @@ class NetEqStreamInput : public test::NetEqInput { }; namespace { + +// Factory to create a "replacement decoder" that produces the decoded audio +// by reading from a file rather than from the encoded payloads. +class ReplacementAudioDecoderFactory : public AudioDecoderFactory { + public: + ReplacementAudioDecoderFactory(const absl::string_view replacement_file_name, + int file_sample_rate_hz) + : replacement_file_name_(replacement_file_name), + file_sample_rate_hz_(file_sample_rate_hz) {} + + std::vector GetSupportedDecoders() override { + RTC_NOTREACHED(); + return {}; + } + + bool IsSupportedDecoder(const SdpAudioFormat& format) override { + return true; + } + + std::unique_ptr MakeAudioDecoder( + const SdpAudioFormat& format, + absl::optional codec_pair_id) override { + auto replacement_file = absl::make_unique( + replacement_file_name_, file_sample_rate_hz_); + replacement_file->set_output_rate_hz(48000); + return absl::make_unique( + std::move(replacement_file), 48000, false); + } + + private: + const std::string replacement_file_name_; + const int file_sample_rate_hz_; +}; + // Creates a NetEq test object and all necessary input and output helpers. Runs // the test and returns the NetEqDelayAnalyzer object that was used to // instrument the test. @@ -1719,18 +1753,9 @@ std::unique_ptr CreateNetEqTestAndRun( std::unique_ptr output(new test::VoidAudioSink()); - // Factory to create a "replacement decoder" that produces the decoded audio - // by reading from a file rather than from the encoded payloads. rtc::scoped_refptr decoder_factory = - new rtc::RefCountedObject( - [replacement_file_name, file_sample_rate_hz]() { - std::unique_ptr replacement_file( - new test::ResampleInputAudioFile(replacement_file_name, - file_sample_rate_hz)); - replacement_file->set_output_rate_hz(48000); - return absl::make_unique( - std::move(replacement_file), 48000, false); - }); + new rtc::RefCountedObject( + replacement_file_name, file_sample_rate_hz); test::NetEqTest::DecoderMap codecs = { {kReplacementPt, SdpAudioFormat("l16", 48000, 1)}};