OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2012 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_APITEST_H_ | |
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_APITEST_H_ | |
13 | |
14 #include "webrtc/base/scoped_ptr.h" | |
15 #include "webrtc/modules/audio_coding/main/include/audio_coding_module.h" | |
16 #include "webrtc/modules/audio_coding/main/test/ACMTest.h" | |
17 #include "webrtc/modules/audio_coding/main/test/Channel.h" | |
18 #include "webrtc/modules/audio_coding/main/test/PCMFile.h" | |
19 #include "webrtc/modules/audio_coding/main/test/utility.h" | |
20 #include "webrtc/system_wrappers/include/event_wrapper.h" | |
21 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | |
22 | |
23 namespace webrtc { | |
24 | |
25 class Config; | |
26 | |
27 enum APITESTAction { | |
28 TEST_CHANGE_CODEC_ONLY = 0, | |
29 DTX_TEST = 1 | |
30 }; | |
31 | |
32 class APITest : public ACMTest { | |
33 public: | |
34 explicit APITest(const Config& config); | |
35 ~APITest(); | |
36 | |
37 void Perform(); | |
38 private: | |
39 int16_t SetUp(); | |
40 | |
41 static bool PushAudioThreadA(void* obj); | |
42 static bool PullAudioThreadA(void* obj); | |
43 static bool ProcessThreadA(void* obj); | |
44 static bool APIThreadA(void* obj); | |
45 | |
46 static bool PushAudioThreadB(void* obj); | |
47 static bool PullAudioThreadB(void* obj); | |
48 static bool ProcessThreadB(void* obj); | |
49 static bool APIThreadB(void* obj); | |
50 | |
51 void CheckVADStatus(char side); | |
52 | |
53 // Set Min delay, get delay, playout timestamp | |
54 void TestDelay(char side); | |
55 | |
56 // Unregister a codec & register again. | |
57 void TestRegisteration(char side); | |
58 | |
59 // Playout Mode, background noise mode. | |
60 // Receiver Frequency, playout frequency. | |
61 void TestPlayout(char receiveSide); | |
62 | |
63 // | |
64 void TestSendVAD(char side); | |
65 | |
66 void CurrentCodec(char side); | |
67 | |
68 void ChangeCodec(char side); | |
69 | |
70 void Wait(uint32_t waitLengthMs); | |
71 | |
72 void RunTest(char thread); | |
73 | |
74 bool PushAudioRunA(); | |
75 bool PullAudioRunA(); | |
76 bool ProcessRunA(); | |
77 bool APIRunA(); | |
78 | |
79 bool PullAudioRunB(); | |
80 bool PushAudioRunB(); | |
81 bool ProcessRunB(); | |
82 bool APIRunB(); | |
83 | |
84 //--- ACMs | |
85 rtc::scoped_ptr<AudioCodingModule> _acmA; | |
86 rtc::scoped_ptr<AudioCodingModule> _acmB; | |
87 | |
88 //--- Channels | |
89 Channel* _channel_A2B; | |
90 Channel* _channel_B2A; | |
91 | |
92 //--- I/O files | |
93 // A | |
94 PCMFile _inFileA; | |
95 PCMFile _outFileA; | |
96 // B | |
97 PCMFile _outFileB; | |
98 PCMFile _inFileB; | |
99 | |
100 //--- I/O params | |
101 // A | |
102 int32_t _outFreqHzA; | |
103 // B | |
104 int32_t _outFreqHzB; | |
105 | |
106 // Should we write to file. | |
107 // we might skip writing to file if we | |
108 // run the test for a long time. | |
109 bool _writeToFile; | |
110 //--- Events | |
111 // A | |
112 EventTimerWrapper* _pullEventA; // pulling data from ACM | |
113 EventTimerWrapper* _pushEventA; // pushing data to ACM | |
114 EventTimerWrapper* _processEventA; // process | |
115 EventWrapper* _apiEventA; // API calls | |
116 // B | |
117 EventTimerWrapper* _pullEventB; // pulling data from ACM | |
118 EventTimerWrapper* _pushEventB; // pushing data to ACM | |
119 EventTimerWrapper* _processEventB; // process | |
120 EventWrapper* _apiEventB; // API calls | |
121 | |
122 // keep track of the codec in either side. | |
123 uint8_t _codecCntrA; | |
124 uint8_t _codecCntrB; | |
125 | |
126 // Is set to true if there is no encoder in either side | |
127 bool _thereIsEncoderA; | |
128 bool _thereIsEncoderB; | |
129 bool _thereIsDecoderA; | |
130 bool _thereIsDecoderB; | |
131 | |
132 bool _sendVADA; | |
133 bool _sendDTXA; | |
134 ACMVADMode _sendVADModeA; | |
135 | |
136 bool _sendVADB; | |
137 bool _sendDTXB; | |
138 ACMVADMode _sendVADModeB; | |
139 | |
140 int32_t _minDelayA; | |
141 int32_t _minDelayB; | |
142 bool _payloadUsed[32]; | |
143 | |
144 bool _verbose; | |
145 | |
146 int _dotPositionA; | |
147 int _dotMoveDirectionA; | |
148 int _dotPositionB; | |
149 int _dotMoveDirectionB; | |
150 | |
151 char _movingDot[41]; | |
152 | |
153 VADCallback* _vadCallbackA; | |
154 VADCallback* _vadCallbackB; | |
155 RWLockWrapper& _apiTestRWLock; | |
156 bool _randomTest; | |
157 int _testNumA; | |
158 int _testNumB; | |
159 }; | |
160 | |
161 } // namespace webrtc | |
162 | |
163 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_APITEST_H_ | |
OLD | NEW |