niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 API_TEST_H |
| 12 | #define API_TEST_H |
| 13 | |
| 14 | #include "ACMTest.h" |
| 15 | #include "Channel.h" |
| 16 | #include "PCMFile.h" |
| 17 | #include "event_wrapper.h" |
| 18 | #include "utility.h" |
| 19 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 20 | namespace webrtc { |
| 21 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | enum APITESTAction {TEST_CHANGE_CODEC_ONLY = 0, DTX_TEST = 1}; |
| 23 | |
| 24 | class APITest : public ACMTest |
| 25 | { |
| 26 | public: |
| 27 | APITest(); |
| 28 | ~APITest(); |
| 29 | |
| 30 | void Perform(); |
| 31 | private: |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 32 | int16_t SetUp(); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 33 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | static bool PushAudioThreadA(void* obj); |
| 35 | static bool PullAudioThreadA(void* obj); |
| 36 | static bool ProcessThreadA(void* obj); |
| 37 | static bool APIThreadA(void* obj); |
| 38 | |
| 39 | static bool PushAudioThreadB(void* obj); |
| 40 | static bool PullAudioThreadB(void* obj); |
| 41 | static bool ProcessThreadB(void* obj); |
| 42 | static bool APIThreadB(void* obj); |
| 43 | |
| 44 | void CheckVADStatus(char side); |
| 45 | |
| 46 | // Set Min delay, get delay, playout timestamp |
| 47 | void TestDelay(char side); |
| 48 | |
| 49 | // Unregister a codec & register again. |
| 50 | void TestRegisteration(char side); |
| 51 | |
| 52 | // Playout Mode, background noise mode. |
| 53 | // Receiver Frequency, playout frequency. |
| 54 | void TestPlayout(char receiveSide); |
| 55 | |
| 56 | // set/get receiver VAD status & mode. |
| 57 | void TestReceiverVAD(char side); |
| 58 | |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 59 | // |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | void TestSendVAD(char side); |
| 61 | |
| 62 | void CurrentCodec(char side); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 63 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | void ChangeCodec(char side); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 65 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 66 | void Wait(uint32_t waitLengthMs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
| 68 | void LookForDTMF(char side); |
| 69 | |
| 70 | void RunTest(char thread); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 71 | |
| 72 | bool PushAudioRunA(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | bool PullAudioRunA(); |
| 74 | bool ProcessRunA(); |
| 75 | bool APIRunA(); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 76 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | bool PullAudioRunB(); |
| 78 | bool PushAudioRunB(); |
| 79 | bool ProcessRunB(); |
| 80 | bool APIRunB(); |
| 81 | |
| 82 | |
| 83 | |
| 84 | //--- ACMs |
| 85 | AudioCodingModule* _acmA; |
| 86 | AudioCodingModule* _acmB; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 87 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | //--- Channels |
| 89 | Channel* _channel_A2B; |
| 90 | Channel* _channel_B2A; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 91 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | //--- I/O files |
| 93 | // A |
| 94 | PCMFile _inFileA; |
| 95 | PCMFile _outFileA; |
| 96 | // B |
| 97 | PCMFile _outFileB; |
| 98 | PCMFile _inFileB; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 99 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 100 | //--- I/O params |
| 101 | // A |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 102 | int32_t _outFreqHzA; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | // B |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 104 | int32_t _outFreqHzB; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 105 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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. |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 123 | uint8_t _codecCntrA; |
| 124 | uint8_t _codecCntrB; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 125 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 140 | int32_t _minDelayA; |
| 141 | int32_t _minDelayB; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 142 | bool _payloadUsed[32]; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 143 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 144 | AudioPlayoutMode _playoutModeA; |
| 145 | AudioPlayoutMode _playoutModeB; |
| 146 | |
| 147 | ACMBackgroundNoiseMode _bgnModeA; |
| 148 | ACMBackgroundNoiseMode _bgnModeB; |
| 149 | |
| 150 | |
tina.legrand@webrtc.org | 731e9ae | 2011-11-04 07:34:22 +0000 | [diff] [blame] | 151 | int _receiveVADActivityA[3]; |
| 152 | int _receiveVADActivityB[3]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 153 | bool _verbose; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 154 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 155 | int _dotPositionA; |
| 156 | int _dotMoveDirectionA; |
| 157 | int _dotPositionB; |
| 158 | int _dotMoveDirectionB; |
| 159 | |
| 160 | char _movingDot[41]; |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 161 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 162 | DTMFDetector* _dtmfCallback; |
| 163 | VADCallback* _vadCallbackA; |
| 164 | VADCallback* _vadCallbackB; |
| 165 | RWLockWrapper& _apiTestRWLock; |
| 166 | bool _randomTest; |
| 167 | int _testNumA; |
| 168 | int _testNumB; |
| 169 | }; |
| 170 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 171 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 172 | |
| 173 | #endif |