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:
kwiberg@webrtc.org 2014-11-04 11:51:46 +00:00
parent c2dd5ee2c0
commit 721ef633d0
11 changed files with 51 additions and 153 deletions

View File

@ -262,8 +262,7 @@ static uint16_t ACMISACFixGetDecSampRate(ACM_ISAC_STRUCT* /* inst */) {
#endif #endif
ACMISAC::ACMISAC(int16_t codec_id) 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), is_enc_initialized_(false),
isac_coding_mode_(CHANNEL_INDEPENDENT), isac_coding_mode_(CHANNEL_INDEPENDENT),
enforce_frame_size_(false), enforce_frame_size_(false),

View File

@ -51,8 +51,6 @@ bool AudioDecoder::PacketHasFec(const uint8_t* encoded,
return false; return false;
} }
NetEqDecoder AudioDecoder::codec_type() const { return codec_type_; }
bool AudioDecoder::CodecSupported(NetEqDecoder codec_type) { bool AudioDecoder::CodecSupported(NetEqDecoder codec_type) {
switch (codec_type) { switch (codec_type) {
case kDecoderPCMu: case kDecoderPCMu:
@ -197,26 +195,24 @@ AudioDecoder* AudioDecoder::CreateAudioDecoder(NetEqDecoder codec_type) {
return new AudioDecoderIsacFix; return new AudioDecoderIsacFix;
#elif defined(WEBRTC_CODEC_ISAC) #elif defined(WEBRTC_CODEC_ISAC)
case kDecoderISAC: case kDecoderISAC:
return new AudioDecoderIsac; return new AudioDecoderIsac(16000);
#endif
#ifdef WEBRTC_CODEC_ISAC
case kDecoderISACswb: case kDecoderISACswb:
return new AudioDecoderIsacSwb;
case kDecoderISACfb: case kDecoderISACfb:
return new AudioDecoderIsacFb; return new AudioDecoderIsac(32000);
#endif #endif
#ifdef WEBRTC_CODEC_PCM16 #ifdef WEBRTC_CODEC_PCM16
case kDecoderPCM16B: case kDecoderPCM16B:
case kDecoderPCM16Bwb: case kDecoderPCM16Bwb:
case kDecoderPCM16Bswb32kHz: case kDecoderPCM16Bswb32kHz:
case kDecoderPCM16Bswb48kHz: case kDecoderPCM16Bswb48kHz:
return new AudioDecoderPcm16B(codec_type); return new AudioDecoderPcm16B;
case kDecoderPCM16B_2ch: case kDecoderPCM16B_2ch:
case kDecoderPCM16Bwb_2ch: case kDecoderPCM16Bwb_2ch:
case kDecoderPCM16Bswb32kHz_2ch: case kDecoderPCM16Bswb32kHz_2ch:
case kDecoderPCM16Bswb48kHz_2ch: case kDecoderPCM16Bswb48kHz_2ch:
return new AudioDecoderPcm16BMultiCh(2);
case kDecoderPCM16B_5ch: case kDecoderPCM16B_5ch:
return new AudioDecoderPcm16BMultiCh(codec_type); return new AudioDecoderPcm16BMultiCh(5);
#endif #endif
#ifdef WEBRTC_CODEC_G722 #ifdef WEBRTC_CODEC_G722
case kDecoderG722: case kDecoderG722:
@ -226,19 +222,21 @@ AudioDecoder* AudioDecoder::CreateAudioDecoder(NetEqDecoder codec_type) {
#endif #endif
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
case kDecoderCELT_32: case kDecoderCELT_32:
return new AudioDecoderCelt(1);
case kDecoderCELT_32_2ch: case kDecoderCELT_32_2ch:
return new AudioDecoderCelt(codec_type); return new AudioDecoderCelt(2);
#endif #endif
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
case kDecoderOpus: case kDecoderOpus:
return new AudioDecoderOpus(1);
case kDecoderOpus_2ch: case kDecoderOpus_2ch:
return new AudioDecoderOpus(codec_type); return new AudioDecoderOpus(2);
#endif #endif
case kDecoderCNGnb: case kDecoderCNGnb:
case kDecoderCNGwb: case kDecoderCNGwb:
case kDecoderCNGswb32kHz: case kDecoderCNGswb32kHz:
case kDecoderCNGswb48kHz: case kDecoderCNGswb48kHz:
return new AudioDecoderCng(codec_type); return new AudioDecoderCng;
case kDecoderRED: case kDecoderRED:
case kDecoderAVT: case kDecoderAVT:
case kDecoderArbitrary: case kDecoderArbitrary:

View File

@ -13,6 +13,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> // memmove #include <string.h> // memmove
#include "webrtc/base/checks.h"
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h" #include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
#endif #endif
@ -75,13 +76,7 @@ int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded,
// PCM16B // PCM16B
#ifdef WEBRTC_CODEC_PCM16 #ifdef WEBRTC_CODEC_PCM16
AudioDecoderPcm16B::AudioDecoderPcm16B(enum NetEqDecoder type) AudioDecoderPcm16B::AudioDecoderPcm16B() {}
: AudioDecoder(type) {
assert(type == kDecoderPCM16B ||
type == kDecoderPCM16Bwb ||
type == kDecoderPCM16Bswb32kHz ||
type == kDecoderPCM16Bswb48kHz);
}
int AudioDecoderPcm16B::Decode(const uint8_t* encoded, size_t encoded_len, int AudioDecoderPcm16B::Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type) { 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_)); return static_cast<int>(encoded_len / (2 * channels_));
} }
AudioDecoderPcm16BMultiCh::AudioDecoderPcm16BMultiCh( AudioDecoderPcm16BMultiCh::AudioDecoderPcm16BMultiCh(int num_channels) {
enum NetEqDecoder type) DCHECK(num_channels > 0);
: AudioDecoderPcm16B(kDecoderPCM16B) { // This will be changed below. channels_ = num_channels;
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);
}
} }
#endif #endif
// iLBC // iLBC
#ifdef WEBRTC_CODEC_ILBC #ifdef WEBRTC_CODEC_ILBC
AudioDecoderIlbc::AudioDecoderIlbc() : AudioDecoder(kDecoderILBC) { AudioDecoderIlbc::AudioDecoderIlbc() {
WebRtcIlbcfix_DecoderCreate(reinterpret_cast<iLBC_decinst_t**>(&state_)); WebRtcIlbcfix_DecoderCreate(reinterpret_cast<iLBC_decinst_t**>(&state_));
} }
@ -152,9 +133,11 @@ int AudioDecoderIlbc::Init() {
// iSAC float // iSAC float
#ifdef WEBRTC_CODEC_ISAC #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_Create(reinterpret_cast<ISACStruct**>(&state_));
WebRtcIsac_SetDecSampRate(static_cast<ISACStruct*>(state_), 16000); WebRtcIsac_SetDecSampRate(static_cast<ISACStruct*>(state_),
decode_sample_rate_hz);
} }
AudioDecoderIsac::~AudioDecoderIsac() { AudioDecoderIsac::~AudioDecoderIsac() {
@ -209,22 +192,11 @@ int AudioDecoderIsac::IncomingPacket(const uint8_t* payload,
int AudioDecoderIsac::ErrorCode() { int AudioDecoderIsac::ErrorCode() {
return WebRtcIsac_GetErrorCode(static_cast<ISACStruct*>(state_)); 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 #endif
// iSAC fix // iSAC fix
#ifdef WEBRTC_CODEC_ISACFX #ifdef WEBRTC_CODEC_ISACFX
AudioDecoderIsacFix::AudioDecoderIsacFix() : AudioDecoder(kDecoderISAC) { AudioDecoderIsacFix::AudioDecoderIsacFix() {
WebRtcIsacfix_Create(reinterpret_cast<ISACFIX_MainStruct**>(&state_)); WebRtcIsacfix_Create(reinterpret_cast<ISACFIX_MainStruct**>(&state_));
} }
@ -266,7 +238,7 @@ int AudioDecoderIsacFix::ErrorCode() {
// G.722 // G.722
#ifdef WEBRTC_CODEC_G722 #ifdef WEBRTC_CODEC_G722
AudioDecoderG722::AudioDecoderG722() : AudioDecoder(kDecoderG722) { AudioDecoderG722::AudioDecoderG722() {
WebRtcG722_CreateDecoder(reinterpret_cast<G722DecInst**>(&state_)); WebRtcG722_CreateDecoder(reinterpret_cast<G722DecInst**>(&state_));
} }
@ -382,14 +354,9 @@ void AudioDecoderG722Stereo::SplitStereoPacket(const uint8_t* encoded,
// CELT // CELT
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
AudioDecoderCelt::AudioDecoderCelt(enum NetEqDecoder type) AudioDecoderCelt::AudioDecoderCelt(int num_channels) {
: AudioDecoder(type) { DCHECK(num_channels == 1 || num_channels == 2);
assert(type == kDecoderCELT_32 || type == kDecoderCELT_32_2ch); channels_ = num_channels;
if (type == kDecoderCELT_32) {
channels_ = 1;
} else {
channels_ = 2;
}
WebRtcCelt_CreateDec(reinterpret_cast<CELT_decinst_t**>(&state_), WebRtcCelt_CreateDec(reinterpret_cast<CELT_decinst_t**>(&state_),
static_cast<int>(channels_)); static_cast<int>(channels_));
} }
@ -431,13 +398,9 @@ int AudioDecoderCelt::DecodePlc(int num_frames, int16_t* decoded) {
// Opus // Opus
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
AudioDecoderOpus::AudioDecoderOpus(enum NetEqDecoder type) AudioDecoderOpus::AudioDecoderOpus(int num_channels) {
: AudioDecoder(type) { DCHECK(num_channels == 1 || num_channels == 2);
if (type == kDecoderOpus_2ch) { channels_ = num_channels;
channels_ = 2;
} else {
channels_ = 1;
}
WebRtcOpus_DecoderCreate(reinterpret_cast<OpusDecInst**>(&state_), WebRtcOpus_DecoderCreate(reinterpret_cast<OpusDecInst**>(&state_),
static_cast<int>(channels_)); static_cast<int>(channels_));
} }
@ -494,10 +457,7 @@ bool AudioDecoderOpus::PacketHasFec(const uint8_t* encoded,
} }
#endif #endif
AudioDecoderCng::AudioDecoderCng(enum NetEqDecoder type) AudioDecoderCng::AudioDecoderCng() {
: AudioDecoder(type) {
assert(type == kDecoderCNGnb || type == kDecoderCNGwb ||
kDecoderCNGswb32kHz || type == kDecoderCNGswb48kHz);
WebRtcCng_CreateDec(reinterpret_cast<CNG_dec_inst**>(&state_)); WebRtcCng_CreateDec(reinterpret_cast<CNG_dec_inst**>(&state_));
assert(state_); assert(state_);
} }

View File

@ -26,7 +26,7 @@ namespace webrtc {
class AudioDecoderPcmU : public AudioDecoder { class AudioDecoderPcmU : public AudioDecoder {
public: public:
AudioDecoderPcmU() : AudioDecoder(kDecoderPCMu) {} AudioDecoderPcmU() {}
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type); int16_t* decoded, SpeechType* speech_type);
virtual int Init() { return 0; } virtual int Init() { return 0; }
@ -38,7 +38,7 @@ class AudioDecoderPcmU : public AudioDecoder {
class AudioDecoderPcmA : public AudioDecoder { class AudioDecoderPcmA : public AudioDecoder {
public: public:
AudioDecoderPcmA() : AudioDecoder(kDecoderPCMa) {} AudioDecoderPcmA() {}
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type); int16_t* decoded, SpeechType* speech_type);
virtual int Init() { return 0; } virtual int Init() { return 0; }
@ -75,7 +75,7 @@ class AudioDecoderPcmAMultiCh : public AudioDecoderPcmA {
// The type is specified in the constructor parameter |type|. // The type is specified in the constructor parameter |type|.
class AudioDecoderPcm16B : public AudioDecoder { class AudioDecoderPcm16B : public AudioDecoder {
public: public:
explicit AudioDecoderPcm16B(enum NetEqDecoder type); AudioDecoderPcm16B();
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type); int16_t* decoded, SpeechType* speech_type);
virtual int Init() { return 0; } virtual int Init() { return 0; }
@ -90,7 +90,7 @@ class AudioDecoderPcm16B : public AudioDecoder {
// of channels is derived from the type. // of channels is derived from the type.
class AudioDecoderPcm16BMultiCh : public AudioDecoderPcm16B { class AudioDecoderPcm16BMultiCh : public AudioDecoderPcm16B {
public: public:
explicit AudioDecoderPcm16BMultiCh(enum NetEqDecoder type); explicit AudioDecoderPcm16BMultiCh(int num_channels);
private: private:
DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcm16BMultiCh); DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcm16BMultiCh);
@ -116,7 +116,7 @@ class AudioDecoderIlbc : public AudioDecoder {
#ifdef WEBRTC_CODEC_ISAC #ifdef WEBRTC_CODEC_ISAC
class AudioDecoderIsac : public AudioDecoder { class AudioDecoderIsac : public AudioDecoder {
public: public:
AudioDecoderIsac(); explicit AudioDecoderIsac(int decode_sample_rate_hz);
virtual ~AudioDecoderIsac(); virtual ~AudioDecoderIsac();
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type); int16_t* decoded, SpeechType* speech_type);
@ -135,22 +135,6 @@ class AudioDecoderIsac : public AudioDecoder {
private: private:
DISALLOW_COPY_AND_ASSIGN(AudioDecoderIsac); 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 #endif
#ifdef WEBRTC_CODEC_ISACFX #ifdef WEBRTC_CODEC_ISACFX
@ -215,7 +199,7 @@ class AudioDecoderG722Stereo : public AudioDecoderG722 {
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
class AudioDecoderCelt : public AudioDecoder { class AudioDecoderCelt : public AudioDecoder {
public: public:
explicit AudioDecoderCelt(enum NetEqDecoder type); explicit AudioDecoderCelt(int num_channels);
virtual ~AudioDecoderCelt(); virtual ~AudioDecoderCelt();
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
@ -232,7 +216,7 @@ class AudioDecoderCelt : public AudioDecoder {
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
class AudioDecoderOpus : public AudioDecoder { class AudioDecoderOpus : public AudioDecoder {
public: public:
explicit AudioDecoderOpus(enum NetEqDecoder type); explicit AudioDecoderOpus(int num_channels);
virtual ~AudioDecoderOpus(); virtual ~AudioDecoderOpus();
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type); int16_t* decoded, SpeechType* speech_type);
@ -257,7 +241,7 @@ class AudioDecoderOpus : public AudioDecoder {
// specific CngDecoder class could both inherit from that class. // specific CngDecoder class could both inherit from that class.
class AudioDecoderCng : public AudioDecoder { class AudioDecoderCng : public AudioDecoder {
public: public:
explicit AudioDecoderCng(enum NetEqDecoder type); explicit AudioDecoderCng();
virtual ~AudioDecoderCng(); virtual ~AudioDecoderCng();
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type) { return -1; } int16_t* decoded, SpeechType* speech_type) { return -1; }

View File

@ -298,7 +298,7 @@ class AudioDecoderPcm16BTest : public AudioDecoderTest {
codec_input_rate_hz_ = 8000; codec_input_rate_hz_ = 8000;
frame_size_ = 160; frame_size_ = 160;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderPcm16B(kDecoderPCM16B); decoder_ = new AudioDecoderPcm16B;
assert(decoder_); assert(decoder_);
} }
@ -369,7 +369,7 @@ class AudioDecoderIsacFloatTest : public AudioDecoderTest {
input_size_ = 160; input_size_ = 160;
frame_size_ = 480; frame_size_ = 480;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderIsac; decoder_ = new AudioDecoderIsac(16000);
assert(decoder_); assert(decoder_);
WebRtcIsac_Create(&encoder_); WebRtcIsac_Create(&encoder_);
WebRtcIsac_SetEncSampRate(encoder_, 16000); WebRtcIsac_SetEncSampRate(encoder_, 16000);
@ -407,7 +407,7 @@ class AudioDecoderIsacSwbTest : public AudioDecoderTest {
input_size_ = 320; input_size_ = 320;
frame_size_ = 960; frame_size_ = 960;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderIsacSwb; decoder_ = new AudioDecoderIsac(32000);
assert(decoder_); assert(decoder_);
WebRtcIsac_Create(&encoder_); WebRtcIsac_Create(&encoder_);
WebRtcIsac_SetEncSampRate(encoder_, 32000); WebRtcIsac_SetEncSampRate(encoder_, 32000);
@ -438,19 +438,6 @@ class AudioDecoderIsacSwbTest : public AudioDecoderTest {
int input_size_; 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 { class AudioDecoderIsacFixTest : public AudioDecoderTest {
protected: protected:
AudioDecoderIsacFixTest() : AudioDecoderTest() { AudioDecoderIsacFixTest() : AudioDecoderTest() {
@ -638,7 +625,7 @@ class AudioDecoderOpusTest : public AudioDecoderTest {
codec_input_rate_hz_ = 48000; codec_input_rate_hz_ = 48000;
frame_size_ = 480; frame_size_ = 480;
data_length_ = 10 * frame_size_; data_length_ = 10 * frame_size_;
decoder_ = new AudioDecoderOpus(kDecoderOpus); decoder_ = new AudioDecoderOpus(1);
AudioEncoderOpus::Config config; AudioEncoderOpus::Config config;
config.frame_size_ms = static_cast<int>(frame_size_) / 48; config.frame_size_ms = static_cast<int>(frame_size_) / 48;
audio_encoder_.reset(new AudioEncoderOpus(config)); audio_encoder_.reset(new AudioEncoderOpus(config));
@ -650,7 +637,7 @@ class AudioDecoderOpusStereoTest : public AudioDecoderOpusTest {
AudioDecoderOpusStereoTest() : AudioDecoderOpusTest() { AudioDecoderOpusStereoTest() : AudioDecoderOpusTest() {
channels_ = 2; channels_ = 2;
delete decoder_; delete decoder_;
decoder_ = new AudioDecoderOpus(kDecoderOpus_2ch); decoder_ = new AudioDecoderOpus(2);
AudioEncoderOpus::Config config; AudioEncoderOpus::Config config;
config.frame_size_ms = static_cast<int>(frame_size_) / 48; config.frame_size_ms = static_cast<int>(frame_size_) / 48;
config.num_channels = 2; config.num_channels = 2;
@ -721,17 +708,6 @@ TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) {
DecodePlcTest(); 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) { TEST_F(AudioDecoderIsacFixTest, DISABLED_EncodeDecode) {
int tolerance = 11034; int tolerance = 11034;
double mse = 3.46e6; double mse = 3.46e6;

View File

@ -189,21 +189,18 @@ TEST(DecoderDatabase, ActiveDecoders) {
EXPECT_TRUE(changed); EXPECT_TRUE(changed);
AudioDecoder* decoder = db.GetActiveDecoder(); AudioDecoder* decoder = db.GetActiveDecoder();
ASSERT_FALSE(decoder == NULL); // Should get a decoder here. ASSERT_FALSE(decoder == NULL); // Should get a decoder here.
EXPECT_EQ(kDecoderPCMu, decoder->codec_type());
// Set the same again. Expect no change. // Set the same again. Expect no change.
EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(0, &changed)); EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(0, &changed));
EXPECT_FALSE(changed); EXPECT_FALSE(changed);
decoder = db.GetActiveDecoder(); decoder = db.GetActiveDecoder();
ASSERT_FALSE(decoder == NULL); // Should get a decoder here. ASSERT_FALSE(decoder == NULL); // Should get a decoder here.
EXPECT_EQ(kDecoderPCMu, decoder->codec_type());
// Change active decoder. // Change active decoder.
EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(103, &changed)); EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(103, &changed));
EXPECT_TRUE(changed); EXPECT_TRUE(changed);
decoder = db.GetActiveDecoder(); decoder = db.GetActiveDecoder();
ASSERT_FALSE(decoder == NULL); // Should get a decoder here. 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. // Remove the active decoder, and verify that the active becomes NULL.
EXPECT_EQ(DecoderDatabase::kOK, db.Remove(103)); EXPECT_EQ(DecoderDatabase::kOK, db.Remove(103));
@ -213,7 +210,6 @@ TEST(DecoderDatabase, ActiveDecoders) {
EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveCngDecoder(13)); EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveCngDecoder(13));
decoder = db.GetActiveCngDecoder(); decoder = db.GetActiveCngDecoder();
ASSERT_FALSE(decoder == NULL); // Should get a decoder here. 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. // Remove the active CNG decoder, and verify that the active becomes NULL.
EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13));

View File

@ -63,12 +63,7 @@ class AudioDecoder {
// Used by PacketDuration below. Save the value -1 for errors. // Used by PacketDuration below. Save the value -1 for errors.
enum { kNotImplemented = -2 }; enum { kNotImplemented = -2 };
explicit AudioDecoder(enum NetEqDecoder type) AudioDecoder() : channels_(1), state_(NULL) {}
: codec_type_(type),
channels_(1),
state_(NULL) {
}
virtual ~AudioDecoder() {} virtual ~AudioDecoder() {}
// Decodes |encode_len| bytes from |encoded| and writes the result in // 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. // Returns true if the packet has FEC and false otherwise.
virtual bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const; virtual bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const;
virtual NetEqDecoder codec_type() const;
// Returns the underlying decoder state. // Returns the underlying decoder state.
void* state() { return state_; } void* state() { return state_; }
@ -140,7 +133,6 @@ class AudioDecoder {
protected: protected:
static SpeechType ConvertSpeechType(int16_t type); static SpeechType ConvertSpeechType(int16_t type);
enum NetEqDecoder codec_type_;
size_t channels_; size_t channels_;
void* state_; void* state_;

View File

@ -19,7 +19,7 @@ namespace webrtc {
class MockAudioDecoder : public AudioDecoder { class MockAudioDecoder : public AudioDecoder {
public: public:
MockAudioDecoder() : AudioDecoder(kDecoderArbitrary) {} MockAudioDecoder() {}
virtual ~MockAudioDecoder() { Die(); } virtual ~MockAudioDecoder() { Die(); }
MOCK_METHOD0(Die, void()); MOCK_METHOD0(Die, void());
MOCK_METHOD4(Decode, int(const uint8_t*, size_t, int16_t*, MOCK_METHOD4(Decode, int(const uint8_t*, size_t, int16_t*,

View File

@ -27,9 +27,7 @@ using ::testing::Invoke;
// audio_decoder_impl.{cc, h}. // audio_decoder_impl.{cc, h}.
class ExternalPcm16B : public AudioDecoder { class ExternalPcm16B : public AudioDecoder {
public: public:
explicit ExternalPcm16B(enum NetEqDecoder type) ExternalPcm16B() {}
: AudioDecoder(type) {
}
virtual int Decode(const uint8_t* encoded, size_t encoded_len, virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type) { 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. // The reason is that we can then track that the correct calls are being made.
class MockExternalPcm16B : public ExternalPcm16B { class MockExternalPcm16B : public ExternalPcm16B {
public: public:
explicit MockExternalPcm16B(enum NetEqDecoder type) MockExternalPcm16B() {
: ExternalPcm16B(type),
real_(type) {
// By default, all calls are delegated to the real object. // By default, all calls are delegated to the real object.
ON_CALL(*this, Decode(_, _, _, _)) ON_CALL(*this, Decode(_, _, _, _))
.WillByDefault(Invoke(&real_, &ExternalPcm16B::Decode)); .WillByDefault(Invoke(&real_, &ExternalPcm16B::Decode));
@ -67,8 +63,6 @@ class MockExternalPcm16B : public ExternalPcm16B {
.WillByDefault(Invoke(&real_, &ExternalPcm16B::IncomingPacket)); .WillByDefault(Invoke(&real_, &ExternalPcm16B::IncomingPacket));
ON_CALL(*this, ErrorCode()) ON_CALL(*this, ErrorCode())
.WillByDefault(Invoke(&real_, &ExternalPcm16B::ErrorCode)); .WillByDefault(Invoke(&real_, &ExternalPcm16B::ErrorCode));
ON_CALL(*this, codec_type())
.WillByDefault(Invoke(&real_, &ExternalPcm16B::codec_type));
} }
virtual ~MockExternalPcm16B() { Die(); } virtual ~MockExternalPcm16B() { Die(); }

View File

@ -47,7 +47,7 @@ class NetEqExternalDecoderTest : public ::testing::Test {
frame_size_ms_(10), frame_size_ms_(10),
frame_size_samples_(frame_size_ms_ * samples_per_ms_), frame_size_samples_(frame_size_ms_ * samples_per_ms_),
output_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_)), rtp_generator_(new test::RtpGenerator(samples_per_ms_)),
payload_size_bytes_(0), payload_size_bytes_(0),
last_send_time_(0), last_send_time_(0),
@ -241,7 +241,7 @@ class LargeTimestampJumpTest : public NetEqExternalDecoderTest {
frame_size_samples_ = frame_size_ms_ * samples_per_ms_; frame_size_samples_ = frame_size_ms_ * samples_per_ms_;
output_size_samples_ = frame_size_ms_ * samples_per_ms_; output_size_samples_ = frame_size_ms_ * samples_per_ms_;
EXPECT_CALL(*external_decoder_, Die()).Times(1); EXPECT_CALL(*external_decoder_, Die()).Times(1);
external_decoder_.reset(new MockExternalPcm16B(kDecoderPCM16B)); external_decoder_.reset(new MockExternalPcm16B);
} }
void SetUp() OVERRIDE { void SetUp() OVERRIDE {

View File

@ -422,8 +422,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
// sample, and then increasing by 1 for each sample. // sample, and then increasing by 1 for each sample.
class CountingSamplesDecoder : public AudioDecoder { class CountingSamplesDecoder : public AudioDecoder {
public: public:
explicit CountingSamplesDecoder(enum NetEqDecoder type) CountingSamplesDecoder() : next_value_(1) {}
: AudioDecoder(type), next_value_(1) {}
// Produce as many samples as input bytes (|encoded_len|). // Produce as many samples as input bytes (|encoded_len|).
virtual int Decode(const uint8_t* encoded, virtual int Decode(const uint8_t* encoded,
@ -446,7 +445,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
private: private:
int16_t next_value_; int16_t next_value_;
} decoder_(kDecoderPCM16B); } decoder_;
EXPECT_EQ(NetEq::kOK, EXPECT_EQ(NetEq::kOK,
neteq_->RegisterExternalDecoder( neteq_->RegisterExternalDecoder(