blob: 3b2d4afba6ffcc96ad2036a531734679ae7c99a5 [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
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000011#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_APITEST_H_
12#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_APITEST_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000014#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
turaj@webrtc.orga305e962013-06-06 19:00:09 +000015#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"
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000021#include "webrtc/system_wrappers/interface/scoped_ptr.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000023namespace webrtc {
24
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000025class Config;
26
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000027enum APITESTAction {
28 TEST_CHANGE_CODEC_ONLY = 0,
29 DTX_TEST = 1
niklase@google.com470e71d2011-07-07 08:21:25 +000030};
31
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000032class APITest : public ACMTest {
33 public:
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000034 explicit APITest(const Config& config);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000035 ~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
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000063 //
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
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000072 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
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +000085 scoped_ptr<AudioCodingModule> _acmA;
86 scoped_ptr<AudioCodingModule> _acmB;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000087
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
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000147 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
niklase@google.com470e71d2011-07-07 08:21:25 +0000166
turaj@webrtc.org6ea3d1c2013-10-02 21:44:33 +0000167#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_APITEST_H_