summaryrefslogtreecommitdiff
path: root/chromium/third_party/webrtc/modules/audio_coding/main/acm2
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/webrtc/modules/audio_coding/main/acm2')
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc217
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h59
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h48
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.cc240
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.h59
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc124
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc15
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h2
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.cc12
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h8
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc109
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.h44
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc23
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc24
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.cc6
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.h2
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc6
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.h4
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc14
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h8
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc1
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi195
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc390
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h77
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc56
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc201
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.cc71
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.h11
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.cc211
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.h51
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc78
-rw-r--r--chromium/third_party/webrtc/modules/audio_coding/main/acm2/dump.proto169
32 files changed, 693 insertions, 1842 deletions
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
index 9f97c79a8a4..9193270363a 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
@@ -27,6 +27,38 @@ namespace webrtc {
namespace acm2 {
+namespace {
+
+// Checks if the bitrate is valid for the codec.
+bool IsRateValid(int codec_id, int rate) {
+ return ACMCodecDB::database_[codec_id].rate == rate;
+}
+
+// Checks if the bitrate is valid for iSAC.
+bool IsISACRateValid(int rate) {
+ return (rate == -1) || ((rate <= 56000) && (rate >= 10000));
+}
+
+// Checks if the bitrate is valid for iLBC.
+bool IsILBCRateValid(int rate, int frame_size_samples) {
+ if (((frame_size_samples == 240) || (frame_size_samples == 480)) &&
+ (rate == 13300)) {
+ return true;
+ } else if (((frame_size_samples == 160) || (frame_size_samples == 320)) &&
+ (rate == 15200)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Checks if the bitrate is valid for Opus.
+bool IsOpusRateValid(int rate) {
+ return (rate >= 6000) && (rate <= 510000);
+}
+
+} // namespace
+
// Not yet used payload-types.
// 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68,
// 67, 66, 65
@@ -39,7 +71,6 @@ const CodecInst ACMCodecDB::database_[] = {
{105, "ISAC", 48000, kIsacPacSize1440, 1, kIsacSwbDefaultRate},
# endif
#endif
-#ifdef WEBRTC_CODEC_PCM16
// Mono
{107, "L16", 8000, 80, 1, 128000},
{108, "L16", 16000, 160, 1, 256000},
@@ -48,7 +79,6 @@ const CodecInst ACMCodecDB::database_[] = {
{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
{0, "PCMU", 8000, 160, 1, 64000},
@@ -77,9 +107,7 @@ const CodecInst ACMCodecDB::database_[] = {
#ifdef ENABLE_48000_HZ
{100, "CN", 48000, 1440, 1, 0},
#endif
-#ifdef WEBRTC_CODEC_AVT
{106, "telephone-event", 8000, 240, 1, 0},
-#endif
#ifdef WEBRTC_CODEC_RED
{127, "red", 8000, 0, 1, 0},
#endif
@@ -93,59 +121,55 @@ const CodecInst ACMCodecDB::database_[] = {
// Basic block samples, max number of channels that are supported.
const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
- {2, {kIsacPacSize480, kIsacPacSize960}, 0, 1, true},
+ {2, {kIsacPacSize480, kIsacPacSize960}, 0, 1},
# if (defined(WEBRTC_CODEC_ISAC))
- {1, {kIsacPacSize960}, 0, 1, true},
- {1, {kIsacPacSize1440}, 0, 1, true},
+ {1, {kIsacPacSize960}, 0, 1},
+ {1, {kIsacPacSize1440}, 0, 1},
# endif
#endif
-#ifdef WEBRTC_CODEC_PCM16
// Mono
- {4, {80, 160, 240, 320}, 0, 2, false},
- {4, {160, 320, 480, 640}, 0, 2, false},
- {2, {320, 640}, 0, 2, false},
+ {4, {80, 160, 240, 320}, 0, 2},
+ {4, {160, 320, 480, 640}, 0, 2},
+ {2, {320, 640}, 0, 2},
// Stereo
- {4, {80, 160, 240, 320}, 0, 2, false},
- {4, {160, 320, 480, 640}, 0, 2, false},
+ {4, {80, 160, 240, 320}, 0, 2},
+ {4, {160, 320, 480, 640}, 0, 2},
{2, {320, 640}, 0, 2},
-#endif
// G.711, PCM mu-law and A-law.
// Mono
- {6, {80, 160, 240, 320, 400, 480}, 0, 2, false},
- {6, {80, 160, 240, 320, 400, 480}, 0, 2, false},
+ {6, {80, 160, 240, 320, 400, 480}, 0, 2},
+ {6, {80, 160, 240, 320, 400, 480}, 0, 2},
// Stereo
- {6, {80, 160, 240, 320, 400, 480}, 0, 2, false},
- {6, {80, 160, 240, 320, 400, 480}, 0, 2, false},
+ {6, {80, 160, 240, 320, 400, 480}, 0, 2},
+ {6, {80, 160, 240, 320, 400, 480}, 0, 2},
#ifdef WEBRTC_CODEC_ILBC
- {4, {160, 240, 320, 480}, 0, 1, false},
+ {4, {160, 240, 320, 480}, 0, 1},
#endif
#ifdef WEBRTC_CODEC_G722
// Mono
- {6, {160, 320, 480, 640, 800, 960}, 0, 2, false},
+ {6, {160, 320, 480, 640, 800, 960}, 0, 2},
// Stereo
- {6, {160, 320, 480, 640, 800, 960}, 0, 2, false},
+ {6, {160, 320, 480, 640, 800, 960}, 0, 2},
#endif
#ifdef WEBRTC_CODEC_OPUS
// Opus supports frames shorter than 10ms,
// but it doesn't help us to use them.
// Mono and stereo.
- {4, {480, 960, 1920, 2880}, 0, 2, false},
+ {4, {480, 960, 1920, 2880}, 0, 2},
#endif
// Comfort noise for three different sampling frequencies.
- {1, {240}, 240, 1, false},
- {1, {480}, 480, 1, false},
- {1, {960}, 960, 1, false},
+ {1, {240}, 240, 1},
+ {1, {480}, 480, 1},
+ {1, {960}, 960, 1},
#ifdef ENABLE_48000_HZ
- {1, {1440}, 1440, 1, false},
-#endif
-#ifdef WEBRTC_CODEC_AVT
- {1, {240}, 240, 1, false},
+ {1, {1440}, 1440, 1},
#endif
+ {1, {240}, 240, 1},
#ifdef WEBRTC_CODEC_RED
- {1, {0}, 0, 1, false},
+ {1, {0}, 0, 1},
#endif
// To prevent compile errors due to trailing commas.
- {-1, {-1}, -1, -1, false}
+ {-1, {-1}, -1, -1}
};
// Create a database of all NetEQ decoders at compile time.
@@ -157,7 +181,6 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = {
kDecoderISACfb,
# endif
#endif
-#ifdef WEBRTC_CODEC_PCM16
// Mono
kDecoderPCM16B,
kDecoderPCM16Bwb,
@@ -166,7 +189,6 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = {
kDecoderPCM16B_2ch,
kDecoderPCM16Bwb_2ch,
kDecoderPCM16Bswb32kHz_2ch,
-#endif
// G.711, PCM mu-las and A-law.
// Mono
kDecoderPCMu,
@@ -194,9 +216,7 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = {
#ifdef ENABLE_48000_HZ
, kDecoderCNGswb48kHz
#endif
-#ifdef WEBRTC_CODEC_AVT
, kDecoderAVT
-#endif
#ifdef WEBRTC_CODEC_RED
, kDecoderRED
#endif
@@ -281,21 +301,9 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) {
} else if (STR_CASE_CMP("ilbc", codec_inst.plname) == 0) {
return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize)
? codec_id : kInvalidRate;
- } else if (STR_CASE_CMP("amr", codec_inst.plname) == 0) {
- return IsAMRRateValid(codec_inst.rate)
- ? codec_id : kInvalidRate;
- } else if (STR_CASE_CMP("amr-wb", codec_inst.plname) == 0) {
- return IsAMRwbRateValid(codec_inst.rate)
- ? codec_id : kInvalidRate;
- } else if (STR_CASE_CMP("g7291", codec_inst.plname) == 0) {
- return IsG7291RateValid(codec_inst.rate)
- ? codec_id : kInvalidRate;
} else if (STR_CASE_CMP("opus", codec_inst.plname) == 0) {
return IsOpusRateValid(codec_inst.rate)
? codec_id : kInvalidRate;
- } else if (STR_CASE_CMP("speex", codec_inst.plname) == 0) {
- return IsSpeexRateValid(codec_inst.rate)
- ? codec_id : kInvalidRate;
}
return IsRateValid(codec_id, codec_inst.rate) ?
@@ -357,126 +365,11 @@ int ACMCodecDB::CodecFreq(int codec_id) {
return database_[codec_id].plfreq;
}
-// Returns the codec's basic coding block size in samples.
-int ACMCodecDB::BasicCodingBlock(int codec_id) {
- // Error check to see that codec_id is not out of bounds.
- if (codec_id < 0 || codec_id >= kNumCodecs) {
- return -1;
- }
-
- return codec_settings_[codec_id].basic_block_samples;
-}
-
-// Returns the NetEQ decoder database.
-const NetEqDecoder* ACMCodecDB::NetEQDecoders() {
- return neteq_decoders_;
-}
-
-// Checks if the bitrate is valid for the codec.
-bool ACMCodecDB::IsRateValid(int codec_id, int rate) {
- return database_[codec_id].rate == rate;
-}
-
-// Checks if the bitrate is valid for iSAC.
-bool ACMCodecDB::IsISACRateValid(int rate) {
- return (rate == -1) || ((rate <= 56000) && (rate >= 10000));
-}
-
-// Checks if the bitrate is valid for iLBC.
-bool ACMCodecDB::IsILBCRateValid(int rate, int frame_size_samples) {
- if (((frame_size_samples == 240) || (frame_size_samples == 480)) &&
- (rate == 13300)) {
- return true;
- } else if (((frame_size_samples == 160) || (frame_size_samples == 320)) &&
- (rate == 15200)) {
- return true;
- } else {
- return false;
- }
-}
-
-// Check if the bitrate is valid for the GSM-AMR.
-bool ACMCodecDB::IsAMRRateValid(int rate) {
- switch (rate) {
- case 4750:
- case 5150:
- case 5900:
- case 6700:
- case 7400:
- case 7950:
- case 10200:
- case 12200: {
- return true;
- }
- default: {
- return false;
- }
- }
-}
-
-// Check if the bitrate is valid for GSM-AMR-WB.
-bool ACMCodecDB::IsAMRwbRateValid(int rate) {
- switch (rate) {
- case 7000:
- case 9000:
- case 12000:
- case 14000:
- case 16000:
- case 18000:
- case 20000:
- case 23000:
- case 24000: {
- return true;
- }
- default: {
- return false;
- }
- }
-}
-
-// Check if the bitrate is valid for G.729.1.
-bool ACMCodecDB::IsG7291RateValid(int rate) {
- switch (rate) {
- case 8000:
- case 12000:
- case 14000:
- case 16000:
- case 18000:
- case 20000:
- case 22000:
- case 24000:
- case 26000:
- case 28000:
- case 30000:
- case 32000: {
- return true;
- }
- default: {
- return false;
- }
- }
-}
-
-// Checks if the bitrate is valid for Speex.
-bool ACMCodecDB::IsSpeexRateValid(int rate) {
- return rate > 2000;
-}
-
-// Checks if the bitrate is valid for Opus.
-bool ACMCodecDB::IsOpusRateValid(int rate) {
- return (rate >= 6000) && (rate <= 510000);
-}
-
// Checks if the payload type is in the valid range.
bool ACMCodecDB::ValidPayloadType(int payload_type) {
return (payload_type >= 0) && (payload_type <= 127);
}
-bool ACMCodecDB::OwnsDecoder(int codec_id) {
- assert(codec_id >= 0 && codec_id < ACMCodecDB::kNumCodecs);
- return ACMCodecDB::codec_settings_[codec_id].owns_decoder;
-}
-
} // namespace acm2
} // namespace webrtc
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h
index b1ae5aa0f56..3ac4c5b3a97 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h
@@ -38,7 +38,6 @@ class ACMCodecDB {
, kISACFB
# endif
#endif
-#ifdef WEBRTC_CODEC_PCM16
// Mono
, kPCM16B
, kPCM16Bwb
@@ -47,7 +46,6 @@ class ACMCodecDB {
, kPCM16B_2ch
, kPCM16Bwb_2ch
, kPCM16Bswb32kHz_2ch
-#endif
// Mono
, kPCMU
, kPCMA
@@ -73,9 +71,7 @@ class ACMCodecDB {
#ifdef ENABLE_48000_HZ
, kCNFB
#endif
-#ifdef WEBRTC_CODEC_AVT
, kAVT
-#endif
#ifdef WEBRTC_CODEC_RED
, kRED
#endif
@@ -90,16 +86,6 @@ class ACMCodecDB {
enum {kISAC = -1};
# endif
#endif
-#ifndef WEBRTC_CODEC_PCM16
- // Mono
- enum {kPCM16B = -1};
- enum {kPCM16Bwb = -1};
- enum {kPCM16Bswb32kHz = -1};
- // Stereo
- enum {kPCM16B_2ch = -1};
- enum {kPCM16Bwb_2ch = -1};
- enum {kPCM16Bswb32kHz_2ch = -1};
-#endif
// 48 kHz not supported, always set to -1.
enum {kPCM16Bswb48kHz = -1};
#ifndef WEBRTC_CODEC_ILBC
@@ -115,9 +101,6 @@ class ACMCodecDB {
// Mono and stereo
enum {kOpus = -1};
#endif
-#ifndef WEBRTC_CODEC_AVT
- enum {kAVT = -1};
-#endif
#ifndef WEBRTC_CODEC_RED
enum {kRED = -1};
#endif
@@ -141,18 +124,11 @@ class ACMCodecDB {
// that can be different from packet size.
// channel_support - number of channels supported to encode;
// 1 = mono, 2 = stereo, etc.
- // owns_decoder - if true, it means that the codec should own the
- // decoder instance. In this case, the codec should
- // implement ACMGenericCodec::Decoder(), which returns
- // a pointer to AudioDecoder. This pointer is injected
- // into NetEq when this codec is registered as receive
- // codec. DEPRECATED.
struct CodecSettings {
int num_packet_sizes;
int packet_sizes_samples[kMaxNumPacketSize];
int basic_block_samples;
int channel_support;
- bool owns_decoder;
};
// Gets codec information from database at the position in database given by
@@ -189,41 +165,6 @@ class ACMCodecDB {
// codec sampling frequency if successful, otherwise -1.
static int CodecFreq(int codec_id);
- // Return the codec's basic coding block size in samples.
- // TODO(tlegrand): Check if function is needed, or if we can change
- // to access database directly.
- // Input:
- // [codec_id] - number that specifies at what position in the database to
- // get the information.
- // Return:
- // codec basic block size if successful, otherwise -1.
- static int BasicCodingBlock(int codec_id);
-
- // Returns the NetEQ decoder database.
- static const NetEqDecoder* NetEQDecoders();
-
- // Specifies if the codec specified by |codec_id| MUST own its own decoder.
- // This is the case for codecs which *should* share a single codec instance
- // between encoder and decoder. Or for codecs which ACM should have control
- // over the decoder. For instance iSAC is such a codec that encoder and
- // decoder share the same codec instance.
- static bool OwnsDecoder(int codec_id);
-
- // Checks if the bitrate is valid for the codec.
- // Input:
- // [codec_id] - number that specifies codec's position in the database.
- // [rate] - bitrate to check.
- // [frame_size_samples] - (used for iLBC) specifies which frame size to go
- // with the rate.
- static bool IsRateValid(int codec_id, int rate);
- static bool IsISACRateValid(int rate);
- static bool IsILBCRateValid(int rate, int frame_size_samples);
- static bool IsAMRRateValid(int rate);
- static bool IsAMRwbRateValid(int rate);
- static bool IsG7291RateValid(int rate);
- static bool IsSpeexRateValid(int rate);
- static bool IsOpusRateValid(int rate);
-
// Check if the payload type is valid, meaning that it is in the valid range
// of 0 to 127.
// Input:
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h
index 85a287e1268..df67ce29145 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h
@@ -11,12 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_COMMON_DEFS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_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.
@@ -24,24 +19,8 @@
#error iSAC and iSACFX codecs cannot be enabled at the same time
#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 @ 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;
@@ -49,33 +28,6 @@ const int kIsacPacSize480 = 480;
const int kIsacPacSize960 = 960;
const int kIsacPacSize1440 = 1440;
-// 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;
-};
-
-// 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_
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.cc
deleted file mode 100644
index 9c624d97b67..00000000000
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.cc
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2015 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/acm2/acm_dump.h"
-
-#include <deque>
-
-#include "webrtc/base/checks.h"
-#include "webrtc/base/thread_annotations.h"
-#include "webrtc/system_wrappers/interface/clock.h"
-#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
-#include "webrtc/system_wrappers/interface/file_wrapper.h"
-
-#ifdef RTC_AUDIOCODING_DEBUG_DUMP
-// Files generated at build-time by the protobuf compiler.
-#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
-#include "external/webrtc/webrtc/modules/audio_coding/dump.pb.h"
-#else
-#include "webrtc/audio_coding/dump.pb.h"
-#endif
-#endif
-
-namespace webrtc {
-
-// Noop implementation if flag is not set
-#ifndef RTC_AUDIOCODING_DEBUG_DUMP
-class AcmDumpImpl final : public AcmDump {
- public:
- void StartLogging(const std::string& file_name, int duration_ms) override{};
- void LogRtpPacket(bool incoming,
- const uint8_t* packet,
- size_t length) override{};
- void LogDebugEvent(DebugEvent event_type,
- const std::string& event_message) override{};
- void LogDebugEvent(DebugEvent event_type) override{};
-};
-#else
-
-class AcmDumpImpl final : public AcmDump {
- public:
- AcmDumpImpl();
-
- void StartLogging(const std::string& file_name, int duration_ms) override;
- void LogRtpPacket(bool incoming,
- const uint8_t* packet,
- size_t length) override;
- void LogDebugEvent(DebugEvent event_type,
- const std::string& event_message) override;
- void LogDebugEvent(DebugEvent event_type) override;
-
- private:
- // This function is identical to LogDebugEvent, but requires holding the lock.
- void LogDebugEventLocked(DebugEvent event_type,
- const std::string& event_message)
- EXCLUSIVE_LOCKS_REQUIRED(crit_);
- // Stops logging and clears the stored data and buffers.
- void Clear() EXCLUSIVE_LOCKS_REQUIRED(crit_);
- // Adds a new event to the logfile if logging is active, or adds it to the
- // list of recent log events otherwise.
- void HandleEvent(ACMDumpEvent* event) EXCLUSIVE_LOCKS_REQUIRED(crit_);
- // Writes the event to the file. Note that this will destroy the state of the
- // input argument.
- void StoreToFile(ACMDumpEvent* event) EXCLUSIVE_LOCKS_REQUIRED(crit_);
- // Adds the event to the list of recent events, and removes any events that
- // are too old and no longer fall in the time window.
- void AddRecentEvent(const ACMDumpEvent& event)
- EXCLUSIVE_LOCKS_REQUIRED(crit_);
-
- // Amount of time in microseconds to record log events, before starting the
- // actual log.
- const int recent_log_duration_us = 10000000;
-
- rtc::scoped_ptr<webrtc::CriticalSectionWrapper> crit_;
- rtc::scoped_ptr<webrtc::FileWrapper> file_ GUARDED_BY(crit_);
- rtc::scoped_ptr<ACMDumpEventStream> stream_ GUARDED_BY(crit_);
- std::deque<ACMDumpEvent> recent_log_events_ GUARDED_BY(crit_);
- bool currently_logging_ GUARDED_BY(crit_);
- int64_t start_time_us_ GUARDED_BY(crit_);
- int64_t duration_us_ GUARDED_BY(crit_);
- const webrtc::Clock* const clock_;
-};
-
-namespace {
-
-// Convert from AcmDump's debug event enum (runtime format) to the corresponding
-// protobuf enum (serialized format).
-ACMDumpDebugEvent_EventType convertDebugEvent(AcmDump::DebugEvent event_type) {
- switch (event_type) {
- case AcmDump::DebugEvent::kLogStart:
- return ACMDumpDebugEvent::LOG_START;
- case AcmDump::DebugEvent::kLogEnd:
- return ACMDumpDebugEvent::LOG_END;
- case AcmDump::DebugEvent::kAudioPlayout:
- return ACMDumpDebugEvent::AUDIO_PLAYOUT;
- }
- return ACMDumpDebugEvent::UNKNOWN_EVENT;
-}
-
-} // Anonymous namespace.
-
-// AcmDumpImpl member functions.
-AcmDumpImpl::AcmDumpImpl()
- : crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
- file_(webrtc::FileWrapper::Create()),
- stream_(new webrtc::ACMDumpEventStream()),
- currently_logging_(false),
- start_time_us_(0),
- duration_us_(0),
- clock_(webrtc::Clock::GetRealTimeClock()) {
-}
-
-void AcmDumpImpl::StartLogging(const std::string& file_name, int duration_ms) {
- CriticalSectionScoped lock(crit_.get());
- Clear();
- if (file_->OpenFile(file_name.c_str(), false) != 0) {
- return;
- }
- // Add LOG_START event to the recent event list. This call will also remove
- // any events that are too old from the recent event list.
- LogDebugEventLocked(DebugEvent::kLogStart, "");
- currently_logging_ = true;
- start_time_us_ = clock_->TimeInMicroseconds();
- duration_us_ = static_cast<int64_t>(duration_ms) * 1000;
- // Write all the recent events to the log file.
- for (auto&& event : recent_log_events_) {
- StoreToFile(&event);
- }
- recent_log_events_.clear();
-}
-
-void AcmDumpImpl::LogRtpPacket(bool incoming,
- const uint8_t* packet,
- size_t length) {
- CriticalSectionScoped lock(crit_.get());
- ACMDumpEvent rtp_event;
- const int64_t timestamp = clock_->TimeInMicroseconds();
- rtp_event.set_timestamp_us(timestamp);
- rtp_event.set_type(webrtc::ACMDumpEvent::RTP_EVENT);
- rtp_event.mutable_packet()->set_direction(
- incoming ? ACMDumpRTPPacket::INCOMING : ACMDumpRTPPacket::OUTGOING);
- rtp_event.mutable_packet()->set_rtp_data(packet, length);
- HandleEvent(&rtp_event);
-}
-
-void AcmDumpImpl::LogDebugEvent(DebugEvent event_type,
- const std::string& event_message) {
- CriticalSectionScoped lock(crit_.get());
- LogDebugEventLocked(event_type, event_message);
-}
-
-void AcmDumpImpl::LogDebugEvent(DebugEvent event_type) {
- CriticalSectionScoped lock(crit_.get());
- LogDebugEventLocked(event_type, "");
-}
-
-void AcmDumpImpl::LogDebugEventLocked(DebugEvent event_type,
- const std::string& event_message) {
- ACMDumpEvent event;
- int64_t timestamp = clock_->TimeInMicroseconds();
- event.set_timestamp_us(timestamp);
- event.set_type(webrtc::ACMDumpEvent::DEBUG_EVENT);
- auto debug_event = event.mutable_debug_event();
- debug_event->set_type(convertDebugEvent(event_type));
- debug_event->set_message(event_message);
- HandleEvent(&event);
-}
-
-void AcmDumpImpl::Clear() {
- if (file_->Open()) {
- file_->CloseFile();
- }
- currently_logging_ = false;
- stream_->Clear();
-}
-
-void AcmDumpImpl::HandleEvent(ACMDumpEvent* event) {
- if (currently_logging_) {
- if (clock_->TimeInMicroseconds() < start_time_us_ + duration_us_) {
- StoreToFile(event);
- } else {
- LogDebugEventLocked(DebugEvent::kLogEnd, "");
- Clear();
- AddRecentEvent(*event);
- }
- } else {
- AddRecentEvent(*event);
- }
-}
-
-void AcmDumpImpl::StoreToFile(ACMDumpEvent* event) {
- // Reuse the same object at every log event.
- if (stream_->stream_size() < 1) {
- stream_->add_stream();
- }
- DCHECK_EQ(stream_->stream_size(), 1);
- stream_->mutable_stream(0)->Swap(event);
-
- std::string dump_buffer;
- stream_->SerializeToString(&dump_buffer);
- file_->Write(dump_buffer.data(), dump_buffer.size());
-}
-
-void AcmDumpImpl::AddRecentEvent(const ACMDumpEvent& event) {
- recent_log_events_.push_back(event);
- while (recent_log_events_.front().timestamp_us() <
- event.timestamp_us() - recent_log_duration_us) {
- recent_log_events_.pop_front();
- }
-}
-
-bool AcmDump::ParseAcmDump(const std::string& file_name,
- ACMDumpEventStream* result) {
- char tmp_buffer[1024];
- int bytes_read = 0;
- rtc::scoped_ptr<FileWrapper> dump_file(FileWrapper::Create());
- if (dump_file->OpenFile(file_name.c_str(), true) != 0) {
- return false;
- }
- std::string dump_buffer;
- while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) {
- dump_buffer.append(tmp_buffer, bytes_read);
- }
- dump_file->CloseFile();
- return result->ParseFromString(dump_buffer);
-}
-
-#endif // RTC_AUDIOCODING_DEBUG_DUMP
-
-// AcmDump member functions.
-rtc::scoped_ptr<AcmDump> AcmDump::Create() {
- return rtc::scoped_ptr<AcmDump>(new AcmDumpImpl());
-}
-} // namespace webrtc
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.h
deleted file mode 100644
index c72c3870965..00000000000
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2015 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_ACM2_ACM_DUMP_H_
-#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_DUMP_H_
-
-#include <string>
-
-#include "webrtc/base/scoped_ptr.h"
-
-namespace webrtc {
-
-// Forward declaration of storage class that is automatically generated from
-// the protobuf file.
-class ACMDumpEventStream;
-
-class AcmDumpImpl;
-
-class AcmDump {
- public:
- // The types of debug events that are currently supported for logging.
- enum class DebugEvent { kLogStart, kLogEnd, kAudioPlayout };
-
- virtual ~AcmDump() {}
-
- static rtc::scoped_ptr<AcmDump> Create();
-
- // Starts logging for the specified duration to the specified file.
- // The logging will stop automatically after the specified duration.
- // If the file already exists it will be overwritten.
- // The function will return false on failure.
- virtual void StartLogging(const std::string& file_name, int duration_ms) = 0;
-
- // Logs an incoming or outgoing RTP packet.
- virtual void LogRtpPacket(bool incoming,
- const uint8_t* packet,
- size_t length) = 0;
-
- // Logs a debug event, with optional message.
- virtual void LogDebugEvent(DebugEvent event_type,
- const std::string& event_message) = 0;
- virtual void LogDebugEvent(DebugEvent event_type) = 0;
-
- // Reads an AcmDump file and returns true when reading was successful.
- // The result is stored in the given ACMDumpEventStream object.
- static bool ParseAcmDump(const std::string& file_name,
- ACMDumpEventStream* result);
-};
-
-} // namespace webrtc
-
-#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_DUMP_H_
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc
deleted file mode 100644
index 98d0e622a87..00000000000
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- */
-
-#ifdef RTC_AUDIOCODING_DEBUG_DUMP
-
-#include <stdio.h>
-#include <string>
-#include <vector>
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webrtc/base/scoped_ptr.h"
-#include "webrtc/modules/audio_coding/main/acm2/acm_dump.h"
-#include "webrtc/system_wrappers/interface/clock.h"
-#include "webrtc/test/test_suite.h"
-#include "webrtc/test/testsupport/fileutils.h"
-#include "webrtc/test/testsupport/gtest_disable.h"
-
-// Files generated at build-time by the protobuf compiler.
-#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
-#include "external/webrtc/webrtc/modules/audio_coding/dump.pb.h"
-#else
-#include "webrtc/audio_coding/dump.pb.h"
-#endif
-
-namespace webrtc {
-
-// Test for the acm dump class. Dumps some RTP packets to disk, then reads them
-// back to see if they match.
-class AcmDumpTest : public ::testing::Test {
- public:
- void VerifyResults(const ACMDumpEventStream& parsed_stream,
- size_t packet_size) {
- // Verify the result.
- EXPECT_EQ(5, parsed_stream.stream_size());
- const ACMDumpEvent& start_event = parsed_stream.stream(2);
- ASSERT_TRUE(start_event.has_type());
- EXPECT_EQ(ACMDumpEvent::DEBUG_EVENT, start_event.type());
- EXPECT_TRUE(start_event.has_timestamp_us());
- EXPECT_FALSE(start_event.has_packet());
- ASSERT_TRUE(start_event.has_debug_event());
- auto start_debug_event = start_event.debug_event();
- ASSERT_TRUE(start_debug_event.has_type());
- EXPECT_EQ(ACMDumpDebugEvent::LOG_START, start_debug_event.type());
- ASSERT_TRUE(start_debug_event.has_message());
-
- for (int i = 0; i < parsed_stream.stream_size(); i++) {
- if (i == 2) {
- // This is the LOG_START packet that was already verified.
- continue;
- }
- const ACMDumpEvent& test_event = parsed_stream.stream(i);
- ASSERT_TRUE(test_event.has_type());
- EXPECT_EQ(ACMDumpEvent::RTP_EVENT, test_event.type());
- EXPECT_TRUE(test_event.has_timestamp_us());
- EXPECT_FALSE(test_event.has_debug_event());
- ASSERT_TRUE(test_event.has_packet());
- const ACMDumpRTPPacket& test_packet = test_event.packet();
- ASSERT_TRUE(test_packet.has_direction());
- if (i <= 1) {
- EXPECT_EQ(ACMDumpRTPPacket::INCOMING, test_packet.direction());
- } else if (i >= 3) {
- EXPECT_EQ(ACMDumpRTPPacket::OUTGOING, test_packet.direction());
- }
- ASSERT_TRUE(test_packet.has_rtp_data());
- ASSERT_EQ(packet_size, test_packet.rtp_data().size());
- for (size_t i = 0; i < packet_size; i++) {
- EXPECT_EQ(rtp_packet_[i],
- static_cast<uint8_t>(test_packet.rtp_data()[i]));
- }
- }
- }
-
- void Run(int packet_size, int random_seed) {
- rtp_packet_.clear();
- rtp_packet_.reserve(packet_size);
- srand(random_seed);
- // Fill the packet vector with random data.
- for (int i = 0; i < packet_size; i++) {
- rtp_packet_.push_back(rand());
- }
- // Find the name of the current test, in order to use it as a temporary
- // filename.
- auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
- const std::string temp_filename =
- test::OutputPath() + test_info->test_case_name() + test_info->name();
-
- // When log_dumper goes out of scope, it causes the log file to be flushed
- // to disk.
- {
- rtc::scoped_ptr<AcmDump> log_dumper(AcmDump::Create());
- log_dumper->LogRtpPacket(true, rtp_packet_.data(), rtp_packet_.size());
- log_dumper->LogRtpPacket(true, rtp_packet_.data(), rtp_packet_.size());
- log_dumper->StartLogging(temp_filename, 10000000);
- log_dumper->LogRtpPacket(false, rtp_packet_.data(), rtp_packet_.size());
- log_dumper->LogRtpPacket(false, rtp_packet_.data(), rtp_packet_.size());
- }
-
- // Read the generated file from disk.
- ACMDumpEventStream parsed_stream;
-
- ASSERT_EQ(true, AcmDump::ParseAcmDump(temp_filename, &parsed_stream));
-
- VerifyResults(parsed_stream, packet_size);
-
- // Clean up temporary file - can be pretty slow.
- remove(temp_filename.c_str());
- }
- std::vector<uint8_t> rtp_packet_;
-};
-
-TEST_F(AcmDumpTest, DumpAndRead) {
- Run(256, 321);
-}
-
-} // namespace webrtc
-
-#endif // RTC_AUDIOCODING_DEBUG_DUMP
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc
index dc59984a953..e01b2631270 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc
@@ -38,9 +38,13 @@ AcmReceiveTest::AcmReceiveTest(PacketSource* packet_source,
}
void AcmReceiveTest::RegisterDefaultCodecs() {
+#ifdef WEBRTC_CODEC_OPUS
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kOpus, 120));
+#endif
+#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kISAC, 103));
-#ifndef WEBRTC_ANDROID
+#endif
+#ifdef WEBRTC_CODEC_ISAC
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kISACSWB, 104));
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kISACFB, 105));
#endif
@@ -56,13 +60,19 @@ void AcmReceiveTest::RegisterDefaultCodecs() {
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kPCMA, 8));
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kPCMU_2ch, 110));
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kPCMA_2ch, 118));
+#ifdef WEBRTC_CODEC_ILBC
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kILBC, 102));
+#endif
+#ifdef WEBRTC_CODEC_G722
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kG722, 9));
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kG722_2ch, 119));
+#endif
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kCNNB, 13));
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kCNWB, 98));
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kCNSWB, 99));
+#ifdef WEBRTC_CODEC_RED
ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kRED, 127));
+#endif
}
void AcmReceiveTest::RegisterNetEqTestCodecs() {
@@ -93,7 +103,8 @@ void AcmReceiveTest::Run() {
AudioFrame output_frame;
EXPECT_TRUE(acm_->Get10MsAudio(&output_frame));
EXPECT_EQ(output_freq_hz_, output_frame.sample_rate_hz_);
- const int samples_per_block = output_freq_hz_ * 10 / 1000;
+ const size_t samples_per_block =
+ static_cast<size_t>(output_freq_hz_ * 10 / 1000);
EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_);
if (expected_output_channels_ != kArbitraryChannels) {
if (output_frame.speech_type_ == webrtc::AudioFrame::kPLC) {
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h
index a1e01423bcb..80e9fbede65 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h
@@ -56,7 +56,7 @@ class AcmReceiveTest {
const int output_freq_hz_;
NumOutputChannels expected_output_channels_;
- DISALLOW_COPY_AND_ASSIGN(AcmReceiveTest);
+ RTC_DISALLOW_COPY_AND_ASSIGN(AcmReceiveTest);
};
} // namespace test
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.cc
index 96a1fc5fdcb..2a0bbe15d4b 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.cc
@@ -143,6 +143,15 @@ void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() {
}
}
+int AcmReceiveTestOldApi::RegisterExternalReceiveCodec(
+ int rtp_payload_type,
+ AudioDecoder* external_decoder,
+ int sample_rate_hz,
+ int num_channels) {
+ return acm_->RegisterExternalReceiveCodec(rtp_payload_type, external_decoder,
+ sample_rate_hz, num_channels);
+}
+
void AcmReceiveTestOldApi::Run() {
for (rtc::scoped_ptr<Packet> packet(packet_source_->NextPacket()); packet;
packet.reset(packet_source_->NextPacket())) {
@@ -151,7 +160,8 @@ void AcmReceiveTestOldApi::Run() {
AudioFrame output_frame;
EXPECT_EQ(0, acm_->PlayoutData10Ms(output_freq_hz_, &output_frame));
EXPECT_EQ(output_freq_hz_, output_frame.sample_rate_hz_);
- const int samples_per_block = output_freq_hz_ * 10 / 1000;
+ const size_t samples_per_block =
+ static_cast<size_t>(output_freq_hz_ * 10 / 1000);
EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_);
if (exptected_output_channels_ != kArbitraryChannels) {
if (output_frame.speech_type_ == webrtc::AudioFrame::kPLC) {
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h
index 5e5ff9a0a0e..6c1209739d1 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h
@@ -17,6 +17,7 @@
namespace webrtc {
class AudioCodingModule;
+class AudioDecoder;
struct CodecInst;
namespace test {
@@ -44,6 +45,11 @@ class AcmReceiveTestOldApi {
// files.
void RegisterNetEqTestCodecs();
+ int RegisterExternalReceiveCodec(int rtp_payload_type,
+ AudioDecoder* external_decoder,
+ int sample_rate_hz,
+ int num_channels);
+
// Runs the test and returns true if successful.
void Run();
@@ -58,7 +64,7 @@ class AcmReceiveTestOldApi {
int output_freq_hz_;
NumOutputChannels exptected_output_channels_;
- DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi);
+ RTC_DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi);
};
// This test toggles the output frequency every |toggle_period_ms|. The test
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index ae5a04f25e0..bfcf76ce724 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -15,6 +15,7 @@
#include <algorithm> // sort
#include <vector>
+#include "webrtc/base/checks.h"
#include "webrtc/base/format_macros.h"
#include "webrtc/base/logging.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
@@ -212,51 +213,6 @@ int AcmReceiver::current_sample_rate_hz() const {
return current_sample_rate_hz_;
}
-// TODO(turajs): use one set of enumerators, e.g. the one defined in
-// common_types.h
-// TODO(henrik.lundin): This method is not used any longer. The call hierarchy
-// stops in voe::Channel::SetNetEQPlayoutMode(). Remove it.
-void AcmReceiver::SetPlayoutMode(AudioPlayoutMode mode) {
- enum NetEqPlayoutMode playout_mode = kPlayoutOn;
- switch (mode) {
- case voice:
- playout_mode = kPlayoutOn;
- break;
- case fax: // No change to background noise mode.
- playout_mode = kPlayoutFax;
- break;
- case streaming:
- playout_mode = kPlayoutStreaming;
- break;
- case off:
- playout_mode = kPlayoutOff;
- break;
- }
- neteq_->SetPlayoutMode(playout_mode);
-}
-
-AudioPlayoutMode AcmReceiver::PlayoutMode() const {
- AudioPlayoutMode acm_mode = voice;
- NetEqPlayoutMode mode = neteq_->PlayoutMode();
- switch (mode) {
- case kPlayoutOn:
- acm_mode = voice;
- break;
- case kPlayoutOff:
- acm_mode = off;
- break;
- case kPlayoutFax:
- acm_mode = fax;
- break;
- case kPlayoutStreaming:
- acm_mode = streaming;
- break;
- default:
- assert(false);
- }
- return acm_mode;
-}
-
int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
const uint8_t* incoming_payload,
size_t length_payload) {
@@ -344,7 +300,7 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
enum NetEqOutputType type;
- int samples_per_channel;
+ size_t samples_per_channel;
int num_channels;
bool return_silence = false;
@@ -394,7 +350,7 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
}
// NetEq always returns 10 ms of audio.
- current_sample_rate_hz_ = samples_per_channel * 100;
+ current_sample_rate_hz_ = static_cast<int>(samples_per_channel * 100);
// Update if resampling is required.
bool need_resampling = (desired_freq_hz != -1) &&
@@ -403,18 +359,19 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
if (need_resampling && !resampled_last_output_frame_) {
// Prime the resampler with the last frame.
int16_t temp_output[AudioFrame::kMaxDataSizeSamples];
- samples_per_channel =
+ int samples_per_channel_int =
resampler_.Resample10Msec(last_audio_buffer_.get(),
current_sample_rate_hz_,
desired_freq_hz,
num_channels,
AudioFrame::kMaxDataSizeSamples,
temp_output);
- if (samples_per_channel < 0) {
+ if (samples_per_channel_int < 0) {
LOG(LERROR) << "AcmReceiver::GetAudio - "
"Resampling last_audio_buffer_ failed.";
return -1;
}
+ samples_per_channel = static_cast<size_t>(samples_per_channel_int);
}
// The audio in |audio_buffer_| is tansferred to |audio_frame_| below, either
@@ -422,17 +379,18 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
// TODO(henrik.lundin) Glitches in the output may appear if the output rate
// from NetEq changes. See WebRTC issue 3923.
if (need_resampling) {
- samples_per_channel =
+ int samples_per_channel_int =
resampler_.Resample10Msec(audio_buffer_.get(),
current_sample_rate_hz_,
desired_freq_hz,
num_channels,
AudioFrame::kMaxDataSizeSamples,
audio_frame->data_);
- if (samples_per_channel < 0) {
+ if (samples_per_channel_int < 0) {
LOG(LERROR) << "AcmReceiver::GetAudio - Resampling audio_buffer_ failed.";
return -1;
}
+ samples_per_channel = static_cast<size_t>(samples_per_channel_int);
resampled_last_output_frame_ = true;
} else {
resampled_last_output_frame_ = false;
@@ -448,7 +406,7 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
audio_frame->num_channels_ = num_channels;
audio_frame->samples_per_channel_ = samples_per_channel;
- audio_frame->sample_rate_hz_ = samples_per_channel * 100;
+ audio_frame->sample_rate_hz_ = static_cast<int>(samples_per_channel * 100);
// Should set |vad_activity| before calling SetAudioFrameActivityAndType().
audio_frame->vad_activity_ = previous_audio_activity_;
@@ -476,8 +434,10 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
int channels,
int sample_rate_hz,
AudioDecoder* audio_decoder) {
- assert(acm_codec_id >= 0);
- NetEqDecoder neteq_decoder = ACMCodecDB::neteq_decoders_[acm_codec_id];
+ assert(acm_codec_id >= -1); // -1 means external decoder
+ NetEqDecoder neteq_decoder = (acm_codec_id == -1)
+ ? kDecoderArbitrary
+ : ACMCodecDB::neteq_decoders_[acm_codec_id];
// Make sure the right decoder is registered for Opus.
if (neteq_decoder == kDecoderOpus && channels == 2) {
@@ -491,14 +451,15 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
auto it = decoders_.find(payload_type);
if (it != decoders_.end()) {
const Decoder& decoder = it->second;
- if (decoder.acm_codec_id == acm_codec_id && decoder.channels == channels &&
+ if (acm_codec_id != -1 && decoder.acm_codec_id == acm_codec_id &&
+ decoder.channels == channels &&
decoder.sample_rate_hz == sample_rate_hz) {
// Re-registering the same codec. Do nothing and return.
return 0;
}
- // Changing codec or number of channels. First unregister the old codec,
- // then register the new one.
+ // Changing codec. First unregister the old codec, then register the new
+ // one.
if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK) {
LOG(LERROR) << "Cannot remove payload " << static_cast<int>(payload_type);
return -1;
@@ -647,31 +608,10 @@ void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) {
acm_stat->currentSecondaryDecodedRate = neteq_stat.secondary_decoded_rate;
acm_stat->clockDriftPPM = neteq_stat.clockdrift_ppm;
acm_stat->addedSamples = neteq_stat.added_zero_samples;
-
- std::vector<int> waiting_times;
- neteq_->WaitingTimes(&waiting_times);
- size_t size = waiting_times.size();
- if (size == 0) {
- acm_stat->meanWaitingTimeMs = -1;
- acm_stat->medianWaitingTimeMs = -1;
- acm_stat->minWaitingTimeMs = -1;
- acm_stat->maxWaitingTimeMs = -1;
- } else {
- std::sort(waiting_times.begin(), waiting_times.end());
- if ((size & 0x1) == 0) {
- acm_stat->medianWaitingTimeMs = (waiting_times[size / 2 - 1] +
- waiting_times[size / 2]) / 2;
- } else {
- acm_stat->medianWaitingTimeMs = waiting_times[size / 2];
- }
- acm_stat->minWaitingTimeMs = waiting_times.front();
- acm_stat->maxWaitingTimeMs = waiting_times.back();
- double sum = 0;
- for (size_t i = 0; i < size; ++i) {
- sum += waiting_times[i];
- }
- acm_stat->meanWaitingTimeMs = static_cast<int>(sum / size);
- }
+ acm_stat->meanWaitingTimeMs = neteq_stat.mean_waiting_time_ms;
+ acm_stat->medianWaitingTimeMs = neteq_stat.median_waiting_time_ms;
+ acm_stat->minWaitingTimeMs = neteq_stat.min_waiting_time_ms;
+ acm_stat->maxWaitingTimeMs = neteq_stat.max_waiting_time_ms;
}
int AcmReceiver::DecoderByPayloadType(uint8_t payload_type,
@@ -784,10 +724,11 @@ bool AcmReceiver::GetSilence(int desired_sample_rate_hz, AudioFrame* frame) {
frame->sample_rate_hz_ = current_sample_rate_hz_;
}
- frame->samples_per_channel_ = frame->sample_rate_hz_ / 100; // Always 10 ms.
+ frame->samples_per_channel_ =
+ static_cast<size_t>(frame->sample_rate_hz_ / 100); // Always 10 ms.
frame->speech_type_ = AudioFrame::kCNG;
frame->vad_activity_ = AudioFrame::kVadPassive;
- int samples = frame->samples_per_channel_ * frame->num_channels_;
+ size_t samples = frame->samples_per_channel_ * frame->num_channels_;
memset(frame->data_, 0, samples * sizeof(int16_t));
return true;
}
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
index 46207fd4492..d726264bf99 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
@@ -93,21 +93,24 @@ class AcmReceiver {
// Adds a new codec to the NetEq codec database.
//
// Input:
- // - acm_codec_id : ACM codec ID.
+ // - acm_codec_id : ACM codec ID; -1 means external decoder.
// - payload_type : payload type.
// - sample_rate_hz : sample rate.
- // - audio_decoder : pointer to a decoder object. If it is NULL
- // then NetEq will internally create the decoder
- // object. Otherwise, NetEq will store this pointer
- // as the decoder corresponding with the given
- // payload type. NetEq won't acquire the ownership
- // of this pointer. It is up to the client of this
- // class (ACM) to delete it. By providing
- // |audio_decoder| ACM will have control over the
- // decoder instance of the codec. This is essential
- // for a codec like iSAC which encoder/decoder
- // encoder has to know about decoder (bandwidth
- // estimator that is updated at decoding time).
+ // - audio_decoder : pointer to a decoder object. If it's null, then
+ // NetEq will internally create a decoder object
+ // based on the value of |acm_codec_id| (which
+ // mustn't be -1). Otherwise, NetEq will use the
+ // given decoder for the given payload type. NetEq
+ // won't take ownership of the decoder; it's up to
+ // the caller to delete it when it's no longer
+ // needed.
+ //
+ // Providing an existing decoder object here is
+ // necessary for external decoders, but may also be
+ // used for built-in decoders if NetEq doesn't have
+ // all the info it needs to construct them properly
+ // (e.g. iSAC, where the decoder needs to be paired
+ // with an encoder).
//
// Return value : 0 if OK.
// <0 if NetEq returned an error.
@@ -175,21 +178,6 @@ class AcmReceiver {
int current_sample_rate_hz() const;
//
- // Sets the playout mode.
- //
- // Input:
- // - mode : an enumerator specifying the playout mode.
- //
- void SetPlayoutMode(AudioPlayoutMode mode);
-
- //
- // Get the current playout mode.
- //
- // Return value : The current playout mode.
- //
- AudioPlayoutMode PlayoutMode() const;
-
- //
// Get the current network statistics from NetEq.
//
// Output:
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc
index 6234d4f501c..ff9c91115a5 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc
@@ -265,21 +265,6 @@ TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(SampleRate)) {
}
}
-// Verify that the playout mode is set correctly.
-TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(PlayoutMode)) {
- receiver_->SetPlayoutMode(voice);
- EXPECT_EQ(voice, receiver_->PlayoutMode());
-
- receiver_->SetPlayoutMode(streaming);
- EXPECT_EQ(streaming, receiver_->PlayoutMode());
-
- receiver_->SetPlayoutMode(fax);
- EXPECT_EQ(fax, receiver_->PlayoutMode());
-
- receiver_->SetPlayoutMode(off);
- EXPECT_EQ(off, receiver_->PlayoutMode());
-}
-
TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(PostdecodingVad)) {
receiver_->EnableVad();
EXPECT_TRUE(receiver_->vad_enabled());
@@ -308,7 +293,13 @@ TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(PostdecodingVad)) {
EXPECT_EQ(AudioFrame::kVadUnknown, frame.vad_activity_);
}
-TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(LastAudioCodec)) {
+#ifdef WEBRTC_CODEC_ISAC
+#define IF_ISAC_FLOAT(x) x
+#else
+#define IF_ISAC_FLOAT(x) DISABLED_##x
+#endif
+
+TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(IF_ISAC_FLOAT(LastAudioCodec))) {
const int kCodecId[] = {
ACMCodecDB::kISAC, ACMCodecDB::kPCMA, ACMCodecDB::kISACSWB,
ACMCodecDB::kPCM16Bswb32kHz,
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc
index 5800fb7367f..c30eaf04323 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc
@@ -264,21 +264,6 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(SampleRate)) {
}
}
-// Verify that the playout mode is set correctly.
-TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(PlayoutMode)) {
- receiver_->SetPlayoutMode(voice);
- EXPECT_EQ(voice, receiver_->PlayoutMode());
-
- receiver_->SetPlayoutMode(streaming);
- EXPECT_EQ(streaming, receiver_->PlayoutMode());
-
- receiver_->SetPlayoutMode(fax);
- EXPECT_EQ(fax, receiver_->PlayoutMode());
-
- receiver_->SetPlayoutMode(off);
- EXPECT_EQ(off, receiver_->PlayoutMode());
-}
-
TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(PostdecodingVad)) {
receiver_->EnableVad();
EXPECT_TRUE(receiver_->vad_enabled());
@@ -307,7 +292,14 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(PostdecodingVad)) {
EXPECT_EQ(AudioFrame::kVadUnknown, frame.vad_activity_);
}
-TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(LastAudioCodec)) {
+#ifdef WEBRTC_CODEC_ISAC
+#define IF_ISAC_FLOAT(x) x
+#else
+#define IF_ISAC_FLOAT(x) DISABLED_##x
+#endif
+
+TEST_F(AcmReceiverTestOldApi,
+ DISABLED_ON_ANDROID(IF_ISAC_FLOAT(LastAudioCodec))) {
const int kCodecId[] = {
ACMCodecDB::kISAC, ACMCodecDB::kPCMA, ACMCodecDB::kISACSWB,
ACMCodecDB::kPCM16Bswb32kHz,
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.cc
index 97d87b1b3a4..2650725331b 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.cc
@@ -29,9 +29,9 @@ int ACMResampler::Resample10Msec(const int16_t* in_audio,
int in_freq_hz,
int out_freq_hz,
int num_audio_channels,
- int out_capacity_samples,
+ size_t out_capacity_samples,
int16_t* out_audio) {
- int in_length = in_freq_hz * num_audio_channels / 100;
+ size_t in_length = static_cast<size_t>(in_freq_hz * num_audio_channels / 100);
int out_length = out_freq_hz * num_audio_channels / 100;
if (in_freq_hz == out_freq_hz) {
if (out_capacity_samples < in_length) {
@@ -39,7 +39,7 @@ int ACMResampler::Resample10Msec(const int16_t* in_audio,
return -1;
}
memcpy(out_audio, in_audio, in_length * sizeof(int16_t));
- return in_length / num_audio_channels;
+ return static_cast<int>(in_length / num_audio_channels);
}
if (resampler_.InitializeIfNeeded(in_freq_hz, out_freq_hz,
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.h
index a8fc6b6f26a..a19b0c45694 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_resampler.h
@@ -26,7 +26,7 @@ class ACMResampler {
int in_freq_hz,
int out_freq_hz,
int num_audio_channels,
- int out_capacity_samples,
+ size_t out_capacity_samples,
int16_t* out_audio);
private:
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc
index b96db6b8b12..b05968645cc 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc
@@ -29,7 +29,8 @@ AcmSendTest::AcmSendTest(InputAudioFile* audio_source,
: clock_(0),
audio_source_(audio_source),
source_rate_hz_(source_rate_hz),
- input_block_size_samples_(source_rate_hz_ * kBlockSizeMs / 1000),
+ input_block_size_samples_(
+ static_cast<size_t>(source_rate_hz_ * kBlockSizeMs / 1000)),
codec_registered_(false),
test_duration_ms_(test_duration_ms),
frame_type_(kAudioFrameSpeech),
@@ -70,7 +71,8 @@ Packet* AcmSendTest::NextPacket() {
// Insert audio and process until one packet is produced.
while (clock_.TimeInMilliseconds() < test_duration_ms_) {
clock_.AdvanceTimeMilliseconds(kBlockSizeMs);
- CHECK(audio_source_->Read(input_block_size_samples_, input_frame_.data_));
+ RTC_CHECK(
+ audio_source_->Read(input_block_size_samples_, input_frame_.data_));
if (input_frame_.num_channels_ > 1) {
InputAudioFile::DuplicateInterleaved(input_frame_.data_,
input_block_size_samples_,
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.h
index 4c4db5bd13b..b0d26ba63b2 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test.h
@@ -63,7 +63,7 @@ class AcmSendTest : public AudioPacketizationCallback, public PacketSource {
rtc::scoped_ptr<AudioCoding> acm_;
InputAudioFile* audio_source_;
int source_rate_hz_;
- const int input_block_size_samples_;
+ const size_t input_block_size_samples_;
AudioFrame input_frame_;
bool codec_registered_;
int test_duration_ms_;
@@ -74,7 +74,7 @@ class AcmSendTest : public AudioPacketizationCallback, public PacketSource {
uint16_t sequence_number_;
std::vector<uint8_t> last_payload_vec_;
- DISALLOW_COPY_AND_ASSIGN(AcmSendTest);
+ RTC_DISALLOW_COPY_AND_ASSIGN(AcmSendTest);
};
} // namespace test
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc
index 1819d59d96d..7e2a3c6b6e7 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc
@@ -31,7 +31,8 @@ AcmSendTestOldApi::AcmSendTestOldApi(InputAudioFile* audio_source,
acm_(webrtc::AudioCodingModule::Create(0, &clock_)),
audio_source_(audio_source),
source_rate_hz_(source_rate_hz),
- input_block_size_samples_(source_rate_hz_ * kBlockSizeMs / 1000),
+ input_block_size_samples_(
+ static_cast<size_t>(source_rate_hz_ * kBlockSizeMs / 1000)),
codec_registered_(false),
test_duration_ms_(test_duration_ms),
frame_type_(kAudioFrameSpeech),
@@ -52,8 +53,8 @@ bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
int payload_type,
int frame_size_samples) {
CodecInst codec;
- CHECK_EQ(0, AudioCodingModule::Codec(payload_name, &codec, sampling_freq_hz,
- channels));
+ RTC_CHECK_EQ(0, AudioCodingModule::Codec(payload_name, &codec,
+ sampling_freq_hz, channels));
codec.pltype = payload_type;
codec.pacsize = frame_size_samples;
codec_registered_ = (acm_->RegisterSendCodec(codec) == 0);
@@ -64,7 +65,7 @@ bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
}
bool AcmSendTestOldApi::RegisterExternalCodec(
- AudioEncoderMutable* external_speech_encoder) {
+ AudioEncoder* external_speech_encoder) {
acm_->RegisterExternalSendCodec(external_speech_encoder);
input_frame_.num_channels_ = external_speech_encoder->NumChannels();
assert(input_block_size_samples_ * input_frame_.num_channels_ <=
@@ -83,7 +84,8 @@ Packet* AcmSendTestOldApi::NextPacket() {
// Insert audio and process until one packet is produced.
while (clock_.TimeInMilliseconds() < test_duration_ms_) {
clock_.AdvanceTimeMilliseconds(kBlockSizeMs);
- CHECK(audio_source_->Read(input_block_size_samples_, input_frame_.data_));
+ RTC_CHECK(
+ audio_source_->Read(input_block_size_samples_, input_frame_.data_));
if (input_frame_.num_channels_ > 1) {
InputAudioFile::DuplicateInterleaved(input_frame_.data_,
input_block_size_samples_,
@@ -91,7 +93,7 @@ Packet* AcmSendTestOldApi::NextPacket() {
input_frame_.data_);
}
data_to_send_ = false;
- CHECK_GE(acm_->Add10MsData(input_frame_), 0);
+ RTC_CHECK_GE(acm_->Add10MsData(input_frame_), 0);
input_frame_.timestamp_ += static_cast<uint32_t>(input_block_size_samples_);
if (data_to_send_) {
// Encoded packet received.
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h
index 8cdc2989831..7d17cb117d4 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h
@@ -20,7 +20,7 @@
#include "webrtc/system_wrappers/interface/clock.h"
namespace webrtc {
-class AudioEncoderMutable;
+class AudioEncoder;
namespace test {
class InputAudioFile;
@@ -42,7 +42,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
int frame_size_samples);
// Registers an external send codec. Returns true on success, false otherwise.
- bool RegisterExternalCodec(AudioEncoderMutable* external_speech_encoder);
+ bool RegisterExternalCodec(AudioEncoder* external_speech_encoder);
// Returns the next encoded packet. Returns NULL if the test duration was
// exceeded. Ownership of the packet is handed over to the caller.
@@ -71,7 +71,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
rtc::scoped_ptr<AudioCodingModule> acm_;
InputAudioFile* audio_source_;
int source_rate_hz_;
- const int input_block_size_samples_;
+ const size_t input_block_size_samples_;
AudioFrame input_frame_;
bool codec_registered_;
int test_duration_ms_;
@@ -83,7 +83,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
std::vector<uint8_t> last_payload_vec_;
bool data_to_send_;
- DISALLOW_COPY_AND_ASSIGN(AcmSendTestOldApi);
+ RTC_DISALLOW_COPY_AND_ASSIGN(AcmSendTestOldApi);
};
} // namespace test
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
index 51b9a788961..f502eb3f8c0 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
@@ -105,7 +105,6 @@ AudioCoding::Config::Config()
clock(Clock::GetRealTimeClock()),
transport(nullptr),
vad_callback(nullptr),
- play_dtmf(true),
initial_playout_delay_ms(0),
playout_channels(1),
playout_frequency_hz(32000) {
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi
deleted file mode 100644
index 13b1d4e73fd..00000000000
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi
+++ /dev/null
@@ -1,195 +0,0 @@
-# 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.
-
-{
- 'variables': {
- 'audio_coding_dependencies': [
- 'cng',
- 'g711',
- 'g722',
- 'ilbc',
- 'isac',
- 'isac_fix',
- 'pcm16b',
- 'red',
- '<(webrtc_root)/common.gyp:webrtc_common',
- '<(webrtc_root)/common_audio/common_audio.gyp:common_audio',
- '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
- ],
- 'audio_coding_defines': [],
- 'conditions': [
- ['include_opus==1', {
- 'audio_coding_dependencies': ['webrtc_opus',],
- 'audio_coding_defines': ['WEBRTC_CODEC_OPUS',],
- }],
- ],
- },
- 'targets': [
- {
- 'target_name': 'audio_coding_module',
- 'type': 'static_library',
- 'defines': [
- '<@(audio_coding_defines)',
- ],
- 'dependencies': [
- '<@(audio_coding_dependencies)',
- '<(webrtc_root)/common.gyp:webrtc_common',
- 'neteq',
- ],
- 'include_dirs': [
- '../interface',
- '../../../interface',
- '<(webrtc_root)',
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [
- '../interface',
- '../../../interface',
- '<(webrtc_root)',
- ],
- },
- 'sources': [
- '../interface/audio_coding_module.h',
- '../interface/audio_coding_module_typedefs.h',
- 'acm_codec_database.cc',
- 'acm_codec_database.h',
- 'acm_common_defs.h',
- 'acm_receiver.cc',
- 'acm_receiver.h',
- 'acm_resampler.cc',
- 'acm_resampler.h',
- 'audio_coding_module.cc',
- 'audio_coding_module_impl.cc',
- 'audio_coding_module_impl.h',
- 'call_statistics.cc',
- 'call_statistics.h',
- 'codec_manager.cc',
- 'codec_manager.h',
- 'codec_owner.cc',
- 'codec_owner.h',
- 'initial_delay_manager.cc',
- 'initial_delay_manager.h',
- 'nack.cc',
- 'nack.h',
- ],
- },
- {
- 'target_name': 'acm_dump',
- 'type': 'static_library',
- 'conditions': [
- ['enable_protobuf==1', {
- 'defines': ['RTC_AUDIOCODING_DEBUG_DUMP'],
- 'dependencies': ['acm_dump_proto'],
- }
- ],
- ],
- 'sources': [
- 'acm_dump.h',
- 'acm_dump.cc'
- ],
- },
- ],
- 'conditions': [
- ['enable_protobuf==1', {
- 'targets': [
- {
- 'target_name': 'acm_dump_proto',
- 'type': 'static_library',
- 'sources': ['dump.proto',],
- 'variables': {
- 'proto_in_dir': '.',
- # Workaround to protect against gyp's pathname relativization when
- # this file is included by modules.gyp.
- 'proto_out_protected': 'webrtc/audio_coding',
- 'proto_out_dir': '<(proto_out_protected)',
- },
- 'includes': ['../../../../build/protoc.gypi',],
- },
- ]
- }],
- ['include_tests==1', {
- 'targets': [
- {
- 'target_name': 'acm_receive_test',
- 'type': 'static_library',
- 'defines': [
- '<@(audio_coding_defines)',
- ],
- 'dependencies': [
- '<@(audio_coding_dependencies)',
- 'audio_coding_module',
- 'neteq_unittest_tools',
- '<(DEPTH)/testing/gtest.gyp:gtest',
- ],
- 'sources': [
- 'acm_receive_test.cc',
- 'acm_receive_test.h',
- 'acm_receive_test_oldapi.cc',
- 'acm_receive_test_oldapi.h',
- ],
- }, # acm_receive_test
- {
- 'target_name': 'acm_send_test',
- 'type': 'static_library',
- 'defines': [
- '<@(audio_coding_defines)',
- ],
- 'dependencies': [
- '<@(audio_coding_dependencies)',
- 'audio_coding_module',
- 'neteq_unittest_tools',
- '<(DEPTH)/testing/gtest.gyp:gtest',
- ],
- 'sources': [
- 'acm_send_test.cc',
- 'acm_send_test.h',
- 'acm_send_test_oldapi.cc',
- 'acm_send_test_oldapi.h',
- ],
- }, # acm_send_test
- {
- 'target_name': 'delay_test',
- 'type': 'executable',
- 'dependencies': [
- 'audio_coding_module',
- '<(DEPTH)/testing/gtest.gyp:gtest',
- '<(webrtc_root)/common.gyp:webrtc_common',
- '<(webrtc_root)/test/test.gyp:test_support',
- '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
- '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers_default',
- '<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
- ],
- 'sources': [
- '../test/delay_test.cc',
- '../test/Channel.cc',
- '../test/PCMFile.cc',
- '../test/utility.cc',
- ],
- }, # delay_test
- {
- 'target_name': 'insert_packet_with_timing',
- 'type': 'executable',
- 'dependencies': [
- 'audio_coding_module',
- '<(DEPTH)/testing/gtest.gyp:gtest',
- '<(webrtc_root)/common.gyp:webrtc_common',
- '<(webrtc_root)/test/test.gyp:test_support',
- '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
- '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers_default',
- '<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
- ],
- 'sources': [
- '../test/insert_packet_with_timing.cc',
- '../test/Channel.cc',
- '../test/PCMFile.cc',
- ],
- }, # delay_test
- ],
- }],
- ],
-}
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
index 9c3183271b7..c5d9d3acc75 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
@@ -32,29 +32,6 @@ namespace webrtc {
namespace acm2 {
-enum {
- kACMToneEnd = 999
-};
-
-// Maximum number of bytes in one packet (PCM16B, 20 ms packets, stereo).
-enum {
- kMaxPacketSize = 2560
-};
-
-// Maximum number of payloads that can be packed in one RED packet. For
-// regular RED, we only pack two payloads. In case of dual-streaming, in worst
-// case we might pack 3 payloads in one RED packet.
-enum {
- kNumRedFragmentationVectors = 2,
- kMaxNumFragmentationVectors = 3
-};
-
-// If packet N is arrived all packets prior to N - |kNackThresholdPackets| which
-// are not received are considered as lost, and appear in NACK list.
-enum {
- kNackThresholdPackets = 2
-};
-
namespace {
// TODO(turajs): the same functionality is used in NetEq. If both classes
@@ -76,22 +53,24 @@ bool IsCodecCN(int index) {
}
// Stereo-to-mono can be used as in-place.
-int DownMix(const AudioFrame& frame, int length_out_buff, int16_t* out_buff) {
+int DownMix(const AudioFrame& frame,
+ size_t length_out_buff,
+ int16_t* out_buff) {
if (length_out_buff < frame.samples_per_channel_) {
return -1;
}
- for (int n = 0; n < frame.samples_per_channel_; ++n)
+ for (size_t n = 0; n < frame.samples_per_channel_; ++n)
out_buff[n] = (frame.data_[2 * n] + frame.data_[2 * n + 1]) >> 1;
return 0;
}
// Mono-to-stereo can be used as in-place.
-int UpMix(const AudioFrame& frame, int length_out_buff, int16_t* out_buff) {
+int UpMix(const AudioFrame& frame, size_t length_out_buff, int16_t* out_buff) {
if (length_out_buff < frame.samples_per_channel_) {
return -1;
}
- for (int n = frame.samples_per_channel_; n > 0; --n) {
- int i = n - 1;
+ for (size_t n = frame.samples_per_channel_; n != 0; --n) {
+ size_t i = n - 1;
int16_t sample = frame.data_[i];
out_buff[2 * i + 1] = sample;
out_buff[2 * i] = sample;
@@ -139,7 +118,6 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(
receiver_(config),
bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"),
previous_pltype_(255),
- aux_rtp_header_(NULL),
receiver_initialized_(false),
first_10ms_data_(false),
first_frame_(true),
@@ -153,23 +131,9 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created");
}
-AudioCodingModuleImpl::~AudioCodingModuleImpl() {
- if (aux_rtp_header_ != NULL) {
- delete aux_rtp_header_;
- aux_rtp_header_ = NULL;
- }
-
- delete callback_crit_sect_;
- callback_crit_sect_ = NULL;
-
- delete acm_crit_sect_;
- acm_crit_sect_ = NULL;
- WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_,
- "Destroyed");
-}
+AudioCodingModuleImpl::~AudioCodingModuleImpl() = default;
int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
- uint8_t stream[2 * MAX_PAYLOAD_SIZE_BYTE]; // Make room for 1 RED payload.
AudioEncoder::EncodedInfo encoded_info;
uint8_t previous_pltype;
@@ -191,11 +155,13 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
last_rtp_timestamp_ = rtp_timestamp;
first_frame_ = false;
- encoded_info = audio_encoder->Encode(rtp_timestamp, input_data.audio,
- input_data.length_per_channel,
- sizeof(stream), stream);
+ encode_buffer_.SetSize(audio_encoder->MaxEncodedBytes());
+ encoded_info = audio_encoder->Encode(
+ rtp_timestamp, input_data.audio, input_data.length_per_channel,
+ encode_buffer_.size(), encode_buffer_.data());
+ encode_buffer_.SetSize(encoded_info.encoded_bytes);
bitrate_logger_.MaybeLog(audio_encoder->GetTargetBitrate() / 1000);
- if (encoded_info.encoded_bytes == 0 && !encoded_info.send_even_if_empty) {
+ if (encode_buffer_.size() == 0 && !encoded_info.send_even_if_empty) {
// Not enough data.
return 0;
}
@@ -204,20 +170,20 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
RTPFragmentationHeader my_fragmentation;
ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation);
FrameType frame_type;
- if (encoded_info.encoded_bytes == 0 && encoded_info.send_even_if_empty) {
+ if (encode_buffer_.size() == 0 && encoded_info.send_even_if_empty) {
frame_type = kFrameEmpty;
encoded_info.payload_type = previous_pltype;
} else {
- DCHECK_GT(encoded_info.encoded_bytes, 0u);
+ RTC_DCHECK_GT(encode_buffer_.size(), 0u);
frame_type = encoded_info.speech ? kAudioFrameSpeech : kAudioFrameCN;
}
{
- CriticalSectionScoped lock(callback_crit_sect_);
+ CriticalSectionScoped lock(callback_crit_sect_.get());
if (packetization_callback_) {
packetization_callback_->SendData(
frame_type, encoded_info.payload_type, encoded_info.encoded_timestamp,
- stream, encoded_info.encoded_bytes,
+ encode_buffer_.data(), encode_buffer_.size(),
my_fragmentation.fragmentationVectorSize > 0 ? &my_fragmentation
: nullptr);
}
@@ -228,37 +194,28 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
}
}
previous_pltype_ = encoded_info.payload_type;
- return static_cast<int32_t>(encoded_info.encoded_bytes);
+ return static_cast<int32_t>(encode_buffer_.size());
}
/////////////////////////////////////////
// Sender
//
-// TODO(henrik.lundin): Remove this method; only used in tests.
-int AudioCodingModuleImpl::ResetEncoder() {
- CriticalSectionScoped lock(acm_crit_sect_);
- if (!HaveValidEncoder("ResetEncoder")) {
- return -1;
- }
- return 0;
-}
-
// Can be called multiple times for Codec, CNG, RED.
int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.RegisterEncoder(send_codec);
}
void AudioCodingModuleImpl::RegisterExternalSendCodec(
- AudioEncoderMutable* external_speech_encoder) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ AudioEncoder* external_speech_encoder) {
+ CriticalSectionScoped lock(acm_crit_sect_.get());
codec_manager_.RegisterEncoder(external_speech_encoder);
}
// Get current send codec.
int AudioCodingModuleImpl::SendCodec(CodecInst* current_codec) const {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.GetCodecInst(current_codec);
}
@@ -266,7 +223,7 @@ int AudioCodingModuleImpl::SendCodec(CodecInst* current_codec) const {
int AudioCodingModuleImpl::SendFrequency() const {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
"SendFrequency()");
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
if (!codec_manager_.CurrentEncoder()) {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
@@ -277,53 +234,18 @@ int AudioCodingModuleImpl::SendFrequency() const {
return codec_manager_.CurrentEncoder()->SampleRateHz();
}
-// Get encode bitrate.
-// Adaptive rate codecs return their current encode target rate, while other
-// codecs return there longterm avarage or their fixed rate.
-// TODO(henrik.lundin): Remove; not used.
-int AudioCodingModuleImpl::SendBitrate() const {
- FATAL() << "Deprecated";
- // This return statement is required to workaround a bug in VS2013 Update 4
- // when turning on the whole program optimizations. Without hit the linker
- // will hang because it doesn't seem to find an exit path for this function.
- // This is likely a bug in link.exe and would probably be fixed in VS2015.
- return -1;
- // CriticalSectionScoped lock(acm_crit_sect_);
- //
- // if (!codec_manager_.current_encoder()) {
- // WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
- // "SendBitrate Failed, no codec is registered");
- // return -1;
- // }
- //
- // WebRtcACMCodecParams encoder_param;
- // codec_manager_.current_encoder()->EncoderParams(&encoder_param);
- //
- // return encoder_param.codec_inst.rate;
-}
-
void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
if (codec_manager_.CurrentEncoder()) {
codec_manager_.CurrentEncoder()->SetTargetBitrate(bitrate_bps);
}
}
-// Set available bandwidth, inform the encoder about the estimated bandwidth
-// received from the remote party.
-// TODO(henrik.lundin): Remove; not used.
-int AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(int bw) {
- CriticalSectionScoped lock(acm_crit_sect_);
- FATAL() << "Dead code?";
- return -1;
-// return codecs_[current_send_codec_idx_]->SetEstimatedBandwidth(bw);
-}
-
// Register a transport callback which will be called to deliver
// the encoded buffers.
int AudioCodingModuleImpl::RegisterTransportCallback(
AudioPacketizationCallback* transport) {
- CriticalSectionScoped lock(callback_crit_sect_);
+ CriticalSectionScoped lock(callback_crit_sect_.get());
packetization_callback_ = transport;
return 0;
}
@@ -331,18 +253,17 @@ int AudioCodingModuleImpl::RegisterTransportCallback(
// Add 10MS of raw (PCM) audio data to the encoder.
int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
InputData input_data;
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
int r = Add10MsDataInternal(audio_frame, &input_data);
return r < 0 ? r : Encode(input_data);
}
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
InputData* input_data) {
- if (audio_frame.samples_per_channel_ <= 0) {
+ if (audio_frame.samples_per_channel_ == 0) {
assert(false);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
- "Cannot Add 10 ms audio, payload length is negative or "
- "zero");
+ "Cannot Add 10 ms audio, payload length is zero");
return -1;
}
@@ -354,7 +275,7 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
}
// If the length and frequency matches. We currently just support raw PCM.
- if ((audio_frame.sample_rate_hz_ / 100) !=
+ if (static_cast<size_t>(audio_frame.sample_rate_hz_ / 100) !=
audio_frame.samples_per_channel_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"Cannot Add 10 ms audio, input frequency and length doesn't"
@@ -477,17 +398,19 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
// The result of the resampler is written to output frame.
dest_ptr_audio = preprocess_frame_.data_;
- preprocess_frame_.samples_per_channel_ = resampler_.Resample10Msec(
+ int samples_per_channel = resampler_.Resample10Msec(
src_ptr_audio, in_frame.sample_rate_hz_,
codec_manager_.CurrentEncoder()->SampleRateHz(),
preprocess_frame_.num_channels_, AudioFrame::kMaxDataSizeSamples,
dest_ptr_audio);
- if (preprocess_frame_.samples_per_channel_ < 0) {
+ if (samples_per_channel < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"Cannot add 10 ms audio, resampling failed");
return -1;
}
+ preprocess_frame_.samples_per_channel_ =
+ static_cast<size_t>(samples_per_channel);
preprocess_frame_.sample_rate_hz_ =
codec_manager_.CurrentEncoder()->SampleRateHz();
}
@@ -504,7 +427,7 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
//
bool AudioCodingModuleImpl::REDStatus() const {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.red_enabled();
}
@@ -512,7 +435,7 @@ bool AudioCodingModuleImpl::REDStatus() const {
int AudioCodingModuleImpl::SetREDStatus(
#ifdef WEBRTC_CODEC_RED
bool enable_red) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.SetCopyRed(enable_red) ? 0 : -1;
#else
bool /* enable_red */) {
@@ -527,20 +450,20 @@ int AudioCodingModuleImpl::SetREDStatus(
//
bool AudioCodingModuleImpl::CodecFEC() const {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.codec_fec_enabled();
}
int AudioCodingModuleImpl::SetCodecFEC(bool enable_codec_fec) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.SetCodecFEC(enable_codec_fec);
}
int AudioCodingModuleImpl::SetPacketLossRate(int loss_rate) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
if (HaveValidEncoder("SetPacketLossRate")) {
- codec_manager_.CurrentSpeechEncoder()->SetProjectedPacketLossRate(
- loss_rate / 100.0);
+ codec_manager_.CurrentEncoder()->SetProjectedPacketLossRate(loss_rate /
+ 100.0);
}
return 0;
}
@@ -552,15 +475,15 @@ int AudioCodingModuleImpl::SetVAD(bool enable_dtx,
bool enable_vad,
ACMVADMode mode) {
// Note: |enable_vad| is not used; VAD is enabled based on the DTX setting.
- DCHECK_EQ(enable_dtx, enable_vad);
- CriticalSectionScoped lock(acm_crit_sect_);
+ RTC_DCHECK_EQ(enable_dtx, enable_vad);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return codec_manager_.SetVAD(enable_dtx, mode);
}
// Get VAD/DTX settings.
int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled,
ACMVADMode* mode) const {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
codec_manager_.VAD(dtx_enabled, vad_enabled, mode);
return 0;
}
@@ -570,7 +493,7 @@ int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled,
//
int AudioCodingModuleImpl::InitializeReceiver() {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return InitializeReceiverSafe();
}
@@ -605,21 +528,12 @@ int AudioCodingModuleImpl::InitializeReceiverSafe() {
return 0;
}
-// TODO(turajs): If NetEq opens an API for reseting the state of decoders then
-// implement this method. Otherwise it should be removed. I might be that by
-// removing and registering a decoder we can achieve the effect of resetting.
-// Reset the decoder state.
-// TODO(henrik.lundin): Remove; only used in one test, and does nothing.
-int AudioCodingModuleImpl::ResetDecoder() {
- return 0;
-}
-
// Get current receive frequency.
int AudioCodingModuleImpl::ReceiveFrequency() const {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
"ReceiveFrequency()");
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
int codec_id = receiver_.last_audio_codec_id();
@@ -632,7 +546,7 @@ int AudioCodingModuleImpl::PlayoutFrequency() const {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
"PlayoutFrequency()");
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return receiver_.current_sample_rate_hz();
}
@@ -640,8 +554,8 @@ int AudioCodingModuleImpl::PlayoutFrequency() const {
// Register possible receive codecs, can be called multiple times,
// for codecs, CNG (NB, WB and SWB), DTMF, RED.
int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
- CriticalSectionScoped lock(acm_crit_sect_);
- DCHECK(receiver_initialized_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
+ RTC_DCHECK(receiver_initialized_);
if (codec.channels > 2 || codec.channels < 0) {
LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels;
return -1;
@@ -667,9 +581,32 @@ int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
codec_manager_.GetAudioDecoder(codec));
}
+int AudioCodingModuleImpl::RegisterExternalReceiveCodec(
+ int rtp_payload_type,
+ AudioDecoder* external_decoder,
+ int sample_rate_hz,
+ int num_channels) {
+ CriticalSectionScoped lock(acm_crit_sect_.get());
+ RTC_DCHECK(receiver_initialized_);
+ if (num_channels > 2 || num_channels < 0) {
+ LOG_F(LS_ERROR) << "Unsupported number of channels: " << num_channels;
+ return -1;
+ }
+
+ // Check if the payload-type is valid.
+ if (!ACMCodecDB::ValidPayloadType(rtp_payload_type)) {
+ LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type
+ << " for external decoder.";
+ return -1;
+ }
+
+ return receiver_.AddCodec(-1 /* external */, rtp_payload_type, num_channels,
+ sample_rate_hz, external_decoder);
+}
+
// Get current received codec.
int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
return receiver_.LastAudioCodec(current_codec);
}
@@ -699,33 +636,6 @@ int AudioCodingModuleImpl::SetMaximumPlayoutDelay(int time_ms) {
return receiver_.SetMaximumDelay(time_ms);
}
-// Estimate the Bandwidth based on the incoming stream, needed for one way
-// audio where the RTCP send the BW estimate.
-// This is also done in the RTP module.
-int AudioCodingModuleImpl::DecoderEstimatedBandwidth() const {
- // We can estimate far-end to near-end bandwidth if the iSAC are sent. Check
- // if the last received packets were iSAC packet then retrieve the bandwidth.
- int last_audio_codec_id = receiver_.last_audio_codec_id();
- if (last_audio_codec_id >= 0 &&
- STR_CASE_CMP("ISAC", ACMCodecDB::database_[last_audio_codec_id].plname)) {
- CriticalSectionScoped lock(acm_crit_sect_);
- FATAL() << "Dead code?";
-// return codecs_[last_audio_codec_id]->GetEstimatedBandwidth();
- }
- return -1;
-}
-
-// Set playout mode for: voice, fax, streaming or off.
-int AudioCodingModuleImpl::SetPlayoutMode(AudioPlayoutMode mode) {
- receiver_.SetPlayoutMode(mode);
- return 0; // TODO(turajs): return value is for backward compatibility.
-}
-
-// Get playout mode voice, fax, streaming or off.
-AudioPlayoutMode AudioCodingModuleImpl::PlayoutMode() const {
- return receiver_.PlayoutMode();
-}
-
// Get 10 milliseconds of raw audio data to play out.
// Automatic resample to the requested frequency.
int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz,
@@ -736,7 +646,6 @@ int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz,
"PlayoutData failed, RecOut Failed");
return -1;
}
-
audio_frame->id_ = id_;
return 0;
}
@@ -755,22 +664,24 @@ int AudioCodingModuleImpl::GetNetworkStatistics(NetworkStatistics* statistics) {
int AudioCodingModuleImpl::RegisterVADCallback(ACMVADCallback* vad_callback) {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, id_,
"RegisterVADCallback()");
- CriticalSectionScoped lock(callback_crit_sect_);
+ CriticalSectionScoped lock(callback_crit_sect_.get());
vad_callback_ = vad_callback;
return 0;
}
-// TODO(tlegrand): Modify this function to work for stereo, and add tests.
+// TODO(kwiberg): Remove this method, and have callers call IncomingPacket
+// instead. The translation logic and state belong with them, not with
+// AudioCodingModuleImpl.
int AudioCodingModuleImpl::IncomingPayload(const uint8_t* incoming_payload,
size_t payload_length,
uint8_t payload_type,
uint32_t timestamp) {
// We are not acquiring any lock when interacting with |aux_rtp_header_| no
// other method uses this member variable.
- if (aux_rtp_header_ == NULL) {
+ if (!aux_rtp_header_) {
// This is the first time that we are using |dummy_rtp_header_|
// so we have to create it.
- aux_rtp_header_ = new WebRtcRTPHeader;
+ aux_rtp_header_.reset(new WebRtcRTPHeader);
aux_rtp_header_->header.payloadType = payload_type;
// Don't matter in this case.
aux_rtp_header_->header.ssrc = 0;
@@ -787,124 +698,58 @@ int AudioCodingModuleImpl::IncomingPayload(const uint8_t* incoming_payload,
return 0;
}
-int AudioCodingModuleImpl::ReplaceInternalDTXWithWebRtc(bool use_webrtc_dtx) {
- CriticalSectionScoped lock(acm_crit_sect_);
-
- if (!HaveValidEncoder("ReplaceInternalDTXWithWebRtc")) {
- WEBRTC_TRACE(
- webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
- "Cannot replace codec internal DTX when no send codec is registered.");
- return -1;
- }
-
- FATAL() << "Dead code?";
-// int res = codecs_[current_send_codec_idx_]->ReplaceInternalDTX(
-// use_webrtc_dtx);
- // Check if VAD is turned on, or if there is any error.
-// if (res == 1) {
-// vad_enabled_ = true;
-// } else if (res < 0) {
-// WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
-// "Failed to set ReplaceInternalDTXWithWebRtc(%d)",
-// use_webrtc_dtx);
-// return res;
-// }
-
- return 0;
-}
-
-int AudioCodingModuleImpl::IsInternalDTXReplacedWithWebRtc(
- bool* uses_webrtc_dtx) {
- *uses_webrtc_dtx = true;
- return 0;
-}
-
-// TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine.
-int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) {
- CriticalSectionScoped lock(acm_crit_sect_);
-
- if (!HaveValidEncoder("SetISACMaxRate")) {
- return -1;
- }
-
- codec_manager_.CurrentSpeechEncoder()->SetMaxRate(max_bit_per_sec);
- return 0;
-}
-
-// TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine.
-int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) {
- CriticalSectionScoped lock(acm_crit_sect_);
-
- if (!HaveValidEncoder("SetISACMaxPayloadSize")) {
- return -1;
- }
-
- codec_manager_.CurrentSpeechEncoder()->SetMaxPayloadSize(max_size_bytes);
- return 0;
-}
-
-// TODO(henrik.lundin): Remove? Only used in tests.
-int AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
- int frame_size_ms,
- int rate_bit_per_sec,
- bool enforce_frame_size) {
- CriticalSectionScoped lock(acm_crit_sect_);
-
- if (!HaveValidEncoder("ConfigISACBandwidthEstimator")) {
- return -1;
- }
-
- FATAL() << "Dead code?";
- return -1;
-// return codecs_[current_send_codec_idx_]->ConfigISACBandwidthEstimator(
-// frame_size_ms, rate_bit_per_sec, enforce_frame_size);
-}
-
int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
if (!HaveValidEncoder("SetOpusApplication")) {
return -1;
}
- AudioEncoderMutable::Application app;
+ if (!codec_manager_.CurrentEncoderIsOpus())
+ return -1;
+ AudioEncoder::Application app;
switch (application) {
case kVoip:
- app = AudioEncoderMutable::kApplicationSpeech;
+ app = AudioEncoder::Application::kSpeech;
break;
case kAudio:
- app = AudioEncoderMutable::kApplicationAudio;
+ app = AudioEncoder::Application::kAudio;
break;
default:
FATAL();
return 0;
}
- return codec_manager_.CurrentSpeechEncoder()->SetApplication(app) ? 0 : -1;
+ return codec_manager_.CurrentEncoder()->SetApplication(app) ? 0 : -1;
}
// Informs Opus encoder of the maximum playback rate the receiver will render.
int AudioCodingModuleImpl::SetOpusMaxPlaybackRate(int frequency_hz) {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
if (!HaveValidEncoder("SetOpusMaxPlaybackRate")) {
return -1;
}
- return codec_manager_.CurrentSpeechEncoder()->SetMaxPlaybackRate(frequency_hz)
- ? 0
- : -1;
+ if (!codec_manager_.CurrentEncoderIsOpus())
+ return -1;
+ codec_manager_.CurrentEncoder()->SetMaxPlaybackRate(frequency_hz);
+ return 0;
}
int AudioCodingModuleImpl::EnableOpusDtx() {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
if (!HaveValidEncoder("EnableOpusDtx")) {
return -1;
}
- return codec_manager_.CurrentSpeechEncoder()->SetDtx(true) ? 0 : -1;
+ if (!codec_manager_.CurrentEncoderIsOpus())
+ return -1;
+ return codec_manager_.CurrentEncoder()->SetDtx(true) ? 0 : -1;
}
int AudioCodingModuleImpl::DisableOpusDtx() {
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
if (!HaveValidEncoder("DisableOpusDtx")) {
return -1;
}
- return codec_manager_.CurrentSpeechEncoder()->SetDtx(false) ? 0 : -1;
+ if (!codec_manager_.CurrentEncoderIsOpus())
+ return -1;
+ return codec_manager_.CurrentEncoder()->SetDtx(false) ? 0 : -1;
}
int AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) {
@@ -924,29 +769,9 @@ int AudioCodingModuleImpl::UnregisterReceiveCodec(uint8_t payload_type) {
return receiver_.RemoveCodec(payload_type);
}
-// TODO(turajs): correct the type of |length_bytes| when it is corrected in
-// GenericCodec.
-int AudioCodingModuleImpl::REDPayloadISAC(int isac_rate,
- int isac_bw_estimate,
- uint8_t* payload,
- int16_t* length_bytes) {
- CriticalSectionScoped lock(acm_crit_sect_);
- if (!HaveValidEncoder("EncodeData")) {
- return -1;
- }
- FATAL() << "Dead code?";
- return -1;
-// int status;
-// status = codecs_[current_send_codec_idx_]->REDPayloadISAC(isac_rate,
-// isac_bw_estimate,
-// payload,
-// length_bytes);
-// return status;
-}
-
int AudioCodingModuleImpl::SetInitialPlayoutDelay(int delay_ms) {
{
- CriticalSectionScoped lock(acm_crit_sect_);
+ CriticalSectionScoped lock(acm_crit_sect_.get());
// Initialize receiver, if it is not initialized. Otherwise, initial delay
// is reset upon initialization of the receiver.
if (!receiver_initialized_)
@@ -955,14 +780,6 @@ int AudioCodingModuleImpl::SetInitialPlayoutDelay(int delay_ms) {
return receiver_.SetInitialDelay(delay_ms);
}
-int AudioCodingModuleImpl::SetDtmfPlayoutStatus(bool enable) {
- return 0;
-}
-
-bool AudioCodingModuleImpl::DtmfPlayoutStatus() const {
- return true;
-}
-
int AudioCodingModuleImpl::EnableNack(size_t max_nack_list_size) {
return receiver_.EnableNack(max_nack_list_size);
}
@@ -992,7 +809,6 @@ AudioCodingImpl::AudioCodingImpl(const Config& config) {
acm_old_.reset(new acm2::AudioCodingModuleImpl(config_old));
acm_old_->RegisterTransportCallback(config.transport);
acm_old_->RegisterVADCallback(config.vad_callback);
- acm_old_->SetDtmfPlayoutStatus(config.play_dtmf);
if (config.initial_playout_delay_ms > 0) {
acm_old_->SetInitialPlayoutDelay(config.initial_playout_delay_ms);
}
@@ -1040,7 +856,7 @@ const CodecInst* AudioCodingImpl::GetSenderCodecInst() {
int AudioCodingImpl::Add10MsAudio(const AudioFrame& audio_frame) {
acm2::AudioCodingModuleImpl::InputData input_data;
- CriticalSectionScoped lock(acm_old_->acm_crit_sect_);
+ CriticalSectionScoped lock(acm_old_->acm_crit_sect_.get());
if (acm_old_->Add10MsDataInternal(audio_frame, &input_data) != 0)
return -1;
return acm_old_->Encode(input_data);
@@ -1149,7 +965,6 @@ bool AudioCodingImpl::MapCodecTypeToParameters(int codec_type,
int* sample_rate_hz,
int* channels) {
switch (codec_type) {
-#ifdef WEBRTC_CODEC_PCM16
case acm2::ACMCodecDB::kPCM16B:
*codec_name = "L16";
*sample_rate_hz = 8000;
@@ -1180,7 +995,6 @@ bool AudioCodingImpl::MapCodecTypeToParameters(int codec_type,
*sample_rate_hz = 32000;
*channels = 2;
break;
-#endif
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
case acm2::ACMCodecDB::kISAC:
*codec_name = "ISAC";
@@ -1266,13 +1080,11 @@ bool AudioCodingImpl::MapCodecTypeToParameters(int codec_type,
*sample_rate_hz = 8000;
*channels = 1;
break;
-#ifdef WEBRTC_CODEC_AVT
case acm2::ACMCodecDB::kAVT:
*codec_name = "telephone-event";
*sample_rate_hz = 8000;
*channels = 1;
break;
-#endif
default:
FATAL() << "Codec type " << codec_type << " not supported.";
}
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
index 19ca01bf9ed..fe9215bac0a 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
@@ -13,6 +13,7 @@
#include <vector>
+#include "webrtc/base/buffer.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/common_types.h"
@@ -29,9 +30,7 @@ class AudioCodingImpl;
namespace acm2 {
-class ACMDTMFDetection;
-
-class AudioCodingModuleImpl : public AudioCodingModule {
+class AudioCodingModuleImpl final : public AudioCodingModule {
public:
friend webrtc::AudioCodingImpl;
@@ -42,14 +41,11 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// Sender
//
- // Reset send codec.
- int ResetEncoder() override;
-
// Can be called multiple times for Codec, CNG, RED.
int RegisterSendCodec(const CodecInst& send_codec) override;
void RegisterExternalSendCodec(
- AudioEncoderMutable* external_speech_encoder) override;
+ AudioEncoder* external_speech_encoder) override;
// Get current send codec.
int SendCodec(CodecInst* current_codec) const override;
@@ -57,20 +53,11 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// Get current send frequency.
int SendFrequency() const override;
- // Get encode bit-rate.
- // Adaptive rate codecs return their current encode target rate, while other
- // codecs return there long-term average or their fixed rate.
- int SendBitrate() const override;
-
// Sets the bitrate to the specified value in bits/sec. In case the codec does
// not support the requested value it will choose an appropriate value
// instead.
void SetBitRate(int bitrate_bps) override;
- // Set available bandwidth, inform the encoder about the
- // estimated bandwidth received from the remote party.
- int SetReceivedEstimatedBandwidth(int bw) override;
-
// Register a transport callback which will be
// called to deliver the encoded buffers.
int RegisterTransportCallback(AudioPacketizationCallback* transport) override;
@@ -124,9 +111,6 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// Initialize receiver, resets codec database etc.
int InitializeReceiver() override;
- // Reset the decoder state.
- int ResetDecoder() override;
-
// Get current receive frequency.
int ReceiveFrequency() const override;
@@ -137,6 +121,11 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// for codecs, CNG, DTMF, RED.
int RegisterReceiveCodec(const CodecInst& receive_codec) override;
+ int RegisterExternalReceiveCodec(int rtp_payload_type,
+ AudioDecoder* external_decoder,
+ int sample_rate_hz,
+ int num_channels) override;
+
// Get current received codec.
int ReceiveCodec(CodecInst* current_codec) const override;
@@ -165,27 +154,6 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// audio is accumulated in NetEq buffer, then starts decoding payloads.
int SetInitialPlayoutDelay(int delay_ms) override;
- // TODO(turajs): DTMF playout is always activated in NetEq these APIs should
- // be removed, as well as all VoE related APIs and methods.
- //
- // Configure Dtmf playout status i.e on/off playout the incoming outband Dtmf
- // tone.
- int SetDtmfPlayoutStatus(bool enable) override;
-
- // Get Dtmf playout status.
- bool DtmfPlayoutStatus() const override;
-
- // Estimate the Bandwidth based on the incoming stream, needed
- // for one way audio where the RTCP send the BW estimate.
- // This is also done in the RTP module .
- int DecoderEstimatedBandwidth() const override;
-
- // Set playout mode voice, fax.
- int SetPlayoutMode(AudioPlayoutMode mode) override;
-
- // Get playout mode voice, fax.
- AudioPlayoutMode PlayoutMode() const override;
-
// Get playout timestamp.
int PlayoutTimestamp(uint32_t* timestamp) override;
@@ -199,26 +167,6 @@ class AudioCodingModuleImpl : public AudioCodingModule {
int GetNetworkStatistics(NetworkStatistics* statistics) override;
- // GET RED payload for iSAC. The method id called when 'this' ACM is
- // the default ACM.
- // TODO(henrik.lundin) Not used. Remove?
- int REDPayloadISAC(int isac_rate,
- int isac_bw_estimate,
- uint8_t* payload,
- int16_t* length_bytes);
-
- int ReplaceInternalDTXWithWebRtc(bool use_webrtc_dtx) override;
-
- int IsInternalDTXReplacedWithWebRtc(bool* uses_webrtc_dtx) override;
-
- int SetISACMaxRate(int max_bit_per_sec) override;
-
- int SetISACMaxPayloadSize(int max_size_bytes) override;
-
- int ConfigISACBandwidthEstimator(int frame_size_ms,
- int rate_bit_per_sec,
- bool enforce_frame_size = false) override;
-
int SetOpusApplication(OpusApplicationMode application) override;
// If current send codec is Opus, informs it about the maximum playback rate
@@ -243,7 +191,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
struct InputData {
uint32_t input_timestamp;
const int16_t* audio;
- uint16_t length_per_channel;
+ size_t length_per_channel;
uint8_t audio_channel;
// If a re-mix is required (up or down), this buffer will store a re-mixed
// version of the input.
@@ -295,7 +243,8 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// to |index|.
int UpdateUponReceivingCodec(int index);
- CriticalSectionWrapper* acm_crit_sect_;
+ const rtc::scoped_ptr<CriticalSectionWrapper> acm_crit_sect_;
+ rtc::Buffer encode_buffer_ GUARDED_BY(acm_crit_sect_);
int id_; // TODO(henrik.lundin) Make const.
uint32_t expected_codec_ts_ GUARDED_BY(acm_crit_sect_);
uint32_t expected_in_ts_ GUARDED_BY(acm_crit_sect_);
@@ -313,7 +262,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// IMPORTANT: this variable is only used in IncomingPayload(), therefore,
// no lock acquired when interacting with this variable. If it is going to
// be used in other methods, locks need to be taken.
- WebRtcRTPHeader* aux_rtp_header_;
+ rtc::scoped_ptr<WebRtcRTPHeader> aux_rtp_header_;
bool receiver_initialized_ GUARDED_BY(acm_crit_sect_);
@@ -324,7 +273,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
uint32_t last_timestamp_ GUARDED_BY(acm_crit_sect_);
uint32_t last_rtp_timestamp_ GUARDED_BY(acm_crit_sect_);
- CriticalSectionWrapper* callback_crit_sect_;
+ const rtc::scoped_ptr<CriticalSectionWrapper> callback_crit_sect_;
AudioPacketizationCallback* packetization_callback_
GUARDED_BY(callback_crit_sect_);
ACMVADCallback* vad_callback_ GUARDED_BY(callback_crit_sect_);
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
index eea51a3489e..c12baf3f404 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
@@ -272,7 +272,8 @@ TEST_F(AudioCodingModuleTest, VerifyOutputFrame) {
EXPECT_TRUE(acm_->Get10MsAudio(&audio_frame));
EXPECT_EQ(0u, audio_frame.timestamp_);
EXPECT_GT(audio_frame.num_channels_, 0);
- EXPECT_EQ(kSampleRateHz / 100, audio_frame.samples_per_channel_);
+ EXPECT_EQ(static_cast<size_t>(kSampleRateHz / 100),
+ audio_frame.samples_per_channel_);
EXPECT_EQ(kSampleRateHz, audio_frame.sample_rate_hz_);
}
@@ -503,7 +504,13 @@ class AcmIsacMtTest : public AudioCodingModuleMtTest {
test::AudioLoop audio_loop_;
};
-TEST_F(AcmIsacMtTest, DoTest) {
+#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
+#define IF_ISAC(x) x
+#else
+#define IF_ISAC(x) DISABLED_##x
+#endif
+
+TEST_F(AcmIsacMtTest, IF_ISAC(DoTest)) {
EXPECT_EQ(kEventSignaled, RunTest());
}
@@ -558,13 +565,20 @@ class AcmReceiverBitExactness : public ::testing::Test {
}
};
+#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISAC)) && \
+ defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722)
+#define IF_ALL_CODECS(x) x
+#else
+#define IF_ALL_CODECS(x) DISABLED_##x
+#endif
+
// Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199
#if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64)
#define MAYBE_8kHzOutput DISABLED_8kHzOutput
#else
#define MAYBE_8kHzOutput 8kHzOutput
#endif
-TEST_F(AcmReceiverBitExactness, MAYBE_8kHzOutput) {
+TEST_F(AcmReceiverBitExactness, IF_ALL_CODECS(MAYBE_8kHzOutput)) {
Run(8000,
PlatformChecksum("dcee98c623b147ebe1b40dd30efa896e",
"adc92e173f908f93b96ba5844209815a",
@@ -577,7 +591,7 @@ TEST_F(AcmReceiverBitExactness, MAYBE_8kHzOutput) {
#else
#define MAYBE_16kHzOutput 16kHzOutput
#endif
-TEST_F(AcmReceiverBitExactness, MAYBE_16kHzOutput) {
+TEST_F(AcmReceiverBitExactness, IF_ALL_CODECS(MAYBE_16kHzOutput)) {
Run(16000,
PlatformChecksum("f790e7a8cce4e2c8b7bb5e0e4c5dac0d",
"8cffa6abcb3e18e33b9d857666dff66a",
@@ -590,7 +604,7 @@ TEST_F(AcmReceiverBitExactness, MAYBE_16kHzOutput) {
#else
#define MAYBE_32kHzOutput 32kHzOutput
#endif
-TEST_F(AcmReceiverBitExactness, MAYBE_32kHzOutput) {
+TEST_F(AcmReceiverBitExactness, IF_ALL_CODECS(MAYBE_32kHzOutput)) {
Run(32000,
PlatformChecksum("306e0d990ee6e92de3fbecc0123ece37",
"3e126fe894720c3f85edadcc91964ba5",
@@ -603,7 +617,7 @@ TEST_F(AcmReceiverBitExactness, MAYBE_32kHzOutput) {
#else
#define MAYBE_48kHzOutput 48kHzOutput
#endif
-TEST_F(AcmReceiverBitExactness, MAYBE_48kHzOutput) {
+TEST_F(AcmReceiverBitExactness, IF_ALL_CODECS(MAYBE_48kHzOutput)) {
Run(48000,
PlatformChecksum("aa7c232f63a67b2a72703593bdd172e0",
"0155665e93067c4e89256b944dd11999",
@@ -769,7 +783,7 @@ class AcmSenderBitExactness : public ::testing::Test,
#else
#define MAYBE_IsacWb30ms IsacWb30ms
#endif
-TEST_F(AcmSenderBitExactness, MAYBE_IsacWb30ms) {
+TEST_F(AcmSenderBitExactness, IF_ISAC(MAYBE_IsacWb30ms)) {
ASSERT_NO_FATAL_FAILURE(SetUpTest(acm2::ACMCodecDB::kISAC, 1, 103, 480, 480));
Run(AcmReceiverBitExactness::PlatformChecksum(
"c7e5bdadfa2871df95639fcc297cf23d",
@@ -789,7 +803,7 @@ TEST_F(AcmSenderBitExactness, MAYBE_IsacWb30ms) {
#else
#define MAYBE_IsacWb60ms IsacWb60ms
#endif
-TEST_F(AcmSenderBitExactness, MAYBE_IsacWb60ms) {
+TEST_F(AcmSenderBitExactness, IF_ISAC(MAYBE_IsacWb60ms)) {
ASSERT_NO_FATAL_FAILURE(SetUpTest(acm2::ACMCodecDB::kISAC, 1, 103, 960, 960));
Run(AcmReceiverBitExactness::PlatformChecksum(
"14d63c5f08127d280e722e3191b73bdd",
@@ -803,7 +817,13 @@ TEST_F(AcmSenderBitExactness, MAYBE_IsacWb60ms) {
test::AcmReceiveTest::kMonoOutput);
}
-TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(IsacSwb30ms)) {
+#ifdef WEBRTC_CODEC_ISAC
+#define IF_ISAC_FLOAT(x) x
+#else
+#define IF_ISAC_FLOAT(x) DISABLED_##x
+#endif
+
+TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(IF_ISAC_FLOAT(IsacSwb30ms))) {
ASSERT_NO_FATAL_FAILURE(
SetUpTest(acm2::ACMCodecDB::kISACSWB, 1, 104, 960, 960));
Run(AcmReceiverBitExactness::PlatformChecksum(
@@ -904,7 +924,13 @@ TEST_F(AcmSenderBitExactness, Pcma_stereo_20ms) {
test::AcmReceiveTest::kStereoOutput);
}
-TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(Ilbc_30ms)) {
+#ifdef WEBRTC_CODEC_ILBC
+#define IF_ILBC(x) x
+#else
+#define IF_ILBC(x) DISABLED_##x
+#endif
+
+TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(IF_ILBC(Ilbc_30ms))) {
ASSERT_NO_FATAL_FAILURE(SetUpTest(acm2::ACMCodecDB::kILBC, 1, 102, 240, 240));
Run(AcmReceiverBitExactness::PlatformChecksum(
"7b6ec10910debd9af08011d3ed5249f7",
@@ -918,7 +944,13 @@ TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(Ilbc_30ms)) {
test::AcmReceiveTest::kMonoOutput);
}
-TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(G722_20ms)) {
+#ifdef WEBRTC_CODEC_G722
+#define IF_G722(x) x
+#else
+#define IF_G722(x) DISABLED_##x
+#endif
+
+TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(IF_G722(G722_20ms))) {
ASSERT_NO_FATAL_FAILURE(SetUpTest(acm2::ACMCodecDB::kG722, 1, 9, 320, 160));
Run(AcmReceiverBitExactness::PlatformChecksum(
"7d759436f2533582950d148b5161a36c",
@@ -932,7 +964,7 @@ TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(G722_20ms)) {
test::AcmReceiveTest::kMonoOutput);
}
-TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(G722_stereo_20ms)) {
+TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(IF_G722(G722_stereo_20ms))) {
ASSERT_NO_FATAL_FAILURE(
SetUpTest(acm2::ACMCodecDB::kG722_2ch, 2, 119, 320, 160));
Run(AcmReceiverBitExactness::PlatformChecksum(
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
index 568ae1ebe7f..01c8bb8e78e 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
@@ -16,6 +16,7 @@
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
+#include "webrtc/modules/audio_coding/codecs/g711/include/audio_decoder_pcm.h"
#include "webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h"
#include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h"
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
@@ -23,6 +24,8 @@
#include "webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
+#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
+#include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
#include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h"
#include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
#include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h"
@@ -312,7 +315,8 @@ TEST_F(AudioCodingModuleTestOldApi, VerifyOutputFrame) {
EXPECT_EQ(id_, audio_frame.id_);
EXPECT_EQ(0u, audio_frame.timestamp_);
EXPECT_GT(audio_frame.num_channels_, 0);
- EXPECT_EQ(kSampleRateHz / 100, audio_frame.samples_per_channel_);
+ EXPECT_EQ(static_cast<size_t>(kSampleRateHz / 100),
+ audio_frame.samples_per_channel_);
EXPECT_EQ(kSampleRateHz, audio_frame.sample_rate_hz_);
}
@@ -338,9 +342,16 @@ TEST_F(AudioCodingModuleTestOldApi, TransportCallbackIsInvokedForEachPacket) {
EXPECT_EQ(kAudioFrameSpeech, packet_cb_.last_frame_type());
}
+#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
+#define IF_ISAC(x) x
+#else
+#define IF_ISAC(x) DISABLED_##x
+#endif
+
// Verifies that the RTP timestamp series is not reset when the codec is
// changed.
-TEST_F(AudioCodingModuleTestOldApi, TimestampSeriesContinuesWhenCodecChanges) {
+TEST_F(AudioCodingModuleTestOldApi,
+ IF_ISAC(TimestampSeriesContinuesWhenCodecChanges)) {
RegisterCodec(); // This registers the default codec.
uint32_t expected_ts = input_frame_.timestamp_;
int blocks_per_packet = codec_.pacsize / (kSampleRateHz / 100);
@@ -696,7 +707,7 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
test::AudioLoop audio_loop_;
};
-TEST_F(AcmIsacMtTestOldApi, DISABLED_ON_IOS(DoTest)) {
+TEST_F(AcmIsacMtTestOldApi, DISABLED_ON_IOS(IF_ISAC(DoTest))) {
EXPECT_EQ(kEventSignaled, RunTest());
}
@@ -721,9 +732,9 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
receive_packet_count_(0),
next_insert_packet_time_ms_(0),
fake_clock_(new SimulatedClock(0)) {
- AudioEncoderDecoderIsac::Config config;
+ AudioEncoderIsac::Config config;
config.payload_type = kPayloadType;
- isac_encoder_.reset(new AudioEncoderDecoderIsac(config));
+ isac_encoder_.reset(new AudioEncoderIsac(config));
clock_ = fake_clock_.get();
}
@@ -845,12 +856,12 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
bool codec_registered_ GUARDED_BY(crit_sect_);
int receive_packet_count_ GUARDED_BY(crit_sect_);
int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_);
- rtc::scoped_ptr<AudioEncoderDecoderIsac> isac_encoder_;
+ rtc::scoped_ptr<AudioEncoderIsac> isac_encoder_;
rtc::scoped_ptr<SimulatedClock> fake_clock_;
test::AudioLoop audio_loop_;
};
-TEST_F(AcmReRegisterIsacMtTestOldApi, DISABLED_ON_IOS(DoTest)) {
+TEST_F(AcmReRegisterIsacMtTestOldApi, DISABLED_ON_IOS(IF_ISAC(DoTest))) {
EXPECT_EQ(kEventSignaled, RunTest());
}
@@ -873,7 +884,16 @@ class AcmReceiverBitExactnessOldApi : public ::testing::Test {
}
protected:
- void Run(int output_freq_hz, const std::string& checksum_ref) {
+ struct ExternalDecoder {
+ int rtp_payload_type;
+ AudioDecoder* external_decoder;
+ int sample_rate_hz;
+ int num_channels;
+ };
+
+ void Run(int output_freq_hz,
+ const std::string& checksum_ref,
+ const std::vector<ExternalDecoder>& external_decoders) {
const std::string input_file_name =
webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp");
rtc::scoped_ptr<test::RtpFileSource> packet_source(
@@ -901,6 +921,11 @@ class AcmReceiverBitExactnessOldApi : public ::testing::Test {
output_freq_hz,
test::AcmReceiveTestOldApi::kArbitraryChannels);
ASSERT_NO_FATAL_FAILURE(test.RegisterNetEqTestCodecs());
+ for (const auto& ed : external_decoders) {
+ ASSERT_EQ(0, test.RegisterExternalReceiveCodec(
+ ed.rtp_payload_type, ed.external_decoder,
+ ed.sample_rate_hz, ed.num_channels));
+ }
test.Run();
std::string checksum_string = checksum.Finish();
@@ -908,17 +933,24 @@ class AcmReceiverBitExactnessOldApi : public ::testing::Test {
}
};
+#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISAC)) && \
+ defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722)
+#define IF_ALL_CODECS(x) x
+#else
+#define IF_ALL_CODECS(x) DISABLED_##x
+#endif
+
// Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199
#if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64)
#define MAYBE_8kHzOutput DISABLED_8kHzOutput
#else
#define MAYBE_8kHzOutput 8kHzOutput
#endif
-TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_8kHzOutput) {
- Run(8000,
- PlatformChecksum("dcee98c623b147ebe1b40dd30efa896e",
- "adc92e173f908f93b96ba5844209815a",
- "908002dc01fc4eb1d2be24eb1d3f354b"));
+TEST_F(AcmReceiverBitExactnessOldApi, IF_ALL_CODECS(MAYBE_8kHzOutput)) {
+ Run(8000, PlatformChecksum("dcee98c623b147ebe1b40dd30efa896e",
+ "adc92e173f908f93b96ba5844209815a",
+ "908002dc01fc4eb1d2be24eb1d3f354b"),
+ std::vector<ExternalDecoder>());
}
// Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199
@@ -927,11 +959,11 @@ TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_8kHzOutput) {
#else
#define MAYBE_16kHzOutput 16kHzOutput
#endif
-TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_16kHzOutput) {
- Run(16000,
- PlatformChecksum("f790e7a8cce4e2c8b7bb5e0e4c5dac0d",
- "8cffa6abcb3e18e33b9d857666dff66a",
- "a909560b5ca49fa472b17b7b277195e9"));
+TEST_F(AcmReceiverBitExactnessOldApi, IF_ALL_CODECS(MAYBE_16kHzOutput)) {
+ Run(16000, PlatformChecksum("f790e7a8cce4e2c8b7bb5e0e4c5dac0d",
+ "8cffa6abcb3e18e33b9d857666dff66a",
+ "a909560b5ca49fa472b17b7b277195e9"),
+ std::vector<ExternalDecoder>());
}
// Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199
@@ -940,11 +972,11 @@ TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_16kHzOutput) {
#else
#define MAYBE_32kHzOutput 32kHzOutput
#endif
-TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_32kHzOutput) {
- Run(32000,
- PlatformChecksum("306e0d990ee6e92de3fbecc0123ece37",
- "3e126fe894720c3f85edadcc91964ba5",
- "441aab4b347fb3db4e9244337aca8d8e"));
+TEST_F(AcmReceiverBitExactnessOldApi, IF_ALL_CODECS(MAYBE_32kHzOutput)) {
+ Run(32000, PlatformChecksum("306e0d990ee6e92de3fbecc0123ece37",
+ "3e126fe894720c3f85edadcc91964ba5",
+ "441aab4b347fb3db4e9244337aca8d8e"),
+ std::vector<ExternalDecoder>());
}
// Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199
@@ -953,11 +985,54 @@ TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_32kHzOutput) {
#else
#define MAYBE_48kHzOutput 48kHzOutput
#endif
-TEST_F(AcmReceiverBitExactnessOldApi, MAYBE_48kHzOutput) {
- Run(48000,
- PlatformChecksum("aa7c232f63a67b2a72703593bdd172e0",
- "0155665e93067c4e89256b944dd11999",
- "4ee2730fa1daae755e8a8fd3abd779ec"));
+TEST_F(AcmReceiverBitExactnessOldApi, IF_ALL_CODECS(MAYBE_48kHzOutput)) {
+ Run(48000, PlatformChecksum("aa7c232f63a67b2a72703593bdd172e0",
+ "0155665e93067c4e89256b944dd11999",
+ "4ee2730fa1daae755e8a8fd3abd779ec"),
+ std::vector<ExternalDecoder>());
+}
+
+// Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4199
+#if defined(WEBRTC_ANDROID) && defined(__aarch64__)
+#define MAYBE_48kHzOutputExternalDecoder DISABLED_48kHzOutputExternalDecoder
+#else
+#define MAYBE_48kHzOutputExternalDecoder 48kHzOutputExternalDecoder
+#endif
+TEST_F(AcmReceiverBitExactnessOldApi,
+ IF_ALL_CODECS(MAYBE_48kHzOutputExternalDecoder)) {
+ AudioDecoderPcmU decoder(1);
+ MockAudioDecoder mock_decoder;
+ // Set expectations on the mock decoder and also delegate the calls to the
+ // real decoder.
+ EXPECT_CALL(mock_decoder, IncomingPacket(_, _, _, _, _))
+ .Times(AtLeast(1))
+ .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::IncomingPacket));
+ EXPECT_CALL(mock_decoder, Channels())
+ .Times(AtLeast(1))
+ .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::Channels));
+ EXPECT_CALL(mock_decoder, Decode(_, _, _, _, _, _))
+ .Times(AtLeast(1))
+ .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::Decode));
+ EXPECT_CALL(mock_decoder, HasDecodePlc())
+ .Times(AtLeast(1))
+ .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::HasDecodePlc));
+ EXPECT_CALL(mock_decoder, PacketDuration(_, _))
+ .Times(AtLeast(1))
+ .WillRepeatedly(Invoke(&decoder, &AudioDecoderPcmU::PacketDuration));
+ ExternalDecoder ed;
+ ed.rtp_payload_type = 0;
+ ed.external_decoder = &mock_decoder;
+ ed.sample_rate_hz = 8000;
+ ed.num_channels = 1;
+ std::vector<ExternalDecoder> external_decoders;
+ external_decoders.push_back(ed);
+
+ Run(48000, PlatformChecksum("aa7c232f63a67b2a72703593bdd172e0",
+ "0155665e93067c4e89256b944dd11999",
+ "4ee2730fa1daae755e8a8fd3abd779ec"),
+ external_decoders);
+
+ EXPECT_CALL(mock_decoder, Die());
}
// This test verifies bit exactness for the send-side of ACM. The test setup is
@@ -1015,7 +1090,7 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test,
frame_size_samples);
}
- bool RegisterExternalSendCodec(AudioEncoderMutable* external_speech_encoder,
+ bool RegisterExternalSendCodec(AudioEncoder* external_speech_encoder,
int payload_type) {
payload_type_ = payload_type;
frame_size_rtp_timestamps_ =
@@ -1117,7 +1192,7 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test,
codec_frame_size_rtp_timestamps));
}
- void SetUpTestExternalEncoder(AudioEncoderMutable* external_speech_encoder,
+ void SetUpTestExternalEncoder(AudioEncoder* external_speech_encoder,
int payload_type) {
ASSERT_TRUE(SetUpSender());
ASSERT_TRUE(
@@ -1140,7 +1215,7 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test,
#else
#define MAYBE_IsacWb30ms IsacWb30ms
#endif
-TEST_F(AcmSenderBitExactnessOldApi, MAYBE_IsacWb30ms) {
+TEST_F(AcmSenderBitExactnessOldApi, IF_ISAC(MAYBE_IsacWb30ms)) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 16000, 1, 103, 480, 480));
Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
"c7e5bdadfa2871df95639fcc297cf23d",
@@ -1160,7 +1235,7 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_IsacWb30ms) {
#else
#define MAYBE_IsacWb60ms IsacWb60ms
#endif
-TEST_F(AcmSenderBitExactnessOldApi, MAYBE_IsacWb60ms) {
+TEST_F(AcmSenderBitExactnessOldApi, IF_ISAC(MAYBE_IsacWb60ms)) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 16000, 1, 103, 960, 960));
Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
"14d63c5f08127d280e722e3191b73bdd",
@@ -1174,7 +1249,14 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_IsacWb60ms) {
test::AcmReceiveTestOldApi::kMonoOutput);
}
-TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(IsacSwb30ms)) {
+#ifdef WEBRTC_CODEC_ISAC
+#define IF_ISAC_FLOAT(x) x
+#else
+#define IF_ISAC_FLOAT(x) DISABLED_##x
+#endif
+
+TEST_F(AcmSenderBitExactnessOldApi,
+ DISABLED_ON_ANDROID(IF_ISAC_FLOAT(IsacSwb30ms))) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 32000, 1, 104, 960, 960));
Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
"2b3c387d06f00b7b7aad4c9be56fb83d",
@@ -1267,7 +1349,13 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcma_stereo_20ms) {
test::AcmReceiveTestOldApi::kStereoOutput);
}
-TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(Ilbc_30ms)) {
+#ifdef WEBRTC_CODEC_ILBC
+#define IF_ILBC(x) x
+#else
+#define IF_ILBC(x) DISABLED_##x
+#endif
+
+TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(IF_ILBC(Ilbc_30ms))) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("ILBC", 8000, 1, 102, 240, 240));
Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
"7b6ec10910debd9af08011d3ed5249f7",
@@ -1281,7 +1369,13 @@ TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(Ilbc_30ms)) {
test::AcmReceiveTestOldApi::kMonoOutput);
}
-TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(G722_20ms)) {
+#ifdef WEBRTC_CODEC_G722
+#define IF_G722(x) x
+#else
+#define IF_G722(x) DISABLED_##x
+#endif
+
+TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(IF_G722(G722_20ms))) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("G722", 16000, 1, 9, 320, 160));
Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
"7d759436f2533582950d148b5161a36c",
@@ -1295,7 +1389,8 @@ TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(G722_20ms)) {
test::AcmReceiveTestOldApi::kMonoOutput);
}
-TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(G722_stereo_20ms)) {
+TEST_F(AcmSenderBitExactnessOldApi,
+ DISABLED_ON_ANDROID(IF_G722(G722_stereo_20ms))) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("G722", 16000, 2, 119, 320, 160));
Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
"7190ee718ab3d80eca181e5f7140c210",
@@ -1542,32 +1637,36 @@ TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) {
codec_inst.channels = 1;
codec_inst.pacsize = 160;
codec_inst.pltype = 0;
- AudioEncoderMutablePcmU encoder(codec_inst);
- MockAudioEncoderMutable mock_encoder;
+ AudioEncoderPcmU encoder(codec_inst);
+ MockAudioEncoder mock_encoder;
// Set expectations on the mock encoder and also delegate the calls to the
// real encoder.
- EXPECT_CALL(mock_encoder, Num10MsFramesInNextPacket())
- .Times(AtLeast(1))
- .WillRepeatedly(Invoke(
- &encoder, &AudioEncoderMutablePcmU::Num10MsFramesInNextPacket));
- EXPECT_CALL(mock_encoder, Max10MsFramesInAPacket())
+ EXPECT_CALL(mock_encoder, MaxEncodedBytes())
.Times(AtLeast(1))
- .WillRepeatedly(
- Invoke(&encoder, &AudioEncoderMutablePcmU::Max10MsFramesInAPacket));
+ .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::MaxEncodedBytes));
EXPECT_CALL(mock_encoder, SampleRateHz())
.Times(AtLeast(1))
- .WillRepeatedly(Invoke(&encoder, &AudioEncoderMutablePcmU::SampleRateHz));
+ .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SampleRateHz));
EXPECT_CALL(mock_encoder, NumChannels())
.Times(AtLeast(1))
- .WillRepeatedly(Invoke(&encoder, &AudioEncoderMutablePcmU::NumChannels));
- EXPECT_CALL(mock_encoder, EncodeInternal(_, _, _, _))
+ .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::NumChannels));
+ EXPECT_CALL(mock_encoder, RtpTimestampRateHz())
+ .Times(AtLeast(1))
+ .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::RtpTimestampRateHz));
+ EXPECT_CALL(mock_encoder, Num10MsFramesInNextPacket())
.Times(AtLeast(1))
.WillRepeatedly(
- Invoke(&encoder, &AudioEncoderMutablePcmU::EncodeInternal));
+ Invoke(&encoder, &AudioEncoderPcmU::Num10MsFramesInNextPacket));
+ EXPECT_CALL(mock_encoder, Max10MsFramesInAPacket())
+ .Times(AtLeast(1))
+ .WillRepeatedly(
+ Invoke(&encoder, &AudioEncoderPcmU::Max10MsFramesInAPacket));
EXPECT_CALL(mock_encoder, GetTargetBitrate())
.Times(AtLeast(1))
- .WillRepeatedly(Invoke(
- &encoder, &AudioEncoderMutablePcmU::GetTargetBitrate));
+ .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate));
+ EXPECT_CALL(mock_encoder, EncodeInternal(_, _, _, _))
+ .Times(AtLeast(1))
+ .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::EncodeInternal));
ASSERT_NO_FATAL_FAILURE(
SetUpTestExternalEncoder(&mock_encoder, codec_inst.pltype));
Run("81a9d4c0bb72e9becc43aef124c981e9", "8f9b8750bd80fe26b6cbf6659b89f0f9",
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.cc
index cad6ee90893..862feaaa702 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.cc
@@ -122,11 +122,7 @@ bool IsPcmA(const CodecInst& codec) {
}
bool IsPcm16B(const CodecInst& codec) {
- return
-#ifdef WEBRTC_CODEC_PCM16
- !STR_CASE_CMP(codec.plname, "l16") ||
-#endif
- false;
+ return !STR_CASE_CMP(codec.plname, "l16");
}
bool IsIlbc(const CodecInst& codec) {
@@ -164,7 +160,8 @@ CodecManager::CodecManager()
vad_mode_(VADNormal),
send_codec_inst_(kEmptyCodecInst),
red_enabled_(false),
- codec_fec_enabled_(false) {
+ codec_fec_enabled_(false),
+ encoder_is_opus_(false) {
// Register the default payload type for RED and for CNG at sampling rates of
// 8, 16, 32 and 48 kHz.
for (int i = (ACMCodecDB::kNumCodecs - 1); i >= 0; i--) {
@@ -188,7 +185,7 @@ CodecManager::CodecManager()
CodecManager::~CodecManager() = default;
int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
int codec_id = IsValidSendCodec(send_codec, true);
// Check for reported errors from function IsValidSendCodec().
@@ -267,7 +264,7 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
bool new_codec = true;
if (codec_owner_.Encoder()) {
int new_codec_id = ACMCodecDB::CodecNumber(send_codec_inst_);
- DCHECK_GE(new_codec_id, 0);
+ RTC_DCHECK_GE(new_codec_id, 0);
new_codec = new_codec_id != codec_id;
}
@@ -275,21 +272,23 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
red_enabled_ = false;
}
+ encoder_is_opus_ = IsOpus(send_codec);
+
if (new_codec) {
// This is a new codec. Register it and return.
- DCHECK(CodecSupported(send_codec));
+ RTC_DCHECK(CodecSupported(send_codec));
if (IsOpus(send_codec)) {
// VAD/DTX not supported.
dtx_enabled_ = false;
}
- codec_owner_.SetEncoders(
- send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
- vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1);
- DCHECK(codec_owner_.Encoder());
+ if (!codec_owner_.SetEncoders(
+ send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
+ vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1))
+ return -1;
+ RTC_DCHECK(codec_owner_.Encoder());
- codec_fec_enabled_ =
- codec_fec_enabled_ &&
- codec_owner_.SpeechEncoder()->SetFec(codec_fec_enabled_);
+ codec_fec_enabled_ = codec_fec_enabled_ &&
+ codec_owner_.Encoder()->SetFec(codec_fec_enabled_);
send_codec_inst_ = send_codec;
return 0;
@@ -299,10 +298,11 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
if (send_codec_inst_.plfreq != send_codec.plfreq ||
send_codec_inst_.pacsize != send_codec.pacsize ||
send_codec_inst_.channels != send_codec.channels) {
- codec_owner_.SetEncoders(
- send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
- vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1);
- DCHECK(codec_owner_.Encoder());
+ if (!codec_owner_.SetEncoders(
+ send_codec, dtx_enabled_ ? CngPayloadType(send_codec.plfreq) : -1,
+ vad_mode_, red_enabled_ ? RedPayloadType(send_codec.plfreq) : -1))
+ return -1;
+ RTC_DCHECK(codec_owner_.Encoder());
}
send_codec_inst_.plfreq = send_codec.plfreq;
send_codec_inst_.pacsize = send_codec.pacsize;
@@ -311,25 +311,24 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) {
// Check if a change in Rate is required.
if (send_codec.rate != send_codec_inst_.rate) {
- codec_owner_.SpeechEncoder()->SetTargetBitrate(send_codec.rate);
+ codec_owner_.Encoder()->SetTargetBitrate(send_codec.rate);
send_codec_inst_.rate = send_codec.rate;
}
- codec_fec_enabled_ = codec_fec_enabled_ &&
- codec_owner_.SpeechEncoder()->SetFec(codec_fec_enabled_);
+ codec_fec_enabled_ =
+ codec_fec_enabled_ && codec_owner_.Encoder()->SetFec(codec_fec_enabled_);
return 0;
}
-void CodecManager::RegisterEncoder(
- AudioEncoderMutable* external_speech_encoder) {
+void CodecManager::RegisterEncoder(AudioEncoder* external_speech_encoder) {
// Make up a CodecInst.
send_codec_inst_.channels = external_speech_encoder->NumChannels();
send_codec_inst_.plfreq = external_speech_encoder->SampleRateHz();
- send_codec_inst_.pacsize =
- rtc::CheckedDivExact(external_speech_encoder->Max10MsFramesInAPacket() *
- send_codec_inst_.plfreq,
- 100);
+ send_codec_inst_.pacsize = rtc::CheckedDivExact(
+ static_cast<int>(external_speech_encoder->Max10MsFramesInAPacket() *
+ send_codec_inst_.plfreq),
+ 100);
send_codec_inst_.pltype = -1; // Not valid.
send_codec_inst_.rate = -1; // Not valid.
static const char kName[] = "external";
@@ -337,8 +336,8 @@ void CodecManager::RegisterEncoder(
if (stereo_send_)
dtx_enabled_ = false;
- codec_fec_enabled_ = codec_fec_enabled_ &&
- codec_owner_.SpeechEncoder()->SetFec(codec_fec_enabled_);
+ codec_fec_enabled_ =
+ codec_fec_enabled_ && codec_owner_.Encoder()->SetFec(codec_fec_enabled_);
int cng_pt = dtx_enabled_
? CngPayloadType(external_speech_encoder->SampleRateHz())
: -1;
@@ -384,8 +383,8 @@ bool CodecManager::SetCopyRed(bool enable) {
int CodecManager::SetVAD(bool enable, ACMVADMode mode) {
// Sanity check of the mode.
- DCHECK(mode == VADNormal || mode == VADLowBitrate || mode == VADAggr ||
- mode == VADVeryAggr);
+ RTC_DCHECK(mode == VADNormal || mode == VADLowBitrate || mode == VADAggr ||
+ mode == VADVeryAggr);
// Check that the send codec is mono. We don't support VAD/DTX for stereo
// sending.
@@ -430,9 +429,9 @@ int CodecManager::SetCodecFEC(bool enable_codec_fec) {
return -1;
}
- CHECK(codec_owner_.SpeechEncoder());
- codec_fec_enabled_ = codec_owner_.SpeechEncoder()->SetFec(enable_codec_fec) &&
- enable_codec_fec;
+ RTC_CHECK(codec_owner_.Encoder());
+ codec_fec_enabled_ =
+ codec_owner_.Encoder()->SetFec(enable_codec_fec) && enable_codec_fec;
return codec_fec_enabled_ == enable_codec_fec ? 0 : -1;
}
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.h
index bb9545d889b..2337521edf3 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_manager.h
@@ -22,7 +22,6 @@ namespace webrtc {
class AudioDecoder;
class AudioEncoder;
-class AudioEncoderMutable;
namespace acm2 {
@@ -33,7 +32,7 @@ class CodecManager final {
int RegisterEncoder(const CodecInst& send_codec);
- void RegisterEncoder(AudioEncoderMutable* external_speech_encoder);
+ void RegisterEncoder(AudioEncoder* external_speech_encoder);
int GetCodecInst(CodecInst* current_codec) const;
@@ -58,12 +57,11 @@ class CodecManager final {
bool codec_fec_enabled() const { return codec_fec_enabled_; }
- AudioEncoderMutable* CurrentSpeechEncoder() {
- return codec_owner_.SpeechEncoder();
- }
AudioEncoder* CurrentEncoder() { return codec_owner_.Encoder(); }
const AudioEncoder* CurrentEncoder() const { return codec_owner_.Encoder(); }
+ bool CurrentEncoderIsOpus() const { return encoder_is_opus_; }
+
private:
int CngPayloadType(int sample_rate_hz) const;
@@ -82,8 +80,9 @@ class CodecManager final {
bool red_enabled_;
bool codec_fec_enabled_;
CodecOwner codec_owner_;
+ bool encoder_is_opus_;
- DISALLOW_COPY_AND_ASSIGN(CodecManager);
+ RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager);
};
} // namespace acm2
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.cc
index 4d214be2428..449a467a172 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.cc
@@ -11,133 +11,104 @@
#include "webrtc/modules/audio_coding/main/acm2/codec_owner.h"
#include "webrtc/base/checks.h"
+#include "webrtc/base/logging.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h"
#include "webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h"
+#ifdef WEBRTC_CODEC_G722
#include "webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h"
+#endif
+#ifdef WEBRTC_CODEC_ILBC
#include "webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h"
+#endif
+#ifdef WEBRTC_CODEC_ISACFX
+#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_decoder_isacfix.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_encoder_isacfix.h"
+#endif
+#ifdef WEBRTC_CODEC_ISAC
+#include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_decoder_isac.h"
#include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h"
+#endif
+#ifdef WEBRTC_CODEC_OPUS
#include "webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h"
+#endif
#include "webrtc/modules/audio_coding/codecs/pcm16b/include/audio_encoder_pcm16b.h"
+#ifdef WEBRTC_CODEC_RED
#include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h"
+#endif
namespace webrtc {
namespace acm2 {
-namespace {
-bool IsIsac(const CodecInst& codec) {
- return
-#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
- !STR_CASE_CMP(codec.plname, "isac") ||
-#endif
- false;
-}
-
-bool IsOpus(const CodecInst& codec) {
- return
-#ifdef WEBRTC_CODEC_OPUS
- !STR_CASE_CMP(codec.plname, "opus") ||
-#endif
- false;
-}
-
-bool IsPcmU(const CodecInst& codec) {
- return !STR_CASE_CMP(codec.plname, "pcmu");
-}
-
-bool IsPcmA(const CodecInst& codec) {
- return !STR_CASE_CMP(codec.plname, "pcma");
-}
-
-bool IsPcm16B(const CodecInst& codec) {
- return
-#ifdef WEBRTC_CODEC_PCM16
- !STR_CASE_CMP(codec.plname, "l16") ||
-#endif
- false;
-}
-
-bool IsIlbc(const CodecInst& codec) {
- return
-#ifdef WEBRTC_CODEC_ILBC
- !STR_CASE_CMP(codec.plname, "ilbc") ||
-#endif
- false;
-}
-
-bool IsG722(const CodecInst& codec) {
- return
-#ifdef WEBRTC_CODEC_G722
- !STR_CASE_CMP(codec.plname, "g722") ||
-#endif
- false;
-}
-} // namespace
-
-CodecOwner::CodecOwner()
- : isac_is_encoder_(false), external_speech_encoder_(nullptr) {
+CodecOwner::CodecOwner() : external_speech_encoder_(nullptr) {
}
CodecOwner::~CodecOwner() = default;
namespace {
-AudioEncoderDecoderMutableIsac* CreateIsacCodec(const CodecInst& speech_inst) {
+
+rtc::scoped_ptr<AudioDecoder> CreateIsacDecoder(
+ LockedIsacBandwidthInfo* bwinfo) {
#if defined(WEBRTC_CODEC_ISACFX)
- return new AudioEncoderDecoderMutableIsacFix(speech_inst);
+ return rtc_make_scoped_ptr(new AudioDecoderIsacFix(bwinfo));
#elif defined(WEBRTC_CODEC_ISAC)
- return new AudioEncoderDecoderMutableIsacFloat(speech_inst);
+ return rtc_make_scoped_ptr(new AudioDecoderIsac(bwinfo));
#else
FATAL() << "iSAC is not supported.";
- return nullptr;
+ return rtc::scoped_ptr<AudioDecoder>();
#endif
}
-void CreateSpeechEncoder(
+// Returns a new speech encoder, or null on error.
+// TODO(kwiberg): Don't handle errors here (bug 5033)
+rtc::scoped_ptr<AudioEncoder> CreateSpeechEncoder(
const CodecInst& speech_inst,
- rtc::scoped_ptr<AudioEncoderMutable>* speech_encoder,
- rtc::scoped_ptr<AudioEncoderDecoderMutableIsac>* isac_codec,
- bool* isac_is_encoder) {
- if (IsIsac(speech_inst)) {
- if (*isac_codec) {
- (*isac_codec)->UpdateSettings(speech_inst);
- } else {
- isac_codec->reset(CreateIsacCodec(speech_inst));
- }
- *isac_is_encoder = true;
- speech_encoder->reset();
- return;
- }
- if (IsOpus(speech_inst)) {
- speech_encoder->reset(new AudioEncoderMutableOpus(speech_inst));
- } else if (IsPcmU(speech_inst)) {
- speech_encoder->reset(new AudioEncoderMutablePcmU(speech_inst));
- } else if (IsPcmA(speech_inst)) {
- speech_encoder->reset(new AudioEncoderMutablePcmA(speech_inst));
- } else if (IsPcm16B(speech_inst)) {
- speech_encoder->reset(new AudioEncoderMutablePcm16B(speech_inst));
- } else if (IsIlbc(speech_inst)) {
- speech_encoder->reset(new AudioEncoderMutableIlbc(speech_inst));
- } else if (IsG722(speech_inst)) {
- speech_encoder->reset(new AudioEncoderMutableG722(speech_inst));
- } else {
- FATAL();
- }
- *isac_is_encoder = false;
+ LockedIsacBandwidthInfo* bwinfo) {
+#if defined(WEBRTC_CODEC_ISACFX)
+ if (STR_CASE_CMP(speech_inst.plname, "isac") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderIsacFix(speech_inst, bwinfo));
+#endif
+#if defined(WEBRTC_CODEC_ISAC)
+ if (STR_CASE_CMP(speech_inst.plname, "isac") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderIsac(speech_inst, bwinfo));
+#endif
+#ifdef WEBRTC_CODEC_OPUS
+ if (STR_CASE_CMP(speech_inst.plname, "opus") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderOpus(speech_inst));
+#endif
+ if (STR_CASE_CMP(speech_inst.plname, "pcmu") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderPcmU(speech_inst));
+ if (STR_CASE_CMP(speech_inst.plname, "pcma") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderPcmA(speech_inst));
+ if (STR_CASE_CMP(speech_inst.plname, "l16") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderPcm16B(speech_inst));
+#ifdef WEBRTC_CODEC_ILBC
+ if (STR_CASE_CMP(speech_inst.plname, "ilbc") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderIlbc(speech_inst));
+#endif
+#ifdef WEBRTC_CODEC_G722
+ if (STR_CASE_CMP(speech_inst.plname, "g722") == 0)
+ return rtc_make_scoped_ptr(new AudioEncoderG722(speech_inst));
+#endif
+ LOG_F(LS_ERROR) << "Could not create encoder of type " << speech_inst.plname;
+ return rtc::scoped_ptr<AudioEncoder>();
}
AudioEncoder* CreateRedEncoder(int red_payload_type,
AudioEncoder* encoder,
rtc::scoped_ptr<AudioEncoder>* red_encoder) {
- if (red_payload_type == -1) {
- red_encoder->reset();
- return encoder;
+#ifdef WEBRTC_CODEC_RED
+ if (red_payload_type != -1) {
+ AudioEncoderCopyRed::Config config;
+ config.payload_type = red_payload_type;
+ config.speech_encoder = encoder;
+ red_encoder->reset(new AudioEncoderCopyRed(config));
+ return red_encoder->get();
}
- AudioEncoderCopyRed::Config config;
- config.payload_type = red_payload_type;
- config.speech_encoder = encoder;
- red_encoder->reset(new AudioEncoderCopyRed(config));
- return red_encoder->get();
+#endif
+
+ red_encoder->reset();
+ return encoder;
}
void CreateCngEncoder(int cng_payload_type,
@@ -172,30 +143,31 @@ void CreateCngEncoder(int cng_payload_type,
}
} // namespace
-void CodecOwner::SetEncoders(const CodecInst& speech_inst,
+bool CodecOwner::SetEncoders(const CodecInst& speech_inst,
int cng_payload_type,
ACMVADMode vad_mode,
int red_payload_type) {
- CreateSpeechEncoder(speech_inst, &speech_encoder_, &isac_codec_,
- &isac_is_encoder_);
+ speech_encoder_ = CreateSpeechEncoder(speech_inst, &isac_bandwidth_info_);
+ if (!speech_encoder_)
+ return false;
external_speech_encoder_ = nullptr;
ChangeCngAndRed(cng_payload_type, vad_mode, red_payload_type);
+ return true;
}
-void CodecOwner::SetEncoders(AudioEncoderMutable* external_speech_encoder,
+void CodecOwner::SetEncoders(AudioEncoder* external_speech_encoder,
int cng_payload_type,
ACMVADMode vad_mode,
int red_payload_type) {
external_speech_encoder_ = external_speech_encoder;
speech_encoder_.reset();
- isac_is_encoder_ = false;
ChangeCngAndRed(cng_payload_type, vad_mode, red_payload_type);
}
void CodecOwner::ChangeCngAndRed(int cng_payload_type,
ACMVADMode vad_mode,
int red_payload_type) {
- AudioEncoderMutable* speech_encoder = SpeechEncoder();
+ AudioEncoder* speech_encoder = SpeechEncoder();
if (cng_payload_type != -1 || red_payload_type != -1) {
// The RED and CNG encoders need to be in sync with the speech encoder, so
// reset the latter to ensure its buffer is empty.
@@ -204,24 +176,13 @@ void CodecOwner::ChangeCngAndRed(int cng_payload_type,
AudioEncoder* encoder =
CreateRedEncoder(red_payload_type, speech_encoder, &red_encoder_);
CreateCngEncoder(cng_payload_type, vad_mode, encoder, &cng_encoder_);
- int num_true =
- !!speech_encoder_ + !!external_speech_encoder_ + isac_is_encoder_;
- DCHECK_EQ(num_true, 1);
- DCHECK(!isac_is_encoder_ || isac_codec_);
+ RTC_DCHECK_EQ(!!speech_encoder_ + !!external_speech_encoder_, 1);
}
AudioDecoder* CodecOwner::GetIsacDecoder() {
- if (!isac_codec_) {
- DCHECK(!isac_is_encoder_);
- // None of the parameter values in |speech_inst| matter when the codec is
- // used only as a decoder.
- CodecInst speech_inst;
- speech_inst.plfreq = 16000;
- speech_inst.rate = -1;
- speech_inst.pacsize = 480;
- isac_codec_.reset(CreateIsacCodec(speech_inst));
- }
- return isac_codec_.get();
+ if (!isac_decoder_)
+ isac_decoder_ = CreateIsacDecoder(&isac_bandwidth_info_);
+ return isac_decoder_.get();
}
AudioEncoder* CodecOwner::Encoder() {
@@ -237,21 +198,15 @@ const AudioEncoder* CodecOwner::Encoder() const {
return SpeechEncoder();
}
-AudioEncoderMutable* CodecOwner::SpeechEncoder() {
- const auto& const_this = *this;
- return const_cast<AudioEncoderMutable*>(const_this.SpeechEncoder());
+AudioEncoder* CodecOwner::SpeechEncoder() {
+ const auto* const_this = this;
+ return const_cast<AudioEncoder*>(const_this->SpeechEncoder());
}
-const AudioEncoderMutable* CodecOwner::SpeechEncoder() const {
- int num_true =
- !!speech_encoder_ + !!external_speech_encoder_ + isac_is_encoder_;
- DCHECK_GE(num_true, 0);
- DCHECK_LE(num_true, 1);
- if (external_speech_encoder_)
- return external_speech_encoder_;
- if (speech_encoder_)
- return speech_encoder_.get();
- return isac_is_encoder_ ? isac_codec_.get() : nullptr;
+const AudioEncoder* CodecOwner::SpeechEncoder() const {
+ RTC_DCHECK(!speech_encoder_ || !external_speech_encoder_);
+ return external_speech_encoder_ ? external_speech_encoder_
+ : speech_encoder_.get();
}
} // namespace acm2
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.h b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.h
index 2468c3ce00e..d2d93cf539e 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.h
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner.h
@@ -15,13 +15,19 @@
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
-#include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h"
+#include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
+#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
+#include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h"
+#else
+// Dummy implementation, for when we don't have iSAC.
namespace webrtc {
+class LockedIsacBandwidthInfo {};
+}
+#endif
-class AudioDecoder;
-
+namespace webrtc {
namespace acm2 {
class CodecOwner {
@@ -29,12 +35,14 @@ class CodecOwner {
CodecOwner();
~CodecOwner();
- void SetEncoders(const CodecInst& speech_inst,
+ // Start using the specified encoder. Returns false on error.
+ // TODO(kwiberg): Don't handle errors here (bug 5033)
+ bool SetEncoders(const CodecInst& speech_inst,
int cng_payload_type,
ACMVADMode vad_mode,
- int red_payload_type);
+ int red_payload_type) WARN_UNUSED_RESULT;
- void SetEncoders(AudioEncoderMutable* external_speech_encoder,
+ void SetEncoders(AudioEncoder* external_speech_encoder,
int cng_payload_type,
ACMVADMode vad_mode,
int red_payload_type);
@@ -49,31 +57,28 @@ class CodecOwner {
AudioEncoder* Encoder();
const AudioEncoder* Encoder() const;
- AudioEncoderMutable* SpeechEncoder();
- const AudioEncoderMutable* SpeechEncoder() const;
private:
- // There are three main cases for the state of the encoder members below:
- // 1. An external encoder is used. |external_speech_encoder_| points to it.
- // |speech_encoder_| is null, and |isac_is_encoder_| is false.
- // 2. The internal iSAC codec is used as encoder. |isac_codec_| points to it
- // and |isac_is_encoder_| is true. |external_speech_encoder_| and
- // |speech_encoder_| are null.
- // 3. Another internal encoder is used. |speech_encoder_| points to it.
- // |external_speech_encoder_| is null, and |isac_is_encoder_| is false.
- // In addition to case 2, |isac_codec_| is valid when GetIsacDecoder has been
- // called.
- rtc::scoped_ptr<AudioEncoderMutable> speech_encoder_;
- rtc::scoped_ptr<AudioEncoderDecoderMutableIsac> isac_codec_;
- bool isac_is_encoder_;
- AudioEncoderMutable* external_speech_encoder_;
+ AudioEncoder* SpeechEncoder();
+ const AudioEncoder* SpeechEncoder() const;
+
+ // At most one of these is non-null:
+ rtc::scoped_ptr<AudioEncoder> speech_encoder_;
+ AudioEncoder* external_speech_encoder_;
+
+ // If we've created an iSAC decoder because someone called GetIsacDecoder,
+ // store it here.
+ rtc::scoped_ptr<AudioDecoder> isac_decoder_;
+
+ // iSAC bandwidth estimation info, for use with iSAC encoders and decoders.
+ LockedIsacBandwidthInfo isac_bandwidth_info_;
// |cng_encoder_| and |red_encoder_| are valid iff CNG or RED, respectively,
// are active.
rtc::scoped_ptr<AudioEncoder> cng_encoder_;
rtc::scoped_ptr<AudioEncoder> red_encoder_;
- DISALLOW_COPY_AND_ASSIGN(CodecOwner);
+ RTC_DISALLOW_COPY_AND_ASSIGN(CodecOwner);
};
} // namespace acm2
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
index a1366a9b885..6c232615a74 100644
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
+++ b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
@@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include <cstring>
+
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/safe_conversions.h"
@@ -34,7 +36,8 @@ class CodecOwnerTest : public ::testing::Test {
CodecOwnerTest() : timestamp_(0) {}
void CreateCodec() {
- codec_owner_.SetEncoders(kDefaultCodecInst, kCngPt, VADNormal, -1);
+ ASSERT_TRUE(
+ codec_owner_.SetEncoders(kDefaultCodecInst, kCngPt, VADNormal, -1));
}
void EncodeAndVerify(size_t expected_out_length,
@@ -56,6 +59,41 @@ class CodecOwnerTest : public ::testing::Test {
encoded_info.send_even_if_empty);
}
+ // Verify that the speech encoder's Reset method is called when CNG or RED
+ // (or both) are switched on, but not when they're switched off.
+ void TestCngAndRedResetSpeechEncoder(bool use_cng, bool use_red) {
+ MockAudioEncoder speech_encoder;
+ EXPECT_CALL(speech_encoder, NumChannels())
+ .WillRepeatedly(Return(1));
+ EXPECT_CALL(speech_encoder, Max10MsFramesInAPacket())
+ .WillRepeatedly(Return(2));
+ EXPECT_CALL(speech_encoder, SampleRateHz())
+ .WillRepeatedly(Return(8000));
+ {
+ InSequence s;
+ EXPECT_CALL(speech_encoder, Mark("start off"));
+ EXPECT_CALL(speech_encoder, Mark("switch on"));
+ if (use_cng || use_red)
+ EXPECT_CALL(speech_encoder, Reset());
+ EXPECT_CALL(speech_encoder, Mark("start on"));
+ if (use_cng || use_red)
+ EXPECT_CALL(speech_encoder, Reset());
+ EXPECT_CALL(speech_encoder, Mark("switch off"));
+ EXPECT_CALL(speech_encoder, Die());
+ }
+
+ int cng_pt = use_cng ? 17 : -1;
+ int red_pt = use_red ? 19 : -1;
+ speech_encoder.Mark("start off");
+ codec_owner_.SetEncoders(&speech_encoder, -1, VADNormal, -1);
+ speech_encoder.Mark("switch on");
+ codec_owner_.ChangeCngAndRed(cng_pt, VADNormal, red_pt);
+ speech_encoder.Mark("start on");
+ codec_owner_.SetEncoders(&speech_encoder, cng_pt, VADNormal, red_pt);
+ speech_encoder.Mark("switch off");
+ codec_owner_.ChangeCngAndRed(-1, VADNormal, -1);
+ }
+
CodecOwner codec_owner_;
uint32_t timestamp_;
};
@@ -99,7 +137,7 @@ TEST_F(CodecOwnerTest, VerifyCngFrames) {
}
TEST_F(CodecOwnerTest, ExternalEncoder) {
- MockAudioEncoderMutable external_encoder;
+ MockAudioEncoder external_encoder;
codec_owner_.SetEncoders(&external_encoder, -1, VADNormal, -1);
const int kSampleRateHz = 8000;
const int kPacketSizeSamples = kSampleRateHz / 100;
@@ -115,35 +153,57 @@ TEST_F(CodecOwnerTest, ExternalEncoder) {
EXPECT_CALL(external_encoder,
EncodeInternal(0, audio, arraysize(encoded), encoded))
.WillOnce(Return(info));
- EXPECT_CALL(external_encoder, Reset());
- EXPECT_CALL(external_encoder, Reset());
+ EXPECT_CALL(external_encoder, Mark("A"));
+ EXPECT_CALL(external_encoder, Mark("B"));
info.encoded_timestamp = 2;
EXPECT_CALL(external_encoder,
EncodeInternal(2, audio, arraysize(encoded), encoded))
.WillOnce(Return(info));
- EXPECT_CALL(external_encoder, Reset());
+ EXPECT_CALL(external_encoder, Die());
}
info = codec_owner_.Encoder()->Encode(0, audio, arraysize(audio),
arraysize(encoded), encoded);
EXPECT_EQ(0u, info.encoded_timestamp);
- external_encoder.Reset(); // Dummy call to mark the sequence of expectations.
+ external_encoder.Mark("A");
// Change to internal encoder.
CodecInst codec_inst = kDefaultCodecInst;
codec_inst.pacsize = kPacketSizeSamples;
- codec_owner_.SetEncoders(codec_inst, -1, VADNormal, -1);
+ ASSERT_TRUE(codec_owner_.SetEncoders(codec_inst, -1, VADNormal, -1));
// Don't expect any more calls to the external encoder.
info = codec_owner_.Encoder()->Encode(1, audio, arraysize(audio),
arraysize(encoded), encoded);
- external_encoder.Reset(); // Dummy call to mark the sequence of expectations.
+ external_encoder.Mark("B");
// Change back to external encoder again.
codec_owner_.SetEncoders(&external_encoder, -1, VADNormal, -1);
info = codec_owner_.Encoder()->Encode(2, audio, arraysize(audio),
arraysize(encoded), encoded);
EXPECT_EQ(2u, info.encoded_timestamp);
- external_encoder.Reset(); // Dummy call to mark the sequence of expectations.
+}
+
+TEST_F(CodecOwnerTest, CngResetsSpeechEncoder) {
+ TestCngAndRedResetSpeechEncoder(true, false);
+}
+
+TEST_F(CodecOwnerTest, RedResetsSpeechEncoder) {
+ TestCngAndRedResetSpeechEncoder(false, true);
+}
+
+TEST_F(CodecOwnerTest, CngAndRedResetsSpeechEncoder) {
+ TestCngAndRedResetSpeechEncoder(true, true);
+}
+
+TEST_F(CodecOwnerTest, NoCngAndRedNoSpeechEncoderReset) {
+ TestCngAndRedResetSpeechEncoder(false, false);
+}
+
+TEST_F(CodecOwnerTest, SetEncodersError) {
+ CodecInst codec_inst = kDefaultCodecInst;
+ static const char bad_name[] = "Robert'); DROP TABLE Students;";
+ std::memcpy(codec_inst.plname, bad_name, sizeof bad_name);
+ EXPECT_FALSE(codec_owner_.SetEncoders(codec_inst, -1, VADNormal, -1));
}
} // namespace acm2
diff --git a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/dump.proto b/chromium/third_party/webrtc/modules/audio_coding/main/acm2/dump.proto
deleted file mode 100644
index 232faec4287..00000000000
--- a/chromium/third_party/webrtc/modules/audio_coding/main/acm2/dump.proto
+++ /dev/null
@@ -1,169 +0,0 @@
-syntax = "proto2";
-option optimize_for = LITE_RUNTIME;
-package webrtc;
-
-// This is the main message to dump to a file, it can contain multiple event
-// messages, but it is possible to append multiple EventStreams (each with a
-// single event) to a file.
-// This has the benefit that there's no need to keep all data in memory.
-message ACMDumpEventStream {
- repeated ACMDumpEvent stream = 1;
-}
-
-
-message ACMDumpEvent {
- // required - Elapsed wallclock time in us since the start of the log.
- optional int64 timestamp_us = 1;
-
- // The different types of events that can occur, the UNKNOWN_EVENT entry
- // is added in case future EventTypes are added, in that case old code will
- // receive the new events as UNKNOWN_EVENT.
- enum EventType {
- UNKNOWN_EVENT = 0;
- RTP_EVENT = 1;
- DEBUG_EVENT = 2;
- CONFIG_EVENT = 3;
- }
-
- // required - Indicates the type of this event
- optional EventType type = 2;
-
- // optional - but required if type == RTP_EVENT
- optional ACMDumpRTPPacket packet = 3;
-
- // optional - but required if type == DEBUG_EVENT
- optional ACMDumpDebugEvent debug_event = 4;
-
- // optional - but required if type == CONFIG_EVENT
- optional ACMDumpConfigEvent config = 5;
-}
-
-
-message ACMDumpRTPPacket {
- // Indicates if the packet is incoming or outgoing with respect to the user
- // that is logging the data.
- enum Direction {
- UNKNOWN_DIRECTION = 0;
- OUTGOING = 1;
- INCOMING = 2;
- }
- enum PayloadType {
- UNKNOWN_TYPE = 0;
- AUDIO = 1;
- VIDEO = 2;
- RTX = 3;
- }
-
- // required
- optional Direction direction = 1;
-
- // required
- optional PayloadType type = 2;
-
- // required - Contains the whole RTP packet (header+payload).
- optional bytes RTP_data = 3;
-}
-
-
-message ACMDumpDebugEvent {
- // Indicates the type of the debug event.
- // LOG_START and LOG_END indicate the start and end of the log respectively.
- // AUDIO_PLAYOUT indicates a call to the PlayoutData10Ms() function in ACM.
- enum EventType {
- UNKNOWN_EVENT = 0;
- LOG_START = 1;
- LOG_END = 2;
- AUDIO_PLAYOUT = 3;
- }
-
- // required
- optional EventType type = 1;
-
- // An optional message that can be used to store additional information about
- // the debug event.
- optional string message = 2;
-}
-
-
-// TODO(terelius): Video and audio streams could in principle share SSRC,
-// so identifying a stream based only on SSRC might not work.
-// It might be better to use a combination of SSRC and media type
-// or SSRC and port number, but for now we will rely on SSRC only.
-message ACMDumpConfigEvent {
- // Synchronization source (stream identifier) to be received.
- optional uint32 remote_ssrc = 1;
-
- // RTX settings for incoming video payloads that may be received. RTX is
- // disabled if there's no config present.
- optional RtcpConfig rtcp_config = 3;
-
- // Map from video RTP payload type -> RTX config.
- repeated RtxMap rtx_map = 4;
-
- // RTP header extensions used for the received stream.
- repeated RtpHeaderExtension header_extensions = 5;
-
- // List of decoders associated with the stream.
- repeated DecoderConfig decoders = 6;
-}
-
-
-// Maps decoder names to payload types.
-message DecoderConfig {
- // required
- optional string name = 1;
-
- // required
- optional sint32 payload_type = 2;
-}
-
-
-// Maps RTP header extension names to numerical ids.
-message RtpHeaderExtension {
- // required
- optional string name = 1;
-
- // required
- optional sint32 id = 2;
-}
-
-
-// RTX settings for incoming video payloads that may be received.
-// RTX is disabled if there's no config present.
-message RtxConfig {
- // required - SSRCs to use for the RTX streams.
- optional uint32 ssrc = 1;
-
- // required - Payload type to use for the RTX stream.
- optional sint32 payload_type = 2;
-}
-
-
-message RtxMap {
- // required
- optional sint32 payload_type = 1;
-
- // required
- optional RtxConfig config = 2;
-}
-
-
-// Configuration information for RTCP.
-// For bandwidth estimation purposes it is more interesting to log the
-// RTCP messages that the sender receives, but we will support logging
-// at the receiver side too.
-message RtcpConfig {
- // Sender SSRC used for sending RTCP (such as receiver reports).
- optional uint32 local_ssrc = 1;
-
- // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
- // RTCP mode is described by RFC 5506.
- enum RtcpMode {RTCP_COMPOUND = 1; RTCP_REDUCEDSIZE = 2;}
- optional RtcpMode rtcp_mode = 2;
-
- // Extended RTCP settings.
- optional bool receiver_reference_time_report = 3;
-
- // Receiver estimated maximum bandwidth.
- optional bool remb = 4;
-}