Clean out platform specific things from voice_engine_defines.h.

BUG=webrtc:4690

Review-Url: https://codereview.webrtc.org/2689183002
Cr-Commit-Position: refs/heads/master@{#16578}
This commit is contained in:
solenberg 2017-02-13 04:42:52 -08:00 committed by Commit bot
parent 552c7c70b0
commit 06f240bc4f
4 changed files with 12 additions and 227 deletions

View File

@ -35,7 +35,7 @@ namespace {
constexpr char kOpusCodecName[] = "opus";
bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) {
return (_stricmp(codec.plname, ref_name) == 0);
return (STR_CASE_CMP(codec.plname, ref_name) == 0);
}
} // namespace

View File

@ -31,7 +31,7 @@ class CodecTest : public AfterStreamingFixture {
};
static void SetRateIfILBC(webrtc::CodecInst* codec_instance, int packet_size) {
if (!_stricmp(codec_instance->plname, "ilbc")) {
if (!STR_CASE_CMP(codec_instance->plname, "ilbc")) {
if (packet_size == 160 || packet_size == 320) {
codec_instance->rate = 15200;
} else {
@ -41,9 +41,9 @@ static void SetRateIfILBC(webrtc::CodecInst* codec_instance, int packet_size) {
}
static bool IsNotViableSendCodec(const char* codec_name) {
return !_stricmp(codec_name, "CN") ||
!_stricmp(codec_name, "telephone-event") ||
!_stricmp(codec_name, "red");
return !STR_CASE_CMP(codec_name, "CN") ||
!STR_CASE_CMP(codec_name, "telephone-event") ||
!STR_CASE_CMP(codec_name, "red");
}
TEST_F(CodecTest, PcmuIsDefaultCodecAndHasTheRightValues) {
@ -138,7 +138,7 @@ TEST_F(CodecTest, VoiceActivityDetectionCanBeTurnedOff) {
TEST_F(CodecTest, OpusMaxPlaybackRateCanBeSet) {
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
voe_codec_->GetCodec(i, codec_instance_);
if (_stricmp("opus", codec_instance_.plname)) {
if (STR_CASE_CMP("opus", codec_instance_.plname)) {
continue;
}
voe_codec_->SetSendCodec(channel_, codec_instance_);
@ -154,7 +154,7 @@ TEST_F(CodecTest, OpusMaxPlaybackRateCanBeSet) {
TEST_F(CodecTest, OpusDtxCanBeSetForOpus) {
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
voe_codec_->GetCodec(i, codec_instance_);
if (_stricmp("opus", codec_instance_.plname)) {
if (STR_CASE_CMP("opus", codec_instance_.plname)) {
continue;
}
voe_codec_->SetSendCodec(channel_, codec_instance_);
@ -166,7 +166,7 @@ TEST_F(CodecTest, OpusDtxCanBeSetForOpus) {
TEST_F(CodecTest, OpusDtxCannotBeSetForNonOpus) {
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
voe_codec_->GetCodec(i, codec_instance_);
if (!_stricmp("opus", codec_instance_.plname)) {
if (!STR_CASE_CMP("opus", codec_instance_.plname)) {
continue;
}
voe_codec_->SetSendCodec(channel_, codec_instance_);

View File

@ -44,7 +44,7 @@ TEST_F(DtmfTest, ManualCanChangeDtmfPayloadType) {
// Start by modifying the receiving side.
for (int i = 0; i < voe_codec_->NumOfCodecs(); i++) {
EXPECT_EQ(0, voe_codec_->GetCodec(i, codec_instance));
if (!_stricmp("telephone-event", codec_instance.plname)) {
if (!STR_CASE_CMP("telephone-event", codec_instance.plname)) {
codec_instance.pltype = 88; // Use 88 instead of default 106.
EXPECT_EQ(0, voe_base_->StopSend(channel_));
EXPECT_EQ(0, voe_base_->StopPlayout(channel_));

View File

@ -10,7 +10,7 @@
/*
* This file contains common constants for VoiceEngine, as well as
* platform specific settings and include files.
* platform specific settings.
*/
#ifndef WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H
@ -20,16 +20,8 @@
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/typedefs.h"
// ----------------------------------------------------------------------------
// Enumerators
// ----------------------------------------------------------------------------
namespace webrtc {
// Internal buffer size required for mono audio, based on the highest sample
// rate voice engine supports (10 ms of audio at 192 kHz).
static const size_t kMaxMonoDataSizeSamples = 1920;
// VolumeControl
enum { kMinVolumeLevel = 0 };
enum { kMaxVolumeLevel = 255 };
@ -42,21 +34,8 @@ const float kMinOutputVolumePanning = 0.0f;
// Max scale factor for output volume panning
const float kMaxOutputVolumePanning = 1.0f;
// DTMF
enum { kMinDtmfEventCode = 0 }; // DTMF digit "0"
enum { kMaxDtmfEventCode = 15 }; // DTMF digit "D"
enum { kMinTelephoneEventCode = 0 }; // RFC4733 (Section 2.3.1)
enum { kMaxTelephoneEventCode = 255 }; // RFC4733 (Section 2.3.1)
enum { kMinTelephoneEventDuration = 100 };
enum { kMaxTelephoneEventDuration = 60000 }; // Actual limit is 2^16
enum { kMinTelephoneEventAttenuation = 0 }; // 0 dBm0
enum { kMaxTelephoneEventAttenuation = 36 }; // -36 dBm0
enum { kMinTelephoneEventSeparationMs = 100 }; // Min delta time between two
// telephone events
enum { kVoiceEngineMaxIpPacketSizeBytes = 1500 }; // assumes Ethernet
enum { kVoiceEngineMaxModuleVersionSize = 960 };
// Audio processing
const NoiseSuppression::Level kDefaultNsMode = NoiseSuppression::kModerate;
const GainControl::Mode kDefaultAgcMode =
@ -73,48 +52,12 @@ const bool kDefaultAgcState =
#endif
const GainControl::Mode kDefaultRxAgcMode = GainControl::kAdaptiveDigital;
// Codec
// Min init target rate for iSAC-wb
enum { kVoiceEngineMinIsacInitTargetRateBpsWb = 10000 };
// Max init target rate for iSAC-wb
enum { kVoiceEngineMaxIsacInitTargetRateBpsWb = 32000 };
// Min init target rate for iSAC-swb
enum { kVoiceEngineMinIsacInitTargetRateBpsSwb = 10000 };
// Max init target rate for iSAC-swb
enum { kVoiceEngineMaxIsacInitTargetRateBpsSwb = 56000 };
// Lowest max rate for iSAC-wb
enum { kVoiceEngineMinIsacMaxRateBpsWb = 32000 };
// Highest max rate for iSAC-wb
enum { kVoiceEngineMaxIsacMaxRateBpsWb = 53400 };
// Lowest max rate for iSAC-swb
enum { kVoiceEngineMinIsacMaxRateBpsSwb = 32000 };
// Highest max rate for iSAC-swb
enum { kVoiceEngineMaxIsacMaxRateBpsSwb = 107000 };
// Lowest max payload size for iSAC-wb
enum { kVoiceEngineMinIsacMaxPayloadSizeBytesWb = 120 };
// Highest max payload size for iSAC-wb
enum { kVoiceEngineMaxIsacMaxPayloadSizeBytesWb = 400 };
// Lowest max payload size for iSAC-swb
enum { kVoiceEngineMinIsacMaxPayloadSizeBytesSwb = 120 };
// Highest max payload size for iSAC-swb
enum { kVoiceEngineMaxIsacMaxPayloadSizeBytesSwb = 600 };
// VideoSync
// Lowest minimum playout delay
enum { kVoiceEngineMinMinPlayoutDelayMs = 0 };
// Highest minimum playout delay
enum { kVoiceEngineMaxMinPlayoutDelayMs = 10000 };
// Network
// Min packet-timeout time for received RTP packets
enum { kVoiceEngineMinPacketTimeoutSec = 1 };
// Max packet-timeout time for received RTP packets
enum { kVoiceEngineMaxPacketTimeoutSec = 150 };
// Min sample time for dead-or-alive detection
enum { kVoiceEngineMinSampleTimeSec = 1 };
// Max sample time for dead-or-alive detection
enum { kVoiceEngineMaxSampleTimeSec = 150 };
// RTP/RTCP
// Min 4-bit ID for RTP extension (see section 4.2 in RFC 5285)
enum { kVoiceEngineMinRtpExtensionId = 1 };
@ -123,37 +66,11 @@ enum { kVoiceEngineMaxRtpExtensionId = 14 };
} // namespace webrtc
// ----------------------------------------------------------------------------
// Macros
// ----------------------------------------------------------------------------
#define NOT_SUPPORTED(stat) \
LOG_F(LS_ERROR) << "not supported"; \
stat.SetLastError(VE_FUNC_NOT_SUPPORTED); \
return -1;
#if (!defined(NDEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
#include <windows.h>
#include <stdio.h>
#define DEBUG_PRINT(...) \
{ \
char msg[256]; \
sprintf(msg, __VA_ARGS__); \
OutputDebugStringA(msg); \
}
#else
// special fix for visual 2003
#define DEBUG_PRINT(exp) ((void)0)
#endif // !defined(NDEBUG) && defined(_WIN32)
#define CHECK_CHANNEL(channel) \
if (CheckChannel(channel) == -1) \
return -1;
// ----------------------------------------------------------------------------
// Inline functions
// ----------------------------------------------------------------------------
namespace webrtc {
inline int VoEId(int veId, int chId) {
@ -175,143 +92,11 @@ inline int VoEChannelId(int moduleId) {
} // namespace webrtc
// ----------------------------------------------------------------------------
// Platform settings
// ----------------------------------------------------------------------------
// *** WINDOWS ***
#if defined(_WIN32)
#include <windows.h>
#pragma comment(lib, "winmm.lib")
#ifndef WEBRTC_EXTERNAL_TRANSPORT
#pragma comment(lib, "ws2_32.lib")
#endif
// ----------------------------------------------------------------------------
// Defines
// ----------------------------------------------------------------------------
// Default device for Windows PC
#define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE \
AudioDeviceModule::kDefaultCommunicationDevice
#else
#define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0
#endif // #if (defined(_WIN32)
// *** LINUX ***
#ifdef WEBRTC_LINUX
#include <arpa/inet.h>
#include <netinet/in.h>
#include <pthread.h>
#include <sys/socket.h>
#include <sys/types.h>
#ifndef QNX
#include <linux/net.h>
#ifndef ANDROID
#include <sys/soundcard.h>
#endif // ANDROID
#endif // QNX
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#define DWORD unsigned long int
#define WINAPI
#define LPVOID void *
#define FALSE 0
#define TRUE 1
#define UINT unsigned int
#define UCHAR unsigned char
#define TCHAR char
#ifdef QNX
#define _stricmp stricmp
#else
#define _stricmp strcasecmp
#endif
#define GetLastError() errno
#define WSAGetLastError() errno
#define LPCTSTR const char *
#define LPCSTR const char *
#define wsprintf sprintf
#define TEXT(a) a
#define _ftprintf fprintf
#define _tcslen strlen
#define FAR
#define __cdecl
#define LPSOCKADDR struct sockaddr *
// Default device for Linux and Android
#define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0
#endif // #ifdef WEBRTC_LINUX
// *** WEBRTC_MAC ***
// including iPhone
#ifdef WEBRTC_MAC
#include <AudioUnit/AudioUnit.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#if !defined(WEBRTC_IOS)
#include <CoreServices/CoreServices.h>
#include <CoreAudio/CoreAudio.h>
#include <AudioToolbox/DefaultAudioOutput.h>
#include <AudioToolbox/AudioConverter.h>
#include <CoreAudio/HostTime.h>
#endif
#define DWORD unsigned long int
#define WINAPI
#define LPVOID void *
#define FALSE 0
#define TRUE 1
#define SOCKADDR_IN struct sockaddr_in
#define UINT unsigned int
#define UCHAR unsigned char
#define TCHAR char
#define _stricmp strcasecmp
#define GetLastError() errno
#define WSAGetLastError() errno
#define LPCTSTR const char *
#define wsprintf sprintf
#define TEXT(a) a
#define _ftprintf fprintf
#define _tcslen strlen
#define FAR
#define __cdecl
#define LPSOCKADDR struct sockaddr *
#define LPCSTR const char *
#define ULONG unsigned long
// Default device for Mac and iPhone
#define WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE 0
#endif // #ifdef WEBRTC_MAC
#endif // WEBRTC_VOICE_ENGINE_VOICE_ENGINE_DEFINES_H