2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
12 * This file contains common constants for VoiceEngine, as well as
13 * platform specific settings and include files.
16 #ifndef WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H
17 #define WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H
19 #include "webrtc/common_types.h"
20 #include "webrtc/engine_configurations.h"
21 #include "webrtc/modules/audio_processing/include/audio_processing.h"
22 #include "webrtc/system_wrappers/interface/logging.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
31 enum { kMinVolumeLevel = 0 };
32 enum { kMaxVolumeLevel = 255 };
33 // Min scale factor for per-channel volume scaling
34 const float kMinOutputVolumeScaling = 0.0f;
35 // Max scale factor for per-channel volume scaling
36 const float kMaxOutputVolumeScaling = 10.0f;
37 // Min scale factor for output volume panning
38 const float kMinOutputVolumePanning = 0.0f;
39 // Max scale factor for output volume panning
40 const float kMaxOutputVolumePanning = 1.0f;
43 enum { kMinDtmfEventCode = 0 }; // DTMF digit "0"
44 enum { kMaxDtmfEventCode = 15 }; // DTMF digit "D"
45 enum { kMinTelephoneEventCode = 0 }; // RFC4733 (Section 2.3.1)
46 enum { kMaxTelephoneEventCode = 255 }; // RFC4733 (Section 2.3.1)
47 enum { kMinTelephoneEventDuration = 100 };
48 enum { kMaxTelephoneEventDuration = 60000 }; // Actual limit is 2^16
49 enum { kMinTelephoneEventAttenuation = 0 }; // 0 dBm0
50 enum { kMaxTelephoneEventAttenuation = 36 }; // -36 dBm0
51 enum { kMinTelephoneEventSeparationMs = 100 }; // Min delta time between two
53 enum { kVoiceEngineMaxIpPacketSizeBytes = 1500 }; // assumes Ethernet
55 enum { kVoiceEngineMaxModuleVersionSize = 960 };
58 enum { kVoiceEngineVersionMaxMessageSize = 1024 };
61 const NoiseSuppression::Level kDefaultNsMode = NoiseSuppression::kModerate;
62 const GainControl::Mode kDefaultAgcMode =
63 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
64 GainControl::kAdaptiveDigital;
66 GainControl::kAdaptiveAnalog;
68 const bool kDefaultAgcState =
69 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
74 const GainControl::Mode kDefaultRxAgcMode = GainControl::kAdaptiveDigital;
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 };
103 // Lowest minimum playout delay
104 enum { kVoiceEngineMinMinPlayoutDelayMs = 0 };
105 // Highest minimum playout delay
106 enum { kVoiceEngineMaxMinPlayoutDelayMs = 10000 };
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 };
119 // Min 4-bit ID for RTP extension (see section 4.2 in RFC 5285)
120 enum { kVoiceEngineMinRtpExtensionId = 1 };
121 // Max 4-bit ID for RTP extension
122 enum { kVoiceEngineMaxRtpExtensionId = 14 };
124 } // namespace webrtc
126 // ----------------------------------------------------------------------------
127 // Build information macros
128 // ----------------------------------------------------------------------------
131 #define BUILDMODE "d"
133 #define BUILDMODE "d"
134 #elif defined(NDEBUG)
135 #define BUILDMODE "r"
137 #define BUILDMODE "?"
140 #define BUILDTIME __TIME__
141 #define BUILDDATE __DATE__
143 // Example: "Oct 10 2002 12:05:30 r"
144 #define BUILDINFO BUILDDATE " " BUILDTIME " " BUILDMODE
146 // ----------------------------------------------------------------------------
148 // ----------------------------------------------------------------------------
150 #define NOT_SUPPORTED(stat) \
151 LOG_F(LS_ERROR) << "not supported"; \
152 stat.SetLastError(VE_FUNC_NOT_SUPPORTED); \
155 #if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
158 #define DEBUG_PRINT(...) \
161 sprintf(msg, __VA_ARGS__); \
162 OutputDebugStringA(msg); \
165 // special fix for visual 2003
166 #define DEBUG_PRINT(exp) ((void)0)
167 #endif // defined(_DEBUG) && defined(_WIN32)
169 #define CHECK_CHANNEL(channel) if (CheckChannel(channel) == -1) return -1;
171 // ----------------------------------------------------------------------------
173 // ----------------------------------------------------------------------------
178 inline int VoEId(int veId, int chId)
182 const int dummyChannel(99);
183 return (int) ((veId << 16) + dummyChannel);
185 return (int) ((veId << 16) + chId);
188 inline int VoEModuleId(int veId, int chId)
190 return (int) ((veId << 16) + chId);
193 // Convert module ID to internal VoE channel ID
194 inline int VoEChannelId(int moduleId)
196 return (int) (moduleId & 0xffff);
199 } // namespace webrtc
201 // ----------------------------------------------------------------------------
203 // ----------------------------------------------------------------------------
211 #pragma comment( lib, "winmm.lib" )
213 #ifndef WEBRTC_EXTERNAL_TRANSPORT
214 #pragma comment( lib, "ws2_32.lib" )
217 // ----------------------------------------------------------------------------
219 // ----------------------------------------------------------------------------
221 // Default device for Windows PC
222 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE \
223 AudioDeviceModule::kDefaultCommunicationDevice
225 #endif // #if (defined(_WIN32)
231 #include <arpa/inet.h>
232 #include <netinet/in.h>
234 #include <sys/socket.h>
235 #include <sys/types.h>
237 #include <linux/net.h>
239 #include <sys/soundcard.h>
248 #include <sys/ioctl.h>
249 #include <sys/stat.h>
250 #include <sys/time.h>
254 #define DWORD unsigned long int
256 #define LPVOID void *
259 #define UINT unsigned int
260 #define UCHAR unsigned char
263 #define _stricmp stricmp
265 #define _stricmp strcasecmp
267 #define GetLastError() errno
268 #define WSAGetLastError() errno
269 #define LPCTSTR const char*
270 #define LPCSTR const char*
271 #define wsprintf sprintf
273 #define _ftprintf fprintf
274 #define _tcslen strlen
277 #define LPSOCKADDR struct sockaddr *
279 // Default device for Linux and Android
280 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0
284 // ----------------------------------------------------------------------------
286 // ----------------------------------------------------------------------------
288 // Always excluded for Android builds
289 #undef WEBRTC_CODEC_ISAC
290 #undef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
292 #define ANDROID_NOT_SUPPORTED(stat) NOT_SUPPORTED(stat)
296 // ----------------------------------------------------------------------------
298 // ----------------------------------------------------------------------------
300 #define ANDROID_NOT_SUPPORTED(stat)
302 #endif // ANDROID - LINUX PC
305 #define ANDROID_NOT_SUPPORTED(stat)
306 #endif // #ifdef WEBRTC_LINUX
308 // *** WEBRTC_MAC ***
313 #include <AudioUnit/AudioUnit.h>
314 #include <arpa/inet.h>
317 #include <netinet/in.h>
323 #include <sys/socket.h>
324 #include <sys/stat.h>
325 #include <sys/time.h>
326 #include <sys/types.h>
329 #if !defined(WEBRTC_IOS)
330 #include <CoreServices/CoreServices.h>
331 #include <CoreAudio/CoreAudio.h>
332 #include <AudioToolbox/DefaultAudioOutput.h>
333 #include <AudioToolbox/AudioConverter.h>
334 #include <CoreAudio/HostTime.h>
337 #define DWORD unsigned long int
339 #define LPVOID void *
342 #define SOCKADDR_IN struct sockaddr_in
343 #define UINT unsigned int
344 #define UCHAR unsigned char
346 #define _stricmp strcasecmp
347 #define GetLastError() errno
348 #define WSAGetLastError() errno
349 #define LPCTSTR const char*
350 #define wsprintf sprintf
352 #define _ftprintf fprintf
353 #define _tcslen strlen
356 #define LPSOCKADDR struct sockaddr *
357 #define LPCSTR const char*
358 #define ULONG unsigned long
360 // Default device for Mac and iPhone
361 #define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0
364 #if defined(WEBRTC_IOS)
366 // ----------------------------------------------------------------------------
368 // ----------------------------------------------------------------------------
370 // Always excluded for iPhone builds
371 #undef WEBRTC_CODEC_ISAC
372 #undef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
374 #define IPHONE_NOT_SUPPORTED(stat) NOT_SUPPORTED(stat)
378 // ----------------------------------------------------------------------------
380 // ----------------------------------------------------------------------------
382 // ----------------------------------------------------------------------------
384 // ----------------------------------------------------------------------------
386 #define IPHONE_NOT_SUPPORTED(stat)
390 #define IPHONE_NOT_SUPPORTED(stat)
391 #endif // #ifdef WEBRTC_MAC
393 #endif // WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H