Replace RegisterExternalDecoder in NetEq test VerifyTimestampPropagation.
Bug: webrtc:10080 Change-Id: Ie93f130863115c2d288cfd9f3e273a9fbc982ed6 Reviewed-on: https://webrtc-review.googlesource.com/c/112904 Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Reviewed-by: Oskar Sundbom <ossu@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25927}
This commit is contained in:
parent
d644feb81f
commit
b7180c09fc
@ -90,6 +90,10 @@ class AudioDecoder {
|
||||
virtual std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
|
||||
uint32_t timestamp);
|
||||
|
||||
// TODO(bugs.webrtc.org/10098): The Decode and DecodeRedundant methods are
|
||||
// obsolete; callers should call ParsePayload instead. For now, subclasses
|
||||
// must still implement DecodeInternal.
|
||||
|
||||
// Decodes |encode_len| bytes from |encoded| and writes the result in
|
||||
// |decoded|. The maximum bytes allowed to be written into |decoded| is
|
||||
// |max_decoded_bytes|. Returns the total number of samples across all
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "modules/audio_coding/neteq/sync_buffer.h"
|
||||
#include "modules/audio_coding/neteq/timestamp_scaler.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "test/audio_decoder_proxy_factory.h"
|
||||
#include "test/function_audio_decoder_factory.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
@ -452,9 +453,6 @@ TEST_F(NetEqImplTest, TestDtmfPacketAVT48kHz) {
|
||||
// This test verifies that timestamps propagate from the incoming packets
|
||||
// through to the sync buffer and to the playout timestamp.
|
||||
TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
|
||||
UseNoMocks();
|
||||
CreateInstance();
|
||||
|
||||
const uint8_t kPayloadType = 17; // Just an arbitrary number.
|
||||
const uint32_t kReceiveTime = 17; // Value doesn't matter for this test.
|
||||
const int kSampleRateHz = 8000;
|
||||
@ -500,9 +498,14 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
|
||||
int16_t next_value_;
|
||||
} decoder_;
|
||||
|
||||
EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder(
|
||||
&decoder_, NetEqDecoder::kDecoderPCM16B,
|
||||
"dummy name", kPayloadType));
|
||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory =
|
||||
new rtc::RefCountedObject<test::AudioDecoderProxyFactory>(&decoder_);
|
||||
|
||||
UseNoMocks();
|
||||
CreateInstance(decoder_factory);
|
||||
|
||||
EXPECT_TRUE(neteq_->RegisterPayloadType(kPayloadType,
|
||||
SdpAudioFormat("l16", 8000, 1)));
|
||||
|
||||
// Insert one packet.
|
||||
EXPECT_EQ(NetEq::kOK,
|
||||
|
||||
@ -830,6 +830,7 @@ rtc_source_set("test_renderer_generic") {
|
||||
rtc_source_set("audio_codec_mocks") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"audio_decoder_proxy_factory.h",
|
||||
"function_audio_decoder_factory.h",
|
||||
"mock_audio_decoder.cc",
|
||||
"mock_audio_decoder.h",
|
||||
|
||||
86
test/audio_decoder_proxy_factory.h
Normal file
86
test/audio_decoder_proxy_factory.h
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef TEST_AUDIO_DECODER_PROXY_FACTORY_H_
|
||||
#define TEST_AUDIO_DECODER_PROXY_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "api/audio_codecs/audio_decoder_factory.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
// An decoder factory with a single underlying AudioDecoder object, intended for
|
||||
// test purposes. Each call to MakeAudioDecoder returns a proxy for the same
|
||||
// decoder, typically a mock or fake decoder.
|
||||
class AudioDecoderProxyFactory : public AudioDecoderFactory {
|
||||
public:
|
||||
explicit AudioDecoderProxyFactory(AudioDecoder* decoder)
|
||||
: decoder_(decoder) {}
|
||||
|
||||
// Unused by tests.
|
||||
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 {
|
||||
return absl::make_unique<DecoderProxy>(decoder_);
|
||||
}
|
||||
|
||||
private:
|
||||
// Wrapper class, since CreateAudioDecoder needs to surrender
|
||||
// ownership to the object it returns.
|
||||
class DecoderProxy final : public AudioDecoder {
|
||||
public:
|
||||
explicit DecoderProxy(AudioDecoder* decoder) : decoder_(decoder) {}
|
||||
|
||||
private:
|
||||
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
|
||||
uint32_t timestamp) override {
|
||||
return decoder_->ParsePayload(std::move(payload), timestamp);
|
||||
}
|
||||
|
||||
void Reset() override { decoder_->Reset(); }
|
||||
|
||||
int SampleRateHz() const override { return decoder_->SampleRateHz(); }
|
||||
|
||||
size_t Channels() const override { return decoder_->Channels(); }
|
||||
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type) override {
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
AudioDecoder* const decoder_;
|
||||
};
|
||||
|
||||
AudioDecoder* const decoder_;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TEST_AUDIO_DECODER_PROXY_FACTORY_H_
|
||||
Loading…
x
Reference in New Issue
Block a user