summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/api/audio
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--third_party/libwebrtc/api/audio/BUILD.gn111
-rw-r--r--third_party/libwebrtc/api/audio/OWNERS2
-rw-r--r--third_party/libwebrtc/api/audio/aec3_config_gn/moz.build221
-rw-r--r--third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build233
-rw-r--r--third_party/libwebrtc/api/audio/audio_frame.cc140
-rw-r--r--third_party/libwebrtc/api/audio/audio_frame.h173
-rw-r--r--third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build226
-rw-r--r--third_party/libwebrtc/api/audio/audio_frame_processor.h43
-rw-r--r--third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build201
-rw-r--r--third_party/libwebrtc/api/audio/audio_mixer.h80
-rw-r--r--third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build209
-rw-r--r--third_party/libwebrtc/api/audio/channel_layout.cc282
-rw-r--r--third_party/libwebrtc/api/audio/channel_layout.h165
-rw-r--r--third_party/libwebrtc/api/audio/echo_canceller3_config.cc278
-rw-r--r--third_party/libwebrtc/api/audio/echo_canceller3_config.h250
-rw-r--r--third_party/libwebrtc/api/audio/echo_canceller3_config_json.cc772
-rw-r--r--third_party/libwebrtc/api/audio/echo_canceller3_config_json.h45
-rw-r--r--third_party/libwebrtc/api/audio/echo_canceller3_factory.cc32
-rw-r--r--third_party/libwebrtc/api/audio/echo_canceller3_factory.h41
-rw-r--r--third_party/libwebrtc/api/audio/echo_control.h75
-rw-r--r--third_party/libwebrtc/api/audio/echo_control_gn/moz.build205
-rw-r--r--third_party/libwebrtc/api/audio/echo_detector_creator.cc21
-rw-r--r--third_party/libwebrtc/api/audio/echo_detector_creator.h26
-rw-r--r--third_party/libwebrtc/api/audio/test/BUILD.gn30
-rw-r--r--third_party/libwebrtc/api/audio/test/audio_frame_unittest.cc136
-rw-r--r--third_party/libwebrtc/api/audio/test/echo_canceller3_config_json_unittest.cc93
-rw-r--r--third_party/libwebrtc/api/audio/test/echo_canceller3_config_unittest.cc46
-rw-r--r--third_party/libwebrtc/api/audio_codecs/BUILD.gn144
-rw-r--r--third_party/libwebrtc/api/audio_codecs/L16/BUILD.gn55
-rw-r--r--third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.cc49
-rw-r--r--third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.h49
-rw-r--r--third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build225
-rw-r--r--third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.cc76
-rw-r--r--third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.h54
-rw-r--r--third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build225
-rw-r--r--third_party/libwebrtc/api/audio_codecs/OWNERS3
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.cc91
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.h74
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build228
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_decoder.cc170
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_decoder.h195
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h53
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_decoder_factory_template.h145
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_encoder.cc114
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_encoder.h260
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_encoder_factory.h62
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_encoder_factory_template.h163
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_format.cc86
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_format.h133
-rw-r--r--third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.cc68
-rw-r--r--third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.h28
-rw-r--r--third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build234
-rw-r--r--third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.cc74
-rw-r--r--third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.h28
-rw-r--r--third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build234
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g711/BUILD.gn55
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.cc67
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.h49
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build225
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.cc95
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.h54
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build225
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/BUILD.gn62
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.cc56
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.h43
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build225
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.cc74
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.h44
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config.h29
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build209
-rw-r--r--third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build225
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/BUILD.gn58
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.cc42
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h39
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build232
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.cc88
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h43
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h28
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build201
-rw-r--r--third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build232
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/BUILD.gn110
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc71
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h42
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h66
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build226
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.cc86
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.h44
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build209
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build233
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc75
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h43
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc106
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h66
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build226
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.cc44
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.h44
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc75
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.h74
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build222
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build233
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.cc49
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.h26
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.cc54
-rw-r--r--third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.h26
-rw-r--r--third_party/libwebrtc/api/audio_codecs/test/BUILD.gn39
-rw-r--r--third_party/libwebrtc/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc222
-rw-r--r--third_party/libwebrtc/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc224
-rw-r--r--third_party/libwebrtc/api/audio_options.cc107
-rw-r--r--third_party/libwebrtc/api/audio_options.h80
-rw-r--r--third_party/libwebrtc/api/audio_options_api_gn/moz.build221
110 files changed, 13499 insertions, 0 deletions
diff --git a/third_party/libwebrtc/api/audio/BUILD.gn b/third_party/libwebrtc/api/audio/BUILD.gn
new file mode 100644
index 0000000000..4832751b5f
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/BUILD.gn
@@ -0,0 +1,111 @@
+# Copyright (c) 2018 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.
+
+import("../../webrtc.gni")
+
+rtc_library("audio_frame_api") {
+ visibility = [ "*" ]
+ sources = [
+ "audio_frame.cc",
+ "audio_frame.h",
+ "channel_layout.cc",
+ "channel_layout.h",
+ ]
+
+ deps = [
+ "..:rtp_packet_info",
+ "../../rtc_base:checks",
+ "../../rtc_base:logging",
+ "../../rtc_base:macromagic",
+ "../../rtc_base:timeutils",
+ ]
+}
+
+rtc_source_set("audio_frame_processor") {
+ visibility = [ "*" ]
+ sources = [ "audio_frame_processor.h" ]
+}
+
+rtc_source_set("audio_mixer_api") {
+ visibility = [ "*" ]
+ sources = [ "audio_mixer.h" ]
+
+ deps = [
+ ":audio_frame_api",
+ "..:make_ref_counted",
+ "../../rtc_base:refcount",
+ ]
+}
+
+rtc_library("aec3_config") {
+ visibility = [ "*" ]
+ sources = [
+ "echo_canceller3_config.cc",
+ "echo_canceller3_config.h",
+ ]
+ deps = [
+ "../../rtc_base:checks",
+ "../../rtc_base:safe_minmax",
+ "../../rtc_base/system:rtc_export",
+ ]
+}
+
+rtc_library("aec3_config_json") {
+ visibility = [ "*" ]
+ allow_poison = [ "rtc_json" ]
+ sources = [
+ "echo_canceller3_config_json.cc",
+ "echo_canceller3_config_json.h",
+ ]
+ deps = [
+ ":aec3_config",
+ "../../rtc_base:checks",
+ "../../rtc_base:logging",
+ "../../rtc_base:rtc_json",
+ "../../rtc_base:stringutils",
+ "../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
+}
+
+rtc_library("aec3_factory") {
+ visibility = [ "*" ]
+ configs += [ "../../modules/audio_processing:apm_debug_dump" ]
+ sources = [
+ "echo_canceller3_factory.cc",
+ "echo_canceller3_factory.h",
+ ]
+
+ deps = [
+ ":aec3_config",
+ ":echo_control",
+ "../../modules/audio_processing/aec3",
+ "../../rtc_base/system:rtc_export",
+ ]
+}
+
+rtc_source_set("echo_control") {
+ visibility = [ "*" ]
+ sources = [ "echo_control.h" ]
+ deps = [ "../../rtc_base:checks" ]
+}
+
+rtc_source_set("echo_detector_creator") {
+ visibility = [ "*" ]
+ allow_poison = [ "default_echo_detector" ]
+ sources = [
+ "echo_detector_creator.cc",
+ "echo_detector_creator.h",
+ ]
+ deps = [
+ "..:make_ref_counted",
+ "../../api:scoped_refptr",
+ "../../modules/audio_processing:api",
+ "../../modules/audio_processing:residual_echo_detector",
+ ]
+}
diff --git a/third_party/libwebrtc/api/audio/OWNERS b/third_party/libwebrtc/api/audio/OWNERS
new file mode 100644
index 0000000000..bb499b450f
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/OWNERS
@@ -0,0 +1,2 @@
+gustaf@webrtc.org
+peah@webrtc.org
diff --git a/third_party/libwebrtc/api/audio/aec3_config_gn/moz.build b/third_party/libwebrtc/api/audio/aec3_config_gn/moz.build
new file mode 100644
index 0000000000..c2d256488d
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/aec3_config_gn/moz.build
@@ -0,0 +1,221 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio/echo_canceller3_config.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("aec3_config_gn")
diff --git a/third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build b/third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build
new file mode 100644
index 0000000000..ecd28a7006
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build
@@ -0,0 +1,233 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_APM_DEBUG_DUMP"] = "0"
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio/echo_canceller3_factory.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "rt"
+ ]
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "crypt32",
+ "iphlpapi",
+ "secur32",
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("aec3_factory_gn")
diff --git a/third_party/libwebrtc/api/audio/audio_frame.cc b/third_party/libwebrtc/api/audio/audio_frame.cc
new file mode 100644
index 0000000000..3e12006386
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/audio_frame.cc
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2018 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 "api/audio/audio_frame.h"
+
+#include <string.h>
+
+#include "rtc_base/checks.h"
+#include "rtc_base/time_utils.h"
+
+namespace webrtc {
+
+AudioFrame::AudioFrame() {
+ // Visual Studio doesn't like this in the class definition.
+ static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes");
+}
+
+void AudioFrame::Reset() {
+ ResetWithoutMuting();
+ muted_ = true;
+}
+
+void AudioFrame::ResetWithoutMuting() {
+ // TODO(wu): Zero is a valid value for `timestamp_`. We should initialize
+ // to an invalid value, or add a new member to indicate invalidity.
+ timestamp_ = 0;
+ elapsed_time_ms_ = -1;
+ ntp_time_ms_ = -1;
+ samples_per_channel_ = 0;
+ sample_rate_hz_ = 0;
+ num_channels_ = 0;
+ channel_layout_ = CHANNEL_LAYOUT_NONE;
+ speech_type_ = kUndefined;
+ vad_activity_ = kVadUnknown;
+ profile_timestamp_ms_ = 0;
+ packet_infos_ = RtpPacketInfos();
+ absolute_capture_timestamp_ms_ = absl::nullopt;
+}
+
+void AudioFrame::UpdateFrame(uint32_t timestamp,
+ const int16_t* data,
+ size_t samples_per_channel,
+ int sample_rate_hz,
+ SpeechType speech_type,
+ VADActivity vad_activity,
+ size_t num_channels) {
+ timestamp_ = timestamp;
+ samples_per_channel_ = samples_per_channel;
+ sample_rate_hz_ = sample_rate_hz;
+ speech_type_ = speech_type;
+ vad_activity_ = vad_activity;
+ num_channels_ = num_channels;
+ channel_layout_ = GuessChannelLayout(num_channels);
+ if (channel_layout_ != CHANNEL_LAYOUT_UNSUPPORTED) {
+ RTC_DCHECK_EQ(num_channels, ChannelLayoutToChannelCount(channel_layout_));
+ }
+
+ const size_t length = samples_per_channel * num_channels;
+ RTC_CHECK_LE(length, kMaxDataSizeSamples);
+ if (data != nullptr) {
+ memcpy(data_, data, sizeof(int16_t) * length);
+ muted_ = false;
+ } else {
+ muted_ = true;
+ }
+}
+
+void AudioFrame::CopyFrom(const AudioFrame& src) {
+ if (this == &src)
+ return;
+
+ timestamp_ = src.timestamp_;
+ elapsed_time_ms_ = src.elapsed_time_ms_;
+ ntp_time_ms_ = src.ntp_time_ms_;
+ packet_infos_ = src.packet_infos_;
+ muted_ = src.muted();
+ samples_per_channel_ = src.samples_per_channel_;
+ sample_rate_hz_ = src.sample_rate_hz_;
+ speech_type_ = src.speech_type_;
+ vad_activity_ = src.vad_activity_;
+ num_channels_ = src.num_channels_;
+ channel_layout_ = src.channel_layout_;
+ absolute_capture_timestamp_ms_ = src.absolute_capture_timestamp_ms();
+
+ const size_t length = samples_per_channel_ * num_channels_;
+ RTC_CHECK_LE(length, kMaxDataSizeSamples);
+ if (!src.muted()) {
+ memcpy(data_, src.data(), sizeof(int16_t) * length);
+ muted_ = false;
+ }
+}
+
+void AudioFrame::UpdateProfileTimeStamp() {
+ profile_timestamp_ms_ = rtc::TimeMillis();
+}
+
+int64_t AudioFrame::ElapsedProfileTimeMs() const {
+ if (profile_timestamp_ms_ == 0) {
+ // Profiling has not been activated.
+ return -1;
+ }
+ return rtc::TimeSince(profile_timestamp_ms_);
+}
+
+const int16_t* AudioFrame::data() const {
+ return muted_ ? empty_data() : data_;
+}
+
+// TODO(henrik.lundin) Can we skip zeroing the buffer?
+// See https://bugs.chromium.org/p/webrtc/issues/detail?id=5647.
+int16_t* AudioFrame::mutable_data() {
+ if (muted_) {
+ memset(data_, 0, kMaxDataSizeBytes);
+ muted_ = false;
+ }
+ return data_;
+}
+
+void AudioFrame::Mute() {
+ muted_ = true;
+}
+
+bool AudioFrame::muted() const {
+ return muted_;
+}
+
+// static
+const int16_t* AudioFrame::empty_data() {
+ static int16_t* null_data = new int16_t[kMaxDataSizeSamples]();
+ return &null_data[0];
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/audio_frame.h b/third_party/libwebrtc/api/audio/audio_frame.h
new file mode 100644
index 0000000000..d5dcb5f788
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/audio_frame.h
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2018 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 API_AUDIO_AUDIO_FRAME_H_
+#define API_AUDIO_AUDIO_FRAME_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "api/audio/channel_layout.h"
+#include "api/rtp_packet_infos.h"
+
+namespace webrtc {
+
+/* This class holds up to 120 ms of super-wideband (32 kHz) stereo audio. It
+ * allows for adding and subtracting frames while keeping track of the resulting
+ * states.
+ *
+ * Notes
+ * - This is a de-facto api, not designed for external use. The AudioFrame class
+ * is in need of overhaul or even replacement, and anyone depending on it
+ * should be prepared for that.
+ * - The total number of samples is samples_per_channel_ * num_channels_.
+ * - Stereo data is interleaved starting with the left channel.
+ */
+class AudioFrame {
+ public:
+ // Using constexpr here causes linker errors unless the variable also has an
+ // out-of-class definition, which is impractical in this header-only class.
+ // (This makes no sense because it compiles as an enum value, which we most
+ // certainly cannot take the address of, just fine.) C++17 introduces inline
+ // variables which should allow us to switch to constexpr and keep this a
+ // header-only class.
+ enum : size_t {
+ // Stereo, 32 kHz, 120 ms (2 * 32 * 120)
+ // Stereo, 192 kHz, 20 ms (2 * 192 * 20)
+ kMaxDataSizeSamples = 7680,
+ kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t),
+ };
+
+ enum VADActivity { kVadActive = 0, kVadPassive = 1, kVadUnknown = 2 };
+ enum SpeechType {
+ kNormalSpeech = 0,
+ kPLC = 1,
+ kCNG = 2,
+ kPLCCNG = 3,
+ kCodecPLC = 5,
+ kUndefined = 4
+ };
+
+ AudioFrame();
+
+ AudioFrame(const AudioFrame&) = delete;
+ AudioFrame& operator=(const AudioFrame&) = delete;
+
+ // Resets all members to their default state.
+ void Reset();
+ // Same as Reset(), but leaves mute state unchanged. Muting a frame requires
+ // the buffer to be zeroed on the next call to mutable_data(). Callers
+ // intending to write to the buffer immediately after Reset() can instead use
+ // ResetWithoutMuting() to skip this wasteful zeroing.
+ void ResetWithoutMuting();
+
+ void UpdateFrame(uint32_t timestamp,
+ const int16_t* data,
+ size_t samples_per_channel,
+ int sample_rate_hz,
+ SpeechType speech_type,
+ VADActivity vad_activity,
+ size_t num_channels = 1);
+
+ void CopyFrom(const AudioFrame& src);
+
+ // Sets a wall-time clock timestamp in milliseconds to be used for profiling
+ // of time between two points in the audio chain.
+ // Example:
+ // t0: UpdateProfileTimeStamp()
+ // t1: ElapsedProfileTimeMs() => t1 - t0 [msec]
+ void UpdateProfileTimeStamp();
+ // Returns the time difference between now and when UpdateProfileTimeStamp()
+ // was last called. Returns -1 if UpdateProfileTimeStamp() has not yet been
+ // called.
+ int64_t ElapsedProfileTimeMs() const;
+
+ // data() returns a zeroed static buffer if the frame is muted.
+ // mutable_frame() always returns a non-static buffer; the first call to
+ // mutable_frame() zeros the non-static buffer and marks the frame unmuted.
+ const int16_t* data() const;
+ int16_t* mutable_data();
+
+ // Prefer to mute frames using AudioFrameOperations::Mute.
+ void Mute();
+ // Frame is muted by default.
+ bool muted() const;
+
+ size_t max_16bit_samples() const { return kMaxDataSizeSamples; }
+ size_t samples_per_channel() const { return samples_per_channel_; }
+ size_t num_channels() const { return num_channels_; }
+ ChannelLayout channel_layout() const { return channel_layout_; }
+ int sample_rate_hz() const { return sample_rate_hz_; }
+
+ void set_absolute_capture_timestamp_ms(
+ int64_t absolute_capture_time_stamp_ms) {
+ absolute_capture_timestamp_ms_ = absolute_capture_time_stamp_ms;
+ }
+
+ absl::optional<int64_t> absolute_capture_timestamp_ms() const {
+ return absolute_capture_timestamp_ms_;
+ }
+
+ // RTP timestamp of the first sample in the AudioFrame.
+ uint32_t timestamp_ = 0;
+ // Time since the first frame in milliseconds.
+ // -1 represents an uninitialized value.
+ int64_t elapsed_time_ms_ = -1;
+ // NTP time of the estimated capture time in local timebase in milliseconds.
+ // -1 represents an uninitialized value.
+ int64_t ntp_time_ms_ = -1;
+ size_t samples_per_channel_ = 0;
+ int sample_rate_hz_ = 0;
+ size_t num_channels_ = 0;
+ ChannelLayout channel_layout_ = CHANNEL_LAYOUT_NONE;
+ SpeechType speech_type_ = kUndefined;
+ VADActivity vad_activity_ = kVadUnknown;
+ // Monotonically increasing timestamp intended for profiling of audio frames.
+ // Typically used for measuring elapsed time between two different points in
+ // the audio path. No lock is used to save resources and we are thread safe
+ // by design.
+ // TODO(nisse@webrtc.org): consider using absl::optional.
+ int64_t profile_timestamp_ms_ = 0;
+
+ // Information about packets used to assemble this audio frame. This is needed
+ // by `SourceTracker` when the frame is delivered to the RTCRtpReceiver's
+ // MediaStreamTrack, in order to implement getContributingSources(). See:
+ // https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-getcontributingsources
+ //
+ // TODO(bugs.webrtc.org/10757):
+ // Note that this information might not be fully accurate since we currently
+ // don't have a proper way to track it across the audio sync buffer. The
+ // sync buffer is the small sample-holding buffer located after the audio
+ // decoder and before where samples are assembled into output frames.
+ //
+ // `RtpPacketInfos` may also be empty if the audio samples did not come from
+ // RTP packets. E.g. if the audio were locally generated by packet loss
+ // concealment, comfort noise generation, etc.
+ RtpPacketInfos packet_infos_;
+
+ private:
+ // A permanently zeroed out buffer to represent muted frames. This is a
+ // header-only class, so the only way to avoid creating a separate empty
+ // buffer per translation unit is to wrap a static in an inline function.
+ static const int16_t* empty_data();
+
+ int16_t data_[kMaxDataSizeSamples];
+ bool muted_ = true;
+
+ // Absolute capture timestamp when this audio frame was originally captured.
+ // This is only valid for audio frames captured on this machine. The absolute
+ // capture timestamp of a received frame is found in `packet_infos_`.
+ // This timestamp MUST be based on the same clock as rtc::TimeMillis().
+ absl::optional<int64_t> absolute_capture_timestamp_ms_;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_AUDIO_FRAME_H_
diff --git a/third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build b/third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build
new file mode 100644
index 0000000000..6fac266c73
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build
@@ -0,0 +1,226 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio/audio_frame.cc",
+ "/third_party/libwebrtc/api/audio/channel_layout.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_frame_api_gn")
diff --git a/third_party/libwebrtc/api/audio/audio_frame_processor.h b/third_party/libwebrtc/api/audio/audio_frame_processor.h
new file mode 100644
index 0000000000..cb65c4817e
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/audio_frame_processor.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2020 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 API_AUDIO_AUDIO_FRAME_PROCESSOR_H_
+#define API_AUDIO_AUDIO_FRAME_PROCESSOR_H_
+
+#include <functional>
+#include <memory>
+
+namespace webrtc {
+
+class AudioFrame;
+
+// If passed into PeerConnectionFactory, will be used for additional
+// processing of captured audio frames, performed before encoding.
+// Implementations must be thread-safe.
+class AudioFrameProcessor {
+ public:
+ using OnAudioFrameCallback = std::function<void(std::unique_ptr<AudioFrame>)>;
+ virtual ~AudioFrameProcessor() = default;
+
+ // Processes the frame received from WebRTC, is called by WebRTC off the
+ // realtime audio capturing path. AudioFrameProcessor must reply with
+ // processed frames by calling `sink_callback` if it was provided in SetSink()
+ // call. `sink_callback` can be called in the context of Process().
+ virtual void Process(std::unique_ptr<AudioFrame> frame) = 0;
+
+ // Atomically replaces the current sink with the new one. Before the
+ // first call to this function, or if the provided `sink_callback` is nullptr,
+ // processed frames are simply discarded.
+ virtual void SetSink(OnAudioFrameCallback sink_callback) = 0;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_AUDIO_FRAME_PROCESSOR_H_
diff --git a/third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build b/third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build
new file mode 100644
index 0000000000..1732aa7d0c
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build
@@ -0,0 +1,201 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_frame_processor_gn")
diff --git a/third_party/libwebrtc/api/audio/audio_mixer.h b/third_party/libwebrtc/api/audio/audio_mixer.h
new file mode 100644
index 0000000000..3483df22bc
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/audio_mixer.h
@@ -0,0 +1,80 @@
+/*
+ * 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 API_AUDIO_AUDIO_MIXER_H_
+#define API_AUDIO_AUDIO_MIXER_H_
+
+#include <memory>
+
+#include "api/audio/audio_frame.h"
+#include "rtc_base/ref_count.h"
+
+namespace webrtc {
+
+// WORK IN PROGRESS
+// This class is under development and is not yet intended for for use outside
+// of WebRtc/Libjingle.
+class AudioMixer : public rtc::RefCountInterface {
+ public:
+ // A callback class that all mixer participants must inherit from/implement.
+ class Source {
+ public:
+ enum class AudioFrameInfo {
+ kNormal, // The samples in audio_frame are valid and should be used.
+ kMuted, // The samples in audio_frame should not be used, but
+ // should be implicitly interpreted as zero. Other
+ // fields in audio_frame may be read and should
+ // contain meaningful values.
+ kError, // The audio_frame will not be used.
+ };
+
+ // Overwrites `audio_frame`. The data_ field is overwritten with
+ // 10 ms of new audio (either 1 or 2 interleaved channels) at
+ // `sample_rate_hz`. All fields in `audio_frame` must be updated.
+ virtual AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz,
+ AudioFrame* audio_frame) = 0;
+
+ // A way for a mixer implementation to distinguish participants.
+ virtual int Ssrc() const = 0;
+
+ // A way for this source to say that GetAudioFrameWithInfo called
+ // with this sample rate or higher will not cause quality loss.
+ virtual int PreferredSampleRate() const = 0;
+
+ virtual ~Source() {}
+ };
+
+ // Returns true if adding was successful. A source is never added
+ // twice. Addition and removal can happen on different threads.
+ virtual bool AddSource(Source* audio_source) = 0;
+
+ // Removal is never attempted if a source has not been successfully
+ // added to the mixer.
+ virtual void RemoveSource(Source* audio_source) = 0;
+
+ // Performs mixing by asking registered audio sources for audio. The
+ // mixed result is placed in the provided AudioFrame. This method
+ // will only be called from a single thread. The channels argument
+ // specifies the number of channels of the mix result. The mixer
+ // should mix at a rate that doesn't cause quality loss of the
+ // sources' audio. The mixing rate is one of the rates listed in
+ // AudioProcessing::NativeRate. All fields in
+ // `audio_frame_for_mixing` must be updated.
+ virtual void Mix(size_t number_of_channels,
+ AudioFrame* audio_frame_for_mixing) = 0;
+
+ protected:
+ // Since the mixer is reference counted, the destructor may be
+ // called from any thread.
+ ~AudioMixer() override {}
+};
+} // namespace webrtc
+
+#endif // API_AUDIO_AUDIO_MIXER_H_
diff --git a/third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build b/third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build
new file mode 100644
index 0000000000..4eac2aa4b4
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build
@@ -0,0 +1,209 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_mixer_api_gn")
diff --git a/third_party/libwebrtc/api/audio/channel_layout.cc b/third_party/libwebrtc/api/audio/channel_layout.cc
new file mode 100644
index 0000000000..e4ae356fab
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/channel_layout.cc
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2019 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 "api/audio/channel_layout.h"
+
+#include <stddef.h>
+
+#include "rtc_base/arraysize.h"
+#include "rtc_base/checks.h"
+#include "rtc_base/logging.h"
+
+namespace webrtc {
+
+static const int kLayoutToChannels[] = {
+ 0, // CHANNEL_LAYOUT_NONE
+ 0, // CHANNEL_LAYOUT_UNSUPPORTED
+ 1, // CHANNEL_LAYOUT_MONO
+ 2, // CHANNEL_LAYOUT_STEREO
+ 3, // CHANNEL_LAYOUT_2_1
+ 3, // CHANNEL_LAYOUT_SURROUND
+ 4, // CHANNEL_LAYOUT_4_0
+ 4, // CHANNEL_LAYOUT_2_2
+ 4, // CHANNEL_LAYOUT_QUAD
+ 5, // CHANNEL_LAYOUT_5_0
+ 6, // CHANNEL_LAYOUT_5_1
+ 5, // CHANNEL_LAYOUT_5_0_BACK
+ 6, // CHANNEL_LAYOUT_5_1_BACK
+ 7, // CHANNEL_LAYOUT_7_0
+ 8, // CHANNEL_LAYOUT_7_1
+ 8, // CHANNEL_LAYOUT_7_1_WIDE
+ 2, // CHANNEL_LAYOUT_STEREO_DOWNMIX
+ 3, // CHANNEL_LAYOUT_2POINT1
+ 4, // CHANNEL_LAYOUT_3_1
+ 5, // CHANNEL_LAYOUT_4_1
+ 6, // CHANNEL_LAYOUT_6_0
+ 6, // CHANNEL_LAYOUT_6_0_FRONT
+ 6, // CHANNEL_LAYOUT_HEXAGONAL
+ 7, // CHANNEL_LAYOUT_6_1
+ 7, // CHANNEL_LAYOUT_6_1_BACK
+ 7, // CHANNEL_LAYOUT_6_1_FRONT
+ 7, // CHANNEL_LAYOUT_7_0_FRONT
+ 8, // CHANNEL_LAYOUT_7_1_WIDE_BACK
+ 8, // CHANNEL_LAYOUT_OCTAGONAL
+ 0, // CHANNEL_LAYOUT_DISCRETE
+ 3, // CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC
+ 5, // CHANNEL_LAYOUT_4_1_QUAD_SIDE
+ 0, // CHANNEL_LAYOUT_BITSTREAM
+};
+
+// The channel orderings for each layout as specified by FFmpeg. Each value
+// represents the index of each channel in each layout. Values of -1 mean the
+// channel at that index is not used for that layout. For example, the left side
+// surround sound channel in FFmpeg's 5.1 layout is in the 5th position (because
+// the order is L, R, C, LFE, LS, RS), so
+// kChannelOrderings[CHANNEL_LAYOUT_5_1][SIDE_LEFT] = 4;
+static const int kChannelOrderings[CHANNEL_LAYOUT_MAX + 1][CHANNELS_MAX + 1] = {
+ // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR
+
+ // CHANNEL_LAYOUT_NONE
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_UNSUPPORTED
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_MONO
+ {-1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_STEREO
+ {0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_2_1
+ {0, 1, -1, -1, -1, -1, -1, -1, 2, -1, -1},
+
+ // CHANNEL_LAYOUT_SURROUND
+ {0, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_4_0
+ {0, 1, 2, -1, -1, -1, -1, -1, 3, -1, -1},
+
+ // CHANNEL_LAYOUT_2_2
+ {0, 1, -1, -1, -1, -1, -1, -1, -1, 2, 3},
+
+ // CHANNEL_LAYOUT_QUAD
+ {0, 1, -1, -1, 2, 3, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_5_0
+ {0, 1, 2, -1, -1, -1, -1, -1, -1, 3, 4},
+
+ // CHANNEL_LAYOUT_5_1
+ {0, 1, 2, 3, -1, -1, -1, -1, -1, 4, 5},
+
+ // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR
+
+ // CHANNEL_LAYOUT_5_0_BACK
+ {0, 1, 2, -1, 3, 4, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_5_1_BACK
+ {0, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_7_0
+ {0, 1, 2, -1, 5, 6, -1, -1, -1, 3, 4},
+
+ // CHANNEL_LAYOUT_7_1
+ {0, 1, 2, 3, 6, 7, -1, -1, -1, 4, 5},
+
+ // CHANNEL_LAYOUT_7_1_WIDE
+ {0, 1, 2, 3, -1, -1, 6, 7, -1, 4, 5},
+
+ // CHANNEL_LAYOUT_STEREO_DOWNMIX
+ {0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_2POINT1
+ {0, 1, -1, 2, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_3_1
+ {0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_4_1
+ {0, 1, 2, 4, -1, -1, -1, -1, 3, -1, -1},
+
+ // CHANNEL_LAYOUT_6_0
+ {0, 1, 2, -1, -1, -1, -1, -1, 5, 3, 4},
+
+ // CHANNEL_LAYOUT_6_0_FRONT
+ {0, 1, -1, -1, -1, -1, 4, 5, -1, 2, 3},
+
+ // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR
+
+ // CHANNEL_LAYOUT_HEXAGONAL
+ {0, 1, 2, -1, 3, 4, -1, -1, 5, -1, -1},
+
+ // CHANNEL_LAYOUT_6_1
+ {0, 1, 2, 3, -1, -1, -1, -1, 6, 4, 5},
+
+ // CHANNEL_LAYOUT_6_1_BACK
+ {0, 1, 2, 3, 4, 5, -1, -1, 6, -1, -1},
+
+ // CHANNEL_LAYOUT_6_1_FRONT
+ {0, 1, -1, 6, -1, -1, 4, 5, -1, 2, 3},
+
+ // CHANNEL_LAYOUT_7_0_FRONT
+ {0, 1, 2, -1, -1, -1, 5, 6, -1, 3, 4},
+
+ // CHANNEL_LAYOUT_7_1_WIDE_BACK
+ {0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_OCTAGONAL
+ {0, 1, 2, -1, 5, 6, -1, -1, 7, 3, 4},
+
+ // CHANNEL_LAYOUT_DISCRETE
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC
+ {0, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // CHANNEL_LAYOUT_4_1_QUAD_SIDE
+ {0, 1, -1, 4, -1, -1, -1, -1, -1, 2, 3},
+
+ // CHANNEL_LAYOUT_BITSTREAM
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+
+ // FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR
+};
+
+int ChannelLayoutToChannelCount(ChannelLayout layout) {
+ RTC_DCHECK_LT(static_cast<size_t>(layout), arraysize(kLayoutToChannels));
+ RTC_DCHECK_LE(kLayoutToChannels[layout], kMaxConcurrentChannels);
+ return kLayoutToChannels[layout];
+}
+
+// Converts a channel count into a channel layout.
+ChannelLayout GuessChannelLayout(int channels) {
+ switch (channels) {
+ case 1:
+ return CHANNEL_LAYOUT_MONO;
+ case 2:
+ return CHANNEL_LAYOUT_STEREO;
+ case 3:
+ return CHANNEL_LAYOUT_SURROUND;
+ case 4:
+ return CHANNEL_LAYOUT_QUAD;
+ case 5:
+ return CHANNEL_LAYOUT_5_0;
+ case 6:
+ return CHANNEL_LAYOUT_5_1;
+ case 7:
+ return CHANNEL_LAYOUT_6_1;
+ case 8:
+ return CHANNEL_LAYOUT_7_1;
+ default:
+ RTC_DLOG(LS_WARNING) << "Unsupported channel count: " << channels;
+ }
+ return CHANNEL_LAYOUT_UNSUPPORTED;
+}
+
+int ChannelOrder(ChannelLayout layout, Channels channel) {
+ RTC_DCHECK_LT(static_cast<size_t>(layout), arraysize(kChannelOrderings));
+ RTC_DCHECK_LT(static_cast<size_t>(channel), arraysize(kChannelOrderings[0]));
+ return kChannelOrderings[layout][channel];
+}
+
+const char* ChannelLayoutToString(ChannelLayout layout) {
+ switch (layout) {
+ case CHANNEL_LAYOUT_NONE:
+ return "NONE";
+ case CHANNEL_LAYOUT_UNSUPPORTED:
+ return "UNSUPPORTED";
+ case CHANNEL_LAYOUT_MONO:
+ return "MONO";
+ case CHANNEL_LAYOUT_STEREO:
+ return "STEREO";
+ case CHANNEL_LAYOUT_2_1:
+ return "2.1";
+ case CHANNEL_LAYOUT_SURROUND:
+ return "SURROUND";
+ case CHANNEL_LAYOUT_4_0:
+ return "4.0";
+ case CHANNEL_LAYOUT_2_2:
+ return "QUAD_SIDE";
+ case CHANNEL_LAYOUT_QUAD:
+ return "QUAD";
+ case CHANNEL_LAYOUT_5_0:
+ return "5.0";
+ case CHANNEL_LAYOUT_5_1:
+ return "5.1";
+ case CHANNEL_LAYOUT_5_0_BACK:
+ return "5.0_BACK";
+ case CHANNEL_LAYOUT_5_1_BACK:
+ return "5.1_BACK";
+ case CHANNEL_LAYOUT_7_0:
+ return "7.0";
+ case CHANNEL_LAYOUT_7_1:
+ return "7.1";
+ case CHANNEL_LAYOUT_7_1_WIDE:
+ return "7.1_WIDE";
+ case CHANNEL_LAYOUT_STEREO_DOWNMIX:
+ return "STEREO_DOWNMIX";
+ case CHANNEL_LAYOUT_2POINT1:
+ return "2POINT1";
+ case CHANNEL_LAYOUT_3_1:
+ return "3.1";
+ case CHANNEL_LAYOUT_4_1:
+ return "4.1";
+ case CHANNEL_LAYOUT_6_0:
+ return "6.0";
+ case CHANNEL_LAYOUT_6_0_FRONT:
+ return "6.0_FRONT";
+ case CHANNEL_LAYOUT_HEXAGONAL:
+ return "HEXAGONAL";
+ case CHANNEL_LAYOUT_6_1:
+ return "6.1";
+ case CHANNEL_LAYOUT_6_1_BACK:
+ return "6.1_BACK";
+ case CHANNEL_LAYOUT_6_1_FRONT:
+ return "6.1_FRONT";
+ case CHANNEL_LAYOUT_7_0_FRONT:
+ return "7.0_FRONT";
+ case CHANNEL_LAYOUT_7_1_WIDE_BACK:
+ return "7.1_WIDE_BACK";
+ case CHANNEL_LAYOUT_OCTAGONAL:
+ return "OCTAGONAL";
+ case CHANNEL_LAYOUT_DISCRETE:
+ return "DISCRETE";
+ case CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC:
+ return "STEREO_AND_KEYBOARD_MIC";
+ case CHANNEL_LAYOUT_4_1_QUAD_SIDE:
+ return "4.1_QUAD_SIDE";
+ case CHANNEL_LAYOUT_BITSTREAM:
+ return "BITSTREAM";
+ }
+ RTC_DCHECK_NOTREACHED() << "Invalid channel layout provided: " << layout;
+ return "";
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/channel_layout.h b/third_party/libwebrtc/api/audio/channel_layout.h
new file mode 100644
index 0000000000..175aee71e5
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/channel_layout.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2019 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 API_AUDIO_CHANNEL_LAYOUT_H_
+#define API_AUDIO_CHANNEL_LAYOUT_H_
+
+namespace webrtc {
+
+// This file is derived from Chromium's base/channel_layout.h.
+
+// Enumerates the various representations of the ordering of audio channels.
+// Logged to UMA, so never reuse a value, always add new/greater ones!
+enum ChannelLayout {
+ CHANNEL_LAYOUT_NONE = 0,
+ CHANNEL_LAYOUT_UNSUPPORTED = 1,
+
+ // Front C
+ CHANNEL_LAYOUT_MONO = 2,
+
+ // Front L, Front R
+ CHANNEL_LAYOUT_STEREO = 3,
+
+ // Front L, Front R, Back C
+ CHANNEL_LAYOUT_2_1 = 4,
+
+ // Front L, Front R, Front C
+ CHANNEL_LAYOUT_SURROUND = 5,
+
+ // Front L, Front R, Front C, Back C
+ CHANNEL_LAYOUT_4_0 = 6,
+
+ // Front L, Front R, Side L, Side R
+ CHANNEL_LAYOUT_2_2 = 7,
+
+ // Front L, Front R, Back L, Back R
+ CHANNEL_LAYOUT_QUAD = 8,
+
+ // Front L, Front R, Front C, Side L, Side R
+ CHANNEL_LAYOUT_5_0 = 9,
+
+ // Front L, Front R, Front C, LFE, Side L, Side R
+ CHANNEL_LAYOUT_5_1 = 10,
+
+ // Front L, Front R, Front C, Back L, Back R
+ CHANNEL_LAYOUT_5_0_BACK = 11,
+
+ // Front L, Front R, Front C, LFE, Back L, Back R
+ CHANNEL_LAYOUT_5_1_BACK = 12,
+
+ // Front L, Front R, Front C, Side L, Side R, Back L, Back R
+ CHANNEL_LAYOUT_7_0 = 13,
+
+ // Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R
+ CHANNEL_LAYOUT_7_1 = 14,
+
+ // Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC
+ CHANNEL_LAYOUT_7_1_WIDE = 15,
+
+ // Stereo L, Stereo R
+ CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
+
+ // Stereo L, Stereo R, LFE
+ CHANNEL_LAYOUT_2POINT1 = 17,
+
+ // Stereo L, Stereo R, Front C, LFE
+ CHANNEL_LAYOUT_3_1 = 18,
+
+ // Stereo L, Stereo R, Front C, Rear C, LFE
+ CHANNEL_LAYOUT_4_1 = 19,
+
+ // Stereo L, Stereo R, Front C, Side L, Side R, Back C
+ CHANNEL_LAYOUT_6_0 = 20,
+
+ // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
+ CHANNEL_LAYOUT_6_0_FRONT = 21,
+
+ // Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C
+ CHANNEL_LAYOUT_HEXAGONAL = 22,
+
+ // Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center
+ CHANNEL_LAYOUT_6_1 = 23,
+
+ // Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center
+ CHANNEL_LAYOUT_6_1_BACK = 24,
+
+ // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
+ CHANNEL_LAYOUT_6_1_FRONT = 25,
+
+ // Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
+ CHANNEL_LAYOUT_7_0_FRONT = 26,
+
+ // Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC
+ CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
+
+ // Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C.
+ CHANNEL_LAYOUT_OCTAGONAL = 28,
+
+ // Channels are not explicitly mapped to speakers.
+ CHANNEL_LAYOUT_DISCRETE = 29,
+
+ // Front L, Front R, Front C. Front C contains the keyboard mic audio. This
+ // layout is only intended for input for WebRTC. The Front C channel
+ // is stripped away in the WebRTC audio input pipeline and never seen outside
+ // of that.
+ CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30,
+
+ // Front L, Front R, Side L, Side R, LFE
+ CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31,
+
+ // Actual channel layout is specified in the bitstream and the actual channel
+ // count is unknown at Chromium media pipeline level (useful for audio
+ // pass-through mode).
+ CHANNEL_LAYOUT_BITSTREAM = 32,
+
+ // Max value, must always equal the largest entry ever logged.
+ CHANNEL_LAYOUT_MAX = CHANNEL_LAYOUT_BITSTREAM
+};
+
+// Note: Do not reorder or reassign these values; other code depends on their
+// ordering to operate correctly. E.g., CoreAudio channel layout computations.
+enum Channels {
+ LEFT = 0,
+ RIGHT,
+ CENTER,
+ LFE,
+ BACK_LEFT,
+ BACK_RIGHT,
+ LEFT_OF_CENTER,
+ RIGHT_OF_CENTER,
+ BACK_CENTER,
+ SIDE_LEFT,
+ SIDE_RIGHT,
+ CHANNELS_MAX =
+ SIDE_RIGHT, // Must always equal the largest value ever logged.
+};
+
+// The maximum number of concurrently active channels for all possible layouts.
+// ChannelLayoutToChannelCount() will never return a value higher than this.
+constexpr int kMaxConcurrentChannels = 8;
+
+// Returns the expected channel position in an interleaved stream. Values of -1
+// mean the channel at that index is not used for that layout. Values range
+// from 0 to ChannelLayoutToChannelCount(layout) - 1.
+int ChannelOrder(ChannelLayout layout, Channels channel);
+
+// Returns the number of channels in a given ChannelLayout.
+int ChannelLayoutToChannelCount(ChannelLayout layout);
+
+// Given the number of channels, return the best layout,
+// or return CHANNEL_LAYOUT_UNSUPPORTED if there is no good match.
+ChannelLayout GuessChannelLayout(int channels);
+
+// Returns a string representation of the channel layout.
+const char* ChannelLayoutToString(ChannelLayout layout);
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CHANNEL_LAYOUT_H_
diff --git a/third_party/libwebrtc/api/audio/echo_canceller3_config.cc b/third_party/libwebrtc/api/audio/echo_canceller3_config.cc
new file mode 100644
index 0000000000..0224c712b4
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_canceller3_config.cc
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2018 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 "api/audio/echo_canceller3_config.h"
+
+#include <algorithm>
+#include <cmath>
+
+#include "rtc_base/checks.h"
+#include "rtc_base/numerics/safe_minmax.h"
+
+namespace webrtc {
+namespace {
+bool Limit(float* value, float min, float max) {
+ float clamped = rtc::SafeClamp(*value, min, max);
+ clamped = std::isfinite(clamped) ? clamped : min;
+ bool res = *value == clamped;
+ *value = clamped;
+ return res;
+}
+
+bool Limit(size_t* value, size_t min, size_t max) {
+ size_t clamped = rtc::SafeClamp(*value, min, max);
+ bool res = *value == clamped;
+ *value = clamped;
+ return res;
+}
+
+bool Limit(int* value, int min, int max) {
+ int clamped = rtc::SafeClamp(*value, min, max);
+ bool res = *value == clamped;
+ *value = clamped;
+ return res;
+}
+
+bool FloorLimit(size_t* value, size_t min) {
+ size_t clamped = *value >= min ? *value : min;
+ bool res = *value == clamped;
+ *value = clamped;
+ return res;
+}
+
+} // namespace
+
+EchoCanceller3Config::EchoCanceller3Config() = default;
+EchoCanceller3Config::EchoCanceller3Config(const EchoCanceller3Config& e) =
+ default;
+EchoCanceller3Config& EchoCanceller3Config::operator=(
+ const EchoCanceller3Config& e) = default;
+EchoCanceller3Config::Delay::Delay() = default;
+EchoCanceller3Config::Delay::Delay(const EchoCanceller3Config::Delay& e) =
+ default;
+EchoCanceller3Config::Delay& EchoCanceller3Config::Delay::operator=(
+ const Delay& e) = default;
+
+EchoCanceller3Config::EchoModel::EchoModel() = default;
+EchoCanceller3Config::EchoModel::EchoModel(
+ const EchoCanceller3Config::EchoModel& e) = default;
+EchoCanceller3Config::EchoModel& EchoCanceller3Config::EchoModel::operator=(
+ const EchoModel& e) = default;
+
+EchoCanceller3Config::Suppressor::Suppressor() = default;
+EchoCanceller3Config::Suppressor::Suppressor(
+ const EchoCanceller3Config::Suppressor& e) = default;
+EchoCanceller3Config::Suppressor& EchoCanceller3Config::Suppressor::operator=(
+ const Suppressor& e) = default;
+
+EchoCanceller3Config::Suppressor::MaskingThresholds::MaskingThresholds(
+ float enr_transparent,
+ float enr_suppress,
+ float emr_transparent)
+ : enr_transparent(enr_transparent),
+ enr_suppress(enr_suppress),
+ emr_transparent(emr_transparent) {}
+EchoCanceller3Config::Suppressor::MaskingThresholds::MaskingThresholds(
+ const EchoCanceller3Config::Suppressor::MaskingThresholds& e) = default;
+EchoCanceller3Config::Suppressor::MaskingThresholds&
+EchoCanceller3Config::Suppressor::MaskingThresholds::operator=(
+ const MaskingThresholds& e) = default;
+
+EchoCanceller3Config::Suppressor::Tuning::Tuning(MaskingThresholds mask_lf,
+ MaskingThresholds mask_hf,
+ float max_inc_factor,
+ float max_dec_factor_lf)
+ : mask_lf(mask_lf),
+ mask_hf(mask_hf),
+ max_inc_factor(max_inc_factor),
+ max_dec_factor_lf(max_dec_factor_lf) {}
+EchoCanceller3Config::Suppressor::Tuning::Tuning(
+ const EchoCanceller3Config::Suppressor::Tuning& e) = default;
+EchoCanceller3Config::Suppressor::Tuning&
+EchoCanceller3Config::Suppressor::Tuning::operator=(const Tuning& e) = default;
+
+bool EchoCanceller3Config::Validate(EchoCanceller3Config* config) {
+ RTC_DCHECK(config);
+ EchoCanceller3Config* c = config;
+ bool res = true;
+
+ if (c->delay.down_sampling_factor != 4 &&
+ c->delay.down_sampling_factor != 8) {
+ c->delay.down_sampling_factor = 4;
+ res = false;
+ }
+
+ res = res & Limit(&c->delay.default_delay, 0, 5000);
+ res = res & Limit(&c->delay.num_filters, 0, 5000);
+ res = res & Limit(&c->delay.delay_headroom_samples, 0, 5000);
+ res = res & Limit(&c->delay.hysteresis_limit_blocks, 0, 5000);
+ res = res & Limit(&c->delay.fixed_capture_delay_samples, 0, 5000);
+ res = res & Limit(&c->delay.delay_estimate_smoothing, 0.f, 1.f);
+ res = res & Limit(&c->delay.delay_candidate_detection_threshold, 0.f, 1.f);
+ res = res & Limit(&c->delay.delay_selection_thresholds.initial, 1, 250);
+ res = res & Limit(&c->delay.delay_selection_thresholds.converged, 1, 250);
+
+ res = res & FloorLimit(&c->filter.refined.length_blocks, 1);
+ res = res & Limit(&c->filter.refined.leakage_converged, 0.f, 1000.f);
+ res = res & Limit(&c->filter.refined.leakage_diverged, 0.f, 1000.f);
+ res = res & Limit(&c->filter.refined.error_floor, 0.f, 1000.f);
+ res = res & Limit(&c->filter.refined.error_ceil, 0.f, 100000000.f);
+ res = res & Limit(&c->filter.refined.noise_gate, 0.f, 100000000.f);
+
+ res = res & FloorLimit(&c->filter.refined_initial.length_blocks, 1);
+ res = res & Limit(&c->filter.refined_initial.leakage_converged, 0.f, 1000.f);
+ res = res & Limit(&c->filter.refined_initial.leakage_diverged, 0.f, 1000.f);
+ res = res & Limit(&c->filter.refined_initial.error_floor, 0.f, 1000.f);
+ res = res & Limit(&c->filter.refined_initial.error_ceil, 0.f, 100000000.f);
+ res = res & Limit(&c->filter.refined_initial.noise_gate, 0.f, 100000000.f);
+
+ if (c->filter.refined.length_blocks <
+ c->filter.refined_initial.length_blocks) {
+ c->filter.refined_initial.length_blocks = c->filter.refined.length_blocks;
+ res = false;
+ }
+
+ res = res & FloorLimit(&c->filter.coarse.length_blocks, 1);
+ res = res & Limit(&c->filter.coarse.rate, 0.f, 1.f);
+ res = res & Limit(&c->filter.coarse.noise_gate, 0.f, 100000000.f);
+
+ res = res & FloorLimit(&c->filter.coarse_initial.length_blocks, 1);
+ res = res & Limit(&c->filter.coarse_initial.rate, 0.f, 1.f);
+ res = res & Limit(&c->filter.coarse_initial.noise_gate, 0.f, 100000000.f);
+
+ if (c->filter.coarse.length_blocks < c->filter.coarse_initial.length_blocks) {
+ c->filter.coarse_initial.length_blocks = c->filter.coarse.length_blocks;
+ res = false;
+ }
+
+ res = res & Limit(&c->filter.config_change_duration_blocks, 0, 100000);
+ res = res & Limit(&c->filter.initial_state_seconds, 0.f, 100.f);
+ res = res & Limit(&c->filter.coarse_reset_hangover_blocks, 0, 250000);
+
+ res = res & Limit(&c->erle.min, 1.f, 100000.f);
+ res = res & Limit(&c->erle.max_l, 1.f, 100000.f);
+ res = res & Limit(&c->erle.max_h, 1.f, 100000.f);
+ if (c->erle.min > c->erle.max_l || c->erle.min > c->erle.max_h) {
+ c->erle.min = std::min(c->erle.max_l, c->erle.max_h);
+ res = false;
+ }
+ res = res & Limit(&c->erle.num_sections, 1, c->filter.refined.length_blocks);
+
+ res = res & Limit(&c->ep_strength.default_gain, 0.f, 1000000.f);
+ res = res & Limit(&c->ep_strength.default_len, -1.f, 1.f);
+ res = res & Limit(&c->ep_strength.nearend_len, -1.0f, 1.0f);
+
+ res =
+ res & Limit(&c->echo_audibility.low_render_limit, 0.f, 32768.f * 32768.f);
+ res = res &
+ Limit(&c->echo_audibility.normal_render_limit, 0.f, 32768.f * 32768.f);
+ res = res & Limit(&c->echo_audibility.floor_power, 0.f, 32768.f * 32768.f);
+ res = res & Limit(&c->echo_audibility.audibility_threshold_lf, 0.f,
+ 32768.f * 32768.f);
+ res = res & Limit(&c->echo_audibility.audibility_threshold_mf, 0.f,
+ 32768.f * 32768.f);
+ res = res & Limit(&c->echo_audibility.audibility_threshold_hf, 0.f,
+ 32768.f * 32768.f);
+
+ res = res &
+ Limit(&c->render_levels.active_render_limit, 0.f, 32768.f * 32768.f);
+ res = res & Limit(&c->render_levels.poor_excitation_render_limit, 0.f,
+ 32768.f * 32768.f);
+ res = res & Limit(&c->render_levels.poor_excitation_render_limit_ds8, 0.f,
+ 32768.f * 32768.f);
+
+ res = res & Limit(&c->echo_model.noise_floor_hold, 0, 1000);
+ res = res & Limit(&c->echo_model.min_noise_floor_power, 0, 2000000.f);
+ res = res & Limit(&c->echo_model.stationary_gate_slope, 0, 1000000.f);
+ res = res & Limit(&c->echo_model.noise_gate_power, 0, 1000000.f);
+ res = res & Limit(&c->echo_model.noise_gate_slope, 0, 1000000.f);
+ res = res & Limit(&c->echo_model.render_pre_window_size, 0, 100);
+ res = res & Limit(&c->echo_model.render_post_window_size, 0, 100);
+
+ res = res & Limit(&c->comfort_noise.noise_floor_dbfs, -200.f, 0.f);
+
+ res = res & Limit(&c->suppressor.nearend_average_blocks, 1, 5000);
+
+ res = res &
+ Limit(&c->suppressor.normal_tuning.mask_lf.enr_transparent, 0.f, 100.f);
+ res = res &
+ Limit(&c->suppressor.normal_tuning.mask_lf.enr_suppress, 0.f, 100.f);
+ res = res &
+ Limit(&c->suppressor.normal_tuning.mask_lf.emr_transparent, 0.f, 100.f);
+ res = res &
+ Limit(&c->suppressor.normal_tuning.mask_hf.enr_transparent, 0.f, 100.f);
+ res = res &
+ Limit(&c->suppressor.normal_tuning.mask_hf.enr_suppress, 0.f, 100.f);
+ res = res &
+ Limit(&c->suppressor.normal_tuning.mask_hf.emr_transparent, 0.f, 100.f);
+ res = res & Limit(&c->suppressor.normal_tuning.max_inc_factor, 0.f, 100.f);
+ res = res & Limit(&c->suppressor.normal_tuning.max_dec_factor_lf, 0.f, 100.f);
+
+ res = res & Limit(&c->suppressor.nearend_tuning.mask_lf.enr_transparent, 0.f,
+ 100.f);
+ res = res &
+ Limit(&c->suppressor.nearend_tuning.mask_lf.enr_suppress, 0.f, 100.f);
+ res = res & Limit(&c->suppressor.nearend_tuning.mask_lf.emr_transparent, 0.f,
+ 100.f);
+ res = res & Limit(&c->suppressor.nearend_tuning.mask_hf.enr_transparent, 0.f,
+ 100.f);
+ res = res &
+ Limit(&c->suppressor.nearend_tuning.mask_hf.enr_suppress, 0.f, 100.f);
+ res = res & Limit(&c->suppressor.nearend_tuning.mask_hf.emr_transparent, 0.f,
+ 100.f);
+ res = res & Limit(&c->suppressor.nearend_tuning.max_inc_factor, 0.f, 100.f);
+ res =
+ res & Limit(&c->suppressor.nearend_tuning.max_dec_factor_lf, 0.f, 100.f);
+
+ res = res & Limit(&c->suppressor.last_permanent_lf_smoothing_band, 0, 64);
+ res = res & Limit(&c->suppressor.last_lf_smoothing_band, 0, 64);
+ res = res & Limit(&c->suppressor.last_lf_band, 0, 63);
+ res = res &
+ Limit(&c->suppressor.first_hf_band, c->suppressor.last_lf_band + 1, 64);
+
+ res = res & Limit(&c->suppressor.dominant_nearend_detection.enr_threshold,
+ 0.f, 1000000.f);
+ res = res & Limit(&c->suppressor.dominant_nearend_detection.snr_threshold,
+ 0.f, 1000000.f);
+ res = res & Limit(&c->suppressor.dominant_nearend_detection.hold_duration, 0,
+ 10000);
+ res = res & Limit(&c->suppressor.dominant_nearend_detection.trigger_threshold,
+ 0, 10000);
+
+ res = res &
+ Limit(&c->suppressor.subband_nearend_detection.nearend_average_blocks,
+ 1, 1024);
+ res =
+ res & Limit(&c->suppressor.subband_nearend_detection.subband1.low, 0, 65);
+ res = res & Limit(&c->suppressor.subband_nearend_detection.subband1.high,
+ c->suppressor.subband_nearend_detection.subband1.low, 65);
+ res =
+ res & Limit(&c->suppressor.subband_nearend_detection.subband2.low, 0, 65);
+ res = res & Limit(&c->suppressor.subband_nearend_detection.subband2.high,
+ c->suppressor.subband_nearend_detection.subband2.low, 65);
+ res = res & Limit(&c->suppressor.subband_nearend_detection.nearend_threshold,
+ 0.f, 1.e24f);
+ res = res & Limit(&c->suppressor.subband_nearend_detection.snr_threshold, 0.f,
+ 1.e24f);
+
+ res = res & Limit(&c->suppressor.high_bands_suppression.enr_threshold, 0.f,
+ 1000000.f);
+ res = res & Limit(&c->suppressor.high_bands_suppression.max_gain_during_echo,
+ 0.f, 1.f);
+ res = res & Limit(&c->suppressor.high_bands_suppression
+ .anti_howling_activation_threshold,
+ 0.f, 32768.f * 32768.f);
+ res = res & Limit(&c->suppressor.high_bands_suppression.anti_howling_gain,
+ 0.f, 1.f);
+
+ res = res & Limit(&c->suppressor.floor_first_increase, 0.f, 1000000.f);
+
+ return res;
+}
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/echo_canceller3_config.h b/third_party/libwebrtc/api/audio/echo_canceller3_config.h
new file mode 100644
index 0000000000..4b1c7fbc47
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_canceller3_config.h
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2018 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 API_AUDIO_ECHO_CANCELLER3_CONFIG_H_
+#define API_AUDIO_ECHO_CANCELLER3_CONFIG_H_
+
+#include <stddef.h> // size_t
+
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// Configuration struct for EchoCanceller3
+struct RTC_EXPORT EchoCanceller3Config {
+ // Checks and updates the config parameters to lie within (mostly) reasonable
+ // ranges. Returns true if and only of the config did not need to be changed.
+ static bool Validate(EchoCanceller3Config* config);
+
+ EchoCanceller3Config();
+ EchoCanceller3Config(const EchoCanceller3Config& e);
+ EchoCanceller3Config& operator=(const EchoCanceller3Config& other);
+
+ struct Buffering {
+ size_t excess_render_detection_interval_blocks = 250;
+ size_t max_allowed_excess_render_blocks = 8;
+ } buffering;
+
+ struct Delay {
+ Delay();
+ Delay(const Delay& e);
+ Delay& operator=(const Delay& e);
+ size_t default_delay = 5;
+ size_t down_sampling_factor = 4;
+ size_t num_filters = 5;
+ size_t delay_headroom_samples = 32;
+ size_t hysteresis_limit_blocks = 1;
+ size_t fixed_capture_delay_samples = 0;
+ float delay_estimate_smoothing = 0.7f;
+ float delay_estimate_smoothing_delay_found = 0.7f;
+ float delay_candidate_detection_threshold = 0.2f;
+ struct DelaySelectionThresholds {
+ int initial;
+ int converged;
+ } delay_selection_thresholds = {5, 20};
+ bool use_external_delay_estimator = false;
+ bool log_warning_on_delay_changes = false;
+ struct AlignmentMixing {
+ bool downmix;
+ bool adaptive_selection;
+ float activity_power_threshold;
+ bool prefer_first_two_channels;
+ };
+ AlignmentMixing render_alignment_mixing = {false, true, 10000.f, true};
+ AlignmentMixing capture_alignment_mixing = {false, true, 10000.f, false};
+ bool detect_pre_echo = true;
+ } delay;
+
+ struct Filter {
+ struct RefinedConfiguration {
+ size_t length_blocks;
+ float leakage_converged;
+ float leakage_diverged;
+ float error_floor;
+ float error_ceil;
+ float noise_gate;
+ };
+
+ struct CoarseConfiguration {
+ size_t length_blocks;
+ float rate;
+ float noise_gate;
+ };
+
+ RefinedConfiguration refined = {13, 0.00005f, 0.05f,
+ 0.001f, 2.f, 20075344.f};
+ CoarseConfiguration coarse = {13, 0.7f, 20075344.f};
+
+ RefinedConfiguration refined_initial = {12, 0.005f, 0.5f,
+ 0.001f, 2.f, 20075344.f};
+ CoarseConfiguration coarse_initial = {12, 0.9f, 20075344.f};
+
+ size_t config_change_duration_blocks = 250;
+ float initial_state_seconds = 2.5f;
+ int coarse_reset_hangover_blocks = 25;
+ bool conservative_initial_phase = false;
+ bool enable_coarse_filter_output_usage = true;
+ bool use_linear_filter = true;
+ bool high_pass_filter_echo_reference = false;
+ bool export_linear_aec_output = false;
+ } filter;
+
+ struct Erle {
+ float min = 1.f;
+ float max_l = 4.f;
+ float max_h = 1.5f;
+ bool onset_detection = true;
+ size_t num_sections = 1;
+ bool clamp_quality_estimate_to_zero = true;
+ bool clamp_quality_estimate_to_one = true;
+ } erle;
+
+ struct EpStrength {
+ float default_gain = 1.f;
+ float default_len = 0.83f;
+ float nearend_len = 0.83f;
+ bool echo_can_saturate = true;
+ bool bounded_erl = false;
+ bool erle_onset_compensation_in_dominant_nearend = false;
+ bool use_conservative_tail_frequency_response = true;
+ } ep_strength;
+
+ struct EchoAudibility {
+ float low_render_limit = 4 * 64.f;
+ float normal_render_limit = 64.f;
+ float floor_power = 2 * 64.f;
+ float audibility_threshold_lf = 10;
+ float audibility_threshold_mf = 10;
+ float audibility_threshold_hf = 10;
+ bool use_stationarity_properties = false;
+ bool use_stationarity_properties_at_init = false;
+ } echo_audibility;
+
+ struct RenderLevels {
+ float active_render_limit = 100.f;
+ float poor_excitation_render_limit = 150.f;
+ float poor_excitation_render_limit_ds8 = 20.f;
+ float render_power_gain_db = 0.f;
+ } render_levels;
+
+ struct EchoRemovalControl {
+ bool has_clock_drift = false;
+ bool linear_and_stable_echo_path = false;
+ } echo_removal_control;
+
+ struct EchoModel {
+ EchoModel();
+ EchoModel(const EchoModel& e);
+ EchoModel& operator=(const EchoModel& e);
+ size_t noise_floor_hold = 50;
+ float min_noise_floor_power = 1638400.f;
+ float stationary_gate_slope = 10.f;
+ float noise_gate_power = 27509.42f;
+ float noise_gate_slope = 0.3f;
+ size_t render_pre_window_size = 1;
+ size_t render_post_window_size = 1;
+ bool model_reverb_in_nonlinear_mode = true;
+ } echo_model;
+
+ struct ComfortNoise {
+ float noise_floor_dbfs = -96.03406f;
+ } comfort_noise;
+
+ struct Suppressor {
+ Suppressor();
+ Suppressor(const Suppressor& e);
+ Suppressor& operator=(const Suppressor& e);
+
+ size_t nearend_average_blocks = 4;
+
+ struct MaskingThresholds {
+ MaskingThresholds(float enr_transparent,
+ float enr_suppress,
+ float emr_transparent);
+ MaskingThresholds(const MaskingThresholds& e);
+ MaskingThresholds& operator=(const MaskingThresholds& e);
+ float enr_transparent;
+ float enr_suppress;
+ float emr_transparent;
+ };
+
+ struct Tuning {
+ Tuning(MaskingThresholds mask_lf,
+ MaskingThresholds mask_hf,
+ float max_inc_factor,
+ float max_dec_factor_lf);
+ Tuning(const Tuning& e);
+ Tuning& operator=(const Tuning& e);
+ MaskingThresholds mask_lf;
+ MaskingThresholds mask_hf;
+ float max_inc_factor;
+ float max_dec_factor_lf;
+ };
+
+ Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f),
+ MaskingThresholds(.07f, .1f, .3f),
+ 2.0f,
+ 0.25f);
+ Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f),
+ MaskingThresholds(.1f, .3f, .3f),
+ 2.0f,
+ 0.25f);
+
+ bool lf_smoothing_during_initial_phase = true;
+ int last_permanent_lf_smoothing_band = 0;
+ int last_lf_smoothing_band = 5;
+ int last_lf_band = 5;
+ int first_hf_band = 8;
+
+ struct DominantNearendDetection {
+ float enr_threshold = .25f;
+ float enr_exit_threshold = 10.f;
+ float snr_threshold = 30.f;
+ int hold_duration = 50;
+ int trigger_threshold = 12;
+ bool use_during_initial_phase = true;
+ bool use_unbounded_echo_spectrum = true;
+ } dominant_nearend_detection;
+
+ struct SubbandNearendDetection {
+ size_t nearend_average_blocks = 1;
+ struct SubbandRegion {
+ size_t low;
+ size_t high;
+ };
+ SubbandRegion subband1 = {1, 1};
+ SubbandRegion subband2 = {1, 1};
+ float nearend_threshold = 1.f;
+ float snr_threshold = 1.f;
+ } subband_nearend_detection;
+
+ bool use_subband_nearend_detection = false;
+
+ struct HighBandsSuppression {
+ float enr_threshold = 1.f;
+ float max_gain_during_echo = 1.f;
+ float anti_howling_activation_threshold = 400.f;
+ float anti_howling_gain = 1.f;
+ } high_bands_suppression;
+
+ float floor_first_increase = 0.00001f;
+ bool conservative_hf_suppression = false;
+ } suppressor;
+
+ struct MultiChannel {
+ bool detect_stereo_content = true;
+ float stereo_detection_threshold = 0.0f;
+ int stereo_detection_timeout_threshold_seconds = 300;
+ float stereo_detection_hysteresis_seconds = 2.0f;
+ } multi_channel;
+};
+} // namespace webrtc
+
+#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_
diff --git a/third_party/libwebrtc/api/audio/echo_canceller3_config_json.cc b/third_party/libwebrtc/api/audio/echo_canceller3_config_json.cc
new file mode 100644
index 0000000000..96e45ffe6d
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_canceller3_config_json.cc
@@ -0,0 +1,772 @@
+/*
+ * Copyright (c) 2018 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 "api/audio/echo_canceller3_config_json.h"
+
+#include <stddef.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "rtc_base/checks.h"
+#include "rtc_base/logging.h"
+#include "rtc_base/strings/json.h"
+#include "rtc_base/strings/string_builder.h"
+
+namespace webrtc {
+namespace {
+void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
+ RTC_DCHECK(param);
+ bool v;
+ if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
+ *param = v;
+ }
+}
+
+void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
+ RTC_DCHECK(param);
+ int v;
+ if (rtc::GetIntFromJsonObject(root, param_name, &v) && v >= 0) {
+ *param = v;
+ }
+}
+
+void ReadParam(const Json::Value& root, std::string param_name, int* param) {
+ RTC_DCHECK(param);
+ int v;
+ if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
+ *param = v;
+ }
+}
+
+void ReadParam(const Json::Value& root, std::string param_name, float* param) {
+ RTC_DCHECK(param);
+ double v;
+ if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
+ *param = static_cast<float>(v);
+ }
+}
+
+void ReadParam(const Json::Value& root,
+ std::string param_name,
+ EchoCanceller3Config::Filter::RefinedConfiguration* param) {
+ RTC_DCHECK(param);
+ Json::Value json_array;
+ if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
+ std::vector<double> v;
+ rtc::JsonArrayToDoubleVector(json_array, &v);
+ if (v.size() != 6) {
+ RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
+ return;
+ }
+ param->length_blocks = static_cast<size_t>(v[0]);
+ param->leakage_converged = static_cast<float>(v[1]);
+ param->leakage_diverged = static_cast<float>(v[2]);
+ param->error_floor = static_cast<float>(v[3]);
+ param->error_ceil = static_cast<float>(v[4]);
+ param->noise_gate = static_cast<float>(v[5]);
+ }
+}
+
+void ReadParam(const Json::Value& root,
+ std::string param_name,
+ EchoCanceller3Config::Filter::CoarseConfiguration* param) {
+ RTC_DCHECK(param);
+ Json::Value json_array;
+ if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
+ std::vector<double> v;
+ rtc::JsonArrayToDoubleVector(json_array, &v);
+ if (v.size() != 3) {
+ RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
+ return;
+ }
+ param->length_blocks = static_cast<size_t>(v[0]);
+ param->rate = static_cast<float>(v[1]);
+ param->noise_gate = static_cast<float>(v[2]);
+ }
+}
+
+void ReadParam(const Json::Value& root,
+ std::string param_name,
+ EchoCanceller3Config::Delay::AlignmentMixing* param) {
+ RTC_DCHECK(param);
+
+ Json::Value subsection;
+ if (rtc::GetValueFromJsonObject(root, param_name, &subsection)) {
+ ReadParam(subsection, "downmix", &param->downmix);
+ ReadParam(subsection, "adaptive_selection", &param->adaptive_selection);
+ ReadParam(subsection, "activity_power_threshold",
+ &param->activity_power_threshold);
+ ReadParam(subsection, "prefer_first_two_channels",
+ &param->prefer_first_two_channels);
+ }
+}
+
+void ReadParam(
+ const Json::Value& root,
+ std::string param_name,
+ EchoCanceller3Config::Suppressor::SubbandNearendDetection::SubbandRegion*
+ param) {
+ RTC_DCHECK(param);
+ Json::Value json_array;
+ if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
+ std::vector<int> v;
+ rtc::JsonArrayToIntVector(json_array, &v);
+ if (v.size() != 2) {
+ RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
+ return;
+ }
+ param->low = static_cast<size_t>(v[0]);
+ param->high = static_cast<size_t>(v[1]);
+ }
+}
+
+void ReadParam(const Json::Value& root,
+ std::string param_name,
+ EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
+ RTC_DCHECK(param);
+ Json::Value json_array;
+ if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
+ std::vector<double> v;
+ rtc::JsonArrayToDoubleVector(json_array, &v);
+ if (v.size() != 3) {
+ RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
+ return;
+ }
+ param->enr_transparent = static_cast<float>(v[0]);
+ param->enr_suppress = static_cast<float>(v[1]);
+ param->emr_transparent = static_cast<float>(v[2]);
+ }
+}
+} // namespace
+
+void Aec3ConfigFromJsonString(absl::string_view json_string,
+ EchoCanceller3Config* config,
+ bool* parsing_successful) {
+ RTC_DCHECK(config);
+ RTC_DCHECK(parsing_successful);
+ EchoCanceller3Config& cfg = *config;
+ cfg = EchoCanceller3Config();
+ *parsing_successful = true;
+
+ Json::Value root;
+ Json::CharReaderBuilder builder;
+ std::string error_message;
+ std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
+ bool success =
+ reader->parse(json_string.data(), json_string.data() + json_string.size(),
+ &root, &error_message);
+ if (!success) {
+ RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << error_message;
+ *parsing_successful = false;
+ return;
+ }
+
+ Json::Value aec3_root;
+ success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
+ if (!success) {
+ RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
+ *parsing_successful = false;
+ return;
+ }
+
+ Json::Value section;
+ if (rtc::GetValueFromJsonObject(aec3_root, "buffering", &section)) {
+ ReadParam(section, "excess_render_detection_interval_blocks",
+ &cfg.buffering.excess_render_detection_interval_blocks);
+ ReadParam(section, "max_allowed_excess_render_blocks",
+ &cfg.buffering.max_allowed_excess_render_blocks);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
+ ReadParam(section, "default_delay", &cfg.delay.default_delay);
+ ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
+ ReadParam(section, "num_filters", &cfg.delay.num_filters);
+ ReadParam(section, "delay_headroom_samples",
+ &cfg.delay.delay_headroom_samples);
+ ReadParam(section, "hysteresis_limit_blocks",
+ &cfg.delay.hysteresis_limit_blocks);
+ ReadParam(section, "fixed_capture_delay_samples",
+ &cfg.delay.fixed_capture_delay_samples);
+ ReadParam(section, "delay_estimate_smoothing",
+ &cfg.delay.delay_estimate_smoothing);
+ ReadParam(section, "delay_estimate_smoothing_delay_found",
+ &cfg.delay.delay_estimate_smoothing_delay_found);
+ ReadParam(section, "delay_candidate_detection_threshold",
+ &cfg.delay.delay_candidate_detection_threshold);
+
+ Json::Value subsection;
+ if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
+ &subsection)) {
+ ReadParam(subsection, "initial",
+ &cfg.delay.delay_selection_thresholds.initial);
+ ReadParam(subsection, "converged",
+ &cfg.delay.delay_selection_thresholds.converged);
+ }
+
+ ReadParam(section, "use_external_delay_estimator",
+ &cfg.delay.use_external_delay_estimator);
+ ReadParam(section, "log_warning_on_delay_changes",
+ &cfg.delay.log_warning_on_delay_changes);
+
+ ReadParam(section, "render_alignment_mixing",
+ &cfg.delay.render_alignment_mixing);
+ ReadParam(section, "capture_alignment_mixing",
+ &cfg.delay.capture_alignment_mixing);
+ ReadParam(section, "detect_pre_echo", &cfg.delay.detect_pre_echo);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
+ ReadParam(section, "refined", &cfg.filter.refined);
+ ReadParam(section, "coarse", &cfg.filter.coarse);
+ ReadParam(section, "refined_initial", &cfg.filter.refined_initial);
+ ReadParam(section, "coarse_initial", &cfg.filter.coarse_initial);
+ ReadParam(section, "config_change_duration_blocks",
+ &cfg.filter.config_change_duration_blocks);
+ ReadParam(section, "initial_state_seconds",
+ &cfg.filter.initial_state_seconds);
+ ReadParam(section, "coarse_reset_hangover_blocks",
+ &cfg.filter.coarse_reset_hangover_blocks);
+ ReadParam(section, "conservative_initial_phase",
+ &cfg.filter.conservative_initial_phase);
+ ReadParam(section, "enable_coarse_filter_output_usage",
+ &cfg.filter.enable_coarse_filter_output_usage);
+ ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
+ ReadParam(section, "high_pass_filter_echo_reference",
+ &cfg.filter.high_pass_filter_echo_reference);
+ ReadParam(section, "export_linear_aec_output",
+ &cfg.filter.export_linear_aec_output);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
+ ReadParam(section, "min", &cfg.erle.min);
+ ReadParam(section, "max_l", &cfg.erle.max_l);
+ ReadParam(section, "max_h", &cfg.erle.max_h);
+ ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
+ ReadParam(section, "num_sections", &cfg.erle.num_sections);
+ ReadParam(section, "clamp_quality_estimate_to_zero",
+ &cfg.erle.clamp_quality_estimate_to_zero);
+ ReadParam(section, "clamp_quality_estimate_to_one",
+ &cfg.erle.clamp_quality_estimate_to_one);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
+ ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
+ ReadParam(section, "default_len", &cfg.ep_strength.default_len);
+ ReadParam(section, "nearend_len", &cfg.ep_strength.nearend_len);
+ ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
+ ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
+ ReadParam(section, "erle_onset_compensation_in_dominant_nearend",
+ &cfg.ep_strength.erle_onset_compensation_in_dominant_nearend);
+ ReadParam(section, "use_conservative_tail_frequency_response",
+ &cfg.ep_strength.use_conservative_tail_frequency_response);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
+ ReadParam(section, "low_render_limit",
+ &cfg.echo_audibility.low_render_limit);
+ ReadParam(section, "normal_render_limit",
+ &cfg.echo_audibility.normal_render_limit);
+
+ ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
+ ReadParam(section, "audibility_threshold_lf",
+ &cfg.echo_audibility.audibility_threshold_lf);
+ ReadParam(section, "audibility_threshold_mf",
+ &cfg.echo_audibility.audibility_threshold_mf);
+ ReadParam(section, "audibility_threshold_hf",
+ &cfg.echo_audibility.audibility_threshold_hf);
+ ReadParam(section, "use_stationarity_properties",
+ &cfg.echo_audibility.use_stationarity_properties);
+ ReadParam(section, "use_stationarity_properties_at_init",
+ &cfg.echo_audibility.use_stationarity_properties_at_init);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
+ ReadParam(section, "active_render_limit",
+ &cfg.render_levels.active_render_limit);
+ ReadParam(section, "poor_excitation_render_limit",
+ &cfg.render_levels.poor_excitation_render_limit);
+ ReadParam(section, "poor_excitation_render_limit_ds8",
+ &cfg.render_levels.poor_excitation_render_limit_ds8);
+ ReadParam(section, "render_power_gain_db",
+ &cfg.render_levels.render_power_gain_db);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
+ &section)) {
+ ReadParam(section, "has_clock_drift",
+ &cfg.echo_removal_control.has_clock_drift);
+ ReadParam(section, "linear_and_stable_echo_path",
+ &cfg.echo_removal_control.linear_and_stable_echo_path);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
+ Json::Value subsection;
+ ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
+ ReadParam(section, "min_noise_floor_power",
+ &cfg.echo_model.min_noise_floor_power);
+ ReadParam(section, "stationary_gate_slope",
+ &cfg.echo_model.stationary_gate_slope);
+ ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
+ ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
+ ReadParam(section, "render_pre_window_size",
+ &cfg.echo_model.render_pre_window_size);
+ ReadParam(section, "render_post_window_size",
+ &cfg.echo_model.render_post_window_size);
+ ReadParam(section, "model_reverb_in_nonlinear_mode",
+ &cfg.echo_model.model_reverb_in_nonlinear_mode);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "comfort_noise", &section)) {
+ ReadParam(section, "noise_floor_dbfs", &cfg.comfort_noise.noise_floor_dbfs);
+ }
+
+ Json::Value subsection;
+ if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
+ ReadParam(section, "nearend_average_blocks",
+ &cfg.suppressor.nearend_average_blocks);
+
+ if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
+ ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
+ ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
+ ReadParam(subsection, "max_inc_factor",
+ &cfg.suppressor.normal_tuning.max_inc_factor);
+ ReadParam(subsection, "max_dec_factor_lf",
+ &cfg.suppressor.normal_tuning.max_dec_factor_lf);
+ }
+
+ if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
+ ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
+ ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
+ ReadParam(subsection, "max_inc_factor",
+ &cfg.suppressor.nearend_tuning.max_inc_factor);
+ ReadParam(subsection, "max_dec_factor_lf",
+ &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
+ }
+
+ ReadParam(section, "lf_smoothing_during_initial_phase",
+ &cfg.suppressor.lf_smoothing_during_initial_phase);
+ ReadParam(section, "last_permanent_lf_smoothing_band",
+ &cfg.suppressor.last_permanent_lf_smoothing_band);
+ ReadParam(section, "last_lf_smoothing_band",
+ &cfg.suppressor.last_lf_smoothing_band);
+ ReadParam(section, "last_lf_band", &cfg.suppressor.last_lf_band);
+ ReadParam(section, "first_hf_band", &cfg.suppressor.first_hf_band);
+
+ if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
+ &subsection)) {
+ ReadParam(subsection, "enr_threshold",
+ &cfg.suppressor.dominant_nearend_detection.enr_threshold);
+ ReadParam(subsection, "enr_exit_threshold",
+ &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
+ ReadParam(subsection, "snr_threshold",
+ &cfg.suppressor.dominant_nearend_detection.snr_threshold);
+ ReadParam(subsection, "hold_duration",
+ &cfg.suppressor.dominant_nearend_detection.hold_duration);
+ ReadParam(subsection, "trigger_threshold",
+ &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
+ ReadParam(
+ subsection, "use_during_initial_phase",
+ &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
+ ReadParam(subsection, "use_unbounded_echo_spectrum",
+ &cfg.suppressor.dominant_nearend_detection
+ .use_unbounded_echo_spectrum);
+ }
+
+ if (rtc::GetValueFromJsonObject(section, "subband_nearend_detection",
+ &subsection)) {
+ ReadParam(
+ subsection, "nearend_average_blocks",
+ &cfg.suppressor.subband_nearend_detection.nearend_average_blocks);
+ ReadParam(subsection, "subband1",
+ &cfg.suppressor.subband_nearend_detection.subband1);
+ ReadParam(subsection, "subband2",
+ &cfg.suppressor.subband_nearend_detection.subband2);
+ ReadParam(subsection, "nearend_threshold",
+ &cfg.suppressor.subband_nearend_detection.nearend_threshold);
+ ReadParam(subsection, "snr_threshold",
+ &cfg.suppressor.subband_nearend_detection.snr_threshold);
+ }
+
+ ReadParam(section, "use_subband_nearend_detection",
+ &cfg.suppressor.use_subband_nearend_detection);
+
+ if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
+ &subsection)) {
+ ReadParam(subsection, "enr_threshold",
+ &cfg.suppressor.high_bands_suppression.enr_threshold);
+ ReadParam(subsection, "max_gain_during_echo",
+ &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
+ ReadParam(subsection, "anti_howling_activation_threshold",
+ &cfg.suppressor.high_bands_suppression
+ .anti_howling_activation_threshold);
+ ReadParam(subsection, "anti_howling_gain",
+ &cfg.suppressor.high_bands_suppression.anti_howling_gain);
+ }
+
+ ReadParam(section, "floor_first_increase",
+ &cfg.suppressor.floor_first_increase);
+ ReadParam(section, "conservative_hf_suppression",
+ &cfg.suppressor.conservative_hf_suppression);
+ }
+
+ if (rtc::GetValueFromJsonObject(aec3_root, "multi_channel", &section)) {
+ ReadParam(section, "detect_stereo_content",
+ &cfg.multi_channel.detect_stereo_content);
+ ReadParam(section, "stereo_detection_threshold",
+ &cfg.multi_channel.stereo_detection_threshold);
+ ReadParam(section, "stereo_detection_timeout_threshold_seconds",
+ &cfg.multi_channel.stereo_detection_timeout_threshold_seconds);
+ ReadParam(section, "stereo_detection_hysteresis_seconds",
+ &cfg.multi_channel.stereo_detection_hysteresis_seconds);
+ }
+}
+
+EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
+ EchoCanceller3Config cfg;
+ bool not_used;
+ Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
+ return cfg;
+}
+
+std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
+ rtc::StringBuilder ost;
+ ost << "{";
+ ost << "\"aec3\": {";
+ ost << "\"buffering\": {";
+ ost << "\"excess_render_detection_interval_blocks\": "
+ << config.buffering.excess_render_detection_interval_blocks << ",";
+ ost << "\"max_allowed_excess_render_blocks\": "
+ << config.buffering.max_allowed_excess_render_blocks;
+ ost << "},";
+
+ ost << "\"delay\": {";
+ ost << "\"default_delay\": " << config.delay.default_delay << ",";
+ ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
+ << ",";
+ ost << "\"num_filters\": " << config.delay.num_filters << ",";
+ ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
+ << ",";
+ ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
+ << ",";
+ ost << "\"fixed_capture_delay_samples\": "
+ << config.delay.fixed_capture_delay_samples << ",";
+ ost << "\"delay_estimate_smoothing\": "
+ << config.delay.delay_estimate_smoothing << ",";
+ ost << "\"delay_estimate_smoothing_delay_found\": "
+ << config.delay.delay_estimate_smoothing_delay_found << ",";
+ ost << "\"delay_candidate_detection_threshold\": "
+ << config.delay.delay_candidate_detection_threshold << ",";
+
+ ost << "\"delay_selection_thresholds\": {";
+ ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
+ << ",";
+ ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
+ ost << "},";
+
+ ost << "\"use_external_delay_estimator\": "
+ << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
+ ost << "\"log_warning_on_delay_changes\": "
+ << (config.delay.log_warning_on_delay_changes ? "true" : "false") << ",";
+
+ ost << "\"render_alignment_mixing\": {";
+ ost << "\"downmix\": "
+ << (config.delay.render_alignment_mixing.downmix ? "true" : "false")
+ << ",";
+ ost << "\"adaptive_selection\": "
+ << (config.delay.render_alignment_mixing.adaptive_selection ? "true"
+ : "false")
+ << ",";
+ ost << "\"activity_power_threshold\": "
+ << config.delay.render_alignment_mixing.activity_power_threshold << ",";
+ ost << "\"prefer_first_two_channels\": "
+ << (config.delay.render_alignment_mixing.prefer_first_two_channels
+ ? "true"
+ : "false");
+ ost << "},";
+
+ ost << "\"capture_alignment_mixing\": {";
+ ost << "\"downmix\": "
+ << (config.delay.capture_alignment_mixing.downmix ? "true" : "false")
+ << ",";
+ ost << "\"adaptive_selection\": "
+ << (config.delay.capture_alignment_mixing.adaptive_selection ? "true"
+ : "false")
+ << ",";
+ ost << "\"activity_power_threshold\": "
+ << config.delay.capture_alignment_mixing.activity_power_threshold << ",";
+ ost << "\"prefer_first_two_channels\": "
+ << (config.delay.capture_alignment_mixing.prefer_first_two_channels
+ ? "true"
+ : "false");
+ ost << "},";
+ ost << "\"detect_pre_echo\": "
+ << (config.delay.detect_pre_echo ? "true" : "false");
+ ost << "},";
+
+ ost << "\"filter\": {";
+
+ ost << "\"refined\": [";
+ ost << config.filter.refined.length_blocks << ",";
+ ost << config.filter.refined.leakage_converged << ",";
+ ost << config.filter.refined.leakage_diverged << ",";
+ ost << config.filter.refined.error_floor << ",";
+ ost << config.filter.refined.error_ceil << ",";
+ ost << config.filter.refined.noise_gate;
+ ost << "],";
+
+ ost << "\"coarse\": [";
+ ost << config.filter.coarse.length_blocks << ",";
+ ost << config.filter.coarse.rate << ",";
+ ost << config.filter.coarse.noise_gate;
+ ost << "],";
+
+ ost << "\"refined_initial\": [";
+ ost << config.filter.refined_initial.length_blocks << ",";
+ ost << config.filter.refined_initial.leakage_converged << ",";
+ ost << config.filter.refined_initial.leakage_diverged << ",";
+ ost << config.filter.refined_initial.error_floor << ",";
+ ost << config.filter.refined_initial.error_ceil << ",";
+ ost << config.filter.refined_initial.noise_gate;
+ ost << "],";
+
+ ost << "\"coarse_initial\": [";
+ ost << config.filter.coarse_initial.length_blocks << ",";
+ ost << config.filter.coarse_initial.rate << ",";
+ ost << config.filter.coarse_initial.noise_gate;
+ ost << "],";
+
+ ost << "\"config_change_duration_blocks\": "
+ << config.filter.config_change_duration_blocks << ",";
+ ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
+ << ",";
+ ost << "\"coarse_reset_hangover_blocks\": "
+ << config.filter.coarse_reset_hangover_blocks << ",";
+ ost << "\"conservative_initial_phase\": "
+ << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
+ ost << "\"enable_coarse_filter_output_usage\": "
+ << (config.filter.enable_coarse_filter_output_usage ? "true" : "false")
+ << ",";
+ ost << "\"use_linear_filter\": "
+ << (config.filter.use_linear_filter ? "true" : "false") << ",";
+ ost << "\"high_pass_filter_echo_reference\": "
+ << (config.filter.high_pass_filter_echo_reference ? "true" : "false")
+ << ",";
+ ost << "\"export_linear_aec_output\": "
+ << (config.filter.export_linear_aec_output ? "true" : "false");
+
+ ost << "},";
+
+ ost << "\"erle\": {";
+ ost << "\"min\": " << config.erle.min << ",";
+ ost << "\"max_l\": " << config.erle.max_l << ",";
+ ost << "\"max_h\": " << config.erle.max_h << ",";
+ ost << "\"onset_detection\": "
+ << (config.erle.onset_detection ? "true" : "false") << ",";
+ ost << "\"num_sections\": " << config.erle.num_sections << ",";
+ ost << "\"clamp_quality_estimate_to_zero\": "
+ << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
+ ost << "\"clamp_quality_estimate_to_one\": "
+ << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
+ ost << "},";
+
+ ost << "\"ep_strength\": {";
+ ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
+ ost << "\"default_len\": " << config.ep_strength.default_len << ",";
+ ost << "\"nearend_len\": " << config.ep_strength.nearend_len << ",";
+ ost << "\"echo_can_saturate\": "
+ << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
+ ost << "\"bounded_erl\": "
+ << (config.ep_strength.bounded_erl ? "true" : "false") << ",";
+ ost << "\"erle_onset_compensation_in_dominant_nearend\": "
+ << (config.ep_strength.erle_onset_compensation_in_dominant_nearend
+ ? "true"
+ : "false")
+ << ",";
+ ost << "\"use_conservative_tail_frequency_response\": "
+ << (config.ep_strength.use_conservative_tail_frequency_response
+ ? "true"
+ : "false");
+ ost << "},";
+
+ ost << "\"echo_audibility\": {";
+ ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
+ << ",";
+ ost << "\"normal_render_limit\": "
+ << config.echo_audibility.normal_render_limit << ",";
+ ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
+ ost << "\"audibility_threshold_lf\": "
+ << config.echo_audibility.audibility_threshold_lf << ",";
+ ost << "\"audibility_threshold_mf\": "
+ << config.echo_audibility.audibility_threshold_mf << ",";
+ ost << "\"audibility_threshold_hf\": "
+ << config.echo_audibility.audibility_threshold_hf << ",";
+ ost << "\"use_stationarity_properties\": "
+ << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
+ << ",";
+ ost << "\"use_stationarity_properties_at_init\": "
+ << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
+ : "false");
+ ost << "},";
+
+ ost << "\"render_levels\": {";
+ ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
+ << ",";
+ ost << "\"poor_excitation_render_limit\": "
+ << config.render_levels.poor_excitation_render_limit << ",";
+ ost << "\"poor_excitation_render_limit_ds8\": "
+ << config.render_levels.poor_excitation_render_limit_ds8 << ",";
+ ost << "\"render_power_gain_db\": "
+ << config.render_levels.render_power_gain_db;
+ ost << "},";
+
+ ost << "\"echo_removal_control\": {";
+ ost << "\"has_clock_drift\": "
+ << (config.echo_removal_control.has_clock_drift ? "true" : "false")
+ << ",";
+ ost << "\"linear_and_stable_echo_path\": "
+ << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
+ : "false");
+
+ ost << "},";
+
+ ost << "\"echo_model\": {";
+ ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
+ ost << "\"min_noise_floor_power\": "
+ << config.echo_model.min_noise_floor_power << ",";
+ ost << "\"stationary_gate_slope\": "
+ << config.echo_model.stationary_gate_slope << ",";
+ ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
+ ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
+ ost << "\"render_pre_window_size\": "
+ << config.echo_model.render_pre_window_size << ",";
+ ost << "\"render_post_window_size\": "
+ << config.echo_model.render_post_window_size << ",";
+ ost << "\"model_reverb_in_nonlinear_mode\": "
+ << (config.echo_model.model_reverb_in_nonlinear_mode ? "true" : "false");
+ ost << "},";
+
+ ost << "\"comfort_noise\": {";
+ ost << "\"noise_floor_dbfs\": " << config.comfort_noise.noise_floor_dbfs;
+ ost << "},";
+
+ ost << "\"suppressor\": {";
+ ost << "\"nearend_average_blocks\": "
+ << config.suppressor.nearend_average_blocks << ",";
+ ost << "\"normal_tuning\": {";
+ ost << "\"mask_lf\": [";
+ ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
+ ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
+ ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
+ ost << "],";
+ ost << "\"mask_hf\": [";
+ ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
+ ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
+ ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
+ ost << "],";
+ ost << "\"max_inc_factor\": "
+ << config.suppressor.normal_tuning.max_inc_factor << ",";
+ ost << "\"max_dec_factor_lf\": "
+ << config.suppressor.normal_tuning.max_dec_factor_lf;
+ ost << "},";
+ ost << "\"nearend_tuning\": {";
+ ost << "\"mask_lf\": [";
+ ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
+ ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
+ ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
+ ost << "],";
+ ost << "\"mask_hf\": [";
+ ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
+ ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
+ ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
+ ost << "],";
+ ost << "\"max_inc_factor\": "
+ << config.suppressor.nearend_tuning.max_inc_factor << ",";
+ ost << "\"max_dec_factor_lf\": "
+ << config.suppressor.nearend_tuning.max_dec_factor_lf;
+ ost << "},";
+ ost << "\"lf_smoothing_during_initial_phase\": "
+ << (config.suppressor.lf_smoothing_during_initial_phase ? "true"
+ : "false")
+ << ",";
+ ost << "\"last_permanent_lf_smoothing_band\": "
+ << config.suppressor.last_permanent_lf_smoothing_band << ",";
+ ost << "\"last_lf_smoothing_band\": "
+ << config.suppressor.last_lf_smoothing_band << ",";
+ ost << "\"last_lf_band\": " << config.suppressor.last_lf_band << ",";
+ ost << "\"first_hf_band\": " << config.suppressor.first_hf_band << ",";
+ {
+ const auto& dnd = config.suppressor.dominant_nearend_detection;
+ ost << "\"dominant_nearend_detection\": {";
+ ost << "\"enr_threshold\": " << dnd.enr_threshold << ",";
+ ost << "\"enr_exit_threshold\": " << dnd.enr_exit_threshold << ",";
+ ost << "\"snr_threshold\": " << dnd.snr_threshold << ",";
+ ost << "\"hold_duration\": " << dnd.hold_duration << ",";
+ ost << "\"trigger_threshold\": " << dnd.trigger_threshold << ",";
+ ost << "\"use_during_initial_phase\": " << dnd.use_during_initial_phase
+ << ",";
+ ost << "\"use_unbounded_echo_spectrum\": "
+ << dnd.use_unbounded_echo_spectrum;
+ ost << "},";
+ }
+ ost << "\"subband_nearend_detection\": {";
+ ost << "\"nearend_average_blocks\": "
+ << config.suppressor.subband_nearend_detection.nearend_average_blocks
+ << ",";
+ ost << "\"subband1\": [";
+ ost << config.suppressor.subband_nearend_detection.subband1.low << ",";
+ ost << config.suppressor.subband_nearend_detection.subband1.high;
+ ost << "],";
+ ost << "\"subband2\": [";
+ ost << config.suppressor.subband_nearend_detection.subband2.low << ",";
+ ost << config.suppressor.subband_nearend_detection.subband2.high;
+ ost << "],";
+ ost << "\"nearend_threshold\": "
+ << config.suppressor.subband_nearend_detection.nearend_threshold << ",";
+ ost << "\"snr_threshold\": "
+ << config.suppressor.subband_nearend_detection.snr_threshold;
+ ost << "},";
+ ost << "\"use_subband_nearend_detection\": "
+ << config.suppressor.use_subband_nearend_detection << ",";
+ ost << "\"high_bands_suppression\": {";
+ ost << "\"enr_threshold\": "
+ << config.suppressor.high_bands_suppression.enr_threshold << ",";
+ ost << "\"max_gain_during_echo\": "
+ << config.suppressor.high_bands_suppression.max_gain_during_echo << ",";
+ ost << "\"anti_howling_activation_threshold\": "
+ << config.suppressor.high_bands_suppression
+ .anti_howling_activation_threshold
+ << ",";
+ ost << "\"anti_howling_gain\": "
+ << config.suppressor.high_bands_suppression.anti_howling_gain;
+ ost << "},";
+ ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
+ << ",";
+ ost << "\"conservative_hf_suppression\": "
+ << config.suppressor.conservative_hf_suppression;
+ ost << "},";
+
+ ost << "\"multi_channel\": {";
+ ost << "\"detect_stereo_content\": "
+ << (config.multi_channel.detect_stereo_content ? "true" : "false") << ",";
+ ost << "\"stereo_detection_threshold\": "
+ << config.multi_channel.stereo_detection_threshold << ",";
+ ost << "\"stereo_detection_timeout_threshold_seconds\": "
+ << config.multi_channel.stereo_detection_timeout_threshold_seconds << ",";
+ ost << "\"stereo_detection_hysteresis_seconds\": "
+ << config.multi_channel.stereo_detection_hysteresis_seconds;
+ ost << "}";
+
+ ost << "}";
+ ost << "}";
+
+ return ost.Release();
+}
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/echo_canceller3_config_json.h b/third_party/libwebrtc/api/audio/echo_canceller3_config_json.h
new file mode 100644
index 0000000000..ecee9541c7
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_canceller3_config_json.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018 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 API_AUDIO_ECHO_CANCELLER3_CONFIG_JSON_H_
+#define API_AUDIO_ECHO_CANCELLER3_CONFIG_JSON_H_
+
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "api/audio/echo_canceller3_config.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+// Parses a JSON-encoded string into an Aec3 config. Fields corresponds to
+// substruct names, with the addition that there must be a top-level node
+// "aec3". Produces default config values for anything that cannot be parsed
+// from the string. If any error was found in the parsing, parsing_successful is
+// set to false.
+RTC_EXPORT void Aec3ConfigFromJsonString(absl::string_view json_string,
+ EchoCanceller3Config* config,
+ bool* parsing_successful);
+
+// To be deprecated.
+// Parses a JSON-encoded string into an Aec3 config. Fields corresponds to
+// substruct names, with the addition that there must be a top-level node
+// "aec3". Returns default config values for anything that cannot be parsed from
+// the string.
+RTC_EXPORT EchoCanceller3Config
+Aec3ConfigFromJsonString(absl::string_view json_string);
+
+// Encodes an Aec3 config in JSON format. Fields corresponds to substruct names,
+// with the addition that the top-level node is named "aec3".
+RTC_EXPORT std::string Aec3ConfigToJsonString(
+ const EchoCanceller3Config& config);
+
+} // namespace webrtc
+
+#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_JSON_H_
diff --git a/third_party/libwebrtc/api/audio/echo_canceller3_factory.cc b/third_party/libwebrtc/api/audio/echo_canceller3_factory.cc
new file mode 100644
index 0000000000..284b117bea
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_canceller3_factory.cc
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018 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 "api/audio/echo_canceller3_factory.h"
+
+#include <memory>
+
+#include "modules/audio_processing/aec3/echo_canceller3.h"
+
+namespace webrtc {
+
+EchoCanceller3Factory::EchoCanceller3Factory() {}
+
+EchoCanceller3Factory::EchoCanceller3Factory(const EchoCanceller3Config& config)
+ : config_(config) {}
+
+std::unique_ptr<EchoControl> EchoCanceller3Factory::Create(
+ int sample_rate_hz,
+ int num_render_channels,
+ int num_capture_channels) {
+ return std::make_unique<EchoCanceller3>(
+ config_, /*multichannel_config=*/absl::nullopt, sample_rate_hz,
+ num_render_channels, num_capture_channels);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/echo_canceller3_factory.h b/third_party/libwebrtc/api/audio/echo_canceller3_factory.h
new file mode 100644
index 0000000000..8b5380057b
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_canceller3_factory.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018 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 API_AUDIO_ECHO_CANCELLER3_FACTORY_H_
+#define API_AUDIO_ECHO_CANCELLER3_FACTORY_H_
+
+#include <memory>
+
+#include "api/audio/echo_canceller3_config.h"
+#include "api/audio/echo_control.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+class RTC_EXPORT EchoCanceller3Factory : public EchoControlFactory {
+ public:
+ // Factory producing EchoCanceller3 instances with the default configuration.
+ EchoCanceller3Factory();
+
+ // Factory producing EchoCanceller3 instances with the specified
+ // configuration.
+ explicit EchoCanceller3Factory(const EchoCanceller3Config& config);
+
+ // Creates an EchoCanceller3 with a specified channel count and sampling rate.
+ std::unique_ptr<EchoControl> Create(int sample_rate_hz,
+ int num_render_channels,
+ int num_capture_channels) override;
+
+ private:
+ const EchoCanceller3Config config_;
+};
+} // namespace webrtc
+
+#endif // API_AUDIO_ECHO_CANCELLER3_FACTORY_H_
diff --git a/third_party/libwebrtc/api/audio/echo_control.h b/third_party/libwebrtc/api/audio/echo_control.h
new file mode 100644
index 0000000000..74fbc27b12
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_control.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2018 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 API_AUDIO_ECHO_CONTROL_H_
+#define API_AUDIO_ECHO_CONTROL_H_
+
+#include <memory>
+
+#include "rtc_base/checks.h"
+
+namespace webrtc {
+
+class AudioBuffer;
+
+// Interface for an acoustic echo cancellation (AEC) submodule.
+class EchoControl {
+ public:
+ // Analysis (not changing) of the render signal.
+ virtual void AnalyzeRender(AudioBuffer* render) = 0;
+
+ // Analysis (not changing) of the capture signal.
+ virtual void AnalyzeCapture(AudioBuffer* capture) = 0;
+
+ // Processes the capture signal in order to remove the echo.
+ virtual void ProcessCapture(AudioBuffer* capture, bool level_change) = 0;
+
+ // As above, but also returns the linear filter output.
+ virtual void ProcessCapture(AudioBuffer* capture,
+ AudioBuffer* linear_output,
+ bool level_change) = 0;
+
+ struct Metrics {
+ double echo_return_loss;
+ double echo_return_loss_enhancement;
+ int delay_ms;
+ };
+
+ // Collect current metrics from the echo controller.
+ virtual Metrics GetMetrics() const = 0;
+
+ // Provides an optional external estimate of the audio buffer delay.
+ virtual void SetAudioBufferDelay(int delay_ms) = 0;
+
+ // Specifies whether the capture output will be used. The purpose of this is
+ // to allow the echo controller to deactivate some of the processing when the
+ // resulting output is anyway not used, for instance when the endpoint is
+ // muted.
+ // TODO(b/177830919): Make pure virtual.
+ virtual void SetCaptureOutputUsage(bool capture_output_used) {}
+
+ // Returns wheter the signal is altered.
+ virtual bool ActiveProcessing() const = 0;
+
+ virtual ~EchoControl() {}
+};
+
+// Interface for a factory that creates EchoControllers.
+class EchoControlFactory {
+ public:
+ virtual std::unique_ptr<EchoControl> Create(int sample_rate_hz,
+ int num_render_channels,
+ int num_capture_channels) = 0;
+
+ virtual ~EchoControlFactory() = default;
+};
+} // namespace webrtc
+
+#endif // API_AUDIO_ECHO_CONTROL_H_
diff --git a/third_party/libwebrtc/api/audio/echo_control_gn/moz.build b/third_party/libwebrtc/api/audio/echo_control_gn/moz.build
new file mode 100644
index 0000000000..2e128f8038
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_control_gn/moz.build
@@ -0,0 +1,205 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("echo_control_gn")
diff --git a/third_party/libwebrtc/api/audio/echo_detector_creator.cc b/third_party/libwebrtc/api/audio/echo_detector_creator.cc
new file mode 100644
index 0000000000..15b7c51dca
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_detector_creator.cc
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2020 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 "api/audio/echo_detector_creator.h"
+
+#include "api/make_ref_counted.h"
+#include "modules/audio_processing/residual_echo_detector.h"
+
+namespace webrtc {
+
+rtc::scoped_refptr<EchoDetector> CreateEchoDetector() {
+ return rtc::make_ref_counted<ResidualEchoDetector>();
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/echo_detector_creator.h b/third_party/libwebrtc/api/audio/echo_detector_creator.h
new file mode 100644
index 0000000000..5ba171de97
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/echo_detector_creator.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2020 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 API_AUDIO_ECHO_DETECTOR_CREATOR_H_
+#define API_AUDIO_ECHO_DETECTOR_CREATOR_H_
+
+#include "api/scoped_refptr.h"
+#include "modules/audio_processing/include/audio_processing.h"
+
+namespace webrtc {
+
+// Returns an instance of the WebRTC implementation of a residual echo detector.
+// It can be provided to the webrtc::AudioProcessingBuilder to obtain the
+// usual residual echo metrics.
+rtc::scoped_refptr<EchoDetector> CreateEchoDetector();
+
+} // namespace webrtc
+
+#endif // API_AUDIO_ECHO_DETECTOR_CREATOR_H_
diff --git a/third_party/libwebrtc/api/audio/test/BUILD.gn b/third_party/libwebrtc/api/audio/test/BUILD.gn
new file mode 100644
index 0000000000..dfe8c32f80
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/test/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright (c) 2018 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.
+
+import("../../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+if (rtc_include_tests) {
+ rtc_library("audio_api_unittests") {
+ testonly = true
+ sources = [
+ "audio_frame_unittest.cc",
+ "echo_canceller3_config_json_unittest.cc",
+ "echo_canceller3_config_unittest.cc",
+ ]
+ deps = [
+ "..:aec3_config",
+ "..:aec3_config_json",
+ "..:audio_frame_api",
+ "../../../test:test_support",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/api/audio/test/audio_frame_unittest.cc b/third_party/libwebrtc/api/audio/test/audio_frame_unittest.cc
new file mode 100644
index 0000000000..dbf45ceabc
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/test/audio_frame_unittest.cc
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2018 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 "api/audio/audio_frame.h"
+
+#include <stdint.h>
+#include <string.h> // memcmp
+
+#include "test/gtest.h"
+
+namespace webrtc {
+
+namespace {
+
+bool AllSamplesAre(int16_t sample, const AudioFrame& frame) {
+ const int16_t* frame_data = frame.data();
+ for (size_t i = 0; i < frame.max_16bit_samples(); i++) {
+ if (frame_data[i] != sample) {
+ return false;
+ }
+ }
+ return true;
+}
+
+constexpr uint32_t kTimestamp = 27;
+constexpr int kSampleRateHz = 16000;
+constexpr size_t kNumChannelsMono = 1;
+constexpr size_t kNumChannelsStereo = 2;
+constexpr size_t kNumChannels5_1 = 6;
+constexpr size_t kSamplesPerChannel = kSampleRateHz / 100;
+
+} // namespace
+
+TEST(AudioFrameTest, FrameStartsMuted) {
+ AudioFrame frame;
+ EXPECT_TRUE(frame.muted());
+ EXPECT_TRUE(AllSamplesAre(0, frame));
+}
+
+TEST(AudioFrameTest, UnmutedFrameIsInitiallyZeroed) {
+ AudioFrame frame;
+ frame.mutable_data();
+ EXPECT_FALSE(frame.muted());
+ EXPECT_TRUE(AllSamplesAre(0, frame));
+}
+
+TEST(AudioFrameTest, MutedFrameBufferIsZeroed) {
+ AudioFrame frame;
+ int16_t* frame_data = frame.mutable_data();
+ for (size_t i = 0; i < frame.max_16bit_samples(); i++) {
+ frame_data[i] = 17;
+ }
+ ASSERT_TRUE(AllSamplesAre(17, frame));
+ frame.Mute();
+ EXPECT_TRUE(frame.muted());
+ EXPECT_TRUE(AllSamplesAre(0, frame));
+}
+
+TEST(AudioFrameTest, UpdateFrameMono) {
+ AudioFrame frame;
+ int16_t samples[kNumChannelsMono * kSamplesPerChannel] = {17};
+ frame.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, kSampleRateHz,
+ AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannelsMono);
+
+ EXPECT_EQ(kTimestamp, frame.timestamp_);
+ EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel());
+ EXPECT_EQ(kSampleRateHz, frame.sample_rate_hz());
+ EXPECT_EQ(AudioFrame::kPLC, frame.speech_type_);
+ EXPECT_EQ(AudioFrame::kVadActive, frame.vad_activity_);
+ EXPECT_EQ(kNumChannelsMono, frame.num_channels());
+ EXPECT_EQ(CHANNEL_LAYOUT_MONO, frame.channel_layout());
+
+ EXPECT_FALSE(frame.muted());
+ EXPECT_EQ(0, memcmp(samples, frame.data(), sizeof(samples)));
+
+ frame.UpdateFrame(kTimestamp, nullptr /* data*/, kSamplesPerChannel,
+ kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
+ kNumChannelsMono);
+ EXPECT_TRUE(frame.muted());
+ EXPECT_TRUE(AllSamplesAre(0, frame));
+}
+
+TEST(AudioFrameTest, UpdateFrameMultiChannel) {
+ AudioFrame frame;
+ frame.UpdateFrame(kTimestamp, nullptr /* data */, kSamplesPerChannel,
+ kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
+ kNumChannelsStereo);
+ EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel());
+ EXPECT_EQ(kNumChannelsStereo, frame.num_channels());
+ EXPECT_EQ(CHANNEL_LAYOUT_STEREO, frame.channel_layout());
+
+ frame.UpdateFrame(kTimestamp, nullptr /* data */, kSamplesPerChannel,
+ kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
+ kNumChannels5_1);
+ EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel());
+ EXPECT_EQ(kNumChannels5_1, frame.num_channels());
+ EXPECT_EQ(CHANNEL_LAYOUT_5_1, frame.channel_layout());
+}
+
+TEST(AudioFrameTest, CopyFrom) {
+ AudioFrame frame1;
+ AudioFrame frame2;
+
+ int16_t samples[kNumChannelsMono * kSamplesPerChannel] = {17};
+ frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, kSampleRateHz,
+ AudioFrame::kPLC, AudioFrame::kVadActive,
+ kNumChannelsMono);
+ frame1.CopyFrom(frame2);
+
+ EXPECT_EQ(frame2.timestamp_, frame1.timestamp_);
+ EXPECT_EQ(frame2.samples_per_channel_, frame1.samples_per_channel_);
+ EXPECT_EQ(frame2.sample_rate_hz_, frame1.sample_rate_hz_);
+ EXPECT_EQ(frame2.speech_type_, frame1.speech_type_);
+ EXPECT_EQ(frame2.vad_activity_, frame1.vad_activity_);
+ EXPECT_EQ(frame2.num_channels_, frame1.num_channels_);
+
+ EXPECT_EQ(frame2.muted(), frame1.muted());
+ EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples)));
+
+ frame2.UpdateFrame(kTimestamp, nullptr /* data */, kSamplesPerChannel,
+ kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
+ kNumChannelsMono);
+ frame1.CopyFrom(frame2);
+
+ EXPECT_EQ(frame2.muted(), frame1.muted());
+ EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples)));
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/test/echo_canceller3_config_json_unittest.cc b/third_party/libwebrtc/api/audio/test/echo_canceller3_config_json_unittest.cc
new file mode 100644
index 0000000000..4146dda9fe
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/test/echo_canceller3_config_json_unittest.cc
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2018 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 "api/audio/echo_canceller3_config_json.h"
+
+#include "api/audio/echo_canceller3_config.h"
+#include "test/gtest.h"
+
+namespace webrtc {
+
+TEST(EchoCanceller3JsonHelpers, ToStringAndParseJson) {
+ EchoCanceller3Config cfg;
+ cfg.delay.down_sampling_factor = 1u;
+ cfg.delay.log_warning_on_delay_changes = true;
+ cfg.filter.refined.error_floor = 2.f;
+ cfg.filter.coarse_initial.length_blocks = 3u;
+ cfg.filter.high_pass_filter_echo_reference =
+ !cfg.filter.high_pass_filter_echo_reference;
+ cfg.comfort_noise.noise_floor_dbfs = 100.f;
+ cfg.echo_model.model_reverb_in_nonlinear_mode = false;
+ cfg.suppressor.normal_tuning.mask_hf.enr_suppress = .5f;
+ cfg.suppressor.subband_nearend_detection.nearend_average_blocks = 3;
+ cfg.suppressor.subband_nearend_detection.subband1 = {1, 3};
+ cfg.suppressor.subband_nearend_detection.subband1 = {4, 5};
+ cfg.suppressor.subband_nearend_detection.nearend_threshold = 2.f;
+ cfg.suppressor.subband_nearend_detection.snr_threshold = 100.f;
+ cfg.multi_channel.detect_stereo_content =
+ !cfg.multi_channel.detect_stereo_content;
+ cfg.multi_channel.stereo_detection_threshold += 1.0f;
+ cfg.multi_channel.stereo_detection_timeout_threshold_seconds += 1;
+ cfg.multi_channel.stereo_detection_hysteresis_seconds += 1;
+ std::string json_string = Aec3ConfigToJsonString(cfg);
+ EchoCanceller3Config cfg_transformed = Aec3ConfigFromJsonString(json_string);
+
+ // Expect unchanged values to remain default.
+ EXPECT_EQ(cfg.ep_strength.default_len,
+ cfg_transformed.ep_strength.default_len);
+ EXPECT_EQ(cfg.ep_strength.nearend_len,
+ cfg_transformed.ep_strength.nearend_len);
+ EXPECT_EQ(cfg.suppressor.normal_tuning.mask_lf.enr_suppress,
+ cfg_transformed.suppressor.normal_tuning.mask_lf.enr_suppress);
+
+ // Expect changed values to carry through the transformation.
+ EXPECT_EQ(cfg.delay.down_sampling_factor,
+ cfg_transformed.delay.down_sampling_factor);
+ EXPECT_EQ(cfg.delay.log_warning_on_delay_changes,
+ cfg_transformed.delay.log_warning_on_delay_changes);
+ EXPECT_EQ(cfg.filter.coarse_initial.length_blocks,
+ cfg_transformed.filter.coarse_initial.length_blocks);
+ EXPECT_EQ(cfg.filter.refined.error_floor,
+ cfg_transformed.filter.refined.error_floor);
+ EXPECT_EQ(cfg.filter.high_pass_filter_echo_reference,
+ cfg_transformed.filter.high_pass_filter_echo_reference);
+ EXPECT_EQ(cfg.comfort_noise.noise_floor_dbfs,
+ cfg_transformed.comfort_noise.noise_floor_dbfs);
+ EXPECT_EQ(cfg.echo_model.model_reverb_in_nonlinear_mode,
+ cfg_transformed.echo_model.model_reverb_in_nonlinear_mode);
+ EXPECT_EQ(cfg.suppressor.normal_tuning.mask_hf.enr_suppress,
+ cfg_transformed.suppressor.normal_tuning.mask_hf.enr_suppress);
+ EXPECT_EQ(cfg.suppressor.subband_nearend_detection.nearend_average_blocks,
+ cfg_transformed.suppressor.subband_nearend_detection
+ .nearend_average_blocks);
+ EXPECT_EQ(cfg.suppressor.subband_nearend_detection.subband1.low,
+ cfg_transformed.suppressor.subband_nearend_detection.subband1.low);
+ EXPECT_EQ(cfg.suppressor.subband_nearend_detection.subband1.high,
+ cfg_transformed.suppressor.subband_nearend_detection.subband1.high);
+ EXPECT_EQ(cfg.suppressor.subband_nearend_detection.subband2.low,
+ cfg_transformed.suppressor.subband_nearend_detection.subband2.low);
+ EXPECT_EQ(cfg.suppressor.subband_nearend_detection.subband2.high,
+ cfg_transformed.suppressor.subband_nearend_detection.subband2.high);
+ EXPECT_EQ(
+ cfg.suppressor.subband_nearend_detection.nearend_threshold,
+ cfg_transformed.suppressor.subband_nearend_detection.nearend_threshold);
+ EXPECT_EQ(cfg.suppressor.subband_nearend_detection.snr_threshold,
+ cfg_transformed.suppressor.subband_nearend_detection.snr_threshold);
+ EXPECT_EQ(cfg.multi_channel.detect_stereo_content,
+ cfg_transformed.multi_channel.detect_stereo_content);
+ EXPECT_EQ(cfg.multi_channel.stereo_detection_threshold,
+ cfg_transformed.multi_channel.stereo_detection_threshold);
+ EXPECT_EQ(
+ cfg.multi_channel.stereo_detection_timeout_threshold_seconds,
+ cfg_transformed.multi_channel.stereo_detection_timeout_threshold_seconds);
+ EXPECT_EQ(cfg.multi_channel.stereo_detection_hysteresis_seconds,
+ cfg_transformed.multi_channel.stereo_detection_hysteresis_seconds);
+}
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio/test/echo_canceller3_config_unittest.cc b/third_party/libwebrtc/api/audio/test/echo_canceller3_config_unittest.cc
new file mode 100644
index 0000000000..91312a0f40
--- /dev/null
+++ b/third_party/libwebrtc/api/audio/test/echo_canceller3_config_unittest.cc
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018 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 "api/audio/echo_canceller3_config.h"
+
+#include "api/audio/echo_canceller3_config_json.h"
+#include "test/gtest.h"
+
+namespace webrtc {
+
+TEST(EchoCanceller3Config, ValidConfigIsNotModified) {
+ EchoCanceller3Config config;
+ EXPECT_TRUE(EchoCanceller3Config::Validate(&config));
+ EchoCanceller3Config default_config;
+ EXPECT_EQ(Aec3ConfigToJsonString(config),
+ Aec3ConfigToJsonString(default_config));
+}
+
+TEST(EchoCanceller3Config, InvalidConfigIsCorrected) {
+ // Change a parameter and validate.
+ EchoCanceller3Config config;
+ config.echo_model.min_noise_floor_power = -1600000.f;
+ EXPECT_FALSE(EchoCanceller3Config::Validate(&config));
+ EXPECT_GE(config.echo_model.min_noise_floor_power, 0.f);
+ // Verify remaining parameters are unchanged.
+ EchoCanceller3Config default_config;
+ config.echo_model.min_noise_floor_power =
+ default_config.echo_model.min_noise_floor_power;
+ EXPECT_EQ(Aec3ConfigToJsonString(config),
+ Aec3ConfigToJsonString(default_config));
+}
+
+TEST(EchoCanceller3Config, ValidatedConfigsAreValid) {
+ EchoCanceller3Config config;
+ config.delay.down_sampling_factor = 983;
+ EXPECT_FALSE(EchoCanceller3Config::Validate(&config));
+ EXPECT_TRUE(EchoCanceller3Config::Validate(&config));
+}
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/BUILD.gn
new file mode 100644
index 0000000000..82ed31a5da
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/BUILD.gn
@@ -0,0 +1,144 @@
+# 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.
+
+import("../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+rtc_library("audio_codecs_api") {
+ visibility = [ "*" ]
+ sources = [
+ "audio_codec_pair_id.cc",
+ "audio_codec_pair_id.h",
+ "audio_decoder.cc",
+ "audio_decoder.h",
+ "audio_decoder_factory.h",
+ "audio_decoder_factory_template.h",
+ "audio_encoder.cc",
+ "audio_encoder.h",
+ "audio_encoder_factory.h",
+ "audio_encoder_factory_template.h",
+ "audio_format.cc",
+ "audio_format.h",
+ ]
+ deps = [
+ "..:array_view",
+ "..:bitrate_allocation",
+ "..:make_ref_counted",
+ "..:scoped_refptr",
+ "../../api:field_trials_view",
+ "../../rtc_base:buffer",
+ "../../rtc_base:checks",
+ "../../rtc_base:event_tracer",
+ "../../rtc_base:refcount",
+ "../../rtc_base:sanitizer",
+ "../../rtc_base/system:rtc_export",
+ "../units:time_delta",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/base:core_headers",
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
+
+rtc_library("builtin_audio_decoder_factory") {
+ visibility = [ "*" ]
+ allow_poison = [ "audio_codecs" ]
+ sources = [
+ "builtin_audio_decoder_factory.cc",
+ "builtin_audio_decoder_factory.h",
+ ]
+ deps = [
+ ":audio_codecs_api",
+ "..:scoped_refptr",
+ "L16:audio_decoder_L16",
+ "g711:audio_decoder_g711",
+ "g722:audio_decoder_g722",
+ ]
+ defines = []
+ if (rtc_include_ilbc) {
+ deps += [ "ilbc:audio_decoder_ilbc" ]
+ defines += [ "WEBRTC_USE_BUILTIN_ILBC=1" ]
+ } else {
+ defines += [ "WEBRTC_USE_BUILTIN_ILBC=0" ]
+ }
+ if (rtc_include_opus) {
+ deps += [
+ "opus:audio_decoder_multiopus",
+ "opus:audio_decoder_opus",
+ ]
+ defines += [ "WEBRTC_USE_BUILTIN_OPUS=1" ]
+ } else {
+ defines += [ "WEBRTC_USE_BUILTIN_OPUS=0" ]
+ }
+}
+
+rtc_library("builtin_audio_encoder_factory") {
+ visibility = [ "*" ]
+ allow_poison = [ "audio_codecs" ]
+ sources = [
+ "builtin_audio_encoder_factory.cc",
+ "builtin_audio_encoder_factory.h",
+ ]
+ deps = [
+ ":audio_codecs_api",
+ "..:scoped_refptr",
+ "L16:audio_encoder_L16",
+ "g711:audio_encoder_g711",
+ "g722:audio_encoder_g722",
+ ]
+ defines = []
+ if (rtc_include_ilbc) {
+ deps += [ "ilbc:audio_encoder_ilbc" ]
+ defines += [ "WEBRTC_USE_BUILTIN_ILBC=1" ]
+ } else {
+ defines += [ "WEBRTC_USE_BUILTIN_ILBC=0" ]
+ }
+ if (rtc_include_opus) {
+ deps += [
+ "opus:audio_encoder_multiopus",
+ "opus:audio_encoder_opus",
+ ]
+ defines += [ "WEBRTC_USE_BUILTIN_OPUS=1" ]
+ } else {
+ defines += [ "WEBRTC_USE_BUILTIN_OPUS=0" ]
+ }
+}
+
+rtc_library("opus_audio_decoder_factory") {
+ visibility = [ "*" ]
+ allow_poison = [ "audio_codecs" ]
+ sources = [
+ "opus_audio_decoder_factory.cc",
+ "opus_audio_decoder_factory.h",
+ ]
+ deps = [
+ ":audio_codecs_api",
+ "..:scoped_refptr",
+ "opus:audio_decoder_multiopus",
+ "opus:audio_decoder_opus",
+ ]
+}
+
+rtc_library("opus_audio_encoder_factory") {
+ visibility = [ "*" ]
+ allow_poison = [ "audio_codecs" ]
+ sources = [
+ "opus_audio_encoder_factory.cc",
+ "opus_audio_encoder_factory.h",
+ ]
+ deps = [
+ ":audio_codecs_api",
+ "..:scoped_refptr",
+ "opus:audio_encoder_multiopus",
+ "opus:audio_encoder_opus",
+ ]
+}
diff --git a/third_party/libwebrtc/api/audio_codecs/L16/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/L16/BUILD.gn
new file mode 100644
index 0000000000..41e9eb42d8
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/L16/BUILD.gn
@@ -0,0 +1,55 @@
+# 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.
+
+import("../../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+rtc_library("audio_encoder_L16") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_encoder_L16.cc",
+ "audio_encoder_L16.h",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:pcm16b",
+ "../../../rtc_base:safe_conversions",
+ "../../../rtc_base:safe_minmax",
+ "../../../rtc_base:stringutils",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
+
+rtc_library("audio_decoder_L16") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_decoder_L16.cc",
+ "audio_decoder_L16.h",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:pcm16b",
+ "../../../rtc_base:safe_conversions",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.cc b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.cc
new file mode 100644
index 0000000000..a03abe26f7
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.cc
@@ -0,0 +1,49 @@
+/*
+ * 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 "api/audio_codecs/L16/audio_decoder_L16.h"
+
+#include <memory>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h"
+#include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h"
+#include "rtc_base/numerics/safe_conversions.h"
+
+namespace webrtc {
+
+absl::optional<AudioDecoderL16::Config> AudioDecoderL16::SdpToConfig(
+ const SdpAudioFormat& format) {
+ Config config;
+ config.sample_rate_hz = format.clockrate_hz;
+ config.num_channels = rtc::checked_cast<int>(format.num_channels);
+ if (absl::EqualsIgnoreCase(format.name, "L16") && config.IsOk()) {
+ return config;
+ }
+ return absl::nullopt;
+}
+
+void AudioDecoderL16::AppendSupportedDecoders(
+ std::vector<AudioCodecSpec>* specs) {
+ Pcm16BAppendSupportedCodecSpecs(specs);
+}
+
+std::unique_ptr<AudioDecoder> AudioDecoderL16::MakeAudioDecoder(
+ const Config& config,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ return nullptr;
+ }
+ return std::make_unique<AudioDecoderPcm16B>(config.sample_rate_hz,
+ config.num_channels);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.h b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.h
new file mode 100644
index 0000000000..5a01b7dc01
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.h
@@ -0,0 +1,49 @@
+/*
+ * 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 API_AUDIO_CODECS_L16_AUDIO_DECODER_L16_H_
+#define API_AUDIO_CODECS_L16_AUDIO_DECODER_L16_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// L16 decoder API for use as a template parameter to
+// CreateAudioDecoderFactory<...>().
+struct RTC_EXPORT AudioDecoderL16 {
+ struct Config {
+ bool IsOk() const {
+ return (sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
+ sample_rate_hz == 32000 || sample_rate_hz == 48000) &&
+ (num_channels >= 1 &&
+ num_channels <= AudioDecoder::kMaxNumberOfChannels);
+ }
+ int sample_rate_hz = 8000;
+ int num_channels = 1;
+ };
+ static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const Config& config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_L16_AUDIO_DECODER_L16_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build
new file mode 100644
index 0000000000..87335c298d
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build
@@ -0,0 +1,225 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_decoder_L16_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.cc b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.cc
new file mode 100644
index 0000000000..20259b9ad8
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.cc
@@ -0,0 +1,76 @@
+/*
+ * 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 "api/audio_codecs/L16/audio_encoder_L16.h"
+
+#include <memory>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h"
+#include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h"
+#include "rtc_base/numerics/safe_conversions.h"
+#include "rtc_base/numerics/safe_minmax.h"
+#include "rtc_base/string_to_number.h"
+
+namespace webrtc {
+
+absl::optional<AudioEncoderL16::Config> AudioEncoderL16::SdpToConfig(
+ const SdpAudioFormat& format) {
+ if (!rtc::IsValueInRangeForNumericType<int>(format.num_channels)) {
+ RTC_DCHECK_NOTREACHED();
+ return absl::nullopt;
+ }
+ Config config;
+ config.sample_rate_hz = format.clockrate_hz;
+ config.num_channels = rtc::dchecked_cast<int>(format.num_channels);
+ auto ptime_iter = format.parameters.find("ptime");
+ if (ptime_iter != format.parameters.end()) {
+ const auto ptime = rtc::StringToNumber<int>(ptime_iter->second);
+ if (ptime && *ptime > 0) {
+ config.frame_size_ms = rtc::SafeClamp(10 * (*ptime / 10), 10, 60);
+ }
+ }
+ if (absl::EqualsIgnoreCase(format.name, "L16") && config.IsOk()) {
+ return config;
+ }
+ return absl::nullopt;
+}
+
+void AudioEncoderL16::AppendSupportedEncoders(
+ std::vector<AudioCodecSpec>* specs) {
+ Pcm16BAppendSupportedCodecSpecs(specs);
+}
+
+AudioCodecInfo AudioEncoderL16::QueryAudioEncoder(
+ const AudioEncoderL16::Config& config) {
+ RTC_DCHECK(config.IsOk());
+ return {config.sample_rate_hz,
+ rtc::dchecked_cast<size_t>(config.num_channels),
+ config.sample_rate_hz * config.num_channels * 16};
+}
+
+std::unique_ptr<AudioEncoder> AudioEncoderL16::MakeAudioEncoder(
+ const AudioEncoderL16::Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ AudioEncoderPcm16B::Config c;
+ c.sample_rate_hz = config.sample_rate_hz;
+ c.num_channels = config.num_channels;
+ c.frame_size_ms = config.frame_size_ms;
+ c.payload_type = payload_type;
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ return std::make_unique<AudioEncoderPcm16B>(c);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.h b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.h
new file mode 100644
index 0000000000..47509849de
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.h
@@ -0,0 +1,54 @@
+/*
+ * 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 API_AUDIO_CODECS_L16_AUDIO_ENCODER_L16_H_
+#define API_AUDIO_CODECS_L16_AUDIO_ENCODER_L16_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// L16 encoder API for use as a template parameter to
+// CreateAudioEncoderFactory<...>().
+struct RTC_EXPORT AudioEncoderL16 {
+ struct Config {
+ bool IsOk() const {
+ return (sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
+ sample_rate_hz == 32000 || sample_rate_hz == 48000) &&
+ num_channels >= 1 &&
+ num_channels <= AudioEncoder::kMaxNumberOfChannels &&
+ frame_size_ms > 0 && frame_size_ms <= 120 &&
+ frame_size_ms % 10 == 0;
+ }
+ int sample_rate_hz = 8000;
+ int num_channels = 1;
+ int frame_size_ms = 10;
+ };
+ static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
+ static AudioCodecInfo QueryAudioEncoder(const Config& config);
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_L16_AUDIO_ENCODER_L16_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build
new file mode 100644
index 0000000000..49e0d546f1
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build
@@ -0,0 +1,225 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_L16_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/OWNERS b/third_party/libwebrtc/api/audio_codecs/OWNERS
new file mode 100644
index 0000000000..77b414abc3
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/OWNERS
@@ -0,0 +1,3 @@
+alessiob@webrtc.org
+henrik.lundin@webrtc.org
+jakobi@webrtc.org
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.cc b/third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.cc
new file mode 100644
index 0000000000..6cb51ed6b7
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.cc
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2018 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 "api/audio_codecs/audio_codec_pair_id.h"
+
+#include <atomic>
+#include <cstdint>
+
+#include "rtc_base/checks.h"
+
+namespace webrtc {
+
+namespace {
+
+// Returns a new value that it has never returned before. You may call it at
+// most 2^63 times in the lifetime of the program. Note: The returned values
+// may be easily predictable.
+uint64_t GetNextId() {
+ static std::atomic<uint64_t> next_id(0);
+
+ // Atomically increment `next_id`, and return the previous value. Relaxed
+ // memory order is sufficient, since all we care about is that different
+ // callers return different values.
+ const uint64_t new_id = next_id.fetch_add(1, std::memory_order_relaxed);
+
+ // This check isn't atomic with the increment, so if we start 2^63 + 1
+ // invocations of GetNextId() in parallel, the last one to do the atomic
+ // increment could return the ID 0 before any of the others had time to
+ // trigger this DCHECK. We blithely assume that this won't happen.
+ RTC_DCHECK_LT(new_id, uint64_t{1} << 63) << "Used up all ID values";
+
+ return new_id;
+}
+
+// Make an integer ID more unpredictable. This is a 1:1 mapping, so you can
+// feed it any value, but the idea is that you can feed it a sequence such as
+// 0, 1, 2, ... and get a new sequence that isn't as trivially predictable, so
+// that users won't rely on it being consecutive or increasing or anything like
+// that.
+constexpr uint64_t ObfuscateId(uint64_t id) {
+ // Any nonzero coefficient that's relatively prime to 2^64 (that is, any odd
+ // number) and any constant will give a 1:1 mapping. These high-entropy
+ // values will prevent the sequence from being trivially predictable.
+ //
+ // Both the multiplication and the addition going to overflow almost always,
+ // but that's fine---we *want* arithmetic mod 2^64.
+ return uint64_t{0x85fdb20e1294309a} + uint64_t{0xc516ef5c37462469} * id;
+}
+
+// The first ten values. Verified against the Python function
+//
+// def f(n):
+// return (0x85fdb20e1294309a + 0xc516ef5c37462469 * n) % 2**64
+//
+// Callers should obviously not depend on these exact values...
+//
+// (On Visual C++, we have to disable warning C4307 (integral constant
+// overflow), even though unsigned integers have perfectly well-defined
+// overflow behavior.)
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4307)
+#endif
+static_assert(ObfuscateId(0) == uint64_t{0x85fdb20e1294309a}, "");
+static_assert(ObfuscateId(1) == uint64_t{0x4b14a16a49da5503}, "");
+static_assert(ObfuscateId(2) == uint64_t{0x102b90c68120796c}, "");
+static_assert(ObfuscateId(3) == uint64_t{0xd5428022b8669dd5}, "");
+static_assert(ObfuscateId(4) == uint64_t{0x9a596f7eefacc23e}, "");
+static_assert(ObfuscateId(5) == uint64_t{0x5f705edb26f2e6a7}, "");
+static_assert(ObfuscateId(6) == uint64_t{0x24874e375e390b10}, "");
+static_assert(ObfuscateId(7) == uint64_t{0xe99e3d93957f2f79}, "");
+static_assert(ObfuscateId(8) == uint64_t{0xaeb52cefccc553e2}, "");
+static_assert(ObfuscateId(9) == uint64_t{0x73cc1c4c040b784b}, "");
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+} // namespace
+
+AudioCodecPairId AudioCodecPairId::Create() {
+ return AudioCodecPairId(ObfuscateId(GetNextId()));
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.h b/third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.h
new file mode 100644
index 0000000000..b10f14ea66
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2018 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 API_AUDIO_CODECS_AUDIO_CODEC_PAIR_ID_H_
+#define API_AUDIO_CODECS_AUDIO_CODEC_PAIR_ID_H_
+
+#include <stdint.h>
+
+#include <utility>
+
+namespace webrtc {
+
+class AudioCodecPairId final {
+ public:
+ // Copyable, but not default constructible.
+ AudioCodecPairId() = delete;
+ AudioCodecPairId(const AudioCodecPairId&) = default;
+ AudioCodecPairId(AudioCodecPairId&&) = default;
+ AudioCodecPairId& operator=(const AudioCodecPairId&) = default;
+ AudioCodecPairId& operator=(AudioCodecPairId&&) = default;
+
+ friend void swap(AudioCodecPairId& a, AudioCodecPairId& b) {
+ using std::swap;
+ swap(a.id_, b.id_);
+ }
+
+ // Creates a new ID, unequal to any previously created ID.
+ static AudioCodecPairId Create();
+
+ // IDs can be tested for equality.
+ friend bool operator==(AudioCodecPairId a, AudioCodecPairId b) {
+ return a.id_ == b.id_;
+ }
+ friend bool operator!=(AudioCodecPairId a, AudioCodecPairId b) {
+ return a.id_ != b.id_;
+ }
+
+ // Comparisons. The ordering of ID values is completely arbitrary, but
+ // stable, so it's useful e.g. if you want to use IDs as keys in an ordered
+ // map.
+ friend bool operator<(AudioCodecPairId a, AudioCodecPairId b) {
+ return a.id_ < b.id_;
+ }
+ friend bool operator<=(AudioCodecPairId a, AudioCodecPairId b) {
+ return a.id_ <= b.id_;
+ }
+ friend bool operator>=(AudioCodecPairId a, AudioCodecPairId b) {
+ return a.id_ >= b.id_;
+ }
+ friend bool operator>(AudioCodecPairId a, AudioCodecPairId b) {
+ return a.id_ > b.id_;
+ }
+
+ // Returns a numeric representation of the ID. The numeric values are
+ // completely arbitrary, but stable, collision-free, and reasonably evenly
+ // distributed, so they are e.g. useful as hash values in unordered maps.
+ uint64_t NumericRepresentation() const { return id_; }
+
+ private:
+ explicit AudioCodecPairId(uint64_t id) : id_(id) {}
+
+ uint64_t id_;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_AUDIO_CODEC_PAIR_ID_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build
new file mode 100644
index 0000000000..846946073e
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build
@@ -0,0 +1,228 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/audio_codec_pair_id.cc",
+ "/third_party/libwebrtc/api/audio_codecs/audio_decoder.cc",
+ "/third_party/libwebrtc/api/audio_codecs/audio_encoder.cc",
+ "/third_party/libwebrtc/api/audio_codecs/audio_format.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_codecs_api_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_decoder.cc b/third_party/libwebrtc/api/audio_codecs/audio_decoder.cc
new file mode 100644
index 0000000000..28f5b8aae8
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_decoder.cc
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "api/audio_codecs/audio_decoder.h"
+
+
+#include <memory>
+#include <utility>
+
+#include "api/array_view.h"
+#include "rtc_base/checks.h"
+#include "rtc_base/sanitizer.h"
+#include "rtc_base/trace_event.h"
+
+namespace webrtc {
+
+namespace {
+
+class OldStyleEncodedFrame final : public AudioDecoder::EncodedAudioFrame {
+ public:
+ OldStyleEncodedFrame(AudioDecoder* decoder, rtc::Buffer&& payload)
+ : decoder_(decoder), payload_(std::move(payload)) {}
+
+ size_t Duration() const override {
+ const int ret = decoder_->PacketDuration(payload_.data(), payload_.size());
+ return ret < 0 ? 0 : static_cast<size_t>(ret);
+ }
+
+ absl::optional<DecodeResult> Decode(
+ rtc::ArrayView<int16_t> decoded) const override {
+ auto speech_type = AudioDecoder::kSpeech;
+ const int ret = decoder_->Decode(
+ payload_.data(), payload_.size(), decoder_->SampleRateHz(),
+ decoded.size() * sizeof(int16_t), decoded.data(), &speech_type);
+ return ret < 0 ? absl::nullopt
+ : absl::optional<DecodeResult>(
+ {static_cast<size_t>(ret), speech_type});
+ }
+
+ private:
+ AudioDecoder* const decoder_;
+ const rtc::Buffer payload_;
+};
+
+} // namespace
+
+bool AudioDecoder::EncodedAudioFrame::IsDtxPacket() const {
+ return false;
+}
+
+AudioDecoder::ParseResult::ParseResult() = default;
+AudioDecoder::ParseResult::ParseResult(ParseResult&& b) = default;
+AudioDecoder::ParseResult::ParseResult(uint32_t timestamp,
+ int priority,
+ std::unique_ptr<EncodedAudioFrame> frame)
+ : timestamp(timestamp), priority(priority), frame(std::move(frame)) {
+ RTC_DCHECK_GE(priority, 0);
+}
+
+AudioDecoder::ParseResult::~ParseResult() = default;
+
+AudioDecoder::ParseResult& AudioDecoder::ParseResult::operator=(
+ ParseResult&& b) = default;
+
+std::vector<AudioDecoder::ParseResult> AudioDecoder::ParsePayload(
+ rtc::Buffer&& payload,
+ uint32_t timestamp) {
+ std::vector<ParseResult> results;
+ std::unique_ptr<EncodedAudioFrame> frame(
+ new OldStyleEncodedFrame(this, std::move(payload)));
+ results.emplace_back(timestamp, 0, std::move(frame));
+ return results;
+}
+
+int AudioDecoder::Decode(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ size_t max_decoded_bytes,
+ int16_t* decoded,
+ SpeechType* speech_type) {
+ TRACE_EVENT0("webrtc", "AudioDecoder::Decode");
+ rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
+ int duration = PacketDuration(encoded, encoded_len);
+ if (duration >= 0 &&
+ duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
+ return -1;
+ }
+ return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded,
+ speech_type);
+}
+
+int AudioDecoder::DecodeRedundant(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ size_t max_decoded_bytes,
+ int16_t* decoded,
+ SpeechType* speech_type) {
+ TRACE_EVENT0("webrtc", "AudioDecoder::DecodeRedundant");
+ rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
+ int duration = PacketDurationRedundant(encoded, encoded_len);
+ if (duration >= 0 &&
+ duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
+ return -1;
+ }
+ return DecodeRedundantInternal(encoded, encoded_len, sample_rate_hz, decoded,
+ speech_type);
+}
+
+int AudioDecoder::DecodeRedundantInternal(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ int16_t* decoded,
+ SpeechType* speech_type) {
+ return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded,
+ speech_type);
+}
+
+bool AudioDecoder::HasDecodePlc() const {
+ return false;
+}
+
+size_t AudioDecoder::DecodePlc(size_t num_frames, int16_t* decoded) {
+ return 0;
+}
+
+// TODO(bugs.webrtc.org/9676): Remove default implementation.
+void AudioDecoder::GeneratePlc(size_t /*requested_samples_per_channel*/,
+ rtc::BufferT<int16_t>* /*concealment_audio*/) {}
+
+int AudioDecoder::ErrorCode() {
+ return 0;
+}
+
+int AudioDecoder::PacketDuration(const uint8_t* encoded,
+ size_t encoded_len) const {
+ return kNotImplemented;
+}
+
+int AudioDecoder::PacketDurationRedundant(const uint8_t* encoded,
+ size_t encoded_len) const {
+ return kNotImplemented;
+}
+
+bool AudioDecoder::PacketHasFec(const uint8_t* encoded,
+ size_t encoded_len) const {
+ return false;
+}
+
+AudioDecoder::SpeechType AudioDecoder::ConvertSpeechType(int16_t type) {
+ switch (type) {
+ case 0: // TODO(hlundin): Both iSAC and Opus return 0 for speech.
+ case 1:
+ return kSpeech;
+ case 2:
+ return kComfortNoise;
+ default:
+ RTC_DCHECK_NOTREACHED();
+ return kSpeech;
+ }
+}
+
+constexpr int AudioDecoder::kMaxNumberOfChannels;
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_decoder.h b/third_party/libwebrtc/api/audio_codecs/audio_decoder.h
new file mode 100644
index 0000000000..41138741bb
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_decoder.h
@@ -0,0 +1,195 @@
+/*
+ * 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.
+ */
+
+#ifndef API_AUDIO_CODECS_AUDIO_DECODER_H_
+#define API_AUDIO_CODECS_AUDIO_DECODER_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/array_view.h"
+#include "rtc_base/buffer.h"
+
+namespace webrtc {
+
+class AudioDecoder {
+ public:
+ enum SpeechType {
+ kSpeech = 1,
+ kComfortNoise = 2,
+ };
+
+ // Used by PacketDuration below. Save the value -1 for errors.
+ enum { kNotImplemented = -2 };
+
+ AudioDecoder() = default;
+ virtual ~AudioDecoder() = default;
+
+ AudioDecoder(const AudioDecoder&) = delete;
+ AudioDecoder& operator=(const AudioDecoder&) = delete;
+
+ class EncodedAudioFrame {
+ public:
+ struct DecodeResult {
+ size_t num_decoded_samples;
+ SpeechType speech_type;
+ };
+
+ virtual ~EncodedAudioFrame() = default;
+
+ // Returns the duration in samples-per-channel of this audio frame.
+ // If no duration can be ascertained, returns zero.
+ virtual size_t Duration() const = 0;
+
+ // Returns true if this packet contains DTX.
+ virtual bool IsDtxPacket() const;
+
+ // Decodes this frame of audio and writes the result in `decoded`.
+ // `decoded` must be large enough to store as many samples as indicated by a
+ // call to Duration() . On success, returns an absl::optional containing the
+ // total number of samples across all channels, as well as whether the
+ // decoder produced comfort noise or speech. On failure, returns an empty
+ // absl::optional. Decode may be called at most once per frame object.
+ virtual absl::optional<DecodeResult> Decode(
+ rtc::ArrayView<int16_t> decoded) const = 0;
+ };
+
+ struct ParseResult {
+ ParseResult();
+ ParseResult(uint32_t timestamp,
+ int priority,
+ std::unique_ptr<EncodedAudioFrame> frame);
+ ParseResult(ParseResult&& b);
+ ~ParseResult();
+
+ ParseResult& operator=(ParseResult&& b);
+
+ // The timestamp of the frame is in samples per channel.
+ uint32_t timestamp;
+ // The relative priority of the frame compared to other frames of the same
+ // payload and the same timeframe. A higher value means a lower priority.
+ // The highest priority is zero - negative values are not allowed.
+ int priority;
+ std::unique_ptr<EncodedAudioFrame> frame;
+ };
+
+ // Let the decoder parse this payload and prepare zero or more decodable
+ // frames. Each frame must be between 10 ms and 120 ms long. The caller must
+ // ensure that the AudioDecoder object outlives any frame objects returned by
+ // this call. The decoder is free to swap or move the data from the `payload`
+ // buffer. `timestamp` is the input timestamp, in samples, corresponding to
+ // the start of the payload.
+ virtual std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
+ uint32_t timestamp);
+
+ // TODO(bugs.webrtc.org/10098): The Decode and DecodeRedundant methods are
+ // obsolete; callers should call ParsePayload instead. For now, subclasses
+ // must still implement DecodeInternal.
+
+ // Decodes `encode_len` bytes from `encoded` and writes the result in
+ // `decoded`. The maximum bytes allowed to be written into `decoded` is
+ // `max_decoded_bytes`. Returns the total number of samples across all
+ // channels. If the decoder produced comfort noise, `speech_type`
+ // is set to kComfortNoise, otherwise it is kSpeech. The desired output
+ // sample rate is provided in `sample_rate_hz`, which must be valid for the
+ // codec at hand.
+ int Decode(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ size_t max_decoded_bytes,
+ int16_t* decoded,
+ SpeechType* speech_type);
+
+ // Same as Decode(), but interfaces to the decoders redundant decode function.
+ // The default implementation simply calls the regular Decode() method.
+ int DecodeRedundant(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ size_t max_decoded_bytes,
+ int16_t* decoded,
+ SpeechType* speech_type);
+
+ // Indicates if the decoder implements the DecodePlc method.
+ virtual bool HasDecodePlc() const;
+
+ // Calls the packet-loss concealment of the decoder to update the state after
+ // one or several lost packets. The caller has to make sure that the
+ // memory allocated in `decoded` should accommodate `num_frames` frames.
+ virtual size_t DecodePlc(size_t num_frames, int16_t* decoded);
+
+ // Asks the decoder to generate packet-loss concealment and append it to the
+ // end of `concealment_audio`. The concealment audio should be in
+ // channel-interleaved format, with as many channels as the last decoded
+ // packet produced. The implementation must produce at least
+ // requested_samples_per_channel, or nothing at all. This is a signal to the
+ // caller to conceal the loss with other means. If the implementation provides
+ // concealment samples, it is also responsible for "stitching" it together
+ // with the decoded audio on either side of the concealment.
+ // Note: The default implementation of GeneratePlc will be deleted soon. All
+ // implementations must provide their own, which can be a simple as a no-op.
+ // TODO(bugs.webrtc.org/9676): Remove default implementation.
+ virtual void GeneratePlc(size_t requested_samples_per_channel,
+ rtc::BufferT<int16_t>* concealment_audio);
+
+ // Resets the decoder state (empty buffers etc.).
+ virtual void Reset() = 0;
+
+ // Returns the last error code from the decoder.
+ virtual int ErrorCode();
+
+ // Returns the duration in samples-per-channel of the payload in `encoded`
+ // which is `encoded_len` bytes long. Returns kNotImplemented if no duration
+ // estimate is available, or -1 in case of an error.
+ virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
+
+ // Returns the duration in samples-per-channel of the redandant payload in
+ // `encoded` which is `encoded_len` bytes long. Returns kNotImplemented if no
+ // duration estimate is available, or -1 in case of an error.
+ virtual int PacketDurationRedundant(const uint8_t* encoded,
+ size_t encoded_len) const;
+
+ // Detects whether a packet has forward error correction. The packet is
+ // comprised of the samples in `encoded` which is `encoded_len` bytes long.
+ // Returns true if the packet has FEC and false otherwise.
+ virtual bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const;
+
+ // Returns the actual sample rate of the decoder's output. This value may not
+ // change during the lifetime of the decoder.
+ virtual int SampleRateHz() const = 0;
+
+ // The number of channels in the decoder's output. This value may not change
+ // during the lifetime of the decoder.
+ virtual size_t Channels() const = 0;
+
+ // The maximum number of audio channels supported by WebRTC decoders.
+ static constexpr int kMaxNumberOfChannels = 24;
+
+ protected:
+ static SpeechType ConvertSpeechType(int16_t type);
+
+ virtual int DecodeInternal(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ int16_t* decoded,
+ SpeechType* speech_type) = 0;
+
+ virtual int DecodeRedundantInternal(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ int16_t* decoded,
+ SpeechType* speech_type);
+};
+
+} // namespace webrtc
+#endif // API_AUDIO_CODECS_AUDIO_DECODER_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h b/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h
new file mode 100644
index 0000000000..2811f6704b
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016 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 API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
+#define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "rtc_base/ref_count.h"
+
+namespace webrtc {
+
+// A factory that creates AudioDecoders.
+class AudioDecoderFactory : public rtc::RefCountInterface {
+ public:
+ virtual std::vector<AudioCodecSpec> GetSupportedDecoders() = 0;
+
+ virtual bool IsSupportedDecoder(const SdpAudioFormat& format) = 0;
+
+ // Create a new decoder instance. The `codec_pair_id` argument is used to link
+ // encoders and decoders that talk to the same remote entity: if a
+ // AudioEncoderFactory::MakeAudioEncoder() and a
+ // AudioDecoderFactory::MakeAudioDecoder() call receive non-null IDs that
+ // compare equal, the factory implementations may assume that the encoder and
+ // decoder form a pair. (The intended use case for this is to set up
+ // communication between the AudioEncoder and AudioDecoder instances, which is
+ // needed for some codecs with built-in bandwidth adaptation.)
+ //
+ // Returns null if the format isn't supported.
+ //
+ // Note: Implementations need to be robust against combinations other than
+ // one encoder, one decoder getting the same ID; such decoders must still
+ // work.
+ virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id) = 0;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory_template.h b/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory_template.h
new file mode 100644
index 0000000000..7ea0c91372
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory_template.h
@@ -0,0 +1,145 @@
+/*
+ * 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 API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_TEMPLATE_H_
+#define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_TEMPLATE_H_
+
+#include <memory>
+#include <vector>
+
+#include "api/audio_codecs/audio_decoder_factory.h"
+#include "api/field_trials_view.h"
+#include "api/make_ref_counted.h"
+#include "api/scoped_refptr.h"
+
+namespace webrtc {
+
+namespace audio_decoder_factory_template_impl {
+
+template <typename... Ts>
+struct Helper;
+
+// Base case: 0 template parameters.
+template <>
+struct Helper<> {
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) {}
+ static bool IsSupportedDecoder(const SdpAudioFormat& format) { return false; }
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id,
+ const FieldTrialsView* field_trials) {
+ return nullptr;
+ }
+};
+
+// Inductive case: Called with n + 1 template parameters; calls subroutines
+// with n template parameters.
+template <typename T, typename... Ts>
+struct Helper<T, Ts...> {
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) {
+ T::AppendSupportedDecoders(specs);
+ Helper<Ts...>::AppendSupportedDecoders(specs);
+ }
+ static bool IsSupportedDecoder(const SdpAudioFormat& format) {
+ auto opt_config = T::SdpToConfig(format);
+ static_assert(std::is_same<decltype(opt_config),
+ absl::optional<typename T::Config>>::value,
+ "T::SdpToConfig() must return a value of type "
+ "absl::optional<T::Config>");
+ return opt_config ? true : Helper<Ts...>::IsSupportedDecoder(format);
+ }
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id,
+ const FieldTrialsView* field_trials) {
+ auto opt_config = T::SdpToConfig(format);
+ return opt_config ? T::MakeAudioDecoder(*opt_config, codec_pair_id)
+ : Helper<Ts...>::MakeAudioDecoder(format, codec_pair_id,
+ field_trials);
+ }
+};
+
+template <typename... Ts>
+class AudioDecoderFactoryT : public AudioDecoderFactory {
+ public:
+ explicit AudioDecoderFactoryT(const FieldTrialsView* field_trials) {
+ field_trials_ = field_trials;
+ }
+
+ std::vector<AudioCodecSpec> GetSupportedDecoders() override {
+ std::vector<AudioCodecSpec> specs;
+ Helper<Ts...>::AppendSupportedDecoders(&specs);
+ return specs;
+ }
+
+ bool IsSupportedDecoder(const SdpAudioFormat& format) override {
+ return Helper<Ts...>::IsSupportedDecoder(format);
+ }
+
+ std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id) override {
+ return Helper<Ts...>::MakeAudioDecoder(format, codec_pair_id,
+ field_trials_);
+ }
+
+ const FieldTrialsView* field_trials_;
+};
+
+} // namespace audio_decoder_factory_template_impl
+
+// Make an AudioDecoderFactory that can create instances of the given decoders.
+//
+// Each decoder type is given as a template argument to the function; it should
+// be a struct with the following static member functions:
+//
+// // Converts `audio_format` to a ConfigType instance. Returns an empty
+// // optional if `audio_format` doesn't correctly specify a decoder of our
+// // type.
+// absl::optional<ConfigType> SdpToConfig(const SdpAudioFormat& audio_format);
+//
+// // Appends zero or more AudioCodecSpecs to the list that will be returned
+// // by AudioDecoderFactory::GetSupportedDecoders().
+// void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
+//
+// // Creates an AudioDecoder for the specified format. Used to implement
+// // AudioDecoderFactory::MakeAudioDecoder().
+// std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+// const ConfigType& config,
+// absl::optional<AudioCodecPairId> codec_pair_id);
+//
+// ConfigType should be a type that encapsulates all the settings needed to
+// create an AudioDecoder. T::Config (where T is the decoder struct) should
+// either be the config type, or an alias for it.
+//
+// Whenever it tries to do something, the new factory will try each of the
+// decoder types in the order they were specified in the template argument
+// list, stopping at the first one that claims to be able to do the job.
+//
+// TODO(kwiberg): Point at CreateBuiltinAudioDecoderFactory() for an example of
+// how it is used.
+template <typename... Ts>
+rtc::scoped_refptr<AudioDecoderFactory> CreateAudioDecoderFactory(
+ const FieldTrialsView* field_trials = nullptr) {
+ // There's no technical reason we couldn't allow zero template parameters,
+ // but such a factory couldn't create any decoders, and callers can do this
+ // by mistake by simply forgetting the <> altogether. So we forbid it in
+ // order to prevent caller foot-shooting.
+ static_assert(sizeof...(Ts) >= 1,
+ "Caller must give at least one template parameter");
+
+ return rtc::make_ref_counted<
+ audio_decoder_factory_template_impl::AudioDecoderFactoryT<Ts...>>(
+ field_trials);
+}
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_TEMPLATE_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_encoder.cc b/third_party/libwebrtc/api/audio_codecs/audio_encoder.cc
new file mode 100644
index 0000000000..31bb8739f7
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_encoder.cc
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014 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 "api/audio_codecs/audio_encoder.h"
+
+#include "rtc_base/checks.h"
+#include "rtc_base/trace_event.h"
+
+namespace webrtc {
+
+ANAStats::ANAStats() = default;
+ANAStats::~ANAStats() = default;
+ANAStats::ANAStats(const ANAStats&) = default;
+
+AudioEncoder::EncodedInfo::EncodedInfo() = default;
+AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default;
+AudioEncoder::EncodedInfo::EncodedInfo(EncodedInfo&&) = default;
+AudioEncoder::EncodedInfo::~EncodedInfo() = default;
+AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(
+ const EncodedInfo&) = default;
+AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(EncodedInfo&&) =
+ default;
+
+int AudioEncoder::RtpTimestampRateHz() const {
+ return SampleRateHz();
+}
+
+AudioEncoder::EncodedInfo AudioEncoder::Encode(
+ uint32_t rtp_timestamp,
+ rtc::ArrayView<const int16_t> audio,
+ rtc::Buffer* encoded) {
+ TRACE_EVENT0("webrtc", "AudioEncoder::Encode");
+ RTC_CHECK_EQ(audio.size(),
+ static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
+
+ const size_t old_size = encoded->size();
+ EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded);
+ RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes);
+ return info;
+}
+
+bool AudioEncoder::SetFec(bool enable) {
+ return !enable;
+}
+
+bool AudioEncoder::SetDtx(bool enable) {
+ return !enable;
+}
+
+bool AudioEncoder::GetDtx() const {
+ return false;
+}
+
+bool AudioEncoder::SetApplication(Application application) {
+ return false;
+}
+
+void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {}
+
+void AudioEncoder::SetTargetBitrate(int target_bps) {}
+
+rtc::ArrayView<std::unique_ptr<AudioEncoder>>
+AudioEncoder::ReclaimContainedEncoders() {
+ return nullptr;
+}
+
+bool AudioEncoder::EnableAudioNetworkAdaptor(const std::string& config_string,
+ RtcEventLog* event_log) {
+ return false;
+}
+
+void AudioEncoder::DisableAudioNetworkAdaptor() {}
+
+void AudioEncoder::OnReceivedUplinkPacketLossFraction(
+ float uplink_packet_loss_fraction) {}
+
+void AudioEncoder::OnReceivedUplinkRecoverablePacketLossFraction(
+ float uplink_recoverable_packet_loss_fraction) {
+ RTC_DCHECK_NOTREACHED();
+}
+
+void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
+ OnReceivedUplinkBandwidth(target_audio_bitrate_bps, absl::nullopt);
+}
+
+void AudioEncoder::OnReceivedUplinkBandwidth(
+ int target_audio_bitrate_bps,
+ absl::optional<int64_t> bwe_period_ms) {}
+
+void AudioEncoder::OnReceivedUplinkAllocation(BitrateAllocationUpdate update) {
+ OnReceivedUplinkBandwidth(update.target_bitrate.bps(),
+ update.bwe_period.ms());
+}
+
+void AudioEncoder::OnReceivedRtt(int rtt_ms) {}
+
+void AudioEncoder::OnReceivedOverhead(size_t overhead_bytes_per_packet) {}
+
+void AudioEncoder::SetReceiverFrameLengthRange(int min_frame_length_ms,
+ int max_frame_length_ms) {}
+
+ANAStats AudioEncoder::GetANAStats() const {
+ return ANAStats();
+}
+
+constexpr int AudioEncoder::kMaxNumberOfChannels;
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_encoder.h b/third_party/libwebrtc/api/audio_codecs/audio_encoder.h
new file mode 100644
index 0000000000..7f5a34214f
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_encoder.h
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2014 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 API_AUDIO_CODECS_AUDIO_ENCODER_H_
+#define API_AUDIO_CODECS_AUDIO_ENCODER_H_
+
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "absl/base/attributes.h"
+#include "absl/types/optional.h"
+#include "api/array_view.h"
+#include "api/call/bitrate_allocation.h"
+#include "api/units/time_delta.h"
+#include "rtc_base/buffer.h"
+
+namespace webrtc {
+
+class RtcEventLog;
+
+// Statistics related to Audio Network Adaptation.
+struct ANAStats {
+ ANAStats();
+ ANAStats(const ANAStats&);
+ ~ANAStats();
+ // Number of actions taken by the ANA bitrate controller since the start of
+ // the call. If this value is not set, it indicates that the bitrate
+ // controller is disabled.
+ absl::optional<uint32_t> bitrate_action_counter;
+ // Number of actions taken by the ANA channel controller since the start of
+ // the call. If this value is not set, it indicates that the channel
+ // controller is disabled.
+ absl::optional<uint32_t> channel_action_counter;
+ // Number of actions taken by the ANA DTX controller since the start of the
+ // call. If this value is not set, it indicates that the DTX controller is
+ // disabled.
+ absl::optional<uint32_t> dtx_action_counter;
+ // Number of actions taken by the ANA FEC controller since the start of the
+ // call. If this value is not set, it indicates that the FEC controller is
+ // disabled.
+ absl::optional<uint32_t> fec_action_counter;
+ // Number of times the ANA frame length controller decided to increase the
+ // frame length since the start of the call. If this value is not set, it
+ // indicates that the frame length controller is disabled.
+ absl::optional<uint32_t> frame_length_increase_counter;
+ // Number of times the ANA frame length controller decided to decrease the
+ // frame length since the start of the call. If this value is not set, it
+ // indicates that the frame length controller is disabled.
+ absl::optional<uint32_t> frame_length_decrease_counter;
+ // The uplink packet loss fractions as set by the ANA FEC controller. If this
+ // value is not set, it indicates that the ANA FEC controller is not active.
+ absl::optional<float> uplink_packet_loss_fraction;
+};
+
+// This is the interface class for encoders in AudioCoding module. Each codec
+// type must have an implementation of this class.
+class AudioEncoder {
+ public:
+ // Used for UMA logging of codec usage. The same codecs, with the
+ // same values, must be listed in
+ // src/tools/metrics/histograms/histograms.xml in chromium to log
+ // correct values.
+ enum class CodecType {
+ kOther = 0, // Codec not specified, and/or not listed in this enum
+ kOpus = 1,
+ kIsac = 2,
+ kPcmA = 3,
+ kPcmU = 4,
+ kG722 = 5,
+ kIlbc = 6,
+
+ // Number of histogram bins in the UMA logging of codec types. The
+ // total number of different codecs that are logged cannot exceed this
+ // number.
+ kMaxLoggedAudioCodecTypes
+ };
+
+ struct EncodedInfoLeaf {
+ size_t encoded_bytes = 0;
+ uint32_t encoded_timestamp = 0;
+ int payload_type = 0;
+ bool send_even_if_empty = false;
+ bool speech = true;
+ CodecType encoder_type = CodecType::kOther;
+ };
+
+ // This is the main struct for auxiliary encoding information. Each encoded
+ // packet should be accompanied by one EncodedInfo struct, containing the
+ // total number of `encoded_bytes`, the `encoded_timestamp` and the
+ // `payload_type`. If the packet contains redundant encodings, the `redundant`
+ // vector will be populated with EncodedInfoLeaf structs. Each struct in the
+ // vector represents one encoding; the order of structs in the vector is the
+ // same as the order in which the actual payloads are written to the byte
+ // stream. When EncoderInfoLeaf structs are present in the vector, the main
+ // struct's `encoded_bytes` will be the sum of all the `encoded_bytes` in the
+ // vector.
+ struct EncodedInfo : public EncodedInfoLeaf {
+ EncodedInfo();
+ EncodedInfo(const EncodedInfo&);
+ EncodedInfo(EncodedInfo&&);
+ ~EncodedInfo();
+ EncodedInfo& operator=(const EncodedInfo&);
+ EncodedInfo& operator=(EncodedInfo&&);
+
+ std::vector<EncodedInfoLeaf> redundant;
+ };
+
+ virtual ~AudioEncoder() = default;
+
+ // Returns the input sample rate in Hz and the number of input channels.
+ // These are constants set at instantiation time.
+ virtual int SampleRateHz() const = 0;
+ virtual size_t NumChannels() const = 0;
+
+ // Returns the rate at which the RTP timestamps are updated. The default
+ // implementation returns SampleRateHz().
+ virtual int RtpTimestampRateHz() const;
+
+ // Returns the number of 10 ms frames the encoder will put in the next
+ // packet. This value may only change when Encode() outputs a packet; i.e.,
+ // the encoder may vary the number of 10 ms frames from packet to packet, but
+ // it must decide the length of the next packet no later than when outputting
+ // the preceding packet.
+ virtual size_t Num10MsFramesInNextPacket() const = 0;
+
+ // Returns the maximum value that can be returned by
+ // Num10MsFramesInNextPacket().
+ virtual size_t Max10MsFramesInAPacket() const = 0;
+
+ // Returns the current target bitrate in bits/s. The value -1 means that the
+ // codec adapts the target automatically, and a current target cannot be
+ // provided.
+ virtual int GetTargetBitrate() const = 0;
+
+ // Accepts one 10 ms block of input audio (i.e., SampleRateHz() / 100 *
+ // NumChannels() samples). Multi-channel audio must be sample-interleaved.
+ // The encoder appends zero or more bytes of output to `encoded` and returns
+ // additional encoding information. Encode() checks some preconditions, calls
+ // EncodeImpl() which does the actual work, and then checks some
+ // postconditions.
+ EncodedInfo Encode(uint32_t rtp_timestamp,
+ rtc::ArrayView<const int16_t> audio,
+ rtc::Buffer* encoded);
+
+ // Resets the encoder to its starting state, discarding any input that has
+ // been fed to the encoder but not yet emitted in a packet.
+ virtual void Reset() = 0;
+
+ // Enables or disables codec-internal FEC (forward error correction). Returns
+ // true if the codec was able to comply. The default implementation returns
+ // true when asked to disable FEC and false when asked to enable it (meaning
+ // that FEC isn't supported).
+ virtual bool SetFec(bool enable);
+
+ // Enables or disables codec-internal VAD/DTX. Returns true if the codec was
+ // able to comply. The default implementation returns true when asked to
+ // disable DTX and false when asked to enable it (meaning that DTX isn't
+ // supported).
+ virtual bool SetDtx(bool enable);
+
+ // Returns the status of codec-internal DTX. The default implementation always
+ // returns false.
+ virtual bool GetDtx() const;
+
+ // Sets the application mode. Returns true if the codec was able to comply.
+ // The default implementation just returns false.
+ enum class Application { kSpeech, kAudio };
+ virtual bool SetApplication(Application application);
+
+ // Tells the encoder about the highest sample rate the decoder is expected to
+ // use when decoding the bitstream. The encoder would typically use this
+ // information to adjust the quality of the encoding. The default
+ // implementation does nothing.
+ virtual void SetMaxPlaybackRate(int frequency_hz);
+
+ // Tells the encoder what average bitrate we'd like it to produce. The
+ // encoder is free to adjust or disregard the given bitrate (the default
+ // implementation does the latter).
+ ABSL_DEPRECATED("Use OnReceivedTargetAudioBitrate instead")
+ virtual void SetTargetBitrate(int target_bps);
+
+ // Causes this encoder to let go of any other encoders it contains, and
+ // returns a pointer to an array where they are stored (which is required to
+ // live as long as this encoder). Unless the returned array is empty, you may
+ // not call any methods on this encoder afterwards, except for the
+ // destructor. The default implementation just returns an empty array.
+ // NOTE: This method is subject to change. Do not call or override it.
+ virtual rtc::ArrayView<std::unique_ptr<AudioEncoder>>
+ ReclaimContainedEncoders();
+
+ // Enables audio network adaptor. Returns true if successful.
+ virtual bool EnableAudioNetworkAdaptor(const std::string& config_string,
+ RtcEventLog* event_log);
+
+ // Disables audio network adaptor.
+ virtual void DisableAudioNetworkAdaptor();
+
+ // Provides uplink packet loss fraction to this encoder to allow it to adapt.
+ // `uplink_packet_loss_fraction` is in the range [0.0, 1.0].
+ virtual void OnReceivedUplinkPacketLossFraction(
+ float uplink_packet_loss_fraction);
+
+ ABSL_DEPRECATED("")
+ virtual void OnReceivedUplinkRecoverablePacketLossFraction(
+ float uplink_recoverable_packet_loss_fraction);
+
+ // Provides target audio bitrate to this encoder to allow it to adapt.
+ virtual void OnReceivedTargetAudioBitrate(int target_bps);
+
+ // Provides target audio bitrate and corresponding probing interval of
+ // the bandwidth estimator to this encoder to allow it to adapt.
+ virtual void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps,
+ absl::optional<int64_t> bwe_period_ms);
+
+ // Provides target audio bitrate and corresponding probing interval of
+ // the bandwidth estimator to this encoder to allow it to adapt.
+ virtual void OnReceivedUplinkAllocation(BitrateAllocationUpdate update);
+
+ // Provides RTT to this encoder to allow it to adapt.
+ virtual void OnReceivedRtt(int rtt_ms);
+
+ // Provides overhead to this encoder to adapt. The overhead is the number of
+ // bytes that will be added to each packet the encoder generates.
+ virtual void OnReceivedOverhead(size_t overhead_bytes_per_packet);
+
+ // To allow encoder to adapt its frame length, it must be provided the frame
+ // length range that receivers can accept.
+ virtual void SetReceiverFrameLengthRange(int min_frame_length_ms,
+ int max_frame_length_ms);
+
+ // Get statistics related to audio network adaptation.
+ virtual ANAStats GetANAStats() const;
+
+ // The range of frame lengths that are supported or nullopt if there's no sch
+ // information. This is used to calculated the full bitrate range, including
+ // overhead.
+ virtual absl::optional<std::pair<TimeDelta, TimeDelta>> GetFrameLengthRange()
+ const = 0;
+
+ // The maximum number of audio channels supported by WebRTC encoders.
+ static constexpr int kMaxNumberOfChannels = 24;
+
+ protected:
+ // Subclasses implement this to perform the actual encoding. Called by
+ // Encode().
+ virtual EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
+ rtc::ArrayView<const int16_t> audio,
+ rtc::Buffer* encoded) = 0;
+};
+} // namespace webrtc
+#endif // API_AUDIO_CODECS_AUDIO_ENCODER_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_encoder_factory.h b/third_party/libwebrtc/api/audio_codecs/audio_encoder_factory.h
new file mode 100644
index 0000000000..6128b1b6f3
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_encoder_factory.h
@@ -0,0 +1,62 @@
+/*
+ * 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 API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
+#define API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "rtc_base/ref_count.h"
+
+namespace webrtc {
+
+// A factory that creates AudioEncoders.
+class AudioEncoderFactory : public rtc::RefCountInterface {
+ public:
+ // Returns a prioritized list of audio codecs, to use for signaling etc.
+ virtual std::vector<AudioCodecSpec> GetSupportedEncoders() = 0;
+
+ // Returns information about how this format would be encoded, provided it's
+ // supported. More format and format variations may be supported than those
+ // returned by GetSupportedEncoders().
+ virtual absl::optional<AudioCodecInfo> QueryAudioEncoder(
+ const SdpAudioFormat& format) = 0;
+
+ // Creates an AudioEncoder for the specified format. The encoder will tags its
+ // payloads with the specified payload type. The `codec_pair_id` argument is
+ // used to link encoders and decoders that talk to the same remote entity: if
+ // a AudioEncoderFactory::MakeAudioEncoder() and a
+ // AudioDecoderFactory::MakeAudioDecoder() call receive non-null IDs that
+ // compare equal, the factory implementations may assume that the encoder and
+ // decoder form a pair. (The intended use case for this is to set up
+ // communication between the AudioEncoder and AudioDecoder instances, which is
+ // needed for some codecs with built-in bandwidth adaptation.)
+ //
+ // Returns null if the format isn't supported.
+ //
+ // Note: Implementations need to be robust against combinations other than
+ // one encoder, one decoder getting the same ID; such encoders must still
+ // work.
+ //
+ // TODO(ossu): Try to avoid audio encoders having to know their payload type.
+ virtual std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ int payload_type,
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id) = 0;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_encoder_factory_template.h b/third_party/libwebrtc/api/audio_codecs/audio_encoder_factory_template.h
new file mode 100644
index 0000000000..8a70ba2268
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_encoder_factory_template.h
@@ -0,0 +1,163 @@
+/*
+ * 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 API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_TEMPLATE_H_
+#define API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_TEMPLATE_H_
+
+#include <memory>
+#include <vector>
+
+#include "api/audio_codecs/audio_encoder_factory.h"
+#include "api/field_trials_view.h"
+#include "api/make_ref_counted.h"
+#include "api/scoped_refptr.h"
+
+namespace webrtc {
+
+namespace audio_encoder_factory_template_impl {
+
+template <typename... Ts>
+struct Helper;
+
+// Base case: 0 template parameters.
+template <>
+struct Helper<> {
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {}
+ static absl::optional<AudioCodecInfo> QueryAudioEncoder(
+ const SdpAudioFormat& format) {
+ return absl::nullopt;
+ }
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ int payload_type,
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id,
+ const FieldTrialsView* field_trials) {
+ return nullptr;
+ }
+};
+
+// Inductive case: Called with n + 1 template parameters; calls subroutines
+// with n template parameters.
+template <typename T, typename... Ts>
+struct Helper<T, Ts...> {
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {
+ T::AppendSupportedEncoders(specs);
+ Helper<Ts...>::AppendSupportedEncoders(specs);
+ }
+ static absl::optional<AudioCodecInfo> QueryAudioEncoder(
+ const SdpAudioFormat& format) {
+ auto opt_config = T::SdpToConfig(format);
+ static_assert(std::is_same<decltype(opt_config),
+ absl::optional<typename T::Config>>::value,
+ "T::SdpToConfig() must return a value of type "
+ "absl::optional<T::Config>");
+ return opt_config ? absl::optional<AudioCodecInfo>(
+ T::QueryAudioEncoder(*opt_config))
+ : Helper<Ts...>::QueryAudioEncoder(format);
+ }
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ int payload_type,
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id,
+ const FieldTrialsView* field_trials) {
+ auto opt_config = T::SdpToConfig(format);
+ if (opt_config) {
+ return T::MakeAudioEncoder(*opt_config, payload_type, codec_pair_id);
+ } else {
+ return Helper<Ts...>::MakeAudioEncoder(payload_type, format,
+ codec_pair_id, field_trials);
+ }
+ }
+};
+
+template <typename... Ts>
+class AudioEncoderFactoryT : public AudioEncoderFactory {
+ public:
+ explicit AudioEncoderFactoryT(const FieldTrialsView* field_trials) {
+ field_trials_ = field_trials;
+ }
+
+ std::vector<AudioCodecSpec> GetSupportedEncoders() override {
+ std::vector<AudioCodecSpec> specs;
+ Helper<Ts...>::AppendSupportedEncoders(&specs);
+ return specs;
+ }
+
+ absl::optional<AudioCodecInfo> QueryAudioEncoder(
+ const SdpAudioFormat& format) override {
+ return Helper<Ts...>::QueryAudioEncoder(format);
+ }
+
+ std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ int payload_type,
+ const SdpAudioFormat& format,
+ absl::optional<AudioCodecPairId> codec_pair_id) override {
+ return Helper<Ts...>::MakeAudioEncoder(payload_type, format, codec_pair_id,
+ field_trials_);
+ }
+
+ const FieldTrialsView* field_trials_;
+};
+
+} // namespace audio_encoder_factory_template_impl
+
+// Make an AudioEncoderFactory that can create instances of the given encoders.
+//
+// Each encoder type is given as a template argument to the function; it should
+// be a struct with the following static member functions:
+//
+// // Converts `audio_format` to a ConfigType instance. Returns an empty
+// // optional if `audio_format` doesn't correctly specify an encoder of our
+// // type.
+// absl::optional<ConfigType> SdpToConfig(const SdpAudioFormat& audio_format);
+//
+// // Appends zero or more AudioCodecSpecs to the list that will be returned
+// // by AudioEncoderFactory::GetSupportedEncoders().
+// void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
+//
+// // Returns information about how this format would be encoded. Used to
+// // implement AudioEncoderFactory::QueryAudioEncoder().
+// AudioCodecInfo QueryAudioEncoder(const ConfigType& config);
+//
+// // Creates an AudioEncoder for the specified format. Used to implement
+// // AudioEncoderFactory::MakeAudioEncoder().
+// std::unique_ptr<AudioDecoder> MakeAudioEncoder(
+// const ConfigType& config,
+// int payload_type,
+// absl::optional<AudioCodecPairId> codec_pair_id);
+//
+// ConfigType should be a type that encapsulates all the settings needed to
+// create an AudioEncoder. T::Config (where T is the encoder struct) should
+// either be the config type, or an alias for it.
+//
+// Whenever it tries to do something, the new factory will try each of the
+// encoders in the order they were specified in the template argument list,
+// stopping at the first one that claims to be able to do the job.
+//
+// TODO(kwiberg): Point at CreateBuiltinAudioEncoderFactory() for an example of
+// how it is used.
+template <typename... Ts>
+rtc::scoped_refptr<AudioEncoderFactory> CreateAudioEncoderFactory(
+ const FieldTrialsView* field_trials = nullptr) {
+ // There's no technical reason we couldn't allow zero template parameters,
+ // but such a factory couldn't create any encoders, and callers can do this
+ // by mistake by simply forgetting the <> altogether. So we forbid it in
+ // order to prevent caller foot-shooting.
+ static_assert(sizeof...(Ts) >= 1,
+ "Caller must give at least one template parameter");
+
+ return rtc::make_ref_counted<
+ audio_encoder_factory_template_impl::AudioEncoderFactoryT<Ts...>>(
+ field_trials);
+}
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_TEMPLATE_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_format.cc b/third_party/libwebrtc/api/audio_codecs/audio_format.cc
new file mode 100644
index 0000000000..2a529a49ee
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_format.cc
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2016 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 "api/audio_codecs/audio_format.h"
+
+#include <utility>
+
+#include "absl/strings/match.h"
+
+namespace webrtc {
+
+SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default;
+SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default;
+
+SdpAudioFormat::SdpAudioFormat(absl::string_view name,
+ int clockrate_hz,
+ size_t num_channels)
+ : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {}
+
+SdpAudioFormat::SdpAudioFormat(absl::string_view name,
+ int clockrate_hz,
+ size_t num_channels,
+ const Parameters& param)
+ : name(name),
+ clockrate_hz(clockrate_hz),
+ num_channels(num_channels),
+ parameters(param) {}
+
+SdpAudioFormat::SdpAudioFormat(absl::string_view name,
+ int clockrate_hz,
+ size_t num_channels,
+ Parameters&& param)
+ : name(name),
+ clockrate_hz(clockrate_hz),
+ num_channels(num_channels),
+ parameters(std::move(param)) {}
+
+bool SdpAudioFormat::Matches(const SdpAudioFormat& o) const {
+ return absl::EqualsIgnoreCase(name, o.name) &&
+ clockrate_hz == o.clockrate_hz && num_channels == o.num_channels;
+}
+
+SdpAudioFormat::~SdpAudioFormat() = default;
+SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default;
+SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default;
+
+bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b) {
+ return absl::EqualsIgnoreCase(a.name, b.name) &&
+ a.clockrate_hz == b.clockrate_hz && a.num_channels == b.num_channels &&
+ a.parameters == b.parameters;
+}
+
+AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
+ size_t num_channels,
+ int bitrate_bps)
+ : AudioCodecInfo(sample_rate_hz,
+ num_channels,
+ bitrate_bps,
+ bitrate_bps,
+ bitrate_bps) {}
+
+AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
+ size_t num_channels,
+ int default_bitrate_bps,
+ int min_bitrate_bps,
+ int max_bitrate_bps)
+ : sample_rate_hz(sample_rate_hz),
+ num_channels(num_channels),
+ default_bitrate_bps(default_bitrate_bps),
+ min_bitrate_bps(min_bitrate_bps),
+ max_bitrate_bps(max_bitrate_bps) {
+ RTC_DCHECK_GT(sample_rate_hz, 0);
+ RTC_DCHECK_GT(num_channels, 0);
+ RTC_DCHECK_GE(min_bitrate_bps, 0);
+ RTC_DCHECK_LE(min_bitrate_bps, default_bitrate_bps);
+ RTC_DCHECK_GE(max_bitrate_bps, default_bitrate_bps);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_format.h b/third_party/libwebrtc/api/audio_codecs/audio_format.h
new file mode 100644
index 0000000000..0cf67799b8
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/audio_format.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2016 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 API_AUDIO_CODECS_AUDIO_FORMAT_H_
+#define API_AUDIO_CODECS_AUDIO_FORMAT_H_
+
+#include <stddef.h>
+
+#include <map>
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "rtc_base/checks.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// SDP specification for a single audio codec.
+struct RTC_EXPORT SdpAudioFormat {
+ using Parameters = std::map<std::string, std::string>;
+
+ SdpAudioFormat(const SdpAudioFormat&);
+ SdpAudioFormat(SdpAudioFormat&&);
+ SdpAudioFormat(absl::string_view name, int clockrate_hz, size_t num_channels);
+ SdpAudioFormat(absl::string_view name,
+ int clockrate_hz,
+ size_t num_channels,
+ const Parameters& param);
+ SdpAudioFormat(absl::string_view name,
+ int clockrate_hz,
+ size_t num_channels,
+ Parameters&& param);
+ ~SdpAudioFormat();
+
+ // Returns true if this format is compatible with `o`. In SDP terminology:
+ // would it represent the same codec between an offer and an answer? As
+ // opposed to operator==, this method disregards codec parameters.
+ bool Matches(const SdpAudioFormat& o) const;
+
+ SdpAudioFormat& operator=(const SdpAudioFormat&);
+ SdpAudioFormat& operator=(SdpAudioFormat&&);
+
+ friend bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b);
+ friend bool operator!=(const SdpAudioFormat& a, const SdpAudioFormat& b) {
+ return !(a == b);
+ }
+
+ std::string name;
+ int clockrate_hz;
+ size_t num_channels;
+ Parameters parameters;
+};
+
+// Information about how an audio format is treated by the codec implementation.
+// Contains basic information, such as sample rate and number of channels, which
+// isn't uniformly presented by SDP. Also contains flags indicating support for
+// integrating with other parts of WebRTC, like external VAD and comfort noise
+// level calculation.
+//
+// To avoid API breakage, and make the code clearer, AudioCodecInfo should not
+// be directly initializable with any flags indicating optional support. If it
+// were, these initializers would break any time a new flag was added. It's also
+// more difficult to understand:
+// AudioCodecInfo info{16000, 1, 32000, true, false, false, true, true};
+// than
+// AudioCodecInfo info(16000, 1, 32000);
+// info.allow_comfort_noise = true;
+// info.future_flag_b = true;
+// info.future_flag_c = true;
+struct AudioCodecInfo {
+ AudioCodecInfo(int sample_rate_hz, size_t num_channels, int bitrate_bps);
+ AudioCodecInfo(int sample_rate_hz,
+ size_t num_channels,
+ int default_bitrate_bps,
+ int min_bitrate_bps,
+ int max_bitrate_bps);
+ AudioCodecInfo(const AudioCodecInfo& b) = default;
+ ~AudioCodecInfo() = default;
+
+ bool operator==(const AudioCodecInfo& b) const {
+ return sample_rate_hz == b.sample_rate_hz &&
+ num_channels == b.num_channels &&
+ default_bitrate_bps == b.default_bitrate_bps &&
+ min_bitrate_bps == b.min_bitrate_bps &&
+ max_bitrate_bps == b.max_bitrate_bps &&
+ allow_comfort_noise == b.allow_comfort_noise &&
+ supports_network_adaption == b.supports_network_adaption;
+ }
+
+ bool operator!=(const AudioCodecInfo& b) const { return !(*this == b); }
+
+ bool HasFixedBitrate() const {
+ RTC_DCHECK_GE(min_bitrate_bps, 0);
+ RTC_DCHECK_LE(min_bitrate_bps, default_bitrate_bps);
+ RTC_DCHECK_GE(max_bitrate_bps, default_bitrate_bps);
+ return min_bitrate_bps == max_bitrate_bps;
+ }
+
+ int sample_rate_hz;
+ size_t num_channels;
+ int default_bitrate_bps;
+ int min_bitrate_bps;
+ int max_bitrate_bps;
+
+ bool allow_comfort_noise = true; // This codec can be used with an external
+ // comfort noise generator.
+ bool supports_network_adaption = false; // This codec can adapt to varying
+ // network conditions.
+};
+
+// AudioCodecSpec ties an audio format to specific information about the codec
+// and its implementation.
+struct AudioCodecSpec {
+ bool operator==(const AudioCodecSpec& b) const {
+ return format == b.format && info == b.info;
+ }
+
+ bool operator!=(const AudioCodecSpec& b) const { return !(*this == b); }
+
+ SdpAudioFormat format;
+ AudioCodecInfo info;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_AUDIO_FORMAT_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.cc b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.cc
new file mode 100644
index 0000000000..881113d985
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.cc
@@ -0,0 +1,68 @@
+/*
+ * 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 "api/audio_codecs/builtin_audio_decoder_factory.h"
+
+#include <memory>
+#include <vector>
+
+#include "api/audio_codecs/L16/audio_decoder_L16.h"
+#include "api/audio_codecs/audio_decoder_factory_template.h"
+#include "api/audio_codecs/g711/audio_decoder_g711.h"
+#include "api/audio_codecs/g722/audio_decoder_g722.h"
+#if WEBRTC_USE_BUILTIN_ILBC
+#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" // nogncheck
+#endif
+#if WEBRTC_USE_BUILTIN_OPUS
+#include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h"
+#include "api/audio_codecs/opus/audio_decoder_opus.h" // nogncheck
+#endif
+
+namespace webrtc {
+
+namespace {
+
+// Modify an audio decoder to not advertise support for anything.
+template <typename T>
+struct NotAdvertised {
+ using Config = typename T::Config;
+ static absl::optional<Config> SdpToConfig(
+ const SdpAudioFormat& audio_format) {
+ return T::SdpToConfig(audio_format);
+ }
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) {
+ // Don't advertise support for anything.
+ }
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const Config& config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) {
+ return T::MakeAudioDecoder(config, codec_pair_id);
+ }
+};
+
+} // namespace
+
+rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() {
+ return CreateAudioDecoderFactory<
+
+#if WEBRTC_USE_BUILTIN_OPUS
+ AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>,
+#endif
+
+ AudioDecoderG722,
+
+#if WEBRTC_USE_BUILTIN_ILBC
+ AudioDecoderIlbc,
+#endif
+
+ AudioDecoderG711, NotAdvertised<AudioDecoderL16>>();
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.h b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.h
new file mode 100644
index 0000000000..72e1e3d96e
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 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 API_AUDIO_CODECS_BUILTIN_AUDIO_DECODER_FACTORY_H_
+#define API_AUDIO_CODECS_BUILTIN_AUDIO_DECODER_FACTORY_H_
+
+#include "api/audio_codecs/audio_decoder_factory.h"
+#include "api/scoped_refptr.h"
+
+namespace webrtc {
+
+// Creates a new factory that can create the built-in types of audio decoders.
+// Note: This will link with all the code implementing those codecs, so if you
+// only need a subset of the codecs, consider using
+// CreateAudioDecoderFactory<...codecs listed here...>() or
+// CreateOpusAudioDecoderFactory() instead.
+rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory();
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_BUILTIN_AUDIO_DECODER_FACTORY_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build
new file mode 100644
index 0000000000..366307ea13
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build
@@ -0,0 +1,234 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["WEBRTC_USE_BUILTIN_ILBC"] = "1"
+DEFINES["WEBRTC_USE_BUILTIN_OPUS"] = "1"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "rt"
+ ]
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "crypt32",
+ "iphlpapi",
+ "secur32",
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("builtin_audio_decoder_factory_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.cc b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.cc
new file mode 100644
index 0000000000..4546a2eaee
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.cc
@@ -0,0 +1,74 @@
+/*
+ * 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 "api/audio_codecs/builtin_audio_encoder_factory.h"
+
+#include <memory>
+#include <vector>
+
+#include "api/audio_codecs/L16/audio_encoder_L16.h"
+#include "api/audio_codecs/audio_encoder_factory_template.h"
+#include "api/audio_codecs/g711/audio_encoder_g711.h"
+#include "api/audio_codecs/g722/audio_encoder_g722.h"
+#if WEBRTC_USE_BUILTIN_ILBC
+#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" // nogncheck
+#endif
+#if WEBRTC_USE_BUILTIN_OPUS
+#include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h"
+#include "api/audio_codecs/opus/audio_encoder_opus.h" // nogncheck
+#endif
+
+namespace webrtc {
+
+namespace {
+
+// Modify an audio encoder to not advertise support for anything.
+template <typename T>
+struct NotAdvertised {
+ using Config = typename T::Config;
+ static absl::optional<Config> SdpToConfig(
+ const SdpAudioFormat& audio_format) {
+ return T::SdpToConfig(audio_format);
+ }
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {
+ // Don't advertise support for anything.
+ }
+ static AudioCodecInfo QueryAudioEncoder(const Config& config) {
+ return T::QueryAudioEncoder(config);
+ }
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr) {
+ return T::MakeAudioEncoder(config, payload_type, codec_pair_id,
+ field_trials);
+ }
+};
+
+} // namespace
+
+rtc::scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory() {
+ return CreateAudioEncoderFactory<
+
+#if WEBRTC_USE_BUILTIN_OPUS
+ AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>,
+#endif
+
+ AudioEncoderG722,
+
+#if WEBRTC_USE_BUILTIN_ILBC
+ AudioEncoderIlbc,
+#endif
+
+ AudioEncoderG711, NotAdvertised<AudioEncoderL16>>();
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.h b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.h
new file mode 100644
index 0000000000..f833de10f1
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 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 API_AUDIO_CODECS_BUILTIN_AUDIO_ENCODER_FACTORY_H_
+#define API_AUDIO_CODECS_BUILTIN_AUDIO_ENCODER_FACTORY_H_
+
+#include "api/audio_codecs/audio_encoder_factory.h"
+#include "api/scoped_refptr.h"
+
+namespace webrtc {
+
+// Creates a new factory that can create the built-in types of audio encoders.
+// Note: This will link with all the code implementing those codecs, so if you
+// only need a subset of the codecs, consider using
+// CreateAudioEncoderFactory<...codecs listed here...>() or
+// CreateOpusAudioEncoderFactory() instead.
+rtc::scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory();
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_BUILTIN_AUDIO_ENCODER_FACTORY_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build
new file mode 100644
index 0000000000..db0e3fbe00
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build
@@ -0,0 +1,234 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+DEFINES["WEBRTC_USE_BUILTIN_ILBC"] = "1"
+DEFINES["WEBRTC_USE_BUILTIN_OPUS"] = "1"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "rt"
+ ]
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "crypt32",
+ "iphlpapi",
+ "secur32",
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("builtin_audio_encoder_factory_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/g711/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/g711/BUILD.gn
new file mode 100644
index 0000000000..b2ff324f12
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g711/BUILD.gn
@@ -0,0 +1,55 @@
+# 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.
+
+import("../../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+rtc_library("audio_encoder_g711") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_encoder_g711.cc",
+ "audio_encoder_g711.h",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:g711",
+ "../../../rtc_base:safe_conversions",
+ "../../../rtc_base:safe_minmax",
+ "../../../rtc_base:stringutils",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
+
+rtc_library("audio_decoder_g711") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_decoder_g711.cc",
+ "audio_decoder_g711.h",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:g711",
+ "../../../rtc_base:safe_conversions",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.cc b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.cc
new file mode 100644
index 0000000000..838f7e9624
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.cc
@@ -0,0 +1,67 @@
+/*
+ * 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 "api/audio_codecs/g711/audio_decoder_g711.h"
+
+#include <memory>
+#include <vector>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
+#include "rtc_base/numerics/safe_conversions.h"
+
+namespace webrtc {
+
+absl::optional<AudioDecoderG711::Config> AudioDecoderG711::SdpToConfig(
+ const SdpAudioFormat& format) {
+ const bool is_pcmu = absl::EqualsIgnoreCase(format.name, "PCMU");
+ const bool is_pcma = absl::EqualsIgnoreCase(format.name, "PCMA");
+ if (format.clockrate_hz == 8000 && format.num_channels >= 1 &&
+ (is_pcmu || is_pcma)) {
+ Config config;
+ config.type = is_pcmu ? Config::Type::kPcmU : Config::Type::kPcmA;
+ config.num_channels = rtc::dchecked_cast<int>(format.num_channels);
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return absl::nullopt;
+ }
+ return config;
+ } else {
+ return absl::nullopt;
+ }
+}
+
+void AudioDecoderG711::AppendSupportedDecoders(
+ std::vector<AudioCodecSpec>* specs) {
+ for (const char* type : {"PCMU", "PCMA"}) {
+ specs->push_back({{type, 8000, 1}, {8000, 1, 64000}});
+ }
+}
+
+std::unique_ptr<AudioDecoder> AudioDecoderG711::MakeAudioDecoder(
+ const Config& config,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ switch (config.type) {
+ case Config::Type::kPcmU:
+ return std::make_unique<AudioDecoderPcmU>(config.num_channels);
+ case Config::Type::kPcmA:
+ return std::make_unique<AudioDecoderPcmA>(config.num_channels);
+ default:
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.h b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.h
new file mode 100644
index 0000000000..0f7a98d345
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.h
@@ -0,0 +1,49 @@
+/*
+ * 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 API_AUDIO_CODECS_G711_AUDIO_DECODER_G711_H_
+#define API_AUDIO_CODECS_G711_AUDIO_DECODER_G711_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// G711 decoder API for use as a template parameter to
+// CreateAudioDecoderFactory<...>().
+struct RTC_EXPORT AudioDecoderG711 {
+ struct Config {
+ enum class Type { kPcmU, kPcmA };
+ bool IsOk() const {
+ return (type == Type::kPcmU || type == Type::kPcmA) &&
+ num_channels >= 1 &&
+ num_channels <= AudioDecoder::kMaxNumberOfChannels;
+ }
+ Type type;
+ int num_channels;
+ };
+ static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const Config& config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_G711_AUDIO_DECODER_G711_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build
new file mode 100644
index 0000000000..4782d01dd1
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build
@@ -0,0 +1,225 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_decoder_g711_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.cc b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.cc
new file mode 100644
index 0000000000..1dca3b80d3
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.cc
@@ -0,0 +1,95 @@
+/*
+ * 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 "api/audio_codecs/g711/audio_encoder_g711.h"
+
+#include <memory>
+#include <vector>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
+#include "rtc_base/numerics/safe_conversions.h"
+#include "rtc_base/numerics/safe_minmax.h"
+#include "rtc_base/string_to_number.h"
+
+namespace webrtc {
+
+absl::optional<AudioEncoderG711::Config> AudioEncoderG711::SdpToConfig(
+ const SdpAudioFormat& format) {
+ const bool is_pcmu = absl::EqualsIgnoreCase(format.name, "PCMU");
+ const bool is_pcma = absl::EqualsIgnoreCase(format.name, "PCMA");
+ if (format.clockrate_hz == 8000 && format.num_channels >= 1 &&
+ (is_pcmu || is_pcma)) {
+ Config config;
+ config.type = is_pcmu ? Config::Type::kPcmU : Config::Type::kPcmA;
+ config.num_channels = rtc::dchecked_cast<int>(format.num_channels);
+ config.frame_size_ms = 20;
+ auto ptime_iter = format.parameters.find("ptime");
+ if (ptime_iter != format.parameters.end()) {
+ const auto ptime = rtc::StringToNumber<int>(ptime_iter->second);
+ if (ptime && *ptime > 0) {
+ config.frame_size_ms = rtc::SafeClamp(10 * (*ptime / 10), 10, 60);
+ }
+ }
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return absl::nullopt;
+ }
+ return config;
+ } else {
+ return absl::nullopt;
+ }
+}
+
+void AudioEncoderG711::AppendSupportedEncoders(
+ std::vector<AudioCodecSpec>* specs) {
+ for (const char* type : {"PCMU", "PCMA"}) {
+ specs->push_back({{type, 8000, 1}, {8000, 1, 64000}});
+ }
+}
+
+AudioCodecInfo AudioEncoderG711::QueryAudioEncoder(const Config& config) {
+ RTC_DCHECK(config.IsOk());
+ return {8000, rtc::dchecked_cast<size_t>(config.num_channels),
+ 64000 * config.num_channels};
+}
+
+std::unique_ptr<AudioEncoder> AudioEncoderG711::MakeAudioEncoder(
+ const Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ switch (config.type) {
+ case Config::Type::kPcmU: {
+ AudioEncoderPcmU::Config impl_config;
+ impl_config.num_channels = config.num_channels;
+ impl_config.frame_size_ms = config.frame_size_ms;
+ impl_config.payload_type = payload_type;
+ return std::make_unique<AudioEncoderPcmU>(impl_config);
+ }
+ case Config::Type::kPcmA: {
+ AudioEncoderPcmA::Config impl_config;
+ impl_config.num_channels = config.num_channels;
+ impl_config.frame_size_ms = config.frame_size_ms;
+ impl_config.payload_type = payload_type;
+ return std::make_unique<AudioEncoderPcmA>(impl_config);
+ }
+ default: {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ }
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.h b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.h
new file mode 100644
index 0000000000..4b3eb845e0
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.h
@@ -0,0 +1,54 @@
+/*
+ * 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 API_AUDIO_CODECS_G711_AUDIO_ENCODER_G711_H_
+#define API_AUDIO_CODECS_G711_AUDIO_ENCODER_G711_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// G711 encoder API for use as a template parameter to
+// CreateAudioEncoderFactory<...>().
+struct RTC_EXPORT AudioEncoderG711 {
+ struct Config {
+ enum class Type { kPcmU, kPcmA };
+ bool IsOk() const {
+ return (type == Type::kPcmU || type == Type::kPcmA) &&
+ frame_size_ms > 0 && frame_size_ms % 10 == 0 &&
+ num_channels >= 1 &&
+ num_channels <= AudioEncoder::kMaxNumberOfChannels;
+ }
+ Type type = Type::kPcmU;
+ int num_channels = 1;
+ int frame_size_ms = 20;
+ };
+ static absl::optional<AudioEncoderG711::Config> SdpToConfig(
+ const SdpAudioFormat& audio_format);
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
+ static AudioCodecInfo QueryAudioEncoder(const Config& config);
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_G711_AUDIO_ENCODER_G711_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build
new file mode 100644
index 0000000000..c972978c13
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build
@@ -0,0 +1,225 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_g711_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/g722/BUILD.gn
new file mode 100644
index 0000000000..af13ac3de3
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/BUILD.gn
@@ -0,0 +1,62 @@
+# 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.
+
+import("../../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+rtc_source_set("audio_encoder_g722_config") {
+ visibility = [ "*" ]
+ sources = [ "audio_encoder_g722_config.h" ]
+ deps = [ "..:audio_codecs_api" ]
+}
+
+rtc_library("audio_encoder_g722") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_encoder_g722.cc",
+ "audio_encoder_g722.h",
+ ]
+ deps = [
+ ":audio_encoder_g722_config",
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:g722",
+ "../../../rtc_base:safe_conversions",
+ "../../../rtc_base:safe_minmax",
+ "../../../rtc_base:stringutils",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
+
+rtc_library("audio_decoder_g722") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_decoder_g722.cc",
+ "audio_decoder_g722.h",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:g722",
+ "../../../rtc_base:safe_conversions",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.cc b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.cc
new file mode 100644
index 0000000000..ed7163471a
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.cc
@@ -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.
+ */
+
+#include "api/audio_codecs/g722/audio_decoder_g722.h"
+
+#include <memory>
+#include <vector>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/g722/audio_decoder_g722.h"
+#include "rtc_base/numerics/safe_conversions.h"
+
+namespace webrtc {
+
+absl::optional<AudioDecoderG722::Config> AudioDecoderG722::SdpToConfig(
+ const SdpAudioFormat& format) {
+ if (absl::EqualsIgnoreCase(format.name, "G722") &&
+ format.clockrate_hz == 8000 &&
+ (format.num_channels == 1 || format.num_channels == 2)) {
+ return Config{rtc::dchecked_cast<int>(format.num_channels)};
+ }
+ return absl::nullopt;
+}
+
+void AudioDecoderG722::AppendSupportedDecoders(
+ std::vector<AudioCodecSpec>* specs) {
+ specs->push_back({{"G722", 8000, 1}, {16000, 1, 64000}});
+}
+
+std::unique_ptr<AudioDecoder> AudioDecoderG722::MakeAudioDecoder(
+ Config config,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ switch (config.num_channels) {
+ case 1:
+ return std::make_unique<AudioDecoderG722Impl>();
+ case 2:
+ return std::make_unique<AudioDecoderG722StereoImpl>();
+ default:
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.h b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.h
new file mode 100644
index 0000000000..6f7b253039
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.h
@@ -0,0 +1,43 @@
+/*
+ * 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 API_AUDIO_CODECS_G722_AUDIO_DECODER_G722_H_
+#define API_AUDIO_CODECS_G722_AUDIO_DECODER_G722_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// G722 decoder API for use as a template parameter to
+// CreateAudioDecoderFactory<...>().
+struct RTC_EXPORT AudioDecoderG722 {
+ struct Config {
+ bool IsOk() const { return num_channels == 1 || num_channels == 2; }
+ int num_channels;
+ };
+ static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ Config config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_G722_AUDIO_DECODER_G722_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build
new file mode 100644
index 0000000000..77003c77a9
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build
@@ -0,0 +1,225 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_decoder_g722_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.cc b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.cc
new file mode 100644
index 0000000000..56a6c4da6a
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.cc
@@ -0,0 +1,74 @@
+/*
+ * 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 "api/audio_codecs/g722/audio_encoder_g722.h"
+
+#include <memory>
+#include <vector>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/g722/audio_encoder_g722.h"
+#include "rtc_base/numerics/safe_conversions.h"
+#include "rtc_base/numerics/safe_minmax.h"
+#include "rtc_base/string_to_number.h"
+
+namespace webrtc {
+
+absl::optional<AudioEncoderG722Config> AudioEncoderG722::SdpToConfig(
+ const SdpAudioFormat& format) {
+ if (!absl::EqualsIgnoreCase(format.name, "g722") ||
+ format.clockrate_hz != 8000) {
+ return absl::nullopt;
+ }
+
+ AudioEncoderG722Config config;
+ config.num_channels = rtc::checked_cast<int>(format.num_channels);
+ auto ptime_iter = format.parameters.find("ptime");
+ if (ptime_iter != format.parameters.end()) {
+ auto ptime = rtc::StringToNumber<int>(ptime_iter->second);
+ if (ptime && *ptime > 0) {
+ const int whole_packets = *ptime / 10;
+ config.frame_size_ms = rtc::SafeClamp<int>(whole_packets * 10, 10, 60);
+ }
+ }
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return absl::nullopt;
+ }
+ return config;
+}
+
+void AudioEncoderG722::AppendSupportedEncoders(
+ std::vector<AudioCodecSpec>* specs) {
+ const SdpAudioFormat fmt = {"G722", 8000, 1};
+ const AudioCodecInfo info = QueryAudioEncoder(*SdpToConfig(fmt));
+ specs->push_back({fmt, info});
+}
+
+AudioCodecInfo AudioEncoderG722::QueryAudioEncoder(
+ const AudioEncoderG722Config& config) {
+ RTC_DCHECK(config.IsOk());
+ return {16000, rtc::dchecked_cast<size_t>(config.num_channels),
+ 64000 * config.num_channels};
+}
+
+std::unique_ptr<AudioEncoder> AudioEncoderG722::MakeAudioEncoder(
+ const AudioEncoderG722Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ return std::make_unique<AudioEncoderG722Impl>(config, payload_type);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.h b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.h
new file mode 100644
index 0000000000..78ceddd1e9
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.h
@@ -0,0 +1,44 @@
+/*
+ * 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 API_AUDIO_CODECS_G722_AUDIO_ENCODER_G722_H_
+#define API_AUDIO_CODECS_G722_AUDIO_ENCODER_G722_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/audio_codecs/g722/audio_encoder_g722_config.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// G722 encoder API for use as a template parameter to
+// CreateAudioEncoderFactory<...>().
+struct RTC_EXPORT AudioEncoderG722 {
+ using Config = AudioEncoderG722Config;
+ static absl::optional<AudioEncoderG722Config> SdpToConfig(
+ const SdpAudioFormat& audio_format);
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
+ static AudioCodecInfo QueryAudioEncoder(const AudioEncoderG722Config& config);
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const AudioEncoderG722Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_G722_AUDIO_ENCODER_G722_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config.h b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config.h
new file mode 100644
index 0000000000..f3f3a9f016
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config.h
@@ -0,0 +1,29 @@
+/*
+ * 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 API_AUDIO_CODECS_G722_AUDIO_ENCODER_G722_CONFIG_H_
+#define API_AUDIO_CODECS_G722_AUDIO_ENCODER_G722_CONFIG_H_
+
+#include "api/audio_codecs/audio_encoder.h"
+
+namespace webrtc {
+
+struct AudioEncoderG722Config {
+ bool IsOk() const {
+ return frame_size_ms > 0 && frame_size_ms % 10 == 0 && num_channels >= 1 &&
+ num_channels <= AudioEncoder::kMaxNumberOfChannels;
+ }
+ int frame_size_ms = 20;
+ int num_channels = 1;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_G722_AUDIO_ENCODER_G722_CONFIG_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build
new file mode 100644
index 0000000000..41e1e248c5
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build
@@ -0,0 +1,209 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_g722_config_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build
new file mode 100644
index 0000000000..c3beba6cdb
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build
@@ -0,0 +1,225 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_g722_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/ilbc/BUILD.gn
new file mode 100644
index 0000000000..22cf48220f
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/BUILD.gn
@@ -0,0 +1,58 @@
+# 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.
+
+import("../../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+rtc_source_set("audio_encoder_ilbc_config") {
+ visibility = [ "*" ]
+ sources = [ "audio_encoder_ilbc_config.h" ]
+}
+
+rtc_library("audio_encoder_ilbc") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_encoder_ilbc.cc",
+ "audio_encoder_ilbc.h",
+ ]
+ deps = [
+ ":audio_encoder_ilbc_config",
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:ilbc",
+ "../../../rtc_base:safe_conversions",
+ "../../../rtc_base:safe_minmax",
+ "../../../rtc_base:stringutils",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
+
+rtc_library("audio_decoder_ilbc") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_decoder_ilbc.cc",
+ "audio_decoder_ilbc.h",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:ilbc",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.cc b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.cc
new file mode 100644
index 0000000000..c58316903a
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.cc
@@ -0,0 +1,42 @@
+/*
+ * 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 "api/audio_codecs/ilbc/audio_decoder_ilbc.h"
+
+#include <memory>
+#include <vector>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h"
+
+namespace webrtc {
+
+absl::optional<AudioDecoderIlbc::Config> AudioDecoderIlbc::SdpToConfig(
+ const SdpAudioFormat& format) {
+ if (absl::EqualsIgnoreCase(format.name, "ILBC") &&
+ format.clockrate_hz == 8000 && format.num_channels == 1) {
+ return Config();
+ }
+ return absl::nullopt;
+}
+
+void AudioDecoderIlbc::AppendSupportedDecoders(
+ std::vector<AudioCodecSpec>* specs) {
+ specs->push_back({{"ILBC", 8000, 1}, {8000, 1, 13300}});
+}
+
+std::unique_ptr<AudioDecoder> AudioDecoderIlbc::MakeAudioDecoder(
+ Config config,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ return std::make_unique<AudioDecoderIlbcImpl>();
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h
new file mode 100644
index 0000000000..60566c88df
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h
@@ -0,0 +1,39 @@
+/*
+ * 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 API_AUDIO_CODECS_ILBC_AUDIO_DECODER_ILBC_H_
+#define API_AUDIO_CODECS_ILBC_AUDIO_DECODER_ILBC_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/field_trials_view.h"
+
+namespace webrtc {
+
+// ILBC decoder API for use as a template parameter to
+// CreateAudioDecoderFactory<...>().
+struct AudioDecoderIlbc {
+ struct Config {}; // Empty---no config values needed!
+ static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ Config config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_ILBC_AUDIO_DECODER_ILBC_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build
new file mode 100644
index 0000000000..53e9d1a4a7
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build
@@ -0,0 +1,232 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "rt"
+ ]
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "crypt32",
+ "iphlpapi",
+ "secur32",
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_decoder_ilbc_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.cc b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.cc
new file mode 100644
index 0000000000..b497948491
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.cc
@@ -0,0 +1,88 @@
+/*
+ * 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 "api/audio_codecs/ilbc/audio_encoder_ilbc.h"
+
+#include <memory>
+#include <vector>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h"
+#include "rtc_base/numerics/safe_conversions.h"
+#include "rtc_base/numerics/safe_minmax.h"
+#include "rtc_base/string_to_number.h"
+
+namespace webrtc {
+namespace {
+int GetIlbcBitrate(int ptime) {
+ switch (ptime) {
+ case 20:
+ case 40:
+ // 38 bytes per frame of 20 ms => 15200 bits/s.
+ return 15200;
+ case 30:
+ case 60:
+ // 50 bytes per frame of 30 ms => (approx) 13333 bits/s.
+ return 13333;
+ default:
+ RTC_CHECK_NOTREACHED();
+ }
+}
+} // namespace
+
+absl::optional<AudioEncoderIlbcConfig> AudioEncoderIlbc::SdpToConfig(
+ const SdpAudioFormat& format) {
+ if (!absl::EqualsIgnoreCase(format.name.c_str(), "ILBC") ||
+ format.clockrate_hz != 8000 || format.num_channels != 1) {
+ return absl::nullopt;
+ }
+
+ AudioEncoderIlbcConfig config;
+ auto ptime_iter = format.parameters.find("ptime");
+ if (ptime_iter != format.parameters.end()) {
+ auto ptime = rtc::StringToNumber<int>(ptime_iter->second);
+ if (ptime && *ptime > 0) {
+ const int whole_packets = *ptime / 10;
+ config.frame_size_ms = rtc::SafeClamp<int>(whole_packets * 10, 20, 60);
+ }
+ }
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return absl::nullopt;
+ }
+ return config;
+}
+
+void AudioEncoderIlbc::AppendSupportedEncoders(
+ std::vector<AudioCodecSpec>* specs) {
+ const SdpAudioFormat fmt = {"ILBC", 8000, 1};
+ const AudioCodecInfo info = QueryAudioEncoder(*SdpToConfig(fmt));
+ specs->push_back({fmt, info});
+}
+
+AudioCodecInfo AudioEncoderIlbc::QueryAudioEncoder(
+ const AudioEncoderIlbcConfig& config) {
+ RTC_DCHECK(config.IsOk());
+ return {8000, 1, GetIlbcBitrate(config.frame_size_ms)};
+}
+
+std::unique_ptr<AudioEncoder> AudioEncoderIlbc::MakeAudioEncoder(
+ const AudioEncoderIlbcConfig& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ return std::make_unique<AudioEncoderIlbcImpl>(config, payload_type);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h
new file mode 100644
index 0000000000..a5306841ce
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h
@@ -0,0 +1,43 @@
+/*
+ * 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 API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_
+#define API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h"
+#include "api/field_trials_view.h"
+
+namespace webrtc {
+
+// ILBC encoder API for use as a template parameter to
+// CreateAudioEncoderFactory<...>().
+struct AudioEncoderIlbc {
+ using Config = AudioEncoderIlbcConfig;
+ static absl::optional<AudioEncoderIlbcConfig> SdpToConfig(
+ const SdpAudioFormat& audio_format);
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
+ static AudioCodecInfo QueryAudioEncoder(const AudioEncoderIlbcConfig& config);
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const AudioEncoderIlbcConfig& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h
new file mode 100644
index 0000000000..4d82f9901c
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config.h
@@ -0,0 +1,28 @@
+/*
+ * 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 API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_CONFIG_H_
+#define API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_CONFIG_H_
+
+namespace webrtc {
+
+struct AudioEncoderIlbcConfig {
+ bool IsOk() const {
+ return (frame_size_ms == 20 || frame_size_ms == 30 || frame_size_ms == 40 ||
+ frame_size_ms == 60);
+ }
+ int frame_size_ms = 30; // Valid values are 20, 30, 40, and 60 ms.
+ // Note that frame size 40 ms produces encodings with two 20 ms frames in
+ // them, and frame size 60 ms consists of two 30 ms frames.
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_CONFIG_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build
new file mode 100644
index 0000000000..75737b8f19
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build
@@ -0,0 +1,201 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_ilbc_config_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build
new file mode 100644
index 0000000000..bddfe42193
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build
@@ -0,0 +1,232 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "rt"
+ ]
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "crypt32",
+ "iphlpapi",
+ "secur32",
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_ilbc_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/opus/BUILD.gn
new file mode 100644
index 0000000000..eb90a0b9ac
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/BUILD.gn
@@ -0,0 +1,110 @@
+# 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.
+
+import("../../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+rtc_library("audio_encoder_opus_config") {
+ visibility = [ "*" ]
+ sources = [
+ "audio_encoder_multi_channel_opus_config.cc",
+ "audio_encoder_multi_channel_opus_config.h",
+ "audio_encoder_opus_config.cc",
+ "audio_encoder_opus_config.h",
+ ]
+ deps = [ "../../../rtc_base/system:rtc_export" ]
+ absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
+ defines = []
+ if (rtc_opus_variable_complexity) {
+ defines += [ "WEBRTC_OPUS_VARIABLE_COMPLEXITY=1" ]
+ } else {
+ defines += [ "WEBRTC_OPUS_VARIABLE_COMPLEXITY=0" ]
+ }
+}
+
+rtc_source_set("audio_decoder_opus_config") {
+ visibility = [ "*" ]
+ sources = [ "audio_decoder_multi_channel_opus_config.h" ]
+ deps = [ "..:audio_codecs_api" ]
+}
+
+rtc_library("audio_encoder_opus") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ public = [ "audio_encoder_opus.h" ]
+ sources = [ "audio_encoder_opus.cc" ]
+ deps = [
+ ":audio_encoder_opus_config",
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:webrtc_opus",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
+
+rtc_library("audio_decoder_opus") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_decoder_opus.cc",
+ "audio_decoder_opus.h",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:webrtc_opus",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
+
+rtc_library("audio_encoder_multiopus") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ public = [ "audio_encoder_multi_channel_opus.h" ]
+ sources = [ "audio_encoder_multi_channel_opus.cc" ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:webrtc_multiopus",
+ "../../../rtc_base/system:rtc_export",
+ "../opus:audio_encoder_opus_config",
+ ]
+ absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
+}
+
+rtc_library("audio_decoder_multiopus") {
+ visibility = [ "*" ]
+ poisonous = [ "audio_codecs" ]
+ sources = [
+ "audio_decoder_multi_channel_opus.cc",
+ "audio_decoder_multi_channel_opus.h",
+ ]
+ deps = [
+ ":audio_decoder_opus_config",
+ "..:audio_codecs_api",
+ "../../../api:field_trials_view",
+ "../../../modules/audio_coding:webrtc_multiopus",
+ "../../../rtc_base/system:rtc_export",
+ ]
+ absl_deps = [
+ "//third_party/abseil-cpp/absl/memory",
+ "//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
+ ]
+}
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc
new file mode 100644
index 0000000000..0fb4e05511
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2019 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 "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h"
+
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "absl/memory/memory.h"
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h"
+
+namespace webrtc {
+
+absl::optional<AudioDecoderMultiChannelOpusConfig>
+AudioDecoderMultiChannelOpus::SdpToConfig(const SdpAudioFormat& format) {
+ return AudioDecoderMultiChannelOpusImpl::SdpToConfig(format);
+}
+
+void AudioDecoderMultiChannelOpus::AppendSupportedDecoders(
+ std::vector<AudioCodecSpec>* specs) {
+ // To get full utilization of the surround support of the Opus lib, we can
+ // mark which channel is the low frequency effects (LFE). But that is not done
+ // ATM.
+ {
+ AudioCodecInfo surround_5_1_opus_info{48000, 6,
+ /* default_bitrate_bps= */ 128000};
+ surround_5_1_opus_info.allow_comfort_noise = false;
+ surround_5_1_opus_info.supports_network_adaption = false;
+ SdpAudioFormat opus_format({"multiopus",
+ 48000,
+ 6,
+ {{"minptime", "10"},
+ {"useinbandfec", "1"},
+ {"channel_mapping", "0,4,1,2,3,5"},
+ {"num_streams", "4"},
+ {"coupled_streams", "2"}}});
+ specs->push_back({std::move(opus_format), surround_5_1_opus_info});
+ }
+ {
+ AudioCodecInfo surround_7_1_opus_info{48000, 8,
+ /* default_bitrate_bps= */ 200000};
+ surround_7_1_opus_info.allow_comfort_noise = false;
+ surround_7_1_opus_info.supports_network_adaption = false;
+ SdpAudioFormat opus_format({"multiopus",
+ 48000,
+ 8,
+ {{"minptime", "10"},
+ {"useinbandfec", "1"},
+ {"channel_mapping", "0,6,1,2,3,4,5,7"},
+ {"num_streams", "5"},
+ {"coupled_streams", "3"}}});
+ specs->push_back({std::move(opus_format), surround_7_1_opus_info});
+ }
+}
+
+std::unique_ptr<AudioDecoder> AudioDecoderMultiChannelOpus::MakeAudioDecoder(
+ AudioDecoderMultiChannelOpusConfig config,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ return AudioDecoderMultiChannelOpusImpl::MakeAudioDecoder(config);
+}
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h
new file mode 100644
index 0000000000..eafd6c6939
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019 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 API_AUDIO_CODECS_OPUS_AUDIO_DECODER_MULTI_CHANNEL_OPUS_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_DECODER_MULTI_CHANNEL_OPUS_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// Opus decoder API for use as a template parameter to
+// CreateAudioDecoderFactory<...>().
+struct RTC_EXPORT AudioDecoderMultiChannelOpus {
+ using Config = AudioDecoderMultiChannelOpusConfig;
+ static absl::optional<AudioDecoderMultiChannelOpusConfig> SdpToConfig(
+ const SdpAudioFormat& audio_format);
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ AudioDecoderMultiChannelOpusConfig config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_DECODER_MULTI_CHANNEL_OPUS_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h
new file mode 100644
index 0000000000..f97c5c3193
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2019 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 API_AUDIO_CODECS_OPUS_AUDIO_DECODER_MULTI_CHANNEL_OPUS_CONFIG_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_DECODER_MULTI_CHANNEL_OPUS_CONFIG_H_
+
+#include <vector>
+
+#include "api/audio_codecs/audio_decoder.h"
+
+namespace webrtc {
+struct AudioDecoderMultiChannelOpusConfig {
+ // The number of channels that the decoder will output.
+ int num_channels;
+
+ // Number of mono or stereo encoded Opus streams.
+ int num_streams;
+
+ // Number of channel pairs coupled together, see RFC 7845 section
+ // 5.1.1. Has to be less than the number of streams.
+ int coupled_streams;
+
+ // Channel mapping table, defines the mapping from encoded streams to output
+ // channels. See RFC 7845 section 5.1.1.
+ std::vector<unsigned char> channel_mapping;
+
+ bool IsOk() const {
+ if (num_channels < 1 || num_channels > AudioDecoder::kMaxNumberOfChannels ||
+ num_streams < 0 || coupled_streams < 0) {
+ return false;
+ }
+ if (num_streams < coupled_streams) {
+ return false;
+ }
+ if (channel_mapping.size() != static_cast<size_t>(num_channels)) {
+ return false;
+ }
+
+ // Every mono stream codes one channel, every coupled stream codes two. This
+ // is the total coded channel count:
+ const int max_coded_channel = num_streams + coupled_streams;
+ for (const auto& x : channel_mapping) {
+ // Coded channels >= max_coded_channel don't exist. Except for 255, which
+ // tells Opus to put silence in output channel x.
+ if (x >= max_coded_channel && x != 255) {
+ return false;
+ }
+ }
+
+ if (num_channels > 255 || max_coded_channel >= 255) {
+ return false;
+ }
+ return true;
+ }
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_DECODER_MULTI_CHANNEL_OPUS_CONFIG_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build
new file mode 100644
index 0000000000..2b2bc6d9a7
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build
@@ -0,0 +1,226 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/media/libopus/include/",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_decoder_multiopus_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.cc b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.cc
new file mode 100644
index 0000000000..efc9a73546
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.cc
@@ -0,0 +1,86 @@
+/*
+ * 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 "api/audio_codecs/opus/audio_decoder_opus.h"
+
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "absl/strings/match.h"
+#include "modules/audio_coding/codecs/opus/audio_decoder_opus.h"
+
+namespace webrtc {
+
+bool AudioDecoderOpus::Config::IsOk() const {
+ if (sample_rate_hz != 16000 && sample_rate_hz != 48000) {
+ // Unsupported sample rate. (libopus supports a few other rates as
+ // well; we can add support for them when needed.)
+ return false;
+ }
+ if (num_channels != 1 && num_channels != 2) {
+ return false;
+ }
+ return true;
+}
+
+absl::optional<AudioDecoderOpus::Config> AudioDecoderOpus::SdpToConfig(
+ const SdpAudioFormat& format) {
+ const auto num_channels = [&]() -> absl::optional<int> {
+ auto stereo = format.parameters.find("stereo");
+ if (stereo != format.parameters.end()) {
+ if (stereo->second == "0") {
+ return 1;
+ } else if (stereo->second == "1") {
+ return 2;
+ } else {
+ return absl::nullopt; // Bad stereo parameter.
+ }
+ }
+ return 1; // Default to mono.
+ }();
+ if (absl::EqualsIgnoreCase(format.name, "opus") &&
+ format.clockrate_hz == 48000 && format.num_channels == 2 &&
+ num_channels) {
+ Config config;
+ config.num_channels = *num_channels;
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return absl::nullopt;
+ }
+ return config;
+ } else {
+ return absl::nullopt;
+ }
+}
+
+void AudioDecoderOpus::AppendSupportedDecoders(
+ std::vector<AudioCodecSpec>* specs) {
+ AudioCodecInfo opus_info{48000, 1, 64000, 6000, 510000};
+ opus_info.allow_comfort_noise = false;
+ opus_info.supports_network_adaption = true;
+ SdpAudioFormat opus_format(
+ {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}});
+ specs->push_back({std::move(opus_format), opus_info});
+}
+
+std::unique_ptr<AudioDecoder> AudioDecoderOpus::MakeAudioDecoder(
+ Config config,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ return std::make_unique<AudioDecoderOpusImpl>(config.num_channels,
+ config.sample_rate_hz);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.h b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.h
new file mode 100644
index 0000000000..138c0377df
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.h
@@ -0,0 +1,44 @@
+/*
+ * 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 API_AUDIO_CODECS_OPUS_AUDIO_DECODER_OPUS_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_DECODER_OPUS_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// Opus decoder API for use as a template parameter to
+// CreateAudioDecoderFactory<...>().
+struct RTC_EXPORT AudioDecoderOpus {
+ struct Config {
+ bool IsOk() const; // Checks if the values are currently OK.
+ int sample_rate_hz = 48000;
+ int num_channels = 1;
+ };
+ static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ Config config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_DECODER_OPUS_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build
new file mode 100644
index 0000000000..e2c470d5ee
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build
@@ -0,0 +1,209 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_decoder_opus_config_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build
new file mode 100644
index 0000000000..58e6355a55
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build
@@ -0,0 +1,233 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/media/libopus/include/",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "rt"
+ ]
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "crypt32",
+ "iphlpapi",
+ "secur32",
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_decoder_opus_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc
new file mode 100644
index 0000000000..14f480b1ec
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2019 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 "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h"
+
+#include <utility>
+
+#include "modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h"
+
+namespace webrtc {
+
+absl::optional<AudioEncoderMultiChannelOpusConfig>
+AudioEncoderMultiChannelOpus::SdpToConfig(const SdpAudioFormat& format) {
+ return AudioEncoderMultiChannelOpusImpl::SdpToConfig(format);
+}
+
+void AudioEncoderMultiChannelOpus::AppendSupportedEncoders(
+ std::vector<AudioCodecSpec>* specs) {
+ // To get full utilization of the surround support of the Opus lib, we can
+ // mark which channel is the low frequency effects (LFE). But that is not done
+ // ATM.
+ {
+ AudioCodecInfo surround_5_1_opus_info{48000, 6,
+ /* default_bitrate_bps= */ 128000};
+ surround_5_1_opus_info.allow_comfort_noise = false;
+ surround_5_1_opus_info.supports_network_adaption = false;
+ SdpAudioFormat opus_format({"multiopus",
+ 48000,
+ 6,
+ {{"minptime", "10"},
+ {"useinbandfec", "1"},
+ {"channel_mapping", "0,4,1,2,3,5"},
+ {"num_streams", "4"},
+ {"coupled_streams", "2"}}});
+ specs->push_back({std::move(opus_format), surround_5_1_opus_info});
+ }
+ {
+ AudioCodecInfo surround_7_1_opus_info{48000, 8,
+ /* default_bitrate_bps= */ 200000};
+ surround_7_1_opus_info.allow_comfort_noise = false;
+ surround_7_1_opus_info.supports_network_adaption = false;
+ SdpAudioFormat opus_format({"multiopus",
+ 48000,
+ 8,
+ {{"minptime", "10"},
+ {"useinbandfec", "1"},
+ {"channel_mapping", "0,6,1,2,3,4,5,7"},
+ {"num_streams", "5"},
+ {"coupled_streams", "3"}}});
+ specs->push_back({std::move(opus_format), surround_7_1_opus_info});
+ }
+}
+
+AudioCodecInfo AudioEncoderMultiChannelOpus::QueryAudioEncoder(
+ const AudioEncoderMultiChannelOpusConfig& config) {
+ return AudioEncoderMultiChannelOpusImpl::QueryAudioEncoder(config);
+}
+
+std::unique_ptr<AudioEncoder> AudioEncoderMultiChannelOpus::MakeAudioEncoder(
+ const AudioEncoderMultiChannelOpusConfig& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ return AudioEncoderMultiChannelOpusImpl::MakeAudioEncoder(config,
+ payload_type);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h
new file mode 100644
index 0000000000..c1c4db3577
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2019 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 API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_MULTI_CHANNEL_OPUS_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_MULTI_CHANNEL_OPUS_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// Opus encoder API for use as a template parameter to
+// CreateAudioEncoderFactory<...>().
+struct RTC_EXPORT AudioEncoderMultiChannelOpus {
+ using Config = AudioEncoderMultiChannelOpusConfig;
+ static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
+ static AudioCodecInfo QueryAudioEncoder(const Config& config);
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_MULTI_CHANNEL_OPUS_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc
new file mode 100644
index 0000000000..0052c429b2
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2019 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 "api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h"
+
+namespace webrtc {
+
+namespace {
+constexpr int kDefaultComplexity = 9;
+} // namespace
+
+AudioEncoderMultiChannelOpusConfig::AudioEncoderMultiChannelOpusConfig()
+ : frame_size_ms(kDefaultFrameSizeMs),
+ num_channels(1),
+ application(ApplicationMode::kVoip),
+ bitrate_bps(32000),
+ fec_enabled(false),
+ cbr_enabled(false),
+ dtx_enabled(false),
+ max_playback_rate_hz(48000),
+ complexity(kDefaultComplexity),
+ num_streams(-1),
+ coupled_streams(-1) {}
+AudioEncoderMultiChannelOpusConfig::AudioEncoderMultiChannelOpusConfig(
+ const AudioEncoderMultiChannelOpusConfig&) = default;
+AudioEncoderMultiChannelOpusConfig::~AudioEncoderMultiChannelOpusConfig() =
+ default;
+AudioEncoderMultiChannelOpusConfig& AudioEncoderMultiChannelOpusConfig::
+operator=(const AudioEncoderMultiChannelOpusConfig&) = default;
+
+bool AudioEncoderMultiChannelOpusConfig::IsOk() const {
+ if (frame_size_ms <= 0 || frame_size_ms % 10 != 0)
+ return false;
+ if (num_channels >= 255) {
+ return false;
+ }
+ if (bitrate_bps < kMinBitrateBps || bitrate_bps > kMaxBitrateBps)
+ return false;
+ if (complexity < 0 || complexity > 10)
+ return false;
+
+ // Check the lengths:
+ if (num_streams < 0 || coupled_streams < 0) {
+ return false;
+ }
+ if (num_streams < coupled_streams) {
+ return false;
+ }
+ if (channel_mapping.size() != static_cast<size_t>(num_channels)) {
+ return false;
+ }
+
+ // Every mono stream codes one channel, every coupled stream codes two. This
+ // is the total coded channel count:
+ const int max_coded_channel = num_streams + coupled_streams;
+ for (const auto& x : channel_mapping) {
+ // Coded channels >= max_coded_channel don't exist. Except for 255, which
+ // tells Opus to ignore input channel x.
+ if (x >= max_coded_channel && x != 255) {
+ return false;
+ }
+ }
+
+ // Inverse mapping.
+ constexpr int kNotSet = -1;
+ std::vector<int> coded_channels_to_input_channels(max_coded_channel, kNotSet);
+ for (size_t i = 0; i < num_channels; ++i) {
+ if (channel_mapping[i] == 255) {
+ continue;
+ }
+
+ // If it's not ignored, put it in the inverted mapping. But first check if
+ // we've told Opus to use another input channel for this coded channel:
+ const int coded_channel = channel_mapping[i];
+ if (coded_channels_to_input_channels[coded_channel] != kNotSet) {
+ // Coded channel `coded_channel` comes from both input channels
+ // `coded_channels_to_input_channels[coded_channel]` and `i`.
+ return false;
+ }
+
+ coded_channels_to_input_channels[coded_channel] = i;
+ }
+
+ // Check that we specified what input the encoder should use to produce
+ // every coded channel.
+ for (int i = 0; i < max_coded_channel; ++i) {
+ if (coded_channels_to_input_channels[i] == kNotSet) {
+ // Coded channel `i` has unspecified input channel.
+ return false;
+ }
+ }
+
+ if (num_channels > 255 || max_coded_channel >= 255) {
+ return false;
+ }
+ return true;
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h
new file mode 100644
index 0000000000..9b51246c15
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2019 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 API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_MULTI_CHANNEL_OPUS_CONFIG_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_MULTI_CHANNEL_OPUS_CONFIG_H_
+
+#include <stddef.h>
+
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/opus/audio_encoder_opus_config.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+struct RTC_EXPORT AudioEncoderMultiChannelOpusConfig {
+ static constexpr int kDefaultFrameSizeMs = 20;
+
+ // Opus API allows a min bitrate of 500bps, but Opus documentation suggests
+ // bitrate should be in the range of 6000 to 510000, inclusive.
+ static constexpr int kMinBitrateBps = 6000;
+ static constexpr int kMaxBitrateBps = 510000;
+
+ AudioEncoderMultiChannelOpusConfig();
+ AudioEncoderMultiChannelOpusConfig(const AudioEncoderMultiChannelOpusConfig&);
+ ~AudioEncoderMultiChannelOpusConfig();
+ AudioEncoderMultiChannelOpusConfig& operator=(
+ const AudioEncoderMultiChannelOpusConfig&);
+
+ int frame_size_ms;
+ size_t num_channels;
+ enum class ApplicationMode { kVoip, kAudio };
+ ApplicationMode application;
+ int bitrate_bps;
+ bool fec_enabled;
+ bool cbr_enabled;
+ bool dtx_enabled;
+ int max_playback_rate_hz;
+ std::vector<int> supported_frame_lengths_ms;
+
+ int complexity;
+
+ // Number of mono/stereo Opus streams.
+ int num_streams;
+
+ // Number of channel pairs coupled together, see RFC 7845 section
+ // 5.1.1. Has to be less than the number of streams
+ int coupled_streams;
+
+ // Channel mapping table, defines the mapping from encoded streams to input
+ // channels. See RFC 7845 section 5.1.1.
+ std::vector<unsigned char> channel_mapping;
+
+ bool IsOk() const;
+};
+
+} // namespace webrtc
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_MULTI_CHANNEL_OPUS_CONFIG_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build
new file mode 100644
index 0000000000..91afd0a4e4
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build
@@ -0,0 +1,226 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/media/libopus/include/",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_multiopus_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.cc b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.cc
new file mode 100644
index 0000000000..5b6322da4c
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.cc
@@ -0,0 +1,44 @@
+/*
+ * 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 "api/audio_codecs/opus/audio_encoder_opus.h"
+
+#include "modules/audio_coding/codecs/opus/audio_encoder_opus.h"
+
+namespace webrtc {
+
+absl::optional<AudioEncoderOpusConfig> AudioEncoderOpus::SdpToConfig(
+ const SdpAudioFormat& format) {
+ return AudioEncoderOpusImpl::SdpToConfig(format);
+}
+
+void AudioEncoderOpus::AppendSupportedEncoders(
+ std::vector<AudioCodecSpec>* specs) {
+ AudioEncoderOpusImpl::AppendSupportedEncoders(specs);
+}
+
+AudioCodecInfo AudioEncoderOpus::QueryAudioEncoder(
+ const AudioEncoderOpusConfig& config) {
+ return AudioEncoderOpusImpl::QueryAudioEncoder(config);
+}
+
+std::unique_ptr<AudioEncoder> AudioEncoderOpus::MakeAudioEncoder(
+ const AudioEncoderOpusConfig& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/,
+ const FieldTrialsView* field_trials) {
+ if (!config.IsOk()) {
+ RTC_DCHECK_NOTREACHED();
+ return nullptr;
+ }
+ return AudioEncoderOpusImpl::MakeAudioEncoder(config, payload_type);
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.h b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.h
new file mode 100644
index 0000000000..df93ae5303
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.h
@@ -0,0 +1,44 @@
+/*
+ * 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 API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
+
+#include <memory>
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "api/audio_codecs/opus/audio_encoder_opus_config.h"
+#include "api/field_trials_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+// Opus encoder API for use as a template parameter to
+// CreateAudioEncoderFactory<...>().
+struct RTC_EXPORT AudioEncoderOpus {
+ using Config = AudioEncoderOpusConfig;
+ static absl::optional<AudioEncoderOpusConfig> SdpToConfig(
+ const SdpAudioFormat& audio_format);
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
+ static AudioCodecInfo QueryAudioEncoder(const AudioEncoderOpusConfig& config);
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const AudioEncoderOpusConfig& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr);
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc
new file mode 100644
index 0000000000..a9ab924b38
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc
@@ -0,0 +1,75 @@
+/*
+ * 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 "api/audio_codecs/opus/audio_encoder_opus_config.h"
+
+namespace webrtc {
+
+namespace {
+
+#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
+constexpr int kDefaultComplexity = 5;
+#else
+constexpr int kDefaultComplexity = 9;
+#endif
+
+constexpr int kDefaultLowRateComplexity =
+ WEBRTC_OPUS_VARIABLE_COMPLEXITY ? 9 : kDefaultComplexity;
+
+} // namespace
+
+constexpr int AudioEncoderOpusConfig::kDefaultFrameSizeMs;
+constexpr int AudioEncoderOpusConfig::kMinBitrateBps;
+constexpr int AudioEncoderOpusConfig::kMaxBitrateBps;
+
+AudioEncoderOpusConfig::AudioEncoderOpusConfig()
+ : frame_size_ms(kDefaultFrameSizeMs),
+ sample_rate_hz(48000),
+ num_channels(1),
+ application(ApplicationMode::kVoip),
+ bitrate_bps(32000),
+ fec_enabled(false),
+ cbr_enabled(false),
+ max_playback_rate_hz(48000),
+ complexity(kDefaultComplexity),
+ low_rate_complexity(kDefaultLowRateComplexity),
+ complexity_threshold_bps(12500),
+ complexity_threshold_window_bps(1500),
+ dtx_enabled(false),
+ uplink_bandwidth_update_interval_ms(200),
+ payload_type(-1) {}
+AudioEncoderOpusConfig::AudioEncoderOpusConfig(const AudioEncoderOpusConfig&) =
+ default;
+AudioEncoderOpusConfig::~AudioEncoderOpusConfig() = default;
+AudioEncoderOpusConfig& AudioEncoderOpusConfig::operator=(
+ const AudioEncoderOpusConfig&) = default;
+
+bool AudioEncoderOpusConfig::IsOk() const {
+ if (frame_size_ms <= 0 || frame_size_ms % 10 != 0)
+ return false;
+ if (sample_rate_hz != 16000 && sample_rate_hz != 48000) {
+ // Unsupported input sample rate. (libopus supports a few other rates as
+ // well; we can add support for them when needed.)
+ return false;
+ }
+ if (num_channels >= 255) {
+ return false;
+ }
+ if (!bitrate_bps)
+ return false;
+ if (*bitrate_bps < kMinBitrateBps || *bitrate_bps > kMaxBitrateBps)
+ return false;
+ if (complexity < 0 || complexity > 10)
+ return false;
+ if (low_rate_complexity < 0 || low_rate_complexity > 10)
+ return false;
+ return true;
+}
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.h b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.h
new file mode 100644
index 0000000000..d5d7256c70
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.h
@@ -0,0 +1,74 @@
+/*
+ * 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 API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_OPUS_CONFIG_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_OPUS_CONFIG_H_
+
+#include <stddef.h>
+
+#include <vector>
+
+#include "absl/types/optional.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace webrtc {
+
+struct RTC_EXPORT AudioEncoderOpusConfig {
+ static constexpr int kDefaultFrameSizeMs = 20;
+
+ // Opus API allows a min bitrate of 500bps, but Opus documentation suggests
+ // bitrate should be in the range of 6000 to 510000, inclusive.
+ static constexpr int kMinBitrateBps = 6000;
+ static constexpr int kMaxBitrateBps = 510000;
+
+ AudioEncoderOpusConfig();
+ AudioEncoderOpusConfig(const AudioEncoderOpusConfig&);
+ ~AudioEncoderOpusConfig();
+ AudioEncoderOpusConfig& operator=(const AudioEncoderOpusConfig&);
+
+ bool IsOk() const; // Checks if the values are currently OK.
+
+ int frame_size_ms;
+ int sample_rate_hz;
+ size_t num_channels;
+ enum class ApplicationMode { kVoip, kAudio };
+ ApplicationMode application;
+
+ // NOTE: This member must always be set.
+ // TODO(kwiberg): Turn it into just an int.
+ absl::optional<int> bitrate_bps;
+
+ bool fec_enabled;
+ bool cbr_enabled;
+ int max_playback_rate_hz;
+
+ // `complexity` is used when the bitrate goes above
+ // `complexity_threshold_bps` + `complexity_threshold_window_bps`;
+ // `low_rate_complexity` is used when the bitrate falls below
+ // `complexity_threshold_bps` - `complexity_threshold_window_bps`. In the
+ // interval in the middle, we keep using the most recent of the two
+ // complexity settings.
+ int complexity;
+ int low_rate_complexity;
+ int complexity_threshold_bps;
+ int complexity_threshold_window_bps;
+
+ bool dtx_enabled;
+ std::vector<int> supported_frame_lengths_ms;
+ int uplink_bandwidth_update_interval_ms;
+
+ // NOTE: This member isn't necessary, and will soon go away. See
+ // https://bugs.chromium.org/p/webrtc/issues/detail?id=7847
+ int payload_type;
+};
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_OPUS_CONFIG_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build
new file mode 100644
index 0000000000..06732b48f4
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build
@@ -0,0 +1,222 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_OPUS_VARIABLE_COMPLEXITY"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_opus_config_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build
new file mode 100644
index 0000000000..ab84d3f755
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build
@@ -0,0 +1,233 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/media/libopus/include/",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "rt"
+ ]
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+ OS_LIBS += [
+ "crypt32",
+ "iphlpapi",
+ "secur32",
+ "winmm"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_encoder_opus_gn")
diff --git a/third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.cc b/third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.cc
new file mode 100644
index 0000000000..ed68f2584e
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.cc
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2019 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 "api/audio_codecs/opus_audio_decoder_factory.h"
+
+#include <memory>
+#include <vector>
+
+#include "api/audio_codecs/audio_decoder_factory_template.h"
+#include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h"
+#include "api/audio_codecs/opus/audio_decoder_opus.h"
+
+namespace webrtc {
+
+namespace {
+
+// Modify an audio decoder to not advertise support for anything.
+template <typename T>
+struct NotAdvertised {
+ using Config = typename T::Config;
+ static absl::optional<Config> SdpToConfig(
+ const SdpAudioFormat& audio_format) {
+ return T::SdpToConfig(audio_format);
+ }
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) {
+ // Don't advertise support for anything.
+ }
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const Config& config,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt) {
+ return T::MakeAudioDecoder(config, codec_pair_id);
+ }
+};
+
+} // namespace
+
+rtc::scoped_refptr<AudioDecoderFactory> CreateOpusAudioDecoderFactory() {
+ return CreateAudioDecoderFactory<
+ AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>>();
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.h b/third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.h
new file mode 100644
index 0000000000..b4f497f8ff
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus_audio_decoder_factory.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2019 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 API_AUDIO_CODECS_OPUS_AUDIO_DECODER_FACTORY_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_DECODER_FACTORY_H_
+
+#include "api/audio_codecs/audio_decoder_factory.h"
+#include "api/scoped_refptr.h"
+
+namespace webrtc {
+
+// Creates a new factory that can create only Opus audio decoders. Works like
+// CreateAudioDecoderFactory<AudioDecoderOpus>(), but is easier to use and is
+// not inline because it isn't a template.
+rtc::scoped_refptr<AudioDecoderFactory> CreateOpusAudioDecoderFactory();
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_DECODER_FACTORY_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.cc b/third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.cc
new file mode 100644
index 0000000000..8c286f21e1
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.cc
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2019 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 "api/audio_codecs/opus_audio_encoder_factory.h"
+
+#include <memory>
+#include <vector>
+
+#include "api/audio_codecs/audio_encoder_factory_template.h"
+#include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h"
+#include "api/audio_codecs/opus/audio_encoder_opus.h"
+
+namespace webrtc {
+namespace {
+
+// Modify an audio encoder to not advertise support for anything.
+template <typename T>
+struct NotAdvertised {
+ using Config = typename T::Config;
+ static absl::optional<Config> SdpToConfig(
+ const SdpAudioFormat& audio_format) {
+ return T::SdpToConfig(audio_format);
+ }
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {
+ // Don't advertise support for anything.
+ }
+ static AudioCodecInfo QueryAudioEncoder(const Config& config) {
+ return T::QueryAudioEncoder(config);
+ }
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const Config& config,
+ int payload_type,
+ absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
+ const FieldTrialsView* field_trials = nullptr) {
+ return T::MakeAudioEncoder(config, payload_type, codec_pair_id,
+ field_trials);
+ }
+};
+
+} // namespace
+
+rtc::scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory() {
+ return CreateAudioEncoderFactory<
+ AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>>();
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.h b/third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.h
new file mode 100644
index 0000000000..8c1683b6f5
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/opus_audio_encoder_factory.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2019 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 API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_FACTORY_H_
+#define API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_FACTORY_H_
+
+#include "api/audio_codecs/audio_encoder_factory.h"
+#include "api/scoped_refptr.h"
+
+namespace webrtc {
+
+// Creates a new factory that can create only Opus audio encoders. Works like
+// CreateAudioEncoderFactory<AudioEncoderOpus>(), but is easier to use and is
+// not inline because it isn't a template.
+rtc::scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory();
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_FACTORY_H_
diff --git a/third_party/libwebrtc/api/audio_codecs/test/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/test/BUILD.gn
new file mode 100644
index 0000000000..89f5fef1ea
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/test/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+import("../../../webrtc.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+}
+
+if (rtc_include_tests) {
+ rtc_library("audio_codecs_api_unittests") {
+ testonly = true
+ sources = [
+ "audio_decoder_factory_template_unittest.cc",
+ "audio_encoder_factory_template_unittest.cc",
+ ]
+ deps = [
+ "..:audio_codecs_api",
+ "../../../test:audio_codec_mocks",
+ "../../../test:scoped_key_value_config",
+ "../../../test:test_support",
+ "../L16:audio_decoder_L16",
+ "../L16:audio_encoder_L16",
+ "../g711:audio_decoder_g711",
+ "../g711:audio_encoder_g711",
+ "../g722:audio_decoder_g722",
+ "../g722:audio_encoder_g722",
+ "../ilbc:audio_decoder_ilbc",
+ "../ilbc:audio_encoder_ilbc",
+ "../opus:audio_decoder_opus",
+ "../opus:audio_encoder_opus",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc b/third_party/libwebrtc/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc
new file mode 100644
index 0000000000..0b18cf934a
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc
@@ -0,0 +1,222 @@
+/*
+ * 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 "api/audio_codecs/audio_decoder_factory_template.h"
+
+#include <memory>
+
+#include "api/audio_codecs/L16/audio_decoder_L16.h"
+#include "api/audio_codecs/g711/audio_decoder_g711.h"
+#include "api/audio_codecs/g722/audio_decoder_g722.h"
+#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h"
+#include "api/audio_codecs/opus/audio_decoder_opus.h"
+#include "test/gmock.h"
+#include "test/gtest.h"
+#include "test/mock_audio_decoder.h"
+#include "test/scoped_key_value_config.h"
+
+namespace webrtc {
+
+namespace {
+
+struct BogusParams {
+ static SdpAudioFormat AudioFormat() { return {"bogus", 8000, 1}; }
+ static AudioCodecInfo CodecInfo() { return {8000, 1, 12345}; }
+};
+
+struct ShamParams {
+ static SdpAudioFormat AudioFormat() {
+ return {"sham", 16000, 2, {{"param", "value"}}};
+ }
+ static AudioCodecInfo CodecInfo() { return {16000, 2, 23456}; }
+};
+
+template <typename Params>
+struct AudioDecoderFakeApi {
+ struct Config {
+ SdpAudioFormat audio_format;
+ };
+
+ static absl::optional<Config> SdpToConfig(
+ const SdpAudioFormat& audio_format) {
+ if (Params::AudioFormat() == audio_format) {
+ Config config = {audio_format};
+ return config;
+ } else {
+ return absl::nullopt;
+ }
+ }
+
+ static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs) {
+ specs->push_back({Params::AudioFormat(), Params::CodecInfo()});
+ }
+
+ static AudioCodecInfo QueryAudioDecoder(const Config&) {
+ return Params::CodecInfo();
+ }
+
+ static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
+ const Config&,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/ = absl::nullopt) {
+ auto dec = std::make_unique<testing::StrictMock<MockAudioDecoder>>();
+ EXPECT_CALL(*dec, SampleRateHz())
+ .WillOnce(::testing::Return(Params::CodecInfo().sample_rate_hz));
+ EXPECT_CALL(*dec, Die());
+ return std::move(dec);
+ }
+};
+
+} // namespace
+
+TEST(AudioDecoderFactoryTemplateTest, NoDecoderTypes) {
+ test::ScopedKeyValueConfig field_trials;
+ rtc::scoped_refptr<AudioDecoderFactory> factory(
+ rtc::make_ref_counted<
+ audio_decoder_factory_template_impl::AudioDecoderFactoryT<>>(
+ &field_trials));
+ EXPECT_THAT(factory->GetSupportedDecoders(), ::testing::IsEmpty());
+ EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+}
+
+TEST(AudioDecoderFactoryTemplateTest, OneDecoderType) {
+ auto factory = CreateAudioDecoderFactory<AudioDecoderFakeApi<BogusParams>>();
+ EXPECT_THAT(factory->GetSupportedDecoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"bogus", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+ auto dec = factory->MakeAudioDecoder({"bogus", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, dec);
+ EXPECT_EQ(8000, dec->SampleRateHz());
+}
+
+TEST(AudioDecoderFactoryTemplateTest, TwoDecoderTypes) {
+ auto factory = CreateAudioDecoderFactory<AudioDecoderFakeApi<BogusParams>,
+ AudioDecoderFakeApi<ShamParams>>();
+ EXPECT_THAT(factory->GetSupportedDecoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}},
+ AudioCodecSpec{{"sham", 16000, 2, {{"param", "value"}}},
+ {16000, 2, 23456}}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"bogus", 8000, 1}));
+ EXPECT_TRUE(
+ factory->IsSupportedDecoder({"sham", 16000, 2, {{"param", "value"}}}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+ auto dec1 = factory->MakeAudioDecoder({"bogus", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, dec1);
+ EXPECT_EQ(8000, dec1->SampleRateHz());
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"sham", 16000, 2}, absl::nullopt));
+ auto dec2 = factory->MakeAudioDecoder(
+ {"sham", 16000, 2, {{"param", "value"}}}, absl::nullopt);
+ ASSERT_NE(nullptr, dec2);
+ EXPECT_EQ(16000, dec2->SampleRateHz());
+}
+
+TEST(AudioDecoderFactoryTemplateTest, G711) {
+ auto factory = CreateAudioDecoderFactory<AudioDecoderG711>();
+ EXPECT_THAT(factory->GetSupportedDecoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"PCMU", 8000, 1}, {8000, 1, 64000}},
+ AudioCodecSpec{{"PCMA", 8000, 1}, {8000, 1, 64000}}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"G711", 8000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"PCMU", 8000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"pcma", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"pcmu", 16000, 1}, absl::nullopt));
+ auto dec1 = factory->MakeAudioDecoder({"pcmu", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, dec1);
+ EXPECT_EQ(8000, dec1->SampleRateHz());
+ auto dec2 = factory->MakeAudioDecoder({"PCMA", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, dec2);
+ EXPECT_EQ(8000, dec2->SampleRateHz());
+}
+
+TEST(AudioDecoderFactoryTemplateTest, G722) {
+ auto factory = CreateAudioDecoderFactory<AudioDecoderG722>();
+ EXPECT_THAT(factory->GetSupportedDecoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"G722", 8000, 1}, {16000, 1, 64000}}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"G722", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+ auto dec1 = factory->MakeAudioDecoder({"G722", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, dec1);
+ EXPECT_EQ(16000, dec1->SampleRateHz());
+ EXPECT_EQ(1u, dec1->Channels());
+ auto dec2 = factory->MakeAudioDecoder({"G722", 8000, 2}, absl::nullopt);
+ ASSERT_NE(nullptr, dec2);
+ EXPECT_EQ(16000, dec2->SampleRateHz());
+ EXPECT_EQ(2u, dec2->Channels());
+ auto dec3 = factory->MakeAudioDecoder({"G722", 8000, 3}, absl::nullopt);
+ ASSERT_EQ(nullptr, dec3);
+}
+
+TEST(AudioDecoderFactoryTemplateTest, Ilbc) {
+ auto factory = CreateAudioDecoderFactory<AudioDecoderIlbc>();
+ EXPECT_THAT(factory->GetSupportedDecoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13300}}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"ilbc", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"bar", 8000, 1}, absl::nullopt));
+ auto dec = factory->MakeAudioDecoder({"ilbc", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, dec);
+ EXPECT_EQ(8000, dec->SampleRateHz());
+}
+
+TEST(AudioDecoderFactoryTemplateTest, L16) {
+ auto factory = CreateAudioDecoderFactory<AudioDecoderL16>();
+ EXPECT_THAT(
+ factory->GetSupportedDecoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}},
+ AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}},
+ AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}},
+ AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}},
+ AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}},
+ AudioCodecSpec{{"L16", 32000, 2}, {32000, 2, 32000 * 16 * 2}}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"L16", 48000, 1}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"L16", 96000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"L16", 8000, 0}, absl::nullopt));
+ auto dec = factory->MakeAudioDecoder({"L16", 48000, 2}, absl::nullopt);
+ ASSERT_NE(nullptr, dec);
+ EXPECT_EQ(48000, dec->SampleRateHz());
+}
+
+TEST(AudioDecoderFactoryTemplateTest, Opus) {
+ auto factory = CreateAudioDecoderFactory<AudioDecoderOpus>();
+ AudioCodecInfo opus_info{48000, 1, 64000, 6000, 510000};
+ opus_info.allow_comfort_noise = false;
+ opus_info.supports_network_adaption = true;
+ const SdpAudioFormat opus_format(
+ {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}});
+ EXPECT_THAT(factory->GetSupportedDecoders(),
+ ::testing::ElementsAre(AudioCodecSpec{opus_format, opus_info}));
+ EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1}));
+ EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioDecoder({"bar", 16000, 1}, absl::nullopt));
+ auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}, absl::nullopt);
+ ASSERT_NE(nullptr, dec);
+ EXPECT_EQ(48000, dec->SampleRateHz());
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc b/third_party/libwebrtc/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
new file mode 100644
index 0000000000..dbba387724
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
@@ -0,0 +1,224 @@
+/*
+ * 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 "api/audio_codecs/audio_encoder_factory_template.h"
+
+#include <memory>
+
+#include "api/audio_codecs/L16/audio_encoder_L16.h"
+#include "api/audio_codecs/g711/audio_encoder_g711.h"
+#include "api/audio_codecs/g722/audio_encoder_g722.h"
+#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h"
+#include "api/audio_codecs/opus/audio_encoder_opus.h"
+#include "test/gmock.h"
+#include "test/gtest.h"
+#include "test/mock_audio_encoder.h"
+#include "test/scoped_key_value_config.h"
+
+namespace webrtc {
+
+namespace {
+
+struct BogusParams {
+ static SdpAudioFormat AudioFormat() { return {"bogus", 8000, 1}; }
+ static AudioCodecInfo CodecInfo() { return {8000, 1, 12345}; }
+};
+
+struct ShamParams {
+ static SdpAudioFormat AudioFormat() {
+ return {"sham", 16000, 2, {{"param", "value"}}};
+ }
+ static AudioCodecInfo CodecInfo() { return {16000, 2, 23456}; }
+};
+
+template <typename Params>
+struct AudioEncoderFakeApi {
+ struct Config {
+ SdpAudioFormat audio_format;
+ };
+
+ static absl::optional<Config> SdpToConfig(
+ const SdpAudioFormat& audio_format) {
+ if (Params::AudioFormat() == audio_format) {
+ Config config = {audio_format};
+ return config;
+ } else {
+ return absl::nullopt;
+ }
+ }
+
+ static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs) {
+ specs->push_back({Params::AudioFormat(), Params::CodecInfo()});
+ }
+
+ static AudioCodecInfo QueryAudioEncoder(const Config&) {
+ return Params::CodecInfo();
+ }
+
+ static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
+ const Config&,
+ int payload_type,
+ absl::optional<AudioCodecPairId> /*codec_pair_id*/ = absl::nullopt) {
+ auto enc = std::make_unique<testing::StrictMock<MockAudioEncoder>>();
+ EXPECT_CALL(*enc, SampleRateHz())
+ .WillOnce(::testing::Return(Params::CodecInfo().sample_rate_hz));
+ return std::move(enc);
+ }
+};
+
+} // namespace
+
+TEST(AudioEncoderFactoryTemplateTest, NoEncoderTypes) {
+ test::ScopedKeyValueConfig field_trials;
+ rtc::scoped_refptr<AudioEncoderFactory> factory(
+ rtc::make_ref_counted<
+ audio_encoder_factory_template_impl::AudioEncoderFactoryT<>>(
+ &field_trials));
+ EXPECT_THAT(factory->GetSupportedEncoders(), ::testing::IsEmpty());
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+}
+
+TEST(AudioEncoderFactoryTemplateTest, OneEncoderType) {
+ auto factory = CreateAudioEncoderFactory<AudioEncoderFakeApi<BogusParams>>();
+ EXPECT_THAT(factory->GetSupportedEncoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}}));
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+ EXPECT_EQ(AudioCodecInfo(8000, 1, 12345),
+ factory->QueryAudioEncoder({"bogus", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+ auto enc = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, enc);
+ EXPECT_EQ(8000, enc->SampleRateHz());
+}
+
+TEST(AudioEncoderFactoryTemplateTest, TwoEncoderTypes) {
+ auto factory = CreateAudioEncoderFactory<AudioEncoderFakeApi<BogusParams>,
+ AudioEncoderFakeApi<ShamParams>>();
+ EXPECT_THAT(factory->GetSupportedEncoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}},
+ AudioCodecSpec{{"sham", 16000, 2, {{"param", "value"}}},
+ {16000, 2, 23456}}));
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+ EXPECT_EQ(AudioCodecInfo(8000, 1, 12345),
+ factory->QueryAudioEncoder({"bogus", 8000, 1}));
+ EXPECT_EQ(
+ AudioCodecInfo(16000, 2, 23456),
+ factory->QueryAudioEncoder({"sham", 16000, 2, {{"param", "value"}}}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+ auto enc1 = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, enc1);
+ EXPECT_EQ(8000, enc1->SampleRateHz());
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"sham", 16000, 2}, absl::nullopt));
+ auto enc2 = factory->MakeAudioEncoder(
+ 17, {"sham", 16000, 2, {{"param", "value"}}}, absl::nullopt);
+ ASSERT_NE(nullptr, enc2);
+ EXPECT_EQ(16000, enc2->SampleRateHz());
+}
+
+TEST(AudioEncoderFactoryTemplateTest, G711) {
+ auto factory = CreateAudioEncoderFactory<AudioEncoderG711>();
+ EXPECT_THAT(factory->GetSupportedEncoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"PCMU", 8000, 1}, {8000, 1, 64000}},
+ AudioCodecSpec{{"PCMA", 8000, 1}, {8000, 1, 64000}}));
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"PCMA", 16000, 1}));
+ EXPECT_EQ(AudioCodecInfo(8000, 1, 64000),
+ factory->QueryAudioEncoder({"PCMA", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"PCMU", 16000, 1}, absl::nullopt));
+ auto enc1 = factory->MakeAudioEncoder(17, {"PCMU", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, enc1);
+ EXPECT_EQ(8000, enc1->SampleRateHz());
+ auto enc2 = factory->MakeAudioEncoder(17, {"PCMA", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, enc2);
+ EXPECT_EQ(8000, enc2->SampleRateHz());
+}
+
+TEST(AudioEncoderFactoryTemplateTest, G722) {
+ auto factory = CreateAudioEncoderFactory<AudioEncoderG722>();
+ EXPECT_THAT(factory->GetSupportedEncoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"G722", 8000, 1}, {16000, 1, 64000}}));
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+ EXPECT_EQ(AudioCodecInfo(16000, 1, 64000),
+ factory->QueryAudioEncoder({"G722", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+ auto enc = factory->MakeAudioEncoder(17, {"G722", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, enc);
+ EXPECT_EQ(16000, enc->SampleRateHz());
+}
+
+TEST(AudioEncoderFactoryTemplateTest, Ilbc) {
+ auto factory = CreateAudioEncoderFactory<AudioEncoderIlbc>();
+ EXPECT_THAT(factory->GetSupportedEncoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13333}}));
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+ EXPECT_EQ(AudioCodecInfo(8000, 1, 13333),
+ factory->QueryAudioEncoder({"ilbc", 8000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"bar", 8000, 1}, absl::nullopt));
+ auto enc = factory->MakeAudioEncoder(17, {"ilbc", 8000, 1}, absl::nullopt);
+ ASSERT_NE(nullptr, enc);
+ EXPECT_EQ(8000, enc->SampleRateHz());
+}
+
+TEST(AudioEncoderFactoryTemplateTest, L16) {
+ auto factory = CreateAudioEncoderFactory<AudioEncoderL16>();
+ EXPECT_THAT(
+ factory->GetSupportedEncoders(),
+ ::testing::ElementsAre(
+ AudioCodecSpec{{"L16", 8000, 1}, {8000, 1, 8000 * 16}},
+ AudioCodecSpec{{"L16", 16000, 1}, {16000, 1, 16000 * 16}},
+ AudioCodecSpec{{"L16", 32000, 1}, {32000, 1, 32000 * 16}},
+ AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}},
+ AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}},
+ AudioCodecSpec{{"L16", 32000, 2}, {32000, 2, 32000 * 16 * 2}}));
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"L16", 8000, 0}));
+ EXPECT_EQ(AudioCodecInfo(48000, 1, 48000 * 16),
+ factory->QueryAudioEncoder({"L16", 48000, 1}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"L16", 8000, 0}, absl::nullopt));
+ auto enc = factory->MakeAudioEncoder(17, {"L16", 48000, 2}, absl::nullopt);
+ ASSERT_NE(nullptr, enc);
+ EXPECT_EQ(48000, enc->SampleRateHz());
+}
+
+TEST(AudioEncoderFactoryTemplateTest, Opus) {
+ auto factory = CreateAudioEncoderFactory<AudioEncoderOpus>();
+ AudioCodecInfo info = {48000, 1, 32000, 6000, 510000};
+ info.allow_comfort_noise = false;
+ info.supports_network_adaption = true;
+ EXPECT_THAT(
+ factory->GetSupportedEncoders(),
+ ::testing::ElementsAre(AudioCodecSpec{
+ {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}},
+ info}));
+ EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));
+ EXPECT_EQ(
+ info,
+ factory->QueryAudioEncoder(
+ {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}));
+ EXPECT_EQ(nullptr,
+ factory->MakeAudioEncoder(17, {"bar", 16000, 1}, absl::nullopt));
+ auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}, absl::nullopt);
+ ASSERT_NE(nullptr, enc);
+ EXPECT_EQ(48000, enc->SampleRateHz());
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/audio_options.cc b/third_party/libwebrtc/api/audio_options.cc
new file mode 100644
index 0000000000..658515062c
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_options.cc
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2018 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 "api/audio_options.h"
+
+#include "api/array_view.h"
+#include "rtc_base/strings/string_builder.h"
+
+namespace cricket {
+namespace {
+
+template <class T>
+void ToStringIfSet(rtc::SimpleStringBuilder* result,
+ const char* key,
+ const absl::optional<T>& val) {
+ if (val) {
+ (*result) << key << ": " << *val << ", ";
+ }
+}
+
+template <typename T>
+void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) {
+ if (o) {
+ *s = o;
+ }
+}
+
+} // namespace
+
+AudioOptions::AudioOptions() = default;
+AudioOptions::~AudioOptions() = default;
+
+void AudioOptions::SetAll(const AudioOptions& change) {
+ SetFrom(&echo_cancellation, change.echo_cancellation);
+#if defined(WEBRTC_IOS)
+ SetFrom(&ios_force_software_aec_HACK, change.ios_force_software_aec_HACK);
+#endif
+ SetFrom(&auto_gain_control, change.auto_gain_control);
+ SetFrom(&noise_suppression, change.noise_suppression);
+ SetFrom(&highpass_filter, change.highpass_filter);
+ SetFrom(&stereo_swapping, change.stereo_swapping);
+ SetFrom(&audio_jitter_buffer_max_packets,
+ change.audio_jitter_buffer_max_packets);
+ SetFrom(&audio_jitter_buffer_fast_accelerate,
+ change.audio_jitter_buffer_fast_accelerate);
+ SetFrom(&audio_jitter_buffer_min_delay_ms,
+ change.audio_jitter_buffer_min_delay_ms);
+ SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe);
+ SetFrom(&audio_network_adaptor, change.audio_network_adaptor);
+ SetFrom(&audio_network_adaptor_config, change.audio_network_adaptor_config);
+ SetFrom(&init_recording_on_send, change.init_recording_on_send);
+}
+
+bool AudioOptions::operator==(const AudioOptions& o) const {
+ return echo_cancellation == o.echo_cancellation &&
+#if defined(WEBRTC_IOS)
+ ios_force_software_aec_HACK == o.ios_force_software_aec_HACK &&
+#endif
+ auto_gain_control == o.auto_gain_control &&
+ noise_suppression == o.noise_suppression &&
+ highpass_filter == o.highpass_filter &&
+ stereo_swapping == o.stereo_swapping &&
+ audio_jitter_buffer_max_packets == o.audio_jitter_buffer_max_packets &&
+ audio_jitter_buffer_fast_accelerate ==
+ o.audio_jitter_buffer_fast_accelerate &&
+ audio_jitter_buffer_min_delay_ms ==
+ o.audio_jitter_buffer_min_delay_ms &&
+ combined_audio_video_bwe == o.combined_audio_video_bwe &&
+ audio_network_adaptor == o.audio_network_adaptor &&
+ audio_network_adaptor_config == o.audio_network_adaptor_config &&
+ init_recording_on_send == o.init_recording_on_send;
+}
+
+std::string AudioOptions::ToString() const {
+ char buffer[1024];
+ rtc::SimpleStringBuilder result(buffer);
+ result << "AudioOptions {";
+ ToStringIfSet(&result, "aec", echo_cancellation);
+#if defined(WEBRTC_IOS)
+ ToStringIfSet(&result, "ios_force_software_aec_HACK",
+ ios_force_software_aec_HACK);
+#endif
+ ToStringIfSet(&result, "agc", auto_gain_control);
+ ToStringIfSet(&result, "ns", noise_suppression);
+ ToStringIfSet(&result, "hf", highpass_filter);
+ ToStringIfSet(&result, "swap", stereo_swapping);
+ ToStringIfSet(&result, "audio_jitter_buffer_max_packets",
+ audio_jitter_buffer_max_packets);
+ ToStringIfSet(&result, "audio_jitter_buffer_fast_accelerate",
+ audio_jitter_buffer_fast_accelerate);
+ ToStringIfSet(&result, "audio_jitter_buffer_min_delay_ms",
+ audio_jitter_buffer_min_delay_ms);
+ ToStringIfSet(&result, "combined_audio_video_bwe", combined_audio_video_bwe);
+ ToStringIfSet(&result, "audio_network_adaptor", audio_network_adaptor);
+ ToStringIfSet(&result, "init_recording_on_send", init_recording_on_send);
+ result << "}";
+ return result.str();
+}
+
+} // namespace cricket
diff --git a/third_party/libwebrtc/api/audio_options.h b/third_party/libwebrtc/api/audio_options.h
new file mode 100644
index 0000000000..39ba3886ea
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_options.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2018 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 API_AUDIO_OPTIONS_H_
+#define API_AUDIO_OPTIONS_H_
+
+#include <stdint.h>
+
+#include <string>
+
+#include "absl/types/optional.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace cricket {
+
+// Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine.
+// Used to be flags, but that makes it hard to selectively apply options.
+// We are moving all of the setting of options to structs like this,
+// but some things currently still use flags.
+struct RTC_EXPORT AudioOptions {
+ AudioOptions();
+ ~AudioOptions();
+ void SetAll(const AudioOptions& change);
+
+ bool operator==(const AudioOptions& o) const;
+ bool operator!=(const AudioOptions& o) const { return !(*this == o); }
+
+ std::string ToString() const;
+
+ // Audio processing that attempts to filter away the output signal from
+ // later inbound pickup.
+ absl::optional<bool> echo_cancellation;
+#if defined(WEBRTC_IOS)
+ // Forces software echo cancellation on iOS. This is a temporary workaround
+ // (until Apple fixes the bug) for a device with non-functioning AEC. May
+ // improve performance on that particular device, but will cause unpredictable
+ // behavior in all other cases. See http://bugs.webrtc.org/8682.
+ absl::optional<bool> ios_force_software_aec_HACK;
+#endif
+ // Audio processing to adjust the sensitivity of the local mic dynamically.
+ absl::optional<bool> auto_gain_control;
+ // Audio processing to filter out background noise.
+ absl::optional<bool> noise_suppression;
+ // Audio processing to remove background noise of lower frequencies.
+ absl::optional<bool> highpass_filter;
+ // Audio processing to swap the left and right channels.
+ absl::optional<bool> stereo_swapping;
+ // Audio receiver jitter buffer (NetEq) max capacity in number of packets.
+ absl::optional<int> audio_jitter_buffer_max_packets;
+ // Audio receiver jitter buffer (NetEq) fast accelerate mode.
+ absl::optional<bool> audio_jitter_buffer_fast_accelerate;
+ // Audio receiver jitter buffer (NetEq) minimum target delay in milliseconds.
+ absl::optional<int> audio_jitter_buffer_min_delay_ms;
+ // Enable combined audio+bandwidth BWE.
+ // TODO(pthatcher): This flag is set from the
+ // "googCombinedAudioVideoBwe", but not used anywhere. So delete it,
+ // and check if any other AudioOptions members are unused.
+ absl::optional<bool> combined_audio_video_bwe;
+ // Enable audio network adaptor.
+ // TODO(webrtc:11717): Remove this API in favor of adaptivePtime in
+ // RtpEncodingParameters.
+ absl::optional<bool> audio_network_adaptor;
+ // Config string for audio network adaptor.
+ absl::optional<std::string> audio_network_adaptor_config;
+ // Pre-initialize the ADM for recording when starting to send. Default to
+ // true.
+ // TODO(webrtc:13566): Remove this option. See issue for details.
+ absl::optional<bool> init_recording_on_send;
+};
+
+} // namespace cricket
+
+#endif // API_AUDIO_OPTIONS_H_
diff --git a/third_party/libwebrtc/api/audio_options_api_gn/moz.build b/third_party/libwebrtc/api/audio_options_api_gn/moz.build
new file mode 100644
index 0000000000..1b19c42e98
--- /dev/null
+++ b/third_party/libwebrtc/api/audio_options_api_gn/moz.build
@@ -0,0 +1,221 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+
+ ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ###
+ ### DO NOT edit it by hand. ###
+
+COMPILE_FLAGS["OS_INCLUDES"] = []
+AllowCompilerWarnings()
+
+DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1"
+DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True
+DEFINES["RTC_ENABLE_VP9"] = True
+DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0"
+DEFINES["WEBRTC_LIBRARY_IMPL"] = True
+DEFINES["WEBRTC_MOZILLA_BUILD"] = True
+DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0"
+DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0"
+
+FINAL_LIBRARY = "webrtc"
+
+
+LOCAL_INCLUDES += [
+ "!/ipc/ipdl/_ipdlheaders",
+ "!/third_party/libwebrtc/gen",
+ "/ipc/chromium/src",
+ "/third_party/libwebrtc/",
+ "/third_party/libwebrtc/third_party/abseil-cpp/",
+ "/tools/profiler/public"
+]
+
+UNIFIED_SOURCES += [
+ "/third_party/libwebrtc/api/audio_options.cc"
+]
+
+if not CONFIG["MOZ_DEBUG"]:
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0"
+ DEFINES["NDEBUG"] = True
+ DEFINES["NVALGRIND"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1":
+
+ DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1"
+
+if CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["ANDROID"] = True
+ DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1"
+ DEFINES["HAVE_SYS_UIO_H"] = True
+ DEFINES["WEBRTC_ANDROID"] = True
+ DEFINES["WEBRTC_ANDROID_OPENSLES"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_GNU_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+ OS_LIBS += [
+ "log"
+ ]
+
+if CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["WEBRTC_MAC"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True
+ DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0"
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_NSS_CERTS"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_UDEV"] = True
+ DEFINES["WEBRTC_LINUX"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["USE_GLIB"] = "1"
+ DEFINES["USE_OZONE"] = "1"
+ DEFINES["USE_X11"] = "1"
+ DEFINES["WEBRTC_BSD"] = True
+ DEFINES["WEBRTC_POSIX"] = True
+ DEFINES["_FILE_OFFSET_BITS"] = "64"
+ DEFINES["_LARGEFILE64_SOURCE"] = True
+ DEFINES["_LARGEFILE_SOURCE"] = True
+ DEFINES["__STDC_CONSTANT_MACROS"] = True
+ DEFINES["__STDC_FORMAT_MACROS"] = True
+
+if CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True
+ DEFINES["NOMINMAX"] = True
+ DEFINES["NTDDI_VERSION"] = "0x0A000000"
+ DEFINES["PSAPI_VERSION"] = "2"
+ DEFINES["UNICODE"] = True
+ DEFINES["USE_AURA"] = "1"
+ DEFINES["WEBRTC_WIN"] = True
+ DEFINES["WIN32"] = True
+ DEFINES["WIN32_LEAN_AND_MEAN"] = True
+ DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP"
+ DEFINES["WINVER"] = "0x0A00"
+ DEFINES["_ATL_NO_OPENGL"] = True
+ DEFINES["_CRT_RAND_S"] = True
+ DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
+ DEFINES["_HAS_EXCEPTIONS"] = "0"
+ DEFINES["_HAS_NODISCARD"] = True
+ DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True
+ DEFINES["_SECURE_ATL"] = True
+ DEFINES["_UNICODE"] = True
+ DEFINES["_WIN32_WINNT"] = "0x0A00"
+ DEFINES["_WINDOWS"] = True
+ DEFINES["__STD_C"] = True
+
+if CONFIG["CPU_ARCH"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "arm":
+
+ CXXFLAGS += [
+ "-mfpu=neon"
+ ]
+
+ DEFINES["WEBRTC_ARCH_ARM"] = True
+ DEFINES["WEBRTC_ARCH_ARM_V7"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["CPU_ARCH"] == "mips32":
+
+ DEFINES["MIPS32_LE"] = True
+ DEFINES["MIPS_FPU_LE"] = True
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "mips64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64":
+
+ DEFINES["WEBRTC_ENABLE_AVX2"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD":
+
+ DEFINES["_DEBUG"] = True
+
+if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT":
+
+ DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+
+if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Android":
+
+ OS_LIBS += [
+ "android_support",
+ "unwind"
+ ]
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Android":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ OS_LIBS += [
+ "android_support"
+ ]
+
+if CONFIG["CPU_ARCH"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "arm" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+
+ CXXFLAGS += [
+ "-msse2"
+ ]
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["CPU_ARCH"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("audio_options_api_gn")