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