1. Make a clear distinction between codec internal FEC and RED, confusing mentioning of FEC in the old codes is replaced by RED

2. Add two new APIs to configure codec internal FEC

3. Add a test and listened to results. This is based modifying EncodeDecodeTest and deriving a new class from it.

New ACM gives good result.
Old ACM does not use NetEq 4, so FEC won't be decoded.

BUG=
R=tina.legrand@webrtc.org, turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/11759004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6233 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
minyue@webrtc.org
2014-05-23 15:16:51 +00:00
parent 706152dcc9
commit aa5ea1c0f9
17 changed files with 708 additions and 159 deletions

View File

@ -10,12 +10,9 @@
#include "webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h"
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <string>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h"
@ -54,16 +51,19 @@ Sender::Sender()
_packetization(NULL) {
}
void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
std::string in_file_name, int sample_rate, int channels) {
acm->InitializeSender();
struct CodecInst sendCodec;
int noOfCodecs = acm->NumberOfCodecs();
int codecNo;
// Open input file
const std::string file_name = webrtc::test::ResourcePath(
"audio_coding/testfile32kHz", "pcm");
_pcmFile.Open(file_name, 32000, "rb");
const std::string file_name = webrtc::test::ResourcePath(in_file_name, "pcm");
_pcmFile.Open(file_name, sample_rate, "rb");
if (channels == 2) {
_pcmFile.ReadStereo(true);
}
// Set the codec for the current test.
if ((testMode == 0) || (testMode == 1)) {
@ -81,10 +81,8 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
}
EXPECT_EQ(0, acm->Codec(codecNo, &sendCodec));
// Default number of channels is 2 for CELT, so we change to 1 in this test.
if (!strcmp(sendCodec.plname, "CELT")) {
sendCodec.channels = 1;
}
sendCodec.channels = channels;
EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec));
_packetization = new TestPacketization(rtpStream, sendCodec.plfreq);
@ -125,21 +123,28 @@ Receiver::Receiver()
_payloadSizeBytes(MAX_INCOMING_PAYLOAD) {
}
void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
std::string out_file_name, int channels) {
struct CodecInst recvCodec;
int noOfCodecs;
EXPECT_EQ(0, acm->InitializeReceiver());
noOfCodecs = acm->NumberOfCodecs();
for (int i = 0; i < noOfCodecs; i++) {
EXPECT_EQ(0, acm->Codec(static_cast<uint8_t>(i), &recvCodec));
EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
EXPECT_EQ(0, acm->Codec(i, &recvCodec));
if (recvCodec.channels == channels)
EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
// Forces mono/stereo for Opus.
if (!strcmp(recvCodec.plname, "opus")) {
recvCodec.channels = channels;
EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
}
}
int playSampFreq;
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath() << "encodeDecode_out"
file_stream << webrtc::test::OutputPath() << out_file_name
<< static_cast<int>(codeId) << ".pcm";
file_name = file_stream.str();
_rtpStream = rtpStream;
@ -156,7 +161,7 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
printf("which means output frequency equal to received signal frequency");
printf("\n\nChoose output sampling frequency: ");
ASSERT_GT(scanf("%d", &playSampFreq), 0);
file_name = webrtc::test::OutputPath() + "encodeDecode_out.pcm";
file_name = webrtc::test::OutputPath() + out_file_name + ".pcm";
_pcmFile.Open(file_name, playSampFreq, "wb+");
}
@ -213,7 +218,8 @@ bool Receiver::PlayoutData() {
if (_playoutLengthSmpls == 0) {
return false;
}
_pcmFile.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
_pcmFile.Write10MsData(audioFrame.data_,
audioFrame.samples_per_channel_ * audioFrame.num_channels_);
return true;
}
@ -310,7 +316,7 @@ void EncodeDecodeTest::Perform() {
_receiver.codeId = codeId;
rtpFile.ReadHeader();
_receiver.Setup(acm.get(), &rtpFile);
_receiver.Setup(acm.get(), &rtpFile, "encodeDecode_out", 1);
_receiver.Run();
_receiver.Teardown();
rtpFile.Close();
@ -335,7 +341,7 @@ void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
_sender.testMode = testMode;
_sender.codeId = codeId;
_sender.Setup(acm.get(), &rtpFile);
_sender.Setup(acm.get(), &rtpFile, "audio_coding/testfile32kHz", 32000, 1);
struct CodecInst sendCodecInst;
if (acm->SendCodec(&sendCodecInst) >= 0) {
_sender.Run();