blob: af2a3a15d4a8717d863d2481586171c21895ce15 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
kjellander3e6db232015-11-26 04:44:54 -080011#ifndef WEBRTC_MODULES_AUDIO_CODING_TEST_APITEST_H_
12#define WEBRTC_MODULES_AUDIO_CODING_TEST_APITEST_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
kwiberg37478382016-02-14 20:40:57 -080014#include <memory>
15
kjellander3e6db232015-11-26 04:44:54 -080016#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 Kjellander98f53512015-10-28 18:17:40 +010021#include "webrtc/system_wrappers/include/event_wrapper.h"
22#include "webrtc/system_wrappers/include/rw_lock_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000024namespace webrtc {
25
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000026class Config;
27
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000028enum APITESTAction {
29 TEST_CHANGE_CODEC_ONLY = 0,
30 DTX_TEST = 1
niklase@google.com470e71d2011-07-07 08:21:25 +000031};
32
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000033class APITest : public ACMTest {
34 public:
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000035 explicit APITest(const Config& config);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000036 ~APITest();
37
38 void Perform();
39 private:
40 int16_t SetUp();
41
42 static bool PushAudioThreadA(void* obj);
43 static bool PullAudioThreadA(void* obj);
44 static bool ProcessThreadA(void* obj);
45 static bool APIThreadA(void* obj);
46
47 static bool PushAudioThreadB(void* obj);
48 static bool PullAudioThreadB(void* obj);
49 static bool ProcessThreadB(void* obj);
50 static bool APIThreadB(void* obj);
51
52 void CheckVADStatus(char side);
53
54 // Set Min delay, get delay, playout timestamp
55 void TestDelay(char side);
56
57 // Unregister a codec & register again.
58 void TestRegisteration(char side);
59
60 // Playout Mode, background noise mode.
61 // Receiver Frequency, playout frequency.
62 void TestPlayout(char receiveSide);
63
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000064 //
65 void TestSendVAD(char side);
66
67 void CurrentCodec(char side);
68
69 void ChangeCodec(char side);
70
71 void Wait(uint32_t waitLengthMs);
72
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000073 void RunTest(char thread);
74
75 bool PushAudioRunA();
76 bool PullAudioRunA();
77 bool ProcessRunA();
78 bool APIRunA();
79
80 bool PullAudioRunB();
81 bool PushAudioRunB();
82 bool ProcessRunB();
83 bool APIRunB();
84
85 //--- ACMs
kwiberg37478382016-02-14 20:40:57 -080086 std::unique_ptr<AudioCodingModule> _acmA;
87 std::unique_ptr<AudioCodingModule> _acmB;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000088
89 //--- Channels
90 Channel* _channel_A2B;
91 Channel* _channel_B2A;
92
93 //--- I/O files
94 // A
95 PCMFile _inFileA;
96 PCMFile _outFileA;
97 // B
98 PCMFile _outFileB;
99 PCMFile _inFileB;
100
101 //--- I/O params
102 // A
103 int32_t _outFreqHzA;
104 // B
105 int32_t _outFreqHzB;
106
107 // Should we write to file.
108 // we might skip writing to file if we
109 // run the test for a long time.
110 bool _writeToFile;
111 //--- Events
112 // A
Peter Boström64c03662015-04-08 11:24:19 +0200113 EventTimerWrapper* _pullEventA; // pulling data from ACM
114 EventTimerWrapper* _pushEventA; // pushing data to ACM
115 EventTimerWrapper* _processEventA; // process
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000116 EventWrapper* _apiEventA; // API calls
117 // B
Peter Boström64c03662015-04-08 11:24:19 +0200118 EventTimerWrapper* _pullEventB; // pulling data from ACM
119 EventTimerWrapper* _pushEventB; // pushing data to ACM
120 EventTimerWrapper* _processEventB; // process
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000121 EventWrapper* _apiEventB; // API calls
122
123 // keep track of the codec in either side.
124 uint8_t _codecCntrA;
125 uint8_t _codecCntrB;
126
127 // Is set to true if there is no encoder in either side
128 bool _thereIsEncoderA;
129 bool _thereIsEncoderB;
130 bool _thereIsDecoderA;
131 bool _thereIsDecoderB;
132
133 bool _sendVADA;
134 bool _sendDTXA;
135 ACMVADMode _sendVADModeA;
136
137 bool _sendVADB;
138 bool _sendDTXB;
139 ACMVADMode _sendVADModeB;
140
141 int32_t _minDelayA;
142 int32_t _minDelayB;
143 bool _payloadUsed[32];
144
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000145 bool _verbose;
146
147 int _dotPositionA;
148 int _dotMoveDirectionA;
149 int _dotPositionB;
150 int _dotMoveDirectionB;
151
152 char _movingDot[41];
153
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000154 VADCallback* _vadCallbackA;
155 VADCallback* _vadCallbackB;
156 RWLockWrapper& _apiTestRWLock;
157 bool _randomTest;
158 int _testNumA;
159 int _testNumB;
160};
161
162} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000163
kjellander3e6db232015-11-26 04:44:54 -0800164#endif // WEBRTC_MODULES_AUDIO_CODING_TEST_APITEST_H_