blob: ead3134ffc80328b139309304ce70ed46464d7b5 [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
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.org554ae1a2011-12-16 10:09:04 +000020namespace webrtc {
21
niklase@google.com470e71d2011-07-07 08:21:25 +000022enum APITESTAction {TEST_CHANGE_CODEC_ONLY = 0, DTX_TEST = 1};
23
24class APITest : public ACMTest
25{
26public:
27 APITest();
28 ~APITest();
29
30 void Perform();
31private:
pbos@webrtc.org0946a562013-04-09 00:28:06 +000032 int16_t SetUp();
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000033
niklase@google.com470e71d2011-07-07 08:21:25 +000034 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.orgd7a71d02012-08-01 01:40:02 +000059 //
niklase@google.com470e71d2011-07-07 08:21:25 +000060 void TestSendVAD(char side);
61
62 void CurrentCodec(char side);
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000063
niklase@google.com470e71d2011-07-07 08:21:25 +000064 void ChangeCodec(char side);
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000065
pbos@webrtc.org0946a562013-04-09 00:28:06 +000066 void Wait(uint32_t waitLengthMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000067
68 void LookForDTMF(char side);
69
70 void RunTest(char thread);
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000071
72 bool PushAudioRunA();
niklase@google.com470e71d2011-07-07 08:21:25 +000073 bool PullAudioRunA();
74 bool ProcessRunA();
75 bool APIRunA();
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000076
niklase@google.com470e71d2011-07-07 08:21:25 +000077 bool PullAudioRunB();
78 bool PushAudioRunB();
79 bool ProcessRunB();
80 bool APIRunB();
81
82
83
84 //--- ACMs
85 AudioCodingModule* _acmA;
86 AudioCodingModule* _acmB;
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000087
niklase@google.com470e71d2011-07-07 08:21:25 +000088 //--- Channels
89 Channel* _channel_A2B;
90 Channel* _channel_B2A;
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000091
niklase@google.com470e71d2011-07-07 08:21:25 +000092 //--- I/O files
93 // A
94 PCMFile _inFileA;
95 PCMFile _outFileA;
96 // B
97 PCMFile _outFileB;
98 PCMFile _inFileB;
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +000099
niklase@google.com470e71d2011-07-07 08:21:25 +0000100 //--- I/O params
101 // A
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000102 int32_t _outFreqHzA;
niklase@google.com470e71d2011-07-07 08:21:25 +0000103 // B
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000104 int32_t _outFreqHzB;
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +0000105
niklase@google.com470e71d2011-07-07 08:21:25 +0000106 // 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.org0946a562013-04-09 00:28:06 +0000123 uint8_t _codecCntrA;
124 uint8_t _codecCntrB;
niklase@google.com470e71d2011-07-07 08:21:25 +0000125
niklase@google.com470e71d2011-07-07 08:21:25 +0000126 // 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.org0946a562013-04-09 00:28:06 +0000140 int32_t _minDelayA;
141 int32_t _minDelayB;
niklase@google.com470e71d2011-07-07 08:21:25 +0000142 bool _payloadUsed[32];
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +0000143
niklase@google.com470e71d2011-07-07 08:21:25 +0000144 AudioPlayoutMode _playoutModeA;
145 AudioPlayoutMode _playoutModeB;
146
147 ACMBackgroundNoiseMode _bgnModeA;
148 ACMBackgroundNoiseMode _bgnModeB;
149
150
tina.legrand@webrtc.org731e9ae2011-11-04 07:34:22 +0000151 int _receiveVADActivityA[3];
152 int _receiveVADActivityB[3];
niklase@google.com470e71d2011-07-07 08:21:25 +0000153 bool _verbose;
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +0000154
niklase@google.com470e71d2011-07-07 08:21:25 +0000155 int _dotPositionA;
156 int _dotMoveDirectionA;
157 int _dotPositionB;
158 int _dotMoveDirectionB;
159
160 char _movingDot[41];
andrew@webrtc.orgd7a71d02012-08-01 01:40:02 +0000161
niklase@google.com470e71d2011-07-07 08:21:25 +0000162 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.org554ae1a2011-12-16 10:09:04 +0000171} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000172
173#endif