Avoid depending on testonly target in event_log_visualizer_utils.

This is done by creating a custom ReplacementAudioDecoderFactory.

Bug: webrtc:8396, webrtc:10080
Change-Id: Ie1cb614fec855b82d65c6ef86c3593f547254559
Reviewed-on: https://webrtc-review.googlesource.com/c/116795
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26217}
This commit is contained in:
Bjorn Terelius
2019-01-11 13:01:29 +01:00
committed by Commit Bot
parent ba50223363
commit 6c4b1b7ade
2 changed files with 38 additions and 14 deletions

View File

@ -238,7 +238,6 @@ if (!build_with_chromium) {
rtc_static_library("event_log_visualizer_utils") { rtc_static_library("event_log_visualizer_utils") {
visibility = [ "*" ] visibility = [ "*" ]
testonly = true
sources = [ sources = [
"event_log_visualizer/analyzer.cc", "event_log_visualizer/analyzer.cc",
"event_log_visualizer/analyzer.h", "event_log_visualizer/analyzer.h",
@ -283,8 +282,8 @@ if (!build_with_chromium) {
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base:rtc_numerics", "../rtc_base:rtc_numerics",
"../rtc_base:stringutils", "../rtc_base:stringutils",
"../test:audio_codec_mocks",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
] ]
} }
} }

View File

@ -18,6 +18,7 @@
#include <utility> #include <utility>
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "api/transport/goog_cc_factory.h" #include "api/transport/goog_cc_factory.h"
#include "call/audio_receive_stream.h" #include "call/audio_receive_stream.h"
#include "call/audio_send_stream.h" #include "call/audio_send_stream.h"
@ -57,7 +58,6 @@
#include "rtc_base/numerics/sequence_number_util.h" #include "rtc_base/numerics/sequence_number_util.h"
#include "rtc_base/rate_statistics.h" #include "rtc_base/rate_statistics.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "test/function_audio_decoder_factory.h"
#ifndef BWE_TEST_LOGGING_COMPILE_TIME_ENABLE #ifndef BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
#define BWE_TEST_LOGGING_COMPILE_TIME_ENABLE 0 #define BWE_TEST_LOGGING_COMPILE_TIME_ENABLE 0
@ -1695,6 +1695,40 @@ class NetEqStreamInput : public test::NetEqInput {
}; };
namespace { 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<AudioCodecSpec> GetSupportedDecoders() override {
RTC_NOTREACHED();
return {};
}
bool IsSupportedDecoder(const SdpAudioFormat& format) override {
return true;
}
std::unique_ptr<AudioDecoder> MakeAudioDecoder(
const SdpAudioFormat& format,
absl::optional<AudioCodecPairId> codec_pair_id) override {
auto replacement_file = absl::make_unique<test::ResampleInputAudioFile>(
replacement_file_name_, file_sample_rate_hz_);
replacement_file->set_output_rate_hz(48000);
return absl::make_unique<test::FakeDecodeFromFile>(
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 // Creates a NetEq test object and all necessary input and output helpers. Runs
// the test and returns the NetEqDelayAnalyzer object that was used to // the test and returns the NetEqDelayAnalyzer object that was used to
// instrument the test. // instrument the test.
@ -1719,18 +1753,9 @@ std::unique_ptr<test::NetEqStatsGetter> CreateNetEqTestAndRun(
std::unique_ptr<test::VoidAudioSink> output(new test::VoidAudioSink()); std::unique_ptr<test::VoidAudioSink> 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<AudioDecoderFactory> decoder_factory = rtc::scoped_refptr<AudioDecoderFactory> decoder_factory =
new rtc::RefCountedObject<test::FunctionAudioDecoderFactory>( new rtc::RefCountedObject<ReplacementAudioDecoderFactory>(
[replacement_file_name, file_sample_rate_hz]() { replacement_file_name, file_sample_rate_hz);
std::unique_ptr<test::ResampleInputAudioFile> replacement_file(
new test::ResampleInputAudioFile(replacement_file_name,
file_sample_rate_hz));
replacement_file->set_output_rate_hz(48000);
return absl::make_unique<test::FakeDecodeFromFile>(
std::move(replacement_file), 48000, false);
});
test::NetEqTest::DecoderMap codecs = { test::NetEqTest::DecoderMap codecs = {
{kReplacementPt, SdpAudioFormat("l16", 48000, 1)}}; {kReplacementPt, SdpAudioFormat("l16", 48000, 1)}};