diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn index 6d1c2f9a00..3a2d20a800 100644 --- a/webrtc/modules/audio_coding/BUILD.gn +++ b/webrtc/modules/audio_coding/BUILD.gn @@ -65,10 +65,6 @@ rtc_static_library("builtin_audio_decoder_factory_internal") { } rtc_static_library("rent_a_codec") { - # TODO(kjellander): Remove (bugs.webrtc.org/6828) - # Gives cyclic dependency with :neteq and :audio_coding if enabled. - check_includes = false - sources = [ "acm2/acm_codec_database.cc", "acm2/acm_codec_database.h", @@ -79,6 +75,12 @@ rtc_static_library("rent_a_codec") { "../../api/audio_codecs:audio_codecs_api", "../..:webrtc_common", "../../base:rtc_base_approved", + "../../system_wrappers", + ":audio_coding_module_typedefs", + ":audio_encoder_interface", + ":isac_common", + ":isac_fix_c", + ":neteq_decoder_enum", ] + audio_codec_deps defines = audio_codec_defines } @@ -90,9 +92,17 @@ config("audio_coding_config") { ] } +rtc_source_set("audio_coding_module_typedefs") { + sources = [ + "include/audio_coding_module_typedefs.h", + ] + deps = [ + "../..:webrtc_common", + ] +} + rtc_static_library("audio_coding") { sources = [ - "acm2/acm_common_defs.h", "acm2/acm_receiver.cc", "acm2/acm_receiver.h", "acm2/acm_resampler.cc", @@ -103,7 +113,6 @@ rtc_static_library("audio_coding") { "acm2/codec_manager.cc", "acm2/codec_manager.h", "include/audio_coding_module.h", - "include/audio_coding_module_typedefs.h", ] defines = [] @@ -126,6 +135,8 @@ rtc_static_library("audio_coding") { deps = audio_coding_deps + [ "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs:builtin_audio_decoder_factory", + ":audio_coding_module_typedefs", + ":audio_encoder_interface", ":neteq", ":rent_a_codec", "../../base:rtc_base_approved", @@ -927,11 +938,18 @@ rtc_static_library("audio_network_adaptor") { } } -rtc_static_library("neteq") { - # TODO(kjellander): Remove (bugs.webrtc.org/6828) - # Cyclic dependency with :audio_coding if enabled. - check_includes = false +rtc_source_set("neteq_decoder_enum") { + sources = [ + "neteq/neteq_decoder_enum.cc", + "neteq/neteq_decoder_enum.h", + ] + deps = [ + "../../api/audio_codecs:audio_codecs_api", + "../../base:rtc_base_approved", + ] +} +rtc_static_library("neteq") { sources = [ "neteq/accelerate.cc", "neteq/accelerate.h", @@ -1007,11 +1025,12 @@ rtc_static_library("neteq") { ] deps = [ + ":audio_coding_module_typedefs", ":cng", ":g711", ":isac_fix", + ":neteq_decoder_enum", ":pcm16b", - ":rent_a_codec", "../..:webrtc_common", "../../api/audio_codecs:audio_codecs_api", "../../base:gtest_prod", @@ -1133,6 +1152,7 @@ if (rtc_include_tests) { ] deps = [ ":audio_coding", + ":audio_coding_module_typedefs", ":audio_format_conversion", ":pcm16b_c", "../..:webrtc_common", @@ -1228,6 +1248,7 @@ if (rtc_include_tests) { deps = [ ":audio_coding", + ":audio_coding_module_typedefs", ":audio_format_conversion", "../../:webrtc_common", "../../base:rtc_base_approved", @@ -2036,6 +2057,7 @@ if (rtc_include_tests) { ":acm_receive_test", ":acm_send_test", ":audio_coding", + ":audio_coding_module_typedefs", ":audio_encoder_interface", ":audio_format_conversion", ":audio_network_adaptor", diff --git a/webrtc/modules/audio_coding/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/acm2/acm_codec_database.cc index 0fae75b91b..a1ff641ab6 100644 --- a/webrtc/modules/audio_coding/acm2/acm_codec_database.cc +++ b/webrtc/modules/audio_coding/acm2/acm_codec_database.cc @@ -20,9 +20,12 @@ #include #include "webrtc/base/checks.h" -#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" #include "webrtc/system_wrappers/include/trace.h" +#if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX)) +#error iSAC and iSACFX codecs cannot be enabled at the same time +#endif + namespace webrtc { namespace acm2 { @@ -60,9 +63,9 @@ bool IsOpusRateValid(int rate) { const CodecInst ACMCodecDB::database_[] = { #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) - {103, "ISAC", 16000, kIsacPacSize480, 1, kIsacWbDefaultRate}, + {103, "ISAC", 16000, 480, 1, 32000}, # if (defined(WEBRTC_CODEC_ISAC)) - {104, "ISAC", 32000, kIsacPacSize960, 1, kIsacSwbDefaultRate}, + {104, "ISAC", 32000, 960, 1, 56000}, # endif #endif // Mono @@ -118,9 +121,9 @@ 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}, + {2, {480, 960}, 0, 1}, # if (defined(WEBRTC_CODEC_ISAC)) - {1, {kIsacPacSize960}, 0, 1}, + {1, {960}, 0, 1}, # endif #endif // Mono diff --git a/webrtc/modules/audio_coding/acm2/acm_codec_database.h b/webrtc/modules/audio_coding/acm2/acm_codec_database.h index 22c40dbb7d..d586cb9e13 100644 --- a/webrtc/modules/audio_coding/acm2/acm_codec_database.h +++ b/webrtc/modules/audio_coding/acm2/acm_codec_database.h @@ -18,7 +18,6 @@ #include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" -#include "webrtc/modules/audio_coding/neteq/include/neteq.h" #include "webrtc/typedefs.h" namespace webrtc { diff --git a/webrtc/modules/audio_coding/acm2/acm_common_defs.h b/webrtc/modules/audio_coding/acm2/acm_common_defs.h deleted file mode 100644 index 085193233a..0000000000 --- a/webrtc/modules/audio_coding/acm2/acm_common_defs.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_COMMON_DEFS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_COMMON_DEFS_H_ - -#include "webrtc/typedefs.h" - -// Checks for enabled codecs, we prevent enabling codecs which are not -// compatible. -#if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX)) -#error iSAC and iSACFX codecs cannot be enabled at the same time -#endif - -namespace webrtc { - -// General codec specific defines -const int kIsacWbDefaultRate = 32000; -const int kIsacSwbDefaultRate = 56000; -const int kIsacPacSize480 = 480; -const int kIsacPacSize960 = 960; - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_COMMON_DEFS_H_ diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/acm2/acm_receiver.cc index 1577d2ded6..21dbc747ec 100644 --- a/webrtc/modules/audio_coding/acm2/acm_receiver.cc +++ b/webrtc/modules/audio_coding/acm2/acm_receiver.cc @@ -27,6 +27,7 @@ #include "webrtc/modules/audio_coding/neteq/include/neteq.h" #include "webrtc/system_wrappers/include/clock.h" #include "webrtc/system_wrappers/include/trace.h" +#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" namespace webrtc { @@ -199,7 +200,7 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id, return *ned; }(); const rtc::Optional new_format = - RentACodec::NetEqDecoderToSdpAudioFormat(neteq_decoder); + NetEqDecoderToSdpAudioFormat(neteq_decoder); rtc::CritScope lock(&crit_sect_); diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc index d5a63ccd49..05f4e1134d 100644 --- a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc +++ b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc @@ -16,6 +16,7 @@ #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" #include "webrtc/base/checks.h" #include "webrtc/base/safe_conversions.h" +#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h" #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" #include "webrtc/system_wrappers/include/clock.h" diff --git a/webrtc/modules/audio_coding/acm2/rent_a_codec.cc b/webrtc/modules/audio_coding/acm2/rent_a_codec.cc index f0ed3011e4..b353b38201 100644 --- a/webrtc/modules/audio_coding/acm2/rent_a_codec.cc +++ b/webrtc/modules/audio_coding/acm2/rent_a_codec.cc @@ -23,12 +23,12 @@ #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" #endif #ifdef WEBRTC_CODEC_ISACFX -#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isacfix.h" -#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isacfix.h" +#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isacfix.h" // nogncheck +#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isacfix.h" // nogncheck #endif #ifdef WEBRTC_CODEC_ISAC -#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h" -#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h" +#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h" // nogncheck +#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h" // nogncheck #endif #ifdef WEBRTC_CODEC_OPUS #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" @@ -38,7 +38,6 @@ #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" #endif #include "webrtc/modules/audio_coding/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" #if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC) #include "webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h" @@ -47,78 +46,6 @@ namespace webrtc { namespace acm2 { -rtc::Optional RentACodec::NetEqDecoderToSdpAudioFormat( - NetEqDecoder nd) { - switch (nd) { - case NetEqDecoder::kDecoderPCMu: - return rtc::Optional(SdpAudioFormat("pcmu", 8000, 1)); - case NetEqDecoder::kDecoderPCMa: - return rtc::Optional(SdpAudioFormat("pcma", 8000, 1)); - case NetEqDecoder::kDecoderPCMu_2ch: - return rtc::Optional(SdpAudioFormat("pcmu", 8000, 2)); - case NetEqDecoder::kDecoderPCMa_2ch: - return rtc::Optional(SdpAudioFormat("pcma", 8000, 2)); - case NetEqDecoder::kDecoderILBC: - return rtc::Optional(SdpAudioFormat("ilbc", 8000, 1)); - case NetEqDecoder::kDecoderISAC: - return rtc::Optional(SdpAudioFormat("isac", 16000, 1)); - case NetEqDecoder::kDecoderISACswb: - return rtc::Optional(SdpAudioFormat("isac", 32000, 1)); - case NetEqDecoder::kDecoderPCM16B: - return rtc::Optional(SdpAudioFormat("l16", 8000, 1)); - case NetEqDecoder::kDecoderPCM16Bwb: - return rtc::Optional(SdpAudioFormat("l16", 16000, 1)); - case NetEqDecoder::kDecoderPCM16Bswb32kHz: - return rtc::Optional(SdpAudioFormat("l16", 32000, 1)); - case NetEqDecoder::kDecoderPCM16Bswb48kHz: - return rtc::Optional(SdpAudioFormat("l16", 48000, 1)); - case NetEqDecoder::kDecoderPCM16B_2ch: - return rtc::Optional(SdpAudioFormat("l16", 8000, 2)); - case NetEqDecoder::kDecoderPCM16Bwb_2ch: - return rtc::Optional(SdpAudioFormat("l16", 16000, 2)); - case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch: - return rtc::Optional(SdpAudioFormat("l16", 32000, 2)); - case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch: - return rtc::Optional(SdpAudioFormat("l16", 48000, 2)); - case NetEqDecoder::kDecoderPCM16B_5ch: - return rtc::Optional(SdpAudioFormat("l16", 8000, 5)); - case NetEqDecoder::kDecoderG722: - return rtc::Optional(SdpAudioFormat("g722", 8000, 1)); - case NetEqDecoder::kDecoderG722_2ch: - return rtc::Optional(SdpAudioFormat("g722", 8000, 2)); - case NetEqDecoder::kDecoderOpus: - return rtc::Optional(SdpAudioFormat("opus", 48000, 2)); - case NetEqDecoder::kDecoderOpus_2ch: - return rtc::Optional( - SdpAudioFormat("opus", 48000, 2, - std::map{{"stereo", "1"}})); - case NetEqDecoder::kDecoderRED: - return rtc::Optional(SdpAudioFormat("red", 8000, 1)); - case NetEqDecoder::kDecoderAVT: - return rtc::Optional( - SdpAudioFormat("telephone-event", 8000, 1)); - case NetEqDecoder::kDecoderAVT16kHz: - return rtc::Optional( - SdpAudioFormat("telephone-event", 16000, 1)); - case NetEqDecoder::kDecoderAVT32kHz: - return rtc::Optional( - SdpAudioFormat("telephone-event", 32000, 1)); - case NetEqDecoder::kDecoderAVT48kHz: - return rtc::Optional( - SdpAudioFormat("telephone-event", 48000, 1)); - case NetEqDecoder::kDecoderCNGnb: - return rtc::Optional(SdpAudioFormat("cn", 8000, 1)); - case NetEqDecoder::kDecoderCNGwb: - return rtc::Optional(SdpAudioFormat("cn", 16000, 1)); - case NetEqDecoder::kDecoderCNGswb32kHz: - return rtc::Optional(SdpAudioFormat("cn", 32000, 1)); - case NetEqDecoder::kDecoderCNGswb48kHz: - return rtc::Optional(SdpAudioFormat("cn", 48000, 1)); - default: - return rtc::Optional(); - } -} - rtc::Optional RentACodec::CodecIdByParams( const char* payload_name, int sampling_freq_hz, diff --git a/webrtc/modules/audio_coding/acm2/rent_a_codec.h b/webrtc/modules/audio_coding/acm2/rent_a_codec.h index 069e1d5f36..0a52f564ec 100644 --- a/webrtc/modules/audio_coding/acm2/rent_a_codec.h +++ b/webrtc/modules/audio_coding/acm2/rent_a_codec.h @@ -16,13 +16,13 @@ #include #include "webrtc/api/audio_codecs/audio_decoder.h" -#include "webrtc/api/audio_codecs/audio_format.h" #include "webrtc/base/array_view.h" #include "webrtc/base/constructormagic.h" #include "webrtc/base/optional.h" #include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" +#include "webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -109,42 +109,6 @@ class RentACodec { kNone = -1 }; - enum class NetEqDecoder { - kDecoderPCMu, - kDecoderPCMa, - kDecoderPCMu_2ch, - kDecoderPCMa_2ch, - kDecoderILBC, - kDecoderISAC, - kDecoderISACswb, - kDecoderPCM16B, - kDecoderPCM16Bwb, - kDecoderPCM16Bswb32kHz, - kDecoderPCM16Bswb48kHz, - kDecoderPCM16B_2ch, - kDecoderPCM16Bwb_2ch, - kDecoderPCM16Bswb32kHz_2ch, - kDecoderPCM16Bswb48kHz_2ch, - kDecoderPCM16B_5ch, - kDecoderG722, - kDecoderG722_2ch, - kDecoderRED, - kDecoderAVT, - kDecoderAVT16kHz, - kDecoderAVT32kHz, - kDecoderAVT48kHz, - kDecoderCNGnb, - kDecoderCNGwb, - kDecoderCNGswb32kHz, - kDecoderCNGswb48kHz, - kDecoderArbitrary, - kDecoderOpus, - kDecoderOpus_2ch, - }; - - static rtc::Optional NetEqDecoderToSdpAudioFormat( - NetEqDecoder nd); - static inline size_t NumberOfCodecs() { return static_cast(CodecId::kNumCodecs); } diff --git a/webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc b/webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc index a9d20e1279..fe049ab44e 100644 --- a/webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc @@ -14,8 +14,6 @@ namespace webrtc { -using NetEqDecoder = acm2::RentACodec::NetEqDecoder; - class SplitBySamplesTest : public ::testing::TestWithParam { protected: virtual void SetUp() { diff --git a/webrtc/modules/audio_coding/include/audio_coding_module.h b/webrtc/modules/audio_coding/include/audio_coding_module.h index 7843fb876d..1893b626de 100644 --- a/webrtc/modules/audio_coding/include/audio_coding_module.h +++ b/webrtc/modules/audio_coding/include/audio_coding_module.h @@ -20,6 +20,7 @@ #include "webrtc/base/function_view.h" #include "webrtc/base/optional.h" #include "webrtc/common_types.h" +#include "webrtc/modules/audio_coding/codecs/audio_encoder.h" #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/neteq/include/neteq.h" #include "webrtc/modules/include/module.h" diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc index be35e5f568..4087973adb 100644 --- a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc +++ b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc @@ -21,12 +21,12 @@ #include "webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" #endif #ifdef WEBRTC_CODEC_ISACFX -#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isacfix.h" -#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isacfix.h" +#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isacfix.h" // nogncheck +#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isacfix.h" // nogncheck #endif #ifdef WEBRTC_CODEC_ISAC -#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h" -#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h" +#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h" // nogncheck +#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h" // nogncheck #endif #ifdef WEBRTC_CODEC_OPUS #include "webrtc/modules/audio_coding/codecs/opus/audio_decoder_opus.h" diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.h b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.h index a876f17976..325674f3e9 100644 --- a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.h +++ b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.h @@ -15,7 +15,7 @@ #include "webrtc/api/audio_codecs/audio_decoder.h" #include "webrtc/base/constructormagic.h" -#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" +#include "webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h" #include "webrtc/typedefs.h" #ifdef WEBRTC_CODEC_G722 @@ -24,8 +24,6 @@ namespace webrtc { -using NetEqDecoder = acm2::RentACodec::NetEqDecoder; - // Returns true if |codec_type| is supported. bool CodecSupported(NetEqDecoder codec_type); diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.cc b/webrtc/modules/audio_coding/neteq/decoder_database.cc index 16bec04453..d147d676ed 100644 --- a/webrtc/modules/audio_coding/neteq/decoder_database.cc +++ b/webrtc/modules/audio_coding/neteq/decoder_database.cc @@ -42,8 +42,7 @@ DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format, DecoderDatabase::DecoderInfo::DecoderInfo(NetEqDecoder ct, AudioDecoderFactory* factory) - : DecoderInfo(*acm2::RentACodec::NetEqDecoderToSdpAudioFormat(ct), - factory) {} + : DecoderInfo(*NetEqDecoderToSdpAudioFormat(ct), factory) {} DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format, AudioDecoder* ext_dec, @@ -135,8 +134,7 @@ int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type, !CodecSupported(codec_type)) { return kCodecNotSupported; } - const auto opt_format = - acm2::RentACodec::NetEqDecoderToSdpAudioFormat(codec_type); + const auto opt_format = NetEqDecoderToSdpAudioFormat(codec_type); if (!opt_format) { return kCodecNotSupported; } @@ -175,8 +173,7 @@ int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type, return kInvalidPointer; } - const auto opt_db_format = - acm2::RentACodec::NetEqDecoderToSdpAudioFormat(codec_type); + const auto opt_db_format = NetEqDecoderToSdpAudioFormat(codec_type); const SdpAudioFormat format = opt_db_format.value_or({"arbitrary", 0, 0}); std::pair ret; diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.h b/webrtc/modules/audio_coding/neteq/decoder_database.h index 114cca32c7..ec470f8d5f 100644 --- a/webrtc/modules/audio_coding/neteq/decoder_database.h +++ b/webrtc/modules/audio_coding/neteq/decoder_database.h @@ -18,6 +18,7 @@ #include "webrtc/api/audio_codecs/audio_decoder_factory.h" #include "webrtc/api/audio_codecs/audio_format.h" #include "webrtc/base/constructormagic.h" +#include "webrtc/base/scoped_ref_ptr.h" #include "webrtc/common_types.h" // NULL #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" diff --git a/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.cc b/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.cc new file mode 100644 index 0000000000..e9abf206fc --- /dev/null +++ b/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.cc @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017 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 +#include + +#include "webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h" + +namespace webrtc { + +rtc::Optional NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) { + switch (nd) { + case NetEqDecoder::kDecoderPCMu: + return rtc::Optional(SdpAudioFormat("pcmu", 8000, 1)); + case NetEqDecoder::kDecoderPCMa: + return rtc::Optional(SdpAudioFormat("pcma", 8000, 1)); + case NetEqDecoder::kDecoderPCMu_2ch: + return rtc::Optional(SdpAudioFormat("pcmu", 8000, 2)); + case NetEqDecoder::kDecoderPCMa_2ch: + return rtc::Optional(SdpAudioFormat("pcma", 8000, 2)); + case NetEqDecoder::kDecoderILBC: + return rtc::Optional(SdpAudioFormat("ilbc", 8000, 1)); + case NetEqDecoder::kDecoderISAC: + return rtc::Optional(SdpAudioFormat("isac", 16000, 1)); + case NetEqDecoder::kDecoderISACswb: + return rtc::Optional(SdpAudioFormat("isac", 32000, 1)); + case NetEqDecoder::kDecoderPCM16B: + return rtc::Optional(SdpAudioFormat("l16", 8000, 1)); + case NetEqDecoder::kDecoderPCM16Bwb: + return rtc::Optional(SdpAudioFormat("l16", 16000, 1)); + case NetEqDecoder::kDecoderPCM16Bswb32kHz: + return rtc::Optional(SdpAudioFormat("l16", 32000, 1)); + case NetEqDecoder::kDecoderPCM16Bswb48kHz: + return rtc::Optional(SdpAudioFormat("l16", 48000, 1)); + case NetEqDecoder::kDecoderPCM16B_2ch: + return rtc::Optional(SdpAudioFormat("l16", 8000, 2)); + case NetEqDecoder::kDecoderPCM16Bwb_2ch: + return rtc::Optional(SdpAudioFormat("l16", 16000, 2)); + case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch: + return rtc::Optional(SdpAudioFormat("l16", 32000, 2)); + case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch: + return rtc::Optional(SdpAudioFormat("l16", 48000, 2)); + case NetEqDecoder::kDecoderPCM16B_5ch: + return rtc::Optional(SdpAudioFormat("l16", 8000, 5)); + case NetEqDecoder::kDecoderG722: + return rtc::Optional(SdpAudioFormat("g722", 8000, 1)); + case NetEqDecoder::kDecoderG722_2ch: + return rtc::Optional(SdpAudioFormat("g722", 8000, 2)); + case NetEqDecoder::kDecoderOpus: + return rtc::Optional(SdpAudioFormat("opus", 48000, 2)); + case NetEqDecoder::kDecoderOpus_2ch: + return rtc::Optional( + SdpAudioFormat("opus", 48000, 2, + std::map{{"stereo", "1"}})); + case NetEqDecoder::kDecoderRED: + return rtc::Optional(SdpAudioFormat("red", 8000, 1)); + case NetEqDecoder::kDecoderAVT: + return rtc::Optional( + SdpAudioFormat("telephone-event", 8000, 1)); + case NetEqDecoder::kDecoderAVT16kHz: + return rtc::Optional( + SdpAudioFormat("telephone-event", 16000, 1)); + case NetEqDecoder::kDecoderAVT32kHz: + return rtc::Optional( + SdpAudioFormat("telephone-event", 32000, 1)); + case NetEqDecoder::kDecoderAVT48kHz: + return rtc::Optional( + SdpAudioFormat("telephone-event", 48000, 1)); + case NetEqDecoder::kDecoderCNGnb: + return rtc::Optional(SdpAudioFormat("cn", 8000, 1)); + case NetEqDecoder::kDecoderCNGwb: + return rtc::Optional(SdpAudioFormat("cn", 16000, 1)); + case NetEqDecoder::kDecoderCNGswb32kHz: + return rtc::Optional(SdpAudioFormat("cn", 32000, 1)); + case NetEqDecoder::kDecoderCNGswb48kHz: + return rtc::Optional(SdpAudioFormat("cn", 48000, 1)); + default: + return rtc::Optional(); + } +} + +} // namespace webrtc diff --git a/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h b/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h new file mode 100644 index 0000000000..6eb9300822 --- /dev/null +++ b/webrtc/modules/audio_coding/neteq/neteq_decoder_enum.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 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_NETEQ_NETEQ_DECODER_ENUM_H_ +#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_NETEQ_DECODER_ENUM_H_ + +#include "webrtc/api/audio_codecs/audio_format.h" +#include "webrtc/base/optional.h" + +namespace webrtc { + +enum class NetEqDecoder { + kDecoderPCMu, + kDecoderPCMa, + kDecoderPCMu_2ch, + kDecoderPCMa_2ch, + kDecoderILBC, + kDecoderISAC, + kDecoderISACswb, + kDecoderPCM16B, + kDecoderPCM16Bwb, + kDecoderPCM16Bswb32kHz, + kDecoderPCM16Bswb48kHz, + kDecoderPCM16B_2ch, + kDecoderPCM16Bwb_2ch, + kDecoderPCM16Bswb32kHz_2ch, + kDecoderPCM16Bswb48kHz_2ch, + kDecoderPCM16B_5ch, + kDecoderG722, + kDecoderG722_2ch, + kDecoderRED, + kDecoderAVT, + kDecoderAVT16kHz, + kDecoderAVT32kHz, + kDecoderAVT48kHz, + kDecoderCNGnb, + kDecoderCNGwb, + kDecoderCNGswb32kHz, + kDecoderCNGswb48kHz, + kDecoderArbitrary, + kDecoderOpus, + kDecoderOpus_2ch, +}; + +rtc::Optional NetEqDecoderToSdpAudioFormat(NetEqDecoder nd); + +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_NETEQ_DECODER_ENUM_H_ diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.h b/webrtc/modules/audio_coding/neteq/neteq_impl.h index 505f0f2a66..a8c3462708 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.h +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.h @@ -26,6 +26,7 @@ #include "webrtc/modules/audio_coding/neteq/rtcp.h" #include "webrtc/modules/audio_coding/neteq/statistics_calculator.h" #include "webrtc/modules/audio_coding/neteq/tick_timer.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/typedefs.h" namespace webrtc { diff --git a/webrtc/modules/audio_coding/test/APITest.cc b/webrtc/modules/audio_coding/test/APITest.cc index a4fc986153..6a458334e8 100644 --- a/webrtc/modules/audio_coding/test/APITest.cc +++ b/webrtc/modules/audio_coding/test/APITest.cc @@ -22,7 +22,6 @@ #include "webrtc/base/platform_thread.h" #include "webrtc/base/timeutils.h" #include "webrtc/common_types.h" -#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" #include "webrtc/modules/audio_coding/test/utility.h" #include "webrtc/system_wrappers/include/event_wrapper.h" diff --git a/webrtc/modules/audio_coding/test/EncodeDecodeTest.cc b/webrtc/modules/audio_coding/test/EncodeDecodeTest.cc index 3eada25c8c..87cd61c8e7 100644 --- a/webrtc/modules/audio_coding/test/EncodeDecodeTest.cc +++ b/webrtc/modules/audio_coding/test/EncodeDecodeTest.cc @@ -16,7 +16,6 @@ #include #include "webrtc/common_types.h" -#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h" #include "webrtc/modules/audio_coding/test/utility.h" diff --git a/webrtc/modules/audio_coding/test/delay_test.cc b/webrtc/modules/audio_coding/test/delay_test.cc index d39daf29b1..846ac29dc0 100644 --- a/webrtc/modules/audio_coding/test/delay_test.cc +++ b/webrtc/modules/audio_coding/test/delay_test.cc @@ -16,7 +16,6 @@ #include "gflags/gflags.h" #include "webrtc/common_types.h" -#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h" #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" diff --git a/webrtc/modules/audio_coding/test/iSACTest.cc b/webrtc/modules/audio_coding/test/iSACTest.cc index 6ccdf3c3cf..f8e8c85814 100644 --- a/webrtc/modules/audio_coding/test/iSACTest.cc +++ b/webrtc/modules/audio_coding/test/iSACTest.cc @@ -23,7 +23,6 @@ #include #endif -#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" #include "webrtc/modules/audio_coding/test/utility.h" #include "webrtc/system_wrappers/include/event_wrapper.h" diff --git a/webrtc/modules/audio_coding/test/utility.cc b/webrtc/modules/audio_coding/test/utility.cc index 30bafd4a49..043e6b93fb 100644 --- a/webrtc/modules/audio_coding/test/utility.cc +++ b/webrtc/modules/audio_coding/test/utility.cc @@ -16,7 +16,6 @@ #include #include "webrtc/common_types.h" -#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h" #include "webrtc/test/gtest.h"