Moving to use data files in resources, for ACM.

The files are removed in a separate CL.

BUG=issue737

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2625 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org
2012-08-17 10:38:28 +00:00
parent c3115837ed
commit ba46804417
15 changed files with 222 additions and 343 deletions

2
DEPS
View File

@ -14,7 +14,7 @@ vars = {
# External resources like video and audio files used for testing purposes.
# Downloaded on demand when needed.
"webrtc_resources_revision": "9",
"webrtc_resources_revision": "10",
}
# NOTE: Prefer revision numbers to tags for svn deps. Use http rather than

View File

@ -5,7 +5,7 @@
# This script can be used to verify the bit exactness of iLBC fixed-point version 1.0.6
#
INP=../../../../../../../data/audio_coding
INP=../../../../../../../resources/audio_coding
EXEP=../../../../../../../out/Release
OUTP=./GeneratedFiles
mkdir ./GeneratedFiles

View File

@ -256,7 +256,6 @@ APITest::SetUp()
CHECK_ERROR_MT(_acmB->RegisterSendCodec(dummyCodec));
_thereIsEncoderB = true;
char fileName[500];
WebRtc_UWord16 frequencyHz;
printf("\n\nAPI Test\n");
@ -264,31 +263,30 @@ APITest::SetUp()
printf("Hit enter to accept the default values indicated in []\n\n");
//--- Input A
strcpy(fileName, "./data/audio_coding/testfile32kHz.pcm");
std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000;
printf("Enter input file at side A [%s]: ", fileName);
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
_inFileA.Open(fileName, frequencyHz, "rb", true);
printf("Enter input file at side A [%s]: ", file_name.c_str());
PCMFile::ChooseFile(&file_name, 499, &frequencyHz);
_inFileA.Open(file_name, frequencyHz, "rb", true);
//--- Output A
std::string outputFileA = webrtc::test::OutputPath() + "outA.pcm";
strcpy(fileName, outputFileA.c_str());
printf("Enter output file at side A [%s]: ", fileName);
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
_outFileA.Open(fileName, frequencyHz, "wb");
std::string out_file_a = webrtc::test::OutputPath() + "outA.pcm";
printf("Enter output file at side A [%s]: ", out_file_a.c_str());
PCMFile::ChooseFile(&out_file_a, 499, &frequencyHz);
_outFileA.Open(out_file_a, frequencyHz, "wb");
//--- Input B
strcpy(fileName, "./data/audio_coding/testfile32kHz.pcm");
printf("\n\nEnter input file at side B [%s]: ", fileName);
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
_inFileB.Open(fileName, frequencyHz, "rb", true);
file_name = webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
printf("\n\nEnter input file at side B [%s]: ", file_name.c_str());
PCMFile::ChooseFile(&file_name, 499, &frequencyHz);
_inFileB.Open(file_name, frequencyHz, "rb", true);
//--- Output B
std::string outputFileB = webrtc::test::OutputPath() + "outB.pcm";
strcpy(fileName, outputFileB.c_str());
printf("Enter output file at side B [%s]: ", fileName);
PCMFile::ChooseFile(fileName, 499, &frequencyHz);
_outFileB.Open(fileName, frequencyHz, "wb");
std::string out_file_b = webrtc::test::OutputPath() + "outB.pcm";
printf("Enter output file at side B [%s]: ", out_file_b.c_str());
PCMFile::ChooseFile(&out_file_b, 499, &frequencyHz);
_outFileB.Open(out_file_b, frequencyHz, "wb");
//--- Set A-to-B channel
_channel_A2B = new Channel(2);

View File

@ -10,6 +10,7 @@
#include "EncodeDecodeTest.h"
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -59,20 +60,17 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
int noOfCodecs = acm->NumberOfCodecs();
int codecNo;
if (testMode == 1) {
// Set the codec, input file, and parameters for the current test.
// Open input file
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
_pcmFile.Open(file_name, 32000, "rb");
// Set the codec for the current test.
if ((testMode == 0) || (testMode == 1)) {
// Set the codec id.
codecNo = codeId;
// Use same input file for now.
char fileName[] = "./data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
} else if (testMode == 0) {
// Set the codec, input file, and parameters for the current test.
codecNo = codeId;
acm->Codec(codecNo, sendCodec);
// Use same input file for now.
char fileName[] = "./data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
} else {
// Choose codec on command line.
printf("List of supported codec.\n");
for (int n = 0; n < noOfCodecs; n++) {
acm->Codec(n, sendCodec);
@ -80,8 +78,6 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
}
printf("Choose your codec:");
ASSERT_GT(scanf("%d", &codecNo), 0);
char fileName[] = "./data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
}
acm->Codec(codecNo, sendCodec);
@ -95,8 +91,8 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
codeId);
}
_acm = acm;
}
_acm = acm;
}
void Sender::Teardown() {
_pcmFile.Close();
@ -155,30 +151,28 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
}
}
char filename[256];
_rtpStream = rtpStream;
int playSampFreq;
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath() << "encodeDecode_out" <<
static_cast<int>(codeId) << ".pcm";
file_name = file_stream.str();
_rtpStream = rtpStream;
if (testMode == 1) {
playSampFreq=recvCodec.plfreq;
//output file for current run
sprintf(filename,"%s/out%dFile.pcm", webrtc::test::OutputPath().c_str(),
codeId);
_pcmFile.Open(filename, recvCodec.plfreq, "wb+");
_pcmFile.Open(file_name, recvCodec.plfreq, "wb+");
} else if (testMode == 0) {
playSampFreq=32000;
//output file for current run
sprintf(filename, "%s/encodeDecode_out%d.pcm",
webrtc::test::OutputPath().c_str(), codeId);
_pcmFile.Open(filename, 32000/*recvCodec.plfreq*/, "wb+");
_pcmFile.Open(file_name, 32000, "wb+");
} else {
printf("\nValid output frequencies:\n");
printf("8000\n16000\n32000\n-1,");
printf("which means output freq equal to received signal freq");
printf("which means output frequency equal to received signal frequency");
printf("\n\nChoose output sampling frequency: ");
ASSERT_GT(scanf("%d", &playSampFreq), 0);
sprintf(filename, "%s/outFile.pcm", webrtc::test::OutputPath().c_str());
_pcmFile.Open(filename, 32000, "wb+");
file_name = webrtc::test::OutputPath() + "encodeDecode_out.pcm";
_pcmFile.Open(file_name, playSampFreq, "wb+");
}
_realPayloadSizeBytes = 0;

View File

@ -46,7 +46,8 @@ PCMFile::PCMFile(WebRtc_UWord32 timestamp)
timestamp_ = timestamp;
}
WebRtc_Word16 PCMFile::ChooseFile(char* filename, WebRtc_Word16 max_len) {
WebRtc_Word16 PCMFile::ChooseFile(std::string* file_name,
WebRtc_Word16 max_len) {
char tmp_name[MAX_FILE_NAME_LENGTH_BYTE];
EXPECT_TRUE(fgets(tmp_name, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL);
@ -78,12 +79,14 @@ WebRtc_Word16 PCMFile::ChooseFile(char* filename, WebRtc_Word16 max_len) {
return -1;
}
if (len > 0) {
strncpy(filename, tmp_name, len + 1);
std::string tmp_string(tmp_name, len + 1);
*file_name = tmp_string;
}
return 0;
}
WebRtc_Word16 PCMFile::ChooseFile(char* filename, WebRtc_Word16 max_len,
WebRtc_Word16 PCMFile::ChooseFile(std::string* file_name,
WebRtc_Word16 max_len,
WebRtc_UWord16* frequency_hz) {
char tmp_name[MAX_FILE_NAME_LENGTH_BYTE];
@ -116,7 +119,8 @@ WebRtc_Word16 PCMFile::ChooseFile(char* filename, WebRtc_Word16 max_len,
return -1;
}
if (len > 0) {
strncpy(filename, tmp_name, len + 1);
std::string tmp_string(tmp_name, len + 1);
*file_name = tmp_string;
}
printf("Enter the sampling frequency (in Hz) of the above file [%u]: ",
*frequency_hz);
@ -128,10 +132,10 @@ WebRtc_Word16 PCMFile::ChooseFile(char* filename, WebRtc_Word16 max_len,
return 0;
}
void PCMFile::Open(const char* filename, WebRtc_UWord16 frequency,
void PCMFile::Open(const std::string& file_name, WebRtc_UWord16 frequency,
const char* mode, bool auto_rewind) {
if ((pcm_file_ = fopen(filename, mode)) == NULL) {
printf("Cannot open file %s.\n", filename);
if ((pcm_file_ = fopen(file_name.c_str(), mode)) == NULL) {
printf("Cannot open file %s.\n", file_name.c_str());
ADD_FAILURE() << "Unable to read file";
}
frequency_ = frequency;

View File

@ -13,6 +13,7 @@
#include <cstdio>
#include <cstdlib>
#include <string>
#include "module_common_types.h"
#include "typedefs.h"
@ -28,8 +29,9 @@ class PCMFile {
fclose(pcm_file_);
}
}
void Open(const char *filename, WebRtc_UWord16 frequency, const char *mode,
bool auto_rewind = false);
void Open(const std::string& filename, WebRtc_UWord16 frequency,
const char* mode, bool auto_rewind = false);
WebRtc_Word32 Read10MsData(AudioFrame& audio_frame);
@ -44,9 +46,11 @@ class PCMFile {
return end_of_file_;
}
void Rewind();
static WebRtc_Word16 ChooseFile(char* filename, WebRtc_Word16 max_len,
static WebRtc_Word16 ChooseFile(std::string* file_name,
WebRtc_Word16 max_len,
WebRtc_UWord16* frequency_hz);
static WebRtc_Word16 ChooseFile(char* filename, WebRtc_Word16 max_len);
static WebRtc_Word16 ChooseFile(std::string* file_name,
WebRtc_Word16 max_len);
bool Rewinded();
void SaveStereo(bool is_stereo = true);
void ReadStereo(bool is_stereo = true);

View File

@ -53,62 +53,45 @@ SpatialAudio::Setup()
// Register the receiver ACM in channel
_channel->RegisterReceiverACM(_acmReceiver);
char audioFileName[MAX_FILE_NAME_LENGTH_BYTE];
WebRtc_UWord16 sampFreqHz = 32000;
strncpy(audioFileName, "./data/audio_coding/testfile32kHz.pcm",
MAX_FILE_NAME_LENGTH_BYTE - 1);
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
_inFile.Open(file_name, sampFreqHz, "rb", false);
std::string output_file = webrtc::test::OutputPath() +
"out_spatial_autotest.pcm";
if(_testMode == 1)
{
printf("Enter the input file [%s]: ", audioFileName);
PCMFile::ChooseFile(audioFileName, MAX_FILE_NAME_LENGTH_BYTE, &sampFreqHz);
}
_inFile.Open(audioFileName, sampFreqHz, "rb", false);
if(_testMode == 0)
{
std::string outputFile = webrtc::test::OutputPath() +
"out_spatial_autotest.pcm";
strncpy(audioFileName, outputFile.c_str(),
MAX_FILE_NAME_LENGTH_BYTE - 1);
}
else if(_testMode == 1)
{
output_file = webrtc::test::OutputPath() + "testspatial_out.pcm";
printf("\n");
std::string outputFile = webrtc::test::OutputPath() +
"testspatial_out.pcm";
strncpy(audioFileName, outputFile.c_str(),
MAX_FILE_NAME_LENGTH_BYTE - 1);
printf("Enter the output file [%s]: ", audioFileName);
PCMFile::ChooseFile(audioFileName, MAX_FILE_NAME_LENGTH_BYTE, &sampFreqHz);
printf("Enter the output file [%s]: ", output_file.c_str());
PCMFile::ChooseFile(&output_file, MAX_FILE_NAME_LENGTH_BYTE,
&sampFreqHz);
}
else
{
std::string outputFile = webrtc::test::OutputPath() +
"testspatial_out.pcm";
strncpy(audioFileName, outputFile.c_str(),
MAX_FILE_NAME_LENGTH_BYTE - 1);
output_file = webrtc::test::OutputPath() + "testspatial_out.pcm";
}
_outFile.Open(audioFileName, sampFreqHz, "wb", false);
_outFile.Open(output_file, sampFreqHz, "wb", false);
_outFile.SaveStereo(true);
// Register couple of codecs as receive codec
// Register all available codes as receiving codecs.
CodecInst codecInst;
_acmLeft->Codec((WebRtc_UWord8)0, codecInst);
codecInst.channels = 2;
CHECK_ERROR(_acmReceiver->RegisterReceiveCodec(codecInst));
_acmLeft->Codec((WebRtc_UWord8)3, codecInst);
codecInst.channels = 2;
CHECK_ERROR(_acmReceiver->RegisterReceiveCodec(codecInst));
_acmLeft->Codec((WebRtc_UWord8)1, codecInst);
CHECK_ERROR(_acmReceiver->RegisterReceiveCodec(codecInst));
_acmLeft->Codec((WebRtc_UWord8)4, codecInst);
CHECK_ERROR(_acmReceiver->RegisterReceiveCodec(codecInst));
int status;
WebRtc_UWord8 num_encoders = _acmReceiver->NumberOfCodecs();
// Register all available codes as receiving codecs once more.
for (WebRtc_UWord8 n = 0; n < num_encoders; n++) {
status = _acmReceiver->Codec(n, codecInst);
if (status < 0) {
printf("Error in Codec(), no matching codec found");
}
status = _acmReceiver->RegisterReceiveCodec(codecInst);
if (status < 0) {
printf("Error in RegisterReceiveCodec() for payload type %d",
codecInst.pltype);
}
}
return 0;
}
@ -119,7 +102,8 @@ SpatialAudio::Perform()
if(_testMode == 0)
{
printf("Running SpatialAudio Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- SpatialAudio ----------");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- SpatialAudio ----------");
}
Setup();

View File

@ -127,8 +127,10 @@ TestAllCodecs::~TestAllCodecs() {
}
void TestAllCodecs::Perform() {
char file[] = "./data/audio_coding/testfile32kHz.pcm";
infile_a_.Open(file, 32000, "rb");
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
infile_a_.Open(file_name, 32000, "rb");
if (test_mode_ == 0) {
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
@ -792,7 +794,7 @@ void TestAllCodecs::OpenOutFile(int test_number) {
filename += "testallcodecs_out_";
filename += test_number_str.str();
filename += ".pcm";
outfile_b_.Open(filename.c_str(), 32000, "wb");
outfile_b_.Open(filename, 32000, "wb");
}
void TestAllCodecs::DisplaySendReceiveCodec() {

View File

@ -59,9 +59,9 @@ void TestFEC::Perform()
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestFEC ----------");
}
char fileName[] = "./data/audio_coding/testfile32kHz.pcm";
_inFileA.Open(fileName, 32000, "rb");
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb");
bool fecEnabled;
@ -599,21 +599,18 @@ void TestFEC::Run()
_inFileA.Rewind();
}
void TestFEC::OpenOutFile(WebRtc_Word16 testNumber)
{
char fileName[500];
if(_testMode == 0)
{
sprintf(fileName, "%s/TestFEC_autoFile_%02d.pcm",
webrtc::test::OutputPath().c_str(), testNumber);
}
else
{
sprintf(fileName, "%s/TestFEC_outFile_%02d.pcm",
webrtc::test::OutputPath().c_str(), testNumber);
}
_outFileB.Open(fileName, 32000, "wb");
void TestFEC::OpenOutFile(WebRtc_Word16 test_number) {
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath();
if (_testMode == 0) {
file_stream << "TestFEC_autoFile_";
} else {
file_stream << "TestFEC_outFile_";
}
file_stream << test_number << ".pcm";
file_name = file_stream.str();
_outFileB.Open(file_name, 16000, "wb");
}
void TestFEC::DisplaySendReceiveCodec()

View File

@ -144,8 +144,6 @@ TestStereo::~TestStereo() {
}
void TestStereo::Perform() {
char file_name_stereo[500];
char file_name_mono[500];
WebRtc_UWord16 frequency_hz;
int audio_channels;
int codec_channels;
@ -160,9 +158,10 @@ void TestStereo::Perform() {
}
// Open both mono and stereo test files in 32 kHz.
strcpy(file_name_stereo, "./data/audio_coding/teststereo32kHz.pcm");
strcpy(file_name_mono, "./data/audio_coding/testfile32kHz.pcm");
const std::string file_name_stereo =
webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm");
const std::string file_name_mono =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequency_hz = 32000;
in_file_stereo_ = new PCMFile();
in_file_mono_ = new PCMFile();
@ -655,7 +654,7 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name,
int payload_type) {
if (test_mode_ != 0) {
// Print out codec and settings
printf("Codec: %s Freq: %d Rate: %d PackSize: %d", codec_name,
printf("Codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name,
sampling_freq_hz, rate, pack_size);
}
@ -776,9 +775,11 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
}
void TestStereo::OpenOutFile(WebRtc_Word16 test_number) {
char file_name[500];
sprintf(file_name, "%s/teststereo_out_%02d.pcm",
webrtc::test::OutputPath().c_str(), test_number);
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath() << "teststereo_out_"
<< test_number << ".pcm";
file_name = file_stream.str();
out_file_.Open(file_name, 32000, "wb");
}

View File

@ -59,8 +59,10 @@ void TestVADDTX::Perform()
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- TestVADDTX ----------");
}
char fileName[] = "./data/audio_coding/testfile32kHz.pcm";
_inFileA.Open(fileName, 32000, "rb");
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb");
_acmA = AudioCodingModule::Create(0);
_acmB = AudioCodingModule::Create(1);
@ -354,20 +356,18 @@ void TestVADDTX::Run()
_monitor.ResetStatistics();
}
void TestVADDTX::OpenOutFile(WebRtc_Word16 testNumber)
{
char fileName[500];
if(_testMode == 0)
{
sprintf(fileName, "%s/testVADDTX_autoFile_%02d.pcm",
webrtc::test::OutputPath().c_str(), testNumber);
}
else
{
sprintf(fileName, "%s/testVADDTX_outFile_%02d.pcm",
webrtc::test::OutputPath().c_str(), testNumber);
}
_outFileB.Open(fileName, 16000, "wb");
void TestVADDTX::OpenOutFile(WebRtc_Word16 test_number) {
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath();
if (_testMode == 0) {
file_stream << "testVADDTX_autoFile_";
} else {
file_stream << "testVADDTX_outFile_";
}
file_stream << test_number << ".pcm";
file_name = file_stream.str();
_outFileB.Open(file_name, 16000, "wb");
}

View File

@ -95,64 +95,6 @@ TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A,
return 0;
}
WebRtc_Word16
TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen,
WebRtc_UWord16* frequencyHz)
{
char tmpName[MAX_FILE_NAME_LENGTH_BYTE];
//strcpy(_fileName, "in.pcm");
//printf("\n\nPlease enter the input file: ");
EXPECT_TRUE(fgets(tmpName, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL);
tmpName[MAX_FILE_NAME_LENGTH_BYTE-1] = '\0';
WebRtc_Word16 n = 0;
// removing leading spaces
while((isspace(tmpName[n]) || iscntrl(tmpName[n])) &&
(tmpName[n] != 0) &&
(n < MAX_FILE_NAME_LENGTH_BYTE))
{
n++;
}
if(n > 0)
{
memmove(tmpName, &tmpName[n], MAX_FILE_NAME_LENGTH_BYTE - n);
}
//removing trailing spaces
n = (WebRtc_Word16)(strlen(tmpName) - 1);
if(n >= 0)
{
while((isspace(tmpName[n]) || iscntrl(tmpName[n])) &&
(n >= 0))
{
n--;
}
}
if(n >= 0)
{
tmpName[n + 1] = '\0';
}
WebRtc_Word16 len = (WebRtc_Word16)strlen(tmpName);
if(len > maxLen)
{
return -1;
}
if(len > 0)
{
strncpy(fileName, tmpName, len+1);
}
printf("Enter the sampling frequency (in Hz) of the above file [%u]: ",
*frequencyHz);
EXPECT_TRUE(fgets(tmpName, 6, stdin) != NULL);
WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName);
if(tmpFreq > 0)
{
*frequencyHz = tmpFreq;
}
return 0;
}
WebRtc_Word16 TwoWayCommunication::SetUp()
{
_acmA = AudioCodingModule::Create(1);
@ -198,47 +140,41 @@ WebRtc_Word16 TwoWayCommunication::SetUp()
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
char fileName[500];
char refFileName[500];
WebRtc_UWord16 frequencyHz;
//--- Input A
strcpy(fileName, "./data/audio_coding/testfile32kHz.pcm");
std::string in_file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000;
printf("Enter input file at side A [%s]: ", fileName);
ChooseFile(fileName, 499, &frequencyHz);
_inFileA.Open(fileName, frequencyHz, "rb");
printf("Enter input file at side A [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
_inFileA.Open(in_file_name, frequencyHz, "rb");
//--- Output A
std::string outputFileA = webrtc::test::OutputPath() + "outA.pcm";
strcpy(fileName, outputFileA.c_str());
frequencyHz = 16000;
printf("Enter output file at side A [%s]: ", fileName);
ChooseFile(fileName, 499, &frequencyHz);
_outFileA.Open(fileName, frequencyHz, "wb");
strcpy(refFileName, "ref_");
strcat(refFileName, fileName);
_outFileRefA.Open(refFileName, frequencyHz, "wb");
std::string out_file_a = webrtc::test::OutputPath() + "outA.pcm";
printf("Output file at side A: %s\n", out_file_a.c_str());
printf("Sampling frequency (in Hz) of the above file: %u\n",
frequencyHz);
_outFileA.Open(out_file_a, frequencyHz, "wb");
std::string ref_file_name = webrtc::test::OutputPath() + "ref_outA.pcm";
_outFileRefA.Open(ref_file_name, frequencyHz, "wb");
//--- Input B
strcpy(fileName, "./data/audio_coding/testfile32kHz.pcm");
in_file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000;
printf("\n\nEnter input file at side B [%s]: ", fileName);
ChooseFile(fileName, 499, &frequencyHz);
_inFileB.Open(fileName, frequencyHz, "rb");
printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
_inFileB.Open(in_file_name, frequencyHz, "rb");
//--- Output B
std::string outputFileB = webrtc::test::OutputPath() + "outB.pcm";
strcpy(fileName, outputFileB.c_str());
frequencyHz = 16000;
printf("Enter output file at side B [%s]: ", fileName);
ChooseFile(fileName, 499, &frequencyHz);
_outFileB.Open(fileName, frequencyHz, "wb");
strcpy(refFileName, "ref_");
strcat(refFileName, fileName);
_outFileRefB.Open(refFileName, frequencyHz, "wb");
std::string out_file_b = webrtc::test::OutputPath() + "outB.pcm";
printf("Output file at side B: %s\n", out_file_b.c_str());
printf("Sampling frequency (in Hz) of the above file: %u\n",
frequencyHz);
_outFileB.Open(out_file_b, frequencyHz, "wb");
ref_file_name = webrtc::test::OutputPath() + "ref_outB.pcm";
_outFileRefB.Open(ref_file_name, frequencyHz, "wb");
//--- Set A-to-B channel
_channel_A2B = new Channel;
@ -308,38 +244,30 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
char fileName[500];
char refFileName[500];
WebRtc_UWord16 frequencyHz;
//--- Input A
strcpy(fileName, "./data/audio_coding/testfile32kHz.pcm");
//--- Input A and B
std::string in_file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 16000;
_inFileA.Open(fileName, frequencyHz, "rb");
_inFileA.Open(in_file_name, frequencyHz, "rb");
_inFileB.Open(in_file_name, frequencyHz, "rb");
//--- Output A
std::string outputFileA = webrtc::test::OutputPath() + "outAutotestA.pcm";
strcpy(fileName, outputFileA.c_str());
std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm";
frequencyHz = 16000;
_outFileA.Open(fileName, frequencyHz, "wb");
std::string outputRefFileA = webrtc::test::OutputPath() + "ref_outAutotestA.pcm";
strcpy(refFileName, outputRefFileA.c_str());
_outFileRefA.Open(refFileName, frequencyHz, "wb");
//--- Input B
strcpy(fileName, "./data/audio_coding/testfile32kHz.pcm");
frequencyHz = 16000;
_inFileB.Open(fileName, frequencyHz, "rb");
_outFileA.Open(output_file_a, frequencyHz, "wb");
std::string output_ref_file_a = webrtc::test::OutputPath() +
"ref_outAutotestA.pcm";
_outFileRefA.Open(output_ref_file_a, frequencyHz, "wb");
//--- Output B
std::string outputFileB = webrtc::test::OutputPath() + "outAutotestB.pcm";
strcpy(fileName, outputFileB.c_str());
std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm";
frequencyHz = 16000;
_outFileB.Open(fileName, frequencyHz, "wb");
std::string outputRefFileB = webrtc::test::OutputPath() + "ref_outAutotestB.pcm";
strcpy(refFileName, outputRefFileB.c_str());
_outFileRefB.Open(refFileName, frequencyHz, "wb");
_outFileB.Open(output_file_b, frequencyHz, "wb");
std::string output_ref_file_b = webrtc::test::OutputPath() +
"ref_outAutotestB.pcm";
_outFileRefB.Open(output_ref_file_b, frequencyHz, "wb");
//--- Set A-to-B channel
_channel_A2B = new Channel;

View File

@ -28,7 +28,6 @@ public:
void Perform();
private:
WebRtc_UWord8 ChooseCodec(WebRtc_UWord8* codecID_A, WebRtc_UWord8* codecID_B);
WebRtc_Word16 ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWord16* frequencyHz);
WebRtc_Word16 SetUp();
WebRtc_Word16 SetUpAutotest();

View File

@ -184,8 +184,8 @@ ISACTest::Setup()
CHECK_ERROR(_acmB->RegisterTransportCallback(_channel_B2A));
_channel_B2A->RegisterReceiverACM(_acmA);
strncpy(_fileNameSWB, "./data/audio_coding/testfile32kHz.pcm",
MAX_FILE_NAME_LENGTH_BYTE);
file_name_swb_ =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
_acmB->RegisterSendCodec(_paramISAC16kHz);
_acmA->RegisterSendCodec(_paramISAC32kHz);
@ -199,11 +199,11 @@ ISACTest::Setup()
printf("%s %d\n", _paramISAC16kHz.plname, _paramISAC16kHz.plfreq);
}
_inFileA.Open(_fileNameSWB, 32000, "rb");
_inFileA.Open(file_name_swb_, 32000, "rb");
std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
_outFileA.Open(fileNameA.c_str(), 32000, "wb");
_outFileB.Open(fileNameB.c_str(), 32000, "wb");
_outFileA.Open(fileNameA, 32000, "wb");
_outFileB.Open(fileNameB, 32000, "wb");
while(!_inFileA.EndOfFile())
{
@ -378,48 +378,32 @@ ISACTest::EncodeDecode(
{
printf("\nTest %d:\n\n", testNr);
}
char fileNameOut[MAX_FILE_NAME_LENGTH_BYTE];
// Files in Side A
_inFileA.Open(_fileNameSWB, 32000, "rb", true);
// Files in Side A and B
_inFileA.Open(file_name_swb_, 32000, "rb", true);
_inFileB.Open(file_name_swb_, 32000, "rb", true);
std::string file_name_out;
std::stringstream file_stream_a;
std::stringstream file_stream_b;
file_stream_a << webrtc::test::OutputPath();
file_stream_b << webrtc::test::OutputPath();
if(_testMode == 0)
{
sprintf(fileNameOut,
"%s/out_iSACTest_%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"A",
testNr);
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
}
else
{
sprintf(fileNameOut,
"%s/out%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"A",
testNr);
file_stream_a << "outA_" << testNr << ".pcm";
file_stream_b << "outB_" << testNr << ".pcm";
}
_outFileA.Open(fileNameOut, 32000, "wb");
file_name_out = file_stream_a.str();
_outFileA.Open(file_name_out, 32000, "wb");
file_name_out = file_stream_b.str();
_outFileB.Open(file_name_out, 32000, "wb");
// Files in Side B
_inFileB.Open(_fileNameSWB, 32000, "rb", true);
if(_testMode == 0)
{
sprintf(fileNameOut,
"%s/out_iSACTest_%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"B",
testNr);
}
else
{
sprintf(fileNameOut,
"%s/out%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"B",
testNr);
}
_outFileB.Open(fileNameOut, 32000, "wb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
@ -491,48 +475,31 @@ ISACTest::SwitchingSamplingRate(
int testNr,
int maxSampRateChange)
{
char fileNameOut[MAX_FILE_NAME_LENGTH_BYTE];
// Files in Side A
_inFileA.Open(_fileNameSWB, 32000, "rb");
_inFileA.Open(file_name_swb_, 32000, "rb");
_inFileB.Open(file_name_swb_, 32000, "rb");
std::string file_name_out;
std::stringstream file_stream_a;
std::stringstream file_stream_b;
file_stream_a << webrtc::test::OutputPath();
file_stream_b << webrtc::test::OutputPath();
if(_testMode == 0)
{
sprintf(fileNameOut,
"%s/out_iSACTest_%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"A",
testNr);
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
}
else
{
printf("\nTest %d", testNr);
printf(" Alternate between WB and SWB at the sender Side\n\n");
sprintf(fileNameOut,
"%s/out%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"A",
testNr);
file_stream_a << "outA_" << testNr << ".pcm";
file_stream_b << "outB_" << testNr << ".pcm";
}
_outFileA.Open(fileNameOut, 32000, "wb", true);
// Files in Side B
_inFileB.Open(_fileNameSWB, 32000, "rb");
if(_testMode == 0)
{
sprintf(fileNameOut,
"%s/out_iSACTest_%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"B",
testNr);
}
else
{
sprintf(fileNameOut, "%s/out%s_%02d.pcm",
webrtc::test::OutputPath().c_str(),
"B",
testNr);
}
_outFileB.Open(fileNameOut, 32000, "wb", true);
file_name_out = file_stream_a.str();
_outFileA.Open(file_name_out, 32000, "wb");
file_name_out = file_stream_b.str();
_outFileB.Open(file_name_out, 32000, "wb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
@ -557,14 +524,14 @@ ISACTest::SwitchingSamplingRate(
{
if(_testMode != 0) printf("\nSide A switched to Send Super-Wideband\n");
_inFileA.Close();
_inFileA.Open(_fileNameSWB, 32000, "rb");
_inFileA.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
}
else
{
if(_testMode != 0) printf("\nSide A switched to Send Wideband\n");
_inFileA.Close();
_inFileA.Open(_fileNameSWB, 32000, "rb");
_inFileA.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
}
numSendCodecChanged++;
@ -576,14 +543,14 @@ ISACTest::SwitchingSamplingRate(
{
if(_testMode != 0) printf("\nSide B switched to Send Super-Wideband\n");
_inFileB.Close();
_inFileB.Open(_fileNameSWB, 32000, "rb");
_inFileB.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
}
else
{
if(_testMode != 0) printf("\nSide B switched to Send Wideband\n");
_inFileB.Close();
_inFileB.Open(_fileNameSWB, 32000, "rb");
_inFileB.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
}
numSendCodecChanged++;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -11,6 +11,8 @@
#ifndef ACM_ISAC_TEST_H
#define ACM_ISAC_TEST_H
#include <string.h>
#include "ACMTest.h"
#include "Channel.h"
#include "PCMFile.h"
@ -81,8 +83,7 @@ private:
CodecInst _paramISAC16kHz;
CodecInst _paramISAC32kHz;
char _fileNameWB[MAX_FILE_NAME_LENGTH_BYTE];
char _fileNameSWB[MAX_FILE_NAME_LENGTH_BYTE];
std::string file_name_swb_;
ACMTestTimer _myTimer;
int _testMode;