Revert "Advertise G722 as 8 kHz rather than 16 kHz"
This reverts r7645. TBR=pthatcher@webrtc.org BUG=3951 Review URL: https://webrtc-codereview.appspot.com/24199004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7653 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
34bda43fa6
commit
dced5d7835
@ -110,7 +110,6 @@ static const int kDefaultAudioDeviceId = 0;
|
|||||||
|
|
||||||
static const char kIsacCodecName[] = "ISAC";
|
static const char kIsacCodecName[] = "ISAC";
|
||||||
static const char kL16CodecName[] = "L16";
|
static const char kL16CodecName[] = "L16";
|
||||||
static const char kG722CodecName[] = "G722";
|
|
||||||
|
|
||||||
// Parameter used for NACK.
|
// Parameter used for NACK.
|
||||||
// This value is equivalent to 5 seconds of audio data at 20 ms per packet.
|
// This value is equivalent to 5 seconds of audio data at 20 ms per packet.
|
||||||
@ -486,24 +485,12 @@ static void GetOpusConfig(const AudioCodec& codec, webrtc::CodecInst* voe_codec,
|
|||||||
voe_codec->rate = GetOpusBitrate(codec, *max_playback_rate);
|
voe_codec->rate = GetOpusBitrate(codec, *max_playback_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changes RTP timestamp rate of G722. This is due to the "bug" in the RFC
|
|
||||||
// which says that G722 should be advertised as 8 kHz although it is a 16 kHz
|
|
||||||
// codec.
|
|
||||||
static void MaybeFixupG722(webrtc::CodecInst* voe_codec, int new_plfreq) {
|
|
||||||
if (_stricmp(voe_codec->plname, kG722CodecName) == 0) {
|
|
||||||
// If the ASSERT triggers, the codec definition in WebRTC VoiceEngine
|
|
||||||
// has changed, and this special case is no longer needed.
|
|
||||||
ASSERT(voe_codec->plfreq != new_plfreq);
|
|
||||||
voe_codec->plfreq = new_plfreq;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebRtcVoiceEngine::ConstructCodecs() {
|
void WebRtcVoiceEngine::ConstructCodecs() {
|
||||||
LOG(LS_INFO) << "WebRtc VoiceEngine codecs:";
|
LOG(LS_INFO) << "WebRtc VoiceEngine codecs:";
|
||||||
int ncodecs = voe_wrapper_->codec()->NumOfCodecs();
|
int ncodecs = voe_wrapper_->codec()->NumOfCodecs();
|
||||||
for (int i = 0; i < ncodecs; ++i) {
|
for (int i = 0; i < ncodecs; ++i) {
|
||||||
webrtc::CodecInst voe_codec;
|
webrtc::CodecInst voe_codec;
|
||||||
if (GetVoeCodec(i, voe_codec)) {
|
if (voe_wrapper_->codec()->GetCodec(i, voe_codec) != -1) {
|
||||||
// Skip uncompressed formats.
|
// Skip uncompressed formats.
|
||||||
if (_stricmp(voe_codec.plname, kL16CodecName) == 0) {
|
if (_stricmp(voe_codec.plname, kL16CodecName) == 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -553,15 +540,6 @@ void WebRtcVoiceEngine::ConstructCodecs() {
|
|||||||
std::sort(codecs_.begin(), codecs_.end(), &AudioCodec::Preferable);
|
std::sort(codecs_.begin(), codecs_.end(), &AudioCodec::Preferable);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebRtcVoiceEngine::GetVoeCodec(int index, webrtc::CodecInst& codec) {
|
|
||||||
if (voe_wrapper_->codec()->GetCodec(index, codec) != -1) {
|
|
||||||
// Change the sample rate of G722 to 8000 to match SDP.
|
|
||||||
MaybeFixupG722(&codec, 8000);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtcVoiceEngine::~WebRtcVoiceEngine() {
|
WebRtcVoiceEngine::~WebRtcVoiceEngine() {
|
||||||
LOG(LS_VERBOSE) << "WebRtcVoiceEngine::~WebRtcVoiceEngine";
|
LOG(LS_VERBOSE) << "WebRtcVoiceEngine::~WebRtcVoiceEngine";
|
||||||
if (voe_wrapper_->base()->DeRegisterVoiceEngineObserver() == -1) {
|
if (voe_wrapper_->base()->DeRegisterVoiceEngineObserver() == -1) {
|
||||||
@ -1246,7 +1224,7 @@ bool WebRtcVoiceEngine::FindWebRtcCodec(const AudioCodec& in,
|
|||||||
int ncodecs = voe_wrapper_->codec()->NumOfCodecs();
|
int ncodecs = voe_wrapper_->codec()->NumOfCodecs();
|
||||||
for (int i = 0; i < ncodecs; ++i) {
|
for (int i = 0; i < ncodecs; ++i) {
|
||||||
webrtc::CodecInst voe_codec;
|
webrtc::CodecInst voe_codec;
|
||||||
if (GetVoeCodec(i, voe_codec)) {
|
if (voe_wrapper_->codec()->GetCodec(i, voe_codec) != -1) {
|
||||||
AudioCodec codec(voe_codec.pltype, voe_codec.plname, voe_codec.plfreq,
|
AudioCodec codec(voe_codec.pltype, voe_codec.plname, voe_codec.plfreq,
|
||||||
voe_codec.rate, voe_codec.channels, 0);
|
voe_codec.rate, voe_codec.channels, 0);
|
||||||
bool multi_rate = IsCodecMultiRate(voe_codec);
|
bool multi_rate = IsCodecMultiRate(voe_codec);
|
||||||
@ -1265,9 +1243,6 @@ bool WebRtcVoiceEngine::FindWebRtcCodec(const AudioCodec& in,
|
|||||||
voe_codec.rate = in.bitrate;
|
voe_codec.rate = in.bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset G722 sample rate to 16000 to match WebRTC.
|
|
||||||
MaybeFixupG722(&voe_codec, 16000);
|
|
||||||
|
|
||||||
// Apply codec-specific settings.
|
// Apply codec-specific settings.
|
||||||
if (IsIsac(codec)) {
|
if (IsIsac(codec)) {
|
||||||
// If ISAC and an explicit bitrate is not specified,
|
// If ISAC and an explicit bitrate is not specified,
|
||||||
|
@ -199,7 +199,6 @@ class WebRtcVoiceEngine
|
|||||||
|
|
||||||
void Construct();
|
void Construct();
|
||||||
void ConstructCodecs();
|
void ConstructCodecs();
|
||||||
bool GetVoeCodec(int index, webrtc::CodecInst& codec);
|
|
||||||
bool InitInternal();
|
bool InitInternal();
|
||||||
bool EnsureSoundclipEngineInit();
|
bool EnsureSoundclipEngineInit();
|
||||||
void SetTraceFilter(int filter);
|
void SetTraceFilter(int filter);
|
||||||
|
@ -52,16 +52,14 @@ static const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1, 0);
|
|||||||
static const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0);
|
static const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0);
|
||||||
static const cricket::AudioCodec kCeltCodec(110, "CELT", 32000, 64000, 2, 0);
|
static const cricket::AudioCodec kCeltCodec(110, "CELT", 32000, 64000, 2, 0);
|
||||||
static const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0);
|
static const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0);
|
||||||
static const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0);
|
|
||||||
static const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0);
|
|
||||||
static const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0);
|
static const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0);
|
||||||
static const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0);
|
static const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0);
|
||||||
static const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0);
|
static const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0);
|
||||||
static const cricket::AudioCodec
|
static const cricket::AudioCodec
|
||||||
kTelephoneEventCodec(106, "telephone-event", 8000, 0, 1, 0);
|
kTelephoneEventCodec(106, "telephone-event", 8000, 0, 1, 0);
|
||||||
static const cricket::AudioCodec* const kAudioCodecs[] = {
|
static const cricket::AudioCodec* const kAudioCodecs[] = {
|
||||||
&kPcmuCodec, &kIsacCodec, &kCeltCodec, &kOpusCodec, &kG722CodecVoE,
|
&kPcmuCodec, &kIsacCodec, &kCeltCodec, &kOpusCodec, &kRedCodec,
|
||||||
&kRedCodec, &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec,
|
&kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec,
|
||||||
};
|
};
|
||||||
const char kRingbackTone[] = "RIFF____WAVE____ABCD1234";
|
const char kRingbackTone[] = "RIFF____WAVE____ABCD1234";
|
||||||
static uint32 kSsrc1 = 0x99;
|
static uint32 kSsrc1 = 0x99;
|
||||||
@ -772,20 +770,6 @@ TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) {
|
|||||||
EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
|
EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that G722 is set with 16000 samples per second to WebRTC.
|
|
||||||
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) {
|
|
||||||
EXPECT_TRUE(SetupEngine());
|
|
||||||
int channel_num = voe_.GetLastChannel();
|
|
||||||
std::vector<cricket::AudioCodec> codecs;
|
|
||||||
codecs.push_back(kG722CodecSdp);
|
|
||||||
EXPECT_TRUE(channel_->SetSendCodecs(codecs));
|
|
||||||
webrtc::CodecInst gcodec;
|
|
||||||
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
|
|
||||||
EXPECT_STREQ("G722", gcodec.plname);
|
|
||||||
EXPECT_EQ(1, gcodec.channels);
|
|
||||||
EXPECT_EQ(16000, gcodec.plfreq);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test that if clockrate is not 48000 for opus, we fail.
|
// Test that if clockrate is not 48000 for opus, we fail.
|
||||||
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) {
|
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) {
|
||||||
EXPECT_TRUE(SetupEngine());
|
EXPECT_TRUE(SetupEngine());
|
||||||
@ -3224,7 +3208,7 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) {
|
|||||||
EXPECT_TRUE(engine.FindCodec(
|
EXPECT_TRUE(engine.FindCodec(
|
||||||
cricket::AudioCodec(96, "PCMA", 8000, 0, 1, 0)));
|
cricket::AudioCodec(96, "PCMA", 8000, 0, 1, 0)));
|
||||||
EXPECT_TRUE(engine.FindCodec(
|
EXPECT_TRUE(engine.FindCodec(
|
||||||
cricket::AudioCodec(96, "G722", 8000, 0, 1, 0)));
|
cricket::AudioCodec(96, "G722", 16000, 0, 1, 0)));
|
||||||
EXPECT_TRUE(engine.FindCodec(
|
EXPECT_TRUE(engine.FindCodec(
|
||||||
cricket::AudioCodec(96, "red", 8000, 0, 1, 0)));
|
cricket::AudioCodec(96, "red", 8000, 0, 1, 0)));
|
||||||
EXPECT_TRUE(engine.FindCodec(
|
EXPECT_TRUE(engine.FindCodec(
|
||||||
@ -3241,7 +3225,7 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) {
|
|||||||
EXPECT_TRUE(engine.FindCodec(
|
EXPECT_TRUE(engine.FindCodec(
|
||||||
cricket::AudioCodec(8, "", 8000, 0, 1, 0))); // PCMA
|
cricket::AudioCodec(8, "", 8000, 0, 1, 0))); // PCMA
|
||||||
EXPECT_TRUE(engine.FindCodec(
|
EXPECT_TRUE(engine.FindCodec(
|
||||||
cricket::AudioCodec(9, "", 8000, 0, 1, 0))); // G722
|
cricket::AudioCodec(9, "", 16000, 0, 1, 0))); // G722
|
||||||
EXPECT_TRUE(engine.FindCodec(
|
EXPECT_TRUE(engine.FindCodec(
|
||||||
cricket::AudioCodec(13, "", 8000, 0, 1, 0))); // CN
|
cricket::AudioCodec(13, "", 8000, 0, 1, 0))); // CN
|
||||||
// Check sample/bitrate matching.
|
// Check sample/bitrate matching.
|
||||||
@ -3264,7 +3248,7 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) {
|
|||||||
EXPECT_EQ(103, it->id);
|
EXPECT_EQ(103, it->id);
|
||||||
} else if (it->name == "ISAC" && it->clockrate == 32000) {
|
} else if (it->name == "ISAC" && it->clockrate == 32000) {
|
||||||
EXPECT_EQ(104, it->id);
|
EXPECT_EQ(104, it->id);
|
||||||
} else if (it->name == "G722" && it->clockrate == 8000) {
|
} else if (it->name == "G722" && it->clockrate == 16000) {
|
||||||
EXPECT_EQ(9, it->id);
|
EXPECT_EQ(9, it->id);
|
||||||
} else if (it->name == "telephone-event") {
|
} else if (it->name == "telephone-event") {
|
||||||
EXPECT_EQ(126, it->id);
|
EXPECT_EQ(126, it->id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user