Revert r4772 "Compile ACM1 and ACM2."

Breaks Android build.

TBR=turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2244004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4777 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org
2013-09-18 12:34:05 +00:00
parent 40d3fc65f5
commit 1c77dfd521
44 changed files with 679 additions and 140 deletions

View File

@@ -102,9 +102,26 @@
namespace webrtc { namespace webrtc {
// Not yet used payload-types. // We dynamically allocate some of the dynamic payload types to the defined
// 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, // codecs. Note! There are a limited number of payload types. If more codecs
// 67, 66, 65 // are defined they will receive reserved fixed payload types (values 69-95).
const int kDynamicPayloadtypes[ACMCodecDB::kMaxNumCodecs] = {
107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 92,
91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80,
79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68,
67, 66, 65
};
// Creates database with all supported codecs at compile time.
// Each entry needs the following parameters in the given order:
// payload type, name, sampling frequency, packet size in samples,
// number of channels, and default rate.
#if (defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) || \
defined(WEBRTC_CODEC_CELT) || defined(WEBRTC_CODEC_G722_1) || \
defined(WEBRTC_CODEC_G722_1C) || defined(WEBRTC_CODEC_G729_1) || \
defined(WEBRTC_CODEC_PCM16) || defined(WEBRTC_CODEC_SPEEX))
static int count_database = 0;
#endif
const CodecInst ACMCodecDB::database_[] = { const CodecInst ACMCodecDB::database_[] = {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
@@ -116,13 +133,13 @@ const CodecInst ACMCodecDB::database_[] = {
#endif #endif
#ifdef WEBRTC_CODEC_PCM16 #ifdef WEBRTC_CODEC_PCM16
// Mono // Mono
{107, "L16", 8000, 80, 1, 128000}, {kDynamicPayloadtypes[count_database++], "L16", 8000, 80, 1, 128000},
{108, "L16", 16000, 160, 1, 256000}, {kDynamicPayloadtypes[count_database++], "L16", 16000, 160, 1, 256000},
{109, "L16", 32000, 320, 1, 512000}, {kDynamicPayloadtypes[count_database++], "L16", 32000, 320, 1, 512000},
// Stereo // Stereo
{111, "L16", 8000, 80, 2, 128000}, {kDynamicPayloadtypes[count_database++], "L16", 8000, 80, 2, 128000},
{112, "L16", 16000, 160, 2, 256000}, {kDynamicPayloadtypes[count_database++], "L16", 16000, 160, 2, 256000},
{113, "L16", 32000, 320, 2, 512000}, {kDynamicPayloadtypes[count_database++], "L16", 32000, 320, 2, 512000},
#endif #endif
// G.711, PCM mu-law and A-law. // G.711, PCM mu-law and A-law.
// Mono // Mono
@@ -135,16 +152,16 @@ const CodecInst ACMCodecDB::database_[] = {
{102, "ILBC", 8000, 240, 1, 13300}, {102, "ILBC", 8000, 240, 1, 13300},
#endif #endif
#ifdef WEBRTC_CODEC_AMR #ifdef WEBRTC_CODEC_AMR
{114, "AMR", 8000, 160, 1, 12200}, {kDynamicPayloadtypes[count_database++], "AMR", 8000, 160, 1, 12200},
#endif #endif
#ifdef WEBRTC_CODEC_AMRWB #ifdef WEBRTC_CODEC_AMRWB
{115, "AMR-WB", 16000, 320, 1, 20000}, {kDynamicPayloadtypes[count_database++], "AMR-WB", 16000, 320, 1, 20000},
#endif #endif
#ifdef WEBRTC_CODEC_CELT #ifdef WEBRTC_CODEC_CELT
// Mono // Mono
{116, "CELT", 32000, 640, 1, 64000}, {kDynamicPayloadtypes[count_database++], "CELT", 32000, 640, 1, 64000},
// Stereo // Stereo
{117, "CELT", 32000, 640, 2, 64000}, {kDynamicPayloadtypes[count_database++], "CELT", 32000, 640, 2, 64000},
#endif #endif
#ifdef WEBRTC_CODEC_G722 #ifdef WEBRTC_CODEC_G722
// Mono // Mono
@@ -153,20 +170,20 @@ const CodecInst ACMCodecDB::database_[] = {
{119, "G722", 16000, 320, 2, 64000}, {119, "G722", 16000, 320, 2, 64000},
#endif #endif
#ifdef WEBRTC_CODEC_G722_1 #ifdef WEBRTC_CODEC_G722_1
{92, "G7221", 16000, 320, 1, 32000}, {kDynamicPayloadtypes[count_database++], "G7221", 16000, 320, 1, 32000},
{91, "G7221", 16000, 320, 1, 24000}, {kDynamicPayloadtypes[count_database++], "G7221", 16000, 320, 1, 24000},
{90, "G7221", 16000, 320, 1, 16000}, {kDynamicPayloadtypes[count_database++], "G7221", 16000, 320, 1, 16000},
#endif #endif
#ifdef WEBRTC_CODEC_G722_1C #ifdef WEBRTC_CODEC_G722_1C
{89, "G7221", 32000, 640, 1, 48000}, {kDynamicPayloadtypes[count_database++], "G7221", 32000, 640, 1, 48000},
{88, "G7221", 32000, 640, 1, 32000}, {kDynamicPayloadtypes[count_database++], "G7221", 32000, 640, 1, 32000},
{87, "G7221", 32000, 640, 1, 24000}, {kDynamicPayloadtypes[count_database++], "G7221", 32000, 640, 1, 24000},
#endif #endif
#ifdef WEBRTC_CODEC_G729 #ifdef WEBRTC_CODEC_G729
{18, "G729", 8000, 240, 1, 8000}, {18, "G729", 8000, 240, 1, 8000},
#endif #endif
#ifdef WEBRTC_CODEC_G729_1 #ifdef WEBRTC_CODEC_G729_1
{86, "G7291", 16000, 320, 1, 32000}, {kDynamicPayloadtypes[count_database++], "G7291", 16000, 320, 1, 32000},
#endif #endif
#ifdef WEBRTC_CODEC_GSMFR #ifdef WEBRTC_CODEC_GSMFR
{3, "GSM", 8000, 160, 1, 13200}, {3, "GSM", 8000, 160, 1, 13200},
@@ -177,16 +194,14 @@ const CodecInst ACMCodecDB::database_[] = {
{120, "opus", 48000, 960, 2, 64000}, {120, "opus", 48000, 960, 2, 64000},
#endif #endif
#ifdef WEBRTC_CODEC_SPEEX #ifdef WEBRTC_CODEC_SPEEX
{85, "speex", 8000, 160, 1, 11000}, {kDynamicPayloadtypes[count_database++], "speex", 8000, 160, 1, 11000},
{84, "speex", 16000, 320, 1, 22000}, {kDynamicPayloadtypes[count_database++], "speex", 16000, 320, 1, 22000},
#endif #endif
// Comfort noise for four different sampling frequencies. // Comfort noise for four different sampling frequencies.
{13, "CN", 8000, 240, 1, 0}, {13, "CN", 8000, 240, 1, 0},
{98, "CN", 16000, 480, 1, 0}, {98, "CN", 16000, 480, 1, 0},
{99, "CN", 32000, 960, 1, 0}, {99, "CN", 32000, 960, 1, 0},
#ifdef ENABLE_48000_HZ
{100, "CN", 48000, 1440, 1, 0}, {100, "CN", 48000, 1440, 1, 0},
#endif
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
{106, "telephone-event", 8000, 240, 1, 0}, {106, "telephone-event", 8000, 240, 1, 0},
#endif #endif
@@ -280,9 +295,7 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
{1, {240}, 240, 1, false}, {1, {240}, 240, 1, false},
{1, {480}, 480, 1, false}, {1, {480}, 480, 1, false},
{1, {960}, 960, 1, false}, {1, {960}, 960, 1, false},
#ifdef ENABLE_48000_HZ
{1, {1440}, 1440, 1, false}, {1, {1440}, 1440, 1, false},
#endif
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
{1, {240}, 240, 1, false}, {1, {240}, 240, 1, false},
#endif #endif
@@ -370,10 +383,8 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = {
// Comfort noise for three different sampling frequencies. // Comfort noise for three different sampling frequencies.
kDecoderCNGnb, kDecoderCNGnb,
kDecoderCNGwb, kDecoderCNGwb,
kDecoderCNGswb32kHz kDecoderCNGswb32kHz,
#ifdef ENABLE_48000_HZ kDecoderCNGswb48kHz
, kDecoderCNGswb48kHz
#endif
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
, kDecoderAVT , kDecoderAVT
#endif #endif
@@ -699,12 +710,10 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst& codec_inst) {
codec_id = kCNSWB; codec_id = kCNSWB;
break; break;
} }
#ifdef ENABLE_48000_HZ
case 48000: { case 48000: {
codec_id = kCNFB; codec_id = kCNFB;
break; break;
} }
#endif
default: { default: {
return NULL; return NULL;
} }
@@ -756,12 +765,10 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst& codec_inst) {
codec_id = kCNSWB; codec_id = kCNSWB;
break; break;
} }
#ifdef ENABLE_48000_HZ
case 48000: { case 48000: {
codec_id = kCNFB; codec_id = kCNFB;
break; break;
} }
#endif
default: { default: {
return NULL; return NULL;
} }

View File

@@ -103,9 +103,7 @@ class ACMCodecDB {
, kCNNB , kCNNB
, kCNWB , kCNWB
, kCNSWB , kCNSWB
#ifdef ENABLE_48000_HZ
, kCNFB , kCNFB
#endif
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
, kAVT , kAVT
#endif #endif
@@ -189,9 +187,6 @@ class ACMCodecDB {
#ifndef WEBRTC_CODEC_RED #ifndef WEBRTC_CODEC_RED
enum {kRED = -1}; enum {kRED = -1};
#endif #endif
#ifndef ENABLE_48000_HZ
enum { kCNFB = -1 };
#endif
// kMaxNumCodecs - Maximum number of codecs that can be activated in one // kMaxNumCodecs - Maximum number of codecs that can be activated in one
// build. // build.

View File

@@ -24,13 +24,22 @@
#error iSAC and iSACFX codecs cannot be enabled at the same time #error iSAC and iSACFX codecs cannot be enabled at the same time
#endif #endif
#ifndef STR_CASE_CMP
#ifdef WIN32
// OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x, y) ::_stricmp(x, y)
#else
// OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x, y) ::strcasecmp(x, y)
#endif
#endif
namespace webrtc { namespace webrtc {
// 60 ms is the maximum block size we support. An extra 20 ms is considered // 60 ms is the maximum block size we support. An extra 20 ms is considered
// for safety if process() method is not called when it should be, i.e. we // for safety if process() method is not called when it should be, i.e. we
// accept 20 ms of jitter. 80 ms @ 48 kHz (full-band) stereo is 7680 samples. // accept 20 ms of jitter. 80 ms @ 32 kHz (super wide-band) is 2560 samples.
#define AUDIO_BUFFER_SIZE_W16 7680 #define AUDIO_BUFFER_SIZE_W16 2560
// There is one timestamp per each 10 ms of audio // There is one timestamp per each 10 ms of audio
// the audio buffer, at max, may contain 32 blocks of 10ms // the audio buffer, at max, may contain 32 blocks of 10ms
@@ -84,17 +93,6 @@ struct WebRtcACMCodecParams {
ACMVADMode vad_mode; ACMVADMode vad_mode;
}; };
// TODO(turajs): Remove when ACM1 is removed.
struct WebRtcACMAudioBuff {
int16_t in_audio[AUDIO_BUFFER_SIZE_W16];
int16_t in_audio_ix_read;
int16_t in_audio_ix_write;
uint32_t in_timestamp[TIMESTAMP_BUFFER_SIZE_W32];
int16_t in_timestamp_ix_write;
uint32_t last_timestamp;
uint32_t last_in_timestamp;
};
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_COMMON_DEFS_H_ #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_COMMON_DEFS_H_

View File

@@ -301,7 +301,7 @@ class AcmAudioDecoderIsac : public AudioDecoder {
uint32_t arrival_timestamp) { uint32_t arrival_timestamp) {
return ACM_ISAC_DECODE_BWE(static_cast<ACM_ISAC_STRUCT*>(state_), return ACM_ISAC_DECODE_BWE(static_cast<ACM_ISAC_STRUCT*>(state_),
reinterpret_cast<const uint16_t*>(payload), reinterpret_cast<const uint16_t*>(payload),
static_cast<uint32_t>(payload_len), payload_len,
rtp_sequence_number, rtp_sequence_number,
rtp_timestamp, rtp_timestamp,
arrival_timestamp); arrival_timestamp);
@@ -311,7 +311,7 @@ class AcmAudioDecoderIsac : public AudioDecoder {
size_t encoded_len, int16_t* decoded, size_t encoded_len, int16_t* decoded,
SpeechType* speech_type) { SpeechType* speech_type) {
int16_t temp_type = 1; // Default is speech. int16_t temp_type = 1; // Default is speech.
int16_t ret = ACM_ISAC_DECODERCU(static_cast<ACM_ISAC_STRUCT*>(state_), int16_t ret = ACM_ISAC_DECODERCU(static_cast<ISACStruct*>(state_),
reinterpret_cast<const uint16_t*>(encoded), reinterpret_cast<const uint16_t*>(encoded),
static_cast<int16_t>(encoded_len), decoded, static_cast<int16_t>(encoded_len), decoded,
&temp_type); &temp_type);

View File

@@ -179,7 +179,7 @@ int AcmReceiver::SetInitialDelay(int delay_ms) {
// improve performance. Here, this call has to be placed before the following // improve performance. Here, this call has to be placed before the following
// block, therefore, we keep it inside critical section. Otherwise, we have to // block, therefore, we keep it inside critical section. Otherwise, we have to
// release |neteq_crit_sect_| and acquire it again, which seems an overkill. // release |neteq_crit_sect_| and acquire it again, which seems an overkill.
if (!neteq_->SetMinimumDelay(delay_ms)) if (neteq_->SetMinimumDelay(delay_ms) < 0)
return -1; return -1;
const int kLatePacketThreshold = 5; const int kLatePacketThreshold = 5;
@@ -620,7 +620,7 @@ void AcmReceiver::NetworkStatistics(ACMNetworkStatistics* acm_stat) {
acm_stat->currentBufferSize = neteq_stat.current_buffer_size_ms; acm_stat->currentBufferSize = neteq_stat.current_buffer_size_ms;
acm_stat->preferredBufferSize = neteq_stat.preferred_buffer_size_ms; acm_stat->preferredBufferSize = neteq_stat.preferred_buffer_size_ms;
acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false; acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found;
acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate; acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate;
acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate; acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate;
acm_stat->currentExpandRate = neteq_stat.expand_rate; acm_stat->currentExpandRate = neteq_stat.expand_rate;
@@ -745,7 +745,7 @@ bool AcmReceiver::GetSilence(int desired_sample_rate_hz, AudioFrame* frame) {
int max_num_packets; int max_num_packets;
int buffer_size_byte; int buffer_size_byte;
int max_buffer_size_byte; int max_buffer_size_byte;
const float kBufferingThresholdScale = 0.9f; const float kBufferingThresholdScale = 0.9;
neteq_->PacketBufferStatistics(&num_packets, &max_num_packets, neteq_->PacketBufferStatistics(&num_packets, &max_num_packets,
&buffer_size_byte, &max_buffer_size_byte); &buffer_size_byte, &max_buffer_size_byte);
if (num_packets > max_num_packets * kBufferingThresholdScale || if (num_packets > max_num_packets * kBufferingThresholdScale ||

View File

@@ -13,24 +13,18 @@
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h" #include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h"
#include "webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
// Create module // Create module
AudioCodingModule* AudioCodingModule::Create(int id) { AudioCodingModule* AudioCodingModule::Create(int id) {
return new acm1::AudioCodingModuleImpl(id, Clock::GetRealTimeClock()); return new AudioCodingModuleImpl(id);
}
AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
return new acm1::AudioCodingModuleImpl(id, clock);
} }
// Destroy module // Destroy module
void AudioCodingModule::Destroy(AudioCodingModule* module) { void AudioCodingModule::Destroy(AudioCodingModule* module) {
delete module; delete static_cast<AudioCodingModuleImpl*>(module);
} }
// Get number of supported codecs // Get number of supported codecs
@@ -96,12 +90,11 @@ bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
} }
} }
AudioCodingModule* AudioCodingModuleFactory::Create(int id) const { AudioCodingModule* AudioCodingModuleFactory::Create(const int32_t id) const {
return new acm1::AudioCodingModuleImpl(static_cast<int32_t>(id), return NULL;
Clock::GetRealTimeClock());
} }
AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const { AudioCodingModule* NewAudioCodingModuleFactory::Create(const int32_t id) const {
return new AudioCodingModuleImpl(id); return new AudioCodingModuleImpl(id);
} }

View File

@@ -16,7 +16,6 @@
], ],
'dependencies': [ 'dependencies': [
'<@(audio_coding_dependencies)', '<@(audio_coding_dependencies)',
'NetEq4',
], ],
'include_dirs': [ 'include_dirs': [
'../interface', '../interface',
@@ -41,7 +40,6 @@
'acm_cng.h', 'acm_cng.h',
'acm_codec_database.cc', 'acm_codec_database.cc',
'acm_codec_database.h', 'acm_codec_database.h',
'acm_common_defs.h',
'acm_dtmf_playout.cc', 'acm_dtmf_playout.cc',
'acm_dtmf_playout.h', 'acm_dtmf_playout.h',
'acm_g722.cc', 'acm_g722.cc',

View File

@@ -153,6 +153,7 @@ void InitialDelayManager::RecordLastPacket(const WebRtcRTPHeader& rtp_info,
void InitialDelayManager::LatePackets( void InitialDelayManager::LatePackets(
uint32_t timestamp_now, SyncStream* sync_stream) { uint32_t timestamp_now, SyncStream* sync_stream) {
assert(sync_stream); assert(sync_stream);
const int kLateThreshold = 5;
sync_stream->num_sync_packets = 0; sync_stream->num_sync_packets = 0;
// If there is no estimate of timestamp increment, |timestamp_step_|, then // If there is no estimate of timestamp increment, |timestamp_step_|, then
@@ -170,7 +171,7 @@ void InitialDelayManager::LatePackets(
int num_late_packets = (timestamp_now - last_receive_timestamp_) / int num_late_packets = (timestamp_now - last_receive_timestamp_) /
timestamp_step_; timestamp_step_;
if (num_late_packets < late_packet_threshold_) if (num_late_packets < kLateThreshold)
return; return;
int sync_offset = 1; // One gap at the end of the sync-stream. int sync_offset = 1; // One gap at the end of the sync-stream.

View File

@@ -85,8 +85,8 @@ class AudioCodingModule: public Module {
// injected into ACM. ACM will take the owner ship of the object clock and // injected into ACM. ACM will take the owner ship of the object clock and
// delete it when destroyed. // delete it when destroyed.
// //
static AudioCodingModule* Create(int id); static AudioCodingModule* Create(const int32_t id);
static AudioCodingModule* Create(int id, Clock* clock); static AudioCodingModule* Create(const int32_t id, Clock* clock);
virtual ~AudioCodingModule() {}; virtual ~AudioCodingModule() {};
// TODO(ajm): Deprecated. Remove all calls to this unneeded method. // TODO(ajm): Deprecated. Remove all calls to this unneeded method.
@@ -103,7 +103,7 @@ class AudioCodingModule: public Module {
// Return value: // Return value:
// number of supported codecs. // number of supported codecs.
/// ///
static int NumberOfCodecs(); static uint8_t NumberOfCodecs();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t Codec() // int32_t Codec()
@@ -120,7 +120,7 @@ class AudioCodingModule: public Module {
// -1 if the list number (list_id) is invalid. // -1 if the list number (list_id) is invalid.
// 0 if succeeded. // 0 if succeeded.
// //
static int Codec(int list_id, CodecInst* codec); static int32_t Codec(uint8_t list_id, CodecInst* codec);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t Codec() // int32_t Codec()
@@ -141,7 +141,7 @@ class AudioCodingModule: public Module {
// -1 if no codec matches the given parameters. // -1 if no codec matches the given parameters.
// 0 if succeeded. // 0 if succeeded.
// //
static int Codec(const char* payload_name, CodecInst* codec, static int32_t Codec(const char* payload_name, CodecInst* codec,
int sampling_freq_hz, int channels); int sampling_freq_hz, int channels);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -160,7 +160,7 @@ class AudioCodingModule: public Module {
// if the codec is found, the index of the codec in the list, // if the codec is found, the index of the codec in the list,
// -1 if the codec is not found. // -1 if the codec is not found.
// //
static int Codec(const char* payload_name, int sampling_freq_hz, static int32_t Codec(const char* payload_name, int sampling_freq_hz,
int channels); int channels);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -582,8 +582,8 @@ class AudioCodingModule: public Module {
// -1 if fails to unregister. // -1 if fails to unregister.
// 0 if the given codec is successfully unregistered. // 0 if the given codec is successfully unregistered.
// //
virtual int UnregisterReceiveCodec( virtual int32_t UnregisterReceiveCodec(
uint8_t payload_type) = 0; const int16_t payload_type) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t ReceiveCodec() // int32_t ReceiveCodec()
@@ -682,6 +682,29 @@ class AudioCodingModule: public Module {
// //
virtual int LeastRequiredDelayMs() const = 0; virtual int LeastRequiredDelayMs() const = 0;
///////////////////////////////////////////////////////////////////////////
// int32_t RegisterIncomingMessagesCallback()
// Used by the module to deliver messages to the codec module/application
// when a DTMF tone is detected, as well as when it stopped.
//
// Inputs:
// -in_message_callback: pointer to callback function which will be called
// if DTMF is detected.
// -cpt : enables CPT (Call Progress Tone) detection for the
// specified country. c.f. definition of ACMCountries
// in audio_coding_module_typedefs.h for valid
// entries. The default value disables CPT
// detection.
//
// Return value:
// -1 if the message callback could not be registered
// 0 if registration is successful.
//
virtual int32_t
RegisterIncomingMessagesCallback(
AudioCodingFeedback* in_message_callback,
const ACMCountries cpt = ACMDisableCountryDetection) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t SetDtmfPlayoutStatus() // int32_t SetDtmfPlayoutStatus()
// Configure DTMF playout, i.e. whether out-of-band // Configure DTMF playout, i.e. whether out-of-band
@@ -707,6 +730,39 @@ class AudioCodingModule: public Module {
// //
virtual bool DtmfPlayoutStatus() const = 0; virtual bool DtmfPlayoutStatus() const = 0;
///////////////////////////////////////////////////////////////////////////
// int32_t SetBackgroundNoiseMode()
// Sets the mode of the background noise playout in an event of long
// packet loss burst. For the valid modes see the declaration of
// ACMBackgroundNoiseMode in audio_coding_module_typedefs.h.
//
// Input:
// -mode : the mode for the background noise playout.
//
// Return value:
// -1 if failed to set the mode.
// 0 if succeeded in setting the mode.
//
virtual int32_t SetBackgroundNoiseMode(
const ACMBackgroundNoiseMode mode) = 0;
///////////////////////////////////////////////////////////////////////////
// int32_t BackgroundNoiseMode()
// Call this method to get the mode of the background noise playout.
// Playout of background noise is a result of a long packet loss burst.
// See ACMBackgroundNoiseMode in audio_coding_module_typedefs.h for
// possible modes.
//
// Output:
// -mode : a reference to ACMBackgroundNoiseMode enumerator.
//
// Return value:
// 0 if the output is a valid mode.
// -1 if ACM failed to output a valid mode.
//
// TODO(tlegrand): Change function to return the mode.
virtual int32_t BackgroundNoiseMode(ACMBackgroundNoiseMode* mode) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t PlayoutTimestamp() // int32_t PlayoutTimestamp()
// The send timestamp of an RTP packet is associated with the decoded // The send timestamp of an RTP packet is associated with the decoded
@@ -796,6 +852,39 @@ class AudioCodingModule: public Module {
virtual int32_t PlayoutData10Ms(int32_t desired_freq_hz, virtual int32_t PlayoutData10Ms(int32_t desired_freq_hz,
AudioFrame* audio_frame) = 0; AudioFrame* audio_frame) = 0;
///////////////////////////////////////////////////////////////////////////
// (CNG) Comfort Noise Generation
// Generate comfort noise when receiving DTX packets
//
///////////////////////////////////////////////////////////////////////////
// int16_t SetReceiveVADMode()
// Configure VAD aggressiveness on the incoming stream.
//
// Input:
// -mode : aggressiveness of the VAD on incoming stream.
// See audio_coding_module_typedefs.h for the
// definition of ACMVADMode, and possible
// values for aggressiveness.
//
// Return value:
// -1 if fails to set the mode,
// 0 if the mode is set successfully.
//
virtual int16_t SetReceiveVADMode(const ACMVADMode mode) = 0;
///////////////////////////////////////////////////////////////////////////
// ACMVADMode ReceiveVADMode()
// Get VAD aggressiveness on the incoming stream.
//
// Return value:
// aggressiveness of VAD, running on the incoming stream. A more
// aggressive mode means more audio frames will be labeled as in-active.
// See audio_coding_module_typedefs.h for the definition of
// ACMVADMode.
//
virtual ACMVADMode ReceiveVADMode() const = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Codec specific // Codec specific
// //
@@ -815,7 +904,8 @@ class AudioCodingModule: public Module {
// -1 if failed to set the maximum rate. // -1 if failed to set the maximum rate.
// 0 if the maximum rate is set successfully. // 0 if the maximum rate is set successfully.
// //
virtual int SetISACMaxRate(int max_rate_bps) = 0; virtual int32_t SetISACMaxRate(
const uint32_t max_rate_bps) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t SetISACMaxPayloadSize() // int32_t SetISACMaxPayloadSize()
@@ -832,7 +922,8 @@ class AudioCodingModule: public Module {
// -1 if failed to set the maximum payload-size. // -1 if failed to set the maximum payload-size.
// 0 if the given length is set successfully. // 0 if the given length is set successfully.
// //
virtual int SetISACMaxPayloadSize(int max_payload_len_bytes) = 0; virtual int32_t SetISACMaxPayloadSize(
const uint16_t max_payload_len_bytes) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t ConfigISACBandwidthEstimator() // int32_t ConfigISACBandwidthEstimator()
@@ -859,9 +950,9 @@ class AudioCodingModule: public Module {
// 0 if the configuration was successfully applied. // 0 if the configuration was successfully applied.
// //
virtual int32_t ConfigISACBandwidthEstimator( virtual int32_t ConfigISACBandwidthEstimator(
int init_frame_size_ms, const uint8_t init_frame_size_ms,
int init_rate_bps, const uint16_t init_rate_bps,
bool enforce_frame_size = false) = 0; const bool enforce_frame_size = false) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// statistics // statistics
@@ -869,8 +960,7 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t NetworkStatistics() // int32_t NetworkStatistics()
// Get network statistics. Note that the internal statistics of NetEq are // Get network statistics.
// reset by this call.
// //
// Input: // Input:
// -network_statistics : a structure that contains network statistics. // -network_statistics : a structure that contains network statistics.
@@ -880,7 +970,7 @@ class AudioCodingModule: public Module {
// 0 if statistics are set successfully. // 0 if statistics are set successfully.
// //
virtual int32_t NetworkStatistics( virtual int32_t NetworkStatistics(
ACMNetworkStatistics* network_statistics) = 0; ACMNetworkStatistics* network_statistics) const = 0;
// //
// Set an initial delay for playout. // Set an initial delay for playout.

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_amr.h" #include "webrtc/modules/audio_coding/main/source/acm_amr.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_amrwb.h" #include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -10,7 +10,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_celt.h" #include "webrtc/modules/audio_coding/main/source/acm_celt.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -12,7 +12,7 @@
#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h" #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -17,7 +17,7 @@
// references, where appropriate. // references, where appropriate.
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"
// Includes needed to create the codecs. // Includes needed to create the codecs.

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#include <string.h>
#include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "webrtc/typedefs.h"
// Checks for enabled codecs, we prevent enabling codecs which are not
// compatible.
#if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX))
#error iSAC and iSACFX codecs cannot be enabled at the same time
#endif
namespace webrtc {
namespace acm1 {
// 60 ms is the maximum block size we support. An extra 20 ms is considered
// for safety if process() method is not called when it should be, i.e. we
// accept 20 ms of jitter. 80 ms @ 48 kHz (full-band) stereo is 7680 samples.
#define AUDIO_BUFFER_SIZE_W16 7680
// There is one timestamp per each 10 ms of audio
// the audio buffer, at max, may contain 32 blocks of 10ms
// audio if the sampling frequency is 8000 Hz (80 samples per block).
// Therefore, The size of the buffer where we keep timestamps
// is defined as follows
#define TIMESTAMP_BUFFER_SIZE_W32 (AUDIO_BUFFER_SIZE_W16/80)
// The maximum size of a payload, that is 60 ms of PCM-16 @ 32 kHz stereo
#define MAX_PAYLOAD_SIZE_BYTE 7680
// General codec specific defines
const int kIsacWbDefaultRate = 32000;
const int kIsacSwbDefaultRate = 56000;
const int kIsacPacSize480 = 480;
const int kIsacPacSize960 = 960;
const int kIsacPacSize1440 = 1440;
// An encoded bit-stream is labeled by one of the following enumerators.
//
// kNoEncoding : There has been no encoding.
// kActiveNormalEncoded : Active audio frame coded by the codec.
// kPassiveNormalEncoded : Passive audio frame coded by the codec.
// kPassiveDTXNB : Passive audio frame coded by narrow-band CN.
// kPassiveDTXWB : Passive audio frame coded by wide-band CN.
// kPassiveDTXSWB : Passive audio frame coded by super-wide-band CN.
// kPassiveDTXFB : Passive audio frame coded by full-band CN.
enum WebRtcACMEncodingType {
kNoEncoding,
kActiveNormalEncoded,
kPassiveNormalEncoded,
kPassiveDTXNB,
kPassiveDTXWB,
kPassiveDTXSWB,
kPassiveDTXFB
};
// A structure which contains codec parameters. For instance, used when
// initializing encoder and decoder.
//
// codec_inst: c.f. common_types.h
// enable_dtx: set true to enable DTX. If codec does not have
// internal DTX, this will enable VAD.
// enable_vad: set true to enable VAD.
// vad_mode: VAD mode, c.f. audio_coding_module_typedefs.h
// for possible values.
struct WebRtcACMCodecParams {
CodecInst codec_inst;
bool enable_dtx;
bool enable_vad;
ACMVADMode vad_mode;
};
// A structure that encapsulates audio buffer and related parameters
// used for synchronization of audio of two ACMs.
//
// in_audio: same as ACMGenericCodec::in_audio_
// in_audio_ix_read: same as ACMGenericCodec::in_audio_ix_read_
// in_audio_ix_write: same as ACMGenericCodec::in_audio_ix_write_
// in_timestamp: same as ACMGenericCodec::in_timestamp_
// in_timestamp_ix_write: same as ACMGenericCodec::in_timestamp_ix_write_
// last_timestamp: same as ACMGenericCodec::last_timestamp_
// last_in_timestamp: same as AudioCodingModuleImpl::last_in_timestamp_
//
struct WebRtcACMAudioBuff {
int16_t in_audio[AUDIO_BUFFER_SIZE_W16];
int16_t in_audio_ix_read;
int16_t in_audio_ix_write;
uint32_t in_timestamp[TIMESTAMP_BUFFER_SIZE_W32];
int16_t in_timestamp_ix_write;
uint32_t last_timestamp;
uint32_t last_in_timestamp;
};
} // namespace acm1
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_

View File

@@ -10,7 +10,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_playout.h" #include "webrtc/modules/audio_coding/main/source/acm_dtmf_playout.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -12,7 +12,7 @@
#include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h" #include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_g7221.h" #include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_g7221c.h" #include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -10,7 +10,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_g729.h" #include "webrtc/modules/audio_coding/main/source/acm_g729.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -10,7 +10,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_g7291.h" #include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -16,7 +16,7 @@
#include "webrtc/common_audio/vad/include/webrtc_vad.h" #include "webrtc/common_audio/vad/include/webrtc_vad.h"
#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h" #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"

View File

@@ -12,7 +12,7 @@
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_ #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"

View File

@@ -10,7 +10,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h" #include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -9,7 +9,7 @@
*/ */
#include "webrtc/modules/audio_coding/main/source/acm_ilbc.h" #include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -10,7 +10,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_isac.h" #include "webrtc/modules/audio_coding/main/source/acm_isac.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_opus.h" #include "webrtc/modules/audio_coding/main/source/acm_opus.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h" #include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_pcma.h" #include "webrtc/modules/audio_coding/main/source/acm_pcma.h"
#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h" #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_pcmu.h" #include "webrtc/modules/audio_coding/main/source/acm_pcmu.h"
#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h" #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -10,7 +10,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_red.h" #include "webrtc/modules/audio_coding/main/source/acm_red.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -11,7 +11,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_speex.h" #include "webrtc/modules/audio_coding/main/source/acm_speex.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h" #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"

View File

@@ -0,0 +1,112 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
#include "webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
// Create module
AudioCodingModule* AudioCodingModule::Create(const int32_t id) {
return new acm1::AudioCodingModuleImpl(id, Clock::GetRealTimeClock());
}
// Used for testing by inserting a simulated clock. ACM will not destroy the
// injected |clock| the client has to take care of that.
AudioCodingModule* AudioCodingModule::Create(const int32_t id,
Clock* clock) {
return new acm1::AudioCodingModuleImpl(id, clock);
}
// Destroy module
void AudioCodingModule::Destroy(AudioCodingModule* module) {
delete static_cast<acm1::AudioCodingModuleImpl*>(module);
}
// Get number of supported codecs
uint8_t AudioCodingModule::NumberOfCodecs() {
return static_cast<uint8_t>(acm1::ACMCodecDB::kNumCodecs);
}
// Get supported codec param with id
int32_t AudioCodingModule::Codec(uint8_t list_id,
CodecInst* codec) {
// Get the codec settings for the codec with the given list ID
return acm1::ACMCodecDB::Codec(list_id, codec);
}
// Get supported codec Param with name, frequency and number of channels.
int32_t AudioCodingModule::Codec(const char* payload_name,
CodecInst* codec, int sampling_freq_hz,
int channels) {
int codec_id;
// Get the id of the codec from the database.
codec_id = acm1::ACMCodecDB::CodecId(payload_name, sampling_freq_hz,
channels);
if (codec_id < 0) {
// We couldn't find a matching codec, set the parameters to unacceptable
// values and return.
codec->plname[0] = '\0';
codec->pltype = -1;
codec->pacsize = 0;
codec->rate = 0;
codec->plfreq = 0;
return -1;
}
// Get default codec settings.
acm1::ACMCodecDB::Codec(codec_id, codec);
// Keep the number of channels from the function call. For most codecs it
// will be the same value as in default codec settings, but not for all.
codec->channels = channels;
return 0;
}
// Get supported codec Index with name, frequency and number of channels.
int32_t AudioCodingModule::Codec(const char* payload_name,
int sampling_freq_hz, int channels) {
return acm1::ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels);
}
// Checks the validity of the parameters of the given codec
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
int mirror_id;
int codec_number = acm1::ACMCodecDB::CodecNumber(&codec, &mirror_id);
if (codec_number < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1,
"Invalid codec settings.");
return false;
} else {
return true;
}
}
AudioCodingModule* AudioCodingModuleFactory::Create(int id) const {
return new acm1::AudioCodingModuleImpl(static_cast<int32_t>(id),
Clock::GetRealTimeClock());
}
AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const {
// TODO(minyue): return new AudioCodingModuleImpl (new version).
return NULL;
}
} // namespace webrtc

View File

@@ -37,7 +37,6 @@
], ],
'dependencies': [ 'dependencies': [
'<@(audio_coding_dependencies)', '<@(audio_coding_dependencies)',
'acm2',
], ],
'include_dirs': [ 'include_dirs': [
'../interface', '../interface',
@@ -101,6 +100,7 @@
'acm_red.h', 'acm_red.h',
'acm_resampler.cc', 'acm_resampler.cc',
'acm_resampler.h', 'acm_resampler.h',
'audio_coding_module.cc',
'audio_coding_module_impl.cc', 'audio_coding_module_impl.cc',
'audio_coding_module_impl.h', 'audio_coding_module_impl.h',
'nack.cc', 'nack.cc',
@@ -146,7 +146,4 @@
], ],
}], }],
], ],
'includes': [
'../acm2/audio_coding_module.gypi',
],
} }

View File

@@ -17,7 +17,7 @@
#include "webrtc/engine_configurations.h" #include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h" #include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
#include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h" #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
#include "webrtc/modules/audio_coding/main/source/acm_resampler.h" #include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
@@ -1262,6 +1262,64 @@ int32_t AudioCodingModuleImpl::RegisterTransportCallback(
return 0; return 0;
} }
// Used by the module to deliver messages to the codec module/application
// AVT(DTMF).
int32_t AudioCodingModuleImpl::RegisterIncomingMessagesCallback(
#ifndef WEBRTC_DTMF_DETECTION
AudioCodingFeedback* /* incoming_message */,
const ACMCountries /* cpt */) {
return -1;
#else
AudioCodingFeedback* incoming_message,
const ACMCountries cpt) {
int16_t status = 0;
// Enter the critical section for callback.
{
CriticalSectionScoped lock(callback_crit_sect_);
dtmf_callback_ = incoming_message;
}
// Enter the ACM critical section to set up the DTMF class.
{
CriticalSectionScoped lock(acm_crit_sect_);
// Check if the call is to disable or enable the callback.
if (incoming_message == NULL) {
// Callback is disabled, delete DTMF-detector class.
if (dtmf_detector_ != NULL) {
delete dtmf_detector_;
dtmf_detector_ = NULL;
}
status = 0;
} else {
status = 0;
if (dtmf_detector_ == NULL) {
dtmf_detector_ = new ACMDTMFDetection;
if (dtmf_detector_ == NULL) {
status = -1;
}
}
if (status >= 0) {
status = dtmf_detector_->Enable(cpt);
if (status < 0) {
// Failed to initialize if DTMF-detection was not enabled before,
// delete the class, and set the callback to NULL and return -1.
delete dtmf_detector_;
dtmf_detector_ = NULL;
}
}
}
}
// Check if we failed in setting up the DTMF-detector class.
if ((status < 0)) {
// We failed, we cannot have the callback.
CriticalSectionScoped lock(callback_crit_sect_);
dtmf_callback_ = NULL;
}
return status;
#endif
}
// Add 10MS of raw (PCM) audio data to the encoder. // Add 10MS of raw (PCM) audio data to the encoder.
int32_t AudioCodingModuleImpl::Add10MsData( int32_t AudioCodingModuleImpl::Add10MsData(
const AudioFrame& audio_frame) { const AudioFrame& audio_frame) {
@@ -2404,12 +2462,27 @@ int32_t AudioCodingModuleImpl::PlayoutData10Ms(
return 0; return 0;
} }
/////////////////////////////////////////
// (CNG) Comfort Noise Generation
// Generate comfort noise when receiving DTX packets
//
// Get VAD aggressiveness on the incoming stream
ACMVADMode AudioCodingModuleImpl::ReceiveVADMode() const {
return neteq_.vad_mode();
}
// Configure VAD aggressiveness on the incoming stream.
int16_t AudioCodingModuleImpl::SetReceiveVADMode(const ACMVADMode mode) {
return neteq_.SetVADMode(mode);
}
///////////////////////////////////////// /////////////////////////////////////////
// Statistics // Statistics
// //
int32_t AudioCodingModuleImpl::NetworkStatistics( int32_t AudioCodingModuleImpl::NetworkStatistics(
ACMNetworkStatistics* statistics) { ACMNetworkStatistics* statistics) const {
int32_t status; int32_t status;
status = neteq_.NetworkStatistics(statistics); status = neteq_.NetworkStatistics(statistics);
return status; return status;
@@ -2649,7 +2722,8 @@ int32_t AudioCodingModuleImpl::IsInternalDTXReplacedWithWebRtc(
return 0; return 0;
} }
int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) { int32_t AudioCodingModuleImpl::SetISACMaxRate(
const uint32_t max_bit_per_sec) {
CriticalSectionScoped lock(acm_crit_sect_); CriticalSectionScoped lock(acm_crit_sect_);
if (!HaveValidEncoder("SetISACMaxRate")) { if (!HaveValidEncoder("SetISACMaxRate")) {
@@ -2659,7 +2733,8 @@ int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) {
return codecs_[current_send_codec_idx_]->SetISACMaxRate(max_bit_per_sec); return codecs_[current_send_codec_idx_]->SetISACMaxRate(max_bit_per_sec);
} }
int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) { int32_t AudioCodingModuleImpl::SetISACMaxPayloadSize(
const uint16_t max_size_bytes) {
CriticalSectionScoped lock(acm_crit_sect_); CriticalSectionScoped lock(acm_crit_sect_);
if (!HaveValidEncoder("SetISACMaxPayloadSize")) { if (!HaveValidEncoder("SetISACMaxPayloadSize")) {
@@ -2671,9 +2746,9 @@ int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) {
} }
int32_t AudioCodingModuleImpl::ConfigISACBandwidthEstimator( int32_t AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
int frame_size_ms, const uint8_t frame_size_ms,
int rate_bit_per_sec, const uint16_t rate_bit_per_sec,
bool enforce_frame_size) { const bool enforce_frame_size) {
CriticalSectionScoped lock(acm_crit_sect_); CriticalSectionScoped lock(acm_crit_sect_);
if (!HaveValidEncoder("ConfigISACBandwidthEstimator")) { if (!HaveValidEncoder("ConfigISACBandwidthEstimator")) {
@@ -2684,6 +2759,21 @@ int32_t AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
frame_size_ms, rate_bit_per_sec, enforce_frame_size); frame_size_ms, rate_bit_per_sec, enforce_frame_size);
} }
int32_t AudioCodingModuleImpl::SetBackgroundNoiseMode(
const ACMBackgroundNoiseMode mode) {
if ((mode < On) || (mode > Off)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"The specified background noise is out of range.\n");
return -1;
}
return neteq_.SetBackgroundNoiseMode(mode);
}
int32_t AudioCodingModuleImpl::BackgroundNoiseMode(
ACMBackgroundNoiseMode* mode) {
return neteq_.BackgroundNoiseMode(*mode);
}
int32_t AudioCodingModuleImpl::PlayoutTimestamp( int32_t AudioCodingModuleImpl::PlayoutTimestamp(
uint32_t* timestamp) { uint32_t* timestamp) {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
@@ -2719,7 +2809,8 @@ bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const {
return true; return true;
} }
int AudioCodingModuleImpl::UnregisterReceiveCodec(uint8_t payload_type) { int32_t AudioCodingModuleImpl::UnregisterReceiveCodec(
const int16_t payload_type) {
CriticalSectionScoped lock(acm_crit_sect_); CriticalSectionScoped lock(acm_crit_sect_);
int id; int id;

View File

@@ -23,14 +23,14 @@
namespace webrtc { namespace webrtc {
struct WebRtcACMAudioBuff;
struct WebRtcACMCodecParams;
class CriticalSectionWrapper; class CriticalSectionWrapper;
class RWLockWrapper; class RWLockWrapper;
class Clock; class Clock;
namespace acm1 { namespace acm1 {
struct WebRtcACMAudioBuff;
struct WebRtcACMCodecParams;
class ACMDTMFDetection; class ACMDTMFDetection;
class ACMGenericCodec; class ACMGenericCodec;
class Nack; class Nack;
@@ -96,9 +96,20 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// called to deliver the encoded buffers. // called to deliver the encoded buffers.
int32_t RegisterTransportCallback(AudioPacketizationCallback* transport); int32_t RegisterTransportCallback(AudioPacketizationCallback* transport);
// Used by the module to deliver messages to the codec module/application
// AVT(DTMF).
int32_t RegisterIncomingMessagesCallback(
AudioCodingFeedback* incoming_message, const ACMCountries cpt);
// Add 10 ms of raw (PCM) audio data to the encoder. // Add 10 ms of raw (PCM) audio data to the encoder.
int32_t Add10MsData(const AudioFrame& audio_frame); int32_t Add10MsData(const AudioFrame& audio_frame);
// Set background noise mode for NetEQ, on, off or fade.
int32_t SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode);
// Get current background noise mode.
int32_t BackgroundNoiseMode(ACMBackgroundNoiseMode* mode);
///////////////////////////////////////// /////////////////////////////////////////
// (FEC) Forward Error Correction // (FEC) Forward Error Correction
// //
@@ -123,6 +134,12 @@ class AudioCodingModuleImpl : public AudioCodingModule {
int32_t RegisterVADCallback(ACMVADCallback* vad_callback); int32_t RegisterVADCallback(ACMVADCallback* vad_callback);
// Get VAD aggressiveness on the incoming stream.
ACMVADMode ReceiveVADMode() const;
// Configure VAD aggressiveness on the incoming stream.
int16_t SetReceiveVADMode(const ACMVADMode mode);
///////////////////////////////////////// /////////////////////////////////////////
// Receiver // Receiver
// //
@@ -203,7 +220,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// Statistics // Statistics
// //
int32_t NetworkStatistics(ACMNetworkStatistics* statistics); int32_t NetworkStatistics(ACMNetworkStatistics* statistics) const;
void DestructEncoderInst(void* inst); void DestructEncoderInst(void* inst);
@@ -226,16 +243,16 @@ class AudioCodingModuleImpl : public AudioCodingModule {
int32_t IsInternalDTXReplacedWithWebRtc(bool* uses_webrtc_dtx); int32_t IsInternalDTXReplacedWithWebRtc(bool* uses_webrtc_dtx);
int SetISACMaxRate(int max_bit_per_sec); int32_t SetISACMaxRate(const uint32_t max_bit_per_sec);
int SetISACMaxPayloadSize(int max_size_bytes); int32_t SetISACMaxPayloadSize(const uint16_t max_size_bytes);
int32_t ConfigISACBandwidthEstimator( int32_t ConfigISACBandwidthEstimator(
int frame_size_ms, const uint8_t frame_size_ms,
int rate_bit_per_sec, const uint16_t rate_bit_per_sec,
bool enforce_frame_size = false); const bool enforce_frame_size = false);
int UnregisterReceiveCodec(uint8_t payload_type); int32_t UnregisterReceiveCodec(const int16_t payload_type);
std::vector<uint16_t> GetNackList(int round_trip_time_ms) const; std::vector<uint16_t> GetNackList(int round_trip_time_ms) const;

View File

@@ -22,7 +22,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h" #include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h" #include "webrtc/modules/audio_coding/main/test/utility.h"
#include "webrtc/system_wrappers/interface/event_wrapper.h" #include "webrtc/system_wrappers/interface/event_wrapper.h"
#include "webrtc/system_wrappers/interface/thread_wrapper.h" #include "webrtc/system_wrappers/interface/thread_wrapper.h"
@@ -98,6 +98,11 @@ APITest::APITest()
_payloadUsed[n] = false; _payloadUsed[n] = false;
} }
for (n = 0; n < 3; n++) {
_receiveVADActivityA[n] = 0;
_receiveVADActivityB[n] = 0;
}
_movingDot[40] = '\0'; _movingDot[40] = '\0';
for (int n = 0; n < 40; n++) { for (int n = 0; n < 40; n++) {
@@ -347,6 +352,7 @@ bool APITest::PullAudioRunA() {
if (_writeToFile) { if (_writeToFile) {
_outFileA.Write10MsData(audioFrame); _outFileA.Write10MsData(audioFrame);
} }
_receiveVADActivityA[(int) audioFrame.vad_activity_]++;
} }
return true; return true;
} }
@@ -368,6 +374,7 @@ bool APITest::PullAudioRunB() {
if (_writeToFile) { if (_writeToFile) {
_outFileB.Write10MsData(audioFrame); _outFileB.Write10MsData(audioFrame);
} }
_receiveVADActivityB[(int) audioFrame.vad_activity_]++;
} }
return true; return true;
} }
@@ -451,7 +458,7 @@ void APITest::RunTest(char thread) {
{ {
WriteLockScoped cs(_apiTestRWLock); WriteLockScoped cs(_apiTestRWLock);
if (thread == 'A') { if (thread == 'A') {
_testNumA = (_testNumB + 1 + (rand() % 4)) % 5; _testNumA = (_testNumB + 1 + (rand() % 6)) % 7;
testNum = _testNumA; testNum = _testNumA;
_movingDot[_dotPositionA] = ' '; _movingDot[_dotPositionA] = ' ';
@@ -464,7 +471,7 @@ void APITest::RunTest(char thread) {
_dotPositionA += _dotMoveDirectionA; _dotPositionA += _dotMoveDirectionA;
_movingDot[_dotPositionA] = (_dotMoveDirectionA > 0) ? '>' : '<'; _movingDot[_dotPositionA] = (_dotMoveDirectionA > 0) ? '>' : '<';
} else { } else {
_testNumB = (_testNumA + 1 + (rand() % 4)) % 5; _testNumB = (_testNumA + 1 + (rand() % 6)) % 7;
testNum = _testNumB; testNum = _testNumB;
_movingDot[_dotPositionB] = ' '; _movingDot[_dotPositionB] = ' ';
@@ -500,6 +507,14 @@ void APITest::RunTest(char thread) {
case 4: case 4:
TestRegisteration('A'); TestRegisteration('A');
break; break;
case 5:
TestReceiverVAD('A');
break;
case 6:
#ifdef WEBRTC_DTMF_DETECTION
LookForDTMF('A');
#endif
break;
default: default:
fprintf(stderr, "Wrong Test Number\n"); fprintf(stderr, "Wrong Test Number\n");
getchar(); getchar();
@@ -528,6 +543,10 @@ bool APITest::APIRunA() {
// VAD TEST // VAD TEST
TestSendVAD('A'); TestSendVAD('A');
TestRegisteration('A'); TestRegisteration('A');
TestReceiverVAD('A');
#ifdef WEBRTC_DTMF_DETECTION
LookForDTMF('A');
#endif
} }
return true; return true;
} }
@@ -962,15 +981,18 @@ void APITest::TestRegisteration(char sendSide) {
void APITest::TestPlayout(char receiveSide) { void APITest::TestPlayout(char receiveSide) {
AudioCodingModule* receiveACM; AudioCodingModule* receiveACM;
AudioPlayoutMode* playoutMode = NULL; AudioPlayoutMode* playoutMode = NULL;
ACMBackgroundNoiseMode* bgnMode = NULL;
switch (receiveSide) { switch (receiveSide) {
case 'A': { case 'A': {
receiveACM = _acmA; receiveACM = _acmA;
playoutMode = &_playoutModeA; playoutMode = &_playoutModeA;
bgnMode = &_bgnModeA;
break; break;
} }
case 'B': { case 'B': {
receiveACM = _acmB; receiveACM = _acmB;
playoutMode = &_playoutModeB; playoutMode = &_playoutModeB;
bgnMode = &_bgnModeB;
break; break;
} }
default: default:
@@ -983,6 +1005,29 @@ void APITest::TestPlayout(char receiveSide) {
CHECK_ERROR_MT(receiveFreqHz); CHECK_ERROR_MT(receiveFreqHz);
CHECK_ERROR_MT(playoutFreqHz); CHECK_ERROR_MT(playoutFreqHz);
char bgnString[25];
switch (*bgnMode) {
case On: {
*bgnMode = Fade;
strncpy(bgnString, "Fade", 25);
break;
}
case Fade: {
*bgnMode = Off;
strncpy(bgnString, "OFF", 25);
break;
}
case Off: {
*bgnMode = On;
strncpy(bgnString, "ON", 25);
break;
}
default:
*bgnMode = On;
strncpy(bgnString, "ON", 25);
}
CHECK_ERROR_MT(receiveACM->SetBackgroundNoiseMode(*bgnMode));
bgnString[24] = '\0';
char playoutString[25]; char playoutString[25];
switch (*playoutMode) { switch (*playoutMode) {
@@ -1015,10 +1060,63 @@ void APITest::TestPlayout(char receiveSide) {
fprintf(stdout, "Receive Frequency....... %d Hz\n", receiveFreqHz); fprintf(stdout, "Receive Frequency....... %d Hz\n", receiveFreqHz);
fprintf(stdout, "Playout Frequency....... %d Hz\n", playoutFreqHz); fprintf(stdout, "Playout Frequency....... %d Hz\n", playoutFreqHz);
fprintf(stdout, "Audio Playout Mode...... %s\n", playoutString); fprintf(stdout, "Audio Playout Mode...... %s\n", playoutString);
fprintf(stdout, "Background Noise Mode... %s\n", bgnString);
} }
} }
// set/get receiver VAD status & mode. // set/get receiver VAD status & mode.
void APITest::TestReceiverVAD(char side) {
AudioCodingModule* myACM;
int* myReceiveVADActivity;
if (side == 'A') {
myACM = _acmA;
myReceiveVADActivity = _receiveVADActivityA;
} else {
myACM = _acmB;
myReceiveVADActivity = _receiveVADActivityB;
}
ACMVADMode mode = myACM->ReceiveVADMode();
CHECK_ERROR_MT(mode);
if (!_randomTest) {
fprintf(stdout, "\n\nCurrent Receive VAD at side %c\n", side);
fprintf(stdout, "----------------------------------\n");
fprintf(stdout, "mode.......... %d\n", (int) mode);
fprintf(stdout, "VAD Active.... %d\n", myReceiveVADActivity[0]);
fprintf(stdout, "VAD Passive... %d\n", myReceiveVADActivity[1]);
fprintf(stdout, "VAD Unknown... %d\n", myReceiveVADActivity[2]);
}
if (!_randomTest) {
fprintf(stdout, "\nChange Receive VAD at side %c\n\n", side);
}
switch (mode) {
case VADNormal:
mode = VADAggr;
break;
case VADLowBitrate:
mode = VADVeryAggr;
break;
case VADAggr:
mode = VADLowBitrate;
break;
case VADVeryAggr:
mode = VADNormal;
break;
default:
mode = VADNormal;
CHECK_ERROR_MT(myACM->SetReceiveVADMode(mode));
}
for (int n = 0; n < 3; n++) {
myReceiveVADActivity[n] = 0;
}
}
void APITest::TestSendVAD(char side) { void APITest::TestSendVAD(char side) {
if (_randomTest) { if (_randomTest) {
return; return;
@@ -1219,4 +1317,23 @@ void APITest::ChangeCodec(char side) {
Wait(500); Wait(500);
} }
void APITest::LookForDTMF(char side) {
if (!_randomTest) {
fprintf(stdout, "\n\nLooking for DTMF Signal in Side %c\n", side);
fprintf(stdout, "----------------------------------------\n");
}
if (side == 'A') {
_acmB->RegisterIncomingMessagesCallback(NULL);
_acmA->RegisterIncomingMessagesCallback(_dtmfCallback);
Wait(1000);
_acmA->RegisterIncomingMessagesCallback(NULL);
} else {
_acmA->RegisterIncomingMessagesCallback(NULL);
_acmB->RegisterIncomingMessagesCallback(_dtmfCallback);
Wait(1000);
_acmB->RegisterIncomingMessagesCallback(NULL);
}
}
} // namespace webrtc } // namespace webrtc

View File

@@ -56,6 +56,9 @@ class APITest : public ACMTest {
// Receiver Frequency, playout frequency. // Receiver Frequency, playout frequency.
void TestPlayout(char receiveSide); void TestPlayout(char receiveSide);
// set/get receiver VAD status & mode.
void TestReceiverVAD(char side);
// //
void TestSendVAD(char side); void TestSendVAD(char side);
@@ -65,6 +68,8 @@ class APITest : public ACMTest {
void Wait(uint32_t waitLengthMs); void Wait(uint32_t waitLengthMs);
void LookForDTMF(char side);
void RunTest(char thread); void RunTest(char thread);
bool PushAudioRunA(); bool PushAudioRunA();
@@ -140,6 +145,11 @@ class APITest : public ACMTest {
AudioPlayoutMode _playoutModeA; AudioPlayoutMode _playoutModeA;
AudioPlayoutMode _playoutModeB; AudioPlayoutMode _playoutModeB;
ACMBackgroundNoiseMode _bgnModeA;
ACMBackgroundNoiseMode _bgnModeB;
int _receiveVADActivityA[3];
int _receiveVADActivityB[3];
bool _verbose; bool _verbose;
int _dotPositionA; int _dotPositionA;

View File

@@ -20,7 +20,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h" #include "webrtc/modules/audio_coding/main/test/utility.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"

View File

@@ -16,7 +16,7 @@
#include "webrtc/engine_configurations.h" #include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h" #include "webrtc/modules/audio_coding/main/test/utility.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/test/testsupport/fileutils.h" #include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"

View File

@@ -20,7 +20,7 @@
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h" #include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/Channel.h" #include "webrtc/modules/audio_coding/main/test/Channel.h"
#include "webrtc/modules/audio_coding/main/test/PCMFile.h" #include "webrtc/modules/audio_coding/main/test/PCMFile.h"
#include "webrtc/modules/audio_coding/main/test/utility.h" #include "webrtc/modules/audio_coding/main/test/utility.h"

View File

@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "../acm2/acm_common_defs.h" #include "../source/acm_common_defs.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "PCMFile.h" #include "PCMFile.h"

View File

@@ -23,7 +23,7 @@
#include <time.h> #include <time.h>
#endif #endif
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h" #include "webrtc/modules/audio_coding/main/test/utility.h"
#include "webrtc/system_wrappers/interface/event_wrapper.h" #include "webrtc/system_wrappers/interface/event_wrapper.h"
#include "webrtc/system_wrappers/interface/tick_util.h" #include "webrtc/system_wrappers/interface/tick_util.h"

View File

@@ -17,7 +17,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13 #define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13