OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 /* | 11 /* |
12 * This file contains common constants for VoiceEngine, as well as | 12 * This file contains common constants for VoiceEngine, as well as |
13 * platform specific settings and include files. | 13 * platform specific settings. |
14 */ | 14 */ |
15 | 15 |
16 #ifndef WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H | 16 #ifndef WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H |
17 #define WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H | 17 #define WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H |
18 | 18 |
19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
20 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 20 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
21 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
22 | 22 |
23 // ---------------------------------------------------------------------------- | |
24 // Enumerators | |
25 // ---------------------------------------------------------------------------- | |
26 | |
27 namespace webrtc { | 23 namespace webrtc { |
28 | 24 |
29 // Internal buffer size required for mono audio, based on the highest sample | |
30 // rate voice engine supports (10 ms of audio at 192 kHz). | |
31 static const size_t kMaxMonoDataSizeSamples = 1920; | |
32 | |
33 // VolumeControl | 25 // VolumeControl |
34 enum { kMinVolumeLevel = 0 }; | 26 enum { kMinVolumeLevel = 0 }; |
35 enum { kMaxVolumeLevel = 255 }; | 27 enum { kMaxVolumeLevel = 255 }; |
36 // Min scale factor for per-channel volume scaling | 28 // Min scale factor for per-channel volume scaling |
37 const float kMinOutputVolumeScaling = 0.0f; | 29 const float kMinOutputVolumeScaling = 0.0f; |
38 // Max scale factor for per-channel volume scaling | 30 // Max scale factor for per-channel volume scaling |
39 const float kMaxOutputVolumeScaling = 10.0f; | 31 const float kMaxOutputVolumeScaling = 10.0f; |
40 // Min scale factor for output volume panning | 32 // Min scale factor for output volume panning |
41 const float kMinOutputVolumePanning = 0.0f; | 33 const float kMinOutputVolumePanning = 0.0f; |
42 // Max scale factor for output volume panning | 34 // Max scale factor for output volume panning |
43 const float kMaxOutputVolumePanning = 1.0f; | 35 const float kMaxOutputVolumePanning = 1.0f; |
44 | 36 |
45 // DTMF | |
46 enum { kMinDtmfEventCode = 0 }; // DTMF digit "0" | |
47 enum { kMaxDtmfEventCode = 15 }; // DTMF digit "D" | |
48 enum { kMinTelephoneEventCode = 0 }; // RFC4733 (Section 2.3.1) | |
49 enum { kMaxTelephoneEventCode = 255 }; // RFC4733 (Section 2.3.1) | |
50 enum { kMinTelephoneEventDuration = 100 }; | |
51 enum { kMaxTelephoneEventDuration = 60000 }; // Actual limit is 2^16 | |
52 enum { kMinTelephoneEventAttenuation = 0 }; // 0 dBm0 | |
53 enum { kMaxTelephoneEventAttenuation = 36 }; // -36 dBm0 | |
54 enum { kMinTelephoneEventSeparationMs = 100 }; // Min delta time between two | |
55 // telephone events | |
56 enum { kVoiceEngineMaxIpPacketSizeBytes = 1500 }; // assumes Ethernet | 37 enum { kVoiceEngineMaxIpPacketSizeBytes = 1500 }; // assumes Ethernet |
57 | 38 |
58 enum { kVoiceEngineMaxModuleVersionSize = 960 }; | |
59 | |
60 // Audio processing | 39 // Audio processing |
61 const NoiseSuppression::Level kDefaultNsMode = NoiseSuppression::kModerate; | 40 const NoiseSuppression::Level kDefaultNsMode = NoiseSuppression::kModerate; |
62 const GainControl::Mode kDefaultAgcMode = | 41 const GainControl::Mode kDefaultAgcMode = |
63 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 42 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
64 GainControl::kAdaptiveDigital; | 43 GainControl::kAdaptiveDigital; |
65 #else | 44 #else |
66 GainControl::kAdaptiveAnalog; | 45 GainControl::kAdaptiveAnalog; |
67 #endif | 46 #endif |
68 const bool kDefaultAgcState = | 47 const bool kDefaultAgcState = |
69 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 48 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
70 false; | 49 false; |
71 #else | 50 #else |
72 true; | 51 true; |
73 #endif | 52 #endif |
74 const GainControl::Mode kDefaultRxAgcMode = GainControl::kAdaptiveDigital; | 53 const GainControl::Mode kDefaultRxAgcMode = GainControl::kAdaptiveDigital; |
75 | 54 |
76 // Codec | |
77 // Min init target rate for iSAC-wb | |
78 enum { kVoiceEngineMinIsacInitTargetRateBpsWb = 10000 }; | |
79 // Max init target rate for iSAC-wb | |
80 enum { kVoiceEngineMaxIsacInitTargetRateBpsWb = 32000 }; | |
81 // Min init target rate for iSAC-swb | |
82 enum { kVoiceEngineMinIsacInitTargetRateBpsSwb = 10000 }; | |
83 // Max init target rate for iSAC-swb | |
84 enum { kVoiceEngineMaxIsacInitTargetRateBpsSwb = 56000 }; | |
85 // Lowest max rate for iSAC-wb | |
86 enum { kVoiceEngineMinIsacMaxRateBpsWb = 32000 }; | |
87 // Highest max rate for iSAC-wb | |
88 enum { kVoiceEngineMaxIsacMaxRateBpsWb = 53400 }; | |
89 // Lowest max rate for iSAC-swb | |
90 enum { kVoiceEngineMinIsacMaxRateBpsSwb = 32000 }; | |
91 // Highest max rate for iSAC-swb | |
92 enum { kVoiceEngineMaxIsacMaxRateBpsSwb = 107000 }; | |
93 // Lowest max payload size for iSAC-wb | |
94 enum { kVoiceEngineMinIsacMaxPayloadSizeBytesWb = 120 }; | |
95 // Highest max payload size for iSAC-wb | |
96 enum { kVoiceEngineMaxIsacMaxPayloadSizeBytesWb = 400 }; | |
97 // Lowest max payload size for iSAC-swb | |
98 enum { kVoiceEngineMinIsacMaxPayloadSizeBytesSwb = 120 }; | |
99 // Highest max payload size for iSAC-swb | |
100 enum { kVoiceEngineMaxIsacMaxPayloadSizeBytesSwb = 600 }; | |
101 | |
102 // VideoSync | 55 // VideoSync |
103 // Lowest minimum playout delay | 56 // Lowest minimum playout delay |
104 enum { kVoiceEngineMinMinPlayoutDelayMs = 0 }; | 57 enum { kVoiceEngineMinMinPlayoutDelayMs = 0 }; |
105 // Highest minimum playout delay | 58 // Highest minimum playout delay |
106 enum { kVoiceEngineMaxMinPlayoutDelayMs = 10000 }; | 59 enum { kVoiceEngineMaxMinPlayoutDelayMs = 10000 }; |
107 | 60 |
108 // Network | |
109 // Min packet-timeout time for received RTP packets | |
110 enum { kVoiceEngineMinPacketTimeoutSec = 1 }; | |
111 // Max packet-timeout time for received RTP packets | |
112 enum { kVoiceEngineMaxPacketTimeoutSec = 150 }; | |
113 // Min sample time for dead-or-alive detection | |
114 enum { kVoiceEngineMinSampleTimeSec = 1 }; | |
115 // Max sample time for dead-or-alive detection | |
116 enum { kVoiceEngineMaxSampleTimeSec = 150 }; | |
117 | |
118 // RTP/RTCP | 61 // RTP/RTCP |
119 // Min 4-bit ID for RTP extension (see section 4.2 in RFC 5285) | 62 // Min 4-bit ID for RTP extension (see section 4.2 in RFC 5285) |
120 enum { kVoiceEngineMinRtpExtensionId = 1 }; | 63 enum { kVoiceEngineMinRtpExtensionId = 1 }; |
121 // Max 4-bit ID for RTP extension | 64 // Max 4-bit ID for RTP extension |
122 enum { kVoiceEngineMaxRtpExtensionId = 14 }; | 65 enum { kVoiceEngineMaxRtpExtensionId = 14 }; |
123 | 66 |
124 } // namespace webrtc | 67 } // namespace webrtc |
125 | 68 |
126 // ---------------------------------------------------------------------------- | |
127 // Macros | |
128 // ---------------------------------------------------------------------------- | |
129 | |
130 #define NOT_SUPPORTED(stat) \ | 69 #define NOT_SUPPORTED(stat) \ |
131 LOG_F(LS_ERROR) << "not supported"; \ | 70 LOG_F(LS_ERROR) << "not supported"; \ |
132 stat.SetLastError(VE_FUNC_NOT_SUPPORTED); \ | 71 stat.SetLastError(VE_FUNC_NOT_SUPPORTED); \ |
133 return -1; | 72 return -1; |
134 | 73 |
135 #if (!defined(NDEBUG) && defined(_WIN32) && (_MSC_VER >= 1400)) | |
136 #include <windows.h> | |
137 #include <stdio.h> | |
138 #define DEBUG_PRINT(...) \ | |
139 { \ | |
140 char msg[256]; \ | |
141 sprintf(msg, __VA_ARGS__); \ | |
142 OutputDebugStringA(msg); \ | |
143 } | |
144 #else | |
145 // special fix for visual 2003 | |
146 #define DEBUG_PRINT(exp) ((void)0) | |
147 #endif // !defined(NDEBUG) && defined(_WIN32) | |
148 | |
149 #define CHECK_CHANNEL(channel) \ | |
150 if (CheckChannel(channel) == -1) \ | |
151 return -1; | |
152 | |
153 // ---------------------------------------------------------------------------- | |
154 // Inline functions | |
155 // ---------------------------------------------------------------------------- | |
156 | |
157 namespace webrtc { | 74 namespace webrtc { |
158 | 75 |
159 inline int VoEId(int veId, int chId) { | 76 inline int VoEId(int veId, int chId) { |
160 if (chId == -1) { | 77 if (chId == -1) { |
161 const int dummyChannel(99); | 78 const int dummyChannel(99); |
162 return (int)((veId << 16) + dummyChannel); | 79 return (int)((veId << 16) + dummyChannel); |
163 } | 80 } |
164 return (int)((veId << 16) + chId); | 81 return (int)((veId << 16) + chId); |
165 } | 82 } |
166 | 83 |
167 inline int VoEModuleId(int veId, int chId) { | 84 inline int VoEModuleId(int veId, int chId) { |
168 return (int)((veId << 16) + chId); | 85 return (int)((veId << 16) + chId); |
169 } | 86 } |
170 | 87 |
171 // Convert module ID to internal VoE channel ID | 88 // Convert module ID to internal VoE channel ID |
172 inline int VoEChannelId(int moduleId) { | 89 inline int VoEChannelId(int moduleId) { |
173 return (int)(moduleId & 0xffff); | 90 return (int)(moduleId & 0xffff); |
174 } | 91 } |
175 | 92 |
176 } // namespace webrtc | 93 } // namespace webrtc |
177 | 94 |
178 // ---------------------------------------------------------------------------- | |
179 // Platform settings | |
180 // ---------------------------------------------------------------------------- | |
181 | |
182 // *** WINDOWS *** | |
183 | |
184 #if defined(_WIN32) | 95 #if defined(_WIN32) |
185 | |
186 #include <windows.h> | |
187 | |
188 #pragma comment(lib, "winmm.lib") | |
189 | |
190 #ifndef WEBRTC_EXTERNAL_TRANSPORT | |
191 #pragma comment(lib, "ws2_32.lib") | |
192 #endif | |
193 | |
194 // ---------------------------------------------------------------------------- | |
195 // Defines | |
196 // ---------------------------------------------------------------------------- | |
197 | |
198 // Default device for Windows PC | |
199 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE \ | 96 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE \ |
200 AudioDeviceModule::kDefaultCommunicationDevice | 97 AudioDeviceModule::kDefaultCommunicationDevice |
201 | 98 #else |
| 99 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0 |
202 #endif // #if (defined(_WIN32) | 100 #endif // #if (defined(_WIN32) |
203 | 101 |
204 // *** LINUX *** | |
205 | |
206 #ifdef WEBRTC_LINUX | |
207 | |
208 #include <arpa/inet.h> | |
209 #include <netinet/in.h> | |
210 #include <pthread.h> | |
211 #include <sys/socket.h> | |
212 #include <sys/types.h> | |
213 #ifndef QNX | |
214 #include <linux/net.h> | |
215 #ifndef ANDROID | |
216 #include <sys/soundcard.h> | |
217 #endif // ANDROID | |
218 #endif // QNX | |
219 #include <errno.h> | |
220 #include <fcntl.h> | |
221 #include <sched.h> | |
222 #include <stdio.h> | |
223 #include <stdlib.h> | |
224 #include <string.h> | |
225 #include <sys/ioctl.h> | |
226 #include <sys/stat.h> | |
227 #include <sys/time.h> | |
228 #include <time.h> | |
229 #include <unistd.h> | |
230 | |
231 #define DWORD unsigned long int | |
232 #define WINAPI | |
233 #define LPVOID void * | |
234 #define FALSE 0 | |
235 #define TRUE 1 | |
236 #define UINT unsigned int | |
237 #define UCHAR unsigned char | |
238 #define TCHAR char | |
239 #ifdef QNX | |
240 #define _stricmp stricmp | |
241 #else | |
242 #define _stricmp strcasecmp | |
243 #endif | |
244 #define GetLastError() errno | |
245 #define WSAGetLastError() errno | |
246 #define LPCTSTR const char * | |
247 #define LPCSTR const char * | |
248 #define wsprintf sprintf | |
249 #define TEXT(a) a | |
250 #define _ftprintf fprintf | |
251 #define _tcslen strlen | |
252 #define FAR | |
253 #define __cdecl | |
254 #define LPSOCKADDR struct sockaddr * | |
255 | |
256 // Default device for Linux and Android | |
257 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0 | |
258 | |
259 #endif // #ifdef WEBRTC_LINUX | |
260 | |
261 // *** WEBRTC_MAC *** | |
262 // including iPhone | |
263 | |
264 #ifdef WEBRTC_MAC | |
265 | |
266 #include <AudioUnit/AudioUnit.h> | |
267 #include <arpa/inet.h> | |
268 #include <errno.h> | |
269 #include <fcntl.h> | |
270 #include <netinet/in.h> | |
271 #include <pthread.h> | |
272 #include <sched.h> | |
273 #include <stdio.h> | |
274 #include <stdlib.h> | |
275 #include <string.h> | |
276 #include <sys/socket.h> | |
277 #include <sys/stat.h> | |
278 #include <sys/time.h> | |
279 #include <sys/types.h> | |
280 #include <time.h> | |
281 #include <unistd.h> | |
282 #if !defined(WEBRTC_IOS) | |
283 #include <CoreServices/CoreServices.h> | |
284 #include <CoreAudio/CoreAudio.h> | |
285 #include <AudioToolbox/DefaultAudioOutput.h> | |
286 #include <AudioToolbox/AudioConverter.h> | |
287 #include <CoreAudio/HostTime.h> | |
288 #endif | |
289 | |
290 #define DWORD unsigned long int | |
291 #define WINAPI | |
292 #define LPVOID void * | |
293 #define FALSE 0 | |
294 #define TRUE 1 | |
295 #define SOCKADDR_IN struct sockaddr_in | |
296 #define UINT unsigned int | |
297 #define UCHAR unsigned char | |
298 #define TCHAR char | |
299 #define _stricmp strcasecmp | |
300 #define GetLastError() errno | |
301 #define WSAGetLastError() errno | |
302 #define LPCTSTR const char * | |
303 #define wsprintf sprintf | |
304 #define TEXT(a) a | |
305 #define _ftprintf fprintf | |
306 #define _tcslen strlen | |
307 #define FAR | |
308 #define __cdecl | |
309 #define LPSOCKADDR struct sockaddr * | |
310 #define LPCSTR const char * | |
311 #define ULONG unsigned long | |
312 | |
313 // Default device for Mac and iPhone | |
314 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0 | |
315 #endif // #ifdef WEBRTC_MAC | |
316 | |
317 #endif // WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H | 102 #endif // WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H |
OLD | NEW |