Compile ACM1 and ACM2.

-Make ACM1 to depend on ACM2.
-Remove APIs to set and get background noise mode. There is no VoE call to these APIs.
-Remove APIs to set and get receive side VAD mode. There is no VoE call to these APIs, and NetEq 4, doesn't support them.
-Remove callback for in-band DTMF detection. ACM doesn't support in-band DTMF detection.
-Use acm_common_defs.h everywhere required.
-Complete ACM factory method.
-Update ACMCodecDatabase of ACM2. CNG full-band need to be define-guarded. Remove dynamic payload-type assignment.

BUG=
R=andrew@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4772 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
turaj@webrtc.org
2013-09-18 00:36:11 +00:00
parent c8dea6a00f
commit 367baa6eb3
44 changed files with 140 additions and 679 deletions

View File

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

View File

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

View File

@@ -24,22 +24,13 @@
#error iSAC and iSACFX codecs cannot be enabled at the same time
#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 {
// 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 @ 32 kHz (super wide-band) is 2560 samples.
#define AUDIO_BUFFER_SIZE_W16 2560
// 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
@@ -93,6 +84,17 @@ struct WebRtcACMCodecParams {
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
#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) {
return ACM_ISAC_DECODE_BWE(static_cast<ACM_ISAC_STRUCT*>(state_),
reinterpret_cast<const uint16_t*>(payload),
payload_len,
static_cast<uint32_t>(payload_len),
rtp_sequence_number,
rtp_timestamp,
arrival_timestamp);
@@ -311,7 +311,7 @@ class AcmAudioDecoderIsac : public AudioDecoder {
size_t encoded_len, int16_t* decoded,
SpeechType* speech_type) {
int16_t temp_type = 1; // Default is speech.
int16_t ret = ACM_ISAC_DECODERCU(static_cast<ISACStruct*>(state_),
int16_t ret = ACM_ISAC_DECODERCU(static_cast<ACM_ISAC_STRUCT*>(state_),
reinterpret_cast<const uint16_t*>(encoded),
static_cast<int16_t>(encoded_len), decoded,
&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
// block, therefore, we keep it inside critical section. Otherwise, we have to
// release |neteq_crit_sect_| and acquire it again, which seems an overkill.
if (neteq_->SetMinimumDelay(delay_ms) < 0)
if (!neteq_->SetMinimumDelay(delay_ms))
return -1;
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->preferredBufferSize = neteq_stat.preferred_buffer_size_ms;
acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found;
acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false;
acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate;
acm_stat->currentDiscardRate = neteq_stat.packet_discard_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 buffer_size_byte;
int max_buffer_size_byte;
const float kBufferingThresholdScale = 0.9;
const float kBufferingThresholdScale = 0.9f;
neteq_->PacketBufferStatistics(&num_packets, &max_num_packets,
&buffer_size_byte, &max_buffer_size_byte);
if (num_packets > max_num_packets * kBufferingThresholdScale ||

View File

@@ -13,18 +13,24 @@
#include "webrtc/common_types.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/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(int id) {
return new AudioCodingModuleImpl(id);
return new acm1::AudioCodingModuleImpl(id, Clock::GetRealTimeClock());
}
AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
return new acm1::AudioCodingModuleImpl(id, clock);
}
// Destroy module
void AudioCodingModule::Destroy(AudioCodingModule* module) {
delete static_cast<AudioCodingModuleImpl*>(module);
delete module;
}
// Get number of supported codecs
@@ -90,11 +96,12 @@ bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
}
}
AudioCodingModule* AudioCodingModuleFactory::Create(const int32_t id) const {
return NULL;
AudioCodingModule* AudioCodingModuleFactory::Create(int id) const {
return new acm1::AudioCodingModuleImpl(static_cast<int32_t>(id),
Clock::GetRealTimeClock());
}
AudioCodingModule* NewAudioCodingModuleFactory::Create(const int32_t id) const {
AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const {
return new AudioCodingModuleImpl(id);
}

View File

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

View File

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