NetEq: Use a BuiltinAudioDecoderFactory to create decoders
Later steps in the refactoring will have the factory injected from the outside rather than owned by NetEq. BUG=webrtc:5801 Review-Url: https://codereview.webrtc.org/1928293002 Cr-Commit-Position: refs/heads/master@{#12604}
This commit is contained in:
@ -19,17 +19,21 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(DecoderDatabase, CreateAndDestroy) {
|
||||
DecoderDatabase db;
|
||||
std::unique_ptr<MockAudioDecoderFactory> factory(new MockAudioDecoderFactory);
|
||||
DecoderDatabase db(std::move(factory));
|
||||
EXPECT_EQ(0, db.Size());
|
||||
EXPECT_TRUE(db.Empty());
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, InsertAndRemove) {
|
||||
DecoderDatabase db;
|
||||
std::unique_ptr<MockAudioDecoderFactory> factory(new MockAudioDecoderFactory);
|
||||
DecoderDatabase db(std::move(factory));
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(
|
||||
@ -43,7 +47,8 @@ TEST(DecoderDatabase, InsertAndRemove) {
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, GetDecoderInfo) {
|
||||
DecoderDatabase db;
|
||||
std::unique_ptr<MockAudioDecoderFactory> factory(new MockAudioDecoderFactory);
|
||||
DecoderDatabase db(std::move(factory));
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(
|
||||
@ -61,7 +66,8 @@ TEST(DecoderDatabase, GetDecoderInfo) {
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, GetRtpPayloadType) {
|
||||
DecoderDatabase db;
|
||||
std::unique_ptr<MockAudioDecoderFactory> factory(new MockAudioDecoderFactory);
|
||||
DecoderDatabase db(std::move(factory));
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(
|
||||
@ -75,7 +81,7 @@ TEST(DecoderDatabase, GetRtpPayloadType) {
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, GetDecoder) {
|
||||
DecoderDatabase db;
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory());
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
@ -86,7 +92,8 @@ TEST(DecoderDatabase, GetDecoder) {
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, TypeTests) {
|
||||
DecoderDatabase db;
|
||||
std::unique_ptr<MockAudioDecoderFactory> factory(new MockAudioDecoderFactory);
|
||||
DecoderDatabase db(std::move(factory));
|
||||
const uint8_t kPayloadTypePcmU = 0;
|
||||
const uint8_t kPayloadTypeCng = 13;
|
||||
const uint8_t kPayloadTypeDtmf = 100;
|
||||
@ -121,7 +128,8 @@ TEST(DecoderDatabase, TypeTests) {
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, ExternalDecoder) {
|
||||
DecoderDatabase db;
|
||||
std::unique_ptr<MockAudioDecoderFactory> factory(new MockAudioDecoderFactory);
|
||||
DecoderDatabase db(std::move(factory));
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
MockAudioDecoder decoder;
|
||||
@ -150,7 +158,8 @@ TEST(DecoderDatabase, ExternalDecoder) {
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, CheckPayloadTypes) {
|
||||
DecoderDatabase db;
|
||||
std::unique_ptr<MockAudioDecoderFactory> factory(new MockAudioDecoderFactory);
|
||||
DecoderDatabase db(std::move(factory));
|
||||
// Load a number of payloads into the database. Payload types are 0, 1, ...,
|
||||
// while the decoder type is the same for all payload types (this does not
|
||||
// matter for the test).
|
||||
@ -194,7 +203,7 @@ TEST(DecoderDatabase, CheckPayloadTypes) {
|
||||
|
||||
// Test the methods for setting and getting active speech and CNG decoders.
|
||||
TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) {
|
||||
DecoderDatabase db;
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory());
|
||||
// Load payload types.
|
||||
ASSERT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(0, NetEqDecoder::kDecoderPCMu, "pcmu"));
|
||||
|
||||
Reference in New Issue
Block a user