OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_UTILITY_H_ | |
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_UTILITY_H_ | |
13 | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 #include "webrtc/modules/audio_coding/main/include/audio_coding_module.h" | |
16 | |
17 namespace webrtc { | |
18 | |
19 //----------------------------- | |
20 #define CHECK_ERROR(f) \ | |
21 do { \ | |
22 EXPECT_GE(f, 0) << "Error Calling API"; \ | |
23 } while(0) | |
24 | |
25 //----------------------------- | |
26 #define CHECK_PROTECTED(f) \ | |
27 do { \ | |
28 if (f >= 0) { \ | |
29 ADD_FAILURE() << "Error Calling API"; \ | |
30 } else { \ | |
31 printf("An expected error is caught.\n"); \ | |
32 } \ | |
33 } while(0) | |
34 | |
35 //---------------------------- | |
36 #define CHECK_ERROR_MT(f) \ | |
37 do { \ | |
38 if (f < 0) { \ | |
39 fprintf(stderr, "Error Calling API in file %s at line %d \n", \ | |
40 __FILE__, __LINE__); \ | |
41 } \ | |
42 } while(0) | |
43 | |
44 //---------------------------- | |
45 #define CHECK_PROTECTED_MT(f) \ | |
46 do { \ | |
47 if (f >= 0) { \ | |
48 fprintf(stderr, "Error Calling API in file %s at line %d \n", \ | |
49 __FILE__, __LINE__); \ | |
50 } else { \ | |
51 printf("An expected error is caught.\n"); \ | |
52 } \ | |
53 } while(0) | |
54 | |
55 #define DELETE_POINTER(p) \ | |
56 do { \ | |
57 if (p != NULL) { \ | |
58 delete p; \ | |
59 p = NULL; \ | |
60 } \ | |
61 } while(0) | |
62 | |
63 class ACMTestTimer { | |
64 public: | |
65 ACMTestTimer(); | |
66 ~ACMTestTimer(); | |
67 | |
68 void Reset(); | |
69 void Tick10ms(); | |
70 void Tick1ms(); | |
71 void Tick100ms(); | |
72 void Tick1sec(); | |
73 void CurrentTimeHMS(char* currTime); | |
74 void CurrentTime(unsigned long& h, unsigned char& m, unsigned char& s, | |
75 unsigned short& ms); | |
76 | |
77 private: | |
78 void Adjust(); | |
79 | |
80 unsigned short _msec; | |
81 unsigned char _sec; | |
82 unsigned char _min; | |
83 unsigned long _hour; | |
84 }; | |
85 | |
86 class CircularBuffer { | |
87 public: | |
88 CircularBuffer(uint32_t len); | |
89 ~CircularBuffer(); | |
90 | |
91 void SetArithMean(bool enable); | |
92 void SetVariance(bool enable); | |
93 | |
94 void Update(const double newVal); | |
95 void IsBufferFull(); | |
96 | |
97 int16_t Variance(double& var); | |
98 int16_t ArithMean(double& mean); | |
99 | |
100 protected: | |
101 double* _buff; | |
102 uint32_t _idx; | |
103 uint32_t _buffLen; | |
104 | |
105 bool _buffIsFull; | |
106 bool _calcAvg; | |
107 bool _calcVar; | |
108 double _sum; | |
109 double _sumSqr; | |
110 }; | |
111 | |
112 int16_t ChooseCodec(CodecInst& codecInst); | |
113 | |
114 void PrintCodecs(); | |
115 | |
116 bool FixedPayloadTypeCodec(const char* payloadName); | |
117 | |
118 class VADCallback : public ACMVADCallback { | |
119 public: | |
120 VADCallback(); | |
121 ~VADCallback() { | |
122 } | |
123 | |
124 int32_t InFrameType(FrameType frame_type); | |
125 | |
126 void PrintFrameTypes(); | |
127 void Reset(); | |
128 | |
129 private: | |
130 uint32_t _numFrameTypes[5]; | |
131 }; | |
132 | |
133 void UseLegacyAcm(webrtc::Config* config); | |
134 | |
135 void UseNewAcm(webrtc::Config* config); | |
136 | |
137 } // namespace webrtc | |
138 | |
139 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_UTILITY_H_ | |
OLD | NEW |