Refactor NetEqDecoderPlc to use AudioDecoderProxyFactory

Bug: webrtc:10080
Change-Id: I651efc70fa020e345776c44d9510245c45f9b092
Reviewed-on: https://webrtc-review.googlesource.com/c/114547
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26067}
This commit is contained in:
Niels Möller 2018-12-17 13:06:10 +01:00 committed by Commit Bot
parent f65309cd47
commit 29a935a7fe
2 changed files with 13 additions and 8 deletions

View file

@ -15,7 +15,6 @@
#include <vector>
#include "absl/types/optional.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h"
#include "modules/audio_coding/neteq/tools/audio_checksum.h"
#include "modules/audio_coding/neteq/tools/audio_sink.h"
@ -24,6 +23,8 @@
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
#include "modules/audio_coding/neteq/tools/neteq_test.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/refcountedobject.h"
#include "test/audio_decoder_proxy_factory.h"
#include "test/gtest.h"
#include "test/testsupport/fileutils.h"
@ -175,10 +176,7 @@ NetEqNetworkStatistics RunTest(int loss_cadence, std::string* checksum) {
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"));
AudioDecoderPlc dec(std::move(input_file), kSampleRateHz);
// Masquerading as a PCM16b decoder.
NetEqTest::ExternalDecoderInfo dec_info = {
&dec, NetEqDecoder::kDecoderPCM16Bswb32kHz, "pcm16b_PLC"};
NetEqTest::ExtDecoderMap external_decoders;
external_decoders.insert(std::make_pair(kPayloadType, dec_info));
decoders[kPayloadType] = {NetEqDecoder::kDecoderPCM16Bswb32kHz, "pcm16b_PLC"};
// Output is simply a checksum calculator.
auto output = absl::make_unique<AudioChecksumWithOutput>(checksum);
@ -186,9 +184,11 @@ NetEqNetworkStatistics RunTest(int loss_cadence, std::string* checksum) {
// No callback objects.
NetEqTest::Callbacks callbacks;
NetEqTest neteq_test(config, CreateBuiltinAudioDecoderFactory(), decoders,
external_decoders, nullptr, std::move(lossy_input),
std::move(output), callbacks);
NetEqTest::ExtDecoderMap external_decoders;
NetEqTest neteq_test(
config, new rtc::RefCountedObject<test::AudioDecoderProxyFactory>(&dec),
decoders, external_decoders, nullptr, std::move(lossy_input),
std::move(output), callbacks);
EXPECT_LE(kRunTimeMs, neteq_test.Run());
auto lifetime_stats = neteq_test.LifetimeStats();

View file

@ -83,6 +83,11 @@ class AudioDecoderProxyFactory : public AudioDecoderFactory {
max_decoded_bytes, decoded, speech_type);
}
void GeneratePlc(size_t requested_samples_per_channel,
rtc::BufferT<int16_t>* concealment_audio) override {
decoder_->GeneratePlc(requested_samples_per_channel, concealment_audio);
}
AudioDecoder* const decoder_;
};