2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 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
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_TEST_UTILITY_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_TEST_UTILITY_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
|
|
|
|
#include "test/gtest.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-16 10:09:04 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
//-----------------------------
|
2013-05-03 07:34:12 +00:00
|
|
|
#define CHECK_ERROR(f) \
|
|
|
|
|
do { \
|
|
|
|
|
EXPECT_GE(f, 0) << "Error Calling API"; \
|
|
|
|
|
} while (0)
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
//-----------------------------
|
2013-05-03 07:34:12 +00:00
|
|
|
#define CHECK_PROTECTED(f) \
|
|
|
|
|
do { \
|
|
|
|
|
if (f >= 0) { \
|
|
|
|
|
ADD_FAILURE() << "Error Calling API"; \
|
|
|
|
|
} else { \
|
|
|
|
|
printf("An expected error is caught.\n"); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
//----------------------------
|
2013-05-03 07:34:12 +00:00
|
|
|
#define CHECK_ERROR_MT(f) \
|
|
|
|
|
do { \
|
|
|
|
|
if (f < 0) { \
|
|
|
|
|
fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \
|
|
|
|
|
__LINE__); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
//----------------------------
|
2013-05-03 07:34:12 +00:00
|
|
|
#define CHECK_PROTECTED_MT(f) \
|
|
|
|
|
do { \
|
|
|
|
|
if (f >= 0) { \
|
|
|
|
|
fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \
|
|
|
|
|
__LINE__); \
|
|
|
|
|
} else { \
|
|
|
|
|
printf("An expected error is caught.\n"); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define DELETE_POINTER(p) \
|
|
|
|
|
do { \
|
|
|
|
|
if (p != NULL) { \
|
|
|
|
|
delete p; \
|
|
|
|
|
p = NULL; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
class ACMTestTimer {
|
|
|
|
|
public:
|
|
|
|
|
ACMTestTimer();
|
|
|
|
|
~ACMTestTimer();
|
|
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
void Tick10ms();
|
|
|
|
|
void Tick1ms();
|
|
|
|
|
void Tick100ms();
|
|
|
|
|
void Tick1sec();
|
|
|
|
|
void CurrentTimeHMS(char* currTime);
|
|
|
|
|
void CurrentTime(unsigned long& h,
|
|
|
|
|
unsigned char& m,
|
|
|
|
|
unsigned char& s,
|
|
|
|
|
unsigned short& ms);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void Adjust();
|
|
|
|
|
|
|
|
|
|
unsigned short _msec;
|
|
|
|
|
unsigned char _sec;
|
|
|
|
|
unsigned char _min;
|
|
|
|
|
unsigned long _hour;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2017-02-11 00:24:10 -08:00
|
|
|
// To avoid clashes with CircularBuffer in APM.
|
|
|
|
|
namespace test {
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
class CircularBuffer {
|
|
|
|
|
public:
|
|
|
|
|
CircularBuffer(uint32_t len);
|
|
|
|
|
~CircularBuffer();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
void SetArithMean(bool enable);
|
|
|
|
|
void SetVariance(bool enable);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
void Update(const double newVal);
|
|
|
|
|
void IsBufferFull();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
int16_t Variance(double& var);
|
|
|
|
|
int16_t ArithMean(double& mean);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
protected:
|
|
|
|
|
double* _buff;
|
|
|
|
|
uint32_t _idx;
|
|
|
|
|
uint32_t _buffLen;
|
2013-04-09 00:28:06 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
bool _buffIsFull;
|
|
|
|
|
bool _calcAvg;
|
|
|
|
|
bool _calcVar;
|
|
|
|
|
double _sum;
|
|
|
|
|
double _sumSqr;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2017-02-11 00:24:10 -08:00
|
|
|
} // namespace test
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
int16_t ChooseCodec(CodecInst& codecInst);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
void PrintCodecs();
|
|
|
|
|
|
|
|
|
|
bool FixedPayloadTypeCodec(const char* payloadName);
|
|
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
class VADCallback : public ACMVADCallback {
|
|
|
|
|
public:
|
|
|
|
|
VADCallback();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-08-29 10:05:24 -07:00
|
|
|
int32_t InFrameType(FrameType frame_type) override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
void PrintFrameTypes();
|
|
|
|
|
void Reset();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-03 07:34:12 +00:00
|
|
|
private:
|
2015-03-06 07:50:34 +00:00
|
|
|
uint32_t _numFrameTypes[5];
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-03-15 13:29:17 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_TEST_UTILITY_H_
|