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/modules/audio_coding/main/interface/audio_coding_module.h" 15 #include "webrtc/modules/audio_coding/main/test/ACMTest.h" 16 #include "webrtc/modules/audio_coding/main/test/Channel.h" 17 #include "webrtc/modules/audio_coding/main/test/PCMFile.h" 18 #include "webrtc/modules/audio_coding/main/test/utility.h" 19 #include "webrtc/system_wrappers/interface/event_wrapper.h" 20 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" 21 #include "webrtc/system_wrappers/interface/scoped_ptr.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 scoped_ptr<AudioCodingModule> _acmA; 86 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 EventWrapper* _pullEventA; // pulling data from ACM 113 EventWrapper* _pushEventA; // pushing data to ACM 114 EventWrapper* _processEventA; // process 115 EventWrapper* _apiEventA; // API calls 116 // B 117 EventWrapper* _pullEventB; // pulling data from ACM 118 EventWrapper* _pushEventB; // pushing data to ACM 119 EventWrapper* _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 AudioPlayoutMode _playoutModeA; 145 AudioPlayoutMode _playoutModeB; 146 147 bool _verbose; 148 149 int _dotPositionA; 150 int _dotMoveDirectionA; 151 int _dotPositionB; 152 int _dotMoveDirectionB; 153 154 char _movingDot[41]; 155 156 DTMFDetector* _dtmfCallback; 157 VADCallback* _vadCallbackA; 158 VADCallback* _vadCallbackB; 159 RWLockWrapper& _apiTestRWLock; 160 bool _randomTest; 161 int _testNumA; 162 int _testNumB; 163 }; 164 165 } // namespace webrtc 166 167 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_APITEST_H_ 168