Merge remote-tracking branch 'upstream/branch-heads/7204'

This commit is contained in:
Jim Gustafson 2025-07-11 15:20:30 -07:00
commit a7ebbabdfe
3460 changed files with 57193 additions and 50658 deletions

1
.gitignore vendored
View File

@ -74,3 +74,4 @@
/.vscode
/.idea
!webrtc/*
rust-project.json

10
.gn
View File

@ -32,10 +32,10 @@ no_check_targets = [
"//third_party/googletest:gtest",
]
# These are the list of GN files that run exec_script. This whitelist exists
# These are the list of GN files that run exec_script. This allowlist exists
# to force additional review for new uses of exec_script, which is strongly
# discouraged except for gypi_to_gn calls.
exec_script_whitelist = build_dotfile_settings.exec_script_whitelist +
exec_script_allowlist = build_dotfile_settings.exec_script_allowlist +
[ "//build_overrides/build.gni" ]
export_compile_commands = [ "*" ]
@ -56,8 +56,7 @@ default_args = {
ios_deployment_target = "14.0"
# The SDK API level, in contrast, is set by build/android/AndroidManifest.xml.
android32_ndk_api_level = 21
android64_ndk_api_level = 21
android_ndk_api_level = 21
# WebRTC does not provide the gflags dependency. Because libyuv uses it only
# for unittests, it can be disabled (see third_party/libyuv/BUILD.gn)
@ -92,4 +91,7 @@ default_args = {
enable_rust = true
enable_rust_cxx = true
enable_chromium_prelude = true
# See context on https://issues.chromium.org/issues/415076048.
enable_js_protobuf = false
}

View File

@ -80,7 +80,7 @@ wheel: <
>
wheel: <
name: "infra/python/wheels/protobuf-py3"
version: "version:6.30.1"
version: "version:6.31.0"
>
wheel: <
name: "infra/python/wheels/requests-py3"

View File

@ -89,7 +89,6 @@ Mallikarjuna Rao V <vm.arjun@samsung.com>
Manish Jethani <manish.jethani@gmail.com>
Martin Storsjo <martin@martin.st>
Matthias Liebig <matthias.gcode@gmail.com>
Maksim Sisov <msisov@igalia.com>
Maxim Pavlov <pavllovmax@gmail.com>
Maxim Potapov <vopatop.skam@gmail.com>
Michael Iedema <michael@kapsulate.com>
@ -123,6 +122,7 @@ Robert Mader <robert.mader@collabora.com>
Robert Mader <robert.mader@posteo.de>
Robert Nagy <robert.nagy@gmail.com>
Ryan Yoakum <ryoakum@skobalt.com>
Saming Lin <santoin351@gmail.com>
Samuel Attard <samuel.r.attard@gmail.com>
Sarah Thompson <sarah@telergy.com>
Satender Saroha <ssaroha@yahoo.com>
@ -178,6 +178,7 @@ Google Inc. <*@google.com>
Highfive, Inc. <*@highfive.com>
Hopin Ltd. <*@hopin.to>
HyperConnect Inc. <*@hpcnt.com>
Igalia S.L. <*@igalia.com>
Intel Corporation <*@intel.com>
LG Electronics, Inc. <*@lge.com>
Life On Air Inc. <*@lifeonair.com>

View File

@ -251,6 +251,10 @@ config("common_inherited_config") {
if (is_ubsan) {
cflags += [ "-fsanitize=float-cast-overflow" ]
}
if (rtc_allow_deprecated_namespaces) {
defines += [ "WEBRTC_ALLOW_DEPRECATED_NAMESPACES" ]
}
}
# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning
@ -374,8 +378,7 @@ config("common_config") {
if (is_clang) {
cflags += [
# TODO(webrtc:13219): Fix -Wshadow instances and enable.
"-Wno-shadow",
"-Wshadow",
# See https://reviews.llvm.org/D56731 for details about this
# warning.
@ -540,6 +543,7 @@ if (!build_with_chromium) {
"api:libjingle_peerconnection_api",
"api:rtc_error",
"api:transport_api",
"api/audio:create_audio_device_module",
"api/audio_codecs:opus_audio_decoder_factory",
"api/crypto",
"api/rtc_event_log:rtc_event_log_factory",
@ -639,6 +643,8 @@ if (rtc_include_tests && !build_with_chromium) {
"api:rtc_api_unittests",
"api/audio:audio_api_unittests",
"api/audio_codecs/test:audio_codecs_api_unittests",
"api/crypto:crypto_options_unittest",
"api/crypto:options",
"api/numerics:numerics_unittests",
"api/task_queue:pending_task_safety_flag_unittests",
"api/test/metrics:metrics_unittests",
@ -830,3 +836,14 @@ group("poison_environment_construction") {
group("poison_software_video_codecs") {
}
if (!build_with_chromium) {
# Write debug logs to gn_logs.txt.
# This is also required for Siso builds.
import("//build/gn_logs.gni")
lines = [
"Generated during 'gn gen' by //BUILD.gn.",
"",
] + build_gn_logs
write_file("$root_build_dir/gn_logs.txt", lines)
}

354
DEPS
View File

@ -10,7 +10,7 @@ vars = {
# chromium waterfalls. More info at: crbug.com/570091.
'checkout_configuration': 'default',
'checkout_instrumented_libraries': 'checkout_linux and checkout_configuration == "default"',
'chromium_revision': '43e4a99fb37358d50c74187b7944a4519683b8a7',
'chromium_revision': '8a36d47cdc4cb85d99099ba00f864008f8a38dbe',
# Fetch the prebuilt binaries for llvm-cov and llvm-profdata. Needed to
# process the raw profiles produced by instrumented targets (built with
@ -20,6 +20,9 @@ vars = {
# Fetch clangd into the same bin/ directory as our clang binary.
'checkout_clangd': False,
# Fetch clang-tidy into the same bin/ directory as our clang binary.
'checkout_clang_tidy': False,
# Fetch libraries required to compile and run fuzzer tests.
'checkout_fuzzer': False,
@ -33,7 +36,7 @@ vars = {
# By default, download the fuchsia sdk from the public sdk directory.
'fuchsia_sdk_cipd_prefix': 'fuchsia/sdk/core/',
'fuchsia_version': 'version:27.20250326.5.1',
'fuchsia_version': 'version:28.20250522.3.1',
# By default, download the fuchsia images from the fuchsia GCS bucket.
'fuchsia_images_bucket': 'fuchsia',
'checkout_fuchsia': False,
@ -48,7 +51,9 @@ vars = {
# RBE instance to use for running remote builds
'rbe_instance': 'projects/rbe-webrtc-developer/instances/default_instance',
# reclient CIPD package version
'reclient_version': 're_client_version:0.177.1.e58c0145-gomaip',
'reclient_version': 're_client_version:0.178.0.5ee9d3e8-gomaip',
# siso CIPD package version.
'siso_version': 'git_revision:df8adf712c5b5605b438fdfcd44235107811e5ef',
# ninja CIPD package.
'ninja_package': 'infra/3pp/tools/ninja/',
@ -59,6 +64,10 @@ vars = {
# condition to allowlist deps for non-git-source processing.
'non_git_source': 'True',
# This can be overridden, e.g. with custom_vars, to build clang from HEAD
# instead of downloading the prebuilt pinned revision.
'llvm_force_head_revision': False,
}
deps = {
@ -74,30 +83,30 @@ deps = {
# TODO(kjellander): Move this to be Android-only.
'src/base':
'https://chromium.googlesource.com/chromium/src/base@1d80e43078965dbe6ded5521fbffb128f59124a6',
'https://chromium.googlesource.com/chromium/src/base@4ba67f727a84a10e32a417dc7e194f4fc6a23390',
'src/build':
'https://chromium.googlesource.com/chromium/src/build@52d62707eaec02b88722a99e335315d166ceda77',
'https://chromium.googlesource.com/chromium/src/build@7adbc7e3263f3ab427ba7c5ac7839a69082ff7fb',
'src/buildtools':
'https://chromium.googlesource.com/chromium/src/buildtools@6f359296daa889aa726f3d05046b9f37be241169',
'https://chromium.googlesource.com/chromium/src/buildtools@1fc7350e65e9d7848c083b83aaf67611e74a5654',
# Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC.
'src/examples/androidtests/third_party/gradle': {
'url': 'https://chromium.googlesource.com/external/github.com/gradle/gradle.git@f2d1fb54a951d8b11d25748e4711bec8d128d7e3',
'condition': 'checkout_android',
},
'src/ios': {
'url': 'https://chromium.googlesource.com/chromium/src/ios@510fadd1e0afbac072c92080322cc044a7836a3c',
'url': 'https://chromium.googlesource.com/chromium/src/ios@28bb2043d52518c3358080a865271d72b7478e06',
'condition': 'checkout_ios',
},
'src/testing':
'https://chromium.googlesource.com/chromium/src/testing@f46b86c7f1fc7a7f52e61c11dbd0573a48cf7a6a',
'https://chromium.googlesource.com/chromium/src/testing@44b0a8d794b28dbd74614e5f5e7da2b407030647',
'src/third_party':
'https://chromium.googlesource.com/chromium/src/third_party@10064104c1f11074312018c3a9c4b66f25584bdd',
'https://chromium.googlesource.com/chromium/src/third_party@8a150db896356cd9b47f8c1a6d916347393f90f2',
'src/buildtools/linux64': {
'packages': [
{
'package': 'gn/gn/linux-${{arch}}',
'version': 'git_revision:6e8e0d6d4a151ab2ed9b4a35366e630c55888444',
'version': 'git_revision:ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b',
}
],
'dep_type': 'cipd',
@ -107,7 +116,7 @@ deps = {
'packages': [
{
'package': 'gn/gn/mac-${{arch}}',
'version': 'git_revision:6e8e0d6d4a151ab2ed9b4a35366e630c55888444',
'version': 'git_revision:ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b',
}
],
'dep_type': 'cipd',
@ -117,7 +126,7 @@ deps = {
'packages': [
{
'package': 'gn/gn/windows-amd64',
'version': 'git_revision:6e8e0d6d4a151ab2ed9b4a35366e630c55888444',
'version': 'git_revision:ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b',
}
],
'dep_type': 'cipd',
@ -136,37 +145,186 @@ deps = {
'condition': 'not (host_os == "linux" and host_cpu == "arm64")',
},
'src/third_party/llvm-build/Release+Asserts': {
'dep_type': 'gcs',
'bucket': 'chromium-browser-clang',
'condition': 'not llvm_force_head_revision',
'objects': [
{
# The Android libclang_rt.builtins libraries are currently only included in the Linux clang package.
'object_name': 'Linux_x64/clang-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '5f69279b3697166facfc354634157e0a8a32fa6e36864200ad8a8f85add3f3f6',
'size_bytes': 55654416,
'generation': 1747138963230938,
'condition': '(host_os == "linux" or checkout_android) and non_git_source',
},
{
'object_name': 'Linux_x64/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '9c9cd089b46f36232d7553d03a0b30cf509f5e42b2113fe8172ba14f905b91df',
'size_bytes': 13597708,
'generation': 1747138963497696,
'condition': 'host_os == "linux" and checkout_clang_tidy and non_git_source',
},
{
'object_name': 'Linux_x64/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': 'cf580450a46e262d899c2d48fff2b6ea8f6691a6bcfc0c280f87d8b6da088e5f',
'size_bytes': 13854788,
'generation': 1747138963598582,
'condition': 'host_os == "linux" and checkout_clangd and non_git_source',
},
{
'object_name': 'Linux_x64/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '1a3488e55d62bda48d09b69fb4e5267ac64247258dc51fd9dabdb7fe5d66da4c',
'size_bytes': 2297996,
'generation': 1747138964068040,
'condition': 'host_os == "linux" and checkout_clang_coverage_tools and non_git_source',
},
{
'object_name': 'Linux_x64/llvmobjdump-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': 'efb127c69ac198284ff3622cd173e9dc4839d0bed33dbcaa96501db169607a2e',
'size_bytes': 5701128,
'generation': 1747138963789285,
'condition': '((checkout_linux or checkout_mac or checkout_android) and host_os == "linux") and non_git_source',
},
{
'object_name': 'Mac/clang-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '3d83bd33ae0a0331ba8e23340023ae05174128503d94116cd8a855913fca88c7',
'size_bytes': 52212572,
'generation': 1747138966013176,
'condition': 'host_os == "mac" and host_cpu == "x64"',
},
{
'object_name': 'Mac/clang-mac-runtime-library-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '809b6f72718d9bcbf25ad6ab80517f215ed2526435a095ee9bceb5ed40f989a2',
'size_bytes': 993800,
'generation': 1747138984414942,
'condition': 'checkout_mac and not host_os == "mac"',
},
{
'object_name': 'Mac/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': 'c1fd7930eadede03470cbc8d38697669c6254069da2f6bd58328a8654d68f70d',
'size_bytes': 13699584,
'generation': 1747138966324770,
'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_tidy',
},
{
'object_name': 'Mac/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '3aa82177f6e03da693d93aa9f8052fa669af1bd897359a20eaf01379db0924b8',
'size_bytes': 15136432,
'generation': 1747138966446697,
'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clangd',
},
{
'object_name': 'Mac/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '1f8d0d65f9d027707890c28433b0bfe29e32551008e9f3c1b9803318ede2bfc6',
'size_bytes': 2272500,
'generation': 1747138966854415,
'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_coverage_tools',
},
{
'object_name': 'Mac_arm64/clang-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '2d5660c50637a7ee6e5501525e7588bb255cdfd48e792b12b86ae7113c31b8ae',
'size_bytes': 44214476,
'generation': 1747138986010150,
'condition': 'host_os == "mac" and host_cpu == "arm64"',
},
{
'object_name': 'Mac_arm64/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': 'c17b6d7d112ff54699477d5fc7f5009e7b650d263d127cad4f8406f8df914996',
'size_bytes': 11838956,
'generation': 1747138986259606,
'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_tidy',
},
{
'object_name': 'Mac_arm64/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': 'd6c134df8273fe9c4c2b5ff5786f2ceeb9ed5f251e223e55edbc0cd7aa772e83',
'size_bytes': 12115024,
'generation': 1747138986359326,
'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clangd',
},
{
'object_name': 'Mac_arm64/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '82ca9187d1fd5ed14266612339b921d560b1008f92e1719255b755ff882d23e3',
'size_bytes': 1982036,
'generation': 1747138986831545,
'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_coverage_tools',
},
{
'object_name': 'Win/clang-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '39e17b8282b9f1e3cbc6b22d3144696728c867f3ae66694b0125c3ed60755401',
'size_bytes': 47250032,
'generation': 1747139012194774,
'condition': 'host_os == "win"',
},
{
'object_name': 'Win/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '9dec82a917bd55947e39891137ba5c13663ca94d2c102d56eb52b9b176365910',
'size_bytes': 13492960,
'generation': 1747139012510054,
'condition': 'host_os == "win" and checkout_clang_tidy',
},
{
'object_name': 'Win/clang-win-runtime-library-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '220abd9ce9a85446a2e7879aab3c1f2f5393665f6b13b067f8cec565ae7d36eb',
'size_bytes': 2486856,
'generation': 1747139033547001,
'condition': 'checkout_win and not host_os == "win"',
},
{
'object_name': 'Win/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '81fa230b6311e3e50147cae3acd6d2c83c1bef13ff46df3df3d580ca911e9d15',
'size_bytes': 13918432,
'generation': 1747139013351355,
'condition': 'host_os == "win" and checkout_clangd',
},
{
'object_name': 'Win/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '611b9689c3d3e80ab7485e698f6b67e0df328b5407f30f177c29fe394b81a13e',
'size_bytes': 2378584,
'generation': 1747139013764369,
'condition': 'host_os == "win" and checkout_clang_coverage_tools',
},
{
'object_name': 'Win/llvmobjdump-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz',
'sha256sum': '67a05210ee38b2f575df3cc1feb04ed36b4186748c2d769e2201572b413305fe',
'size_bytes': 5698204,
'generation': 1747139013159526,
'condition': '(checkout_linux or checkout_mac or checkout_android) and host_os == "win"',
},
]
},
# Update prebuilt Rust toolchain.
'src/third_party/rust-toolchain': {
'dep_type': 'gcs',
'bucket': 'chromium-browser-clang',
'objects': [
{
'object_name': 'Linux_x64/rust-toolchain-9fcc9cf4a202aadfe1f44722b39c83536eba3dba-2-llvmorg-21-init-1655-g7b473dfe.tar.xz',
'sha256sum': '4bf96a6d0d9bdff23475e556d925bb6846036859ea3868c2c74caa8e5fab42df',
'size_bytes': 116749200,
'generation': 1739484481010800,
'object_name': 'Linux_x64/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz',
'sha256sum': 'df1573701599cb7d00c1050b71636a436320b8ad47bb09cb46d6e96b3f8ac585',
'size_bytes': 118529212,
'generation': 1747160498430964,
'condition': 'host_os == "linux" and non_git_source',
},
{
'object_name': 'Mac/rust-toolchain-9fcc9cf4a202aadfe1f44722b39c83536eba3dba-2-llvmorg-21-init-1655-g7b473dfe.tar.xz',
'sha256sum': '6d950bab0d0cdf7ae201344b55291def8a6b2bd868fb477133ce5532ab6c1e55',
'size_bytes': 109928956,
'generation': 1739484482836636,
'object_name': 'Mac/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz',
'sha256sum': '83836493c8a81b212c20e16666c6b918bff28748f4d6685c5107eb7e9d16f6fe',
'size_bytes': 111691772,
'generation': 1747160500088595,
'condition': 'host_os == "mac" and host_cpu == "x64"',
},
{
'object_name': 'Mac_arm64/rust-toolchain-9fcc9cf4a202aadfe1f44722b39c83536eba3dba-2-llvmorg-21-init-1655-g7b473dfe.tar.xz',
'sha256sum': 'fd1620c4cced85861f5838e177fc8e1cbe1973a365143ed7de32a19c9e9cb725',
'size_bytes': 98784068,
'generation': 1739484484763552,
'object_name': 'Mac_arm64/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz',
'sha256sum': 'd975e322a2e5c680b54f27a6545c63c0de2c5367ca6ffefda04de491d6b76553',
'size_bytes': 102206348,
'generation': 1747160501743827,
'condition': 'host_os == "mac" and host_cpu == "arm64"',
},
{
'object_name': 'Win/rust-toolchain-9fcc9cf4a202aadfe1f44722b39c83536eba3dba-2-llvmorg-21-init-1655-g7b473dfe.tar.xz',
'sha256sum': 'e06ac15f6cdab4cd2ac259785adf93da5275e44060c794ba8ff5bd5b4c29ff28',
'size_bytes': 178946936,
'generation': 1739484486536378,
'object_name': 'Win/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz',
'sha256sum': '25c51b4c2e0e8b4e974973f0357b12ecb645a0a7a136f9e0a6604e87c21acc7a',
'size_bytes': 193582440,
'generation': 1747160503376785,
'condition': 'host_os == "win"',
},
],
@ -174,14 +332,16 @@ deps = {
'src/third_party/clang-format/script':
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/clang/tools/clang-format.git@37f6e68a107df43b7d7e044fd36a13cbae3413f2',
'src/third_party/compiler-rt/src':
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/compiler-rt.git@57196dd146582915c955f6d388e31aea93220c51',
'src/third_party/libc++/src':
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@449310fe2e37834a7e62972d2a690cade2ef596b',
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@a01c02c9d4acbdae3b7e8a2f3ee58579a9c29f96',
'src/third_party/libc++abi/src':
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@94c5d7a8edc09f0680aee57548c0b5d400c2840d',
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@9810fb23f6ba666f017c2b67c67de2bcac2b44bd',
'src/third_party/llvm-libc/src':
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libc.git@188329a7f2118a957efbb3e6219c255e7dba997c',
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libc.git@9c3ae3120fe83b998d0498dcc9ad3a56c29fad0c',
'src/third_party/libunwind/src':
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@e2e6f2a67e9420e770b014ce9bba476fa2ab9874',
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@8575f4ae4fcf8892938bd9766cf1a5c90a0ed04e',
'src/third_party/test_fonts/test_fonts': {
'dep_type': 'gcs',
@ -189,10 +349,10 @@ deps = {
'bucket': 'chromium-fonts',
'objects': [
{
'object_name': 'f26f29c9d3bfae588207bbc9762de8d142e58935c62a86f67332819b15203b35',
'sha256sum': 'f26f29c9d3bfae588207bbc9762de8d142e58935c62a86f67332819b15203b35',
'size_bytes': 32750602,
'generation': 1717109450425063,
'object_name': 'a28b222b79851716f8358d2800157d9ffe117b3545031ae51f69b7e1e1b9a969',
'sha256sum': 'a28b222b79851716f8358d2800157d9ffe117b3545031ae51f69b7e1e1b9a969',
'size_bytes': 33233004,
'generation': 1746454415712520,
},
],
},
@ -208,6 +368,17 @@ deps = {
'dep_type': 'cipd',
},
'src/third_party/siso/cipd': {
'packages': [
{
'package': 'infra/build/siso/${{platform}}',
'version': Var('siso_version'),
}
],
'condition': 'non_git_source',
'dep_type': 'cipd',
},
'src/third_party/android_system_sdk/cipd': {
'packages': [
{
@ -266,7 +437,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/android_build_tools/error_prone',
'version': '2cQ2nbgV3geU7-RincCggMgIe4NuUB_eW5Rm58CgMY8C',
'version': '2jzgic7at7ZxQds7qXCsmkfC4bO7d3qnWU5Q7SFUiJwC',
},
],
'condition': 'checkout_android',
@ -288,7 +459,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/android_build_tools/lint',
'version': 'hwubetoXxz5wxh6e9dQGVJl1Ih69nM8m0tFi5cUGujIC',
'version': 'Rh_qNy2kyeA9GGIdsjnPMvQa1WpHOEoUBZqV9opGGgIC',
},
],
'condition': 'checkout_android and non_git_source',
@ -300,7 +471,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/android_build_tools/nullaway',
'version': 'Br9gBQM1eYGrSHKahSZ-WTQPlz-YegUJ9mvraq3UajUC',
'version': 'mFkUqdlIqmMQ3rAaTHFmOBYjNFgFUQOmMlPG6PGgmHYC',
},
],
'condition': 'checkout_android and non_git_source',
@ -319,11 +490,11 @@ deps = {
},
'src/third_party/boringssl/src':
'https://boringssl.googlesource.com/boringssl.git@a9993612faac4866bc33ca8ff37bfd0659af1c48',
'https://boringssl.googlesource.com/boringssl.git@9295969e1dad2c31d0d99481734c1c68dcbc6403',
'src/third_party/breakpad/breakpad':
'https://chromium.googlesource.com/breakpad/breakpad.git@657a441e5c1a818d4c10b7bafd431454e6614901',
'https://chromium.googlesource.com/breakpad/breakpad.git@2625edb085169e92cf036c236ac79ab594a7b1cc',
'src/third_party/catapult':
'https://chromium.googlesource.com/catapult.git@5bda0fdab9d93ec9963e2cd858c7b49ad7fec7d4',
'https://chromium.googlesource.com/catapult.git@5477c6dfde1132b685c73edc16e1bc71449a691d',
'src/third_party/ced/src': {
'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5',
},
@ -336,23 +507,23 @@ deps = {
'src/third_party/crc32c/src':
'https://chromium.googlesource.com/external/github.com/google/crc32c.git@d3d60ac6e0f16780bcfcc825385e1d338801a558',
'src/third_party/depot_tools':
'https://chromium.googlesource.com/chromium/tools/depot_tools.git@f40ddcd8d51626fb7be3ab3c418b3f3be801623f',
'https://chromium.googlesource.com/chromium/tools/depot_tools.git@a8900cc0f023d6a662eb66b317e8ddceeb113490',
'src/third_party/ffmpeg':
'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@fbce2a76c00cd2e5aeffe3c2e71d44c284ec52d6',
'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@dcdd0fa51b65a0b1688ff6b8f0cc81908f09ded2',
'src/third_party/flatbuffers/src':
'https://chromium.googlesource.com/external/github.com/google/flatbuffers.git@8db59321d9f02cdffa30126654059c7d02f70c32',
'src/third_party/grpc/src': {
'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@d8ce421830bd993885038934abdc74e1e56e3213',
'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@cadf3c8329377e93b1f5e2d6a43d91f7a4becc28',
},
# Used for embedded builds. CrOS & Linux use the system version.
'src/third_party/fontconfig/src': {
'url': 'https://chromium.googlesource.com/external/fontconfig.git@14d466b30a8ab4a9d789977ed94f2c30e7209267',
'url': 'https://chromium.googlesource.com/external/fontconfig.git@8cf0ce700a8abe0d97ace4bf7efc7f9534b729ba',
'condition': 'checkout_linux',
},
'src/third_party/freetype/src':
'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@82090e67c24259c343c83fd9cefe6ff0be7a7eca',
'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@e07e56c7f106b600262ab653d696b7b57f320127',
'src/third_party/harfbuzz-ng/src':
'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@8efd2d85c78fbba6ca09a3e454f77525f3b296ce',
'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@9f83bbbe64654b45ba5bb06927ff36c2e7588495',
'src/third_party/google_benchmark/src': {
'url': 'https://chromium.googlesource.com/external/github.com/google/benchmark.git@761305ec3b33abf30e08d50eb829e19a802581cc',
},
@ -364,9 +535,9 @@ deps = {
'condition': 'checkout_android',
},
'src/third_party/googletest/src':
'https://chromium.googlesource.com/external/github.com/google/googletest.git@52204f78f94d7512df1f0f3bea1d47437a2c3a58',
'https://chromium.googlesource.com/external/github.com/google/googletest.git@09ffd0015395354774c059a17d9f5bee36177ff9',
'src/third_party/icu': {
'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@c9fb4b3a6fb54aa8c20a03bbcaa0a4a985ffd34b',
'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@b929596baebf0ab4ac7ec07f38365db4c50a559d',
},
'src/third_party/jdk/current': {
'packages': [
@ -402,7 +573,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/kotlin_stdlib',
'version': 'Ek4qdlAGvswwQ1AaKLNPnDUMCYHw4uWRL63Yek0nMwkC',
'version': 'GUpKElqF0PYGB-SP4D5w6p_MuMYQSBrRkGqFGjPhsIYC',
},
],
'condition': 'checkout_android',
@ -413,7 +584,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/kotlinc',
'version': 'Wood5j4J3uPDtbP0fk868sOS0Y0umzF5X7w6U6QWupgC',
'version': 'XmaM7JA4hB75AuMdzCegF-XYzXtoHKOA1anrWqAJL3QC',
},
],
'condition': 'checkout_android',
@ -422,7 +593,7 @@ deps = {
'src/third_party/libFuzzer/src':
'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/compiler-rt/lib/fuzzer.git@e31b99917861f891308269c36a32363b120126bb',
'src/third_party/fuzztest/src':
'https://chromium.googlesource.com/external/github.com/google/fuzztest.git@3c7bc855a4938c5d0d1d07303aa0697c88d33e6c',
'https://chromium.googlesource.com/external/github.com/google/fuzztest.git@f03aafb7516050ea73f617bf969f03eac641aefc',
'src/third_party/libjpeg_turbo':
'https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@e14cbfaa85529d47f9f55b0f104a579c1061f9ad',
'src/third_party/libsrtp':
@ -430,19 +601,19 @@ deps = {
'src/third_party/dav1d/libdav1d':
'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@8d956180934f16244bdb58b39175824775125e55',
'src/third_party/libaom/source/libaom':
'https://aomedia.googlesource.com/aom.git@9680f2b1781fb33b9eeb52409b75c679c8a954be',
'https://aomedia.googlesource.com/aom.git@2cca4aba034f99842c2e6cdc173f83801d289764',
'src/third_party/libunwindstack': {
'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@e5061bbda4c2ba6438020669ed06b122032433dd',
'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@0d758dd57f42564acecdd7a1e7ac5c8521c1b01a',
'condition': 'checkout_android',
},
'src/third_party/perfetto':
'https://android.googlesource.com/platform/external/perfetto.git@40b529923598b739b2892a536a7692eedbed5685',
Var('chromium_git') + '/external/github.com/google/perfetto.git' + '@' + 'dd35b295cd359ba094404218414955f961a0d6ae',
'src/third_party/protobuf-javascript/src':
Var('chromium_git') + '/external/github.com/protocolbuffers/protobuf-javascript' + '@' + 'eb785a9363664a402b6336dfe96aad27fb33ffa8',
Var('chromium_git') + '/external/github.com/protocolbuffers/protobuf-javascript' + '@' + '28bf5df73ef2f345a936d9cc95d64ba8ed426a53',
'src/third_party/libvpx/source/libvpx':
'https://chromium.googlesource.com/webm/libvpx.git@027bbee30a0103b99d86327b48d29567fed11688',
'https://chromium.googlesource.com/webm/libvpx.git@b84ca9b63730e7d4563573a56a66317eb0087ebf',
'src/third_party/libyuv':
'https://chromium.googlesource.com/libyuv/libyuv.git@ccdf870348764e4b77fa3b56accb2a896a901bad',
'https://chromium.googlesource.com/libyuv/libyuv.git@61bdaee13a701d2b52c6dc943ccc5c888077a591',
'src/third_party/lss': {
'url': 'https://chromium.googlesource.com/linux-syscall-support.git@ed31caa60f20a4f6569883b2d752ef7522de51e0',
'condition': 'checkout_android or checkout_linux',
@ -458,7 +629,7 @@ deps = {
# Used by boringssl.
'src/third_party/nasm': {
'url': 'https://chromium.googlesource.com/chromium/deps/nasm.git@767a169c8811b090df222a458b25dfa137fc637e'
'url': 'https://chromium.googlesource.com/chromium/deps/nasm.git@9f916e90e6fc34ec302573f6ce147e43e33d68ca'
},
'src/third_party/openh264/src':
@ -471,7 +642,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/r8',
'version': 'lg4ep5S4K6V2zni9jgt42ga6U-8AR6aAWNSqbe2VdmoC',
'version': 'QhYGRVpYYKZmt3f_Zb2HoJ9LIBEnWaeeLXRNei47Z30C',
},
],
'condition': 'checkout_android',
@ -484,7 +655,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/r8',
'version': 'f-Ka2tsB3j_I6-Av4qE9ftl6KddtjV-pRVcUUc9cgYQC',
'version': 'QhYGRVpYYKZmt3f_Zb2HoJ9LIBEnWaeeLXRNei47Z30C',
},
],
'condition': 'checkout_android',
@ -495,7 +666,7 @@ deps = {
'condition': 'checkout_android',
},
'src/tools':
'https://chromium.googlesource.com/chromium/src/tools@3460fbcdee33353d37800dad5caa6bba327ad8c8',
'https://chromium.googlesource.com/chromium/src/tools@901b847deda65d44f1bba16a9f47e2ea68a805be',
'src/third_party/espresso': {
'packages': [
@ -523,7 +694,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/android_toolchain/android_toolchain',
'version': 'Idl-vYnWGnM8K3XJhM3h6zjYVDXlnljVz3FE00V9IM8C',
'version': 'KXOia11cm9lVdUdPlbGLu8sCz6Y4ey_HV2s8_8qeqhgC',
},
],
'condition': 'checkout_android',
@ -534,7 +705,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/androidx',
'version': 'OHTk-Zj-BcsXRtP5QWpR0SIoInMBgiClQfxw-BTV9pQC',
'version': 'SRLnRQtsEaeNt_-cy_acdUbX63elq51jmwvif531vHgC',
},
],
'condition': 'checkout_android and non_git_source',
@ -545,7 +716,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/android_build_tools/manifest_merger',
'version': 'Gv6-zTnY5Cj7i1ck5bS92diwCClFq1HHoTCf4kWr4SsC',
'version': 'i1CvLtWlkB9QDx0DL_52AZNLpuQc2d6MbpRsCbzgEtEC',
},
],
'condition': 'checkout_android',
@ -616,7 +787,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/turbine',
'version': 'lnlrbUuImYl1BaRqVclTMOqA0KVYDYdym4ujLkPurbMC',
'version': 'VGtOG2ivl1SJR7Lai5FQddIu15mWCYDnp47QtozMQeoC',
},
],
'condition': 'checkout_android',
@ -624,7 +795,7 @@ deps = {
},
'src/third_party/zstd/src': {
'url': Var('chromium_git') + '/external/github.com/facebook/zstd.git' + '@' + 'ef2bf5781112a4cd6b62ac1817f7842bbdc7ea8f',
'url': Var('chromium_git') + '/external/github.com/facebook/zstd.git' + '@' + 'f9938c217da17ec3e9dcd2a2d99c5cf39536aeb9',
'condition': 'checkout_android',
},
@ -632,15 +803,15 @@ deps = {
'packages': [
{
'package': 'infra/tools/luci/cas/${{platform}}',
'version': 'git_revision:7a44078a668bc9f75dd6e40a332450e76f2f7399',
'version': 'git_revision:14c1dfd95e07b23eeaff304bd29a2eb80b06fe0b',
},
{
'package': 'infra/tools/luci/isolate/${{platform}}',
'version': 'git_revision:7a44078a668bc9f75dd6e40a332450e76f2f7399',
'version': 'git_revision:14c1dfd95e07b23eeaff304bd29a2eb80b06fe0b',
},
{
'package': 'infra/tools/luci/swarming/${{platform}}',
'version': 'git_revision:7a44078a668bc9f75dd6e40a332450e76f2f7399',
'version': 'git_revision:14c1dfd95e07b23eeaff304bd29a2eb80b06fe0b',
}
],
'dep_type': 'cipd',
@ -666,7 +837,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/android_deps/autorolled',
'version': '-kw2ioUuVwgaTHjBYvcyYBT3SZ24bRuwH_rIhsiZ24IC',
'version': 'p_9xkMekw1ax7bzdkzI9gjCXkONcxJb-xhJDLgyxxlUC',
},
],
'condition': 'checkout_android and non_git_source',
@ -2036,34 +2207,6 @@ hooks = [
'{checkout_fuchsia_boot_images}',
],
},
{
# Note: On Win, this should run after win_toolchain, as it may use it.
'name': 'clang',
'pattern': '.',
'action': ['python3', 'src/tools/clang/scripts/update.py'],
},
{
# This is supposed to support the same set of platforms as 'clang' above.
'name': 'clang_coverage',
'pattern': '.',
'condition': 'checkout_clang_coverage_tools',
'action': ['python3', 'src/tools/clang/scripts/update.py',
'--package=coverage_tools'],
},
{
# This is also supposed to support the same set of platforms as 'clang'
# above. LLVM ToT support isn't provided at the moment.
'name': 'clangd',
'pattern': '.',
'condition': 'checkout_clangd',
'action': ['vpython3', 'src/tools/clang/scripts/update.py',
'--package=clangd'],
},
{
'name': 'rust',
'pattern': '.',
'action': ['python3', 'src/tools/rust/update_rust.py'],
},
{
# Update LASTCHANGE.
'name': 'lastchange',
@ -2180,7 +2323,16 @@ hooks = [
'--quiet',
],
},
# Configure Siso for developer builds.
{
'name': 'configure_siso',
'pattern': '.',
'action': ['python3',
'src/build/config/siso/configure_siso.py',
'--rbe_instance',
Var('rbe_instance'),
],
},
{
# Ensure we remove any file from disk that is no longer needed (e.g. after
# hooks to native GCS deps migration).

View File

@ -538,7 +538,7 @@ def CheckNoStreamUsageIsAdded(input_api,
'std::ostream& F() { // no-presubmit-check TODO(webrtc:8982)\n'
'\n'
'If you are adding new code, consider using '
'rtc::SimpleStringBuilder\n'
'webrtc::SimpleStringBuilder\n'
'(in rtc_base/strings/string_builder.h).\n'
'Affected files:\n')
errors = [] # 2-element tuples with (file, line number)

View File

@ -26,7 +26,7 @@ rtc_source_set("call_api") {
sources = [ "call/audio_sink.h" ]
}
rtc_source_set("enable_media") {
rtc_library("enable_media") {
visibility = [ "*" ]
sources = [
"enable_media.cc",
@ -46,7 +46,7 @@ rtc_source_set("enable_media") {
]
}
rtc_source_set("enable_media_with_defaults") {
rtc_library("enable_media_with_defaults") {
visibility = [ "*" ]
allow_poison = [
"audio_codecs",
@ -65,7 +65,6 @@ rtc_source_set("enable_media_with_defaults") {
"audio:builtin_audio_processing_builder",
"audio_codecs:builtin_audio_decoder_factory",
"audio_codecs:builtin_audio_encoder_factory",
"task_queue:default_task_queue_factory",
"video_codecs:builtin_video_decoder_factory",
"video_codecs:builtin_video_encoder_factory",
]
@ -84,10 +83,7 @@ if (!build_with_chromium) {
":field_trials_view",
":libjingle_peerconnection_api",
":scoped_refptr",
"../api/rtc_event_log:rtc_event_log_factory",
"../pc:peer_connection_factory",
"../pc:webrtc_sdp",
"../rtc_base:socket_server",
"../rtc_base:threading",
"../rtc_base/system:rtc_export",
"../stats:rtc_stats",
@ -96,6 +92,8 @@ if (!build_with_chromium) {
"audio:audio_processing",
"audio:builtin_audio_processing_builder",
"audio_codecs:audio_codecs_api",
"environment:environment_factory",
"rtc_event_log:rtc_event_log_factory",
"video_codecs:video_codecs_api",
]
}
@ -198,6 +196,7 @@ rtc_library("candidate") {
"../rtc_base:stringutils",
"../rtc_base/system:rtc_export",
"//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/strings:string_view",
]
}
@ -321,9 +320,9 @@ rtc_library("libjingle_peerconnection_api") {
":async_dns_resolver",
":audio_options_api",
":candidate",
":data_channel_event_observer_interface",
":dtls_transport_interface",
":fec_controller_api",
":field_trials",
":field_trials_view",
":frame_transformer_interface",
":ice_transport_interface",
@ -368,6 +367,7 @@ rtc_library("libjingle_peerconnection_api") {
"crypto:frame_decryptor_interface",
"crypto:frame_encryptor_interface",
"crypto:options",
"environment",
"metronome",
"neteq:neteq_api",
"rtc_event_log:rtc_event_log_factory_interface",
@ -390,6 +390,7 @@ rtc_library("libjingle_peerconnection_api") {
"//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/functional:any_invocable",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/strings:string_view",
# Basically, don't add stuff here. You might break sensitive downstream
@ -404,7 +405,7 @@ rtc_library("libjingle_peerconnection_api") {
]
}
rtc_source_set("frame_transformer_interface") {
rtc_library("frame_transformer_interface") {
visibility = [ "*" ]
sources = [
"frame_transformer_interface.cc",
@ -433,7 +434,6 @@ rtc_library("rtc_error") {
deps = [
"../rtc_base:checks",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base/system:rtc_export",
"//third_party/abseil-cpp/absl/meta:type_traits",
"//third_party/abseil-cpp/absl/strings",
@ -459,6 +459,7 @@ rtc_source_set("packet_socket_factory") {
":async_dns_resolver",
"../rtc_base:async_packet_socket",
"../rtc_base:socket_address",
"../rtc_base:ssl",
"../rtc_base/system:rtc_export",
]
}
@ -526,12 +527,16 @@ rtc_source_set("rtp_transceiver_direction") {
sources = [ "rtp_transceiver_direction.h" ]
}
rtc_source_set("priority") {
rtc_library("priority") {
visibility = [ "*" ]
sources = [ "priority.h" ]
sources = [
"priority.cc",
"priority.h",
]
deps = [
"../rtc_base:checks",
"../rtc_base:strong_alias",
"../rtc_base/system:rtc_export",
]
}
@ -651,7 +656,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") {
]
}
rtc_source_set("frame_generator_api") {
rtc_library("frame_generator_api") {
visibility = [ "*" ]
sources = [
"test/frame_generator_interface.cc",
@ -790,6 +795,15 @@ rtc_library("create_peer_connection_quality_test_frame_generator") {
]
}
rtc_source_set("data_channel_event_observer_interface") {
visibility = [ "*" ]
sources = [ "data_channel_event_observer_interface.h" ]
deps = [
":array_view",
"//third_party/abseil-cpp/absl/strings:string_view",
]
}
rtc_source_set("libjingle_logging_api") {
visibility = [ "*" ]
sources = [ "rtc_event_log_output.h" ]
@ -877,7 +891,6 @@ rtc_source_set("simulated_network_api") {
visibility = [ "*" ]
sources = [ "test/simulated_network.h" ]
deps = [
"../rtc_base:macromagic",
"../rtc_base:random",
"transport:ecn_marking",
"units:data_rate",
@ -886,7 +899,7 @@ rtc_source_set("simulated_network_api") {
}
# TODO(srte): Move to network_emulation sub directory.
rtc_source_set("network_emulation_manager_api") {
rtc_library("network_emulation_manager_api") {
visibility = [ "*" ]
sources = [
"test/network_emulation_manager.cc",
@ -912,7 +925,7 @@ rtc_source_set("network_emulation_manager_api") {
]
}
rtc_source_set("time_controller") {
rtc_library("time_controller") {
visibility = [ "*" ]
sources = [
"test/time_controller.cc",
@ -965,7 +978,6 @@ rtc_source_set("refcountedbase") {
sources = [ "ref_counted_base.h" ]
deps = [
":ref_count",
"../rtc_base:macromagic",
"../rtc_base:refcount",
]
}
@ -1311,6 +1323,7 @@ if (rtc_include_tests) {
deps = [
":candidate",
":data_channel_event_observer_interface",
":dtls_transport_interface",
":libjingle_logging_api",
":libjingle_peerconnection_api",
@ -1322,6 +1335,7 @@ if (rtc_include_tests) {
":rtp_parameters",
"../api:scoped_refptr",
"../rtc_base:refcount",
"../rtc_base:threading",
"../test:test_support",
"adaptation:resource_adaptation_api",
"transport:bandwidth_estimation_settings",
@ -1353,6 +1367,7 @@ if (rtc_include_tests) {
testonly = true
sources = [ "test/mock_session_description_interface.h" ]
deps = [
":candidate",
":libjingle_peerconnection_api",
"../test:test_support",
]
@ -1366,6 +1381,7 @@ if (rtc_include_tests) {
":array_view",
":frame_transformer_interface",
"../test:test_support",
"units:time_delta",
"units:timestamp",
]
}
@ -1422,6 +1438,7 @@ if (rtc_include_tests) {
":frame_transformer_interface",
"../api/units:timestamp",
"../test:test_support",
"units:time_delta",
]
}
@ -1533,20 +1550,9 @@ if (rtc_include_tests) {
]
deps = [
":enable_media_with_defaults",
":libjingle_peerconnection_api",
":time_controller",
"../call",
"../call:call_interfaces",
"../media:media_engine",
"../pc:media_factory",
"../rtc_base:checks",
"../system_wrappers",
"../test/time_controller",
"environment",
"environment:environment_factory",
"units:timestamp",
"//third_party/abseil-cpp/absl/base:nullability",
]
}
@ -1612,7 +1618,6 @@ if (rtc_include_tests) {
"task_queue:task_queue_default_factory_unittests",
"test/pclf:media_configuration",
"test/video:video_frame_writer",
"transport:field_trial_based_config",
"units:time_delta",
"units:timestamp",
"units:units_unittests",
@ -1667,7 +1672,7 @@ if (rtc_include_tests) {
}
}
rtc_source_set("field_trials_registry") {
rtc_library("field_trials_registry") {
visibility = [ "*" ]
sources = [
"field_trials_registry.cc",
@ -1711,7 +1716,8 @@ rtc_library("field_trials") {
":field_trials_registry",
"../rtc_base:checks",
"../rtc_base/containers:flat_map",
"../system_wrappers:field_trial",
"//third_party/abseil-cpp/absl/base:nullability",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings:string_view",
]
}

View File

@ -49,7 +49,6 @@ specific_include_rules = {
],
".*\.h": [
"+rtc_base/arraysize.h",
"+rtc_base/checks.h",
"+rtc_base/system/rtc_export.h",
"+rtc_base/system/rtc_export_template.h",
@ -78,6 +77,10 @@ specific_include_rules = {
"audio_device_defines\.h": [
"+rtc_base/strings/string_builder.h",
],
"audio_format\.h": [
"+rtc_base/strings/string_builder.h",
],
"candidate\.h": [
"+rtc_base/network_constants.h",
@ -107,6 +110,7 @@ specific_include_rules = {
"packet_socket_factory\.h": [
"+rtc_base/async_packet_socket.h",
"+rtc_base/socket_address.h",
"+rtc_base/ssl_certificate.h",
],
"turn_customizer\.h": [

View File

@ -8,7 +8,7 @@
import("../../webrtc.gni")
rtc_source_set("resource_adaptation_api") {
rtc_library("resource_adaptation_api") {
visibility = [ "*" ]
sources = [
"resource.cc",

View File

@ -35,9 +35,8 @@ class RTC_EXPORT ResourceListener {
public:
virtual ~ResourceListener();
virtual void OnResourceUsageStateMeasured(
rtc::scoped_refptr<Resource> resource,
ResourceUsageState usage_state) = 0;
virtual void OnResourceUsageStateMeasured(scoped_refptr<Resource> resource,
ResourceUsageState usage_state) = 0;
};
// A Resource monitors an implementation-specific resource. It may report

View File

@ -22,7 +22,7 @@
namespace webrtc {
// tl;dr: rtc::ArrayView is the same thing as gsl::span from the Guideline
// tl;dr: webrtc::ArrayView is the same thing as gsl::span from the Guideline
// Support Library.
//
// Many functions read from or write to arrays. The obvious way to do this is
@ -37,10 +37,10 @@ namespace webrtc {
// }
//
// This is flexible, since it doesn't matter how the array is stored (C array,
// std::vector, rtc::Buffer, ...), but it's error-prone because the caller has
// to correctly specify the array length:
// std::vector, webrtc::Buffer, ...), but it's error-prone because the caller
// has to correctly specify the array length:
//
// Contains17(arr, arraysize(arr)); // C array
// Contains17(arr, std::size(arr)); // C array
// Contains17(arr.data(), arr.size()); // std::vector
// Contains17(arr, size); // pointer + size
// ...
@ -48,11 +48,11 @@ namespace webrtc {
// It's also kind of messy to have two separate arguments for what is
// conceptually a single thing.
//
// Enter rtc::ArrayView<T>. It contains a T pointer (to an array it doesn't
// Enter webrtc::ArrayView<T>. It contains a T pointer (to an array it doesn't
// own) and a count, and supports the basic things you'd expect, such as
// indexing and iteration. It allows us to write our function like this:
//
// bool Contains17(rtc::ArrayView<const int> arr) {
// bool Contains17(webrtc::ArrayView<const int> arr) {
// for (auto e : arr) {
// if (e == 17)
// return true;
@ -65,7 +65,7 @@ namespace webrtc {
//
// Contains17(arr); // C array
// Contains17(arr); // std::vector
// Contains17(rtc::ArrayView<int>(arr, size)); // pointer + size
// Contains17(webrtc::ArrayView<int>(arr, size)); // pointer + size
// Contains17(nullptr); // nullptr -> empty ArrayView
// ...
//
@ -239,8 +239,8 @@ class ArrayView final : public array_view_internal::ArrayViewBase<T, Size> {
// ArrayView<T, N> to ArrayView<T> or ArrayView<const T>,
// std::vector<T> to ArrayView<T> or ArrayView<const T>,
// const std::vector<T> to ArrayView<const T>,
// rtc::Buffer to ArrayView<uint8_t> or ArrayView<const uint8_t>, and
// const rtc::Buffer to ArrayView<const uint8_t>.
// webrtc::Buffer to ArrayView<uint8_t> or ArrayView<const uint8_t>, and
// const webrtc::Buffer to ArrayView<const uint8_t>.
template <
typename U,
typename std::enable_if<Size == array_view_internal::kArrayViewVarSize &&
@ -334,6 +334,7 @@ inline ArrayView<U, Size> reinterpret_array_view(ArrayView<T, Size> view) {
// Re-export symbols from the webrtc namespace for backwards compatibility.
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES
namespace rtc {
template <typename T,
std::ptrdiff_t Size = webrtc::array_view_internal::kArrayViewVarSize>
@ -341,5 +342,6 @@ using ArrayView = ::webrtc::ArrayView<T, Size>;
using ::webrtc::MakeArrayView;
using ::webrtc::reinterpret_array_view;
} // namespace rtc
#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES
#endif // API_ARRAY_VIEW_H_

View File

@ -354,7 +354,7 @@ TEST(ArrayViewTest, TestStdVector) {
}
TEST(ArrayViewTest, TestRtcBuffer) {
rtc::Buffer b = "so buffer";
Buffer b = "so buffer";
EXPECT_EQ(10u, Call<const uint8_t>(b));
EXPECT_EQ(10u, Call<uint8_t>(b));
// Call<int8_t>(b); // Compile error, because incompatible types.
@ -366,7 +366,7 @@ TEST(ArrayViewTest, TestRtcBuffer) {
EXPECT_EQ(10u, y.size());
EXPECT_EQ(b.data(), y.data());
// ArrayView<char> d = b; // Compile error, because incompatible types.
const rtc::Buffer cb = "very const";
const Buffer cb = "very const";
EXPECT_EQ(11u, Call<const uint8_t>(cb));
// Call<uint8_t>(cb); // Compile error, because can't drop const.
ArrayView<const uint8_t> z = cb;

View File

@ -16,13 +16,27 @@ rtc_source_set("audio_device") {
]
deps = [
"..:ref_count",
"..:scoped_refptr",
"../../rtc_base:checks",
"../../rtc_base:stringutils",
"../task_queue",
]
}
if (rtc_include_internal_audio_device) {
rtc_library("create_audio_device_module") {
visibility = [ "*" ]
sources = [
"create_audio_device_module.cc",
"create_audio_device_module.h",
]
deps = [
":audio_device",
"..:scoped_refptr",
"../../modules/audio_device:audio_device_impl",
"../environment",
"//third_party/abseil-cpp/absl/base:nullability",
]
}
}
rtc_library("audio_frame_api") {
visibility = [ "*" ]
sources = [
@ -38,7 +52,6 @@ rtc_library("audio_frame_api") {
"..:rtp_packet_info",
"../../rtc_base:checks",
"../../rtc_base:logging",
"../../rtc_base:macromagic",
"../../rtc_base:timeutils",
]
}
@ -55,11 +68,12 @@ rtc_source_set("audio_mixer_api") {
deps = [
":audio_frame_api",
"..:make_ref_counted",
"..:ref_count",
"../../rtc_base:refcount",
]
}
rtc_source_set("audio_processing") {
rtc_library("audio_processing") {
visibility = [ "*" ]
sources = [
"audio_processing.cc",
@ -73,7 +87,6 @@ rtc_source_set("audio_processing") {
"..:ref_count",
"..:scoped_refptr",
"../../rtc_base:checks",
"../../rtc_base:macromagic",
"../../rtc_base:stringutils",
"../../rtc_base/system:arch",
"../../rtc_base/system:file_wrapper",
@ -105,7 +118,7 @@ rtc_library("builtin_audio_processing_builder") {
]
}
rtc_source_set("audio_processing_statistics") {
rtc_library("audio_processing_statistics") {
visibility = [ "*" ]
sources = [
"audio_processing_statistics.cc",
@ -155,7 +168,7 @@ rtc_source_set("echo_control") {
]
}
rtc_source_set("echo_detector_creator") {
rtc_library("echo_detector_creator") {
visibility = [ "*" ]
allow_poison = [ "default_echo_detector" ]
sources = [

View File

@ -11,11 +11,11 @@
#ifndef API_AUDIO_AUDIO_DEVICE_H_
#define API_AUDIO_AUDIO_DEVICE_H_
#include <cstdint>
#include <optional>
#include "api/audio/audio_device_defines.h"
#include "api/ref_count.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/task_queue_factory.h"
namespace webrtc {
@ -59,14 +59,6 @@ class AudioDeviceModule : public webrtc::RefCountInterface {
};
public:
// Creates a default ADM for usage in production code.
static rtc::scoped_refptr<AudioDeviceModule> Create(
AudioLayer audio_layer, TaskQueueFactory* task_queue_factory);
// Creates an ADM with support for extra test methods. Don't use this factory
// in production code.
static rtc::scoped_refptr<AudioDeviceModuleForTest> CreateForTest(
AudioLayer audio_layer, TaskQueueFactory* task_queue_factory);
// Retrieve the currently utilized audio layer
virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const = 0;

View File

@ -38,7 +38,7 @@ AudioFrame::AudioFrame(int sample_rate_hz,
channel_layout_(layout == CHANNEL_LAYOUT_UNSUPPORTED
? GuessChannelLayout(num_channels)
: layout) {
RTC_DCHECK_LE(num_channels_, kMaxConcurrentChannels);
RTC_DCHECK_LE(num_channels_, kMaxNumberOfAudioChannels);
RTC_DCHECK_GT(sample_rate_hz_, 0);
RTC_DCHECK_GT(samples_per_channel_, 0u);
}
@ -72,7 +72,7 @@ void AudioFrame::UpdateFrame(uint32_t timestamp,
SpeechType speech_type,
VADActivity vad_activity,
size_t num_channels) {
RTC_CHECK_LE(num_channels, kMaxConcurrentChannels);
RTC_CHECK_LE(num_channels, kMaxNumberOfAudioChannels);
timestamp_ = timestamp;
samples_per_channel_ = samples_per_channel;
sample_rate_hz_ = sample_rate_hz;
@ -148,9 +148,9 @@ InterleavedView<const int16_t> AudioFrame::data_view() const {
// If you get a nullptr from `data_view()`, it's likely because the
// samples_per_channel_ and/or num_channels_ members haven't been properly
// set. Since `data_view()` returns an InterleavedView<> (which internally
// uses rtc::ArrayView<>), we inherit the behavior in InterleavedView when the
// view size is 0 that ArrayView<>::data() returns nullptr. So, even when an
// AudioFrame is muted and we want to return `zeroed_data()`, if
// uses webrtc::ArrayView<>), we inherit the behavior in InterleavedView when
// the view size is 0 that ArrayView<>::data() returns nullptr. So, even when
// an AudioFrame is muted and we want to return `zeroed_data()`, if
// samples_per_channel_ or num_channels_ is 0, the view will point to
// nullptr.
return InterleavedView<const int16_t>(muted_ ? &zeroed_data()[0] : &data_[0],
@ -172,7 +172,7 @@ InterleavedView<int16_t> AudioFrame::mutable_data(size_t samples_per_channel,
size_t num_channels) {
const size_t total_samples = samples_per_channel * num_channels;
RTC_CHECK_LE(total_samples, data_.size());
RTC_CHECK_LE(num_channels, kMaxConcurrentChannels);
RTC_CHECK_LE(num_channels, kMaxNumberOfAudioChannels);
// Sanity check for valid argument values during development.
// If `samples_per_channel` is < `num_channels` but larger than 0,
// then chances are the order of arguments is incorrect.
@ -227,9 +227,9 @@ void AudioFrame::SetSampleRateAndChannelSize(int sample_rate) {
}
// static
rtc::ArrayView<const int16_t> AudioFrame::zeroed_data() {
ArrayView<const int16_t> AudioFrame::zeroed_data() {
static int16_t* null_data = new int16_t[kMaxDataSizeSamples]();
return rtc::ArrayView<const int16_t>(null_data, kMaxDataSizeSamples);
return ArrayView<const int16_t>(null_data, kMaxDataSizeSamples);
}
} // namespace webrtc

View File

@ -64,6 +64,10 @@ class AudioFrame {
enum : size_t {
// Stereo, 32 kHz, 120 ms (2 * 32 * 120)
// Stereo, 192 kHz, 20 ms (2 * 192 * 20)
// 8 channels (kMaxConcurrentChannels), 48 kHz, 20 ms (8 * 48 * 20).
// 24 channels (kMaxNumberOfAudioChannels), 32 kHz kHz, 10 ms (24 * 32 * 10)
// At 48 kHz, 10 ms buffers, the maximum number of channels AudioFrame can
// hold, is 16. (16 * 48 * 10).
kMaxDataSizeSamples = 7680,
kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t),
};
@ -212,7 +216,7 @@ class AudioFrame {
// A permanently zeroed out buffer to represent muted frames. This is a
// header-only class, so the only way to avoid creating a separate zeroed
// buffer per translation unit is to wrap a static in an inline function.
static rtc::ArrayView<const int16_t> zeroed_data();
static ArrayView<const int16_t> zeroed_data();
std::array<int16_t, kMaxDataSizeSamples> data_;
bool muted_ = true;
@ -221,7 +225,7 @@ class AudioFrame {
// 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().
// This timestamp MUST be based on the same clock as webrtc::TimeMillis().
std::optional<int64_t> absolute_capture_timestamp_ms_;
};

View File

@ -11,10 +11,10 @@
#ifndef API_AUDIO_AUDIO_MIXER_H_
#define API_AUDIO_AUDIO_MIXER_H_
#include <memory>
#include <cstddef>
#include "api/audio/audio_frame.h"
#include "rtc_base/ref_count.h"
#include "api/ref_count.h"
namespace webrtc {

View File

@ -55,8 +55,6 @@ std::string GainController1ModeToString(const Agc1Config::Mode& mode) {
} // namespace
constexpr int AudioProcessing::kNativeSampleRatesHz[];
void CustomProcessing::SetRuntimeSetting(
AudioProcessing::RuntimeSetting /* setting */) {}
@ -214,21 +212,21 @@ std::string AudioProcessing::Config::ToString() const {
return builder.str();
}
absl::Nonnull<std::unique_ptr<AudioProcessingBuilderInterface>>
absl_nonnull std::unique_ptr<AudioProcessingBuilderInterface>
CustomAudioProcessing(
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing) {
absl_nonnull scoped_refptr<AudioProcessing> audio_processing) {
class Builder : public AudioProcessingBuilderInterface {
public:
explicit Builder(absl::Nonnull<scoped_refptr<AudioProcessing>> ap)
explicit Builder(absl_nonnull scoped_refptr<AudioProcessing> ap)
: ap_(std::move(ap)) {}
absl::Nullable<scoped_refptr<AudioProcessing>> Build(
absl_nullable scoped_refptr<AudioProcessing> Build(
const Environment& /*env*/) override {
return std::move(ap_);
}
private:
absl::Nonnull<scoped_refptr<AudioProcessing>> ap_;
absl_nonnull scoped_refptr<AudioProcessing> ap_;
};
RTC_CHECK(audio_processing);

View File

@ -26,7 +26,6 @@
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "absl/base/nullability.h"
#include "absl/strings/string_view.h"
@ -37,7 +36,6 @@
#include "api/ref_count.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/task_queue_base.h"
#include "rtc_base/arraysize.h"
#include "rtc_base/checks.h"
#include "rtc_base/system/rtc_export.h"
@ -601,7 +599,7 @@ class RTC_EXPORT AudioProcessing : public RefCountInterface {
// representation of the input is returned. Returns true/false to indicate
// whether an output returned.
virtual bool GetLinearAecOutput(
rtc::ArrayView<std::array<float, 160>> linear_output) const = 0;
ArrayView<std::array<float, 160>> linear_output) const = 0;
// This must be called prior to ProcessStream() if and only if adaptive analog
// gain control is enabled, to pass the current analog level from the audio
@ -643,14 +641,14 @@ class RTC_EXPORT AudioProcessing : public RefCountInterface {
// return value of true indicates that the file has been
// sucessfully opened, while a value of false indicates that
// opening the file failed.
virtual bool CreateAndAttachAecDump(
absl::string_view file_name,
int64_t max_log_size_bytes,
absl::Nonnull<TaskQueueBase*> worker_queue) = 0;
virtual bool CreateAndAttachAecDump(
absl::Nonnull<FILE*> handle,
int64_t max_log_size_bytes,
absl::Nonnull<TaskQueueBase*> worker_queue) = 0;
virtual bool CreateAndAttachAecDump(absl::string_view file_name,
int64_t max_log_size_bytes,
TaskQueueBase* absl_nonnull
worker_queue) = 0;
virtual bool CreateAndAttachAecDump(FILE* absl_nonnull handle,
int64_t max_log_size_bytes,
TaskQueueBase* absl_nonnull
worker_queue) = 0;
// TODO(webrtc:5298) Deprecated variant.
// Attaches provided webrtc::AecDump for recording debugging
@ -702,22 +700,16 @@ class RTC_EXPORT AudioProcessing : public RefCountInterface {
};
// Native rates supported by the integer interfaces.
enum NativeRate {
enum NativeRate : int {
kSampleRate8kHz = 8000,
kSampleRate16kHz = 16000,
kSampleRate32kHz = 32000,
kSampleRate48kHz = 48000
};
// TODO(kwiberg): We currently need to support a compiler (Visual C++) that
// complains if we don't explicitly state the size of the array here. Remove
// the size when that's no longer the case.
static constexpr int kNativeSampleRatesHz[4] = {
static constexpr std::array kNativeSampleRatesHz = {
kSampleRate8kHz, kSampleRate16kHz, kSampleRate32kHz, kSampleRate48kHz};
static constexpr size_t kNumNativeSampleRates =
arraysize(kNativeSampleRatesHz);
static constexpr int kMaxNativeSampleRateHz =
kNativeSampleRatesHz[kNumNativeSampleRates - 1];
static constexpr int kMaxNativeSampleRateHz = kNativeSampleRatesHz.back();
// APM processes audio in chunks of about 10 ms. See GetFrameSize() for
// details.
@ -748,7 +740,7 @@ class AudioProcessingBuilderInterface {
public:
virtual ~AudioProcessingBuilderInterface() = default;
virtual absl::Nullable<scoped_refptr<AudioProcessing>> Build(
virtual absl_nullable scoped_refptr<AudioProcessing> Build(
const Environment& env) = 0;
};
@ -757,9 +749,9 @@ class AudioProcessingBuilderInterface {
// nullptr `audio_processing` is not supported as in some scenarios that imply
// no audio processing, while in others - default builtin audio processing.
// Callers should be explicit which of these two behaviors they want.
absl::Nonnull<std::unique_ptr<AudioProcessingBuilderInterface>>
absl_nonnull std::unique_ptr<AudioProcessingBuilderInterface>
CustomAudioProcessing(
absl::Nonnull<scoped_refptr<AudioProcessing>> audio_processing);
absl_nonnull scoped_refptr<AudioProcessing> audio_processing);
// Experimental interface for a custom analysis submodule.
class CustomAudioAnalyzer {
@ -889,11 +881,10 @@ class EchoDetector : public RefCountInterface {
int num_render_channels) = 0;
// Analysis (not changing) of the first channel of the render signal.
virtual void AnalyzeRenderAudio(rtc::ArrayView<const float> render_audio) = 0;
virtual void AnalyzeRenderAudio(ArrayView<const float> render_audio) = 0;
// Analysis (not changing) of the capture signal.
virtual void AnalyzeCaptureAudio(
rtc::ArrayView<const float> capture_audio) = 0;
virtual void AnalyzeCaptureAudio(ArrayView<const float> capture_audio) = 0;
struct Metrics {
std::optional<double> echo_likelihood;

View File

@ -11,8 +11,12 @@
#ifndef API_AUDIO_AUDIO_VIEW_H_
#define API_AUDIO_AUDIO_VIEW_H_
#include <cstddef>
#include <iterator>
#include <variant>
#include <vector>
#include "api/array_view.h"
#include "api/audio/channel_layout.h"
#include "rtc_base/checks.h"
namespace webrtc {
@ -29,7 +33,7 @@ namespace webrtc {
// buffer. Channels can be enumerated and accessing the individual channel
// data is done via MonoView<>.
//
// The views are comparable to and built on rtc::ArrayView<> but add
// The views are comparable to and built on webrtc::ArrayView<> but add
// audio specific properties for the dimensions of the buffer and the above
// specialized [de]interleaved support.
//
@ -40,7 +44,14 @@ namespace webrtc {
// can be either an single channel (mono) interleaved buffer (e.g. AudioFrame),
// or a de-interleaved channel (e.g. from AudioBuffer).
template <typename T>
using MonoView = rtc::ArrayView<T>;
using MonoView = ArrayView<T>;
// The maximum number of audio channels supported by WebRTC encoders, decoders
// and the AudioFrame class.
// TODO(peah, tommi): Should kMaxNumberOfAudioChannels be 16 rather than 24?
// The reason is that AudioFrame's max number of samples is 7680, which can
// hold 16 10ms 16bit channels at 48 kHz (and not 24 channels).
static constexpr size_t kMaxNumberOfAudioChannels = 24;
// InterleavedView<> is a view over an interleaved audio buffer (e.g. from
// AudioFrame).
@ -56,7 +67,7 @@ class InterleavedView {
: num_channels_(num_channels),
samples_per_channel_(samples_per_channel),
data_(data, num_channels * samples_per_channel) {
RTC_DCHECK_LE(num_channels_, kMaxConcurrentChannels);
RTC_DCHECK_LE(num_channels_, kMaxNumberOfAudioChannels);
RTC_DCHECK(num_channels_ == 0u || samples_per_channel_ != 0u);
}
@ -77,7 +88,7 @@ class InterleavedView {
size_t num_channels() const { return num_channels_; }
size_t samples_per_channel() const { return samples_per_channel_; }
rtc::ArrayView<T> data() const { return data_; }
ArrayView<T> data() const { return data_; }
bool empty() const { return data_.empty(); }
size_t size() const { return data_.size(); }
@ -116,7 +127,7 @@ class InterleavedView {
// construction.
size_t num_channels_ = 0u;
size_t samples_per_channel_ = 0u;
rtc::ArrayView<T> data_;
ArrayView<T> data_;
};
template <typename T>
@ -126,31 +137,65 @@ class DeinterleavedView {
DeinterleavedView() = default;
// Construct a view where all the channels are coallocated in a single buffer.
template <typename U>
DeinterleavedView(U* data, size_t samples_per_channel, size_t num_channels)
: num_channels_(num_channels),
samples_per_channel_(samples_per_channel),
data_(data, num_channels * samples_per_channel_) {}
data_(data) {}
// Construct a view from an array of channel pointers where the channels
// may all be allocated seperately.
template <typename U>
DeinterleavedView(U* const* channels,
size_t samples_per_channel,
size_t num_channels)
: num_channels_(num_channels),
samples_per_channel_(samples_per_channel),
data_(channels) {}
// Construct a view from an array of channel pointers where the pointers are
// helt in a `std::vector<>`.
template <typename U>
DeinterleavedView(const std::vector<U*>& channels, size_t samples_per_channel)
: num_channels_(channels.size()),
samples_per_channel_(samples_per_channel),
data_(channels.data()) {}
// Construct a view from another view. Note that the type of
// the other view may be different from the current type and
// therefore the internal data types may not be exactly the
// same, but still compatible.
// E.g.:
// DeinterleavedView<float> mutable_view;
// DeinterleavedView<const float> const_view(mutable_view);
template <typename U>
DeinterleavedView(const DeinterleavedView<U>& other)
: num_channels_(other.num_channels()),
samples_per_channel_(other.samples_per_channel()),
data_(other.data()) {}
: num_channels_(other.num_channels_),
samples_per_channel_(other.samples_per_channel()) {
if (other.is_ptr_array()) {
data_ = std::get<U* const*>(other.data_);
} else {
data_ = std::get<U*>(other.data_);
}
}
// Returns a deinterleaved channel where `idx` is the zero based index,
// in the range [0 .. num_channels()-1].
MonoView<T> operator[](size_t idx) const {
RTC_DCHECK_LT(idx, num_channels_);
return MonoView<T>(&data_[idx * samples_per_channel_],
RTC_DCHECK_LT(idx, num_channels());
if (is_ptr_array())
return MonoView<T>(std::get<T* const*>(data_)[idx], samples_per_channel_);
return MonoView<T>(&std::get<T*>(data_)[idx * samples_per_channel_],
samples_per_channel_);
}
size_t num_channels() const { return num_channels_; }
size_t samples_per_channel() const { return samples_per_channel_; }
rtc::ArrayView<T> data() const { return data_; }
bool empty() const { return data_.empty(); }
size_t size() const { return data_.size(); }
bool empty() const {
return num_channels_ == 0u || samples_per_channel_ == 0u;
}
size_t size() const { return num_channels_ * samples_per_channel_; }
// Returns the first (and possibly only) channel.
MonoView<T> AsMono() const {
@ -158,12 +203,23 @@ class DeinterleavedView {
return (*this)[0];
}
// Zeros out all samples in channels represented by the view.
void Clear() {
for (size_t i = 0u; i < num_channels_; ++i) {
MonoView<T> view = (*this)[i];
ClearSamples(view);
}
}
private:
// TODO(tommi): Consider having these be stored as uint16_t to save a few
// bytes per view. Use `dchecked_cast` to support size_t during construction.
bool is_ptr_array() const { return std::holds_alternative<T* const*>(data_); }
template <typename U>
friend class DeinterleavedView;
size_t num_channels_ = 0u;
size_t samples_per_channel_ = 0u;
rtc::ArrayView<T> data_;
std::variant<T* const*, T*> data_;
};
template <typename T>

View File

@ -17,11 +17,10 @@
#include "api/make_ref_counted.h"
#include "api/scoped_refptr.h"
#include "modules/audio_processing/audio_processing_impl.h"
#include "rtc_base/logging.h"
namespace webrtc {
absl::Nullable<scoped_refptr<AudioProcessing>>
absl_nullable scoped_refptr<AudioProcessing>
BuiltinAudioProcessingBuilder::Build(const Environment& env) {
return make_ref_counted<AudioProcessingImpl>(
env, config_, std::move(capture_post_processing_),

View File

@ -64,7 +64,7 @@ class RTC_EXPORT BuiltinAudioProcessingBuilder
// Sets the echo detector to inject when APM is created.
BuiltinAudioProcessingBuilder& SetEchoDetector(
rtc::scoped_refptr<EchoDetector> echo_detector) {
scoped_refptr<EchoDetector> echo_detector) {
echo_detector_ = std::move(echo_detector);
return *this;
}
@ -79,7 +79,7 @@ class RTC_EXPORT BuiltinAudioProcessingBuilder
// Creates an APM instance with the specified config or the default one if
// unspecified. Injects the specified components transferring the ownership
// to the newly created APM instance.
absl::Nullable<scoped_refptr<AudioProcessing>> Build(
absl_nullable scoped_refptr<AudioProcessing> Build(
const Environment& env) override;
private:

View File

@ -12,7 +12,8 @@
#include <stddef.h>
#include "rtc_base/arraysize.h"
#include <iterator>
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
@ -170,7 +171,7 @@ static const int kChannelOrderings[CHANNEL_LAYOUT_MAX + 1][CHANNELS_MAX + 1] = {
};
int ChannelLayoutToChannelCount(ChannelLayout layout) {
RTC_DCHECK_LT(static_cast<size_t>(layout), arraysize(kLayoutToChannels));
RTC_DCHECK_LT(static_cast<size_t>(layout), std::size(kLayoutToChannels));
RTC_DCHECK_LE(kLayoutToChannels[layout], kMaxConcurrentChannels);
return kLayoutToChannels[layout];
}
@ -201,8 +202,8 @@ ChannelLayout GuessChannelLayout(int channels) {
}
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]));
RTC_DCHECK_LT(static_cast<size_t>(layout), std::size(kChannelOrderings));
RTC_DCHECK_LT(static_cast<size_t>(channel), std::size(kChannelOrderings[0]));
return kChannelOrderings[layout][channel];
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2025 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/create_audio_device_module.h"
#include "absl/base/nullability.h"
#include "api/audio/audio_device.h"
#include "api/environment/environment.h"
#include "api/scoped_refptr.h"
#include "modules/audio_device/audio_device_impl.h"
namespace webrtc {
absl_nullable scoped_refptr<AudioDeviceModule> CreateAudioDeviceModule(
const Environment& env,
AudioDeviceModule::AudioLayer audio_layer) {
return AudioDeviceModuleImpl::Create(env, audio_layer);
}
} // namespace webrtc

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2025 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_CREATE_AUDIO_DEVICE_MODULE_H_
#define API_AUDIO_CREATE_AUDIO_DEVICE_MODULE_H_
#include "absl/base/nullability.h"
#include "api/audio/audio_device.h"
#include "api/environment/environment.h"
#include "api/scoped_refptr.h"
namespace webrtc {
absl_nullable scoped_refptr<AudioDeviceModule> CreateAudioDeviceModule(
const Environment& env,
AudioDeviceModule::AudioLayer audio_layer);
} // namespace webrtc
#endif // API_AUDIO_CREATE_AUDIO_DEVICE_MODULE_H_

View File

@ -11,6 +11,7 @@
#include <algorithm>
#include <cmath>
#include <cstddef>
#include "rtc_base/checks.h"
#include "rtc_base/numerics/safe_minmax.h"
@ -275,4 +276,20 @@ bool EchoCanceller3Config::Validate(EchoCanceller3Config* config) {
return res;
}
EchoCanceller3Config EchoCanceller3Config::CreateDefaultMultichannelConfig() {
EchoCanceller3Config cfg;
// Use shorter and more rapidly adapting coarse filter to compensate for
// the increased number of total filter parameters to adapt.
cfg.filter.coarse.length_blocks = 11;
cfg.filter.coarse.rate = 0.95f;
cfg.filter.coarse_initial.length_blocks = 11;
cfg.filter.coarse_initial.rate = 0.95f;
// Use more conservative suppressor behavior for non-nearend speech.
cfg.suppressor.normal_tuning.max_dec_factor_lf = 0.35f;
cfg.suppressor.normal_tuning.max_inc_factor = 1.5f;
return cfg;
}
} // namespace webrtc

View File

@ -23,6 +23,9 @@ struct RTC_EXPORT EchoCanceller3Config {
// ranges. Returns true if and only of the config did not need to be changed.
static bool Validate(EchoCanceller3Config* config);
// Produces a default configuration for multichannel.
static EchoCanceller3Config CreateDefaultMultichannelConfig();
EchoCanceller3Config();
EchoCanceller3Config(const EchoCanceller3Config& e);
EchoCanceller3Config& operator=(const EchoCanceller3Config& other);

View File

@ -23,16 +23,21 @@ namespace webrtc {
EchoCanceller3Factory::EchoCanceller3Factory() {}
EchoCanceller3Factory::EchoCanceller3Factory(const EchoCanceller3Config& config)
: config_(config) {}
: config_(config), multichannel_config_(std::nullopt) {}
absl::Nonnull<std::unique_ptr<EchoControl>> EchoCanceller3Factory::Create(
EchoCanceller3Factory::EchoCanceller3Factory(
const EchoCanceller3Config& config,
std::optional<EchoCanceller3Config> multichannel_config)
: config_(config), multichannel_config_(multichannel_config) {}
absl_nonnull std::unique_ptr<EchoControl> EchoCanceller3Factory::Create(
const Environment& env,
int sample_rate_hz,
int num_render_channels,
int num_capture_channels) {
return std::make_unique<EchoCanceller3>(
env, config_, /*multichannel_config=*/std::nullopt, sample_rate_hz,
num_render_channels, num_capture_channels);
return std::make_unique<EchoCanceller3>(env, config_, multichannel_config_,
sample_rate_hz, num_render_channels,
num_capture_channels);
}
} // namespace webrtc

View File

@ -12,6 +12,7 @@
#define API_AUDIO_ECHO_CANCELLER3_FACTORY_H_
#include <memory>
#include <optional>
#include "absl/base/nullability.h"
#include "api/audio/echo_canceller3_config.h"
@ -30,8 +31,14 @@ class RTC_EXPORT EchoCanceller3Factory : public EchoControlFactory {
// configuration.
explicit EchoCanceller3Factory(const EchoCanceller3Config& config);
// Factory producing EchoCanceller3 instances with the specified
// configuration and multichannel configuration.
EchoCanceller3Factory(
const EchoCanceller3Config& config,
std::optional<EchoCanceller3Config> multichannel_config);
// Creates an EchoCanceller3 with a specified channel count and sampling rate.
absl::Nonnull<std::unique_ptr<EchoControl>> Create(
absl_nonnull std::unique_ptr<EchoControl> Create(
const Environment& env,
int sample_rate_hz,
int num_render_channels,
@ -39,6 +46,7 @@ class RTC_EXPORT EchoCanceller3Factory : public EchoControlFactory {
private:
const EchoCanceller3Config config_;
const std::optional<EchoCanceller3Config> multichannel_config_;
};
} // namespace webrtc

View File

@ -67,7 +67,7 @@ class EchoControlFactory {
public:
virtual ~EchoControlFactory() = default;
virtual absl::Nonnull<std::unique_ptr<EchoControl>> Create(
virtual absl_nonnull std::unique_ptr<EchoControl> Create(
const Environment& env,
int sample_rate_hz,
int num_render_channels,

View File

@ -9,13 +9,15 @@
*/
#include "api/audio/echo_detector_creator.h"
#include "api/audio/audio_processing.h"
#include "api/make_ref_counted.h"
#include "api/scoped_refptr.h"
#include "modules/audio_processing/residual_echo_detector.h"
namespace webrtc {
rtc::scoped_refptr<EchoDetector> CreateEchoDetector() {
return rtc::make_ref_counted<ResidualEchoDetector>();
scoped_refptr<EchoDetector> CreateEchoDetector() {
return make_ref_counted<ResidualEchoDetector>();
}
} // namespace webrtc

View File

@ -23,7 +23,10 @@ if (rtc_include_tests) {
deps = [
"..:aec3_config",
"..:audio_frame_api",
"../..:array_view",
"../../../modules/audio_processing:aec3_config_json",
"../../../rtc_base:checks",
"../../../rtc_base:macromagic",
"../../../test:test_support",
]
}

View File

@ -13,6 +13,9 @@
#include <stdint.h>
#include <string.h> // memcmp
#include "api/audio/audio_view.h"
#include "api/audio/channel_layout.h"
#include "rtc_base/checks.h"
#include "test/gtest.h"
namespace webrtc {

View File

@ -11,7 +11,12 @@
#include "api/audio/audio_view.h"
#include <array>
#include <cstddef>
#include <cstdint>
#include <vector>
#include "api/array_view.h"
#include "rtc_base/arraysize.h"
#include "test/gtest.h"
namespace webrtc {
@ -33,7 +38,7 @@ void Increment(int16_t& t) {
// Fills a given buffer with monotonically increasing values.
template <typename T>
void FillBuffer(rtc::ArrayView<T> buffer) {
void FillBuffer(ArrayView<T> buffer) {
T value = {};
for (T& t : buffer) {
Increment<T>(value);
@ -46,7 +51,7 @@ void FillBuffer(rtc::ArrayView<T> buffer) {
TEST(AudioViewTest, MonoView) {
const size_t kArraySize = 100u;
int16_t arr[kArraySize];
FillBuffer(rtc::ArrayView<int16_t>(arr));
FillBuffer(ArrayView<int16_t>(arr));
MonoView<int16_t> mono(arr);
MonoView<const int16_t> const_mono(arr);
@ -65,7 +70,7 @@ TEST(AudioViewTest, MonoView) {
TEST(AudioViewTest, InterleavedView) {
const size_t kArraySize = 100u;
int16_t arr[kArraySize];
FillBuffer(rtc::ArrayView<int16_t>(arr));
FillBuffer(ArrayView<int16_t>(arr));
InterleavedView<int16_t> interleaved(arr, kArraySize, 1);
EXPECT_EQ(NumChannels(interleaved), 1u);
@ -137,7 +142,7 @@ TEST(AudioViewTest, CopySamples) {
const size_t kArraySize = 100u;
int16_t source_arr[kArraySize] = {};
int16_t dest_arr[kArraySize] = {};
FillBuffer(rtc::ArrayView<int16_t>(source_arr));
FillBuffer(ArrayView<int16_t>(source_arr));
InterleavedView<const int16_t> source(source_arr, 2);
InterleavedView<int16_t> destination(dest_arr, 2);
@ -160,7 +165,7 @@ TEST(AudioViewTest, CopySamples) {
TEST(AudioViewTest, ClearSamples) {
std::array<int16_t, 100u> samples = {};
FillBuffer(rtc::ArrayView<int16_t>(samples));
FillBuffer(ArrayView<int16_t>(samples));
ASSERT_NE(samples[0], 0);
ClearSamples(samples);
for (const auto s : samples) {
@ -168,7 +173,7 @@ TEST(AudioViewTest, ClearSamples) {
}
std::array<float, 100u> samples_f = {};
FillBuffer(rtc::ArrayView<float>(samples_f));
FillBuffer(ArrayView<float>(samples_f));
ASSERT_NE(samples_f[0], 0.0);
ClearSamples(samples_f);
for (const auto s : samples_f) {
@ -176,7 +181,7 @@ TEST(AudioViewTest, ClearSamples) {
}
// Clear only half of the buffer
FillBuffer(rtc::ArrayView<int16_t>(samples));
FillBuffer(ArrayView<int16_t>(samples));
const auto half_way = samples.size() / 2;
ClearSamples(samples, half_way);
for (size_t i = 0u; i < samples.size(); ++i) {
@ -187,4 +192,31 @@ TEST(AudioViewTest, ClearSamples) {
}
}
}
TEST(AudioViewTest, DeinterleavedViewPointerArray) {
// Create vectors of varying sizes to guarantee that they don't end up
// aligned in memory.
std::vector<float> v1(100), v2(200), v3(300), v4(400);
std::vector<float*> channels = {&v1[0], &v2[0], &v3[0], &v4[0]};
DeinterleavedView<float> di(channels, v1.size());
EXPECT_EQ(NumChannels(di), channels.size());
EXPECT_EQ(SamplesPerChannel(di), v1.size());
EXPECT_EQ(di[0].data(), v1.data());
EXPECT_EQ(di[1].data(), v2.data());
EXPECT_EQ(di[2].data(), v3.data());
EXPECT_EQ(di[3].data(), v4.data());
// Test that the same thing works with T* const *.
float* channel_array[] = {&v1[0], &v2[0], &v3[0], &v4[0]};
di = DeinterleavedView<float>(channel_array, v1.size(),
arraysize(channel_array));
EXPECT_EQ(NumChannels(di), channels.size());
EXPECT_EQ(SamplesPerChannel(di), v1.size());
EXPECT_EQ(di[0].data(), v1.data());
EXPECT_EQ(di[1].data(), v2.data());
EXPECT_EQ(di[2].data(), v3.data());
EXPECT_EQ(di[3].data(), v4.data());
}
} // namespace webrtc

View File

@ -35,11 +35,13 @@ rtc_library("audio_codecs_api") {
"..:ref_count",
"..:scoped_refptr",
"../../api:rtp_parameters",
"../../api/audio:audio_frame_api",
"../../rtc_base:buffer",
"../../rtc_base:checks",
"../../rtc_base:event_tracer",
"../../rtc_base:refcount",
"../../rtc_base:sanitizer",
"../../rtc_base:stringutils",
"../../rtc_base/system:rtc_export",
"../environment",
"../units:data_rate",

View File

@ -15,7 +15,6 @@
#include <map>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "absl/strings/match.h"

View File

@ -27,9 +27,12 @@ namespace webrtc {
namespace {
// TODO(peah): Rationale
static_assert(AudioDecoder::kMaxNumberOfChannels <= 255, "");
class OldStyleEncodedFrame final : public AudioDecoder::EncodedAudioFrame {
public:
OldStyleEncodedFrame(AudioDecoder* decoder, rtc::Buffer&& payload)
OldStyleEncodedFrame(AudioDecoder* decoder, Buffer&& payload)
: decoder_(decoder), payload_(std::move(payload)) {}
size_t Duration() const override {
@ -38,7 +41,7 @@ class OldStyleEncodedFrame final : public AudioDecoder::EncodedAudioFrame {
}
std::optional<DecodeResult> Decode(
rtc::ArrayView<int16_t> decoded) const override {
ArrayView<int16_t> decoded) const override {
auto speech_type = AudioDecoder::kSpeech;
const int ret = decoder_->Decode(
payload_.data(), payload_.size(), decoder_->SampleRateHz(),
@ -50,7 +53,7 @@ class OldStyleEncodedFrame final : public AudioDecoder::EncodedAudioFrame {
private:
AudioDecoder* const decoder_;
const rtc::Buffer payload_;
const Buffer payload_;
};
} // namespace
@ -74,7 +77,7 @@ AudioDecoder::ParseResult& AudioDecoder::ParseResult::operator=(
ParseResult&& b) = default;
std::vector<AudioDecoder::ParseResult> AudioDecoder::ParsePayload(
rtc::Buffer&& payload,
Buffer&& payload,
uint32_t timestamp) {
std::vector<ParseResult> results;
std::unique_ptr<EncodedAudioFrame> frame(
@ -90,7 +93,7 @@ int AudioDecoder::Decode(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
TRACE_EVENT0("webrtc", "AudioDecoder::Decode");
MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
MsanCheckInitialized(MakeArrayView(encoded, encoded_len));
int duration = PacketDuration(encoded, encoded_len);
if (duration >= 0 &&
duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
@ -107,7 +110,7 @@ int AudioDecoder::DecodeRedundant(const uint8_t* encoded,
int16_t* decoded,
SpeechType* speech_type) {
TRACE_EVENT0("webrtc", "AudioDecoder::DecodeRedundant");
MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
MsanCheckInitialized(MakeArrayView(encoded, encoded_len));
int duration = PacketDurationRedundant(encoded, encoded_len);
if (duration >= 0 &&
duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
@ -137,7 +140,7 @@ size_t AudioDecoder::DecodePlc(size_t /* num_frames */,
// TODO(bugs.webrtc.org/9676): Remove default implementation.
void AudioDecoder::GeneratePlc(size_t /*requested_samples_per_channel*/,
rtc::BufferT<int16_t>* /*concealment_audio*/) {}
BufferT<int16_t>* /*concealment_audio*/) {}
int AudioDecoder::ErrorCode() {
return 0;

View File

@ -19,6 +19,7 @@
#include <vector>
#include "api/array_view.h"
#include "api/audio/audio_view.h"
#include "rtc_base/buffer.h"
namespace webrtc {
@ -62,7 +63,7 @@ class AudioDecoder {
// decoder produced comfort noise or speech. On failure, returns an empty
// std::optional. Decode may be called at most once per frame object.
virtual std::optional<DecodeResult> Decode(
rtc::ArrayView<int16_t> decoded) const = 0;
ArrayView<int16_t> decoded) const = 0;
};
struct ParseResult {
@ -90,7 +91,7 @@ class AudioDecoder {
// 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,
virtual std::vector<ParseResult> ParsePayload(Buffer&& payload,
uint32_t timestamp);
// TODO(bugs.webrtc.org/10098): The Decode and DecodeRedundant methods are
@ -140,7 +141,7 @@ class AudioDecoder {
// 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);
BufferT<int16_t>* concealment_audio);
// Resets the decoder state (empty buffers etc.).
virtual void Reset() = 0;
@ -173,7 +174,7 @@ class AudioDecoder {
virtual size_t Channels() const = 0;
// The maximum number of audio channels supported by WebRTC decoders.
static constexpr int kMaxNumberOfChannels = 24;
static constexpr int kMaxNumberOfChannels = kMaxNumberOfAudioChannels;
protected:
static SpeechType ConvertSpeechType(int16_t type);

View File

@ -45,7 +45,7 @@ class AudioDecoderFactory : public RefCountInterface {
// Note: Implementations need to be robust against combinations other than
// one encoder, one decoder getting the same ID; such decoders must still
// work.
virtual absl::Nullable<std::unique_ptr<AudioDecoder>> Create(
virtual absl_nullable std::unique_ptr<AudioDecoder> Create(
const Environment& env,
const SdpAudioFormat& format,
std::optional<AudioCodecPairId> codec_pair_id) = 0;

View File

@ -14,8 +14,10 @@
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>
#include "absl/base/nullability.h"
#include "api/audio_codecs/audio_codec_pair_id.h"
#include "api/audio_codecs/audio_decoder.h"
#include "api/audio_codecs/audio_decoder_factory.h"
@ -40,7 +42,7 @@ struct Helper<> {
return false;
}
static absl::Nullable<std::unique_ptr<AudioDecoder>> MakeAudioDecoder(
static absl_nullable std::unique_ptr<AudioDecoder> MakeAudioDecoder(
const Environment& /* env */,
const SdpAudioFormat& /* format */,
std::optional<AudioCodecPairId> /* codec_pair_id */) {
@ -59,7 +61,7 @@ template <typename Trait,
std::declval<typename Trait::Config>(),
std::declval<std::optional<AudioCodecPairId>>())),
std::unique_ptr<AudioDecoder>>>>
absl::Nullable<std::unique_ptr<AudioDecoder>> CreateDecoder(
absl_nullable std::unique_ptr<AudioDecoder> CreateDecoder(
Rank1,
const Environment& env,
const typename Trait::Config& config,
@ -73,7 +75,7 @@ template <typename Trait,
std::declval<typename Trait::Config>(),
std::declval<std::optional<AudioCodecPairId>>())),
std::unique_ptr<AudioDecoder>>>>
absl::Nullable<std::unique_ptr<AudioDecoder>> CreateDecoder(
absl_nullable std::unique_ptr<AudioDecoder> CreateDecoder(
Rank0,
const Environment& /* env */,
const typename Trait::Config& config,
@ -98,7 +100,7 @@ struct Helper<T, Ts...> {
return opt_config ? true : Helper<Ts...>::IsSupportedDecoder(format);
}
static absl::Nullable<std::unique_ptr<AudioDecoder>> MakeAudioDecoder(
static absl_nullable std::unique_ptr<AudioDecoder> MakeAudioDecoder(
const Environment& env,
const SdpAudioFormat& format,
std::optional<AudioCodecPairId> codec_pair_id) {
@ -122,7 +124,7 @@ class AudioDecoderFactoryT : public AudioDecoderFactory {
return Helper<Ts...>::IsSupportedDecoder(format);
}
absl::Nullable<std::unique_ptr<AudioDecoder>> Create(
absl_nullable std::unique_ptr<AudioDecoder> Create(
const Environment& env,
const SdpAudioFormat& format,
std::optional<AudioCodecPairId> codec_pair_id) override {

View File

@ -24,6 +24,9 @@
namespace webrtc {
// TODO(peah): Rationale
static_assert(AudioEncoder::kMaxNumberOfChannels <= 255, "");
ANAStats::ANAStats() = default;
ANAStats::~ANAStats() = default;
ANAStats::ANAStats(const ANAStats&) = default;
@ -41,10 +44,9 @@ int AudioEncoder::RtpTimestampRateHz() const {
return SampleRateHz();
}
AudioEncoder::EncodedInfo AudioEncoder::Encode(
uint32_t rtp_timestamp,
rtc::ArrayView<const int16_t> audio,
rtc::Buffer* encoded) {
AudioEncoder::EncodedInfo AudioEncoder::Encode(uint32_t rtp_timestamp,
ArrayView<const int16_t> audio,
Buffer* encoded) {
TRACE_EVENT0("webrtc", "AudioEncoder::Encode");
RTC_CHECK_EQ(audio.size(),
static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
@ -75,7 +77,7 @@ void AudioEncoder::SetMaxPlaybackRate(int /* frequency_hz */) {}
void AudioEncoder::SetTargetBitrate(int /* target_bps */) {}
rtc::ArrayView<std::unique_ptr<AudioEncoder>>
ArrayView<std::unique_ptr<AudioEncoder>>
AudioEncoder::ReclaimContainedEncoders() {
return nullptr;
}

View File

@ -22,6 +22,7 @@
#include "absl/base/attributes.h"
#include "api/array_view.h"
#include "api/audio/audio_view.h"
#include "api/call/bitrate_allocation.h"
#include "api/units/data_rate.h"
#include "api/units/time_delta.h"
@ -191,8 +192,8 @@ class AudioEncoder {
// 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);
ArrayView<const int16_t> audio,
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.
@ -237,8 +238,7 @@ class AudioEncoder {
// 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();
virtual ArrayView<std::unique_ptr<AudioEncoder>> ReclaimContainedEncoders();
// Enables audio network adaptor. Returns true if successful.
virtual bool EnableAudioNetworkAdaptor(const std::string& config_string,
@ -297,7 +297,7 @@ class AudioEncoder {
}
// The maximum number of audio channels supported by WebRTC encoders.
static constexpr int kMaxNumberOfChannels = 24;
static constexpr int kMaxNumberOfChannels = kMaxNumberOfAudioChannels;
// RingRTC Change to configure opus
virtual bool Configure(const Config& config) {
@ -309,8 +309,8 @@ class AudioEncoder {
// 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;
ArrayView<const int16_t> audio,
Buffer* encoded) = 0;
};
} // namespace webrtc
#endif // API_AUDIO_CODECS_AUDIO_ENCODER_H_

View File

@ -15,12 +15,12 @@
#include <optional>
#include <vector>
#include "absl/base/nullability.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/environment/environment.h"
#include "rtc_base/checks.h"
#include "rtc_base/ref_count.h"
#include "api/ref_count.h"
namespace webrtc {
@ -58,7 +58,7 @@ class AudioEncoderFactory : public RefCountInterface {
// Creates an AudioEncoder for the specified format.
// Returns null if the format isn't supported.
virtual absl::Nullable<std::unique_ptr<AudioEncoder>> Create(
virtual absl_nullable std::unique_ptr<AudioEncoder> Create(
const Environment& env,
const SdpAudioFormat& format,
Options options) = 0;

View File

@ -14,6 +14,7 @@
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>
#include "absl/base/nullability.h"
@ -41,7 +42,7 @@ struct Helper<> {
const SdpAudioFormat& /* format */) {
return std::nullopt;
}
static absl::Nullable<std::unique_ptr<AudioEncoder>> CreateAudioEncoder(
static absl_nullable std::unique_ptr<AudioEncoder> CreateAudioEncoder(
const Environment& /* env */,
const SdpAudioFormat& /* format */,
const AudioEncoderFactory::Options& /* options */) {
@ -60,7 +61,7 @@ template <typename Trait,
std::declval<typename Trait::Config>(),
std::declval<AudioEncoderFactory::Options>())),
std::unique_ptr<AudioEncoder>>>>
absl::Nullable<std::unique_ptr<AudioEncoder>> CreateEncoder(
absl_nullable std::unique_ptr<AudioEncoder> CreateEncoder(
Rank1,
const Environment& env,
const typename Trait::Config& config,
@ -75,7 +76,7 @@ template <typename Trait,
int{},
std::declval<std::optional<AudioCodecPairId>>())),
std::unique_ptr<AudioEncoder>>>>
absl::Nullable<std::unique_ptr<AudioEncoder>> CreateEncoder(
absl_nullable std::unique_ptr<AudioEncoder> CreateEncoder(
Rank0,
const Environment& /* env */,
const typename Trait::Config& config,
@ -104,7 +105,7 @@ struct Helper<T, Ts...> {
: Helper<Ts...>::QueryAudioEncoder(format);
}
static absl::Nullable<std::unique_ptr<AudioEncoder>> CreateAudioEncoder(
static absl_nullable std::unique_ptr<AudioEncoder> CreateAudioEncoder(
const Environment& env,
const SdpAudioFormat& format,
const AudioEncoderFactory::Options& options) {
@ -129,7 +130,7 @@ class AudioEncoderFactoryT : public AudioEncoderFactory {
return Helper<Ts...>::QueryAudioEncoder(format);
}
absl::Nullable<std::unique_ptr<AudioEncoder>> Create(
absl_nullable std::unique_ptr<AudioEncoder> Create(
const Environment& env,
const SdpAudioFormat& format,
Options options) override {
@ -181,7 +182,7 @@ class AudioEncoderFactoryT : public AudioEncoderFactory {
// TODO(kwiberg): Point at CreateBuiltinAudioEncoderFactory() for an example of
// how it is used.
template <typename... Ts>
rtc::scoped_refptr<AudioEncoderFactory> CreateAudioEncoderFactory() {
scoped_refptr<AudioEncoderFactory> CreateAudioEncoderFactory() {
// 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
@ -189,7 +190,7 @@ rtc::scoped_refptr<AudioEncoderFactory> CreateAudioEncoderFactory() {
static_assert(sizeof...(Ts) >= 1,
"Caller must give at least one template parameter");
return rtc::make_ref_counted<
return make_ref_counted<
audio_encoder_factory_template_impl::AudioEncoderFactoryT<Ts...>>();
}

View File

@ -19,7 +19,8 @@
#include "absl/strings/string_view.h"
#include "api/rtp_parameters.h"
#include "rtc_base/checks.h"
#include "rtc_base/system/rtc_export.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/system/rtc_export.h" // IWYU pragma: private
namespace webrtc {
@ -54,6 +55,23 @@ struct RTC_EXPORT SdpAudioFormat {
return !(a == b);
}
template <typename Sink>
friend void AbslStringify(Sink& sink, const SdpAudioFormat& saf) {
StringBuilder sb("{");
bool first = true;
for (const auto& [key, value] : saf.parameters) {
if (!first) {
sb << ", ";
}
first = false;
sb << key << ": " << value;
}
sb << "}";
absl::Format(
&sink, "{name: %s, clockrate_hz: %d, num_channels: %d, parameters: %v}",
saf.name, saf.clockrate_hz, saf.num_channels, sb.Release());
}
std::string name;
int clockrate_hz;
size_t num_channels;
@ -105,6 +123,17 @@ struct AudioCodecInfo {
return min_bitrate_bps == max_bitrate_bps;
}
template <typename Sink>
friend void AbslStringify(Sink& sink, const AudioCodecInfo& aci) {
absl::Format(&sink,
"{sample_rate_hz: %d, num_channels: %d, default_bitrate_bps: "
"%d, min_bitrate_bps: %d, max_bitrate_bps: %d, "
"allow_comfort_noise: %v, supports_network_adaption: %v}",
aci.sample_rate_hz, aci.num_channels, aci.default_bitrate_bps,
aci.min_bitrate_bps, aci.max_bitrate_bps,
aci.allow_comfort_noise, aci.supports_network_adaption);
}
int sample_rate_hz;
size_t num_channels;
int default_bitrate_bps;
@ -126,6 +155,11 @@ struct AudioCodecSpec {
bool operator!=(const AudioCodecSpec& b) const { return !(*this == b); }
template <typename Sink>
friend void AbslStringify(Sink& sink, const AudioCodecSpec& acs) {
absl::Format(&sink, "{format: %v, info: %v}", acs.format, acs.info);
}
SdpAudioFormat format;
AudioCodecInfo info;
};

View File

@ -52,7 +52,7 @@ struct NotAdvertised {
} // namespace
rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() {
scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() {
return CreateAudioDecoderFactory<
#if WEBRTC_USE_BUILTIN_OPUS

View File

@ -21,7 +21,7 @@ namespace webrtc {
// only need a subset of the codecs, consider using
// CreateAudioDecoderFactory<...codecs listed here...>() or
// CreateOpusAudioDecoderFactory() instead.
rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory();
scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory();
} // namespace webrtc

View File

@ -59,7 +59,7 @@ struct NotAdvertised {
} // namespace
rtc::scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory() {
scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory() {
return CreateAudioEncoderFactory<
#if WEBRTC_USE_BUILTIN_OPUS

View File

@ -21,7 +21,7 @@ namespace webrtc {
// only need a subset of the codecs, consider using
// CreateAudioEncoderFactory<...codecs listed here...>() or
// CreateOpusAudioEncoderFactory() instead.
rtc::scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory();
scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory();
} // namespace webrtc

View File

@ -16,7 +16,6 @@
#include <map>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "absl/strings/match.h"

View File

@ -15,7 +15,6 @@
#include <map>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "absl/strings/match.h"

View File

@ -20,7 +20,10 @@ rtc_library("audio_encoder_opus_config") {
"audio_encoder_opus_config.cc",
"audio_encoder_opus_config.h",
]
deps = [ "../../../rtc_base/system:rtc_export" ]
deps = [
"..:audio_codecs_api",
"../../../rtc_base/system:rtc_export",
]
defines = []
if (rtc_opus_variable_complexity) {
defines += [ "WEBRTC_OPUS_VARIABLE_COMPLEXITY=1" ]
@ -59,6 +62,7 @@ rtc_library("audio_decoder_opus") {
]
deps = [
"..:audio_codecs_api",
"../..:field_trials_view",
"../../../modules/audio_coding:webrtc_opus",
"../../../rtc_base:checks",
"../../../rtc_base/system:rtc_export",
@ -105,6 +109,7 @@ rtc_library("unittests") {
sources = [ "audio_decoder_opus_unittest.cc" ]
deps = [
":audio_decoder_opus",
"..:audio_codecs_api",
"../../../api/environment",
"../../../api/environment:environment_factory",
"../../../test:explicit_key_value_config",

View File

@ -11,6 +11,7 @@
#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 <cstddef>
#include <vector>
#include "api/audio_codecs/audio_decoder.h"
@ -54,7 +55,7 @@ struct AudioDecoderMultiChannelOpusConfig {
}
}
if (num_channels > 255 || max_coded_channel >= 255) {
if (max_coded_channel >= 255) {
return false;
}
return true;

View File

@ -18,9 +18,10 @@
#include <vector>
#include "absl/strings/match.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/environment/environment.h"
#include "api/field_trials_view.h"
#include "modules/audio_coding/codecs/opus/audio_decoder_opus.h"
#include "rtc_base/checks.h"

View File

@ -10,8 +10,11 @@
#include "api/audio_codecs/opus/audio_decoder_opus.h"
#include <string>
#include <cstddef>
#include <memory>
#include <optional>
#include "api/audio_codecs/audio_format.h"
#include "api/environment/environment.h"
#include "api/environment/environment_factory.h"
#include "test/explicit_key_value_config.h"

View File

@ -10,8 +10,16 @@
#include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h"
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#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 "modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h"
namespace webrtc {

View File

@ -10,6 +10,11 @@
#include "api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h"
#include <cstddef>
#include <vector>
#include "api/audio_codecs/audio_encoder.h"
namespace webrtc {
namespace {
@ -39,7 +44,7 @@ AudioEncoderMultiChannelOpusConfig::operator=(
bool AudioEncoderMultiChannelOpusConfig::IsOk() const {
if (frame_size_ms <= 0 || frame_size_ms % 10 != 0)
return false;
if (num_channels >= 255) {
if (num_channels > AudioEncoder::kMaxNumberOfChannels) {
return false;
}
if (bitrate_bps < kMinBitrateBps || bitrate_bps > kMaxBitrateBps)

View File

@ -14,11 +14,11 @@
#include <optional>
#include <vector>
#include "api/audio_codecs/audio_codec_pair_id.h"
#include "api/audio_codecs/audio_encoder.h"
#include "api/audio_codecs/audio_encoder_factory.h"
#include "api/audio_codecs/audio_format.h"
#include "api/audio_codecs/opus/audio_encoder_opus_config.h"
#include "api/environment/environment.h"
#include "modules/audio_coding/codecs/opus/audio_encoder_opus.h"
#include "rtc_base/checks.h"

View File

@ -10,6 +10,8 @@
#include "api/audio_codecs/opus/audio_encoder_opus_config.h"
#include "api/audio_codecs/audio_encoder.h"
namespace webrtc {
namespace {
@ -59,7 +61,7 @@ bool AudioEncoderOpusConfig::IsOk() const {
// well; we can add support for them when needed.)
return false;
}
if (num_channels >= 255) {
if (num_channels > AudioEncoder::kMaxNumberOfChannels) {
return false;
}
if (!bitrate_bps)

View File

@ -47,7 +47,7 @@ struct NotAdvertised {
} // namespace
rtc::scoped_refptr<AudioDecoderFactory> CreateOpusAudioDecoderFactory() {
scoped_refptr<AudioDecoderFactory> CreateOpusAudioDecoderFactory() {
return CreateAudioDecoderFactory<
AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>>();
}

View File

@ -19,7 +19,7 @@ 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();
scoped_refptr<AudioDecoderFactory> CreateOpusAudioDecoderFactory();
} // namespace webrtc

View File

@ -53,7 +53,7 @@ struct NotAdvertised {
} // namespace
rtc::scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory() {
scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory() {
return CreateAudioEncoderFactory<
AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>>();
}

View File

@ -19,7 +19,7 @@ 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();
scoped_refptr<AudioEncoderFactory> CreateOpusAudioEncoderFactory();
} // namespace webrtc

View File

@ -156,8 +156,8 @@ TEST(AudioDecoderFactoryTemplateTest,
TEST(AudioDecoderFactoryTemplateTest, NoDecoderTypes) {
const Environment env = CreateEnvironment();
rtc::scoped_refptr<AudioDecoderFactory> factory(
rtc::make_ref_counted<
scoped_refptr<AudioDecoderFactory> factory(
make_ref_counted<
audio_decoder_factory_template_impl::AudioDecoderFactoryT<>>());
EXPECT_THAT(factory->GetSupportedDecoders(), ::testing::IsEmpty());
EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
@ -284,5 +284,14 @@ TEST(AudioDecoderFactoryTemplateTest, Opus) {
EXPECT_EQ(48000, dec->SampleRateHz());
}
TEST(AudioDecoderFactoryTemplateTest, G711TooManyChannels) {
auto factory = CreateAudioDecoderFactory<AudioDecoderG711>();
const Environment env = CreateEnvironment();
EXPECT_EQ(nullptr, factory->Create(env,
{"pcmu", 16000,
/* num_channels=*/1000},
std::nullopt));
}
} // namespace
} // namespace webrtc

View File

@ -184,8 +184,8 @@ TEST(AudioEncoderFactoryTemplateTest, CanUseTraitWithOnlyV2MakeAudioEncoder) {
TEST(AudioEncoderFactoryTemplateTest, NoEncoderTypes) {
const Environment env = CreateEnvironment();
rtc::scoped_refptr<AudioEncoderFactory> factory(
rtc::make_ref_counted<
scoped_refptr<AudioEncoderFactory> factory(
make_ref_counted<
audio_encoder_factory_template_impl::AudioEncoderFactoryT<>>());
EXPECT_THAT(factory->GetSupportedEncoders(), ::testing::IsEmpty());
EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1}));

View File

@ -16,11 +16,11 @@
#include "api/array_view.h"
#include "rtc_base/strings/string_builder.h"
namespace cricket {
namespace webrtc {
namespace {
template <class T>
void ToStringIfSet(rtc::SimpleStringBuilder* result,
void ToStringIfSet(SimpleStringBuilder* result,
const char* key,
const std::optional<T>& val) {
if (val) {
@ -81,7 +81,7 @@ bool AudioOptions::operator==(const AudioOptions& o) const {
std::string AudioOptions::ToString() const {
char buffer[1024];
rtc::SimpleStringBuilder result(buffer);
SimpleStringBuilder result(buffer);
result << "AudioOptions {";
ToStringIfSet(&result, "aec", echo_cancellation);
#if defined(WEBRTC_IOS)
@ -104,4 +104,4 @@ std::string AudioOptions::ToString() const {
return result.str();
}
} // namespace cricket
} // namespace webrtc

View File

@ -16,7 +16,7 @@
#include "rtc_base/system/rtc_export.h"
namespace cricket {
namespace webrtc {
// Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine.
// Used to be flags, but that makes it hard to selectively apply options.
@ -68,6 +68,14 @@ struct RTC_EXPORT AudioOptions {
std::optional<bool> init_recording_on_send;
};
} // namespace webrtc
// Re-export symbols from the webrtc namespace for backwards compatibility.
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES
namespace cricket {
using ::webrtc::AudioOptions;
} // namespace cricket
#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES
#endif // API_AUDIO_OPTIONS_H_

View File

@ -28,7 +28,8 @@ struct PacketOptions {
// as packet_id not being set.
int64_t packet_id = -1;
// Whether this is an audio or video packet, excluding retransmissions.
bool is_media = true;
// Defaults to `false` which is the more common case.
bool is_media = false;
bool included_in_feedback = false;
bool included_in_allocation = false;
bool send_as_ect1 = false;
@ -40,12 +41,13 @@ struct PacketOptions {
class Transport {
public:
virtual bool SendRtp(rtc::ArrayView<const uint8_t> packet,
virtual bool SendRtp(ArrayView<const uint8_t> packet,
const PacketOptions& options) = 0;
virtual bool SendRtcp(rtc::ArrayView<const uint8_t> packet) = 0;
virtual bool SendRtcp(ArrayView<const uint8_t> packet,
const PacketOptions& options) = 0;
protected:
virtual ~Transport() {}
virtual ~Transport() = default;
};
} // namespace webrtc

View File

@ -14,6 +14,7 @@
#include <cstdint>
#include <string>
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "p2p/base/p2p_constants.h"
#include "rtc_base/checks.h"
@ -22,7 +23,6 @@
#include "rtc_base/ip_address.h"
#include "rtc_base/network_constants.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/strings/string_builder.h"
using webrtc::IceCandidateType;
@ -46,10 +46,10 @@ namespace webrtc {
Candidate::Candidate()
: id_(CreateRandomString(8)),
component_(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT),
component_(ICE_CANDIDATE_COMPONENT_DEFAULT),
priority_(0),
network_type_(webrtc::ADAPTER_TYPE_UNKNOWN),
underlying_type_for_vpn_(webrtc::ADAPTER_TYPE_UNKNOWN),
network_type_(ADAPTER_TYPE_UNKNOWN),
underlying_type_for_vpn_(ADAPTER_TYPE_UNKNOWN),
generation_(0),
network_id_(0),
network_cost_(0) {}
@ -73,8 +73,8 @@ Candidate::Candidate(int component,
username_(username),
password_(password),
type_(type),
network_type_(webrtc::ADAPTER_TYPE_UNKNOWN),
underlying_type_for_vpn_(webrtc::ADAPTER_TYPE_UNKNOWN),
network_type_(ADAPTER_TYPE_UNKNOWN),
underlying_type_for_vpn_(ADAPTER_TYPE_UNKNOWN),
generation_(generation),
foundation_(foundation),
network_id_(network_id),
@ -102,7 +102,7 @@ bool Candidate::is_relay() const {
}
absl::string_view Candidate::type_name() const {
return webrtc::IceCandidateTypeToString(type_);
return IceCandidateTypeToString(type_);
}
bool Candidate::IsEquivalent(const Candidate& c) const {
@ -157,7 +157,7 @@ uint32_t Candidate::GetPriority(uint32_t type_preference,
// local preference = (NIC Type << 8 | Addr_Pref) + relay preference.
// The relay preference is based on the number of TURN servers, the
// first TURN server gets the highest preference.
int addr_pref = webrtc::IPAddressPrecedence(address_.ipaddr());
int addr_pref = IPAddressPrecedence(address_.ipaddr());
int local_preference =
((network_adapter_preference << 8) | addr_pref) + relay_preference;
@ -205,7 +205,7 @@ Candidate Candidate::ToSanitizedCopy(bool use_hostname_address,
// IP needs to be redacted, but no hostname available.
SocketAddress redacted_addr("redacted-ip.invalid", address().port());
copy.set_address(redacted_addr);
} else if (webrtc::IPFromString(address().hostname(), &ip)) {
} else if (IPFromString(address().hostname(), &ip)) {
// The hostname is an IP literal, and needs to be redacted too.
SocketAddress redacted_addr("redacted-literal.invalid", address().port());
copy.set_address(redacted_addr);
@ -216,7 +216,7 @@ Candidate Candidate::ToSanitizedCopy(bool use_hostname_address,
}
if (filter_related_address) {
copy.set_related_address(
webrtc::EmptySocketAddressWithFamily(copy.address().family()));
EmptySocketAddressWithFamily(copy.address().family()));
}
if (filter_ufrag) {
copy.set_username("");
@ -252,14 +252,14 @@ void Candidate::ComputeFoundation(const SocketAddress& base_address,
// number, called the tie-breaker, uniformly distributed between 0 and (2**64)
// - 1 (that is, a 64-bit positive integer). This number is used in
// connectivity checks to detect and repair this case [...]
sb << rtc::ToString(tie_breaker);
foundation_ = rtc::ToString(webrtc::ComputeCrc32(sb.Release()));
sb << absl::StrCat(tie_breaker);
foundation_ = absl::StrCat(ComputeCrc32(sb.Release()));
}
void Candidate::ComputePrflxFoundation() {
RTC_DCHECK(is_prflx());
RTC_DCHECK(!id_.empty());
foundation_ = rtc::ToString(webrtc::ComputeCrc32(id_));
foundation_ = absl::StrCat(ComputeCrc32(id_));
}
void Candidate::Assign(std::string& s, absl::string_view view) {

View File

@ -105,7 +105,7 @@ class RTC_EXPORT Candidate {
absl::string_view type_name() const;
// Setting the type requires a constant string (e.g.
// cricket::LOCAL_PORT_TYPE). The type should really be an enum rather than a
// webrtc::LOCAL_PORT_TYPE). The type should really be an enum rather than a
// string, but until we make that change the lifetime attribute helps us lock
// things down. See also the `Port` class.
void set_type(IceCandidateType type) { type_ = type; }
@ -159,7 +159,8 @@ class RTC_EXPORT Candidate {
// `network_cost` measures the cost/penalty of using this candidate. A network
// cost of 0 indicates this candidate can be used freely. A value of
// rtc::kNetworkCostMax indicates it should be used only as the last resort.
// webrtc::kNetworkCostMax indicates it should be used only as the last
// resort.
void set_network_cost(uint16_t network_cost) {
RTC_DCHECK_LE(network_cost, webrtc::kNetworkCostMax);
network_cost_ = network_cost;
@ -290,6 +291,7 @@ class RTC_EXPORT Candidate {
// Re-export symbols from the webrtc namespace for backwards compatibility.
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES
namespace cricket {
using ::webrtc::Candidate;
using ::webrtc::kMaxTurnServers;
@ -298,5 +300,6 @@ using ::webrtc::PRFLX_PORT_TYPE;
using ::webrtc::RELAY_PORT_TYPE;
using ::webrtc::STUN_PORT_TYPE;
} // namespace cricket
#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES
#endif // API_CANDIDATE_H_

View File

@ -32,9 +32,9 @@ TEST(CandidateTest, Id) {
TEST(CandidateTest, Component) {
Candidate c;
EXPECT_EQ(c.component(), cricket::ICE_CANDIDATE_COMPONENT_DEFAULT);
c.set_component(cricket::ICE_CANDIDATE_COMPONENT_RTCP);
EXPECT_EQ(c.component(), cricket::ICE_CANDIDATE_COMPONENT_RTCP);
EXPECT_EQ(c.component(), ICE_CANDIDATE_COMPONENT_DEFAULT);
c.set_component(ICE_CANDIDATE_COMPONENT_RTCP);
EXPECT_EQ(c.component(), ICE_CANDIDATE_COMPONENT_RTCP);
}
TEST(CandidateTest, TypeName) {

View File

@ -20,6 +20,7 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/audio_codecs/audio_encoder_factory.h"
#include "api/enable_media.h"
#include "api/environment/environment_factory.h"
#include "api/field_trials_view.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_event_log/rtc_event_log_factory.h"
@ -30,17 +31,17 @@
namespace webrtc {
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
Thread* network_thread,
Thread* worker_thread,
Thread* signaling_thread,
rtc::scoped_refptr<AudioDeviceModule> default_adm,
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
scoped_refptr<AudioDeviceModule> default_adm,
scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<VideoEncoderFactory> video_encoder_factory,
std::unique_ptr<VideoDecoderFactory> video_decoder_factory,
rtc::scoped_refptr<AudioMixer> audio_mixer,
rtc::scoped_refptr<AudioProcessing> audio_processing,
scoped_refptr<AudioMixer> audio_mixer,
scoped_refptr<AudioProcessing> audio_processing,
std::unique_ptr<AudioFrameProcessor> audio_frame_processor,
std::unique_ptr<FieldTrialsView> field_trials) {
PeerConnectionFactoryDependencies dependencies;
@ -48,10 +49,10 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
dependencies.worker_thread = worker_thread;
dependencies.signaling_thread = signaling_thread;
dependencies.event_log_factory = std::make_unique<RtcEventLogFactory>();
dependencies.trials = std::move(field_trials);
dependencies.env = CreateEnvironment(std::move(field_trials));
if (network_thread) {
// TODO(bugs.webrtc.org/13145): Add an rtc::SocketFactory* argument.
// TODO(bugs.webrtc.org/13145): Add an webrtc::SocketFactory* argument.
dependencies.socket_factory = network_thread->socketserver();
}
dependencies.adm = std::move(default_adm);

View File

@ -33,18 +33,18 @@ class AudioFrameProcessor;
// Create a new instance of PeerConnectionFactoryInterface with optional video
// codec factories. These video factories represents all video codecs, i.e. no
// extra internal video codecs will be added.
RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
RTC_EXPORT scoped_refptr<PeerConnectionFactoryInterface>
CreatePeerConnectionFactory(
Thread* network_thread,
Thread* worker_thread,
Thread* signaling_thread,
rtc::scoped_refptr<AudioDeviceModule> default_adm,
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
scoped_refptr<AudioDeviceModule> default_adm,
scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<VideoEncoderFactory> video_encoder_factory,
std::unique_ptr<VideoDecoderFactory> video_decoder_factory,
rtc::scoped_refptr<AudioMixer> audio_mixer,
rtc::scoped_refptr<AudioProcessing> audio_processing,
scoped_refptr<AudioMixer> audio_mixer,
scoped_refptr<AudioProcessing> audio_processing,
std::unique_ptr<AudioFrameProcessor> audio_frame_processor = nullptr,
std::unique_ptr<FieldTrialsView> field_trials = nullptr);

View File

@ -23,6 +23,7 @@ rtc_library("options") {
"crypto_options.h",
]
deps = [
"..:field_trials_view",
"../../rtc_base:checks",
"../../rtc_base:ssl_adapter",
"../../rtc_base/system:rtc_export",
@ -50,3 +51,21 @@ rtc_source_set("frame_encryptor_interface") {
"../../rtc_base:refcount",
]
}
if (rtc_include_tests) {
rtc_library("crypto_options_unittest") {
visibility = [ "*" ]
testonly = true
sources = [ "crypto_options_unittest.cc" ]
deps = [
":options",
"../../rtc_base:ssl_adapter",
"../../test:scoped_key_value_config",
"../../test:test_support",
"//testing/gtest",
]
if (rtc_build_ssl) {
deps += [ "//third_party/boringssl" ]
}
}
}

View File

@ -10,8 +10,13 @@
#include "api/crypto/crypto_options.h"
#include <algorithm>
#include <cstdint>
#include <set>
#include <utility>
#include <vector>
#include "api/field_trials_view.h"
#include "rtc_base/checks.h"
#include "rtc_base/ssl_stream_adapter.h"
@ -19,13 +24,6 @@ namespace webrtc {
CryptoOptions::CryptoOptions() {}
CryptoOptions::CryptoOptions(const CryptoOptions& other) {
srtp = other.srtp;
sframe = other.sframe;
}
CryptoOptions::~CryptoOptions() {}
// static
CryptoOptions CryptoOptions::NoGcm() {
CryptoOptions options;
@ -69,6 +67,7 @@ bool CryptoOptions::operator==(const CryptoOptions& other) const {
struct SFrame {
bool require_frame_encryption;
} sframe;
EphemeralKeyExchangeCipherGroups ephemeral_key_exchange_cipher_groups;
};
static_assert(sizeof(data_being_tested_for_equality) == sizeof(*this),
"Did you add something to CryptoOptions and forget to "
@ -82,11 +81,71 @@ bool CryptoOptions::operator==(const CryptoOptions& other) const {
srtp.enable_encrypted_rtp_header_extensions ==
other.srtp.enable_encrypted_rtp_header_extensions &&
sframe.require_frame_encryption ==
other.sframe.require_frame_encryption;
other.sframe.require_frame_encryption &&
ephemeral_key_exchange_cipher_groups ==
other.ephemeral_key_exchange_cipher_groups;
}
bool CryptoOptions::operator!=(const CryptoOptions& other) const {
return !(*this == other);
}
CryptoOptions::EphemeralKeyExchangeCipherGroups::
EphemeralKeyExchangeCipherGroups()
: enabled_(SSLStreamAdapter::GetDefaultEphemeralKeyExchangeCipherGroups(
/* field_trials= */ nullptr)) {}
bool CryptoOptions::EphemeralKeyExchangeCipherGroups::operator==(
const CryptoOptions::EphemeralKeyExchangeCipherGroups& other) const {
return enabled_ == other.enabled_;
}
std::set<uint16_t>
CryptoOptions::EphemeralKeyExchangeCipherGroups::GetSupported() {
return SSLStreamAdapter::GetSupportedEphemeralKeyExchangeCipherGroups();
}
void CryptoOptions::EphemeralKeyExchangeCipherGroups::AddFirst(uint16_t group) {
std::erase(enabled_, group);
enabled_.insert(enabled_.begin(), group);
}
void CryptoOptions::EphemeralKeyExchangeCipherGroups::Update(
const FieldTrialsView* field_trials,
const std::vector<uint16_t>* disabled_groups) {
// Note: assumption is that these lists contains few elements...so converting
// to set<> is not worth it.
std::vector<uint16_t> default_groups =
SSLStreamAdapter::GetDefaultEphemeralKeyExchangeCipherGroups(
field_trials);
// Remove all disabled.
if (disabled_groups) {
default_groups.erase(std::remove_if(
default_groups.begin(), default_groups.end(), [&](uint16_t val) {
return std::find(disabled_groups->begin(), disabled_groups->end(),
val) != disabled_groups->end();
}));
enabled_.erase(
std::remove_if(enabled_.begin(), enabled_.end(), [&](uint16_t val) {
return std::find(disabled_groups->begin(), disabled_groups->end(),
val) != disabled_groups->end();
}));
}
// Add those enabled by field-trials first.
std::vector<uint16_t> current = std::move(enabled_);
for (auto val : default_groups) {
if (std::find(current.begin(), current.end(), val) == current.end()) {
enabled_.push_back(val);
}
}
// Then re-add those present (unless already there).
for (auto val : current) {
if (std::find(enabled_.begin(), enabled_.end(), val) == enabled_.end()) {
enabled_.push_back(val);
}
}
}
} // namespace webrtc

View File

@ -11,8 +11,13 @@
#ifndef API_CRYPTO_CRYPTO_OPTIONS_H_
#define API_CRYPTO_CRYPTO_OPTIONS_H_
#include <cstdint>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include "api/field_trials_view.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
@ -22,8 +27,6 @@ namespace webrtc {
// and are only applicable to native use cases of WebRTC.
struct RTC_EXPORT CryptoOptions {
CryptoOptions();
CryptoOptions(const CryptoOptions& other);
~CryptoOptions();
// Helper method to return an instance of the CryptoOptions with GCM crypto
// suites disabled. This method should be used instead of depending on current
@ -67,6 +70,42 @@ struct RTC_EXPORT CryptoOptions {
// FrameDecryptor attached to them before they are able to receive packets.
bool require_frame_encryption = false;
} sframe;
// Cipher groups used by DTLS when establishing an ephemeral key during
// handshake.
class EphemeralKeyExchangeCipherGroups {
public:
// Which cipher groups are supported by this binary,
// - ssl.h: SSL_GROUP_{}
// - https://www.rfc-editor.org/rfc/rfc8422#section-5.1.1
// - https://datatracker.ietf.org/doc/draft-ietf-tls-mlkem
static constexpr uint16_t kSECP224R1 = 21;
static constexpr uint16_t kSECP256R1 = 23;
static constexpr uint16_t kSECP384R1 = 24;
static constexpr uint16_t kSECP521R1 = 25;
static constexpr uint16_t kX25519 = 29;
static constexpr uint16_t kX25519_MLKEM768 = 0x11ec;
static std::set<uint16_t> GetSupported();
static std::optional<std::string> GetName(uint16_t);
EphemeralKeyExchangeCipherGroups();
// Which cipher groups are enabled in this crypto options.
std::vector<uint16_t> GetEnabled() const { return enabled_; }
void SetEnabled(const std::vector<uint16_t>& groups) { enabled_ = groups; }
void AddFirst(uint16_t group);
// Update list of enabled groups based on field_trials,
// optionally providing list of groups that should NOT be added.
void Update(const FieldTrialsView* field_trials,
const std::vector<uint16_t>* disabled_groups = nullptr);
bool operator==(const EphemeralKeyExchangeCipherGroups& other) const;
private:
std::vector<uint16_t> enabled_;
} ephemeral_key_exchange_cipher_groups;
};
} // namespace webrtc

View File

@ -0,0 +1,141 @@
/*
* Copyright 2025 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/crypto/crypto_options.h"
#include <cstdint>
#include <set>
#include <vector>
#include "rtc_base/openssl_stream_adapter.h"
#include "test/gtest.h"
#include "test/scoped_key_value_config.h"
TEST(EphemeralKeyExchangeCipherGroupsTest, GetSupported) {
std::set<uint16_t> expected = {
#ifdef SSL_GROUP_SECP224R1
SSL_GROUP_SECP224R1,
#endif
#ifdef SSL_GROUP_SECP256R1
SSL_GROUP_SECP256R1,
#endif
#ifdef SSL_GROUP_SECP384R1
SSL_GROUP_SECP384R1,
#endif
#ifdef SSL_GROUP_SECP521R1
SSL_GROUP_SECP521R1,
#endif
#ifdef SSL_GROUP_X25519
SSL_GROUP_X25519,
#endif
#ifdef SSL_GROUP_X25519_MLKEM768
SSL_GROUP_X25519_MLKEM768,
#endif
};
auto supported =
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::GetSupported();
for (auto group : expected) {
EXPECT_TRUE(supported.contains(group));
}
}
TEST(EphemeralKeyExchangeCipherGroupsTest, GetEnabled) {
std::vector<uint16_t> expected = {
#ifdef SSL_GROUP_X25519
SSL_GROUP_X25519,
#endif
#ifdef SSL_GROUP_SECP256R1
SSL_GROUP_SECP256R1,
#endif
#ifdef SSL_GROUP_SECP384R1
SSL_GROUP_SECP384R1,
#endif
};
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups groups;
EXPECT_EQ(groups.GetEnabled(), expected);
}
TEST(EphemeralKeyExchangeCipherGroupsTest, SetEnabled) {
std::vector<uint16_t> expected = {
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519,
};
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups groups;
groups.SetEnabled(expected);
EXPECT_EQ(groups.GetEnabled(), expected);
}
TEST(EphemeralKeyExchangeCipherGroupsTest, AddFirst) {
std::vector<uint16_t> initial = {
#ifdef SSL_GROUP_X25519
SSL_GROUP_X25519,
#endif
#ifdef SSL_GROUP_SECP256R1
SSL_GROUP_SECP256R1,
#endif
#ifdef SSL_GROUP_SECP384R1
SSL_GROUP_SECP384R1,
#endif
};
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups groups;
EXPECT_EQ(groups.GetEnabled(), initial);
groups.AddFirst(webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::
kX25519_MLKEM768);
std::vector<uint16_t> expected = {
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519_MLKEM768,
#ifdef SSL_GROUP_X25519
SSL_GROUP_X25519,
#endif
#ifdef SSL_GROUP_SECP256R1
SSL_GROUP_SECP256R1,
#endif
#ifdef SSL_GROUP_SECP384R1
SSL_GROUP_SECP384R1,
#endif
};
EXPECT_EQ(groups.GetEnabled(), expected);
}
TEST(EphemeralKeyExchangeCipherGroupsTest, Update) {
std::vector<uint16_t> expected = {
#ifdef SSL_GROUP_X25519_MLKEM768
SSL_GROUP_X25519_MLKEM768,
#endif
#ifdef SSL_GROUP_SECP256R1
SSL_GROUP_SECP256R1,
#endif
#ifdef SSL_GROUP_SECP384R1
SSL_GROUP_SECP384R1,
#endif
};
std::vector<uint16_t> disable = {
#ifdef SSL_GROUP_X25519
SSL_GROUP_X25519,
#endif
};
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups groups;
webrtc::test::ScopedKeyValueConfig field_trials(
"WebRTC-EnableDtlsPqc/Enabled/");
groups.Update(&field_trials, &disable);
EXPECT_EQ(groups.GetEnabled(), expected);
}
TEST(EphemeralKeyExchangeCipherGroupsTest, CopyCryptoOptions) {
webrtc::CryptoOptions options;
options.ephemeral_key_exchange_cipher_groups.SetEnabled({
webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519_MLKEM768,
});
webrtc::CryptoOptions copy1 = options;
webrtc::CryptoOptions copy2(options);
EXPECT_EQ(options, copy1);
EXPECT_EQ(options, copy2);
}

View File

@ -62,9 +62,9 @@ class FrameDecryptorInterface : public RefCountInterface {
// cases.
virtual Result Decrypt(webrtc::MediaType media_type,
const std::vector<uint32_t>& csrcs,
rtc::ArrayView<const uint8_t> additional_data,
rtc::ArrayView<const uint8_t> encrypted_frame,
rtc::ArrayView<uint8_t> frame) = 0;
ArrayView<const uint8_t> additional_data,
ArrayView<const uint8_t> encrypted_frame,
ArrayView<uint8_t> frame) = 0;
// Returns the total required length in bytes for the output of the
// decryption. This can be larger than the actual number of bytes you need but

View File

@ -40,9 +40,9 @@ class FrameEncryptorInterface : public RefCountInterface {
// selected by the implementer to represent error codes.
virtual int Encrypt(webrtc::MediaType media_type,
uint32_t ssrc,
rtc::ArrayView<const uint8_t> additional_data,
rtc::ArrayView<const uint8_t> frame,
rtc::ArrayView<uint8_t> encrypted_frame,
ArrayView<const uint8_t> additional_data,
ArrayView<const uint8_t> frame,
ArrayView<uint8_t> encrypted_frame,
size_t* bytes_written) = 0;
// Returns the total required length in bytes for the output of the

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2025 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_DATA_CHANNEL_EVENT_OBSERVER_INTERFACE_H_
#define API_DATA_CHANNEL_EVENT_OBSERVER_INTERFACE_H_
#include <cstdint>
#include <string>
#include <vector>
#include "absl/strings/string_view.h"
#include "api/array_view.h"
namespace webrtc {
// TODO: issues.chromium.org/407785197 - Maybe update the observer to also
// notify on controll messages as well.
// TODO: issues.chromium.org/407785197 - Remove comment below when DataChannel
// logging has been launched.
// NOTE: This class is still under development and may change without notice.
class DataChannelEventObserverInterface {
public:
virtual ~DataChannelEventObserverInterface() = default;
class Message {
public:
enum class Direction { kSend, kReceive };
enum class DataType { kString, kBinary };
// When `direction` is `kSend` the timestamp represent when the message was
// handed over to the transport, if `direction` is `kReceive` then it
// represent when the message was received from the transport.
int64_t unix_timestamp_ms() const { return unix_timestamp_; }
void set_unix_timestamp_ms(int64_t timestamp) {
unix_timestamp_ = timestamp;
}
int datachannel_id() const { return datachannel_id_; }
void set_datachannel_id(int id) { datachannel_id_ = id; }
absl::string_view label() const { return label_; }
void set_label(absl::string_view label) { label_ = std::string(label); }
Direction direction() const { return direction_; }
void set_direction(Direction direction) { direction_ = direction; }
DataType data_type() const { return data_type_; }
void set_data_type(DataType type) { data_type_ = type; }
const std::vector<uint8_t>& data() const { return data_; }
void set_data(ArrayView<const uint8_t> d) {
data_.assign(d.begin(), d.end());
}
private:
int64_t unix_timestamp_;
int datachannel_id_;
std::string label_;
Direction direction_;
DataType data_type_;
std::vector<uint8_t> data_;
};
virtual void OnMessage(const Message& message) = 0;
};
} // namespace webrtc
#endif // API_DATA_CHANNEL_EVENT_OBSERVER_INTERFACE_H_

View File

@ -74,14 +74,14 @@ struct DataChannelInit {
// this structure's `binary` flag tells whether the data should be interpreted
// as binary or text.
struct DataBuffer {
DataBuffer(const rtc::CopyOnWriteBuffer& data, bool binary)
DataBuffer(const CopyOnWriteBuffer& data, bool binary)
: data(data), binary(binary) {}
// For convenience for unit tests.
explicit DataBuffer(const std::string& text)
: data(text.data(), text.length()), binary(false) {}
size_t size() const { return data.size(); }
rtc::CopyOnWriteBuffer data;
CopyOnWriteBuffer data;
// Indicates if the received data contains UTF-8 or binary data.
// Note that the upper layers are left to verify the UTF-8 encoding.
// TODO(jiayl): prefer to use an enum instead of a bool.

View File

@ -30,13 +30,15 @@ DtlsTransportInformation::DtlsTransportInformation(
std::optional<int> tls_version,
std::optional<int> ssl_cipher_suite,
std::optional<int> srtp_cipher_suite,
std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates)
std::unique_ptr<SSLCertChain> remote_ssl_certificates,
std::optional<int> ssl_group_id)
: state_(state),
role_(role),
tls_version_(tls_version),
ssl_cipher_suite_(ssl_cipher_suite),
srtp_cipher_suite_(srtp_cipher_suite),
remote_ssl_certificates_(std::move(remote_ssl_certificates)) {}
remote_ssl_certificates_(std::move(remote_ssl_certificates)),
ssl_group_id_(ssl_group_id) {}
// Deprecated version
DtlsTransportInformation::DtlsTransportInformation(
@ -44,7 +46,7 @@ DtlsTransportInformation::DtlsTransportInformation(
std::optional<int> tls_version,
std::optional<int> ssl_cipher_suite,
std::optional<int> srtp_cipher_suite,
std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates)
std::unique_ptr<SSLCertChain> remote_ssl_certificates)
: state_(state),
role_(std::nullopt),
tls_version_(tls_version),
@ -61,7 +63,8 @@ DtlsTransportInformation::DtlsTransportInformation(
srtp_cipher_suite_(c.srtp_cipher_suite_),
remote_ssl_certificates_(c.remote_ssl_certificates()
? c.remote_ssl_certificates()->Clone()
: nullptr) {}
: nullptr),
ssl_group_id_(c.ssl_group_id_) {}
DtlsTransportInformation& DtlsTransportInformation::operator=(
const DtlsTransportInformation& c) {
@ -73,6 +76,7 @@ DtlsTransportInformation& DtlsTransportInformation::operator=(
remote_ssl_certificates_ = c.remote_ssl_certificates()
? c.remote_ssl_certificates()->Clone()
: nullptr;
ssl_group_id_ = c.ssl_group_id_;
return *this;
}

View File

@ -53,14 +53,15 @@ class RTC_EXPORT DtlsTransportInformation {
std::optional<int> tls_version,
std::optional<int> ssl_cipher_suite,
std::optional<int> srtp_cipher_suite,
std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates);
std::unique_ptr<SSLCertChain> remote_ssl_certificates,
std::optional<int> ssl_group_id);
ABSL_DEPRECATED("Use version with role parameter")
DtlsTransportInformation(
DtlsTransportState state,
std::optional<int> tls_version,
std::optional<int> ssl_cipher_suite,
std::optional<int> srtp_cipher_suite,
std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates);
std::unique_ptr<SSLCertChain> remote_ssl_certificates);
// Copy and assign
DtlsTransportInformation(const DtlsTransportInformation& c);
@ -75,8 +76,9 @@ class RTC_EXPORT DtlsTransportInformation {
std::optional<int> tls_version() const { return tls_version_; }
std::optional<int> ssl_cipher_suite() const { return ssl_cipher_suite_; }
std::optional<int> srtp_cipher_suite() const { return srtp_cipher_suite_; }
std::optional<int> ssl_group_id() const { return ssl_group_id_; }
// The accessor returns a temporary pointer, it does not release ownership.
const rtc::SSLCertChain* remote_ssl_certificates() const {
const SSLCertChain* remote_ssl_certificates() const {
return remote_ssl_certificates_.get();
}
@ -86,7 +88,8 @@ class RTC_EXPORT DtlsTransportInformation {
std::optional<int> tls_version_;
std::optional<int> ssl_cipher_suite_;
std::optional<int> srtp_cipher_suite_;
std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates_;
std::unique_ptr<SSLCertChain> remote_ssl_certificates_;
std::optional<int> ssl_group_id_;
};
class DtlsTransportObserverInterface {
@ -110,7 +113,7 @@ class DtlsTransportObserverInterface {
class DtlsTransportInterface : public webrtc::RefCountInterface {
public:
// Returns a pointer to the ICE transport that is owned by the DTLS transport.
virtual rtc::scoped_refptr<IceTransportInterface> ice_transport() = 0;
virtual scoped_refptr<IceTransportInterface> ice_transport() = 0;
// Returns information on the state of the DtlsTransport.
// This function can be called from other threads.
virtual DtlsTransportInformation Information() = 0;

View File

@ -27,11 +27,6 @@
namespace webrtc {
namespace {
using ::cricket::CompositeMediaEngine;
using ::cricket::MediaEngineInterface;
using ::cricket::WebRtcVideoEngine;
using ::cricket::WebRtcVoiceEngine;
class MediaFactoryImpl : public MediaFactory {
public:
MediaFactoryImpl() = default;
@ -40,26 +35,21 @@ class MediaFactoryImpl : public MediaFactory {
~MediaFactoryImpl() override = default;
std::unique_ptr<Call> CreateCall(CallConfig config) override {
return webrtc::Call::Create(std::move(config));
return Call::Create(std::move(config));
}
std::unique_ptr<MediaEngineInterface> CreateMediaEngine(
const Environment& env,
PeerConnectionFactoryDependencies& deps) override {
absl::Nullable<scoped_refptr<AudioProcessing>> audio_processing =
deps.audio_processing_builder != nullptr
? std::move(deps.audio_processing_builder)->Build(env)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
: std::move(deps.audio_processing);
#pragma clang diagnostic pop
absl_nullable scoped_refptr<AudioProcessing> audio_processing;
if (deps.audio_processing_builder != nullptr) {
audio_processing = std::move(deps.audio_processing_builder)->Build(env);
}
auto audio_engine = std::make_unique<WebRtcVoiceEngine>(
&env.task_queue_factory(), deps.adm.get(),
std::move(deps.audio_encoder_factory),
env, std::move(deps.adm), std::move(deps.audio_encoder_factory),
std::move(deps.audio_decoder_factory), std::move(deps.audio_mixer),
std::move(audio_processing), std::move(deps.audio_frame_processor),
env.field_trials());
std::move(audio_processing), std::move(deps.audio_frame_processor));
auto video_engine = std::make_unique<WebRtcVideoEngine>(
std::move(deps.video_encoder_factory),
std::move(deps.video_decoder_factory), env.field_trials());

View File

@ -18,27 +18,20 @@
#include "api/enable_media.h"
#include "api/peer_connection_interface.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "api/video_codecs/builtin_video_decoder_factory.h"
#include "api/video_codecs/builtin_video_encoder_factory.h"
namespace webrtc {
void EnableMediaWithDefaults(PeerConnectionFactoryDependencies& deps) {
if (deps.task_queue_factory == nullptr) {
deps.task_queue_factory = CreateDefaultTaskQueueFactory();
}
if (deps.audio_encoder_factory == nullptr) {
deps.audio_encoder_factory = CreateBuiltinAudioEncoderFactory();
}
if (deps.audio_decoder_factory == nullptr) {
deps.audio_decoder_factory = CreateBuiltinAudioDecoderFactory();
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (deps.audio_processing == nullptr &&
#pragma clang diagnostic pop
deps.audio_processing_builder == nullptr) {
if (deps.audio_processing_builder == nullptr) {
deps.audio_processing_builder =
std::make_unique<BuiltinAudioProcessingBuilder>();
}

View File

@ -93,11 +93,11 @@ class RTC_EXPORT Environment final {
private:
friend class EnvironmentFactory;
Environment(scoped_refptr<const rtc::RefCountedBase> storage,
absl::Nonnull<const FieldTrialsView*> field_trials,
absl::Nonnull<Clock*> clock,
absl::Nonnull<TaskQueueFactory*> task_queue_factory,
absl::Nonnull<RtcEventLog*> event_log)
Environment(scoped_refptr<const RefCountedBase> storage,
const FieldTrialsView* absl_nonnull field_trials,
Clock* absl_nonnull clock,
TaskQueueFactory* absl_nonnull task_queue_factory,
RtcEventLog* absl_nonnull event_log)
: storage_(std::move(storage)),
field_trials_(field_trials),
clock_(clock),
@ -110,12 +110,12 @@ class RTC_EXPORT Environment final {
// be copyable. It is up to the `EnvironmentFactory` to provide an object that
// ensures references to utilties below are valid while object in the
// `storage_` is alive.
scoped_refptr<const rtc::RefCountedBase> storage_;
scoped_refptr<const RefCountedBase> storage_;
absl::Nonnull<const FieldTrialsView*> field_trials_;
absl::Nonnull<Clock*> clock_;
absl::Nonnull<TaskQueueFactory*> task_queue_factory_;
absl::Nonnull<RtcEventLog*> event_log_;
const FieldTrialsView* absl_nonnull field_trials_;
Clock* absl_nonnull clock_;
TaskQueueFactory* absl_nonnull task_queue_factory_;
RtcEventLog* absl_nonnull event_log_;
};
//------------------------------------------------------------------------------

View File

@ -30,12 +30,12 @@ namespace webrtc {
namespace {
template <typename T>
void Store(absl::Nonnull<std::unique_ptr<T>> value,
scoped_refptr<const rtc::RefCountedBase>& leaf) {
class StorageNode : public rtc::RefCountedBase {
void Store(absl_nonnull std::unique_ptr<T> value,
scoped_refptr<const webrtc::RefCountedBase>& leaf) {
class StorageNode : public RefCountedBase {
public:
StorageNode(scoped_refptr<const rtc::RefCountedBase> parent,
absl::Nonnull<std::unique_ptr<T>> value)
StorageNode(scoped_refptr<const RefCountedBase> parent,
absl_nonnull std::unique_ptr<T> value)
: parent_(std::move(parent)), value_(std::move(value)) {}
StorageNode(const StorageNode&) = delete;
@ -44,8 +44,8 @@ void Store(absl::Nonnull<std::unique_ptr<T>> value,
~StorageNode() override = default;
private:
scoped_refptr<const rtc::RefCountedBase> parent_;
absl::Nonnull<std::unique_ptr<T>> value_;
scoped_refptr<const RefCountedBase> parent_;
absl_nonnull std::unique_ptr<T> value_;
};
// Utilities provided with ownership form a tree:
@ -55,7 +55,7 @@ void Store(absl::Nonnull<std::unique_ptr<T>> value,
// 'leaf_' - node with the last provided utility. This way `Environment` keeps
// ownership of a single branch of the storage tree with each used utiltity
// owned by one of the nodes on that branch.
leaf = rtc::make_ref_counted<StorageNode>(std::move(leaf), std::move(value));
leaf = make_ref_counted<StorageNode>(std::move(leaf), std::move(value));
}
} // namespace
@ -68,14 +68,14 @@ EnvironmentFactory::EnvironmentFactory(const Environment& env)
event_log_(env.event_log_) {}
void EnvironmentFactory::Set(
absl::Nullable<std::unique_ptr<const FieldTrialsView>> utility) {
absl_nullable std::unique_ptr<const FieldTrialsView> utility) {
if (utility != nullptr) {
field_trials_ = utility.get();
Store(std::move(utility), leaf_);
}
}
void EnvironmentFactory::Set(absl::Nullable<std::unique_ptr<Clock>> utility) {
void EnvironmentFactory::Set(absl_nullable std::unique_ptr<Clock> utility) {
if (utility != nullptr) {
clock_ = utility.get();
Store(std::move(utility), leaf_);
@ -83,7 +83,7 @@ void EnvironmentFactory::Set(absl::Nullable<std::unique_ptr<Clock>> utility) {
}
void EnvironmentFactory::Set(
absl::Nullable<std::unique_ptr<TaskQueueFactory>> utility) {
absl_nullable std::unique_ptr<TaskQueueFactory> utility) {
if (utility != nullptr) {
task_queue_factory_ = utility.get();
Store(std::move(utility), leaf_);
@ -91,7 +91,7 @@ void EnvironmentFactory::Set(
}
void EnvironmentFactory::Set(
absl::Nullable<std::unique_ptr<RtcEventLog>> utility) {
absl_nullable std::unique_ptr<RtcEventLog> utility) {
if (utility != nullptr) {
event_log_ = utility.get();
Store(std::move(utility), leaf_);

View File

@ -50,27 +50,27 @@ class RTC_EXPORT EnvironmentFactory final {
~EnvironmentFactory() = default;
void Set(absl::Nullable<std::unique_ptr<const FieldTrialsView>> utility);
void Set(absl::Nullable<std::unique_ptr<Clock>> utility);
void Set(absl::Nullable<std::unique_ptr<TaskQueueFactory>> utility);
void Set(absl::Nullable<std::unique_ptr<RtcEventLog>> utility);
void Set(absl_nullable std::unique_ptr<const FieldTrialsView> utility);
void Set(absl_nullable std::unique_ptr<Clock> utility);
void Set(absl_nullable std::unique_ptr<TaskQueueFactory> utility);
void Set(absl_nullable std::unique_ptr<RtcEventLog> utility);
void Set(absl::Nullable<const FieldTrialsView*> utility);
void Set(absl::Nullable<Clock*> utility);
void Set(absl::Nullable<TaskQueueFactory*> utility);
void Set(absl::Nullable<RtcEventLog*> utility);
void Set(const FieldTrialsView* absl_nullable utility);
void Set(Clock* absl_nullable utility);
void Set(TaskQueueFactory* absl_nullable utility);
void Set(RtcEventLog* absl_nullable utility);
Environment Create() const;
private:
Environment CreateWithDefaults() &&;
scoped_refptr<const rtc::RefCountedBase> leaf_;
scoped_refptr<const RefCountedBase> leaf_;
absl::Nullable<const FieldTrialsView*> field_trials_ = nullptr;
absl::Nullable<Clock*> clock_ = nullptr;
absl::Nullable<TaskQueueFactory*> task_queue_factory_ = nullptr;
absl::Nullable<RtcEventLog*> event_log_ = nullptr;
const FieldTrialsView* absl_nullable field_trials_ = nullptr;
Clock* absl_nullable clock_ = nullptr;
TaskQueueFactory* absl_nullable task_queue_factory_ = nullptr;
RtcEventLog* absl_nullable event_log_ = nullptr;
};
// Helper for concise way to create an environment.
@ -93,25 +93,25 @@ Environment CreateEnvironment(Utilities&&... utilities);
//------------------------------------------------------------------------------
inline void EnvironmentFactory::Set(
absl::Nullable<const FieldTrialsView*> utility) {
const FieldTrialsView* absl_nullable utility) {
if (utility != nullptr) {
field_trials_ = utility;
}
}
inline void EnvironmentFactory::Set(absl::Nullable<Clock*> utility) {
inline void EnvironmentFactory::Set(Clock* absl_nullable utility) {
if (utility != nullptr) {
clock_ = utility;
}
}
inline void EnvironmentFactory::Set(absl::Nullable<TaskQueueFactory*> utility) {
inline void EnvironmentFactory::Set(TaskQueueFactory* absl_nullable utility) {
if (utility != nullptr) {
task_queue_factory_ = utility;
}
}
inline void EnvironmentFactory::Set(absl::Nullable<RtcEventLog*> utility) {
inline void EnvironmentFactory::Set(RtcEventLog* absl_nullable utility) {
if (utility != nullptr) {
event_log_ = utility;
}

View File

@ -10,94 +10,87 @@
#include "api/field_trials.h"
#include <atomic>
#include <memory>
#include <string>
#include <utility>
#include "absl/base/nullability.h"
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
#include "rtc_base/containers/flat_map.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
webrtc::flat_map<std::string, std::string> InsertIntoMap(absl::string_view s) {
webrtc::flat_map<std::string, std::string> key_value_map;
while (!s.empty()) {
absl::string_view::size_type separator_pos = s.find('/');
RTC_CHECK_NE(separator_pos, absl::string_view::npos)
<< "Missing separator '/' after field trial key.";
RTC_CHECK_GT(separator_pos, 0) << "Field trial key cannot be empty.";
absl::string_view key = s.substr(0, separator_pos);
s.remove_prefix(separator_pos + 1);
RTC_CHECK(!s.empty())
<< "Missing value after field trial key. String ended.";
separator_pos = s.find('/');
RTC_CHECK_NE(separator_pos, absl::string_view::npos)
<< "Missing terminating '/' in field trial string.";
RTC_CHECK_GT(separator_pos, 0) << "Field trial value cannot be empty.";
absl::string_view value = s.substr(0, separator_pos);
s.remove_prefix(separator_pos + 1);
// If a key is specified multiple times, only the value linked to the first
// key is stored. note: This will crash in debug build when calling
// InitFieldTrialsFromString().
key_value_map.emplace(key, value);
absl::string_view NextKeyOrValue(absl::string_view& s) {
absl::string_view::size_type separator_pos = s.find('/');
if (separator_pos == absl::string_view::npos) {
// Missing separator '/' after field trial key or value.
return "";
}
return key_value_map;
absl::string_view result = s.substr(0, separator_pos);
s.remove_prefix(separator_pos + 1);
return result;
}
// Makes sure that only one instance is created, since the usage
// of global string makes behaviour unpredicatable otherwise.
// TODO(bugs.webrtc.org/10335): Remove once global string is gone.
std::atomic<bool> instance_created_{false};
bool Parse(absl::string_view s,
flat_map<std::string, std::string>& key_value_map) {
while (!s.empty()) {
absl::string_view key = NextKeyOrValue(s);
absl::string_view value = NextKeyOrValue(s);
if (key.empty() || value.empty()) {
return false;
}
auto it = key_value_map.emplace(key, value).first;
if (it->second != value) {
// Duplicate trials with different values is not fine.
return false;
}
}
return true;
}
} // namespace
namespace webrtc {
FieldTrials::FieldTrials(absl::string_view s)
: uses_global_(true),
field_trial_string_(s),
previous_field_trial_string_(webrtc::field_trial::GetFieldTrialString()),
key_value_map_(InsertIntoMap(s)) {
// TODO(bugs.webrtc.org/10335): Remove the global string!
field_trial::InitFieldTrialsFromString(field_trial_string_.c_str());
RTC_CHECK(!instance_created_.exchange(true))
<< "Only one instance may be instanciated at any given time!";
absl_nullable std::unique_ptr<FieldTrials> FieldTrials::Create(
absl::string_view s) {
flat_map<std::string, std::string> key_value_map;
if (!Parse(s, key_value_map)) {
return nullptr;
}
// Using `new` to access a private constructor.
return absl::WrapUnique(new FieldTrials(std::move(key_value_map)));
}
std::unique_ptr<FieldTrials> FieldTrials::CreateNoGlobal(absl::string_view s) {
return std::unique_ptr<FieldTrials>(new FieldTrials(s, true));
FieldTrials::FieldTrials(absl::string_view s) {
RTC_CHECK(Parse(s, key_value_map_));
}
FieldTrials::FieldTrials(absl::string_view s, bool)
: uses_global_(false),
previous_field_trial_string_(nullptr),
key_value_map_(InsertIntoMap(s)) {}
void FieldTrials::Merge(const FieldTrials& other) {
for (const auto& [trial, group] : other.key_value_map_) {
key_value_map_.insert_or_assign(trial, group);
}
}
FieldTrials::~FieldTrials() {
// TODO(bugs.webrtc.org/10335): Remove the global string!
if (uses_global_) {
field_trial::InitFieldTrialsFromString(previous_field_trial_string_);
RTC_CHECK(instance_created_.exchange(false));
void FieldTrials::Set(absl::string_view trial, absl::string_view group) {
RTC_CHECK(!trial.empty());
RTC_CHECK_EQ(trial.find('/'), absl::string_view::npos);
RTC_CHECK_EQ(group.find('/'), absl::string_view::npos);
if (group.empty()) {
key_value_map_.erase(trial);
} else {
key_value_map_.insert_or_assign(trial, group);
}
}
std::string FieldTrials::GetValue(absl::string_view key) const {
auto it = key_value_map_.find(key);
if (it != key_value_map_.end())
if (it != key_value_map_.end()) {
return it->second;
// Check the global string so that programs using
// a mix between FieldTrials and the global string continue to work
// TODO(bugs.webrtc.org/10335): Remove the global string!
if (uses_global_) {
return field_trial::FindFullName(key);
}
return "";
}

View File

@ -13,7 +13,9 @@
#include <memory>
#include <string>
#include <utility>
#include "absl/base/nullability.h"
#include "absl/strings/string_view.h"
#include "api/field_trials_registry.h"
#include "rtc_base/containers/flat_map.h"
@ -30,30 +32,72 @@ namespace webrtc {
// feature is on/off.
//
// The field trials are injected into objects that use them at creation time.
//
// NOTE: Creating multiple FieldTrials-object is currently prohibited
// until we remove the global string (TODO(bugs.webrtc.org/10335))
// (unless using CreateNoGlobal):
class FieldTrials : public FieldTrialsRegistry {
public:
explicit FieldTrials(absl::string_view s);
~FieldTrials();
// Creates field trials from a valid field trial string.
// Returns nullptr if the string is invalid.
// E.g., valid string:
// "WebRTC-ExperimentFoo/Enabled/WebRTC-ExperimentBar/Enabled100kbps/"
// Assigns to group "Enabled" on WebRTC-ExperimentFoo trial
// and to group "Enabled100kbps" on WebRTC-ExperimentBar.
//
// E.g., invalid string:
// "WebRTC-experiment1/Enabled" (note missing / separator at the end).
static absl_nullable std::unique_ptr<FieldTrials> Create(absl::string_view s);
// Create a FieldTrials object that is not reading/writing from
// global variable (i.e can not be used for all parts of webrtc).
static std::unique_ptr<FieldTrials> CreateNoGlobal(absl::string_view s);
// Creates field trials from a string.
// It is an error to call the constructor with an invalid field trial string.
explicit FieldTrials(absl::string_view s);
FieldTrials(const FieldTrials&) = default;
FieldTrials(FieldTrials&&) = default;
FieldTrials& operator=(const FieldTrials&) = default;
FieldTrials& operator=(FieldTrials&&) = default;
~FieldTrials() override = default;
template <typename Sink>
friend void AbslStringify(Sink& sink, const FieldTrials& self);
// Merges field trials from the `other` into this.
//
// If a key (trial) exists twice with conflicting values (groups), the value
// in `other` takes precedence.
void Merge(const FieldTrials& other);
// Sets value (`group`) for an indvidual `trial`.
// It is an error to call this function with an invalid `trial` or `group`.
// Setting empty `group` is valid and removes the `trial`.
void Set(absl::string_view trial, absl::string_view group);
// TODO: bugs.webrtc.org/42220378 - Deprecate and inline once no longer used
// within webrtc.
static std::unique_ptr<FieldTrials> CreateNoGlobal(absl::string_view s) {
return std::make_unique<FieldTrials>(s);
}
private:
explicit FieldTrials(absl::string_view s, bool);
explicit FieldTrials(flat_map<std::string, std::string> key_value_map)
: key_value_map_(std::move(key_value_map)) {}
std::string GetValue(absl::string_view key) const override;
const bool uses_global_;
const std::string field_trial_string_;
const char* const previous_field_trial_string_;
const flat_map<std::string, std::string> key_value_map_;
flat_map<std::string, std::string> key_value_map_;
};
template <typename Sink>
void AbslStringify(Sink& sink, const FieldTrials& self) {
for (const auto& [trial, group] : self.key_value_map_) {
sink.Append(trial);
sink.Append("/");
sink.Append(group);
// Intentionally output a string that is not a valid field trial string.
// Stringification is intended only for human readable logs, and is not
// intended for reusing as `FieldTrials` construction parameter.
sink.Append("//");
}
}
} // namespace webrtc
#endif // API_FIELD_TRIALS_H_

View File

@ -10,25 +10,23 @@
#include "api/field_trials.h"
#include <memory>
#include "api/transport/field_trial_based_config.h"
#include "absl/strings/str_cat.h"
#include "rtc_base/containers/flat_set.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
#include "test/gmock.h"
#include "test/gtest.h"
#if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
#include "test/testsupport/rtc_expect_death.h"
#endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
namespace webrtc {
namespace {
using field_trial::FieldTrialsAllowedInScopeForTesting;
using test::ScopedFieldTrials;
using ::testing::AllOf;
using ::testing::HasSubstr;
using ::testing::IsNull;
using ::testing::Not;
using ::testing::NotNull;
using ::webrtc::field_trial::FieldTrialsAllowedInScopeForTesting;
using ::webrtc::test::ScopedFieldTrials;
TEST(FieldTrialsTest, EmptyStringHasNoEffect) {
FieldTrialsAllowedInScopeForTesting k({"MyCoolTrial"});
@ -61,89 +59,138 @@ TEST(FieldTrialsTest, FieldTrialsDoesNotReadGlobalString) {
EXPECT_FALSE(f.IsDisabled("MyUncoolTrial"));
}
TEST(FieldTrialsTest, FieldTrialsWritesGlobalString) {
FieldTrialsAllowedInScopeForTesting k({"MyCoolTrial", "MyUncoolTrial"});
FieldTrials f("MyCoolTrial/Enabled/MyUncoolTrial/Disabled/");
EXPECT_TRUE(webrtc::field_trial::IsEnabled("MyCoolTrial"));
EXPECT_TRUE(webrtc::field_trial::IsDisabled("MyUncoolTrial"));
}
TEST(FieldTrialsTest, FieldTrialsRestoresGlobalStringAfterDestruction) {
static constexpr char s[] = "SomeString/Enabled/";
ScopedFieldTrials g(s);
{
FieldTrials f("SomeOtherString/Enabled/");
EXPECT_STREQ(webrtc::field_trial::GetFieldTrialString(),
"SomeOtherString/Enabled/");
}
EXPECT_STREQ(webrtc::field_trial::GetFieldTrialString(), s);
}
#if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
TEST(FieldTrialsTest, FieldTrialsDoesNotSupportSimultaneousInstances) {
FieldTrials f("SomeString/Enabled/");
RTC_EXPECT_DEATH(FieldTrials("SomeOtherString/Enabled/").Lookup("Whatever"),
"Only one instance");
}
#endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
TEST(FieldTrialsTest, FieldTrialsSupportsSeparateInstances) {
{ FieldTrials f("SomeString/Enabled/"); }
{ FieldTrials f("SomeOtherString/Enabled/"); }
}
TEST(FieldTrialsTest, NonGlobalFieldTrialsInstanceDoesNotModifyGlobalString) {
TEST(FieldTrialsTest, FieldTrialsInstanceDoesNotModifyGlobalString) {
FieldTrialsAllowedInScopeForTesting k({"SomeString"});
std::unique_ptr<FieldTrials> f =
FieldTrials::CreateNoGlobal("SomeString/Enabled/");
ASSERT_THAT(f, NotNull());
f->RegisterKeysForTesting({"SomeString"});
FieldTrials f("SomeString/Enabled/");
f.RegisterKeysForTesting({"SomeString"});
EXPECT_TRUE(f->IsEnabled("SomeString"));
EXPECT_FALSE(webrtc::field_trial::IsEnabled("SomeString"));
EXPECT_TRUE(f.IsEnabled("SomeString"));
EXPECT_FALSE(field_trial::IsEnabled("SomeString"));
}
TEST(FieldTrialsTest, NonGlobalFieldTrialsSupportSimultaneousInstances) {
std::unique_ptr<FieldTrials> f1 =
FieldTrials::CreateNoGlobal("SomeString/Enabled/");
std::unique_ptr<FieldTrials> f2 =
FieldTrials::CreateNoGlobal("SomeOtherString/Enabled/");
ASSERT_THAT(f1, NotNull());
ASSERT_THAT(f2, NotNull());
f1->RegisterKeysForTesting({"SomeString", "SomeOtherString"});
f2->RegisterKeysForTesting({"SomeString", "SomeOtherString"});
EXPECT_TRUE(f1->IsEnabled("SomeString"));
EXPECT_FALSE(f1->IsEnabled("SomeOtherString"));
EXPECT_FALSE(f2->IsEnabled("SomeString"));
EXPECT_TRUE(f2->IsEnabled("SomeOtherString"));
}
TEST(FieldTrialsTest, GlobalAndNonGlobalFieldTrialsAreDisjoint) {
FieldTrialsAllowedInScopeForTesting k({"SomeString", "SomeOtherString"});
TEST(FieldTrialsTest, FieldTrialsSupportSimultaneousInstances) {
FieldTrials f1("SomeString/Enabled/");
std::unique_ptr<FieldTrials> f2 =
FieldTrials::CreateNoGlobal("SomeOtherString/Enabled/");
ASSERT_THAT(f2, NotNull());
FieldTrials f2("SomeOtherString/Enabled/");
f1.RegisterKeysForTesting({"SomeString", "SomeOtherString"});
f2->RegisterKeysForTesting({"SomeString", "SomeOtherString"});
f2.RegisterKeysForTesting({"SomeString", "SomeOtherString"});
EXPECT_TRUE(f1.IsEnabled("SomeString"));
EXPECT_FALSE(f1.IsEnabled("SomeOtherString"));
EXPECT_FALSE(f2->IsEnabled("SomeString"));
EXPECT_TRUE(f2->IsEnabled("SomeOtherString"));
EXPECT_FALSE(f2.IsEnabled("SomeString"));
EXPECT_TRUE(f2.IsEnabled("SomeOtherString"));
}
TEST(FieldTrialsTest, FieldTrialBasedConfigReadsGlobalString) {
FieldTrialsAllowedInScopeForTesting k({"MyCoolTrial", "MyUncoolTrial"});
ScopedFieldTrials g("MyCoolTrial/Enabled/MyUncoolTrial/Disabled/");
FieldTrialBasedConfig f;
f.RegisterKeysForTesting({"MyCoolTrial", "MyUncoolTrial"});
TEST(FieldTrialsTest, GlobalAndNonGlobalFieldTrialsAreDisjoint) {
FieldTrialsAllowedInScopeForTesting k({"SomeString", "SomeOtherString"});
ScopedFieldTrials g("SomeString/Enabled/");
FieldTrials f("SomeOtherString/Enabled/");
EXPECT_TRUE(f.IsEnabled("MyCoolTrial"));
EXPECT_TRUE(f.IsDisabled("MyUncoolTrial"));
f.RegisterKeysForTesting({"SomeString", "SomeOtherString"});
EXPECT_TRUE(field_trial::IsEnabled("SomeString"));
EXPECT_FALSE(field_trial::IsEnabled("SomeOtherString"));
EXPECT_FALSE(f.IsEnabled("SomeString"));
EXPECT_TRUE(f.IsEnabled("SomeOtherString"));
}
TEST(FieldTrialsTest, CreateAcceptsValidInputs) {
EXPECT_THAT(FieldTrials::Create(""), NotNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/"), NotNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/Video/Disabled/"), NotNull());
// Duplicate trials with the same value is fine
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/Audio/Enabled/"), NotNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/B/C/Audio/Enabled/"),
NotNull());
}
TEST(FieldTrialsTest, CreateRejectsBadInputs) {
// Bad delimiters
EXPECT_THAT(FieldTrials::Create("Audio/EnabledVideo/Disabled/"), IsNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled//Video/Disabled/"), IsNull());
EXPECT_THAT(FieldTrials::Create("/Audio/Enabled/Video/Disabled/"), IsNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/Video/Disabled"), IsNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/Video/Disabled/garbage"),
IsNull());
// Empty trial or group
EXPECT_THAT(FieldTrials::Create("Audio//"), IsNull());
EXPECT_THAT(FieldTrials::Create("/Enabled/"), IsNull());
EXPECT_THAT(FieldTrials::Create("//"), IsNull());
EXPECT_THAT(FieldTrials::Create("//Enabled"), IsNull());
// Duplicate trials with different values is not fine
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/Audio/Disabled/"), IsNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/B/C/Audio/Disabled/"),
IsNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/Audio/Disabled/"), IsNull());
EXPECT_THAT(FieldTrials::Create("Audio/Enabled/B/C/Audio/Disabled/"),
IsNull());
}
TEST(FieldTrialsTest, StringfiyMentionsKeysAndValues) {
// Exact format of the stringification is undefined.
EXPECT_THAT(absl::StrCat(FieldTrials("Audio/Enabled/Video/Value/")),
AllOf(HasSubstr("Audio"), HasSubstr("Enabled"),
HasSubstr("Video"), HasSubstr("Value")));
}
TEST(FieldTrialsTest, MergeCombinesFieldTrials) {
FieldTrials f("Video/Value1/");
FieldTrials other("Audio/Value2/");
f.Merge(other);
f.RegisterKeysForTesting({"Audio", "Video"});
EXPECT_EQ(f.Lookup("Video"), "Value1");
EXPECT_EQ(f.Lookup("Audio"), "Value2");
}
TEST(FieldTrialsTest, MergeGivesPrecedenceToOther) {
FieldTrials f("Audio/Disabled/Video/Enabled/");
FieldTrials other("Audio/Enabled/");
f.Merge(other);
f.RegisterKeysForTesting({"Audio"});
EXPECT_EQ(f.Lookup("Audio"), "Enabled");
}
TEST(FieldTrialsTest, MergeDoesntChangeTrialAbsentInOther) {
FieldTrials f("Audio/Enabled/Video/Enabled/");
FieldTrials other("Audio/Enabled/");
f.Merge(other);
f.RegisterKeysForTesting({"Video"});
EXPECT_EQ(f.Lookup("Video"), "Enabled");
}
TEST(FieldTrialsTest, SetUpdatesTrial) {
FieldTrials f("Audio/Enabled/Video/Enabled/");
f.Set("Audio", "Disabled");
f.RegisterKeysForTesting({"Audio"});
EXPECT_EQ(f.Lookup("Audio"), "Disabled");
}
TEST(FieldTrialsTest, SettingEmptyValueRemovesFieldTrial) {
FieldTrials f("Audio/Enabled/Video/Enabled/");
f.Set("Audio", "");
f.RegisterKeysForTesting({"Audio"});
EXPECT_EQ(f.Lookup("Audio"), "");
EXPECT_THAT(absl::StrCat(f), Not(HasSubstr("Audio")));
// Absent field trials shouldn't override previous value during merge.
FieldTrials f2("Audio/Disabled/");
f2.Merge(f);
f2.RegisterKeysForTesting({"Audio"});
EXPECT_EQ(f2.Lookup("Audio"), "Disabled");
}
} // namespace

View File

@ -45,12 +45,14 @@ class TransformableFrameInterface {
// Returns the frame payload data. The data is valid until the next non-const
// method call.
virtual rtc::ArrayView<const uint8_t> GetData() const = 0;
virtual ArrayView<const uint8_t> GetData() const = 0;
// Copies `data` into the owned frame payload data.
virtual void SetData(rtc::ArrayView<const uint8_t> data) = 0;
virtual void SetData(ArrayView<const uint8_t> data) = 0;
virtual uint8_t GetPayloadType() const = 0;
virtual bool CanSetPayloadType() const { return false; }
virtual void SetPayloadType(uint8_t payload_type) { RTC_DCHECK_NOTREACHED(); }
virtual uint32_t GetSsrc() const = 0;
virtual uint32_t GetTimestamp() const = 0;
virtual void SetRTPTimestamp(uint32_t timestamp) = 0;
@ -85,11 +87,17 @@ class TransformableFrameInterface {
virtual std::optional<Timestamp> ReceiveTime() const = 0;
// Timestamp at which the frame was captured in the capturer system.
// The timestamp is expressed in the capturer system's clock relative to the
// NTP epoch (January 1st 1970 00:00 UTC)
// Accessible only if the absolute capture timestamp header extension is
// For receiver frames, the timestamp is expressed in the capturer system's
// clock relative to the NTP epoch (January 1st 1970 00:00 UTC) and is
// available only if the absolute capture timestamp header extension is
// enabled.
// For sender frames, the timestamp is expressed relative to the local
// system clock's default epoch.
virtual std::optional<Timestamp> CaptureTime() const = 0;
virtual bool CanSetCaptureTime() const { return false; }
virtual void SetCaptureTime(std::optional<Timestamp> capture_time) {
RTC_DCHECK_NOTREACHED();
}
// Offset between the sender system's clock and the capturer system's clock.
// Can be used to express the capture time in the local system's clock as
@ -117,7 +125,7 @@ class TransformableAudioFrameInterface : public TransformableFrameInterface {
RTC_EXPORT explicit TransformableAudioFrameInterface(Passkey passkey);
virtual ~TransformableAudioFrameInterface() = default;
virtual rtc::ArrayView<const uint32_t> GetContributingSources() const = 0;
virtual ArrayView<const uint32_t> GetContributingSources() const = 0;
virtual const std::optional<uint16_t> SequenceNumber() const = 0;
@ -134,6 +142,10 @@ class TransformableAudioFrameInterface : public TransformableFrameInterface {
// dBov. 127 represents digital silence. Only present on remote frames if
// the audio level header extension was included.
virtual std::optional<uint8_t> AudioLevel() const = 0;
virtual bool CanSetAudioLevel() const { return false; }
virtual void SetAudioLevel(std::optional<uint8_t> audio_level_dbov) {
RTC_DCHECK_NOTREACHED();
}
};
// Objects implement this interface to be notified with the transformed frame.
@ -161,9 +173,9 @@ class FrameTransformerInterface : public RefCountInterface {
std::unique_ptr<TransformableFrameInterface> transformable_frame) = 0;
virtual void RegisterTransformedFrameCallback(
rtc::scoped_refptr<TransformedFrameCallback>) {}
scoped_refptr<TransformedFrameCallback>) {}
virtual void RegisterTransformedFrameSinkCallback(
rtc::scoped_refptr<TransformedFrameCallback>,
scoped_refptr<TransformedFrameCallback>,
uint32_t /* ssrc */) {}
virtual void UnregisterTransformedFrameCallback() {}
virtual void UnregisterTransformedFrameSinkCallback(uint32_t /* ssrc */) {}
@ -178,7 +190,7 @@ class FrameTransformerHost {
public:
virtual ~FrameTransformerHost() {}
virtual void SetFrameTransformer(
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
// TODO: bugs.webrtc.org/15929 - To be added:
// virtual AddIncomingMediaType(RtpCodec codec) = 0;
// virtual AddOutgoingMediaType(RtpCodec codec) = 0;

View File

@ -29,7 +29,7 @@
//
// Example use:
//
// void SomeFunction(rtc::FunctionView<int(int)> index_transform);
// void SomeFunction(webrtc::FunctionView<int(int)> index_transform);
// ...
// SomeFunction([](int i) { return 2 * i + 1; });
//
@ -130,8 +130,10 @@ class FunctionView<RetT(ArgT...)> final {
// Re-export symbols from the webrtc namespace for backwards compatibility.
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES
namespace rtc {
using ::webrtc::FunctionView;
} // namespace rtc
#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES
#endif // API_FUNCTION_VIEW_H_

View File

@ -53,18 +53,17 @@ class IceTransportWithTransportChannel : public IceTransportInterface {
} // namespace
rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
scoped_refptr<IceTransportInterface> CreateIceTransport(
PortAllocator* port_allocator) {
IceTransportInit init;
init.set_port_allocator(port_allocator);
return CreateIceTransport(std::move(init));
}
rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
IceTransportInit init) {
return rtc::make_ref_counted<IceTransportWithTransportChannel>(
cricket::P2PTransportChannel::Create(
"", cricket::ICE_CANDIDATE_COMPONENT_RTP, std::move(init)));
scoped_refptr<IceTransportInterface> CreateIceTransport(IceTransportInit init) {
return make_ref_counted<IceTransportWithTransportChannel>(
P2PTransportChannel::Create("", ICE_CANDIDATE_COMPONENT_RTP,
std::move(init)));
}
} // namespace webrtc

View File

@ -25,7 +25,7 @@ namespace webrtc {
// The PortAllocator must outlive the created IceTransportInterface object.
// TODO(steveanton): Remove in favor of the overload that takes
// IceTransportInit.
RTC_EXPORT rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
RTC_EXPORT scoped_refptr<IceTransportInterface> CreateIceTransport(
PortAllocator* port_allocator);
// Static factory for an IceTransport object that can be created
@ -36,7 +36,7 @@ RTC_EXPORT rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
// IceTransportInterface object.
// `init.async_resolver_factory()` and `init.event_log()` are optional, but if
// provided must outlive the created IceTransportInterface object.
RTC_EXPORT rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
RTC_EXPORT scoped_refptr<IceTransportInterface> CreateIceTransport(
IceTransportInit);
} // namespace webrtc

View File

@ -35,7 +35,7 @@ class IceTransportInterface : public RefCountInterface {
// The returned object can only be safely used on the signalling thread.
// TODO(crbug.com/907849): Add API calls for the functions that have to
// be exposed to clients, and stop allowing access to the
// cricket::IceTransportInternal API.
// webrtc::IceTransportInternal API.
virtual IceTransportInternal* internal() = 0;
};
@ -121,7 +121,7 @@ class IceTransportFactory {
// requires the returned transport to be constructed and destroyed on the
// network thread and an ICE transport factory that intends to work with a
// peer connection should offer transports compatible with these assumptions.
virtual rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
virtual scoped_refptr<IceTransportInterface> CreateIceTransport(
const std::string& transport_name,
int component,
IceTransportInit init) = 0;

View File

@ -15,6 +15,8 @@
#include <string>
#include <vector>
#include "api/candidate.h"
namespace webrtc {
std::string IceCandidateInterface::server_url() const {
@ -22,7 +24,7 @@ std::string IceCandidateInterface::server_url() const {
}
size_t SessionDescriptionInterface::RemoveCandidates(
const std::vector<cricket::Candidate>& /* candidates */) {
const std::vector<Candidate>& /* candidates */) {
return 0;
}

View File

@ -9,13 +9,13 @@
*/
// This file contains declarations of interfaces that wrap SDP-related
// constructs; session descriptions and ICE candidates. The inner "cricket::"
// constructs; session descriptions and ICE candidates. The inner "webrtc::"
// objects shouldn't be accessed directly; the intention is that an application
// using the PeerConnection API only creates these objects from strings, and
// them passes them into the PeerConnection.
//
// Though in the future, we're planning to provide an SDP parsing API, with a
// structure more friendly than cricket::SessionDescription.
// structure more friendly than webrtc::SessionDescription.
#ifndef API_JSEP_H_
#define API_JSEP_H_

View File

@ -17,10 +17,10 @@
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/strings/str_cat.h"
#include "api/make_ref_counted.h"
#include "api/sequence_checker.h"
#include "rtc_base/checks.h"
#include "rtc_base/string_encode.h"
// TODO(tommi): Could we have a static map of value name -> expected type
// and use this to RTC_DCHECK on correct usage (somewhat strongly typed values)?
@ -104,7 +104,7 @@ class TypedIntId : public StatsReport::IdBase {
std::string ToString() const override {
return std::string(InternalTypeToString(type_)) + kSeparator +
rtc::ToString(id_);
absl::StrCat(id_);
}
protected:
@ -170,7 +170,7 @@ class ComponentId : public StatsReport::IdBase {
std::string ret(prefix);
ret += content_name_;
ret += '-';
ret += rtc::ToString(component_);
ret += absl::StrCat(component_);
return ret;
}
@ -195,7 +195,7 @@ class CandidatePairId : public ComponentId {
std::string ToString() const override {
std::string ret(ComponentId::ToString("Conn-"));
ret += '-';
ret += rtc::ToString(index_);
ret += absl::StrCat(index_);
return ret;
}
@ -672,11 +672,11 @@ const char* StatsReport::Value::display_name() const {
std::string StatsReport::Value::ToString() const {
switch (type_) {
case kInt:
return rtc::ToString(value_.int_);
return absl::StrCat(value_.int_);
case kInt64:
return rtc::ToString(value_.int64_);
return absl::StrCat(value_.int64_);
case kFloat:
return rtc::ToString(value_.float_);
return absl::StrCat(value_.float_);
case kStaticString:
return std::string(value_.static_string_);
case kString:
@ -698,17 +698,17 @@ StatsReport::~StatsReport() = default;
// static
StatsReport::Id StatsReport::NewBandwidthEstimationId() {
return rtc::make_ref_counted<BandwidthEstimationId>();
return make_ref_counted<BandwidthEstimationId>();
}
// static
StatsReport::Id StatsReport::NewTypedId(StatsType type, const std::string& id) {
return rtc::make_ref_counted<TypedId>(type, id);
return make_ref_counted<TypedId>(type, id);
}
// static
StatsReport::Id StatsReport::NewTypedIntId(StatsType type, int id) {
return rtc::make_ref_counted<TypedIntId>(type, id);
return make_ref_counted<TypedIntId>(type, id);
}
// static
@ -716,25 +716,25 @@ StatsReport::Id StatsReport::NewIdWithDirection(
StatsType type,
const std::string& id,
StatsReport::Direction direction) {
return rtc::make_ref_counted<IdWithDirection>(type, id, direction);
return make_ref_counted<IdWithDirection>(type, id, direction);
}
// static
StatsReport::Id StatsReport::NewCandidateId(bool local, const std::string& id) {
return rtc::make_ref_counted<CandidateId>(local, id);
return make_ref_counted<CandidateId>(local, id);
}
// static
StatsReport::Id StatsReport::NewComponentId(const std::string& content_name,
int component) {
return rtc::make_ref_counted<ComponentId>(content_name, component);
return make_ref_counted<ComponentId>(content_name, component);
}
// static
StatsReport::Id StatsReport::NewCandidatePairId(const std::string& content_name,
int component,
int index) {
return rtc::make_ref_counted<CandidatePairId>(content_name, component, index);
return make_ref_counted<CandidatePairId>(content_name, component, index);
}
const char* StatsReport::TypeToString() const {

Some files were not shown because too many files have changed in this diff Show More