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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TEST_ALL_CODECS_H
|
||||
#define TEST_ALL_CODECS_H
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
|
||||
|
||||
#include "ACMTest.h"
|
||||
#include "Channel.h"
|
||||
#include "PCMFile.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class TestPack : public AudioPacketizationCallback
|
||||
{
|
||||
public:
|
||||
TestPack();
|
||||
~TestPack();
|
||||
|
||||
void RegisterReceiverACM(AudioCodingModule* acm);
|
||||
|
||||
virtual WebRtc_Word32 SendData(const FrameType frameType,
|
||||
const WebRtc_UWord8 payloadType,
|
||||
const WebRtc_UWord32 timeStamp,
|
||||
const WebRtc_UWord8* payloadData,
|
||||
const WebRtc_UWord16 payloadSize,
|
||||
const RTPFragmentationHeader* fragmentation);
|
||||
class TestPack : public AudioPacketizationCallback {
|
||||
public:
|
||||
TestPack();
|
||||
~TestPack();
|
||||
|
||||
WebRtc_UWord16 GetPayloadSize();
|
||||
WebRtc_UWord32 GetTimeStampDiff();
|
||||
void ResetPayloadSize();
|
||||
void RegisterReceiverACM(AudioCodingModule* acm);
|
||||
|
||||
private:
|
||||
AudioCodingModule* _receiverACM;
|
||||
WebRtc_Word16 _seqNo;
|
||||
WebRtc_UWord8 _payloadData[60 * 32 * 2 * 2];
|
||||
WebRtc_UWord32 _timeStampDiff;
|
||||
WebRtc_UWord32 _lastInTimestamp;
|
||||
WebRtc_UWord64 _totalBytes;
|
||||
WebRtc_UWord16 _payloadSize;
|
||||
int32_t SendData(FrameType frame_type, uint8_t payload_type,
|
||||
uint32_t timestamp, const uint8_t* payload_data,
|
||||
uint16_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation);
|
||||
|
||||
uint16_t payload_size();
|
||||
uint32_t timestamp_diff();
|
||||
void reset_payload_size();
|
||||
|
||||
private:
|
||||
AudioCodingModule* receiver_acm_;
|
||||
uint16_t sequence_number_;
|
||||
uint8_t payload_data_[60 * 32 * 2 * 2];
|
||||
uint32_t timestamp_diff_;
|
||||
uint32_t last_in_timestamp_;
|
||||
uint64_t total_bytes_;
|
||||
uint16_t payload_size_;
|
||||
};
|
||||
|
||||
class TestAllCodecs : public ACMTest
|
||||
{
|
||||
public:
|
||||
TestAllCodecs(int testMode);
|
||||
~TestAllCodecs();
|
||||
class TestAllCodecs : public ACMTest {
|
||||
public:
|
||||
TestAllCodecs(int test_mode);
|
||||
~TestAllCodecs();
|
||||
|
||||
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 Perform();
|
||||
|
||||
void Run(TestPack* channel);
|
||||
void OpenOutFile(WebRtc_Word16 testNumber);
|
||||
void DisplaySendReceiveCodec();
|
||||
private:
|
||||
// The default value of '-1' indicates that the registration is based only on
|
||||
// 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(
|
||||
const FrameType frameType,
|
||||
const WebRtc_UWord8 payloadType,
|
||||
const WebRtc_UWord32 timeStamp,
|
||||
const WebRtc_UWord8* payloadData,
|
||||
const WebRtc_UWord16 payloadSize,
|
||||
const RTPFragmentationHeader* fragmentation);
|
||||
void Run(TestPack* channel);
|
||||
void OpenOutFile(int test_number);
|
||||
void DisplaySendReceiveCodec();
|
||||
|
||||
int _testMode;
|
||||
|
||||
AudioCodingModule* _acmA;
|
||||
AudioCodingModule* _acmB;
|
||||
|
||||
TestPack* _channelA2B;
|
||||
|
||||
PCMFile _inFileA;
|
||||
PCMFile _outFileB;
|
||||
WebRtc_Word16 _testCntr;
|
||||
WebRtc_UWord16 _packSizeSamp;
|
||||
WebRtc_UWord16 _packSizeBytes;
|
||||
int _counter;
|
||||
int test_mode_;
|
||||
AudioCodingModule* acm_a_;
|
||||
AudioCodingModule* acm_b_;
|
||||
TestPack* channel_a_to_b_;
|
||||
PCMFile infile_a_;
|
||||
PCMFile outfile_b_;
|
||||
int test_count_;
|
||||
uint16_t packet_size_samples_;
|
||||
uint16_t packet_size_bytes_;
|
||||
};
|
||||
|
||||
#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::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:
|
||||
#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.
|
||||
// Used for debugging and for testing while implementing.
|
||||
//#define ACM_TEST_TWO_WAY // Debugging
|
||||
//#define ACM_TEST_ALL_ENC_DEC // Loop through all defined codecs and settings
|
||||
//#define ACM_TEST_STEREO // Run stereo and spatial audio tests
|
||||
//#define ACM_TEST_VAD_DTX // Run all VAD/DTX tests
|
||||
//#define ACM_TEST_FEC // Test FEC (also called RED)
|
||||
//#define ACM_TEST_CODEC_SPEC_API // Only iSAC has codec specfic APIs in this version
|
||||
//#define ACM_TEST_FULL_API // Test all APIs with threads (long test)
|
||||
//
|
||||
// ACM_AUTO_TEST - Most common codecs and settings will be tested. All the
|
||||
// other tests will be activated.
|
||||
// ACM_TEST_ENC_DEC - You decide what to test in run time. Used for debugging
|
||||
// and for testing while implementing.
|
||||
// ACM_TEST_TWO_WAY - Mainly for debugging.
|
||||
// ACM_TEST_ALL_CODECS - Loop through all defined codecs and settings.
|
||||
// ACM_TEST_STEREO - Run stereo and spatial audio tests.
|
||||
// ACM_TEST_VAD_DTX - Run all VAD/DTX tests.
|
||||
// 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) {
|
||||
Trace::CreateTrace();
|
||||
@ -50,7 +79,6 @@ void PopulateTests(std::vector<ACMTest*>* tests) {
|
||||
printf(" ACM auto test\n");
|
||||
tests->push_back(new webrtc::EncodeDecodeTest(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::TestVADDTX(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");
|
||||
tests->push_back(new webrtc::TwoWayCommunication(1));
|
||||
#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
|
||||
printf(" ACM stereo test\n");
|
||||
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
|
||||
// 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) {
|
||||
std::vector<ACMTest*> tests;
|
||||
PopulateTests(&tests);
|
||||
|
Loading…
Reference in New Issue
Block a user