blob: 99a7201847f77d794e3344efb3569612d4883b89 [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
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000026enum APITESTAction {
27 TEST_CHANGE_CODEC_ONLY = 0,
28 DTX_TEST = 1
niklase@google.com470e71d2011-07-07 08:21:25 +000029};
30
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000031class APITest : public ACMTest {
32 public:
solenberg88499ec2016-09-07 07:34:41 -070033 APITest();
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000034 ~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.orgd5726a12013-05-03 07:34:12 +000062 //
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.orgd5726a12013-05-03 07:34:12 +000071 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
kwiberg37478382016-02-14 20:40:57 -080084 std::unique_ptr<AudioCodingModule> _acmA;
85 std::unique_ptr<AudioCodingModule> _acmB;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000086
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öm64c03662015-04-08 11:24:19 +0200111 EventTimerWrapper* _pullEventA; // pulling data from ACM
112 EventTimerWrapper* _pushEventA; // pushing data to ACM
113 EventTimerWrapper* _processEventA; // process
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000114 EventWrapper* _apiEventA; // API calls
115 // B
Peter Boström64c03662015-04-08 11:24:19 +0200116 EventTimerWrapper* _pullEventB; // pulling data from ACM
117 EventTimerWrapper* _pushEventB; // pushing data to ACM
118 EventTimerWrapper* _processEventB; // process
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000119 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.orgd5726a12013-05-03 07:34:12 +0000143 bool _verbose;
144
145 int _dotPositionA;
146 int _dotMoveDirectionA;
147 int _dotPositionB;
148 int _dotMoveDirectionB;
149
150 char _movingDot[41];
151
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000152 VADCallback* _vadCallbackA;
153 VADCallback* _vadCallbackB;
154 RWLockWrapper& _apiTestRWLock;
155 bool _randomTest;
156 int _testNumA;
157 int _testNumB;
158};
159
160} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000161
kjellander3e6db232015-11-26 04:44:54 -0800162#endif // WEBRTC_MODULES_AUDIO_CODING_TEST_APITEST_H_