Refactoring of TestAllCodecs
ACM testing consists of seven individual tests. Up til now we haven't used gtest everywhere, and many of the tests needs some rewriting to follow the style guide. I've started with this tests, doing formatting, adding the test as a separate test which can now either succeed of fail in a proper way. Still to do in this test is handling of input file, but that will be changed in a separate CL, because all tests uses the PCMFile class that will be affected by the change. BUG=none TEST=audio_coding_module_test, ACM_AUTO_TEST and ACM_TEST_ALL_CODECS. Review URL: https://webrtc-codereview.appspot.com/646011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2416 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
db2f6cf878
commit
50d5ca5bf2
File diff suppressed because it is too large
Load Diff
@ -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
|
* 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
|
* that can be found in the LICENSE file in the root of the source
|
||||||
@ -8,89 +8,72 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TEST_ALL_CODECS_H
|
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
|
||||||
#define TEST_ALL_CODECS_H
|
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
|
||||||
|
|
||||||
#include "ACMTest.h"
|
#include "ACMTest.h"
|
||||||
#include "Channel.h"
|
#include "Channel.h"
|
||||||
#include "PCMFile.h"
|
#include "PCMFile.h"
|
||||||
|
#include "typedefs.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class TestPack : public AudioPacketizationCallback
|
class TestPack : public AudioPacketizationCallback {
|
||||||
{
|
public:
|
||||||
public:
|
TestPack();
|
||||||
TestPack();
|
~TestPack();
|
||||||
~TestPack();
|
|
||||||
|
|
||||||
void RegisterReceiverACM(AudioCodingModule* acm);
|
void RegisterReceiverACM(AudioCodingModule* acm);
|
||||||
|
|
||||||
virtual WebRtc_Word32 SendData(const FrameType frameType,
|
int32_t SendData(FrameType frame_type, uint8_t payload_type,
|
||||||
const WebRtc_UWord8 payloadType,
|
uint32_t timestamp, const uint8_t* payload_data,
|
||||||
const WebRtc_UWord32 timeStamp,
|
uint16_t payload_size,
|
||||||
const WebRtc_UWord8* payloadData,
|
const RTPFragmentationHeader* fragmentation);
|
||||||
const WebRtc_UWord16 payloadSize,
|
|
||||||
const RTPFragmentationHeader* fragmentation);
|
|
||||||
|
|
||||||
WebRtc_UWord16 GetPayloadSize();
|
uint16_t payload_size();
|
||||||
WebRtc_UWord32 GetTimeStampDiff();
|
uint32_t timestamp_diff();
|
||||||
void ResetPayloadSize();
|
void reset_payload_size();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioCodingModule* _receiverACM;
|
AudioCodingModule* receiver_acm_;
|
||||||
WebRtc_Word16 _seqNo;
|
uint16_t sequence_number_;
|
||||||
WebRtc_UWord8 _payloadData[60 * 32 * 2 * 2];
|
uint8_t payload_data_[60 * 32 * 2 * 2];
|
||||||
WebRtc_UWord32 _timeStampDiff;
|
uint32_t timestamp_diff_;
|
||||||
WebRtc_UWord32 _lastInTimestamp;
|
uint32_t last_in_timestamp_;
|
||||||
WebRtc_UWord64 _totalBytes;
|
uint64_t total_bytes_;
|
||||||
WebRtc_UWord16 _payloadSize;
|
uint16_t payload_size_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestAllCodecs : public ACMTest
|
class TestAllCodecs : public ACMTest {
|
||||||
{
|
public:
|
||||||
public:
|
TestAllCodecs(int test_mode);
|
||||||
TestAllCodecs(int testMode);
|
~TestAllCodecs();
|
||||||
~TestAllCodecs();
|
|
||||||
|
|
||||||
void Perform();
|
void Perform();
|
||||||
private:
|
|
||||||
// The default value of '-1' indicates that the registration is based only on codec name
|
|
||||||
// and a sampling frequncy matching is not required. This is useful for codecs which support
|
|
||||||
// several sampling frequency.
|
|
||||||
WebRtc_Word16 RegisterSendCodec(char side,
|
|
||||||
char* codecName,
|
|
||||||
WebRtc_Word32 sampFreqHz,
|
|
||||||
int rate,
|
|
||||||
int packSize,
|
|
||||||
int extraByte);
|
|
||||||
|
|
||||||
void Run(TestPack* channel);
|
private:
|
||||||
void OpenOutFile(WebRtc_Word16 testNumber);
|
// The default value of '-1' indicates that the registration is based only on
|
||||||
void DisplaySendReceiveCodec();
|
// codec name, and a sampling frequency matching is not required.
|
||||||
|
// This is useful for codecs which support several sampling frequency.
|
||||||
|
// Note! Only mono mode is tested in this test.
|
||||||
|
void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz,
|
||||||
|
int rate, int packet_size, int extra_byte);
|
||||||
|
|
||||||
WebRtc_Word32 SendData(
|
void Run(TestPack* channel);
|
||||||
const FrameType frameType,
|
void OpenOutFile(int test_number);
|
||||||
const WebRtc_UWord8 payloadType,
|
void DisplaySendReceiveCodec();
|
||||||
const WebRtc_UWord32 timeStamp,
|
|
||||||
const WebRtc_UWord8* payloadData,
|
|
||||||
const WebRtc_UWord16 payloadSize,
|
|
||||||
const RTPFragmentationHeader* fragmentation);
|
|
||||||
|
|
||||||
int _testMode;
|
int test_mode_;
|
||||||
|
AudioCodingModule* acm_a_;
|
||||||
AudioCodingModule* _acmA;
|
AudioCodingModule* acm_b_;
|
||||||
AudioCodingModule* _acmB;
|
TestPack* channel_a_to_b_;
|
||||||
|
PCMFile infile_a_;
|
||||||
TestPack* _channelA2B;
|
PCMFile outfile_b_;
|
||||||
|
int test_count_;
|
||||||
PCMFile _inFileA;
|
uint16_t packet_size_samples_;
|
||||||
PCMFile _outFileB;
|
uint16_t packet_size_bytes_;
|
||||||
WebRtc_Word16 _testCntr;
|
|
||||||
WebRtc_UWord16 _packSizeSamp;
|
|
||||||
WebRtc_UWord16 _packSizeBytes;
|
|
||||||
int _counter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TEST_ALL_CODECS_H
|
} // namespace webrtc
|
||||||
|
|
||||||
} // namespace webrtc
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
|
||||||
|
@ -29,17 +29,46 @@
|
|||||||
using webrtc::AudioCodingModule;
|
using webrtc::AudioCodingModule;
|
||||||
using webrtc::Trace;
|
using webrtc::Trace;
|
||||||
|
|
||||||
|
// This parameter is used to describe how to run the tests. It is normally
|
||||||
|
// set to 1, but in auto test all printing is turned off, and the parameter is
|
||||||
|
// set to 0.
|
||||||
|
#define ACM_TEST_MODE 1
|
||||||
|
|
||||||
|
// TODO(tlegrand): Add all tests as individual gtests, like already done for
|
||||||
|
// TestAllCodecs (ACM_TEST_ALL_ENC_DEC).
|
||||||
|
|
||||||
// Choose what tests to run by defining one or more of the following:
|
// Choose what tests to run by defining one or more of the following:
|
||||||
#define ACM_AUTO_TEST // Most common codecs and settings will be tested
|
//
|
||||||
//#define ACM_TEST_ENC_DEC // You decide what to test in run time.
|
// ACM_AUTO_TEST - Most common codecs and settings will be tested. All the
|
||||||
// Used for debugging and for testing while implementing.
|
// other tests will be activated.
|
||||||
//#define ACM_TEST_TWO_WAY // Debugging
|
// ACM_TEST_ENC_DEC - You decide what to test in run time. Used for debugging
|
||||||
//#define ACM_TEST_ALL_ENC_DEC // Loop through all defined codecs and settings
|
// and for testing while implementing.
|
||||||
//#define ACM_TEST_STEREO // Run stereo and spatial audio tests
|
// ACM_TEST_TWO_WAY - Mainly for debugging.
|
||||||
//#define ACM_TEST_VAD_DTX // Run all VAD/DTX tests
|
// ACM_TEST_ALL_CODECS - Loop through all defined codecs and settings.
|
||||||
//#define ACM_TEST_FEC // Test FEC (also called RED)
|
// ACM_TEST_STEREO - Run stereo and spatial audio tests.
|
||||||
//#define ACM_TEST_CODEC_SPEC_API // Only iSAC has codec specfic APIs in this version
|
// ACM_TEST_VAD_DTX - Run all VAD/DTX tests.
|
||||||
//#define ACM_TEST_FULL_API // Test all APIs with threads (long test)
|
// ACM_TEST_FEC - Test FEC (also called RED).
|
||||||
|
// ACM_TEST_CODEC_SPEC_API - Test the iSAC has codec specfic APIs.
|
||||||
|
// ACM_TEST_FULL_API - Test all APIs with threads (long test).
|
||||||
|
|
||||||
|
#define ACM_AUTO_TEST
|
||||||
|
//#define ACM_TEST_ENC_DEC
|
||||||
|
//#define ACM_TEST_TWO_WAY
|
||||||
|
//#define ACM_TEST_ALL_CODECS
|
||||||
|
//#define ACM_TEST_STEREO
|
||||||
|
//#define ACM_TEST_VAD_DTX
|
||||||
|
//#define ACM_TEST_FEC
|
||||||
|
//#define ACM_TEST_CODEC_SPEC_API
|
||||||
|
//#define ACM_TEST_FULL_API
|
||||||
|
|
||||||
|
// If Auto test is active, we activate all tests.
|
||||||
|
#ifdef ACM_AUTO_TEST
|
||||||
|
#undef ACM_TEST_MODE
|
||||||
|
#define ACM_TEST_MODE 0
|
||||||
|
#ifndef ACM_TEST_ALL_CODECS
|
||||||
|
#define ACM_TEST_ALL_CODECS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void PopulateTests(std::vector<ACMTest*>* tests) {
|
void PopulateTests(std::vector<ACMTest*>* tests) {
|
||||||
Trace::CreateTrace();
|
Trace::CreateTrace();
|
||||||
@ -50,7 +79,6 @@ void PopulateTests(std::vector<ACMTest*>* tests) {
|
|||||||
printf(" ACM auto test\n");
|
printf(" ACM auto test\n");
|
||||||
tests->push_back(new webrtc::EncodeDecodeTest(0));
|
tests->push_back(new webrtc::EncodeDecodeTest(0));
|
||||||
tests->push_back(new webrtc::TwoWayCommunication(0));
|
tests->push_back(new webrtc::TwoWayCommunication(0));
|
||||||
tests->push_back(new webrtc::TestAllCodecs(0));
|
|
||||||
tests->push_back(new webrtc::TestStereo(0));
|
tests->push_back(new webrtc::TestStereo(0));
|
||||||
tests->push_back(new webrtc::TestVADDTX(0));
|
tests->push_back(new webrtc::TestVADDTX(0));
|
||||||
tests->push_back(new webrtc::TestFEC(0));
|
tests->push_back(new webrtc::TestFEC(0));
|
||||||
@ -64,10 +92,6 @@ void PopulateTests(std::vector<ACMTest*>* tests) {
|
|||||||
printf(" ACM two-way communication test\n");
|
printf(" ACM two-way communication test\n");
|
||||||
tests->push_back(new webrtc::TwoWayCommunication(1));
|
tests->push_back(new webrtc::TwoWayCommunication(1));
|
||||||
#endif
|
#endif
|
||||||
#ifdef ACM_TEST_ALL_ENC_DEC
|
|
||||||
printf(" ACM all codecs test\n");
|
|
||||||
tests->push_back(new webrtc::TestAllCodecs(1));
|
|
||||||
#endif
|
|
||||||
#ifdef ACM_TEST_STEREO
|
#ifdef ACM_TEST_STEREO
|
||||||
printf(" ACM stereo test\n");
|
printf(" ACM stereo test\n");
|
||||||
tests->push_back(new webrtc::TestStereo(1));
|
tests->push_back(new webrtc::TestStereo(1));
|
||||||
@ -93,6 +117,17 @@ void PopulateTests(std::vector<ACMTest*>* tests) {
|
|||||||
|
|
||||||
// TODO(kjellander): Make this a proper gtest instead of using this single test
|
// TODO(kjellander): Make this a proper gtest instead of using this single test
|
||||||
// to run all the tests.
|
// to run all the tests.
|
||||||
|
|
||||||
|
#ifdef ACM_TEST_ALL_CODECS
|
||||||
|
TEST(AudioCodingModuleTest, TestAllCodecs) {
|
||||||
|
Trace::CreateTrace();
|
||||||
|
Trace::SetTraceFile((webrtc::test::OutputPath() +
|
||||||
|
"acm_allcodecs_trace.txt").c_str());
|
||||||
|
webrtc::TestAllCodecs(ACM_TEST_MODE).Perform();
|
||||||
|
Trace::ReturnTrace();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(AudioCodingModuleTest, RunAllTests) {
|
TEST(AudioCodingModuleTest, RunAllTests) {
|
||||||
std::vector<ACMTest*> tests;
|
std::vector<ACMTest*> tests;
|
||||||
PopulateTests(&tests);
|
PopulateTests(&tests);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user