Remove the codec_type_ member from AudioDecoder
It isn't actually required, as evidenced by the comparative ease with which it can be removed. R=henrik.lundin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31939004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7606 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
c2dd5ee2c0
commit
721ef633d0
@ -262,8 +262,7 @@ static uint16_t ACMISACFixGetDecSampRate(ACM_ISAC_STRUCT* /* inst */) {
|
||||
#endif
|
||||
|
||||
ACMISAC::ACMISAC(int16_t codec_id)
|
||||
: AudioDecoder(ACMCodecDB::neteq_decoders_[codec_id]),
|
||||
codec_inst_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
: codec_inst_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
is_enc_initialized_(false),
|
||||
isac_coding_mode_(CHANNEL_INDEPENDENT),
|
||||
enforce_frame_size_(false),
|
||||
|
@ -51,8 +51,6 @@ bool AudioDecoder::PacketHasFec(const uint8_t* encoded,
|
||||
return false;
|
||||
}
|
||||
|
||||
NetEqDecoder AudioDecoder::codec_type() const { return codec_type_; }
|
||||
|
||||
bool AudioDecoder::CodecSupported(NetEqDecoder codec_type) {
|
||||
switch (codec_type) {
|
||||
case kDecoderPCMu:
|
||||
@ -197,26 +195,24 @@ AudioDecoder* AudioDecoder::CreateAudioDecoder(NetEqDecoder codec_type) {
|
||||
return new AudioDecoderIsacFix;
|
||||
#elif defined(WEBRTC_CODEC_ISAC)
|
||||
case kDecoderISAC:
|
||||
return new AudioDecoderIsac;
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
return new AudioDecoderIsac(16000);
|
||||
case kDecoderISACswb:
|
||||
return new AudioDecoderIsacSwb;
|
||||
case kDecoderISACfb:
|
||||
return new AudioDecoderIsacFb;
|
||||
return new AudioDecoderIsac(32000);
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_PCM16
|
||||
case kDecoderPCM16B:
|
||||
case kDecoderPCM16Bwb:
|
||||
case kDecoderPCM16Bswb32kHz:
|
||||
case kDecoderPCM16Bswb48kHz:
|
||||
return new AudioDecoderPcm16B(codec_type);
|
||||
return new AudioDecoderPcm16B;
|
||||
case kDecoderPCM16B_2ch:
|
||||
case kDecoderPCM16Bwb_2ch:
|
||||
case kDecoderPCM16Bswb32kHz_2ch:
|
||||
case kDecoderPCM16Bswb48kHz_2ch:
|
||||
return new AudioDecoderPcm16BMultiCh(2);
|
||||
case kDecoderPCM16B_5ch:
|
||||
return new AudioDecoderPcm16BMultiCh(codec_type);
|
||||
return new AudioDecoderPcm16BMultiCh(5);
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G722
|
||||
case kDecoderG722:
|
||||
@ -226,19 +222,21 @@ AudioDecoder* AudioDecoder::CreateAudioDecoder(NetEqDecoder codec_type) {
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
case kDecoderCELT_32:
|
||||
return new AudioDecoderCelt(1);
|
||||
case kDecoderCELT_32_2ch:
|
||||
return new AudioDecoderCelt(codec_type);
|
||||
return new AudioDecoderCelt(2);
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
case kDecoderOpus:
|
||||
return new AudioDecoderOpus(1);
|
||||
case kDecoderOpus_2ch:
|
||||
return new AudioDecoderOpus(codec_type);
|
||||
return new AudioDecoderOpus(2);
|
||||
#endif
|
||||
case kDecoderCNGnb:
|
||||
case kDecoderCNGwb:
|
||||
case kDecoderCNGswb32kHz:
|
||||
case kDecoderCNGswb48kHz:
|
||||
return new AudioDecoderCng(codec_type);
|
||||
return new AudioDecoderCng;
|
||||
case kDecoderRED:
|
||||
case kDecoderAVT:
|
||||
case kDecoderArbitrary:
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <assert.h>
|
||||
#include <string.h> // memmove
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
|
||||
#endif
|
||||
@ -75,13 +76,7 @@ int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded,
|
||||
|
||||
// PCM16B
|
||||
#ifdef WEBRTC_CODEC_PCM16
|
||||
AudioDecoderPcm16B::AudioDecoderPcm16B(enum NetEqDecoder type)
|
||||
: AudioDecoder(type) {
|
||||
assert(type == kDecoderPCM16B ||
|
||||
type == kDecoderPCM16Bwb ||
|
||||
type == kDecoderPCM16Bswb32kHz ||
|
||||
type == kDecoderPCM16Bswb48kHz);
|
||||
}
|
||||
AudioDecoderPcm16B::AudioDecoderPcm16B() {}
|
||||
|
||||
int AudioDecoderPcm16B::Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type) {
|
||||
@ -99,29 +94,15 @@ int AudioDecoderPcm16B::PacketDuration(const uint8_t* encoded,
|
||||
return static_cast<int>(encoded_len / (2 * channels_));
|
||||
}
|
||||
|
||||
AudioDecoderPcm16BMultiCh::AudioDecoderPcm16BMultiCh(
|
||||
enum NetEqDecoder type)
|
||||
: AudioDecoderPcm16B(kDecoderPCM16B) { // This will be changed below.
|
||||
codec_type_ = type; // Changing to actual type here.
|
||||
switch (codec_type_) {
|
||||
case kDecoderPCM16B_2ch:
|
||||
case kDecoderPCM16Bwb_2ch:
|
||||
case kDecoderPCM16Bswb32kHz_2ch:
|
||||
case kDecoderPCM16Bswb48kHz_2ch:
|
||||
channels_ = 2;
|
||||
break;
|
||||
case kDecoderPCM16B_5ch:
|
||||
channels_ = 5;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
AudioDecoderPcm16BMultiCh::AudioDecoderPcm16BMultiCh(int num_channels) {
|
||||
DCHECK(num_channels > 0);
|
||||
channels_ = num_channels;
|
||||
}
|
||||
#endif
|
||||
|
||||
// iLBC
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
AudioDecoderIlbc::AudioDecoderIlbc() : AudioDecoder(kDecoderILBC) {
|
||||
AudioDecoderIlbc::AudioDecoderIlbc() {
|
||||
WebRtcIlbcfix_DecoderCreate(reinterpret_cast<iLBC_decinst_t**>(&state_));
|
||||
}
|
||||
|
||||
@ -152,9 +133,11 @@ int AudioDecoderIlbc::Init() {
|
||||
|
||||
// iSAC float
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
AudioDecoderIsac::AudioDecoderIsac() : AudioDecoder(kDecoderISAC) {
|
||||
AudioDecoderIsac::AudioDecoderIsac(int decode_sample_rate_hz) {
|
||||
DCHECK(decode_sample_rate_hz == 16000 || decode_sample_rate_hz == 32000);
|
||||
WebRtcIsac_Create(reinterpret_cast<ISACStruct**>(&state_));
|
||||
WebRtcIsac_SetDecSampRate(static_cast<ISACStruct*>(state_), 16000);
|
||||
WebRtcIsac_SetDecSampRate(static_cast<ISACStruct*>(state_),
|
||||
decode_sample_rate_hz);
|
||||
}
|
||||
|
||||
AudioDecoderIsac::~AudioDecoderIsac() {
|
||||
@ -209,22 +192,11 @@ int AudioDecoderIsac::IncomingPacket(const uint8_t* payload,
|
||||
int AudioDecoderIsac::ErrorCode() {
|
||||
return WebRtcIsac_GetErrorCode(static_cast<ISACStruct*>(state_));
|
||||
}
|
||||
|
||||
// iSAC SWB
|
||||
AudioDecoderIsacSwb::AudioDecoderIsacSwb() : AudioDecoderIsac() {
|
||||
codec_type_ = kDecoderISACswb;
|
||||
WebRtcIsac_SetDecSampRate(static_cast<ISACStruct*>(state_), 32000);
|
||||
}
|
||||
|
||||
// iSAC FB
|
||||
AudioDecoderIsacFb::AudioDecoderIsacFb() : AudioDecoderIsacSwb() {
|
||||
codec_type_ = kDecoderISACfb;
|
||||
}
|
||||
#endif
|
||||
|
||||
// iSAC fix
|
||||
#ifdef WEBRTC_CODEC_ISACFX
|
||||
AudioDecoderIsacFix::AudioDecoderIsacFix() : AudioDecoder(kDecoderISAC) {
|
||||
AudioDecoderIsacFix::AudioDecoderIsacFix() {
|
||||
WebRtcIsacfix_Create(reinterpret_cast<ISACFIX_MainStruct**>(&state_));
|
||||
}
|
||||
|
||||
@ -266,7 +238,7 @@ int AudioDecoderIsacFix::ErrorCode() {
|
||||
|
||||
// G.722
|
||||
#ifdef WEBRTC_CODEC_G722
|
||||
AudioDecoderG722::AudioDecoderG722() : AudioDecoder(kDecoderG722) {
|
||||
AudioDecoderG722::AudioDecoderG722() {
|
||||
WebRtcG722_CreateDecoder(reinterpret_cast<G722DecInst**>(&state_));
|
||||
}
|
||||
|
||||
@ -382,14 +354,9 @@ void AudioDecoderG722Stereo::SplitStereoPacket(const uint8_t* encoded,
|
||||
|
||||
// CELT
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
AudioDecoderCelt::AudioDecoderCelt(enum NetEqDecoder type)
|
||||
: AudioDecoder(type) {
|
||||
assert(type == kDecoderCELT_32 || type == kDecoderCELT_32_2ch);
|
||||
if (type == kDecoderCELT_32) {
|
||||
channels_ = 1;
|
||||
} else {
|
||||
channels_ = 2;
|
||||
}
|
||||
AudioDecoderCelt::AudioDecoderCelt(int num_channels) {
|
||||
DCHECK(num_channels == 1 || num_channels == 2);
|
||||
channels_ = num_channels;
|
||||
WebRtcCelt_CreateDec(reinterpret_cast<CELT_decinst_t**>(&state_),
|
||||
static_cast<int>(channels_));
|
||||
}
|
||||
@ -431,13 +398,9 @@ int AudioDecoderCelt::DecodePlc(int num_frames, int16_t* decoded) {
|
||||
|
||||
// Opus
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
AudioDecoderOpus::AudioDecoderOpus(enum NetEqDecoder type)
|
||||
: AudioDecoder(type) {
|
||||
if (type == kDecoderOpus_2ch) {
|
||||
channels_ = 2;
|
||||
} else {
|
||||
channels_ = 1;
|
||||
}
|
||||
AudioDecoderOpus::AudioDecoderOpus(int num_channels) {
|
||||
DCHECK(num_channels == 1 || num_channels == 2);
|
||||
channels_ = num_channels;
|
||||
WebRtcOpus_DecoderCreate(reinterpret_cast<OpusDecInst**>(&state_),
|
||||
static_cast<int>(channels_));
|
||||
}
|
||||
@ -494,10 +457,7 @@ bool AudioDecoderOpus::PacketHasFec(const uint8_t* encoded,
|
||||
}
|
||||
#endif
|
||||
|
||||
AudioDecoderCng::AudioDecoderCng(enum NetEqDecoder type)
|
||||
: AudioDecoder(type) {
|
||||
assert(type == kDecoderCNGnb || type == kDecoderCNGwb ||
|
||||
kDecoderCNGswb32kHz || type == kDecoderCNGswb48kHz);
|
||||
AudioDecoderCng::AudioDecoderCng() {
|
||||
WebRtcCng_CreateDec(reinterpret_cast<CNG_dec_inst**>(&state_));
|
||||
assert(state_);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace webrtc {
|
||||
|
||||
class AudioDecoderPcmU : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderPcmU() : AudioDecoder(kDecoderPCMu) {}
|
||||
AudioDecoderPcmU() {}
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type);
|
||||
virtual int Init() { return 0; }
|
||||
@ -38,7 +38,7 @@ class AudioDecoderPcmU : public AudioDecoder {
|
||||
|
||||
class AudioDecoderPcmA : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderPcmA() : AudioDecoder(kDecoderPCMa) {}
|
||||
AudioDecoderPcmA() {}
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type);
|
||||
virtual int Init() { return 0; }
|
||||
@ -75,7 +75,7 @@ class AudioDecoderPcmAMultiCh : public AudioDecoderPcmA {
|
||||
// The type is specified in the constructor parameter |type|.
|
||||
class AudioDecoderPcm16B : public AudioDecoder {
|
||||
public:
|
||||
explicit AudioDecoderPcm16B(enum NetEqDecoder type);
|
||||
AudioDecoderPcm16B();
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type);
|
||||
virtual int Init() { return 0; }
|
||||
@ -90,7 +90,7 @@ class AudioDecoderPcm16B : public AudioDecoder {
|
||||
// of channels is derived from the type.
|
||||
class AudioDecoderPcm16BMultiCh : public AudioDecoderPcm16B {
|
||||
public:
|
||||
explicit AudioDecoderPcm16BMultiCh(enum NetEqDecoder type);
|
||||
explicit AudioDecoderPcm16BMultiCh(int num_channels);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcm16BMultiCh);
|
||||
@ -116,7 +116,7 @@ class AudioDecoderIlbc : public AudioDecoder {
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
class AudioDecoderIsac : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderIsac();
|
||||
explicit AudioDecoderIsac(int decode_sample_rate_hz);
|
||||
virtual ~AudioDecoderIsac();
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type);
|
||||
@ -135,22 +135,6 @@ class AudioDecoderIsac : public AudioDecoder {
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderIsac);
|
||||
};
|
||||
|
||||
class AudioDecoderIsacSwb : public AudioDecoderIsac {
|
||||
public:
|
||||
AudioDecoderIsacSwb();
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderIsacSwb);
|
||||
};
|
||||
|
||||
class AudioDecoderIsacFb : public AudioDecoderIsacSwb {
|
||||
public:
|
||||
AudioDecoderIsacFb();
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderIsacFb);
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef WEBRTC_CODEC_ISACFX
|
||||
@ -215,7 +199,7 @@ class AudioDecoderG722Stereo : public AudioDecoderG722 {
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
class AudioDecoderCelt : public AudioDecoder {
|
||||
public:
|
||||
explicit AudioDecoderCelt(enum NetEqDecoder type);
|
||||
explicit AudioDecoderCelt(int num_channels);
|
||||
virtual ~AudioDecoderCelt();
|
||||
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
@ -232,7 +216,7 @@ class AudioDecoderCelt : public AudioDecoder {
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
class AudioDecoderOpus : public AudioDecoder {
|
||||
public:
|
||||
explicit AudioDecoderOpus(enum NetEqDecoder type);
|
||||
explicit AudioDecoderOpus(int num_channels);
|
||||
virtual ~AudioDecoderOpus();
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type);
|
||||
@ -257,7 +241,7 @@ class AudioDecoderOpus : public AudioDecoder {
|
||||
// specific CngDecoder class could both inherit from that class.
|
||||
class AudioDecoderCng : public AudioDecoder {
|
||||
public:
|
||||
explicit AudioDecoderCng(enum NetEqDecoder type);
|
||||
explicit AudioDecoderCng();
|
||||
virtual ~AudioDecoderCng();
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type) { return -1; }
|
||||
|
@ -298,7 +298,7 @@ class AudioDecoderPcm16BTest : public AudioDecoderTest {
|
||||
codec_input_rate_hz_ = 8000;
|
||||
frame_size_ = 160;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderPcm16B(kDecoderPCM16B);
|
||||
decoder_ = new AudioDecoderPcm16B;
|
||||
assert(decoder_);
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ class AudioDecoderIsacFloatTest : public AudioDecoderTest {
|
||||
input_size_ = 160;
|
||||
frame_size_ = 480;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderIsac;
|
||||
decoder_ = new AudioDecoderIsac(16000);
|
||||
assert(decoder_);
|
||||
WebRtcIsac_Create(&encoder_);
|
||||
WebRtcIsac_SetEncSampRate(encoder_, 16000);
|
||||
@ -407,7 +407,7 @@ class AudioDecoderIsacSwbTest : public AudioDecoderTest {
|
||||
input_size_ = 320;
|
||||
frame_size_ = 960;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderIsacSwb;
|
||||
decoder_ = new AudioDecoderIsac(32000);
|
||||
assert(decoder_);
|
||||
WebRtcIsac_Create(&encoder_);
|
||||
WebRtcIsac_SetEncSampRate(encoder_, 32000);
|
||||
@ -438,19 +438,6 @@ class AudioDecoderIsacSwbTest : public AudioDecoderTest {
|
||||
int input_size_;
|
||||
};
|
||||
|
||||
// This test is identical to AudioDecoderIsacSwbTest, except that it creates
|
||||
// an AudioDecoderIsacFb decoder object.
|
||||
class AudioDecoderIsacFbTest : public AudioDecoderIsacSwbTest {
|
||||
protected:
|
||||
AudioDecoderIsacFbTest() : AudioDecoderIsacSwbTest() {
|
||||
// Delete the |decoder_| that was created by AudioDecoderIsacSwbTest and
|
||||
// create an AudioDecoderIsacFb object instead.
|
||||
delete decoder_;
|
||||
decoder_ = new AudioDecoderIsacFb;
|
||||
assert(decoder_);
|
||||
}
|
||||
};
|
||||
|
||||
class AudioDecoderIsacFixTest : public AudioDecoderTest {
|
||||
protected:
|
||||
AudioDecoderIsacFixTest() : AudioDecoderTest() {
|
||||
@ -638,7 +625,7 @@ class AudioDecoderOpusTest : public AudioDecoderTest {
|
||||
codec_input_rate_hz_ = 48000;
|
||||
frame_size_ = 480;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderOpus(kDecoderOpus);
|
||||
decoder_ = new AudioDecoderOpus(1);
|
||||
AudioEncoderOpus::Config config;
|
||||
config.frame_size_ms = static_cast<int>(frame_size_) / 48;
|
||||
audio_encoder_.reset(new AudioEncoderOpus(config));
|
||||
@ -650,7 +637,7 @@ class AudioDecoderOpusStereoTest : public AudioDecoderOpusTest {
|
||||
AudioDecoderOpusStereoTest() : AudioDecoderOpusTest() {
|
||||
channels_ = 2;
|
||||
delete decoder_;
|
||||
decoder_ = new AudioDecoderOpus(kDecoderOpus_2ch);
|
||||
decoder_ = new AudioDecoderOpus(2);
|
||||
AudioEncoderOpus::Config config;
|
||||
config.frame_size_ms = static_cast<int>(frame_size_) / 48;
|
||||
config.num_channels = 2;
|
||||
@ -721,17 +708,6 @@ TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) {
|
||||
DecodePlcTest();
|
||||
}
|
||||
|
||||
TEST_F(AudioDecoderIsacFbTest, EncodeDecode) {
|
||||
int tolerance = 19757;
|
||||
double mse = 8.18e6;
|
||||
int delay = 160; // Delay from input to output.
|
||||
EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISACswb));
|
||||
EncodeDecodeTest(0, tolerance, mse, delay);
|
||||
ReInitTest();
|
||||
EXPECT_TRUE(decoder_->HasDecodePlc());
|
||||
DecodePlcTest();
|
||||
}
|
||||
|
||||
TEST_F(AudioDecoderIsacFixTest, DISABLED_EncodeDecode) {
|
||||
int tolerance = 11034;
|
||||
double mse = 3.46e6;
|
||||
|
@ -189,21 +189,18 @@ TEST(DecoderDatabase, ActiveDecoders) {
|
||||
EXPECT_TRUE(changed);
|
||||
AudioDecoder* decoder = db.GetActiveDecoder();
|
||||
ASSERT_FALSE(decoder == NULL); // Should get a decoder here.
|
||||
EXPECT_EQ(kDecoderPCMu, decoder->codec_type());
|
||||
|
||||
// Set the same again. Expect no change.
|
||||
EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(0, &changed));
|
||||
EXPECT_FALSE(changed);
|
||||
decoder = db.GetActiveDecoder();
|
||||
ASSERT_FALSE(decoder == NULL); // Should get a decoder here.
|
||||
EXPECT_EQ(kDecoderPCMu, decoder->codec_type());
|
||||
|
||||
// Change active decoder.
|
||||
EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(103, &changed));
|
||||
EXPECT_TRUE(changed);
|
||||
decoder = db.GetActiveDecoder();
|
||||
ASSERT_FALSE(decoder == NULL); // Should get a decoder here.
|
||||
EXPECT_EQ(kDecoderISAC, decoder->codec_type());
|
||||
|
||||
// Remove the active decoder, and verify that the active becomes NULL.
|
||||
EXPECT_EQ(DecoderDatabase::kOK, db.Remove(103));
|
||||
@ -213,7 +210,6 @@ TEST(DecoderDatabase, ActiveDecoders) {
|
||||
EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveCngDecoder(13));
|
||||
decoder = db.GetActiveCngDecoder();
|
||||
ASSERT_FALSE(decoder == NULL); // Should get a decoder here.
|
||||
EXPECT_EQ(kDecoderCNGnb, decoder->codec_type());
|
||||
|
||||
// Remove the active CNG decoder, and verify that the active becomes NULL.
|
||||
EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13));
|
||||
|
@ -63,12 +63,7 @@ class AudioDecoder {
|
||||
// Used by PacketDuration below. Save the value -1 for errors.
|
||||
enum { kNotImplemented = -2 };
|
||||
|
||||
explicit AudioDecoder(enum NetEqDecoder type)
|
||||
: codec_type_(type),
|
||||
channels_(1),
|
||||
state_(NULL) {
|
||||
}
|
||||
|
||||
AudioDecoder() : channels_(1), state_(NULL) {}
|
||||
virtual ~AudioDecoder() {}
|
||||
|
||||
// Decodes |encode_len| bytes from |encoded| and writes the result in
|
||||
@ -119,8 +114,6 @@ class AudioDecoder {
|
||||
// Returns true if the packet has FEC and false otherwise.
|
||||
virtual bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const;
|
||||
|
||||
virtual NetEqDecoder codec_type() const;
|
||||
|
||||
// Returns the underlying decoder state.
|
||||
void* state() { return state_; }
|
||||
|
||||
@ -140,7 +133,6 @@ class AudioDecoder {
|
||||
protected:
|
||||
static SpeechType ConvertSpeechType(int16_t type);
|
||||
|
||||
enum NetEqDecoder codec_type_;
|
||||
size_t channels_;
|
||||
void* state_;
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace webrtc {
|
||||
|
||||
class MockAudioDecoder : public AudioDecoder {
|
||||
public:
|
||||
MockAudioDecoder() : AudioDecoder(kDecoderArbitrary) {}
|
||||
MockAudioDecoder() {}
|
||||
virtual ~MockAudioDecoder() { Die(); }
|
||||
MOCK_METHOD0(Die, void());
|
||||
MOCK_METHOD4(Decode, int(const uint8_t*, size_t, int16_t*,
|
||||
|
@ -27,9 +27,7 @@ using ::testing::Invoke;
|
||||
// audio_decoder_impl.{cc, h}.
|
||||
class ExternalPcm16B : public AudioDecoder {
|
||||
public:
|
||||
explicit ExternalPcm16B(enum NetEqDecoder type)
|
||||
: AudioDecoder(type) {
|
||||
}
|
||||
ExternalPcm16B() {}
|
||||
|
||||
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
int16_t* decoded, SpeechType* speech_type) {
|
||||
@ -51,9 +49,7 @@ class ExternalPcm16B : public AudioDecoder {
|
||||
// The reason is that we can then track that the correct calls are being made.
|
||||
class MockExternalPcm16B : public ExternalPcm16B {
|
||||
public:
|
||||
explicit MockExternalPcm16B(enum NetEqDecoder type)
|
||||
: ExternalPcm16B(type),
|
||||
real_(type) {
|
||||
MockExternalPcm16B() {
|
||||
// By default, all calls are delegated to the real object.
|
||||
ON_CALL(*this, Decode(_, _, _, _))
|
||||
.WillByDefault(Invoke(&real_, &ExternalPcm16B::Decode));
|
||||
@ -67,8 +63,6 @@ class MockExternalPcm16B : public ExternalPcm16B {
|
||||
.WillByDefault(Invoke(&real_, &ExternalPcm16B::IncomingPacket));
|
||||
ON_CALL(*this, ErrorCode())
|
||||
.WillByDefault(Invoke(&real_, &ExternalPcm16B::ErrorCode));
|
||||
ON_CALL(*this, codec_type())
|
||||
.WillByDefault(Invoke(&real_, &ExternalPcm16B::codec_type));
|
||||
}
|
||||
virtual ~MockExternalPcm16B() { Die(); }
|
||||
|
||||
|
@ -47,7 +47,7 @@ class NetEqExternalDecoderTest : public ::testing::Test {
|
||||
frame_size_ms_(10),
|
||||
frame_size_samples_(frame_size_ms_ * samples_per_ms_),
|
||||
output_size_samples_(frame_size_ms_ * samples_per_ms_),
|
||||
external_decoder_(new MockExternalPcm16B(kDecoderPCM16Bswb32kHz)),
|
||||
external_decoder_(new MockExternalPcm16B),
|
||||
rtp_generator_(new test::RtpGenerator(samples_per_ms_)),
|
||||
payload_size_bytes_(0),
|
||||
last_send_time_(0),
|
||||
@ -241,7 +241,7 @@ class LargeTimestampJumpTest : public NetEqExternalDecoderTest {
|
||||
frame_size_samples_ = frame_size_ms_ * samples_per_ms_;
|
||||
output_size_samples_ = frame_size_ms_ * samples_per_ms_;
|
||||
EXPECT_CALL(*external_decoder_, Die()).Times(1);
|
||||
external_decoder_.reset(new MockExternalPcm16B(kDecoderPCM16B));
|
||||
external_decoder_.reset(new MockExternalPcm16B);
|
||||
}
|
||||
|
||||
void SetUp() OVERRIDE {
|
||||
|
@ -422,8 +422,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
|
||||
// sample, and then increasing by 1 for each sample.
|
||||
class CountingSamplesDecoder : public AudioDecoder {
|
||||
public:
|
||||
explicit CountingSamplesDecoder(enum NetEqDecoder type)
|
||||
: AudioDecoder(type), next_value_(1) {}
|
||||
CountingSamplesDecoder() : next_value_(1) {}
|
||||
|
||||
// Produce as many samples as input bytes (|encoded_len|).
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
@ -446,7 +445,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
|
||||
|
||||
private:
|
||||
int16_t next_value_;
|
||||
} decoder_(kDecoderPCM16B);
|
||||
} decoder_;
|
||||
|
||||
EXPECT_EQ(NetEq::kOK,
|
||||
neteq_->RegisterExternalDecoder(
|
||||
|
Loading…
Reference in New Issue
Block a user