niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | 8012474 | 2012-03-08 17:54:24 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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 | /* |
| 12 | * This file contains common constants for VoiceEngine, as well as |
| 13 | * platform specific settings and include files. |
| 14 | */ |
| 15 | |
| 16 | #ifndef WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H |
| 17 | #define WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H |
| 18 | |
andrew@webrtc.org | 8012474 | 2012-03-08 17:54:24 +0000 | [diff] [blame] | 19 | #include "common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | #include "engine_configurations.h" |
| 21 | |
| 22 | // ---------------------------------------------------------------------------- |
| 23 | // Enumerators |
| 24 | // ---------------------------------------------------------------------------- |
| 25 | |
| 26 | namespace webrtc |
| 27 | { |
| 28 | |
| 29 | // VolumeControl |
| 30 | enum { kMinVolumeLevel = 0 }; |
| 31 | enum { kMaxVolumeLevel = 255 }; |
| 32 | // Min scale factor for per-channel volume scaling |
| 33 | const float kMinOutputVolumeScaling = 0.0f; |
| 34 | // Max scale factor for per-channel volume scaling |
| 35 | const float kMaxOutputVolumeScaling = 10.0f; |
| 36 | // Min scale factor for output volume panning |
| 37 | const float kMinOutputVolumePanning = 0.0f; |
| 38 | // Max scale factor for output volume panning |
| 39 | const float kMaxOutputVolumePanning = 1.0f; |
| 40 | |
| 41 | // DTMF |
| 42 | enum { kMinDtmfEventCode = 0 }; // DTMF digit "0" |
| 43 | enum { kMaxDtmfEventCode = 15 }; // DTMF digit "D" |
| 44 | enum { kMinTelephoneEventCode = 0 }; // RFC4733 (Section 2.3.1) |
| 45 | enum { kMaxTelephoneEventCode = 255 }; // RFC4733 (Section 2.3.1) |
| 46 | enum { kMinTelephoneEventDuration = 100 }; |
| 47 | enum { kMaxTelephoneEventDuration = 60000 }; // Actual limit is 2^16 |
| 48 | enum { kMinTelephoneEventAttenuation = 0 }; // 0 dBm0 |
| 49 | enum { kMaxTelephoneEventAttenuation = 36 }; // -36 dBm0 |
| 50 | enum { kMinTelephoneEventSeparationMs = 100 }; // Min delta time between two |
| 51 | // telephone events |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | enum { kVoiceEngineMaxIpPacketSizeBytes = 1500 }; // assumes Ethernet |
| 53 | |
| 54 | enum { kVoiceEngineMaxModuleVersionSize = 960 }; |
| 55 | |
| 56 | // Base |
| 57 | enum { kVoiceEngineVersionMaxMessageSize = 1024 }; |
| 58 | |
| 59 | // Encryption |
| 60 | // SRTP uses 30 bytes key length |
| 61 | enum { kVoiceEngineMaxSrtpKeyLength = 30 }; |
| 62 | // SRTP minimum key/tag length for encryption level |
| 63 | enum { kVoiceEngineMinSrtpEncryptLength = 16 }; |
| 64 | // SRTP maximum key/tag length for encryption level |
| 65 | enum { kVoiceEngineMaxSrtpEncryptLength = 256 }; |
| 66 | // SRTP maximum key/tag length for authentication level, |
| 67 | // HMAC SHA1 authentication type |
| 68 | enum { kVoiceEngineMaxSrtpAuthSha1Length = 20 }; |
| 69 | // SRTP maximum tag length for authentication level, |
| 70 | // null authentication type |
| 71 | enum { kVoiceEngineMaxSrtpTagAuthNullLength = 12 }; |
| 72 | // SRTP maximum key length for authentication level, |
| 73 | // null authentication type |
| 74 | enum { kVoiceEngineMaxSrtpKeyAuthNullLength = 256 }; |
| 75 | |
| 76 | // Audio processing |
| 77 | enum { kVoiceEngineAudioProcessingDeviceSampleRateHz = 48000 }; |
| 78 | |
| 79 | // Codec |
| 80 | // Min init target rate for iSAC-wb |
| 81 | enum { kVoiceEngineMinIsacInitTargetRateBpsWb = 10000 }; |
| 82 | // Max init target rate for iSAC-wb |
| 83 | enum { kVoiceEngineMaxIsacInitTargetRateBpsWb = 32000 }; |
| 84 | // Min init target rate for iSAC-swb |
| 85 | enum { kVoiceEngineMinIsacInitTargetRateBpsSwb = 10000 }; |
| 86 | // Max init target rate for iSAC-swb |
| 87 | enum { kVoiceEngineMaxIsacInitTargetRateBpsSwb = 56000 }; |
| 88 | // Lowest max rate for iSAC-wb |
| 89 | enum { kVoiceEngineMinIsacMaxRateBpsWb = 32000 }; |
| 90 | // Highest max rate for iSAC-wb |
| 91 | enum { kVoiceEngineMaxIsacMaxRateBpsWb = 53400 }; |
| 92 | // Lowest max rate for iSAC-swb |
| 93 | enum { kVoiceEngineMinIsacMaxRateBpsSwb = 32000 }; |
| 94 | // Highest max rate for iSAC-swb |
| 95 | enum { kVoiceEngineMaxIsacMaxRateBpsSwb = 107000 }; |
| 96 | // Lowest max payload size for iSAC-wb |
| 97 | enum { kVoiceEngineMinIsacMaxPayloadSizeBytesWb = 120 }; |
| 98 | // Highest max payload size for iSAC-wb |
| 99 | enum { kVoiceEngineMaxIsacMaxPayloadSizeBytesWb = 400 }; |
| 100 | // Lowest max payload size for iSAC-swb |
| 101 | enum { kVoiceEngineMinIsacMaxPayloadSizeBytesSwb = 120 }; |
| 102 | // Highest max payload size for iSAC-swb |
| 103 | enum { kVoiceEngineMaxIsacMaxPayloadSizeBytesSwb = 600 }; |
| 104 | |
| 105 | // VideoSync |
| 106 | // Lowest minimum playout delay |
| 107 | enum { kVoiceEngineMinMinPlayoutDelayMs = 0 }; |
| 108 | // Highest minimum playout delay |
| 109 | enum { kVoiceEngineMaxMinPlayoutDelayMs = 1000 }; |
| 110 | |
| 111 | // Network |
| 112 | // Min packet-timeout time for received RTP packets |
| 113 | enum { kVoiceEngineMinPacketTimeoutSec = 1 }; |
| 114 | // Max packet-timeout time for received RTP packets |
| 115 | enum { kVoiceEngineMaxPacketTimeoutSec = 150 }; |
| 116 | // Min sample time for dead-or-alive detection |
| 117 | enum { kVoiceEngineMinSampleTimeSec = 1 }; |
| 118 | // Max sample time for dead-or-alive detection |
| 119 | enum { kVoiceEngineMaxSampleTimeSec = 150 }; |
| 120 | |
| 121 | // RTP/RTCP |
| 122 | // Min 4-bit ID for RTP extension (see section 4.2 in RFC 5285) |
| 123 | enum { kVoiceEngineMinRtpExtensionId = 1 }; |
| 124 | // Max 4-bit ID for RTP extension |
| 125 | enum { kVoiceEngineMaxRtpExtensionId = 14 }; |
| 126 | |
| 127 | } // namespace webrtc |
| 128 | |
andrew@webrtc.org | f458916 | 2011-10-03 15:22:28 +0000 | [diff] [blame] | 129 | // TODO(andrew): we shouldn't be using the precompiler for this. |
| 130 | // Use enums or bools as appropriate. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 131 | #define WEBRTC_AUDIO_PROCESSING_OFF false |
| 132 | |
| 133 | #define WEBRTC_VOICE_ENGINE_HP_DEFAULT_STATE true |
| 134 | // AudioProcessing HP is ON |
| 135 | #define WEBRTC_VOICE_ENGINE_NS_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 136 | // AudioProcessing NS off |
| 137 | #define WEBRTC_VOICE_ENGINE_AGC_DEFAULT_STATE true |
| 138 | // AudioProcessing AGC on |
| 139 | #define WEBRTC_VOICE_ENGINE_EC_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 140 | // AudioProcessing EC off |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 141 | #define WEBRTC_VOICE_ENGINE_VAD_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 142 | // AudioProcessing off |
| 143 | #define WEBRTC_VOICE_ENGINE_RX_AGC_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 144 | // AudioProcessing RX AGC off |
| 145 | #define WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 146 | // AudioProcessing RX NS off |
| 147 | #define WEBRTC_VOICE_ENGINE_RX_HP_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 148 | // AudioProcessing RX High Pass Filter off |
| 149 | |
andrew@webrtc.org | 8012474 | 2012-03-08 17:54:24 +0000 | [diff] [blame] | 150 | #define WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE NoiseSuppression::kModerate |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | // AudioProcessing NS moderate suppression |
| 152 | #define WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE GainControl::kAdaptiveAnalog |
| 153 | // AudioProcessing AGC analog digital combined |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 154 | #define WEBRTC_VOICE_ENGINE_RX_AGC_DEFAULT_MODE GainControl::kAdaptiveDigital |
| 155 | // AudioProcessing AGC mode |
andrew@webrtc.org | 8012474 | 2012-03-08 17:54:24 +0000 | [diff] [blame] | 156 | #define WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_MODE NoiseSuppression::kModerate |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 157 | // AudioProcessing RX NS mode |
| 158 | |
| 159 | // Macros |
| 160 | // Comparison of two strings without regard to case |
| 161 | #define STR_CASE_CMP(x,y) ::_stricmp(x,y) |
| 162 | // Compares characters of two strings without regard to case |
| 163 | #define STR_NCASE_CMP(x,y,n) ::_strnicmp(x,y,n) |
| 164 | |
| 165 | // ---------------------------------------------------------------------------- |
| 166 | // Build information macros |
| 167 | // ---------------------------------------------------------------------------- |
| 168 | |
| 169 | #if defined(_DEBUG) |
| 170 | #define BUILDMODE "d" |
| 171 | #elif defined(DEBUG) |
| 172 | #define BUILDMODE "d" |
| 173 | #elif defined(NDEBUG) |
| 174 | #define BUILDMODE "r" |
| 175 | #else |
| 176 | #define BUILDMODE "?" |
| 177 | #endif |
| 178 | |
| 179 | #define BUILDTIME __TIME__ |
| 180 | #define BUILDDATE __DATE__ |
| 181 | |
| 182 | // Example: "Oct 10 2002 12:05:30 r" |
| 183 | #define BUILDINFO BUILDDATE " " BUILDTIME " " BUILDMODE |
| 184 | |
| 185 | // ---------------------------------------------------------------------------- |
| 186 | // Macros |
| 187 | // ---------------------------------------------------------------------------- |
| 188 | |
| 189 | #if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400)) |
| 190 | #include <windows.h> |
| 191 | #include <stdio.h> |
| 192 | #define DEBUG_PRINT(...) \ |
| 193 | { \ |
| 194 | char msg[256]; \ |
| 195 | sprintf(msg, __VA_ARGS__); \ |
| 196 | OutputDebugStringA(msg); \ |
| 197 | } |
| 198 | #else |
| 199 | // special fix for visual 2003 |
| 200 | #define DEBUG_PRINT(exp) ((void)0) |
| 201 | #endif // defined(_DEBUG) && defined(_WIN32) |
| 202 | |
| 203 | #define CHECK_CHANNEL(channel) if (CheckChannel(channel) == -1) return -1; |
| 204 | |
| 205 | // ---------------------------------------------------------------------------- |
| 206 | // Default Trace filter |
| 207 | // ---------------------------------------------------------------------------- |
| 208 | |
| 209 | #define WEBRTC_VOICE_ENGINE_DEFAULT_TRACE_FILTER \ |
| 210 | kTraceStateInfo | kTraceWarning | kTraceError | kTraceCritical | \ |
| 211 | kTraceApiCall |
| 212 | |
| 213 | // ---------------------------------------------------------------------------- |
| 214 | // Inline functions |
| 215 | // ---------------------------------------------------------------------------- |
| 216 | |
| 217 | namespace webrtc |
| 218 | { |
| 219 | |
| 220 | inline int VoEId(const int veId, const int chId) |
| 221 | { |
| 222 | if (chId == -1) |
| 223 | { |
| 224 | const int dummyChannel(99); |
| 225 | return (int) ((veId << 16) + dummyChannel); |
| 226 | } |
| 227 | return (int) ((veId << 16) + chId); |
| 228 | } |
| 229 | |
| 230 | inline int VoEModuleId(const int veId, const int chId) |
| 231 | { |
| 232 | return (int) ((veId << 16) + chId); |
| 233 | } |
| 234 | |
| 235 | // Convert module ID to internal VoE channel ID |
| 236 | inline int VoEChannelId(const int moduleId) |
| 237 | { |
| 238 | return (int) (moduleId & 0xffff); |
| 239 | } |
| 240 | |
| 241 | } // namespace webrtc |
| 242 | |
| 243 | // ---------------------------------------------------------------------------- |
| 244 | // Platform settings |
| 245 | // ---------------------------------------------------------------------------- |
| 246 | |
| 247 | // *** WINDOWS *** |
| 248 | |
| 249 | #if defined(_WIN32) |
| 250 | |
| 251 | #pragma comment( lib, "winmm.lib" ) |
| 252 | |
| 253 | #ifndef WEBRTC_EXTERNAL_TRANSPORT |
| 254 | #pragma comment( lib, "ws2_32.lib" ) |
| 255 | #endif |
| 256 | |
| 257 | // ---------------------------------------------------------------------------- |
| 258 | // Enumerators |
| 259 | // ---------------------------------------------------------------------------- |
| 260 | |
| 261 | namespace webrtc |
| 262 | { |
| 263 | // Max number of supported channels |
| 264 | enum { kVoiceEngineMaxNumOfChannels = 32 }; |
| 265 | // Max number of channels which can be played out simultaneously |
| 266 | enum { kVoiceEngineMaxNumOfActiveChannels = 16 }; |
| 267 | } // namespace webrtc |
| 268 | |
| 269 | // ---------------------------------------------------------------------------- |
| 270 | // Defines |
| 271 | // ---------------------------------------------------------------------------- |
| 272 | |
| 273 | #include <windows.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 274 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 275 | // Comparison of two strings without regard to case |
| 276 | #define STR_CASE_CMP(x,y) ::_stricmp(x,y) |
| 277 | // Compares characters of two strings without regard to case |
| 278 | #define STR_NCASE_CMP(x,y,n) ::_strnicmp(x,y,n) |
| 279 | |
| 280 | // Default device for Windows PC |
| 281 | #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE \ |
| 282 | AudioDeviceModule::kDefaultCommunicationDevice |
| 283 | |
| 284 | #endif // #if (defined(_WIN32) |
| 285 | |
| 286 | // *** LINUX *** |
| 287 | |
| 288 | #ifdef WEBRTC_LINUX |
| 289 | |
| 290 | #include <pthread.h> |
| 291 | #include <sys/types.h> |
| 292 | #include <sys/socket.h> |
| 293 | #include <netinet/in.h> |
| 294 | #include <arpa/inet.h> |
| 295 | #ifndef QNX |
| 296 | #include <linux/net.h> |
| 297 | #ifndef ANDROID |
| 298 | #include <sys/soundcard.h> |
| 299 | #endif // ANDROID |
| 300 | #endif // QNX |
| 301 | #include <stdio.h> |
| 302 | #include <string.h> |
| 303 | #include <stdlib.h> |
| 304 | #include <errno.h> |
| 305 | #include <sys/stat.h> |
| 306 | #include <sys/ioctl.h> |
| 307 | #include <unistd.h> |
| 308 | #include <fcntl.h> |
| 309 | #include <sched.h> |
| 310 | #include <time.h> |
| 311 | #include <sys/time.h> |
| 312 | |
| 313 | #define DWORD unsigned long int |
| 314 | #define WINAPI |
| 315 | #define LPVOID void * |
| 316 | #define FALSE 0 |
| 317 | #define TRUE 1 |
| 318 | #define UINT unsigned int |
| 319 | #define UCHAR unsigned char |
| 320 | #define TCHAR char |
| 321 | #ifdef QNX |
| 322 | #define _stricmp stricmp |
| 323 | #else |
| 324 | #define _stricmp strcasecmp |
| 325 | #endif |
| 326 | #define GetLastError() errno |
| 327 | #define WSAGetLastError() errno |
| 328 | #define LPCTSTR const char* |
| 329 | #define LPCSTR const char* |
| 330 | #define wsprintf sprintf |
| 331 | #define TEXT(a) a |
| 332 | #define _ftprintf fprintf |
| 333 | #define _tcslen strlen |
| 334 | #define FAR |
| 335 | #define __cdecl |
| 336 | #define LPSOCKADDR struct sockaddr * |
| 337 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 338 | // Default device for Linux and Android |
| 339 | #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0 |
| 340 | |
| 341 | #ifdef ANDROID |
| 342 | |
| 343 | // ---------------------------------------------------------------------------- |
| 344 | // Enumerators |
| 345 | // ---------------------------------------------------------------------------- |
| 346 | |
| 347 | namespace webrtc |
| 348 | { |
| 349 | // Max number of supported channels |
leozwang@webrtc.org | d5fbdc8 | 2012-11-13 21:30:34 +0000 | [diff] [blame] | 350 | enum { kVoiceEngineMaxNumOfChannels = 32 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 351 | // Max number of channels which can be played out simultaneously |
leozwang@webrtc.org | d5fbdc8 | 2012-11-13 21:30:34 +0000 | [diff] [blame] | 352 | enum { kVoiceEngineMaxNumOfActiveChannels = 16 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 353 | } // namespace webrtc |
| 354 | |
| 355 | // ---------------------------------------------------------------------------- |
| 356 | // Defines |
| 357 | // ---------------------------------------------------------------------------- |
| 358 | |
| 359 | // Always excluded for Android builds |
| 360 | #undef WEBRTC_CODEC_ISAC |
| 361 | #undef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT |
| 362 | #undef WEBRTC_CONFERENCING |
| 363 | #undef WEBRTC_TYPING_DETECTION |
| 364 | |
| 365 | // Default audio processing states |
| 366 | #undef WEBRTC_VOICE_ENGINE_NS_DEFAULT_STATE |
| 367 | #undef WEBRTC_VOICE_ENGINE_AGC_DEFAULT_STATE |
| 368 | #undef WEBRTC_VOICE_ENGINE_EC_DEFAULT_STATE |
| 369 | #define WEBRTC_VOICE_ENGINE_NS_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 370 | #define WEBRTC_VOICE_ENGINE_AGC_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 371 | #define WEBRTC_VOICE_ENGINE_EC_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 372 | |
| 373 | // Default audio processing modes |
| 374 | #undef WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE |
| 375 | #undef WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 376 | #define WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE \ |
| 377 | NoiseSuppression::kModerate |
| 378 | #define WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE \ |
| 379 | GainControl::kAdaptiveDigital |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 380 | |
leozwang@webrtc.org | 2638577 | 2012-01-20 18:45:45 +0000 | [diff] [blame] | 381 | #define ANDROID_NOT_SUPPORTED(stat) \ |
| 382 | stat.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, \ |
leozwang@webrtc.org | f5cacdc | 2012-01-23 23:14:13 +0000 | [diff] [blame] | 383 | "API call not supported"); \ |
leozwang@webrtc.org | 2638577 | 2012-01-20 18:45:45 +0000 | [diff] [blame] | 384 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 385 | |
| 386 | #else // LINUX PC |
| 387 | // ---------------------------------------------------------------------------- |
| 388 | // Enumerators |
| 389 | // ---------------------------------------------------------------------------- |
| 390 | |
| 391 | namespace webrtc |
| 392 | { |
| 393 | // Max number of supported channels |
| 394 | enum { kVoiceEngineMaxNumOfChannels = 32 }; |
| 395 | // Max number of channels which can be played out simultaneously |
| 396 | enum { kVoiceEngineMaxNumOfActiveChannels = 16 }; |
| 397 | } // namespace webrtc |
| 398 | |
| 399 | // ---------------------------------------------------------------------------- |
| 400 | // Defines |
| 401 | // ---------------------------------------------------------------------------- |
| 402 | |
leozwang@webrtc.org | 2638577 | 2012-01-20 18:45:45 +0000 | [diff] [blame] | 403 | #define ANDROID_NOT_SUPPORTED(stat) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 404 | |
| 405 | #endif // ANDROID - LINUX PC |
| 406 | |
| 407 | #else |
leozwang@webrtc.org | 2638577 | 2012-01-20 18:45:45 +0000 | [diff] [blame] | 408 | #define ANDROID_NOT_SUPPORTED(stat) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 409 | #endif // #ifdef WEBRTC_LINUX |
| 410 | |
| 411 | // *** WEBRTC_MAC *** |
| 412 | // including iPhone |
| 413 | |
| 414 | #ifdef WEBRTC_MAC |
| 415 | |
| 416 | #include <pthread.h> |
| 417 | #include <sys/types.h> |
| 418 | #include <sys/socket.h> |
| 419 | #include <netinet/in.h> |
| 420 | #include <arpa/inet.h> |
| 421 | #include <stdio.h> |
| 422 | #include <string.h> |
| 423 | #include <stdlib.h> |
| 424 | #include <errno.h> |
| 425 | #include <sys/stat.h> |
| 426 | #include <unistd.h> |
| 427 | #include <fcntl.h> |
| 428 | #include <sched.h> |
| 429 | #include <sys/time.h> |
| 430 | #include <time.h> |
| 431 | #include <AudioUnit/AudioUnit.h> |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 432 | #if !defined(WEBRTC_IOS) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 433 | #include <CoreServices/CoreServices.h> |
| 434 | #include <CoreAudio/CoreAudio.h> |
| 435 | #include <AudioToolbox/DefaultAudioOutput.h> |
| 436 | #include <AudioToolbox/AudioConverter.h> |
| 437 | #include <CoreAudio/HostTime.h> |
| 438 | #endif |
| 439 | |
| 440 | #define DWORD unsigned long int |
| 441 | #define WINAPI |
| 442 | #define LPVOID void * |
| 443 | #define FALSE 0 |
| 444 | #define TRUE 1 |
| 445 | #define SOCKADDR_IN struct sockaddr_in |
| 446 | #define UINT unsigned int |
| 447 | #define UCHAR unsigned char |
| 448 | #define TCHAR char |
| 449 | #define _stricmp strcasecmp |
| 450 | #define GetLastError() errno |
| 451 | #define WSAGetLastError() errno |
| 452 | #define LPCTSTR const char* |
| 453 | #define wsprintf sprintf |
| 454 | #define TEXT(a) a |
| 455 | #define _ftprintf fprintf |
| 456 | #define _tcslen strlen |
| 457 | #define FAR |
| 458 | #define __cdecl |
| 459 | #define LPSOCKADDR struct sockaddr * |
| 460 | #define LPCSTR const char* |
| 461 | #define ULONG unsigned long |
| 462 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 463 | // Default device for Mac and iPhone |
| 464 | #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0 |
| 465 | |
| 466 | // iPhone specific |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 467 | #if defined(WEBRTC_IOS) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 468 | |
| 469 | // ---------------------------------------------------------------------------- |
| 470 | // Enumerators |
| 471 | // ---------------------------------------------------------------------------- |
| 472 | |
| 473 | namespace webrtc |
| 474 | { |
| 475 | // Max number of supported channels |
| 476 | enum { kVoiceEngineMaxNumOfChannels = 2 }; |
| 477 | // Max number of channels which can be played out simultaneously |
| 478 | enum { kVoiceEngineMaxNumOfActiveChannels = 2 }; |
| 479 | } // namespace webrtc |
| 480 | |
| 481 | // ---------------------------------------------------------------------------- |
| 482 | // Defines |
| 483 | // ---------------------------------------------------------------------------- |
| 484 | |
| 485 | // Always excluded for iPhone builds |
| 486 | #undef WEBRTC_CODEC_ISAC |
| 487 | #undef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT |
| 488 | |
| 489 | #undef WEBRTC_VOICE_ENGINE_NS_DEFAULT_STATE |
| 490 | #undef WEBRTC_VOICE_ENGINE_AGC_DEFAULT_STATE |
| 491 | #undef WEBRTC_VOICE_ENGINE_EC_DEFAULT_STATE |
| 492 | #define WEBRTC_VOICE_ENGINE_NS_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 493 | #define WEBRTC_VOICE_ENGINE_AGC_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 494 | #define WEBRTC_VOICE_ENGINE_EC_DEFAULT_STATE WEBRTC_AUDIO_PROCESSING_OFF |
| 495 | |
| 496 | #undef WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE |
| 497 | #undef WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 498 | #define WEBRTC_VOICE_ENGINE_NS_DEFAULT_MODE \ |
| 499 | NoiseSuppression::kModerate |
| 500 | #define WEBRTC_VOICE_ENGINE_AGC_DEFAULT_MODE \ |
| 501 | GainControl::kAdaptiveDigital |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 502 | |
sjlee@webrtc.org | 4b42508 | 2012-09-10 17:58:21 +0000 | [diff] [blame] | 503 | #define IPHONE_NOT_SUPPORTED(stat) \ |
| 504 | stat.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError, \ |
| 505 | "API call not supported"); \ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 506 | return -1; |
| 507 | |
| 508 | #else // Non-iPhone |
| 509 | |
| 510 | // ---------------------------------------------------------------------------- |
| 511 | // Enumerators |
| 512 | // ---------------------------------------------------------------------------- |
| 513 | |
| 514 | namespace webrtc |
| 515 | { |
| 516 | // Max number of supported channels |
| 517 | enum { kVoiceEngineMaxNumOfChannels = 32 }; |
| 518 | // Max number of channels which can be played out simultaneously |
| 519 | enum { kVoiceEngineMaxNumOfActiveChannels = 16 }; |
| 520 | } // namespace webrtc |
| 521 | |
| 522 | // ---------------------------------------------------------------------------- |
| 523 | // Defines |
| 524 | // ---------------------------------------------------------------------------- |
| 525 | |
sjlee@webrtc.org | 4b42508 | 2012-09-10 17:58:21 +0000 | [diff] [blame] | 526 | #define IPHONE_NOT_SUPPORTED(stat) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 527 | #endif |
| 528 | |
| 529 | #else |
sjlee@webrtc.org | 4b42508 | 2012-09-10 17:58:21 +0000 | [diff] [blame] | 530 | #define IPHONE_NOT_SUPPORTED(stat) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 531 | #endif // #ifdef WEBRTC_MAC |
| 532 | |
| 533 | |
| 534 | |
| 535 | #endif // WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H |