diff --git a/.gitignore b/.gitignore index 2ff4979337..35f872131b 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ /.vscode !webrtc/* out_ios_libs +rust-project.json diff --git a/.gn b/.gn index e628c3abba..d29e7e3ced 100644 --- a/.gn +++ b/.gn @@ -55,8 +55,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) @@ -90,4 +89,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 } diff --git a/.vpython3 b/.vpython3 index 6d52ebcba6..dfbd4323ef 100644 --- a/.vpython3 +++ b/.vpython3 @@ -80,7 +80,7 @@ wheel: < > wheel: < name: "infra/python/wheels/protobuf-py3" - version: "version:6.30.2" + version: "version:6.31.0" > wheel: < name: "infra/python/wheels/requests-py3" diff --git a/AUTHORS b/AUTHORS index 0599f49da1..62ae7720b3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -122,6 +122,7 @@ Robert Mader Robert Mader Robert Nagy Ryan Yoakum +Saming Lin Samuel Attard Sarah Thompson Satender Saroha diff --git a/BUILD.gn b/BUILD.gn index ca8d8faa61..4ad7f3e00c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -377,8 +377,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. @@ -537,6 +536,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", @@ -632,6 +632,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", @@ -823,3 +825,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) +} diff --git a/DEPS b/DEPS index 61027df618..2ae7d6b92a 100644 --- a/DEPS +++ b/DEPS @@ -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': '92c0179e11451c30349504abb941d3615938ca29', + '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 @@ -36,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.20250424.2.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, @@ -51,9 +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:70e1167e0e6dad10c8388cace8fd9d9376c43316', + 'siso_version': 'git_revision:df8adf712c5b5605b438fdfcd44235107811e5ef', # ninja CIPD package. 'ninja_package': 'infra/3pp/tools/ninja/', @@ -73,30 +73,30 @@ vars = { deps = { # TODO(kjellander): Move this to be Android-only. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@86c814633cf284bc8057a539bc722e2a672afe2f', + 'https://chromium.googlesource.com/chromium/src/base@4ba67f727a84a10e32a417dc7e194f4fc6a23390', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@88030b320338e0706b6b93336c4b35e6bbaf467e', + 'https://chromium.googlesource.com/chromium/src/build@7adbc7e3263f3ab427ba7c5ac7839a69082ff7fb', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@0f32cb9025766951122d4ed19aba87a94ded3f43', + '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@058aa981a69171da048bdcf82d89c64fcd43d16b', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@28bb2043d52518c3358080a865271d72b7478e06', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@a89c37d36bf80c05963727e28b9916835ae88d3a', + 'https://chromium.googlesource.com/chromium/src/testing@44b0a8d794b28dbd74614e5f5e7da2b407030647', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@8062e0e102496ff14a8c58b586f014527424953d', + 'https://chromium.googlesource.com/chromium/src/third_party@8a150db896356cd9b47f8c1a6d916347393f90f2', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-${{arch}}', - 'version': 'git_revision:85cc21e94af590a267c1c7a47020d9b420f8a033', + 'version': 'git_revision:ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b', } ], 'dep_type': 'cipd', @@ -106,7 +106,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:85cc21e94af590a267c1c7a47020d9b420f8a033', + 'version': 'git_revision:ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b', } ], 'dep_type': 'cipd', @@ -116,7 +116,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:85cc21e94af590a267c1c7a47020d9b420f8a033', + 'version': 'git_revision:ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b', } ], 'dep_type': 'cipd', @@ -142,143 +142,143 @@ deps = { 'objects': [ { # The Android libclang_rt.builtins libraries are currently only included in the Linux clang package. - 'object_name': 'Linux_x64/clang-llvmorg-21-init-6681-g5b36835d-1.tar.xz', - 'sha256sum': '17d9277d32a87f856c6d0a5ee3f662015d423d876315d7736ca7b05b2b6f047e', - 'size_bytes': 54610924, - 'generation': 1743178947242029, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '426b5f0daf964c3e1a9b9e7626311e8544a3e4768c8ef80d31464894b0fead68', - 'size_bytes': 13573888, - 'generation': 1743178947383618, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': 'e419c7db3d30a163fdd8692cfeef26a1fb22db039f2f6ab42b930edfc4e5fd43', - 'size_bytes': 13829552, - 'generation': 1743178947404834, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '935be59242458aa5849133c5a47b4ae11f6d8cae92401188e7db070dcae11326', - 'size_bytes': 2303256, - 'generation': 1743178947639495, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '3617952c541889b46806f66223bb4e8342e4c714938e7c83c7b9ca27b8e94cec', - 'size_bytes': 5699348, - 'generation': 1743178947497618, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '690ae86dbd1c3689713db944059e7249760bdc30d4e06fdee79851780d62b255', - 'size_bytes': 51731764, - 'generation': 1743178948995628, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '6e5b19f3ef4f2a84b2137f64c66cf7dc559c399ee070b69c26791ad4530dc84a', - 'size_bytes': 980732, - 'generation': 1743178955913911, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '05c89e445986aece87cf514b0e877c6cb1b847ac32c8fe24baf5386fa2874956', - 'size_bytes': 13595068, - 'generation': 1743178949025853, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '27945ba4a22b9e59b0c28dd299919a1da3a18a2d76e10f30a5e0e72242af6b55', - 'size_bytes': 15018860, - 'generation': 1743178949033402, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '3eb87f93194f7fe3177d4796c8d6376421811538747d1e65c825654ec4ecceea', - 'size_bytes': 2257340, - 'generation': 1743178949227666, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': 'd4478bb335f9555fe6b0c888a4c0f5d48695081b02ce662cfe7a125f3f501eca', - 'size_bytes': 43908296, - 'generation': 1743178957140254, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '06bd6ba46d4c0fc51e018d53c41f1ab81f7222f99dde95a10d57cb7f6c340eb7', - 'size_bytes': 11774556, - 'generation': 1743178957285392, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '1cb1d20b1d9bcf5bfab05f333c1cd21ff723a463f8b3a84c3b1f79758fc8d834', - 'size_bytes': 12058388, - 'generation': 1743178957310593, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '932bd7fb9dd4b8da2a59880f71f9f9fb4c66b071a4e481b19bbc340b9336dd11', - 'size_bytes': 1978748, - 'generation': 1743178957577801, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '6f486adfb406b0fcb9d3b83485ed4fca3467a3565d67baf0d9fd822721b780a1', - 'size_bytes': 46895260, - 'generation': 1743178966458891, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '3fd9808e08070f84920d22ad537e1f2445bcf5773c134ddef28b14cfe46a67e1', - 'size_bytes': 13459292, - 'generation': 1743178966633313, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': 'bcf2e1a93afb20f384dbbcc484815989cb0aa2e593f2235251498c97d7f22493', - 'size_bytes': 2477288, - 'generation': 1743178973852867, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '12978a7e84b777aa10857e13f1e5e999061091126891631bf29df486f4bb2770', - 'size_bytes': 13891176, - 'generation': 1743178966674825, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '14842204c68030e276bb054bd5058a561be025d1ee1a0909943ea4f8c31cd715', - 'size_bytes': 2367868, - 'generation': 1743178966817841, + '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-6681-g5b36835d-1.tar.xz', - 'sha256sum': '6c505137fcc3879c3f0ad3562ec1f530a4b83f725d2a91363d1cfdcc3536252e', - 'size_bytes': 5673896, - 'generation': 1743178966726617, + '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"', }, ] @@ -290,31 +290,31 @@ deps = { '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"', }, ], @@ -323,15 +323,15 @@ 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@57213f125d03209892fed26189feb3b736e96735', + '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@917609c669e43edc850eeb192a342434a54e1dfd', + '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@f2a7f2987f9dcdf8b04c2d8cd4dcb186641a7c3e', + '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@912274164f0877ca917c06e8484ad3be1784833a', + '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@81e2cb40a70de2b6978e6d8658891ded9a77f7e3', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@8575f4ae4fcf8892938bd9766cf1a5c90a0ed04e', 'src/third_party/test_fonts/test_fonts': { 'dep_type': 'gcs', @@ -339,10 +339,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, }, ], }, @@ -427,7 +427,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/error_prone', - 'version': '-IrkxgAkj3RxGNBPp6b4r9OWZC6_dTbI-jC3c3UPgq8C', + 'version': '2jzgic7at7ZxQds7qXCsmkfC4bO7d3qnWU5Q7SFUiJwC', }, ], 'condition': 'checkout_android', @@ -449,7 +449,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/lint', - 'version': 'gx4NrAApWUVG5HG3WJRIIzZrTssD6H5uGbKe0g77mucC', + 'version': 'Rh_qNy2kyeA9GGIdsjnPMvQa1WpHOEoUBZqV9opGGgIC', }, ], 'condition': 'checkout_android and non_git_source', @@ -461,7 +461,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/nullaway', - 'version': 'F6la8NsEkr27_Sm2MswVDBDB7UXVqRtaCMS5YWEQ9dQC', + 'version': 'mFkUqdlIqmMQ3rAaTHFmOBYjNFgFUQOmMlPG6PGgmHYC', }, ], 'condition': 'checkout_android and non_git_source', @@ -480,11 +480,11 @@ deps = { }, 'src/third_party/boringssl/src': - 'https://boringssl.googlesource.com/boringssl.git@34492c89a8e381e0e856a686cc71b1eb5bd728db', + 'https://boringssl.googlesource.com/boringssl.git@9295969e1dad2c31d0d99481734c1c68dcbc6403', 'src/third_party/breakpad/breakpad': - 'https://chromium.googlesource.com/breakpad/breakpad.git@232a723f5096ab02d53d87931efa485fa77d3b03', + 'https://chromium.googlesource.com/breakpad/breakpad.git@2625edb085169e92cf036c236ac79ab594a7b1cc', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@000f47cfa393d7f9557025a252862e2a61a60d44', + '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', }, @@ -497,21 +497,21 @@ 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@fa8fc854e1766b86f10c9a15902cf3cc23adaac2', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@a8900cc0f023d6a662eb66b317e8ddceeb113490', 'src/third_party/ffmpeg': - 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@01f23648c6b84de6c0f717fa4e1816f53b9ee72e', + '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@957c9f95224b1e1318c0ecb98d0e7584ea5ccff2', + '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@1da283b8ae6d6b94f34a5c4b8c1227adc9dbb1d8', + '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@9f83bbbe64654b45ba5bb06927ff36c2e7588495', 'src/third_party/google_benchmark/src': { @@ -525,9 +525,9 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/googletest/src': - 'https://chromium.googlesource.com/external/github.com/google/googletest.git@cd430b47a54841ec45d64d2377d7cabaf0eba610', + 'https://chromium.googlesource.com/external/github.com/google/googletest.git@09ffd0015395354774c059a17d9f5bee36177ff9', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@4c8cc4b365a505ce35be1e0bd488476c5f79805d', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@b929596baebf0ab4ac7ec07f38365db4c50a559d', }, 'src/third_party/jdk/current': { 'packages': [ @@ -563,7 +563,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/kotlin_stdlib', - 'version': 'WkqHVVoDtiOfLxiPT-eO3zyieJRoIRrvs7XqgcIXBYIC', + 'version': 'GUpKElqF0PYGB-SP4D5w6p_MuMYQSBrRkGqFGjPhsIYC', }, ], 'condition': 'checkout_android', @@ -574,7 +574,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/kotlinc', - 'version': 'YASKBvUSO-m2borC3V_hGLsRTyOSnHl2J0BaCmINZkUC', + 'version': 'XmaM7JA4hB75AuMdzCegF-XYzXtoHKOA1anrWqAJL3QC', }, ], 'condition': 'checkout_android', @@ -583,7 +583,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@b10387fdbbca18192f85eaa5323a59f44bf9c468', + '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': @@ -591,19 +591,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@a23a4799ec2d7dd6e436c7b64a34553773014ed7', + 'https://aomedia.googlesource.com/aom.git@2cca4aba034f99842c2e6cdc173f83801d289764', 'src/third_party/libunwindstack': { 'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@0d758dd57f42564acecdd7a1e7ac5c8521c1b01a', 'condition': 'checkout_android', }, 'src/third_party/perfetto': - Var('chromium_git') + '/external/github.com/google/perfetto.git' + '@' + 'a54dd38d60593129ae56d400f1a72860670abea4', + 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@ff1d193f4b9dfa9b2ced51efbb6ec7a69e58e88c', + 'https://chromium.googlesource.com/webm/libvpx.git@b84ca9b63730e7d4563573a56a66317eb0087ebf', 'src/third_party/libyuv': - 'https://chromium.googlesource.com/libyuv/libyuv.git@1e40e34573c3861480d107cd4a4ce290df79951f', + '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', @@ -632,7 +632,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'bA3htCoEd_EArHekDGQSNpmBzQrcby2ioG6SFyl3AtwC', + 'version': 'QhYGRVpYYKZmt3f_Zb2HoJ9LIBEnWaeeLXRNei47Z30C', }, ], 'condition': 'checkout_android', @@ -645,7 +645,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': '6qLey8EBp9ivhThnqVPWy2ZDGpsf5Y29EsTbi_rZ1pMC', + 'version': 'QhYGRVpYYKZmt3f_Zb2HoJ9LIBEnWaeeLXRNei47Z30C', }, ], 'condition': 'checkout_android', @@ -656,7 +656,7 @@ deps = { 'condition': 'checkout_android', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@ffcbc837bbb14d80d09147c2af5302ff6bd4bd69', + 'https://chromium.googlesource.com/chromium/src/tools@901b847deda65d44f1bba16a9f47e2ea68a805be', 'src/third_party/espresso': { 'packages': [ @@ -695,7 +695,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'cxEyTzVT7uuNifSPlUiuKlb4tSo35_YQjBbMVmgZeCwC', + 'version': 'SRLnRQtsEaeNt_-cy_acdUbX63elq51jmwvif531vHgC', }, ], 'condition': 'checkout_android and non_git_source', @@ -706,7 +706,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/manifest_merger', - 'version': 'HhXknpcPosMUDHZQD-8Ogve-HaG4HmJ4p082zKKAcnMC', + 'version': 'i1CvLtWlkB9QDx0DL_52AZNLpuQc2d6MbpRsCbzgEtEC', }, ], 'condition': 'checkout_android', @@ -777,7 +777,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/turbine', - 'version': 'scfGptWnO9bwzbg-jr0mcnVO3NG5KQJvlAQd_JSD5QUC', + 'version': 'VGtOG2ivl1SJR7Lai5FQddIu15mWCYDnp47QtozMQeoC', }, ], 'condition': 'checkout_android', @@ -785,7 +785,7 @@ deps = { }, 'src/third_party/zstd/src': { - 'url': Var('chromium_git') + '/external/github.com/facebook/zstd.git' + '@' + 'd654fca78690fa15cceb8058ac47454d914a0e63', + 'url': Var('chromium_git') + '/external/github.com/facebook/zstd.git' + '@' + 'f9938c217da17ec3e9dcd2a2d99c5cf39536aeb9', 'condition': 'checkout_android', }, @@ -793,15 +793,15 @@ deps = { 'packages': [ { 'package': 'infra/tools/luci/cas/${{platform}}', - 'version': 'git_revision:fd48b8efe637ea5f431fc371f1617b215b7ba1a2', + 'version': 'git_revision:14c1dfd95e07b23eeaff304bd29a2eb80b06fe0b', }, { 'package': 'infra/tools/luci/isolate/${{platform}}', - 'version': 'git_revision:fd48b8efe637ea5f431fc371f1617b215b7ba1a2', + 'version': 'git_revision:14c1dfd95e07b23eeaff304bd29a2eb80b06fe0b', }, { 'package': 'infra/tools/luci/swarming/${{platform}}', - 'version': 'git_revision:fd48b8efe637ea5f431fc371f1617b215b7ba1a2', + 'version': 'git_revision:14c1dfd95e07b23eeaff304bd29a2eb80b06fe0b', } ], 'dep_type': 'cipd', @@ -827,7 +827,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/autorolled', - 'version': 'yZGuDQ9pDcy816oWVPUC2zMwLtFUfGt4W2PmIYEWTcAC', + 'version': 'p_9xkMekw1ax7bzdkzI9gjCXkONcxJb-xhJDLgyxxlUC', }, ], 'condition': 'checkout_android and non_git_source', @@ -2197,34 +2197,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', diff --git a/api/BUILD.gn b/api/BUILD.gn index 7a3591881f..d7d103de5b 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -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", ] } @@ -321,7 +319,6 @@ rtc_library("libjingle_peerconnection_api") { ":data_channel_event_observer_interface", ":dtls_transport_interface", ":fec_controller_api", - ":field_trials", ":field_trials_view", ":frame_transformer_interface", ":ice_transport_interface", @@ -366,6 +363,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", @@ -403,7 +401,7 @@ rtc_library("libjingle_peerconnection_api") { ] } -rtc_source_set("frame_transformer_interface") { +rtc_library("frame_transformer_interface") { visibility = [ "*" ] sources = [ "frame_transformer_interface.cc", @@ -432,7 +430,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", @@ -526,12 +523,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 +652,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", @@ -886,7 +887,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", @@ -895,7 +895,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", @@ -921,7 +921,7 @@ rtc_source_set("network_emulation_manager_api") { ] } -rtc_source_set("time_controller") { +rtc_library("time_controller") { visibility = [ "*" ] sources = [ "test/time_controller.cc", @@ -974,7 +974,6 @@ rtc_source_set("refcountedbase") { sources = [ "ref_counted_base.h" ] deps = [ ":ref_count", - "../rtc_base:macromagic", "../rtc_base:refcount", ] } @@ -1547,20 +1546,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", ] } @@ -1626,7 +1614,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", @@ -1681,7 +1668,7 @@ if (rtc_include_tests) { } } -rtc_source_set("field_trials_registry") { +rtc_library("field_trials_registry") { visibility = [ "*" ] sources = [ "field_trials_registry.cc", @@ -1725,7 +1712,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", ] } diff --git a/api/DEPS b/api/DEPS index 0efc076c3e..7f168075d9 100644 --- a/api/DEPS +++ b/api/DEPS @@ -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", diff --git a/api/adaptation/BUILD.gn b/api/adaptation/BUILD.gn index fe66065a36..8e1579f9f1 100644 --- a/api/adaptation/BUILD.gn +++ b/api/adaptation/BUILD.gn @@ -8,7 +8,7 @@ import("../../webrtc.gni") -rtc_source_set("resource_adaptation_api") { +rtc_library("resource_adaptation_api") { visibility = [ "*" ] sources = [ "resource.cc", diff --git a/api/array_view.h b/api/array_view.h index db85b47991..577d6cb46c 100644 --- a/api/array_view.h +++ b/api/array_view.h @@ -40,7 +40,7 @@ namespace webrtc { // 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 // ... diff --git a/api/audio/BUILD.gn b/api/audio/BUILD.gn index 13e8d1f82c..2e3c44a3ad 100644 --- a/api/audio/BUILD.gn +++ b/api/audio/BUILD.gn @@ -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", ] } @@ -60,7 +73,7 @@ rtc_source_set("audio_mixer_api") { ] } -rtc_source_set("audio_processing") { +rtc_library("audio_processing") { visibility = [ "*" ] sources = [ "audio_processing.cc", @@ -74,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", @@ -106,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", @@ -156,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 = [ diff --git a/api/audio/audio_device.h b/api/audio/audio_device.h index b22b021ec4..5db7d7ecdd 100644 --- a/api/audio/audio_device.h +++ b/api/audio/audio_device.h @@ -13,10 +13,9 @@ #include #include + #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 { @@ -60,14 +59,6 @@ class AudioDeviceModule : public webrtc::RefCountInterface { }; public: - // Creates a default ADM for usage in production code. - static scoped_refptr 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 scoped_refptr CreateForTest( - AudioLayer audio_layer, TaskQueueFactory* task_queue_factory); - // Retrieve the currently utilized audio layer virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const = 0; diff --git a/api/audio/audio_frame.cc b/api/audio/audio_frame.cc index f578b719ff..4fc224bb52 100644 --- a/api/audio/audio_frame.cc +++ b/api/audio/audio_frame.cc @@ -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; @@ -172,7 +172,7 @@ InterleavedView 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. diff --git a/api/audio/audio_frame.h b/api/audio/audio_frame.h index 456bd2885c..f6f7abe22b 100644 --- a/api/audio/audio_frame.h +++ b/api/audio/audio_frame.h @@ -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), }; diff --git a/api/audio/audio_processing.cc b/api/audio/audio_processing.cc index 2941001c1d..76f0d71ddc 100644 --- a/api/audio/audio_processing.cc +++ b/api/audio/audio_processing.cc @@ -55,8 +55,6 @@ std::string GainController1ModeToString(const Agc1Config::Mode& mode) { } // namespace -constexpr int AudioProcessing::kNativeSampleRatesHz[]; - void CustomProcessing::SetRuntimeSetting( AudioProcessing::RuntimeSetting /* setting */) {} diff --git a/api/audio/audio_processing.h b/api/audio/audio_processing.h index 6a56874fe7..b7882133ff 100644 --- a/api/audio/audio_processing.h +++ b/api/audio/audio_processing.h @@ -36,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" @@ -691,22 +690,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. diff --git a/api/audio/audio_view.h b/api/audio/audio_view.h index 719d60896c..9c4396fd8e 100644 --- a/api/audio/audio_view.h +++ b/api/audio/audio_view.h @@ -13,9 +13,10 @@ #include #include +#include +#include #include "api/array_view.h" -#include "api/audio/channel_layout.h" #include "rtc_base/checks.h" namespace webrtc { @@ -45,6 +46,13 @@ namespace webrtc { template using MonoView = ArrayView; +// 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). template @@ -59,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); } @@ -129,31 +137,65 @@ class DeinterleavedView { DeinterleavedView() = default; + // Construct a view where all the channels are coallocated in a single buffer. template 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 + 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 + DeinterleavedView(const std::vector& 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 mutable_view; + // DeinterleavedView const_view(mutable_view); template DeinterleavedView(const DeinterleavedView& 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(other.data_); + } else { + data_ = std::get(other.data_); + } + } // Returns a deinterleaved channel where `idx` is the zero based index, // in the range [0 .. num_channels()-1]. MonoView operator[](size_t idx) const { - RTC_DCHECK_LT(idx, num_channels_); - return MonoView(&data_[idx * samples_per_channel_], + RTC_DCHECK_LT(idx, num_channels()); + if (is_ptr_array()) + return MonoView(std::get(data_)[idx], samples_per_channel_); + return MonoView(&std::get(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_; } - ArrayView 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 AsMono() const { @@ -161,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 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(data_); } + + template + friend class DeinterleavedView; + size_t num_channels_ = 0u; size_t samples_per_channel_ = 0u; - ArrayView data_; + std::variant data_; }; template diff --git a/api/audio/channel_layout.cc b/api/audio/channel_layout.cc index e4ae356fab..596db90cfd 100644 --- a/api/audio/channel_layout.cc +++ b/api/audio/channel_layout.cc @@ -12,7 +12,8 @@ #include -#include "rtc_base/arraysize.h" +#include + #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(layout), arraysize(kLayoutToChannels)); + RTC_DCHECK_LT(static_cast(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(layout), arraysize(kChannelOrderings)); - RTC_DCHECK_LT(static_cast(channel), arraysize(kChannelOrderings[0])); + RTC_DCHECK_LT(static_cast(layout), std::size(kChannelOrderings)); + RTC_DCHECK_LT(static_cast(channel), std::size(kChannelOrderings[0])); return kChannelOrderings[layout][channel]; } diff --git a/api/audio/create_audio_device_module.cc b/api/audio/create_audio_device_module.cc new file mode 100644 index 0000000000..26cb6c12d8 --- /dev/null +++ b/api/audio/create_audio_device_module.cc @@ -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 CreateAudioDeviceModule( + const Environment& env, + AudioDeviceModule::AudioLayer audio_layer) { + return AudioDeviceModuleImpl::Create(env, audio_layer); +} + +} // namespace webrtc diff --git a/api/audio/create_audio_device_module.h b/api/audio/create_audio_device_module.h new file mode 100644 index 0000000000..b86873d16a --- /dev/null +++ b/api/audio/create_audio_device_module.h @@ -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 CreateAudioDeviceModule( + const Environment& env, + AudioDeviceModule::AudioLayer audio_layer); + +} // namespace webrtc + +#endif // API_AUDIO_CREATE_AUDIO_DEVICE_MODULE_H_ diff --git a/api/audio/echo_canceller3_factory.cc b/api/audio/echo_canceller3_factory.cc index 6e3a54a783..8a87f0a648 100644 --- a/api/audio/echo_canceller3_factory.cc +++ b/api/audio/echo_canceller3_factory.cc @@ -22,11 +22,11 @@ namespace webrtc { EchoCanceller3Factory::EchoCanceller3Factory() {} -EchoCanceller3Factory::EchoCanceller3Factory(const EchoCanceller3Config config) +EchoCanceller3Factory::EchoCanceller3Factory(const EchoCanceller3Config& config) : config_(config), multichannel_config_(std::nullopt) {} EchoCanceller3Factory::EchoCanceller3Factory( - const EchoCanceller3Config config, + const EchoCanceller3Config& config, std::optional multichannel_config) : config_(config), multichannel_config_(multichannel_config) {} diff --git a/api/audio/echo_canceller3_factory.h b/api/audio/echo_canceller3_factory.h index e26f298930..756fd4682e 100644 --- a/api/audio/echo_canceller3_factory.h +++ b/api/audio/echo_canceller3_factory.h @@ -29,12 +29,12 @@ class RTC_EXPORT EchoCanceller3Factory : public EchoControlFactory { // Factory producing EchoCanceller3 instances with the specified // configuration. - explicit EchoCanceller3Factory(const EchoCanceller3Config config); + explicit EchoCanceller3Factory(const EchoCanceller3Config& config); // Factory producing EchoCanceller3 instances with the specified // configuration and multichannel configuration. EchoCanceller3Factory( - const EchoCanceller3Config config, + const EchoCanceller3Config& config, std::optional multichannel_config); // Creates an EchoCanceller3 with a specified channel count and sampling rate. diff --git a/api/audio/test/BUILD.gn b/api/audio/test/BUILD.gn index b1060faae3..73762fc54a 100644 --- a/api/audio/test/BUILD.gn +++ b/api/audio/test/BUILD.gn @@ -26,6 +26,7 @@ if (rtc_include_tests) { "../..:array_view", "../../../modules/audio_processing:aec3_config_json", "../../../rtc_base:checks", + "../../../rtc_base:macromagic", "../../../test:test_support", ] } diff --git a/api/audio/test/audio_view_unittest.cc b/api/audio/test/audio_view_unittest.cc index 1d3f5f17b5..55e9d87f63 100644 --- a/api/audio/test/audio_view_unittest.cc +++ b/api/audio/test/audio_view_unittest.cc @@ -13,8 +13,10 @@ #include #include #include +#include #include "api/array_view.h" +#include "rtc_base/arraysize.h" #include "test/gtest.h" namespace webrtc { @@ -190,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 v1(100), v2(200), v3(300), v4(400); + std::vector channels = {&v1[0], &v2[0], &v3[0], &v4[0]}; + + DeinterleavedView 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(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 diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn index 492a44aa2f..25ea12557b 100644 --- a/api/audio_codecs/BUILD.gn +++ b/api/audio_codecs/BUILD.gn @@ -35,6 +35,7 @@ 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", diff --git a/api/audio_codecs/audio_decoder.cc b/api/audio_codecs/audio_decoder.cc index 83d09bb1e5..dbdaff1d37 100644 --- a/api/audio_codecs/audio_decoder.cc +++ b/api/audio_codecs/audio_decoder.cc @@ -27,6 +27,9 @@ namespace webrtc { namespace { +// TODO(peah): Rationale +static_assert(AudioDecoder::kMaxNumberOfChannels <= 255, ""); + class OldStyleEncodedFrame final : public AudioDecoder::EncodedAudioFrame { public: OldStyleEncodedFrame(AudioDecoder* decoder, Buffer&& payload) diff --git a/api/audio_codecs/audio_decoder.h b/api/audio_codecs/audio_decoder.h index d2d5e7b30c..a085d3b059 100644 --- a/api/audio_codecs/audio_decoder.h +++ b/api/audio_codecs/audio_decoder.h @@ -19,6 +19,7 @@ #include #include "api/array_view.h" +#include "api/audio/audio_view.h" #include "rtc_base/buffer.h" namespace webrtc { @@ -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); diff --git a/api/audio_codecs/audio_encoder.cc b/api/audio_codecs/audio_encoder.cc index 377db93c5e..b79d0a8a1e 100644 --- a/api/audio_codecs/audio_encoder.cc +++ b/api/audio_codecs/audio_encoder.cc @@ -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; diff --git a/api/audio_codecs/audio_encoder.h b/api/audio_codecs/audio_encoder.h index 56ea287319..8d45eb6201 100644 --- a/api/audio_codecs/audio_encoder.h +++ b/api/audio_codecs/audio_encoder.h @@ -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" @@ -256,7 +257,7 @@ class AudioEncoder { } // The maximum number of audio channels supported by WebRTC encoders. - static constexpr int kMaxNumberOfChannels = 24; + static constexpr int kMaxNumberOfChannels = kMaxNumberOfAudioChannels; protected: // Subclasses implement this to perform the actual encoding. Called by diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn index 2035a791be..c24e3d779b 100644 --- a/api/audio_codecs/opus/BUILD.gn +++ b/api/audio_codecs/opus/BUILD.gn @@ -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" ] diff --git a/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h b/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h index a24e28e036..0bb7c431e5 100644 --- a/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h +++ b/api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h @@ -55,7 +55,7 @@ struct AudioDecoderMultiChannelOpusConfig { } } - if (num_channels > 255 || max_coded_channel >= 255) { + if (max_coded_channel >= 255) { return false; } return true; diff --git a/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc b/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc index d8367b45c9..a8123cb17a 100644 --- a/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc +++ b/api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.cc @@ -13,6 +13,8 @@ #include #include +#include "api/audio_codecs/audio_encoder.h" + namespace webrtc { namespace { @@ -42,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) diff --git a/api/audio_codecs/opus/audio_encoder_opus_config.cc b/api/audio_codecs/opus/audio_encoder_opus_config.cc index a9ab924b38..92ee7bd66c 100644 --- a/api/audio_codecs/opus/audio_encoder_opus_config.cc +++ b/api/audio_codecs/opus/audio_encoder_opus_config.cc @@ -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) diff --git a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc index 50768b930a..f2dfe93608 100644 --- a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc @@ -281,5 +281,14 @@ TEST(AudioDecoderFactoryTemplateTest, Opus) { EXPECT_EQ(48000, dec->SampleRateHz()); } +TEST(AudioDecoderFactoryTemplateTest, G711TooManyChannels) { + auto factory = CreateAudioDecoderFactory(); + const Environment env = CreateEnvironment(); + EXPECT_EQ(nullptr, factory->Create(env, + {"pcmu", 16000, + /* num_channels=*/1000}, + std::nullopt)); +} + } // namespace } // namespace webrtc diff --git a/api/call/transport.h b/api/call/transport.h index b2bc18ef10..74d7addf6c 100644 --- a/api/call/transport.h +++ b/api/call/transport.h @@ -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; @@ -42,10 +43,11 @@ class Transport { public: virtual bool SendRtp(ArrayView packet, const PacketOptions& options) = 0; - virtual bool SendRtcp(ArrayView packet) = 0; + virtual bool SendRtcp(ArrayView packet, + const PacketOptions& options) = 0; protected: - virtual ~Transport() {} + virtual ~Transport() = default; }; } // namespace webrtc diff --git a/api/candidate.cc b/api/candidate.cc index 30a6c1b87b..bb12f06a3b 100644 --- a/api/candidate.cc +++ b/api/candidate.cc @@ -48,8 +48,8 @@ Candidate::Candidate() : id_(CreateRandomString(8)), 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(""); @@ -253,13 +253,13 @@ void Candidate::ComputeFoundation(const SocketAddress& base_address, // - 1 (that is, a 64-bit positive integer). This number is used in // connectivity checks to detect and repair this case [...] sb << absl::StrCat(tie_breaker); - foundation_ = absl::StrCat(webrtc::ComputeCrc32(sb.Release())); + foundation_ = absl::StrCat(ComputeCrc32(sb.Release())); } void Candidate::ComputePrflxFoundation() { RTC_DCHECK(is_prflx()); RTC_DCHECK(!id_.empty()); - foundation_ = absl::StrCat(webrtc::ComputeCrc32(id_)); + foundation_ = absl::StrCat(ComputeCrc32(id_)); } void Candidate::Assign(std::string& s, absl::string_view view) { diff --git a/api/create_peerconnection_factory.cc b/api/create_peerconnection_factory.cc index ededc00816..aec4f12549 100644 --- a/api/create_peerconnection_factory.cc +++ b/api/create_peerconnection_factory.cc @@ -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" @@ -48,7 +49,7 @@ scoped_refptr CreatePeerConnectionFactory( dependencies.worker_thread = worker_thread; dependencies.signaling_thread = signaling_thread; dependencies.event_log_factory = std::make_unique(); - dependencies.trials = std::move(field_trials); + dependencies.env = CreateEnvironment(std::move(field_trials)); if (network_thread) { // TODO(bugs.webrtc.org/13145): Add an webrtc::SocketFactory* argument. diff --git a/api/crypto/BUILD.gn b/api/crypto/BUILD.gn index 2970f341b1..7bfae89caf 100644 --- a/api/crypto/BUILD.gn +++ b/api/crypto/BUILD.gn @@ -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" ] + } + } +} diff --git a/api/crypto/crypto_options.cc b/api/crypto/crypto_options.cc index 2923833c2f..e939f390e5 100644 --- a/api/crypto/crypto_options.cc +++ b/api/crypto/crypto_options.cc @@ -10,8 +10,13 @@ #include "api/crypto/crypto_options.h" +#include +#include +#include +#include #include +#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 +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* disabled_groups) { + // Note: assumption is that these lists contains few elements...so converting + // to set<> is not worth it. + std::vector 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 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 diff --git a/api/crypto/crypto_options.h b/api/crypto/crypto_options.h index a937490787..8adfe4eb36 100644 --- a/api/crypto/crypto_options.h +++ b/api/crypto/crypto_options.h @@ -11,8 +11,13 @@ #ifndef API_CRYPTO_CRYPTO_OPTIONS_H_ #define API_CRYPTO_CRYPTO_OPTIONS_H_ +#include +#include +#include +#include #include +#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 @@ -66,6 +69,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 GetSupported(); + static std::optional GetName(uint16_t); + + EphemeralKeyExchangeCipherGroups(); + + // Which cipher groups are enabled in this crypto options. + std::vector GetEnabled() const { return enabled_; } + void SetEnabled(const std::vector& 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* disabled_groups = nullptr); + + bool operator==(const EphemeralKeyExchangeCipherGroups& other) const; + + private: + std::vector enabled_; + } ephemeral_key_exchange_cipher_groups; }; } // namespace webrtc diff --git a/api/crypto/crypto_options_unittest.cc b/api/crypto/crypto_options_unittest.cc new file mode 100644 index 0000000000..6abc806c3a --- /dev/null +++ b/api/crypto/crypto_options_unittest.cc @@ -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 +#include +#include + +#include "rtc_base/openssl_stream_adapter.h" +#include "test/gtest.h" +#include "test/scoped_key_value_config.h" + +TEST(EphemeralKeyExchangeCipherGroupsTest, GetSupported) { + std::set 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 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 expected = { + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519, + }; + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups groups; + groups.SetEnabled(expected); + EXPECT_EQ(groups.GetEnabled(), expected); +} + +TEST(EphemeralKeyExchangeCipherGroupsTest, AddFirst) { + std::vector 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 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 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 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); +} diff --git a/api/dtls_transport_interface.cc b/api/dtls_transport_interface.cc index 4e672e2201..88d137e8ed 100644 --- a/api/dtls_transport_interface.cc +++ b/api/dtls_transport_interface.cc @@ -30,13 +30,15 @@ DtlsTransportInformation::DtlsTransportInformation( std::optional tls_version, std::optional ssl_cipher_suite, std::optional srtp_cipher_suite, - std::unique_ptr remote_ssl_certificates) + std::unique_ptr remote_ssl_certificates, + std::optional 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( @@ -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; } diff --git a/api/dtls_transport_interface.h b/api/dtls_transport_interface.h index 10fc174643..c444313a5d 100644 --- a/api/dtls_transport_interface.h +++ b/api/dtls_transport_interface.h @@ -53,7 +53,8 @@ class RTC_EXPORT DtlsTransportInformation { std::optional tls_version, std::optional ssl_cipher_suite, std::optional srtp_cipher_suite, - std::unique_ptr remote_ssl_certificates); + std::unique_ptr remote_ssl_certificates, + std::optional ssl_group_id); ABSL_DEPRECATED("Use version with role parameter") DtlsTransportInformation( DtlsTransportState state, @@ -75,6 +76,7 @@ class RTC_EXPORT DtlsTransportInformation { std::optional tls_version() const { return tls_version_; } std::optional ssl_cipher_suite() const { return ssl_cipher_suite_; } std::optional srtp_cipher_suite() const { return srtp_cipher_suite_; } + std::optional ssl_group_id() const { return ssl_group_id_; } // The accessor returns a temporary pointer, it does not release ownership. const SSLCertChain* remote_ssl_certificates() const { return remote_ssl_certificates_.get(); @@ -87,6 +89,7 @@ class RTC_EXPORT DtlsTransportInformation { std::optional ssl_cipher_suite_; std::optional srtp_cipher_suite_; std::unique_ptr remote_ssl_certificates_; + std::optional ssl_group_id_; }; class DtlsTransportObserverInterface { diff --git a/api/enable_media.cc b/api/enable_media.cc index 7d6d0cc3df..81cb890185 100644 --- a/api/enable_media.cc +++ b/api/enable_media.cc @@ -35,19 +35,16 @@ class MediaFactoryImpl : public MediaFactory { ~MediaFactoryImpl() override = default; std::unique_ptr CreateCall(CallConfig config) override { - return webrtc::Call::Create(std::move(config)); + return Call::Create(std::move(config)); } std::unique_ptr CreateMediaEngine( const Environment& env, PeerConnectionFactoryDependencies& deps) override { - absl_nullable scoped_refptr 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 audio_processing; + if (deps.audio_processing_builder != nullptr) { + audio_processing = std::move(deps.audio_processing_builder)->Build(env); + } auto audio_engine = std::make_unique( env, std::move(deps.adm), std::move(deps.audio_encoder_factory), diff --git a/api/enable_media_with_defaults.cc b/api/enable_media_with_defaults.cc index 2ad88849d8..e55e1710e3 100644 --- a/api/enable_media_with_defaults.cc +++ b/api/enable_media_with_defaults.cc @@ -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(); } diff --git a/api/field_trials.cc b/api/field_trials.cc index 4aca69d781..fc896e1258 100644 --- a/api/field_trials.cc +++ b/api/field_trials.cc @@ -10,94 +10,87 @@ #include "api/field_trials.h" -#include #include #include #include +#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 InsertIntoMap(absl::string_view s) { - webrtc::flat_map 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 instance_created_{false}; +bool Parse(absl::string_view s, + flat_map& 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::Create( + absl::string_view s) { + flat_map 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::CreateNoGlobal(absl::string_view s) { - return std::unique_ptr(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 ""; } diff --git a/api/field_trials.h b/api/field_trials.h index 693c1afe8c..4937b506be 100644 --- a/api/field_trials.h +++ b/api/field_trials.h @@ -13,7 +13,9 @@ #include #include +#include +#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: + // 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 Create(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(); - // 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 CreateNoGlobal(absl::string_view s); + FieldTrials(const FieldTrials&) = default; + FieldTrials(FieldTrials&&) = default; + FieldTrials& operator=(const FieldTrials&) = default; + FieldTrials& operator=(FieldTrials&&) = default; + + ~FieldTrials() override = default; + + template + 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 CreateNoGlobal(absl::string_view s) { + return std::make_unique(s); + } private: - explicit FieldTrials(absl::string_view s, bool); + explicit FieldTrials(flat_map 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 key_value_map_; + flat_map key_value_map_; }; +template +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_ diff --git a/api/field_trials_unittest.cc b/api/field_trials_unittest.cc index 8144f11c38..d3521b49ca 100644 --- a/api/field_trials_unittest.cc +++ b/api/field_trials_unittest.cc @@ -10,25 +10,23 @@ #include "api/field_trials.h" -#include - -#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, FieldTrialsInstanceDoesNotModifyGlobalString) { + FieldTrialsAllowedInScopeForTesting k({"SomeString"}); + FieldTrials f("SomeString/Enabled/"); + f.RegisterKeysForTesting({"SomeString"}); + + EXPECT_TRUE(f.IsEnabled("SomeString")); + EXPECT_FALSE(field_trial::IsEnabled("SomeString")); +} + +TEST(FieldTrialsTest, FieldTrialsSupportSimultaneousInstances) { + FieldTrials f1("SomeString/Enabled/"); + FieldTrials f2("SomeOtherString/Enabled/"); + 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, 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); +TEST(FieldTrialsTest, GlobalAndNonGlobalFieldTrialsAreDisjoint) { + FieldTrialsAllowedInScopeForTesting k({"SomeString", "SomeOtherString"}); + ScopedFieldTrials g("SomeString/Enabled/"); + FieldTrials f("SomeOtherString/Enabled/"); + + 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")); } -#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"); +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()); } -#endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -TEST(FieldTrialsTest, FieldTrialsSupportsSeparateInstances) { - { FieldTrials f("SomeString/Enabled/"); } - { FieldTrials f("SomeOtherString/Enabled/"); } +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, NonGlobalFieldTrialsInstanceDoesNotModifyGlobalString) { - FieldTrialsAllowedInScopeForTesting k({"SomeString"}); - std::unique_ptr f = - FieldTrials::CreateNoGlobal("SomeString/Enabled/"); - ASSERT_THAT(f, NotNull()); - f->RegisterKeysForTesting({"SomeString"}); +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); - EXPECT_TRUE(f->IsEnabled("SomeString")); - EXPECT_FALSE(webrtc::field_trial::IsEnabled("SomeString")); + f.RegisterKeysForTesting({"Audio", "Video"}); + EXPECT_EQ(f.Lookup("Video"), "Value1"); + EXPECT_EQ(f.Lookup("Audio"), "Value2"); } -TEST(FieldTrialsTest, NonGlobalFieldTrialsSupportSimultaneousInstances) { - std::unique_ptr f1 = - FieldTrials::CreateNoGlobal("SomeString/Enabled/"); - std::unique_ptr 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, 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, GlobalAndNonGlobalFieldTrialsAreDisjoint) { - FieldTrialsAllowedInScopeForTesting k({"SomeString", "SomeOtherString"}); - FieldTrials f1("SomeString/Enabled/"); - std::unique_ptr f2 = - FieldTrials::CreateNoGlobal("SomeOtherString/Enabled/"); - ASSERT_THAT(f2, NotNull()); - f1.RegisterKeysForTesting({"SomeString", "SomeOtherString"}); - f2->RegisterKeysForTesting({"SomeString", "SomeOtherString"}); +TEST(FieldTrialsTest, MergeDoesntChangeTrialAbsentInOther) { + FieldTrials f("Audio/Enabled/Video/Enabled/"); + FieldTrials other("Audio/Enabled/"); - EXPECT_TRUE(f1.IsEnabled("SomeString")); - EXPECT_FALSE(f1.IsEnabled("SomeOtherString")); + f.Merge(other); - EXPECT_FALSE(f2->IsEnabled("SomeString")); - EXPECT_TRUE(f2->IsEnabled("SomeOtherString")); + f.RegisterKeysForTesting({"Video"}); + EXPECT_EQ(f.Lookup("Video"), "Enabled"); } -TEST(FieldTrialsTest, FieldTrialBasedConfigReadsGlobalString) { - FieldTrialsAllowedInScopeForTesting k({"MyCoolTrial", "MyUncoolTrial"}); - ScopedFieldTrials g("MyCoolTrial/Enabled/MyUncoolTrial/Disabled/"); - FieldTrialBasedConfig f; - f.RegisterKeysForTesting({"MyCoolTrial", "MyUncoolTrial"}); +TEST(FieldTrialsTest, SetUpdatesTrial) { + FieldTrials f("Audio/Enabled/Video/Enabled/"); - EXPECT_TRUE(f.IsEnabled("MyCoolTrial")); - EXPECT_TRUE(f.IsDisabled("MyUncoolTrial")); + 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 diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h index 873bf6dce3..db3a8cdac3 100644 --- a/api/frame_transformer_interface.h +++ b/api/frame_transformer_interface.h @@ -51,6 +51,8 @@ class TransformableFrameInterface { virtual void SetData(ArrayView 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 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 CaptureTime() const = 0; + virtual bool CanSetCaptureTime() const { return false; } + virtual void SetCaptureTime(std::optional 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 @@ -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 AudioLevel() const = 0; + virtual bool CanSetAudioLevel() const { return false; } + virtual void SetAudioLevel(std::optional audio_level_dbov) { + RTC_DCHECK_NOTREACHED(); + } }; // Objects implement this interface to be notified with the transformed frame. diff --git a/api/neteq/BUILD.gn b/api/neteq/BUILD.gn index 9e79a877fd..3fd020b6fe 100644 --- a/api/neteq/BUILD.gn +++ b/api/neteq/BUILD.gn @@ -8,7 +8,7 @@ import("../../webrtc.gni") -rtc_source_set("neteq_api") { +rtc_library("neteq_api") { visibility = [ "*" ] sources = [ "neteq.cc", @@ -28,7 +28,7 @@ rtc_source_set("neteq_api") { ] } -rtc_source_set("default_neteq_factory") { +rtc_library("default_neteq_factory") { visibility = [ "*" ] sources = [ "default_neteq_factory.cc", @@ -44,7 +44,7 @@ rtc_source_set("default_neteq_factory") { ] } -rtc_source_set("custom_neteq_factory") { +rtc_library("custom_neteq_factory") { visibility = [ "*" ] sources = [ "custom_neteq_factory.cc", @@ -75,7 +75,7 @@ rtc_source_set("neteq_controller_api") { ] } -rtc_source_set("default_neteq_controller_factory") { +rtc_library("default_neteq_controller_factory") { visibility = [ "*" ] sources = [ "default_neteq_controller_factory.cc", @@ -89,7 +89,7 @@ rtc_source_set("default_neteq_controller_factory") { ] } -rtc_source_set("tick_timer") { +rtc_library("tick_timer") { visibility = [ "*" ] sources = [ "tick_timer.cc", @@ -98,7 +98,7 @@ rtc_source_set("tick_timer") { deps = [ "../../rtc_base:checks" ] } -rtc_source_set("tick_timer_unittest") { +rtc_library("tick_timer_unittest") { visibility = [ "*" ] testonly = true sources = [ "tick_timer_unittest.cc" ] diff --git a/api/peer_connection_interface.cc b/api/peer_connection_interface.cc index 947ecc62a6..1af738a9d9 100644 --- a/api/peer_connection_interface.cc +++ b/api/peer_connection_interface.cc @@ -45,21 +45,16 @@ PeerConnectionDependencies::PeerConnectionDependencies( PeerConnectionObserver* observer_in) : observer(observer_in) {} -// TODO(bugs.webrtc.org/12598: remove pragma once async_resolver_factory -// is removed from PeerConnectionDependencies -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" PeerConnectionDependencies::PeerConnectionDependencies( PeerConnectionDependencies&&) = default; -#pragma clang diagnostic pop PeerConnectionDependencies::~PeerConnectionDependencies() = default; PeerConnectionFactoryDependencies::PeerConnectionFactoryDependencies() = default; -// TODO: bugs.webrtc.org/369904700 - remove pragma once `audio_processing` -// is removed from PeerConnectionFactoryDependencies. +// Allow move constructor to move deprecated members. Pragma can be removed +// when there are no deprecated depedencies at the moment. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" PeerConnectionFactoryDependencies::PeerConnectionFactoryDependencies( diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h index de071d5b04..1cd3379cba 100644 --- a/api/peer_connection_interface.h +++ b/api/peer_connection_interface.h @@ -92,6 +92,7 @@ #include "api/data_channel_event_observer_interface.h" #include "api/data_channel_interface.h" #include "api/dtls_transport_interface.h" +#include "api/environment/environment.h" #include "api/fec_controller.h" #include "api/field_trials_view.h" #include "api/ice_transport_interface.h" @@ -1430,9 +1431,16 @@ struct RTC_EXPORT PeerConnectionFactoryDependencies final { Thread* worker_thread = nullptr; Thread* signaling_thread = nullptr; SocketFactory* socket_factory = nullptr; + + // Provides common widely used dependencies for webrtc subcomponents. + // `task_queue_factory` and `field_trials` members below override values in + // `env` when set. + std::optional env; + // The `packet_socket_factory` will only be used if CreatePeerConnection is // called without a `port_allocator`. std::unique_ptr packet_socket_factory; + [[deprecated("Pass custom task queue factory through the 'env'")]] std::unique_ptr task_queue_factory; std::unique_ptr event_log_factory; std::unique_ptr fec_controller_factory; @@ -1448,6 +1456,7 @@ struct RTC_EXPORT PeerConnectionFactoryDependencies final { std::unique_ptr network_monitor_factory; std::unique_ptr neteq_factory; std::unique_ptr sctp_factory; + [[deprecated("Pass custom field trials through the 'env'")]] std::unique_ptr trials; std::unique_ptr transport_controller_send_factory; @@ -1463,9 +1472,6 @@ struct RTC_EXPORT PeerConnectionFactoryDependencies final { scoped_refptr audio_encoder_factory; scoped_refptr audio_decoder_factory; scoped_refptr audio_mixer; - // TODO: bugs.webrtc.org/369904700 - Delete `audio_processing` in favor - // of `audio_processing_builder`. - [[deprecated]] scoped_refptr audio_processing; std::unique_ptr audio_processing_builder; std::unique_ptr audio_frame_processor; std::unique_ptr video_encoder_factory; diff --git a/api/priority.cc b/api/priority.cc new file mode 100644 index 0000000000..3ae4fd5c9c --- /dev/null +++ b/api/priority.cc @@ -0,0 +1,36 @@ +/* + * 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/priority.h" + +#include "rtc_base/checks.h" + +namespace webrtc { + +PriorityValue::PriorityValue(Priority priority) { + switch (priority) { + case Priority::kVeryLow: + value_ = 128; + break; + case Priority::kLow: + value_ = 256; + break; + case Priority::kMedium: + value_ = 512; + break; + case Priority::kHigh: + value_ = 1024; + break; + default: + RTC_CHECK_NOTREACHED(); + } +} + +} // namespace webrtc diff --git a/api/priority.h b/api/priority.h index 2735c2c282..bb2f88187b 100644 --- a/api/priority.h +++ b/api/priority.h @@ -13,8 +13,8 @@ #include -#include "rtc_base/checks.h" #include "rtc_base/strong_alias.h" +#include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -26,28 +26,10 @@ enum class Priority { kHigh, }; -class PriorityValue +class RTC_EXPORT PriorityValue : public webrtc::StrongAlias { public: - explicit PriorityValue(Priority priority) { - switch (priority) { - case Priority::kVeryLow: - value_ = 128; - break; - case Priority::kLow: - value_ = 256; - break; - case Priority::kMedium: - value_ = 512; - break; - case Priority::kHigh: - value_ = 1024; - break; - default: - RTC_CHECK_NOTREACHED(); - } - } - + explicit PriorityValue(Priority priority); explicit PriorityValue(uint16_t priority) : StrongAlias(priority) {} }; diff --git a/api/rtp_parameters.cc b/api/rtp_parameters.cc index bb2f500fd4..c6560d4bb0 100644 --- a/api/rtp_parameters.cc +++ b/api/rtp_parameters.cc @@ -166,35 +166,32 @@ constexpr int RtpExtension::kOneByteHeaderExtensionMaxId; constexpr int RtpExtension::kOneByteHeaderExtensionMaxValueSize; bool RtpExtension::IsSupportedForAudio(absl::string_view uri) { - return uri == webrtc::RtpExtension::kAudioLevelUri || - uri == webrtc::RtpExtension::kAbsSendTimeUri || - uri == webrtc::RtpExtension::kAbsoluteCaptureTimeUri || - uri == webrtc::RtpExtension::kTransportSequenceNumberUri || - uri == webrtc::RtpExtension::kTransportSequenceNumberV2Uri || - uri == webrtc::RtpExtension::kMidUri || - uri == webrtc::RtpExtension::kRidUri || - uri == webrtc::RtpExtension::kRepairedRidUri; + return uri == RtpExtension::kAudioLevelUri || + uri == RtpExtension::kAbsSendTimeUri || + uri == RtpExtension::kAbsoluteCaptureTimeUri || + uri == RtpExtension::kTransportSequenceNumberUri || + uri == RtpExtension::kTransportSequenceNumberV2Uri || + uri == RtpExtension::kMidUri || uri == RtpExtension::kRidUri || + uri == RtpExtension::kRepairedRidUri; } bool RtpExtension::IsSupportedForVideo(absl::string_view uri) { - return uri == webrtc::RtpExtension::kTimestampOffsetUri || - uri == webrtc::RtpExtension::kAbsSendTimeUri || - uri == webrtc::RtpExtension::kAbsoluteCaptureTimeUri || - uri == webrtc::RtpExtension::kVideoRotationUri || - uri == webrtc::RtpExtension::kTransportSequenceNumberUri || - uri == webrtc::RtpExtension::kTransportSequenceNumberV2Uri || - uri == webrtc::RtpExtension::kPlayoutDelayUri || - uri == webrtc::RtpExtension::kVideoContentTypeUri || - uri == webrtc::RtpExtension::kVideoTimingUri || - uri == webrtc::RtpExtension::kMidUri || - uri == webrtc::RtpExtension::kGenericFrameDescriptorUri00 || - uri == webrtc::RtpExtension::kDependencyDescriptorUri || - uri == webrtc::RtpExtension::kColorSpaceUri || - uri == webrtc::RtpExtension::kRidUri || - uri == webrtc::RtpExtension::kRepairedRidUri || - uri == webrtc::RtpExtension::kVideoLayersAllocationUri || - uri == webrtc::RtpExtension::kVideoFrameTrackingIdUri || - uri == webrtc::RtpExtension::kCorruptionDetectionUri; + return uri == RtpExtension::kTimestampOffsetUri || + uri == RtpExtension::kAbsSendTimeUri || + uri == RtpExtension::kAbsoluteCaptureTimeUri || + uri == RtpExtension::kVideoRotationUri || + uri == RtpExtension::kTransportSequenceNumberUri || + uri == RtpExtension::kTransportSequenceNumberV2Uri || + uri == RtpExtension::kPlayoutDelayUri || + uri == RtpExtension::kVideoContentTypeUri || + uri == RtpExtension::kVideoTimingUri || uri == RtpExtension::kMidUri || + uri == RtpExtension::kGenericFrameDescriptorUri00 || + uri == RtpExtension::kDependencyDescriptorUri || + uri == RtpExtension::kColorSpaceUri || uri == RtpExtension::kRidUri || + uri == RtpExtension::kRepairedRidUri || + uri == RtpExtension::kVideoLayersAllocationUri || + uri == RtpExtension::kVideoFrameTrackingIdUri || + uri == RtpExtension::kCorruptionDetectionUri; } bool RtpExtension::IsEncryptionSupported(absl::string_view uri) { @@ -207,7 +204,7 @@ bool RtpExtension::IsEncryptionSupported(absl::string_view uri) { // encrypted (which can't be done by Chromium). uri != webrtc::RtpExtension::kAbsSendTimeUri && #endif - uri != webrtc::RtpExtension::kEncryptHeaderExtensionsUri; + uri != RtpExtension::kEncryptHeaderExtensionsUri; } // Returns whether a header extension with the given URI exists. @@ -228,7 +225,7 @@ const RtpExtension* RtpExtension::FindHeaderExtensionByUri( const std::vector& extensions, absl::string_view uri, Filter filter) { - const webrtc::RtpExtension* fallback_extension = nullptr; + const RtpExtension* fallback_extension = nullptr; for (const auto& extension : extensions) { if (extension.uri != uri) { continue; diff --git a/api/rtp_parameters_unittest.cc b/api/rtp_parameters_unittest.cc index 0dc3cb5bd6..7d26e9d2b0 100644 --- a/api/rtp_parameters_unittest.cc +++ b/api/rtp_parameters_unittest.cc @@ -16,7 +16,6 @@ namespace webrtc { -using webrtc::RtpExtension; static const char kExtensionUri1[] = "extension-uri1"; static const char kExtensionUri2[] = "extension-uri2"; diff --git a/api/sequence_checker_unittest.cc b/api/sequence_checker_unittest.cc index 41eef3a7a7..b6e432c2d3 100644 --- a/api/sequence_checker_unittest.cc +++ b/api/sequence_checker_unittest.cc @@ -44,7 +44,7 @@ class CompileTimeTestForGuardedBy { private: int guarded_ RTC_GUARDED_BY(sequence_checker_); - ::webrtc::SequenceChecker sequence_checker_; + SequenceChecker sequence_checker_; }; void RunOnDifferentThread(FunctionView run) { diff --git a/api/task_queue/task_queue_test.cc b/api/task_queue/task_queue_test.cc index 1366a39cd8..a7c62262e3 100644 --- a/api/task_queue/task_queue_test.cc +++ b/api/task_queue/task_queue_test.cc @@ -36,20 +36,20 @@ void SleepFor(TimeDelta duration) { } std::unique_ptr CreateTaskQueue( - const std::unique_ptr& factory, + const std::unique_ptr& factory, absl::string_view task_queue_name, TaskQueueFactory::Priority priority = TaskQueueFactory::Priority::NORMAL) { return factory->CreateTaskQueue(task_queue_name, priority); } TEST_P(TaskQueueTest, Construct) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); auto queue = CreateTaskQueue(factory, "Construct"); EXPECT_FALSE(queue->IsCurrent()); } TEST_P(TaskQueueTest, PostAndCheckCurrent) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event event; auto queue = CreateTaskQueue(factory, "PostAndCheckCurrent"); @@ -67,7 +67,7 @@ TEST_P(TaskQueueTest, PostAndCheckCurrent) { } TEST_P(TaskQueueTest, PostCustomTask) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event ran; auto queue = CreateTaskQueue(factory, "PostCustomImplementation"); @@ -86,7 +86,7 @@ TEST_P(TaskQueueTest, PostCustomTask) { } TEST_P(TaskQueueTest, PostDelayedZero) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event event; auto queue = CreateTaskQueue(factory, "PostDelayedZero"); @@ -95,7 +95,7 @@ TEST_P(TaskQueueTest, PostDelayedZero) { } TEST_P(TaskQueueTest, PostFromQueue) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event event; auto queue = CreateTaskQueue(factory, "PostFromQueue"); @@ -105,7 +105,7 @@ TEST_P(TaskQueueTest, PostFromQueue) { } TEST_P(TaskQueueTest, PostDelayed) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event event; auto queue = CreateTaskQueue(factory, "PostDelayed", TaskQueueFactory::Priority::HIGH); @@ -127,7 +127,7 @@ TEST_P(TaskQueueTest, PostDelayed) { } TEST_P(TaskQueueTest, PostMultipleDelayed) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); auto queue = CreateTaskQueue(factory, "PostMultipleDelayed"); std::vector events(100); @@ -146,7 +146,7 @@ TEST_P(TaskQueueTest, PostMultipleDelayed) { } TEST_P(TaskQueueTest, PostDelayedAfterDestruct) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event run; Event deleted; auto queue = CreateTaskQueue(factory, "PostDelayedAfterDestruct"); @@ -161,7 +161,7 @@ TEST_P(TaskQueueTest, PostDelayedAfterDestruct) { } TEST_P(TaskQueueTest, PostDelayedHighPrecisionAfterDestruct) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event run; Event deleted; auto queue = @@ -178,7 +178,7 @@ TEST_P(TaskQueueTest, PostDelayedHighPrecisionAfterDestruct) { } TEST_P(TaskQueueTest, PostedUnexecutedClosureDestroyedOnTaskQueue) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); auto queue = CreateTaskQueue(factory, "PostedUnexecutedClosureDestroyedOnTaskQueue"); TaskQueueBase* queue_ptr = queue.get(); @@ -198,7 +198,7 @@ TEST_P(TaskQueueTest, PostedUnexecutedClosureDestroyedOnTaskQueue) { } TEST_P(TaskQueueTest, PostedClosureDestroyedOnTaskQueue) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); auto queue = CreateTaskQueue(factory, "PostedClosureDestroyedOnTaskQueue"); TaskQueueBase* queue_ptr = queue.get(); Event finished; @@ -215,7 +215,7 @@ TEST_P(TaskQueueTest, PostedClosureDestroyedOnTaskQueue) { } TEST_P(TaskQueueTest, PostedExecutedClosureDestroyedOnTaskQueue) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); auto queue = CreateTaskQueue(factory, "PostedExecutedClosureDestroyedOnTaskQueue"); TaskQueueBase* queue_ptr = queue.get(); @@ -229,7 +229,7 @@ TEST_P(TaskQueueTest, PostedExecutedClosureDestroyedOnTaskQueue) { } TEST_P(TaskQueueTest, PostAndReuse) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); Event event; auto post_queue = CreateTaskQueue(factory, "PostQueue"); auto reply_queue = CreateTaskQueue(factory, "ReplyQueue"); @@ -274,7 +274,7 @@ TEST_P(TaskQueueTest, PostALot) { explicit BlockingCounter(int initial_count) : count_(initial_count) {} void DecrementCount() { - if (count_.DecRef() == webrtc::RefCountReleaseStatus::kDroppedLastRef) { + if (count_.DecRef() == RefCountReleaseStatus::kDroppedLastRef) { event_.Set(); } } @@ -285,7 +285,7 @@ TEST_P(TaskQueueTest, PostALot) { Event event_; }; - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); static constexpr int kTaskCount = 0xffff; Event posting_done; BlockingCounter all_destroyed(kTaskCount); @@ -329,7 +329,7 @@ TEST_P(TaskQueueTest, PostALot) { // unit test, run it under TSan or some other tool that is able to // directly detect data races. TEST_P(TaskQueueTest, PostTwoWithSharedUnprotectedState) { - std::unique_ptr factory = GetParam()(nullptr); + std::unique_ptr factory = GetParam()(nullptr); struct SharedState { // First task will set this value to 1 and second will assert it. int state = 0; diff --git a/api/test/create_time_controller.cc b/api/test/create_time_controller.cc index 9754f70ea8..2c50599a9c 100644 --- a/api/test/create_time_controller.cc +++ b/api/test/create_time_controller.cc @@ -11,21 +11,9 @@ #include "api/test/create_time_controller.h" #include -#include -#include "absl/base/nullability.h" -#include "api/enable_media_with_defaults.h" -#include "api/environment/environment.h" -#include "api/environment/environment_factory.h" -#include "api/peer_connection_interface.h" #include "api/test/time_controller.h" #include "api/units/timestamp.h" -#include "call/call.h" -#include "call/call_config.h" -#include "media/base/media_engine.h" -#include "pc/media_factory.h" -#include "rtc_base/checks.h" -#include "system_wrappers/include/clock.h" #include "test/time_controller/simulated_time_controller.h" namespace webrtc { @@ -35,39 +23,4 @@ std::unique_ptr CreateSimulatedTimeController() { Timestamp::Seconds(10000)); } -void EnableMediaWithDefaultsAndTimeController( - TimeController& time_controller, - PeerConnectionFactoryDependencies& deps) { - class TimeControllerBasedFactory : public MediaFactory { - public: - TimeControllerBasedFactory( - Clock* absl_nonnull clock, - absl_nonnull std::unique_ptr media_factory) - : clock_(clock), media_factory_(std::move(media_factory)) {} - - std::unique_ptr CreateCall(CallConfig config) override { - EnvironmentFactory env_factory(config.env); - env_factory.Set(clock_); - - config.env = env_factory.Create(); - return media_factory_->CreateCall(std::move(config)); - } - - std::unique_ptr CreateMediaEngine( - const Environment& env, - PeerConnectionFactoryDependencies& dependencies) override { - return media_factory_->CreateMediaEngine(env, dependencies); - } - - private: - Clock* absl_nonnull clock_; - absl_nonnull std::unique_ptr media_factory_; - }; - - EnableMediaWithDefaults(deps); - RTC_CHECK(deps.media_factory); - deps.media_factory = std::make_unique( - time_controller.GetClock(), std::move(deps.media_factory)); -} - } // namespace webrtc diff --git a/api/test/create_time_controller.h b/api/test/create_time_controller.h index 7d1d9b3800..3e632593f1 100644 --- a/api/test/create_time_controller.h +++ b/api/test/create_time_controller.h @@ -12,7 +12,6 @@ #include -#include "api/peer_connection_interface.h" #include "api/test/time_controller.h" namespace webrtc { @@ -20,13 +19,6 @@ namespace webrtc { // Creates a time controller that runs in simulated time. std::unique_ptr CreateSimulatedTimeController(); -// Adjusts media `deps` to use clock `time_controller` provides, fills media -// related dependencies, and enables media support for a PeerConnectionFactory -// created from `deps`. -void EnableMediaWithDefaultsAndTimeController( - TimeController& time_controller, - PeerConnectionFactoryDependencies& deps); - } // namespace webrtc #endif // API_TEST_CREATE_TIME_CONTROLLER_H_ diff --git a/api/test/fake_frame_decryptor.cc b/api/test/fake_frame_decryptor.cc index ad635467f3..0e1da2c3f2 100644 --- a/api/test/fake_frame_decryptor.cc +++ b/api/test/fake_frame_decryptor.cc @@ -25,7 +25,7 @@ FakeFrameDecryptor::FakeFrameDecryptor(uint8_t fake_key, : fake_key_(fake_key), expected_postfix_byte_(expected_postfix_byte) {} FakeFrameDecryptor::Result FakeFrameDecryptor::Decrypt( - webrtc::MediaType /* media_type */, + MediaType /* media_type */, const std::vector& /* csrcs */, ArrayView /* additional_data */, ArrayView encrypted_frame, @@ -47,7 +47,7 @@ FakeFrameDecryptor::Result FakeFrameDecryptor::Decrypt( } size_t FakeFrameDecryptor::GetMaxPlaintextByteSize( - webrtc::MediaType /* media_type */, + MediaType /* media_type */, size_t encrypted_frame_size) { return encrypted_frame_size - 1; } diff --git a/api/test/fake_frame_encryptor.cc b/api/test/fake_frame_encryptor.cc index b988245b99..d35756e065 100644 --- a/api/test/fake_frame_encryptor.cc +++ b/api/test/fake_frame_encryptor.cc @@ -22,7 +22,7 @@ FakeFrameEncryptor::FakeFrameEncryptor(uint8_t fake_key, uint8_t postfix_byte) : fake_key_(fake_key), postfix_byte_(postfix_byte) {} // FrameEncryptorInterface implementation -int FakeFrameEncryptor::Encrypt(webrtc::MediaType /* media_type */, +int FakeFrameEncryptor::Encrypt(MediaType /* media_type */, uint32_t /* ssrc */, ArrayView /* additional_data */, ArrayView frame, @@ -42,9 +42,8 @@ int FakeFrameEncryptor::Encrypt(webrtc::MediaType /* media_type */, return static_cast(FakeEncryptionStatus::OK); } -size_t FakeFrameEncryptor::GetMaxCiphertextByteSize( - webrtc::MediaType /* media_type */, - size_t frame_size) { +size_t FakeFrameEncryptor::GetMaxCiphertextByteSize(MediaType /* media_type */, + size_t frame_size) { return frame_size + 1; } diff --git a/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc b/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc index b03185d4b0..5fe0b14c2b 100644 --- a/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc +++ b/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc @@ -75,7 +75,7 @@ ImproveDirection ToChromePerfDashboardImproveDirection( bool WriteMetricsToFile(const std::string& path, const std::string& data) { CreateDir(DirName(path)); FILE* output = fopen(path.c_str(), "wb"); - if (output == NULL) { + if (output == nullptr) { printf("Failed to write to %s.\n", path.c_str()); return false; } diff --git a/api/test/metrics/chrome_perf_dashboard_metrics_exporter_test.cc b/api/test/metrics/chrome_perf_dashboard_metrics_exporter_test.cc index ae1ab84b30..7177ed6c06 100644 --- a/api/test/metrics/chrome_perf_dashboard_metrics_exporter_test.cc +++ b/api/test/metrics/chrome_perf_dashboard_metrics_exporter_test.cc @@ -55,14 +55,11 @@ class ChromePerfDashboardMetricsExporterTest : public Test { ~ChromePerfDashboardMetricsExporterTest() override = default; void SetUp() override { - temp_filename_ = webrtc::test::TempFilename( - webrtc::test::OutputPath(), - "chrome_perf_dashboard_metrics_exporter_test"); + temp_filename_ = test::TempFilename( + test::OutputPath(), "chrome_perf_dashboard_metrics_exporter_test"); } - void TearDown() override { - ASSERT_TRUE(webrtc::test::RemoveFile(temp_filename_)); - } + void TearDown() override { ASSERT_TRUE(test::RemoveFile(temp_filename_)); } std::string temp_filename_; }; diff --git a/api/test/metrics/metrics_set_proto_file_exporter.cc b/api/test/metrics/metrics_set_proto_file_exporter.cc index 49364846e8..044828c120 100644 --- a/api/test/metrics/metrics_set_proto_file_exporter.cc +++ b/api/test/metrics/metrics_set_proto_file_exporter.cc @@ -30,42 +30,41 @@ namespace test { namespace { #if WEBRTC_ENABLE_PROTOBUF -webrtc::test_metrics::Unit ToProtoUnit(Unit unit) { +test_metrics::Unit ToProtoUnit(Unit unit) { switch (unit) { case Unit::kMilliseconds: - return webrtc::test_metrics::Unit::MILLISECONDS; + return test_metrics::Unit::MILLISECONDS; case Unit::kPercent: - return webrtc::test_metrics::Unit::PERCENT; + return test_metrics::Unit::PERCENT; case Unit::kBytes: - return webrtc::test_metrics::Unit::BYTES; + return test_metrics::Unit::BYTES; case Unit::kKilobitsPerSecond: - return webrtc::test_metrics::Unit::KILOBITS_PER_SECOND; + return test_metrics::Unit::KILOBITS_PER_SECOND; case Unit::kHertz: - return webrtc::test_metrics::Unit::HERTZ; + return test_metrics::Unit::HERTZ; case Unit::kUnitless: - return webrtc::test_metrics::Unit::UNITLESS; + return test_metrics::Unit::UNITLESS; case Unit::kCount: - return webrtc::test_metrics::Unit::COUNT; + return test_metrics::Unit::COUNT; } } -webrtc::test_metrics::ImprovementDirection ToProtoImprovementDirection( +test_metrics::ImprovementDirection ToProtoImprovementDirection( ImprovementDirection direction) { switch (direction) { case ImprovementDirection::kBiggerIsBetter: - return webrtc::test_metrics::ImprovementDirection::BIGGER_IS_BETTER; + return test_metrics::ImprovementDirection::BIGGER_IS_BETTER; case ImprovementDirection::kNeitherIsBetter: - return webrtc::test_metrics::ImprovementDirection::NEITHER_IS_BETTER; + return test_metrics::ImprovementDirection::NEITHER_IS_BETTER; case ImprovementDirection::kSmallerIsBetter: - return webrtc::test_metrics::ImprovementDirection::SMALLER_IS_BETTER; + return test_metrics::ImprovementDirection::SMALLER_IS_BETTER; } } -void SetTimeSeries( - const Metric::TimeSeries& time_series, - webrtc::test_metrics::Metric::TimeSeries* proto_time_series) { +void SetTimeSeries(const Metric::TimeSeries& time_series, + test_metrics::Metric::TimeSeries* proto_time_series) { for (const Metric::TimeSeries::Sample& sample : time_series.samples) { - webrtc::test_metrics::Metric::TimeSeries::Sample* proto_sample = + test_metrics::Metric::TimeSeries::Sample* proto_sample = proto_time_series->add_samples(); proto_sample->set_value(sample.value); proto_sample->set_timestamp_us(sample.timestamp.us()); @@ -76,7 +75,7 @@ void SetTimeSeries( } void SetStats(const Metric::Stats& stats, - webrtc::test_metrics::Metric::Stats* proto_stats) { + test_metrics::Metric::Stats* proto_stats) { if (stats.mean.has_value()) { proto_stats->set_mean(*stats.mean); } @@ -92,7 +91,7 @@ void SetStats(const Metric::Stats& stats, } bool WriteMetricsToFile(const std::string& path, - const webrtc::test_metrics::MetricsSet& metrics_set) { + const test_metrics::MetricsSet& metrics_set) { std::string data; bool ok = metrics_set.SerializeToString(&data); if (!ok) { @@ -102,7 +101,7 @@ bool WriteMetricsToFile(const std::string& path, CreateDir(DirName(path)); FILE* output = fopen(path.c_str(), "wb"); - if (output == NULL) { + if (output == nullptr) { RTC_LOG(LS_ERROR) << "Failed to write to " << path; return false; } @@ -135,12 +134,12 @@ MetricsSetProtoFileExporter::Options::Options( bool MetricsSetProtoFileExporter::Export(ArrayView metrics) { #if WEBRTC_ENABLE_PROTOBUF - webrtc::test_metrics::MetricsSet metrics_set; + test_metrics::MetricsSet metrics_set; for (const auto& [key, value] : options_.metadata) { metrics_set.mutable_metadata()->insert({key, value}); } for (const Metric& metric : metrics) { - webrtc::test_metrics::Metric* metric_proto = metrics_set.add_metrics(); + test_metrics::Metric* metric_proto = metrics_set.add_metrics(); metric_proto->set_name(metric.name); metric_proto->set_unit(ToProtoUnit(metric.unit)); metric_proto->set_improvement_direction( diff --git a/api/test/metrics/metrics_set_proto_file_exporter_test.cc b/api/test/metrics/metrics_set_proto_file_exporter_test.cc index 7eee6c3d2b..cc9ecde8d2 100644 --- a/api/test/metrics/metrics_set_proto_file_exporter_test.cc +++ b/api/test/metrics/metrics_set_proto_file_exporter_test.cc @@ -31,7 +31,7 @@ namespace { using ::testing::Eq; using ::testing::Test; -namespace proto = ::webrtc::test_metrics; +namespace proto = test_metrics; std::string ReadFileAsString(const std::string& filename) { std::ifstream infile(filename, std::ios_base::binary); @@ -66,13 +66,11 @@ class MetricsSetProtoFileExporterTest : public Test { ~MetricsSetProtoFileExporterTest() override = default; void SetUp() override { - temp_filename_ = webrtc::test::TempFilename( - webrtc::test::OutputPath(), "metrics_set_proto_file_exporter_test"); + temp_filename_ = test::TempFilename(test::OutputPath(), + "metrics_set_proto_file_exporter_test"); } - void TearDown() override { - ASSERT_TRUE(webrtc::test::RemoveFile(temp_filename_)); - } + void TearDown() override { ASSERT_TRUE(test::RemoveFile(temp_filename_)); } std::string temp_filename_; }; @@ -103,7 +101,7 @@ TEST_F(MetricsSetProtoFileExporterTest, MetricsAreExportedCorrectly) { .mean = 30.0, .stddev = 10.0, .min = 20.0, .max = 40.0}}; ASSERT_TRUE(exporter.Export(std::vector{metric1, metric2})); - webrtc::test_metrics::MetricsSet actual_metrics_set; + test_metrics::MetricsSet actual_metrics_set; actual_metrics_set.ParseFromString(ReadFileAsString(temp_filename_)); EXPECT_THAT(actual_metrics_set.metrics().size(), Eq(2)); @@ -152,7 +150,7 @@ TEST_F(MetricsSetProtoFileExporterTest, NoMetricsSetMetadata) { MetricsSetProtoFileExporter::Options options(temp_filename_); MetricsSetProtoFileExporter exporter(options); ASSERT_TRUE(exporter.Export(std::vector{})); - webrtc::test_metrics::MetricsSet actual_metrics_set; + test_metrics::MetricsSet actual_metrics_set; actual_metrics_set.ParseFromString(ReadFileAsString(temp_filename_)); EXPECT_EQ(actual_metrics_set.metadata_size(), 0); } @@ -162,7 +160,7 @@ TEST_F(MetricsSetProtoFileExporterTest, MetricsSetMetadata) { temp_filename_, {{"a_metadata_key", "a_metadata_value"}}); MetricsSetProtoFileExporter exporter(options); ASSERT_TRUE(exporter.Export(std::vector{})); - webrtc::test_metrics::MetricsSet actual_metrics_set; + test_metrics::MetricsSet actual_metrics_set; actual_metrics_set.ParseFromString(ReadFileAsString(temp_filename_)); EXPECT_EQ(actual_metrics_set.metadata_size(), 1); EXPECT_EQ(actual_metrics_set.metadata().at("a_metadata_key"), diff --git a/api/test/mock_transformable_audio_frame.h b/api/test/mock_transformable_audio_frame.h index 552d109f24..c92624a0ad 100644 --- a/api/test/mock_transformable_audio_frame.h +++ b/api/test/mock_transformable_audio_frame.h @@ -31,6 +31,8 @@ class MockTransformableAudioFrame : public TransformableAudioFrameInterface { MOCK_METHOD(void, SetData, (webrtc::ArrayView), (override)); MOCK_METHOD(void, SetRTPTimestamp, (uint32_t), (override)); MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override)); + MOCK_METHOD(bool, CanSetPayloadType, (), (const, override)); + MOCK_METHOD(void, SetPayloadType, (uint8_t), (override)); MOCK_METHOD(uint32_t, GetSsrc, (), (const, override)); MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override)); MOCK_METHOD(std::string, GetMimeType, (), (const, override)); @@ -55,9 +57,13 @@ class MockTransformableAudioFrame : public TransformableAudioFrameInterface { (), (const, override)); MOCK_METHOD(std::optional, AudioLevel, (), (const, override)); + MOCK_METHOD(bool, CanSetAudioLevel, (), (const, override)); + MOCK_METHOD(void, SetAudioLevel, (std::optional), (override)); MOCK_METHOD(std::optional, ReceiveTime, (), (const, override)); MOCK_METHOD(std::optional, CaptureTime, (), (const, override)); + MOCK_METHOD(bool, CanSetCaptureTime, (), (const, override)); + MOCK_METHOD(void, SetCaptureTime, (std::optional), (override)); MOCK_METHOD(std::optional, SenderCaptureTimeOffset, (), diff --git a/api/test/mock_transformable_frame.h b/api/test/mock_transformable_frame.h index 9a1456d6fa..e79834068d 100644 --- a/api/test/mock_transformable_frame.h +++ b/api/test/mock_transformable_frame.h @@ -32,6 +32,8 @@ class MockTransformableFrame : public TransformableFrameInterface { MOCK_METHOD(ArrayView, GetData, (), (const, override)); MOCK_METHOD(void, SetData, (webrtc::ArrayView), (override)); MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override)); + MOCK_METHOD(bool, CanSetPayloadType, (), (const, override)); + MOCK_METHOD(void, SetPayloadType, (uint8_t), (override)); MOCK_METHOD(uint32_t, GetSsrc, (), (const, override)); MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override)); MOCK_METHOD(void, SetRTPTimestamp, (uint32_t), (override)); @@ -42,6 +44,8 @@ class MockTransformableFrame : public TransformableFrameInterface { MOCK_METHOD(std::string, GetMimeType, (), (const, override)); MOCK_METHOD(std::optional, ReceiveTime, (), (const, override)); MOCK_METHOD(std::optional, CaptureTime, (), (const, override)); + MOCK_METHOD(bool, CanSetCaptureTime, (), (const, override)); + MOCK_METHOD(void, SetCaptureTime, (std::optional), (override)); MOCK_METHOD(std::optional, SenderCaptureTimeOffset, (), diff --git a/api/test/mock_transformable_video_frame.h b/api/test/mock_transformable_video_frame.h index 8b13e16e95..61207c2ee9 100644 --- a/api/test/mock_transformable_video_frame.h +++ b/api/test/mock_transformable_video_frame.h @@ -43,6 +43,8 @@ class MockTransformableVideoFrame (const webrtc::VideoFrameMetadata&), (override)); MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override)); + MOCK_METHOD(bool, CanSetPayloadType, (), (const, override)); + MOCK_METHOD(void, SetPayloadType, (uint8_t), (override)); MOCK_METHOD(TransformableFrameInterface::Direction, GetDirection, (), @@ -55,6 +57,8 @@ class MockTransformableVideoFrame (const, override)); MOCK_METHOD(std::optional, ReceiveTime, (), (const, override)); MOCK_METHOD(std::optional, CaptureTime, (), (const, override)); + MOCK_METHOD(bool, CanSetCaptureTime, (), (const, override)); + MOCK_METHOD(void, SetCaptureTime, (std::optional), (override)); MOCK_METHOD(std::optional, SenderCaptureTimeOffset, (), diff --git a/api/test/network_emulation/BUILD.gn b/api/test/network_emulation/BUILD.gn index e574cb342a..d22cc09d00 100644 --- a/api/test/network_emulation/BUILD.gn +++ b/api/test/network_emulation/BUILD.gn @@ -16,7 +16,7 @@ if (rtc_enable_protobuf) { proto_out_dir = "api/test/network_emulation/" } - rtc_source_set("schedulable_network_node_builder") { + rtc_library("schedulable_network_node_builder") { visibility = [ "*" ] sources = [ "schedulable_network_node_builder.cc", diff --git a/api/test/network_emulation/schedulable_network_node_builder.cc b/api/test/network_emulation/schedulable_network_node_builder.cc index 2b2bf39d86..f6117d9189 100644 --- a/api/test/network_emulation/schedulable_network_node_builder.cc +++ b/api/test/network_emulation/schedulable_network_node_builder.cc @@ -24,18 +24,18 @@ namespace webrtc { SchedulableNetworkNodeBuilder::SchedulableNetworkNodeBuilder( - webrtc::NetworkEmulationManager& net, + NetworkEmulationManager& net, network_behaviour::NetworkConfigSchedule schedule) : net_(net), schedule_(std::move(schedule)), - start_condition_([](webrtc::Timestamp) { return true; }) {} + start_condition_([](Timestamp) { return true; }) {} void SchedulableNetworkNodeBuilder::set_start_condition( - absl::AnyInvocable start_condition) { + absl::AnyInvocable start_condition) { start_condition_ = std::move(start_condition); } -webrtc::EmulatedNetworkNode* SchedulableNetworkNodeBuilder::Build( +EmulatedNetworkNode* SchedulableNetworkNodeBuilder::Build( std::optional random_seed) { uint64_t seed = random_seed.has_value() ? *random_seed : static_cast(TimeNanos()); diff --git a/api/test/pclf/BUILD.gn b/api/test/pclf/BUILD.gn index fd0a4a10e4..3082bdd7d3 100644 --- a/api/test/pclf/BUILD.gn +++ b/api/test/pclf/BUILD.gn @@ -8,7 +8,7 @@ import("../../../webrtc.gni") -rtc_source_set("media_configuration") { +rtc_library("media_configuration") { visibility = [ "*" ] testonly = true sources = [ @@ -81,7 +81,6 @@ rtc_library("peer_configurer") { "../..:frame_generator_api", "../..:ice_transport_interface", "../..:libjingle_peerconnection_api", - "../..:network_emulation_manager_api", "../..:peer_network_dependencies", "../..:scoped_refptr", "../../../p2p:port_allocator", @@ -96,7 +95,6 @@ rtc_library("peer_configurer") { "../../transport:bitrate_settings", "../../transport:network_control", "../../video_codecs:video_codecs_api", - "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/strings:string_view", ] } diff --git a/api/test/pclf/peer_configurer.cc b/api/test/pclf/peer_configurer.cc index 7da73512d5..9077be94bf 100644 --- a/api/test/pclf/peer_configurer.cc +++ b/api/test/pclf/peer_configurer.cc @@ -92,17 +92,17 @@ PeerConfigurer* PeerConfigurer::SetVideoDecoderFactory( return this; } PeerConfigurer* PeerConfigurer::SetAudioEncoderFactory( - scoped_refptr audio_encoder_factory) { + scoped_refptr audio_encoder_factory) { components_->pcf_dependencies->audio_encoder_factory = audio_encoder_factory; return this; } PeerConfigurer* PeerConfigurer::SetAudioDecoderFactory( - scoped_refptr audio_decoder_factory) { + scoped_refptr audio_decoder_factory) { components_->pcf_dependencies->audio_decoder_factory = audio_decoder_factory; return this; } PeerConfigurer* PeerConfigurer::SetAsyncDnsResolverFactory( - std::unique_ptr + std::unique_ptr async_dns_resolver_factory) { components_->pc_dependencies->async_dns_resolver_factory = std::move(async_dns_resolver_factory); @@ -187,7 +187,7 @@ PeerConfigurer* PeerConfigurer::SetAudioProcessing( return this; } PeerConfigurer* PeerConfigurer::SetAudioMixer( - scoped_refptr audio_mixer) { + scoped_refptr audio_mixer) { components_->pcf_dependencies->audio_mixer = audio_mixer; return this; } diff --git a/api/test/pclf/peer_configurer.h b/api/test/pclf/peer_configurer.h index 2eb525ed9d..9fab752fe7 100644 --- a/api/test/pclf/peer_configurer.h +++ b/api/test/pclf/peer_configurer.h @@ -13,11 +13,9 @@ #include #include #include -#include #include #include -#include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "api/async_dns_resolver.h" #include "api/audio/audio_mixer.h" @@ -81,12 +79,6 @@ class PeerConfigurer { PeerConfigurer* SetNetEqFactory(std::unique_ptr neteq_factory); PeerConfigurer* SetAudioProcessing( std::unique_ptr audio_processing); - ABSL_DEPRECATE_AND_INLINE() - PeerConfigurer* SetAudioProcessing( - scoped_refptr audio_processing) { - return SetAudioProcessing( - CustomAudioProcessing(std::move(audio_processing))); - } PeerConfigurer* SetAudioMixer(scoped_refptr audio_mixer); // Forces the Peerconnection to use the network thread as the worker thread. diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn index 7769526e07..11b03496be 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -62,6 +62,7 @@ rtc_library("network_control") { rtc_library("field_trial_based_config") { visibility = [ "*" ] + allow_poison = [ "environment_construction" ] sources = [ "field_trial_based_config.cc", "field_trial_based_config.h", @@ -106,7 +107,7 @@ rtc_source_set("sctp_transport_factory_interface") { deps = [ "../../api/environment" ] } -rtc_source_set("stun_types") { +rtc_library("stun_types") { visibility = [ "*" ] sources = [ "stun.cc", @@ -138,6 +139,8 @@ if (rtc_include_tests) { deps = [ ":network_control", "..:simulated_network_api", + "../../api:network_emulation_manager_api", + "../../api/rtc_event_log:rtc_event_log", "../units:data_rate", "../units:data_size", "../units:time_delta", @@ -154,13 +157,15 @@ if (rtc_include_tests) { deps = [ ":network_control", ":test_feedback_generator_interface", + "../../api:network_emulation_manager_api", + "../../api/rtc_event_log:rtc_event_log", "../../test/network:feedback_generator", ] } } if (rtc_include_tests) { - rtc_source_set("stun_unittest") { + rtc_library("stun_unittest") { visibility = [ "*" ] testonly = true sources = [ "stun_unittest.cc" ] @@ -170,7 +175,6 @@ if (rtc_include_tests) { "../../rtc_base:byte_buffer", "../../rtc_base:byte_order", "../../rtc_base:ip_address", - "../../rtc_base:macromagic", "../../rtc_base:socket_address", "../../system_wrappers:metrics", "../../test:test_support", diff --git a/api/transport/field_trial_based_config.cc b/api/transport/field_trial_based_config.cc index ea3ce21512..81abd07411 100644 --- a/api/transport/field_trial_based_config.cc +++ b/api/transport/field_trial_based_config.cc @@ -16,6 +16,6 @@ namespace webrtc { std::string FieldTrialBasedConfig::GetValue(absl::string_view key) const { - return webrtc::field_trial::FindFullName(std::string(key)); + return field_trial::FindFullName(std::string(key)); } } // namespace webrtc diff --git a/api/transport/network_types.h b/api/transport/network_types.h index d229d77bfc..79bcc12d44 100644 --- a/api/transport/network_types.h +++ b/api/transport/network_types.h @@ -154,13 +154,18 @@ struct RTC_EXPORT TransportLossReport { }; // Packet level feedback - struct RTC_EXPORT PacketResult { class ReceiveTimeOrder { public: bool operator()(const PacketResult& lhs, const PacketResult& rhs); }; + struct RtpPacketInfo { + uint32_t ssrc = 0; + uint16_t rtp_sequence_number = 0; + bool is_retransmission = false; + }; + PacketResult(); PacketResult(const PacketResult&); ~PacketResult(); @@ -170,6 +175,9 @@ struct RTC_EXPORT PacketResult { SentPacket sent_packet; Timestamp receive_time = Timestamp::PlusInfinity(); EcnMarking ecn = EcnMarking::kNotEct; + + // `rtp_packet_info` is only set if the feedback is related to a RTP packet. + std::optional rtp_packet_info; }; struct RTC_EXPORT TransportPacketsFeedback { diff --git a/api/transport/rtp/BUILD.gn b/api/transport/rtp/BUILD.gn index d4d5e4460c..9982346e12 100644 --- a/api/transport/rtp/BUILD.gn +++ b/api/transport/rtp/BUILD.gn @@ -19,7 +19,7 @@ rtc_source_set("rtp_source") { ] } -rtc_source_set("dependency_descriptor") { +rtc_library("dependency_descriptor") { visibility = [ "*" ] sources = [ "dependency_descriptor.cc", diff --git a/api/transport/stun.cc b/api/transport/stun.cc index dd7c142829..d688f0c4ff 100644 --- a/api/transport/stun.cc +++ b/api/transport/stun.cc @@ -381,7 +381,7 @@ bool StunMessage::ValidateMessageIntegrityOfType(int mi_attr_type, } // Getting the message length from the STUN header. - uint16_t msg_length = webrtc::GetBE16(&data[2]); + uint16_t msg_length = GetBE16(&data[2]); if (size != (msg_length + kStunHeaderSize)) { return false; } @@ -392,8 +392,8 @@ bool StunMessage::ValidateMessageIntegrityOfType(int mi_attr_type, while (current_pos + 4 <= size) { uint16_t attr_type, attr_length; // Getting attribute type and length. - attr_type = webrtc::GetBE16(&data[current_pos]); - attr_length = webrtc::GetBE16(&data[current_pos + sizeof(attr_type)]); + attr_type = GetBE16(&data[current_pos]); + attr_length = GetBE16(&data[current_pos + sizeof(attr_type)]); // If M-I, sanity check it, and break out. if (attr_type == mi_attr_type) { @@ -434,14 +434,12 @@ bool StunMessage::ValidateMessageIntegrityOfType(int mi_attr_type, // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // |0 0| STUN Message Type | Message Length | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - webrtc::SetBE16(temp_data.get() + 2, - static_cast(new_adjusted_len)); + SetBE16(temp_data.get() + 2, static_cast(new_adjusted_len)); } char hmac[kStunMessageIntegritySize]; - size_t ret = webrtc::ComputeHmac(webrtc::DIGEST_SHA_1, password.c_str(), - password.size(), temp_data.get(), mi_pos, - hmac, sizeof(hmac)); + size_t ret = ComputeHmac(DIGEST_SHA_1, password.c_str(), password.size(), + temp_data.get(), mi_pos, hmac, sizeof(hmac)); RTC_DCHECK(ret == sizeof(hmac)); if (ret != sizeof(hmac)) { return false; @@ -481,9 +479,8 @@ bool StunMessage::AddMessageIntegrityOfType(int attr_type, int msg_len_for_hmac = static_cast( buf.Length() - kStunAttributeHeaderSize - msg_integrity_attr->length()); char hmac[kStunMessageIntegritySize]; - size_t ret = - webrtc::ComputeHmac(webrtc::DIGEST_SHA_1, key.data(), key.size(), - buf.Data(), msg_len_for_hmac, hmac, sizeof(hmac)); + size_t ret = ComputeHmac(DIGEST_SHA_1, key.data(), key.size(), buf.Data(), + msg_len_for_hmac, hmac, sizeof(hmac)); RTC_DCHECK(ret == sizeof(hmac)); if (ret != sizeof(hmac)) { RTC_LOG(LS_ERROR) << "HMAC computation failed. Message-Integrity " @@ -511,26 +508,26 @@ bool StunMessage::ValidateFingerprint(const char* data, size_t size) { // Skip the rest if the magic cookie isn't present. const char* magic_cookie = data + kStunTransactionIdOffset - kStunMagicCookieLength; - if (webrtc::GetBE32(magic_cookie) != kStunMagicCookie) + if (GetBE32(magic_cookie) != kStunMagicCookie) return false; // Check the fingerprint type and length. const char* fingerprint_attr_data = data + size - fingerprint_attr_size; - if (webrtc::GetBE16(fingerprint_attr_data) != STUN_ATTR_FINGERPRINT || - webrtc::GetBE16(fingerprint_attr_data + sizeof(uint16_t)) != + if (GetBE16(fingerprint_attr_data) != STUN_ATTR_FINGERPRINT || + GetBE16(fingerprint_attr_data + sizeof(uint16_t)) != StunUInt32Attribute::SIZE) return false; // Check the fingerprint value. uint32_t fingerprint = - webrtc::GetBE32(fingerprint_attr_data + kStunAttributeHeaderSize); + GetBE32(fingerprint_attr_data + kStunAttributeHeaderSize); return ((fingerprint ^ STUN_FINGERPRINT_XOR_VALUE) == - webrtc::ComputeCrc32(data, size - fingerprint_attr_size)); + ComputeCrc32(data, size - fingerprint_attr_size)); } // static std::string StunMessage::GenerateTransactionId() { - return webrtc::CreateRandomString(kStunTransactionIdLength); + return CreateRandomString(kStunTransactionIdLength); } bool StunMessage::IsStunMethod(ArrayView methods, @@ -543,10 +540,10 @@ bool StunMessage::IsStunMethod(ArrayView methods, // Skip the rest if the magic cookie isn't present. const char* magic_cookie = data + kStunTransactionIdOffset - kStunMagicCookieLength; - if (webrtc::GetBE32(magic_cookie) != kStunMagicCookie) + if (GetBE32(magic_cookie) != kStunMagicCookie) return false; - int method = webrtc::GetBE16(data); + int method = GetBE16(data); for (int m : methods) { if (m == method) { return true; @@ -570,7 +567,7 @@ bool StunMessage::AddFingerprint() { int msg_len_for_crc32 = static_cast( buf.Length() - kStunAttributeHeaderSize - fingerprint_attr->length()); - uint32_t c = webrtc::ComputeCrc32(buf.Data(), msg_len_for_crc32); + uint32_t c = ComputeCrc32(buf.Data(), msg_len_for_crc32); // Insert the correct CRC-32, XORed with a constant, into the attribute. fingerprint_attr->SetValue(c ^ STUN_FINGERPRINT_XOR_VALUE); @@ -609,7 +606,7 @@ bool StunMessage::Read(ByteBufferReader* buf) { static_assert(sizeof(magic_cookie_int) == kStunMagicCookieLength, "Integer size mismatch: magic_cookie_int and kStunMagicCookie"); std::memcpy(&magic_cookie_int, magic_cookie.data(), sizeof(magic_cookie_int)); - if (webrtc::NetworkToHost32(magic_cookie_int) != kStunMagicCookie) { + if (NetworkToHost32(magic_cookie_int) != kStunMagicCookie) { // If magic cookie is invalid it means that the peer implements // RFC3489 instead of RFC5389. transaction_id.insert(0, magic_cookie); @@ -735,7 +732,7 @@ StunAttribute* StunMessage::CreateAttribute(int type, size_t length) /*const*/ { return StunAttribute::Create(STUN_VALUE_BYTE_STRING, type, static_cast(length), this); } else { - return NULL; + return nullptr; } } @@ -745,7 +742,7 @@ const StunAttribute* StunMessage::GetAttribute(int type) const { return attr.get(); } } - return NULL; + return nullptr; } bool StunMessage::IsValidTransactionId(absl::string_view transaction_id) { @@ -831,7 +828,7 @@ StunAttribute* StunAttribute::Create(StunAttributeValueType value_type, case STUN_VALUE_UINT16_LIST: return new StunUInt16ListAttribute(type, length); default: - return NULL; + return nullptr; } } @@ -957,7 +954,7 @@ bool StunAddressAttribute::Write(ByteBufferWriter* buf) const { StunXorAddressAttribute::StunXorAddressAttribute(uint16_t type, const SocketAddress& addr) - : StunAddressAttribute(type, addr), owner_(NULL) {} + : StunAddressAttribute(type, addr), owner_(nullptr) {} StunXorAddressAttribute::StunXorAddressAttribute(uint16_t type, uint16_t length, @@ -978,8 +975,7 @@ IPAddress StunXorAddressAttribute::GetXoredIP() const { switch (ip.family()) { case AF_INET: { in_addr v4addr = ip.ipv4_address(); - v4addr.s_addr = - (v4addr.s_addr ^ webrtc::HostToNetwork32(kStunMagicCookie)); + v4addr.s_addr = (v4addr.s_addr ^ HostToNetwork32(kStunMagicCookie)); return IPAddress(v4addr); } case AF_INET6: { @@ -992,8 +988,7 @@ IPAddress StunXorAddressAttribute::GetXoredIP() const { uint32_t* ip_as_ints = reinterpret_cast(&v6addr.s6_addr); // Transaction ID is in network byte order, but magic cookie // is stored in host byte order. - ip_as_ints[0] = - (ip_as_ints[0] ^ webrtc::HostToNetwork32(kStunMagicCookie)); + ip_as_ints[0] = (ip_as_ints[0] ^ HostToNetwork32(kStunMagicCookie)); ip_as_ints[1] = (ip_as_ints[1] ^ transactionid_as_ints[0]); ip_as_ints[2] = (ip_as_ints[2] ^ transactionid_as_ints[1]); ip_as_ints[3] = (ip_as_ints[3] ^ transactionid_as_ints[2]); @@ -1101,23 +1096,23 @@ bool StunUInt64Attribute::Write(ByteBufferWriter* buf) const { } StunByteStringAttribute::StunByteStringAttribute(uint16_t type) - : StunAttribute(type, 0), bytes_(NULL) {} + : StunAttribute(type, 0), bytes_(nullptr) {} StunByteStringAttribute::StunByteStringAttribute(uint16_t type, absl::string_view str) - : StunAttribute(type, 0), bytes_(NULL) { + : StunAttribute(type, 0), bytes_(nullptr) { CopyBytes(str); } StunByteStringAttribute::StunByteStringAttribute(uint16_t type, const void* bytes, size_t length) - : StunAttribute(type, 0), bytes_(NULL) { + : StunAttribute(type, 0), bytes_(nullptr) { CopyBytes(bytes, length); } StunByteStringAttribute::StunByteStringAttribute(uint16_t type, uint16_t length) - : StunAttribute(type, length), bytes_(NULL) {} + : StunAttribute(type, length), bytes_(nullptr) {} StunByteStringAttribute::~StunByteStringAttribute() { delete[] bytes_; @@ -1140,13 +1135,13 @@ void StunByteStringAttribute::CopyBytes(const void* bytes, size_t length) { } uint8_t StunByteStringAttribute::GetByte(size_t index) const { - RTC_DCHECK(bytes_ != NULL); + RTC_DCHECK(bytes_ != nullptr); RTC_DCHECK(index < length()); return bytes_[index]; } void StunByteStringAttribute::SetByte(size_t index, uint8_t value) { - RTC_DCHECK(bytes_ != NULL); + RTC_DCHECK(bytes_ != nullptr); RTC_DCHECK(index < length()); bytes_[index] = value; } @@ -1388,8 +1383,8 @@ bool ComputeStunCredentialHash(const std::string& username, input += password; char digest[MessageDigest::kMaxSize]; - size_t size = webrtc::ComputeDigest(webrtc::DIGEST_MD5, input.c_str(), - input.size(), digest, sizeof(digest)); + size_t size = ComputeDigest(DIGEST_MD5, input.c_str(), input.size(), digest, + sizeof(digest)); if (size == 0) { return false; } diff --git a/api/transport/stun_unittest.cc b/api/transport/stun_unittest.cc index 793973e037..0aeff066d4 100644 --- a/api/transport/stun_unittest.cc +++ b/api/transport/stun_unittest.cc @@ -18,7 +18,6 @@ #include #include "api/array_view.h" -#include "rtc_base/arraysize.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/byte_order.h" #include "rtc_base/ip_address.h" @@ -566,7 +565,7 @@ TEST_F(StunTest, MessageTypes) { int types[] = {STUN_BINDING_REQUEST, STUN_BINDING_INDICATION, STUN_BINDING_RESPONSE, STUN_BINDING_ERROR_RESPONSE}; - for (size_t i = 0; i < arraysize(types); ++i) { + for (size_t i = 0; i < std::size(types); ++i) { EXPECT_EQ(i == 0U, IsStunRequestType(types[i])); EXPECT_EQ(i == 1U, IsStunIndicationType(types[i])); EXPECT_EQ(i == 2U, IsStunSuccessResponseType(types[i])); @@ -652,20 +651,20 @@ TEST_F(StunTest, ReadRfc5769RequestMessage) { const StunByteStringAttribute* software = msg.GetByteString(STUN_ATTR_SOFTWARE); - ASSERT_TRUE(software != NULL); + ASSERT_TRUE(software != nullptr); EXPECT_EQ(kRfc5769SampleMsgClientSoftware, software->string_view()); const StunByteStringAttribute* username = msg.GetByteString(STUN_ATTR_USERNAME); - ASSERT_TRUE(username != NULL); + ASSERT_TRUE(username != nullptr); EXPECT_EQ(kRfc5769SampleMsgUsername, username->string_view()); // Actual M-I value checked in a later test. - ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); + ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != nullptr); // Fingerprint checked in a later test, but double-check the value here. const StunUInt32Attribute* fingerprint = msg.GetUInt32(STUN_ATTR_FINGERPRINT); - ASSERT_TRUE(fingerprint != NULL); + ASSERT_TRUE(fingerprint != nullptr); EXPECT_EQ(0xe57a3bcf, fingerprint->value()); } @@ -679,17 +678,17 @@ TEST_F(StunTest, ReadRfc5769ResponseMessage) { const StunByteStringAttribute* software = msg.GetByteString(STUN_ATTR_SOFTWARE); - ASSERT_TRUE(software != NULL); + ASSERT_TRUE(software != nullptr); EXPECT_EQ(kRfc5769SampleMsgServerSoftware, software->string_view()); const StunAddressAttribute* mapped_address = msg.GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - ASSERT_TRUE(mapped_address != NULL); + ASSERT_TRUE(mapped_address != nullptr); EXPECT_EQ(kRfc5769SampleMsgMappedAddress, mapped_address->GetAddress()); // Actual M-I and fingerprint checked in later tests. - ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); - ASSERT_TRUE(msg.GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); + ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != nullptr); + ASSERT_TRUE(msg.GetUInt32(STUN_ATTR_FINGERPRINT) != nullptr); } // Read the RFC5389 fields from the RFC5769 sample STUN response for IPv6. @@ -702,17 +701,17 @@ TEST_F(StunTest, ReadRfc5769ResponseMessageIPv6) { const StunByteStringAttribute* software = msg.GetByteString(STUN_ATTR_SOFTWARE); - ASSERT_TRUE(software != NULL); + ASSERT_TRUE(software != nullptr); EXPECT_EQ(kRfc5769SampleMsgServerSoftware, software->string_view()); const StunAddressAttribute* mapped_address = msg.GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - ASSERT_TRUE(mapped_address != NULL); + ASSERT_TRUE(mapped_address != nullptr); EXPECT_EQ(kRfc5769SampleMsgIPv6MappedAddress, mapped_address->GetAddress()); // Actual M-I and fingerprint checked in later tests. - ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); - ASSERT_TRUE(msg.GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); + ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != nullptr); + ASSERT_TRUE(msg.GetUInt32(STUN_ATTR_FINGERPRINT) != nullptr); } // Read the RFC5389 fields from the RFC5769 sample STUN response with auth. @@ -725,20 +724,20 @@ TEST_F(StunTest, ReadRfc5769RequestMessageLongTermAuth) { const StunByteStringAttribute* username = msg.GetByteString(STUN_ATTR_USERNAME); - ASSERT_TRUE(username != NULL); + ASSERT_TRUE(username != nullptr); EXPECT_EQ(kRfc5769SampleMsgWithAuthUsername, username->string_view()); const StunByteStringAttribute* nonce = msg.GetByteString(STUN_ATTR_NONCE); - ASSERT_TRUE(nonce != NULL); + ASSERT_TRUE(nonce != nullptr); EXPECT_EQ(kRfc5769SampleMsgWithAuthNonce, nonce->string_view()); const StunByteStringAttribute* realm = msg.GetByteString(STUN_ATTR_REALM); - ASSERT_TRUE(realm != NULL); + ASSERT_TRUE(realm != nullptr); EXPECT_EQ(kRfc5769SampleMsgWithAuthRealm, realm->string_view()); // No fingerprint, actual M-I checked in later tests. - ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); - ASSERT_TRUE(msg.GetUInt32(STUN_ATTR_FINGERPRINT) == NULL); + ASSERT_TRUE(msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != nullptr); + ASSERT_TRUE(msg.GetUInt32(STUN_ATTR_FINGERPRINT) == nullptr); } // The RFC3489 packet in this test is the same as @@ -778,7 +777,7 @@ TEST_F(StunTest, SetIPv6XorAddressAttributeOwner) { // Owner with a different transaction ID. StunMessage msg2(STUN_INVALID_MESSAGE_TYPE, "ABCDABCDABCD"); - StunXorAddressAttribute addr2(STUN_ATTR_XOR_MAPPED_ADDRESS, 20, NULL); + StunXorAddressAttribute addr2(STUN_ATTR_XOR_MAPPED_ADDRESS, 20, nullptr); addr2.SetIP(addr->ipaddr()); addr2.SetPort(addr->port()); addr2.SetOwner(&msg2); @@ -799,7 +798,7 @@ TEST_F(StunTest, SetIPv6XorAddressAttributeOwner) { addr2.SetIP(addr->ipaddr()); addr2.SetPort(addr->port()); // Try writing with no owner at all, should fail and write nothing. - addr2.SetOwner(NULL); + addr2.SetOwner(nullptr); ASSERT_EQ(addr2.ipaddr(), addr->ipaddr()); wrong_buf.Clear(); EXPECT_FALSE(addr2.Write(&wrong_buf)); @@ -825,7 +824,7 @@ TEST_F(StunTest, SetIPv4XorAddressAttributeOwner) { // Owner with a different transaction ID. StunMessage msg2(STUN_INVALID_MESSAGE_TYPE, "ABCDABCDABCD"); - StunXorAddressAttribute addr2(STUN_ATTR_XOR_MAPPED_ADDRESS, 20, NULL); + StunXorAddressAttribute addr2(STUN_ATTR_XOR_MAPPED_ADDRESS, 20, nullptr); addr2.SetIP(addr->ipaddr()); addr2.SetPort(addr->port()); addr2.SetOwner(&msg2); @@ -846,7 +845,7 @@ TEST_F(StunTest, SetIPv4XorAddressAttributeOwner) { ASSERT_EQ(addr->ipaddr(), addr2.ipaddr()); // However, no owner is still an error, should fail and write nothing. - addr2.SetOwner(NULL); + addr2.SetOwner(nullptr); ASSERT_EQ(addr2.ipaddr(), addr->ipaddr()); wrong_buf.Clear(); EXPECT_FALSE(addr2.Write(&wrong_buf)); @@ -1015,7 +1014,7 @@ TEST_F(StunTest, ReadByteStringAttribute) { CheckStunTransactionID(msg, kTestTransactionId2, kStunTransactionIdLength); const StunByteStringAttribute* username = msg.GetByteString(STUN_ATTR_USERNAME); - ASSERT_TRUE(username != NULL); + ASSERT_TRUE(username != nullptr); EXPECT_EQ(kTestUserName1, username->string_view()); } @@ -1028,7 +1027,7 @@ TEST_F(StunTest, ReadPaddedByteStringAttribute) { CheckStunTransactionID(msg, kTestTransactionId2, kStunTransactionIdLength); const StunByteStringAttribute* username = msg.GetByteString(STUN_ATTR_USERNAME); - ASSERT_TRUE(username != NULL); + ASSERT_TRUE(username != nullptr); EXPECT_EQ(kTestUserName2, username->string_view()); } @@ -1039,7 +1038,7 @@ TEST_F(StunTest, ReadErrorCodeAttribute) { CheckStunHeader(msg, STUN_BINDING_ERROR_RESPONSE, size); CheckStunTransactionID(msg, kTestTransactionId1, kStunTransactionIdLength); const StunErrorCodeAttribute* errorcode = msg.GetErrorCode(); - ASSERT_TRUE(errorcode != NULL); + ASSERT_TRUE(errorcode != nullptr); EXPECT_EQ(kTestErrorClass, errorcode->eclass()); EXPECT_EQ(kTestErrorNumber, errorcode->number()); EXPECT_EQ(kTestErrorReason, errorcode->reason()); @@ -1060,7 +1059,7 @@ TEST_F(StunTest, ReadMessageWithAUInt16ListAttribute) { size_t size = ReadStunMessage(&msg, kStunMessageWithUInt16ListAttribute); CheckStunHeader(msg, STUN_BINDING_REQUEST, size); const StunUInt16ListAttribute* types = msg.GetUnknownAttributes(); - ASSERT_TRUE(types != NULL); + ASSERT_TRUE(types != nullptr); EXPECT_EQ(3U, types->Size()); EXPECT_EQ(0x1U, types->GetType(0)); EXPECT_EQ(0x1000U, types->GetType(1)); @@ -1075,7 +1074,7 @@ TEST_F(StunTest, ReadMessageWithAnUnknownAttribute) { // Parsing should have succeeded and there should be a USERNAME attribute const StunByteStringAttribute* username = msg.GetByteString(STUN_ATTR_USERNAME); - ASSERT_TRUE(username != NULL); + ASSERT_TRUE(username != nullptr); EXPECT_EQ(kTestUserName2, username->string_view()); } @@ -1194,15 +1193,15 @@ TEST_F(StunTest, ValidateMessageIntegrity) { // Again, but with the lengths matching what is claimed in the headers. EXPECT_FALSE(StunMessage::ValidateMessageIntegrityForTesting( reinterpret_cast(kStunMessageWithZeroLength), - kStunHeaderSize + webrtc::GetBE16(&kStunMessageWithZeroLength[2]), + kStunHeaderSize + GetBE16(&kStunMessageWithZeroLength[2]), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrityForTesting( reinterpret_cast(kStunMessageWithExcessLength), - kStunHeaderSize + webrtc::GetBE16(&kStunMessageWithExcessLength[2]), + kStunHeaderSize + GetBE16(&kStunMessageWithExcessLength[2]), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrityForTesting( reinterpret_cast(kStunMessageWithSmallLength), - kStunHeaderSize + webrtc::GetBE16(&kStunMessageWithSmallLength[2]), + kStunHeaderSize + GetBE16(&kStunMessageWithSmallLength[2]), kRfc5769SampleMsgPassword)); // Check that a too-short HMAC doesn't cause buffer overflow. @@ -1285,15 +1284,15 @@ TEST_F(StunTest, ValidateMessageIntegrity32) { // Again, but with the lengths matching what is claimed in the headers. EXPECT_FALSE(StunMessage::ValidateMessageIntegrity32ForTesting( reinterpret_cast(kStunMessageWithZeroLength), - kStunHeaderSize + webrtc::GetBE16(&kStunMessageWithZeroLength[2]), + kStunHeaderSize + GetBE16(&kStunMessageWithZeroLength[2]), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity32ForTesting( reinterpret_cast(kStunMessageWithExcessLength), - kStunHeaderSize + webrtc::GetBE16(&kStunMessageWithExcessLength[2]), + kStunHeaderSize + GetBE16(&kStunMessageWithExcessLength[2]), kRfc5769SampleMsgPassword)); EXPECT_FALSE(StunMessage::ValidateMessageIntegrity32ForTesting( reinterpret_cast(kStunMessageWithSmallLength), - kStunHeaderSize + webrtc::GetBE16(&kStunMessageWithSmallLength[2]), + kStunHeaderSize + GetBE16(&kStunMessageWithSmallLength[2]), kRfc5769SampleMsgPassword)); // Check that a too-short HMAC doesn't cause buffer overflow. @@ -1680,7 +1679,7 @@ TEST_F(StunTest, GoogMiscInfo) { CheckStunHeader(msg, STUN_BINDING_REQUEST, read_size); const StunUInt16ListAttribute* types = msg.GetUInt16List(STUN_ATTR_GOOG_MISC_INFO); - ASSERT_TRUE(types != NULL); + ASSERT_TRUE(types != nullptr); EXPECT_EQ(4U, types->Size()); EXPECT_EQ(0x1U, types->GetType(0)); EXPECT_EQ(0x0U, types->GetType(1)); @@ -1706,24 +1705,24 @@ TEST_F(StunTest, SizeRestrictionOnAttributes) { } TEST_F(StunTest, ValidateMessageIntegrityWithParser) { - webrtc::metrics::Reset(); // Ensure counters start from zero. + metrics::Reset(); // Ensure counters start from zero. // Try the messages from RFC 5769. StunMessage message; ByteBufferReader reader(kRfc5769SampleRequest); EXPECT_TRUE(message.Read(&reader)); EXPECT_EQ(message.ValidateMessageIntegrity(kRfc5769SampleMsgPassword), StunMessage::IntegrityStatus::kIntegrityOk); - EXPECT_EQ(webrtc::metrics::NumEvents( + EXPECT_EQ(metrics::NumEvents( "WebRTC.Stun.Integrity.Request", static_cast(StunMessage::IntegrityStatus::kIntegrityOk)), 1); EXPECT_EQ(message.RevalidateMessageIntegrity("Invalid password"), StunMessage::IntegrityStatus::kIntegrityBad); - EXPECT_EQ(webrtc::metrics::NumEvents( + EXPECT_EQ(metrics::NumEvents( "WebRTC.Stun.Integrity.Request", static_cast(StunMessage::IntegrityStatus::kIntegrityBad)), 1); - EXPECT_EQ(webrtc::metrics::NumSamples("WebRTC.Stun.Integrity.Request"), 2); + EXPECT_EQ(metrics::NumSamples("WebRTC.Stun.Integrity.Request"), 2); } } // namespace webrtc diff --git a/api/transport/test/create_feedback_generator.cc b/api/transport/test/create_feedback_generator.cc index 6144bccacf..d7097e80d9 100644 --- a/api/transport/test/create_feedback_generator.cc +++ b/api/transport/test/create_feedback_generator.cc @@ -11,6 +11,7 @@ #include +#include "api/test/network_emulation_manager.h" #include "api/transport/test/feedback_generator_interface.h" #include "test/network/feedback_generator.h" @@ -21,4 +22,12 @@ std::unique_ptr CreateFeedbackGenerator( return std::make_unique(confg); } +std::unique_ptr +CreateFeedbackGeneratorWithoutNetwork( + FeedbackGeneratorWithoutNetwork::Config config, + NetworkEmulationManager& network_emulation_manager) { + return std::make_unique( + config, network_emulation_manager); +} + } // namespace webrtc diff --git a/api/transport/test/create_feedback_generator.h b/api/transport/test/create_feedback_generator.h index a1a2226496..616e8500b8 100644 --- a/api/transport/test/create_feedback_generator.h +++ b/api/transport/test/create_feedback_generator.h @@ -12,10 +12,16 @@ #include +#include "api/test/network_emulation_manager.h" #include "api/transport/test/feedback_generator_interface.h" namespace webrtc { std::unique_ptr CreateFeedbackGenerator( FeedbackGenerator::Config confg); + +std::unique_ptr +CreateFeedbackGeneratorWithoutNetwork( + FeedbackGeneratorWithoutNetwork::Config config, + NetworkEmulationManager& network_emulation_manager); } // namespace webrtc #endif // API_TRANSPORT_TEST_CREATE_FEEDBACK_GENERATOR_H_ diff --git a/api/transport/test/feedback_generator_interface.h b/api/transport/test/feedback_generator_interface.h index 1ffc8b0796..38bee44dc4 100644 --- a/api/transport/test/feedback_generator_interface.h +++ b/api/transport/test/feedback_generator_interface.h @@ -13,6 +13,8 @@ #include #include +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/test/network_emulation_manager.h" #include "api/test/simulated_network.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -32,11 +34,38 @@ class FeedbackGenerator { virtual ~FeedbackGenerator() = default; virtual Timestamp Now() = 0; virtual void Sleep(TimeDelta duration) = 0; + // Send a packet of the given size over the simulated network. virtual void SendPacket(size_t size) = 0; virtual std::vector PopFeedback() = 0; virtual void SetSendConfig(BuiltInNetworkBehaviorConfig config) = 0; virtual void SetReturnConfig(BuiltInNetworkBehaviorConfig config) = 0; virtual void SetSendLinkCapacity(DataRate capacity) = 0; + virtual RtcEventLog& event_log() = 0; }; + +// Same as FeedbackGenerator, but NetworkEmulationManager is owned externally. +// Packets can be sent and received via multiple nodes. +class FeedbackGeneratorWithoutNetwork { + public: + struct Config { + std::vector sent_via_nodes; + std::vector received_via_nodes; + TimeDelta feedback_interval = TimeDelta::Millis(50); + DataSize feedback_packet_size = DataSize::Bytes(20); + }; + + virtual ~FeedbackGeneratorWithoutNetwork() = default; + + // Send a packet of the given size over the simulated network. + // The packet size logged in the event log is `total_size` - `overhead`. + // This allows a user to ensure that LoggedPacketInfo.size + + // LoggedPacketInfo.overhead in the event log is `total_size`. + // Note that ParsedRtcEventLog estimate the overhead depending on the + // selected ice candidate. + virtual void SendPacket(size_t total_size, size_t overhead) = 0; + virtual std::vector PopFeedback() = 0; + virtual RtcEventLog& event_log() = 0; +}; + } // namespace webrtc #endif // API_TRANSPORT_TEST_FEEDBACK_GENERATOR_INTERFACE_H_ diff --git a/api/uma_metrics.h b/api/uma_metrics.h index 1525f08526..93c8c8d0ca 100644 --- a/api/uma_metrics.h +++ b/api/uma_metrics.h @@ -195,6 +195,7 @@ enum SdpMungingType { kPayloadTypes = 26, kSsrcs = 27, kIceOptionsRenomination = 28, + kDirection = 29, // RTP header extension munging. kRtpHeaderExtensionRemoved = 40, kRtpHeaderExtensionAdded = 41, @@ -221,9 +222,20 @@ enum SdpMungingType { kVideoCodecsFmtpH264SpsPpsIdrInKeyframe = 84, kVideoCodecsFmtp = 85, kVideoCodecsRtcpFb = 86, + kVideoCodecsAddedWithRawPacketization = 87, + kVideoCodecsModifiedWithRawPacketization = 88, kMaxValue, }; +// The outcome of setting the local description, whether SDP munging is detected +// and if the should be accepted or rejected. Keep in sync with +// SdpMungingOutcome from tools/metrics/histograms/metadata/web_rtc/enums.xml +enum class SdpMungingOutcome { + kAccepted = 0, + kRejected = 1, + kMaxValue = kRejected, +}; + // When adding new metrics please consider using the style described in // https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#usage // instead of the legacy enums used above. diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index 98591e6050..d0af76a6a0 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -350,7 +350,7 @@ rtc_source_set("video_stream_encoder") { ] } -rtc_source_set("video_frame_metadata") { +rtc_library("video_frame_metadata") { visibility = [ "*" ] sources = [ "video_frame_metadata.cc", diff --git a/api/video/encoded_image.cc b/api/video/encoded_image.cc index c5f1787f1a..163250a87e 100644 --- a/api/video/encoded_image.cc +++ b/api/video/encoded_image.cc @@ -77,7 +77,7 @@ void EncodedImage::SetEncodeTime(int64_t encode_start_ms, timing_.encode_finish_ms = encode_finish_ms; } -webrtc::Timestamp EncodedImage::CaptureTime() const { +Timestamp EncodedImage::CaptureTime() const { return capture_time_ms_ > 0 ? Timestamp::Millis(capture_time_ms_) : Timestamp::MinusInfinity(); } diff --git a/api/video/i010_buffer.cc b/api/video/i010_buffer.cc index e9cbe09298..59da7fb114 100644 --- a/api/video/i010_buffer.cc +++ b/api/video/i010_buffer.cc @@ -103,7 +103,7 @@ scoped_refptr I010Buffer::Copy(const I420BufferInterface& source) { // static scoped_refptr I010Buffer::Rotate(const I010BufferInterface& src, VideoRotation rotation) { - if (rotation == webrtc::kVideoRotation_0) + if (rotation == kVideoRotation_0) return Copy(src); RTC_CHECK(src.DataY()); @@ -111,13 +111,11 @@ scoped_refptr I010Buffer::Rotate(const I010BufferInterface& src, RTC_CHECK(src.DataV()); int rotated_width = src.width(); int rotated_height = src.height(); - if (rotation == webrtc::kVideoRotation_90 || - rotation == webrtc::kVideoRotation_270) { + if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) { std::swap(rotated_width, rotated_height); } - scoped_refptr buffer = - Create(rotated_width, rotated_height); + scoped_refptr buffer = Create(rotated_width, rotated_height); int res = libyuv::I010Rotate( src.DataY(), src.StrideY(), src.DataU(), src.StrideU(), src.DataV(), diff --git a/api/video/i210_buffer.cc b/api/video/i210_buffer.cc index c01214eff8..1f7919e3b4 100644 --- a/api/video/i210_buffer.cc +++ b/api/video/i210_buffer.cc @@ -110,12 +110,11 @@ scoped_refptr I210Buffer::Rotate(const I210BufferInterface& src, int rotated_width = src.width(); int rotated_height = src.height(); - if (rotation == webrtc::kVideoRotation_90 || - rotation == webrtc::kVideoRotation_270) { + if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) { std::swap(rotated_width, rotated_height); } - scoped_refptr buffer = + scoped_refptr buffer = I210Buffer::Create(rotated_width, rotated_height); RTC_CHECK_EQ(0, diff --git a/api/video/i410_buffer.cc b/api/video/i410_buffer.cc index f6fc13f25e..37564b9f3a 100644 --- a/api/video/i410_buffer.cc +++ b/api/video/i410_buffer.cc @@ -122,12 +122,11 @@ scoped_refptr I410Buffer::Rotate(const I410BufferInterface& src, int rotated_width = src.width(); int rotated_height = src.height(); - if (rotation == webrtc::kVideoRotation_90 || - rotation == webrtc::kVideoRotation_270) { + if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) { std::swap(rotated_width, rotated_height); } - scoped_refptr buffer = + scoped_refptr buffer = I410Buffer::Create(rotated_width, rotated_height); int res = libyuv::I410Rotate( diff --git a/api/video/i420_buffer.cc b/api/video/i420_buffer.cc index 39260b125a..33b2ea666e 100644 --- a/api/video/i420_buffer.cc +++ b/api/video/i420_buffer.cc @@ -120,12 +120,11 @@ scoped_refptr I420Buffer::Rotate(const I420BufferInterface& src, int rotated_width = src.width(); int rotated_height = src.height(); - if (rotation == webrtc::kVideoRotation_90 || - rotation == webrtc::kVideoRotation_270) { + if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) { std::swap(rotated_width, rotated_height); } - scoped_refptr buffer = + scoped_refptr buffer = I420Buffer::Create(rotated_width, rotated_height); RTC_CHECK_EQ(0, diff --git a/api/video/i422_buffer.cc b/api/video/i422_buffer.cc index 4322ace00c..25814a88d9 100644 --- a/api/video/i422_buffer.cc +++ b/api/video/i422_buffer.cc @@ -136,12 +136,11 @@ scoped_refptr I422Buffer::Rotate(const I422BufferInterface& src, int rotated_width = src.width(); int rotated_height = src.height(); - if (rotation == webrtc::kVideoRotation_90 || - rotation == webrtc::kVideoRotation_270) { + if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) { std::swap(rotated_width, rotated_height); } - scoped_refptr buffer = + scoped_refptr buffer = I422Buffer::Create(rotated_width, rotated_height); int res = libyuv::I422Rotate( diff --git a/api/video/i444_buffer.cc b/api/video/i444_buffer.cc index 73486622bc..ace6af1ea1 100644 --- a/api/video/i444_buffer.cc +++ b/api/video/i444_buffer.cc @@ -119,12 +119,11 @@ scoped_refptr I444Buffer::Rotate(const I444BufferInterface& src, int rotated_width = src.width(); int rotated_height = src.height(); - if (rotation == webrtc::kVideoRotation_90 || - rotation == webrtc::kVideoRotation_270) { + if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) { std::swap(rotated_width, rotated_height); } - scoped_refptr buffer = + scoped_refptr buffer = I444Buffer::Create(rotated_width, rotated_height); RTC_CHECK_EQ(0, diff --git a/api/video/rtp_video_frame_assembler.cc b/api/video/rtp_video_frame_assembler.cc index 7d79b7a5aa..e09688a438 100644 --- a/api/video/rtp_video_frame_assembler.cc +++ b/api/video/rtp_video_frame_assembler.cc @@ -239,7 +239,7 @@ RtpVideoFrameAssembler::Impl::UpdateWithPadding(uint16_t seq_num) { bool RtpVideoFrameAssembler::Impl::ParseDependenciesDescriptorExtension( const RtpPacketReceived& rtp_packet, RTPVideoHeader& video_header) { - webrtc::DependencyDescriptor dependency_descriptor; + DependencyDescriptor dependency_descriptor; if (!rtp_packet.GetExtension( video_structure_.get(), &dependency_descriptor)) { diff --git a/api/video/video_frame.cc b/api/video/video_frame.cc index 8483ed011a..8ae4e3348a 100644 --- a/api/video/video_frame.cc +++ b/api/video/video_frame.cc @@ -265,7 +265,7 @@ VideoFrame::Builder& VideoFrame::Builder::set_packet_infos( } VideoFrame::VideoFrame(const scoped_refptr& buffer, - webrtc::VideoRotation rotation, + VideoRotation rotation, int64_t timestamp_us) : video_frame_buffer_(buffer), timestamp_rtp_(0), diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn index 8351ae424b..802f8cc436 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn @@ -12,7 +12,7 @@ if (is_android) { import("//build/config/android/rules.gni") } -rtc_source_set("scalability_mode") { +rtc_library("scalability_mode") { visibility = [ "*" ] sources = [ "scalability_mode.cc", @@ -25,7 +25,7 @@ rtc_source_set("scalability_mode") { ] } -rtc_source_set("scalability_mode_helper") { +rtc_library("scalability_mode_helper") { visibility = [ "*" ] sources = [ "scalability_mode_helper.cc", @@ -86,7 +86,6 @@ rtc_library("video_codecs_api") { "../../modules/video_coding:codec_globals_headers", "../../rtc_base:checks", "../../rtc_base:logging", - "../../rtc_base:macromagic", "../../rtc_base:refcount", "../../rtc_base:stringutils", "../../rtc_base/system:rtc_export", diff --git a/api/video_codecs/h264_profile_level_id.cc b/api/video_codecs/h264_profile_level_id.cc index 0bdaed7fd3..4dafda078f 100644 --- a/api/video_codecs/h264_profile_level_id.cc +++ b/api/video_codecs/h264_profile_level_id.cc @@ -18,7 +18,6 @@ #include #include "api/rtp_parameters.h" -#include "rtc_base/arraysize.h" namespace webrtc { @@ -166,7 +165,7 @@ std::optional H264SupportedLevel(int max_frame_pixel_count, float max_fps) { static const int kPixelsPerMacroblock = 16 * 16; - for (int i = arraysize(kLevelConstraints) - 1; i >= 0; --i) { + for (int i = std::ssize(kLevelConstraints) - 1; i >= 0; --i) { const LevelConstraint& level_constraint = kLevelConstraints[i]; if (level_constraint.max_macroblock_frame_size * kPixelsPerMacroblock <= max_frame_pixel_count && diff --git a/api/video_codecs/h265_profile_tier_level.cc b/api/video_codecs/h265_profile_tier_level.cc index f63321a293..306effa96a 100644 --- a/api/video_codecs/h265_profile_tier_level.cc +++ b/api/video_codecs/h265_profile_tier_level.cc @@ -15,7 +15,6 @@ #include "api/rtp_parameters.h" #include "api/video/resolution.h" -#include "rtc_base/arraysize.h" #include "rtc_base/string_to_number.h" namespace webrtc { @@ -310,7 +309,7 @@ std::optional GetSupportedH265Level(const Resolution& resolution, int aligned_height = (resolution.height + kMinCbSizeYMax - 1) & ~(kMinCbSizeYMax - 1); - for (int i = arraysize(kLevelConstraints) - 1; i >= 0; --i) { + for (int i = std::ssize(kLevelConstraints) - 1; i >= 0; --i) { const LevelConstraint& level_constraint = kLevelConstraints[i]; if (level_constraint.max_luma_picture_size <= aligned_width * aligned_height && diff --git a/api/video_codecs/libaom_av1_encoder_factory.cc b/api/video_codecs/libaom_av1_encoder_factory.cc index 7652aae250..f82538f5c8 100644 --- a/api/video_codecs/libaom_av1_encoder_factory.cc +++ b/api/video_codecs/libaom_av1_encoder_factory.cc @@ -105,7 +105,7 @@ class LibaomAv1Encoder : public VideoEncoderInterface { const VideoEncoderFactoryInterface::StaticEncoderSettings& settings, const std::map& encoder_specific_settings); - void Encode(scoped_refptr frame_buffer, + void Encode(scoped_refptr frame_buffer, const TemporalUnitSettings& tu_settings, std::vector frame_settings) override; @@ -269,7 +269,7 @@ ThreadTilesAndSuperblockSizeInfo GetThreadingTilesAndSuperblockSize( } bool ValidateEncodeParams( - const webrtc::VideoFrameBuffer& /* frame_buffer */, + const VideoFrameBuffer& /* frame_buffer */, const VideoEncoderInterface::TemporalUnitSettings& /* tu_settings */, const std::vector& frame_settings, @@ -537,7 +537,7 @@ aom_svc_ref_frame_config_t GetSvcRefFrameConfig( } aom_svc_params_t GetSvcParams( - const webrtc::VideoFrameBuffer& frame_buffer, + const VideoFrameBuffer& frame_buffer, const std::vector& frame_settings) { aom_svc_params_t svc_params = {}; @@ -634,10 +634,9 @@ aom_svc_params_t GetSvcParams( return svc_params; } -void LibaomAv1Encoder::Encode( - scoped_refptr frame_buffer, - const TemporalUnitSettings& tu_settings, - std::vector frame_settings) { +void LibaomAv1Encoder::Encode(scoped_refptr frame_buffer, + const TemporalUnitSettings& tu_settings, + std::vector frame_settings) { absl::Cleanup on_return = [&] { // On return call `EncodeComplete` with EncodingError result unless they // were already called with an EncodedData result. diff --git a/api/video_codecs/sdp_video_format.cc b/api/video_codecs/sdp_video_format.cc index 5c2c5dac3c..6d70ae3850 100644 --- a/api/video_codecs/sdp_video_format.cc +++ b/api/video_codecs/sdp_video_format.cc @@ -191,7 +191,7 @@ bool SdpVideoFormat::IsSameCodec(const SdpVideoFormat& other) const { } bool SdpVideoFormat::IsCodecInList( - ArrayView formats) const { + ArrayView formats) const { for (const auto& format : formats) { if (IsSameCodec(format)) { return true; diff --git a/api/video_codecs/simple_encoder_wrapper.cc b/api/video_codecs/simple_encoder_wrapper.cc index cf0fd80f8e..7ecec6d134 100644 --- a/api/video_codecs/simple_encoder_wrapper.cc +++ b/api/video_codecs/simple_encoder_wrapper.cc @@ -152,10 +152,9 @@ void SimpleEncoderWrapper::SetEncodeFps(int fps) { fps_ = fps; } -void SimpleEncoderWrapper::Encode( - scoped_refptr frame_buffer, - bool force_keyframe, - EncodeResultCallback callback) { +void SimpleEncoderWrapper::Encode(scoped_refptr frame_buffer, + bool force_keyframe, + EncodeResultCallback callback) { std::vector configs = svc_controller_->NextFrameConfig(force_keyframe); std::vector encode_settings; diff --git a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc index d452884c11..5ff941f273 100644 --- a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc +++ b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc @@ -184,12 +184,12 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, ForwardsRegisterDecodeCompleteCallback) { class FakeDecodedImageCallback : public DecodedImageCallback { int32_t Decoded(VideoFrame& /* decodedImage */) override { return 0; } - int32_t Decoded(webrtc::VideoFrame& /* decodedImage */, + int32_t Decoded(VideoFrame& /* decodedImage */, int64_t /* decode_time_ms */) override { RTC_DCHECK_NOTREACHED(); return -1; } - void Decoded(webrtc::VideoFrame& /* decodedImage */, + void Decoded(VideoFrame& /* decodedImage */, std::optional /* decode_time_ms */, std::optional /* qp */) override { RTC_DCHECK_NOTREACHED(); diff --git a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc index 94e31ecf8b..903e7fe1d4 100644 --- a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc +++ b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc @@ -219,12 +219,11 @@ void VideoEncoderSoftwareFallbackWrapperTestBase::EncodeFrame( I420Buffer::SetBlack(buffer.get()); std::vector types(1, VideoFrameType::kVideoFrameKey); - frame_ = - std::make_unique(VideoFrame::Builder() - .set_video_frame_buffer(buffer) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(0) - .build()); + frame_ = std::make_unique(VideoFrame::Builder() + .set_video_frame_buffer(buffer) + .set_rotation(kVideoRotation_0) + .set_timestamp_us(0) + .build()); EXPECT_EQ(expected_ret, fallback_wrapper_->Encode(*frame_, &types)); } diff --git a/api/video_codecs/video_encoder_software_fallback_wrapper.cc b/api/video_codecs/video_encoder_software_fallback_wrapper.cc index 1ef2c609df..e1b7910b16 100644 --- a/api/video_codecs/video_encoder_software_fallback_wrapper.cc +++ b/api/video_codecs/video_encoder_software_fallback_wrapper.cc @@ -144,11 +144,10 @@ std::optional GetForcedFallbackParams( class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder { public: - VideoEncoderSoftwareFallbackWrapper( - const FieldTrialsView& field_trials, - std::unique_ptr sw_encoder, - std::unique_ptr hw_encoder, - bool prefer_temporal_support); + VideoEncoderSoftwareFallbackWrapper(const FieldTrialsView& field_trials, + std::unique_ptr sw_encoder, + std::unique_ptr hw_encoder, + bool prefer_temporal_support); ~VideoEncoderSoftwareFallbackWrapper() override; void SetFecControllerOverride( @@ -221,8 +220,8 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder { }; EncoderState encoder_state_; - const std::unique_ptr encoder_; - const std::unique_ptr fallback_encoder_; + const std::unique_ptr encoder_; + const std::unique_ptr fallback_encoder_; EncodedImageCallback* callback_; @@ -233,8 +232,8 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder { VideoEncoderSoftwareFallbackWrapper::VideoEncoderSoftwareFallbackWrapper( const FieldTrialsView& field_trials, - std::unique_ptr sw_encoder, - std::unique_ptr hw_encoder, + std::unique_ptr sw_encoder, + std::unique_ptr hw_encoder, bool prefer_temporal_support) : encoder_state_(EncoderState::kUninitialized), encoder_(std::move(hw_encoder)), diff --git a/audio/BUILD.gn b/audio/BUILD.gn index 702a8d839d..0492dd24e5 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -260,19 +260,31 @@ if (rtc_include_tests) { sources = [ "channel_receive_unittest.cc" ] deps = [ ":audio", + "../api:array_view", + "../api:make_ref_counted", "../api:mock_frame_transformer", + "../api:scoped_refptr", + "../api:transport_api", "../api/audio:audio_device", + "../api/audio:audio_frame_api", + "../api/audio_codecs:audio_codecs_api", "../api/audio_codecs:builtin_audio_decoder_factory", "../api/crypto:frame_decryptor_interface", + "../api/crypto:options", "../api/environment:environment_factory", "../api/task_queue:default_task_queue_factory", + "../api/units:time_delta", + "../api/units:timestamp", "../logging:mocks", "../modules/audio_device:mock_audio_device", "../modules/rtp_rtcp", "../modules/rtp_rtcp:ntp_time_util", "../modules/rtp_rtcp:rtp_rtcp_format", "../rtc_base:logging", + "../rtc_base:stringutils", "../rtc_base:threading", + "../rtc_base:timeutils", + "../system_wrappers", "../test:audio_codec_mocks", "../test:mock_transport", "../test:test_support", diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 344c4b4428..1c4d634729 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -77,9 +77,9 @@ std::string AudioReceiveStreamInterface::Config::ToString() const { namespace { std::unique_ptr CreateChannelReceive( const Environment& env, - webrtc::AudioState* audio_state, + AudioState* audio_state, NetEqFactory* neteq_factory, - const webrtc::AudioReceiveStreamInterface::Config& config) { + const AudioReceiveStreamInterface::Config& config) { RTC_DCHECK(audio_state); internal::AudioState* internal_audio_state = static_cast(audio_state); @@ -98,8 +98,8 @@ AudioReceiveStreamImpl::AudioReceiveStreamImpl( const Environment& env, PacketRouter* packet_router, NetEqFactory* neteq_factory, - const webrtc::AudioReceiveStreamInterface::Config& config, - const scoped_refptr& audio_state) + const AudioReceiveStreamInterface::Config& config, + const scoped_refptr& audio_state) : AudioReceiveStreamImpl( env, packet_router, @@ -111,8 +111,8 @@ AudioReceiveStreamImpl::AudioReceiveStreamImpl( AudioReceiveStreamImpl::AudioReceiveStreamImpl( const Environment& /* env */, PacketRouter* packet_router, - const webrtc::AudioReceiveStreamInterface::Config& config, - const scoped_refptr& audio_state, + const AudioReceiveStreamInterface::Config& config, + const scoped_refptr& audio_state, std::unique_ptr channel_receive) : config_(config), audio_state_(audio_state), @@ -159,7 +159,7 @@ void AudioReceiveStreamImpl::UnregisterFromTransport() { } void AudioReceiveStreamImpl::ReconfigureForTesting( - const webrtc::AudioReceiveStreamInterface::Config& config) { + const AudioReceiveStreamInterface::Config& config) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); // SSRC can't be changed mid-stream. @@ -212,7 +212,7 @@ bool AudioReceiveStreamImpl::IsRunning() const { } void AudioReceiveStreamImpl::SetDepacketizerToDecoderFrameTransformer( - scoped_refptr frame_transformer) { + scoped_refptr frame_transformer) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); channel_receive_->SetDepacketizerToDecoderFrameTransformer( std::move(frame_transformer)); @@ -238,7 +238,7 @@ void AudioReceiveStreamImpl::SetNackHistory(int history_ms) { channel_receive_->SetNACKStatus(history_ms != 0, history_ms / 20); } -void AudioReceiveStreamImpl::SetRtcpMode(webrtc::RtcpMode mode) { +void AudioReceiveStreamImpl::SetRtcpMode(RtcpMode mode) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); if (config_.rtp.rtcp_mode == mode) @@ -255,17 +255,17 @@ void AudioReceiveStreamImpl::SetNonSenderRttMeasurement(bool enabled) { } void AudioReceiveStreamImpl::SetFrameDecryptor( - scoped_refptr frame_decryptor) { + scoped_refptr frame_decryptor) { // TODO(bugs.webrtc.org/11993): This is called via WebRtcAudioReceiveStream, // expect to be called on the network thread. RTC_DCHECK_RUN_ON(&worker_thread_checker_); channel_receive_->SetFrameDecryptor(std::move(frame_decryptor)); } -webrtc::AudioReceiveStreamInterface::Stats AudioReceiveStreamImpl::GetStats( +AudioReceiveStreamInterface::Stats AudioReceiveStreamImpl::GetStats( bool get_and_clear_legacy_stats) const { RTC_DCHECK_RUN_ON(&worker_thread_checker_); - webrtc::AudioReceiveStreamInterface::Stats stats; + AudioReceiveStreamInterface::Stats stats; stats.remote_ssrc = remote_ssrc(); auto receive_codec = channel_receive_->GetReceiveCodec(); @@ -274,8 +274,7 @@ webrtc::AudioReceiveStreamInterface::Stats AudioReceiveStreamImpl::GetStats( stats.codec_payload_type = receive_codec->first; } - webrtc::CallReceiveStatistics call_stats = - channel_receive_->GetRTCPStatistics(); + CallReceiveStatistics call_stats = channel_receive_->GetRTCPStatistics(); stats.payload_bytes_received = call_stats.payload_bytes_received; stats.header_and_padding_bytes_received = call_stats.header_and_padding_bytes_received; diff --git a/audio/audio_state_unittest.cc b/audio/audio_state_unittest.cc index 0c278d770c..c886a13b86 100644 --- a/audio/audio_state_unittest.cc +++ b/audio/audio_state_unittest.cc @@ -11,6 +11,7 @@ #include "audio/audio_state.h" #include +#include #include #include @@ -57,7 +58,7 @@ struct FakeAsyncAudioProcessingHelper { std::unique_ptr CreateTaskQueue( absl::string_view /* name */, Priority /* priority */) const override { - return std::unique_ptr( + return std::unique_ptr( new FakeTaskQueue()); } }; @@ -150,7 +151,7 @@ std::vector Create10msTestData(int sample_rate_hz, const int samples_per_channel = sample_rate_hz / 100; std::vector audio_data(samples_per_channel * num_channels, 0); // Fill the first channel with a 1kHz sine wave. - const float inc = (2 * 3.14159265f * 1000) / sample_rate_hz; + const float inc = (2 * std::numbers::pi_v * 1000) / sample_rate_hz; float w = 0.f; for (int i = 0; i < samples_per_channel; ++i) { audio_data[i * num_channels] = static_cast(32767.f * std::sin(w)); diff --git a/audio/audio_transport_impl.cc b/audio/audio_transport_impl.cc index ef8d3baf8d..cd83fd9e3b 100644 --- a/audio/audio_transport_impl.cc +++ b/audio/audio_transport_impl.cc @@ -11,15 +11,24 @@ #include "audio/audio_transport_impl.h" #include +#include +#include #include +#include #include +#include +#include "api/audio/audio_frame.h" +#include "api/audio/audio_mixer.h" +#include "api/audio/audio_view.h" #include "audio/remix_resample.h" #include "audio/utility/audio_frame_operations.h" #include "call/audio_sender.h" +#include "common_audio/resampler/include/push_resampler.h" #include "modules/async_audio_processing/async_audio_processing.h" #include "modules/audio_processing/include/audio_frame_proxies.h" #include "rtc_base/checks.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/trace_event.h" namespace webrtc { @@ -67,10 +76,10 @@ void ProcessCaptureFrame(uint32_t delay_ms, // Resample audio in `frame` to given sample rate preserving the // channel count and place the result in `destination`. -int Resample(const AudioFrame& frame, - const int destination_sample_rate, - PushResampler* resampler, - InterleavedView destination) { +void Resample(const AudioFrame& frame, + const int destination_sample_rate, + PushResampler* resampler, + InterleavedView destination) { TRACE_EVENT2("webrtc", "Resample", "frame sample rate", frame.sample_rate_hz_, "destination_sample_rate", destination_sample_rate); const size_t target_number_of_samples_per_channel = @@ -82,7 +91,7 @@ int Resample(const AudioFrame& frame, frame.num_channels_ * target_number_of_samples_per_channel); // TODO(yujo): Add special case handling of muted frames. - return resampler->Resample(frame.data_view(), destination); + resampler->Resample(frame.data_view(), destination); } } // namespace @@ -233,11 +242,10 @@ int32_t AudioTransportImpl::NeedMorePlayData(const size_t nSamples, RTC_DCHECK_EQ(error, AudioProcessing::kNoError); } - nSamplesOut = - Resample(mixed_frame_, samplesPerSec, &render_resampler_, - InterleavedView(static_cast(audioSamples), - nSamples, nChannels)); - RTC_DCHECK_EQ(nSamplesOut, nChannels * nSamples); + InterleavedView resampled(static_cast(audioSamples), + nSamples, nChannels); + Resample(mixed_frame_, samplesPerSec, &render_resampler_, resampled); + nSamplesOut = resampled.size(); return 0; } @@ -266,11 +274,9 @@ void AudioTransportImpl::PullRenderData(int bits_per_sample, *elapsed_time_ms = mixed_frame_.elapsed_time_ms_; *ntp_time_ms = mixed_frame_.ntp_time_ms_; - int output_samples = - Resample(mixed_frame_, sample_rate, &render_resampler_, - InterleavedView(static_cast(audio_data), - number_of_frames, number_of_channels)); - RTC_DCHECK_EQ(output_samples, number_of_channels * number_of_frames); + Resample(mixed_frame_, sample_rate, &render_resampler_, + InterleavedView(static_cast(audio_data), + number_of_frames, number_of_channels)); } void AudioTransportImpl::UpdateAudioSenders(std::vector senders, diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index cfbf843032..832f86aaab 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -132,7 +132,7 @@ class ChannelReceive : public ChannelReceiveInterface, scoped_refptr decoder_factory, std::optional codec_pair_id, scoped_refptr frame_decryptor, - const webrtc::CryptoOptions& crypto_options, + const CryptoOptions& crypto_options, scoped_refptr frame_transformer); ~ChannelReceive() override; @@ -190,7 +190,7 @@ class ChannelReceive : public ChannelReceiveInterface, CallReceiveStatistics GetRTCPStatistics() const override; void SetNACKStatus(bool enable, int max_packets) override; - void SetRtcpMode(webrtc::RtcpMode mode) override; + void SetRtcpMode(RtcpMode mode) override; void SetNonSenderRttMeasurement(bool enabled) override; AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( @@ -204,11 +204,10 @@ class ChannelReceive : public ChannelReceiveInterface, // Sets a frame transformer between the depacketizer and the decoder, to // transform the received frames before decoding them. void SetDepacketizerToDecoderFrameTransformer( - scoped_refptr frame_transformer) - override; + scoped_refptr frame_transformer) override; void SetFrameDecryptor( - scoped_refptr frame_decryptor) override; + scoped_refptr frame_decryptor) override; void OnLocalSsrcChange(uint32_t local_ssrc) override; @@ -233,7 +232,7 @@ class ChannelReceive : public ChannelReceiveInterface, RTC_RUN_ON(worker_thread_checker_); void InitFrameTransformerDelegate( - scoped_refptr frame_transformer) + scoped_refptr frame_transformer) RTC_RUN_ON(worker_thread_checker_); // Thread checkers document and lock usage of some methods to specific threads @@ -293,7 +292,7 @@ class ChannelReceive : public ChannelReceiveInterface, mutable Mutex ts_stats_lock_; - webrtc::RtpTimestampUnwrapper rtp_ts_wraparound_handler_; + RtpTimestampUnwrapper rtp_ts_wraparound_handler_; // The rtp timestamp of the first played out audio frame. int64_t capture_start_rtp_time_stamp_; // The capture ntp time (in local timebase) of the first played out audio @@ -310,12 +309,12 @@ class ChannelReceive : public ChannelReceiveInterface, // E2EE Audio Frame Decryption scoped_refptr frame_decryptor_ RTC_GUARDED_BY(worker_thread_checker_); - webrtc::CryptoOptions crypto_options_; + CryptoOptions crypto_options_; - webrtc::AbsoluteCaptureTimeInterpolator absolute_capture_time_interpolator_ + AbsoluteCaptureTimeInterpolator absolute_capture_time_interpolator_ RTC_GUARDED_BY(worker_thread_checker_); - webrtc::CaptureClockOffsetUpdater capture_clock_offset_updater_ + CaptureClockOffsetUpdater capture_clock_offset_updater_ RTC_GUARDED_BY(ts_stats_lock_); scoped_refptr @@ -381,7 +380,7 @@ void ChannelReceive::OnReceivedPayloadData(ArrayView payload, } void ChannelReceive::InitFrameTransformerDelegate( - scoped_refptr frame_transformer) { + scoped_refptr frame_transformer) { RTC_DCHECK(frame_transformer); RTC_DCHECK(!frame_transformer_delegate_); RTC_DCHECK(worker_thread_->IsCurrent()); @@ -565,7 +564,7 @@ ChannelReceive::ChannelReceive( scoped_refptr decoder_factory, std::optional codec_pair_id, scoped_refptr frame_decryptor, - const webrtc::CryptoOptions& crypto_options, + const CryptoOptions& crypto_options, scoped_refptr frame_transformer) : env_(env), worker_thread_(TaskQueueBase::Current()), @@ -713,14 +712,14 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet, Buffer decrypted_audio_payload; if (frame_decryptor_ != nullptr) { const size_t max_plaintext_size = frame_decryptor_->GetMaxPlaintextByteSize( - webrtc::MediaType::AUDIO, payload_length); + MediaType::AUDIO, payload_length); decrypted_audio_payload.SetSize(max_plaintext_size); const std::vector csrcs(header.arrOfCSRCs, header.arrOfCSRCs + header.numCSRCs); const FrameDecryptorInterface::Result decrypt_result = frame_decryptor_->Decrypt( - webrtc::MediaType::AUDIO, csrcs, + MediaType::AUDIO, csrcs, /*additional_data=*/ nullptr, ArrayView(payload, payload_data_length), decrypted_audio_payload); @@ -747,7 +746,7 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet, char buf[1024]; SimpleStringBuilder mime_type(buf); auto it = payload_type_map_.find(header.payloadType); - mime_type << webrtc::MediaTypeToString(webrtc::MediaType::AUDIO) << "/" + mime_type << MediaTypeToString(MediaType::AUDIO) << "/" << (it != payload_type_map_.end() ? it->second.name : "x-unknown"); frame_transformer_delegate_->Transform(payload_data, header, remote_ssrc_, @@ -906,7 +905,7 @@ void ChannelReceive::SetNACKStatus(bool enable, int max_packets) { } } -void ChannelReceive::SetRtcpMode(webrtc::RtcpMode mode) { +void ChannelReceive::SetRtcpMode(RtcpMode mode) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); rtp_rtcp_->SetRTCPStatus(mode); } @@ -933,7 +932,7 @@ void ChannelReceive::RtcpPacketTypesCounterUpdated( } void ChannelReceive::SetDepacketizerToDecoderFrameTransformer( - scoped_refptr frame_transformer) { + scoped_refptr frame_transformer) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); if (!frame_transformer) { RTC_DCHECK_NOTREACHED() << "Not setting the transformer?"; @@ -953,7 +952,7 @@ void ChannelReceive::SetDepacketizerToDecoderFrameTransformer( } void ChannelReceive::SetFrameDecryptor( - scoped_refptr frame_decryptor) { + scoped_refptr frame_decryptor) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); frame_decryptor_ = std::move(frame_decryptor); } @@ -1189,7 +1188,7 @@ std::unique_ptr CreateChannelReceive( scoped_refptr decoder_factory, std::optional codec_pair_id, scoped_refptr frame_decryptor, - const webrtc::CryptoOptions& crypto_options, + const CryptoOptions& crypto_options, scoped_refptr frame_transformer) { return std::make_unique( env, neteq_factory, audio_device_module, rtcp_send_transport, local_ssrc, diff --git a/audio/channel_receive.h b/audio/channel_receive.h index ee72187b7d..6179c4f8f0 100644 --- a/audio/channel_receive.h +++ b/audio/channel_receive.h @@ -27,6 +27,7 @@ #include "api/call/audio_sink.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" +#include "api/crypto/frame_decryptor_interface.h" #include "api/environment/environment.h" #include "api/frame_transformer_interface.h" #include "api/neteq/neteq_factory.h" @@ -42,7 +43,6 @@ namespace webrtc { class AudioDeviceModule; -class FrameDecryptorInterface; class PacketRouter; class RateLimiter; class ReceiveStatistics; diff --git a/audio/channel_receive_frame_transformer_delegate.cc b/audio/channel_receive_frame_transformer_delegate.cc index 42f40b764a..7995548043 100644 --- a/audio/channel_receive_frame_transformer_delegate.cc +++ b/audio/channel_receive_frame_transformer_delegate.cc @@ -10,6 +10,7 @@ #include "audio/channel_receive_frame_transformer_delegate.h" +#include #include #include #include @@ -92,6 +93,17 @@ class TransformableIncomingAudioFrame return std::nullopt; } + bool CanSetAudioLevel() const override { return true; } + + void SetAudioLevel(std::optional audio_level_dbov) override { + header_.extension.set_audio_level( + audio_level_dbov.has_value() + ? std::make_optional(webrtc::AudioLevel( + /*voice_activity=*/true, + std::min(*audio_level_dbov, static_cast(127u)))) + : std::nullopt); + } + std::optional ReceiveTime() const override { return receive_time_ == Timestamp::MinusInfinity() ? std::nullopt @@ -100,7 +112,7 @@ class TransformableIncomingAudioFrame std::optional CaptureTime() const override { if (header_.extension.absolute_capture_time) { - return Timestamp::Micros(UQ32x32ToInt64Us( + return Timestamp::Millis(UQ32x32ToInt64Ms( header_.extension.absolute_capture_time->absolute_capture_timestamp)); } return std::nullopt; @@ -110,8 +122,8 @@ class TransformableIncomingAudioFrame if (header_.extension.absolute_capture_time && header_.extension.absolute_capture_time ->estimated_capture_clock_offset) { - return TimeDelta::Micros( - Q32x32ToInt64Us(*header_.extension.absolute_capture_time + return TimeDelta::Millis( + Q32x32ToInt64Ms(*header_.extension.absolute_capture_time ->estimated_capture_clock_offset)); } return std::nullopt; @@ -200,6 +212,12 @@ void ChannelReceiveFrameTransformerDelegate::ReceiveFrame( header.extension.absolute_capture_time->absolute_capture_timestamp = transformed_frame->AbsoluteCaptureTimestamp().value(); } + if (transformed_frame->AudioLevel().has_value()) { + // TODO(crbug.com/webrtc/419746427): Add support for voice activity in + // TransformableAudioFrameInterface. + header.extension.set_audio_level(AudioLevel( + /*voice_activity=*/true, *transformed_frame->AudioLevel())); + } } else { auto* transformed_incoming_frame = static_cast(frame.get()); diff --git a/audio/channel_receive_frame_transformer_delegate_unittest.cc b/audio/channel_receive_frame_transformer_delegate_unittest.cc index 95bfd50b13..5e8d35fc5d 100644 --- a/audio/channel_receive_frame_transformer_delegate_unittest.cc +++ b/audio/channel_receive_frame_transformer_delegate_unittest.cc @@ -34,6 +34,7 @@ namespace { using ::testing::_; using ::testing::ElementsAre; using ::testing::NiceMock; +using ::testing::Return; using ::testing::SaveArg; constexpr Timestamp kFakeReceiveTimestamp = Timestamp::Millis(1234567); @@ -42,7 +43,7 @@ class MockChannelReceive { public: MOCK_METHOD(void, ReceiveFrame, - (webrtc::ArrayView packet, + (ArrayView packet, const RTPHeader& header, Timestamp receive_time)); @@ -308,5 +309,65 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, } } +TEST(ChannelReceiveFrameTransformerDelegateTest, SetAudioLevel) { + AutoThread main_thread; + scoped_refptr mock_frame_transformer = + make_ref_counted>(); + scoped_refptr delegate = + make_ref_counted( + /*receive_frame_callback=*/nullptr, mock_frame_transformer, + Thread::Current()); + delegate->Init(); + const uint8_t data[] = {1, 2, 3, 4}; + ArrayView packet(data, sizeof(data)); + std::unique_ptr frame; + ON_CALL(*mock_frame_transformer, Transform) + .WillByDefault( + [&](std::unique_ptr transform_frame) { + frame = std::move(transform_frame); + }); + delegate->Transform(packet, RTPHeader(), /*ssrc=*/1111, + /*mimeType=*/"audio/opus", kFakeReceiveTimestamp); + + EXPECT_TRUE(frame); + auto* audio_frame = + static_cast(frame.get()); + EXPECT_TRUE(audio_frame->CanSetAudioLevel()); + EXPECT_FALSE(audio_frame->AudioLevel().has_value()); + + audio_frame->SetAudioLevel(67u); + EXPECT_EQ(audio_frame->AudioLevel(), 67u); + + // Audio level is clamped to the range [0, 127]. + audio_frame->SetAudioLevel(128u); + EXPECT_EQ(audio_frame->AudioLevel(), 127u); +} + +TEST(ChannelReceiveFrameTransformerDelegateTest, + ReceivingSenderFrameWithAudioValueSetsAudioLevelInHeader) { + AutoThread main_thread; + scoped_refptr mock_frame_transformer = + make_ref_counted>(); + MockChannelReceive mock_channel; + scoped_refptr delegate = + make_ref_counted( + mock_channel.callback(), mock_frame_transformer, Thread::Current()); + delegate->Init(); + + std::unique_ptr audio_frame = + std::make_unique>(); + ON_CALL(*audio_frame, GetDirection()) + .WillByDefault(Return(TransformableFrameInterface::Direction::kSender)); + ON_CALL(*audio_frame, AudioLevel()).WillByDefault(Return(111u)); + + RTPHeader header; + EXPECT_CALL(mock_channel, ReceiveFrame).WillOnce(SaveArg<1>(&header)); + delegate->OnTransformedFrame(std::move(audio_frame)); + ThreadManager::ProcessAllMessageQueuesForTesting(); + + ASSERT_TRUE(header.extension.audio_level().has_value()); + EXPECT_EQ(header.extension.audio_level()->level(), 111); +} + } // namespace } // namespace webrtc diff --git a/audio/channel_receive_unittest.cc b/audio/channel_receive_unittest.cc index 7cedba677a..e228b42c5e 100644 --- a/audio/channel_receive_unittest.cc +++ b/audio/channel_receive_unittest.cc @@ -10,25 +10,38 @@ #include "audio/channel_receive.h" -#include "absl/strings/escaping.h" -#include "api/audio/audio_device.h" +#include +#include +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" -#include "api/crypto/frame_decryptor_interface.h" +#include "api/call/transport.h" +#include "api/crypto/crypto_options.h" #include "api/environment/environment_factory.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" #include "api/test/mock_frame_transformer.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/audio_device/include/mock_audio_device.h" -#include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/ntp_time_util.h" #include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" -#include "modules/rtp_rtcp/source/rtcp_packet/sdes.h" #include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/logging.h" -#include "rtc_base/thread.h" +#include "rtc_base/string_encode.h" +#include "rtc_base/time_utils.h" +#include "system_wrappers/include/ntp_time.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/mock_audio_decoder_factory.h" #include "test/mock_transport.h" #include "test/time_controller/simulated_time_controller.h" @@ -171,7 +184,8 @@ TEST_F(ChannelReceiveTest, ReceiveReportGeneratedOnTime) { bool receiver_report_sent = false; EXPECT_CALL(transport_, SendRtcp) - .WillRepeatedly([&](ArrayView packet) { + .WillRepeatedly([&](ArrayView packet, + const PacketOptions& options) { if (packet.size() >= 2 && packet[1] == rtcp::ReceiverReport::kPacketType) { receiver_report_sent = true; @@ -189,10 +203,11 @@ TEST_F(ChannelReceiveTest, CaptureStartTimeBecomesValid) { auto channel = CreateTestChannelReceive(); EXPECT_CALL(transport_, SendRtcp) - .WillRepeatedly([&](ArrayView packet) { - HandleGeneratedRtcp(*channel, packet); - return true; - }); + .WillRepeatedly( + [&](ArrayView packet, const PacketOptions& options) { + HandleGeneratedRtcp(*channel, packet); + return true; + }); // Before any packets are sent, CaptureStartTime is invalid. EXPECT_EQ(ProbeCaptureStartNtpTime(*channel), -1); diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 52817f31ff..2077d97718 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -132,7 +132,7 @@ class ChannelSend : public ChannelSendInterface, Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, FrameEncryptorInterface* frame_encryptor, - const webrtc::CryptoOptions& crypto_options, + const CryptoOptions& crypto_options, bool extmap_allow_mixed, int rtcp_report_interval_ms, uint32_t ssrc, @@ -204,8 +204,7 @@ class ChannelSend : public ChannelSendInterface, // Sets a frame transformer between encoder and packetizer, to transform // encoded frames before sending them out the network. void SetEncoderToPacketizerFrameTransformer( - scoped_refptr frame_transformer) - override; + scoped_refptr frame_transformer) override; // RtcpPacketTypeCounterObserver. void RtcpPacketTypesCounterUpdated( @@ -249,7 +248,7 @@ class ChannelSend : public ChannelSendInterface, void OnReceivedRtt(int64_t rtt_ms); void InitFrameTransformerDelegate( - scoped_refptr frame_transformer); + scoped_refptr frame_transformer); // Calls the encoder on the encoder queue (instead of blocking). void CallEncoderAsync(absl::AnyInvocable modifier); @@ -301,7 +300,7 @@ class ChannelSend : public ChannelSendInterface, scoped_refptr frame_encryptor_ RTC_GUARDED_BY(encoder_queue_checker_); // E2EE Frame Encryption Options - const webrtc::CryptoOptions crypto_options_; + const CryptoOptions crypto_options_; // Delegates calls to a frame transformer to transform audio, and // receives callbacks with the transformed frames; delegates calls to @@ -389,7 +388,7 @@ int32_t ChannelSend::SendData(AudioFrameType frameType, // is transformed, the delegate will call SendRtpAudio to send it. char buf[1024]; SimpleStringBuilder mime_type(buf); - mime_type << webrtc::MediaTypeToString(webrtc::MediaType::AUDIO) << "/" + mime_type << MediaTypeToString(MediaType::AUDIO) << "/" << encoder_format_.name; frame_transformer_delegate_->Transform( frameType, payloadType, rtp_timestamp + rtp_rtcp_->StartTimestamp(), @@ -421,13 +420,13 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, // TODO(benwright@webrtc.org) - Allocate enough to always encrypt inline. // Allocate a buffer to hold the maximum possible encrypted payload. size_t max_ciphertext_size = frame_encryptor_->GetMaxCiphertextByteSize( - webrtc::MediaType::AUDIO, payload.size()); + MediaType::AUDIO, payload.size()); encrypted_audio_payload.SetSize(max_ciphertext_size); // Encrypt the audio payload into the buffer. size_t bytes_written = 0; int encrypt_status = - frame_encryptor_->Encrypt(webrtc::MediaType::AUDIO, rtp_rtcp_->SSRC(), + frame_encryptor_->Encrypt(MediaType::AUDIO, rtp_rtcp_->SSRC(), /*additional_data=*/nullptr, payload, encrypted_audio_payload, &bytes_written); if (encrypt_status != 0) { @@ -489,7 +488,7 @@ ChannelSend::ChannelSend( Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, FrameEncryptorInterface* frame_encryptor, - const webrtc::CryptoOptions& crypto_options, + const CryptoOptions& crypto_options, bool extmap_allow_mixed, int rtcp_report_interval_ms, uint32_t ssrc, @@ -550,7 +549,7 @@ ChannelSend::~ChannelSend() { frame_transformer_delegate_->Reset(); StopSend(); - int error = audio_coding_->RegisterTransportCallback(NULL); + int error = audio_coding_->RegisterTransportCallback(nullptr); RTC_DCHECK_EQ(0, error); // Delete the encoder task queue first to ensure that there are no running @@ -919,7 +918,7 @@ void ChannelSend::SetFrameEncryptor( } void ChannelSend::SetEncoderToPacketizerFrameTransformer( - scoped_refptr frame_transformer) { + scoped_refptr frame_transformer) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); if (!frame_transformer) return; @@ -937,7 +936,7 @@ void ChannelSend::OnReceivedRtt(int64_t rtt_ms) { } void ChannelSend::InitFrameTransformerDelegate( - scoped_refptr frame_transformer) { + scoped_refptr frame_transformer) { RTC_DCHECK_RUN_ON(&encoder_queue_checker_); RTC_DCHECK(frame_transformer); RTC_DCHECK(!frame_transformer_delegate_); @@ -971,7 +970,7 @@ std::unique_ptr CreateChannelSend( Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, FrameEncryptorInterface* frame_encryptor, - const webrtc::CryptoOptions& crypto_options, + const CryptoOptions& crypto_options, bool extmap_allow_mixed, int rtcp_report_interval_ms, uint32_t ssrc, diff --git a/audio/channel_send_frame_transformer_delegate.cc b/audio/channel_send_frame_transformer_delegate.cc index 8a94ce4c7c..f1a8b4e37d 100644 --- a/audio/channel_send_frame_transformer_delegate.cc +++ b/audio/channel_send_frame_transformer_delegate.cc @@ -89,6 +89,10 @@ class TransformableOutgoingAudioFrame } uint8_t GetPayloadType() const override { return payload_type_; } + bool CanSetPayloadType() const override { return true; } + void SetPayloadType(uint8_t payload_type) override { + payload_type_ = payload_type; + } Direction GetDirection() const override { return Direction::kSender; } std::string GetMimeType() const override { return codec_mime_type_; } @@ -112,8 +116,27 @@ class TransformableOutgoingAudioFrame return audio_level_dbov_; } + bool CanSetAudioLevel() const override { return true; } + void SetAudioLevel(std::optional audio_level_dbov) override { + if (audio_level_dbov.has_value() && audio_level_dbov > 127u) { + audio_level_dbov = 127u; + } + audio_level_dbov_ = audio_level_dbov; + } + std::optional ReceiveTime() const override { return std::nullopt; } - std::optional CaptureTime() const override { return std::nullopt; } + + std::optional CaptureTime() const override { + return absolute_capture_timestamp_ms_ + ? std::make_optional( + Timestamp::Millis(*absolute_capture_timestamp_ms_)) + : std::nullopt; + } + bool CanSetCaptureTime() const override { return true; } + void SetCaptureTime(std::optional capture_time) override { + absolute_capture_timestamp_ms_ = + capture_time ? std::make_optional(capture_time->ms()) : std::nullopt; + } std::optional SenderCaptureTimeOffset() const override { return std::nullopt; } diff --git a/audio/channel_send_frame_transformer_delegate_unittest.cc b/audio/channel_send_frame_transformer_delegate_unittest.cc index 2a526f0570..2eac45ca4f 100644 --- a/audio/channel_send_frame_transformer_delegate_unittest.cc +++ b/audio/channel_send_frame_transformer_delegate_unittest.cc @@ -51,9 +51,9 @@ class MockChannelSend { (AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp, - webrtc::ArrayView payload, + ArrayView payload, int64_t absolute_capture_timestamp_ms, - webrtc::ArrayView csrcs, + ArrayView csrcs, std::optional audio_level_dbov)); ChannelSendFrameTransformerDelegate::SendFrameCallback callback() { @@ -104,7 +104,7 @@ std::unique_ptr CreateFrame() { AudioFrameType::kEmptyFrame, 0, 0, mock_data, sizeof(mock_data), 0, /*ssrc=*/0, /*mimeType=*/"audio/opus", /*audio_level_dbov=*/123); return absl::WrapUnique( - static_cast(frame.release())); + static_cast(frame.release())); } // Test that the delegate registers itself with the frame transformer on Init(). @@ -278,5 +278,37 @@ TEST(ChannelSendFrameTransformerDelegateTest, CloningReceiverFrameWithCsrcs) { EXPECT_EQ(cloned_frame->AudioLevel(), frame->AudioLevel()); } +TEST(ChannelSendFrameTransformerDelegateTest, SetCaptureTime) { + std::unique_ptr frame = CreateFrame(); + EXPECT_TRUE(frame->CanSetCaptureTime()); + frame->SetCaptureTime(webrtc::Timestamp::Millis(100)); + EXPECT_EQ(frame->CaptureTime(), webrtc::Timestamp::Millis(100)); + frame->SetCaptureTime(std::nullopt); + EXPECT_FALSE(frame->CaptureTime().has_value()); +} + +TEST(ChannelSendFrameTransformerDelegateTest, SetPayloadType) { + std::unique_ptr frame = CreateFrame(); + EXPECT_TRUE(frame->CanSetPayloadType()); + frame->SetPayloadType(45); + EXPECT_EQ(frame->GetPayloadType(), 45); +} + +TEST(ChannelSendFrameTransformerDelegateTest, SetAudioLevel) { + std::unique_ptr frame = CreateFrame(); + EXPECT_TRUE(frame->CanSetAudioLevel()); + frame->SetAudioLevel(45u); + EXPECT_EQ(frame->AudioLevel(), 45u); + frame->SetAudioLevel(std::nullopt); + EXPECT_FALSE(frame->AudioLevel().has_value()); +} + +TEST(ChannelSendFrameTransformerDelegateTest, SetAudioLevelIsClamped) { + std::unique_ptr frame = CreateFrame(); + EXPECT_TRUE(frame->CanSetAudioLevel()); + frame->SetAudioLevel(128u); + EXPECT_EQ(frame->AudioLevel(), 127u); +} + } // namespace } // namespace webrtc diff --git a/audio/channel_send_unittest.cc b/audio/channel_send_unittest.cc index 03ce5bceeb..7636ee32c6 100644 --- a/audio/channel_send_unittest.cc +++ b/audio/channel_send_unittest.cc @@ -123,7 +123,7 @@ class ChannelSendTest : public ::testing::Test { void ProcessNextFrame() { ProcessNextFrame(CreateAudioFrame()); } GlobalSimulatedTimeController time_controller_; - webrtc::test::ScopedKeyValueConfig field_trials_; + test::ScopedKeyValueConfig field_trials_; Environment env_; NiceMock transport_; CryptoOptions crypto_options_; diff --git a/audio/remix_resample.cc b/audio/remix_resample.cc index 93e86517ae..0f87803dc0 100644 --- a/audio/remix_resample.cc +++ b/audio/remix_resample.cc @@ -11,12 +11,13 @@ #include "audio/remix_resample.h" #include +#include #include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" #include "audio/utility/audio_frame_operations.h" #include "common_audio/resampler/include/push_resampler.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" namespace webrtc { namespace voe { @@ -70,12 +71,9 @@ void RemixAndResample(InterleavedView src_data, // `dst_frame` as a target buffer with the same number of channels as the // source. auto original_dst_number_of_channels = dst_frame->num_channels_; - int out_length = resampler->Resample( - src_data, dst_frame->mutable_data(dst_frame->samples_per_channel_, - src_data.num_channels())); - RTC_CHECK_NE(out_length, -1) << "src_data.size=" << src_data.size(); - RTC_DCHECK_EQ(dst_frame->samples_per_channel(), - out_length / src_data.num_channels()); + resampler->Resample(src_data, + dst_frame->mutable_data(dst_frame->samples_per_channel_, + src_data.num_channels())); // Upmix after resampling. if (src_data.num_channels() == 1 && original_dst_number_of_channels == 2) { diff --git a/audio/test/audio_end_to_end_test.cc b/audio/test/audio_end_to_end_test.cc index 746ae3fea7..95bc86dcca 100644 --- a/audio/test/audio_end_to_end_test.cc +++ b/audio/test/audio_end_to_end_test.cc @@ -16,7 +16,6 @@ #include "api/task_queue/task_queue_base.h" #include "call/fake_network_pipe.h" #include "modules/audio_device/include/test_audio_device.h" -#include "system_wrappers/include/sleep.h" #include "test/gtest.h" #include "test/video_test_constants.h" @@ -63,8 +62,7 @@ void AudioEndToEndTest::ModifyAudioConfigs( AudioSendStream::Config* send_config, std::vector* /* receive_configs */) { // Large bitrate by default. - const webrtc::SdpAudioFormat kDefaultFormat("opus", 48000, 2, - {{"stereo", "1"}}); + const SdpAudioFormat kDefaultFormat("opus", 48000, 2, {{"stereo", "1"}}); send_config->send_codec_spec = AudioSendStream::Config::SendCodecSpec( test::VideoTestConstants::kAudioSendPayloadType, kDefaultFormat); send_config->min_bitrate_bps = 32000; diff --git a/audio/test/audio_stats_test.cc b/audio/test/audio_stats_test.cc index e8521cfe99..d8f1d406a5 100644 --- a/audio/test/audio_stats_test.cc +++ b/audio/test/audio_stats_test.cc @@ -10,7 +10,7 @@ #include "audio/test/audio_end_to_end_test.h" #include "rtc_base/numerics/safe_compare.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" #include "test/gtest.h" namespace webrtc { @@ -42,10 +42,11 @@ class NoLossTest : public AudioEndToEndTest { } void PerformTest() override { - SleepMs(kTestDurationMs); + Thread::SleepMs(kTestDurationMs); send_audio_device()->StopRecording(); // and some extra time to account for network delay. - SleepMs(GetSendTransportConfig().queue_delay_ms + kExtraRecordTimeMs); + Thread::SleepMs(GetSendTransportConfig().queue_delay_ms + + kExtraRecordTimeMs); } void OnStreamsStopped() override { diff --git a/audio/test/nack_test.cc b/audio/test/nack_test.cc index b36adf8991..05cd11b2ce 100644 --- a/audio/test/nack_test.cc +++ b/audio/test/nack_test.cc @@ -9,7 +9,7 @@ */ #include "audio/test/audio_end_to_end_test.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" #include "test/gtest.h" namespace webrtc { @@ -40,7 +40,7 @@ TEST_F(NackTest, ShouldNackInLossyNetwork) { AudioEndToEndTest::ModifyAudioConfigs(send_config, receive_configs); } - void PerformTest() override { SleepMs(kTestDurationMs); } + void PerformTest() override { Thread::SleepMs(kTestDurationMs); } void OnStreamsStopped() override { AudioReceiveStreamInterface::Stats recv_stats = diff --git a/audio/test/non_sender_rtt_test.cc b/audio/test/non_sender_rtt_test.cc index 17dd97ef09..49b6cae92e 100644 --- a/audio/test/non_sender_rtt_test.cc +++ b/audio/test/non_sender_rtt_test.cc @@ -60,7 +60,7 @@ TEST_F(NonSenderRttTest, NonSenderRttStats) { // cases it can take more than 10 seconds. EXPECT_THAT( WaitUntil([&] { return HasRoundTripTimeMeasurement(); }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kLongTimeoutMs)}), + {.timeout = TimeDelta::Millis(kLongTimeoutMs)}), IsRtcOk()); } diff --git a/audio/voip/test/BUILD.gn b/audio/voip/test/BUILD.gn index 7f120065b5..2b80dc66c6 100644 --- a/audio/voip/test/BUILD.gn +++ b/audio/voip/test/BUILD.gn @@ -46,17 +46,25 @@ if (rtc_include_tests) { deps = [ ":mock_task_queue", "..:audio_channel", + "../../../api:array_view", + "../../../api:make_ref_counted", + "../../../api:scoped_refptr", "../../../api:transport_api", + "../../../api/audio:audio_frame_api", + "../../../api/audio:audio_mixer_api", + "../../../api/audio_codecs:audio_codecs_api", "../../../api/audio_codecs:builtin_audio_decoder_factory", "../../../api/audio_codecs:builtin_audio_encoder_factory", "../../../api/environment", "../../../api/environment:environment_factory", "../../../api/task_queue:task_queue", + "../../../api/voip:voip_api", "../../../modules/audio_mixer:audio_mixer_impl", "../../../modules/audio_mixer:audio_mixer_test_utils", "../../../modules/rtp_rtcp:rtp_rtcp", "../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../rtc_base:logging", + "../../../system_wrappers", "../../../test:mock_transport", "../../../test:test_support", "//third_party/abseil-cpp/absl/functional:any_invocable", diff --git a/audio/voip/test/audio_channel_unittest.cc b/audio/voip/test/audio_channel_unittest.cc index 9a47e03710..ad71c67120 100644 --- a/audio/voip/test/audio_channel_unittest.cc +++ b/audio/voip/test/audio_channel_unittest.cc @@ -10,19 +10,32 @@ #include "audio/voip/audio_channel.h" +#include +#include +#include +#include +#include + #include "absl/functional/any_invocable.h" +#include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio/audio_mixer.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_encoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" -#include "api/call/transport.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/task_queue/task_queue_base.h" -#include "api/task_queue/task_queue_factory.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/voip/voip_statistics.h" #include "audio/voip/test/mock_task_queue.h" #include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/audio_mixer/sine_wave_generator.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "rtc_base/logging.h" +#include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" @@ -229,7 +242,7 @@ TEST_F(AudioChannelTest, TestChannelStatistics) { audio_channel_->ReceivedRTPPacket(packet); return true; }; - auto loop_rtcp = [&](ArrayView packet) { + auto loop_rtcp = [&](ArrayView packet, Unused) { audio_channel_->ReceivedRTCPPacket(packet); return true; }; @@ -316,7 +329,7 @@ TEST_F(AudioChannelTest, RttIsAvailableAfterChangeOfRemoteSsrc) { auto send_recv_rtcp = [&](scoped_refptr rtcp_sender, scoped_refptr rtcp_receiver) { // Setup routing logic via transport_. - auto route_rtcp = [&](ArrayView packet) { + auto route_rtcp = [&](ArrayView packet, Unused) { rtcp_receiver->ReceivedRTCPPacket(packet); return true; }; diff --git a/call/BUILD.gn b/call/BUILD.gn index 073b4099e6..cf4ad08d15 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -333,6 +333,7 @@ rtc_library("call") { "../modules/video_coding:nack_requester", "../rtc_base:checks", "../rtc_base:copy_on_write_buffer", + "../rtc_base:cpu_info", "../rtc_base:event_tracer", "../rtc_base:logging", "../rtc_base:macromagic", diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn index d3a8ad6f32..c6e5d8f5bf 100644 --- a/call/adaptation/BUILD.gn +++ b/call/adaptation/BUILD.gn @@ -96,7 +96,7 @@ if (rtc_include_tests) { ] } - rtc_source_set("resource_adaptation_test_utilities") { + rtc_library("resource_adaptation_test_utilities") { testonly = true sources = [ diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc index 79433c7bb3..fe60171c2a 100644 --- a/call/adaptation/resource_adaptation_processor_unittest.cc +++ b/call/adaptation/resource_adaptation_processor_unittest.cc @@ -147,7 +147,7 @@ class ResourceAdaptationProcessorTest : public ::testing::Test { protected: AutoThread main_thread_; - webrtc::test::ScopedKeyValueConfig field_trials_; + test::ScopedKeyValueConfig field_trials_; FakeFrameRateProvider frame_rate_provider_; VideoStreamInputStateProvider input_state_provider_; scoped_refptr resource_; diff --git a/call/adaptation/video_stream_adapter_unittest.cc b/call/adaptation/video_stream_adapter_unittest.cc index 83720b4318..4e57883d89 100644 --- a/call/adaptation/video_stream_adapter_unittest.cc +++ b/call/adaptation/video_stream_adapter_unittest.cc @@ -155,7 +155,7 @@ class VideoStreamAdapterTest : public ::testing::Test { field_trials_) {} protected: - webrtc::test::ScopedKeyValueConfig field_trials_; + test::ScopedKeyValueConfig field_trials_; FakeVideoStreamInputStateProvider input_state_provider_; scoped_refptr resource_; testing::StrictMock encoder_stats_observer_; @@ -918,7 +918,7 @@ TEST_F(VideoStreamAdapterTest, AdaptationConstraintDisallowsAdaptationsUp) { TEST(VideoStreamAdapterDeathTest, SetDegradationPreferenceInvalidatesAdaptations) { - webrtc::test::ScopedKeyValueConfig field_trials; + test::ScopedKeyValueConfig field_trials; FakeVideoStreamInputStateProvider input_state_provider; testing::StrictMock encoder_stats_observer_; VideoStreamAdapter adapter(&input_state_provider, &encoder_stats_observer_, @@ -931,7 +931,7 @@ TEST(VideoStreamAdapterDeathTest, } TEST(VideoStreamAdapterDeathTest, AdaptDownInvalidatesAdaptations) { - webrtc::test::ScopedKeyValueConfig field_trials; + test::ScopedKeyValueConfig field_trials; FakeVideoStreamInputStateProvider input_state_provider; testing::StrictMock encoder_stats_observer_; VideoStreamAdapter adapter(&input_state_provider, &encoder_stats_observer_, diff --git a/call/call.cc b/call/call.cc index ace69e717a..d6d0e4b2d3 100644 --- a/call/call.cc +++ b/call/call.cc @@ -80,6 +80,7 @@ #include "modules/video_coding/nack_requester.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/cpu_info.h" #include "rtc_base/logging.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/strings/string_builder.h" @@ -90,7 +91,6 @@ #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/cpu_info.h" #include "system_wrappers/include/metrics.h" #include "video/call_stats2.h" #include "video/config/video_encoder_config.h" @@ -718,7 +718,7 @@ Call::Call(CallConfig config, config.decode_metronome, worker_thread_) : nullptr), - num_cpu_cores_(CpuInfo::DetectNumberOfCores()), + num_cpu_cores_(cpu_info::DetectNumberOfCores()), call_stats_(new CallStats(&env_.clock(), worker_thread_)), bitrate_allocator_(new BitrateAllocator( this, diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index b72558d978..c7d2e17d8b 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -90,9 +90,9 @@ using webrtc::test::DriftingClock; namespace webrtc { namespace { -using ::webrtc::test::GetGlobalMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::GetGlobalMetricsLogger; +using test::ImprovementDirection; +using test::Unit; enum : int { // The first valid value is 1. kTransportSequenceNumberExtensionId = 1, @@ -237,8 +237,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, metrics::Reset(); scoped_refptr fake_audio_device = TestAudioDeviceModule::Create( - &env().task_queue_factory(), - TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000), + env(), TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000), TestAudioDeviceModule::CreateDiscardRenderer(48000), audio_rtp_speed); EXPECT_EQ(0, fake_audio_device->Init()); @@ -667,7 +666,7 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) { const FieldTrialsView& /*field_trials*/, int frame_width, int frame_height, - const webrtc::VideoEncoderConfig& encoder_config) override { + const VideoEncoderConfig& encoder_config) override { std::vector streams = test::CreateVideoStreams(frame_width, frame_height, encoder_config); streams[0].min_bitrate_bps = 50000; diff --git a/call/call_unittest.cc b/call/call_unittest.cc index d891853dcc..32f41fece0 100644 --- a/call/call_unittest.cc +++ b/call/call_unittest.cc @@ -53,16 +53,16 @@ namespace webrtc { namespace { +using test::FakeEncoder; +using test::FunctionVideoEncoderFactory; +using test::MockAudioDeviceModule; +using test::MockAudioMixer; +using test::MockAudioProcessing; +using test::RunLoop; using ::testing::_; using ::testing::MockFunction; using ::testing::NiceMock; using ::testing::StrictMock; -using ::webrtc::test::FakeEncoder; -using ::webrtc::test::FunctionVideoEncoderFactory; -using ::webrtc::test::MockAudioDeviceModule; -using ::webrtc::test::MockAudioMixer; -using ::webrtc::test::MockAudioProcessing; -using ::webrtc::test::RunLoop; struct CallHelper { explicit CallHelper(bool use_null_audio_processing) { @@ -123,8 +123,7 @@ TEST(CallTest, CreateDestroy_AudioReceiveStream) { MockTransport rtcp_send_transport; config.rtp.remote_ssrc = 42; config.rtcp_send_transport = &rtcp_send_transport; - config.decoder_factory = - make_ref_counted(); + config.decoder_factory = make_ref_counted(); AudioReceiveStreamInterface* stream = call->CreateAudioReceiveStream(config); EXPECT_NE(stream, nullptr); @@ -163,8 +162,7 @@ TEST(CallTest, CreateDestroy_AudioReceiveStreams) { AudioReceiveStreamInterface::Config config; MockTransport rtcp_send_transport; config.rtcp_send_transport = &rtcp_send_transport; - config.decoder_factory = - make_ref_counted(); + config.decoder_factory = make_ref_counted(); std::list streams; for (int i = 0; i < 2; ++i) { for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index a1150b30c1..f63bf11ef1 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -323,7 +323,8 @@ void FakeNetworkPipe::DeliverNetworkPacket(NetworkPacket* packet) { return; } if (packet->is_rtcp()) { - transport->SendRtcp(MakeArrayView(packet->data(), packet->data_length())); + transport->SendRtcp(MakeArrayView(packet->data(), packet->data_length()), + packet->packet_options()); } else { transport->SendRtp(MakeArrayView(packet->data(), packet->data_length()), packet->packet_options()); diff --git a/call/payload_type_picker.cc b/call/payload_type_picker.cc index cee6d46094..3ce57cc502 100644 --- a/call/payload_type_picker.cc +++ b/call/payload_type_picker.cc @@ -45,7 +45,7 @@ static const int kLastDynamicPayloadTypeUpperRange = 127; // is only a temporary measure. struct MapTableEntry { - webrtc::SdpAudioFormat format; + SdpAudioFormat format; int payload_type; }; @@ -169,7 +169,7 @@ PayloadTypePicker::PayloadTypePicker() { // Includes data to reduce collisions (and thus reassignments) // TODO(bugs.webrtc.org/400630582): Delete this, it's only for test // stability. - {{"reserved-do-not-use", 0, 0}, 102}, + {{"reserved-do-not-use", 1, 0}, 102}, {{kCnCodecName, 16000, 1}, 105}, {{kCnCodecName, 32000, 1}, 106}, {{kOpusCodecName, diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index 5b121f01b5..3a18e8c6d8 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -61,9 +61,9 @@ ABSL_FLAG(std::string, namespace webrtc { namespace { -using ::webrtc::test::GetGlobalMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::GetGlobalMetricsLogger; +using test::ImprovementDirection; +using test::Unit; constexpr TimeDelta kPollInterval = TimeDelta::Millis(20); static const int kExpectedHighVideoBitrateBps = 80000; @@ -450,7 +450,7 @@ void RampUpDownUpTester::PollStats() { int transmit_bitrate_bps = 0; bool suspended = false; if (num_video_streams_ > 0 && send_stream_) { - webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); + VideoSendStream::Stats stats = send_stream_->GetStats(); for (const auto& it : stats.substreams) { transmit_bitrate_bps += it.second.total_bitrate_bps; } @@ -503,7 +503,7 @@ int RampUpDownUpTester::GetExpectedHighBitrate() const { size_t RampUpDownUpTester::GetFecBytes() const { size_t flex_fec_bytes = 0; if (num_flexfec_streams_ > 0) { - webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); + VideoSendStream::Stats stats = send_stream_->GetStats(); for (const auto& kv : stats.substreams) flex_fec_bytes += kv.second.rtp_stats.fec.TotalBytes(); } diff --git a/call/receive_time_calculator_unittest.cc b/call/receive_time_calculator_unittest.cc index 0dd8e45545..61275f884e 100644 --- a/call/receive_time_calculator_unittest.cc +++ b/call/receive_time_calculator_unittest.cc @@ -169,7 +169,7 @@ class EmulatedNonMonotoneousClock : public EmulatedClock { }; TEST(ClockRepair, NoClockDrift) { - webrtc::test::ScopedKeyValueConfig field_trials; + test::ScopedKeyValueConfig field_trials; const int kSeeds = 10; const int kFirstSeed = 1; const int64_t kRuntimeUs = 10 * kNumMicrosecsPerSec; diff --git a/call/rtp_demuxer_unittest.cc b/call/rtp_demuxer_unittest.cc index e2702267b4..5cbc1bc641 100644 --- a/call/rtp_demuxer_unittest.cc +++ b/call/rtp_demuxer_unittest.cc @@ -20,7 +20,6 @@ #include "call/test/mock_rtp_packet_sink_interface.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "rtc_base/arraysize.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/gmock.h" @@ -290,12 +289,12 @@ TEST_F(RtpDemuxerTest, DISABLED_RejectAddSinkForSamePayloadTypes) { TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkBySsrc) { constexpr uint32_t ssrcs[] = {101, 202, 303}; - MockRtpPacketSink sinks[arraysize(ssrcs)]; - for (size_t i = 0; i < arraysize(ssrcs); i++) { + MockRtpPacketSink sinks[std::size(ssrcs)]; + for (size_t i = 0; i < std::size(ssrcs); i++) { AddSinkOnlySsrc(ssrcs[i], &sinks[i]); } - for (size_t i = 0; i < arraysize(ssrcs); i++) { + for (size_t i = 0; i < std::size(ssrcs); i++) { auto packet = CreatePacketWithSsrc(ssrcs[i]); EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1); EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); @@ -304,12 +303,12 @@ TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkBySsrc) { TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByRsid) { const std::string rsids[] = {"a", "b", "c"}; - MockRtpPacketSink sinks[arraysize(rsids)]; - for (size_t i = 0; i < arraysize(rsids); i++) { + MockRtpPacketSink sinks[std::size(rsids)]; + for (size_t i = 0; i < std::size(rsids); i++) { AddSinkOnlyRsid(rsids[i], &sinks[i]); } - for (size_t i = 0; i < arraysize(rsids); i++) { + for (size_t i = 0; i < std::size(rsids); i++) { auto packet = CreatePacketWithSsrcRsid(checked_cast(i), rsids[i]); EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1); EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); @@ -318,12 +317,12 @@ TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByRsid) { TEST_F(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkByMid) { const std::string mids[] = {"a", "v", "s"}; - MockRtpPacketSink sinks[arraysize(mids)]; - for (size_t i = 0; i < arraysize(mids); i++) { + MockRtpPacketSink sinks[std::size(mids)]; + for (size_t i = 0; i < std::size(mids); i++) { AddSinkOnlyMid(mids[i], &sinks[i]); } - for (size_t i = 0; i < arraysize(mids); i++) { + for (size_t i = 0; i < std::size(mids); i++) { auto packet = CreatePacketWithSsrcMid(checked_cast(i), mids[i]); EXPECT_CALL(sinks[i], OnRtpPacket(SamePacketAs(*packet))).Times(1); EXPECT_TRUE(demuxer_.OnRtpPacket(*packet)); @@ -376,7 +375,7 @@ TEST_F(RtpDemuxerTest, PacketsDeliveredInRightOrder) { AddSinkOnlySsrc(ssrc, &sink); std::unique_ptr packets[5]; - for (size_t i = 0; i < arraysize(packets); i++) { + for (size_t i = 0; i < std::size(packets); i++) { packets[i] = CreatePacketWithSsrc(ssrc); packets[i]->SetSequenceNumber(checked_cast(i)); } @@ -511,7 +510,7 @@ TEST_F(RtpDemuxerTest, RsidLearnedAndLaterPacketsDeliveredWithOnlySsrc) { std::unique_ptr packets[5]; constexpr uint32_t rsid_ssrc = 111; packets[0] = CreatePacketWithSsrcRsid(rsid_ssrc, rsid); - for (size_t i = 1; i < arraysize(packets); i++) { + for (size_t i = 1; i < std::size(packets); i++) { packets[i] = CreatePacketWithSsrc(rsid_ssrc); } @@ -663,7 +662,7 @@ TEST_F(RtpDemuxerTest, MultipleRsidsOnSameSink) { } InSequence sequence; - for (size_t i = 0; i < arraysize(rsids); i++) { + for (size_t i = 0; i < std::size(rsids); i++) { // Assign different SSRCs and sequence numbers to all packets. const uint32_t ssrc = 1000 + static_cast(i); const uint16_t sequence_number = 50 + static_cast(i); diff --git a/call/rtp_payload_params.cc b/call/rtp_payload_params.cc index 2941f6375c..a3151814c3 100644 --- a/call/rtp_payload_params.cc +++ b/call/rtp_payload_params.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include "absl/container/inlined_vector.h" @@ -36,7 +37,6 @@ #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" #include "modules/video_coding/frame_dependencies_calculator.h" #include "modules/video_coding/include/video_codec_interface.h" -#include "rtc_base/arraysize.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/random.h" @@ -789,7 +789,7 @@ void RtpPayloadParams::SetDependenciesVp8New( RTC_DCHECK_GT(vp8_info.referencedBuffersCount, 0u); RTC_DCHECK_LE(vp8_info.referencedBuffersCount, - arraysize(vp8_info.referencedBuffers)); + std::size(vp8_info.referencedBuffers)); for (size_t i = 0; i < vp8_info.referencedBuffersCount; ++i) { const size_t referenced_buffer = vp8_info.referencedBuffers[i]; diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 992e3a436c..dcf12b2159 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -50,7 +50,6 @@ #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h" #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" -#include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/field_trial_parser.h" @@ -624,15 +623,6 @@ void RtpTransportControllerSend::NotifyBweOfPacedSentPacket( RTC_DCHECK_NOTREACHED() << "Unknown packet type"; return; } - if (packet.HasExtension()) { - // TODO: bugs.webrtc.org/42225697 - Refactor TransportFeedbackDemuxer to use - // TransportPacketsFeedback instead of directly using - // rtcp::TransportFeedback. For now, only use it if TransportSeqeunce number - // header extension is used. - RtpPacketSendInfo packet_info = - RtpPacketSendInfo::From(packet, pacing_info); - feedback_demuxer_.AddPacket(packet_info); - } Timestamp creation_time = Timestamp::Millis(env_.clock().TimeInMilliseconds()); transport_feedback_adapter_.AddPacket( @@ -652,7 +642,6 @@ void RtpTransportControllerSend::OnTransportFeedback( const rtcp::TransportFeedback& feedback) { RTC_DCHECK_RUN_ON(&sequence_checker_); ++transport_cc_feedback_count_; - feedback_demuxer_.OnTransportFeedback(feedback); std::optional feedback_msg = transport_feedback_adapter_.ProcessTransportFeedback(feedback, receive_time); @@ -666,9 +655,6 @@ void RtpTransportControllerSend::OnCongestionControlFeedback( const rtcp::CongestionControlFeedback& feedback) { RTC_DCHECK_RUN_ON(&sequence_checker_); ++feedback_count_; - // TODO: bugs.webrtc.org/42225697 - update feedback demuxer for RFC 8888. - // Suggest feedback_demuxer_.OnTransportFeedback use TransportPacketFeedback - // instead. See usage in OnTransportFeedback. std::optional feedback_msg = transport_feedback_adapter_.ProcessCongestionControlFeedback( feedback, receive_time); @@ -689,6 +675,8 @@ void RtpTransportControllerSend::HandleTransportPacketsFeedback( << " ECN capable. Stop sending ECT(1)."; packet_router_.ConfigureForRfc8888Feedback(sending_packets_as_ect1_); } + + feedback_demuxer_.OnTransportFeedback(feedback); if (controller_) PostUpdates(controller_->OnTransportPacketsFeedback(feedback)); diff --git a/call/version.cc b/call/version.cc index 7684820d5d..f10e6c2f1a 100644 --- a/call/version.cc +++ b/call/version.cc @@ -13,7 +13,7 @@ namespace webrtc { // The timestamp is always in UTC. -const char* const kSourceTimestamp = "WebRTC source stamp 2025-04-28T04:05:58"; +const char* const kSourceTimestamp = "WebRTC source stamp 2025-05-26T04:07:21"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn index 9a7478d8db..d40cf4e2b5 100644 --- a/common_audio/BUILD.gn +++ b/common_audio/BUILD.gn @@ -337,6 +337,8 @@ if (rtc_include_tests && !build_with_chromium) { testonly = true sources = [ + "allocation_counter.cc", + "allocation_counter.h", "audio_converter_unittest.cc", "audio_util_unittest.cc", "channel_buffer_unittest.cc", @@ -387,6 +389,7 @@ if (rtc_include_tests && !build_with_chromium) { "../test:test_main", "../test:test_support", "//testing/gtest", + "//third_party/abseil-cpp/absl/base:core_headers", ] if (is_android) { diff --git a/common_audio/allocation_counter.cc b/common_audio/allocation_counter.cc new file mode 100644 index 0000000000..2a60d2b13a --- /dev/null +++ b/common_audio/allocation_counter.cc @@ -0,0 +1,83 @@ +/* + * 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 "common_audio/allocation_counter.h" + +#if defined(WEBRTC_ALLOCATION_COUNTER_AVAILABLE) + +#include + +#include +#include + +#include "absl/base/attributes.h" +#include "test/gtest.h" + +namespace { +#if defined(ABSL_HAVE_THREAD_LOCAL) +ABSL_CONST_INIT thread_local size_t g_new_count = 0u; +ABSL_CONST_INIT thread_local size_t g_delete_count = 0u; +#elif defined(WEBRTC_POSIX) +#error Handle WEBRTC_POSIX +#else +#error Unsupported platform +#endif +} // namespace + +void* operator new(size_t s) { + ++g_new_count; + return malloc(s); +} + +void* operator new[](size_t s) { + ++g_new_count; + return malloc(s); +} + +void operator delete(void* p) throw() { + ++g_delete_count; + return free(p); +} + +void operator delete[](void* p) throw() { + ++g_delete_count; + return free(p); +} + +namespace webrtc { + +AllocationCounter::AllocationCounter() + : initial_new_count_(g_new_count), initial_delete_count_(g_delete_count) {} + +size_t AllocationCounter::new_count() const { + return g_new_count - initial_new_count_; +} + +size_t AllocationCounter::delete_count() const { + return g_delete_count - initial_delete_count_; +} + +TEST(AllocationCounterTest, CountsHeapAllocations) { + std::vector v; + AllocationCounter counter; + EXPECT_EQ(counter.new_count(), 0u); + EXPECT_EQ(counter.delete_count(), 0u); + v.resize(1000); + EXPECT_EQ(counter.new_count(), 1u); + EXPECT_EQ(counter.delete_count(), 0u); + v.clear(); + v.shrink_to_fit(); + EXPECT_EQ(counter.new_count(), 1u); + EXPECT_EQ(counter.delete_count(), 1u); +} + +} // namespace webrtc + +#endif // defined(WEBRTC_ALLOCATION_COUNTER_AVAILABLE) diff --git a/common_audio/allocation_counter.h b/common_audio/allocation_counter.h new file mode 100644 index 0000000000..1d1caf3edd --- /dev/null +++ b/common_audio/allocation_counter.h @@ -0,0 +1,52 @@ +/* + * 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 COMMON_AUDIO_ALLOCATION_COUNTER_H_ +#define COMMON_AUDIO_ALLOCATION_COUNTER_H_ + +#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ + defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ + defined(UNDEFINED_SANITIZER) +// The allocator override mechanism is not available since the +// sanitizers override the allocators themselves. +#else +#define WEBRTC_ALLOCATION_COUNTER_AVAILABLE 1 + +#include + +namespace webrtc { + +// Use to count the number of heap allocations that have been performed on the +// current thread within the scope of the AllocationCounter. +// +// * Note1: This class is a test-only utility. In order to be able to count +// allocations, AllocationCounter overrides the global new and delete +// operators for the test binary. +// +// * Note2: An AllocationCounter instance must always be used from the same +// thread. +class AllocationCounter { + public: + AllocationCounter(); + ~AllocationCounter() = default; + + // Returns the number of heap allocations that have been made since + // construction. + size_t new_count() const; + size_t delete_count() const; + + private: + const size_t initial_new_count_; + const size_t initial_delete_count_; +}; +} // namespace webrtc + +#endif // all the sanitizers +#endif // COMMON_AUDIO_ALLOCATION_COUNTER_H_ diff --git a/common_audio/resampler/include/push_resampler.h b/common_audio/resampler/include/push_resampler.h index 394e96b133..fe33d56c35 100644 --- a/common_audio/resampler/include/push_resampler.h +++ b/common_audio/resampler/include/push_resampler.h @@ -11,6 +11,7 @@ #ifndef COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ #define COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_ +#include #include #include @@ -31,12 +32,10 @@ class PushResampler final { size_t num_channels); ~PushResampler(); - // Returns the total number of samples provided in destination (e.g. 32 kHz, - // 2 channel audio gives 640 samples). - int Resample(InterleavedView src, InterleavedView dst); - // For when a deinterleaved/mono channel already exists and we can skip the - // deinterleaved operation. - int Resample(MonoView src, MonoView dst); + void Resample(InterleavedView src, InterleavedView dst); + // For when a deinterleaved (or mono) channel already exists and we can skip + // the deinterleaved operation. + void Resample(MonoView src, MonoView dst); private: // Ensures that source and destination buffers for deinterleaving are diff --git a/common_audio/resampler/push_resampler.cc b/common_audio/resampler/push_resampler.cc index 2e75679c82..d35b9af605 100644 --- a/common_audio/resampler/push_resampler.cc +++ b/common_audio/resampler/push_resampler.cc @@ -15,7 +15,7 @@ #include -#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" #include "common_audio/include/audio_util.h" #include "common_audio/resampler/push_sinc_resampler.h" #include "rtc_base/checks.h" @@ -77,8 +77,8 @@ void PushResampler::EnsureInitialized(size_t src_samples_per_channel, } template -int PushResampler::Resample(InterleavedView src, - InterleavedView dst) { +void PushResampler::Resample(InterleavedView src, + InterleavedView dst) { EnsureInitialized(SamplesPerChannel(src), SamplesPerChannel(dst), NumChannels(src)); @@ -91,7 +91,7 @@ int PushResampler::Resample(InterleavedView src, // The old resampler provides this memcpy facility in the case of matching // sample rates, so reproduce it here for the sinc resampler. CopySamples(dst, src); - return static_cast(src.data().size()); + return; } Deinterleave(src, source_view_); @@ -103,21 +103,19 @@ int PushResampler::Resample(InterleavedView src, } Interleave(destination_view_, dst); - return static_cast(dst.size()); } template -int PushResampler::Resample(MonoView src, MonoView dst) { +void PushResampler::Resample(MonoView src, MonoView dst) { RTC_DCHECK_EQ(resamplers_.size(), 1); RTC_DCHECK_EQ(SamplesPerChannel(src), SamplesPerChannel(source_view_)); RTC_DCHECK_EQ(SamplesPerChannel(dst), SamplesPerChannel(destination_view_)); if (SamplesPerChannel(src) == SamplesPerChannel(dst)) { CopySamples(dst, src); - return static_cast(src.size()); + } else { + resamplers_[0]->Resample(src, dst); } - - return resamplers_[0]->Resample(src, dst); } // Explictly generate required instantiations. diff --git a/common_audio/window_generator.cc b/common_audio/window_generator.cc index da5603d9e7..7c33d255f0 100644 --- a/common_audio/window_generator.cc +++ b/common_audio/window_generator.cc @@ -14,6 +14,7 @@ #include #include +#include #include "rtc_base/checks.h" @@ -41,7 +42,7 @@ void WindowGenerator::Hanning(int length, float* window) { RTC_CHECK(window != nullptr); for (int i = 0; i < length; ++i) { window[i] = - 0.5f * (1 - cosf(2 * static_cast(M_PI) * i / (length - 1))); + 0.5f * (1 - cosf(2 * std::numbers::pi_v * i / (length - 1))); } } @@ -56,7 +57,7 @@ void WindowGenerator::KaiserBesselDerived(float alpha, for (size_t i = 0; i <= half; ++i) { complex r = (4.0f * i) / length - 1.0f; - sum += I0(static_cast(M_PI) * alpha * sqrt(1.0f - r * r)).real(); + sum += I0(std::numbers::pi_v * alpha * sqrt(1.0f - r * r)).real(); window[i] = sum; } for (size_t i = length - 1; i >= half; --i) { diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn index 1a69762a65..d8bc46c19e 100644 --- a/common_video/BUILD.gn +++ b/common_video/BUILD.gn @@ -144,6 +144,7 @@ if (rtc_include_tests && !build_with_chromium) { ":corruption_detection_converters", ":frame_instrumentation_data", "../api/transport/rtp:corruption_detection_message", + "../rtc_base:checks", "../test:test_support", ] } @@ -176,8 +177,10 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":common_video", ":corruption_detection_converters_unittest", + "../api:array_view", "../api:scoped_refptr", "../api/units:time_delta", + "../api/units:timestamp", "../api/video:video_frame", "../api/video:video_frame_i010", "../api/video:video_rtp_headers", diff --git a/common_video/bitrate_adjuster.cc b/common_video/bitrate_adjuster.cc index 8f3ddeb532..66f31d9e0b 100644 --- a/common_video/bitrate_adjuster.cc +++ b/common_video/bitrate_adjuster.cc @@ -12,8 +12,12 @@ #include #include +#include +#include +#include #include "rtc_base/logging.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/time_utils.h" namespace webrtc { diff --git a/common_video/bitrate_adjuster_unittest.cc b/common_video/bitrate_adjuster_unittest.cc index 1ff911c4be..088e71fd89 100644 --- a/common_video/bitrate_adjuster_unittest.cc +++ b/common_video/bitrate_adjuster_unittest.cc @@ -10,6 +10,9 @@ #include "common_video/include/bitrate_adjuster.h" +#include +#include + #include "api/units/time_delta.h" #include "rtc_base/fake_clock.h" #include "test/gtest.h" @@ -34,7 +37,7 @@ class BitrateAdjusterTest : public ::testing::Test { const size_t frame_size_bytes = (bitrate_bps * frame_interval_ms) / (8 * 1000); for (size_t i = 0; i < update_frame_interval; ++i) { - clock_.AdvanceTime(webrtc::TimeDelta::Millis(frame_interval_ms)); + clock_.AdvanceTime(TimeDelta::Millis(frame_interval_ms)); adjuster_.Update(frame_size_bytes); } } diff --git a/common_video/corruption_detection_converters_unittest.cc b/common_video/corruption_detection_converters_unittest.cc index 8b3372e653..c84fb597c9 100644 --- a/common_video/corruption_detection_converters_unittest.cc +++ b/common_video/corruption_detection_converters_unittest.cc @@ -15,6 +15,7 @@ #include "api/transport/rtp/corruption_detection_message.h" #include "common_video/frame_instrumentation_data.h" +#include "rtc_base/checks.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/common_video/frame_rate_estimator.cc b/common_video/frame_rate_estimator.cc index c83f268c6c..09a13bda94 100644 --- a/common_video/frame_rate_estimator.cc +++ b/common_video/frame_rate_estimator.cc @@ -10,6 +10,10 @@ #include "common_video/frame_rate_estimator.h" +#include + +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "rtc_base/time_utils.h" namespace webrtc { diff --git a/common_video/frame_rate_estimator_unittest.cc b/common_video/frame_rate_estimator_unittest.cc index d11a7d4140..f4d37cd97e 100644 --- a/common_video/frame_rate_estimator_unittest.cc +++ b/common_video/frame_rate_estimator_unittest.cc @@ -10,8 +10,9 @@ #include "common_video/frame_rate_estimator.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "system_wrappers/include/clock.h" -#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { diff --git a/common_video/framerate_controller.cc b/common_video/framerate_controller.cc index 771a369bca..5a1326d3c6 100644 --- a/common_video/framerate_controller.cc +++ b/common_video/framerate_controller.cc @@ -10,7 +10,10 @@ #include "common_video/framerate_controller.h" +#include +#include #include +#include #include "rtc_base/time_utils.h" diff --git a/common_video/framerate_controller_unittest.cc b/common_video/framerate_controller_unittest.cc index a0a323c654..4b0abdef4e 100644 --- a/common_video/framerate_controller_unittest.cc +++ b/common_video/framerate_controller_unittest.cc @@ -10,7 +10,7 @@ #include "common_video/framerate_controller.h" -#include +#include #include "rtc_base/time_utils.h" #include "test/gtest.h" diff --git a/common_video/generic_frame_descriptor/generic_frame_info.cc b/common_video/generic_frame_descriptor/generic_frame_info.cc index af66bbaf67..168304e981 100644 --- a/common_video/generic_frame_descriptor/generic_frame_info.cc +++ b/common_video/generic_frame_descriptor/generic_frame_info.cc @@ -9,9 +9,8 @@ */ #include "common_video/generic_frame_descriptor/generic_frame_info.h" -#include - -#include "rtc_base/checks.h" +#include "absl/strings/string_view.h" +#include "api/transport/rtp/dependency_descriptor.h" namespace webrtc { diff --git a/common_video/generic_frame_descriptor/generic_frame_info.h b/common_video/generic_frame_descriptor/generic_frame_info.h index 30db423e37..45037b706e 100644 --- a/common_video/generic_frame_descriptor/generic_frame_info.h +++ b/common_video/generic_frame_descriptor/generic_frame_info.h @@ -12,7 +12,7 @@ #define COMMON_VIDEO_GENERIC_FRAME_DESCRIPTOR_GENERIC_FRAME_INFO_H_ #include -#include +#include #include #include "absl/container/inlined_vector.h" diff --git a/common_video/h264/h264_bitstream_parser.cc b/common_video/h264/h264_bitstream_parser.cc index 1d2d0496a5..d6a2e48603 100644 --- a/common_video/h264/h264_bitstream_parser.cc +++ b/common_video/h264/h264_bitstream_parser.cc @@ -12,9 +12,13 @@ #include #include +#include #include +#include "api/array_view.h" #include "common_video/h264/h264_common.h" +#include "common_video/h264/pps_parser.h" +#include "common_video/h264/sps_parser.h" #include "rtc_base/bitstream_reader.h" #include "rtc_base/logging.h" diff --git a/common_video/h264/h264_bitstream_parser.h b/common_video/h264/h264_bitstream_parser.h index e308fe1c10..2dafa86185 100644 --- a/common_video/h264/h264_bitstream_parser.h +++ b/common_video/h264/h264_bitstream_parser.h @@ -15,6 +15,7 @@ #include +#include "api/array_view.h" #include "api/video_codecs/bitstream_parser.h" #include "common_video/h264/pps_parser.h" #include "common_video/h264/sps_parser.h" diff --git a/common_video/h264/h264_bitstream_parser_unittest.cc b/common_video/h264/h264_bitstream_parser_unittest.cc index 00186a6a34..233486481f 100644 --- a/common_video/h264/h264_bitstream_parser_unittest.cc +++ b/common_video/h264/h264_bitstream_parser_unittest.cc @@ -10,6 +10,9 @@ #include "common_video/h264/h264_bitstream_parser.h" +#include +#include + #include "test/gtest.h" namespace webrtc { diff --git a/common_video/h264/h264_common.cc b/common_video/h264/h264_common.cc index 5444fcd6eb..2533bab965 100644 --- a/common_video/h264/h264_common.cc +++ b/common_video/h264/h264_common.cc @@ -10,7 +10,12 @@ #include "common_video/h264/h264_common.h" +#include #include +#include + +#include "api/array_view.h" +#include "rtc_base/buffer.h" namespace webrtc { namespace H264 { diff --git a/common_video/h264/h264_common.h b/common_video/h264/h264_common.h index e197fb4407..68c9504107 100644 --- a/common_video/h264/h264_common.h +++ b/common_video/h264/h264_common.h @@ -16,6 +16,7 @@ #include +#include "api/array_view.h" #include "rtc_base/buffer.h" #include "rtc_base/system/rtc_export.h" diff --git a/common_video/h264/pps_parser.cc b/common_video/h264/pps_parser.cc index 9d9d04a2c2..64a49feda8 100644 --- a/common_video/h264/pps_parser.cc +++ b/common_video/h264/pps_parser.cc @@ -12,9 +12,11 @@ #include #include +#include #include #include "absl/numeric/bits.h" +#include "api/array_view.h" #include "common_video/h264/h264_common.h" #include "rtc_base/bitstream_reader.h" #include "rtc_base/checks.h" diff --git a/common_video/h264/pps_parser_unittest.cc b/common_video/h264/pps_parser_unittest.cc index 287909f533..e3a9c08fd8 100644 --- a/common_video/h264/pps_parser_unittest.cc +++ b/common_video/h264/pps_parser_unittest.cc @@ -10,8 +10,12 @@ #include "common_video/h264/pps_parser.h" +#include +#include +#include #include +#include "api/array_view.h" #include "common_video/h264/h264_common.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/buffer.h" diff --git a/common_video/h264/sps_parser.cc b/common_video/h264/sps_parser.cc index 197fac9573..cf99700a71 100644 --- a/common_video/h264/sps_parser.cc +++ b/common_video/h264/sps_parser.cc @@ -10,9 +10,12 @@ #include "common_video/h264/sps_parser.h" +#include #include +#include #include +#include "api/array_view.h" #include "common_video/h264/h264_common.h" #include "rtc_base/bitstream_reader.h" diff --git a/common_video/h264/sps_parser.h b/common_video/h264/sps_parser.h index a8a6675e0a..b24194c6e9 100644 --- a/common_video/h264/sps_parser.h +++ b/common_video/h264/sps_parser.h @@ -11,8 +11,10 @@ #ifndef COMMON_VIDEO_H264_SPS_PARSER_H_ #define COMMON_VIDEO_H264_SPS_PARSER_H_ +#include #include +#include "api/array_view.h" #include "rtc_base/bitstream_reader.h" #include "rtc_base/system/rtc_export.h" diff --git a/common_video/h264/sps_parser_unittest.cc b/common_video/h264/sps_parser_unittest.cc index 0f20eb6a31..d2396d016a 100644 --- a/common_video/h264/sps_parser_unittest.cc +++ b/common_video/h264/sps_parser_unittest.cc @@ -10,8 +10,12 @@ #include "common_video/h264/sps_parser.h" +#include +#include +#include + +#include "api/array_view.h" #include "common_video/h264/h264_common.h" -#include "rtc_base/arraysize.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/buffer.h" #include "test/gtest.h" diff --git a/common_video/h264/sps_vui_rewriter.cc b/common_video/h264/sps_vui_rewriter.cc index b102cf4c78..497f0932f6 100644 --- a/common_video/h264/sps_vui_rewriter.cc +++ b/common_video/h264/sps_vui_rewriter.cc @@ -15,13 +15,16 @@ #include #include +#include #include +#include "api/array_view.h" #include "api/video/color_space.h" #include "common_video/h264/h264_common.h" #include "common_video/h264/sps_parser.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/bitstream_reader.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "system_wrappers/include/metrics.h" @@ -85,7 +88,7 @@ uint32_t CopyBits(int bits, bool CopyAndRewriteVui(const SpsParser::SpsState& sps, BitstreamReader& source, BitBufferWriter& destination, - const webrtc::ColorSpace* color_space, + const ColorSpace* color_space, SpsVuiRewriter::ParseResult& out_vui_rewritten); void CopyHrdParameters(BitstreamReader& source, BitBufferWriter& destination); @@ -134,7 +137,7 @@ void SpsVuiRewriter::UpdateStats(ParseResult result, Direction direction) { SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps( ArrayView buffer, std::optional* sps, - const webrtc::ColorSpace* color_space, + const ColorSpace* color_space, Buffer* destination) { // Create temporary RBSP decoded buffer of the payload (exlcuding the // leading nalu type header byte (the SpsParser uses only the payload). @@ -210,7 +213,7 @@ SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps( SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps( ArrayView buffer, std::optional* sps, - const webrtc::ColorSpace* color_space, + const ColorSpace* color_space, Buffer* destination, Direction direction) { ParseResult result = @@ -221,7 +224,7 @@ SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps( Buffer SpsVuiRewriter::ParseOutgoingBitstreamAndRewrite( ArrayView buffer, - const webrtc::ColorSpace* color_space) { + const ColorSpace* color_space) { std::vector nalus = H264::FindNaluIndices(buffer); // Allocate some extra space for potentially adding a missing VUI. @@ -281,7 +284,7 @@ namespace { bool CopyAndRewriteVui(const SpsParser::SpsState& sps, BitstreamReader& source, BitBufferWriter& destination, - const webrtc::ColorSpace* color_space, + const ColorSpace* color_space, SpsVuiRewriter::ParseResult& out_vui_rewritten) { out_vui_rewritten = SpsVuiRewriter::ParseResult::kVuiOk; diff --git a/common_video/h264/sps_vui_rewriter.h b/common_video/h264/sps_vui_rewriter.h index 8cdc04e5ef..665142f3a0 100644 --- a/common_video/h264/sps_vui_rewriter.h +++ b/common_video/h264/sps_vui_rewriter.h @@ -17,6 +17,7 @@ #include +#include "api/array_view.h" #include "api/video/color_space.h" #include "common_video/h264/sps_parser.h" #include "rtc_base/buffer.h" diff --git a/common_video/h264/sps_vui_rewriter_unittest.cc b/common_video/h264/sps_vui_rewriter_unittest.cc index 581b9ef276..b9c6c86bf5 100644 --- a/common_video/h264/sps_vui_rewriter_unittest.cc +++ b/common_video/h264/sps_vui_rewriter_unittest.cc @@ -10,11 +10,15 @@ #include "common_video/h264/sps_vui_rewriter.h" +#include #include -#include +#include +#include +#include "api/array_view.h" #include "api/video/color_space.h" #include "common_video/h264/h264_common.h" +#include "common_video/h264/sps_parser.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/buffer.h" #include "rtc_base/logging.h" @@ -150,37 +154,37 @@ static const VuiHeader kVuiLimitedRangeBt709Color = { /* transfer_characteristics= */ 1, /* matrix_coefficients= */ 1}; -static const webrtc::ColorSpace kColorSpaceH264Default( +static const ColorSpace kColorSpaceH264Default( ColorSpace::PrimaryID::kUnspecified, ColorSpace::TransferID::kUnspecified, ColorSpace::MatrixID::kUnspecified, ColorSpace::RangeID::kLimited); -static const webrtc::ColorSpace kColorSpacePrimariesBt709( +static const ColorSpace kColorSpacePrimariesBt709( ColorSpace::PrimaryID::kBT709, ColorSpace::TransferID::kUnspecified, ColorSpace::MatrixID::kUnspecified, ColorSpace::RangeID::kLimited); -static const webrtc::ColorSpace kColorSpaceTransferBt709( +static const ColorSpace kColorSpaceTransferBt709( ColorSpace::PrimaryID::kUnspecified, ColorSpace::TransferID::kBT709, ColorSpace::MatrixID::kUnspecified, ColorSpace::RangeID::kLimited); -static const webrtc::ColorSpace kColorSpaceMatrixBt709( +static const ColorSpace kColorSpaceMatrixBt709( ColorSpace::PrimaryID::kUnspecified, ColorSpace::TransferID::kUnspecified, ColorSpace::MatrixID::kBT709, ColorSpace::RangeID::kLimited); -static const webrtc::ColorSpace kColorSpaceFullRange( +static const ColorSpace kColorSpaceFullRange( ColorSpace::PrimaryID::kBT709, ColorSpace::TransferID::kUnspecified, ColorSpace::MatrixID::kUnspecified, ColorSpace::RangeID::kFull); -static const webrtc::ColorSpace kColorSpaceBt709LimitedRange( +static const ColorSpace kColorSpaceBt709LimitedRange( ColorSpace::PrimaryID::kBT709, ColorSpace::TransferID::kBT709, ColorSpace::MatrixID::kBT709, diff --git a/common_video/h265/h265_bitstream_parser.h b/common_video/h265/h265_bitstream_parser.h index 7c337f8be4..20eb8dfb74 100644 --- a/common_video/h265/h265_bitstream_parser.h +++ b/common_video/h265/h265_bitstream_parser.h @@ -15,8 +15,8 @@ #include #include -#include +#include "api/array_view.h" #include "api/video_codecs/bitstream_parser.h" #include "common_video/h265/h265_pps_parser.h" #include "common_video/h265/h265_sps_parser.h" diff --git a/common_video/h265/h265_bitstream_parser_unittest.cc b/common_video/h265/h265_bitstream_parser_unittest.cc index e359c5c2ae..754300b8c7 100644 --- a/common_video/h265/h265_bitstream_parser_unittest.cc +++ b/common_video/h265/h265_bitstream_parser_unittest.cc @@ -10,6 +10,10 @@ #include "common_video/h265/h265_bitstream_parser.h" +#include +#include + +#include "api/array_view.h" #include "common_video/h265/h265_common.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/common_video/h265/h265_common.cc b/common_video/h265/h265_common.cc index cb5557dc0f..2705d52773 100644 --- a/common_video/h265/h265_common.cc +++ b/common_video/h265/h265_common.cc @@ -10,7 +10,13 @@ #include "common_video/h265/h265_common.h" +#include +#include + +#include "api/array_view.h" #include "common_video/h264/h264_common.h" +#include "common_video/h265/h265_inline.h" +#include "rtc_base/buffer.h" namespace webrtc { namespace H265 { diff --git a/common_video/h265/h265_common.h b/common_video/h265/h265_common.h index 7bba7f84a7..9ce9fbee58 100644 --- a/common_video/h265/h265_common.h +++ b/common_video/h265/h265_common.h @@ -11,10 +11,11 @@ #ifndef COMMON_VIDEO_H265_H265_COMMON_H_ #define COMMON_VIDEO_H265_H265_COMMON_H_ -#include +#include +#include #include -#include "common_video/h265/h265_inline.h" +#include "api/array_view.h" #include "rtc_base/buffer.h" #include "rtc_base/system/rtc_export.h" diff --git a/common_video/h265/h265_pps_parser.cc b/common_video/h265/h265_pps_parser.cc index 52c1026f1e..c94e362ec9 100644 --- a/common_video/h265/h265_pps_parser.cc +++ b/common_video/h265/h265_pps_parser.cc @@ -10,13 +10,15 @@ #include "common_video/h265/h265_pps_parser.h" -#include +#include #include #include +#include "api/array_view.h" #include "common_video/h265/h265_common.h" -#include "rtc_base/bit_buffer.h" +#include "common_video/h265/h265_sps_parser.h" #include "rtc_base/bitstream_reader.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #define IN_RANGE_OR_RETURN_NULL(val, min, max) \ diff --git a/common_video/h265/h265_pps_parser.h b/common_video/h265/h265_pps_parser.h index ab4fd9a481..2cb3f67dab 100644 --- a/common_video/h265/h265_pps_parser.h +++ b/common_video/h265/h265_pps_parser.h @@ -11,6 +11,8 @@ #ifndef COMMON_VIDEO_H265_H265_PPS_PARSER_H_ #define COMMON_VIDEO_H265_H265_PPS_PARSER_H_ +#include +#include #include #include "api/array_view.h" diff --git a/common_video/h265/h265_pps_parser_unittest.cc b/common_video/h265/h265_pps_parser_unittest.cc index ff0058b2cf..688e9e98d7 100644 --- a/common_video/h265/h265_pps_parser_unittest.cc +++ b/common_video/h265/h265_pps_parser_unittest.cc @@ -11,12 +11,15 @@ #include "common_video/h265/h265_pps_parser.h" #include +#include +#include +#include +#include "api/array_view.h" #include "common_video/h265/h265_common.h" -#include "rtc_base/arraysize.h" +#include "common_video/h265/h265_sps_parser.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/buffer.h" -#include "rtc_base/checks.h" #include "test/gtest.h" namespace webrtc { diff --git a/common_video/h265/h265_sps_parser.h b/common_video/h265/h265_sps_parser.h index 7830477462..1bccf6adcc 100644 --- a/common_video/h265/h265_sps_parser.h +++ b/common_video/h265/h265_sps_parser.h @@ -11,6 +11,8 @@ #ifndef COMMON_VIDEO_H265_H265_SPS_PARSER_H_ #define COMMON_VIDEO_H265_H265_SPS_PARSER_H_ +#include +#include #include #include diff --git a/common_video/h265/h265_sps_parser_unittest.cc b/common_video/h265/h265_sps_parser_unittest.cc index c51b7ab1c2..1d3e1b2859 100644 --- a/common_video/h265/h265_sps_parser_unittest.cc +++ b/common_video/h265/h265_sps_parser_unittest.cc @@ -10,8 +10,13 @@ #include "common_video/h265/h265_sps_parser.h" +#include +#include +#include +#include + +#include "api/array_view.h" #include "common_video/h265/h265_common.h" -#include "rtc_base/arraysize.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/buffer.h" #include "test/gtest.h" diff --git a/common_video/h265/h265_vps_parser.cc b/common_video/h265/h265_vps_parser.cc index 5b3fc6b12f..8ebe5f96a1 100644 --- a/common_video/h265/h265_vps_parser.cc +++ b/common_video/h265/h265_vps_parser.cc @@ -10,10 +10,12 @@ #include "common_video/h265/h265_vps_parser.h" +#include +#include + +#include "api/array_view.h" #include "common_video/h265/h265_common.h" -#include "rtc_base/bit_buffer.h" #include "rtc_base/bitstream_reader.h" -#include "rtc_base/logging.h" namespace webrtc { diff --git a/common_video/h265/h265_vps_parser.h b/common_video/h265/h265_vps_parser.h index 619ae2e211..e890e4e64f 100644 --- a/common_video/h265/h265_vps_parser.h +++ b/common_video/h265/h265_vps_parser.h @@ -11,6 +11,8 @@ #ifndef COMMON_VIDEO_H265_H265_VPS_PARSER_H_ #define COMMON_VIDEO_H265_H265_VPS_PARSER_H_ +#include +#include #include #include "api/array_view.h" diff --git a/common_video/h265/h265_vps_parser_unittest.cc b/common_video/h265/h265_vps_parser_unittest.cc index fd2e8a8f52..740d676035 100644 --- a/common_video/h265/h265_vps_parser_unittest.cc +++ b/common_video/h265/h265_vps_parser_unittest.cc @@ -10,10 +10,9 @@ #include "common_video/h265/h265_vps_parser.h" -#include "common_video/h265/h265_common.h" -#include "rtc_base/arraysize.h" -#include "rtc_base/bit_buffer.h" -#include "rtc_base/buffer.h" +#include +#include + #include "test/gtest.h" namespace webrtc { diff --git a/common_video/include/video_frame_buffer_pool.h b/common_video/include/video_frame_buffer_pool.h index 2eabe910ea..77df050686 100644 --- a/common_video/include/video_frame_buffer_pool.h +++ b/common_video/include/video_frame_buffer_pool.h @@ -23,6 +23,7 @@ #include "api/video/i422_buffer.h" #include "api/video/i444_buffer.h" #include "api/video/nv12_buffer.h" +#include "api/video/video_frame_buffer.h" #include "rtc_base/race_checker.h" namespace webrtc { diff --git a/common_video/libyuv/libyuv_unittest.cc b/common_video/libyuv/libyuv_unittest.cc index fbaf67cad4..375eb4a3fd 100644 --- a/common_video/libyuv/libyuv_unittest.cc +++ b/common_video/libyuv/libyuv_unittest.cc @@ -8,13 +8,17 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "third_party/libyuv/include/libyuv.h" - #include #include +#include +#include +#include #include +#include +#include +#include "api/scoped_refptr.h" #include "api/video/i010_buffer.h" #include "api/video/i210_buffer.h" #include "api/video/i410_buffer.h" @@ -23,12 +27,15 @@ #include "api/video/i444_buffer.h" #include "api/video/nv12_buffer.h" #include "api/video/video_frame.h" +#include "api/video/video_frame_buffer.h" +#include "api/video/video_rotation.h" #include "common_video/libyuv/include/webrtc_libyuv.h" -#include "rtc_base/logging.h" #include "test/frame_utils.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" +#include "third_party/libyuv/include/libyuv/convert.h" +#include "third_party/libyuv/include/libyuv/rotate.h" namespace webrtc { @@ -88,7 +95,7 @@ class TestLibYuv : public ::testing::Test { }; TestLibYuv::TestLibYuv() - : source_file_(NULL), + : source_file_(nullptr), orig_frame_(), width_(352), height_(288), @@ -97,37 +104,35 @@ TestLibYuv::TestLibYuv() frame_length_(CalcBufferSize(VideoType::kI420, 352, 288)) {} void TestLibYuv::SetUp() { - const std::string input_file_name = - webrtc::test::ResourcePath("foreman_cif", "yuv"); + const std::string input_file_name = test::ResourcePath("foreman_cif", "yuv"); source_file_ = fopen(input_file_name.c_str(), "rb"); - ASSERT_TRUE(source_file_ != NULL) + ASSERT_TRUE(source_file_ != nullptr) << "Cannot read file: " << input_file_name << "\n"; scoped_refptr buffer( test::ReadI420Buffer(width_, height_, source_file_)); - orig_frame_ = - std::make_unique(VideoFrame::Builder() - .set_video_frame_buffer(buffer) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(0) - .build()); + orig_frame_ = std::make_unique(VideoFrame::Builder() + .set_video_frame_buffer(buffer) + .set_rotation(kVideoRotation_0) + .set_timestamp_us(0) + .build()); } void TestLibYuv::TearDown() { - if (source_file_ != NULL) { + if (source_file_ != nullptr) { ASSERT_EQ(0, fclose(source_file_)); } - source_file_ = NULL; + source_file_ = nullptr; } TEST_F(TestLibYuv, ConvertTest) { // Reading YUV frame - testing on the first frame of the foreman sequence int j = 0; std::string output_file_name = - webrtc::test::OutputPath() + "LibYuvTest_conversion.yuv"; + test::OutputPath() + "LibYuvTest_conversion.yuv"; FILE* output_file = fopen(output_file_name.c_str(), "wb"); - ASSERT_TRUE(output_file != NULL); + ASSERT_TRUE(output_file != nullptr); double psnr = 0.0; @@ -291,9 +296,9 @@ TEST_F(TestLibYuv, ConvertTest) { TEST_F(TestLibYuv, ConvertAlignedFrame) { // Reading YUV frame - testing on the first frame of the foreman sequence std::string output_file_name = - webrtc::test::OutputPath() + "LibYuvTest_conversion.yuv"; + test::OutputPath() + "LibYuvTest_conversion.yuv"; FILE* output_file = fopen(output_file_name.c_str(), "wb"); - ASSERT_TRUE(output_file != NULL); + ASSERT_TRUE(output_file != nullptr); double psnr = 0.0; diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc index 8524bcbb11..916acafe4f 100644 --- a/common_video/libyuv/webrtc_libyuv.cc +++ b/common_video/libyuv/webrtc_libyuv.cc @@ -10,12 +10,21 @@ #include "common_video/libyuv/include/webrtc_libyuv.h" +#include #include +#include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_buffer.h" #include "common_video/include/video_frame_buffer.h" #include "rtc_base/checks.h" -#include "third_party/libyuv/include/libyuv.h" +#include "third_party/libyuv/include/libyuv/compare.h" +#include "third_party/libyuv/include/libyuv/convert.h" +#include "third_party/libyuv/include/libyuv/convert_from.h" +#include "third_party/libyuv/include/libyuv/planar_functions.h" +#include "third_party/libyuv/include/libyuv/scale.h" +#include "third_party/libyuv/include/libyuv/video_common.h" namespace webrtc { diff --git a/common_video/test/utilities.cc b/common_video/test/utilities.cc index c2a3266dc1..e4bfe6e5e9 100644 --- a/common_video/test/utilities.cc +++ b/common_video/test/utilities.cc @@ -9,7 +9,11 @@ */ #include "common_video/test/utilities.h" -#include +#include + +#include "api/rtp_packet_infos.h" +#include "api/video/color_space.h" +#include "api/video/hdr_metadata.h" namespace webrtc { diff --git a/common_video/test/utilities.h b/common_video/test/utilities.h index 7e15cf947c..eb7cddf99a 100644 --- a/common_video/test/utilities.h +++ b/common_video/test/utilities.h @@ -11,10 +11,11 @@ #ifndef COMMON_VIDEO_TEST_UTILITIES_H_ #define COMMON_VIDEO_TEST_UTILITIES_H_ -#include +#include #include "api/rtp_packet_infos.h" #include "api/video/color_space.h" +#include "api/video/hdr_metadata.h" namespace webrtc { diff --git a/common_video/video_frame_buffer.cc b/common_video/video_frame_buffer.cc index e88cd0f3f0..0b043b6e03 100644 --- a/common_video/video_frame_buffer.cc +++ b/common_video/video_frame_buffer.cc @@ -9,9 +9,15 @@ */ #include "common_video/include/video_frame_buffer.h" +#include +#include + #include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/video_frame_buffer.h" #include "rtc_base/checks.h" +#include "rtc_base/ref_counted_object.h" #include "third_party/libyuv/include/libyuv/convert.h" namespace webrtc { diff --git a/common_video/video_frame_buffer_pool.cc b/common_video/video_frame_buffer_pool.cc index d7349e1924..07d3fd00c8 100644 --- a/common_video/video_frame_buffer_pool.cc +++ b/common_video/video_frame_buffer_pool.cc @@ -10,10 +10,22 @@ #include "common_video/include/video_frame_buffer_pool.h" +#include #include #include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/video/i010_buffer.h" +#include "api/video/i210_buffer.h" +#include "api/video/i410_buffer.h" +#include "api/video/i420_buffer.h" +#include "api/video/i422_buffer.h" +#include "api/video/i444_buffer.h" +#include "api/video/nv12_buffer.h" +#include "api/video/video_frame_buffer.h" #include "rtc_base/checks.h" +#include "rtc_base/race_checker.h" +#include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/common_video/video_frame_buffer_pool_unittest.cc b/common_video/video_frame_buffer_pool_unittest.cc index 0d8a37bbd2..6c3feb85a3 100644 --- a/common_video/video_frame_buffer_pool_unittest.cc +++ b/common_video/video_frame_buffer_pool_unittest.cc @@ -15,7 +15,6 @@ #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" -#include "api/video/video_frame_buffer.h" #include "test/gtest.h" namespace webrtc { diff --git a/common_video/video_frame_unittest.cc b/common_video/video_frame_unittest.cc index c2611aa3ff..a10f322805 100644 --- a/common_video/video_frame_unittest.cc +++ b/common_video/video_frame_unittest.cc @@ -13,6 +13,12 @@ #include #include +#include +#include +#include +#include + +#include "api/scoped_refptr.h" #include "api/video/i010_buffer.h" #include "api/video/i210_buffer.h" #include "api/video/i410_buffer.h" @@ -20,7 +26,8 @@ #include "api/video/i422_buffer.h" #include "api/video/i444_buffer.h" #include "api/video/nv12_buffer.h" -#include "rtc_base/time_utils.h" +#include "api/video/video_frame_buffer.h" +#include "api/video/video_rotation.h" #include "test/fake_texture_frame.h" #include "test/frame_utils.h" #include "test/gtest.h" @@ -146,7 +153,7 @@ void CheckCrop(const T& frame, template void CheckRotate(int width, int height, - webrtc::VideoRotation rotation, + VideoRotation rotation, const T& rotated) { int rotated_width = width; int rotated_height = height; @@ -204,7 +211,7 @@ TEST(TestVideoFrame, WidthHeightValues) { VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(10, 10, 10, 14, 90)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_ms(789) .build(); const int valid_value = 10; @@ -251,10 +258,8 @@ TEST(TestVideoFrame, ShallowCopy) { VideoFrame frame2(frame1); EXPECT_EQ(frame1.video_frame_buffer(), frame2.video_frame_buffer()); - const webrtc::I420BufferInterface* yuv1 = - frame1.video_frame_buffer()->GetI420(); - const webrtc::I420BufferInterface* yuv2 = - frame2.video_frame_buffer()->GetI420(); + const I420BufferInterface* yuv1 = frame1.video_frame_buffer()->GetI420(); + const I420BufferInterface* yuv2 = frame2.video_frame_buffer()->GetI420(); EXPECT_EQ(yuv1->DataY(), yuv2->DataY()); EXPECT_EQ(yuv1->DataU(), yuv2->DataU()); EXPECT_EQ(yuv1->DataV(), yuv2->DataV()); @@ -276,8 +281,8 @@ TEST(TestVideoFrame, ShallowCopy) { } TEST(TestVideoFrame, TextureInitialValues) { - VideoFrame frame = test::FakeNativeBuffer::CreateFrame( - 640, 480, 100, 10, webrtc::kVideoRotation_0); + VideoFrame frame = + test::FakeNativeBuffer::CreateFrame(640, 480, 100, 10, kVideoRotation_0); EXPECT_EQ(640, frame.width()); EXPECT_EQ(480, frame.height()); EXPECT_EQ(100u, frame.rtp_timestamp()); @@ -425,7 +430,7 @@ class TestPlanarYuvBufferRotate : public ::testing::Test { TYPED_TEST_SUITE_P(TestPlanarYuvBufferRotate); TYPED_TEST_P(TestPlanarYuvBufferRotate, Rotates) { - for (const webrtc::VideoRotation& rotation : this->RotationParams) { + for (const VideoRotation& rotation : this->RotationParams) { scoped_refptr buffer = CreateGradient(640, 480); scoped_refptr rotated_buffer = TypeParam::Rotate(*buffer, rotation); diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 69022724e4..4508146c93 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -684,8 +684,8 @@ if (is_linux || is_chromeos || is_win) { "../api:async_dns_resolver", "../api:audio_options_api", "../api:create_frame_generator", - "../api:create_peerconnection_factory", "../api:enable_media", + "../api:field_trials", "../api:libjingle_peerconnection_api", "../api:make_ref_counted", "../api:media_stream_interface", @@ -696,8 +696,9 @@ if (is_linux || is_chromeos || is_win) { "../api/audio:audio_mixer_api", "../api/audio:audio_processing", "../api/audio_codecs:audio_codecs_api", + "../api/environment", + "../api/environment:environment_factory", "../api/task_queue", - "../api/task_queue:default_task_queue_factory", "../api/task_queue:pending_task_safety_flag", "../api/units:time_delta", "../api/video:video_frame", @@ -712,7 +713,6 @@ if (is_linux || is_chromeos || is_win) { "../rtc_base:buffer", "../rtc_base:checks", "../rtc_base:logging", - "../rtc_base:macromagic", "../rtc_base:net_helpers", "../rtc_base:refcount", "../rtc_base:rtc_certificate_generator", @@ -721,12 +721,11 @@ if (is_linux || is_chromeos || is_win) { "../rtc_base:threading", "../rtc_base/third_party/sigslot", "../system_wrappers", - "../system_wrappers:field_trial", - "../test:field_trial", "../test:frame_generator_capturer", "../test:platform_video_capturer", "../test:rtp_test_utils", "../test:test_video_capturer", + "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/memory", "//third_party/jsoncpp", ] @@ -796,19 +795,17 @@ if (is_linux || is_chromeos || is_win) { "peerconnection/server/main.cc", "peerconnection/server/peer_channel.cc", "peerconnection/server/peer_channel.h", - "peerconnection/server/utils.cc", - "peerconnection/server/utils.h", ] deps = [ "../rtc_base:checks", "../rtc_base:ip_address", "../rtc_base:net_helpers", "../rtc_base:stringutils", - "../system_wrappers:field_trial", - "../test:field_trial", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/flags:usage", + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/strings:string_view", ] } rtc_executable("turnserver") { diff --git a/examples/androidnativeapi/BUILD.gn b/examples/androidnativeapi/BUILD.gn index 65ab875893..7211192206 100644 --- a/examples/androidnativeapi/BUILD.gn +++ b/examples/androidnativeapi/BUILD.gn @@ -48,10 +48,17 @@ if (is_android) { deps = [ ":generated_jni", "../../api:enable_media_with_defaults", + "../../api:make_ref_counted", + "../../api:media_stream_interface", + "../../api:rtc_error", "../../api:scoped_refptr", "../../api:sequence_checker", + "../../api/video:video_frame", + "../../rtc_base:checks", + "../../rtc_base:logging", "../../rtc_base:ssl", "../../rtc_base:ssl_adapter", + "../../rtc_base:threading", "../../rtc_base/synchronization:mutex", "//api:libjingle_peerconnection_api", "//api/rtc_event_log:rtc_event_log_factory", diff --git a/examples/androidnativeapi/jni/android_call_client.cc b/examples/androidnativeapi/jni/android_call_client.cc index b61af374d4..33ccc2e5b1 100644 --- a/examples/androidnativeapi/jni/android_call_client.cc +++ b/examples/androidnativeapi/jni/android_call_client.cc @@ -10,18 +10,35 @@ #include "examples/androidnativeapi/jni/android_call_client.h" +#include + #include +#include #include +#include "api/data_channel_interface.h" #include "api/enable_media_with_defaults.h" +#include "api/jsep.h" +#include "api/make_ref_counted.h" +#include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" +#include "api/rtc_error.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/task_queue/default_task_queue_factory.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" +#include "api/set_remote_description_observer_interface.h" +#include "api/video/video_source_interface.h" #include "examples/androidnativeapi/generated_jni/CallClient_jni.h" #include "media/engine/internal_decoder_factory.h" #include "media/engine/internal_encoder_factory.h" -#include "media/engine/webrtc_media_engine.h" +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" +#include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" +#include "sdk/android/native_api/video/video_source.h" #include "sdk/android/native_api/video/wrapper.h" namespace webrtc_examples { @@ -153,7 +170,6 @@ void AndroidCallClient::CreatePeerConnectionFactory() { pcf_deps.network_thread = network_thread_.get(); pcf_deps.worker_thread = worker_thread_.get(); pcf_deps.signaling_thread = signaling_thread_.get(); - pcf_deps.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); pcf_deps.event_log_factory = std::make_unique(); pcf_deps.video_encoder_factory = diff --git a/examples/androidvoip/BUILD.gn b/examples/androidvoip/BUILD.gn index 05bccd7f77..4c8af525ec 100644 --- a/examples/androidvoip/BUILD.gn +++ b/examples/androidvoip/BUILD.gn @@ -57,6 +57,7 @@ if (is_android) { deps = [ ":generated_jni", "../../api/audio:builtin_audio_processing_builder", + "../../api/environment:environment_factory", "../../rtc_base:async_packet_socket", "../../rtc_base:async_udp_socket", "../../rtc_base:logging", @@ -69,7 +70,6 @@ if (is_android) { "//api/audio_codecs:audio_codecs_api", "//api/audio_codecs:builtin_audio_decoder_factory", "//api/audio_codecs:builtin_audio_encoder_factory", - "//api/task_queue:default_task_queue_factory", "//api/units:time_delta", "//api/voip:voip_api", "//api/voip:voip_engine_factory", diff --git a/examples/androidvoip/jni/android_voip_client.cc b/examples/androidvoip/jni/android_voip_client.cc index f15355d748..ceef8e925b 100644 --- a/examples/androidvoip/jni/android_voip_client.cc +++ b/examples/androidvoip/jni/android_voip_client.cc @@ -23,7 +23,7 @@ #include "api/audio/builtin_audio_processing_builder.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" -#include "api/task_queue/default_task_queue_factory.h" +#include "api/environment/environment_factory.h" #include "api/units/time_delta.h" #include "api/voip/voip_base.h" #include "api/voip/voip_codec.h" @@ -127,9 +127,9 @@ void AndroidVoipClient::Init( webrtc::VoipEngineConfig config; config.encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); config.decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); - config.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); - config.audio_device_module = - webrtc::CreateJavaAudioDeviceModule(env, application_context.obj()); + config.env = webrtc::CreateEnvironment(); + config.audio_device_module = webrtc::CreateJavaAudioDeviceModule( + env, *config.env, application_context.obj()); config.audio_processing_builder = std::make_unique(); @@ -479,7 +479,8 @@ void AndroidVoipClient::SendRtcpPacket( } } -bool AndroidVoipClient::SendRtcp(webrtc::ArrayView packet) { +bool AndroidVoipClient::SendRtcp(webrtc::ArrayView packet, + const webrtc::PacketOptions& options) { std::vector packet_copy(packet.begin(), packet.end()); voip_thread_->PostTask([this, packet_copy = std::move(packet_copy)] { SendRtcpPacket(packet_copy); diff --git a/examples/androidvoip/jni/android_voip_client.h b/examples/androidvoip/jni/android_voip_client.h index 29a0fc82e5..cb8b927978 100644 --- a/examples/androidvoip/jni/android_voip_client.h +++ b/examples/androidvoip/jni/android_voip_client.h @@ -120,7 +120,8 @@ class AndroidVoipClient : public webrtc::Transport { // Implementation for Transport. bool SendRtp(webrtc::ArrayView packet, const webrtc::PacketOptions& options) override; - bool SendRtcp(webrtc::ArrayView packet) override; + bool SendRtcp(webrtc::ArrayView packet, + const webrtc::PacketOptions& options) override; void OnSignalReadRTPPacket(webrtc::AsyncPacketSocket* socket, const webrtc::ReceivedIpPacket& packet); diff --git a/examples/objc/AppRTCMobile/ARDAppClient.m b/examples/objc/AppRTCMobile/ARDAppClient.m index 72961abad9..614037e6f7 100644 --- a/examples/objc/AppRTCMobile/ARDAppClient.m +++ b/examples/objc/AppRTCMobile/ARDAppClient.m @@ -200,9 +200,9 @@ - (void)setShouldGetStats:(BOOL)shouldGetStats { statisticsWithCompletionHandler:^( RTC_OBJC_TYPE(RTCStatisticsReport) * stats) { dispatch_async(dispatch_get_main_queue(), ^{ - ARDAppClient *strongSelf = weakSelf; - [strongSelf.delegate appClient:strongSelf - didGetStats:stats]; + ARDAppClient *strongerSelf = weakSelf; + [strongerSelf.delegate appClient:strongerSelf + didGetStats:stats]; }); }]; }]; @@ -497,10 +497,10 @@ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection __weak ARDAppClient *weakSelf = self; [self.peerConnection setLocalDescription:sdp - completionHandler:^(NSError *error) { + completionHandler:^(NSError *sldError) { ARDAppClient *strongSelf = weakSelf; [strongSelf peerConnection:strongSelf.peerConnection - didSetSessionDescriptionWithError:error]; + didSetSessionDescriptionWithError:sldError]; }]; ARDSessionDescriptionMessage *message = [[ARDSessionDescriptionMessage alloc] initWithDescription:sdp]; @@ -534,11 +534,11 @@ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection [self.peerConnection answerForConstraints:constraints completionHandler:^(RTC_OBJC_TYPE(RTCSessionDescription) * sdp, - NSError * error) { + NSError * answerError) { ARDAppClient *strongSelf = weakSelf; [strongSelf peerConnection:strongSelf.peerConnection didCreateSessionDescription:sdp - error:error]; + error:answerError]; }]; } }); @@ -768,9 +768,9 @@ - (void)createMediaSenders { [self defaultMediaAudioConstraints]; RTC_OBJC_TYPE(RTCAudioSource) *source = [_factory audioSourceWithConstraints:constraints]; - RTC_OBJC_TYPE(RTCAudioTrack) *track = + RTC_OBJC_TYPE(RTCAudioTrack) *audioTrack = [_factory audioTrackWithSource:source trackId:kARDAudioTrackId]; - [_peerConnection addTrack:track streamIds:@[ kARDMediaStreamId ]]; + [_peerConnection addTrack:audioTrack streamIds:@[ kARDMediaStreamId ]]; _localVideoTrack = [self createLocalVideoTrack]; if (_localVideoTrack) { [_peerConnection addTrack:_localVideoTrack @@ -780,9 +780,9 @@ - (void)createMediaSenders { // transceiver already has an RTC_OBJC_TYPE(RTCRtpReceiver) with a track. // The track will automatically get unmuted and produce frames once RTP is // received. - RTC_OBJC_TYPE(RTCVideoTrack) *track = (RTC_OBJC_TYPE(RTCVideoTrack) *)( + RTC_OBJC_TYPE(RTCVideoTrack) *videoTrack = (RTC_OBJC_TYPE(RTCVideoTrack) *)( [self videoTransceiver].receiver.track); - [_delegate appClient:self didReceiveRemoteVideoTrack:track]; + [_delegate appClient:self didReceiveRemoteVideoTrack:videoTrack]; } } diff --git a/examples/objc/AppRTCMobile/ARDAppEngineClient.m b/examples/objc/AppRTCMobile/ARDAppEngineClient.m index b7f8dcf784..e65b39a718 100644 --- a/examples/objc/AppRTCMobile/ARDAppEngineClient.m +++ b/examples/objc/AppRTCMobile/ARDAppEngineClient.m @@ -66,8 +66,8 @@ - (void)joinRoomWithRoomId:(NSString *)roomId [ARDJoinResponse responseFromJSONData:data]; if (!joinResponse) { if (completionHandler) { - NSError *error = [[self class] badResponseError]; - completionHandler(nil, error); + NSError *err = [[self class] badResponseError]; + completionHandler(nil, err); } return; } @@ -86,37 +86,37 @@ - (void)sendMessage:(ARDSignalingMessage *)message NSParameterAssert(roomId.length); NSParameterAssert(clientId.length); - NSData *data = [message JSONData]; + NSData *messageData = [message JSONData]; NSString *urlString = [NSString stringWithFormat:kARDRoomServerMessageFormat, roomId, clientId]; NSURL *url = [NSURL URLWithString:urlString]; RTCLog(@"C->RS POST: %@", message); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; request.HTTPMethod = @"POST"; - request.HTTPBody = data; - [NSURLConnection - sendAsyncRequest:request - completionHandler:^( - NSURLResponse *response __unused, NSData *data, NSError *error) { - if (error) { - if (completionHandler) { - completionHandler(nil, error); - } - return; - } - ARDMessageResponse *messageResponse = - [ARDMessageResponse responseFromJSONData:data]; - if (!messageResponse) { - if (completionHandler) { - NSError *error = [[self class] badResponseError]; - completionHandler(nil, error); - } - return; - } - if (completionHandler) { - completionHandler(messageResponse, nil); - } - }]; + request.HTTPBody = messageData; + [NSURLConnection sendAsyncRequest:request + completionHandler:^(NSURLResponse *response __unused, + NSData *data, + NSError *responseError) { + if (responseError) { + if (completionHandler) { + completionHandler(nil, responseError); + } + return; + } + ARDMessageResponse *messageResponse = + [ARDMessageResponse responseFromJSONData:data]; + if (!messageResponse) { + if (completionHandler) { + NSError *err = [[self class] badResponseError]; + completionHandler(nil, err); + } + return; + } + if (completionHandler) { + completionHandler(messageResponse, nil); + } + }]; } - (void)leaveRoomWithRoomId:(NSString *)roomId diff --git a/examples/objc/AppRTCMobile/ARDWebSocketChannel.m b/examples/objc/AppRTCMobile/ARDWebSocketChannel.m index 37260d63ba..e21b30deed 100644 --- a/examples/objc/AppRTCMobile/ARDWebSocketChannel.m +++ b/examples/objc/AppRTCMobile/ARDWebSocketChannel.m @@ -80,14 +80,10 @@ - (void)sendMessage:(ARDSignalingMessage *)message { if (_state == kARDSignalingChannelStateRegistered) { NSString *payload = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - NSDictionary *message = @{ - @"cmd" : @"send", - @"msg" : payload, - }; - NSData *messageJSONObject = - [NSJSONSerialization dataWithJSONObject:message - options:NSJSONWritingPrettyPrinted - error:nil]; + NSData *messageJSONObject = [NSJSONSerialization + dataWithJSONObject:@{@"cmd" : @"send", @"msg" : payload} + options:NSJSONWritingPrettyPrinted + error:nil]; NSString *messageString = [[NSString alloc] initWithData:messageJSONObject encoding:NSUTF8StringEncoding]; diff --git a/examples/objc/AppRTCMobile/common/ARDUtilities.m b/examples/objc/AppRTCMobile/common/ARDUtilities.m index 9ac5508a51..539445ead7 100644 --- a/examples/objc/AppRTCMobile/common/ARDUtilities.m +++ b/examples/objc/AppRTCMobile/common/ARDUtilities.m @@ -70,28 +70,28 @@ + (void)sendAsyncPostToURL:(NSURL *)url [[self class] sendAsyncRequest:request completionHandler:^( - NSURLResponse *response, NSData *data, NSError *error) { + NSURLResponse *response, NSData *responseData, NSError *error) { if (error) { RTCLogError(@"Error posting data: %@", error.localizedDescription); if (completionHandler) { - completionHandler(NO, data); + completionHandler(NO, responseData); } return; } NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; if (httpResponse.statusCode != 200) { - NSString *serverResponse = data.length > 0 ? - [[NSString alloc] initWithData:data + NSString *serverResponse = responseData.length > 0 ? + [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] : nil; RTCLogError(@"Received bad response: %@", serverResponse); if (completionHandler) { - completionHandler(NO, data); + completionHandler(NO, responseData); } return; } if (completionHandler) { - completionHandler(YES, data); + completionHandler(YES, responseData); } }]; } diff --git a/examples/objc/AppRTCMobile/mac/APPRTCViewController.m b/examples/objc/AppRTCMobile/mac/APPRTCViewController.m index cf87b49ac7..f8bb55e6a2 100644 --- a/examples/objc/AppRTCMobile/mac/APPRTCViewController.m +++ b/examples/objc/AppRTCMobile/mac/APPRTCViewController.m @@ -149,11 +149,11 @@ - (void)updateConstraints { #pragma mark - Constraints helper -+ (void)addConstraints:(NSArray*)constraints ++ (void)addConstraints:(NSArray*)constraintFormats toView:(NSView*)view viewsDictionary:(NSDictionary*)viewsDictionary metrics:(NSDictionary*)metrics { - for (NSString* constraintFormat in constraints) { + for (NSString* constraintFormat in constraintFormats) { NSArray* constraints = [NSLayoutConstraint constraintsWithVisualFormat:constraintFormat options:0 diff --git a/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m b/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m index 68f3e93f7f..3888ecfd27 100644 --- a/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m +++ b/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m @@ -483,15 +483,15 @@ - (void)_readHTTPHeader; _receivedHTTPHeaders = CFHTTPMessageCreateEmpty(NULL, NO); } - [self _readUntilHeaderCompleteWithCallback:^(SRWebSocket *self, NSData *data) { - CFHTTPMessageAppendBytes(self->_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length); + [self _readUntilHeaderCompleteWithCallback:^(SRWebSocket *socket, NSData *data) { + CFHTTPMessageAppendBytes(socket->_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length); - if (CFHTTPMessageIsHeaderComplete(self->_receivedHTTPHeaders)) { + if (CFHTTPMessageIsHeaderComplete(socket->_receivedHTTPHeaders)) { SRFastLog(@"Finished reading headers %@", - CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(self->_receivedHTTPHeaders))); - [self _HTTPHeadersDidFinish]; + CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(socket->_receivedHTTPHeaders))); + [socket _HTTPHeadersDidFinish]; } else { - [self _readHTTPHeader]; + [socket _readHTTPHeader]; } }]; } @@ -929,15 +929,15 @@ - (void)_handleFrameHeader:(frame_header)frame_header curData:(NSData *)curData; } } else { assert(frame_header.payload_length <= SIZE_T_MAX); - [self _addConsumerWithDataLength:(size_t)frame_header.payload_length callback:^(SRWebSocket *self, NSData *newData) { + [self _addConsumerWithDataLength:(size_t)frame_header.payload_length callback:^(SRWebSocket *socket, NSData *newData) { if (isControlFrame) { - [self _handleFrameWithData:newData opCode:frame_header.opcode]; + [socket _handleFrameWithData:newData opCode:frame_header.opcode]; } else { if (frame_header.fin) { - [self _handleFrameWithData:self->_currentFrameData opCode:frame_header.opcode]; + [socket _handleFrameWithData:socket->_currentFrameData opCode:frame_header.opcode]; } else { // TODO add assert that opcode is not a control; - [self _readFrameContinue]; + [socket _readFrameContinue]; } } @@ -978,14 +978,14 @@ - (void)_readFrameContinue; { assert((_currentFrameCount == 0 && _currentFrameOpcode == 0) || (_currentFrameCount > 0 && _currentFrameOpcode > 0)); - [self _addConsumerWithDataLength:2 callback:^(SRWebSocket *self, NSData *data) { + [self _addConsumerWithDataLength:2 callback:^(SRWebSocket *sself, NSData *data) { __block frame_header header = {0}; const uint8_t *headerBuffer = data.bytes; assert(data.length >= 2); if (headerBuffer[0] & SRRsvMask) { - [self _closeWithProtocolError:@"Server used RSV bits"]; + [sself _closeWithProtocolError:@"Server used RSV bits"]; return; } @@ -993,17 +993,17 @@ - (void)_readFrameContinue; BOOL isControlFrame = (receivedOpcode == SROpCodePing || receivedOpcode == SROpCodePong || receivedOpcode == SROpCodeConnectionClose); - if (!isControlFrame && receivedOpcode != 0 && self->_currentFrameCount > 0) { - [self _closeWithProtocolError:@"all data frames after the initial data frame must have opcode 0"]; + if (!isControlFrame && receivedOpcode != 0 && sself->_currentFrameCount > 0) { + [sself _closeWithProtocolError:@"all data frames after the initial data frame must have opcode 0"]; return; } - if (receivedOpcode == 0 && self->_currentFrameCount == 0) { - [self _closeWithProtocolError:@"cannot continue a message"]; + if (receivedOpcode == 0 && sself->_currentFrameCount == 0) { + [sself _closeWithProtocolError:@"cannot continue a message"]; return; } - header.opcode = receivedOpcode == 0 ? self->_currentFrameOpcode : receivedOpcode; + header.opcode = receivedOpcode == 0 ? sself->_currentFrameOpcode : receivedOpcode; header.fin = !!(SRFinMask & headerBuffer[0]); @@ -1014,10 +1014,10 @@ - (void)_readFrameContinue; headerBuffer = NULL; if (header.masked) { - [self _closeWithProtocolError:@"Client must receive unmasked data"]; + [sself _closeWithProtocolError:@"Client must receive unmasked data"]; } - size_t extra_bytes_needed = header.masked ? sizeof(self->_currentReadMaskKey) : 0; + size_t extra_bytes_needed = header.masked ? sizeof(sself->_currentReadMaskKey) : 0; if (header.payload_length == 126) { extra_bytes_needed += sizeof(uint16_t); @@ -1026,11 +1026,11 @@ - (void)_readFrameContinue; } if (extra_bytes_needed == 0) { - [self _handleFrameHeader:header curData:self->_currentFrameData]; + [sself _handleFrameHeader:header curData:sself->_currentFrameData]; } else { - [self _addConsumerWithDataLength:extra_bytes_needed callback:^(SRWebSocket *self, NSData *data) { - size_t mapped_size = data.length; - const void *mapped_buffer = data.bytes; + [sself _addConsumerWithDataLength:extra_bytes_needed callback:^(SRWebSocket *eself, NSData *edata) { + size_t mapped_size = edata.length; + const void *mapped_buffer = edata.bytes; size_t offset = 0; if (header.payload_length == 126) { @@ -1048,13 +1048,13 @@ - (void)_readFrameContinue; if (header.masked) { - assert(mapped_size >= sizeof(self->_currentReadMaskOffset) + offset); - memcpy(self->_currentReadMaskKey, + assert(mapped_size >= sizeof(eself->_currentReadMaskOffset) + offset); + memcpy(eself->_currentReadMaskKey, ((uint8_t *)mapped_buffer) + offset, - sizeof(self->_currentReadMaskKey)); + sizeof(eself->_currentReadMaskKey)); } - [self _handleFrameHeader:header curData:self->_currentFrameData]; + [eself _handleFrameHeader:header curData:eself->_currentFrameData]; } readToCurrentFrame:NO unmaskBytes:NO]; } } readToCurrentFrame:NO unmaskBytes:NO]; diff --git a/examples/objcnativeapi/objc/objc_call_client.mm b/examples/objcnativeapi/objc/objc_call_client.mm index 15406ad7d0..a0c9e4bfdb 100644 --- a/examples/objcnativeapi/objc/objc_call_client.mm +++ b/examples/objcnativeapi/objc/objc_call_client.mm @@ -25,7 +25,6 @@ #include "api/enable_media.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/task_queue/default_task_queue_factory.h" #include "sdk/objc/native/api/video_capturer.h" #include "sdk/objc/native/api/video_decoder_factory.h" #include "sdk/objc/native/api/video_encoder_factory.h" @@ -121,7 +120,6 @@ explicit CreateOfferObserver( dependencies.network_thread = network_thread_.get(); dependencies.worker_thread = worker_thread_.get(); dependencies.signaling_thread = signaling_thread_.get(); - dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); dependencies.audio_decoder_factory = diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index 8356484207..2039ea66ee 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -18,12 +18,13 @@ #include #include +#include "absl/base/nullability.h" #include "absl/memory/memory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_options.h" -#include "api/create_peerconnection_factory.h" #include "api/enable_media.h" +#include "api/environment/environment.h" #include "api/jsep.h" #include "api/make_ref_counted.h" #include "api/media_stream_interface.h" @@ -32,7 +33,6 @@ #include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/task_queue_factory.h" #include "api/test/create_frame_generator.h" #include "api/video/video_frame.h" @@ -59,6 +59,7 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/json.h" +#include "rtc_base/thread.h" #include "system_wrappers/include/clock.h" #include "test/frame_generator_capturer.h" #include "test/platform_video_capturer.h" @@ -140,8 +141,14 @@ class CapturerTrackSource : public webrtc::VideoTrackSource { } // namespace -Conductor::Conductor(PeerConnectionClient* client, MainWindow* main_wnd) - : peer_id_(-1), loopback_(false), client_(client), main_wnd_(main_wnd) { +Conductor::Conductor(const webrtc::Environment& env, + PeerConnectionClient* absl_nonnull client, + MainWindow* absl_nonnull main_wnd) + : peer_id_(-1), + loopback_(false), + env_(env), + client_(client), + main_wnd_(main_wnd) { client_->RegisterObserver(this); main_wnd->RegisterObserver(this); } @@ -170,7 +177,7 @@ bool Conductor::InitializePeerConnection() { webrtc::PeerConnectionFactoryDependencies deps; deps.signaling_thread = signaling_thread_.get(); - deps.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(), + deps.env = env_, deps.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); deps.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); deps.video_encoder_factory = @@ -186,7 +193,6 @@ bool Conductor::InitializePeerConnection() { webrtc::OpenH264DecoderTemplateAdapter, webrtc::Dav1dDecoderTemplateAdapter>>(); webrtc::EnableMedia(deps); - task_queue_factory_ = deps.task_queue_factory.get(); peer_connection_factory_ = webrtc::CreateModularPeerConnectionFactory(std::move(deps)); @@ -337,7 +343,7 @@ void Conductor::OnPeerDisconnected(int id) { RTC_LOG(LS_INFO) << __FUNCTION__; if (id == peer_id_) { RTC_LOG(LS_INFO) << "Our peer disconnected"; - main_wnd_->QueueUIThreadCallback(PEER_CONNECTION_CLOSED, NULL); + main_wnd_->QueueUIThreadCallback(PEER_CONNECTION_CLOSED, nullptr); } else { // Refresh the list if we're showing it. if (main_wnd_->current_ui() == MainWindow::LIST_PEERS) @@ -454,7 +460,7 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { void Conductor::OnMessageSent(int err) { // Process the next pending message if any. - main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, NULL); + main_wnd_->QueueUIThreadCallback(SEND_MESSAGE_TO_PEER, nullptr); } void Conductor::OnServerConnectionFailure() { @@ -514,7 +520,7 @@ void Conductor::AddTracks() { } webrtc::scoped_refptr video_device = - CapturerTrackSource::Create(*task_queue_factory_); + CapturerTrackSource::Create(env_.task_queue_factory()); if (video_device) { webrtc::scoped_refptr video_track_( peer_connection_factory_->CreateVideoTrack(video_device, kVideoLabel)); diff --git a/examples/peerconnection/client/conductor.h b/examples/peerconnection/client/conductor.h index ffc5c27012..68b70bb2f6 100644 --- a/examples/peerconnection/client/conductor.h +++ b/examples/peerconnection/client/conductor.h @@ -16,14 +16,15 @@ #include #include +#include "absl/base/nullability.h" #include "api/data_channel_interface.h" +#include "api/environment/environment.h" #include "api/jsep.h" #include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" #include "api/rtc_error.h" #include "api/rtp_receiver_interface.h" #include "api/scoped_refptr.h" -#include "api/task_queue/task_queue_factory.h" #include "examples/peerconnection/client/main_wnd.h" #include "examples/peerconnection/client/peer_connection_client.h" #include "rtc_base/thread.h" @@ -45,7 +46,9 @@ class Conductor : public webrtc::PeerConnectionObserver, TRACK_REMOVED, }; - Conductor(PeerConnectionClient* client, MainWindow* main_wnd); + Conductor(const webrtc::Environment& env, + PeerConnectionClient* absl_nonnull client, + MainWindow* absl_nonnull main_wnd); bool connection_active() const; @@ -124,8 +127,8 @@ class Conductor : public webrtc::PeerConnectionObserver, int peer_id_; bool loopback_; + const webrtc::Environment env_; std::unique_ptr signaling_thread_; - webrtc::TaskQueueFactory* task_queue_factory_ = nullptr; webrtc::scoped_refptr peer_connection_; webrtc::scoped_refptr peer_connection_factory_; diff --git a/examples/peerconnection/client/defaults.cc b/examples/peerconnection/client/defaults.cc index ee3a9e1f0a..9ff7aeedf3 100644 --- a/examples/peerconnection/client/defaults.cc +++ b/examples/peerconnection/client/defaults.cc @@ -12,14 +12,16 @@ #include +#include +#include +#include + #ifdef WIN32 #include #else #include #endif -#include "rtc_base/arraysize.h" - const char kAudioLabel[] = "audio_label"; const char kVideoLabel[] = "video_label"; const char kStreamId[] = "stream_id"; @@ -50,7 +52,7 @@ std::string GetPeerName() { char computer_name[256]; std::string ret(GetEnvVarOrDefault("USERNAME", "user")); ret += '@'; - if (gethostname(computer_name, arraysize(computer_name)) == 0) { + if (gethostname(computer_name, std::size(computer_name)) == 0) { ret += computer_name; } else { ret += "host"; diff --git a/examples/peerconnection/client/linux/main.cc b/examples/peerconnection/client/linux/main.cc index 3278e9d0fd..a0a80e83ac 100644 --- a/examples/peerconnection/client/linux/main.cc +++ b/examples/peerconnection/client/linux/main.cc @@ -12,8 +12,17 @@ #include #include +#include +#include + +#include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" +#include "api/field_trials.h" +#include "api/make_ref_counted.h" #include "api/scoped_refptr.h" +#include "api/units/time_delta.h" #include "examples/peerconnection/client/conductor.h" #include "examples/peerconnection/client/flag_defs.h" #include "examples/peerconnection/client/linux/main_wnd.h" @@ -21,13 +30,11 @@ #include "rtc_base/physical_socket_server.h" #include "rtc_base/ssl_adapter.h" #include "rtc_base/thread.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" class CustomSocketServer : public webrtc::PhysicalSocketServer { public: explicit CustomSocketServer(GtkMainWnd* wnd) - : wnd_(wnd), conductor_(NULL), client_(NULL) {} + : wnd_(wnd), conductor_(nullptr), client_(nullptr) {} virtual ~CustomSocketServer() {} void SetMessageQueue(webrtc::Thread* queue) override { @@ -49,7 +56,7 @@ class CustomSocketServer : public webrtc::PhysicalSocketServer { gtk_main_iteration(); if (!wnd_->IsWindow() && !conductor_->connection_active() && - client_ != NULL && !client_->is_connected()) { + client_ != nullptr && !client_->is_connected()) { message_queue_->Quit(); } return webrtc::PhysicalSocketServer::Wait(webrtc::TimeDelta::Zero(), @@ -78,11 +85,9 @@ int main(int argc, char* argv[]) { absl::ParseCommandLine(argc, argv); - // InitFieldTrialsFromString stores the char*, so the char array must outlive - // the application. - const std::string forced_field_trials = - absl::GetFlag(FLAGS_force_fieldtrials); - webrtc::field_trial::InitFieldTrialsFromString(forced_field_trials.c_str()); + webrtc::Environment env = + webrtc::CreateEnvironment(std::make_unique( + absl::GetFlag(FLAGS_force_fieldtrials))); // Abort if the user specifies a port that is outside the allowed // range [1, 65535]. @@ -103,7 +108,7 @@ int main(int argc, char* argv[]) { webrtc::InitializeSSL(); // Must be constructed after we set the socketserver. PeerConnectionClient client; - auto conductor = webrtc::make_ref_counted(&client, &wnd); + auto conductor = webrtc::make_ref_counted(env, &client, &wnd); socket_server.set_client(&client); socket_server.set_conductor(conductor.get()); diff --git a/examples/peerconnection/client/linux/main_wnd.cc b/examples/peerconnection/client/linux/main_wnd.cc index c750365dbc..ef624f1a65 100644 --- a/examples/peerconnection/client/linux/main_wnd.cc +++ b/examples/peerconnection/client/linux/main_wnd.cc @@ -80,7 +80,7 @@ gboolean SimulateLastRowActivated(gpointer data) { GtkTreeModel* model = gtk_tree_view_get_model(tree_view); // "if iter is NULL, then the number of toplevel nodes is returned." - int rows = gtk_tree_model_iter_n_children(model, NULL); + int rows = gtk_tree_model_iter_n_children(model, nullptr); GtkTreePath* lastpath = gtk_tree_path_new_from_indices(rows - 1, -1); // Select the last item in the list @@ -154,13 +154,13 @@ GtkMainWnd::GtkMainWnd(const char* server, int port, bool autoconnect, bool autocall) - : window_(NULL), - draw_area_(NULL), - vbox_(NULL), - server_edit_(NULL), - port_edit_(NULL), - peer_list_(NULL), - callback_(NULL), + : window_(nullptr), + draw_area_(nullptr), + vbox_(nullptr), + server_edit_(nullptr), + port_edit_(nullptr), + peer_list_(nullptr), + callback_(nullptr), server_(server), autoconnect_(autoconnect), autocall_(autocall) { @@ -178,7 +178,7 @@ void GtkMainWnd::RegisterObserver(MainWndCallback* callback) { } bool GtkMainWnd::IsWindow() { - return window_ != NULL && GTK_IS_WINDOW(window_); + return window_ != nullptr && GTK_IS_WINDOW(window_); } void GtkMainWnd::MessageBox(const char* caption, @@ -226,7 +226,7 @@ void GtkMainWnd::QueueUIThreadCallback(int msg_id, void* data) { } bool GtkMainWnd::Create() { - RTC_DCHECK(window_ == NULL); + RTC_DCHECK(window_ == nullptr); window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); if (window_) { @@ -241,7 +241,7 @@ bool GtkMainWnd::Create() { SwitchToConnectUI(); } - return window_ != NULL; + return window_ != nullptr; } bool GtkMainWnd::Destroy() { @@ -249,7 +249,7 @@ bool GtkMainWnd::Destroy() { return false; gtk_widget_destroy(window_); - window_ = NULL; + window_ = nullptr; return true; } @@ -258,13 +258,13 @@ void GtkMainWnd::SwitchToConnectUI() { RTC_LOG(LS_INFO) << __FUNCTION__; RTC_DCHECK(IsWindow()); - RTC_DCHECK(vbox_ == NULL); + RTC_DCHECK(vbox_ == nullptr); gtk_container_set_border_width(GTK_CONTAINER(window_), 10); if (peer_list_) { gtk_widget_destroy(peer_list_); - peer_list_ = NULL; + peer_list_ = nullptr; } vbox_ = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); @@ -309,12 +309,12 @@ void GtkMainWnd::SwitchToPeerList(const Peers& peers) { gtk_container_set_border_width(GTK_CONTAINER(window_), 0); if (vbox_) { gtk_widget_destroy(vbox_); - vbox_ = NULL; - server_edit_ = NULL; - port_edit_ = NULL; + vbox_ = nullptr; + server_edit_ = nullptr; + port_edit_ = nullptr; } else if (draw_area_) { gtk_widget_destroy(draw_area_); - draw_area_ = NULL; + draw_area_ = nullptr; draw_buffer_.SetSize(0); } @@ -342,12 +342,12 @@ void GtkMainWnd::SwitchToPeerList(const Peers& peers) { void GtkMainWnd::SwitchToStreamingUI() { RTC_LOG(LS_INFO) << __FUNCTION__; - RTC_DCHECK(draw_area_ == NULL); + RTC_DCHECK(draw_area_ == nullptr); gtk_container_set_border_width(GTK_CONTAINER(window_), 0); if (peer_list_) { gtk_widget_destroy(peer_list_); - peer_list_ = NULL; + peer_list_ = nullptr; } draw_area_ = gtk_drawing_area_new(); @@ -359,12 +359,12 @@ void GtkMainWnd::SwitchToStreamingUI() { void GtkMainWnd::OnDestroyed(GtkWidget* widget, GdkEvent* event) { callback_->Close(); - window_ = NULL; - draw_area_ = NULL; - vbox_ = NULL; - server_edit_ = NULL; - port_edit_ = NULL; - peer_list_ = NULL; + window_ = nullptr; + draw_area_ = nullptr; + vbox_ = nullptr; + server_edit_ = nullptr; + port_edit_ = nullptr; + peer_list_ = nullptr; } void GtkMainWnd::OnClicked(GtkWidget* widget) { @@ -392,7 +392,7 @@ void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) { case GDK_KEY_KP_Enter: case GDK_KEY_Return: if (vbox_) { - OnClicked(NULL); + OnClicked(nullptr); } else if (peer_list_) { // OnRowActivated will be called automatically when the user // presses enter. @@ -408,7 +408,7 @@ void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) { void GtkMainWnd::OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path, GtkTreeViewColumn* column) { - RTC_DCHECK(peer_list_ != NULL); + RTC_DCHECK(peer_list_ != nullptr); GtkTreeIter iter; GtkTreeModel* model; GtkTreeSelection* selection = @@ -428,7 +428,7 @@ void GtkMainWnd::OnRedraw() { VideoRenderer* remote_renderer = remote_renderer_.get(); if (remote_renderer && !remote_renderer->image().empty() && - draw_area_ != NULL) { + draw_area_ != nullptr) { if (width_ != remote_renderer->width() || height_ != remote_renderer->height()) { width_ = remote_renderer->width(); diff --git a/examples/peerconnection/client/main.cc b/examples/peerconnection/client/main.cc index c5ac647f72..87f78120a2 100644 --- a/examples/peerconnection/client/main.cc +++ b/examples/peerconnection/client/main.cc @@ -14,20 +14,29 @@ #include // must come after windows.h // clang-format on +#include +#include +#include +#include #include #include +#include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" +#include "api/field_trials.h" +#include "api/make_ref_counted.h" #include "examples/peerconnection/client/conductor.h" #include "examples/peerconnection/client/flag_defs.h" #include "examples/peerconnection/client/main_wnd.h" #include "examples/peerconnection/client/peer_connection_client.h" #include "rtc_base/checks.h" +#include "rtc_base/physical_socket_server.h" #include "rtc_base/ssl_adapter.h" #include "rtc_base/string_utils.h" // For ToUtf8 +#include "rtc_base/thread.h" #include "rtc_base/win32_socket_init.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" namespace { // A helper class to translate Windows command line arguments into UTF8, @@ -83,11 +92,9 @@ int PASCAL wWinMain(HINSTANCE instance, absl::ParseCommandLine(argc, argv); - // InitFieldTrialsFromString stores the char*, so the char array must outlive - // the application. - const std::string forced_field_trials = - absl::GetFlag(FLAGS_force_fieldtrials); - webrtc::field_trial::InitFieldTrialsFromString(forced_field_trials.c_str()); + webrtc::Environment env = + webrtc::CreateEnvironment(std::make_unique( + absl::GetFlag(FLAGS_force_fieldtrials))); // Abort if the user specifies a port that is outside the allowed // range [1, 65535]. @@ -106,7 +113,7 @@ int PASCAL wWinMain(HINSTANCE instance, webrtc::InitializeSSL(); PeerConnectionClient client; - auto conductor = webrtc::make_ref_counted(&client, &wnd); + auto conductor = webrtc::make_ref_counted(env, &client, &wnd); // Main loop. MSG msg; diff --git a/examples/peerconnection/client/main_wnd.cc b/examples/peerconnection/client/main_wnd.cc index 59854875fb..a9d00d3d2d 100644 --- a/examples/peerconnection/client/main_wnd.cc +++ b/examples/peerconnection/client/main_wnd.cc @@ -12,11 +12,22 @@ #include +#include +#include +#include +#include +#include +#include + +#include "api/media_stream_interface.h" +#include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" -#include "examples/peerconnection/client/defaults.h" -#include "rtc_base/arraysize.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_buffer.h" +#include "api/video/video_rotation.h" +#include "api/video/video_source_interface.h" +#include "examples/peerconnection/client/peer_connection_client.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" #include "third_party/libyuv/include/libyuv/convert_argb.h" ATOM MainWnd::wnd_class_ = 0; @@ -53,7 +64,7 @@ HFONT GetDefaultFont() { std::string GetWindowText(HWND wnd) { char text[MAX_PATH] = {0}; - ::GetWindowTextA(wnd, &text[0], ARRAYSIZE(text)); + ::GetWindowTextA(wnd, &text[0], std::size(text)); return text; } @@ -254,11 +265,10 @@ void MainWnd::OnPaint() { ::SetStretchBltMode(dc_mem, HALFTONE); // Set the map mode so that the ratio will be maintained for us. - HDC all_dc[] = {ps.hdc, dc_mem}; - for (size_t i = 0; i < arraysize(all_dc); ++i) { - SetMapMode(all_dc[i], MM_ISOTROPIC); - SetWindowExtEx(all_dc[i], width, height, NULL); - SetViewportExtEx(all_dc[i], rc.right, rc.bottom, NULL); + for (HDC dc : {ps.hdc, dc_mem}) { + SetMapMode(dc, MM_ISOTROPIC); + SetWindowExtEx(dc, width, height, nullptr); + SetViewportExtEx(dc, rc.right, rc.bottom, nullptr); } HBITMAP bmp_mem = ::CreateCompatibleBitmap(ps.hdc, rc.right, rc.bottom); @@ -279,15 +289,15 @@ void MainWnd::OnPaint() { &bmi, DIB_RGB_COLORS, SRCCOPY); if ((rc.right - rc.left) > 200 && (rc.bottom - rc.top) > 200) { - const BITMAPINFO& bmi = local_renderer->bmi(); + const BITMAPINFO& local_bmi = local_renderer->bmi(); image = local_renderer->image(); - int thumb_width = bmi.bmiHeader.biWidth / 4; - int thumb_height = abs(bmi.bmiHeader.biHeight) / 4; + int thumb_width = local_bmi.bmiHeader.biWidth / 4; + int thumb_height = abs(local_bmi.bmiHeader.biHeight) / 4; StretchDIBits(dc_mem, logical_area.x - thumb_width - 10, logical_area.y - thumb_height - 10, thumb_width, - thumb_height, 0, 0, bmi.bmiHeader.biWidth, - -bmi.bmiHeader.biHeight, image, &bmi, DIB_RGB_COLORS, - SRCCOPY); + thumb_height, 0, 0, local_bmi.bmiHeader.biWidth, + -local_bmi.bmiHeader.biHeight, image, &local_bmi, + DIB_RGB_COLORS, SRCCOPY); } BitBlt(ps.hdc, 0, 0, logical_area.x, logical_area.y, dc_mem, 0, 0, @@ -503,31 +513,31 @@ void MainWnd::LayoutConnectUI(bool show) { if (show) { const size_t kSeparator = 5; - size_t total_width = (ARRAYSIZE(windows) - 1) * kSeparator; + size_t total_width = (std::size(windows) - 1) * kSeparator; - for (size_t i = 0; i < ARRAYSIZE(windows); ++i) { - CalculateWindowSizeForText(windows[i].wnd, windows[i].text, - &windows[i].width, &windows[i].height); - total_width += windows[i].width; + for (Windows& window : windows) { + CalculateWindowSizeForText(window.wnd, window.text, &window.width, + &window.height); + total_width += window.width; } RECT rc; ::GetClientRect(wnd_, &rc); size_t x = (rc.right / 2) - (total_width / 2); size_t y = rc.bottom / 2; - for (size_t i = 0; i < ARRAYSIZE(windows); ++i) { - size_t top = y - (windows[i].height / 2); - ::MoveWindow(windows[i].wnd, static_cast(x), static_cast(top), - static_cast(windows[i].width), - static_cast(windows[i].height), TRUE); - x += kSeparator + windows[i].width; - if (windows[i].text[0] != 'X') - ::SetWindowTextW(windows[i].wnd, windows[i].text); - ::ShowWindow(windows[i].wnd, SW_SHOWNA); + for (Windows& window : windows) { + size_t top = y - (window.height / 2); + ::MoveWindow(window.wnd, static_cast(x), static_cast(top), + static_cast(window.width), + static_cast(window.height), TRUE); + x += kSeparator + window.width; + if (window.text[0] != 'X') + ::SetWindowTextW(window.wnd, window.text); + ::ShowWindow(window.wnd, SW_SHOWNA); } } else { - for (size_t i = 0; i < ARRAYSIZE(windows); ++i) { - ::ShowWindow(windows[i].wnd, SW_HIDE); + for (Windows& window : windows) { + ::ShowWindow(window.wnd, SW_HIDE); } } } diff --git a/examples/peerconnection/client/peer_connection_client.cc b/examples/peerconnection/client/peer_connection_client.cc index b646c58226..6aa60e8746 100644 --- a/examples/peerconnection/client/peer_connection_client.cc +++ b/examples/peerconnection/client/peer_connection_client.cc @@ -27,20 +27,23 @@ constexpr webrtc::TimeDelta kReconnectDelay = webrtc::TimeDelta::Seconds(2); webrtc::Socket* CreateClientSocket(int family) { webrtc::Thread* thread = webrtc::Thread::Current(); - RTC_DCHECK(thread != NULL); + RTC_DCHECK(thread != nullptr); return thread->socketserver()->CreateSocket(family, SOCK_STREAM); } } // namespace PeerConnectionClient::PeerConnectionClient() - : callback_(NULL), resolver_(nullptr), state_(NOT_CONNECTED), my_id_(-1) {} + : callback_(nullptr), + resolver_(nullptr), + state_(NOT_CONNECTED), + my_id_(-1) {} PeerConnectionClient::~PeerConnectionClient() = default; void PeerConnectionClient::InitSocketSignals() { - RTC_DCHECK(control_socket_.get() != NULL); - RTC_DCHECK(hanging_get_.get() != NULL); + RTC_DCHECK(control_socket_.get() != nullptr); + RTC_DCHECK(hanging_get_.get() != nullptr); control_socket_->SignalCloseEvent.connect(this, &PeerConnectionClient::OnClose); hanging_get_->SignalCloseEvent.connect(this, &PeerConnectionClient::OnClose); @@ -249,7 +252,7 @@ bool PeerConnectionClient::GetHeaderValue(const std::string& data, size_t eoh, const char* header_pattern, size_t* value) { - RTC_DCHECK(value != NULL); + RTC_DCHECK(value != nullptr); size_t found = data.find(header_pattern); if (found != std::string::npos && found < eoh) { *value = atoi(&data[found + strlen(header_pattern)]); @@ -262,7 +265,7 @@ bool PeerConnectionClient::GetHeaderValue(const std::string& data, size_t eoh, const char* header_pattern, std::string* value) { - RTC_DCHECK(value != NULL); + RTC_DCHECK(value != nullptr); size_t found = data.find(header_pattern); if (found != std::string::npos && found < eoh) { size_t begin = found + strlen(header_pattern); @@ -412,9 +415,9 @@ bool PeerConnectionClient::ParseEntry(const std::string& entry, std::string* name, int* id, bool* connected) { - RTC_DCHECK(name != NULL); - RTC_DCHECK(id != NULL); - RTC_DCHECK(connected != NULL); + RTC_DCHECK(name != nullptr); + RTC_DCHECK(id != nullptr); + RTC_DCHECK(connected != nullptr); RTC_DCHECK(!entry.empty()); *connected = false; diff --git a/examples/peerconnection/server/data_socket.cc b/examples/peerconnection/server/data_socket.cc index 855ebd8c0c..9ece090a64 100644 --- a/examples/peerconnection/server/data_socket.cc +++ b/examples/peerconnection/server/data_socket.cc @@ -13,13 +13,20 @@ #include #include #include + +#include +#include + +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "rtc_base/checks.h" +#include "rtc_base/ip_address.h" +#include "rtc_base/net_helpers.h" + #if defined(WEBRTC_POSIX) #include #endif -#include "examples/peerconnection/server/utils.h" -#include "rtc_base/checks.h" - static const char kHeaderTerminator[] = "\r\n\r\n"; static const int kHeaderTerminatorLength = sizeof(kHeaderTerminator) - 1; @@ -138,8 +145,7 @@ bool DataSocket::Send(const std::string& status, if (!content_type.empty()) buffer += "Content-Type: " + content_type + "\r\n"; - buffer += - "Content-Length: " + int2str(static_cast(data.size())) + "\r\n"; + buffer += "Content-Length: " + absl::StrCat(data.size()) + "\r\n"; if (!extra_headers.empty()) { buffer += extra_headers; @@ -197,14 +203,13 @@ bool DataSocket::ParseMethodAndPath(const char* begin, size_t len) { {"OPTIONS", 7, OPTIONS}, }; - const char* path = NULL; - for (size_t i = 0; i < ARRAYSIZE(supported_methods); ++i) { - if (len > supported_methods[i].method_name_len && - isspace(begin[supported_methods[i].method_name_len]) && - strncmp(begin, supported_methods[i].method_name, - supported_methods[i].method_name_len) == 0) { - method_ = supported_methods[i].id; - path = begin + supported_methods[i].method_name_len; + const char* path = nullptr; + for (const auto& method : supported_methods) { + if (len > method.method_name_len && + isspace(begin[method.method_name_len]) && + strncmp(begin, method.method_name, method.method_name_len) == 0) { + method_ = method.id; + path = begin + method.method_name_len; break; } } @@ -230,23 +235,21 @@ bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) { const char* end = headers + length; while (headers && headers < end) { if (!isspace(headers[0])) { - static const char kContentLength[] = "Content-Length:"; - static const char kContentType[] = "Content-Type:"; - if ((headers + ARRAYSIZE(kContentLength)) < end && - strncmp(headers, kContentLength, ARRAYSIZE(kContentLength) - 1) == - 0) { - headers += ARRAYSIZE(kContentLength) - 1; + static constexpr absl::string_view kContentLength = "Content-Length:"; + static constexpr absl::string_view kContentType = "Content-Type:"; + if (absl::string_view(headers, end - headers) + .starts_with(kContentLength)) { + headers += kContentLength.size(); while (headers[0] == ' ') ++headers; content_length_ = atoi(headers); - } else if ((headers + ARRAYSIZE(kContentType)) < end && - strncmp(headers, kContentType, ARRAYSIZE(kContentType) - 1) == - 0) { - headers += ARRAYSIZE(kContentType) - 1; + } else if (absl::string_view(headers, end - headers) + .starts_with(kContentType)) { + headers += kContentType.size(); while (headers[0] == ' ') ++headers; const char* type_end = strstr(headers, "\r\n"); - if (type_end == NULL) + if (type_end == nullptr) type_end = end; content_type_.assign(headers, type_end); } @@ -293,7 +296,7 @@ DataSocket* ListeningSocket::Accept() const { NativeSocket client = accept(socket_, reinterpret_cast(&addr), &size); if (client == INVALID_SOCKET) - return NULL; + return nullptr; return new DataSocket(client); } diff --git a/examples/peerconnection/server/main.cc b/examples/peerconnection/server/main.cc index 50b8c23401..0b4e483427 100644 --- a/examples/peerconnection/server/main.cc +++ b/examples/peerconnection/server/main.cc @@ -24,9 +24,11 @@ #include "examples/peerconnection/server/data_socket.h" #include "examples/peerconnection/server/peer_channel.h" #include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" +// As of now, no components in peerconnection_server rely on WebRTC components +// that change its behavior based on a field trial, so this flag is currently +// unused. See peerconnection_client for example how this command line flag +// can be used and propagated. ABSL_FLAG( std::string, force_fieldtrials, @@ -70,11 +72,6 @@ int main(int argc, char* argv[]) { "Example usage: ./peerconnection_server --port=8888\n"); absl::ParseCommandLine(argc, argv); - // InitFieldTrialsFromString stores the char*, so the char array must outlive - // the application. - const std::string force_field_trials = absl::GetFlag(FLAGS_force_fieldtrials); - webrtc::field_trial::InitFieldTrialsFromString(force_field_trials.c_str()); - int port = absl::GetFlag(FLAGS_port); // Abort if the user specifies a port that is outside the allowed @@ -109,7 +106,8 @@ int main(int argc, char* argv[]) { FD_SET((*i)->socket(), &socket_set); struct timeval timeout = {10, 0}; - if (select(FD_SETSIZE, &socket_set, NULL, NULL, &timeout) == SOCKET_ERROR) { + if (select(FD_SETSIZE, &socket_set, nullptr, nullptr, &timeout) == + SOCKET_ERROR) { printf("select failed\n"); break; } diff --git a/examples/peerconnection/server/peer_channel.cc b/examples/peerconnection/server/peer_channel.cc index f53820cc60..4b8a8d5253 100644 --- a/examples/peerconnection/server/peer_channel.cc +++ b/examples/peerconnection/server/peer_channel.cc @@ -14,9 +14,13 @@ #include #include +#include +#include +#include +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #include "examples/peerconnection/server/data_socket.h" -#include "examples/peerconnection/server/utils.h" #include "rtc_base/checks.h" // Set to the peer id of the originator when messages are being @@ -53,16 +57,16 @@ const size_t kMaxNameLength = 512; int ChannelMember::s_member_id_ = 0; ChannelMember::ChannelMember(DataSocket* socket) - : waiting_socket_(NULL), + : waiting_socket_(nullptr), id_(++s_member_id_), connected_(true), - timestamp_(time(NULL)) { + timestamp_(time(nullptr)) { RTC_DCHECK(socket); RTC_DCHECK_EQ(socket->method(), DataSocket::GET); RTC_DCHECK(socket->PathEquals("/sign_in")); name_ = socket->request_arguments(); if (name_.empty()) - name_ = "peer_" + int2str(id_); + name_ = "peer_" + absl::StrCat(id_); else if (name_.length() > kMaxNameLength) name_.resize(kMaxNameLength); @@ -76,12 +80,11 @@ bool ChannelMember::is_wait_request(DataSocket* ds) const { } bool ChannelMember::TimedOut() { - return waiting_socket_ == NULL && (time(NULL) - timestamp_) > 30; + return waiting_socket_ == nullptr && (time(nullptr) - timestamp_) > 30; } std::string ChannelMember::GetPeerIdHeader() const { - std::string ret(kPeerIdHeader + int2str(id_) + "\r\n"); - return ret; + return kPeerIdHeader + absl::StrCat(id_) + "\r\n"; } bool ChannelMember::NotifyOfOtherMember(const ChannelMember& other) { @@ -119,8 +122,8 @@ void ChannelMember::ForwardRequestToPeer(DataSocket* ds, ChannelMember* peer) { void ChannelMember::OnClosing(DataSocket* ds) { if (ds == waiting_socket_) { - waiting_socket_ = NULL; - timestamp_ = time(NULL); + waiting_socket_ = nullptr; + timestamp_ = time(nullptr); } } @@ -136,8 +139,8 @@ void ChannelMember::QueueResponse(const std::string& status, if (!ok) { printf("Failed to deliver data to waiting socket\n"); } - waiting_socket_ = NULL; - timestamp_ = time(NULL); + waiting_socket_ = nullptr; + timestamp_ = time(nullptr); } else { QueuedResponse qr; qr.status = status; @@ -176,24 +179,24 @@ ChannelMember* PeerChannel::Lookup(DataSocket* ds) const { RTC_DCHECK(ds); if (ds->method() != DataSocket::GET && ds->method() != DataSocket::POST) - return NULL; + return nullptr; size_t i = 0; - for (; i < ARRAYSIZE(kRequestPaths); ++i) { + for (; i < std::size(kRequestPaths); ++i) { if (ds->PathEquals(kRequestPaths[i])) break; } - if (i == ARRAYSIZE(kRequestPaths)) - return NULL; + if (i == std::size(kRequestPaths)) + return nullptr; std::string args(ds->request_arguments()); - static const char kPeerId[] = "peer_id="; + static constexpr absl::string_view kPeerId = "peer_id="; size_t found = args.find(kPeerId); if (found == std::string::npos) - return NULL; + return nullptr; - int id = atoi(&args[found + ARRAYSIZE(kPeerId) - 1]); + int id = atoi(&args[found + kPeerId.size()]); Members::const_iterator iter = members_.begin(); for (; iter != members_.end(); ++iter) { if (id == (*iter)->id()) { @@ -205,7 +208,7 @@ ChannelMember* PeerChannel::Lookup(DataSocket* ds) const { } } - return NULL; + return nullptr; } ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const { @@ -215,18 +218,18 @@ ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const { const std::string& path = ds->request_path(); size_t args = path.find('?'); if (args == std::string::npos) - return NULL; + return nullptr; size_t found; - const char kTargetPeerIdParam[] = "to="; + static constexpr absl::string_view kTargetPeerIdParam = "to="; do { found = path.find(kTargetPeerIdParam, args); if (found == std::string::npos) - return NULL; + return nullptr; if (found == (args + 1) || path[found - 1] == '&') { - found += ARRAYSIZE(kTargetPeerIdParam) - 1; + found += kTargetPeerIdParam.size(); break; } - args = found + ARRAYSIZE(kTargetPeerIdParam) - 1; + args = found + kTargetPeerIdParam.size(); } while (true); int id = atoi(&path[found]); Members::const_iterator i = members_.begin(); @@ -235,7 +238,7 @@ ChannelMember* PeerChannel::IsTargetedRequest(const DataSocket* ds) const { return *i; } } - return NULL; + return nullptr; } bool PeerChannel::AddMember(DataSocket* ds) { @@ -246,8 +249,8 @@ bool PeerChannel::AddMember(DataSocket* ds) { HandleDeliveryFailures(&failures); members_.push_back(new_guy); - printf("New member added (total=%s): %s\n", - size_t2str(members_.size()).c_str(), new_guy->name().c_str()); + printf("New member added (total=%zu): %s\n", members_.size(), + new_guy->name().c_str()); // Let the newly connected peer know about other members of the channel. std::string content_type; @@ -279,7 +282,7 @@ void PeerChannel::OnClosing(DataSocket* ds) { break; } } - printf("Total connected: %s\n", size_t2str(members_.size()).c_str()); + printf("Total connected: %zu\n", members_.size()); } void PeerChannel::CheckForTimeout() { diff --git a/examples/peerconnection/server/utils.cc b/examples/peerconnection/server/utils.cc deleted file mode 100644 index 4cdaa0af15..0000000000 --- a/examples/peerconnection/server/utils.cc +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2011 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "examples/peerconnection/server/utils.h" - -#include - -#include "rtc_base/string_encode.h" - -using absl::StrCat; - -std::string int2str(int i) { - return absl::StrCat(i); -} - -std::string size_t2str(size_t i) { - return absl::StrCat(i); -} diff --git a/examples/peerconnection/server/utils.h b/examples/peerconnection/server/utils.h deleted file mode 100644 index 85c04a40e9..0000000000 --- a/examples/peerconnection/server/utils.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2011 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef EXAMPLES_PEERCONNECTION_SERVER_UTILS_H_ -#define EXAMPLES_PEERCONNECTION_SERVER_UTILS_H_ - -#include - -#include - -#ifndef ARRAYSIZE -#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -std::string int2str(int i); -std::string size_t2str(size_t i); - -#endif // EXAMPLES_PEERCONNECTION_SERVER_UTILS_H_ diff --git a/experiments/field_trials.py b/experiments/field_trials.py index b23b72457b..ec83ca5615 100755 --- a/experiments/field_trials.py +++ b/experiments/field_trials.py @@ -80,6 +80,9 @@ def bug_url(self) -> str: FieldTrial('WebRTC-DisableRtxRateLimiter', 42225500, date(2024, 4, 1)), + FieldTrial('WebRTC-DisableSslGroupIds', + 404763475, + date(2025,9,1)), FieldTrial('WebRTC-ElasticBitrateAllocation', 350555527, date(2025, 3, 1)), @@ -122,12 +125,18 @@ def bug_url(self) -> str: FieldTrial('WebRTC-NoSdpMangleUfragRestrictedAddresses', 409713509, date(2025, 10, 11)), + FieldTrial('WebRTC-NoSdpMangleNumberOfContents', + 40567530, + date(2025, 10, 11)), FieldTrial('WebRTC-Pacer-FastRetransmissions', 40235589, date(2024, 4, 1)), FieldTrial('WebRTC-Pacer-KeyframeFlushing', 42221435, date(2024, 4, 1)), + FieldTrial('WebRTC-PostFilterKillSwitch', + 417439718, + date(2025, 9, 1)), FieldTrial('WebRTC-QCM-Dynamic-AV1', 349860657, date(2025, 7, 1)), @@ -161,6 +170,9 @@ def bug_url(self) -> str: FieldTrial('WebRTC-SetReadyToSendFalseIfSendFail', 361124449, date(2024, 12, 1)), + FieldTrial('WebRTC-SimulcastEncoderAdapter-DropUnalignedResolution', + 415329365, + date(2025, 11, 2)), FieldTrial('WebRTC-SrtpRemoveReceiveStream', 42225949, date(2024, 10, 1)), @@ -487,9 +499,6 @@ def bug_url(self) -> str: FieldTrial('WebRTC-Audio-AlrProbing', 42220234, date(2024, 4, 1)), - FieldTrial('WebRTC-Audio-FecAdaptation', - 42233254, - date(2024, 4, 1)), FieldTrial('WebRTC-Audio-LegacyOverhead', 42221084, INDEFINITE), @@ -902,7 +911,7 @@ def bug_url(self) -> str: ]) # yapf: disable POLICY_EXEMPT_FIELD_TRIALS_DIGEST: str = \ - 'e10a1af33d0a4cf81a6dc87d963b82cf6092ada3' + '8e2640561e5ff33824da8ecf4f37b34eeaad92f3' REGISTERED_FIELD_TRIALS: FrozenSet[FieldTrial] = ACTIVE_FIELD_TRIALS.union( POLICY_EXEMPT_FIELD_TRIALS) diff --git a/g3doc/become_a_committer.md b/g3doc/become_a_committer.md index fcd1849b6e..725b9faa7a 100644 --- a/g3doc/become_a_committer.md +++ b/g3doc/become_a_committer.md @@ -88,5 +88,5 @@ demonstrate activity and maintain their WebRTC Committer status. [3]: https://webrtc.googlesource.com/src/+/refs/heads/main/g3doc/style-guide.md [4]: https://developers.google.com/open-source/cla/individual?hl=en [5]: https://google.github.io/styleguide/cppguide.html -[6]: https://bugs.chromium.org/p/webrtc/issues/entry?template=Become+WebRTC+committer -[7]: https://bugs.chromium.org/p/webrtc/issues/entry?template=Get+tryjob+access +[6]: https://issues.webrtc.org/issues/new?component=1565136&template=1986141 +[7]: https://issues.webrtc.org/issues/new?component=1565136&template=1986372 diff --git a/g3doc/style-guide.md b/g3doc/style-guide.md index dd4e2cbcac..0ffaef13e4 100644 --- a/g3doc/style-guide.md +++ b/g3doc/style-guide.md @@ -1,5 +1,5 @@ - + # WebRTC coding style guide @@ -123,18 +123,12 @@ In other words, rename the existing function, and provide an inline wrapper using the original name that calls it. That way, callers who are willing to call it using the `DEPRECATED_`-prefixed name don't get the warning. -NOTE 3: Occasionally, with long descriptions, `git cl format` will do the wrong -thing with the attribute. In that case, you can use the -[`ABSL_DEPRECATED` macro][ABSL_DEPRECATED], which is formatted in a more -readable way. - [DEPRECATED]: https://en.cppreference.com/w/cpp/language/attributes/deprecated -[ABSL_DEPRECATED]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/base/attributes.h?q=ABSL_DEPRECATED [ABSL_DEPRECATE_AND_INLINE]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/abseil-cpp/absl/base/macros.h?q=ABSL_DEPRECATE_AND_INLINE ### ArrayView -When passing an array of values to a function, use `webrtc::ArrayView` +When passing an array of values to a function, use `ArrayView` whenever possible—that is, whenever you're not passing ownership of the array, and don't allow the callee to change the array size. @@ -146,7 +140,7 @@ For example, | `const T* ptr, size_t num_elements` | `ArrayView` | | `T* ptr, size_t num_elements` | `ArrayView` | -See the [source code for `webrtc::ArrayView`](api/array_view.h) for more detailed +See the [source code for `ArrayView`](api/array_view.h) for more detailed docs. ### Strings @@ -284,8 +278,8 @@ configuration, only use the following [GN templates][gn-templ]. |------------------|-----------------------------------------------------------------------------------------| | `executable` | `rtc_executable` | | `shared_library` | `rtc_shared_library` | -| `source_set` | `rtc_source_set` (only for header only libraries, for everything else use `rtc_library` | -| `static_library` | `rtc_static_library` (use `rtc_library` unless you really need `rtc_static_library` | +| `source_set` | `rtc_source_set` (only for header only libraries, for everything else use `rtc_library`)| +| `static_library` | `rtc_static_library` (use `rtc_library` unless you really need `rtc_static_library`) | | `test` | `rtc_test` | diff --git a/infra/config/config.star b/infra/config/config.star index ec925311d5..c9e5361484 100755 --- a/infra/config/config.star +++ b/infra/config/config.star @@ -18,20 +18,15 @@ DEFAULT_CPU = "x86-64" # Helpers: -def make_rbe_properties(instance, jobs = None, use_siso = None): +def make_siso_properties(instance, jobs = None): """Makes a default RBE property with the specified argument. Args: instance: RBE insatnce name. jobs: Number of jobs to be used by the builder. - use_siso: Add $build/siso properties to switch from Ninja to Siso. Returns: - A dictonary with the reclient properties. + A dictonary with the siso properties. """ - reclient_props = { - "instance": instance, - "metrics_project": "chromium-reclient-metrics", - } siso_props = { "project": instance, "configs": ["builder"], @@ -40,13 +35,10 @@ def make_rbe_properties(instance, jobs = None, use_siso = None): "enable_monitoring": True, } if jobs: - reclient_props["jobs"] = jobs siso_props["remote_jobs"] = jobs props = { - "$build/reclient": reclient_props, + "$build/siso": siso_props, } - if use_siso: - props["$build/siso"] = siso_props return props def os_from_name(name): @@ -571,7 +563,6 @@ def ci_builder( perf_cat = None, prioritized = False, enabled = True, - use_siso = None, **kwargs): """Add a post-submit builder. @@ -582,7 +573,6 @@ def ci_builder( perf_cat: the category + name for the /perf/ console, or None to omit from the console. prioritized: True to make this builder have a higher priority and never batch builds. enabled: False to exclude this builder from consoles and failure notifications. - use_siso: True to switch build system from Ninja to Siso. **kwargs: Pass on to webrtc_builder / luci.builder. Returns: A luci.builder. @@ -604,7 +594,7 @@ def ci_builder( dimensions["builderless"] = "1" properties = properties or {} properties["builder_group"] = "client.webrtc" - properties.update(make_rbe_properties("rbe-webrtc-trusted", use_siso = use_siso)) + properties.update(make_siso_properties("rbe-webrtc-trusted")) notifies = ["post_submit_failure_notifier", "infra_failure_notifier"] notifies += ["webrtc_tree_closer"] if name not in skipped_lkgr_bots else [] @@ -627,7 +617,6 @@ def try_builder( cq = {}, branch_cq = True, builder = None, - use_siso = None, **kwargs): """Add a pre-submit builder. @@ -638,7 +627,6 @@ def try_builder( cq: None to exclude this from all commit queues, or a dict of kwargs for cq_tryjob_verifier. branch_cq: False to exclude this builder just from the release-branch CQ. builder: builder to set in the dimensions, if None, builderless:1 is used. - use_siso: True to switch build system from Ninja to Siso. **kwargs: Pass on to webrtc_builder / luci.builder. Returns: A luci.builder. @@ -651,7 +639,7 @@ def try_builder( dimensions["builderless"] = "1" properties = properties or {} properties["builder_group"] = "tryserver.webrtc" - properties.update(make_rbe_properties("rbe-webrtc-untrusted", use_siso = use_siso)) + properties.update(make_siso_properties("rbe-webrtc-untrusted")) if cq != None: luci.cq_tryjob_verifier(name, cq_group = "cq", **cq) if branch_cq: @@ -680,7 +668,7 @@ def perf_builder(name, perf_cat, **kwargs): Notifications are also disabled. """ add_milo(name, {"perf": perf_cat}) - properties = make_rbe_properties("rbe-webrtc-trusted") + properties = make_siso_properties("rbe-webrtc-trusted") properties["builder_group"] = "client.webrtc.perf" dimensions = {"pool": "luci.webrtc.perf", "os": "Linux"} return webrtc_builder( @@ -720,7 +708,6 @@ def chromium_try_builder(name, **kwargs): recipe = "chromium_trybot", branch_cq = False, execution_timeout = 3 * time.hour, - use_siso = True, **kwargs ) diff --git a/infra/config/cr-buildbucket.cfg b/infra/config/cr-buildbucket.cfg index 9e2c14b094..3630d8abd1 100644 --- a/infra/config/cr-buildbucket.cfg +++ b/infra/config/cr-buildbucket.cfg @@ -29,9 +29,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -76,9 +81,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -123,9 +133,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -170,9 +185,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -217,9 +237,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -264,9 +289,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -311,9 +341,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -358,9 +393,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -405,9 +445,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -452,9 +497,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -499,9 +549,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -546,9 +601,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -593,9 +653,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -640,9 +705,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -687,9 +757,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -734,9 +809,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -781,9 +861,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -828,9 +913,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -875,9 +965,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -922,9 +1017,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -969,9 +1069,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1016,9 +1121,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1063,9 +1173,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1110,9 +1225,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1157,9 +1277,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1204,9 +1329,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1251,9 +1381,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1298,9 +1433,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1345,9 +1485,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1392,9 +1537,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1439,9 +1589,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1486,9 +1641,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1533,9 +1693,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1580,9 +1745,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1632,9 +1802,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1684,9 +1859,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -1736,13 +1916,18 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' ' "status",' ' "v.test_suite"' ' ]' @@ -2014,9 +2199,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2061,9 +2251,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2108,9 +2303,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2155,9 +2355,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2202,9 +2407,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2249,9 +2459,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2294,9 +2509,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2339,9 +2559,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2384,9 +2609,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2429,9 +2659,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2474,9 +2709,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2519,9 +2759,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2564,9 +2809,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2611,9 +2861,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-trusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-trusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2678,9 +2933,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2725,9 +2985,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2772,9 +3037,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2819,9 +3089,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2866,9 +3141,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -2913,10 +3193,6 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' ' "$build/siso": {' ' "configs": [' ' "builder"' @@ -2969,9 +3245,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3016,9 +3297,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3063,9 +3349,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3110,9 +3401,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3157,9 +3453,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3204,9 +3505,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3251,9 +3557,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3298,9 +3609,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3345,9 +3661,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3392,9 +3713,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3444,9 +3770,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3496,9 +3827,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3548,9 +3884,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3600,11 +3941,16 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' - ' "$recipe_engine/resultdb/test_presentation": {' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' ' "grouping_keys": [' ' "status",' @@ -3647,9 +3993,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3694,10 +4045,6 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' ' "$build/siso": {' ' "configs": [' ' "builder"' @@ -3750,10 +4097,6 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' ' "$build/siso": {' ' "configs": [' ' "builder"' @@ -3806,9 +4149,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3853,9 +4201,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3900,9 +4253,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3947,9 +4305,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -3994,9 +4357,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4041,9 +4409,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4088,9 +4461,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4135,9 +4513,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4182,9 +4565,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4229,9 +4617,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4276,9 +4669,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4323,9 +4721,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4370,9 +4773,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4417,9 +4825,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4464,9 +4877,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4511,9 +4929,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4558,9 +4981,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4605,9 +5033,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4652,10 +5085,6 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' ' "$build/siso": {' ' "configs": [' ' "builder"' @@ -4708,9 +5137,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4755,9 +5189,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4802,9 +5241,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4849,9 +5293,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4896,9 +5345,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4943,9 +5397,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -4990,9 +5449,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5039,10 +5503,6 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' ' "$build/siso": {' ' "configs": [' ' "builder"' @@ -5095,9 +5555,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5142,9 +5607,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5189,9 +5659,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5236,10 +5711,6 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' ' "$build/siso": {' ' "configs": [' ' "builder"' @@ -5292,10 +5763,6 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' - ' },' ' "$build/siso": {' ' "configs": [' ' "builder"' @@ -5348,9 +5815,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5395,9 +5867,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5442,9 +5919,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5489,9 +5971,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5536,9 +6023,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5583,9 +6075,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5630,9 +6127,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5677,9 +6179,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' @@ -5724,9 +6231,14 @@ buckets { } properties: '{' - ' "$build/reclient": {' - ' "instance": "rbe-webrtc-untrusted",' - ' "metrics_project": "chromium-reclient-metrics"' + ' "$build/siso": {' + ' "configs": [' + ' "builder"' + ' ],' + ' "enable_cloud_profiler": true,' + ' "enable_cloud_trace": true,' + ' "enable_monitoring": true,' + ' "project": "rbe-webrtc-untrusted"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],' diff --git a/infra/config/project.cfg b/infra/config/project.cfg index fae10a3043..24599b5d9e 100644 --- a/infra/config/project.cfg +++ b/infra/config/project.cfg @@ -7,7 +7,7 @@ name: "webrtc" access: "group:all" lucicfg { - version: "1.44.1" + version: "1.45.0" package_dir: "." config_dir: "." entry_point: "config.star" diff --git a/logging/BUILD.gn b/logging/BUILD.gn index ea483b29a1..a56f9266e4 100644 --- a/logging/BUILD.gn +++ b/logging/BUILD.gn @@ -547,6 +547,11 @@ if (rtc_enable_protobuf) { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", ] + + # Normally public deps should not be used, but the proto must be included + # by all targets depending on rtc_event_log_parser. + public_deps += # no-presubmit-check TODO(webrtc:8603) + [ ":rtc_event_log_proto" ] } if (rtc_include_tests) { diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc index d6fce461d0..38bf7cf165 100644 --- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc +++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc @@ -170,19 +170,19 @@ bool ConvertToProtoFormat(const std::vector& extensions, } rtclog2::DtlsTransportStateEvent::DtlsTransportState ConvertToProtoFormat( - webrtc::DtlsTransportState state) { + DtlsTransportState state) { switch (state) { - case webrtc::DtlsTransportState::kNew: + case DtlsTransportState::kNew: return rtclog2::DtlsTransportStateEvent::DTLS_TRANSPORT_NEW; - case webrtc::DtlsTransportState::kConnecting: + case DtlsTransportState::kConnecting: return rtclog2::DtlsTransportStateEvent::DTLS_TRANSPORT_CONNECTING; - case webrtc::DtlsTransportState::kConnected: + case DtlsTransportState::kConnected: return rtclog2::DtlsTransportStateEvent::DTLS_TRANSPORT_CONNECTED; - case webrtc::DtlsTransportState::kClosed: + case DtlsTransportState::kClosed: return rtclog2::DtlsTransportStateEvent::DTLS_TRANSPORT_CLOSED; - case webrtc::DtlsTransportState::kFailed: + case DtlsTransportState::kFailed: return rtclog2::DtlsTransportStateEvent::DTLS_TRANSPORT_FAILED; - case webrtc::DtlsTransportState::kNumValues: + case DtlsTransportState::kNumValues: RTC_DCHECK_NOTREACHED(); } RTC_DCHECK_NOTREACHED(); diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index aff018197a..61ab4f5ec9 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -1123,8 +1123,7 @@ ParsedRtcEventLog::LoggedRtpStreamView::LoggedRtpStreamView( // is not stored in the event log. // TODO(ivoc): Remove this once this mapping is stored in the event log for // audio streams. Tracking bug: webrtc:6399 -webrtc::RtpHeaderExtensionMap -ParsedRtcEventLog::GetDefaultHeaderExtensionMap() { +RtpHeaderExtensionMap ParsedRtcEventLog::GetDefaultHeaderExtensionMap() { // Values from before the default RTP header extension IDs were removed. constexpr int kAudioLevelDefaultId = 1; constexpr int kTimestampOffsetDefaultId = 2; @@ -1136,7 +1135,7 @@ ParsedRtcEventLog::GetDefaultHeaderExtensionMap() { constexpr int kVideoTimingDefaultId = 8; constexpr int kDependencyDescriptorDefaultId = 9; - webrtc::RtpHeaderExtensionMap default_map(/*extmap_allow_mixed=*/true); + RtpHeaderExtensionMap default_map(/*extmap_allow_mixed=*/true); default_map.Register(kAudioLevelDefaultId); default_map.Register(kTimestampOffsetDefaultId); default_map.Register(kAbsSendTimeDefaultId); diff --git a/media/BUILD.gn b/media/BUILD.gn index 8042a7ce34..47782316a6 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -174,7 +174,6 @@ rtc_library("video_adapter") { "../rtc_base:timeutils", "../rtc_base/synchronization:mutex", "../rtc_base/system:rtc_export", - "../system_wrappers:field_trial", ] } @@ -222,7 +221,6 @@ rtc_library("video_common") { deps = [ "../api:array_view", "../rtc_base:checks", - "../rtc_base:macromagic", "../rtc_base:stringutils", "../rtc_base:timeutils", "../rtc_base/system:rtc_export", @@ -545,7 +543,6 @@ rtc_library("rtc_internal_video_codecs") { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base/system:rtc_export", - "../system_wrappers:field_trial", "../test:fake_video_codecs", "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings", @@ -681,6 +678,11 @@ rtc_library("rtc_audio_video") { public_configs += [ ":rtc_media_defines_config" ] deps += [ "../modules/video_capture:video_capture_internal_impl" ] } + + if (rtc_include_internal_audio_device) { + deps += [ "../api/audio:create_audio_device_module" ] + } + if (rtc_enable_protobuf) { deps += [ "../modules/audio_coding:ana_config_proto", @@ -774,7 +776,6 @@ rtc_library("rtc_data_sctp_transport_factory") { deps += [ ":rtc_data_dcsctp_transport", "../system_wrappers", - "../system_wrappers:field_trial", ] } } @@ -1030,7 +1031,6 @@ if (rtc_include_tests) { "../rtc_base:checks", "../rtc_base:copy_on_write_buffer", "../rtc_base:dscp", - "../rtc_base:macromagic", "../rtc_base:safe_conversions", "../rtc_base:socket", "../rtc_base:threading", @@ -1039,7 +1039,6 @@ if (rtc_include_tests) { "../rtc_base/experiments:min_video_bitrate_experiment", "../rtc_base/system:file_wrapper", "../system_wrappers", - "../system_wrappers:field_trial", "../test:audio_codec_mocks", "../test:fake_video_codecs", "../test:field_trial", diff --git a/media/base/adapted_video_track_source.cc b/media/base/adapted_video_track_source.cc index f015956d19..c2ec91b1fd 100644 --- a/media/base/adapted_video_track_source.cc +++ b/media/base/adapted_video_track_source.cc @@ -53,13 +53,13 @@ void AdaptedVideoTrackSource::OnFrame(const VideoFrame& frame) { true was just added. The VideoBroadcaster enforces synchronization for us in this case, by not passing the frame on to sinks which don't want it. */ - if (apply_rotation() && frame.rotation() != webrtc::kVideoRotation_0 && + if (apply_rotation() && frame.rotation() != kVideoRotation_0 && buffer->type() == VideoFrameBuffer::Type::kI420) { /* Apply pending rotation. */ VideoFrame rotated_frame(frame); rotated_frame.set_video_frame_buffer( I420Buffer::Rotate(*buffer->GetI420(), frame.rotation())); - rotated_frame.set_rotation(webrtc::kVideoRotation_0); + rotated_frame.set_rotation(kVideoRotation_0); broadcaster_.OnFrame(rotated_frame); } else { broadcaster_.OnFrame(frame); @@ -109,7 +109,7 @@ bool AdaptedVideoTrackSource::AdaptFrame(int width, } if (!video_adapter_.AdaptFrameResolution( - width, height, time_us * webrtc::kNumNanosecsPerMicrosec, crop_width, + width, height, time_us * kNumNanosecsPerMicrosec, crop_width, crop_height, out_width, out_height)) { broadcaster_.OnDiscardedFrame(); // VideoAdapter dropped the frame. diff --git a/media/base/codec.cc b/media/base/codec.cc index b0b6a81cb9..f97f082fd9 100644 --- a/media/base/codec.cc +++ b/media/base/codec.cc @@ -110,9 +110,16 @@ Codec::Codec(Type type, name(name), clockrate(clockrate), bitrate(0), - channels(channels) {} + channels(channels) { + RTC_DCHECK_GT(clockrate, 0); +} -Codec::Codec(Type type) : Codec(type, kIdNotSet, "", 0) {} +Codec::Codec(Type type) + : Codec(type, + kIdNotSet, + "", + type == Type::kVideo ? kDefaultVideoClockRateHz + : kDefaultAudioClockRateHz) {} Codec::Codec(const webrtc::SdpAudioFormat& c) : Codec(Type::kAudio, kIdNotSet, c.name, c.clockrate_hz, c.num_channels) { @@ -285,7 +292,8 @@ std::string Codec::ToString() const { } Codec CreateAudioRtxCodec(int rtx_payload_type, int associated_payload_type) { - Codec rtx_codec = CreateAudioCodec(rtx_payload_type, kRtxCodecName, 0, 1); + Codec rtx_codec = CreateAudioCodec(rtx_payload_type, kRtxCodecName, + kDefaultAudioClockRateHz, 1); rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); return rtx_codec; } diff --git a/media/base/codec.h b/media/base/codec.h index 029b93c6ae..9566f37e73 100644 --- a/media/base/codec.h +++ b/media/base/codec.h @@ -16,7 +16,6 @@ #include #include -#include "absl/base/macros.h" #include "absl/container/inlined_vector.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" @@ -68,6 +67,8 @@ class FeedbackParams { std::vector params_; }; +constexpr int kDefaultVideoClockRateHz = 90'000; +constexpr int kDefaultAudioClockRateHz = 8'000; struct RTC_EXPORT Codec { enum class Type { @@ -172,6 +173,8 @@ struct RTC_EXPORT Codec { std::string ToString() const; + // Default constructor, for initialization. + Codec() : Codec(Type::kAudio, kIdNotSet, "", kDefaultAudioClockRateHz) {} Codec& operator=(const Codec& c); Codec& operator=(Codec&& c); diff --git a/media/base/codec_comparators.cc b/media/base/codec_comparators.cc index 3dbf316ebf..02ed96ac7c 100644 --- a/media/base/codec_comparators.cc +++ b/media/base/codec_comparators.cc @@ -313,22 +313,18 @@ bool MatchesWithCodecRules(const Codec& left_codec, const Codec& right_codec) { auto matches_type_specific = [&]() { switch (left_codec.type) { case Codec::Type::kAudio: - // If a nonzero clockrate is specified, it must match the actual - // clockrate. If a nonzero bitrate is specified, it must match the + // If a nonzero bitrate is specified, it must match the // actual bitrate, unless the codec is VBR (0), where we just force the // supplied value. The number of channels must match exactly, with the // exception that channels=0 is treated synonymously as channels=1, per // RFC 4566 section 6: " [The channels] parameter is OPTIONAL and may be // omitted if the number of channels is one." // Preference is ignored. - // TODO(juberti): Treat a zero clockrate as 8000Hz, the RTP default - // clockrate. - return ((right_codec.clockrate == 0 /*&& clockrate == 8000*/) || - left_codec.clockrate == right_codec.clockrate) && - (right_codec.bitrate == 0 || left_codec.bitrate <= 0 || - left_codec.bitrate == right_codec.bitrate) && - ((right_codec.channels < 2 && left_codec.channels < 2) || - left_codec.channels == right_codec.channels); + return ((left_codec.clockrate == right_codec.clockrate) && + (right_codec.bitrate == 0 || left_codec.bitrate <= 0 || + left_codec.bitrate == right_codec.bitrate) && + ((right_codec.channels < 2 && left_codec.channels < 2) || + left_codec.channels == right_codec.channels)); case Codec::Type::kVideo: return IsSameCodecSpecific(left_codec.name, left_codec.params, @@ -398,14 +394,13 @@ bool IsSameRtpCodecIgnoringLevel(const Codec& codec, // Some video codecs are compatible with others (e.g. same profile but // different level). This comparison looks at the relevant parameters, // ignoring ones that are either irrelevant or unrecognized. - if (rtp_codec.kind == webrtc::MediaType::VIDEO && rtp_codec.IsMediaCodec()) { + if (rtp_codec.kind == MediaType::VIDEO && rtp_codec.IsMediaCodec()) { return IsSameCodecSpecific(rtp_codec.name, params1, rtp_codec2.name, params2); } // audio/RED should ignore the parameters which specify payload types so // can not be compared. - if (rtp_codec.kind == webrtc::MediaType::AUDIO && - rtp_codec.name == kRedCodecName) { + if (rtp_codec.kind == MediaType::AUDIO && rtp_codec.name == kRedCodecName) { return true; } diff --git a/media/base/codec_comparators_unittest.cc b/media/base/codec_comparators_unittest.cc index 214bff85a7..67b630aebc 100644 --- a/media/base/codec_comparators_unittest.cc +++ b/media/base/codec_comparators_unittest.cc @@ -342,7 +342,6 @@ TEST(CodecTest, TestCodecMatches) { EXPECT_TRUE(c0.Matches(CreateAudioCodec(34, "", 44100, 1))); EXPECT_TRUE(c0.Matches(CreateAudioCodec(34, "", 44100, 0))); EXPECT_TRUE(c0.Matches(CreateAudioCodec(34, "", 44100, 0))); - EXPECT_TRUE(c0.Matches(CreateAudioCodec(34, "", 0, 0))); EXPECT_FALSE(c0.Matches(CreateAudioCodec(96, "A", 44100, 1))); EXPECT_FALSE(c0.Matches(CreateAudioCodec(96, "", 44100, 1))); EXPECT_FALSE(c0.Matches(CreateAudioCodec(95, "", 55100, 1))); @@ -352,15 +351,15 @@ TEST(CodecTest, TestCodecMatches) { // Test a codec with a dynamic payload type. Codec c1 = CreateAudioCodec(96, "A", 44100, 1); - EXPECT_TRUE(c1.Matches(CreateAudioCodec(96, "A", 0, 0))); - EXPECT_TRUE(c1.Matches(CreateAudioCodec(97, "A", 0, 0))); - EXPECT_TRUE(c1.Matches(CreateAudioCodec(96, "a", 0, 0))); - EXPECT_TRUE(c1.Matches(CreateAudioCodec(97, "a", 0, 0))); - EXPECT_TRUE(c1.Matches(CreateAudioCodec(35, "a", 0, 0))); - EXPECT_TRUE(c1.Matches(CreateAudioCodec(42, "a", 0, 0))); - EXPECT_TRUE(c1.Matches(CreateAudioCodec(65, "a", 0, 0))); - EXPECT_FALSE(c1.Matches(CreateAudioCodec(95, "A", 0, 0))); - EXPECT_FALSE(c1.Matches(CreateAudioCodec(34, "A", 0, 0))); + EXPECT_TRUE(c1.Matches(CreateAudioCodec(96, "A", 44100, 0))); + EXPECT_TRUE(c1.Matches(CreateAudioCodec(97, "A", 44100, 0))); + EXPECT_TRUE(c1.Matches(CreateAudioCodec(96, "a", 44100, 0))); + EXPECT_TRUE(c1.Matches(CreateAudioCodec(97, "a", 44100, 0))); + EXPECT_TRUE(c1.Matches(CreateAudioCodec(35, "a", 44100, 0))); + EXPECT_TRUE(c1.Matches(CreateAudioCodec(42, "a", 44100, 0))); + EXPECT_TRUE(c1.Matches(CreateAudioCodec(65, "a", 44100, 0))); + EXPECT_FALSE(c1.Matches(CreateAudioCodec(95, "A", 44100, 0))); + EXPECT_FALSE(c1.Matches(CreateAudioCodec(34, "A", 44100, 0))); EXPECT_FALSE(c1.Matches(CreateAudioCodec(96, "", 44100, 2))); EXPECT_FALSE(c1.Matches(CreateAudioCodec(96, "A", 55100, 1))); @@ -390,8 +389,7 @@ TEST(CodecTest, TestOpusAudioCodecWithDifferentParameters) { // Matches does not compare parameters for audio. EXPECT_TRUE(opus_with_fec.Matches(opus_without_fec)); - webrtc::RtpCodecParameters rtp_opus_with_fec = - opus_with_fec.ToCodecParameters(); + RtpCodecParameters rtp_opus_with_fec = opus_with_fec.ToCodecParameters(); // MatchesRtpCodec takes parameters into account. EXPECT_TRUE(opus_with_fec.MatchesRtpCodec(rtp_opus_with_fec)); EXPECT_FALSE(opus_without_fec.MatchesRtpCodec(rtp_opus_with_fec)); @@ -480,19 +478,19 @@ TEST(CodecTest, TestVP9CodecMatches) { Codec c_no_profile = CreateVideoCodec(95, kVp9CodecName); Codec c_profile0 = CreateVideoCodec(95, kVp9CodecName); - c_profile0.params[webrtc::kVP9FmtpProfileId] = kProfile0; + c_profile0.params[kVP9FmtpProfileId] = kProfile0; EXPECT_TRUE(c_profile0.Matches(c_no_profile)); { Codec c_profile0_eq = CreateVideoCodec(95, kVp9CodecName); - c_profile0_eq.params[webrtc::kVP9FmtpProfileId] = kProfile0; + c_profile0_eq.params[kVP9FmtpProfileId] = kProfile0; EXPECT_TRUE(c_profile0.Matches(c_profile0_eq)); } { Codec c_profile2 = CreateVideoCodec(95, kVp9CodecName); - c_profile2.params[webrtc::kVP9FmtpProfileId] = kProfile2; + c_profile2.params[kVP9FmtpProfileId] = kProfile2; EXPECT_FALSE(c_profile0.Matches(c_profile2)); EXPECT_FALSE(c_no_profile.Matches(c_profile2)); } diff --git a/media/base/codec_list.cc b/media/base/codec_list.cc index 14f8fbde54..30c6c5f16a 100644 --- a/media/base/codec_list.cc +++ b/media/base/codec_list.cc @@ -23,9 +23,6 @@ namespace webrtc { -using webrtc::RTCError; -using webrtc::RTCErrorOr; -using webrtc::RTCErrorType; namespace { @@ -36,14 +33,17 @@ RTCError CheckInputConsistency(const std::vector& codecs) { for (size_t i = 0; i < codecs.size(); i++) { const Codec& codec = codecs[i]; if (codec.id != Codec::kIdNotSet) { - bool inserted = pt_to_index.insert({codec.id, i}).second; - if (!inserted) { + auto [it, success] = pt_to_index.insert({codec.id, i}); + if (!success) { + RTC_LOG(LS_ERROR) << "Duplicate payload type in codec list, " << codec + << " and " << codecs[it->second] + << " have the same ID"; LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "Duplicate payload type in codec list"); } } } - for (const webrtc::Codec& codec : codecs) { + for (const Codec& codec : codecs) { switch (codec.GetResiliencyType()) { case Codec::ResiliencyType::kRed: // Check that the target codec exists @@ -71,7 +71,7 @@ RTCError CheckInputConsistency(const std::vector& codecs) { break; } int associated_pt; - if (!(webrtc::FromString(apt_it->second, &associated_pt))) { + if (!(FromString(apt_it->second, &associated_pt))) { RTC_LOG(LS_ERROR) << "Non-numeric argument to rtx apt: " << codec << " apt=" << apt_it->second; LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, diff --git a/media/base/codec_list_unittest.cc b/media/base/codec_list_unittest.cc index 161b59d788..b7bc1dde47 100644 --- a/media/base/codec_list_unittest.cc +++ b/media/base/codec_list_unittest.cc @@ -22,8 +22,6 @@ namespace webrtc { namespace { -using webrtc::RTCErrorOr; -using webrtc::RTCErrorType; TEST(CodecList, StoreAndRecall) { CodecList empty_list = CodecList::CreateFromTrustedData(std::vector{}); @@ -36,7 +34,7 @@ TEST(CodecList, StoreAndRecall) { } TEST(CodecList, RejectIllegalConstructorArguments) { - std::vector apt_without_number{webrtc::CreateVideoCodec( + std::vector apt_without_number{CreateVideoCodec( {SdpVideoFormat{"rtx", CodecParameterMap{{"apt", "not-a-number"}}}})}; apt_without_number[0].id = 96; RTCErrorOr checked_codec_list = @@ -54,7 +52,7 @@ TEST(CodecList, CrashOnIllegalConstructorArguments) { // Checks that can't be enabled log things instead. // Note: DCHECK is on in some release builds, so we can't use // EXPECT_DEBUG_DEATH here. - std::vector apt_without_number{webrtc::CreateVideoCodec( + std::vector apt_without_number{CreateVideoCodec( {SdpVideoFormat{"rtx", CodecParameterMap{{"apt", "not-a-number"}}}})}; apt_without_number[0].id = 96; #if RTC_DCHECK_IS_ON diff --git a/media/base/codec_unittest.cc b/media/base/codec_unittest.cc index e00b08d8c2..231198daa5 100644 --- a/media/base/codec_unittest.cc +++ b/media/base/codec_unittest.cc @@ -65,7 +65,7 @@ TEST(CodecTest, TestCodecOperators) { EXPECT_TRUE(c0 != c1); TestCodec c5; - TestCodec c6(Codec::kIdNotSet, "", 0); + TestCodec c6(Codec::kIdNotSet, "", kDefaultAudioClockRateHz); EXPECT_TRUE(c5 == c6); } @@ -83,7 +83,7 @@ TEST(CodecTest, TestAudioCodecOperators) { EXPECT_NE(c0, c4); EXPECT_NE(c0, c5); - Codec c8 = CreateAudioCodec(0, "", 0, 0); + Codec c8 = CreateAudioCodec(0, "", kDefaultAudioClockRateHz, 0); Codec c9 = c0; EXPECT_EQ(c9, c0); @@ -254,9 +254,9 @@ TEST(CodecTest, TestValidateCodecFormat) { TEST(CodecTest, TestToCodecParameters) { Codec v = CreateVideoCodec(96, "V"); v.SetParam("p1", "v1"); - webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters(); + RtpCodecParameters codec_params_1 = v.ToCodecParameters(); EXPECT_EQ(96, codec_params_1.payload_type); - EXPECT_EQ(webrtc::MediaType::VIDEO, codec_params_1.kind); + EXPECT_EQ(MediaType::VIDEO, codec_params_1.kind); EXPECT_EQ("V", codec_params_1.name); EXPECT_EQ(kVideoCodecClockrate, codec_params_1.clock_rate); EXPECT_EQ(std::nullopt, codec_params_1.num_channels); @@ -266,9 +266,9 @@ TEST(CodecTest, TestToCodecParameters) { Codec a = CreateAudioCodec(97, "A", 44100, 2); a.SetParam("p1", "a1"); - webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters(); + RtpCodecParameters codec_params_2 = a.ToCodecParameters(); EXPECT_EQ(97, codec_params_2.payload_type); - EXPECT_EQ(webrtc::MediaType::AUDIO, codec_params_2.kind); + EXPECT_EQ(MediaType::AUDIO, codec_params_2.kind); EXPECT_EQ("A", codec_params_2.name); EXPECT_EQ(44100, codec_params_2.clock_rate); EXPECT_EQ(2, codec_params_2.num_channels); @@ -278,22 +278,21 @@ TEST(CodecTest, TestToCodecParameters) { } TEST(CodecTest, H264CostrainedBaselineIsAddedIfH264IsSupported) { - const std::vector kExplicitlySupportedFormats = { - webrtc::CreateH264Format(webrtc::H264Profile::kProfileBaseline, - webrtc::H264Level::kLevel3_1, "1"), - webrtc::CreateH264Format(webrtc::H264Profile::kProfileBaseline, - webrtc::H264Level::kLevel3_1, "0")}; - - std::vector supported_formats = - kExplicitlySupportedFormats; + const std::vector kExplicitlySupportedFormats = { + CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1, + "1"), + CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1, + "0")}; + + std::vector supported_formats = kExplicitlySupportedFormats; AddH264ConstrainedBaselineProfileToSupportedFormats(&supported_formats); - const webrtc::SdpVideoFormat kH264ConstrainedBasedlinePacketization1 = - webrtc::CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, - webrtc::H264Level::kLevel3_1, "1"); - const webrtc::SdpVideoFormat kH264ConstrainedBasedlinePacketization0 = - webrtc::CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, - webrtc::H264Level::kLevel3_1, "0"); + const SdpVideoFormat kH264ConstrainedBasedlinePacketization1 = + CreateH264Format(H264Profile::kProfileConstrainedBaseline, + H264Level::kLevel3_1, "1"); + const SdpVideoFormat kH264ConstrainedBasedlinePacketization0 = + CreateH264Format(H264Profile::kProfileConstrainedBaseline, + H264Level::kLevel3_1, "0"); EXPECT_EQ(supported_formats[0], kExplicitlySupportedFormats[0]); EXPECT_EQ(supported_formats[1], kExplicitlySupportedFormats[1]); @@ -302,13 +301,11 @@ TEST(CodecTest, H264CostrainedBaselineIsAddedIfH264IsSupported) { } TEST(CodecTest, H264CostrainedBaselineIsNotAddedIfH264IsUnsupported) { - const std::vector kExplicitlySupportedFormats = { + const std::vector kExplicitlySupportedFormats = { {kVp9CodecName, - {{webrtc::kVP9FmtpProfileId, - VP9ProfileToString(webrtc::VP9Profile::kProfile0)}}}}; + {{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}}}}; - std::vector supported_formats = - kExplicitlySupportedFormats; + std::vector supported_formats = kExplicitlySupportedFormats; AddH264ConstrainedBaselineProfileToSupportedFormats(&supported_formats); EXPECT_EQ(supported_formats[0], kExplicitlySupportedFormats[0]); @@ -316,18 +313,17 @@ TEST(CodecTest, H264CostrainedBaselineIsNotAddedIfH264IsUnsupported) { } TEST(CodecTest, H264CostrainedBaselineNotAddedIfAlreadySpecified) { - const std::vector kExplicitlySupportedFormats = { - webrtc::CreateH264Format(webrtc::H264Profile::kProfileBaseline, - webrtc::H264Level::kLevel3_1, "1"), - webrtc::CreateH264Format(webrtc::H264Profile::kProfileBaseline, - webrtc::H264Level::kLevel3_1, "0"), - webrtc::CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, - webrtc::H264Level::kLevel3_1, "1"), - webrtc::CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, - webrtc::H264Level::kLevel3_1, "0")}; - - std::vector supported_formats = - kExplicitlySupportedFormats; + const std::vector kExplicitlySupportedFormats = { + CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1, + "1"), + CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1, + "0"), + CreateH264Format(H264Profile::kProfileConstrainedBaseline, + H264Level::kLevel3_1, "1"), + CreateH264Format(H264Profile::kProfileConstrainedBaseline, + H264Level::kLevel3_1, "0")}; + + std::vector supported_formats = kExplicitlySupportedFormats; AddH264ConstrainedBaselineProfileToSupportedFormats(&supported_formats); EXPECT_EQ(supported_formats[0], kExplicitlySupportedFormats[0]); diff --git a/media/base/fake_frame_source.cc b/media/base/fake_frame_source.cc index 41a014313f..7c87553985 100644 --- a/media/base/fake_frame_source.cc +++ b/media/base/fake_frame_source.cc @@ -48,12 +48,12 @@ void FakeFrameSource::SetRotation(VideoRotation rotation) { VideoFrame FakeFrameSource::GetFrameRotationApplied() { switch (rotation_) { - case webrtc::kVideoRotation_0: - case webrtc::kVideoRotation_180: - return GetFrame(width_, height_, webrtc::kVideoRotation_0, interval_us_); - case webrtc::kVideoRotation_90: - case webrtc::kVideoRotation_270: - return GetFrame(height_, width_, webrtc::kVideoRotation_0, interval_us_); + case kVideoRotation_0: + case kVideoRotation_180: + return GetFrame(width_, height_, kVideoRotation_0, interval_us_); + case kVideoRotation_90: + case kVideoRotation_270: + return GetFrame(height_, width_, kVideoRotation_0, interval_us_); } RTC_DCHECK_NOTREACHED() << "Invalid rotation value: " << static_cast(rotation_); diff --git a/media/base/fake_media_engine.cc b/media/base/fake_media_engine.cc index 5485c02441..9a9b0c1611 100644 --- a/media/base/fake_media_engine.cc +++ b/media/base/fake_media_engine.cc @@ -47,7 +47,6 @@ #include "rtc_base/system/file_wrapper.h" namespace webrtc { -using webrtc::TaskQueueBase; FakeVoiceMediaReceiveChannel::DtmfInfo::DtmfInfo(uint32_t ssrc, int event_code, @@ -495,7 +494,7 @@ bool FakeVideoMediaReceiveChannel::AddRecvStream(const StreamParams& sp) { if (!RtpReceiveChannelHelper< VideoMediaReceiveChannelInterface>::AddRecvStream(sp)) return false; - sinks_[sp.first_ssrc()] = NULL; + sinks_[sp.first_ssrc()] = nullptr; output_delays_[sp.first_ssrc()] = 0; return true; } @@ -561,12 +560,11 @@ bool FakeVideoMediaReceiveChannel::GetStats(VideoMediaReceiveInfo* /* info */) { } FakeVoiceEngine::FakeVoiceEngine() - : encoder_factory_(webrtc::make_ref_counted(this)), - decoder_factory_( - webrtc::make_ref_counted(this)) { + : encoder_factory_(make_ref_counted(this)), + decoder_factory_(make_ref_counted(this)) { // Add a fake audio codec. Note that the name must not be "" as there are // sanity checks against that. - SetCodecs({webrtc::CreateAudioCodec(101, "fake_audio_codec", 8000, 1)}); + SetCodecs({CreateAudioCodec(101, "fake_audio_codec", 8000, 1)}); } void FakeVoiceEngine::Init() {} scoped_refptr FakeVoiceEngine::GetAudioState() const { @@ -635,8 +633,8 @@ void FakeVoiceEngine::SetRtpHeaderExtensions( FakeVideoEngine::FakeVideoEngine() : capture_(false) { // Add a fake video codec. Note that the name must not be "" as there are // sanity checks against that. - send_codecs_.push_back(webrtc::CreateVideoCodec(111, "fake_video_codec")); - recv_codecs_.push_back(webrtc::CreateVideoCodec(111, "fake_video_codec")); + send_codecs_.push_back(CreateVideoCodec(111, "fake_video_codec")); + recv_codecs_.push_back(CreateVideoCodec(111, "fake_video_codec")); } bool FakeVideoEngine::SetOptions(const VideoOptions& options) { options_ = options; diff --git a/media/base/media_channel_impl.cc b/media/base/media_channel_impl.cc index 40da627b4b..b88007703c 100644 --- a/media/base/media_channel_impl.cc +++ b/media/base/media_channel_impl.cc @@ -19,9 +19,6 @@ #include "api/array_view.h" #include "api/audio_options.h" #include "api/call/transport.h" -#include "api/crypto/frame_decryptor_interface.h" -#include "api/crypto/frame_encryptor_interface.h" -#include "api/frame_transformer_interface.h" #include "api/media_stream_interface.h" #include "api/rtc_error.h" #include "api/rtp_sender_interface.h" @@ -173,15 +170,32 @@ MediaChannelUtil::TransportForMediaChannels::~TransportForMediaChannels() { RTC_DCHECK(!network_interface_); } +AsyncSocketPacketOptions +MediaChannelUtil::TransportForMediaChannels::TranslatePacketOptions( + const PacketOptions& options) { + AsyncSocketPacketOptions rtc_options; + rtc_options.packet_id = options.packet_id; + if (DscpEnabled()) { + rtc_options.dscp = PreferredDscp(); + } + rtc_options.info_signaled_after_sent.included_in_feedback = + options.included_in_feedback; + rtc_options.info_signaled_after_sent.included_in_allocation = + options.included_in_allocation; + rtc_options.info_signaled_after_sent.is_media = options.is_media; + rtc_options.ecn_1 = options.send_as_ect1; + rtc_options.batchable = options.batchable; + rtc_options.last_packet_in_batch = options.last_packet_in_batch; + return rtc_options; +} + bool MediaChannelUtil::TransportForMediaChannels::SendRtcp( - ArrayView packet) { - auto send = [this, packet = CopyOnWriteBuffer( - packet, webrtc::kMaxRtpPacketLen)]() mutable { - AsyncSocketPacketOptions rtc_options; - if (DscpEnabled()) { - rtc_options.dscp = PreferredDscp(); - } - DoSendPacket(&packet, true, rtc_options); + ArrayView packet, + const PacketOptions& options) { + auto send = [this, + packet = CopyOnWriteBuffer(packet, webrtc::kMaxRtpPacketLen), + options]() mutable { + DoSendPacket(&packet, true, TranslatePacketOptions(options)); }; if (network_thread_->IsCurrent()) { @@ -195,28 +209,10 @@ bool MediaChannelUtil::TransportForMediaChannels::SendRtcp( bool MediaChannelUtil::TransportForMediaChannels::SendRtp( ArrayView packet, const webrtc::PacketOptions& options) { - auto send = [this, packet_id = options.packet_id, - included_in_feedback = options.included_in_feedback, - included_in_allocation = options.included_in_allocation, - batchable = options.batchable, - last_packet_in_batch = options.last_packet_in_batch, - is_media = options.is_media, ect_1 = options.send_as_ect1, - packet = CopyOnWriteBuffer(packet, - webrtc::kMaxRtpPacketLen)]() mutable { - AsyncSocketPacketOptions rtc_options; - rtc_options.packet_id = packet_id; - if (DscpEnabled()) { - rtc_options.dscp = PreferredDscp(); - } - rtc_options.info_signaled_after_sent.included_in_feedback = - included_in_feedback; - rtc_options.info_signaled_after_sent.included_in_allocation = - included_in_allocation; - rtc_options.info_signaled_after_sent.is_media = is_media; - rtc_options.ecn_1 = ect_1; - rtc_options.batchable = batchable; - rtc_options.last_packet_in_batch = last_packet_in_batch; - DoSendPacket(&packet, false, rtc_options); + auto send = [this, + packet = CopyOnWriteBuffer(packet, webrtc::kMaxRtpPacketLen), + options]() mutable { + DoSendPacket(&packet, false, TranslatePacketOptions(options)); }; // TODO(bugs.webrtc.org/11993): ModuleRtpRtcpImpl2 and related classes (e.g. diff --git a/media/base/media_channel_impl.h b/media/base/media_channel_impl.h index 3c30e6bd1e..8c222b23b7 100644 --- a/media/base/media_channel_impl.h +++ b/media/base/media_channel_impl.h @@ -91,7 +91,8 @@ class MediaChannelUtil { // Implementation of webrtc::Transport bool SendRtp(ArrayView packet, const PacketOptions& options) override; - bool SendRtcp(ArrayView packet) override; + bool SendRtcp(ArrayView packet, + const PacketOptions& options) override; // Not implementation of webrtc::Transport void SetInterface(MediaChannelNetworkInterface* iface); @@ -99,6 +100,8 @@ class MediaChannelUtil { int SetOption(MediaChannelNetworkInterface::SocketType type, Socket::Option opt, int option); + AsyncSocketPacketOptions TranslatePacketOptions( + const PacketOptions& options); bool DoSendPacket(CopyOnWriteBuffer* packet, bool rtcp, diff --git a/media/base/media_engine.cc b/media/base/media_engine.cc index f1f5173027..e9d9c6c72a 100644 --- a/media/base/media_engine.cc +++ b/media/base/media_engine.cc @@ -40,10 +40,9 @@ bool SupportsMode(const Codec& codec, if (!scalability_mode.has_value()) { return true; } - return absl::c_any_of( - codec.scalability_modes, [&](webrtc::ScalabilityMode mode) { - return ScalabilityModeToString(mode) == *scalability_mode; - }); + return absl::c_any_of(codec.scalability_modes, [&](ScalabilityMode mode) { + return ScalabilityModeToString(mode) == *scalability_mode; + }); } } // namespace @@ -90,8 +89,6 @@ std::vector GetDefaultEnabledRtpHeaderExtensions( RTCError CheckScalabilityModeValues(const RtpParameters& rtp_parameters, ArrayView send_codecs, std::optional send_codec) { - using webrtc::RTCErrorType; - if (send_codecs.empty()) { // This is an audio sender or an extra check in the stack where the codec // list is not available and we can't check the scalability_mode values. @@ -101,7 +98,7 @@ RTCError CheckScalabilityModeValues(const RtpParameters& rtp_parameters, for (size_t i = 0; i < rtp_parameters.encodings.size(); ++i) { if (rtp_parameters.encodings[i].codec) { bool codecFound = false; - for (const webrtc::Codec& codec : send_codecs) { + for (const Codec& codec : send_codecs) { if (IsSameRtpCodecIgnoringLevel(codec, *rtp_parameters.encodings[i].codec) && SupportsMode(codec, rtp_parameters.encodings[i].scalability_mode)) { @@ -120,7 +117,7 @@ RTCError CheckScalabilityModeValues(const RtpParameters& rtp_parameters, if (rtp_parameters.encodings[i].scalability_mode) { if (!send_codec) { bool scalabilityModeFound = false; - for (const webrtc::Codec& codec : send_codecs) { + for (const Codec& codec : send_codecs) { for (const auto& scalability_mode : codec.scalability_modes) { if (ScalabilityModeToString(scalability_mode) == *rtp_parameters.encodings[i].scalability_mode) { @@ -164,8 +161,6 @@ RTCError CheckRtpParametersValues(const RtpParameters& rtp_parameters, ArrayView send_codecs, std::optional send_codec, const FieldTrialsView& field_trials) { - using webrtc::RTCErrorType; - bool has_scale_resolution_down_to = false; for (size_t i = 0; i < rtp_parameters.encodings.size(); ++i) { if (rtp_parameters.encodings[i].bitrate_priority <= 0) { @@ -198,7 +193,7 @@ RTCError CheckRtpParametersValues(const RtpParameters& rtp_parameters, if (rtp_parameters.encodings[i].num_temporal_layers) { if (*rtp_parameters.encodings[i].num_temporal_layers < 1 || *rtp_parameters.encodings[i].num_temporal_layers > - webrtc::kMaxTemporalStreams) { + kMaxTemporalStreams) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_RANGE, "Attempted to set RtpParameters " "num_temporal_layers to an invalid number."); @@ -252,7 +247,6 @@ RTCError CheckRtpParametersInvalidModificationAndValues( ArrayView send_codecs, std::optional send_codec, const FieldTrialsView& field_trials) { - using webrtc::RTCErrorType; if (rtp_parameters.encodings.size() != old_rtp_parameters.encodings.size()) { LOG_AND_RETURN_ERROR( RTCErrorType::INVALID_MODIFICATION, diff --git a/media/base/rtp_utils.cc b/media/base/rtp_utils.cc index 4a905b2fe7..7b4fe196dd 100644 --- a/media/base/rtp_utils.cc +++ b/media/base/rtp_utils.cc @@ -102,10 +102,10 @@ void UpdateRtpAuthTag(uint8_t* rtp, size_t auth_required_length = length - tag_length + kRocLength; uint8_t output[64]; - size_t result = webrtc::ComputeHmac( - webrtc::DIGEST_SHA_1, &packet_time_params.srtp_auth_key[0], - packet_time_params.srtp_auth_key.size(), rtp, auth_required_length, - output, sizeof(output)); + size_t result = + ComputeHmac(DIGEST_SHA_1, &packet_time_params.srtp_auth_key[0], + packet_time_params.srtp_auth_key.size(), rtp, + auth_required_length, output, sizeof(output)); if (result < tag_length) { RTC_DCHECK_NOTREACHED(); @@ -147,7 +147,7 @@ bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value) { // SDES packet parsing is not supported. if (pl_type == kRtcpTypeSDES) return false; - *value = webrtc::GetBE32(static_cast(data) + 4); + *value = GetBE32(static_cast(data) + 4); return true; } @@ -176,10 +176,10 @@ absl::string_view RtpPacketTypeToString(RtpPacketType packet_type) { } RtpPacketType InferRtpPacketType(ArrayView packet) { - if (webrtc::IsRtcpPacket(packet)) { + if (IsRtcpPacket(packet)) { return RtpPacketType::kRtcp; } - if (webrtc::IsRtpPacket(packet)) { + if (IsRtpPacket(packet)) { return RtpPacketType::kRtp; } return RtpPacketType::kUnknown; @@ -219,7 +219,7 @@ bool ValidateRtpHeader(const uint8_t* rtp, // Getting extension profile length. // Length is in 32 bit words. - uint16_t extension_length_in_32bits = webrtc::GetBE16(rtp + 2); + uint16_t extension_length_in_32bits = GetBE16(rtp + 2); size_t extension_length = extension_length_in_32bits * 4; size_t rtp_header_length = extension_length + @@ -267,9 +267,9 @@ bool UpdateRtpAbsSendTimeExtension(uint8_t* rtp, rtp += header_length_without_extension; // Getting extension profile ID and length. - uint16_t profile_id = webrtc::GetBE16(rtp); + uint16_t profile_id = GetBE16(rtp); // Length is in 32 bit words. - uint16_t extension_length_in_32bits = webrtc::GetBE16(rtp + 2); + uint16_t extension_length_in_32bits = GetBE16(rtp + 2); size_t extension_length = extension_length_in_32bits * 4; rtp += kRtpExtensionHeaderLen; // Moving past extension header. @@ -373,14 +373,14 @@ bool ApplyPacketOptions(uint8_t* data, // indication. size_t rtp_start_pos; size_t rtp_length; - if (!webrtc::UnwrapTurnPacket(data, length, &rtp_start_pos, &rtp_length)) { + if (!UnwrapTurnPacket(data, length, &rtp_start_pos, &rtp_length)) { RTC_DCHECK_NOTREACHED(); return false; } // Making sure we have a valid RTP packet at the end. auto packet = MakeArrayView(data + rtp_start_pos, rtp_length); - if (!webrtc::IsRtpPacket(packet) || + if (!IsRtpPacket(packet) || !ValidateRtpHeader(data + rtp_start_pos, rtp_length, nullptr)) { RTC_DCHECK_NOTREACHED(); return false; diff --git a/media/base/stream_params.cc b/media/base/stream_params.cc index 8346e4cd47..94e2dea50f 100644 --- a/media/base/stream_params.cc +++ b/media/base/stream_params.cc @@ -178,7 +178,7 @@ void StreamParams::GenerateSsrcs(int num_layers, void StreamParams::GetPrimarySsrcs(std::vector* primary_ssrcs) const { const SsrcGroup* sim_group = get_ssrc_group(kSimSsrcGroupSemantics); - if (sim_group == NULL) { + if (sim_group == nullptr) { primary_ssrcs->push_back(first_ssrc()); } else { primary_ssrcs->insert(primary_ssrcs->end(), sim_group->ssrcs.begin(), diff --git a/media/base/stream_params_unittest.cc b/media/base/stream_params_unittest.cc index efb113a68b..2b9a0f3243 100644 --- a/media/base/stream_params_unittest.cc +++ b/media/base/stream_params_unittest.cc @@ -16,8 +16,8 @@ #include #include +#include "api/array_view.h" #include "media/base/test_utils.h" -#include "rtc_base/arraysize.h" #include "rtc_base/unique_id_generator.h" #include "test/gmock.h" #include "test/gtest.h" @@ -30,10 +30,9 @@ static const uint32_t kSsrcs2[] = {1, 2}; static webrtc::StreamParams CreateStreamParamsWithSsrcGroup( const std::string& semantics, - const uint32_t ssrcs_in[], - size_t len) { + webrtc::ArrayView ssrcs_in) { webrtc::StreamParams stream; - std::vector ssrcs(ssrcs_in, ssrcs_in + len); + std::vector ssrcs(ssrcs_in.begin(), ssrcs_in.end()); webrtc::SsrcGroup sg(semantics, ssrcs); stream.ssrcs = ssrcs; stream.ssrc_groups.push_back(sg); @@ -48,8 +47,8 @@ TEST(SsrcGroup, EqualNotEqual) { webrtc::SsrcGroup("abc", MAKE_VECTOR(kSsrcs2)), }; - for (size_t i = 0; i < arraysize(ssrc_groups); ++i) { - for (size_t j = 0; j < arraysize(ssrc_groups); ++j) { + for (size_t i = 0; i < std::size(ssrc_groups); ++i) { + for (size_t j = 0; j < std::size(ssrc_groups); ++j) { EXPECT_EQ((ssrc_groups[i] == ssrc_groups[j]), (i == j)); EXPECT_EQ((ssrc_groups[i] != ssrc_groups[j]), (i != j)); } @@ -85,8 +84,7 @@ TEST(StreamParams, CreateLegacy) { } TEST(StreamParams, HasSsrcGroup) { - webrtc::StreamParams sp = - CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2)); + webrtc::StreamParams sp = CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2); EXPECT_EQ(2U, sp.ssrcs.size()); EXPECT_EQ(kSsrcs2[0], sp.first_ssrc()); EXPECT_TRUE(sp.has_ssrcs()); @@ -100,9 +98,8 @@ TEST(StreamParams, HasSsrcGroup) { } TEST(StreamParams, GetSsrcGroup) { - webrtc::StreamParams sp = - CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2)); - EXPECT_EQ(NULL, sp.get_ssrc_group("xyz")); + webrtc::StreamParams sp = CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2); + EXPECT_EQ(nullptr, sp.get_ssrc_group("xyz")); EXPECT_EQ(&sp.ssrc_groups[0], sp.get_ssrc_group("XYZ")); } @@ -120,18 +117,14 @@ TEST(StreamParams, HasStreamWithNoSsrcs) { TEST(StreamParams, EqualNotEqual) { webrtc::StreamParams l1 = webrtc::StreamParams::CreateLegacy(1); webrtc::StreamParams l2 = webrtc::StreamParams::CreateLegacy(2); - webrtc::StreamParams sg1 = - CreateStreamParamsWithSsrcGroup("ABC", kSsrcs1, arraysize(kSsrcs1)); - webrtc::StreamParams sg2 = - CreateStreamParamsWithSsrcGroup("ABC", kSsrcs2, arraysize(kSsrcs2)); - webrtc::StreamParams sg3 = - CreateStreamParamsWithSsrcGroup("Abc", kSsrcs2, arraysize(kSsrcs2)); - webrtc::StreamParams sg4 = - CreateStreamParamsWithSsrcGroup("abc", kSsrcs2, arraysize(kSsrcs2)); + webrtc::StreamParams sg1 = CreateStreamParamsWithSsrcGroup("ABC", kSsrcs1); + webrtc::StreamParams sg2 = CreateStreamParamsWithSsrcGroup("ABC", kSsrcs2); + webrtc::StreamParams sg3 = CreateStreamParamsWithSsrcGroup("Abc", kSsrcs2); + webrtc::StreamParams sg4 = CreateStreamParamsWithSsrcGroup("abc", kSsrcs2); webrtc::StreamParams sps[] = {l1, l2, sg1, sg2, sg3, sg4}; - for (size_t i = 0; i < arraysize(sps); ++i) { - for (size_t j = 0; j < arraysize(sps); ++j) { + for (size_t i = 0; i < std::size(sps); ++i) { + for (size_t j = 0; j < std::size(sps); ++j) { EXPECT_EQ((sps[i] == sps[j]), (i == j)); EXPECT_EQ((sps[i] != sps[j]), (i != j)); } @@ -227,8 +220,7 @@ TEST(StreamParams, FecFrFunctions) { } TEST(StreamParams, ToString) { - webrtc::StreamParams sp = - CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2)); + webrtc::StreamParams sp = CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2); sp.set_stream_ids({"stream_id"}); EXPECT_STREQ( "{ssrcs:[1,2];ssrc_groups:{semantics:XYZ;ssrcs:[1,2]};stream_ids:stream_" diff --git a/media/base/test_utils.h b/media/base/test_utils.h index 94f4492752..403b4922b0 100644 --- a/media/base/test_utils.h +++ b/media/base/test_utils.h @@ -17,7 +17,6 @@ #include #include "media/base/stream_params.h" -#include "rtc_base/arraysize.h" namespace webrtc { class VideoFrame; @@ -34,7 +33,7 @@ template inline std::vector MakeVector(const T a[], size_t s) { return std::vector(a, a + s); } -#define MAKE_VECTOR(a) webrtc::MakeVector(a, arraysize(a)) +#define MAKE_VECTOR(a) webrtc::MakeVector(a, std::size(a)) // Create Simulcast StreamParams with given `ssrcs` and `cname`. StreamParams CreateSimStreamParams(const std::string& cname, diff --git a/media/base/turn_utils.cc b/media/base/turn_utils.cc index 4e4783f965..d006bb892d 100644 --- a/media/base/turn_utils.cc +++ b/media/base/turn_utils.cc @@ -31,7 +31,7 @@ bool IsTurnSendIndicationPacket(const uint8_t* data, size_t length) { return false; } - uint16_t type = webrtc::GetBE16(data); + uint16_t type = GetBE16(data); return (type == TURN_SEND_INDICATION); } @@ -52,7 +52,7 @@ bool UnwrapTurnPacket(const uint8_t* packet, // / Application Data / // / / // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - size_t length = webrtc::GetBE16(&packet[2]); + size_t length = GetBE16(&packet[2]); if (length + kTurnChannelHeaderLength > packet_size) { return false; } @@ -64,7 +64,7 @@ bool UnwrapTurnPacket(const uint8_t* packet, if (IsTurnSendIndicationPacket(packet, packet_size)) { // Validate STUN message length. - const size_t stun_message_length = webrtc::GetBE16(&packet[2]); + const size_t stun_message_length = GetBE16(&packet[2]); if (stun_message_length + kStunHeaderSize != packet_size) { return false; } @@ -94,8 +94,8 @@ bool UnwrapTurnPacket(const uint8_t* packet, } // Getting attribute type and length. - attr_type = webrtc::GetBE16(&packet[pos]); - attr_length = webrtc::GetBE16(&packet[pos + sizeof(attr_type)]); + attr_type = GetBE16(&packet[pos]); + attr_length = GetBE16(&packet[pos + sizeof(attr_type)]); pos += kAttrHeaderLength; // Skip STUN_DATA_ATTR header. diff --git a/media/base/video_adapter.cc b/media/base/video_adapter.cc index a4f88145f4..2b5dcf6513 100644 --- a/media/base/video_adapter.cc +++ b/media/base/video_adapter.cc @@ -309,7 +309,7 @@ void VideoAdapter::OnOutputFormatRequest( target_aspect_ratio = std::make_pair(format->width, format->height); max_pixel_count = format->width * format->height; if (format->interval > 0) - max_fps = webrtc::kNumNanosecsPerSec / format->interval; + max_fps = kNumNanosecsPerSec / format->interval; } OnOutputFormatRequest(target_aspect_ratio, max_pixel_count, max_fps); } diff --git a/media/base/video_adapter_unittest.cc b/media/base/video_adapter_unittest.cc index 135afa5f4a..8b4a158095 100644 --- a/media/base/video_adapter_unittest.cc +++ b/media/base/video_adapter_unittest.cc @@ -23,7 +23,6 @@ #include "api/video/video_source_interface.h" #include "media/base/fake_frame_source.h" #include "media/base/video_common.h" -#include "rtc_base/arraysize.h" #include "rtc_base/time_utils.h" #include "test/field_trial.h" #include "test/gmock.h" @@ -35,10 +34,10 @@ constexpr int kWidth = 1280; constexpr int kHeight = 720; constexpr int kDefaultFps = 30; +using test::ScopedFieldTrials; using ::testing::_; using ::testing::Eq; using ::testing::Pair; -using ::webrtc::test::ScopedFieldTrials; VideoSinkWants BuildSinkWants(std::optional target_pixel_count, int max_pixel_count, @@ -84,8 +83,7 @@ class VideoAdapterTest : public ::testing::Test, frame_source_(std::make_unique( kWidth, kHeight, - VideoFormat::FpsToInterval(kDefaultFps) / - webrtc::kNumNanosecsPerMicrosec)), + VideoFormat::FpsToInterval(kDefaultFps) / kNumNanosecsPerMicrosec)), adapter_(source_resolution_alignment), adapter_wrapper_(std::make_unique(&adapter_)), use_new_format_request_(GetParam()) {} @@ -117,8 +115,8 @@ class VideoAdapterTest : public ::testing::Test, int out_height; if (video_adapter_->AdaptFrameResolution( in_width, in_height, - frame.timestamp_us() * webrtc::kNumNanosecsPerMicrosec, - &cropped_width, &cropped_height, &out_width, &out_height)) { + frame.timestamp_us() * kNumNanosecsPerMicrosec, &cropped_width, + &cropped_height, &out_width, &out_height)) { stats_.cropped_width = cropped_width; stats_.cropped_height = cropped_height; stats_.out_width = out_width; @@ -164,7 +162,7 @@ class VideoAdapterTest : public ::testing::Test, } adapter_.OnOutputFormatRequest( VideoFormat(width, height, fps ? VideoFormat::FpsToInterval(*fps) : 0, - webrtc::FOURCC_I420)); + FOURCC_I420)); } // Return pair of @@ -1058,7 +1056,7 @@ TEST(VideoAdapterTestMultipleOrientation, TestNormal) { EXPECT_TRUE(video_adapter.AdaptFrameResolution( /* in_width= */ 480, /* in_height= */ 640, - /* in_timestamp_ns= */ webrtc::kNumNanosecsPerSec / 30, &cropped_width, + /* in_timestamp_ns= */ kNumNanosecsPerSec / 30, &cropped_width, &cropped_height, &out_width, &out_height)); EXPECT_EQ(360, cropped_width); EXPECT_EQ(640, cropped_height); @@ -1086,7 +1084,7 @@ TEST(VideoAdapterTestMultipleOrientation, TestForcePortrait) { EXPECT_TRUE(video_adapter.AdaptFrameResolution( /* in_width= */ 480, /* in_height= */ 640, - /* in_timestamp_ns= */ webrtc::kNumNanosecsPerSec / 30, &cropped_width, + /* in_timestamp_ns= */ kNumNanosecsPerSec / 30, &cropped_width, &cropped_height, &out_width, &out_height)); EXPECT_EQ(360, cropped_width); EXPECT_EQ(640, cropped_height); @@ -1105,7 +1103,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst3_4) { int request_width = kWidth; int request_height = kHeight; - for (size_t i = 0; i < arraysize(kExpectedWidths); ++i) { + for (size_t i = 0; i < std::size(kExpectedWidths); ++i) { // Adapt down one step. adapter_.OnSinkWants(BuildSinkWants(std::nullopt, request_width * request_height - 1, @@ -1134,7 +1132,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2_3) { int request_width = kWidth1080p; int request_height = kHeight1080p; - for (size_t i = 0; i < arraysize(kExpectedWidths); ++i) { + for (size_t i = 0; i < std::size(kExpectedWidths); ++i) { // Adapt down one step. adapter_.OnSinkWants(BuildSinkWants(std::nullopt, request_width * request_height - 1, @@ -1163,7 +1161,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2x2_3) { int request_width = kWidth1080p4to3; int request_height = kHeight1080p4to3; - for (size_t i = 0; i < arraysize(kExpectedWidths); ++i) { + for (size_t i = 0; i < std::size(kExpectedWidths); ++i) { // Adapt down one step. adapter_.OnSinkWants(BuildSinkWants(std::nullopt, request_width * request_height - 1, @@ -1195,8 +1193,8 @@ TEST_P(VideoAdapterTest, AdaptResolutionWithSinkAlignment) { std::numeric_limits::max(), sink_alignment)); EXPECT_TRUE(adapter_.AdaptFrameResolution( kSourceWidth, kSourceHeight, - frame_num * webrtc::kNumNanosecsPerSec / kSourceFramerate, - &cropped_width_, &cropped_height_, &out_width_, &out_height_)); + frame_num * kNumNanosecsPerSec / kSourceFramerate, &cropped_width_, + &cropped_height_, &out_width_, &out_height_)); EXPECT_EQ(out_width_ % sink_alignment, 0); EXPECT_EQ(out_height_ % sink_alignment, 0); diff --git a/media/base/video_broadcaster.cc b/media/base/video_broadcaster.cc index 7f5cf85958..ac26324e31 100644 --- a/media/base/video_broadcaster.cc +++ b/media/base/video_broadcaster.cc @@ -74,7 +74,7 @@ void VideoBroadcaster::OnFrame(const VideoFrame& frame) { bool current_frame_was_discarded = false; for (auto& sink_pair : sink_pairs()) { if (sink_pair.wants.rotation_applied && - frame.rotation() != webrtc::kVideoRotation_0) { + frame.rotation() != kVideoRotation_0) { // Calls to OnFrame are not synchronized with changes to the sink wants. // When rotation_applied is set to true, one or a few frames may get here // with rotation still pending. Protect sinks that don't expect any diff --git a/media/base/video_common.cc b/media/base/video_common.cc index bc18d85b70..c5abb9e6e5 100644 --- a/media/base/video_common.cc +++ b/media/base/video_common.cc @@ -15,7 +15,6 @@ #include #include "api/array_view.h" -#include "rtc_base/arraysize.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" @@ -44,9 +43,9 @@ static const FourCCAliasEntry kFourCCAliases[] = { }; uint32_t CanonicalFourCC(uint32_t fourcc) { - for (uint32_t i = 0; i < arraysize(kFourCCAliases); ++i) { - if (kFourCCAliases[i].alias == fourcc) { - return kFourCCAliases[i].canonical; + for (const FourCCAliasEntry& entry : kFourCCAliases) { + if (entry.alias == fourcc) { + return entry.canonical; } } // Not an alias, so return it as-is. diff --git a/media/base/video_common_unittest.cc b/media/base/video_common_unittest.cc index a813aa3fa7..37b5c5521c 100644 --- a/media/base/video_common_unittest.cc +++ b/media/base/video_common_unittest.cc @@ -40,8 +40,8 @@ TEST(VideoCommonTest, TestCanonicalFourCC) { // Test conversion between interval and fps TEST(VideoCommonTest, TestVideoFormatFps) { EXPECT_EQ(VideoFormat::kMinimumInterval, VideoFormat::FpsToInterval(0)); - EXPECT_EQ(webrtc::kNumNanosecsPerSec / 20, VideoFormat::FpsToInterval(20)); - EXPECT_EQ(20, VideoFormat::IntervalToFps(webrtc::kNumNanosecsPerSec / 20)); + EXPECT_EQ(kNumNanosecsPerSec / 20, VideoFormat::FpsToInterval(20)); + EXPECT_EQ(20, VideoFormat::IntervalToFps(kNumNanosecsPerSec / 20)); EXPECT_EQ(0, VideoFormat::IntervalToFps(0)); } diff --git a/media/engine/fake_video_codec_factory.cc b/media/engine/fake_video_codec_factory.cc index 70811f9568..d7b9b2e24f 100644 --- a/media/engine/fake_video_codec_factory.cc +++ b/media/engine/fake_video_codec_factory.cc @@ -32,11 +32,10 @@ namespace webrtc { std::vector FakeVideoEncoderFactory::GetSupportedFormats() const { - const absl::InlinedVector - kSupportedScalabilityModes = {webrtc::ScalabilityMode::kL1T1, - webrtc::ScalabilityMode::kL1T2, - webrtc::ScalabilityMode::kL1T3}; + const absl::InlinedVector + kSupportedScalabilityModes = {ScalabilityMode::kL1T1, + ScalabilityMode::kL1T2, + ScalabilityMode::kL1T3}; return std::vector( 1, SdpVideoFormat(kFakeCodecFactoryCodecName, {}, diff --git a/media/engine/fake_webrtc_call.cc b/media/engine/fake_webrtc_call.cc index fb8d985a14..523ce610c4 100644 --- a/media/engine/fake_webrtc_call.cc +++ b/media/engine/fake_webrtc_call.cc @@ -58,8 +58,6 @@ namespace webrtc { -using ::webrtc::Environment; -using ::webrtc::ParseRtpSsrc; FakeAudioSendStream::FakeAudioSendStream(int id, const AudioSendStream::Config& config) @@ -68,7 +66,7 @@ FakeAudioSendStream::FakeAudioSendStream(int id, void FakeAudioSendStream::Reconfigure(const AudioSendStream::Config& config, SetParametersCallback callback) { config_ = config; - webrtc::InvokeSetParametersCallback(callback, RTCError::OK()); + InvokeSetParametersCallback(callback, RTCError::OK()); } const AudioSendStream::Config& FakeAudioSendStream::GetConfig() const { @@ -353,7 +351,7 @@ void FakeVideoSendStream::ReconfigureVideoEncoder( codec_settings_set_ = config.encoder_specific_settings != nullptr; encoder_config_ = std::move(config); ++num_encoder_reconfigurations_; - webrtc::InvokeSetParametersCallback(callback, RTCError::OK()); + InvokeSetParametersCallback(callback, RTCError::OK()); } void FakeVideoSendStream::Start() { @@ -467,8 +465,8 @@ FakeCall::FakeCall(const Environment& env, : env_(env), network_thread_(network_thread), worker_thread_(worker_thread), - audio_network_state_(webrtc::kNetworkUp), - video_network_state_(webrtc::kNetworkUp), + audio_network_state_(kNetworkUp), + video_network_state_(kNetworkUp), num_created_send_streams_(0), num_created_receive_streams_(0) {} @@ -537,13 +535,13 @@ NetworkState FakeCall::GetNetworkState(MediaType media) const { case MediaType::ANY: case MediaType::UNSUPPORTED: ADD_FAILURE() << "GetNetworkState called with unknown parameter."; - return webrtc::kNetworkDown; + return kNetworkDown; } // Even though all the values for the enum class are listed above,the compiler // will emit a warning as the method may be called with a value outside of the // valid enum range, unless this case is also handled. ADD_FAILURE() << "GetNetworkState called with unknown parameter."; - return webrtc::kNetworkDown; + return kNetworkDown; } AudioSendStream* FakeCall::CreateAudioSendStream( diff --git a/media/engine/fake_webrtc_video_engine.cc b/media/engine/fake_webrtc_video_engine.cc index 89a536d449..b016da355d 100644 --- a/media/engine/fake_webrtc_video_engine.cc +++ b/media/engine/fake_webrtc_video_engine.cc @@ -42,7 +42,6 @@ namespace webrtc { namespace { -using ::webrtc::Environment; static constexpr TimeDelta kEventTimeout = TimeDelta::Seconds(10); @@ -103,7 +102,7 @@ std::vector FakeWebRtcVideoDecoderFactory::GetSupportedFormats() const { std::vector formats; - for (const webrtc::SdpVideoFormat& format : supported_codec_formats_) { + for (const SdpVideoFormat& format : supported_codec_formats_) { // We need to test erroneous scenarios, so just warn if there's // a duplicate. if (format.IsCodecInList(formats)) { @@ -232,7 +231,7 @@ std::vector FakeWebRtcVideoEncoderFactory::GetSupportedFormats() const { std::vector formats; - for (const webrtc::SdpVideoFormat& format : formats_) { + for (const SdpVideoFormat& format : formats_) { // Don't add same codec twice. if (!format.IsCodecInList(formats)) formats.push_back(format); diff --git a/media/engine/internal_decoder_factory_unittest.cc b/media/engine/internal_decoder_factory_unittest.cc index a7cd2762dc..d5a30c1acc 100644 --- a/media/engine/internal_decoder_factory_unittest.cc +++ b/media/engine/internal_decoder_factory_unittest.cc @@ -18,7 +18,6 @@ #include "api/video_codecs/video_decoder.h" #include "api/video_codecs/video_decoder_factory.h" #include "media/base/media_constants.h" -#include "system_wrappers/include/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" @@ -28,8 +27,6 @@ using ::testing::Contains; using ::testing::Field; using ::testing::Not; -using ::webrtc::field_trial::InitFieldTrialsFromString; - #ifdef RTC_ENABLE_VP9 constexpr bool kVp9Enabled = true; #else diff --git a/media/engine/internal_encoder_factory.cc b/media/engine/internal_encoder_factory.cc index a00c056f0a..9c02ac13bf 100644 --- a/media/engine/internal_encoder_factory.cc +++ b/media/engine/internal_encoder_factory.cc @@ -33,14 +33,14 @@ namespace webrtc { namespace { using Factory = - VideoEncoderFactoryTemplate; + LibvpxVp9EncoderTemplateAdapter>; } // namespace std::vector InternalEncoderFactory::GetSupportedFormats() diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc index 73040a485f..ebd0e1b473 100644 --- a/media/engine/simulcast_encoder_adapter.cc +++ b/media/engine/simulcast_encoder_adapter.cc @@ -115,7 +115,7 @@ int VerifyCodec(const VideoCodec* codec_settings) { if (codec_settings->width <= 1 || codec_settings->height <= 1) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } - if (codec_settings->codecType == webrtc::kVideoCodecVP8 && + if (codec_settings->codecType == kVideoCodecVP8 && codec_settings->VP8().automaticResizeOn && CountActiveStreams(*codec_settings) > 1) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; @@ -270,6 +270,8 @@ SimulcastEncoderAdapter::SimulcastEncoderAdapter( prefer_temporal_support_on_base_layer_(env_.field_trials().IsEnabled( "WebRTC-Video-PreferTemporalSupportOnBaseLayer")), per_layer_pli_(SupportsPerLayerPictureLossIndication(format.parameters)), + drop_unaligned_resolution_(!env_.field_trials().IsDisabled( + "WebRTC-SimulcastEncoderAdapter-DropUnalignedResolution")), encoder_info_override_(env.field_trials()) { RTC_DCHECK(primary_factory); @@ -476,7 +478,8 @@ int SimulcastEncoderAdapter::Encode( RTC_LOG(LS_WARNING) << "Frame " << input_image.width() << "x" << input_image.height() << " not divisible by " << alignment; - return WEBRTC_VIDEO_CODEC_ERROR; + return drop_unaligned_resolution_ ? WEBRTC_VIDEO_CODEC_NO_OUTPUT + : WEBRTC_VIDEO_CODEC_ERROR; } if (encoder_info_override_.apply_alignment_to_all_simulcast_layers()) { for (const auto& layer : stream_contexts_) { @@ -484,7 +487,8 @@ int SimulcastEncoderAdapter::Encode( RTC_LOG(LS_WARNING) << "Codec " << layer.width() << "x" << layer.height() << " not divisible by " << alignment; - return WEBRTC_VIDEO_CODEC_ERROR; + return drop_unaligned_resolution_ ? WEBRTC_VIDEO_CODEC_NO_OUTPUT + : WEBRTC_VIDEO_CODEC_ERROR; } } } @@ -587,7 +591,7 @@ int SimulcastEncoderAdapter::Encode( // TODO(ilnik): Consider scaling UpdateRect together with the buffer. VideoFrame frame(input_image); frame.set_video_frame_buffer(dst_buffer); - frame.set_rotation(webrtc::kVideoRotation_0); + frame.set_rotation(kVideoRotation_0); frame.set_update_rect( VideoFrame::UpdateRect{0, 0, frame.width(), frame.height()}); int ret = layer.encoder().Encode(frame, &stream_frame_types); @@ -795,13 +799,13 @@ SimulcastEncoderAdapter::FetchOrCreateEncoderContext( return encoder_context; } -webrtc::VideoCodec SimulcastEncoderAdapter::MakeStreamCodec( - const webrtc::VideoCodec& codec, +VideoCodec SimulcastEncoderAdapter::MakeStreamCodec( + const VideoCodec& codec, int stream_idx, uint32_t start_bitrate_kbps, bool is_lowest_quality_stream, bool is_highest_quality_stream) { - webrtc::VideoCodec codec_params = codec; + VideoCodec codec_params = codec; const SimulcastStream& stream_params = codec.simulcastStream[stream_idx]; codec_params.numberOfSimulcastStreams = 0; @@ -841,7 +845,7 @@ webrtc::VideoCodec SimulcastEncoderAdapter::MakeStreamCodec( codec_params.qpMax = kLowestResMaxQp; } } - if (codec.codecType == webrtc::kVideoCodecVP8) { + if (codec.codecType == kVideoCodecVP8) { codec_params.VP8()->numberOfTemporalLayers = stream_params.numberOfTemporalLayers; if (!is_highest_quality_stream) { @@ -850,15 +854,15 @@ webrtc::VideoCodec SimulcastEncoderAdapter::MakeStreamCodec( int pixels_per_frame = codec_params.width * codec_params.height; if (pixels_per_frame < 352 * 288) { codec_params.SetVideoEncoderComplexity( - webrtc::VideoCodecComplexity::kComplexityHigher); + VideoCodecComplexity::kComplexityHigher); } // Turn off denoising for all streams but the highest resolution. codec_params.VP8()->denoisingOn = false; } - } else if (codec.codecType == webrtc::kVideoCodecH264) { + } else if (codec.codecType == kVideoCodecH264) { codec_params.H264()->numberOfTemporalLayers = stream_params.numberOfTemporalLayers; - } else if (codec.codecType == webrtc::kVideoCodecVP9 && + } else if (codec.codecType == kVideoCodecVP9 && scalability_mode.has_value() && !only_active_stream) { // If VP9 simulcast then explicitly set a single spatial layer for each // simulcast stream. diff --git a/media/engine/simulcast_encoder_adapter.h b/media/engine/simulcast_encoder_adapter.h index 1461416c4c..7673683127 100644 --- a/media/engine/simulcast_encoder_adapter.h +++ b/media/engine/simulcast_encoder_adapter.h @@ -196,6 +196,7 @@ class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder { const bool boost_base_layer_quality_; const bool prefer_temporal_support_on_base_layer_; const bool per_layer_pli_; + const bool drop_unaligned_resolution_; const SimulcastEncoderAdapterEncoderInfoSettings encoder_info_override_; }; diff --git a/media/engine/simulcast_encoder_adapter_unittest.cc b/media/engine/simulcast_encoder_adapter_unittest.cc index a332003054..86475311ff 100644 --- a/media/engine/simulcast_encoder_adapter_unittest.cc +++ b/media/engine/simulcast_encoder_adapter_unittest.cc @@ -301,7 +301,7 @@ class MockVideoEncoder : public VideoEncoder { image._encodedWidth = width; image._encodedHeight = height; CodecSpecificInfo codec_specific_info; - codec_specific_info.codecType = webrtc::kVideoCodecVP8; + codec_specific_info.codecType = kVideoCodecVP8; callback_->OnEncodedImage(image, &codec_specific_info); } @@ -617,7 +617,7 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test, InitRefCodec(0, &ref_codec); ref_codec.qpMax = 45; ref_codec.SetVideoEncoderComplexity( - webrtc::VideoCodecComplexity::kComplexityHigher); + VideoCodecComplexity::kComplexityHigher); ref_codec.VP8()->denoisingOn = false; ref_codec.startBitrate = 100; // Should equal to the target bitrate. VerifyCodec(ref_codec, 0); @@ -1366,8 +1366,7 @@ TEST_F(TestSimulcastEncoderAdapterFake, DoesNotAlterMaxQpForScreenshare) { VideoCodec ref_codec; InitRefCodec(0, &ref_codec); ref_codec.qpMax = kHighMaxQp; - ref_codec.SetVideoEncoderComplexity( - webrtc::VideoCodecComplexity::kComplexityHigher); + ref_codec.SetVideoEncoderComplexity(VideoCodecComplexity::kComplexityHigher); ref_codec.VP8()->denoisingOn = false; ref_codec.startBitrate = 100; // Should equal to the target bitrate. VerifyCodec(ref_codec, 0); @@ -1400,8 +1399,7 @@ TEST_F(TestSimulcastEncoderAdapterFake, VideoCodec ref_codec; InitRefCodec(2, &ref_codec, true /* reverse_layer_order */); ref_codec.qpMax = kHighMaxQp; - ref_codec.SetVideoEncoderComplexity( - webrtc::VideoCodecComplexity::kComplexityHigher); + ref_codec.SetVideoEncoderComplexity(VideoCodecComplexity::kComplexityHigher); ref_codec.VP8()->denoisingOn = false; ref_codec.startBitrate = 100; // Should equal to the target bitrate. VerifyCodec(ref_codec, 2); @@ -2126,5 +2124,58 @@ TEST_F(TestSimulcastEncoderAdapterFake, PopulatesScalabilityModeOfSubcodecs) { ScalabilityMode::kL1T3); } +TEST_F(TestSimulcastEncoderAdapterFake, + EncodeDropsFrameIfResolutionIsNotAlignedByDefault) { + test::ScopedKeyValueConfig field_trials( + field_trials_, + "WebRTC-SimulcastEncoderAdapter-GetEncoderInfoOverride/" + "requested_resolution_alignment:8," + "apply_alignment_to_all_simulcast_layers/"); + SetUp(); + SimulcastTestFixtureImpl::DefaultSettings( + &codec_, static_cast(kTestTemporalLayerProfile), + kVideoCodecVP8); + SetupCodec(); + EXPECT_EQ(0, adapter_->InitEncode(&codec_, kSettings)); + scoped_refptr buffer(I420Buffer::Create(1280, 720)); + VideoFrame input_frame = VideoFrame::Builder() + .set_video_frame_buffer(buffer) + .set_rtp_timestamp(0) + .set_timestamp_ms(0) + .build(); + std::vector frame_types; + frame_types.resize(codec_.numberOfSimulcastStreams, + VideoFrameType::kVideoFrameKey); + EXPECT_EQ(WEBRTC_VIDEO_CODEC_NO_OUTPUT, + adapter_->Encode(input_frame, &frame_types)); +} + +TEST_F(TestSimulcastEncoderAdapterFake, + EncodeReturnsErrorIfResolutionIsNotAlignedAndDroppingIsDisabled) { + test::ScopedKeyValueConfig field_trials( + field_trials_, + "WebRTC-SimulcastEncoderAdapter-DropUnalignedResolution/Disabled/" + "WebRTC-SimulcastEncoderAdapter-GetEncoderInfoOverride/" + "requested_resolution_alignment:8," + "apply_alignment_to_all_simulcast_layers/"); + SetUp(); + SimulcastTestFixtureImpl::DefaultSettings( + &codec_, static_cast(kTestTemporalLayerProfile), + kVideoCodecVP8); + SetupCodec(); + EXPECT_EQ(0, adapter_->InitEncode(&codec_, kSettings)); + scoped_refptr buffer(I420Buffer::Create(1280, 720)); + VideoFrame input_frame = VideoFrame::Builder() + .set_video_frame_buffer(buffer) + .set_rtp_timestamp(0) + .set_timestamp_ms(0) + .build(); + std::vector frame_types; + frame_types.resize(codec_.numberOfSimulcastStreams, + VideoFrameType::kVideoFrameKey); + EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, + adapter_->Encode(input_frame, &frame_types)); +} + } // namespace test } // namespace webrtc diff --git a/media/engine/webrtc_media_engine.cc b/media/engine/webrtc_media_engine.cc index 60bf57f775..7565d9a540 100644 --- a/media/engine/webrtc_media_engine.cc +++ b/media/engine/webrtc_media_engine.cc @@ -37,8 +37,7 @@ void DiscardRedundantExtensions( bool found = false; for (const char* uri : extensions_decreasing_prio) { auto it = absl::c_find_if( - *extensions, - [uri](const webrtc::RtpExtension& rhs) { return rhs.uri == uri; }); + *extensions, [uri](const RtpExtension& rhs) { return rhs.uri == uri; }); if (it != extensions->end()) { if (found) { extensions->erase(it); diff --git a/media/engine/webrtc_media_engine_unittest.cc b/media/engine/webrtc_media_engine_unittest.cc index 91893fa08a..ec41af8c29 100644 --- a/media/engine/webrtc_media_engine_unittest.cc +++ b/media/engine/webrtc_media_engine_unittest.cc @@ -22,7 +22,7 @@ namespace webrtc { namespace { -using webrtc::test::ScopedKeyValueConfig; +using test::ScopedKeyValueConfig; std::vector MakeUniqueExtensions() { std::vector result; diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 3645bd054f..3a3d197cc6 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -88,7 +88,6 @@ #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "modules/rtp_rtcp/source/rtp_util.h" #include "modules/video_coding/svc/scalability_mode_util.h" #include "rtc_base/checks.h" #include "rtc_base/dscp.h" @@ -106,10 +105,7 @@ namespace webrtc { namespace { -using ::webrtc::ParseRtpPayloadType; -using ::webrtc::ParseRtpSsrc; - -constexpr int64_t kUnsignaledSsrcCooldownMs = webrtc::kNumMillisecsPerSec / 2; +constexpr int64_t kUnsignaledSsrcCooldownMs = kNumMillisecsPerSec / 2; // This constant is really an on/off, lower-level configurable NACK history // duration hasn't been implemented. @@ -176,8 +172,7 @@ std::vector GetDefaultSupportedFormats( std::vector supported_formats = factory->GetSupportedFormats(); if (is_decoder_factory) { - webrtc::AddH264ConstrainedBaselineProfileToSupportedFormats( - &supported_formats); + AddH264ConstrainedBaselineProfileToSupportedFormats(&supported_formats); } if (supported_formats.empty()) @@ -205,7 +200,7 @@ std::vector GetDefaultSupportedFormats( RTCErrorOr AssignPayloadType(const SdpVideoFormat& format, PayloadTypePicker& pt_mapper, const FieldTrialsView& trials) { - Codec codec = webrtc::CreateVideoCodec(format); + Codec codec = CreateVideoCodec(format); RTCErrorOr result = pt_mapper.SuggestMapping(codec, /* excluder= */ nullptr); if (!result.ok()) { @@ -220,8 +215,7 @@ RTCErrorOr AssignPayloadType(const SdpVideoFormat& format, // (VP8, VP9, AV1, H264, and RED). RTCErrorOr AddRtx(const Codec& primary_codec, PayloadTypePicker& pt_mapper) { - Codec rtx_codec = - webrtc::CreateVideoRtxCodec(Codec::kIdNotSet, primary_codec.id); + Codec rtx_codec = CreateVideoRtxCodec(Codec::kIdNotSet, primary_codec.id); RTCErrorOr result = pt_mapper.SuggestMapping(rtx_codec, /* excluder= */ nullptr); if (!result.ok()) { @@ -394,8 +388,8 @@ static bool ValidateStreamParams(const StreamParams& sp) { // Returns true if the given codec is disallowed from doing simulcast. bool IsCodecDisabledForSimulcast(bool legacy_scalability_mode, VideoCodecType codec_type) { - if (legacy_scalability_mode && (codec_type == webrtc::kVideoCodecVP9 || - codec_type == webrtc::kVideoCodecAV1)) { + if (legacy_scalability_mode && + (codec_type == kVideoCodecVP9 || codec_type == kVideoCodecAV1)) { return true; } @@ -424,9 +418,8 @@ std::optional NumSpatialLayersFromEncoding( if (idx >= rtp_parameters.encodings.size()) return std::nullopt; - std::optional scalability_mode = - webrtc::ScalabilityModeFromString( - rtp_parameters.encodings[idx].scalability_mode.value_or("")); + std::optional scalability_mode = ScalabilityModeFromString( + rtp_parameters.encodings[idx].scalability_mode.value_or("")); return scalability_mode ? std::optional( ScalabilityModeToNumSpatialLayers(*scalability_mode)) @@ -492,7 +485,7 @@ bool IsActiveFromEncodings( // with this ssrc does not exist. auto encoding_it = std::find_if( encodings.begin(), encodings.end(), - [ssrc = ssrc.value()](const webrtc::RtpEncodingParameters& encoding) { + [ssrc = ssrc.value()](const RtpEncodingParameters& encoding) { return encoding.ssrc.has_value() && encoding.ssrc.value() == ssrc; }); return encoding_it != encodings.end() ? encoding_it->active : false; @@ -547,11 +540,11 @@ void FallbackToDefaultScalabilityModeIfNotSupported( config)) { encoding.scalability_mode = (encoding.scalability_mode != - std::string(webrtc::kDefaultScalabilityModeStr) && - IsScalabilityModeSupportedByCodec( - codec, webrtc::kDefaultScalabilityModeStr, config)) - ? webrtc::kDefaultScalabilityModeStr - : webrtc::kNoLayeringScalabilityModeStr; + std::string(kDefaultScalabilityModeStr) && + IsScalabilityModeSupportedByCodec(codec, kDefaultScalabilityModeStr, + config)) + ? kDefaultScalabilityModeStr + : kNoLayeringScalabilityModeStr; RTC_LOG(LS_INFO) << " -> " << *encoding.scalability_mode; } } @@ -577,12 +570,11 @@ RTCErrorOr> MapCodecs( UlpfecConfig ulpfec_config; std::optional flexfec_payload_type; - for (const webrtc::Codec& in_codec : codecs) { + for (const Codec& in_codec : codecs) { const int payload_type = in_codec.id; if (payload_codec_type.find(payload_type) != payload_codec_type.end()) { - if (webrtc::MatchesWithCodecRules(defined_codecs.at(in_codec.id), - in_codec)) { + if (MatchesWithCodecRules(defined_codecs.at(in_codec.id), in_codec)) { // Ignore second occurence of the same codec. // This can happen with multiple H.264 profiles. continue; @@ -776,8 +768,7 @@ void ExtractCodecInformation( int ParseReceiveBufferSize(const FieldTrialsView& trials) { FieldTrialParameter size_bytes("size_bytes", kVideoRtpRecvBufferSize); - webrtc::ParseFieldTrial({&size_bytes}, - trials.Lookup("WebRTC-ReceiveBufferSize")); + ParseFieldTrial({&size_bytes}, trials.Lookup("WebRTC-ReceiveBufferSize")); if (size_bytes.Get() < 10'000 || size_bytes.Get() > 10'000'000) { RTC_LOG(LS_WARNING) << "WebRTC-ReceiveBufferSize out of bounds: " << size_bytes.Get(); @@ -851,7 +842,7 @@ WebRtcVideoEngine::CreateSendChannel( VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { return std::make_unique( call, config, options, crypto_options, encoder_factory_.get(), - decoder_factory_.get(), video_bitrate_allocator_factory); + video_bitrate_allocator_factory); } std::unique_ptr WebRtcVideoEngine::CreateReceiveChannel(Call* call, @@ -881,21 +872,19 @@ WebRtcVideoEngine::GetRtpHeaderExtensions() const { // resolve conflicts. int id = 1; for (const auto& uri : - {webrtc::RtpExtension::kTimestampOffsetUri, - webrtc::RtpExtension::kAbsSendTimeUri, - webrtc::RtpExtension::kVideoRotationUri, - webrtc::RtpExtension::kTransportSequenceNumberUri, - webrtc::RtpExtension::kPlayoutDelayUri, - webrtc::RtpExtension::kVideoContentTypeUri, - webrtc::RtpExtension::kVideoTimingUri, - webrtc::RtpExtension::kColorSpaceUri, webrtc::RtpExtension::kMidUri, - webrtc::RtpExtension::kRidUri, webrtc::RtpExtension::kRepairedRidUri}) { + {RtpExtension::kTimestampOffsetUri, RtpExtension::kAbsSendTimeUri, + RtpExtension::kVideoRotationUri, + RtpExtension::kTransportSequenceNumberUri, + RtpExtension::kPlayoutDelayUri, RtpExtension::kVideoContentTypeUri, + RtpExtension::kVideoTimingUri, RtpExtension::kColorSpaceUri, + RtpExtension::kMidUri, RtpExtension::kRidUri, + RtpExtension::kRepairedRidUri}) { result.emplace_back(uri, id++, RtpTransceiverDirection::kSendRecv); } result.emplace_back(RtpExtension::kCorruptionDetectionUri, id++, /*preferred_encrypt=*/true, RtpTransceiverDirection::kStopped); - for (const auto& uri : {webrtc::RtpExtension::kAbsoluteCaptureTimeUri}) { + for (const auto& uri : {RtpExtension::kAbsoluteCaptureTimeUri}) { result.emplace_back(uri, id, RtpTransceiverDirection::kStopped); } result.emplace_back(RtpExtension::kGenericFrameDescriptorUri00, id, @@ -935,7 +924,6 @@ WebRtcVideoSendChannel::WebRtcVideoSendChannel( const VideoOptions& options, const CryptoOptions& crypto_options, VideoEncoderFactory* encoder_factory, - VideoDecoderFactory* decoder_factory, VideoBitrateAllocatorFactory* bitrate_allocator_factory) : MediaChannelUtil(call->network_thread(), config.enable_dscp), worker_thread_(call->worker_thread()), @@ -945,7 +933,6 @@ WebRtcVideoSendChannel::WebRtcVideoSendChannel( default_sink_(nullptr), video_config_(config.video), encoder_factory_(encoder_factory), - decoder_factory_(decoder_factory), bitrate_allocator_factory_(bitrate_allocator_factory), default_send_options_(options), last_send_stats_log_ms_(-1), @@ -956,13 +943,6 @@ WebRtcVideoSendChannel::WebRtcVideoSendChannel( crypto_options_(crypto_options) { RTC_DCHECK_RUN_ON(&thread_checker_); rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; - // Crash if MapCodecs fails. - recv_codecs_ = MapCodecs(GetPayloadTypesAndDefaultCodecs( - decoder_factory_, /*is_decoder_factory=*/true, - /*include_rtx=*/true, call_->trials())) - .value(); - recv_flexfec_payload_type_ = - recv_codecs_.empty() ? 0 : recv_codecs_.front().flexfec_payload_type; } WebRtcVideoSendChannel::~WebRtcVideoSendChannel() { @@ -1030,7 +1010,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( {{"off", InterLayerPredMode::kOff}, {"on", InterLayerPredMode::kOn}, {"onkeypic", InterLayerPredMode::kOnKeyPic}}); - webrtc::ParseFieldTrial( + ParseFieldTrial( {&interlayer_pred_experiment_enabled, &inter_layer_pred_mode}, call_->trials().Lookup("WebRTC-Vp9InterLayerPred")); if (interlayer_pred_experiment_enabled) { @@ -1407,7 +1387,7 @@ RtpParameters WebRtcVideoSendChannel::GetRtpSendParameters( RtpParameters rtp_params = it->second->GetRtpParameters(); // Need to add the common list of codecs to the send stream-specific // RTP parameters. - for (const webrtc::Codec& codec : send_params_.codecs) { + for (const Codec& codec : send_params_.codecs) { if (send_codec() && send_codec()->codec.id == codec.id) { // Put the current send codec to the front of the codecs list. RTC_DCHECK_EQ(codec.name, send_codec()->codec.name); @@ -1432,8 +1412,8 @@ RTCError WebRtcVideoSendChannel::SetRtpSendParameters( RTC_LOG(LS_ERROR) << "Attempting to set RTP send parameters for stream " "with ssrc " << ssrc << " which doesn't exist."; - return webrtc::InvokeSetParametersCallback( - callback, RTCError(RTCErrorType::INTERNAL_ERROR)); + return InvokeSetParametersCallback(callback, + RTCError(RTCErrorType::INTERNAL_ERROR)); } // TODO(deadbeef): Handle setting parameters with a list of codecs in a @@ -1442,8 +1422,8 @@ RTCError WebRtcVideoSendChannel::SetRtpSendParameters( if (current_parameters.codecs != parameters.codecs) { RTC_DLOG(LS_ERROR) << "Using SetParameters to change the set of codecs " "is not currently supported."; - return webrtc::InvokeSetParametersCallback( - callback, RTCError(RTCErrorType::INTERNAL_ERROR)); + return InvokeSetParametersCallback(callback, + RTCError(RTCErrorType::INTERNAL_ERROR)); } if (!parameters.encodings.empty()) { @@ -1451,19 +1431,19 @@ RTCError WebRtcVideoSendChannel::SetRtpSendParameters( // https://tools.ietf.org/html/draft-ietf-tsvwg-rtcweb-qos-16#section-5 // TODO(deadbeef): Change values depending on whether we are sending a // keyframe or non-keyframe. - DiffServCodePoint new_dscp = webrtc::DSCP_DEFAULT; + DiffServCodePoint new_dscp = DSCP_DEFAULT; switch (parameters.encodings[0].network_priority) { case Priority::kVeryLow: - new_dscp = webrtc::DSCP_CS1; + new_dscp = DSCP_CS1; break; case Priority::kLow: - new_dscp = webrtc::DSCP_DEFAULT; + new_dscp = DSCP_DEFAULT; break; case Priority::kMedium: - new_dscp = webrtc::DSCP_AF42; + new_dscp = DSCP_AF42; break; case Priority::kHigh: - new_dscp = webrtc::DSCP_AF41; + new_dscp = DSCP_AF41; break; } @@ -1475,7 +1455,7 @@ RTCError WebRtcVideoSendChannel::SetRtpSendParameters( ResolveSendCodecs(*send_codec_, send_codecs_, parameters.encodings, negotiated_codecs_, &send_codecs); if (!error.ok()) { - return webrtc::InvokeSetParametersCallback(callback, error); + return InvokeSetParametersCallback(callback, error); } if (send_codecs_ != send_codecs) { @@ -1642,7 +1622,7 @@ bool WebRtcVideoSendChannel::GetStats(VideoMediaSendInfo* info) { // Log stats periodically. bool log_stats = false; - int64_t now_ms = webrtc::TimeMillis(); + int64_t now_ms = TimeMillis(); if (last_send_stats_log_ms_ == -1 || now_ms - last_send_stats_log_ms_ > kStatsLogIntervalMs) { last_send_stats_log_ms_ = now_ms; @@ -1721,8 +1701,8 @@ void WebRtcVideoSendChannel::OnPacketSent(const SentPacketInfo& sent_packet) { void WebRtcVideoSendChannel::OnReadyToSend(bool ready) { RTC_DCHECK_RUN_ON(&network_thread_checker_); RTC_LOG(LS_VERBOSE) << "OnReadyToSend: " << (ready ? "Ready." : "Not ready."); - call_->SignalChannelNetworkState( - MediaType::VIDEO, ready ? webrtc::kNetworkUp : webrtc::kNetworkDown); + call_->SignalChannelNetworkState(MediaType::VIDEO, + ready ? kNetworkUp : kNetworkDown); } void WebRtcVideoSendChannel::OnNetworkRouteChanged( @@ -1889,7 +1869,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( } WebRtcVideoSendChannel::WebRtcVideoSendStream::~WebRtcVideoSendStream() { - if (stream_ != NULL) { + if (stream_ != nullptr) { call_->DestroyVideoSendStream(stream_); } } @@ -2011,12 +1991,12 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::SetCodec( } } - const bool has_lntf = webrtc::HasLntf(codec_settings.codec); + const bool has_lntf = HasLntf(codec_settings.codec); parameters_.config.rtp.lntf.enabled = has_lntf; parameters_.config.encoder_settings.capabilities.loss_notification = has_lntf; parameters_.config.rtp.nack.rtp_history_ms = - webrtc::HasNack(codec_settings.codec) ? kNackHistoryMs : 0; + HasNack(codec_settings.codec) ? kNackHistoryMs : 0; parameters_.codec_settings = codec_settings; @@ -2126,7 +2106,7 @@ RTCError WebRtcVideoSendChannel::WebRtcVideoSendStream::SetRtpParameters( RTCError error = CheckRtpParametersInvalidModificationAndValues( rtp_parameters_, new_parameters, call_->trials()); if (!error.ok()) { - return webrtc::InvokeSetParametersCallback(callback, error); + return InvokeSetParametersCallback(callback, error); } bool new_param = false; @@ -2205,7 +2185,7 @@ RTCError WebRtcVideoSendChannel::WebRtcVideoSendStream::SetRtpParameters( } GenerateKeyFrame(key_frames_requested_by_rid); } - return webrtc::InvokeSetParametersCallback(callback, RTCError::OK()); + return InvokeSetParametersCallback(callback, RTCError::OK()); } RtpParameters WebRtcVideoSendChannel::WebRtcVideoSendStream::GetRtpParameters() @@ -2257,7 +2237,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig( const Codec& codec) const { RTC_DCHECK_RUN_ON(&thread_checker_); VideoEncoderConfig encoder_config; - encoder_config.codec_type = webrtc::PayloadStringToCodecType(codec.name); + encoder_config.codec_type = PayloadStringToCodecType(codec.name); encoder_config.video_format = SdpVideoFormat(codec.name, codec.params); bool is_screencast = parameters_.options.is_screencast.value_or(false); @@ -2276,8 +2256,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig( // `legacy_scalability_mode` and codec used. encoder_config.number_of_streams = parameters_.config.rtp.ssrcs.size(); bool legacy_scalability_mode = true; - for (const webrtc::RtpEncodingParameters& encoding : - rtp_parameters_.encodings) { + for (const RtpEncodingParameters& encoding : rtp_parameters_.encodings) { if (encoding.scalability_mode.has_value() && (encoding.scale_resolution_down_by.has_value() || encoding.scale_resolution_down_to.has_value())) { @@ -2339,7 +2318,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig( encoder_config.simulcast_layers[i].active = rtp_parameters_.encodings[i].active; encoder_config.simulcast_layers[i].scalability_mode = - webrtc::ScalabilityModeFromString( + ScalabilityModeFromString( rtp_parameters_.encodings[i].scalability_mode.value_or("")); if (rtp_parameters_.encodings[i].min_bitrate_bps) { encoder_config.simulcast_layers[i].min_bitrate_bps = @@ -2389,7 +2368,7 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::ReconfigureEncoder( if (!stream_) { // The webrtc::VideoSendStream `stream_` has not yet been created but other // parameters has changed. - webrtc::InvokeSetParametersCallback(callback, RTCError::OK()); + InvokeSetParametersCallback(callback, RTCError::OK()); return; } @@ -2420,7 +2399,7 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::ReconfigureEncoder( // The app is switching between legacy and standard modes, recreate instead // of reconfiguring to avoid number of streams not matching in lower layers. RecreateWebRtcStream(); - webrtc::InvokeSetParametersCallback(callback, RTCError::OK()); + InvokeSetParametersCallback(callback, RTCError::OK()); return; } @@ -2454,7 +2433,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::GetPerLayerVideoSenderInfos( } else { stats = stream_->GetStats(); if (log_stats) - RTC_LOG(LS_INFO) << stats.ToString(webrtc::TimeMillis()); + RTC_LOG(LS_INFO) << stats.ToString(TimeMillis()); // Metrics that are in common for all substreams. common_info.adapt_changes = stats.number_of_cpu_adapt_changes; @@ -2626,7 +2605,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::GetAggregatedVideoSenderInfo( void WebRtcVideoSendChannel::WebRtcVideoSendStream::FillBitrateInfo( BandwidthEstimationInfo* bwe_info) { RTC_DCHECK_RUN_ON(&thread_checker_); - if (stream_ == NULL) { + if (stream_ == nullptr) { return; } VideoSendStream::Stats stats = stream_->GetStats(); @@ -2680,7 +2659,7 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::RecreateWebRtcStream() { config.encoder_settings.enable_frame_instrumentation_generator = true; } - if (stream_ != NULL) { + if (stream_ != nullptr) { // TODO: webrtc:40644448 - Make sure the stats are not updated between // GetStats and DestroyVideoSendStream. VideoSendStream::Stats stats = stream_->GetStats(); @@ -2693,7 +2672,7 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::RecreateWebRtcStream() { parameters_.encoder_config.Copy()); } - parameters_.encoder_config.encoder_specific_settings = NULL; + parameters_.encoder_config.encoder_specific_settings = nullptr; // Calls stream_->StartPerRtpStream() to start the VideoSendStream // if necessary conditions are met. @@ -2709,7 +2688,7 @@ void WebRtcVideoSendChannel::WebRtcVideoSendStream::RecreateWebRtcStream() { void WebRtcVideoSendChannel::WebRtcVideoSendStream::GenerateKeyFrame( const std::vector& rids) { RTC_DCHECK_RUN_ON(&thread_checker_); - if (stream_ != NULL) { + if (stream_ != nullptr) { stream_->GenerateKeyFrame(rids); } else { RTC_LOG(LS_WARNING) @@ -2819,7 +2798,7 @@ RtpParameters WebRtcVideoReceiveChannel::GetRtpReceiverParameters( rtp_params.header_extensions = recv_rtp_extensions_; // Add codecs, which any stream is prepared to receive. - for (const webrtc::Codec& codec : recv_params_.codecs) { + for (const Codec& codec : recv_params_.codecs) { rtp_params.codecs.push_back(codec.ToCodecParameters()); } @@ -2839,7 +2818,7 @@ RtpParameters WebRtcVideoReceiveChannel::GetDefaultRtpReceiveParameters() rtp_params.encodings.emplace_back(); // Add codecs, which any stream is prepared to receive. - for (const webrtc::Codec& codec : recv_params_.codecs) { + for (const Codec& codec : recv_params_.codecs) { rtp_params.codecs.push_back(codec.ToCodecParameters()); } @@ -2871,8 +2850,7 @@ bool WebRtcVideoReceiveChannel::GetChangedReceiverParameters( /*is_decoder_factory=*/true, /*include_rtx=*/true, call_->trials()); for (const VideoCodecSettings& mapped_codec : mapped_codecs) { - if (!webrtc::FindMatchingVideoCodec(local_supported_codecs, - mapped_codec.codec)) { + if (!FindMatchingVideoCodec(local_supported_codecs, mapped_codec.codec)) { RTC_LOG(LS_ERROR) << "GetChangedReceiverParameters called with " "unsupported video codec: " << mapped_codec.codec.ToString(); @@ -3189,7 +3167,7 @@ bool WebRtcVideoReceiveChannel::GetStats(VideoMediaReceiveInfo* info) { // Log stats periodically. bool log_stats = false; - int64_t now_ms = webrtc::TimeMillis(); + int64_t now_ms = TimeMillis(); if (last_receive_stats_log_ms_ == -1 || now_ms - last_receive_stats_log_ms_ > kStatsLogIntervalMs) { last_receive_stats_log_ms_ = now_ms; @@ -3214,8 +3192,8 @@ void WebRtcVideoReceiveChannel::FillReceiverStats( void WebRtcVideoReceiveChannel::FillReceiveCodecStats( VideoMediaReceiveInfo* video_media_info) { for (const auto& receiver : video_media_info->receivers) { - auto codec = absl::c_find_if( - recv_params_.codecs, [&receiver](const webrtc::Codec& c) { + auto codec = + absl::c_find_if(recv_params_.codecs, [&receiver](const Codec& c) { return receiver.codec_payload_type && *receiver.codec_payload_type == c.id; }); @@ -3300,7 +3278,7 @@ bool WebRtcVideoReceiveChannel::MaybeCreateDefaultReceiveStream( // of creating decoders on every packet eats up processing time (e.g. // https://crbug.com/1069603) and this cooldown prevents that. if (last_unsignalled_ssrc_creation_time_ms_.has_value()) { - int64_t now_ms = webrtc::TimeMillis(); + int64_t now_ms = TimeMillis(); if (now_ms - last_unsignalled_ssrc_creation_time_ms_.value() < kUnsignaledSsrcCooldownMs) { // We've already created an unsignalled ssrc stream within the last @@ -3314,7 +3292,7 @@ bool WebRtcVideoReceiveChannel::MaybeCreateDefaultReceiveStream( // RTX SSRC not yet known. ReCreateDefaultReceiveStream(packet.Ssrc(), std::nullopt); - last_unsignalled_ssrc_creation_time_ms_ = webrtc::TimeMillis(); + last_unsignalled_ssrc_creation_time_ms_ = TimeMillis(); return true; } @@ -3438,12 +3416,12 @@ WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( const FlexfecReceiveStream::Config& flexfec_config) : call_(call), stream_params_(sp), - stream_(NULL), + stream_(nullptr), default_stream_(default_stream), config_(std::move(config)), flexfec_config_(flexfec_config), flexfec_stream_(nullptr), - sink_(NULL), + sink_(nullptr), first_frame_timestamp_(-1), estimated_remote_start_ntp_time_ms_(0), receiving_(false) { @@ -3456,15 +3434,13 @@ WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( const VideoCodecSettings& codec = recv_codecs.front(); config_.rtp.ulpfec_payload_type = codec.ulpfec.ulpfec_payload_type; config_.rtp.red_payload_type = codec.ulpfec.red_payload_type; - config_.rtp.lntf.enabled = webrtc::HasLntf(codec.codec); - config_.rtp.nack.rtp_history_ms = - webrtc::HasNack(codec.codec) ? kNackHistoryMs : 0; + config_.rtp.lntf.enabled = HasLntf(codec.codec); + config_.rtp.nack.rtp_history_ms = HasNack(codec.codec) ? kNackHistoryMs : 0; if (codec.rtx_time && config_.rtp.nack.rtp_history_ms != 0) { config_.rtp.nack.rtp_history_ms = *codec.rtx_time; } - config_.rtp.rtcp_xr.receiver_reference_time_report = - webrtc::HasRrtr(codec.codec); + config_.rtp.rtcp_xr.receiver_reference_time_report = HasRrtr(codec.codec); if (codec.ulpfec.red_rtx_payload_type != -1) { config_.rtp @@ -3545,14 +3521,14 @@ bool WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::ReconfigureCodecs( config_.rtp.ulpfec_payload_type); } - const bool has_lntf = webrtc::HasLntf(codec.codec); + const bool has_lntf = HasLntf(codec.codec); if (config_.rtp.lntf.enabled != has_lntf) { config_.rtp.lntf.enabled = has_lntf; stream_->SetLossNotificationEnabled(has_lntf); } int new_history_ms = config_.rtp.nack.rtp_history_ms; - const int rtp_history_ms = webrtc::HasNack(codec.codec) ? kNackHistoryMs : 0; + const int rtp_history_ms = HasNack(codec.codec) ? kNackHistoryMs : 0; if (rtp_history_ms != config_.rtp.nack.rtp_history_ms) { new_history_ms = rtp_history_ms; } @@ -3568,7 +3544,7 @@ bool WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::ReconfigureCodecs( stream_->SetNackHistory(TimeDelta::Millis(new_history_ms)); } - const bool has_rtr = webrtc::HasRrtr(codec.codec); + const bool has_rtr = HasRrtr(codec.codec); if (has_rtr != config_.rtp.rtcp_xr.receiver_reference_time_report) { config_.rtp.rtcp_xr.receiver_reference_time_report = has_rtr; stream_->SetRtcpXr(config_.rtp.rtcp_xr); @@ -3742,14 +3718,14 @@ void WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::OnFrame( const VideoFrame& frame) { MutexLock lock(&sink_lock_); - int64_t time_now_ms = webrtc::TimeMillis(); + int64_t time_now_ms = TimeMillis(); if (first_frame_timestamp_ < 0) first_frame_timestamp_ = time_now_ms; int64_t elapsed_time_ms = time_now_ms - first_frame_timestamp_; if (frame.ntp_time_ms() > 0) estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; - if (sink_ == NULL) { + if (sink_ == nullptr) { RTC_LOG(LS_WARNING) << "VideoReceiveStreamInterface not connected to a VideoSink."; return; @@ -3928,7 +3904,7 @@ WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::GetVideoReceiverInfo( // present if DLRR is enabled. if (log_stats) - RTC_LOG(LS_INFO) << stats.ToString(webrtc::TimeMillis()); + RTC_LOG(LS_INFO) << stats.ToString(TimeMillis()); return info; } @@ -4018,9 +3994,9 @@ void WebRtcVideoReceiveChannel::ProcessReceivedPacket( // It would likely be good if extensions where merged per BUNDLE and // applied directly in RtpTransport::DemuxPacket; packet.IdentifyExtensions(recv_rtp_extension_map_); - packet.set_payload_type_frequency(webrtc::kVideoPayloadTypeFrequency); + packet.set_payload_type_frequency(kVideoPayloadTypeFrequency); if (!packet.arrival_time().IsFinite()) { - packet.set_arrival_time(Timestamp::Micros(webrtc::TimeMicros())); + packet.set_arrival_time(Timestamp::Micros(TimeMicros())); } call_->Receiver()->DeliverRtpPacket( diff --git a/media/engine/webrtc_video_engine.h b/media/engine/webrtc_video_engine.h index 5d6bd6a847..e8cfa264bc 100644 --- a/media/engine/webrtc_video_engine.h +++ b/media/engine/webrtc_video_engine.h @@ -25,7 +25,6 @@ #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/crypto/crypto_options.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/crypto/frame_encryptor_interface.h" @@ -164,7 +163,6 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, const VideoOptions& options, const CryptoOptions& crypto_options, VideoEncoderFactory* encoder_factory, - VideoDecoderFactory* decoder_factory, VideoBitrateAllocatorFactory* bitrate_allocator_factory); ~WebRtcVideoSendChannel() override; @@ -308,15 +306,6 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, bool ValidateSendSsrcAvailability(const StreamParams& sp) const RTC_EXCLUSIVE_LOCKS_REQUIRED(thread_checker_); - // Populates `rtx_associated_payload_types`, `raw_payload_types` and - // `decoders` based on codec settings provided by `recv_codecs`. - // `recv_codecs` must be non-empty and all other parameters must be empty. - static void ExtractCodecInformation( - ArrayView recv_codecs, - std::map& rtx_associated_payload_types, - std::set& raw_payload_types, - std::vector& decoders); - // Wrapper for the sender part. class WebRtcVideoSendStream { public: @@ -505,13 +494,8 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, RTC_GUARDED_BY(thread_checker_); VideoEncoderFactory* const encoder_factory_ RTC_GUARDED_BY(thread_checker_); - VideoDecoderFactory* const decoder_factory_ RTC_GUARDED_BY(thread_checker_); VideoBitrateAllocatorFactory* const bitrate_allocator_factory_ RTC_GUARDED_BY(thread_checker_); - std::vector recv_codecs_ RTC_GUARDED_BY(thread_checker_); - RtpHeaderExtensionMap recv_rtp_extension_map_ RTC_GUARDED_BY(thread_checker_); - std::vector recv_rtp_extensions_ - RTC_GUARDED_BY(thread_checker_); // See reason for keeping track of the FlexFEC payload type separately in // comment in WebRtcVideoChannel::ChangedReceiverParameters. int recv_flexfec_payload_type_ RTC_GUARDED_BY(thread_checker_); diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index 8e1029a2e1..596c555f15 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -107,7 +107,6 @@ #include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/video_coding/svc/scalability_mode_util.h" -#include "rtc_base/arraysize.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" @@ -127,6 +126,9 @@ #include "video/config/simulcast.h" #include "video/config/video_encoder_config.h" +namespace webrtc { +namespace { + using ::testing::_; using ::testing::Combine; using ::testing::Contains; @@ -149,8 +151,6 @@ using ::webrtc::test::FunctionVideoDecoderFactory; using ::webrtc::test::RtcpPacketParser; using ::webrtc::test::ScopedKeyValueConfig; -namespace webrtc { -namespace { static const uint8_t kRedRtxPayloadType = 125; @@ -175,31 +175,31 @@ constexpr size_t kNumSimulcastStreams = 3; static const char kUnsupportedExtensionName[] = "urn:ietf:params:rtp-hdrext:unsupported"; -webrtc::Codec RemoveFeedbackParams(webrtc::Codec&& codec) { - codec.feedback_params = webrtc::FeedbackParams(); +Codec RemoveFeedbackParams(Codec&& codec) { + codec.feedback_params = FeedbackParams(); return std::move(codec); } -void VerifyCodecHasDefaultFeedbackParams(const webrtc::Codec& codec, +void VerifyCodecHasDefaultFeedbackParams(const Codec& codec, bool lntf_expected) { - EXPECT_EQ(lntf_expected, codec.HasFeedbackParam(webrtc::FeedbackParam( + EXPECT_EQ(lntf_expected, codec.HasFeedbackParam(FeedbackParam( kRtcpFbParamLntf, kParamValueEmpty))); EXPECT_TRUE(codec.HasFeedbackParam( - webrtc::FeedbackParam(kRtcpFbParamNack, kParamValueEmpty))); + FeedbackParam(kRtcpFbParamNack, kParamValueEmpty))); EXPECT_TRUE(codec.HasFeedbackParam( - webrtc::FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli))); + FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli))); EXPECT_TRUE(codec.HasFeedbackParam( - webrtc::FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty))); + FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty))); EXPECT_TRUE(codec.HasFeedbackParam( - webrtc::FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty))); + FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty))); EXPECT_TRUE(codec.HasFeedbackParam( - webrtc::FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir))); + FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir))); } // Return true if any codec in `codecs` is an RTX codec with associated // payload type `payload_type`. -bool HasRtxCodec(const std::vector& codecs, int payload_type) { - for (const webrtc::Codec& codec : codecs) { +bool HasRtxCodec(const std::vector& codecs, int payload_type) { + for (const Codec& codec : codecs) { int associated_payload_type; if (absl::EqualsIgnoreCase(codec.name.c_str(), "rtx") && codec.GetParam(kCodecParamAssociatedPayloadType, @@ -213,8 +213,8 @@ bool HasRtxCodec(const std::vector& codecs, int payload_type) { // Return true if any codec in `codecs` is an RTX codec, independent of // payload type. -bool HasAnyRtxCodec(const std::vector& codecs) { - for (const webrtc::Codec& codec : codecs) { +bool HasAnyRtxCodec(const std::vector& codecs) { + for (const Codec& codec : codecs) { if (absl::EqualsIgnoreCase(codec.name.c_str(), "rtx")) { return true; } @@ -230,16 +230,15 @@ const int* FindKeyByValue(const std::map& m, int v) { return nullptr; } -bool HasRtxReceiveAssociation( - const webrtc::VideoReceiveStreamInterface::Config& config, - int payload_type) { +bool HasRtxReceiveAssociation(const VideoReceiveStreamInterface::Config& config, + int payload_type) { return FindKeyByValue(config.rtp.rtx_associated_payload_types, payload_type) != nullptr; } // Check that there's an Rtx payload type for each decoder. bool VerifyRtxReceiveAssociations( - const webrtc::VideoReceiveStreamInterface::Config& config) { + const VideoReceiveStreamInterface::Config& config) { for (const auto& decoder : config.decoders) { if (!HasRtxReceiveAssociation(config, decoder.payload_type)) return false; @@ -247,15 +246,13 @@ bool VerifyRtxReceiveAssociations( return true; } -scoped_refptr CreateBlackFrameBuffer(int width, - int height) { - scoped_refptr buffer = - webrtc::I420Buffer::Create(width, height); - webrtc::I420Buffer::SetBlack(buffer.get()); +scoped_refptr CreateBlackFrameBuffer(int width, int height) { + scoped_refptr buffer = I420Buffer::Create(width, height); + I420Buffer::SetBlack(buffer.get()); return buffer; } -void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config, +void VerifySendStreamHasRtxTypes(const VideoSendStream::Config& config, const std::map& rtx_types) { std::map::const_iterator it; it = rtx_types.find(config.rtp.payload_type); @@ -288,17 +285,16 @@ int GetMaxDefaultBitrateBps(size_t width, size_t height) { } } -class MockVideoSource - : public webrtc::VideoSourceInterface { +class MockVideoSource : public VideoSourceInterface { public: MOCK_METHOD(void, AddOrUpdateSink, - (webrtc::VideoSinkInterface * sink, - const webrtc::VideoSinkWants& wants), + (VideoSinkInterface * sink, + const VideoSinkWants& wants), (override)); MOCK_METHOD(void, RemoveSink, - (webrtc::VideoSinkInterface * sink), + (VideoSinkInterface * sink), (override)); }; @@ -306,23 +302,23 @@ class MockNetworkInterface : public MediaChannelNetworkInterface { public: MOCK_METHOD(bool, SendPacket, - (webrtc::CopyOnWriteBuffer * packet, - const webrtc::AsyncSocketPacketOptions& options), + (CopyOnWriteBuffer * packet, + const AsyncSocketPacketOptions& options), (override)); MOCK_METHOD(bool, SendRtcp, - (webrtc::CopyOnWriteBuffer * packet, - const webrtc::AsyncSocketPacketOptions& options), + (CopyOnWriteBuffer * packet, + const AsyncSocketPacketOptions& options), (override)); MOCK_METHOD(int, SetOption, - (SocketType type, webrtc::Socket::Option opt, int option), + (SocketType type, Socket::Option opt, int option), (override)); }; -std::vector GetStreamResolutions( - const std::vector& streams) { - std::vector res; +std::vector GetStreamResolutions( + const std::vector& streams) { + std::vector res; for (const auto& s : streams) { if (s.active) { res.push_back({checked_cast(s.width), checked_cast(s.height)}); @@ -396,7 +392,7 @@ class WebRtcVideoEngineTest : public ::testing::Test { encoder_factory_(new FakeWebRtcVideoEncoderFactory), decoder_factory_(new FakeWebRtcVideoDecoderFactory), video_bitrate_allocator_factory_( - webrtc::CreateBuiltinVideoBitrateAllocatorFactory()), + CreateBuiltinVideoBitrateAllocatorFactory()), engine_( std::unique_ptr(encoder_factory_), std::unique_ptr(decoder_factory_), @@ -470,7 +466,7 @@ TEST_F(WebRtcVideoEngineTest, AddSupportedVideoCodecType("VP9"); AddSupportedVideoCodecType("AV1"); AddSupportedVideoCodecType("H264"); - for (const webrtc::Codec& codec : engine_.LegacySendCodecs()) { + for (const Codec& codec : engine_.LegacySendCodecs()) { if (codec.name != kRtxCodecName) continue; int associated_payload_type; @@ -478,7 +474,7 @@ TEST_F(WebRtcVideoEngineTest, &associated_payload_type)); EXPECT_EQ(codec.id, associated_payload_type + 1); } - for (const webrtc::Codec& codec : engine_.LegacyRecvCodecs()) { + for (const Codec& codec : engine_.LegacyRecvCodecs()) { if (codec.name != kRtxCodecName) continue; int associated_payload_type; @@ -757,7 +753,7 @@ TEST_F(WebRtcVideoEngineTest, UseFactoryForVp8WhenSupported) { EXPECT_EQ(0, encoder_factory_->GetNumCreatedEncoders()); EXPECT_TRUE(send_channel->SetSend(true)); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE(send_channel->SetVideoSend(kSsrc, nullptr, &frame_forwarder)); frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame()); time_controller_.AdvanceTime(TimeDelta::Zero()); @@ -785,10 +781,6 @@ TEST_F(WebRtcVideoEngineTest, UseFactoryForVp8WhenSupported) { // TODO(deadbeef): This test should be updated if/when we start // adding RTX codecs for unrecognized codec names. TEST_F(WebRtcVideoEngineTest, RtxCodecAddedForH264Codec) { - using webrtc::H264Level; - using webrtc::H264Profile; - using webrtc::H264ProfileLevelId; - using webrtc::H264ProfileLevelIdToString; SdpVideoFormat h264_constrained_baseline("H264"); h264_constrained_baseline.parameters[kH264FmtpProfileLevelId] = *H264ProfileLevelIdToString(H264ProfileLevelId( @@ -810,17 +802,15 @@ TEST_F(WebRtcVideoEngineTest, RtxCodecAddedForH264Codec) { // Now search for RTX codecs for them. Expect that they all have associated // RTX codecs. EXPECT_TRUE(HasRtxCodec( - codecs, webrtc::FindMatchingVideoCodec( - codecs, webrtc::CreateVideoCodec(h264_constrained_baseline)) + codecs, FindMatchingVideoCodec( + codecs, CreateVideoCodec(h264_constrained_baseline)) ->id)); EXPECT_TRUE(HasRtxCodec( - codecs, webrtc::FindMatchingVideoCodec( - codecs, webrtc::CreateVideoCodec(h264_constrained_high)) - ->id)); - EXPECT_TRUE( - HasRtxCodec(codecs, webrtc::FindMatchingVideoCodec( - codecs, webrtc::CreateVideoCodec(h264_high)) - ->id)); + codecs, + FindMatchingVideoCodec(codecs, CreateVideoCodec(h264_constrained_high)) + ->id)); + EXPECT_TRUE(HasRtxCodec( + codecs, FindMatchingVideoCodec(codecs, CreateVideoCodec(h264_high))->id)); } #if defined(RTC_ENABLE_VP9) @@ -843,7 +833,7 @@ TEST_F(WebRtcVideoEngineTest, PropagatesInputFrameTimestamp) { EXPECT_TRUE(send_channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 60); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 60); EXPECT_TRUE(send_channel->SetVideoSend(kSsrc, nullptr, &frame_forwarder)); send_channel->SetSend(true); @@ -863,14 +853,12 @@ TEST_F(WebRtcVideoEngineTest, PropagatesInputFrameTimestamp) { last_timestamp = timestamp; } - frame_forwarder.IncomingCapturedFrame( - frame_source.GetFrame(1280, 720, VideoRotation::kVideoRotation_0, - webrtc::kNumMicrosecsPerSec / 30)); + frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame( + 1280, 720, VideoRotation::kVideoRotation_0, kNumMicrosecsPerSec / 30)); last_timestamp = stream->GetLastTimestamp(); for (int i = 0; i < 10; i++) { - frame_forwarder.IncomingCapturedFrame( - frame_source.GetFrame(1280, 720, VideoRotation::kVideoRotation_0, - webrtc::kNumMicrosecsPerSec / 30)); + frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame( + 1280, 720, VideoRotation::kVideoRotation_0, kNumMicrosecsPerSec / 30)); int64_t timestamp = stream->GetLastTimestamp(); int64_t interval = timestamp - last_timestamp; @@ -888,7 +876,7 @@ TEST_F(WebRtcVideoEngineTest, PropagatesInputFrameTimestamp) { void WebRtcVideoEngineTest::AssignDefaultAptRtxTypes() { std::vector engine_codecs = engine_.LegacySendCodecs(); RTC_DCHECK(!engine_codecs.empty()); - for (const webrtc::Codec& codec : engine_codecs) { + for (const Codec& codec : engine_codecs) { if (codec.name == "rtx") { int associated_payload_type; if (codec.GetParam(kCodecParamAssociatedPayloadType, @@ -903,7 +891,7 @@ void WebRtcVideoEngineTest::AssignDefaultCodec() { std::vector engine_codecs = engine_.LegacySendCodecs(); RTC_DCHECK(!engine_codecs.empty()); bool codec_set = false; - for (const webrtc::Codec& codec : engine_codecs) { + for (const Codec& codec : engine_codecs) { if (!codec_set && codec.name != "rtx" && codec.name != "red" && codec.name != "ulpfec" && codec.name != "flexfec-03") { default_codec_ = codec; @@ -925,7 +913,7 @@ size_t WebRtcVideoEngineTest::GetEngineCodecIndex( // an internal H264 codec from the engine with a different H264 profile. if (absl::EqualsIgnoreCase(name.c_str(), kH264CodecName)) { const std::optional profile_level_id = - webrtc::ParseSdpForH264ProfileLevelId(engine_codec.params); + ParseSdpForH264ProfileLevelId(engine_codec.params); if (profile_level_id->profile != H264Profile::kProfileConstrainedBaseline) { continue; @@ -962,8 +950,7 @@ WebRtcVideoEngineTest::SetSendParamsWithAllSupportedCodecs() { video_bitrate_allocator_factory_.get()); VideoSenderParameters parameters; // We need to look up the codec in the engine to get the correct payload type. - for (const webrtc::SdpVideoFormat& format : - encoder_factory_->GetSupportedFormats()) { + for (const SdpVideoFormat& format : encoder_factory_->GetSupportedFormats()) { Codec engine_codec = GetEngineCodec(format.name); if (!absl::c_linear_search(parameters.codecs, engine_codec)) { parameters.codecs.push_back(engine_codec); @@ -991,8 +978,7 @@ WebRtcVideoEngineTest::SetRecvParamsWithSupportedCodecs( std::unique_ptr WebRtcVideoEngineTest::SetRecvParamsWithAllSupportedCodecs() { std::vector codecs; - for (const webrtc::SdpVideoFormat& format : - decoder_factory_->GetSupportedFormats()) { + for (const SdpVideoFormat& format : decoder_factory_->GetSupportedFormats()) { Codec engine_codec = GetEngineCodec(format.name); if (!absl::c_linear_search(codecs, engine_codec)) { codecs.push_back(engine_codec); @@ -1103,12 +1089,12 @@ TEST_F(WebRtcVideoEngineTest, UsesSimulcastAdapterForVp8Factories) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - EXPECT_TRUE(send_channel->AddSendStream( - webrtc::CreateSimStreamParams("cname", ssrcs))); + EXPECT_TRUE( + send_channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); EXPECT_TRUE(send_channel->SetSend(true)); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 60); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 60); EXPECT_TRUE( send_channel->SetVideoSend(ssrcs.front(), nullptr, &frame_forwarder)); frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame()); @@ -1139,7 +1125,7 @@ TEST_F(WebRtcVideoEngineTest, ChannelWithH264CanChangeToVp8) { // Frame source. FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); std::unique_ptr send_channel = engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), @@ -1183,15 +1169,15 @@ TEST_F(WebRtcVideoEngineTest, std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - EXPECT_TRUE(send_channel->AddSendStream( - webrtc::CreateSimStreamParams("cname", ssrcs))); + EXPECT_TRUE( + send_channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); EXPECT_TRUE(send_channel->SetSend(true)); // Send a fake frame, or else the media engine will configure the simulcast // encoder adapter at a low-enough size that it'll only create a single // encoder layer. FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE( send_channel->SetVideoSend(ssrcs.front(), nullptr, &frame_forwarder)); frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame()); @@ -1199,7 +1185,7 @@ TEST_F(WebRtcVideoEngineTest, ASSERT_TRUE(encoder_factory_->WaitForCreatedVideoEncoders(2)); ASSERT_TRUE(encoder_factory_->encoders()[0]->WaitForInitEncode()); - EXPECT_EQ(webrtc::kVideoCodecVP8, + EXPECT_EQ(kVideoCodecVP8, encoder_factory_->encoders()[0]->GetCodecSettings().codecType); send_channel.reset(); @@ -1224,14 +1210,14 @@ TEST_F(WebRtcVideoEngineTest, // Send a frame of 720p. This should trigger a "real" encoder initialization. FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE(send_channel->SetVideoSend(kSsrc, nullptr, &frame_forwarder)); frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame()); time_controller_.AdvanceTime(TimeDelta::Zero()); ASSERT_TRUE(encoder_factory_->WaitForCreatedVideoEncoders(1)); ASSERT_EQ(1u, encoder_factory_->encoders().size()); ASSERT_TRUE(encoder_factory_->encoders()[0]->WaitForInitEncode()); - EXPECT_EQ(webrtc::kVideoCodecH264, + EXPECT_EQ(kVideoCodecH264, encoder_factory_->encoders()[0]->GetCodecSettings().codecType); send_channel.reset(); @@ -1252,12 +1238,12 @@ TEST_F(WebRtcVideoEngineTest, SimulcastEnabledForH264) { EXPECT_TRUE(send_channel->SetSenderParameters(parameters)); const std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - EXPECT_TRUE(send_channel->AddSendStream( - webrtc::CreateSimStreamParams("cname", ssrcs))); + EXPECT_TRUE( + send_channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); // Send a frame of 720p. This should trigger a "real" encoder initialization. FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE(send_channel->SetVideoSend(ssrcs[0], nullptr, &frame_forwarder)); frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame()); time_controller_.AdvanceTime(TimeDelta::Zero()); @@ -1266,7 +1252,7 @@ TEST_F(WebRtcVideoEngineTest, SimulcastEnabledForH264) { ASSERT_EQ(1u, encoder_factory_->encoders().size()); FakeWebRtcVideoEncoder* encoder = encoder_factory_->encoders()[0]; ASSERT_TRUE(encoder_factory_->encoders()[0]->WaitForInitEncode()); - EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType); + EXPECT_EQ(kVideoCodecH264, encoder->GetCodecSettings().codecType); EXPECT_LT(1u, encoder->GetCodecSettings().numberOfSimulcastStreams); EXPECT_TRUE(send_channel->SetVideoSend(ssrcs[0], nullptr, nullptr)); } @@ -1443,7 +1429,7 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { std::unique_ptr rate_allocator_factory = std::make_unique(); EXPECT_CALL(*rate_allocator_factory, - Create(_, Field(&VideoCodec::codecType, webrtc::kVideoCodecVP8))) + Create(_, Field(&VideoCodec::codecType, kVideoCodecVP8))) .WillOnce([] { return std::make_unique(); }); FieldTrialBasedConfig trials; WebRtcVideoEngine engine( @@ -1520,7 +1506,7 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { // Set capturer. FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE(send_channel->SetVideoSend(send_ssrc, nullptr, &frame_forwarder)); // Sending one frame will allocate the encoder. frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame()); @@ -1560,7 +1546,7 @@ TEST_F(WebRtcVideoEngineTest, DISABLED_RecreatesEncoderOnContentTypeChange) { ASSERT_TRUE(send_channel->SetSenderParameters(parameters)); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); VideoOptions options; EXPECT_TRUE(send_channel->SetVideoSend(kSsrc, &options, &frame_forwarder)); @@ -1632,7 +1618,7 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { time_controller_.GetClock())), call_(Call::Create(CallConfig(env_))), video_bitrate_allocator_factory_( - webrtc::CreateBuiltinVideoBitrateAllocatorFactory()), + CreateBuiltinVideoBitrateAllocatorFactory()), engine_( std::make_unique< VideoEncoderFactoryTemplateAddSendStream(DefaultSendStreamParams())); frame_forwarder_ = std::make_unique(); frame_source_ = std::make_unique( - 640, 480, webrtc::kNumMicrosecsPerSec / kFramerate); + 640, 480, kNumMicrosecsPerSec / kFramerate); EXPECT_TRUE( send_channel_->SetVideoSend(kSsrc, nullptr, frame_forwarder_.get())); } @@ -1901,7 +1887,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { bool SetOneCodec(const Codec& codec) { frame_source_ = std::make_unique( - kVideoWidth, kVideoHeight, webrtc::kNumMicrosecsPerSec / kFramerate); + kVideoWidth, kVideoHeight, kNumMicrosecsPerSec / kFramerate); bool sending = SendImpl()->sending(); bool success = SetSend(false); @@ -1998,13 +1984,13 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { } Codec GetEngineCodec(const std::string& name) { - for (const webrtc::Codec& engine_codec : engine_.LegacySendCodecs()) { + for (const Codec& engine_codec : engine_.LegacySendCodecs()) { if (absl::EqualsIgnoreCase(name, engine_codec.name)) return engine_codec; } // This point should never be reached. ADD_FAILURE() << "Unrecognized codec name: " << name; - return webrtc::CreateVideoCodec(0, ""); + return CreateVideoCodec(0, ""); } Codec DefaultCodec() { return GetEngineCodec("VP8"); } @@ -2202,7 +2188,7 @@ TEST_F(WebRtcVideoChannelBaseTest, GetStatsMultipleSendStreams) { const int kTestWidth = 160; const int kTestHeight = 120; FakeFrameSource frame_source(kTestWidth, kTestHeight, - webrtc::kNumMicrosecsPerSec / 5); + kNumMicrosecsPerSec / 5); EXPECT_TRUE(send_channel_->AddSendStream(StreamParams::CreateLegacy(5678))); EXPECT_TRUE(send_channel_->SetVideoSend(5678, nullptr, &frame_forwarder)); EXPECT_TRUE( @@ -2307,7 +2293,7 @@ TEST_F(WebRtcVideoChannelBaseTest, SetSendSsrcAfterSetCodecs) { TEST_F(WebRtcVideoChannelBaseTest, SetSink) { RtpPacketReceived packet; packet.SetSsrc(kSsrc); - receive_channel_->SetDefaultSink(NULL); + receive_channel_->SetDefaultSink(nullptr); EXPECT_TRUE(SetDefaultCodec()); EXPECT_TRUE(SetSend(true)); EXPECT_EQ(0, renderer_.num_rendered_frames()); @@ -2381,8 +2367,6 @@ TEST_F(WebRtcVideoChannelBaseTest, SimulateConference) { // Tests that we can add and remove capturers and frames are sent out properly TEST_F(WebRtcVideoChannelBaseTest, DISABLED_AddRemoveCapturer) { - using webrtc::Codec; - Codec codec = DefaultCodec(); const int time_between_send_ms = VideoFormat::FpsToInterval(kFramerate); EXPECT_TRUE(SetOneCodec(codec)); @@ -2393,8 +2377,8 @@ TEST_F(WebRtcVideoChannelBaseTest, DISABLED_AddRemoveCapturer) { EXPECT_FRAME(1, kVideoWidth, kVideoHeight); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(480, 360, webrtc::kNumMicrosecsPerSec / 30, - webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(480, 360, kNumMicrosecsPerSec / 30, + kNumMicrosecsPerSec / 30); // TODO(nisse): This testcase fails if we don't configure // screencast. It's unclear why, I see nothing obvious in this @@ -2480,7 +2464,7 @@ TEST_F(WebRtcVideoChannelBaseTest, AddRemoveCapturerMultipleSources) { FrameForwarder frame_forwarder1; FakeFrameSource frame_source(kVideoWidth, kVideoHeight, - webrtc::kNumMicrosecsPerSec / kFramerate); + kNumMicrosecsPerSec / kFramerate); // Set up additional stream 2. FakeVideoRenderer renderer2; @@ -2503,13 +2487,13 @@ TEST_F(WebRtcVideoChannelBaseTest, AddRemoveCapturerMultipleSources) { const int kTestHeight = 120; frame_forwarder1.IncomingCapturedFrame(frame_source.GetFrame( kTestWidth, kTestHeight, VideoRotation::kVideoRotation_0, - webrtc::kNumMicrosecsPerSec / kFramerate)); + kNumMicrosecsPerSec / kFramerate)); time_controller_.AdvanceTime(kFrameDuration); EXPECT_FRAME_ON_RENDERER(renderer1, 1, kTestWidth, kTestHeight); // Capture a frame with additional capturer2, frames should be received frame_forwarder2.IncomingCapturedFrame(frame_source.GetFrame( kTestWidth, kTestHeight, VideoRotation::kVideoRotation_0, - webrtc::kNumMicrosecsPerSec / kFramerate)); + kNumMicrosecsPerSec / kFramerate)); time_controller_.AdvanceTime(kFrameDuration); EXPECT_FRAME_ON_RENDERER(renderer2, 1, kTestWidth, kTestHeight); // Successfully remove the capturer. @@ -2572,6 +2556,8 @@ TEST_F(WebRtcVideoChannelBaseTest, TwoStreamsSendAndReceive) { TEST_F(WebRtcVideoChannelBaseTest, RequestEncoderFallbackNextCodecFollowNegotiatedOrder) { + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-SwitchEncoderFollowCodecPreferenceOrder/Enabled/"); VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP9")); parameters.codecs.push_back(GetEngineCodec("AV1")); @@ -2713,7 +2699,7 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest { WebRtcVideoChannelTest() : WebRtcVideoChannelTest("") {} explicit WebRtcVideoChannelTest(const char* field_trials) : WebRtcVideoEngineTest(field_trials), - frame_source_(1280, 720, webrtc::kNumMicrosecsPerSec / 30), + frame_source_(1280, 720, kNumMicrosecsPerSec / 30), last_ssrc_(0) {} void SetUp() override { AddSupportedVideoCodecType("VP8"); @@ -2775,13 +2761,13 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest { } Codec GetEngineCodec(const std::string& name) { - for (const webrtc::Codec& engine_codec : engine_.LegacySendCodecs()) { + for (const Codec& engine_codec : engine_.LegacySendCodecs()) { if (absl::EqualsIgnoreCase(name, engine_codec.name)) return engine_codec; } // This point should never be reached. ADD_FAILURE() << "Unrecognized codec name: " << name; - return webrtc::CreateVideoCodec(0, ""); + return CreateVideoCodec(0, ""); } Codec DefaultCodec() { return GetEngineCodec("VP8"); } @@ -3025,9 +3011,9 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest { } if (with_rtx) { return AddSendStream( - webrtc::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); + CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); } - return AddSendStream(webrtc::CreateSimStreamParams("cname", ssrcs)); + return AddSendStream(CreateSimStreamParams("cname", ssrcs)); } int GetMaxEncoderBitrate() { @@ -3107,16 +3093,16 @@ TEST_F(WebRtcVideoChannelTest, RecvStreamWithSimAndRtx) { // Send side. const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); - FakeVideoSendStream* send_stream = AddSendStream( - webrtc::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); + FakeVideoSendStream* send_stream = + AddSendStream(CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); for (size_t i = 0; i < rtx_ssrcs.size(); ++i) EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); // Receiver side. - FakeVideoReceiveStream* recv_stream = AddRecvStream( - webrtc::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); + FakeVideoReceiveStream* recv_stream = + AddRecvStream(CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); EXPECT_FALSE( recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty()); EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) @@ -3340,21 +3326,21 @@ TEST_F(WebRtcVideoChannelTest, TEST_F(WebRtcVideoChannelTest, SetSendRtpHeaderExtensionsRejectsIncorrectIds) { const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; - for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { + for (int incorrect_id : kIncorrectIds) { send_parameters_.extensions.push_back( - RtpExtension(RtpExtension::kTimestampOffsetUri, kIncorrectIds[i])); + RtpExtension(RtpExtension::kTimestampOffsetUri, incorrect_id)); EXPECT_FALSE(send_channel_->SetSenderParameters(send_parameters_)) - << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; + << "Bad extension id '" << incorrect_id << "' accepted."; } } TEST_F(WebRtcVideoChannelTest, SetRecvRtpHeaderExtensionsRejectsIncorrectIds) { const int kIncorrectIds[] = {-2, -1, 0, 15, 16}; - for (size_t i = 0; i < arraysize(kIncorrectIds); ++i) { + for (int incorrect_id : kIncorrectIds) { recv_parameters_.extensions.push_back( - RtpExtension(RtpExtension::kTimestampOffsetUri, kIncorrectIds[i])); + RtpExtension(RtpExtension::kTimestampOffsetUri, incorrect_id)); EXPECT_FALSE(receive_channel_->SetReceiverParameters(recv_parameters_)) - << "Bad extension id '" << kIncorrectIds[i] << "' accepted."; + << "Bad extension id '" << incorrect_id << "' accepted."; } } @@ -3544,7 +3530,7 @@ TEST_F(WebRtcVideoChannelTest, ReconfiguresEncodersWhenNotSending) { EXPECT_EQ(0u, streams[0].height); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE( send_channel_->SetVideoSend(last_ssrc_, nullptr, &frame_forwarder)); @@ -3567,7 +3553,7 @@ TEST_F(WebRtcVideoChannelTest, UsesCorrectSettingsForScreencast) { AddSendStream(); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); VideoOptions min_bitrate_options; min_bitrate_options.screencast_min_bitrate_kbps = kScreenshareMinBitrateKbps; EXPECT_TRUE(send_channel_->SetVideoSend(last_ssrc_, &min_bitrate_options, @@ -3627,7 +3613,7 @@ TEST_F(WebRtcVideoChannelTest, VideoOptions options; options.is_screencast = true; FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE( send_channel_->SetVideoSend(last_ssrc_, &options, &frame_forwarder)); EXPECT_TRUE(send_channel_->SetSend(true)); @@ -3993,7 +3979,7 @@ TEST_F(Vp9SettingsTest, MultipleSsrcsEnablesSvc) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); FakeVideoSendStream* stream = - AddSendStream(webrtc::CreateSimStreamParams("cname", ssrcs)); + AddSendStream(CreateSimStreamParams("cname", ssrcs)); VideoSendStream::Config config = stream->GetConfig().Copy(); @@ -4022,7 +4008,7 @@ TEST_F(Vp9SettingsTest, SvcModeCreatesSingleRtpStream) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); FakeVideoSendStream* stream = - AddSendStream(webrtc::CreateSimStreamParams("cname", ssrcs)); + AddSendStream(CreateSimStreamParams("cname", ssrcs)); VideoSendStream::Config config = stream->GetConfig().Copy(); @@ -4053,7 +4039,7 @@ TEST_F(Vp9SettingsTest, AllEncodingParametersCopied) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); FakeVideoSendStream* stream = - AddSendStream(webrtc::CreateSimStreamParams("cname", ssrcs)); + AddSendStream(CreateSimStreamParams("cname", ssrcs)); RtpParameters parameters = send_channel_->GetRtpSendParameters(ssrcs[0]); ASSERT_EQ(kNumSpatialLayers, parameters.encodings.size()); @@ -4084,7 +4070,7 @@ TEST_F(Vp9SettingsTest, MaxBitrateDeterminedBySvcResolutions) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); FakeVideoSendStream* stream = - AddSendStream(webrtc::CreateSimStreamParams("cname", ssrcs)); + AddSendStream(CreateSimStreamParams("cname", ssrcs)); VideoSendStream::Config config = stream->GetConfig().Copy(); @@ -4128,7 +4114,7 @@ TEST_F(Vp9SettingsTest, Vp9SvcTargetBitrateCappedByMax) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); FakeVideoSendStream* stream = - AddSendStream(webrtc::CreateSimStreamParams("cname", ssrcs)); + AddSendStream(CreateSimStreamParams("cname", ssrcs)); VideoSendStream::Config config = stream->GetConfig().Copy(); @@ -4237,7 +4223,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(WebRtcVideoChannelTest, VerifyMinBitrate) { std::vector streams = AddSendStream()->GetVideoStreams(); ASSERT_EQ(1u, streams.size()); - EXPECT_EQ(webrtc::kDefaultMinVideoBitrateBps, streams[0].min_bitrate_bps); + EXPECT_EQ(kDefaultMinVideoBitrateBps, streams[0].min_bitrate_bps); } TEST_F(WebRtcVideoChannelTest, VerifyMinBitrateWithForcedFallbackFieldTrial) { @@ -4430,7 +4416,7 @@ TEST_F(WebRtcVideoChannelTest, EstimatesNtpStartTimeCorrectly) { .set_video_frame_buffer(CreateBlackFrameBuffer(4, 4)) .set_rtp_timestamp(kInitialTimestamp) .set_timestamp_us(0) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .build(); // Initial NTP time is not available on the first frame, but should still be // able to be estimated. @@ -4470,8 +4456,8 @@ TEST_F(WebRtcVideoChannelTest, SetDefaultSendCodecs) { // Using a RTX setup to verify that the default RTX payload type is good. const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); - FakeVideoSendStream* stream = AddSendStream( - webrtc::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); + FakeVideoSendStream* stream = + AddSendStream(CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); VideoSendStream::Config config = stream->GetConfig().Copy(); // Make sure NACK and FEC are enabled on the correct payload types. @@ -4520,9 +4506,8 @@ TEST_F(WebRtcVideoChannelTest, FlexfecSendCodecWithoutSsrcNotExposedByDefault) { } TEST_F(WebRtcVideoChannelTest, FlexfecSendCodecWithSsrcNotExposedByDefault) { - FakeVideoSendStream* stream = - AddSendStream(webrtc::CreatePrimaryWithFecFrStreamParams( - "cname", kSsrcs1[0], kFlexfecSsrc)); + FakeVideoSendStream* stream = AddSendStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); VideoSendStream::Config config = stream->GetConfig().Copy(); EXPECT_EQ(-1, config.rtp.flexfec.payload_type); @@ -4539,8 +4524,8 @@ TEST_F(WebRtcVideoChannelTest, FlexfecRecvCodecWithoutSsrcNotExposedByDefault) { } TEST_F(WebRtcVideoChannelTest, FlexfecRecvCodecWithSsrcExposedByDefault) { - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); const std::vector& streams = fake_call_->GetFlexfecReceiveStreams(); @@ -4558,7 +4543,7 @@ class WebRtcVideoChannelFlexfecRecvTest : public WebRtcVideoChannelTest { TEST_F(WebRtcVideoChannelFlexfecRecvTest, DefaultFlexfecCodecHasRembFeedbackParam) { - EXPECT_TRUE(webrtc::HasRemb(GetEngineCodec("flexfec-03"))); + EXPECT_TRUE(HasRemb(GetEngineCodec("flexfec-03"))); } TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetDefaultRecvCodecsWithoutSsrc) { @@ -4579,8 +4564,8 @@ TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetDefaultRecvCodecsWithoutSsrc) { } TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetDefaultRecvCodecsWithSsrc) { - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); const std::vector& streams = fake_call_->GetFlexfecReceiveStreams(); @@ -4612,8 +4597,8 @@ TEST_F(WebRtcVideoChannelFlexfecRecvTest, recv_parameters.codecs.push_back(GetEngineCodec("VP8")); ASSERT_TRUE(receive_channel_->SetReceiverParameters(recv_parameters)); - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams()); const std::vector& video_streams = fake_call_->GetVideoReceiveStreams(); @@ -4654,8 +4639,8 @@ TEST_F(WebRtcVideoChannelFlexfecRecvTest, recv_parameters.codecs.push_back(GetEngineCodec("flexfec-03")); ASSERT_TRUE(receive_channel_->SetReceiverParameters(recv_parameters)); - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); EXPECT_EQ(2, fake_call_->GetNumCreatedReceiveStreams()); EXPECT_EQ(1U, fake_call_->GetFlexfecReceiveStreams().size()); const std::vector& video_streams = @@ -4697,8 +4682,8 @@ TEST_F(WebRtcVideoChannelFlexfecRecvTest, DuplicateFlexfecCodecIsDropped) { recv_parameters.codecs.push_back(duplicate); ASSERT_TRUE(receive_channel_->SetReceiverParameters(recv_parameters)); - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); const std::vector& streams = fake_call_->GetFlexfecReceiveStreams(); @@ -4729,9 +4714,8 @@ TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, SetDefaultSendCodecsWithoutSsrc) { } TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, SetDefaultSendCodecsWithSsrc) { - FakeVideoSendStream* stream = - AddSendStream(webrtc::CreatePrimaryWithFecFrStreamParams( - "cname", kSsrcs1[0], kFlexfecSsrc)); + FakeVideoSendStream* stream = AddSendStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); VideoSendStream::Config config = stream->GetConfig().Copy(); EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type); @@ -4764,8 +4748,8 @@ TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, SetSendCodecsWithoutFec) { } TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetRecvCodecsWithFec) { - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); VideoReceiverParameters recv_parameters; recv_parameters.codecs.push_back(GetEngineCodec("VP8")); @@ -4821,9 +4805,8 @@ TEST_F(WebRtcVideoChannelFlexfecRecvTest, parameters.codecs.push_back(GetEngineCodec("flexfec-03")); ASSERT_TRUE(send_channel_->SetSenderParameters(parameters)); - FakeVideoSendStream* stream = - AddSendStream(webrtc::CreatePrimaryWithFecFrStreamParams( - "cname", kSsrcs1[0], kFlexfecSsrc)); + FakeVideoSendStream* stream = AddSendStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); VideoSendStream::Config config = stream->GetConfig().Copy(); EXPECT_EQ(-1, config.rtp.flexfec.payload_type); @@ -4834,11 +4817,10 @@ TEST_F(WebRtcVideoChannelFlexfecRecvTest, TEST_F(WebRtcVideoChannelTest, SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { const int kUnusedPayloadType = 127; - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType)); + EXPECT_FALSE(FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType)); VideoSenderParameters parameters; - Codec rtx_codec = webrtc::CreateVideoCodec(kUnusedPayloadType, "rtx"); + Codec rtx_codec = CreateVideoCodec(kUnusedPayloadType, "rtx"); parameters.codecs.push_back(rtx_codec); EXPECT_FALSE(send_channel_->SetSenderParameters(parameters)) << "RTX codec without associated payload type should be rejected."; @@ -4848,13 +4830,11 @@ TEST_F(WebRtcVideoChannelTest, SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { const int kUnusedPayloadType1 = 126; const int kUnusedPayloadType2 = 127; - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType1)); - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType2)); + EXPECT_FALSE(FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType1)); + EXPECT_FALSE(FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType2)); { - Codec rtx_codec = webrtc::CreateVideoRtxCodec(kUnusedPayloadType1, - GetEngineCodec("VP8").id); + Codec rtx_codec = + CreateVideoRtxCodec(kUnusedPayloadType1, GetEngineCodec("VP8").id); VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); parameters.codecs.push_back(rtx_codec); @@ -4862,7 +4842,7 @@ TEST_F(WebRtcVideoChannelTest, } { Codec rtx_codec = - webrtc::CreateVideoRtxCodec(kUnusedPayloadType1, kUnusedPayloadType2); + CreateVideoRtxCodec(kUnusedPayloadType1, kUnusedPayloadType2); VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); parameters.codecs.push_back(rtx_codec); @@ -4874,10 +4854,8 @@ TEST_F(WebRtcVideoChannelTest, TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithChangedRtxPayloadType) { const int kUnusedPayloadType1 = 126; const int kUnusedPayloadType2 = 127; - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType1)); - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType2)); + EXPECT_FALSE(FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType1)); + EXPECT_FALSE(FindCodecById(engine_.LegacySendCodecs(), kUnusedPayloadType2)); // SSRCs for RTX. StreamParams params = StreamParams::CreateLegacy(kSsrcs1[0]); @@ -4887,7 +4865,7 @@ TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithChangedRtxPayloadType) { // Original payload type for RTX. VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); - Codec rtx_codec = webrtc::CreateVideoCodec(kUnusedPayloadType1, "rtx"); + Codec rtx_codec = CreateVideoCodec(kUnusedPayloadType1, "rtx"); rtx_codec.SetParam("apt", GetEngineCodec("VP8").id); parameters.codecs.push_back(rtx_codec); EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); @@ -4936,9 +4914,8 @@ TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, parameters.codecs.push_back(GetEngineCodec("flexfec-03")); ASSERT_TRUE(send_channel_->SetSenderParameters(parameters)); - FakeVideoSendStream* stream = - AddSendStream(webrtc::CreatePrimaryWithFecFrStreamParams( - "cname", kSsrcs1[0], kFlexfecSsrc)); + FakeVideoSendStream* stream = AddSendStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); VideoSendStream::Config config = stream->GetConfig().Copy(); EXPECT_EQ(GetEngineCodec("flexfec-03").id, config.rtp.flexfec.payload_type); @@ -4957,7 +4934,7 @@ TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, TEST_F(WebRtcVideoChannelTest, SetSendCodecsChangesExistingStreams) { VideoSenderParameters parameters; - Codec codec = webrtc::CreateVideoCodec(100, "VP8"); + Codec codec = CreateVideoCodec(100, "VP8"); codec.SetParam(kCodecParamMaxQuantization, kDefaultVideoMaxQpVpx); parameters.codecs.push_back(codec); @@ -5012,8 +4989,8 @@ TEST_F(WebRtcVideoChannelTest, SetSenderParametersRemovesSelectedCodecFromRtpParameters) { EXPECT_TRUE(AddSendStream()); VideoSenderParameters parameters; - parameters.codecs.push_back(webrtc::CreateVideoCodec(100, "VP8")); - parameters.codecs.push_back(webrtc::CreateVideoCodec(100, "VP9")); + parameters.codecs.push_back(CreateVideoCodec(100, "VP8")); + parameters.codecs.push_back(CreateVideoCodec(100, "VP9")); send_channel_->SetSenderParameters(parameters); RtpParameters initial_params = @@ -5031,7 +5008,7 @@ TEST_F(WebRtcVideoChannelTest, send_channel_->SetRtpSendParameters(last_ssrc_, initial_params).ok()); parameters.codecs.clear(); - parameters.codecs.push_back(webrtc::CreateVideoCodec(100, "VP8")); + parameters.codecs.push_back(CreateVideoCodec(100, "VP8")); send_channel_->SetSenderParameters(parameters); // Since VP9 is no longer negotiated, the RTP parameters should not have a @@ -5221,8 +5198,8 @@ TEST_F(WebRtcVideoChannelTest, ASSERT_TRUE(send_channel_->SetSenderParameters(parameters)); send_channel_->SetSend(true); - FakeVideoSendStream* stream = AddSendStream( - webrtc::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); + FakeVideoSendStream* stream = + AddSendStream(CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); // Send a frame to make sure this scales up to >1 stream (simulcast). FrameForwarder frame_forwarder; @@ -5233,7 +5210,7 @@ TEST_F(WebRtcVideoChannelTest, std::vector streams = stream->GetVideoStreams(); ASSERT_GT(streams.size(), 1u) << "Without simulcast this test doesn't make sense."; - int initial_max_bitrate_bps = webrtc::GetTotalMaxBitrate(streams).bps(); + int initial_max_bitrate_bps = GetTotalMaxBitrate(streams).bps(); EXPECT_GT(initial_max_bitrate_bps, 0); parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; @@ -5241,7 +5218,7 @@ TEST_F(WebRtcVideoChannelTest, // Insert a frame to update the encoder config. frame_forwarder.IncomingCapturedFrame(frame_source_.GetFrame()); streams = stream->GetVideoStreams(); - int increased_max_bitrate_bps = webrtc::GetTotalMaxBitrate(streams).bps(); + int increased_max_bitrate_bps = GetTotalMaxBitrate(streams).bps(); EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); EXPECT_TRUE(send_channel_->SetVideoSend(kSsrcs3[0], nullptr, nullptr)); @@ -5266,10 +5243,10 @@ TEST_F(WebRtcVideoChannelTest, SetSendCodecsRejectBadPayloadTypes) { static const int kIncorrectPayloads[] = {-2, -1, 128, 129}; VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); - for (size_t i = 0; i < arraysize(kIncorrectPayloads); ++i) { - parameters.codecs[0].id = kIncorrectPayloads[i]; + for (int incorrect_id : kIncorrectPayloads) { + parameters.codecs[0].id = incorrect_id; EXPECT_FALSE(send_channel_->SetSenderParameters(parameters)) - << "Bad payload type '" << kIncorrectPayloads[i] << "' accepted."; + << "Bad payload type '" << incorrect_id << "' accepted."; } } @@ -5313,14 +5290,12 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithOnlyVp8) { TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithRtx) { const int kUnusedPayloadType1 = 126; const int kUnusedPayloadType2 = 127; - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType1)); - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType2)); + EXPECT_FALSE(FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType1)); + EXPECT_FALSE(FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType2)); VideoReceiverParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); - Codec rtx_codec = webrtc::CreateVideoCodec(kUnusedPayloadType1, "rtx"); + Codec rtx_codec = CreateVideoCodec(kUnusedPayloadType1, "rtx"); parameters.codecs.push_back(rtx_codec); EXPECT_FALSE(receive_channel_->SetReceiverParameters(parameters)) << "RTX codec without associated payload should be rejected."; @@ -5332,7 +5307,7 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithRtx) { parameters.codecs[1].SetParam("apt", GetEngineCodec("VP8").id); EXPECT_TRUE(receive_channel_->SetReceiverParameters(parameters)); - Codec rtx_codec2 = webrtc::CreateVideoCodec(kUnusedPayloadType2, "rtx"); + Codec rtx_codec2 = CreateVideoCodec(kUnusedPayloadType2, "rtx"); rtx_codec2.SetParam("apt", rtx_codec.id); parameters.codecs.push_back(rtx_codec2); @@ -5382,9 +5357,9 @@ TEST_F(WebRtcVideoChannelTest, DuplicateUlpfecCodecIsDropped) { VideoReceiverParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); parameters.codecs.push_back( - webrtc::CreateVideoCodec(kFirstUlpfecPayloadType, kUlpfecCodecName)); + CreateVideoCodec(kFirstUlpfecPayloadType, kUlpfecCodecName)); parameters.codecs.push_back( - webrtc::CreateVideoCodec(kSecondUlpfecPayloadType, kUlpfecCodecName)); + CreateVideoCodec(kSecondUlpfecPayloadType, kUlpfecCodecName)); ASSERT_TRUE(receive_channel_->SetReceiverParameters(parameters)); FakeVideoReceiveStream* recv_stream = AddRecvStream(); @@ -5399,9 +5374,9 @@ TEST_F(WebRtcVideoChannelTest, DuplicateRedCodecIsDropped) { VideoReceiverParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); parameters.codecs.push_back( - webrtc::CreateVideoCodec(kFirstRedPayloadType, kRedCodecName)); + CreateVideoCodec(kFirstRedPayloadType, kRedCodecName)); parameters.codecs.push_back( - webrtc::CreateVideoCodec(kSecondRedPayloadType, kRedCodecName)); + CreateVideoCodec(kSecondRedPayloadType, kRedCodecName)); ASSERT_TRUE(receive_channel_->SetReceiverParameters(parameters)); FakeVideoReceiveStream* recv_stream = AddRecvStream(); @@ -5412,10 +5387,8 @@ TEST_F(WebRtcVideoChannelTest, DuplicateRedCodecIsDropped) { TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithChangedRtxPayloadType) { const int kUnusedPayloadType1 = 126; const int kUnusedPayloadType2 = 127; - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType1)); - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType2)); + EXPECT_FALSE(FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType1)); + EXPECT_FALSE(FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType2)); // SSRCs for RTX. StreamParams params = StreamParams::CreateLegacy(kSsrcs1[0]); @@ -5425,7 +5398,7 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithChangedRtxPayloadType) { // Original payload type for RTX. VideoReceiverParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); - Codec rtx_codec = webrtc::CreateVideoCodec(kUnusedPayloadType1, "rtx"); + Codec rtx_codec = CreateVideoCodec(kUnusedPayloadType1, "rtx"); rtx_codec.SetParam("apt", GetEngineCodec("VP8").id); parameters.codecs.push_back(rtx_codec); EXPECT_TRUE(receive_channel_->SetReceiverParameters(parameters)); @@ -5456,10 +5429,8 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithChangedRtxPayloadType) { TEST_F(WebRtcVideoChannelTest, SetRecvCodecsRtxWithRtxTime) { const int kUnusedPayloadType1 = 126; const int kUnusedPayloadType2 = 127; - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType1)); - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType2)); + EXPECT_FALSE(FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType1)); + EXPECT_FALSE(FindCodecById(engine_.LegacyRecvCodecs(), kUnusedPayloadType2)); // SSRCs for RTX. StreamParams params = StreamParams::CreateLegacy(kSsrcs1[0]); @@ -5469,7 +5440,7 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsRtxWithRtxTime) { // Payload type for RTX. VideoReceiverParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); - Codec rtx_codec = webrtc::CreateVideoCodec(kUnusedPayloadType1, "rtx"); + Codec rtx_codec = CreateVideoCodec(kUnusedPayloadType1, "rtx"); rtx_codec.SetParam("apt", GetEngineCodec("VP8").id); parameters.codecs.push_back(rtx_codec); EXPECT_TRUE(receive_channel_->SetReceiverParameters(parameters)); @@ -5546,7 +5517,7 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsAcceptDefaultCodecs) { TEST_F(WebRtcVideoChannelTest, SetRecvCodecsRejectUnsupportedCodec) { VideoReceiverParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); - parameters.codecs.push_back(webrtc::CreateVideoCodec(101, "WTF3")); + parameters.codecs.push_back(CreateVideoCodec(101, "WTF3")); EXPECT_FALSE(receive_channel_->SetReceiverParameters(parameters)); } @@ -5579,8 +5550,8 @@ TEST_F(WebRtcVideoChannelTest, SetRecvCodecsWithoutFecDisablesFec) { } TEST_F(WebRtcVideoChannelFlexfecRecvTest, SetRecvParamsWithoutFecDisablesFec) { - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); const std::vector& streams = fake_call_->GetFlexfecReceiveStreams(); @@ -5627,8 +5598,8 @@ TEST_F(WebRtcVideoChannelTest, SetSendParamsWithFecEnablesFec) { TEST_F(WebRtcVideoChannelFlexfecSendRecvTest, SetSendRecvParamsWithFecEnablesFec) { - AddRecvStream(webrtc::CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], - kFlexfecSsrc)); + AddRecvStream( + CreatePrimaryWithFecFrStreamParams("cname", kSsrcs1[0], kFlexfecSsrc)); const std::vector& streams = fake_call_->GetFlexfecReceiveStreams(); @@ -5788,7 +5759,8 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) { // Packets should also self-identify their dscp in PacketOptions. const uint8_t kData[10] = {0}; - EXPECT_TRUE(ChannelImplAsTransport(send_channel.get())->SendRtcp(kData)); + EXPECT_TRUE(ChannelImplAsTransport(send_channel.get()) + ->SendRtcp(kData, /*packet_options=*/{})); EXPECT_EQ(DSCP_CS1, network_interface->options().dscp); send_channel->SetInterface(nullptr); @@ -5847,17 +5819,16 @@ TEST_F(WebRtcVideoChannelTest, TestSetRecvRtcpReducedSize) { } TEST_F(WebRtcVideoChannelTest, OnReadyToSendSignalsNetworkState) { - EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState(MediaType::VIDEO)); - EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState(MediaType::AUDIO)); + EXPECT_EQ(kNetworkUp, fake_call_->GetNetworkState(MediaType::VIDEO)); + EXPECT_EQ(kNetworkUp, fake_call_->GetNetworkState(MediaType::AUDIO)); send_channel_->OnReadyToSend(false); - EXPECT_EQ(webrtc::kNetworkDown, - fake_call_->GetNetworkState(MediaType::VIDEO)); - EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState(MediaType::AUDIO)); + EXPECT_EQ(kNetworkDown, fake_call_->GetNetworkState(MediaType::VIDEO)); + EXPECT_EQ(kNetworkUp, fake_call_->GetNetworkState(MediaType::AUDIO)); send_channel_->OnReadyToSend(true); - EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState(MediaType::VIDEO)); - EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState(MediaType::AUDIO)); + EXPECT_EQ(kNetworkUp, fake_call_->GetNetworkState(MediaType::VIDEO)); + EXPECT_EQ(kNetworkUp, fake_call_->GetNetworkState(MediaType::AUDIO)); } TEST_F(WebRtcVideoChannelTest, GetStatsReportsSentCodecName) { @@ -6338,7 +6309,7 @@ TEST_F(WebRtcVideoChannelTest, // Create simulcast stream from both SSRCs. // `kSsrc1` is the "main" ssrc used for getting parameters. FakeVideoSendStream* stream = - AddSendStream(webrtc::CreateSimStreamParams("cname", {kSsrc1, kSsrc2})); + AddSendStream(CreateSimStreamParams("cname", {kSsrc1, kSsrc2})); RtpParameters parameters = send_channel_->GetRtpSendParameters(kSsrc1); ASSERT_EQ(2u, parameters.encodings.size()); @@ -6377,8 +6348,8 @@ TEST_F(WebRtcVideoChannelTest, OutboundRtpIsActiveComesFromAnyEncodingInSvc) { // Configuring SVC is done the same way that simulcast is configured, the only // difference is that the VP9 codec is used. This triggers special hacks that // we depend on because we don't have a proper SVC API yet. - FakeVideoSendStream* stream = AddSendStream( - webrtc::CreateSimStreamParams("cname", {kSsrc1, kSsrc2, kSsrc3})); + FakeVideoSendStream* stream = + AddSendStream(CreateSimStreamParams("cname", {kSsrc1, kSsrc2, kSsrc3})); // Expect that we got SVC. EXPECT_EQ(stream->GetEncoderConfig().number_of_streams, 1u); VideoCodecVP9 vp9_settings; @@ -6972,7 +6943,7 @@ TEST_F(WebRtcVideoChannelTest, DefaultReceiveStreamReconfiguresToUseRtx) { << "Default receive stream should not have configured RTX"; EXPECT_TRUE(receive_channel_->AddRecvStream( - webrtc::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); + CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) << "AddRecvStream should have reconfigured, not added a new receiver."; recv_stream = fake_call_->GetVideoReceiveStreams()[0]; @@ -6992,8 +6963,7 @@ TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithMissingSsrcsForRtx) { const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); - StreamParams sp = - webrtc::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); + StreamParams sp = CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); sp.ssrcs = ssrcs; // Without RTXs, this is the important part. EXPECT_FALSE(send_channel_->AddSendStream(sp)); @@ -7006,8 +6976,7 @@ TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithOverlappingRtxSsrcs) { const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); - StreamParams sp = - webrtc::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); + StreamParams sp = CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); EXPECT_TRUE(send_channel_->AddSendStream(sp)); EXPECT_TRUE(receive_channel_->AddRecvStream(sp)); @@ -7032,14 +7001,13 @@ TEST_F(WebRtcVideoChannelTest, EXPECT_TRUE(send_channel_->SetSenderParameters(send_parameters_)); StreamParams sp = - webrtc::CreateSimStreamParams("cname", MAKE_VECTOR(kFirstStreamSsrcs)); + CreateSimStreamParams("cname", MAKE_VECTOR(kFirstStreamSsrcs)); EXPECT_TRUE(send_channel_->AddSendStream(sp)); EXPECT_TRUE(receive_channel_->AddRecvStream(sp)); // One of the SSRCs is already used in previous streams, using it should fail. - sp = webrtc::CreateSimStreamParams("cname", - MAKE_VECTOR(kOverlappingStreamSsrcs)); + sp = CreateSimStreamParams("cname", MAKE_VECTOR(kOverlappingStreamSsrcs)); EXPECT_FALSE(send_channel_->AddSendStream(sp)); EXPECT_FALSE(receive_channel_->AddRecvStream(sp)); @@ -7057,7 +7025,7 @@ TEST_F(WebRtcVideoChannelTest, ReportsSsrcGroupsInStats) { static const uint32_t kSenderSsrcs[] = {4, 7, 10}; static const uint32_t kSenderRtxSsrcs[] = {5, 8, 11}; - StreamParams sender_sp = webrtc::CreateSimWithRtxStreamParams( + StreamParams sender_sp = CreateSimWithRtxStreamParams( "cname", MAKE_VECTOR(kSenderSsrcs), MAKE_VECTOR(kSenderRtxSsrcs)); EXPECT_TRUE(send_channel_->AddSendStream(sender_sp)); @@ -7065,7 +7033,7 @@ TEST_F(WebRtcVideoChannelTest, ReportsSsrcGroupsInStats) { static const uint32_t kReceiverSsrcs[] = {3}; static const uint32_t kReceiverRtxSsrcs[] = {2}; - StreamParams receiver_sp = webrtc::CreateSimWithRtxStreamParams( + StreamParams receiver_sp = CreateSimWithRtxStreamParams( "cname", MAKE_VECTOR(kReceiverSsrcs), MAKE_VECTOR(kReceiverRtxSsrcs)); EXPECT_TRUE(receive_channel_->AddRecvStream(receiver_sp)); @@ -7521,12 +7489,11 @@ void WebRtcVideoChannelTest::TestReceiveUnsignaledSsrcPacket( uint8_t payload_type, bool expect_created_receive_stream) { // kRedRtxPayloadType must currently be unused. - EXPECT_FALSE( - webrtc::FindCodecById(engine_.LegacyRecvCodecs(), kRedRtxPayloadType)); + EXPECT_FALSE(FindCodecById(engine_.LegacyRecvCodecs(), kRedRtxPayloadType)); // Add a RED RTX codec. Codec red_rtx_codec = - webrtc::CreateVideoRtxCodec(kRedRtxPayloadType, GetEngineCodec("red").id); + CreateVideoRtxCodec(kRedRtxPayloadType, GetEngineCodec("red").id); recv_parameters_.codecs.push_back(red_rtx_codec); EXPECT_TRUE(receive_channel_->SetReceiverParameters(recv_parameters_)); @@ -7693,7 +7660,7 @@ TEST_F(WebRtcVideoChannelTest, ReceiveDifferentUnsignaledSsrc) { .set_video_frame_buffer(CreateBlackFrameBuffer(4, 4)) .set_rtp_timestamp(100) .set_timestamp_us(0) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .build(); recv_stream->InjectFrame(video_frame); EXPECT_EQ(1, renderer.num_rendered_frames()); @@ -7712,7 +7679,7 @@ TEST_F(WebRtcVideoChannelTest, ReceiveDifferentUnsignaledSsrc) { .set_video_frame_buffer(CreateBlackFrameBuffer(4, 4)) .set_rtp_timestamp(200) .set_timestamp_us(0) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .build(); recv_stream->InjectFrame(video_frame2); EXPECT_EQ(2, renderer.num_rendered_frames()); @@ -7834,13 +7801,13 @@ TEST_F(WebRtcVideoChannelTest, // we are just testing the behavior of // EncoderStreamFactory::CreateEncoderStreams. ASSERT_EQ(1UL, stream->GetVideoStreams().size()); - EXPECT_EQ(webrtc::kDefaultMinVideoBitrateBps, + EXPECT_EQ(kDefaultMinVideoBitrateBps, stream->GetVideoStreams()[0].min_bitrate_bps); // Set a low max bitrate & check that VideoStream.min_bitrate_bps is limited // by this amount. parameters = send_channel_->GetRtpSendParameters(last_ssrc_); - int low_max_bitrate_bps = webrtc::kDefaultMinVideoBitrateBps - 1000; + int low_max_bitrate_bps = kDefaultMinVideoBitrateBps - 1000; parameters.encodings[0].max_bitrate_bps = low_max_bitrate_bps; EXPECT_TRUE(send_channel_->SetRtpSendParameters(last_ssrc_, parameters).ok()); @@ -7878,7 +7845,7 @@ TEST_F(WebRtcVideoChannelTest, ExpectSetMaxBitrate(send_parameters_.max_bandwidth_bps); ASSERT_TRUE(send_channel_->SetSenderParameters(send_parameters_)); ASSERT_EQ(1UL, stream->GetVideoStreams().size()); - EXPECT_EQ(webrtc::kDefaultMinVideoBitrateBps, + EXPECT_EQ(kDefaultMinVideoBitrateBps, stream->GetVideoStreams()[0].min_bitrate_bps); EXPECT_EQ(send_parameters_.max_bandwidth_bps, stream->GetVideoStreams()[0].max_bitrate_bps); @@ -7963,7 +7930,7 @@ TEST_F(WebRtcVideoChannelTest, TEST_F(WebRtcVideoChannelTest, CannotSetSimulcastRtpSendParametersWithIncorrectNumberOfEncodings) { std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - StreamParams sp = webrtc::CreateSimStreamParams("cname", ssrcs); + StreamParams sp = CreateSimStreamParams("cname", ssrcs); AddSendStream(sp); RtpParameters parameters = send_channel_->GetRtpSendParameters(last_ssrc_); @@ -7993,8 +7960,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersInvalidBitratePriority) { AddSendStream(); RtpParameters parameters = send_channel_->GetRtpSendParameters(last_ssrc_); EXPECT_EQ(1UL, parameters.encodings.size()); - EXPECT_EQ(webrtc::kDefaultBitratePriority, - parameters.encodings[0].bitrate_priority); + EXPECT_EQ(kDefaultBitratePriority, parameters.encodings[0].bitrate_priority); parameters.encodings[0].bitrate_priority = 0; EXPECT_FALSE( @@ -8010,8 +7976,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPriorityOneStream) { AddSendStream(); RtpParameters parameters = send_channel_->GetRtpSendParameters(last_ssrc_); EXPECT_EQ(1UL, parameters.encodings.size()); - EXPECT_EQ(webrtc::kDefaultBitratePriority, - parameters.encodings[0].bitrate_priority); + EXPECT_EQ(kDefaultBitratePriority, parameters.encodings[0].bitrate_priority); // Change the value and set it on the VideoChannel. double new_bitrate_priority = 2.0; @@ -8046,7 +8011,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPriorityOneStream) { TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPrioritySimulcastStreams) { // Create the stream params with multiple ssrcs for simulcast. std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - StreamParams stream_params = webrtc::CreateSimStreamParams("cname", ssrcs); + StreamParams stream_params = CreateSimStreamParams("cname", ssrcs); AddSendStream(stream_params); uint32_t primary_ssrc = stream_params.first_ssrc(); @@ -8058,15 +8023,13 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPrioritySimulcastStreams) { EXPECT_TRUE( send_channel_->SetVideoSend(primary_ssrc, &options, &frame_forwarder)); send_channel_->SetSend(true); - frame_forwarder.IncomingCapturedFrame( - frame_source_.GetFrame(1920, 1080, VideoRotation::kVideoRotation_0, - webrtc::kNumMicrosecsPerSec / 30)); + frame_forwarder.IncomingCapturedFrame(frame_source_.GetFrame( + 1920, 1080, VideoRotation::kVideoRotation_0, kNumMicrosecsPerSec / 30)); // Get and set the rtp encoding parameters. RtpParameters parameters = send_channel_->GetRtpSendParameters(primary_ssrc); EXPECT_EQ(kNumSimulcastStreams, parameters.encodings.size()); - EXPECT_EQ(webrtc::kDefaultBitratePriority, - parameters.encodings[0].bitrate_priority); + EXPECT_EQ(kDefaultBitratePriority, parameters.encodings[0].bitrate_priority); // Change the value and set it on the VideoChannel. double new_bitrate_priority = 2.0; parameters.encodings[0].bitrate_priority = new_bitrate_priority; @@ -8124,7 +8087,7 @@ TEST_P(WebRtcVideoChannelScaleResolutionDownByTest, ScaleResolutionDownBy) { // Set up WebRtcVideoChannel for 3-layer simulcast. encoder_factory_->AddSupportedVideoCodecType(codec_name); VideoSenderParameters parameters; - Codec codec = webrtc::CreateVideoCodec(codec_name); + Codec codec = CreateVideoCodec(codec_name); // Codec ID does not matter, but must be valid. codec.id = 123; parameters.codecs.push_back(codec); @@ -8152,7 +8115,7 @@ TEST_P(WebRtcVideoChannelScaleResolutionDownByTest, ScaleResolutionDownBy) { // (See field trial set at the top of the test.) FakeFrameSource frame_source(test_params.resolution.width, test_params.resolution.height, - webrtc::kNumMicrosecsPerSec / 30); + kNumMicrosecsPerSec / 30); frame_forwarder.IncomingCapturedFrame(frame_source.GetFrame()); // Ensure the scaling is correct. @@ -8256,7 +8219,7 @@ TEST_F(WebRtcVideoChannelTest, parameters.encodings[0].num_temporal_layers = 0; EXPECT_EQ(RTCErrorType::INVALID_RANGE, send_channel_->SetRtpSendParameters(last_ssrc_, parameters).type()); - parameters.encodings[0].num_temporal_layers = webrtc::kMaxTemporalStreams + 1; + parameters.encodings[0].num_temporal_layers = kMaxTemporalStreams + 1; EXPECT_EQ(RTCErrorType::INVALID_RANGE, send_channel_->SetRtpSendParameters(last_ssrc_, parameters).type()); } @@ -8410,7 +8373,7 @@ TEST_F(WebRtcVideoChannelTest, } TEST_F(WebRtcVideoChannelTest, FallbackForUnsetOrUnsupportedScalabilityMode) { - const absl::InlinedVector + const absl::InlinedVector kSupportedModes = {ScalabilityMode::kL1T1, ScalabilityMode::kL1T2, ScalabilityMode::kL1T3}; @@ -8438,7 +8401,7 @@ TEST_F(WebRtcVideoChannelTest, FallbackForUnsetOrUnsupportedScalabilityMode) { // Verify that the new value is propagated down to the encoder. // Check that WebRtcVideoSendStream updates VideoEncoderConfig correctly. const std::optional kDefaultScalabilityMode = - webrtc::ScalabilityModeFromString(kDefaultScalabilityModeStr); + ScalabilityModeFromString(kDefaultScalabilityModeStr); EXPECT_EQ(2, stream->num_encoder_reconfigurations()); VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy(); EXPECT_EQ(kNumSimulcastStreams, encoder_config.number_of_streams); @@ -8479,7 +8442,7 @@ TEST_F(WebRtcVideoChannelTest, FallbackForUnsetOrUnsupportedScalabilityMode) { TEST_F( WebRtcVideoChannelTest, NoLayeringValueUsedIfModeIsUnsetOrUnsupportedByH265AndDefaultUnsupported) { - const absl::InlinedVector + const absl::InlinedVector kSupportedModes = {ScalabilityMode::kL1T1, ScalabilityMode::kL1T3}; encoder_factory_->AddSupportedVideoCodec( @@ -8509,7 +8472,7 @@ TEST_F( // Verify that the new value is propagated down to the encoder. // Check that WebRtcVideoSendStream updates VideoEncoderConfig correctly. const std::optional kDefaultScalabilityMode = - webrtc::ScalabilityModeFromString(webrtc::kNoLayeringScalabilityModeStr); + ScalabilityModeFromString(kNoLayeringScalabilityModeStr); EXPECT_EQ(2, stream->num_encoder_reconfigurations()); VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy(); EXPECT_EQ(kNumSimulcastStreams, encoder_config.number_of_streams); @@ -8534,10 +8497,10 @@ TEST_F( EXPECT_THAT( parameters.encodings, ElementsAre(Field(&RtpEncodingParameters::scalability_mode, - webrtc::kNoLayeringScalabilityModeStr), + kNoLayeringScalabilityModeStr), Field(&RtpEncodingParameters::scalability_mode, "L1T3"), Field(&RtpEncodingParameters::scalability_mode, - webrtc::kNoLayeringScalabilityModeStr))); + kNoLayeringScalabilityModeStr))); // No parameters changed, encoder should not be reconfigured. EXPECT_TRUE(send_channel_->SetRtpSendParameters(last_ssrc_, parameters).ok()); @@ -8776,7 +8739,7 @@ TEST_F(WebRtcVideoChannelTest, // Verify that the new value is propagated down to the encoder. // Check that WebRtcVideoSendStream updates VideoEncoderConfig correctly. const std::optional kDefaultScalabilityMode = - webrtc::ScalabilityModeFromString(kDefaultScalabilityModeStr); + ScalabilityModeFromString(kDefaultScalabilityModeStr); EXPECT_EQ(2, stream->num_encoder_reconfigurations()); VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy(); EXPECT_EQ(1u, encoder_config.number_of_streams); @@ -9083,7 +9046,7 @@ TEST_F(WebRtcVideoChannelTest, BandwidthAboveTotalMaxBitrateGivenToMaxLayer) { // Set max bandwidth equal to total max bitrate. send_parameters_.max_bandwidth_bps = - webrtc::GetTotalMaxBitrate(stream->GetVideoStreams()).bps(); + GetTotalMaxBitrate(stream->GetVideoStreams()).bps(); ExpectSetMaxBitrate(send_parameters_.max_bandwidth_bps); ASSERT_TRUE(send_channel_->SetSenderParameters(send_parameters_)); @@ -9094,7 +9057,7 @@ TEST_F(WebRtcVideoChannelTest, BandwidthAboveTotalMaxBitrateGivenToMaxLayer) { // Set max bandwidth above the total max bitrate. send_parameters_.max_bandwidth_bps = - webrtc::GetTotalMaxBitrate(stream->GetVideoStreams()).bps() + 1; + GetTotalMaxBitrate(stream->GetVideoStreams()).bps() + 1; ExpectSetMaxBitrate(send_parameters_.max_bandwidth_bps); ASSERT_TRUE(send_channel_->SetSenderParameters(send_parameters_)); @@ -9102,7 +9065,7 @@ TEST_F(WebRtcVideoChannelTest, BandwidthAboveTotalMaxBitrateGivenToMaxLayer) { // max should be given to the highest layer. EXPECT_EQ(kNumSimulcastStreams, stream->GetVideoStreams().size()); EXPECT_EQ(send_parameters_.max_bandwidth_bps, - webrtc::GetTotalMaxBitrate(stream->GetVideoStreams()).bps()); + GetTotalMaxBitrate(stream->GetVideoStreams()).bps()); EXPECT_EQ(kDefault[2].max_bitrate_bps + 1, stream->GetVideoStreams()[2].max_bitrate_bps); @@ -9131,7 +9094,7 @@ TEST_F(WebRtcVideoChannelTest, // Set max bandwidth above the total max bitrate. send_parameters_.max_bandwidth_bps = - webrtc::GetTotalMaxBitrate(stream->GetVideoStreams()).bps() + 1; + GetTotalMaxBitrate(stream->GetVideoStreams()).bps() + 1; ExpectSetMaxBitrate(send_parameters_.max_bandwidth_bps); ASSERT_TRUE(send_channel_->SetSenderParameters(send_parameters_)); @@ -9148,7 +9111,7 @@ TEST_F(WebRtcVideoChannelTest, SetMixedCodecSimulcastStreamConfig) { ScopedKeyValueConfig field_trials(field_trials_, "WebRTC-MixedCodecSimulcast/Enabled/"); - StreamParams sp = webrtc::CreateSimStreamParams("cname", {123, 456, 789}); + StreamParams sp = CreateSimStreamParams("cname", {123, 456, 789}); std::vector rid_descriptions; rid_descriptions.emplace_back("f", RidDirection::kSend); @@ -9195,22 +9158,22 @@ TEST_F(WebRtcVideoChannelTest, SetMixedCodecSimulcastStreamConfig) { #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) TEST_F(WebRtcVideoChannelTest, SetMixedCodecSimulcastWithDifferentConfigSettingsSizes) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-MixedCodecSimulcast/Enabled/"); AddSendStream(); - webrtc::VideoSenderParameters parameters; - webrtc::Codec vp8 = GetEngineCodec("VP8"); + VideoSenderParameters parameters; + Codec vp8 = GetEngineCodec("VP8"); parameters.codecs.push_back(vp8); // `codec_settings_list.size()` is 1 after this in the EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); // It sets 2 sizes of config ssrc. - webrtc::StreamParams sp = CreateSimStreamParams("cname", {123, 456}); - std::vector rid_descriptions2; - rid_descriptions2.emplace_back("f", webrtc::RidDirection::kSend); - rid_descriptions2.emplace_back("h", webrtc::RidDirection::kSend); + StreamParams sp = CreateSimStreamParams("cname", {123, 456}); + std::vector rid_descriptions2; + rid_descriptions2.emplace_back("f", RidDirection::kSend); + rid_descriptions2.emplace_back("h", RidDirection::kSend); sp.set_rids(rid_descriptions2); // `WebRtcVideoSendStream::SetCodec` test for different sizes @@ -9266,7 +9229,7 @@ TEST_F(WebRtcVideoChannelTest, DefaultMinAndMaxBitratePropagatedToEncoder) { // FakeVideoSendStream calls CreateEncoderStreams, test that the vector of // VideoStreams are created appropriately. EXPECT_EQ(1u, stream->GetVideoStreams().size()); - EXPECT_EQ(webrtc::kDefaultMinVideoBitrateBps, + EXPECT_EQ(kDefaultMinVideoBitrateBps, stream->GetVideoStreams()[0].min_bitrate_bps); EXPECT_GT(stream->GetVideoStreams()[0].max_bitrate_bps, stream->GetVideoStreams()[0].min_bitrate_bps); @@ -9280,7 +9243,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersSetsMinBitrateForFirstActiveStream) { // Create the stream params with multiple ssrcs for simulcast. std::vector ssrcs = MAKE_VECTOR(kSsrcs3); - StreamParams stream_params = webrtc::CreateSimStreamParams("cname", ssrcs); + StreamParams stream_params = CreateSimStreamParams("cname", ssrcs); FakeVideoSendStream* fake_video_send_stream = AddSendStream(stream_params); uint32_t primary_ssrc = stream_params.first_ssrc(); @@ -9292,9 +9255,8 @@ TEST_F(WebRtcVideoChannelTest, EXPECT_TRUE( send_channel_->SetVideoSend(primary_ssrc, &options, &frame_forwarder)); send_channel_->SetSend(true); - frame_forwarder.IncomingCapturedFrame( - frame_source_.GetFrame(1920, 1080, VideoRotation::kVideoRotation_0, - webrtc::kNumMicrosecsPerSec / 30)); + frame_forwarder.IncomingCapturedFrame(frame_source_.GetFrame( + 1920, 1080, VideoRotation::kVideoRotation_0, kNumMicrosecsPerSec / 30)); // Check that all encodings are initially active. RtpParameters parameters = send_channel_->GetRtpSendParameters(primary_ssrc); @@ -9446,10 +9408,10 @@ TEST_F(WebRtcVideoChannelTest, GetRtpReceiveFmtpSprop) { TEST_F(WebRtcVideoChannelTest, DISABLED_GetRtpReceiveFmtpSprop) { #endif VideoReceiverParameters parameters; - Codec kH264sprop1 = webrtc::CreateVideoCodec(101, "H264"); + Codec kH264sprop1 = CreateVideoCodec(101, "H264"); kH264sprop1.SetParam(kH264FmtpSpropParameterSets, "uvw"); parameters.codecs.push_back(kH264sprop1); - Codec kH264sprop2 = webrtc::CreateVideoCodec(102, "H264"); + Codec kH264sprop2 = CreateVideoCodec(102, "H264"); kH264sprop2.SetParam(kH264FmtpSpropParameterSets, "xyz"); parameters.codecs.push_back(kH264sprop2); EXPECT_TRUE(receive_channel_->SetReceiverParameters(parameters)); @@ -9678,8 +9640,7 @@ TEST_F(WebRtcVideoChannelTest, GenerateKeyFrameSinglecast) { } TEST_F(WebRtcVideoChannelTest, GenerateKeyFrameSimulcast) { - StreamParams stream_params = - webrtc::CreateSimStreamParams("cname", {123, 456, 789}); + StreamParams stream_params = CreateSimStreamParams("cname", {123, 456, 789}); std::vector rids = {"f", "h", "q"}; std::vector rid_descriptions; @@ -9782,12 +9743,12 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { RTC_DCHECK(num_configured_streams <= ssrcs.size()); ssrcs.resize(num_configured_streams); - AddSendStream(webrtc::CreateSimStreamParams("cname", ssrcs)); + AddSendStream(CreateSimStreamParams("cname", ssrcs)); // Send a full-size frame to trigger a stream reconfiguration to use all // expected simulcast layers. FrameForwarder frame_forwarder; FakeFrameSource frame_source(capture_width, capture_height, - webrtc::kNumMicrosecsPerSec / 30); + kNumMicrosecsPerSec / 30); VideoOptions options; if (screenshare) @@ -9815,7 +9776,7 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { expected_streams = factory->CreateEncoderStreams( field_trials_, capture_width, capture_height, encoder_config); if (screenshare && conference_mode) { - for (const webrtc::VideoStream& expected_stream : expected_streams) { + for (const VideoStream& expected_stream : expected_streams) { // Never scale screen content. EXPECT_EQ(expected_stream.width, checked_cast(capture_width)); EXPECT_EQ(expected_stream.height, @@ -9827,7 +9788,7 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { expected_stream.width = capture_width; expected_stream.height = capture_height; expected_stream.max_framerate = kDefaultVideoMaxFramerate; - expected_stream.min_bitrate_bps = webrtc::kDefaultMinVideoBitrateBps; + expected_stream.min_bitrate_bps = kDefaultMinVideoBitrateBps; expected_stream.target_bitrate_bps = expected_stream.max_bitrate_bps = GetMaxDefaultBitrateBps(capture_width, capture_height); expected_stream.max_qp = kDefaultVideoMaxQpVpx; @@ -9915,34 +9876,31 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { }; TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsWith2SimulcastStreams) { - VerifySimulcastSettings(webrtc::CreateVideoCodec("VP8"), 640, 360, 2, 2, - false, true); + VerifySimulcastSettings(CreateVideoCodec("VP8"), 640, 360, 2, 2, false, true); } TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsWith3SimulcastStreams) { - VerifySimulcastSettings(webrtc::CreateVideoCodec("VP8"), 1280, 720, 3, 3, - false, true); + VerifySimulcastSettings(CreateVideoCodec("VP8"), 1280, 720, 3, 3, false, + true); } // Test that we normalize send codec format size in simulcast. TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { - VerifySimulcastSettings(webrtc::CreateVideoCodec("VP8"), 541, 271, 2, 2, - false, true); + VerifySimulcastSettings(CreateVideoCodec("VP8"), 541, 271, 2, 2, false, true); } TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsForScreenshare) { - VerifySimulcastSettings(webrtc::CreateVideoCodec("VP8"), 1280, 720, 3, 3, - true, false); + VerifySimulcastSettings(CreateVideoCodec("VP8"), 1280, 720, 3, 3, true, + false); } TEST_F(WebRtcVideoChannelSimulcastTest, SetSendCodecsForSimulcastScreenshare) { - VerifySimulcastSettings(webrtc::CreateVideoCodec("VP8"), 1280, 720, 3, 2, - true, true); + VerifySimulcastSettings(CreateVideoCodec("VP8"), 1280, 720, 3, 2, true, true); } TEST_F(WebRtcVideoChannelSimulcastTest, SimulcastScreenshareWithoutConference) { - VerifySimulcastSettings(webrtc::CreateVideoCodec("VP8"), 1280, 720, 3, 3, - true, false); + VerifySimulcastSettings(CreateVideoCodec("VP8"), 1280, 720, 3, 3, true, + false); } TEST_F(WebRtcVideoChannelBaseTest, GetSources) { @@ -9986,7 +9944,7 @@ TEST_F(WebRtcVideoChannelBaseTest, GetSources) { } TEST_F(WebRtcVideoChannelTest, SetsRidsOnSendStream) { - StreamParams sp = webrtc::CreateSimStreamParams("cname", {123, 456, 789}); + StreamParams sp = CreateSimStreamParams("cname", {123, 456, 789}); std::vector rids = {"f", "h", "q"}; std::vector rid_descriptions; @@ -10039,7 +9997,7 @@ TEST_F(WebRtcVideoChannelTest, ScaleResolutionDownToSinglecast) { FakeVideoSendStream* stream = AddSendStream(); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE( send_channel_->SetVideoSend(last_ssrc_, nullptr, &frame_forwarder)); @@ -10097,7 +10055,7 @@ TEST_F(WebRtcVideoChannelTest, ScaleResolutionDownToSinglecastScaling) { FakeVideoSendStream* stream = AddSendStream(); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE( send_channel_->SetVideoSend(last_ssrc_, nullptr, &frame_forwarder)); @@ -10173,7 +10131,7 @@ TEST_F(WebRtcVideoChannelTest, ScaleResolutionDownToSimulcast) { FakeVideoSendStream* stream = SetUpSimulcast(true, /*with_rtx=*/false); FrameForwarder frame_forwarder; - FakeFrameSource frame_source(1280, 720, webrtc::kNumMicrosecsPerSec / 30); + FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); EXPECT_TRUE( send_channel_->SetVideoSend(last_ssrc_, nullptr, &frame_forwarder)); diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index cb48226931..2d397c6008 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -112,6 +112,10 @@ #endif +#if defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE) +#include "api/audio/create_audio_device_module.h" +#endif + namespace webrtc { namespace { @@ -520,8 +524,8 @@ void WebRtcVoiceEngine::Init() { #if defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE) // No ADM supplied? Create a default one. if (!adm_) { - adm_ = AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio, - &env_.task_queue_factory()); + adm_ = + CreateAudioDeviceModule(env_, AudioDeviceModule::kPlatformDefaultAudio); } #endif // WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE RTC_CHECK(adm()); diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 4223f8878b..3bdd0f7250 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -30,6 +30,7 @@ #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_options.h" #include "api/call/audio_sink.h" +#include "api/call/transport.h" #include "api/crypto/crypto_options.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -65,7 +66,6 @@ #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "rtc_base/arraysize.h" #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" @@ -2457,7 +2457,7 @@ TEST_P(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { // Verify that we are in a sending state for all the created streams. EXPECT_TRUE(GetSendStream(ssrc).IsSending()); } - EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size()); + EXPECT_EQ(std::size(kSsrcs4), call_.GetAudioSendStreams().size()); // Delete the send streams. for (uint32_t ssrc : kSsrcs4) { @@ -2565,8 +2565,7 @@ TEST_P(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { &receive_info, /*get_and_clear_legacy_stats=*/true)); // We have added 4 send streams. We should see empty stats for all. - EXPECT_EQ(static_cast(arraysize(kSsrcs4)), - send_info.senders.size()); + EXPECT_EQ(std::size(kSsrcs4), send_info.senders.size()); for (const auto& sender : send_info.senders) { VerifyVoiceSenderInfo(sender, false); } @@ -2586,8 +2585,7 @@ TEST_P(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { EXPECT_EQ(true, send_channel_->GetStats(&send_info)); EXPECT_EQ(true, receive_channel_->GetStats( &receive_info, /*get_and_clear_legacy_stats=*/true)); - EXPECT_EQ(static_cast(arraysize(kSsrcs4)), - send_info.senders.size()); + EXPECT_EQ(std::size(kSsrcs4), send_info.senders.size()); EXPECT_EQ(0u, receive_info.receivers.size()); } @@ -2602,8 +2600,7 @@ TEST_P(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { EXPECT_EQ(true, send_channel_->GetStats(&send_info)); EXPECT_EQ(true, receive_channel_->GetStats( &receive_info, /*get_and_clear_legacy_stats=*/true)); - EXPECT_EQ(static_cast(arraysize(kSsrcs4)), - send_info.senders.size()); + EXPECT_EQ(std::size(kSsrcs4), send_info.senders.size()); EXPECT_EQ(1u, receive_info.receivers.size()); VerifyVoiceReceiverInfo(receive_info.receivers[0]); VerifyVoiceSendRecvCodecs(send_info, receive_info); @@ -2812,7 +2809,7 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { EXPECT_TRUE(AddRecvStream(ssrc3)); // Create packets with the right SSRCs. unsigned char packets[4][sizeof(kPcmuFrame)]; - for (size_t i = 0; i < arraysize(packets); ++i) { + for (size_t i = 0; i < std::size(packets); ++i) { memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); webrtc::SetBE32(packets[i] + 8, static_cast(i)); } @@ -3427,7 +3424,9 @@ TEST_P(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { // Packets should also self-identify their dscp in PacketOptions. const uint8_t kData[10] = {0}; - EXPECT_TRUE(SendImplFromPointer(channel.get())->transport()->SendRtcp(kData)); + EXPECT_TRUE(SendImplFromPointer(channel.get()) + ->transport() + ->SendRtcp(kData, /*packet_options=*/{})); EXPECT_EQ(webrtc::DSCP_CS1, network_interface.options().dscp); channel->SetInterface(nullptr); @@ -4080,8 +4079,8 @@ TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { // Rather than just ASSERTing that there are enough codecs, ensure that we // can check the actual values safely, to provide better test results. auto get_codec = [&codecs](size_t index) -> const webrtc::Codec& { - static const webrtc::Codec missing_codec = - webrtc::CreateAudioCodec(0, "", 0, 0); + static const webrtc::Codec missing_codec = webrtc::CreateAudioCodec( + 0, "", webrtc::kDefaultAudioClockRateHz, 0); if (codecs.size() > index) return codecs[index]; return missing_codec; @@ -4169,8 +4168,8 @@ TEST(WebRtcVoiceEngineTest, CollectRecvCodecsWithLatePtAssignment) { // Rather than just ASSERTing that there are enough codecs, ensure that we // can check the actual values safely, to provide better test results. auto get_codec = [&codecs](size_t index) -> const webrtc::Codec& { - static const webrtc::Codec missing_codec = - webrtc::CreateAudioCodec(0, "", 0, 0); + static const webrtc::Codec missing_codec = webrtc::CreateAudioCodec( + 0, "", webrtc::kDefaultAudioClockRateHz, 0); if (codecs.size() > index) return codecs[index]; return missing_codec; diff --git a/media/sctp/dcsctp_transport.cc b/media/sctp/dcsctp_transport.cc index af2e6eaed3..529de89a41 100644 --- a/media/sctp/dcsctp_transport.cc +++ b/media/sctp/dcsctp_transport.cc @@ -706,7 +706,7 @@ void DcSctpTransport::OnTransportWritableState( } void DcSctpTransport::OnDtlsTransportState(DtlsTransportInternal* transport, - webrtc::DtlsTransportState state) { + DtlsTransportState state) { if (state == DtlsTransportState::kNew && socket_) { // IF DTLS restart (DtlsTransportState::kNew) // THEN diff --git a/media/sctp/dcsctp_transport_unittest.cc b/media/sctp/dcsctp_transport_unittest.cc index d629722078..fe16899f26 100644 --- a/media/sctp/dcsctp_transport_unittest.cc +++ b/media/sctp/dcsctp_transport_unittest.cc @@ -57,7 +57,7 @@ class MockDataChannelSink : public DataChannelSink { // DataChannelSink MOCK_METHOD(void, OnDataReceived, - (int, DataMessageType, const webrtc::CopyOnWriteBuffer&)); + (int, DataMessageType, const CopyOnWriteBuffer&)); MOCK_METHOD(void, OnChannelClosing, (int)); MOCK_METHOD(void, OnChannelClosed, (int)); MOCK_METHOD(void, OnReadyToSend, ()); @@ -82,7 +82,7 @@ class Peer { .Times(1) .WillOnce(Return(ByMove(std::move(socket_ptr)))); - sctp_transport_ = std::make_unique( + sctp_transport_ = std::make_unique( env_, Thread::Current(), &fake_dtls_transport_, std::move(mock_dcsctp_socket_factory)); sctp_transport_->SetDataChannelSink(&sink_); @@ -90,10 +90,10 @@ class Peer { } FakeDtlsTransport fake_dtls_transport_; - webrtc::SimulatedClock simulated_clock_; + SimulatedClock simulated_clock_; Environment env_; dcsctp::MockDcSctpSocket* socket_; - std::unique_ptr sctp_transport_; + std::unique_ptr sctp_transport_; NiceMock sink_; }; } // namespace @@ -290,8 +290,7 @@ TEST(DcSctpTransportTest, DeliversMessage) { AutoThread main_thread; Peer peer_a; - EXPECT_CALL(peer_a.sink_, - OnDataReceived(1, webrtc::DataMessageType::kBinary, _)) + EXPECT_CALL(peer_a.sink_, OnDataReceived(1, DataMessageType::kBinary, _)) .Times(1); peer_a.sctp_transport_->OpenStream(1, kDefaultPriority); diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 6a13b89c4e..3a8d0db866 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -100,9 +100,11 @@ rtc_library("audio_encoder_cng") { deps = [ ":webrtc_cng", + "../../api:array_view", "../../api/audio_codecs:audio_codecs_api", "../../api/units:time_delta", "../../common_audio", + "../../rtc_base:buffer", "../../rtc_base:checks", ] } @@ -116,6 +118,7 @@ rtc_library("red") { deps = [ "../../api:array_view", + "../../api:bitrate_allocation", "../../api:field_trials_view", "../../api/audio_codecs:audio_codecs_api", "../../api/units:time_delta", @@ -259,6 +262,7 @@ rtc_library("audio_coding_opus_common") { deps = [ "../../api:array_view", "../../api/audio_codecs:audio_codecs_api", + "../../rtc_base:buffer", "../../rtc_base:checks", "../../rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings:string_view", @@ -279,10 +283,12 @@ rtc_library("webrtc_opus") { ":audio_coding_opus_common", ":audio_network_adaptor", "../../api:array_view", + "../../api:bitrate_allocation", "../../api:field_trials_view", "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs/opus:audio_encoder_opus_config", "../../api/environment", + "../../api/units:time_delta", "../../common_audio", "../../rtc_base:buffer", "../../rtc_base:checks", @@ -297,6 +303,7 @@ rtc_library("webrtc_opus") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", + "//third_party/opus", ] public_deps += # no-presubmit-check TODO(webrtc:8603) [ ":webrtc_opus_wrapper" ] @@ -416,6 +423,7 @@ rtc_library("audio_network_adaptor") { [ ":audio_network_adaptor_config" ] deps = [ + "../../api:array_view", "../../api/audio_codecs:audio_codecs_api", "../../api/rtc_event_log", "../../common_audio", @@ -427,7 +435,6 @@ rtc_library("audio_network_adaptor") { "../../rtc_base:timeutils", "../../rtc_base/system:file_wrapper", "../../system_wrappers", - "../../system_wrappers:field_trial", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -577,6 +584,7 @@ rtc_library("neteq_tools_minimal") { "../../api:field_trials", "../../api:neteq_simulator_api", "../../api:rtp_headers", + "../../api:scoped_refptr", "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", "../../api/environment", @@ -593,6 +601,7 @@ rtc_library("neteq_tools_minimal") { "../../rtc_base:stringutils", "../../system_wrappers", "../rtp_rtcp:rtp_rtcp_format", + "//third_party/abseil-cpp/absl/strings:string_view", ] defines = audio_codec_defines } @@ -657,7 +666,14 @@ rtc_library("neteq_tools") { ":neteq_tools_minimal", "..:module_api_public", "../../api:array_view", + "../../api:rtp_headers", + "../../api:rtp_packet_info", + "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", + "../../api/neteq:neteq_api", + "../../logging:rtc_event_audio", + "../../logging:rtc_event_rtp_rtcp", + "../../rtc_base:buffer", "../../rtc_base:checks", "../../rtc_base:rtc_numerics", "../../rtc_base:safe_conversions", @@ -732,8 +748,11 @@ rtc_library("audio_coding_modules_tests_shared") { ":neteq_tools_minimal", ":webrtc_opus_wrapper", "..:module_api", + "../../api:array_view", "../../api:rtp_headers", + "../../api:rtp_parameters", "../../api/audio:audio_frame_api", + "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs:builtin_audio_decoder_factory", "../../api/audio_codecs:builtin_audio_encoder_factory", "../../api/environment", @@ -741,6 +760,7 @@ rtc_library("audio_coding_modules_tests_shared") { "../../api/neteq:default_neteq_factory", "../../api/neteq:neteq_api", "../../api/units:timestamp", + "../../common_audio", "../../rtc_base:checks", "../../rtc_base:digest", "../../rtc_base:stringutils", @@ -785,6 +805,7 @@ if (rtc_include_tests) { ] deps = [ ":audio_network_adaptor", + "../../api/audio_codecs:audio_codecs_api", "../../test:test_support", ] } @@ -849,7 +870,9 @@ if (rtc_include_tests) { ":red", ":webrtc_opus_wrapper", "..:module_api", + "../../api:array_view", "../../api:rtp_headers", + "../../api:scoped_refptr", "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs:builtin_audio_decoder_factory", @@ -869,6 +892,7 @@ if (rtc_include_tests) { "../../api/units:timestamp", "../../common_audio", "../../rtc_base:checks", + "../../rtc_base:ip_address", "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:stringutils", @@ -894,10 +918,14 @@ if (rtc_include_tests) { deps = [ ":neteq_test_support", ":neteq_test_tools", + "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs/opus:audio_encoder_opus", + "../../api/audio_codecs/opus:audio_encoder_opus_config", + "../../api/environment", "../../api/environment:environment_factory", "../../api/test/metrics:global_metrics_logger_and_exporter", "../../api/test/metrics:metric", + "../../rtc_base:buffer", "../../rtc_base:macromagic", "../../rtc_base:timeutils", "../../system_wrappers", @@ -921,6 +949,7 @@ if (rtc_include_tests) { ":audio_coding", ":neteq_tools", ":neteq_tools_minimal", + "../../api:array_view", "../../api:scoped_refptr", "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs:builtin_audio_decoder_factory", @@ -945,6 +974,7 @@ if (rtc_include_tests) { deps = [ ":audio_coding", + ":audio_coding_module_typedefs", ":neteq_input_audio_tools", ":neteq_tools", ":neteq_tools_minimal", @@ -955,6 +985,7 @@ if (rtc_include_tests) { "../../api/environment", "../../api/environment:environment_factory", "../../rtc_base:checks", + "../../rtc_base:copy_on_write_buffer", "../../rtc_base:stringutils", "../../test:test_support", "//testing/gtest", @@ -986,10 +1017,15 @@ if (rtc_include_tests) { ":neteq", ":neteq_input_audio_tools", ":neteq_tools", + "../../api:array_view", "../../api/audio_codecs:audio_codecs_api", + "../../api/audio_codecs/g722:audio_encoder_g722_config", "../../api/audio_codecs/opus:audio_encoder_opus", + "../../api/audio_codecs/opus:audio_encoder_opus_config", "../../api/environment:environment_factory", "../../common_audio", + "../../rtc_base:buffer", + "../../rtc_base:checks", "../../rtc_base/system:arch", "../../test:explicit_key_value_config", "../../test:fileutils", @@ -1088,6 +1124,7 @@ if (rtc_include_tests) { deps = [ "../../rtc_base:macromagic", "../../test:fileutils", + "//third_party/opus", ] sources = [ "codecs/opus/opus_speed_test.cc", @@ -1129,6 +1166,7 @@ if (rtc_include_tests) { ":neteq", ":neteq_test_tools", ":pcm16b", + "../../api:rtp_headers", "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs:builtin_audio_decoder_factory", @@ -1136,6 +1174,7 @@ if (rtc_include_tests) { "../../api/environment:environment_factory", "../../api/neteq:default_neteq_factory", "../../api/neteq:neteq_api", + "../../api/units:timestamp", "../../rtc_base:checks", "../../system_wrappers", "../../test:fileutils", @@ -1157,11 +1196,16 @@ if (rtc_include_tests) { ":neteq_input_audio_tools", ":neteq_test_tools", ":neteq_tools_minimal", + "../../api:array_view", + "../../api:rtp_headers", + "../../api:scoped_refptr", + "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs:builtin_audio_decoder_factory", "../../api/environment:environment_factory", "../../api/neteq:default_neteq_factory", "../../api/neteq:neteq_api", "../../api/units:timestamp", + "../../rtc_base:buffer", "../../rtc_base:checks", "../../rtc_base:stringutils", "../../system_wrappers", @@ -1207,6 +1251,7 @@ if (rtc_include_tests) { deps = [ "../../api:array_view", "../../rtc_base:buffer", + "../../rtc_base:checks", "../rtp_rtcp:rtp_rtcp_format", ] @@ -1239,6 +1284,9 @@ if (rtc_include_tests) { ":neteq_test_tools", ":neteq_tools_minimal", ":pcm16b", + "../../api:rtp_headers", + "../../rtc_base:checks", + "../rtp_rtcp:rtp_rtcp_format", "//testing/gtest", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", @@ -1255,9 +1303,16 @@ if (rtc_include_tests) { ":neteq_quality_test_support", ":neteq_tools", ":webrtc_opus", + "../../api:array_view", + "../../api:rtp_parameters", + "../../api/audio_codecs:audio_codecs_api", + "../../rtc_base:buffer", + "../../rtc_base:checks", "../../test:test_main", + "../../test:test_support", "//testing/gtest", "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/opus", ] } @@ -1285,10 +1340,14 @@ if (rtc_include_tests) { ":g711", ":neteq", ":neteq_quality_test_support", + "../../api:array_view", + "../../api/audio_codecs:audio_codecs_api", + "../../rtc_base:buffer", "../../rtc_base:checks", "../../rtc_base:safe_conversions", "../../test:fileutils", "../../test:test_main", + "../../test:test_support", "//testing/gtest", "//third_party/abseil-cpp/absl/flags:flag", ] @@ -1303,10 +1362,14 @@ if (rtc_include_tests) { ":neteq", ":neteq_quality_test_support", ":pcm16b", + "../../api:array_view", + "../../api/audio_codecs:audio_codecs_api", + "../../rtc_base:buffer", "../../rtc_base:checks", "../../rtc_base:safe_conversions", "../../test:fileutils", "../../test:test_main", + "../../test:test_support", "//testing/gtest", "//third_party/abseil-cpp/absl/flags:flag", ] @@ -1449,7 +1512,12 @@ if (rtc_include_tests) { "..:module_api", "..:module_api_public", "../../api:array_view", + "../../api:bitrate_allocation", + "../../api:field_trials_view", "../../api:make_ref_counted", + "../../api:rtp_headers", + "../../api:rtp_packet_info", + "../../api:rtp_parameters", "../../api:scoped_refptr", "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", @@ -1469,6 +1537,7 @@ if (rtc_include_tests) { "../../api/neteq:tick_timer", "../../api/neteq:tick_timer_unittest", "../../api/rtc_event_log", + "../../api/units:data_rate", "../../api/units:time_delta", "../../api/units:timestamp", "../../common_audio", @@ -1479,7 +1548,9 @@ if (rtc_include_tests) { "../../modules/rtp_rtcp:rtp_rtcp_format", "../../rtc_base:buffer", "../../rtc_base:checks", + "../../rtc_base:copy_on_write_buffer", "../../rtc_base:digest", + "../../rtc_base:ip_address", "../../rtc_base:macromagic", "../../rtc_base:platform_thread", "../../rtc_base:random", @@ -1489,6 +1560,7 @@ if (rtc_include_tests) { "../../rtc_base:safe_conversions", "../../rtc_base:sanitizer", "../../rtc_base:stringutils", + "../../rtc_base:threading", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:arch", @@ -1496,7 +1568,6 @@ if (rtc_include_tests) { "../../test:audio_codec_mocks", "../../test:audio_test_common", "../../test:explicit_key_value_config", - "../../test:field_trial", "../../test:fileutils", "../../test:rtc_expect_death", "../../test:rtp_test_utils", @@ -1510,6 +1581,7 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", + "//third_party/opus", ] defines = audio_coding_defines diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc index bf1fa7f1fe..afa6f77d45 100644 --- a/modules/audio_coding/acm2/acm_receive_test.cc +++ b/modules/audio_coding/acm2/acm_receive_test.cc @@ -12,11 +12,18 @@ #include +#include #include +#include +#include +#include "api/array_view.h" +#include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" +#include "api/scoped_refptr.h" #include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/neteq/tools/audio_sink.h" #include "modules/audio_coding/neteq/tools/packet.h" @@ -98,7 +105,7 @@ void AcmReceiveTestOldApi::Run() { static_cast(output_freq_hz_ * 10 / 1000); EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_); if (exptected_output_channels_ != kArbitraryChannels) { - if (output_frame.speech_type_ == webrtc::AudioFrame::kPLC) { + if (output_frame.speech_type_ == AudioFrame::kPLC) { // Don't check number of channels for PLC output, since each test run // usually starts with a short period of mono PLC before decoding the // first packet. diff --git a/modules/audio_coding/acm2/acm_receive_test.h b/modules/audio_coding/acm2/acm_receive_test.h index 9cc9019591..f1958124ed 100644 --- a/modules/audio_coding/acm2/acm_receive_test.h +++ b/modules/audio_coding/acm2/acm_receive_test.h @@ -13,8 +13,8 @@ #include // for size_t +#include #include -#include #include "api/audio_codecs/audio_decoder_factory.h" #include "api/neteq/neteq.h" diff --git a/modules/audio_coding/acm2/acm_remixing.cc b/modules/audio_coding/acm2/acm_remixing.cc index 45eb3c1247..3ad995542b 100644 --- a/modules/audio_coding/acm2/acm_remixing.cc +++ b/modules/audio_coding/acm2/acm_remixing.cc @@ -10,7 +10,15 @@ #include "modules/audio_coding/acm2/acm_remixing.h" +#include +#include +#include +#include + +#include "api/array_view.h" +#include "api/audio/audio_frame.h" #include "rtc_base/checks.h" +#include "rtc_base/numerics/safe_conversions.h" namespace webrtc { diff --git a/modules/audio_coding/acm2/acm_remixing.h b/modules/audio_coding/acm2/acm_remixing.h index c6ae2c3844..0ccb7c0bf4 100644 --- a/modules/audio_coding/acm2/acm_remixing.h +++ b/modules/audio_coding/acm2/acm_remixing.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_ACM2_ACM_REMIXING_H_ #define MODULES_AUDIO_CODING_ACM2_ACM_REMIXING_H_ +#include +#include #include #include "api/array_view.h" diff --git a/modules/audio_coding/acm2/acm_remixing_unittest.cc b/modules/audio_coding/acm2/acm_remixing_unittest.cc index 7c0c0ef665..dfc3e50ad8 100644 --- a/modules/audio_coding/acm2/acm_remixing_unittest.cc +++ b/modules/audio_coding/acm2/acm_remixing_unittest.cc @@ -10,10 +10,12 @@ #include "modules/audio_coding/acm2/acm_remixing.h" +#include +#include #include #include "api/audio/audio_frame.h" -#include "system_wrappers/include/clock.h" +#include "api/audio/audio_view.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" diff --git a/modules/audio_coding/acm2/acm_resampler.cc b/modules/audio_coding/acm2/acm_resampler.cc index 85f22ac6ef..9daa04d14b 100644 --- a/modules/audio_coding/acm2/acm_resampler.cc +++ b/modules/audio_coding/acm2/acm_resampler.cc @@ -10,52 +10,16 @@ #include "modules/audio_coding/acm2/acm_resampler.h" -#include +#include +#include #include "api/audio/audio_frame.h" -#include "rtc_base/logging.h" +#include "api/audio/audio_view.h" +#include "rtc_base/checks.h" namespace webrtc { namespace acm2 { -ACMResampler::ACMResampler() {} - -ACMResampler::~ACMResampler() {} - -int ACMResampler::Resample10Msec(const int16_t* in_audio, - int in_freq_hz, - int out_freq_hz, - size_t num_audio_channels, - size_t out_capacity_samples, - int16_t* out_audio) { - InterleavedView src( - in_audio, SampleRateToDefaultChannelSize(in_freq_hz), num_audio_channels); - InterleavedView dst(out_audio, - SampleRateToDefaultChannelSize(out_freq_hz), - num_audio_channels); - RTC_DCHECK_GE(out_capacity_samples, dst.size()); - if (in_freq_hz == out_freq_hz) { - if (out_capacity_samples < src.data().size()) { - RTC_DCHECK_NOTREACHED(); - return -1; - } - CopySamples(dst, src); - RTC_DCHECK_EQ(dst.samples_per_channel(), src.samples_per_channel()); - return static_cast(dst.samples_per_channel()); - } - - int out_length = resampler_.Resample(src, dst); - if (out_length == -1) { - RTC_LOG(LS_ERROR) << "Resample(" << in_audio << ", " << src.data().size() - << ", " << out_audio << ", " << out_capacity_samples - << ") failed."; - return -1; - } - RTC_DCHECK_EQ(out_length, dst.size()); - RTC_DCHECK_EQ(out_length / num_audio_channels, dst.samples_per_channel()); - return static_cast(dst.samples_per_channel()); -} - ResamplerHelper::ResamplerHelper() { ClearSamples(last_audio_buffer_); } @@ -64,44 +28,38 @@ bool ResamplerHelper::MaybeResample(int desired_sample_rate_hz, AudioFrame* audio_frame) { const int current_sample_rate_hz = audio_frame->sample_rate_hz_; RTC_DCHECK_NE(current_sample_rate_hz, 0); + RTC_DCHECK_GT(desired_sample_rate_hz, 0); // Update if resampling is required. + // TODO(tommi): `desired_sample_rate_hz` should never be -1. + // Remove the first check. const bool need_resampling = (desired_sample_rate_hz != -1) && (current_sample_rate_hz != desired_sample_rate_hz); if (need_resampling && !resampled_last_output_frame_) { // Prime the resampler with the last frame. - int16_t temp_output[AudioFrame::kMaxDataSizeSamples]; - int samples_per_channel_int = resampler_.Resample10Msec( - last_audio_buffer_.data(), current_sample_rate_hz, - desired_sample_rate_hz, audio_frame->num_channels_, - AudioFrame::kMaxDataSizeSamples, temp_output); - if (samples_per_channel_int < 0) { - RTC_LOG(LS_ERROR) << "AcmReceiver::GetAudio - " - "Resampling last_audio_buffer_ failed."; - return false; - } + InterleavedView src(last_audio_buffer_.data(), + audio_frame->samples_per_channel(), + audio_frame->num_channels()); + std::array temp_output; + InterleavedView dst( + temp_output.data(), + SampleRateToDefaultChannelSize(desired_sample_rate_hz), + audio_frame->num_channels_); + resampler_.Resample(src, dst); } // TODO(bugs.webrtc.org/3923) Glitches in the output may appear if the output // rate from NetEq changes. if (need_resampling) { - // TODO(yujo): handle this more efficiently for muted frames. - int samples_per_channel_int = resampler_.Resample10Msec( - audio_frame->data(), current_sample_rate_hz, desired_sample_rate_hz, - audio_frame->num_channels_, AudioFrame::kMaxDataSizeSamples, - audio_frame->mutable_data()); - if (samples_per_channel_int < 0) { - RTC_LOG(LS_ERROR) - << "AcmReceiver::GetAudio - Resampling audio_buffer_ failed."; - return false; - } - audio_frame->samples_per_channel_ = - static_cast(samples_per_channel_int); - audio_frame->sample_rate_hz_ = desired_sample_rate_hz; - RTC_DCHECK_EQ(audio_frame->sample_rate_hz_, - dchecked_cast(audio_frame->samples_per_channel_ * 100)); + // Grab the source view of the current layout before changing properties. + InterleavedView src = audio_frame->data_view(); + audio_frame->SetSampleRateAndChannelSize(desired_sample_rate_hz); + InterleavedView dst = audio_frame->mutable_data( + audio_frame->samples_per_channel(), audio_frame->num_channels()); + // TODO(tommi): Don't resample muted audio frames. + resampler_.Resample(src, dst); resampled_last_output_frame_ = true; } else { resampled_last_output_frame_ = false; @@ -109,10 +67,10 @@ bool ResamplerHelper::MaybeResample(int desired_sample_rate_hz, } // Store current audio in `last_audio_buffer_` for next time. - // TODO: b/335805780 - Use CopySamples(). - memcpy(last_audio_buffer_.data(), audio_frame->data(), - sizeof(int16_t) * audio_frame->samples_per_channel_ * - audio_frame->num_channels_); + InterleavedView dst(last_audio_buffer_.data(), + audio_frame->samples_per_channel(), + audio_frame->num_channels()); + CopySamples(dst, audio_frame->data_view()); return true; } diff --git a/modules/audio_coding/acm2/acm_resampler.h b/modules/audio_coding/acm2/acm_resampler.h index cf7133c38d..8b6cee04ce 100644 --- a/modules/audio_coding/acm2/acm_resampler.h +++ b/modules/audio_coding/acm2/acm_resampler.h @@ -14,29 +14,14 @@ #include #include +#include + #include "api/audio/audio_frame.h" #include "common_audio/resampler/include/push_resampler.h" namespace webrtc { namespace acm2 { -class ACMResampler { - public: - ACMResampler(); - ~ACMResampler(); - - // TODO: b/335805780 - Change to accept InterleavedView<>. - int Resample10Msec(const int16_t* in_audio, - int in_freq_hz, - int out_freq_hz, - size_t num_audio_channels, - size_t out_capacity_samples, - int16_t* out_audio); - - private: - PushResampler resampler_; -}; - // Helper class to perform resampling if needed, meant to be used after // receiving the audio_frame from NetEq. Provides reasonably glitch free // transitions between different output sample rates from NetEq. @@ -48,7 +33,7 @@ class ResamplerHelper { bool MaybeResample(int desired_sample_rate_hz, AudioFrame* audio_frame); private: - ACMResampler resampler_; + PushResampler resampler_; bool resampled_last_output_frame_ = true; std::array last_audio_buffer_; }; diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc index c79bded007..64cd530934 100644 --- a/modules/audio_coding/acm2/acm_send_test.cc +++ b/modules/audio_coding/acm2/acm_send_test.cc @@ -13,18 +13,23 @@ #include #include +#include +#include +#include + #include "absl/strings/match.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "api/audio_codecs/audio_encoder.h" -#include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/environment/environment_factory.h" #include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/audio_coding/neteq/tools/packet.h" #include "rtc_base/checks.h" -#include "rtc_base/string_encode.h" -#include "test/gtest.h" +#include "rtc_base/copy_on_write_buffer.h" namespace webrtc { namespace test { @@ -34,7 +39,7 @@ AcmSendTestOldApi::AcmSendTestOldApi(InputAudioFile* audio_source, int test_duration_ms) : clock_(0), env_(CreateEnvironment(&clock_)), - acm_(webrtc::AudioCodingModule::Create()), + acm_(AudioCodingModule::Create()), audio_source_(audio_source), source_rate_hz_(source_rate_hz), input_block_size_samples_( diff --git a/modules/audio_coding/acm2/acm_send_test.h b/modules/audio_coding/acm2/acm_send_test.h index 1bba67618b..694c1f92ed 100644 --- a/modules/audio_coding/acm2/acm_send_test.h +++ b/modules/audio_coding/acm2/acm_send_test.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_ACM2_ACM_SEND_TEST_H_ #define MODULES_AUDIO_CODING_ACM2_ACM_SEND_TEST_H_ +#include +#include #include #include @@ -18,6 +20,7 @@ #include "api/audio/audio_frame.h" #include "api/environment/environment.h" #include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/audio_coding/neteq/tools/packet_source.h" #include "system_wrappers/include/clock.h" diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc index f2b4237301..41d022ecf3 100644 --- a/modules/audio_coding/acm2/audio_coding_module.cc +++ b/modules/audio_coding/acm2/audio_coding_module.cc @@ -20,10 +20,11 @@ #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/audio/audio_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/function_view.h" +#include "common_audio/resampler/include/push_resampler.h" #include "modules/audio_coding/acm2/acm_remixing.h" -#include "modules/audio_coding/acm2/acm_resampler.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/include/module_common_types_public.h" #include "rtc_base/buffer.h" @@ -122,6 +123,13 @@ class AudioCodingModuleImpl final : public AudioCodingModule { bool HaveValidEncoder(absl::string_view caller_name) const RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_); + // Updates or checks `expected_in_ts_` and `expected_codec_ts` based on the + // timestamps in `in_frame`. If no audio frame has been received, the fields + // are just set. For subsequent frames, the expected timestamps are checked + // for consistency. + void SetInputTimestamps(const AudioFrame& in_frame) + RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_); + // Preprocessing of input audio, including resampling and down-mixing if // required, before pushing audio into encoder's buffer. // @@ -137,6 +145,14 @@ class AudioCodingModuleImpl final : public AudioCodingModule { const AudioFrame** ptr_out) RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_); + // Called from `PreprocessToAddData` when no resampling or downmixing is + // required. Returns a pointer to an output audio_frame. If timestamps are as + // expected the return value will point to `in_frame`, otherwise the data will + // have been copied into `preprocess_frame_` and the returned pointer points + // to `preprocess_frame_`. + const AudioFrame* AddDataNoPreProcess(const AudioFrame& in_frame) + RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_); + // Change required states after starting to receive the codec corresponding // to `index`. int UpdateUponReceivingCodec(int index); @@ -145,7 +161,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule { Buffer encode_buffer_ RTC_GUARDED_BY(acm_mutex_); uint32_t expected_codec_ts_ RTC_GUARDED_BY(acm_mutex_); uint32_t expected_in_ts_ RTC_GUARDED_BY(acm_mutex_); - acm2::ACMResampler resampler_ RTC_GUARDED_BY(acm_mutex_); + PushResampler resampler_ RTC_GUARDED_BY(acm_mutex_); ChangeLogger bitrate_logger_ RTC_GUARDED_BY(acm_mutex_); // Current encoder stack, provided by a call to RegisterEncoder. @@ -180,8 +196,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule { void UpdateCodecTypeHistogram(size_t codec_type) { RTC_HISTOGRAM_ENUMERATION( "WebRTC.Audio.Encoder.CodecType", static_cast(codec_type), - static_cast( - webrtc::AudioEncoder::CodecType::kMaxLoggedAudioCodecTypes)); + static_cast(AudioEncoder::CodecType::kMaxLoggedAudioCodecTypes)); } void AudioCodingModuleImpl::ChangeLogger::MaybeLog(int value) { @@ -200,7 +215,7 @@ AudioCodingModuleImpl::AudioCodingModuleImpl() previous_pltype_(255), first_10ms_data_(false), first_frame_(true), - packetization_callback_(NULL), + packetization_callback_(nullptr), codec_histogram_bins_log_(), number_of_consecutive_empty_packets_(0) { RTC_LOG(LS_INFO) << "Created"; @@ -411,6 +426,23 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame, return 0; } +void AudioCodingModuleImpl::SetInputTimestamps(const AudioFrame& in_frame) { + if (!first_10ms_data_) { + expected_in_ts_ = in_frame.timestamp_; + expected_codec_ts_ = in_frame.timestamp_; + first_10ms_data_ = true; + } else if (in_frame.timestamp_ != expected_in_ts_) { + RTC_LOG(LS_WARNING) << "Unexpected input timestamp: " << in_frame.timestamp_ + << ", expected: " << expected_in_ts_; + expected_codec_ts_ += + (in_frame.timestamp_ - expected_in_ts_) * + static_cast( + static_cast(encoder_stack_->SampleRateHz()) / + static_cast(in_frame.sample_rate_hz_)); + expected_in_ts_ = in_frame.timestamp_; + } +} + // Perform a resampling and down-mix if required. We down-mix only if // encoder is mono and input is stereo. In case of dual-streaming, both // encoders has to be mono for down-mix to take place. @@ -419,6 +451,8 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame, // TODO(yujo): Make this more efficient for muted frames. int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame, const AudioFrame** ptr_out) { + SetInputTimestamps(in_frame); + const bool resample = in_frame.sample_rate_hz_ != encoder_stack_->SampleRateHz(); @@ -429,82 +463,53 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame, const bool down_mix = in_frame.num_channels_ == 2 && encoder_stack_->NumChannels() == 1; - if (!first_10ms_data_) { - expected_in_ts_ = in_frame.timestamp_; - expected_codec_ts_ = in_frame.timestamp_; - first_10ms_data_ = true; - } else if (in_frame.timestamp_ != expected_in_ts_) { - RTC_LOG(LS_WARNING) << "Unexpected input timestamp: " << in_frame.timestamp_ - << ", expected: " << expected_in_ts_; - expected_codec_ts_ += - (in_frame.timestamp_ - expected_in_ts_) * - static_cast( - static_cast(encoder_stack_->SampleRateHz()) / - static_cast(in_frame.sample_rate_hz_)); - expected_in_ts_ = in_frame.timestamp_; - } - if (!down_mix && !resample) { // No preprocessing is required. - if (expected_in_ts_ == expected_codec_ts_) { - // If we've never resampled, we can use the input frame as-is - *ptr_out = &in_frame; - } else { - // Otherwise we'll need to alter the timestamp. Since in_frame is const, - // we'll have to make a copy of it. - preprocess_frame_.CopyFrom(in_frame); - preprocess_frame_.timestamp_ = expected_codec_ts_; - *ptr_out = &preprocess_frame_; - } - - expected_in_ts_ += static_cast(in_frame.samples_per_channel_); - expected_codec_ts_ += static_cast(in_frame.samples_per_channel_); + *ptr_out = AddDataNoPreProcess(in_frame); return 0; } + // Some pre-processing will be required, so we'll use the internal buffer. *ptr_out = &preprocess_frame_; - preprocess_frame_.num_channels_ = in_frame.num_channels_; + preprocess_frame_.timestamp_ = expected_codec_ts_; preprocess_frame_.samples_per_channel_ = in_frame.samples_per_channel_; + + // Temporary buffer in case both downmixing and resampling is required. std::array audio; - const int16_t* src_ptr_audio; + // When resampling is needed, this view will represent the buffer to resample. + InterleavedView resample_src_audio; + if (down_mix) { - // If a resampling is required, the output of a down-mix is written into a - // local buffer, otherwise, it will be written to the output frame. - int16_t* dest_ptr_audio = - resample ? audio.data() : preprocess_frame_.mutable_data(); - RTC_DCHECK_GE(audio.size(), preprocess_frame_.samples_per_channel_); - RTC_DCHECK_GE(audio.size(), in_frame.samples_per_channel_); - DownMixFrame(in_frame, - ArrayView(dest_ptr_audio, - preprocess_frame_.samples_per_channel_)); - preprocess_frame_.num_channels_ = 1; - - // Set the input of the resampler to the down-mixed signal. - src_ptr_audio = audio.data(); + RTC_DCHECK_GE(audio.size(), in_frame.samples_per_channel()); + preprocess_frame_.num_channels_ = 1; // We always downmix to mono. + // If a resampling is also required, the output of a down-mix is written + // into a local buffer, otherwise, it will be written to the output frame. + auto downmixed = + resample + ? InterleavedView(audio.data(), + in_frame.samples_per_channel(), 1) + : preprocess_frame_.mutable_data(in_frame.samples_per_channel(), 1); + DownMixFrame(in_frame, downmixed.AsMono()); + if (resample) { + // Set the input for the resampler to the down-mixed signal. + resample_src_audio = downmixed; + } } else { - // Set the input of the resampler to the original data. - src_ptr_audio = in_frame.data(); + preprocess_frame_.num_channels_ = in_frame.num_channels_; + if (resample) { + // Set the input of the resampler to the original data. + resample_src_audio = in_frame.data_view(); + } } - preprocess_frame_.timestamp_ = expected_codec_ts_; - preprocess_frame_.sample_rate_hz_ = in_frame.sample_rate_hz_; - // If it is required, we have to do a resampling. - if (resample) { - // The result of the resampler is written to output frame. - int16_t* dest_ptr_audio = preprocess_frame_.mutable_data(); - - int samples_per_channel = resampler_.Resample10Msec( - src_ptr_audio, in_frame.sample_rate_hz_, encoder_stack_->SampleRateHz(), - preprocess_frame_.num_channels_, AudioFrame::kMaxDataSizeSamples, - dest_ptr_audio); + RTC_DCHECK(resample_src_audio.empty() || resample); + preprocess_frame_.SetSampleRateAndChannelSize(encoder_stack_->SampleRateHz()); - if (samples_per_channel < 0) { - RTC_LOG(LS_ERROR) << "Cannot add 10 ms audio, resampling failed"; - return -1; - } - preprocess_frame_.samples_per_channel_ = - static_cast(samples_per_channel); - preprocess_frame_.sample_rate_hz_ = encoder_stack_->SampleRateHz(); + if (resample) { + resampler_.Resample( + resample_src_audio, + preprocess_frame_.mutable_data(preprocess_frame_.samples_per_channel(), + preprocess_frame_.num_channels())); } expected_codec_ts_ += @@ -514,6 +519,27 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame, return 0; } +const AudioFrame* AudioCodingModuleImpl::AddDataNoPreProcess( + const AudioFrame& in_frame) { + const AudioFrame* ret = nullptr; + // No preprocessing is required. + if (expected_in_ts_ == expected_codec_ts_) { + // Timestamps as expected, we can use the input frame as-is. + ret = &in_frame; + } else { + // Otherwise we'll need to alter the timestamp. Since in_frame is const, + // we'll have to make a copy of it. + preprocess_frame_.CopyFrom(in_frame); + preprocess_frame_.timestamp_ = expected_codec_ts_; + ret = &preprocess_frame_; + } + + expected_in_ts_ += static_cast(in_frame.samples_per_channel_); + expected_codec_ts_ += static_cast(in_frame.samples_per_channel_); + + return ret; +} + ///////////////////////////////////////// // (FEC) Forward Error Correction (codec internal) // diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc index 51f49b1112..ba8ca870d1 100644 --- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -63,9 +63,9 @@ #include "rtc_base/string_encode.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/arch.h" +#include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/sleep.h" #include "test/audio_decoder_proxy_factory.h" #include "test/gmock.h" #include "test/gtest.h" @@ -441,7 +441,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { // The send thread doesn't have to care about the current simulated time, // since only the AcmReceiver is using the clock. void CbSendImpl() { - SleepMs(1); + Thread::SleepMs(1); if (HasFatalFailure()) { // End the test early if a fatal failure (ASSERT_*) has occurred. test_complete_.Set(); @@ -454,7 +454,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { } void CbInsertPacketImpl() { - SleepMs(1); + Thread::SleepMs(1); { MutexLock lock(&mutex_); if (env_.clock().TimeInMilliseconds() < next_insert_packet_time_ms_) { @@ -468,7 +468,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { } void CbPullAudioImpl() { - SleepMs(1); + Thread::SleepMs(1); { MutexLock lock(&mutex_); // Don't let the insert thread fall behind. @@ -666,7 +666,7 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, audio_source_.reset(new test::InputAudioFile(input_file_name)); send_test_.reset(new test::AcmSendTestOldApi(audio_source_.get(), source_rate, kTestDurationMs)); - return send_test_.get() != NULL; + return send_test_.get() != nullptr; } // Registers a send codec in the test::AcmSendTest object. Returns true on @@ -707,7 +707,7 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, // output. test::AudioChecksum audio_checksum; const std::string output_file_name = - webrtc::test::OutputPath() + + test::OutputPath() + ::testing::UnitTest::GetInstance() ->current_test_info() ->test_case_name() + @@ -758,7 +758,7 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, std::unique_ptr NextPacket() override { auto packet = send_test_->NextPacket(); if (!packet) - return NULL; + return nullptr; VerifyPacket(packet.get()); // TODO(henrik.lundin) Save the packet to file as well. @@ -817,13 +817,12 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, uint32_t last_timestamp_; std::unique_ptr payload_checksum_; const std::string kTestFileMono32kHz = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); const std::string kTestFileFakeStereo32kHz = - webrtc::test::ResourcePath("audio_coding/testfile_fake_stereo_32kHz", - "pcm"); - const std::string kTestFileQuad48kHz = webrtc::test::ResourcePath( - "audio_coding/speech_4_channels_48k_one_second", - "wav"); + test::ResourcePath("audio_coding/testfile_fake_stereo_32kHz", "pcm"); + const std::string kTestFileQuad48kHz = + test::ResourcePath("audio_coding/speech_4_channels_48k_one_second", + "wav"); }; class AcmSenderBitExactnessNewApi : public AcmSenderBitExactnessOldApi {}; @@ -1047,7 +1046,7 @@ class AcmSetBitRateTest : public ::testing::Test { // false. bool SetUpSender() { const std::string input_file_name = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); // Note that `audio_source_` will loop forever. The test duration is set // explicitly by `kTestDurationMs`. audio_source_.reset(new test::InputAudioFile(input_file_name)); @@ -1270,10 +1269,9 @@ TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) { EXPECT_CALL(*mock_encoder, EncodeImpl(_, _, _)) .Times(AtLeast(1)) .WillRepeatedly(Invoke( - &encoder, - static_cast, webrtc::Buffer*)>( - &AudioEncoderPcmU::Encode))); + &encoder, static_cast, Buffer*)>( + &AudioEncoderPcmU::Encode))); ASSERT_TRUE(SetUpSender(kTestFileMono32kHz, 32000)); ASSERT_NO_FATAL_FAILURE( SetUpTestExternalEncoder(std::move(mock_encoder), config.payload_type)); @@ -1310,7 +1308,7 @@ class AcmSwitchingOutputFrequencyOldApi : public ::testing::Test, // Set up the receiver used to decode the packets and verify the decoded // output. const std::string output_file_name = - webrtc::test::OutputPath() + + test::OutputPath() + ::testing::UnitTest::GetInstance() ->current_test_info() ->test_case_name() + @@ -1340,7 +1338,7 @@ class AcmSwitchingOutputFrequencyOldApi : public ::testing::Test, // "manually". if (num_packets_++ > kTestNumPackets) { EXPECT_TRUE(has_toggled_); - return NULL; // Test ended. + return nullptr; // Test ended. } // Get the next packet from the source. diff --git a/modules/audio_coding/acm2/call_statistics.cc b/modules/audio_coding/acm2/call_statistics.cc index 9f3bdadc88..de3e3cc070 100644 --- a/modules/audio_coding/acm2/call_statistics.cc +++ b/modules/audio_coding/acm2/call_statistics.cc @@ -10,6 +10,8 @@ #include "modules/audio_coding/acm2/call_statistics.h" +#include "api/audio/audio_frame.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/acm2/call_statistics_unittest.cc b/modules/audio_coding/acm2/call_statistics_unittest.cc index b96977b8e4..4cafa90699 100644 --- a/modules/audio_coding/acm2/call_statistics_unittest.cc +++ b/modules/audio_coding/acm2/call_statistics_unittest.cc @@ -10,6 +10,8 @@ #include "modules/audio_coding/acm2/call_statistics.h" +#include "api/audio/audio_frame.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc index ddcf6c8060..74979843fa 100644 --- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc +++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc @@ -12,15 +12,20 @@ #include +#include +#include +#include +#include #include -#include +#include "api/audio_codecs/audio_encoder.h" +#include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/controller_manager.h" #include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h" #include "modules/audio_coding/audio_network_adaptor/event_log_writer.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/checks.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc index 59c5eb8714..339b968512 100644 --- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc @@ -10,17 +10,22 @@ #include "modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h" +#include +#include +#include #include #include #include "api/rtc_event_log/rtc_event.h" +#include "api/units/time_delta.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" +#include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/mock/mock_controller.h" #include "modules/audio_coding/audio_network_adaptor/mock/mock_controller_manager.h" #include "modules/audio_coding/audio_network_adaptor/mock/mock_debug_dump_writer.h" #include "rtc_base/fake_clock.h" -#include "test/field_trial.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { @@ -174,8 +179,6 @@ TEST(AudioNetworkAdaptorImplTest, TEST(AudioNetworkAdaptorImplTest, DumpEncoderRuntimeConfigIsCalledOnGetEncoderRuntimeConfig) { - test::ScopedFieldTrials override_field_trials( - "WebRTC-Audio-FecAdaptation/Enabled/"); ScopedFakeClock fake_clock; fake_clock.AdvanceTime(TimeDelta::Millis(kClockInitialTimeMs)); auto states = CreateAudioNetworkAdaptor(); @@ -246,8 +249,6 @@ TEST(AudioNetworkAdaptorImplTest, } TEST(AudioNetworkAdaptorImplTest, LogRuntimeConfigOnGetEncoderRuntimeConfig) { - test::ScopedFieldTrials override_field_trials( - "WebRTC-Audio-FecAdaptation/Enabled/"); auto states = CreateAudioNetworkAdaptor(); AudioEncoderRuntimeConfig config; diff --git a/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc b/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc index 88ca38d074..63aed54d8d 100644 --- a/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc +++ b/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc @@ -12,8 +12,8 @@ #include +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace audio_network_adaptor { diff --git a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc index b142915c24..304cb0d517 100644 --- a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc @@ -10,8 +10,12 @@ #include "modules/audio_coding/audio_network_adaptor/bitrate_controller.h" +#include +#include + +#include "modules/audio_coding/audio_network_adaptor/controller.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/numerics/safe_conversions.h" -#include "test/field_trial.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/channel_controller.cc b/modules/audio_coding/audio_network_adaptor/channel_controller.cc index 2ef2f4c4d8..73d3e39e2a 100644 --- a/modules/audio_coding/audio_network_adaptor/channel_controller.cc +++ b/modules/audio_coding/audio_network_adaptor/channel_controller.cc @@ -11,7 +11,9 @@ #include "modules/audio_coding/audio_network_adaptor/channel_controller.h" #include +#include +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc index 1803d449ed..003ab0dd6d 100644 --- a/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc @@ -10,8 +10,12 @@ #include "modules/audio_coding/audio_network_adaptor/channel_controller.h" +#include #include +#include +#include "modules/audio_coding/audio_network_adaptor/controller.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/controller.h b/modules/audio_coding/audio_network_adaptor/controller.h index fc2cba78ed..80b0435bfb 100644 --- a/modules/audio_coding/audio_network_adaptor/controller.h +++ b/modules/audio_coding/audio_network_adaptor/controller.h @@ -11,9 +11,10 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_ +#include #include -#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/modules/audio_coding/audio_network_adaptor/controller_manager.cc index 599fcc3653..c126897bfb 100644 --- a/modules/audio_coding/audio_network_adaptor/controller_manager.cc +++ b/modules/audio_coding/audio_network_adaptor/controller_manager.cc @@ -10,21 +10,30 @@ #include "modules/audio_coding/audio_network_adaptor/controller_manager.h" +#include #include +#include +#include +#include #include +#include +#include #include #include +#include #include "absl/strings/string_view.h" +#include "api/array_view.h" #include "modules/audio_coding/audio_network_adaptor/bitrate_controller.h" #include "modules/audio_coding/audio_network_adaptor/channel_controller.h" +#include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h" #include "modules/audio_coding/audio_network_adaptor/dtx_controller.h" #include "modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h" #include "modules/audio_coding/audio_network_adaptor/frame_length_controller.h" #include "modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h" #include "modules/audio_coding/audio_network_adaptor/util/threshold_curve.h" -#include "rtc_base/logging.h" +#include "rtc_base/checks.h" #include "rtc_base/time_utils.h" #if WEBRTC_ENABLE_PROTOBUF diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.h b/modules/audio_coding/audio_network_adaptor/controller_manager.h index 632cc616a3..7fd617dc69 100644 --- a/modules/audio_coding/audio_network_adaptor/controller_manager.h +++ b/modules/audio_coding/audio_network_adaptor/controller_manager.h @@ -11,12 +11,16 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_ +#include +#include #include #include -#include +#include +#include #include #include "absl/strings/string_view.h" +#include "api/array_view.h" #include "modules/audio_coding/audio_network_adaptor/controller.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc index 4504e04088..21d0aa750b 100644 --- a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc +++ b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc @@ -10,17 +10,24 @@ #include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h" +#include +#include +#include #include #include +#include "modules/audio_coding/audio_network_adaptor/controller.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/system/file_wrapper.h" #if WEBRTC_ENABLE_PROTOBUF #ifdef WEBRTC_ANDROID_PLATFORM_BUILD +#include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump.pb.h" #else +#include "modules/audio_coding/audio_network_adaptor/config.pb.h" #include "modules/audio_coding/audio_network_adaptor/debug_dump.pb.h" #endif #endif diff --git a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h index fd3a64dbb1..93effbd905 100644 --- a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h +++ b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h @@ -11,11 +11,12 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP_WRITER_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP_WRITER_H_ +#include +#include #include #include "modules/audio_coding/audio_network_adaptor/controller.h" -#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" -#include "rtc_base/system/file_wrapper.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #if WEBRTC_ENABLE_PROTOBUF #ifdef WEBRTC_ANDROID_PLATFORM_BUILD diff --git a/modules/audio_coding/audio_network_adaptor/dtx_controller.cc b/modules/audio_coding/audio_network_adaptor/dtx_controller.cc index b0a7d5d59d..e589657c98 100644 --- a/modules/audio_coding/audio_network_adaptor/dtx_controller.cc +++ b/modules/audio_coding/audio_network_adaptor/dtx_controller.cc @@ -10,6 +10,7 @@ #include "modules/audio_coding/audio_network_adaptor/dtx_controller.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc index 46c8f8b844..d92ee6cd81 100644 --- a/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc @@ -11,7 +11,10 @@ #include "modules/audio_coding/audio_network_adaptor/dtx_controller.h" #include +#include +#include "modules/audio_coding/audio_network_adaptor/controller.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/event_log_writer.cc b/modules/audio_coding/audio_network_adaptor/event_log_writer.cc index 1bef64eaa6..3e12125bc8 100644 --- a/modules/audio_coding/audio_network_adaptor/event_log_writer.cc +++ b/modules/audio_coding/audio_network_adaptor/event_log_writer.cc @@ -18,7 +18,6 @@ #include #include -#include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" #include "rtc_base/checks.h" diff --git a/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc b/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc index 2c344534ea..1ae5794505 100644 --- a/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/event_log_writer_unittest.cc @@ -10,11 +10,14 @@ #include "modules/audio_coding/audio_network_adaptor/event_log_writer.h" +#include #include +#include "api/rtc_event_log/rtc_event.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" #include "rtc_base/checks.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc index bcfbd75c61..5db593abd3 100644 --- a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc +++ b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc @@ -10,9 +10,13 @@ #include "modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h" -#include +#include +#include #include +#include "common_audio/smoothing_filter.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" +#include "modules/audio_coding/audio_network_adaptor/util/threshold_curve.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc index c3ec2d7072..40f98482ad 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc @@ -11,9 +11,13 @@ #include "modules/audio_coding/audio_network_adaptor/frame_length_controller.h" #include +#include #include +#include +#include #include +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc index 2bf52b21aa..926e4c6f20 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc @@ -10,9 +10,14 @@ #include "modules/audio_coding/audio_network_adaptor/frame_length_controller.h" +#include +#include #include -#include +#include +#include +#include "modules/audio_coding/audio_network_adaptor/controller.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.cc index f6f4759ba1..bbb0a2de29 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.cc +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.cc @@ -10,9 +10,9 @@ #include "modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h" -#include - #include "absl/algorithm/container.h" +#include "api/array_view.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h index c64c75f051..e8ff5adfde 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h @@ -14,8 +14,9 @@ #include #include +#include "api/array_view.h" #include "modules/audio_coding/audio_network_adaptor/controller.h" -#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc index 1bec1acfc9..e038b48af3 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc @@ -10,8 +10,8 @@ #include "modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h" -#include #include +#include #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" diff --git a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h index ed07298e8e..7e5ab54ec0 100644 --- a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h +++ b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_ -#include +#include +#include #include "api/audio_codecs/audio_encoder.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" diff --git a/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h b/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h index 26a9061745..9d0fbab246 100644 --- a/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h +++ b/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h @@ -11,7 +11,12 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_MOCK_MOCK_AUDIO_NETWORK_ADAPTOR_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_MOCK_MOCK_AUDIO_NETWORK_ADAPTOR_H_ +#include +#include + +#include "api/audio_codecs/audio_encoder.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "test/gmock.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/mock/mock_controller.h b/modules/audio_coding/audio_network_adaptor/mock/mock_controller.h index de554c0517..d7624f3974 100644 --- a/modules/audio_coding/audio_network_adaptor/mock/mock_controller.h +++ b/modules/audio_coding/audio_network_adaptor/mock/mock_controller.h @@ -12,6 +12,7 @@ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_MOCK_MOCK_CONTROLLER_H_ #include "modules/audio_coding/audio_network_adaptor/controller.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "test/gmock.h" namespace webrtc { diff --git a/modules/audio_coding/audio_network_adaptor/mock/mock_controller_manager.h b/modules/audio_coding/audio_network_adaptor/mock/mock_controller_manager.h index 9e2fa466fc..71194b0874 100644 --- a/modules/audio_coding/audio_network_adaptor/mock/mock_controller_manager.h +++ b/modules/audio_coding/audio_network_adaptor/mock/mock_controller_manager.h @@ -13,6 +13,7 @@ #include +#include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/controller_manager.h" #include "test/gmock.h" diff --git a/modules/audio_coding/audio_network_adaptor/util/threshold_curve_unittest.cc b/modules/audio_coding/audio_network_adaptor/util/threshold_curve_unittest.cc index dc3aec0b18..09e66c9b79 100644 --- a/modules/audio_coding/audio_network_adaptor/util/threshold_curve_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/util/threshold_curve_unittest.cc @@ -12,6 +12,7 @@ #include +#include "rtc_base/checks.h" #include "test/gtest.h" // A threshold curve divides 2D space into three domains - below, on and above diff --git a/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc b/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc index 55ca237966..fe3adbd823 100644 --- a/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc +++ b/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc @@ -11,9 +11,18 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include +#include +#include +#include +#include +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/rtp_parameters.h" +#include "api/scoped_refptr.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/builtin_audio_encoder_factory_unittest.cc b/modules/audio_coding/codecs/builtin_audio_encoder_factory_unittest.cc index 78ba36fe85..f1250a29f4 100644 --- a/modules/audio_coding/codecs/builtin_audio_encoder_factory_unittest.cc +++ b/modules/audio_coding/codecs/builtin_audio_encoder_factory_unittest.cc @@ -10,12 +10,21 @@ #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include +#include #include #include +#include #include +#include "api/array_view.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/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/scoped_refptr.h" +#include "rtc_base/buffer.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc index a4d0b9abd4..e93887606f 100644 --- a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc +++ b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc @@ -10,13 +10,19 @@ #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" +#include #include #include #include #include +#include +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" #include "api/units/time_delta.h" +#include "common_audio/vad/include/vad.h" #include "modules/audio_coding/codecs/cng/webrtc_cng.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc index c6c2df7f0c..606a6b807c 100644 --- a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc +++ b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc @@ -10,11 +10,21 @@ #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" +#include +#include +#include #include -#include +#include +#include +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/units/time_delta.h" +#include "common_audio/vad/include/vad.h" #include "common_audio/vad/mock/mock_vad.h" +#include "rtc_base/buffer.h" #include "rtc_base/numerics/safe_conversions.h" +#include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" #include "test/testsupport/rtc_expect_death.h" diff --git a/modules/audio_coding/codecs/cng/cng_unittest.cc b/modules/audio_coding/codecs/cng/cng_unittest.cc index 76d11d413c..01b7fbfb1c 100644 --- a/modules/audio_coding/codecs/cng/cng_unittest.cc +++ b/modules/audio_coding/codecs/cng/cng_unittest.cc @@ -7,10 +7,15 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include +#include #include +#include "api/array_view.h" #include "modules/audio_coding/codecs/cng/webrtc_cng.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -45,13 +50,13 @@ class CngDeathTest : public CngTest {}; void CngTest::SetUp() { FILE* input_file; const std::string file_name = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); input_file = fopen(file_name.c_str(), "rb"); - ASSERT_TRUE(input_file != NULL); + ASSERT_TRUE(input_file != nullptr); ASSERT_EQ(640, static_cast( fread(speech_data_, sizeof(int16_t), 640, input_file))); fclose(input_file); - input_file = NULL; + input_file = nullptr; } void CngTest::TestCngEncode(int sample_rate_hz, int quality) { diff --git a/modules/audio_coding/codecs/cng/webrtc_cng.cc b/modules/audio_coding/codecs/cng/webrtc_cng.cc index 4649f16d9e..5961cb0e9c 100644 --- a/modules/audio_coding/codecs/cng/webrtc_cng.cc +++ b/modules/audio_coding/codecs/cng/webrtc_cng.cc @@ -11,8 +11,12 @@ #include "modules/audio_coding/codecs/cng/webrtc_cng.h" #include +#include +#include +#include "api/array_view.h" #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc index 4b97e11c02..f67ff2dfff 100644 --- a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc +++ b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc @@ -10,10 +10,16 @@ #include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" +#include +#include #include +#include +#include "api/audio_codecs/audio_decoder.h" #include "modules/audio_coding/codecs/g711/g711_interface.h" #include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/g711/audio_decoder_pcm.h b/modules/audio_coding/codecs/g711/audio_decoder_pcm.h index 7eb2835be4..6071ef1e46 100644 --- a/modules/audio_coding/codecs/g711/audio_decoder_pcm.h +++ b/modules/audio_coding/codecs/g711/audio_decoder_pcm.h @@ -26,6 +26,7 @@ class AudioDecoderPcmU final : public AudioDecoder { public: explicit AudioDecoderPcmU(size_t num_channels) : num_channels_(num_channels) { RTC_DCHECK_GE(num_channels, 1); + RTC_DCHECK_LE(num_channels, AudioDecoder::kMaxNumberOfChannels); } AudioDecoderPcmU(const AudioDecoderPcmU&) = delete; @@ -55,6 +56,7 @@ class AudioDecoderPcmA final : public AudioDecoder { public: explicit AudioDecoderPcmA(size_t num_channels) : num_channels_(num_channels) { RTC_DCHECK_GE(num_channels, 1); + RTC_DCHECK_LE(num_channels, AudioDecoder::kMaxNumberOfChannels); } AudioDecoderPcmA(const AudioDecoderPcmA&) = delete; diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc index 38232e1c7b..281be597cf 100644 --- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc +++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc @@ -10,15 +10,23 @@ #include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" +#include #include +#include +#include +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/units/time_delta.h" #include "modules/audio_coding/codecs/g711/g711_interface.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { bool AudioEncoderPcm::Config::IsOk() const { - return (frame_size_ms % 10 == 0) && (num_channels >= 1); + return (frame_size_ms % 10 == 0) && (num_channels >= 1) && + (num_channels <= AudioEncoder::kMaxNumberOfChannels); } AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz) diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.h b/modules/audio_coding/codecs/g711/audio_encoder_pcm.h index 18a4770ec4..0d56e58d02 100644 --- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.h +++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.h @@ -11,12 +11,16 @@ #ifndef MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ #define MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ +#include +#include #include #include #include +#include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/units/time_delta.h" +#include "rtc_base/buffer.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/g711/test/testG711.cc b/modules/audio_coding/codecs/g711/test/testG711.cc index f3a42f5d79..770836c337 100644 --- a/modules/audio_coding/codecs/g711/test/testG711.cc +++ b/modules/audio_coding/codecs/g711/test/testG711.cc @@ -21,6 +21,8 @@ /* Runtime statistics */ #include + +#include #define CLOCKS_PER_SEC_G711 1000 /* function for reading audio data from PCM file */ @@ -36,7 +38,7 @@ int main(int argc, char* argv[]) { char inname[80], outname[40], bitname[40]; FILE* inp; FILE* outp; - FILE* bitp = NULL; + FILE* bitp = nullptr; int framecnt; bool endfile; @@ -92,17 +94,17 @@ int main(int argc, char* argv[]) { sscanf(argv[4], "%s", outname); if (argc == 6) { sscanf(argv[5], "%s", bitname); - if ((bitp = fopen(bitname, "wb")) == NULL) { + if ((bitp = fopen(bitname, "wb")) == nullptr) { printf(" G.711: Cannot read file %s.\n", bitname); exit(1); } } - if ((inp = fopen(inname, "rb")) == NULL) { + if ((inp = fopen(inname, "rb")) == nullptr) { printf(" G.711: Cannot read file %s.\n", inname); exit(1); } - if ((outp = fopen(outname, "wb")) == NULL) { + if ((outp = fopen(outname, "wb")) == nullptr) { printf(" G.711: Cannot write file %s.\n", outname); exit(1); } diff --git a/modules/audio_coding/codecs/g722/audio_decoder_g722.cc b/modules/audio_coding/codecs/g722/audio_decoder_g722.cc index cbffc488ec..0fbf91474f 100644 --- a/modules/audio_coding/codecs/g722/audio_decoder_g722.cc +++ b/modules/audio_coding/codecs/g722/audio_decoder_g722.cc @@ -12,10 +12,14 @@ #include +#include #include +#include +#include "api/audio_codecs/audio_decoder.h" #include "modules/audio_coding/codecs/g722/g722_interface.h" #include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/g722/audio_decoder_g722.h b/modules/audio_coding/codecs/g722/audio_decoder_g722.h index 431d896b18..812f08c9c3 100644 --- a/modules/audio_coding/codecs/g722/audio_decoder_g722.h +++ b/modules/audio_coding/codecs/g722/audio_decoder_g722.h @@ -11,7 +11,12 @@ #ifndef MODULES_AUDIO_CODING_CODECS_G722_AUDIO_DECODER_G722_H_ #define MODULES_AUDIO_CODING_CODECS_G722_AUDIO_DECODER_G722_H_ +#include +#include +#include + #include "api/audio_codecs/audio_decoder.h" +#include "rtc_base/buffer.h" typedef struct WebRtcG722DecInst G722DecInst; diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc index 699aeb47d1..078ba0a39b 100644 --- a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc +++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc @@ -10,11 +10,18 @@ #include "modules/audio_coding/codecs/g722/audio_encoder_g722.h" +#include #include +#include +#include +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/g722/audio_encoder_g722_config.h" +#include "api/units/time_delta.h" #include "modules/audio_coding/codecs/g722/g722_interface.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.h b/modules/audio_coding/codecs/g722/audio_encoder_g722.h index 8a584e26e8..42ce125d47 100644 --- a/modules/audio_coding/codecs/g722/audio_encoder_g722.h +++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.h @@ -11,10 +11,13 @@ #ifndef MODULES_AUDIO_CODING_CODECS_G722_AUDIO_ENCODER_G722_H_ #define MODULES_AUDIO_CODING_CODECS_G722_AUDIO_ENCODER_G722_H_ +#include +#include #include #include #include +#include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/g722/audio_encoder_g722_config.h" #include "api/units/time_delta.h" diff --git a/modules/audio_coding/codecs/g722/test/testG722.cc b/modules/audio_coding/codecs/g722/test/testG722.cc index 9f2155d0f7..fcff08edd2 100644 --- a/modules/audio_coding/codecs/g722/test/testG722.cc +++ b/modules/audio_coding/codecs/g722/test/testG722.cc @@ -21,6 +21,8 @@ /* Runtime statistics */ #include + +#include #define CLOCKS_PER_SEC_G722 100000 // Forward declaration @@ -85,15 +87,15 @@ int main(int argc, char* argv[]) { sscanf(argv[3], "%s", outbit); sscanf(argv[4], "%s", outname); - if ((inp = fopen(inname, "rb")) == NULL) { + if ((inp = fopen(inname, "rb")) == nullptr) { printf(" G.722: Cannot read file %s.\n", inname); exit(1); } - if ((outbitp = fopen(outbit, "wb")) == NULL) { + if ((outbitp = fopen(outbit, "wb")) == nullptr) { printf(" G.722: Cannot write file %s.\n", outbit); exit(1); } - if ((outp = fopen(outname, "wb")) == NULL) { + if ((outp = fopen(outname, "wb")) == nullptr) { printf(" G.722: Cannot write file %s.\n", outname); exit(1); } diff --git a/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h b/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h index fe9afa4ba2..7191d9fbab 100644 --- a/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h +++ b/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h @@ -11,10 +11,6 @@ #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ -#include - -#include "rtc_base/system/arch.h" - #if defined(WEBRTC_POSIX) #define WebRtcIsac_lrint lrint #elif (defined(WEBRTC_ARCH_X86) && defined(WIN32)) diff --git a/modules/audio_coding/codecs/isac/main/source/pitch_filter.h b/modules/audio_coding/codecs/isac/main/source/pitch_filter.h index 9a232de87b..e1bbb5dad7 100644 --- a/modules/audio_coding/codecs/isac/main/source/pitch_filter.h +++ b/modules/audio_coding/codecs/isac/main/source/pitch_filter.h @@ -11,6 +11,7 @@ #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_FILTER_H_ #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_FILTER_H_ +#include "modules/audio_coding/codecs/isac/main/source/settings.h" #include "modules/audio_coding/codecs/isac/main/source/structs.h" void WebRtcIsac_PitchfilterPre(double* indat, diff --git a/modules/audio_coding/codecs/isac/main/source/structs.h b/modules/audio_coding/codecs/isac/main/source/structs.h index 6861ca42bd..0ca9b68803 100644 --- a/modules/audio_coding/codecs/isac/main/source/structs.h +++ b/modules/audio_coding/codecs/isac/main/source/structs.h @@ -18,6 +18,8 @@ #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_STRUCTS_H_ #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_STRUCTS_H_ +#include + #include "modules/audio_coding/codecs/isac/bandwidth_info.h" #include "modules/audio_coding/codecs/isac/main/source/settings.h" #include "modules/third_party/fft/fft.h" diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc index adbda10e2e..6b884a479a 100644 --- a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc +++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc @@ -11,9 +11,16 @@ #include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" #include +#include +#include #include +#include #include +#include +#include "api/array_view.h" +#include "api/audio_codecs/audio_decoder.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc b/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc index 486f3a9f56..1a6dab0aaa 100644 --- a/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc +++ b/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc @@ -10,7 +10,14 @@ #include "modules/audio_coding/codecs/opus/audio_coder_opus_common.h" +#include +#include +#include +#include + #include "absl/strings/string_view.h" +#include "api/audio_codecs/audio_format.h" +#include "rtc_base/string_to_number.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/opus/audio_coder_opus_common.h b/modules/audio_coding/codecs/opus/audio_coder_opus_common.h index adbfbc6eea..44f019eb2a 100644 --- a/modules/audio_coding/codecs/opus/audio_coder_opus_common.h +++ b/modules/audio_coding/codecs/opus/audio_coder_opus_common.h @@ -11,14 +11,18 @@ #ifndef MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_CODER_OPUS_COMMON_H_ #define MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_CODER_OPUS_COMMON_H_ +#include +#include #include #include #include #include #include "absl/strings/string_view.h" +#include "api/array_view.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "rtc_base/buffer.h" #include "rtc_base/string_to_number.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc index 8acb6d2262..6d9205d8bc 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc +++ b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc @@ -10,15 +10,20 @@ #include "modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h" -#include +#include +#include #include -#include +#include #include #include -#include "absl/memory/memory.h" +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_format.h" +#include "api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h" #include "modules/audio_coding/codecs/opus/audio_coder_opus_common.h" -#include "rtc_base/string_to_number.h" +#include "modules/audio_coding/codecs/opus/opus_interface.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h index 7d9d6aadf1..debca5d11d 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h +++ b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h @@ -13,7 +13,9 @@ #include +#include #include +#include #include #include "api/audio_codecs/audio_decoder.h" diff --git a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc index 7b30a392f9..b1bc921af2 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc @@ -10,6 +10,13 @@ #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h" +#include +#include +#include +#include + +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_format.h" #include "modules/audio_coding/codecs/opus/audio_coder_opus_common.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/modules/audio_coding/codecs/opus/audio_decoder_opus.cc b/modules/audio_coding/codecs/opus/audio_decoder_opus.cc index fae0bd47de..c4fb057718 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_opus.cc +++ b/modules/audio_coding/codecs/opus/audio_decoder_opus.cc @@ -10,13 +10,18 @@ #include "modules/audio_coding/codecs/opus/audio_decoder_opus.h" +#include +#include #include -#include #include +#include #include "api/array_view.h" +#include "api/audio_codecs/audio_decoder.h" #include "api/field_trials_view.h" #include "modules/audio_coding/codecs/opus/audio_coder_opus_common.h" +#include "modules/audio_coding/codecs/opus/opus_interface.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/opus/audio_decoder_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_decoder_opus_unittest.cc index cba690406b..56b846f8cf 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_decoder_opus_unittest.cc @@ -10,7 +10,10 @@ #include "modules/audio_coding/codecs/opus/audio_decoder_opus.h" +#include #include +#include +#include #include #include #include @@ -19,6 +22,7 @@ #include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/opus/audio_encoder_opus_config.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -26,6 +30,7 @@ #include "modules/audio_coding/test/PCMFile.h" #include "rtc_base/buffer.h" #include "rtc_base/checks.h" +#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/random.h" #include "test/explicit_key_value_config.h" #include "test/gmock.h" @@ -38,8 +43,8 @@ namespace { using test::ExplicitKeyValueConfig; using testing::SizeIs; -using DecodeResult = ::webrtc::AudioDecoder::EncodedAudioFrame::DecodeResult; -using ParseResult = ::webrtc::AudioDecoder::ParseResult; +using DecodeResult = AudioDecoder::EncodedAudioFrame::DecodeResult; +using ParseResult = AudioDecoder::ParseResult; constexpr int kSampleRateHz = 48000; diff --git a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc index 13d4cd7826..e0853d315e 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc @@ -20,14 +20,25 @@ #include "modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h" #include +#include +#include #include #include +#include #include +#include #include #include "absl/strings/match.h" +#include "api/array_view.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/audio_codecs/opus/audio_encoder_opus_config.h" +#include "api/units/time_delta.h" #include "modules/audio_coding/codecs/opus/audio_coder_opus_common.h" +#include "modules/audio_coding/codecs/opus/opus_interface.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc index 7601589557..7c4d53dcc1 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc @@ -10,7 +10,14 @@ #include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h" +#include +#include +#include + +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" #include "test/gmock.h" +#include "test/gtest.h" namespace webrtc { using ::testing::NiceMock; diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc index dbab35d4a8..8f95fed01c 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -11,20 +11,34 @@ #include "modules/audio_coding/codecs/opus/audio_encoder_opus.h" #include +#include +#include #include #include +#include #include #include +#include #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" +#include "api/audio_codecs/opus/audio_encoder_opus_config.h" +#include "api/call/bitrate_allocation.h" +#include "api/environment/environment.h" #include "api/field_trials_view.h" +#include "api/units/time_delta.h" +#include "common_audio/smoothing_filter.h" #include "modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h" #include "modules/audio_coding/audio_network_adaptor/controller_manager.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" #include "modules/audio_coding/codecs/opus/audio_coder_opus_common.h" #include "modules/audio_coding/codecs/opus/opus_interface.h" #include "rtc_base/arraysize.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/exp_filter.h" diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.h b/modules/audio_coding/codecs/opus/audio_encoder_opus.h index 706280f2e3..d46d2b5770 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus.h +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.h @@ -11,20 +11,27 @@ #ifndef MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ #define MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ +#include +#include #include #include #include #include +#include #include #include "absl/strings/string_view.h" +#include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/opus/audio_encoder_opus_config.h" +#include "api/call/bitrate_allocation.h" #include "api/environment/environment.h" +#include "api/units/time_delta.h" #include "common_audio/smoothing_filter.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" #include "modules/audio_coding/codecs/opus/opus_interface.h" +#include "rtc_base/buffer.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc index d4fe4683e1..1d777112c4 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc @@ -10,17 +10,33 @@ #include "api/audio_codecs/opus/audio_encoder_opus.h" -#include +#include +#include #include +#include +#include #include +#include #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" +#include "api/audio_codecs/opus/audio_encoder_opus_config.h" +#include "api/call/bitrate_allocation.h" #include "api/environment/environment_factory.h" +#include "api/field_trials_view.h" +#include "api/rtp_parameters.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "common_audio/mocks/mock_smoothing_filter.h" +#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" #include "modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h" #include "modules/audio_coding/codecs/opus/audio_encoder_opus.h" #include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/neteq/tools/audio_loop.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/fake_clock.h" #include "test/explicit_key_value_config.h" @@ -614,7 +630,7 @@ TEST(AudioEncoderOpusTest, TestConfigFromParams) { } TEST(AudioEncoderOpusTest, TestConfigFromInvalidParams) { - const webrtc::SdpAudioFormat format("opus", 48000, 2); + const SdpAudioFormat format("opus", 48000, 2); const auto default_config = *AudioEncoderOpus::SdpToConfig(format); #if WEBRTC_OPUS_SUPPORT_120MS_PTIME const std::vector default_supported_frame_lengths_ms({20, 40, 60, 120}); @@ -674,9 +690,8 @@ TEST(AudioEncoderOpusTest, GetFrameLenghtRange) { CreateConfigWithParameters({{"maxptime", "10"}, {"ptime", "10"}}); std::unique_ptr encoder = AudioEncoderOpus::MakeAudioEncoder( CreateEnvironment(), config, {.payload_type = kDefaultOpusPayloadType}); - auto ptime = webrtc::TimeDelta::Millis(10); - std::optional> range = { - {ptime, ptime}}; + auto ptime = TimeDelta::Millis(10); + std::optional> range = {{ptime, ptime}}; EXPECT_EQ(encoder->GetFrameLengthRange(), range); } @@ -769,7 +784,7 @@ TEST_P(AudioEncoderOpusTest, OpusFlagDtxAsNonSpeech) { // Open file containing speech and silence. const std::string kInputFileName = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); test::AudioLoop audio_loop; // Use the file as if it were sampled at our desired input rate. const size_t max_loop_length_samples = diff --git a/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc b/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc index 2d5aa445ee..12783a656d 100644 --- a/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc +++ b/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc @@ -8,14 +8,27 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" +#include "api/audio_codecs/opus/audio_encoder_opus_config.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "common_audio/include/audio_util.h" #include "common_audio/window_generator.h" #include "modules/audio_coding/codecs/opus/test/lapped_transform.h" #include "modules/audio_coding/neteq/tools/audio_loop.h" +#include "rtc_base/buffer.h" #include "test/explicit_key_value_config.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -126,7 +139,7 @@ TEST(BandwidthAdaptationTest, BandwidthAdaptationTest) { // Open speech file. const std::string kInputFileName = - webrtc::test::ResourcePath("audio_coding/speech_mono_32_48kHz", "pcm"); + test::ResourcePath("audio_coding/speech_mono_32_48kHz", "pcm"); test::AudioLoop audio_loop; EXPECT_EQ(kSampleRateHz, encoder->SampleRateHz()); ASSERT_TRUE(audio_loop.Init(kInputFileName, kMaxLoopLengthSamples, diff --git a/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc b/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc index b280ec0b17..bf116813f6 100644 --- a/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc +++ b/modules/audio_coding/codecs/opus/opus_complexity_unittest.cc @@ -8,11 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include + +#include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" +#include "api/audio_codecs/opus/audio_encoder_opus_config.h" +#include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" #include "api/test/metrics/metric.h" #include "modules/audio_coding/neteq/tools/audio_loop.h" +#include "rtc_base/buffer.h" #include "rtc_base/time_utils.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -20,9 +28,9 @@ namespace webrtc { namespace { -using ::webrtc::test::GetGlobalMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::GetGlobalMetricsLogger; +using test::ImprovementDirection; +using test::Unit; int64_t RunComplexityTest(const Environment& env, const AudioEncoderOpusConfig& config) { @@ -31,7 +39,7 @@ int64_t RunComplexityTest(const Environment& env, AudioEncoderOpus::MakeAudioEncoder(env, config, {.payload_type = 17}); // Open speech file. const std::string kInputFileName = - webrtc::test::ResourcePath("audio_coding/speech_mono_32_48kHz", "pcm"); + test::ResourcePath("audio_coding/speech_mono_32_48kHz", "pcm"); test::AudioLoop audio_loop; constexpr int kSampleRateHz = 48000; EXPECT_EQ(kSampleRateHz, encoder->SampleRateHz()); diff --git a/modules/audio_coding/codecs/opus/opus_fec_test.cc b/modules/audio_coding/codecs/opus/opus_fec_test.cc index 815f26e31c..bf38347148 100644 --- a/modules/audio_coding/codecs/opus/opus_fec_test.cc +++ b/modules/audio_coding/codecs/opus/opus_fec_test.cc @@ -8,7 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include +#include +#include #include +#include +#include #include "modules/audio_coding/codecs/opus/opus_interface.h" #include "test/gtest.h" @@ -74,7 +81,7 @@ void OpusFecTest::SetUp() { in_filename_ = test::ResourcePath(get<2>(GetParam()), get<3>(GetParam())); FILE* fp = fopen(in_filename_.c_str(), "rb"); - ASSERT_FALSE(fp == NULL); + ASSERT_FALSE(fp == nullptr); // Obtain file size. fseek(fp, 0, SEEK_END); @@ -128,8 +135,8 @@ OpusFecTest::OpusFecTest() data_pointer_(0), max_bytes_(0), encoded_bytes_(0), - opus_encoder_(NULL), - opus_decoder_(NULL) {} + opus_encoder_(nullptr), + opus_decoder_(nullptr) {} void OpusFecTest::EncodeABlock() { int value = @@ -154,8 +161,8 @@ void OpusFecTest::DecodeABlock(bool lost_previous, bool lost_current) { } else { // Call decoder PLC. while (value_1 < static_cast(block_length_sample_)) { - int ret = WebRtcOpus_Decode(opus_decoder_, NULL, 0, &out_data_[value_1], - &audio_type); + int ret = WebRtcOpus_Decode(opus_decoder_, nullptr, 0, + &out_data_[value_1], &audio_type); EXPECT_EQ(ret, sampling_khz_ * 10); // Should return 10 ms of samples. value_1 += ret; } diff --git a/modules/audio_coding/codecs/opus/opus_inst.h b/modules/audio_coding/codecs/opus/opus_inst.h index f7b45ea69b..6aea55262d 100644 --- a/modules/audio_coding/codecs/opus/opus_inst.h +++ b/modules/audio_coding/codecs/opus/opus_inst.h @@ -16,8 +16,10 @@ #include "rtc_base/ignore_wundef.h" RTC_PUSH_IGNORING_WUNDEF() -#include "third_party/opus/src/include/opus.h" -#include "third_party/opus/src/include/opus_multistream.h" +#include "third_party/opus/src/include/opus.h" // IWYU pragma: export +#include "third_party/opus/src/include/opus_defines.h" // IWYU pragma: export +#include "third_party/opus/src/include/opus_multistream.h" // IWYU pragma: export +#include "third_party/opus/src/include/opus_types.h" // IWYU pragma: export RTC_POP_IGNORING_WUNDEF() struct WebRtcOpusEncInst { diff --git a/modules/audio_coding/codecs/opus/opus_interface.cc b/modules/audio_coding/codecs/opus/opus_interface.cc index d18b517fe4..f934cca073 100644 --- a/modules/audio_coding/codecs/opus/opus_interface.cc +++ b/modules/audio_coding/codecs/opus/opus_interface.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/codecs/opus/opus_interface.h" +#include #include -#include -#include "api/array_view.h" #include "rtc_base/checks.h" enum { @@ -382,10 +381,10 @@ int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int error; OpusDecInst* state; - if (inst != NULL) { + if (inst != nullptr) { // Create Opus decoder state. state = reinterpret_cast(calloc(1, sizeof(OpusDecInst))); - if (state == NULL) { + if (state == nullptr) { return -1; } @@ -419,10 +418,10 @@ int16_t WebRtcOpus_MultistreamDecoderCreate( int error; OpusDecInst* state; - if (inst != NULL) { + if (inst != nullptr) { // Create Opus decoder state. state = reinterpret_cast(calloc(1, sizeof(OpusDecInst))); - if (state == NULL) { + if (state == nullptr) { return -1; } @@ -533,7 +532,7 @@ static int DecodePlc(OpusDecInst* inst, int16_t* decoded) { FrameSizePerChannel(kWebRtcOpusPlcFrameSizeMs, inst->sample_rate_hz); decoded_samples = - DecodeNative(inst, NULL, 0, plc_samples, decoded, &audio_type, 0); + DecodeNative(inst, nullptr, 0, plc_samples, decoded, &audio_type, 0); if (decoded_samples < 0) { return -1; } @@ -679,7 +678,7 @@ int WebRtcOpus_NumSilkFrames(const uint8_t* payload) { // parsing the LP layer of an Opus packet, particularly the LBRR flag. int WebRtcOpus_PacketHasFec(const uint8_t* payload, size_t payload_length_bytes) { - if (payload == NULL || payload_length_bytes == 0) + if (payload == nullptr || payload_length_bytes == 0) return 0; // In CELT_ONLY mode, packets should not have FEC. @@ -700,7 +699,7 @@ int WebRtcOpus_PacketHasFec(const uint8_t* payload, // Parse packet to get the frames. But we only care about the first frame, // since we can only decode the FEC from the first one. if (opus_packet_parse(payload, static_cast(payload_length_bytes), - NULL, frame_data, frame_sizes, NULL) < 0) { + nullptr, frame_data, frame_sizes, nullptr) < 0) { return 0; } @@ -728,7 +727,7 @@ int WebRtcOpus_PacketHasFec(const uint8_t* payload, int WebRtcOpus_PacketHasVoiceActivity(const uint8_t* payload, size_t payload_length_bytes) { - if (payload == NULL || payload_length_bytes == 0) + if (payload == nullptr || payload_length_bytes == 0) return 0; // In CELT_ONLY mode we can not determine whether there is VAD. @@ -749,7 +748,7 @@ int WebRtcOpus_PacketHasVoiceActivity(const uint8_t* payload, // Parse packet to get the frames. int frames = opus_packet_parse(payload, static_cast(payload_length_bytes), - NULL, frame_data, frame_sizes, NULL); + nullptr, frame_data, frame_sizes, nullptr); if (frames < 0) return -1; diff --git a/modules/audio_coding/codecs/opus/opus_interface.h b/modules/audio_coding/codecs/opus/opus_interface.h index dd64e82476..4fb1dff233 100644 --- a/modules/audio_coding/codecs/opus/opus_interface.h +++ b/modules/audio_coding/codecs/opus/opus_interface.h @@ -14,7 +14,7 @@ #include #include -#include "modules/audio_coding/codecs/opus/opus_inst.h" +#include "modules/audio_coding/codecs/opus/opus_inst.h" // IWYU pragma: export #ifdef __cplusplus extern "C" { diff --git a/modules/audio_coding/codecs/opus/opus_speed_test.cc b/modules/audio_coding/codecs/opus/opus_speed_test.cc index 4477e8a5f8..6bc015ff88 100644 --- a/modules/audio_coding/codecs/opus/opus_speed_test.cc +++ b/modules/audio_coding/codecs/opus/opus_speed_test.cc @@ -8,8 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include +#include +#include +#include + #include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h" +#include "test/gtest.h" using ::std::string; @@ -38,8 +46,8 @@ OpusSpeedTest::OpusSpeedTest() : AudioCodecSpeedTest(kOpusBlockDurationMs, kOpusSamplingKhz, kOpusSamplingKhz), - opus_encoder_(NULL), - opus_decoder_(NULL) {} + opus_encoder_(nullptr), + opus_decoder_(nullptr) {} void OpusSpeedTest::SetUp() { AudioCodecSpeedTest::SetUp(); diff --git a/modules/audio_coding/codecs/opus/opus_unittest.cc b/modules/audio_coding/codecs/opus/opus_unittest.cc index 0d04f1dc3b..af00347c3e 100644 --- a/modules/audio_coding/codecs/opus/opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/opus_unittest.cc @@ -8,10 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "opus.h" + +#include +#include +#include +#include +#include #include #include +#include +#include -#include "modules/audio_coding/codecs/opus/opus_inst.h" +#include "api/array_view.h" #include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/neteq/tools/audio_loop.h" #include "rtc_base/checks.h" @@ -175,7 +184,7 @@ void OpusTest::PrepareSpeechData(int block_length_ms, int loop_length_ms) { {4, "audio_coding/speech_4_channels_48k_one_second"}}; std::map channel_to_suffix = { {1, "pcm"}, {2, "pcm"}, {4, "wav"}}; - const std::string file_name = webrtc::test::ResourcePath( + const std::string file_name = test::ResourcePath( channel_to_basename[channels_], channel_to_suffix[channels_]); if (loop_length_ms < block_length_ms) { loop_length_ms = block_length_ms; @@ -231,8 +240,8 @@ int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder, decoder_sample_rate_hz_ / encoder_sample_rate_hz_; while (total_dtx_len < output_samples_per_channel) { - int est_len = WebRtcOpus_DurationEst(decoder, NULL, 0); - int act_len = WebRtcOpus_Decode(decoder, NULL, 0, + int est_len = WebRtcOpus_DurationEst(decoder, nullptr, 0); + int act_len = WebRtcOpus_Decode(decoder, nullptr, 0, &output_audio[total_dtx_len * channels_], audio_type); EXPECT_EQ(est_len, act_len); @@ -467,7 +476,7 @@ TEST(OpusTest, OpusCreateFail) { WebRtcOpusDecInst* opus_decoder; // Test to see that an invalid pointer is caught. - EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(NULL, 1, 0, 48000)); + EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(nullptr, 1, 0, 48000)); // Invalid channel number. EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 257, 0, 48000)); // Invalid applciation mode. @@ -475,7 +484,7 @@ TEST(OpusTest, OpusCreateFail) { // Invalid sample rate. EXPECT_EQ(-1, WebRtcOpus_EncoderCreate(&opus_encoder, 1, 0, 12345)); - EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(NULL, 1, 48000)); + EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(nullptr, 1, 48000)); // Invalid channel number. EXPECT_EQ(-1, WebRtcOpus_DecoderCreate(&opus_decoder, 257, 48000)); // Invalid sample rate. @@ -485,8 +494,8 @@ TEST(OpusTest, OpusCreateFail) { // Test failing Free. TEST(OpusTest, OpusFreeFail) { // Test to see that an invalid pointer is caught. - EXPECT_EQ(-1, WebRtcOpus_EncoderFree(NULL)); - EXPECT_EQ(-1, WebRtcOpus_DecoderFree(NULL)); + EXPECT_EQ(-1, WebRtcOpus_EncoderFree(nullptr)); + EXPECT_EQ(-1, WebRtcOpus_DecoderFree(nullptr)); } // Test normal Create and Free. @@ -495,8 +504,8 @@ TEST_P(OpusTest, OpusCreateFree) { use_multistream_, encoder_sample_rate_hz_); CreateSingleOrMultiStreamDecoder(&opus_decoder_, channels_, use_multistream_, decoder_sample_rate_hz_); - EXPECT_TRUE(opus_encoder_ != NULL); - EXPECT_TRUE(opus_decoder_ != NULL); + EXPECT_TRUE(opus_encoder_ != nullptr); + EXPECT_TRUE(opus_decoder_ != nullptr); // Free encoder and decoder memory. EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); @@ -829,8 +838,8 @@ TEST_P(OpusTest, OpusDecodePlc) { constexpr int kPlcDurationMs = 10; const int plc_samples = decoder_sample_rate_hz_ * kPlcDurationMs / 1000; int16_t* plc_buffer = new int16_t[plc_samples * channels_]; - EXPECT_EQ(plc_samples, - WebRtcOpus_Decode(opus_decoder_, NULL, 0, plc_buffer, &audio_type)); + EXPECT_EQ(plc_samples, WebRtcOpus_Decode(opus_decoder_, nullptr, 0, + plc_buffer, &audio_type)); // Free memory. delete[] plc_buffer; diff --git a/modules/audio_coding/codecs/opus/test/BUILD.gn b/modules/audio_coding/codecs/opus/test/BUILD.gn index 8bc0bf5e0e..0b2fc17a36 100644 --- a/modules/audio_coding/codecs/opus/test/BUILD.gn +++ b/modules/audio_coding/codecs/opus/test/BUILD.gn @@ -47,6 +47,7 @@ if (rtc_include_tests) { ":test", "../../../../../common_audio", "../../../../../common_audio:common_audio_c", + "../../../../../rtc_base:checks", "../../../../../rtc_base:macromagic", "../../../../../test:test_support", "//testing/gtest", diff --git a/modules/audio_coding/codecs/opus/test/audio_ring_buffer.cc b/modules/audio_coding/codecs/opus/test/audio_ring_buffer.cc index 2a71b43d2c..616413a529 100644 --- a/modules/audio_coding/codecs/opus/test/audio_ring_buffer.cc +++ b/modules/audio_coding/codecs/opus/test/audio_ring_buffer.cc @@ -10,6 +10,8 @@ #include "modules/audio_coding/codecs/opus/test/audio_ring_buffer.h" +#include + #include "common_audio/ring_buffer.h" #include "rtc_base/checks.h" diff --git a/modules/audio_coding/codecs/opus/test/audio_ring_buffer.h b/modules/audio_coding/codecs/opus/test/audio_ring_buffer.h index a280ca2410..f73613b7d3 100644 --- a/modules/audio_coding/codecs/opus/test/audio_ring_buffer.h +++ b/modules/audio_coding/codecs/opus/test/audio_ring_buffer.h @@ -12,7 +12,6 @@ #include -#include #include struct RingBuffer; diff --git a/modules/audio_coding/codecs/opus/test/audio_ring_buffer_unittest.cc b/modules/audio_coding/codecs/opus/test/audio_ring_buffer_unittest.cc index 6dbc8ee9fe..617a281b0a 100644 --- a/modules/audio_coding/codecs/opus/test/audio_ring_buffer_unittest.cc +++ b/modules/audio_coding/codecs/opus/test/audio_ring_buffer_unittest.cc @@ -10,6 +10,7 @@ #include "modules/audio_coding/codecs/opus/test/audio_ring_buffer.h" +#include #include #include "common_audio/channel_buffer.h" diff --git a/modules/audio_coding/codecs/opus/test/blocker.h b/modules/audio_coding/codecs/opus/test/blocker.h index 59b7e29621..4f82f6413f 100644 --- a/modules/audio_coding/codecs/opus/test/blocker.h +++ b/modules/audio_coding/codecs/opus/test/blocker.h @@ -11,6 +11,7 @@ #ifndef MODULES_AUDIO_CODING_CODECS_OPUS_TEST_BLOCKER_H_ #define MODULES_AUDIO_CODING_CODECS_OPUS_TEST_BLOCKER_H_ +#include #include #include "common_audio/channel_buffer.h" diff --git a/modules/audio_coding/codecs/opus/test/blocker_unittest.cc b/modules/audio_coding/codecs/opus/test/blocker_unittest.cc index edca73980e..b5a349451c 100644 --- a/modules/audio_coding/codecs/opus/test/blocker_unittest.cc +++ b/modules/audio_coding/codecs/opus/test/blocker_unittest.cc @@ -10,8 +10,11 @@ #include "modules/audio_coding/codecs/opus/test/blocker.h" +#include +#include #include +#include "common_audio/channel_buffer.h" #include "rtc_base/arraysize.h" #include "test/gtest.h" diff --git a/modules/audio_coding/codecs/opus/test/lapped_transform.cc b/modules/audio_coding/codecs/opus/test/lapped_transform.cc index b1a6526bba..405616636c 100644 --- a/modules/audio_coding/codecs/opus/test/lapped_transform.cc +++ b/modules/audio_coding/codecs/opus/test/lapped_transform.cc @@ -10,7 +10,6 @@ #include "modules/audio_coding/codecs/opus/test/lapped_transform.h" -#include #include #include diff --git a/modules/audio_coding/codecs/opus/test/lapped_transform.h b/modules/audio_coding/codecs/opus/test/lapped_transform.h index 5a67d31801..5902abc24c 100644 --- a/modules/audio_coding/codecs/opus/test/lapped_transform.h +++ b/modules/audio_coding/codecs/opus/test/lapped_transform.h @@ -12,10 +12,12 @@ #define MODULES_AUDIO_CODING_CODECS_OPUS_TEST_LAPPED_TRANSFORM_H_ #include +#include #include #include "common_audio/real_fourier.h" #include "modules/audio_coding/codecs/opus/test/blocker.h" +#include "rtc_base/checks.h" #include "rtc_base/memory/aligned_malloc.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/opus/test/lapped_transform_unittest.cc b/modules/audio_coding/codecs/opus/test/lapped_transform_unittest.cc index 8273f8d7f8..4ccba02475 100644 --- a/modules/audio_coding/codecs/opus/test/lapped_transform_unittest.cc +++ b/modules/audio_coding/codecs/opus/test/lapped_transform_unittest.cc @@ -12,8 +12,10 @@ #include #include +#include #include +#include "rtc_base/checks.h" #include "test/gtest.h" using std::complex; diff --git a/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.cc b/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.cc index 79f3562ed9..8007b322a2 100644 --- a/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.cc +++ b/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.cc @@ -10,10 +10,15 @@ #include "modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" +#include +#include #include +#include +#include "api/audio_codecs/audio_decoder.h" #include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { @@ -24,6 +29,7 @@ AudioDecoderPcm16B::AudioDecoderPcm16B(int sample_rate_hz, size_t num_channels) sample_rate_hz == 32000 || sample_rate_hz == 48000) << "Unsupported sample rate " << sample_rate_hz; RTC_DCHECK_GE(num_channels, 1); + RTC_DCHECK_LE(num_channels, AudioDecoder::kMaxNumberOfChannels); } void AudioDecoderPcm16B::Reset() {} diff --git a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc index 9445b1ee3e..d9b4435cca 100644 --- a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc +++ b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc @@ -10,8 +10,12 @@ #include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" +#include +#include + +#include "api/audio_codecs/audio_encoder.h" +#include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" -#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h index c363b40b3f..2d6463707b 100644 --- a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h +++ b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h @@ -11,6 +11,10 @@ #ifndef MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_ENCODER_PCM16B_H_ #define MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_ENCODER_PCM16B_H_ +#include +#include + +#include "api/audio_codecs/audio_encoder.h" #include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc b/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc index ecf91b45ac..28962853e9 100644 --- a/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc +++ b/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc @@ -13,6 +13,9 @@ #include #include +#include + +#include "api/audio_codecs/audio_format.h" namespace webrtc { diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc index 660ab91fa7..725aec0226 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc @@ -12,13 +12,24 @@ #include +#include +#include +#include +#include +#include +#include #include #include #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/call/bitrate_allocation.h" +#include "api/field_trials_view.h" +#include "api/units/time_delta.h" +#include "rtc_base/buffer.h" #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" namespace webrtc { static constexpr const int kRedMaxPacketSize = diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h index 09d21325e2..e5a3d948dd 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h @@ -17,10 +17,12 @@ #include #include #include +#include #include #include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" +#include "api/call/bitrate_allocation.h" #include "api/field_trials_view.h" #include "api/units/time_delta.h" #include "rtc_base/buffer.h" diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc index 92dec2c835..cc791dde44 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc @@ -10,12 +10,20 @@ #include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h" +#include +#include +#include #include +#include +#include #include -#include "rtc_base/checks.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/units/time_delta.h" +#include "rtc_base/buffer.h" #include "rtc_base/numerics/safe_conversions.h" -#include "test/field_trial.h" +#include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" #include "test/scoped_key_value_config.h" @@ -60,7 +68,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test { void TearDown() override { red_.reset(); } void Encode() { - ASSERT_TRUE(red_.get() != NULL); + ASSERT_TRUE(red_.get() != nullptr); encoded_.Clear(); encoded_info_ = red_->Encode( timestamp_, ArrayView(audio_, num_audio_samples_10ms), @@ -199,7 +207,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes1) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 0. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes0) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-0/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; @@ -225,7 +233,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes0) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 2. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes2) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-2/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; @@ -267,7 +275,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes2) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 3. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes3) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-3/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; @@ -481,7 +489,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header) { // Variant with a redundancy of 0. TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header0) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-0/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; @@ -509,7 +517,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header0) { } // Variant with a redundancy of 2. TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header2) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-2/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; @@ -642,9 +650,9 @@ TEST_F(AudioEncoderCopyRedDeathTest, WrongFrameSize) { TEST_F(AudioEncoderCopyRedDeathTest, NullSpeechEncoder) { test::ScopedKeyValueConfig field_trials; - AudioEncoderCopyRed* red = NULL; + AudioEncoderCopyRed* red = nullptr; AudioEncoderCopyRed::Config config; - config.speech_encoder = NULL; + config.speech_encoder = nullptr; RTC_EXPECT_DEATH( red = new AudioEncoderCopyRed(std::move(config), field_trials), "Speech encoder not provided."); diff --git a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc index 537e6fcede..6fb58911b9 100644 --- a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc +++ b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc @@ -10,6 +10,12 @@ #include "modules/audio_coding/codecs/tools/audio_codec_speed_test.h" +#include +#include +#include +#include +#include + #include "rtc_base/checks.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -34,7 +40,7 @@ AudioCodecSpeedTest::AudioCodecSpeedTest(int block_duration_ms, encoded_bytes_(0), encoding_time_ms_(0.0), decoding_time_ms_(0.0), - out_file_(NULL) {} + out_file_(nullptr) {} void AudioCodecSpeedTest::SetUp() { channels_ = get<0>(GetParam()); diff --git a/modules/audio_coding/codecs/tools/audio_codec_speed_test.h b/modules/audio_coding/codecs/tools/audio_codec_speed_test.h index c5f1d7c259..71d80ba73b 100644 --- a/modules/audio_coding/codecs/tools/audio_codec_speed_test.h +++ b/modules/audio_coding/codecs/tools/audio_codec_speed_test.h @@ -11,8 +11,12 @@ #ifndef MODULES_AUDIO_CODING_CODECS_TOOLS_AUDIO_CODEC_SPEED_TEST_H_ #define MODULES_AUDIO_CODING_CODECS_TOOLS_AUDIO_CODEC_SPEED_TEST_H_ +#include +#include +#include #include #include +#include #include "test/gtest.h" diff --git a/modules/audio_coding/include/audio_coding_module.h b/modules/audio_coding/include/audio_coding_module.h index d4a6a39b66..1493034d54 100644 --- a/modules/audio_coding/include/audio_coding_module.h +++ b/modules/audio_coding/include/audio_coding_module.h @@ -11,15 +11,15 @@ #ifndef MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ #define MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ +#include +#include #include -#include -#include #include -#include #include "api/audio_codecs/audio_encoder.h" #include "api/function_view.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/include/audio_coding_module_typedefs.h b/modules/audio_coding/include/audio_coding_module_typedefs.h index f375108195..f0939c5c94 100644 --- a/modules/audio_coding/include/audio_coding_module_typedefs.h +++ b/modules/audio_coding/include/audio_coding_module_typedefs.h @@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_TYPEDEFS_H_ #define MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_TYPEDEFS_H_ -#include +#include namespace webrtc { diff --git a/modules/audio_coding/neteq/accelerate.cc b/modules/audio_coding/neteq/accelerate.cc index c15ab73d67..eda4370541 100644 --- a/modules/audio_coding/neteq/accelerate.cc +++ b/modules/audio_coding/neteq/accelerate.cc @@ -10,8 +10,13 @@ #include "modules/audio_coding/neteq/accelerate.h" +#include +#include + #include "api/array_view.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" +#include "modules/audio_coding/neteq/time_stretch.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/audio_decoder_unittest.cc b/modules/audio_coding/neteq/audio_decoder_unittest.cc index 06a088299c..d8b891298e 100644 --- a/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -8,14 +8,23 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "api/audio_codecs/audio_decoder.h" + #include #include +#include #include -#include +#include +#include +#include #include +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/g722/audio_encoder_g722_config.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" +#include "api/audio_codecs/opus/audio_encoder_opus_config.h" #include "api/environment/environment_factory.h" #include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" #include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" @@ -24,8 +33,10 @@ #include "modules/audio_coding/codecs/opus/audio_decoder_opus.h" #include "modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" #include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" +#include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/audio_coding/neteq/tools/resample_input_audio_file.h" -#include "rtc_base/system/arch.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "test/explicit_key_value_config.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -92,15 +103,14 @@ double MseInputOutput(const std::vector& input, class AudioDecoderTest : public ::testing::Test { protected: AudioDecoderTest() - : input_audio_( - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), - 32000), + : input_audio_(test::ResourcePath("audio_coding/testfile32kHz", "pcm"), + 32000), codec_input_rate_hz_(32000), // Legacy default value. frame_size_(0), data_length_(0), channels_(1), payload_type_(17), - decoder_(NULL) {} + decoder_(nullptr) {} ~AudioDecoderTest() override {} @@ -113,7 +123,7 @@ class AudioDecoderTest : public ::testing::Test { void TearDown() override { delete decoder_; - decoder_ = NULL; + decoder_ = nullptr; } virtual void InitEncoder() {} diff --git a/modules/audio_coding/neteq/audio_multi_vector.cc b/modules/audio_coding/neteq/audio_multi_vector.cc index e86d9356ad..baad7720eb 100644 --- a/modules/audio_coding/neteq/audio_multi_vector.cc +++ b/modules/audio_coding/neteq/audio_multi_vector.cc @@ -11,55 +11,52 @@ #include "modules/audio_coding/neteq/audio_multi_vector.h" #include +#include +#include +#include +#include "api/array_view.h" +#include "api/audio/audio_view.h" +#include "modules/audio_coding/neteq/audio_vector.h" #include "rtc_base/checks.h" namespace webrtc { -AudioMultiVector::AudioMultiVector(size_t N) { +AudioMultiVector::AudioMultiVector(size_t N) : channels_(N) { RTC_DCHECK_GT(N, 0); - if (N < 1) - N = 1; - for (size_t n = 0; n < N; ++n) { - channels_.push_back(new AudioVector); + RTC_DCHECK_LE(N, kMaxNumberOfAudioChannels); + for (auto& c : channels_) { + c.reset(new AudioVector()); } - num_channels_ = N; } -AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) { +AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) + : channels_(N) { RTC_DCHECK_GT(N, 0); - if (N < 1) - N = 1; - for (size_t n = 0; n < N; ++n) { - channels_.push_back(new AudioVector(initial_size)); + RTC_DCHECK_LE(N, kMaxNumberOfAudioChannels); + for (auto& c : channels_) { + c.reset(new AudioVector(initial_size)); } - num_channels_ = N; } -AudioMultiVector::~AudioMultiVector() { - std::vector::iterator it = channels_.begin(); - while (it != channels_.end()) { - delete (*it); - ++it; - } -} +AudioMultiVector::~AudioMultiVector() = default; void AudioMultiVector::Clear() { - for (size_t i = 0; i < num_channels_; ++i) { - channels_[i]->Clear(); + for (auto& c : channels_) { + c->Clear(); } } void AudioMultiVector::Zeros(size_t length) { - for (size_t i = 0; i < num_channels_; ++i) { - channels_[i]->Clear(); - channels_[i]->Extend(length); + for (auto& c : channels_) { + c->Clear(); + c->Extend(length); } } void AudioMultiVector::CopyTo(AudioMultiVector* copy_to) const { if (copy_to) { - for (size_t i = 0; i < num_channels_; ++i) { + for (size_t i = 0; i < Channels(); ++i) { channels_[i]->CopyTo(&(*copy_to)[i]); } } @@ -67,21 +64,21 @@ void AudioMultiVector::CopyTo(AudioMultiVector* copy_to) const { void AudioMultiVector::PushBackInterleaved( ArrayView append_this) { - RTC_DCHECK_EQ(append_this.size() % num_channels_, 0); + RTC_DCHECK_EQ(append_this.size() % Channels(), 0); if (append_this.empty()) { return; } - if (num_channels_ == 1) { + if (Channels() == 1) { // Special case to avoid extra allocation and data shuffling. channels_[0]->PushBack(append_this.data(), append_this.size()); return; } - size_t length_per_channel = append_this.size() / num_channels_; + size_t length_per_channel = append_this.size() / Channels(); int16_t* temp_array = new int16_t[length_per_channel]; // Temporary storage. - for (size_t channel = 0; channel < num_channels_; ++channel) { + for (size_t channel = 0; channel < Channels(); ++channel) { // Copy elements to `temp_array`. for (size_t i = 0; i < length_per_channel; ++i) { - temp_array[i] = append_this[channel + i * num_channels_]; + temp_array[i] = append_this[channel + i * Channels()]; } channels_[channel]->PushBack(temp_array, length_per_channel); } @@ -89,9 +86,9 @@ void AudioMultiVector::PushBackInterleaved( } void AudioMultiVector::PushBack(const AudioMultiVector& append_this) { - RTC_DCHECK_EQ(num_channels_, append_this.num_channels_); - if (num_channels_ == append_this.num_channels_) { - for (size_t i = 0; i < num_channels_; ++i) { + RTC_DCHECK_EQ(Channels(), append_this.Channels()); + if (Channels() == append_this.Channels()) { + for (size_t i = 0; i < Channels(); ++i) { channels_[i]->PushBack(append_this[i]); } } @@ -102,23 +99,23 @@ void AudioMultiVector::PushBackFromIndex(const AudioMultiVector& append_this, RTC_DCHECK_LT(index, append_this.Size()); index = std::min(index, append_this.Size() - 1); size_t length = append_this.Size() - index; - RTC_DCHECK_EQ(num_channels_, append_this.num_channels_); - if (num_channels_ == append_this.num_channels_) { - for (size_t i = 0; i < num_channels_; ++i) { + RTC_DCHECK_EQ(Channels(), append_this.Channels()); + if (Channels() == append_this.Channels()) { + for (size_t i = 0; i < Channels(); ++i) { channels_[i]->PushBack(append_this[i], length, index); } } } void AudioMultiVector::PopFront(size_t length) { - for (size_t i = 0; i < num_channels_; ++i) { - channels_[i]->PopFront(length); + for (auto& c : channels_) { + c->PopFront(length); } } void AudioMultiVector::PopBack(size_t length) { - for (size_t i = 0; i < num_channels_; ++i) { - channels_[i]->PopBack(length); + for (auto& c : channels_) { + c->PopBack(length); } } @@ -137,13 +134,13 @@ size_t AudioMultiVector::ReadInterleavedFromIndex(size_t start_index, if (length + start_index > Size()) { length = Size() - start_index; } - if (num_channels_ == 1) { + if (Channels() == 1) { // Special case to avoid the nested for loop below. (*this)[0].CopyTo(length, start_index, destination); return length; } for (size_t i = 0; i < length; ++i) { - for (size_t channel = 0; channel < num_channels_; ++channel) { + for (size_t channel = 0; channel < Channels(); ++channel) { destination[index] = (*this)[channel][i + start_index]; ++index; } @@ -160,12 +157,12 @@ size_t AudioMultiVector::ReadInterleavedFromEnd(size_t length, void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this, size_t length, size_t position) { - RTC_DCHECK_EQ(num_channels_, insert_this.num_channels_); + RTC_DCHECK_EQ(Channels(), insert_this.Channels()); // Cap `length` at the length of `insert_this`. RTC_DCHECK_LE(length, insert_this.Size()); length = std::min(length, insert_this.Size()); - if (num_channels_ == insert_this.num_channels_) { - for (size_t i = 0; i < num_channels_; ++i) { + if (Channels() == insert_this.Channels()) { + for (size_t i = 0; i < Channels(); ++i) { channels_[i]->OverwriteAt(insert_this[i], length, position); } } @@ -173,16 +170,16 @@ void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this, void AudioMultiVector::CrossFade(const AudioMultiVector& append_this, size_t fade_length) { - RTC_DCHECK_EQ(num_channels_, append_this.num_channels_); - if (num_channels_ == append_this.num_channels_) { - for (size_t i = 0; i < num_channels_; ++i) { + RTC_DCHECK_EQ(Channels(), append_this.Channels()); + if (Channels() == append_this.Channels()) { + for (size_t i = 0; i < Channels(); ++i) { channels_[i]->CrossFade(append_this[i], fade_length); } } } size_t AudioMultiVector::Channels() const { - return num_channels_; + return channels_.size(); } size_t AudioMultiVector::Size() const { @@ -193,8 +190,8 @@ size_t AudioMultiVector::Size() const { void AudioMultiVector::AssertSize(size_t required_size) { if (Size() < required_size) { size_t extend_length = required_size - Size(); - for (size_t channel = 0; channel < num_channels_; ++channel) { - channels_[channel]->Extend(extend_length); + for (auto& c : channels_) { + c->Extend(extend_length); } } } @@ -205,9 +202,9 @@ bool AudioMultiVector::Empty() const { } void AudioMultiVector::CopyChannel(size_t from_channel, size_t to_channel) { - RTC_DCHECK_LT(from_channel, num_channels_); - RTC_DCHECK_LT(to_channel, num_channels_); - channels_[from_channel]->CopyTo(channels_[to_channel]); + RTC_DCHECK_LT(from_channel, Channels()); + RTC_DCHECK_LT(to_channel, Channels()); + channels_[from_channel]->CopyTo(channels_[to_channel].get()); } const AudioVector& AudioMultiVector::operator[](size_t index) const { diff --git a/modules/audio_coding/neteq/audio_multi_vector.h b/modules/audio_coding/neteq/audio_multi_vector.h index 6cb4def994..b98e870f82 100644 --- a/modules/audio_coding/neteq/audio_multi_vector.h +++ b/modules/audio_coding/neteq/audio_multi_vector.h @@ -14,6 +14,7 @@ #include #include +#include #include #include "api/array_view.h" @@ -21,6 +22,7 @@ namespace webrtc { +// TODO: b/335805780 - Update to use InterleavedView. class AudioMultiVector { public: // Creates an empty AudioMultiVector with `N` audio channels. `N` must be @@ -37,16 +39,16 @@ class AudioMultiVector { AudioMultiVector& operator=(const AudioMultiVector&) = delete; // Deletes all values and make the vector empty. - virtual void Clear(); + void Clear(); // Clears the vector and inserts `length` zeros into each channel. - virtual void Zeros(size_t length); + void Zeros(size_t length); // Copies all values from this vector to `copy_to`. Any contents in `copy_to` // are deleted. After the operation is done, `copy_to` will be an exact // replica of this object. The source and the destination must have the same // number of channels. - virtual void CopyTo(AudioMultiVector* copy_to) const; + void CopyTo(AudioMultiVector* copy_to) const; // Appends the contents of `append_this` to the end of this object. The array // is assumed to be channel-interleaved. The length must be an even multiple @@ -61,34 +63,32 @@ class AudioMultiVector { // Appends the contents of AudioMultiVector `append_this` to this object, // taken from `index` up until the end of `append_this`. The length of this // object is increased. - virtual void PushBackFromIndex(const AudioMultiVector& append_this, - size_t index); + void PushBackFromIndex(const AudioMultiVector& append_this, size_t index); // Removes `length` elements from the beginning of this object, from each // channel. - virtual void PopFront(size_t length); + void PopFront(size_t length); // Removes `length` elements from the end of this object, from each // channel. - virtual void PopBack(size_t length); + void PopBack(size_t length); // Reads `length` samples from each channel and writes them interleaved to // `destination`. The total number of elements written to `destination` is // returned, i.e., `length` * number of channels. If the AudioMultiVector // contains less than `length` samples per channel, this is reflected in the // return value. - virtual size_t ReadInterleaved(size_t length, int16_t* destination) const; + size_t ReadInterleaved(size_t length, int16_t* destination) const; // Like ReadInterleaved() above, but reads from `start_index` instead of from // the beginning. - virtual size_t ReadInterleavedFromIndex(size_t start_index, - size_t length, - int16_t* destination) const; + size_t ReadInterleavedFromIndex(size_t start_index, + size_t length, + int16_t* destination) const; // Like ReadInterleaved() above, but reads from the end instead of from // the beginning. - virtual size_t ReadInterleavedFromEnd(size_t length, - int16_t* destination) const; + size_t ReadInterleavedFromEnd(size_t length, int16_t* destination) const; // Overwrites each channel in this AudioMultiVector with values taken from // `insert_this`. The values are taken from the beginning of `insert_this` and @@ -97,32 +97,31 @@ class AudioMultiVector { // extends beyond the end of the current AudioVector, the vector is extended // to accommodate the new data. `length` is limited to the length of // `insert_this`. - virtual void OverwriteAt(const AudioMultiVector& insert_this, - size_t length, - size_t position); + void OverwriteAt(const AudioMultiVector& insert_this, + size_t length, + size_t position); // Appends `append_this` to the end of the current vector. Lets the two // vectors overlap by `fade_length` samples (per channel), and cross-fade // linearly in this region. - virtual void CrossFade(const AudioMultiVector& append_this, - size_t fade_length); + void CrossFade(const AudioMultiVector& append_this, size_t fade_length); // Returns the number of channels. - virtual size_t Channels() const; + size_t Channels() const; // Returns the number of elements per channel in this AudioMultiVector. - virtual size_t Size() const; + size_t Size() const; // Verify that each channel can hold at least `required_size` elements. If // not, extend accordingly. - virtual void AssertSize(size_t required_size); + void AssertSize(size_t required_size); - virtual bool Empty() const; + bool Empty() const; // Copies the data between two channels in the AudioMultiVector. The method // does not add any new channel. Thus, `from_channel` and `to_channel` must // both be valid channel numbers. - virtual void CopyChannel(size_t from_channel, size_t to_channel); + void CopyChannel(size_t from_channel, size_t to_channel); // Accesses and modifies a channel (i.e., an AudioVector object) of this // AudioMultiVector. @@ -130,8 +129,7 @@ class AudioMultiVector { AudioVector& operator[](size_t index); protected: - std::vector channels_; - size_t num_channels_; + std::vector> channels_; }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc index eaf31476b3..61938476ee 100644 --- a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc +++ b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc @@ -12,9 +12,11 @@ #include -#include +#include +#include #include +#include "modules/audio_coding/neteq/audio_vector.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/gtest.h" @@ -118,7 +120,7 @@ TEST_P(AudioMultiVectorTest, PushBackInterleavedAndCopy) { // Try to copy to a NULL pointer. Nothing should happen. TEST_P(AudioMultiVectorTest, CopyToNull) { AudioMultiVector vec(num_channels_); - AudioMultiVector* vec_copy = NULL; + AudioMultiVector* vec_copy = nullptr; vec.PushBackInterleaved(array_interleaved_); vec.CopyTo(vec_copy); } diff --git a/modules/audio_coding/neteq/audio_vector.cc b/modules/audio_coding/neteq/audio_vector.cc index 89105949d5..afbd6d4e41 100644 --- a/modules/audio_coding/neteq/audio_vector.cc +++ b/modules/audio_coding/neteq/audio_vector.cc @@ -11,6 +11,9 @@ #include "modules/audio_coding/neteq/audio_vector.h" #include +#include +#include +#include #include #include "rtc_base/checks.h" diff --git a/modules/audio_coding/neteq/audio_vector.h b/modules/audio_coding/neteq/audio_vector.h index d68f3ec6be..6b37aedf5f 100644 --- a/modules/audio_coding/neteq/audio_vector.h +++ b/modules/audio_coding/neteq/audio_vector.h @@ -20,7 +20,7 @@ namespace webrtc { -class AudioVector { +class AudioVector final { public: // Creates an empty AudioVector. AudioVector(); @@ -28,91 +28,85 @@ class AudioVector { // Creates an AudioVector with an initial size. explicit AudioVector(size_t initial_size); - virtual ~AudioVector(); + ~AudioVector(); AudioVector(const AudioVector&) = delete; AudioVector& operator=(const AudioVector&) = delete; // Deletes all values and make the vector empty. - virtual void Clear(); + void Clear(); // Copies all values from this vector to `copy_to`. Any contents in `copy_to` // are deleted before the copy operation. After the operation is done, // `copy_to` will be an exact replica of this object. - virtual void CopyTo(AudioVector* copy_to) const; + void CopyTo(AudioVector* copy_to) const; // Copies `length` values from `position` in this vector to `copy_to`. - virtual void CopyTo(size_t length, size_t position, int16_t* copy_to) const; + void CopyTo(size_t length, size_t position, int16_t* copy_to) const; // Prepends the contents of AudioVector `prepend_this` to this object. The // length of this object is increased with the length of `prepend_this`. - virtual void PushFront(const AudioVector& prepend_this); + void PushFront(const AudioVector& prepend_this); // Same as above, but with an array `prepend_this` with `length` elements as // source. - virtual void PushFront(const int16_t* prepend_this, size_t length); + void PushFront(const int16_t* prepend_this, size_t length); // Same as PushFront but will append to the end of this object. - virtual void PushBack(const AudioVector& append_this); + void PushBack(const AudioVector& append_this); // Appends a segment of `append_this` to the end of this object. The segment // starts from `position` and has `length` samples. - virtual void PushBack(const AudioVector& append_this, - size_t length, - size_t position); + void PushBack(const AudioVector& append_this, size_t length, size_t position); // Same as PushFront but will append to the end of this object. - virtual void PushBack(const int16_t* append_this, size_t length); + void PushBack(const int16_t* append_this, size_t length); // Removes `length` elements from the beginning of this object. - virtual void PopFront(size_t length); + void PopFront(size_t length); // Removes `length` elements from the end of this object. - virtual void PopBack(size_t length); + void PopBack(size_t length); // Extends this object with `extra_length` elements at the end. The new // elements are initialized to zero. - virtual void Extend(size_t extra_length); + void Extend(size_t extra_length); // Inserts `length` elements taken from the array `insert_this` and insert // them at `position`. The length of the AudioVector is increased by `length`. // `position` = 0 means that the new values are prepended to the vector. // `position` = Size() means that the new values are appended to the vector. - virtual void InsertAt(const int16_t* insert_this, - size_t length, - size_t position); + void InsertAt(const int16_t* insert_this, size_t length, size_t position); // Like InsertAt, but inserts `length` zero elements at `position`. - virtual void InsertZerosAt(size_t length, size_t position); + void InsertZerosAt(size_t length, size_t position); // Overwrites `length` elements of this AudioVector starting from `position` // with first values in `AudioVector`. The definition of `position` // is the same as for InsertAt(). If `length` and `position` are selected // such that the new data extends beyond the end of the current AudioVector, // the vector is extended to accommodate the new data. - virtual void OverwriteAt(const AudioVector& insert_this, - size_t length, - size_t position); + void OverwriteAt(const AudioVector& insert_this, + size_t length, + size_t position); // Overwrites `length` elements of this AudioVector with values taken from the // array `insert_this`, starting at `position`. The definition of `position` // is the same as for InsertAt(). If `length` and `position` are selected // such that the new data extends beyond the end of the current AudioVector, // the vector is extended to accommodate the new data. - virtual void OverwriteAt(const int16_t* insert_this, - size_t length, - size_t position); + void OverwriteAt(const int16_t* insert_this, size_t length, size_t position); // Appends `append_this` to the end of the current vector. Lets the two // vectors overlap by `fade_length` samples, and cross-fade linearly in this // region. - virtual void CrossFade(const AudioVector& append_this, size_t fade_length); + void CrossFade(const AudioVector& append_this, size_t fade_length); // Returns the number of elements in this AudioVector. - virtual size_t Size() const; + size_t Size() const; // Returns true if this AudioVector is empty. - virtual bool Empty() const; + bool Empty() const; // Accesses and modifies an element of AudioVector. inline const int16_t& operator[](size_t index) const { diff --git a/modules/audio_coding/neteq/audio_vector_unittest.cc b/modules/audio_coding/neteq/audio_vector_unittest.cc index 8221a5f6c7..97c1b7e10e 100644 --- a/modules/audio_coding/neteq/audio_vector_unittest.cc +++ b/modules/audio_coding/neteq/audio_vector_unittest.cc @@ -12,7 +12,7 @@ #include -#include +#include #include "rtc_base/numerics/safe_conversions.h" #include "test/gtest.h" diff --git a/modules/audio_coding/neteq/background_noise.cc b/modules/audio_coding/neteq/background_noise.cc index 812d656c96..50c622eb21 100644 --- a/modules/audio_coding/neteq/background_noise.cc +++ b/modules/audio_coding/neteq/background_noise.cc @@ -13,10 +13,15 @@ #include // memcpy #include // min, max +#include +#include "api/array_view.h" +#include "common_audio/signal_processing/dot_product_with_scale.h" #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "common_audio/signal_processing/include/spl_inl.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/cross_correlation.h" +#include "rtc_base/checks.h" namespace webrtc { namespace { diff --git a/modules/audio_coding/neteq/background_noise.h b/modules/audio_coding/neteq/background_noise.h index ef2f9cb966..1a506a195b 100644 --- a/modules/audio_coding/neteq/background_noise.h +++ b/modules/audio_coding/neteq/background_noise.h @@ -13,6 +13,7 @@ #include // size_t +#include #include #include "api/array_view.h" diff --git a/modules/audio_coding/neteq/background_noise_unittest.cc b/modules/audio_coding/neteq/background_noise_unittest.cc index e32492f57e..16b0051277 100644 --- a/modules/audio_coding/neteq/background_noise_unittest.cc +++ b/modules/audio_coding/neteq/background_noise_unittest.cc @@ -12,6 +12,8 @@ #include "modules/audio_coding/neteq/background_noise.h" +#include + #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/buffer_level_filter.cc b/modules/audio_coding/neteq/buffer_level_filter.cc index 79789feffc..d2070a4bae 100644 --- a/modules/audio_coding/neteq/buffer_level_filter.cc +++ b/modules/audio_coding/neteq/buffer_level_filter.cc @@ -13,6 +13,7 @@ #include #include +#include #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/neteq/comfort_noise.cc b/modules/audio_coding/neteq/comfort_noise.cc index 49ba21e6de..da94881585 100644 --- a/modules/audio_coding/neteq/comfort_noise.cc +++ b/modules/audio_coding/neteq/comfort_noise.cc @@ -10,6 +10,7 @@ #include "modules/audio_coding/neteq/comfort_noise.h" +#include #include #include @@ -20,7 +21,6 @@ #include "modules/audio_coding/neteq/decoder_database.h" #include "modules/audio_coding/neteq/dsp_helper.h" #include "modules/audio_coding/neteq/sync_buffer.h" -#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/modules/audio_coding/neteq/comfort_noise_unittest.cc b/modules/audio_coding/neteq/comfort_noise_unittest.cc index b436800061..7b376d1f50 100644 --- a/modules/audio_coding/neteq/comfort_noise_unittest.cc +++ b/modules/audio_coding/neteq/comfort_noise_unittest.cc @@ -14,6 +14,7 @@ #include "modules/audio_coding/neteq/mock/mock_decoder_database.h" #include "modules/audio_coding/neteq/sync_buffer.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/cross_correlation.cc b/modules/audio_coding/neteq/cross_correlation.cc index 37ed9374f0..121ba210fc 100644 --- a/modules/audio_coding/neteq/cross_correlation.cc +++ b/modules/audio_coding/neteq/cross_correlation.cc @@ -10,10 +10,11 @@ #include "modules/audio_coding/neteq/cross_correlation.h" +#include #include -#include #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "common_audio/signal_processing/include/spl_inl.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/decision_logic_unittest.cc b/modules/audio_coding/neteq/decision_logic_unittest.cc index 2d3170b9ec..363b45c83b 100644 --- a/modules/audio_coding/neteq/decision_logic_unittest.cc +++ b/modules/audio_coding/neteq/decision_logic_unittest.cc @@ -12,6 +12,11 @@ #include "modules/audio_coding/neteq/decision_logic.h" +#include +#include +#include + +#include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/delay_manager.h" @@ -19,6 +24,7 @@ #include "modules/audio_coding/neteq/mock/mock_delay_manager.h" #include "modules/audio_coding/neteq/mock/mock_packet_arrival_history.h" #include "test/explicit_key_value_config.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/decoder_database.cc b/modules/audio_coding/neteq/decoder_database.cc index 821efec811..dbeba60171 100644 --- a/modules/audio_coding/neteq/decoder_database.cc +++ b/modules/audio_coding/neteq/decoder_database.cc @@ -14,13 +14,22 @@ #include #include -#include +#include +#include #include +#include #include "absl/strings/match.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.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" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" +#include "api/scoped_refptr.h" +#include "modules/audio_coding/codecs/cng/webrtc_cng.h" +#include "modules/audio_coding/neteq/packet.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -179,7 +188,7 @@ const DecoderDatabase::DecoderInfo* DecoderDatabase::GetDecoderInfo( DecoderMap::const_iterator it = decoders_.find(rtp_payload_type); if (it == decoders_.end()) { // Decoder not found. - return NULL; + return nullptr; } return &it->second; } @@ -212,7 +221,7 @@ int DecoderDatabase::SetActiveDecoder(uint8_t rtp_payload_type, AudioDecoder* DecoderDatabase::GetActiveDecoder() const { if (active_decoder_type_ < 0) { // No active decoder. - return NULL; + return nullptr; } return GetDecoder(active_decoder_type_); } @@ -237,7 +246,7 @@ int DecoderDatabase::SetActiveCngDecoder(uint8_t rtp_payload_type) { ComfortNoiseDecoder* DecoderDatabase::GetActiveCngDecoder() const { if (active_cng_decoder_type_ < 0) { // No active CNG decoder. - return NULL; + return nullptr; } if (!active_cng_decoder_) { active_cng_decoder_.reset(new ComfortNoiseDecoder); diff --git a/modules/audio_coding/neteq/decoder_database.h b/modules/audio_coding/neteq/decoder_database.h index 9c1a1ec1ef..a8970d393d 100644 --- a/modules/audio_coding/neteq/decoder_database.h +++ b/modules/audio_coding/neteq/decoder_database.h @@ -11,17 +11,23 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ #define MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ +#include #include #include +#include #include +#include #include "absl/strings/string_view.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" #include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/scoped_refptr.h" #include "modules/audio_coding/codecs/cng/webrtc_cng.h" #include "modules/audio_coding/neteq/packet.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/decoder_database_unittest.cc b/modules/audio_coding/neteq/decoder_database_unittest.cc index e11b38070e..6df9ab3892 100644 --- a/modules/audio_coding/neteq/decoder_database_unittest.cc +++ b/modules/audio_coding/neteq/decoder_database_unittest.cc @@ -12,11 +12,19 @@ #include +#include +#include #include +#include #include "absl/memory/memory.h" +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment_factory.h" +#include "api/make_ref_counted.h" +#include "modules/audio_coding/codecs/cng/webrtc_cng.h" +#include "modules/audio_coding/neteq/packet.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_decoder.h" @@ -80,12 +88,12 @@ TEST(DecoderDatabase, GetDecoderInfo) { db.RegisterPayload(kPayloadType, SdpAudioFormat(kCodecName, 8000, 1))); const DecoderDatabase::DecoderInfo* info; info = db.GetDecoderInfo(kPayloadType); - ASSERT_TRUE(info != NULL); + ASSERT_TRUE(info != nullptr); EXPECT_TRUE(info->IsType("pcmu")); EXPECT_EQ(kCodecName, info->get_name()); EXPECT_EQ(decoder, db.GetDecoder(kPayloadType)); info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. - EXPECT_TRUE(info == NULL); // Should not be found. + EXPECT_TRUE(info == nullptr); // Should not be found. } TEST(DecoderDatabase, GetDecoder) { @@ -95,7 +103,7 @@ TEST(DecoderDatabase, GetDecoder) { EXPECT_EQ(DecoderDatabase::kOK, db.RegisterPayload(kPayloadType, SdpAudioFormat("l16", 8000, 1))); AudioDecoder* dec = db.GetDecoder(kPayloadType); - ASSERT_TRUE(dec != NULL); + ASSERT_TRUE(dec != nullptr); } TEST(DecoderDatabase, TypeTests) { @@ -185,40 +193,40 @@ TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) { ASSERT_EQ(DecoderDatabase::kOK, db.RegisterPayload(13, SdpAudioFormat("cn", 8000, 1))); // Verify that no decoders are active from the start. - EXPECT_EQ(NULL, db.GetActiveDecoder()); - EXPECT_EQ(NULL, db.GetActiveCngDecoder()); + EXPECT_EQ(nullptr, db.GetActiveDecoder()); + EXPECT_EQ(nullptr, db.GetActiveCngDecoder()); // Set active speech codec. bool changed; // Should be true when the active decoder changed. EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(0, &changed)); EXPECT_TRUE(changed); AudioDecoder* decoder = db.GetActiveDecoder(); - ASSERT_FALSE(decoder == NULL); // Should get a decoder here. + ASSERT_FALSE(decoder == nullptr); // Should get a decoder here. // Set the same again. Expect no change. EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(0, &changed)); EXPECT_FALSE(changed); decoder = db.GetActiveDecoder(); - ASSERT_FALSE(decoder == NULL); // Should get a decoder here. + ASSERT_FALSE(decoder == nullptr); // Should get a decoder here. // Change active decoder. EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveDecoder(103, &changed)); EXPECT_TRUE(changed); decoder = db.GetActiveDecoder(); - ASSERT_FALSE(decoder == NULL); // Should get a decoder here. + ASSERT_FALSE(decoder == nullptr); // Should get a decoder here. // Remove the active decoder, and verify that the active becomes NULL. EXPECT_EQ(DecoderDatabase::kOK, db.Remove(103)); - EXPECT_EQ(NULL, db.GetActiveDecoder()); + EXPECT_EQ(nullptr, db.GetActiveDecoder()); // Set active CNG codec. EXPECT_EQ(DecoderDatabase::kOK, db.SetActiveCngDecoder(13)); ComfortNoiseDecoder* cng = db.GetActiveCngDecoder(); - ASSERT_FALSE(cng == NULL); // Should get a decoder here. + ASSERT_FALSE(cng == nullptr); // Should get a decoder here. // Remove the active CNG decoder, and verify that the active becomes NULL. EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); - EXPECT_EQ(NULL, db.GetActiveCngDecoder()); + EXPECT_EQ(nullptr, db.GetActiveCngDecoder()); // Try to set non-existing codecs as active. EXPECT_EQ(DecoderDatabase::kDecoderNotFound, diff --git a/modules/audio_coding/neteq/dsp_helper.cc b/modules/audio_coding/neteq/dsp_helper.cc index a979f94214..af3edcb103 100644 --- a/modules/audio_coding/neteq/dsp_helper.cc +++ b/modules/audio_coding/neteq/dsp_helper.cc @@ -13,8 +13,12 @@ #include // Access to memset. #include // Access to min, max. +#include #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "modules/audio_coding/neteq/audio_multi_vector.h" +#include "modules/audio_coding/neteq/audio_vector.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/dsp_helper_unittest.cc b/modules/audio_coding/neteq/dsp_helper_unittest.cc index 09247417d3..5f03d81a1b 100644 --- a/modules/audio_coding/neteq/dsp_helper_unittest.cc +++ b/modules/audio_coding/neteq/dsp_helper_unittest.cc @@ -10,6 +10,8 @@ #include "modules/audio_coding/neteq/dsp_helper.h" +#include + #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "test/gtest.h" diff --git a/modules/audio_coding/neteq/dtmf_buffer.cc b/modules/audio_coding/neteq/dtmf_buffer.cc index 9f78aca6e2..5813f6df9a 100644 --- a/modules/audio_coding/neteq/dtmf_buffer.cc +++ b/modules/audio_coding/neteq/dtmf_buffer.cc @@ -11,6 +11,8 @@ #include "modules/audio_coding/neteq/dtmf_buffer.h" #include // max +#include +#include #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/modules/audio_coding/neteq/dtmf_buffer_unittest.cc b/modules/audio_coding/neteq/dtmf_buffer_unittest.cc index 83745b6c09..cd66116158 100644 --- a/modules/audio_coding/neteq/dtmf_buffer_unittest.cc +++ b/modules/audio_coding/neteq/dtmf_buffer_unittest.cc @@ -10,14 +10,14 @@ #include "modules/audio_coding/neteq/dtmf_buffer.h" +#include + #ifdef WIN32 #include // ntohl() #else -#include // ntohl() #endif -#include - +#include "rtc_base/ip_address.h" #include "test/gtest.h" // Modify the tests so that they pass with the modifications done to DtmfBuffer diff --git a/modules/audio_coding/neteq/dtmf_tone_generator.cc b/modules/audio_coding/neteq/dtmf_tone_generator.cc index 9061e27c67..01f6ead3d9 100644 --- a/modules/audio_coding/neteq/dtmf_tone_generator.cc +++ b/modules/audio_coding/neteq/dtmf_tone_generator.cc @@ -30,6 +30,10 @@ #include "modules/audio_coding/neteq/dtmf_tone_generator.h" +#include +#include + +#include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/audio_vector.h" #include "rtc_base/arraysize.h" #include "rtc_base/checks.h" diff --git a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc index 989fe05a11..7a7d65aeff 100644 --- a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc +++ b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc @@ -14,6 +14,9 @@ #include +#include +#include + #include "common_audio/include/audio_util.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "rtc_base/strings/string_builder.h" @@ -44,7 +47,7 @@ class DtmfToneGeneratorTest : public ::testing::Test { double f1 = kLowFreqHz[event]; double f2 = kHighFreqHz[event]; - const double pi = 3.14159265358979323846; + const double pi = std::numbers::pi; for (int n = 0; n < kNumSamples; ++n) { double x = k3dbAttenuation * sin(2.0 * pi * f1 / fs_hz * (-n - 1)) + @@ -174,7 +177,7 @@ TEST(DtmfToneGenerator, TestErrors) { EXPECT_TRUE(tone_gen.initialized()); // NULL pointer to destination. EXPECT_EQ(DtmfToneGenerator::kParameterError, - tone_gen.Generate(kNumSamples, NULL)); + tone_gen.Generate(kNumSamples, nullptr)); } } // namespace webrtc diff --git a/modules/audio_coding/neteq/expand.h b/modules/audio_coding/neteq/expand.h index bd58788ae0..09ff46d5d0 100644 --- a/modules/audio_coding/neteq/expand.h +++ b/modules/audio_coding/neteq/expand.h @@ -11,9 +11,12 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ #define MODULES_AUDIO_CODING_NETEQ_EXPAND_H_ +#include +#include #include #include "modules/audio_coding/neteq/audio_vector.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/expand_uma_logger.cc b/modules/audio_coding/neteq/expand_uma_logger.cc index e735a45636..282a6e3895 100644 --- a/modules/audio_coding/neteq/expand_uma_logger.cc +++ b/modules/audio_coding/neteq/expand_uma_logger.cc @@ -9,7 +9,12 @@ #include "modules/audio_coding/neteq/expand_uma_logger.h" +#include +#include +#include + #include "absl/strings/string_view.h" +#include "api/neteq/tick_timer.h" #include "rtc_base/checks.h" #include "system_wrappers/include/metrics.h" diff --git a/modules/audio_coding/neteq/expand_unittest.cc b/modules/audio_coding/neteq/expand_unittest.cc index 4a63a020f2..6e2c28327c 100644 --- a/modules/audio_coding/neteq/expand_unittest.cc +++ b/modules/audio_coding/neteq/expand_unittest.cc @@ -12,7 +12,11 @@ #include "modules/audio_coding/neteq/expand.h" -#include "common_audio/signal_processing/include/signal_processing_library.h" +#include +#include +#include + +#include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/background_noise.h" #include "modules/audio_coding/neteq/random_vector.h" #include "modules/audio_coding/neteq/statistics_calculator.h" @@ -46,7 +50,7 @@ TEST(Expand, CreateUsingFactory) { ExpandFactory expand_factory; Expand* expand = expand_factory.Create(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels); - EXPECT_TRUE(expand != NULL); + EXPECT_TRUE(expand != nullptr); delete expand; } diff --git a/modules/audio_coding/neteq/histogram.cc b/modules/audio_coding/neteq/histogram.cc index 825c8ac349..454f3112a4 100644 --- a/modules/audio_coding/neteq/histogram.cc +++ b/modules/audio_coding/neteq/histogram.cc @@ -11,12 +11,11 @@ #include "modules/audio_coding/neteq/histogram.h" #include +#include #include -#include #include #include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/histogram_unittest.cc b/modules/audio_coding/neteq/histogram_unittest.cc index e30a2956dc..793c40b826 100644 --- a/modules/audio_coding/neteq/histogram_unittest.cc +++ b/modules/audio_coding/neteq/histogram_unittest.cc @@ -11,6 +11,8 @@ #include "modules/audio_coding/neteq/histogram.h" #include +#include +#include #include "test/gtest.h" diff --git a/modules/audio_coding/neteq/merge.cc b/modules/audio_coding/neteq/merge.cc index 17767975d7..e6a05ae587 100644 --- a/modules/audio_coding/neteq/merge.cc +++ b/modules/audio_coding/neteq/merge.cc @@ -13,14 +13,20 @@ #include // memmove, memcpy, memset, size_t #include // min, max +#include +#include #include +#include "api/array_view.h" +#include "common_audio/signal_processing/dot_product_with_scale.h" #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "common_audio/signal_processing/include/spl_inl.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/cross_correlation.h" #include "modules/audio_coding/neteq/dsp_helper.h" #include "modules/audio_coding/neteq/expand.h" #include "modules/audio_coding/neteq/sync_buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_minmax.h" diff --git a/modules/audio_coding/neteq/merge.h b/modules/audio_coding/neteq/merge.h index 2f27106bfe..89e171f2b3 100644 --- a/modules/audio_coding/neteq/merge.h +++ b/modules/audio_coding/neteq/merge.h @@ -11,6 +11,10 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MERGE_H_ #define MODULES_AUDIO_CODING_NETEQ_MERGE_H_ +#include +#include +#include + #include "modules/audio_coding/neteq/audio_multi_vector.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/merge_unittest.cc b/modules/audio_coding/neteq/merge_unittest.cc index 87740af508..eb5ee93455 100644 --- a/modules/audio_coding/neteq/merge_unittest.cc +++ b/modules/audio_coding/neteq/merge_unittest.cc @@ -12,9 +12,12 @@ #include "modules/audio_coding/neteq/merge.h" -#include +#include +#include +#include #include +#include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/background_noise.h" #include "modules/audio_coding/neteq/expand.h" #include "modules/audio_coding/neteq/random_vector.h" diff --git a/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h b/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h index 503f6ac6bd..b843910883 100644 --- a/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h +++ b/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_BUFFER_LEVEL_FILTER_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_BUFFER_LEVEL_FILTER_H_ +#include + #include "modules/audio_coding/neteq/buffer_level_filter.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_decoder_database.h b/modules/audio_coding/neteq/mock/mock_decoder_database.h index 08e12156df..9fe73dfcc1 100644 --- a/modules/audio_coding/neteq/mock/mock_decoder_database.h +++ b/modules/audio_coding/neteq/mock/mock_decoder_database.h @@ -11,9 +11,13 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DECODER_DATABASE_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DECODER_DATABASE_H_ -#include +#include +#include +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment_factory.h" +#include "modules/audio_coding/codecs/cng/webrtc_cng.h" #include "modules/audio_coding/neteq/decoder_database.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h b/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h index c60c56d36b..2f3c595706 100644 --- a/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h +++ b/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h @@ -11,6 +11,9 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DTMF_BUFFER_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DTMF_BUFFER_H_ +#include +#include + #include "modules/audio_coding/neteq/dtmf_buffer.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h b/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h index 60de167c29..ce37aa7730 100644 --- a/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h +++ b/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h @@ -11,6 +11,9 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DTMF_TONE_GENERATOR_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_DTMF_TONE_GENERATOR_H_ +#include + +#include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/dtmf_tone_generator.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_expand.h b/modules/audio_coding/neteq/mock/mock_expand.h index 9d66779021..59b608b5c1 100644 --- a/modules/audio_coding/neteq/mock/mock_expand.h +++ b/modules/audio_coding/neteq/mock/mock_expand.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXPAND_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_EXPAND_H_ +#include + #include "modules/audio_coding/neteq/expand.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_histogram.h b/modules/audio_coding/neteq/mock/mock_histogram.h index 03abbc1d4b..365a2675d0 100644 --- a/modules/audio_coding/neteq/mock/mock_histogram.h +++ b/modules/audio_coding/neteq/mock/mock_histogram.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_HISTOGRAM_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_HISTOGRAM_H_ +#include + #include "modules/audio_coding/neteq/histogram.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_neteq_controller.h b/modules/audio_coding/neteq/mock/mock_neteq_controller.h index ea7809a1b8..fef7c4865e 100644 --- a/modules/audio_coding/neteq/mock/mock_neteq_controller.h +++ b/modules/audio_coding/neteq/mock/mock_neteq_controller.h @@ -11,6 +11,11 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_NETEQ_CONTROLLER_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_NETEQ_CONTROLLER_H_ +#include +#include +#include + +#include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h b/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h index 23731d093b..01fe0e3c7d 100644 --- a/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h +++ b/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_PACKET_ARRIVAL_HISTORY_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_PACKET_ARRIVAL_HISTORY_H_ +#include + #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/packet_arrival_history.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_packet_buffer.h b/modules/audio_coding/neteq/mock/mock_packet_buffer.h index 85bc82bec3..7876ebf6c4 100644 --- a/modules/audio_coding/neteq/mock/mock_packet_buffer.h +++ b/modules/audio_coding/neteq/mock/mock_packet_buffer.h @@ -11,6 +11,11 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_PACKET_BUFFER_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_PACKET_BUFFER_H_ +#include +#include +#include + +#include "modules/audio_coding/neteq/packet.h" #include "modules/audio_coding/neteq/packet_buffer.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_red_payload_splitter.h b/modules/audio_coding/neteq/mock/mock_red_payload_splitter.h index 9daf571a80..6af02c25ce 100644 --- a/modules/audio_coding/neteq/mock/mock_red_payload_splitter.h +++ b/modules/audio_coding/neteq/mock/mock_red_payload_splitter.h @@ -11,6 +11,7 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_RED_PAYLOAD_SPLITTER_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_RED_PAYLOAD_SPLITTER_H_ +#include "modules/audio_coding/neteq/packet.h" #include "modules/audio_coding/neteq/red_payload_splitter.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/mock/mock_statistics_calculator.h b/modules/audio_coding/neteq/mock/mock_statistics_calculator.h index 85c70beb6a..70e7a27e0e 100644 --- a/modules/audio_coding/neteq/mock/mock_statistics_calculator.h +++ b/modules/audio_coding/neteq/mock/mock_statistics_calculator.h @@ -11,6 +11,9 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_STATISTICS_CALCULATOR_H_ #define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_STATISTICS_CALCULATOR_H_ +#include + +#include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/statistics_calculator.h" #include "test/gmock.h" diff --git a/modules/audio_coding/neteq/nack_tracker.cc b/modules/audio_coding/neteq/nack_tracker.cc index f6f6b80dbc..a85c8af984 100644 --- a/modules/audio_coding/neteq/nack_tracker.cc +++ b/modules/audio_coding/neteq/nack_tracker.cc @@ -10,10 +10,14 @@ #include "modules/audio_coding/neteq/nack_tracker.h" +#include #include +#include #include +#include #include "api/field_trials_view.h" +#include "modules/include/module_common_types_public.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/struct_parameters_parser.h" #include "rtc_base/logging.h" diff --git a/modules/audio_coding/neteq/nack_tracker_unittest.cc b/modules/audio_coding/neteq/nack_tracker_unittest.cc index 89d3555b29..716544a75e 100644 --- a/modules/audio_coding/neteq/nack_tracker_unittest.cc +++ b/modules/audio_coding/neteq/nack_tracker_unittest.cc @@ -13,9 +13,10 @@ #include #include +#include #include +#include -#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "test/explicit_key_value_config.h" #include "test/gtest.h" diff --git a/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc b/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc index df22fbdd71..6417cf45e7 100644 --- a/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc +++ b/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc @@ -10,18 +10,28 @@ // Test to verify correct operation when using the decoder-internal PLC. +#include +#include #include #include +#include #include #include +#include "api/array_view.h" +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_format.h" +#include "api/make_ref_counted.h" +#include "api/neteq/neteq.h" +#include "api/rtp_headers.h" #include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" #include "modules/audio_coding/neteq/tools/audio_checksum.h" -#include "modules/audio_coding/neteq/tools/audio_sink.h" #include "modules/audio_coding/neteq/tools/encode_neteq_input.h" -#include "modules/audio_coding/neteq/tools/fake_decode_from_file.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/audio_decoder_proxy_factory.h" #include "test/gtest.h" @@ -202,7 +212,7 @@ TestStatistics RunTest(int loss_cadence, NetEqTest::DecoderMap decoders; // Using a fake decoder which simply reads the output audio from a file. auto input_file = std::make_unique( - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm")); + test::ResourcePath("audio_coding/testfile32kHz", "pcm")); AudioDecoderPlc dec(std::move(input_file), kSampleRateHz); // Masquerading as a PCM16b decoder. decoders.emplace(kPayloadType, SdpAudioFormat("l16", 32000, 1)); diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc index 204cde0c12..4141b76868 100644 --- a/modules/audio_coding/neteq/neteq_impl.cc +++ b/modules/audio_coding/neteq/neteq_impl.cc @@ -22,6 +22,8 @@ #include "absl/strings/str_cat.h" #include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_format.h" @@ -188,7 +190,7 @@ int NetEqImpl::InsertPacket(const RTPHeader& rtp_header, MsanCheckInitialized(payload); TRACE_EVENT0("webrtc", "NetEqImpl::InsertPacket"); MutexLock lock(&mutex_); - if (InsertPacketInternal(rtp_header, payload, packet_info) != 0) { + if (InsertPacketInternal(rtp_header, payload, packet_info) != kNoError) { return kFail; } return kOK; @@ -209,7 +211,7 @@ int NetEqImpl::GetAudio(AudioFrame* audio_frame, std::optional action_override) { TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio"); MutexLock lock(&mutex_); - if (GetAudioInternal(audio_frame, action_override) != 0) { + if (GetAudioInternal(audio_frame, action_override) != kNoError) { return kFail; } stats_->IncreaseCounter(output_size_samples_, fs_hz_); @@ -452,9 +454,10 @@ NetEq::Operation NetEqImpl::last_operation_for_test() const { // Methods below this line are private. -int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, - ArrayView payload, - const RtpPacketInfo& packet_info) { +NetEqImpl::Error NetEqImpl::InsertPacketInternal( + const RTPHeader& rtp_header, + ArrayView payload, + const RtpPacketInfo& packet_info) { if (payload.empty()) { RTC_LOG_F(LS_ERROR) << "payload is empty"; return kInvalidPointer; @@ -693,12 +696,14 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, AudioDecoder* decoder = decoder_database_->GetDecoder(payload_type); RTC_DCHECK(decoder); // Payloads are already checked to be valid. channels = decoder->Channels(); + RTC_DCHECK_LE(channels, kMaxNumberOfAudioChannels); } const DecoderDatabase::DecoderInfo* decoder_info = decoder_database_->GetDecoderInfo(payload_type); RTC_DCHECK(decoder_info); if (decoder_info->SampleRateHz() != fs_hz_ || channels != algorithm_buffer_->Channels()) { + RTC_DCHECK_LE(channels, kMaxNumberOfAudioChannels); SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels); } if (nack_enabled_) { @@ -708,7 +713,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, } } - return 0; + return kNoError; } bool NetEqImpl::MaybeChangePayloadType(uint8_t payload_type) { @@ -755,6 +760,9 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, // Make sure the total number of samples fits in the AudioFrame. if (output_size_samples_ * sync_buffer_->Channels() > AudioFrame::kMaxDataSizeSamples) { + // TODO(tommi): Remove this check. This should no longer happen + // after stricter checks were added to SetSampleRateAndChannels(). + RTC_DCHECK_NOTREACHED(); return kSampleUnderrun; } audio_frame->samples_per_channel_ = output_size_samples_; @@ -881,6 +889,9 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, size_t num_output_samples_per_channel = output_size_samples_; size_t num_output_samples = output_size_samples_ * sync_buffer_->Channels(); if (num_output_samples > AudioFrame::kMaxDataSizeSamples) { + // TODO(tommi): Remove this check. This should no longer happen + // after stricter checks were added to SetSampleRateAndChannels(). + RTC_DCHECK_NOTREACHED(); RTC_LOG(LS_WARNING) << "Output array is too short. " << AudioFrame::kMaxDataSizeSamples << " < " << output_size_samples_ << " * " @@ -1302,7 +1313,6 @@ int NetEqImpl::Decode(PacketList* packet_list, // a reset. if (decoder_info->SampleRateHz() != fs_hz_ || decoder->Channels() != algorithm_buffer_->Channels()) { - // TODO(tlegrand): Add unittest to cover this event. SetSampleRateAndChannels(decoder_info->SampleRateHz(), decoder->Channels()); } @@ -2000,16 +2010,24 @@ void NetEqImpl::UpdatePlcComponents(int fs_hz, size_t channels) { void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) { RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " " << channels; - // TODO(hlundin): Change to an enumerator and skip assert. - RTC_DCHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || - fs_hz == 48000); - RTC_DCHECK_GT(channels, 0); + RTC_CHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || + fs_hz == 48000); + RTC_CHECK_GT(channels, 0); + RTC_CHECK_LE(channels, kMaxNumberOfAudioChannels); + + // The format must fit in an AudioFrame. Situations where this could + // theoratically happen but aren't supported is e.g. if receiving 24 channels + // of 10ms 48 kHz buffers. + output_size_samples_ = SampleRateToDefaultChannelSize(fs_hz); + RTC_CHECK_LE(channels * output_size_samples_, + AudioFrame::kMaxDataSizeSamples); // Before changing the sample rate, end and report any ongoing expand event. stats_->EndExpandEvent(fs_hz_); fs_hz_ = fs_hz; fs_mult_ = fs_hz / 8000; - output_size_samples_ = static_cast(kOutputSizeMs * 8 * fs_mult_); + RTC_DCHECK_EQ(output_size_samples_, + static_cast(kOutputSizeMs * 8 * fs_mult_)); decoder_frame_length_ = 3 * output_size_samples_; // Initialize to 30ms. last_mode_ = Mode::kNormal; diff --git a/modules/audio_coding/neteq/neteq_impl.h b/modules/audio_coding/neteq/neteq_impl.h index 9fbf21abcc..2a5b4acdc0 100644 --- a/modules/audio_coding/neteq/neteq_impl.h +++ b/modules/audio_coding/neteq/neteq_impl.h @@ -31,6 +31,7 @@ #include "api/rtp_headers.h" #include "api/rtp_packet_info.h" #include "api/scoped_refptr.h" +#include "api/units/timestamp.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/packet.h" #include "modules/audio_coding/neteq/packet_buffer.h" @@ -74,7 +75,7 @@ class NetEqImpl : public webrtc::NetEq { kCodecPLC }; - enum ErrorCodes { + enum Error : int { kNoError = 0, kOtherError, kUnknownRtpPayloadType, @@ -91,7 +92,7 @@ class NetEqImpl : public webrtc::NetEq { kSampleUnderrun, kDecodedTooMuch, kRedundancySplitError, - kPacketBufferCorruption + kPacketBufferCorruption, }; struct Dependencies { @@ -216,9 +217,9 @@ class NetEqImpl : public webrtc::NetEq { // Inserts a new packet into NetEq. This is used by the InsertPacket method // above. Returns 0 on success, otherwise an error code. // TODO(hlundin): Merge this with InsertPacket above? - int InsertPacketInternal(const RTPHeader& rtp_header, - ArrayView payload, - const RtpPacketInfo& packet_info) + Error InsertPacketInternal(const RTPHeader& rtp_header, + ArrayView payload, + const RtpPacketInfo& packet_info) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); // Returns true if the payload type changed (this should be followed by @@ -333,6 +334,8 @@ class NetEqImpl : public webrtc::NetEq { // Resets various variables and objects to new values based on the sample rate // `fs_hz` and `channels` number audio channels. + // If the sample rate, the number of channels or a combination thereof aren't + // supported, the function will fail on an RTC_CHECK. void SetSampleRateAndChannels(int fs_hz, size_t channels) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); diff --git a/modules/audio_coding/neteq/neteq_impl_unittest.cc b/modules/audio_coding/neteq/neteq_impl_unittest.cc index c625dcd898..bc9e84ae24 100644 --- a/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -10,31 +10,45 @@ #include "modules/audio_coding/neteq/neteq_impl.h" +#include +#include +#include #include +#include #include #include +#include "api/audio/audio_view.h" +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/make_ref_counted.h" #include "api/neteq/default_neteq_controller_factory.h" #include "api/neteq/default_neteq_factory.h" #include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" +#include "api/neteq/tick_timer.h" +#include "api/rtp_headers.h" +#include "api/rtp_packet_info.h" +#include "api/scoped_refptr.h" #include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" -#include "modules/audio_coding/neteq/accelerate.h" #include "modules/audio_coding/neteq/decision_logic.h" #include "modules/audio_coding/neteq/expand.h" -#include "modules/audio_coding/neteq/histogram.h" #include "modules/audio_coding/neteq/mock/mock_decoder_database.h" #include "modules/audio_coding/neteq/mock/mock_dtmf_buffer.h" #include "modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h" #include "modules/audio_coding/neteq/mock/mock_neteq_controller.h" #include "modules/audio_coding/neteq/mock/mock_packet_buffer.h" #include "modules/audio_coding/neteq/mock/mock_red_payload_splitter.h" -#include "modules/audio_coding/neteq/preemptive_expand.h" -#include "modules/audio_coding/neteq/statistics_calculator.h" +#include "modules/audio_coding/neteq/packet.h" +#include "modules/audio_coding/neteq/packet_buffer.h" +#include "modules/audio_coding/neteq/red_payload_splitter.h" #include "modules/audio_coding/neteq/sync_buffer.h" #include "modules/audio_coding/neteq/timestamp_scaler.h" +#include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "system_wrappers/include/clock.h" #include "test/audio_decoder_proxy_factory.h" @@ -143,13 +157,14 @@ class NetEqImplTest : public ::testing::Test { new TimestampScaler(*deps.decoder_database.get())); neteq_.reset(new NetEqImpl(config_, std::move(deps))); - ASSERT_TRUE(neteq_ != NULL); + ASSERT_TRUE(neteq_ != nullptr); } void CreateInstance() { CreateInstance(CreateBuiltinAudioDecoderFactory()); } void UseNoMocks() { - ASSERT_TRUE(neteq_ == NULL) << "Must call UseNoMocks before CreateInstance"; + ASSERT_TRUE(neteq_ == nullptr) + << "Must call UseNoMocks before CreateInstance"; use_mock_decoder_database_ = false; use_mock_neteq_controller_ = false; use_mock_dtmf_buffer_ = false; @@ -555,7 +570,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { // Check the timestamp for the last value in the sync buffer. This should // be one full frame length ahead of the RTP timestamp. const SyncBuffer* sync_buffer = neteq_->sync_buffer_for_test(); - ASSERT_TRUE(sync_buffer != NULL); + ASSERT_TRUE(sync_buffer != nullptr); EXPECT_EQ(rtp_header.timestamp + kPayloadLengthSamples, sync_buffer->end_timestamp()); @@ -1583,8 +1598,17 @@ TEST_F(NetEqImplTest, NotifyControllerOfReorderedPacket) { EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload)); } -// When using a codec with 1000 channels, there should be no crashes. -TEST_F(NetEqImplTest, NoCrashWith1000Channels) { +#if RTC_DCHECK_IS_ON +#if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) +TEST(NetEqImplDeathTest, CrashWith1000Channels) { + EXPECT_DEATH(std::make_unique(1000), ""); +} +#endif // GTEST_HAS_DEATH_TEST +#endif + +// When using a codec with kMaxNumberOfAudioChannels channels, there should be +// no crashes. +TEST_F(NetEqImplTest, NoCrashWithMaxChannels) { using ::testing::AllOf; using ::testing::Field; UseNoMocks(); @@ -1614,7 +1638,8 @@ TEST_F(NetEqImplTest, NoCrashWith1000Channels) { EXPECT_CALL(*mock_decoder_factory, Create) .WillOnce(WithArg<1>([&](const SdpAudioFormat& format) { EXPECT_EQ("pcmu", format.name); - auto dec = std::make_unique(1000); + auto dec = + std::make_unique(kMaxNumberOfAudioChannels); decoder = dec.get(); return dec; })); @@ -1637,13 +1662,18 @@ TEST_F(NetEqImplTest, NoCrashWith1000Channels) { neteq_->InsertPacket(rtp_header, payload); AudioFrame audio_frame; - bool muted; + bool muted = false; + bool got_error = false; // Repeat 40 times to ensure we enter muted state. - for (int i = 0; i < 40; i++) { + for (int i = 0; i < 40 && !muted; i++) { // GetAudio should return an error, and not crash, even in muted state. - EXPECT_NE(0, neteq_->GetAudio(&audio_frame, &muted)); + // EXPECT_NE(0, neteq_->GetAudio(&audio_frame, &muted)); + if (neteq_->GetAudio(&audio_frame, &muted) == -1) + got_error = true; } + EXPECT_TRUE(got_error); + EXPECT_TRUE(muted); } // The test first inserts a packet with narrow-band CNG, then a packet with diff --git a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc index 3fd6541c39..4f2306dc00 100644 --- a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc +++ b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc @@ -8,18 +8,32 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include #include +#include #include +#include +#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_decoder.h" -#include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment_factory.h" +#include "api/make_ref_counted.h" #include "api/neteq/default_neteq_factory.h" #include "api/neteq/neteq.h" +#include "api/rtp_headers.h" +#include "api/scoped_refptr.h" +#include "api/units/timestamp.h" #include "modules/audio_coding/neteq/tools/rtp_generator.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "test/audio_decoder_proxy_factory.h" #include "test/gmock.h" +#include "test/gtest.h" namespace webrtc { namespace test { @@ -54,7 +68,10 @@ class MockAudioDecoder final : public AudioDecoder { class MockFrame : public AudioDecoder::EncodedAudioFrame { public: - MockFrame(size_t num_channels) : num_channels_(num_channels) {} + MockFrame(size_t num_channels) : num_channels_(num_channels) { + RTC_DCHECK_GE(num_channels_, 1); + RTC_DCHECK_LE(num_channels_, AudioDecoder::kMaxNumberOfChannels); + } size_t Duration() const override { return kPacketDuration; } diff --git a/modules/audio_coding/neteq/neteq_stereo_unittest.cc b/modules/audio_coding/neteq/neteq_stereo_unittest.cc index 1eb810835a..6cab630474 100644 --- a/modules/audio_coding/neteq/neteq_stereo_unittest.cc +++ b/modules/audio_coding/neteq/neteq_stereo_unittest.cc @@ -11,20 +11,28 @@ // Test to verify correct stereo and multi-channel operation. #include +#include +#include +#include #include #include +#include #include +#include "api/array_view.h" #include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" #include "api/neteq/neteq.h" +#include "api/rtp_headers.h" #include "api/units/timestamp.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/audio_coding/neteq/tools/rtp_generator.h" +#include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" #include "system_wrappers/include/clock.h" #include "test/gtest.h" @@ -92,7 +100,7 @@ class NetEqStereoTest : public ::testing::TestWithParam { virtual void SetUp() { const std::string file_name = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); input_file_.reset(new test::InputAudioFile(file_name)); RTC_CHECK_GE(num_channels_, 2); ASSERT_TRUE(neteq_mono_->RegisterPayloadType( diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc index b0e0e77c54..2b1d28302f 100644 --- a/modules/audio_coding/neteq/neteq_unittest.cc +++ b/modules/audio_coding/neteq/neteq_unittest.cc @@ -15,27 +15,32 @@ #include // memset #include +#include +#include #include +#include #include #include -#include +#include #include "absl/flags/flag.h" +#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/rtp_headers.h" +#include "api/units/time_delta.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "modules/audio_coding/neteq/test/neteq_decoding_test.h" #include "modules/audio_coding/neteq/tools/audio_loop.h" +#include "modules/audio_coding/neteq/tools/audio_sink.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" #include "modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" #include "modules/include/module_common_types_public.h" -#include "modules/rtp_rtcp/include/rtcp_statistics.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "rtc_base/message_digest.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/system/arch.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -46,7 +51,7 @@ namespace webrtc { // TODO(bugs.webrtc.org/345525069): Either fix/enable or remove. TEST_F(NetEqDecodingTest, DISABLED_TestBitExactness) { const std::string input_rtp_file = - webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); + test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); const std::string output_checksum = "dee7a10ab92526876a70a85bc48a4906901af3df"; @@ -67,7 +72,7 @@ TEST_F(NetEqDecodingTest, DISABLED_TestBitExactness) { #endif TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { const std::string input_rtp_file = - webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp"); + test::ResourcePath("audio_coding/neteq_opus", "rtp"); const std::string output_checksum = "434bdc4ec08546510ee903d001c8be1a01c44e24|" @@ -91,7 +96,7 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { #endif TEST_F(NetEqDecodingTest, MAYBE_TestOpusDtxBitExactness) { const std::string input_rtp_file = - webrtc::test::ResourcePath("audio_coding/neteq_opus_dtx", "rtp"); + test::ResourcePath("audio_coding/neteq_opus_dtx", "rtp"); const std::string output_checksum = "7eddce841cbfa500964c91cdae78b01b9f448948|" @@ -317,10 +322,10 @@ class NetEqBgnTest : public NetEqDecodingTest { // We are using the same 32 kHz input file for all tests, regardless of // `sampling_rate_hz`. The output may sound weird, but the test is still // valid. - ASSERT_TRUE(input.Init( - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), - 10 * sampling_rate_hz, // Max 10 seconds loop length. - expected_samples_per_channel)); + ASSERT_TRUE( + input.Init(test::ResourcePath("audio_coding/testfile32kHz", "pcm"), + 10 * sampling_rate_hz, // Max 10 seconds loop length. + expected_samples_per_channel)); // Payload of 10 ms of PCM16 32 kHz. uint8_t payload[kBlockSize32kHz * sizeof(int16_t)]; @@ -996,7 +1001,7 @@ TEST(NetEqNoTimeStretchingMode, RunTest) { {7, kRtpExtensionVideoContentType}, {8, kRtpExtensionVideoTiming}}; std::unique_ptr input = CreateNetEqRtpDumpInput( - webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"), + test::ResourcePath("audio_coding/neteq_universal_new", "rtp"), rtp_ext_map, std::nullopt /*No SSRC filter*/); std::unique_ptr input_time_limit( new TimeLimitedNetEqInput(std::move(input), 20000)); diff --git a/modules/audio_coding/neteq/normal.cc b/modules/audio_coding/neteq/normal.cc index 489aeee339..c3748d8931 100644 --- a/modules/audio_coding/neteq/normal.cc +++ b/modules/audio_coding/neteq/normal.cc @@ -13,8 +13,15 @@ #include // memset, memcpy #include // min +#include +#include +#include "api/array_view.h" +#include "api/neteq/neteq.h" +#include "common_audio/signal_processing/dot_product_with_scale.h" #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "common_audio/signal_processing/include/spl_inl.h" +#include "modules/audio_coding/codecs/cng/webrtc_cng.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/background_noise.h" #include "modules/audio_coding/neteq/decoder_database.h" diff --git a/modules/audio_coding/neteq/normal_unittest.cc b/modules/audio_coding/neteq/normal_unittest.cc index f774733b11..dfbf0078fd 100644 --- a/modules/audio_coding/neteq/normal_unittest.cc +++ b/modules/audio_coding/neteq/normal_unittest.cc @@ -12,10 +12,11 @@ #include "modules/audio_coding/neteq/normal.h" -#include -#include +#include +#include -#include "common_audio/signal_processing/include/signal_processing_library.h" +#include "api/neteq/neteq.h" +#include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/background_noise.h" #include "modules/audio_coding/neteq/expand.h" @@ -24,6 +25,7 @@ #include "modules/audio_coding/neteq/random_vector.h" #include "modules/audio_coding/neteq/statistics_calculator.h" #include "modules/audio_coding/neteq/sync_buffer.h" +#include "test/gmock.h" #include "test/gtest.h" using ::testing::_; diff --git a/modules/audio_coding/neteq/packet.cc b/modules/audio_coding/neteq/packet.cc index 333f161229..e70824ef28 100644 --- a/modules/audio_coding/neteq/packet.cc +++ b/modules/audio_coding/neteq/packet.cc @@ -10,6 +10,8 @@ #include "modules/audio_coding/neteq/packet.h" +#include "rtc_base/checks.h" + namespace webrtc { Packet::Packet() = default; diff --git a/modules/audio_coding/neteq/packet.h b/modules/audio_coding/neteq/packet.h index f6ee755b77..671ab26cb4 100644 --- a/modules/audio_coding/neteq/packet.h +++ b/modules/audio_coding/neteq/packet.h @@ -15,6 +15,7 @@ #include #include +#include #include "api/audio_codecs/audio_decoder.h" #include "api/neteq/tick_timer.h" diff --git a/modules/audio_coding/neteq/packet_arrival_history_unittest.cc b/modules/audio_coding/neteq/packet_arrival_history_unittest.cc index dd95fec0f7..58a0a5108b 100644 --- a/modules/audio_coding/neteq/packet_arrival_history_unittest.cc +++ b/modules/audio_coding/neteq/packet_arrival_history_unittest.cc @@ -13,6 +13,7 @@ #include #include +#include "api/neteq/tick_timer.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/packet_buffer.cc b/modules/audio_coding/neteq/packet_buffer.cc index 894fc5bef6..a2e3a7ee8a 100644 --- a/modules/audio_coding/neteq/packet_buffer.cc +++ b/modules/audio_coding/neteq/packet_buffer.cc @@ -15,17 +15,19 @@ #include "modules/audio_coding/neteq/packet_buffer.h" #include +#include +#include #include #include -#include +#include #include #include "api/audio_codecs/audio_decoder.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/decoder_database.h" +#include "modules/audio_coding/neteq/packet.h" #include "modules/audio_coding/neteq/statistics_calculator.h" #include "rtc_base/checks.h" -#include "rtc_base/experiments/struct_parameters_parser.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/neteq/packet_buffer.h b/modules/audio_coding/neteq/packet_buffer.h index 547e993a4d..d7c98288ea 100644 --- a/modules/audio_coding/neteq/packet_buffer.h +++ b/modules/audio_coding/neteq/packet_buffer.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_ #define MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_ +#include +#include #include #include "modules/audio_coding/neteq/decoder_database.h" diff --git a/modules/audio_coding/neteq/packet_buffer_unittest.cc b/modules/audio_coding/neteq/packet_buffer_unittest.cc index 6e134a17ae..873ded51fc 100644 --- a/modules/audio_coding/neteq/packet_buffer_unittest.cc +++ b/modules/audio_coding/neteq/packet_buffer_unittest.cc @@ -12,14 +12,21 @@ #include "modules/audio_coding/neteq/packet_buffer.h" +#include +#include +#include #include +#include +#include +#include -#include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_decoder.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/mock/mock_decoder_database.h" #include "modules/audio_coding/neteq/mock/mock_statistics_calculator.h" #include "modules/audio_coding/neteq/packet.h" -#include "test/field_trial.h" +#include "rtc_base/checks.h" #include "test/gmock.h" #include "test/gtest.h" @@ -384,7 +391,7 @@ TEST(PacketBuffer, Failures) { EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer.NextTimestamp(&temp_ts)); EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer.NextHigherTimestamp(0, &temp_ts)); - EXPECT_EQ(NULL, buffer.PeekNextPacket()); + EXPECT_EQ(nullptr, buffer.PeekNextPacket()); EXPECT_FALSE(buffer.GetNextPacket()); // Discarding packets will not invoke mock_stats.PacketDiscarded() because the diff --git a/modules/audio_coding/neteq/preemptive_expand.cc b/modules/audio_coding/neteq/preemptive_expand.cc index f5d540bf06..a183c3dd96 100644 --- a/modules/audio_coding/neteq/preemptive_expand.cc +++ b/modules/audio_coding/neteq/preemptive_expand.cc @@ -11,6 +11,8 @@ #include "modules/audio_coding/neteq/preemptive_expand.h" #include +#include +#include #include "api/array_view.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" diff --git a/modules/audio_coding/neteq/random_vector.cc b/modules/audio_coding/neteq/random_vector.cc index ada175831c..f57ede6a85 100644 --- a/modules/audio_coding/neteq/random_vector.cc +++ b/modules/audio_coding/neteq/random_vector.cc @@ -10,6 +10,9 @@ #include "modules/audio_coding/neteq/random_vector.h" +#include +#include + namespace webrtc { const int16_t RandomVector::kRandomTable[RandomVector::kRandomTableSize] = { diff --git a/modules/audio_coding/neteq/red_payload_splitter.cc b/modules/audio_coding/neteq/red_payload_splitter.cc index 4c753f553e..d8c27db218 100644 --- a/modules/audio_coding/neteq/red_payload_splitter.cc +++ b/modules/audio_coding/neteq/red_payload_splitter.cc @@ -20,6 +20,7 @@ #include "modules/audio_coding/neteq/decoder_database.h" #include "modules/audio_coding/neteq/packet.h" #include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/neteq/red_payload_splitter.h b/modules/audio_coding/neteq/red_payload_splitter.h index 2f48e4b7d4..db637c204d 100644 --- a/modules/audio_coding/neteq/red_payload_splitter.h +++ b/modules/audio_coding/neteq/red_payload_splitter.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ #define MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ +#include + #include "modules/audio_coding/neteq/packet.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc index 7a5dde0056..c902edb8ac 100644 --- a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc +++ b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc @@ -12,14 +12,19 @@ #include "modules/audio_coding/neteq/red_payload_splitter.h" -#include +#include +#include +#include +#include #include // pair -#include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/make_ref_counted.h" #include "modules/audio_coding/neteq/decoder_database.h" #include "modules/audio_coding/neteq/packet.h" +#include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/gtest.h" #include "test/mock_audio_decoder_factory.h" diff --git a/modules/audio_coding/neteq/reorder_optimizer.cc b/modules/audio_coding/neteq/reorder_optimizer.cc index b3d9154a9a..98dbedfaa4 100644 --- a/modules/audio_coding/neteq/reorder_optimizer.cc +++ b/modules/audio_coding/neteq/reorder_optimizer.cc @@ -14,6 +14,7 @@ #include #include +#include #include namespace webrtc { diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc index 69e14608a0..1ae4221a64 100644 --- a/modules/audio_coding/neteq/statistics_calculator.cc +++ b/modules/audio_coding/neteq/statistics_calculator.cc @@ -13,9 +13,11 @@ #include // memset #include +#include #include "absl/strings/string_view.h" -#include "modules/audio_coding/neteq/delay_manager.h" +#include "api/neteq/neteq.h" +#include "api/neteq/tick_timer.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "system_wrappers/include/metrics.h" diff --git a/modules/audio_coding/neteq/statistics_calculator.h b/modules/audio_coding/neteq/statistics_calculator.h index 28ac613bc7..07c8345462 100644 --- a/modules/audio_coding/neteq/statistics_calculator.h +++ b/modules/audio_coding/neteq/statistics_calculator.h @@ -11,11 +11,14 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ #define MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ +#include +#include #include #include #include "absl/strings/string_view.h" #include "api/neteq/neteq.h" +#include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/expand_uma_logger.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/statistics_calculator_unittest.cc b/modules/audio_coding/neteq/statistics_calculator_unittest.cc index a8ad359ab0..110c2db5d6 100644 --- a/modules/audio_coding/neteq/statistics_calculator_unittest.cc +++ b/modules/audio_coding/neteq/statistics_calculator_unittest.cc @@ -10,6 +10,10 @@ #include "modules/audio_coding/neteq/statistics_calculator.h" +#include + +#include "api/neteq/neteq.h" +#include "api/neteq/tick_timer.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/sync_buffer.cc b/modules/audio_coding/neteq/sync_buffer.cc index 5144462cae..26fa54f2a6 100644 --- a/modules/audio_coding/neteq/sync_buffer.cc +++ b/modules/audio_coding/neteq/sync_buffer.cc @@ -11,7 +11,12 @@ #include "modules/audio_coding/neteq/sync_buffer.h" #include // Access to min. +#include +#include +#include "api/audio/audio_frame.h" +#include "modules/audio_coding/neteq/audio_multi_vector.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { @@ -73,7 +78,7 @@ void SyncBuffer::ReplaceAtIndex(const AudioMultiVector& insert_this, size_t position) { position = std::min(position, Size()); // Cap `position` in the valid range. length = std::min(length, Size() - position); - AudioMultiVector::OverwriteAt(insert_this, length, position); + OverwriteAt(insert_this, length, position); } void SyncBuffer::ReplaceAtIndex(const AudioMultiVector& insert_this, diff --git a/modules/audio_coding/neteq/sync_buffer.h b/modules/audio_coding/neteq/sync_buffer.h index ea81babca6..7374fdd685 100644 --- a/modules/audio_coding/neteq/sync_buffer.h +++ b/modules/audio_coding/neteq/sync_buffer.h @@ -23,7 +23,7 @@ namespace webrtc { -class SyncBuffer : public AudioMultiVector { +class SyncBuffer final : public AudioMultiVector { public: SyncBuffer(size_t channels, size_t length) : AudioMultiVector(channels, length), @@ -34,6 +34,8 @@ class SyncBuffer : public AudioMultiVector { SyncBuffer(const SyncBuffer&) = delete; SyncBuffer& operator=(const SyncBuffer&) = delete; + ~SyncBuffer() override = default; + // Returns the number of samples yet to play out from the buffer. size_t FutureLength() const; @@ -57,7 +59,7 @@ class SyncBuffer : public AudioMultiVector { // Inserts `length` zeros into each channel at index `position`. The size of // the SyncBuffer is kept constant, which means that the last `length` // elements in each channel will be purged. - virtual void InsertZerosAtIndex(size_t length, size_t position); + void InsertZerosAtIndex(size_t length, size_t position); // Overwrites each channel in this SyncBuffer with values taken from // `insert_this`. The values are taken from the beginning of `insert_this` and @@ -66,14 +68,13 @@ class SyncBuffer : public AudioMultiVector { // and `position` are selected such that the new data would extend beyond the // end of the current SyncBuffer, the buffer is not extended. // The `next_index_` is not updated. - virtual void ReplaceAtIndex(const AudioMultiVector& insert_this, - size_t length, - size_t position); + void ReplaceAtIndex(const AudioMultiVector& insert_this, + size_t length, + size_t position); // Same as the above method, but where all of `insert_this` is written (with // the same constraints as above, that the SyncBuffer is not extended). - virtual void ReplaceAtIndex(const AudioMultiVector& insert_this, - size_t position); + void ReplaceAtIndex(const AudioMultiVector& insert_this, size_t position); // Reads `requested_len` samples from each channel and writes them interleaved // into `output`. The `next_index_` is updated to point to the sample to read diff --git a/modules/audio_coding/neteq/sync_buffer_unittest.cc b/modules/audio_coding/neteq/sync_buffer_unittest.cc index f4057cf3bc..d2137e3f7b 100644 --- a/modules/audio_coding/neteq/sync_buffer_unittest.cc +++ b/modules/audio_coding/neteq/sync_buffer_unittest.cc @@ -10,6 +10,11 @@ #include "modules/audio_coding/neteq/sync_buffer.h" +#include +#include + +#include "api/audio/audio_frame.h" +#include "modules/audio_coding/neteq/audio_multi_vector.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/gtest.h" diff --git a/modules/audio_coding/neteq/test/neteq_decoding_test.cc b/modules/audio_coding/neteq/test/neteq_decoding_test.cc index aca3efc95f..eb0b196499 100644 --- a/modules/audio_coding/neteq/test/neteq_decoding_test.cc +++ b/modules/audio_coding/neteq/test/neteq_decoding_test.cc @@ -10,14 +10,26 @@ #include "modules/audio_coding/neteq/test/neteq_decoding_test.h" +#include +#include +#include +#include +#include + #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" #include "api/rtp_headers.h" #include "api/units/timestamp.h" #include "modules/audio_coding/neteq/test/result_sink.h" +#include "modules/audio_coding/neteq/tools/rtp_file_source.h" #include "rtc_base/strings/string_builder.h" +#include "test/gtest.h" #include "test/testsupport/file_utils.h" #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT @@ -25,7 +37,7 @@ #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" #else -#include "modules/audio_coding/neteq/neteq_unittest.pb.h" +#include "modules/audio_coding/neteq/neteq_unittest.pb.h" // IWYU pragma: keep #endif #endif @@ -34,7 +46,7 @@ namespace webrtc { namespace { -void LoadDecoders(webrtc::NetEq* neteq) { +void LoadDecoders(NetEq* neteq) { ASSERT_EQ(true, neteq->RegisterPayloadType(0, SdpAudioFormat("pcmu", 8000, 1))); ASSERT_EQ(true, @@ -138,11 +150,11 @@ void NetEqDecodingTest::DecodeAndCompare( OpenInputFile(rtp_file); std::string ref_out_file = - gen_ref ? webrtc::test::OutputPath() + "neteq_universal_ref.pcm" : ""; + gen_ref ? test::OutputPath() + "neteq_universal_ref.pcm" : ""; ResultSink output(ref_out_file); std::string stat_out_file = - gen_ref ? webrtc::test::OutputPath() + "neteq_network_stats.dat" : ""; + gen_ref ? test::OutputPath() + "neteq_network_stats.dat" : ""; ResultSink network_stats(stat_out_file); packet_ = rtp_source_->NextPacket(); diff --git a/modules/audio_coding/neteq/test/neteq_decoding_test.h b/modules/audio_coding/neteq/test/neteq_decoding_test.h index fa348dbc48..a7557dcf0a 100644 --- a/modules/audio_coding/neteq/test/neteq_decoding_test.h +++ b/modules/audio_coding/neteq/test/neteq_decoding_test.h @@ -11,9 +11,10 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TEST_NETEQ_DECODING_TEST_H_ #define MODULES_AUDIO_CODING_NETEQ_TEST_NETEQ_DECODING_TEST_H_ +#include +#include #include #include -#include #include "absl/strings/string_view.h" #include "api/audio/audio_frame.h" diff --git a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc index 59be7cdbf9..276adc106e 100644 --- a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc @@ -8,10 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include + #include "absl/flags/flag.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_format.h" +#include "api/rtp_parameters.h" #include "modules/audio_coding/codecs/opus/opus_inst.h" #include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/neteq/tools/neteq_quality_test.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" +#include "test/gtest.h" ABSL_FLAG(int, bit_rate_kbps, 32, "Target bit rate (kbps)."); @@ -72,8 +82,8 @@ NetEqOpusQualityTest::NetEqOpusQualityTest() kOpusSamplingKhz, kOpusSamplingKhz, SdpAudioFormat("opus", 48000, 2)), - opus_encoder_(NULL), - repacketizer_(NULL), + opus_encoder_(nullptr), + repacketizer_(nullptr), sub_block_size_samples_( static_cast(kOpusBlockDurationMs * kOpusSamplingKhz)), bit_rate_kbps_(absl::GetFlag(FLAGS_bit_rate_kbps)), diff --git a/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc b/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc index 53af21f8ff..6cf73f6bda 100644 --- a/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc @@ -8,13 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include #include #include "absl/flags/flag.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" #include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" #include "modules/audio_coding/neteq/tools/neteq_quality_test.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" +#include "test/gtest.h" #include "test/testsupport/file_utils.h" ABSL_FLAG(int, frame_size_ms, 20, "Codec frame size (milliseconds)."); diff --git a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc index 62ea361d0a..2de5170c26 100644 --- a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc @@ -8,13 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include #include #include "absl/flags/flag.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" #include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" #include "modules/audio_coding/neteq/tools/neteq_quality_test.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" +#include "test/gtest.h" #include "test/testsupport/file_utils.h" ABSL_FLAG(int, frame_size_ms, 20, "Codec frame size (milliseconds)."); diff --git a/modules/audio_coding/neteq/test/neteq_performance_unittest.cc b/modules/audio_coding/neteq/test/neteq_performance_unittest.cc index 1b453cf7bf..6664137a8c 100644 --- a/modules/audio_coding/neteq/test/neteq_performance_unittest.cc +++ b/modules/audio_coding/neteq/test/neteq_performance_unittest.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "absl/flags/flag.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" #include "api/test/metrics/metric.h" @@ -18,9 +20,9 @@ namespace webrtc { namespace { -using ::webrtc::test::GetGlobalMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::GetGlobalMetricsLogger; +using test::ImprovementDirection; +using test::Unit; // Runs a test with 10% packet losses and 10% clock drift, to exercise // both loss concealment and time-stretching code. diff --git a/modules/audio_coding/neteq/test/neteq_speed_test.cc b/modules/audio_coding/neteq/test/neteq_speed_test.cc index a72b2009eb..0ffee03aed 100644 --- a/modules/audio_coding/neteq/test/neteq_speed_test.cc +++ b/modules/audio_coding/neteq/test/neteq_speed_test.cc @@ -10,7 +10,9 @@ #include +#include #include +#include #include #include "absl/flags/flag.h" diff --git a/modules/audio_coding/neteq/test/result_sink.cc b/modules/audio_coding/neteq/test/result_sink.cc index 98683b1d8d..5310ca8a86 100644 --- a/modules/audio_coding/neteq/test/result_sink.cc +++ b/modules/audio_coding/neteq/test/result_sink.cc @@ -34,8 +34,8 @@ namespace webrtc { #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT -void Convert(const webrtc::NetEqNetworkStatistics& stats_raw, - webrtc::neteq_unittest::NetEqNetworkStatistics* stats) { +void Convert(const NetEqNetworkStatistics& stats_raw, + neteq_unittest::NetEqNetworkStatistics* stats) { stats->set_current_buffer_size_ms(stats_raw.current_buffer_size_ms); stats->set_preferred_buffer_size_ms(stats_raw.preferred_buffer_size_ms); stats->set_jitter_peaks_found(stats_raw.jitter_peaks_found); @@ -69,7 +69,7 @@ ResultSink::ResultSink(absl::string_view output_file) : output_fp_(nullptr), digest_(MessageDigestFactory::Create(DIGEST_SHA_1)) { if (!output_file.empty()) { output_fp_ = fopen(std::string(output_file).c_str(), "wb"); - EXPECT_TRUE(output_fp_ != NULL); + EXPECT_TRUE(output_fp_ != nullptr); } } diff --git a/modules/audio_coding/neteq/time_stretch.cc b/modules/audio_coding/neteq/time_stretch.cc index d6dddd5317..39be0404cd 100644 --- a/modules/audio_coding/neteq/time_stretch.cc +++ b/modules/audio_coding/neteq/time_stretch.cc @@ -11,12 +11,17 @@ #include "modules/audio_coding/neteq/time_stretch.h" #include // min, max +#include +#include #include +#include "common_audio/signal_processing/dot_product_with_scale.h" #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "common_audio/signal_processing/include/spl_inl.h" #include "modules/audio_coding/neteq/background_noise.h" #include "modules/audio_coding/neteq/cross_correlation.h" #include "modules/audio_coding/neteq/dsp_helper.h" +#include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/time_stretch.h b/modules/audio_coding/neteq/time_stretch.h index f0ddaebeca..9d81a7f55f 100644 --- a/modules/audio_coding/neteq/time_stretch.h +++ b/modules/audio_coding/neteq/time_stretch.h @@ -13,7 +13,10 @@ #include // memset, size_t +#include + #include "modules/audio_coding/neteq/audio_multi_vector.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/time_stretch_unittest.cc b/modules/audio_coding/neteq/time_stretch_unittest.cc index da3a98229a..029ab887e9 100644 --- a/modules/audio_coding/neteq/time_stretch_unittest.cc +++ b/modules/audio_coding/neteq/time_stretch_unittest.cc @@ -10,10 +10,13 @@ // Unit tests for Accelerate and PreemptiveExpand classes. +#include "modules/audio_coding/neteq/time_stretch.h" + +#include +#include #include #include -#include "common_audio/signal_processing/include/signal_processing_library.h" #include "modules/audio_coding/neteq/accelerate.h" #include "modules/audio_coding/neteq/background_noise.h" #include "modules/audio_coding/neteq/preemptive_expand.h" @@ -45,13 +48,13 @@ TEST(TimeStretch, CreateUsingFactory) { AccelerateFactory accelerate_factory; Accelerate* accelerate = accelerate_factory.Create(kSampleRate, kNumChannels, bgn); - EXPECT_TRUE(accelerate != NULL); + EXPECT_TRUE(accelerate != nullptr); delete accelerate; PreemptiveExpandFactory preemptive_expand_factory; PreemptiveExpand* preemptive_expand = preemptive_expand_factory.Create( kSampleRate, kNumChannels, bgn, kOverlapSamples); - EXPECT_TRUE(preemptive_expand != NULL); + EXPECT_TRUE(preemptive_expand != nullptr); delete preemptive_expand; } diff --git a/modules/audio_coding/neteq/timestamp_scaler.cc b/modules/audio_coding/neteq/timestamp_scaler.cc index 59177d027f..6bb546c026 100644 --- a/modules/audio_coding/neteq/timestamp_scaler.cc +++ b/modules/audio_coding/neteq/timestamp_scaler.cc @@ -10,8 +10,11 @@ #include "modules/audio_coding/neteq/timestamp_scaler.h" +#include + #include "api/audio_codecs/audio_format.h" #include "modules/audio_coding/neteq/decoder_database.h" +#include "modules/audio_coding/neteq/packet.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/timestamp_scaler.h b/modules/audio_coding/neteq/timestamp_scaler.h index f42ce7207a..833e09be44 100644 --- a/modules/audio_coding/neteq/timestamp_scaler.h +++ b/modules/audio_coding/neteq/timestamp_scaler.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TIMESTAMP_SCALER_H_ #define MODULES_AUDIO_CODING_NETEQ_TIMESTAMP_SCALER_H_ +#include + #include "modules/audio_coding/neteq/packet.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc index e880004a5b..b32928e0de 100644 --- a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc +++ b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc @@ -10,6 +10,12 @@ #include "modules/audio_coding/neteq/timestamp_scaler.h" +#include +#include +#include +#include + +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" @@ -326,7 +332,7 @@ TEST(TimestampScaler, Failures) { uint32_t timestamp = 4711; // Some number. EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType)); - Packet* packet = NULL; + Packet* packet = nullptr; scaler.ToInternal(packet); // Should not crash. That's all we can test. EXPECT_CALL(db, Die()); // Called when database object is deleted. diff --git a/modules/audio_coding/neteq/tools/audio_loop.cc b/modules/audio_coding/neteq/tools/audio_loop.cc index cfac0f3300..cff9fd1d1d 100644 --- a/modules/audio_coding/neteq/tools/audio_loop.cc +++ b/modules/audio_coding/neteq/tools/audio_loop.cc @@ -13,7 +13,11 @@ #include #include +#include +#include + #include "absl/strings/string_view.h" +#include "api/array_view.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/audio_loop.h b/modules/audio_coding/neteq/tools/audio_loop.h index d722e01666..d5c561d623 100644 --- a/modules/audio_coding/neteq/tools/audio_loop.h +++ b/modules/audio_coding/neteq/tools/audio_loop.h @@ -11,8 +11,9 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_AUDIO_LOOP_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_AUDIO_LOOP_H_ +#include +#include #include -#include #include "absl/strings/string_view.h" #include "api/array_view.h" diff --git a/modules/audio_coding/neteq/tools/audio_sink.cc b/modules/audio_coding/neteq/tools/audio_sink.cc index 656dda43a1..84ab2d6784 100644 --- a/modules/audio_coding/neteq/tools/audio_sink.cc +++ b/modules/audio_coding/neteq/tools/audio_sink.cc @@ -10,6 +10,9 @@ #include "modules/audio_coding/neteq/tools/audio_sink.h" +#include +#include + namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/audio_sink.h b/modules/audio_coding/neteq/tools/audio_sink.h index 53729fa920..30df6c27d6 100644 --- a/modules/audio_coding/neteq/tools/audio_sink.h +++ b/modules/audio_coding/neteq/tools/audio_sink.h @@ -11,6 +11,9 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_AUDIO_SINK_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_AUDIO_SINK_H_ +#include +#include + #include "api/audio/audio_frame.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc b/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc index d63e1b05e1..20cd8356d6 100644 --- a/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc +++ b/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc @@ -10,11 +10,15 @@ #include "modules/audio_coding/neteq/tools/constant_pcm_packet_source.h" -#include +#include +#include +#include +#include #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "modules/audio_coding/neteq/tools/packet.h" #include "rtc_base/checks.h" +#include "rtc_base/copy_on_write_buffer.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h b/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h index ab4f5c2281..4727aff583 100644 --- a/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h +++ b/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h @@ -13,8 +13,10 @@ #include -#include +#include +#include +#include "modules/audio_coding/neteq/tools/packet.h" #include "modules/audio_coding/neteq/tools/packet_source.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/encode_neteq_input.cc b/modules/audio_coding/neteq/tools/encode_neteq_input.cc index b4a940bdaf..c76dbbb7e2 100644 --- a/modules/audio_coding/neteq/tools/encode_neteq_input.cc +++ b/modules/audio_coding/neteq/tools/encode_neteq_input.cc @@ -10,8 +10,15 @@ #include "modules/audio_coding/neteq/tools/encode_neteq_input.h" +#include +#include +#include +#include #include +#include "api/audio_codecs/audio_encoder.h" +#include "api/rtp_headers.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/neteq/tools/encode_neteq_input.h b/modules/audio_coding/neteq/tools/encode_neteq_input.h index 63666e86d8..eb8fea7991 100644 --- a/modules/audio_coding/neteq/tools/encode_neteq_input.h +++ b/modules/audio_coding/neteq/tools/encode_neteq_input.h @@ -11,9 +11,14 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_ENCODE_NETEQ_INPUT_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_ENCODE_NETEQ_INPUT_H_ +#include +#include #include +#include +#include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" +#include "api/rtp_headers.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/fake_decode_from_file.cc b/modules/audio_coding/neteq/tools/fake_decode_from_file.cc index 95ce8e9948..37e79fd63c 100644 --- a/modules/audio_coding/neteq/tools/fake_decode_from_file.cc +++ b/modules/audio_coding/neteq/tools/fake_decode_from_file.cc @@ -10,7 +10,18 @@ #include "modules/audio_coding/neteq/tools/fake_decode_from_file.h" +#include +#include +#include +#include +#include +#include + +#include "api/array_view.h" +#include "api/audio_codecs/audio_decoder.h" +#include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/rtp_rtcp/source/byte_io.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/neteq/tools/fake_decode_from_file.h b/modules/audio_coding/neteq/tools/fake_decode_from_file.h index ea1610e3ec..a5e734f3b8 100644 --- a/modules/audio_coding/neteq/tools/fake_decode_from_file.h +++ b/modules/audio_coding/neteq/tools/fake_decode_from_file.h @@ -11,12 +11,17 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_FAKE_DECODE_FROM_FILE_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_FAKE_DECODE_FROM_FILE_H_ +#include +#include #include #include +#include +#include #include "api/array_view.h" #include "api/audio_codecs/audio_decoder.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" +#include "rtc_base/buffer.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc index c41ef590bd..b2bb4f1a92 100644 --- a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc +++ b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc @@ -10,10 +10,14 @@ #include "modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h" -#include +#include #include +#include #include +#include "api/rtp_headers.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h index f72c21c70f..47939de66b 100644 --- a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h +++ b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h @@ -11,10 +11,11 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_INITIAL_PACKET_INSERTER_NETEQ_INPUT_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_INITIAL_PACKET_INSERTER_NETEQ_INPUT_H_ -#include +#include #include -#include +#include +#include "api/rtp_headers.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/input_audio_file.cc b/modules/audio_coding/neteq/tools/input_audio_file.cc index b077dbff21..e0000097aa 100644 --- a/modules/audio_coding/neteq/tools/input_audio_file.cc +++ b/modules/audio_coding/neteq/tools/input_audio_file.cc @@ -10,6 +10,11 @@ #include "modules/audio_coding/neteq/tools/input_audio_file.h" +#include +#include +#include +#include + #include "absl/strings/string_view.h" #include "rtc_base/checks.h" diff --git a/modules/audio_coding/neteq/tools/input_audio_file.h b/modules/audio_coding/neteq/tools/input_audio_file.h index e885bb39eb..4fe5b43a3e 100644 --- a/modules/audio_coding/neteq/tools/input_audio_file.h +++ b/modules/audio_coding/neteq/tools/input_audio_file.h @@ -14,7 +14,6 @@ #include #include -#include #include "absl/strings/string_view.h" diff --git a/modules/audio_coding/neteq/tools/input_audio_file_unittest.cc b/modules/audio_coding/neteq/tools/input_audio_file_unittest.cc index 54d5b3fbfa..91cbb2745e 100644 --- a/modules/audio_coding/neteq/tools/input_audio_file_unittest.cc +++ b/modules/audio_coding/neteq/tools/input_audio_file_unittest.cc @@ -12,6 +12,9 @@ #include "modules/audio_coding/neteq/tools/input_audio_file.h" +#include +#include + #include "rtc_base/numerics/safe_conversions.h" #include "test/gtest.h" diff --git a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.cc b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.cc index 71e388066f..894eef922c 100644 --- a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.cc +++ b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.cc @@ -11,13 +11,21 @@ #include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" #include +#include +#include #include #include -#include #include +#include // no-presubmit-check TODO(webrtc:8982) +#include #include +#include #include "absl/strings/string_view.h" +#include "api/audio/audio_frame.h" +#include "api/neteq/neteq.h" +#include "api/rtp_packet_info.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" diff --git a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h index cdf178b463..caa3302bb7 100644 --- a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h +++ b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h @@ -11,13 +11,17 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_DELAY_ANALYZER_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_DELAY_ANALYZER_H_ +#include +#include #include #include #include -#include +#include #include #include "absl/strings/string_view.h" +#include "api/audio/audio_frame.h" +#include "api/neteq/neteq.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" diff --git a/modules/audio_coding/neteq/tools/neteq_event_log_input.cc b/modules/audio_coding/neteq/tools/neteq_event_log_input.cc index d42a31b7d9..9066bd6323 100644 --- a/modules/audio_coding/neteq/tools/neteq_event_log_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_event_log_input.cc @@ -10,11 +10,18 @@ #include "modules/audio_coding/neteq/tools/neteq_event_log_input.h" -#include +#include +#include #include - -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" +#include +#include + +#include "api/rtp_headers.h" +#include "logging/rtc_event_log/events/logged_rtp_rtcp.h" +#include "logging/rtc_event_log/events/rtc_event_audio_playout.h" +#include "logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.h" +#include "logging/rtc_event_log/rtc_event_log_parser.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/neteq_event_log_input.h b/modules/audio_coding/neteq/tools/neteq_event_log_input.h index cdfd62d80f..23c6388ab0 100644 --- a/modules/audio_coding/neteq/tools/neteq_event_log_input.h +++ b/modules/audio_coding/neteq/tools/neteq_event_log_input.h @@ -11,9 +11,10 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EVENT_LOG_INPUT_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EVENT_LOG_INPUT_H_ +#include +#include #include -#include "absl/strings/string_view.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" diff --git a/modules/audio_coding/neteq/tools/neteq_input.cc b/modules/audio_coding/neteq/tools/neteq_input.cc index 707ce1b4c8..8c27b8e014 100644 --- a/modules/audio_coding/neteq/tools/neteq_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_input.cc @@ -10,6 +10,13 @@ #include "modules/audio_coding/neteq/tools/neteq_input.h" +#include +#include +#include +#include +#include + +#include "api/rtp_headers.h" #include "rtc_base/strings/string_builder.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/neteq_input.h b/modules/audio_coding/neteq/tools/neteq_input.h index 0f1b090e94..269d7b6b1f 100644 --- a/modules/audio_coding/neteq/tools/neteq_input.h +++ b/modules/audio_coding/neteq/tools/neteq_input.h @@ -12,12 +12,12 @@ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_INPUT_H_ #include +#include #include #include #include -#include "modules/audio_coding/neteq/tools/packet.h" -#include "modules/audio_coding/neteq/tools/packet_source.h" +#include "api/rtp_headers.h" #include "rtc_base/buffer.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/modules/audio_coding/neteq/tools/neteq_performance_test.cc index c3205ded1c..1b4b259014 100644 --- a/modules/audio_coding/neteq/tools/neteq_performance_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_performance_test.cc @@ -10,12 +10,20 @@ #include "modules/audio_coding/neteq/tools/neteq_performance_test.h" +#include +#include +#include +#include + #include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" #include "api/neteq/neteq.h" +#include "api/rtp_headers.h" +#include "api/units/timestamp.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "modules/audio_coding/neteq/tools/audio_loop.h" #include "modules/audio_coding/neteq/tools/rtp_generator.h" @@ -34,7 +42,7 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, int lossrate, double drift_factor) { const std::string kInputFileName = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); const int kSampRateHz = 32000; const std::string kDecoderName = "pcm16-swb32"; const int kPayloadType = 95; diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/modules/audio_coding/neteq/tools/neteq_quality_test.cc index 4ddef25bab..161914995a 100644 --- a/modules/audio_coding/neteq/tools/neteq_quality_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_quality_test.cc @@ -12,20 +12,39 @@ #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "absl/flags/flag.h" #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" +#include "api/scoped_refptr.h" #include "api/units/timestamp.h" #include "modules/audio_coding/neteq/tools/neteq_quality_test.h" #include "modules/audio_coding/neteq/tools/output_audio_file.h" #include "modules/audio_coding/neteq/tools/output_wav_file.h" #include "modules/audio_coding/neteq/tools/resample_input_audio_file.h" +#include "modules/audio_coding/neteq/tools/rtp_generator.h" #include "rtc_base/checks.h" #include "rtc_base/string_encode.h" -#include "system_wrappers/include/clock.h" +#include "test/gtest.h" #include "test/testsupport/file_utils.h" ABSL_FLAG(std::string, @@ -94,13 +113,12 @@ const std::string& GetInFilenamePath(absl::string_view file_name) { std::vector name_parts = split(file_name, '.'); RTC_CHECK_EQ(name_parts.size(), 2); static const std::string path = - ::webrtc::test::ResourcePath(name_parts[0], name_parts[1]); + test::ResourcePath(name_parts[0], name_parts[1]); return path; } const std::string& GetOutFilenamePath(absl::string_view file_name) { - static const std::string path = - ::webrtc::test::OutputPath() + std::string(file_name); + static const std::string path = test::OutputPath() + std::string(file_name); return path; } @@ -242,10 +260,10 @@ NetEqQualityTest::NetEqQualityTest( out_filename.substr(out_filename.size() - 4) == ".wav") { // Open a wav file. output_.reset( - new webrtc::test::OutputWavFile(out_filename, 1000 * out_sampling_khz)); + new test::OutputWavFile(out_filename, 1000 * out_sampling_khz)); } else { // Open a pcm file. - output_.reset(new webrtc::test::OutputAudioFile(out_filename)); + output_.reset(new test::OutputAudioFile(out_filename)); } NetEq::Config config; diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.h b/modules/audio_coding/neteq/tools/neteq_quality_test.h index d995095d99..9b84e239f2 100644 --- a/modules/audio_coding/neteq/tools/neteq_quality_test.h +++ b/modules/audio_coding/neteq/tools/neteq_quality_test.h @@ -11,15 +11,22 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_QUALITY_TEST_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_QUALITY_TEST_H_ +#include +#include #include #include +#include +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/neteq/neteq.h" +#include "api/rtp_headers.h" +#include "api/scoped_refptr.h" #include "modules/audio_coding/neteq/tools/audio_sink.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "modules/audio_coding/neteq/tools/rtp_generator.h" -#include "system_wrappers/include/clock.h" +#include "rtc_base/buffer.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/neteq_replacement_input.cc b/modules/audio_coding/neteq/tools/neteq_replacement_input.cc index 2fb53d8b3f..374279fb2e 100644 --- a/modules/audio_coding/neteq/tools/neteq_replacement_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_replacement_input.cc @@ -10,7 +10,16 @@ #include "modules/audio_coding/neteq/tools/neteq_replacement_input.h" +#include +#include +#include +#include +#include +#include + +#include "api/rtp_headers.h" #include "modules/audio_coding/neteq/tools/fake_decode_from_file.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/neteq_replacement_input.h b/modules/audio_coding/neteq/tools/neteq_replacement_input.h index 33d8138812..a7efbc1f16 100644 --- a/modules/audio_coding/neteq/tools/neteq_replacement_input.h +++ b/modules/audio_coding/neteq/tools/neteq_replacement_input.h @@ -11,9 +11,12 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_REPLACEMENT_INPUT_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_REPLACEMENT_INPUT_H_ +#include #include +#include #include +#include "api/rtp_headers.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc index b3c29c1b8e..29831dca6a 100644 --- a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc @@ -10,8 +10,18 @@ #include "modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h" +#include +#include +#include +#include +#include + #include "absl/strings/string_view.h" +#include "api/rtp_headers.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" +#include "modules/audio_coding/neteq/tools/packet.h" #include "modules/audio_coding/neteq/tools/rtp_file_source.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h index da03732a2a..771be08036 100644 --- a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h +++ b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h @@ -11,6 +11,7 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_RTP_DUMP_INPUT_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_RTP_DUMP_INPUT_H_ +#include #include #include #include diff --git a/modules/audio_coding/neteq/tools/neteq_stats_getter.cc b/modules/audio_coding/neteq/tools/neteq_stats_getter.cc index 2c4e7bc6a4..4c3ced72ee 100644 --- a/modules/audio_coding/neteq/tools/neteq_stats_getter.cc +++ b/modules/audio_coding/neteq/tools/neteq_stats_getter.cc @@ -11,9 +11,15 @@ #include "modules/audio_coding/neteq/tools/neteq_stats_getter.h" #include +#include +#include #include +#include #include +#include "api/audio/audio_frame.h" +#include "api/neteq/neteq.h" +#include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/time_utils.h" diff --git a/modules/audio_coding/neteq/tools/neteq_stats_getter.h b/modules/audio_coding/neteq/tools/neteq_stats_getter.h index b1b12bb1f8..83ed4f3afa 100644 --- a/modules/audio_coding/neteq/tools/neteq_stats_getter.h +++ b/modules/audio_coding/neteq/tools/neteq_stats_getter.h @@ -11,10 +11,15 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_STATS_GETTER_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_STATS_GETTER_H_ +#include +#include #include #include +#include #include +#include "api/audio/audio_frame.h" +#include "api/neteq/neteq.h" #include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" diff --git a/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc b/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc index 47bcd314bc..f207199226 100644 --- a/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc +++ b/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc @@ -13,9 +13,14 @@ #include #include +#include +#include +#include #include #include "absl/strings/string_view.h" +#include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" +#include "modules/audio_coding/neteq/tools/neteq_stats_getter.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/neteq_stats_plotter.h b/modules/audio_coding/neteq/tools/neteq_stats_plotter.h index 11c16da9d1..d1f5e67a50 100644 --- a/modules/audio_coding/neteq/tools/neteq_stats_plotter.h +++ b/modules/audio_coding/neteq/tools/neteq_stats_plotter.h @@ -11,11 +11,11 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_STATS_PLOTTER_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_STATS_PLOTTER_H_ +#include #include #include #include "absl/strings/string_view.h" -#include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h" #include "modules/audio_coding/neteq/tools/neteq_stats_getter.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" diff --git a/modules/audio_coding/neteq/tools/neteq_test.cc b/modules/audio_coding/neteq/tools/neteq_test.cc index 67cd892f85..2baea86b46 100644 --- a/modules/audio_coding/neteq/tools/neteq_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_test.cc @@ -10,15 +10,34 @@ #include "modules/audio_coding/neteq/tools/neteq_test.h" +#include +#include +#include #include #include +#include +#include +#include +#include +#include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/field_trials.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" +#include "api/neteq/neteq_factory.h" +#include "api/scoped_refptr.h" +#include "api/test/neteq_simulator.h" #include "api/units/timestamp.h" +#include "modules/audio_coding/neteq/tools/audio_sink.h" +#include "modules/audio_coding/neteq/tools/neteq_input.h" #include "modules/rtp_rtcp/source/byte_io.h" +#include "rtc_base/checks.h" #include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/neteq_test.h b/modules/audio_coding/neteq/tools/neteq_test.h index b576b3fea8..8717cd0424 100644 --- a/modules/audio_coding/neteq/tools/neteq_test.h +++ b/modules/audio_coding/neteq/tools/neteq_test.h @@ -11,17 +11,19 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_TEST_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_TEST_H_ +#include #include #include #include #include -#include -#include +#include "absl/strings/string_view.h" #include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/neteq/neteq.h" #include "api/neteq/neteq_factory.h" +#include "api/scoped_refptr.h" #include "api/test/neteq_simulator.h" #include "modules/audio_coding/neteq/tools/audio_sink.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" diff --git a/modules/audio_coding/neteq/tools/neteq_test_factory.cc b/modules/audio_coding/neteq/tools/neteq_test_factory.cc index f74d211089..857c633859 100644 --- a/modules/audio_coding/neteq/tools/neteq_test_factory.cc +++ b/modules/audio_coding/neteq/tools/neteq_test_factory.cc @@ -60,9 +60,8 @@ namespace webrtc { namespace test { namespace { -std::optional CodecSampleRate( - uint8_t payload_type, - webrtc::test::NetEqTestFactory::Config config) { +std::optional CodecSampleRate(uint8_t payload_type, + test::NetEqTestFactory::Config config) { if (payload_type == config.pcmu || payload_type == config.pcma || payload_type == config.pcm16b || payload_type == config.cn_nb || payload_type == config.avt) @@ -298,9 +297,9 @@ std::unique_ptr NetEqTestFactory::InitializeTest( std::set cn_types = std_set_int32_to_uint8( {config.cn_nb, config.cn_wb, config.cn_swb32, config.cn_swb48}); - std::set forbidden_types = std_set_int32_to_uint8( - {config.g722, config.red, config.opus_red, config.avt, config.avt_16, - config.avt_32, config.avt_48}); + std::set forbidden_types = + std_set_int32_to_uint8({config.g722, config.red, config.avt, + config.avt_16, config.avt_32, config.avt_48}); input.reset(new NetEqReplacementInput(std::move(input), replacement_pt, cn_types, forbidden_types)); diff --git a/modules/audio_coding/neteq/tools/output_audio_file.h b/modules/audio_coding/neteq/tools/output_audio_file.h index 25577fc882..8afc37b92a 100644 --- a/modules/audio_coding/neteq/tools/output_audio_file.h +++ b/modules/audio_coding/neteq/tools/output_audio_file.h @@ -13,10 +13,12 @@ #include +#include #include #include "absl/strings/string_view.h" #include "modules/audio_coding/neteq/tools/audio_sink.h" +#include "rtc_base/checks.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/output_wav_file.h b/modules/audio_coding/neteq/tools/output_wav_file.h index 20eedfb554..5a39aef3b9 100644 --- a/modules/audio_coding/neteq/tools/output_wav_file.h +++ b/modules/audio_coding/neteq/tools/output_wav_file.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_OUTPUT_WAV_FILE_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_OUTPUT_WAV_FILE_H_ -#include +#include +#include #include "absl/strings/string_view.h" #include "common_audio/wav_file.h" diff --git a/modules/audio_coding/neteq/tools/packet.cc b/modules/audio_coding/neteq/tools/packet.cc index 42480e0115..3e9ef26f66 100644 --- a/modules/audio_coding/neteq/tools/packet.cc +++ b/modules/audio_coding/neteq/tools/packet.cc @@ -10,7 +10,14 @@ #include "modules/audio_coding/neteq/tools/packet.h" +#include +#include +#include +#include + #include "api/array_view.h" +#include "api/rtp_headers.h" +#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" @@ -88,7 +95,7 @@ void Packet::DeleteRedHeaders(std::list* headers) { bool Packet::ParseHeader(const RtpHeaderExtensionMap* extension_map) { // Use RtpPacketReceived instead of RtpPacket because former already has a // converter into legacy RTPHeader. - webrtc::RtpPacketReceived rtp_packet(extension_map); + RtpPacketReceived rtp_packet(extension_map); // Because of the special case of dummy packets that have padding marked in // the RTP header, but do not have rtp payload with the padding size, handle diff --git a/modules/audio_coding/neteq/tools/packet.h b/modules/audio_coding/neteq/tools/packet.h index a94a0fdc5e..6d13ba6d4e 100644 --- a/modules/audio_coding/neteq/tools/packet.h +++ b/modules/audio_coding/neteq/tools/packet.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_H_ +#include +#include #include #include "api/array_view.h" diff --git a/modules/audio_coding/neteq/tools/packet_source.cc b/modules/audio_coding/neteq/tools/packet_source.cc index 598ae6edd4..dd7674c051 100644 --- a/modules/audio_coding/neteq/tools/packet_source.cc +++ b/modules/audio_coding/neteq/tools/packet_source.cc @@ -10,6 +10,8 @@ #include "modules/audio_coding/neteq/tools/packet_source.h" +#include + namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/packet_source.h b/modules/audio_coding/neteq/tools/packet_source.h index be1705cae1..68de0d51ed 100644 --- a/modules/audio_coding/neteq/tools/packet_source.h +++ b/modules/audio_coding/neteq/tools/packet_source.h @@ -12,6 +12,7 @@ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_SOURCE_H_ #include +#include #include #include "modules/audio_coding/neteq/tools/packet.h" diff --git a/modules/audio_coding/neteq/tools/packet_unittest.cc b/modules/audio_coding/neteq/tools/packet_unittest.cc index a935ff6477..df516d885c 100644 --- a/modules/audio_coding/neteq/tools/packet_unittest.cc +++ b/modules/audio_coding/neteq/tools/packet_unittest.cc @@ -12,6 +12,13 @@ #include "modules/audio_coding/neteq/tools/packet.h" +#include +#include +#include +#include + +#include "api/rtp_headers.h" +#include "rtc_base/copy_on_write_buffer.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/resample_input_audio_file.cc b/modules/audio_coding/neteq/tools/resample_input_audio_file.cc index 5050e1fb17..49e9015e2f 100644 --- a/modules/audio_coding/neteq/tools/resample_input_audio_file.cc +++ b/modules/audio_coding/neteq/tools/resample_input_audio_file.cc @@ -10,8 +10,11 @@ #include "modules/audio_coding/neteq/tools/resample_input_audio_file.h" +#include +#include #include +#include "modules/audio_coding/neteq/tools/input_audio_file.h" #include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/resample_input_audio_file.h b/modules/audio_coding/neteq/tools/resample_input_audio_file.h index 279fece616..0eae44bd37 100644 --- a/modules/audio_coding/neteq/tools/resample_input_audio_file.h +++ b/modules/audio_coding/neteq/tools/resample_input_audio_file.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_RESAMPLE_INPUT_AUDIO_FILE_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_RESAMPLE_INPUT_AUDIO_FILE_H_ -#include +#include +#include #include "absl/strings/string_view.h" #include "common_audio/resampler/include/resampler.h" diff --git a/modules/audio_coding/neteq/tools/rtp_analyze.cc b/modules/audio_coding/neteq/tools/rtp_analyze.cc index 8e94cbdc05..a4bf3dfe7f 100644 --- a/modules/audio_coding/neteq/tools/rtp_analyze.cc +++ b/modules/audio_coding/neteq/tools/rtp_analyze.cc @@ -10,13 +10,19 @@ #include +#include +#include #include +#include #include #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "api/rtp_headers.h" #include "modules/audio_coding/neteq/tools/packet.h" #include "modules/audio_coding/neteq/tools/rtp_file_source.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "rtc_base/checks.h" ABSL_FLAG(int, red, 117, "RTP payload type for RED"); ABSL_FLAG(int, diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.cc b/modules/audio_coding/neteq/tools/rtp_file_source.cc index 437b560543..4a83cf70fa 100644 --- a/modules/audio_coding/neteq/tools/rtp_file_source.cc +++ b/modules/audio_coding/neteq/tools/rtp_file_source.cc @@ -57,7 +57,7 @@ std::unique_ptr RtpFileSource::NextPacket() { while (true) { RtpPacket temp_packet; if (!rtp_reader_->NextPacket(&temp_packet)) { - return NULL; + return nullptr; } if (temp_packet.original_length == 0) { // May be an RTCP packet. diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.h b/modules/audio_coding/neteq/tools/rtp_file_source.h index 300981a025..47005ca273 100644 --- a/modules/audio_coding/neteq/tools/rtp_file_source.h +++ b/modules/audio_coding/neteq/tools/rtp_file_source.h @@ -13,12 +13,14 @@ #include +#include #include #include -#include #include "absl/strings/string_view.h" +#include "modules/audio_coding/neteq/tools/packet.h" #include "modules/audio_coding/neteq/tools/packet_source.h" +#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/rtp_generator.cc b/modules/audio_coding/neteq/tools/rtp_generator.cc index 5633f11b86..56c799f125 100644 --- a/modules/audio_coding/neteq/tools/rtp_generator.cc +++ b/modules/audio_coding/neteq/tools/rtp_generator.cc @@ -10,6 +10,12 @@ #include "modules/audio_coding/neteq/tools/rtp_generator.h" +#include +#include + +#include "api/rtp_headers.h" +#include "rtc_base/checks.h" + namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/rtp_generator.h b/modules/audio_coding/neteq/tools/rtp_generator.h index 2e615adec5..526a995672 100644 --- a/modules/audio_coding/neteq/tools/rtp_generator.h +++ b/modules/audio_coding/neteq/tools/rtp_generator.h @@ -11,6 +11,9 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ +#include +#include + #include "api/rtp_headers.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/tools/rtp_jitter.cc b/modules/audio_coding/neteq/tools/rtp_jitter.cc index 23fc35f657..419a99a4b7 100644 --- a/modules/audio_coding/neteq/tools/rtp_jitter.cc +++ b/modules/audio_coding/neteq/tools/rtp_jitter.cc @@ -11,13 +11,17 @@ #include #include +#include #include #include +#include +#include #include #include "api/array_view.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "rtc_base/buffer.h" +#include "rtc_base/checks.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/rtpcat.cc b/modules/audio_coding/neteq/tools/rtpcat.cc index 431de553ae..9e91490512 100644 --- a/modules/audio_coding/neteq/tools/rtpcat.cc +++ b/modules/audio_coding/neteq/tools/rtpcat.cc @@ -10,6 +10,7 @@ #include +#include #include #include "rtc_base/checks.h" @@ -28,13 +29,13 @@ int main(int argc, char* argv[]) { std::unique_ptr output( RtpFileWriter::Create(RtpFileWriter::kRtpDump, argv[argc - 1])); - RTC_CHECK(output.get() != NULL) << "Cannot open output file."; + RTC_CHECK(output.get() != nullptr) << "Cannot open output file."; printf("Output RTP file: %s\n", argv[argc - 1]); for (int i = 1; i < argc - 1; i++) { std::unique_ptr input( RtpFileReader::Create(RtpFileReader::kRtpDump, argv[i])); - RTC_CHECK(input.get() != NULL) << "Cannot open input file " << argv[i]; + RTC_CHECK(input.get() != nullptr) << "Cannot open input file " << argv[i]; printf("Input RTP file: %s\n", argv[i]); webrtc::test::RtpPacket packet; diff --git a/modules/audio_coding/neteq/underrun_optimizer.cc b/modules/audio_coding/neteq/underrun_optimizer.cc index d1f12e9bfd..dcee8e19fe 100644 --- a/modules/audio_coding/neteq/underrun_optimizer.cc +++ b/modules/audio_coding/neteq/underrun_optimizer.cc @@ -11,6 +11,9 @@ #include "modules/audio_coding/neteq/underrun_optimizer.h" #include +#include + +#include "api/neteq/tick_timer.h" namespace webrtc { diff --git a/modules/audio_coding/neteq/underrun_optimizer_unittest.cc b/modules/audio_coding/neteq/underrun_optimizer_unittest.cc index 0988e03d73..e782cdb180 100644 --- a/modules/audio_coding/neteq/underrun_optimizer_unittest.cc +++ b/modules/audio_coding/neteq/underrun_optimizer_unittest.cc @@ -10,6 +10,9 @@ #include "modules/audio_coding/neteq/underrun_optimizer.h" +#include + +#include "api/neteq/tick_timer.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/audio_coding/test/Channel.cc b/modules/audio_coding/test/Channel.cc index 4c91f5948a..5d3c2192d3 100644 --- a/modules/audio_coding/test/Channel.cc +++ b/modules/audio_coding/test/Channel.cc @@ -10,8 +10,17 @@ #include "modules/audio_coding/test/Channel.h" -#include +#include +#include +#include +#include +#include "api/array_view.h" +#include "api/neteq/neteq.h" +#include "api/rtp_headers.h" +#include "api/units/timestamp.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" +#include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/time_utils.h" @@ -108,7 +117,7 @@ void Channel::CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize) { _lastPayloadType = rtp_header.payloadType; bool newPayload = true; - ACMTestPayloadStats* currentPayloadStr = NULL; + ACMTestPayloadStats* currentPayloadStr = nullptr; for (n = 0; n < MAX_NUM_PAYLOADS; n++) { if (rtp_header.payloadType == _payloadStats[n].payloadType) { newPayload = false; @@ -187,9 +196,9 @@ void Channel::CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize) { } Channel::Channel(int16_t chID) - : _neteq(NULL), + : _neteq(nullptr), _seqNo(0), - _bitStreamFile(NULL), + _bitStreamFile(nullptr), _saveBitStream(false), _lastPayloadType(-1), _isStereo(false), diff --git a/modules/audio_coding/test/Channel.h b/modules/audio_coding/test/Channel.h index 616e283647..364f4e35ea 100644 --- a/modules/audio_coding/test/Channel.h +++ b/modules/audio_coding/test/Channel.h @@ -13,9 +13,11 @@ #include +#include + #include "api/neteq/neteq.h" #include "modules/audio_coding/include/audio_coding_module.h" -#include "modules/include/module_common_types.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "rtc_base/synchronization/mutex.h" namespace webrtc { diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc index f50fb15e48..ab298064d4 100644 --- a/modules/audio_coding/test/EncodeDecodeTest.cc +++ b/modules/audio_coding/test/EncodeDecodeTest.cc @@ -13,15 +13,24 @@ #include #include +#include +#include #include +#include #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" +#include "api/units/timestamp.h" #include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" +#include "modules/audio_coding/test/RTPFile.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -52,7 +61,7 @@ int32_t TestPacketization::SendData( } Sender::Sender() - : _acm(NULL), _pcmFile(), _audioFrame(), _packetization(NULL) {} + : _acm(nullptr), _pcmFile(), _audioFrame(), _packetization(nullptr) {} void Sender::Setup(const Environment& env, AudioCodingModule* acm, @@ -62,7 +71,7 @@ void Sender::Setup(const Environment& env, int payload_type, SdpAudioFormat format) { // Open input file - const std::string file_name = webrtc::test::ResourcePath(in_file_name, "pcm"); + const std::string file_name = test::ResourcePath(in_file_name, "pcm"); _pcmFile.Open(file_name, in_sample_rate, "rb"); if (format.num_channels == 2) { _pcmFile.ReadStereo(true); @@ -137,8 +146,7 @@ void Receiver::Setup(NetEq* neteq, int playSampFreq; std::string file_name; StringBuilder file_stream; - file_stream << webrtc::test::OutputPath() << out_file_name << file_num - << ".pcm"; + file_stream << test::OutputPath() << out_file_name << file_num << ".pcm"; file_name = file_stream.str(); _rtpStream = rtpStream; @@ -250,8 +258,8 @@ void EncodeDecodeTest::Perform() { RTPFile rtpFile; std::unique_ptr acm(AudioCodingModule::Create()); - std::string fileName = webrtc::test::TempFilename( - webrtc::test::OutputPath(), "encode_decode_rtp"); + std::string fileName = + test::TempFilename(test::OutputPath(), "encode_decode_rtp"); rtpFile.Open(fileName.c_str(), "wb+"); rtpFile.WriteHeader(); Sender sender; diff --git a/modules/audio_coding/test/EncodeDecodeTest.h b/modules/audio_coding/test/EncodeDecodeTest.h index 8a20998cd7..f3c4580f10 100644 --- a/modules/audio_coding/test/EncodeDecodeTest.h +++ b/modules/audio_coding/test/EncodeDecodeTest.h @@ -14,14 +14,17 @@ #include #include +#include + #include "absl/strings/string_view.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/neteq/neteq.h" #include "modules/audio_coding/acm2/acm_resampler.h" #include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/audio_coding/test/PCMFile.h" #include "modules/audio_coding/test/RTPFile.h" -#include "modules/include/module_common_types.h" namespace webrtc { diff --git a/modules/audio_coding/test/PCMFile.cc b/modules/audio_coding/test/PCMFile.cc index e069a42de1..b6c0d4c5cc 100644 --- a/modules/audio_coding/test/PCMFile.cc +++ b/modules/audio_coding/test/PCMFile.cc @@ -14,7 +14,12 @@ #include #include +#include +#include +#include + #include "absl/strings/string_view.h" +#include "api/audio/audio_frame.h" #include "rtc_base/checks.h" #include "test/gtest.h" @@ -23,7 +28,7 @@ namespace webrtc { #define MAX_FILE_NAME_LENGTH_BYTE 500 PCMFile::PCMFile() - : pcm_file_(NULL), + : pcm_file_(nullptr), samples_10ms_(160), frequency_(16000), end_of_file_(false), @@ -36,7 +41,7 @@ PCMFile::PCMFile() } PCMFile::PCMFile(uint32_t timestamp) - : pcm_file_(NULL), + : pcm_file_(nullptr), samples_10ms_(160), frequency_(16000), end_of_file_(false), @@ -58,7 +63,7 @@ int16_t PCMFile::ChooseFile(std::string* file_name, uint16_t* frequency_hz) { char tmp_name[MAX_FILE_NAME_LENGTH_BYTE]; - EXPECT_TRUE(fgets(tmp_name, MAX_FILE_NAME_LENGTH_BYTE, stdin) != NULL); + EXPECT_TRUE(fgets(tmp_name, MAX_FILE_NAME_LENGTH_BYTE, stdin) != nullptr); tmp_name[MAX_FILE_NAME_LENGTH_BYTE - 1] = '\0'; int16_t n = 0; @@ -96,7 +101,7 @@ int16_t PCMFile::ChooseFile(std::string* file_name, } printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequency_hz); - EXPECT_TRUE(fgets(tmp_name, 10, stdin) != NULL); + EXPECT_TRUE(fgets(tmp_name, 10, stdin) != nullptr); uint16_t tmp_frequency = (uint16_t)atoi(tmp_name); if (tmp_frequency > 0) { *frequency_hz = tmp_frequency; @@ -109,7 +114,7 @@ void PCMFile::Open(absl::string_view file_name, absl::string_view mode, bool auto_rewind) { if ((pcm_file_ = fopen(std::string(file_name).c_str(), - std::string(mode).c_str())) == NULL) { + std::string(mode).c_str())) == nullptr) { printf("Cannot open file %s.\n", std::string(file_name).c_str()); ADD_FAILURE() << "Unable to read file"; } @@ -203,7 +208,7 @@ void PCMFile::Write10MsData(const int16_t* playout_buffer, void PCMFile::Close() { fclose(pcm_file_); - pcm_file_ = NULL; + pcm_file_ = nullptr; blocks_read_ = 0; } diff --git a/modules/audio_coding/test/PCMFile.h b/modules/audio_coding/test/PCMFile.h index 64af5df007..f0212f3b0a 100644 --- a/modules/audio_coding/test/PCMFile.h +++ b/modules/audio_coding/test/PCMFile.h @@ -14,6 +14,7 @@ #include #include +#include #include #include diff --git a/modules/audio_coding/test/PacketLossTest.cc b/modules/audio_coding/test/PacketLossTest.cc index 41737521b7..59b5309c80 100644 --- a/modules/audio_coding/test/PacketLossTest.cc +++ b/modules/audio_coding/test/PacketLossTest.cc @@ -10,14 +10,23 @@ #include "modules/audio_coding/test/PacketLossTest.h" +#include #include +#include #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" #include "api/units/timestamp.h" +#include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/test/EncodeDecodeTest.h" +#include "modules/audio_coding/test/RTPFile.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -150,8 +159,8 @@ void PacketLossTest::Perform() { send_format.parameters = {{"stereo", "1"}}; } - std::string fileName = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "packet_loss_test"); + std::string fileName = + test::TempFilename(test::OutputPath(), "packet_loss_test"); rtpFile.Open(fileName.c_str(), "wb+"); rtpFile.WriteHeader(); SenderWithFEC sender; diff --git a/modules/audio_coding/test/PacketLossTest.h b/modules/audio_coding/test/PacketLossTest.h index 41a62d519a..8bb80ca5cf 100644 --- a/modules/audio_coding/test/PacketLossTest.h +++ b/modules/audio_coding/test/PacketLossTest.h @@ -14,7 +14,12 @@ #include #include "absl/strings/string_view.h" +#include "api/audio_codecs/audio_format.h" +#include "api/environment/environment.h" +#include "api/neteq/neteq.h" +#include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/test/EncodeDecodeTest.h" +#include "modules/audio_coding/test/RTPFile.h" namespace webrtc { diff --git a/modules/audio_coding/test/RTPFile.cc b/modules/audio_coding/test/RTPFile.cc index 0c2ab3c443..adb12fc630 100644 --- a/modules/audio_coding/test/RTPFile.cc +++ b/modules/audio_coding/test/RTPFile.cc @@ -11,15 +11,22 @@ #include "RTPFile.h" #include +#include +#include +#include +#include #include +#include #include "absl/strings/string_view.h" +#include "api/rtp_headers.h" +#include "rtc_base/ip_address.h" +#include "rtc_base/synchronization/mutex.h" #ifdef WIN32 #include #else -#include #endif // TODO(tlegrand): Consider removing usage of gtest. @@ -127,7 +134,7 @@ bool RTPBuffer::EndOfFile() const { void RTPFile::Open(absl::string_view filename, absl::string_view mode) { std::string filename_str = std::string(filename); if ((_rtpFile = fopen(filename_str.c_str(), std::string(mode).c_str())) == - NULL) { + nullptr) { printf("Cannot write file %s.\n", filename_str.c_str()); ADD_FAILURE() << "Unable to write file"; exit(1); @@ -135,9 +142,9 @@ void RTPFile::Open(absl::string_view filename, absl::string_view mode) { } void RTPFile::Close() { - if (_rtpFile != NULL) { + if (_rtpFile != nullptr) { fclose(_rtpFile); - _rtpFile = NULL; + _rtpFile = nullptr; } } @@ -158,7 +165,7 @@ void RTPFile::ReadHeader() { uint32_t start_sec, start_usec, source; uint16_t port, padding; char fileHeader[40]; - EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != 0); + EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != nullptr); EXPECT_EQ(1u, fread(&start_sec, 4, 1, _rtpFile)); start_sec = ntohl(start_sec); EXPECT_EQ(1u, fread(&start_usec, 4, 1, _rtpFile)); diff --git a/modules/audio_coding/test/RTPFile.h b/modules/audio_coding/test/RTPFile.h index b796491da9..0598a60e4f 100644 --- a/modules/audio_coding/test/RTPFile.h +++ b/modules/audio_coding/test/RTPFile.h @@ -13,6 +13,7 @@ #include +#include #include #include "absl/strings/string_view.h" diff --git a/modules/audio_coding/test/TestAllCodecs.cc b/modules/audio_coding/test/TestAllCodecs.cc index e0ef536b3a..cbf04a43d0 100644 --- a/modules/audio_coding/test/TestAllCodecs.cc +++ b/modules/audio_coding/test/TestAllCodecs.cc @@ -10,21 +10,27 @@ #include "modules/audio_coding/test/TestAllCodecs.h" +#include #include +#include #include #include #include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "api/array_view.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" #include "api/neteq/neteq.h" +#include "api/rtp_headers.h" +#include "api/units/timestamp.h" #include "modules/audio_coding/acm2/acm_resampler.h" +#include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" -#include "modules/include/module_common_types.h" -#include "rtc_base/logging.h" -#include "rtc_base/string_encode.h" +#include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -50,7 +56,7 @@ namespace webrtc { // Class for simulating packet handling. TestPack::TestPack() - : neteq_(NULL), + : neteq_(nullptr), sequence_number_(0), timestamp_diff_(0), last_in_timestamp_(0), @@ -115,21 +121,21 @@ TestAllCodecs::TestAllCodecs() neteq_(DefaultNetEqFactory().Create(env_, NetEq::Config(), CreateBuiltinAudioDecoderFactory())), - channel_a_to_b_(NULL), + channel_a_to_b_(nullptr), test_count_(0), packet_size_samples_(0), packet_size_bytes_(0) {} TestAllCodecs::~TestAllCodecs() { - if (channel_a_to_b_ != NULL) { + if (channel_a_to_b_ != nullptr) { delete channel_a_to_b_; - channel_a_to_b_ = NULL; + channel_a_to_b_ = nullptr; } } void TestAllCodecs::Perform() { const std::string file_name = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); infile_a_.Open(file_name, 32000, "rb"); neteq_->SetCodecs({{107, {"L16", 8000, 1}}, @@ -372,7 +378,7 @@ void TestAllCodecs::Run(TestPack* channel) { } void TestAllCodecs::OpenOutFile(int test_number) { - std::string filename = webrtc::test::OutputPath(); + std::string filename = test::OutputPath(); StringBuilder test_number_str; test_number_str << test_number; filename += "testallcodecs_out_"; diff --git a/modules/audio_coding/test/TestAllCodecs.h b/modules/audio_coding/test/TestAllCodecs.h index 0712332a5e..25302ee81f 100644 --- a/modules/audio_coding/test/TestAllCodecs.h +++ b/modules/audio_coding/test/TestAllCodecs.h @@ -11,10 +11,13 @@ #ifndef MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_ #define MODULES_AUDIO_CODING_TEST_TESTALLCODECS_H_ +#include +#include #include #include "api/environment/environment.h" #include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/audio_coding/test/PCMFile.h" namespace webrtc { diff --git a/modules/audio_coding/test/TestRedFec.cc b/modules/audio_coding/test/TestRedFec.cc index 1900c905fc..965eb69506 100644 --- a/modules/audio_coding/test/TestRedFec.cc +++ b/modules/audio_coding/test/TestRedFec.cc @@ -10,14 +10,22 @@ #include "modules/audio_coding/test/TestRedFec.h" +#include +#include +#include #include +#include +#include #include #include "absl/strings/match.h" +#include "api/audio/audio_frame.h" #include "api/audio_codecs/L16/audio_decoder_L16.h" #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "api/audio_codecs/audio_decoder_factory_template.h" +#include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory_template.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/g711/audio_decoder_g711.h" #include "api/audio_codecs/g711/audio_encoder_g711.h" #include "api/audio_codecs/g722/audio_decoder_g722.h" @@ -26,9 +34,12 @@ #include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" +#include "common_audio/vad/include/vad.h" #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" #include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h" -#include "modules/audio_coding/include/audio_coding_module_typedefs.h" +#include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/test/Channel.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -49,19 +60,19 @@ TestRedFec::TestRedFec() _neteq(DefaultNetEqFactory().Create(env_, NetEq::Config(), decoder_factory_)), - _channelA2B(NULL), + _channelA2B(nullptr), _testCntr(0) {} TestRedFec::~TestRedFec() { - if (_channelA2B != NULL) { + if (_channelA2B != nullptr) { delete _channelA2B; - _channelA2B = NULL; + _channelA2B = nullptr; } } void TestRedFec::Perform() { const std::string file_name = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); _inFileA.Open(file_name, 32000, "rb"); // Create and connect the channel @@ -193,7 +204,7 @@ void TestRedFec::Run() { void TestRedFec::OpenOutFile(int16_t test_number) { std::string file_name; StringBuilder file_stream; - file_stream << webrtc::test::OutputPath(); + file_stream << test::OutputPath(); file_stream << "TestRedFec_outFile_"; file_stream << test_number << ".pcm"; file_name = file_stream.str(); diff --git a/modules/audio_coding/test/TestRedFec.h b/modules/audio_coding/test/TestRedFec.h index 3016b3889a..112de845aa 100644 --- a/modules/audio_coding/test/TestRedFec.h +++ b/modules/audio_coding/test/TestRedFec.h @@ -11,15 +11,19 @@ #ifndef MODULES_AUDIO_CODING_TEST_TESTREDFEC_H_ #define MODULES_AUDIO_CODING_TEST_TESTREDFEC_H_ +#include #include -#include +#include #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_encoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/neteq/neteq.h" +#include "api/scoped_refptr.h" #include "common_audio/vad/include/vad.h" #include "modules/audio_coding/acm2/acm_resampler.h" +#include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/test/Channel.h" #include "modules/audio_coding/test/PCMFile.h" #include "test/scoped_key_value_config.h" diff --git a/modules/audio_coding/test/TestStereo.cc b/modules/audio_coding/test/TestStereo.cc index 8a9a973d21..78b0d8ca74 100644 --- a/modules/audio_coding/test/TestStereo.cc +++ b/modules/audio_coding/test/TestStereo.cc @@ -10,15 +10,30 @@ #include "modules/audio_coding/test/TestStereo.h" +#include +#include +#include +#include #include +#include #include "absl/strings/match.h" +#include "absl/strings/str_cat.h" +#include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" +#include "api/rtp_headers.h" +#include "api/rtp_parameters.h" +#include "api/units/timestamp.h" +#include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" -#include "modules/include/module_common_types.h" +#include "modules/audio_coding/test/PCMFile.h" +#include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -27,7 +42,7 @@ namespace webrtc { // Class for simulating packet handling TestPackStereo::TestPackStereo() - : neteq_(NULL), + : neteq_(nullptr), seq_no_(0), timestamp_diff_(0), last_in_timestamp_(0), @@ -105,16 +120,16 @@ TestStereo::TestStereo() neteq_(DefaultNetEqFactory().Create(env_, NetEq::Config(), CreateBuiltinAudioDecoderFactory())), - channel_a2b_(NULL), + channel_a2b_(nullptr), test_cntr_(0), pack_size_samp_(0), pack_size_bytes_(0), counter_(0) {} TestStereo::~TestStereo() { - if (channel_a2b_ != NULL) { + if (channel_a2b_ != nullptr) { delete channel_a2b_; - channel_a2b_ = NULL; + channel_a2b_ = nullptr; } } @@ -125,9 +140,9 @@ void TestStereo::Perform() { // Open both mono and stereo test files in 32 kHz. const std::string file_name_stereo = - webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"); + test::ResourcePath("audio_coding/teststereo32kHz", "pcm"); const std::string file_name_mono = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); frequency_hz = 32000; in_file_stereo_ = new PCMFile(); in_file_mono_ = new PCMFile(); @@ -137,7 +152,7 @@ void TestStereo::Perform() { in_file_mono_->ReadStereo(false); // Create and initialize two ACMs, one for each side of a one-to-one call. - ASSERT_TRUE((acm_a_.get() != NULL) && (neteq_.get() != NULL)); + ASSERT_TRUE((acm_a_.get() != nullptr) && (neteq_.get() != nullptr)); neteq_->FlushBuffers(); neteq_->SetCodecs({{103, {"ISAC", 16000, 1}}, @@ -459,7 +474,7 @@ void TestStereo::RegisterSendCodec(char side, 0.875); // Set pointer to the ACM where to register the codec - AudioCodingModule* my_acm = NULL; + AudioCodingModule* my_acm = nullptr; switch (side) { case 'A': { my_acm = acm_a_.get(); @@ -474,7 +489,7 @@ void TestStereo::RegisterSendCodec(char side, default: break; } - ASSERT_TRUE(my_acm != NULL); + ASSERT_TRUE(my_acm != nullptr); auto encoder_factory = CreateBuiltinAudioEncoderFactory(); const int clockrate_hz = absl::EqualsIgnoreCase(codec_name, "g722") @@ -603,7 +618,7 @@ void TestStereo::Run(TestPackStereo* channel, void TestStereo::OpenOutFile(int16_t test_number) { std::string file_name; StringBuilder file_stream; - file_stream << webrtc::test::OutputPath() << "teststereo_out_" << test_number + file_stream << test::OutputPath() << "teststereo_out_" << test_number << ".pcm"; file_name = file_stream.str(); out_file_.Open(file_name, 32000, "wb"); diff --git a/modules/audio_coding/test/TestStereo.h b/modules/audio_coding/test/TestStereo.h index 7f315695d0..e7a10734d8 100644 --- a/modules/audio_coding/test/TestStereo.h +++ b/modules/audio_coding/test/TestStereo.h @@ -13,12 +13,15 @@ #include +#include +#include #include #include "api/environment/environment.h" #include "api/neteq/neteq.h" #include "modules/audio_coding/acm2/acm_resampler.h" #include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/audio_coding/test/PCMFile.h" #define PCMA_AND_PCMU diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc index d03f1aed49..ee0fb79f5c 100644 --- a/modules/audio_coding/test/TestVADDTX.cc +++ b/modules/audio_coding/test/TestVADDTX.cc @@ -10,17 +10,33 @@ #include "modules/audio_coding/test/TestVADDTX.h" +#include +#include +#include +#include +#include +#include +#include #include +#include #include "absl/strings/match.h" #include "absl/strings/string_view.h" +#include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_decoder_factory_template.h" +#include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory_template.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" +#include "common_audio/vad/include/vad.h" #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" +#include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" +#include "modules/audio_coding/test/Channel.h" #include "modules/audio_coding/test/PCMFile.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" @@ -206,9 +222,9 @@ void TestWebRtcVadDtx::Test(bool new_outfile, bool expect_dtx_enabled) { output_file_num_++; } StringBuilder out_filename; - out_filename << webrtc::test::OutputPath() << "testWebRtcVadDtx_outFile_" + out_filename << test::OutputPath() << "testWebRtcVadDtx_outFile_" << output_file_num_ << ".pcm"; - Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, + Run(test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, out_filename.str(), !new_outfile, expects); } @@ -218,13 +234,13 @@ void TestOpusDtx::Perform() { // Register Opus as send codec std::string out_filename = - webrtc::test::OutputPath() + "testOpusDtx_outFile_mono.pcm"; + test::OutputPath() + "testOpusDtx_outFile_mono.pcm"; RegisterCodec({"opus", 48000, 2}, std::nullopt); acm_send_->ModifyEncoder([](std::unique_ptr* encoder_ptr) { (*encoder_ptr)->SetDtx(false); }); - Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, + Run(test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, out_filename, false, expects); acm_send_->ModifyEncoder([](std::unique_ptr* encoder_ptr) { @@ -232,7 +248,7 @@ void TestOpusDtx::Perform() { }); expects[static_cast(AudioFrameType::kEmptyFrame)] = 1; expects[static_cast(AudioFrameType::kAudioFrameCN)] = 1; - Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, + Run(test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1, out_filename, true, expects); } diff --git a/modules/audio_coding/test/TestVADDTX.h b/modules/audio_coding/test/TestVADDTX.h index e37ad03fae..3d2c99e6a0 100644 --- a/modules/audio_coding/test/TestVADDTX.h +++ b/modules/audio_coding/test/TestVADDTX.h @@ -11,13 +11,18 @@ #ifndef MODULES_AUDIO_CODING_TEST_TESTVADDTX_H_ #define MODULES_AUDIO_CODING_TEST_TESTVADDTX_H_ +#include +#include #include +#include #include "absl/strings/string_view.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_encoder_factory.h" +#include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/neteq/neteq.h" +#include "api/scoped_refptr.h" #include "common_audio/vad/include/vad.h" #include "modules/audio_coding/acm2/acm_resampler.h" #include "modules/audio_coding/include/audio_coding_module.h" diff --git a/modules/audio_coding/test/Tester.cc b/modules/audio_coding/test/Tester.cc index 9dbc64500a..f3f2c16081 100644 --- a/modules/audio_coding/test/Tester.cc +++ b/modules/audio_coding/test/Tester.cc @@ -10,10 +10,6 @@ #include -#include -#include - -#include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/test/EncodeDecodeTest.h" #include "modules/audio_coding/test/PacketLossTest.h" #include "modules/audio_coding/test/TestAllCodecs.h" diff --git a/modules/audio_coding/test/opus_test.cc b/modules/audio_coding/test/opus_test.cc index 0438514e7d..6b511c25f5 100644 --- a/modules/audio_coding/test/opus_test.cc +++ b/modules/audio_coding/test/opus_test.cc @@ -10,11 +10,19 @@ #include "modules/audio_coding/test/opus_test.h" +#include +#include +#include +#include #include +#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" #include "modules/audio_coding/codecs/opus/opus_interface.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/audio_coding/test/TestStereo.h" @@ -27,31 +35,31 @@ OpusTest::OpusTest() : neteq_(DefaultNetEqFactory().Create(CreateEnvironment(), NetEq::Config(), CreateBuiltinAudioDecoderFactory())), - channel_a2b_(NULL), + channel_a2b_(nullptr), counter_(0), payload_type_(255), rtp_timestamp_(0) {} OpusTest::~OpusTest() { - if (channel_a2b_ != NULL) { + if (channel_a2b_ != nullptr) { delete channel_a2b_; - channel_a2b_ = NULL; + channel_a2b_ = nullptr; } - if (opus_mono_encoder_ != NULL) { + if (opus_mono_encoder_ != nullptr) { WebRtcOpus_EncoderFree(opus_mono_encoder_); - opus_mono_encoder_ = NULL; + opus_mono_encoder_ = nullptr; } - if (opus_stereo_encoder_ != NULL) { + if (opus_stereo_encoder_ != nullptr) { WebRtcOpus_EncoderFree(opus_stereo_encoder_); - opus_stereo_encoder_ = NULL; + opus_stereo_encoder_ = nullptr; } - if (opus_mono_decoder_ != NULL) { + if (opus_mono_decoder_ != nullptr) { WebRtcOpus_DecoderFree(opus_mono_decoder_); - opus_mono_decoder_ = NULL; + opus_mono_decoder_ = nullptr; } - if (opus_stereo_decoder_ != NULL) { + if (opus_stereo_decoder_ != nullptr) { WebRtcOpus_DecoderFree(opus_stereo_decoder_); - opus_stereo_decoder_ = NULL; + opus_stereo_decoder_ = nullptr; } } @@ -66,9 +74,9 @@ void OpusTest::Perform() { // Open both mono and stereo test files in 32 kHz. const std::string file_name_stereo = - webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"); + test::ResourcePath("audio_coding/teststereo32kHz", "pcm"); const std::string file_name_mono = - webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + test::ResourcePath("audio_coding/testfile32kHz", "pcm"); frequency_hz = 32000; in_file_stereo_.Open(file_name_stereo, frequency_hz, "rb"); in_file_stereo_.ReadStereo(true); @@ -85,7 +93,7 @@ void OpusTest::Perform() { WebRtcOpus_DecoderInit(opus_mono_decoder_); WebRtcOpus_DecoderInit(opus_stereo_decoder_); - ASSERT_TRUE(neteq_.get() != NULL); + ASSERT_TRUE(neteq_.get() != nullptr); neteq_->FlushBuffers(); // Register Opus stereo as receiving codec. @@ -258,11 +266,9 @@ void OpusTest::Run(TestPackStereo* channel, } // If input audio is sampled at 32 kHz, resampling to 48 kHz is required. - EXPECT_EQ(480, resampler_.Resample10Msec( - audio_frame.data(), audio_frame.sample_rate_hz_, 48000, - channels, kBufferSizeSamples - written_samples, - &audio[written_samples])); - written_samples += 480 * channels; + InterleavedView dst(&audio[written_samples], 480, channels); + resampler_.Resample(audio_frame.data_view(), dst); + written_samples += dst.size(); // Sometimes we need to loop over the audio vector to produce the right // number of packets. @@ -308,7 +314,7 @@ void OpusTest::Run(TestPackStereo* channel, size_t total_plc_samples = 0; while (total_plc_samples < frame_length) { int ret = WebRtcOpus_Decode( - opus_mono_decoder_, NULL, 0, + opus_mono_decoder_, nullptr, 0, &out_audio[decoded_samples * channels], &audio_type); EXPECT_EQ(ret, kPlcSamples); decoded_samples += ret; @@ -328,7 +334,7 @@ void OpusTest::Run(TestPackStereo* channel, size_t total_plc_samples = 0; while (total_plc_samples < frame_length) { int ret = WebRtcOpus_Decode( - opus_stereo_decoder_, NULL, 0, + opus_stereo_decoder_, nullptr, 0, &out_audio[decoded_samples * channels], &audio_type); EXPECT_EQ(ret, kPlcSamples); decoded_samples += ret; @@ -389,14 +395,13 @@ void OpusTest::Run(TestPackStereo* channel, void OpusTest::OpenOutFile(int test_number) { std::string file_name; std::stringstream file_stream; - file_stream << webrtc::test::OutputPath() << "opustest_out_" << test_number - << ".pcm"; + file_stream << test::OutputPath() << "opustest_out_" << test_number << ".pcm"; file_name = file_stream.str(); out_file_.Open(file_name, 48000, "wb"); file_stream.str(""); file_name = file_stream.str(); - file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" - << test_number << ".pcm"; + file_stream << test::OutputPath() << "opusstandalone_out_" << test_number + << ".pcm"; file_name = file_stream.str(); out_file_standalone_.Open(file_name, 48000, "wb"); } diff --git a/modules/audio_coding/test/opus_test.h b/modules/audio_coding/test/opus_test.h index a2ae758e55..4d2586ee4b 100644 --- a/modules/audio_coding/test/opus_test.h +++ b/modules/audio_coding/test/opus_test.h @@ -13,11 +13,14 @@ #include +#include +#include #include #include "api/neteq/neteq.h" +#include "common_audio/resampler/include/push_resampler.h" #include "modules/audio_coding/acm2/acm_resampler.h" -#include "modules/audio_coding/codecs/opus/opus_interface.h" +#include "modules/audio_coding/codecs/opus/opus_inst.h" #include "modules/audio_coding/test/PCMFile.h" #include "modules/audio_coding/test/TestStereo.h" @@ -49,7 +52,7 @@ class OpusTest { int counter_; uint8_t payload_type_; uint32_t rtp_timestamp_; - acm2::ACMResampler resampler_; + PushResampler resampler_; WebRtcOpusEncInst* opus_mono_encoder_; WebRtcOpusEncInst* opus_stereo_encoder_; WebRtcOpusDecInst* opus_mono_decoder_; diff --git a/modules/audio_coding/test/target_delay_unittest.cc b/modules/audio_coding/test/target_delay_unittest.cc index 8da125700a..0b26e888c9 100644 --- a/modules/audio_coding/test/target_delay_unittest.cc +++ b/modules/audio_coding/test/target_delay_unittest.cc @@ -8,12 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include +#include #include +#include "api/array_view.h" #include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/environment/environment_factory.h" #include "api/neteq/default_neteq_factory.h" +#include "api/neteq/neteq.h" #include "api/rtp_headers.h" #include "api/units/timestamp.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn index aa4d216b28..9bf81c315f 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -101,7 +101,7 @@ rtc_library("audio_device_name") { deps = [ "//third_party/abseil-cpp/absl/strings:string_view" ] } -rtc_source_set("windows_core_audio_utility") { +rtc_library("windows_core_audio_utility") { if (is_win && !build_with_chromium) { sources = [ "win/core_audio_utility_win.cc", @@ -129,7 +129,7 @@ rtc_source_set("windows_core_audio_utility") { # audio_device_impl target. The goal is to use this new structure and # gradually phase out the old design. # TODO(henrika): currently only supported on Windows. -rtc_source_set("audio_device_module_from_input_and_output") { +rtc_library("audio_device_module_from_input_and_output") { visibility = [ "*" ] if (is_win && !build_with_chromium) { sources = [ @@ -178,6 +178,11 @@ if (!build_with_chromium) { "test_audio_device_impl.cc", "test_audio_device_impl.h", ] + + # TODO: bugs.webrtc.org/413413572 - Mark this build target as testonly or + # or update downstream not to use deprecated function. Explicit poison + # can be removed then. + allow_poison = [ "environment_construction" ] deps = [ ":audio_device_buffer", ":audio_device_default", @@ -187,6 +192,8 @@ if (!build_with_chromium) { "../../api:make_ref_counted", "../../api:scoped_refptr", "../../api/audio:audio_device", + "../../api/environment", + "../../api/environment:environment_factory", "../../api/task_queue", "../../api/units:time_delta", "../../common_audio", @@ -200,6 +207,7 @@ if (!build_with_chromium) { "../../rtc_base:safe_conversions", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", + "../../rtc_base/system:file_wrapper", "../../rtc_base/task_utils:repeating_task", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -238,10 +246,10 @@ if (!build_with_chromium) { "../../rtc_base:logging", "../../rtc_base:platform_thread", "../../rtc_base:stringutils", + "../../rtc_base:threading", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:file_wrapper", - "../../system_wrappers", "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -263,6 +271,7 @@ rtc_library("audio_device_impl") { "../../api:scoped_refptr", "../../api:sequence_checker", "../../api/audio:audio_device", + "../../api/environment", "../../api/task_queue", "../../api/units:time_delta", "../../common_audio", @@ -276,16 +285,16 @@ rtc_library("audio_device_impl") { "../../rtc_base:rtc_event", "../../rtc_base:safe_conversions", "../../rtc_base:stringutils", + "../../rtc_base:threading", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:arch", "../../rtc_base/system:file_wrapper", "../../rtc_base/task_utils:repeating_task", - "../../system_wrappers", - "../../system_wrappers:field_trial", "../../system_wrappers:metrics", "../utility", "//third_party/abseil-cpp/absl/base:core_headers", + "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", ] if (rtc_include_internal_audio_device && is_ios) { @@ -317,8 +326,6 @@ rtc_library("audio_device_impl") { "include/audio_device_data_observer.h", ] if (is_android) { - deps += [ "../../sdk/android:native_api_audio_device_module" ] - if (build_with_mozilla) { include_dirs += [ "/config/external/nspr", @@ -457,6 +464,9 @@ if (rtc_include_tests && !build_with_chromium) { "../../api:scoped_refptr", "../../api:sequence_checker", "../../api/audio:audio_device", + "../../api/audio:create_audio_device_module", + "../../api/environment", + "../../api/environment:environment_factory", "../../api/task_queue", "../../api/task_queue:default_task_queue_factory", "../../api/units:time_delta", diff --git a/modules/audio_device/audio_device_impl.cc b/modules/audio_device/audio_device_impl.cc index 44cfabeddd..c63a478c5f 100644 --- a/modules/audio_device/audio_device_impl.cc +++ b/modules/audio_device/audio_device_impl.cc @@ -12,8 +12,17 @@ #include +#include +#include +#include + +#include "absl/base/nullability.h" +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "api/environment/environment.h" #include "api/make_ref_counted.h" #include "api/scoped_refptr.h" +#include "api/task_queue/task_queue_factory.h" #include "modules/audio_device/audio_device_config.h" // IWYU pragma: keep #include "modules/audio_device/audio_device_generic.h" #include "rtc_base/checks.h" @@ -24,10 +33,6 @@ #if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) #include "modules/audio_device/win/audio_device_core_win.h" #endif -#elif defined(WEBRTC_ANDROID) -#include - -#include "sdk/android/native_api/audio_device_module/audio_device_android.h" #elif defined(WEBRTC_LINUX) #if defined(WEBRTC_ENABLE_LINUX_ALSA) #include "modules/audio_device/linux/audio_device_alsa_linux.h" @@ -62,17 +67,8 @@ namespace webrtc { -scoped_refptr AudioDeviceModule::Create( - AudioLayer audio_layer, - TaskQueueFactory* task_queue_factory) { - RTC_DLOG(LS_INFO) << __FUNCTION__; - return AudioDeviceModule::CreateForTest(audio_layer, task_queue_factory); -} - -// static -scoped_refptr AudioDeviceModule::CreateForTest( - AudioLayer audio_layer, - TaskQueueFactory* task_queue_factory) { +absl_nullable scoped_refptr +AudioDeviceModuleImpl::Create(const Environment& env, AudioLayer audio_layer) { RTC_DLOG(LS_INFO) << __FUNCTION__; // The "AudioDeviceModule::kWindowsCoreAudio2" audio layer has its own @@ -93,8 +89,8 @@ scoped_refptr AudioDeviceModule::CreateForTest( } // Create the generic reference counted (platform independent) implementation. - auto audio_device = - make_ref_counted(audio_layer, task_queue_factory); + auto audio_device = make_ref_counted( + audio_layer, &env.task_queue_factory()); // Ensure that the current platform is supported. if (audio_device->CheckPlatform() == -1) { @@ -102,7 +98,7 @@ scoped_refptr AudioDeviceModule::CreateForTest( } // Create the platform-dependent implementation. - if (audio_device->CreatePlatformSpecificObjects() == -1) { + if (audio_device->CreatePlatformSpecificObjects(env) == -1) { return nullptr; } @@ -166,7 +162,8 @@ int32_t AudioDeviceModuleImpl::CheckPlatform() { return 0; } -int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() { +int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects( + [[maybe_unused]] const Environment& env) { RTC_LOG(LS_INFO) << __FUNCTION__; if (audio_device_ != nullptr) { RTC_LOG(LS_INFO) << "Reusing provided audio device"; @@ -241,10 +238,11 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() { // iOS ADM implementation. #if defined(WEBRTC_IOS) if (audio_layer == kPlatformDefaultAudio) { - audio_device_.reset(new ios_adm::AudioDeviceIOS( + audio_device_ = std::make_unique( + env, /*bypass_voice_processing=*/false, /*muted_speech_event_handler=*/nullptr, - /*render_error_handler=*/nullptr)); + /*render_error_handler=*/nullptr); RTC_LOG(LS_INFO) << "iPhone Audio APIs will be utilized."; } // END #if defined(WEBRTC_IOS) @@ -654,16 +652,16 @@ int32_t AudioDeviceModuleImpl::PlayoutDeviceName( char guid[kAdmMaxGuidSize]) { RTC_LOG(LS_INFO) << __FUNCTION__ << "(" << index << ", ...)"; CHECKinitialized_(); - if (name == NULL) { + if (name == nullptr) { return -1; } if (audio_device_->PlayoutDeviceName(index, name, guid) == -1) { return -1; } - if (name != NULL) { + if (name != nullptr) { RTC_LOG(LS_INFO) << "output: name = " << name; } - if (guid != NULL) { + if (guid != nullptr) { RTC_LOG(LS_INFO) << "output: guid = " << guid; } return 0; @@ -675,16 +673,16 @@ int32_t AudioDeviceModuleImpl::RecordingDeviceName( char guid[kAdmMaxGuidSize]) { RTC_LOG(LS_INFO) << __FUNCTION__ << "(" << index << ", ...)"; CHECKinitialized_(); - if (name == NULL) { + if (name == nullptr) { return -1; } if (audio_device_->RecordingDeviceName(index, name, guid) == -1) { return -1; } - if (name != NULL) { + if (name != nullptr) { RTC_LOG(LS_INFO) << "output: name = " << name; } - if (guid != NULL) { + if (guid != nullptr) { RTC_LOG(LS_INFO) << "output: guid = " << guid; } return 0; diff --git a/modules/audio_device/audio_device_impl.h b/modules/audio_device/audio_device_impl.h index 41d68209e8..c7a229d2d9 100644 --- a/modules/audio_device/audio_device_impl.h +++ b/modules/audio_device/audio_device_impl.h @@ -17,7 +17,11 @@ #include +#include "absl/base/nullability.h" #include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "api/environment/environment.h" +#include "api/scoped_refptr.h" #include "api/task_queue/task_queue_factory.h" #include "modules/audio_device/audio_device_buffer.h" @@ -42,9 +46,9 @@ class AudioDeviceModuleImpl : public AudioDeviceModuleForTest { kPlatformFuchsia = 7, }; - int32_t CheckPlatform(); - int32_t CreatePlatformSpecificObjects(); - int32_t AttachAudioBuffer(); + static absl_nullable scoped_refptr Create( + const Environment& env, + AudioLayer audio_layer); AudioDeviceModuleImpl(AudioLayer audio_layer, TaskQueueFactory* task_queue_factory); @@ -56,6 +60,10 @@ class AudioDeviceModuleImpl : public AudioDeviceModuleForTest { bool create_detached); ~AudioDeviceModuleImpl() override; + int32_t CheckPlatform(); + int32_t CreatePlatformSpecificObjects(const Environment& env); + int32_t AttachAudioBuffer(); + // Retrieve the currently utilized audio layer int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override; diff --git a/modules/audio_device/audio_device_unittest.cc b/modules/audio_device/audio_device_unittest.cc index 8c97b5f93f..c7b1cb3c62 100644 --- a/modules/audio_device/audio_device_unittest.cc +++ b/modules/audio_device/audio_device_unittest.cc @@ -11,21 +11,27 @@ #include "api/audio/audio_device.h" #include +#include +#include #include +#include #include -#include #include #include +#include #include "api/array_view.h" +#include "api/audio/audio_device_defines.h" +#include "api/audio/create_audio_device_module.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" -#include "api/task_queue/default_task_queue_factory.h" -#include "api/task_queue/task_queue_factory.h" +#include "api/units/time_delta.h" #include "modules/audio_device/audio_device_impl.h" #include "modules/audio_device/include/mock_audio_transport.h" -#include "rtc_base/arraysize.h" #include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/event.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" @@ -35,6 +41,7 @@ #include "rtc_base/time_utils.h" #include "test/gmock.h" #include "test/gtest.h" + #ifdef WEBRTC_WIN #include "modules/audio_device/include/audio_device_factory.h" #include "modules/audio_device/win/core_audio_utility_win.h" @@ -515,11 +522,10 @@ class MockAudioTransport : public test::MockAudioTransport { #endif class MAYBE_AudioDeviceTest - : public ::testing::TestWithParam { + : public ::testing::TestWithParam { protected: MAYBE_AudioDeviceTest() - : audio_layer_(GetParam()), - task_queue_factory_(CreateDefaultTaskQueueFactory()) { + : audio_layer_(GetParam()), env_(CreateEnvironment()) { LogMessage::LogToDebug(LS_INFO); // Add extra logging fields here if needed for debugging. LogMessage::LogTimestamps(); @@ -589,8 +595,7 @@ class MAYBE_AudioDeviceTest // The value of `audio_layer_` is set at construction by GetParam() and two // different layers are tested on Windows only. if (audio_layer_ == AudioDeviceModule::kPlatformDefaultAudio) { - return AudioDeviceModule::CreateForTest(audio_layer_, - task_queue_factory_.get()); + return AudioDeviceModuleImpl::Create(env_, audio_layer_); } else if (audio_layer_ == AudioDeviceModule::kWindowsCoreAudio2) { #ifdef WEBRTC_WIN // We must initialize the COM library on a thread before we calling any of @@ -602,7 +607,7 @@ class MAYBE_AudioDeviceTest EXPECT_TRUE(webrtc_win::core_audio_utility::IsSupported()); EXPECT_TRUE(webrtc_win::core_audio_utility::IsMMCSSSupported()); return CreateWindowsCoreAudioAudioDeviceModuleForTest( - task_queue_factory_.get(), true); + &env_.task_queue_factory(), true); #else return nullptr; #endif @@ -659,7 +664,7 @@ class MAYBE_AudioDeviceTest std::unique_ptr com_initializer_; #endif AudioDeviceModule::AudioLayer audio_layer_; - std::unique_ptr task_queue_factory_; + const Environment env_; bool requirements_satisfied_ = true; Event event_; scoped_refptr audio_device_; @@ -669,13 +674,12 @@ class MAYBE_AudioDeviceTest // Instead of using the test fixture, verify that the different factory methods // work as intended. TEST(MAYBE_AudioDeviceTestWin, ConstructDestructWithFactory) { - std::unique_ptr task_queue_factory = - CreateDefaultTaskQueueFactory(); + const Environment env = CreateEnvironment(); scoped_refptr audio_device; - // The default factory should work for all platforms when a default ADM is + // The default environment should work for all platforms when a default ADM is // requested. - audio_device = AudioDeviceModule::Create( - AudioDeviceModule::kPlatformDefaultAudio, task_queue_factory.get()); + audio_device = + CreateAudioDeviceModule(env, AudioDeviceModule::kPlatformDefaultAudio); EXPECT_TRUE(audio_device); audio_device = nullptr; #ifdef WEBRTC_WIN @@ -683,8 +687,8 @@ TEST(MAYBE_AudioDeviceTestWin, ConstructDestructWithFactory) { // specific parts are implemented by an AudioDeviceGeneric object. Verify // that the old factory can't be used in combination with the latest audio // layer AudioDeviceModule::kWindowsCoreAudio2. - audio_device = AudioDeviceModule::Create( - AudioDeviceModule::kWindowsCoreAudio2, task_queue_factory.get()); + audio_device = + CreateAudioDeviceModule(env, AudioDeviceModule::kWindowsCoreAudio2); EXPECT_FALSE(audio_device); audio_device = nullptr; // Instead, ensure that the new dedicated factory method called @@ -694,7 +698,7 @@ TEST(MAYBE_AudioDeviceTestWin, ConstructDestructWithFactory) { ScopedCOMInitializer com_initializer(ScopedCOMInitializer::kMTA); EXPECT_TRUE(com_initializer.Succeeded()); audio_device = - CreateWindowsCoreAudioAudioDeviceModule(task_queue_factory.get()); + CreateWindowsCoreAudioAudioDeviceModule(&env.task_queue_factory()); EXPECT_TRUE(audio_device); AudioDeviceModule::AudioLayer audio_layer; EXPECT_EQ(0, audio_device->ActiveAudioLayer(&audio_layer)); @@ -827,8 +831,8 @@ TEST_P(MAYBE_AudioDeviceTest, StartStopPlayoutWithRealDevice) { AudioDeviceModule::WindowsDeviceType device_role[] = { AudioDeviceModule::kDefaultDevice, AudioDeviceModule::kDefaultCommunicationDevice}; - for (size_t i = 0; i < arraysize(device_role); ++i) { - EXPECT_EQ(0, audio_device()->SetPlayoutDevice(device_role[i])); + for (AudioDeviceModule::WindowsDeviceType device_type : device_role) { + EXPECT_EQ(0, audio_device()->SetPlayoutDevice(device_type)); StartPlayout(); StopPlayout(); } @@ -854,8 +858,8 @@ TEST_P(MAYBE_AudioDeviceTest, StartStopRecordingWithRealDevice) { AudioDeviceModule::WindowsDeviceType device_role[] = { AudioDeviceModule::kDefaultDevice, AudioDeviceModule::kDefaultCommunicationDevice}; - for (size_t i = 0; i < arraysize(device_role); ++i) { - EXPECT_EQ(0, audio_device()->SetRecordingDevice(device_role[i])); + for (AudioDeviceModule::WindowsDeviceType device_type : device_role) { + EXPECT_EQ(0, audio_device()->SetRecordingDevice(device_type)); StartRecording(); StopRecording(); } diff --git a/modules/audio_device/dummy/file_audio_device.cc b/modules/audio_device/dummy/file_audio_device.cc index 9a365047ca..e33036b315 100644 --- a/modules/audio_device/dummy/file_audio_device.cc +++ b/modules/audio_device/dummy/file_audio_device.cc @@ -16,8 +16,8 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/sleep.h" namespace webrtc { @@ -32,9 +32,9 @@ const size_t kRecordingBufferSize = FileAudioDevice::FileAudioDevice(absl::string_view inputFilename, absl::string_view outputFilename) - : _ptrAudioBuffer(NULL), - _recordingBuffer(NULL), - _playoutBuffer(NULL), + : _ptrAudioBuffer(nullptr), + _recordingBuffer(nullptr), + _playoutBuffer(nullptr), _recordingFramesLeft(0), _playoutFramesLeft(0), _recordingBufferSizeIn10MS(0), @@ -212,7 +212,7 @@ int32_t FileAudioDevice::StartPlayout() { RTC_LOG(LS_ERROR) << "Failed to open playout file: " << _outputFilename; _playing = false; delete[] _playoutBuffer; - _playoutBuffer = NULL; + _playoutBuffer = nullptr; return -1; } } @@ -244,7 +244,7 @@ int32_t FileAudioDevice::StopPlayout() { _playoutFramesLeft = 0; delete[] _playoutBuffer; - _playoutBuffer = NULL; + _playoutBuffer = nullptr; _outputFile.Close(); RTC_LOG(LS_INFO) << "Stopped playout capture to output file: " @@ -273,7 +273,7 @@ int32_t FileAudioDevice::StartRecording() { << _inputFilename; _recording = false; delete[] _recordingBuffer; - _recordingBuffer = NULL; + _recordingBuffer = nullptr; return -1; } } @@ -304,7 +304,7 @@ int32_t FileAudioDevice::StopRecording() { _recordingFramesLeft = 0; if (_recordingBuffer) { delete[] _recordingBuffer; - _recordingBuffer = NULL; + _recordingBuffer = nullptr; } _inputFile.Close(); @@ -466,7 +466,7 @@ bool FileAudioDevice::PlayThreadProcess() { int64_t deltaTimeMillis = TimeMillis() - currentTime; if (deltaTimeMillis < 10) { - SleepMs(10 - deltaTimeMillis); + Thread::SleepMs(10 - deltaTimeMillis); } return true; @@ -499,7 +499,7 @@ bool FileAudioDevice::RecThreadProcess() { int64_t deltaTimeMillis = TimeMillis() - currentTime; if (deltaTimeMillis < 10) { - SleepMs(10 - deltaTimeMillis); + Thread::SleepMs(10 - deltaTimeMillis); } return true; diff --git a/modules/audio_device/include/test_audio_device.cc b/modules/audio_device/include/test_audio_device.cc index c945b016ce..3b58ff21da 100644 --- a/modules/audio_device/include/test_audio_device.cc +++ b/modules/audio_device/include/test_audio_device.cc @@ -12,29 +12,29 @@ #include #include #include +#include #include #include -#include #include #include #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/audio/audio_device.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" #include "api/task_queue/task_queue_factory.h" #include "common_audio/wav_file.h" #include "modules/audio_device/audio_device_impl.h" -#include "modules/audio_device/include/audio_device_default.h" #include "modules/audio_device/test_audio_device_impl.h" #include "rtc_base/buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/event.h" -#include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" -#include "rtc_base/platform_thread.h" #include "rtc_base/random.h" #include "rtc_base/synchronization/mutex.h" -#include "rtc_base/task_utils/repeating_task.h" +#include "rtc_base/system/file_wrapper.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" @@ -45,25 +45,6 @@ namespace { constexpr int kFrameLengthUs = 10000; constexpr int kFramesPerSecond = kNumMicrosecsPerSec / kFrameLengthUs; -class TestAudioDeviceModuleImpl : public AudioDeviceModuleImpl { - public: - TestAudioDeviceModuleImpl( - TaskQueueFactory* task_queue_factory, - std::unique_ptr capturer, - std::unique_ptr renderer, - float speed = 1) - : AudioDeviceModuleImpl( - AudioLayer::kDummyAudio, - std::make_unique(task_queue_factory, - std::move(capturer), - std::move(renderer), - speed), - task_queue_factory, - /*create_detached=*/true) {} - - ~TestAudioDeviceModuleImpl() override = default; -}; - // A fake capturer that generates pulses with random samples between // -max_amplitude and +max_amplitude. class PulsedNoiseCapturerImpl final @@ -449,8 +430,22 @@ scoped_refptr TestAudioDeviceModule::Create( std::unique_ptr capturer, std::unique_ptr renderer, float speed) { - auto audio_device = make_ref_counted( - task_queue_factory, std::move(capturer), std::move(renderer), speed); + return Create(CreateEnvironment(task_queue_factory), std::move(capturer), + std::move(renderer), speed); +} + +scoped_refptr TestAudioDeviceModule::Create( + const Environment& env, + std::unique_ptr capturer, + std::unique_ptr renderer, + float speed) { + auto audio_device = make_ref_counted( + AudioDeviceModule::AudioLayer::kDummyAudio, + std::make_unique(&env.task_queue_factory(), + std::move(capturer), + std::move(renderer), speed), + &env.task_queue_factory(), + /*create_detached=*/true); // Ensure that the current platform is supported. if (audio_device->CheckPlatform() == -1) { @@ -458,7 +453,7 @@ scoped_refptr TestAudioDeviceModule::Create( } // Create the platform-dependent implementation. - if (audio_device->CreatePlatformSpecificObjects() == -1) { + if (audio_device->CreatePlatformSpecificObjects(env) == -1) { return nullptr; } diff --git a/modules/audio_device/include/test_audio_device.h b/modules/audio_device/include/test_audio_device.h index 6a9834235d..d7c556861d 100644 --- a/modules/audio_device/include/test_audio_device.h +++ b/modules/audio_device/include/test_audio_device.h @@ -14,12 +14,11 @@ #include #include -#include #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/audio/audio_device.h" -#include "api/audio/audio_device_defines.h" +#include "api/environment/environment.h" #include "api/scoped_refptr.h" #include "api/task_queue/task_queue_factory.h" #include "rtc_base/buffer.h" @@ -81,6 +80,13 @@ class TestAudioDeviceModule { // `renderer` is an object that receives audio data that would have been // played out. Can be nullptr if this device is never used for playing. // Use one of the Create... functions to get these instances. + static scoped_refptr Create( + const Environment& env, + std::unique_ptr capturer, + std::unique_ptr renderer, + float speed = 1); + + [[deprecated("bugs.webrtc.org/413413572")]] static scoped_refptr Create( TaskQueueFactory* task_queue_factory, std::unique_ptr capturer, diff --git a/modules/audio_device/include/test_audio_device_unittest.cc b/modules/audio_device/include/test_audio_device_unittest.cc index 18abf00f84..5e4888b372 100644 --- a/modules/audio_device/include/test_audio_device_unittest.cc +++ b/modules/audio_device/include/test_audio_device_unittest.cc @@ -10,22 +10,32 @@ #include "modules/audio_device/include/test_audio_device.h" +#include + #include -#include +#include +#include +#include +#include #include #include +#include #include +#include #include "api/array_view.h" +#include "api/audio/audio_device.h" #include "api/audio/audio_device_defines.h" -#include "api/task_queue/task_queue_factory.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" +#include "api/scoped_refptr.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "common_audio/wav_file.h" -#include "common_audio/wav_header.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -463,15 +473,17 @@ class TestAudioTransport : public AudioTransport { TEST(TestAudioDeviceModuleTest, CreatedADMCanRecord) { GlobalSimulatedTimeController time_controller(kStartTime); + const Environment env = CreateEnvironment( + time_controller.GetClock(), time_controller.GetTaskQueueFactory()); TestAudioTransport audio_transport(TestAudioTransport::Mode::kRecording); std::unique_ptr capturer = TestAudioDeviceModule::CreatePulsedNoiseCapturer( /*max_amplitude=*/1000, /*sampling_frequency_in_hz=*/48000, /*num_channels=*/2); - scoped_refptr adm = TestAudioDeviceModule::Create( - time_controller.GetTaskQueueFactory(), std::move(capturer), - /*renderer=*/nullptr); + scoped_refptr adm = + TestAudioDeviceModule::Create(env, std::move(capturer), + /*renderer=*/nullptr); ASSERT_EQ(adm->RegisterAudioCallback(&audio_transport), 0); ASSERT_EQ(adm->Init(), 0); @@ -495,13 +507,15 @@ TEST(TestAudioDeviceModuleTest, CreatedADMCanRecord) { TEST(TestAudioDeviceModuleTest, CreatedADMCanPlay) { GlobalSimulatedTimeController time_controller(kStartTime); + const Environment env = CreateEnvironment( + time_controller.GetClock(), time_controller.GetTaskQueueFactory()); TestAudioTransport audio_transport(TestAudioTransport::Mode::kPlaying); std::unique_ptr renderer = TestAudioDeviceModule::CreateDiscardRenderer( /*sampling_frequency_in_hz=*/48000, /*num_channels=*/2); scoped_refptr adm = - TestAudioDeviceModule::Create(time_controller.GetTaskQueueFactory(), + TestAudioDeviceModule::Create(env, /*capturer=*/nullptr, std::move(renderer)); ASSERT_EQ(adm->RegisterAudioCallback(&audio_transport), 0); diff --git a/modules/audio_device/linux/audio_device_alsa_linux.cc b/modules/audio_device/linux/audio_device_alsa_linux.cc index f5a3189371..5667df1aa0 100644 --- a/modules/audio_device/linux/audio_device_alsa_linux.cc +++ b/modules/audio_device/linux/audio_device_alsa_linux.cc @@ -13,7 +13,7 @@ #include "modules/audio_device/audio_device_config.h" #include "rtc_base/logging.h" #include "rtc_base/system/arch.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" WebRTCAlsaSymbolTable* GetAlsaSymbolTable() { static WebRTCAlsaSymbolTable* alsa_symbol_table = new WebRTCAlsaSymbolTable(); @@ -65,13 +65,13 @@ static const unsigned int ALSA_CAPTURE_WAIT_TIMEOUT = 5; // in ms #define FUNC_GET_DEVICE_NAME_FOR_AN_ENUM 2 AudioDeviceLinuxALSA::AudioDeviceLinuxALSA() - : _ptrAudioBuffer(NULL), + : _ptrAudioBuffer(nullptr), _inputDeviceIndex(0), _outputDeviceIndex(0), _inputDeviceIsSpecified(false), _outputDeviceIsSpecified(false), - _handleRecord(NULL), - _handlePlayout(NULL), + _handleRecord(nullptr), + _handlePlayout(nullptr), _recordingBuffersizeInFrame(0), _recordingPeriodSizeInFrame(0), _playoutBufferSizeInFrame(0), @@ -84,8 +84,8 @@ AudioDeviceLinuxALSA::AudioDeviceLinuxALSA() _playoutFreq(ALSA_PLAYOUT_FREQ), _recChannels(ALSA_CAPTURE_CH), _playChannels(ALSA_PLAYOUT_CH), - _recordingBuffer(NULL), - _playoutBuffer(NULL), + _recordingBuffer(nullptr), + _playoutBuffer(nullptr), _recordingFramesLeft(0), _playoutFramesLeft(0), _initialized(false), @@ -111,11 +111,11 @@ AudioDeviceLinuxALSA::~AudioDeviceLinuxALSA() { // Clean up the recording buffer and playout buffer. if (_recordingBuffer) { delete[] _recordingBuffer; - _recordingBuffer = NULL; + _recordingBuffer = nullptr; } if (_playoutBuffer) { delete[] _playoutBuffer; - _playoutBuffer = NULL; + _playoutBuffer = nullptr; } } @@ -154,7 +154,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceLinuxALSA::Init() { } #if defined(WEBRTC_USE_X11) // Get X display handle for typing detection - _XDisplay = XOpenDisplay(NULL); + _XDisplay = XOpenDisplay(nullptr); if (!_XDisplay) { RTC_LOG(LS_WARNING) << "failed to open X display, typing detection will not work"; @@ -186,7 +186,7 @@ int32_t AudioDeviceLinuxALSA::Terminate() { #if defined(WEBRTC_USE_X11) if (_XDisplay) { XCloseDisplay(_XDisplay); - _XDisplay = NULL; + _XDisplay = nullptr; } #endif _initialized = false; @@ -616,13 +616,13 @@ int32_t AudioDeviceLinuxALSA::PlayoutDeviceName( char guid[kAdmMaxGuidSize]) { const uint16_t nDevices(PlayoutDevices()); - if ((index > (nDevices - 1)) || (name == NULL)) { + if ((index > (nDevices - 1)) || (name == nullptr)) { return -1; } memset(name, 0, kAdmMaxDeviceNameSize); - if (guid != NULL) { + if (guid != nullptr) { memset(guid, 0, kAdmMaxGuidSize); } @@ -635,13 +635,13 @@ int32_t AudioDeviceLinuxALSA::RecordingDeviceName( char guid[kAdmMaxGuidSize]) { const uint16_t nDevices(RecordingDevices()); - if ((index > (nDevices - 1)) || (name == NULL)) { + if ((index > (nDevices - 1)) || (name == nullptr)) { return -1; } memset(name, 0, kAdmMaxDeviceNameSize); - if (guid != NULL) { + if (guid != nullptr) { memset(guid, 0, kAdmMaxGuidSize); } @@ -759,9 +759,9 @@ int32_t AudioDeviceLinuxALSA::InitPlayoutLocked() { // Start by closing any existing wave-output devices // - if (_handlePlayout != NULL) { + if (_handlePlayout != nullptr) { LATE(snd_pcm_close)(_handlePlayout); - _handlePlayout = NULL; + _handlePlayout = nullptr; _playIsInitialized = false; if (errVal < 0) { RTC_LOG(LS_ERROR) << "Error closing current playout sound device, error: " @@ -782,7 +782,7 @@ int32_t AudioDeviceLinuxALSA::InitPlayoutLocked() { if (errVal == -EBUSY) // Device busy - try some more! { for (int i = 0; i < 5; i++) { - SleepMs(1000); + Thread::SleepMs(1000); errVal = LATE(snd_pcm_open)(&_handlePlayout, deviceName, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); if (errVal == 0) { @@ -793,7 +793,7 @@ int32_t AudioDeviceLinuxALSA::InitPlayoutLocked() { if (errVal < 0) { RTC_LOG(LS_ERROR) << "unable to open playback device: " << LATE(snd_strerror)(errVal) << " (" << errVal << ")"; - _handlePlayout = NULL; + _handlePlayout = nullptr; return -1; } @@ -817,7 +817,7 @@ int32_t AudioDeviceLinuxALSA::InitPlayoutLocked() { << LATE(snd_strerror)(errVal) << " (" << errVal << ")"; ErrorRecovery(errVal, _handlePlayout); errVal = LATE(snd_pcm_close)(_handlePlayout); - _handlePlayout = NULL; + _handlePlayout = nullptr; return -1; } @@ -846,7 +846,7 @@ int32_t AudioDeviceLinuxALSA::InitPlayoutLocked() { // Init varaibles used for play - if (_handlePlayout != NULL) { + if (_handlePlayout != nullptr) { _playIsInitialized = true; return 0; } else { @@ -881,9 +881,9 @@ int32_t AudioDeviceLinuxALSA::InitRecordingLocked() { // Start by closing any existing pcm-input devices // - if (_handleRecord != NULL) { + if (_handleRecord != nullptr) { errVal = LATE(snd_pcm_close)(_handleRecord); - _handleRecord = NULL; + _handleRecord = nullptr; _recIsInitialized = false; if (errVal < 0) { RTC_LOG(LS_ERROR) @@ -906,7 +906,7 @@ int32_t AudioDeviceLinuxALSA::InitRecordingLocked() { if (errVal == -EBUSY) // Device busy - try some more! { for (int i = 0; i < 5; i++) { - SleepMs(1000); + Thread::SleepMs(1000); errVal = LATE(snd_pcm_open)(&_handleRecord, deviceName, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK); if (errVal == 0) { @@ -917,7 +917,7 @@ int32_t AudioDeviceLinuxALSA::InitRecordingLocked() { if (errVal < 0) { RTC_LOG(LS_ERROR) << "unable to open record device: " << LATE(snd_strerror)(errVal); - _handleRecord = NULL; + _handleRecord = nullptr; return -1; } @@ -959,7 +959,7 @@ int32_t AudioDeviceLinuxALSA::InitRecordingLocked() { << LATE(snd_strerror)(errVal) << " (" << errVal << ")"; ErrorRecovery(errVal, _handleRecord); errVal = LATE(snd_pcm_close)(_handleRecord); - _handleRecord = NULL; + _handleRecord = nullptr; return -1; } } @@ -987,7 +987,7 @@ int32_t AudioDeviceLinuxALSA::InitRecordingLocked() { _recordingBufferSizeIn10MS = LATE(snd_pcm_frames_to_bytes)(_handleRecord, _recordingFramesIn10MS); - if (_handleRecord != NULL) { + if (_handleRecord != nullptr) { // Mark recording side as initialized _recIsInitialized = true; return 0; @@ -1062,7 +1062,7 @@ int32_t AudioDeviceLinuxALSA::StopRecordingLocked() { return 0; } - if (_handleRecord == NULL) { + if (_handleRecord == nullptr) { return -1; } @@ -1075,7 +1075,7 @@ int32_t AudioDeviceLinuxALSA::StopRecordingLocked() { _recordingFramesLeft = 0; if (_recordingBuffer) { delete[] _recordingBuffer; - _recordingBuffer = NULL; + _recordingBuffer = nullptr; } // Stop and close pcm recording device. @@ -1100,7 +1100,7 @@ int32_t AudioDeviceLinuxALSA::StopRecordingLocked() { } // set the pcm input handle to NULL - _handleRecord = NULL; + _handleRecord = nullptr; return 0; } @@ -1167,7 +1167,7 @@ int32_t AudioDeviceLinuxALSA::StopPlayoutLocked() { return 0; } - if (_handlePlayout == NULL) { + if (_handlePlayout == nullptr) { return -1; } @@ -1178,7 +1178,7 @@ int32_t AudioDeviceLinuxALSA::StopPlayoutLocked() { _playoutFramesLeft = 0; delete[] _playoutBuffer; - _playoutBuffer = NULL; + _playoutBuffer = nullptr; // stop and close pcm playout device int errVal = LATE(snd_pcm_drop)(_handlePlayout); @@ -1193,7 +1193,7 @@ int32_t AudioDeviceLinuxALSA::StopPlayoutLocked() { // set the pcm input handle to NULL _playIsInitialized = false; - _handlePlayout = NULL; + _handlePlayout = nullptr; RTC_LOG(LS_VERBOSE) << "handle_playout is now set to NULL"; return 0; @@ -1261,7 +1261,7 @@ int32_t AudioDeviceLinuxALSA::GetDevicesInfo(const int32_t function, return 0; } - for (void** list = hints; *list != NULL; ++list) { + for (void** list = hints; *list != nullptr; ++list) { char* actualType = LATE(snd_device_name_get_hint)(*list, "IOID"); if (actualType) { // NULL means it's both. bool wrongType = (strcmp(actualType, type) != 0); @@ -1351,7 +1351,7 @@ int32_t AudioDeviceLinuxALSA::GetDevicesInfo(const int32_t function, } int32_t AudioDeviceLinuxALSA::InputSanityCheckAfterUnlockedPeriod() const { - if (_handleRecord == NULL) { + if (_handleRecord == nullptr) { RTC_LOG(LS_ERROR) << "input state has been modified during unlocked period"; return -1; } @@ -1359,7 +1359,7 @@ int32_t AudioDeviceLinuxALSA::InputSanityCheckAfterUnlockedPeriod() const { } int32_t AudioDeviceLinuxALSA::OutputSanityCheckAfterUnlockedPeriod() const { - if (_handlePlayout == NULL) { + if (_handlePlayout == nullptr) { RTC_LOG(LS_ERROR) << "output state has been modified during unlocked period"; return -1; diff --git a/modules/audio_device/linux/audio_device_pulse_linux.cc b/modules/audio_device/linux/audio_device_pulse_linux.cc index 8843fe727e..7acfc5d9b9 100644 --- a/modules/audio_device/linux/audio_device_pulse_linux.cc +++ b/modules/audio_device/linux/audio_device_pulse_linux.cc @@ -33,7 +33,7 @@ WebRTCPulseSymbolTable* GetPulseSymbolTable() { namespace webrtc { AudioDeviceLinuxPulse::AudioDeviceLinuxPulse() - : _ptrAudioBuffer(NULL), + : _ptrAudioBuffer(nullptr), _inputDeviceIndex(0), _outputDeviceIndex(0), _inputDeviceIsSpecified(false), @@ -55,28 +55,28 @@ AudioDeviceLinuxPulse::AudioDeviceLinuxPulse() _deviceIndex(-1), _numPlayDevices(0), _numRecDevices(0), - _playDeviceName(NULL), - _recDeviceName(NULL), - _playDisplayDeviceName(NULL), - _recDisplayDeviceName(NULL), - _playBuffer(NULL), + _playDeviceName(nullptr), + _recDeviceName(nullptr), + _playDisplayDeviceName(nullptr), + _recDisplayDeviceName(nullptr), + _playBuffer(nullptr), _playbackBufferSize(0), _playbackBufferUnused(0), _tempBufferSpace(0), - _recBuffer(NULL), + _recBuffer(nullptr), _recordBufferSize(0), _recordBufferUsed(0), - _tempSampleData(NULL), + _tempSampleData(nullptr), _tempSampleDataSize(0), _configuredLatencyPlay(0), _configuredLatencyRec(0), _paDeviceIndex(-1), _paStateChanged(false), - _paMainloop(NULL), - _paMainloopApi(NULL), - _paContext(NULL), - _recStream(NULL), - _playStream(NULL), + _paMainloop(nullptr), + _paMainloopApi(nullptr), + _paContext(nullptr), + _recStream(nullptr), + _playStream(nullptr), _recStreamFlags(0), _playStreamFlags(0) { RTC_DLOG(LS_INFO) << __FUNCTION__ << " created"; @@ -94,19 +94,19 @@ AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse() { if (_recBuffer) { delete[] _recBuffer; - _recBuffer = NULL; + _recBuffer = nullptr; } if (_playBuffer) { delete[] _playBuffer; - _playBuffer = NULL; + _playBuffer = nullptr; } if (_playDeviceName) { delete[] _playDeviceName; - _playDeviceName = NULL; + _playDeviceName = nullptr; } if (_recDeviceName) { delete[] _recDeviceName; - _recDeviceName = NULL; + _recDeviceName = nullptr; } } @@ -151,7 +151,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceLinuxPulse::Init() { #if defined(WEBRTC_USE_X11) // Get X display handle for typing detection - _XDisplay = XOpenDisplay(NULL); + _XDisplay = XOpenDisplay(nullptr); if (!_XDisplay) { RTC_LOG(LS_WARNING) << "failed to open X display, typing detection will not work"; @@ -208,7 +208,7 @@ int32_t AudioDeviceLinuxPulse::Terminate() { #if defined(WEBRTC_USE_X11) if (_XDisplay) { XCloseDisplay(_XDisplay); - _XDisplay = NULL; + _XDisplay = nullptr; } #endif @@ -238,7 +238,7 @@ int32_t AudioDeviceLinuxPulse::InitSpeaker() { // check if default device if (_outputDeviceIndex == 0) { uint16_t deviceIndex = 0; - GetDefaultDeviceInfo(false, NULL, deviceIndex); + GetDefaultDeviceInfo(false, nullptr, deviceIndex); _paDeviceIndex = deviceIndex; } else { // get the PA device index from @@ -275,7 +275,7 @@ int32_t AudioDeviceLinuxPulse::InitMicrophone() { // Check if default device if (_inputDeviceIndex == 0) { uint16_t deviceIndex = 0; - GetDefaultDeviceInfo(true, NULL, deviceIndex); + GetDefaultDeviceInfo(true, nullptr, deviceIndex); _paDeviceIndex = deviceIndex; } else { // Get the PA device index from @@ -642,7 +642,7 @@ int32_t AudioDeviceLinuxPulse::MinMicrophoneVolume(uint32_t& minVolume) const { int16_t AudioDeviceLinuxPulse::PlayoutDevices() { PaLock(); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; _numPlayDevices = 1; // init to 1 to account for "default" // get the whole list of devices and update _numPlayDevices @@ -691,13 +691,13 @@ int32_t AudioDeviceLinuxPulse::PlayoutDeviceName( RTC_DCHECK(thread_checker_.IsCurrent()); const uint16_t nDevices = PlayoutDevices(); - if ((index > (nDevices - 1)) || (name == NULL)) { + if ((index > (nDevices - 1)) || (name == nullptr)) { return -1; } memset(name, 0, kAdmMaxDeviceNameSize); - if (guid != NULL) { + if (guid != nullptr) { memset(guid, 0, kAdmMaxGuidSize); } @@ -716,7 +716,7 @@ int32_t AudioDeviceLinuxPulse::PlayoutDeviceName( PlayoutDevices(); // clear device name and index - _playDisplayDeviceName = NULL; + _playDisplayDeviceName = nullptr; _deviceIndex = -1; return 0; @@ -729,13 +729,13 @@ int32_t AudioDeviceLinuxPulse::RecordingDeviceName( RTC_DCHECK(thread_checker_.IsCurrent()); const uint16_t nDevices(RecordingDevices()); - if ((index > (nDevices - 1)) || (name == NULL)) { + if ((index > (nDevices - 1)) || (name == nullptr)) { return -1; } memset(name, 0, kAdmMaxDeviceNameSize); - if (guid != NULL) { + if (guid != nullptr) { memset(guid, 0, kAdmMaxGuidSize); } @@ -754,7 +754,7 @@ int32_t AudioDeviceLinuxPulse::RecordingDeviceName( RecordingDevices(); // Clear device name and index - _recDisplayDeviceName = NULL; + _recDisplayDeviceName = nullptr; _deviceIndex = -1; return 0; @@ -763,7 +763,7 @@ int32_t AudioDeviceLinuxPulse::RecordingDeviceName( int16_t AudioDeviceLinuxPulse::RecordingDevices() { PaLock(); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; _numRecDevices = 1; // Init to 1 to account for "default" // Get the whole list of devices and update _numRecDevices @@ -869,7 +869,7 @@ int32_t AudioDeviceLinuxPulse::InitPlayout() { { MutexLock lock(&mutex_); _playStream = - LATE(pa_stream_new)(_paContext, "playStream", &playSampleSpec, NULL); + LATE(pa_stream_new)(_paContext, "playStream", &playSampleSpec, nullptr); } if (!_playStream) { @@ -976,7 +976,7 @@ int32_t AudioDeviceLinuxPulse::InitRecording() { // Create a new rec stream _recStream = - LATE(pa_stream_new)(_paContext, "recStream", &recSampleSpec, NULL); + LATE(pa_stream_new)(_paContext, "recStream", &recSampleSpec, nullptr); if (!_recStream) { RTC_LOG(LS_ERROR) << "failed to create rec stream, err=" << LATE(pa_context_errno)(_paContext); @@ -1091,7 +1091,7 @@ int32_t AudioDeviceLinuxPulse::StopRecording() { return 0; } - if (_recStream == NULL) { + if (_recStream == nullptr) { return -1; } @@ -1104,10 +1104,10 @@ int32_t AudioDeviceLinuxPulse::StopRecording() { PaLock(); DisableReadCallback(); - LATE(pa_stream_set_overflow_callback)(_recStream, NULL, NULL); + LATE(pa_stream_set_overflow_callback)(_recStream, nullptr, nullptr); // Unset this here so that we don't get a TERMINATED callback - LATE(pa_stream_set_state_callback)(_recStream, NULL, NULL); + LATE(pa_stream_set_state_callback)(_recStream, nullptr, nullptr); if (LATE(pa_stream_get_state)(_recStream) != PA_STREAM_UNCONNECTED) { // Disconnect the stream @@ -1122,7 +1122,7 @@ int32_t AudioDeviceLinuxPulse::StopRecording() { } LATE(pa_stream_unref)(_recStream); - _recStream = NULL; + _recStream = nullptr; PaUnLock(); @@ -1131,7 +1131,7 @@ int32_t AudioDeviceLinuxPulse::StopRecording() { if (_recBuffer) { delete[] _recBuffer; - _recBuffer = NULL; + _recBuffer = nullptr; } return 0; @@ -1206,7 +1206,7 @@ int32_t AudioDeviceLinuxPulse::StopPlayout() { return 0; } - if (_playStream == NULL) { + if (_playStream == nullptr) { return -1; } @@ -1220,10 +1220,10 @@ int32_t AudioDeviceLinuxPulse::StopPlayout() { PaLock(); DisableWriteCallback(); - LATE(pa_stream_set_underflow_callback)(_playStream, NULL, NULL); + LATE(pa_stream_set_underflow_callback)(_playStream, nullptr, nullptr); // Unset this here so that we don't get a TERMINATED callback - LATE(pa_stream_set_state_callback)(_playStream, NULL, NULL); + LATE(pa_stream_set_state_callback)(_playStream, nullptr, nullptr); if (LATE(pa_stream_get_state)(_playStream) != PA_STREAM_UNCONNECTED) { // Disconnect the stream @@ -1238,7 +1238,7 @@ int32_t AudioDeviceLinuxPulse::StopPlayout() { } LATE(pa_stream_unref)(_playStream); - _playStream = NULL; + _playStream = nullptr; PaUnLock(); @@ -1247,7 +1247,7 @@ int32_t AudioDeviceLinuxPulse::StopPlayout() { if (_playBuffer) { delete[] _playBuffer; - _playBuffer = NULL; + _playBuffer = nullptr; } return 0; @@ -1437,7 +1437,7 @@ void AudioDeviceLinuxPulse::PaStreamStateCallbackHandler(pa_stream* p) { int32_t AudioDeviceLinuxPulse::CheckPulseAudioVersion() { PaLock(); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; // get the server info and update deviceName paOperation = @@ -1455,7 +1455,7 @@ int32_t AudioDeviceLinuxPulse::CheckPulseAudioVersion() { int32_t AudioDeviceLinuxPulse::InitSamplingFrequency() { PaLock(); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; // Get the server info and update sample_rate_hz_ paOperation = @@ -1474,7 +1474,7 @@ int32_t AudioDeviceLinuxPulse::GetDefaultDeviceInfo(bool recDevice, char tmpName[kAdmMaxDeviceNameSize] = {0}; // subtract length of "default: " uint16_t nameLen = kAdmMaxDeviceNameSize - 9; - char* pName = NULL; + char* pName = nullptr; if (name) { // Add "default: " @@ -1498,7 +1498,7 @@ int32_t AudioDeviceLinuxPulse::GetDefaultDeviceInfo(bool recDevice, PaLock(); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; // Get the server info and update deviceName paOperation = @@ -1528,8 +1528,8 @@ int32_t AudioDeviceLinuxPulse::GetDefaultDeviceInfo(bool recDevice, } // Clear members - _playDisplayDeviceName = NULL; - _recDisplayDeviceName = NULL; + _playDisplayDeviceName = nullptr; + _recDisplayDeviceName = nullptr; _paDeviceIndex = -1; _deviceIndex = -1; _numPlayDevices = 0; @@ -1598,8 +1598,8 @@ int32_t AudioDeviceLinuxPulse::InitPulseAudio() { // Connect the context to a server (default) _paStateChanged = false; - retVal = - LATE(pa_context_connect)(_paContext, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL); + retVal = LATE(pa_context_connect)(_paContext, nullptr, PA_CONTEXT_NOAUTOSPAWN, + nullptr); if (retVal != PA_OK) { RTC_LOG(LS_ERROR) << "failed to connect context, error=" << retVal; @@ -1671,7 +1671,7 @@ int32_t AudioDeviceLinuxPulse::TerminatePulseAudio() { } PaUnLock(); - _paContext = NULL; + _paContext = nullptr; // Stop the threaded main loop if (_paMainloop) { @@ -1683,7 +1683,7 @@ int32_t AudioDeviceLinuxPulse::TerminatePulseAudio() { LATE(pa_threaded_mainloop_free)(_paMainloop); } - _paMainloop = NULL; + _paMainloop = nullptr; RTC_LOG(LS_VERBOSE) << "PulseAudio terminated"; @@ -1733,7 +1733,7 @@ void AudioDeviceLinuxPulse::EnableWriteCallback() { } void AudioDeviceLinuxPulse::DisableWriteCallback() { - LATE(pa_stream_set_write_callback)(_playStream, NULL, NULL); + LATE(pa_stream_set_write_callback)(_playStream, nullptr, nullptr); } void AudioDeviceLinuxPulse::PaStreamWriteCallback(pa_stream* /*unused*/, @@ -1789,7 +1789,7 @@ void AudioDeviceLinuxPulse::PaStreamUnderflowCallbackHandler() { _playBufferAttr.prebuf = _playBufferAttr.tlength - _playBufferAttr.minreq; pa_operation* op = LATE(pa_stream_set_buffer_attr)( - _playStream, &_playBufferAttr, NULL, NULL); + _playStream, &_playBufferAttr, nullptr, nullptr); if (!op) { RTC_LOG(LS_ERROR) << "pa_stream_set_buffer_attr()"; return; @@ -1807,7 +1807,7 @@ void AudioDeviceLinuxPulse::EnableReadCallback() { } void AudioDeviceLinuxPulse::DisableReadCallback() { - LATE(pa_stream_set_read_callback)(_recStream, NULL, NULL); + LATE(pa_stream_set_read_callback)(_recStream, nullptr, nullptr); } void AudioDeviceLinuxPulse::PaStreamReadCallback(pa_stream* /*unused1*/, @@ -1991,7 +1991,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() { RTC_LOG(LS_VERBOSE) << "_startPlay true, performing initial actions"; _startPlay = false; - _playDeviceName = NULL; + _playDeviceName = nullptr; // Set if not default device if (_outputDeviceIndex > 0) { @@ -2021,7 +2021,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() { PaLock(); // NULL gives PA the choice of startup volume. - pa_cvolume* ptr_cvolume = NULL; + pa_cvolume* ptr_cvolume = nullptr; if (update_speaker_volume_at_startup_) { pa_cvolume cVolumes; ptr_cvolume = &cVolumes; @@ -2033,9 +2033,10 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() { } // Connect the stream to a sink - if (LATE(pa_stream_connect_playback)( - _playStream, _playDeviceName, &_playBufferAttr, - (pa_stream_flags_t)_playStreamFlags, ptr_cvolume, NULL) != PA_OK) { + if (LATE(pa_stream_connect_playback)(_playStream, _playDeviceName, + &_playBufferAttr, + (pa_stream_flags_t)_playStreamFlags, + ptr_cvolume, nullptr) != PA_OK) { RTC_LOG(LS_ERROR) << "failed to connect play stream, err=" << LATE(pa_context_errno)(_paContext); } @@ -2057,7 +2058,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() { // Clear device name if (_playDeviceName) { delete[] _playDeviceName; - _playDeviceName = NULL; + _playDeviceName = nullptr; } _playing = true; @@ -2081,7 +2082,7 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() { PaLock(); if (LATE(pa_stream_write)( _playStream, (void*)&_playBuffer[_playbackBufferUnused], write, - NULL, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) { + nullptr, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) { _writeErrors++; if (_writeErrors > 10) { RTC_LOG(LS_ERROR) << "Playout error: _writeErrors=" << _writeErrors @@ -2125,7 +2126,8 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() { RTC_LOG(LS_VERBOSE) << "will write"; PaLock(); if (LATE(pa_stream_write)(_playStream, (void*)&_playBuffer[0], write, - NULL, (int64_t)0, PA_SEEK_RELATIVE) != PA_OK) { + nullptr, (int64_t)0, + PA_SEEK_RELATIVE) != PA_OK) { _writeErrors++; if (_writeErrors > 10) { RTC_LOG(LS_ERROR) << "Playout error: _writeErrors=" << _writeErrors @@ -2160,7 +2162,7 @@ bool AudioDeviceLinuxPulse::RecThreadProcess() { if (_startRec) { RTC_LOG(LS_VERBOSE) << "_startRec true, performing initial actions"; - _recDeviceName = NULL; + _recDeviceName = nullptr; // Set if not default device if (_inputDeviceIndex > 0) { @@ -2199,7 +2201,7 @@ bool AudioDeviceLinuxPulse::RecThreadProcess() { // Clear device name if (_recDeviceName) { delete[] _recDeviceName; - _recDeviceName = NULL; + _recDeviceName = nullptr; } _startRec = false; @@ -2215,7 +2217,7 @@ bool AudioDeviceLinuxPulse::RecThreadProcess() { return true; } - _tempSampleData = NULL; + _tempSampleData = nullptr; _tempSampleDataSize = 0; PaLock(); diff --git a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc index e7e7033173..76084c6bda 100644 --- a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc +++ b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc @@ -23,10 +23,10 @@ namespace webrtc { AudioMixerManagerLinuxALSA::AudioMixerManagerLinuxALSA() - : _outputMixerHandle(NULL), - _inputMixerHandle(NULL), - _outputMixerElement(NULL), - _inputMixerElement(NULL) { + : _outputMixerHandle(nullptr), + _inputMixerHandle(nullptr), + _outputMixerElement(nullptr), + _inputMixerElement(nullptr) { RTC_DLOG(LS_INFO) << __FUNCTION__ << " created"; memset(_outputMixerStr, 0, kAdmMaxDeviceNameSize); @@ -63,7 +63,7 @@ int32_t AudioMixerManagerLinuxALSA::CloseSpeakerLocked() { int errVal = 0; - if (_outputMixerHandle != NULL) { + if (_outputMixerHandle != nullptr) { RTC_LOG(LS_VERBOSE) << "Closing playout mixer"; LATE(snd_mixer_free)(_outputMixerHandle); if (errVal < 0) { @@ -80,8 +80,8 @@ int32_t AudioMixerManagerLinuxALSA::CloseSpeakerLocked() { RTC_LOG(LS_ERROR) << "Error snd_mixer_close(handleMixer) errVal=" << errVal; } - _outputMixerHandle = NULL; - _outputMixerElement = NULL; + _outputMixerHandle = nullptr; + _outputMixerElement = nullptr; } memset(_outputMixerStr, 0, kAdmMaxDeviceNameSize); @@ -98,7 +98,7 @@ int32_t AudioMixerManagerLinuxALSA::CloseMicrophoneLocked() { int errVal = 0; - if (_inputMixerHandle != NULL) { + if (_inputMixerHandle != nullptr) { RTC_LOG(LS_VERBOSE) << "Closing record mixer"; LATE(snd_mixer_free)(_inputMixerHandle); @@ -122,8 +122,8 @@ int32_t AudioMixerManagerLinuxALSA::CloseMicrophoneLocked() { } RTC_LOG(LS_VERBOSE) << "Closing record mixer 4"; - _inputMixerHandle = NULL; - _inputMixerElement = NULL; + _inputMixerHandle = nullptr; + _inputMixerElement = nullptr; } memset(_inputMixerStr, 0, kAdmMaxDeviceNameSize); @@ -140,7 +140,7 @@ int32_t AudioMixerManagerLinuxALSA::OpenSpeaker(char* deviceName) { // Close any existing output mixer handle // - if (_outputMixerHandle != NULL) { + if (_outputMixerHandle != nullptr) { RTC_LOG(LS_VERBOSE) << "Closing playout mixer"; LATE(snd_mixer_free)(_outputMixerHandle); @@ -159,8 +159,8 @@ int32_t AudioMixerManagerLinuxALSA::OpenSpeaker(char* deviceName) { << errVal; } } - _outputMixerHandle = NULL; - _outputMixerElement = NULL; + _outputMixerHandle = nullptr; + _outputMixerElement = nullptr; errVal = LATE(snd_mixer_open)(&_outputMixerHandle, 0); if (errVal < 0) { @@ -178,18 +178,18 @@ int32_t AudioMixerManagerLinuxALSA::OpenSpeaker(char* deviceName) { if (errVal < 0) { RTC_LOG(LS_ERROR) << "snd_mixer_attach(_outputMixerHandle, " << controlName << ") error: " << LATE(snd_strerror)(errVal); - _outputMixerHandle = NULL; + _outputMixerHandle = nullptr; return -1; } strcpy(_outputMixerStr, controlName); - errVal = LATE(snd_mixer_selem_register)(_outputMixerHandle, NULL, NULL); + errVal = LATE(snd_mixer_selem_register)(_outputMixerHandle, nullptr, nullptr); if (errVal < 0) { RTC_LOG(LS_ERROR) << "snd_mixer_selem_register(_outputMixerHandle, NULL, NULL), " "error: " << LATE(snd_strerror)(errVal); - _outputMixerHandle = NULL; + _outputMixerHandle = nullptr; return -1; } @@ -198,7 +198,7 @@ int32_t AudioMixerManagerLinuxALSA::OpenSpeaker(char* deviceName) { return -1; } - if (_outputMixerHandle != NULL) { + if (_outputMixerHandle != nullptr) { RTC_LOG(LS_VERBOSE) << "the output mixer device is now open (" << _outputMixerHandle << ")"; } @@ -216,7 +216,7 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char* deviceName) { // Close any existing input mixer handle // - if (_inputMixerHandle != NULL) { + if (_inputMixerHandle != nullptr) { RTC_LOG(LS_VERBOSE) << "Closing record mixer"; LATE(snd_mixer_free)(_inputMixerHandle); @@ -240,8 +240,8 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char* deviceName) { } RTC_LOG(LS_VERBOSE) << "Closing record mixer"; } - _inputMixerHandle = NULL; - _inputMixerElement = NULL; + _inputMixerHandle = nullptr; + _inputMixerElement = nullptr; errVal = LATE(snd_mixer_open)(&_inputMixerHandle, 0); if (errVal < 0) { @@ -260,19 +260,19 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char* deviceName) { RTC_LOG(LS_ERROR) << "snd_mixer_attach(_inputMixerHandle, " << controlName << ") error: " << LATE(snd_strerror)(errVal); - _inputMixerHandle = NULL; + _inputMixerHandle = nullptr; return -1; } strcpy(_inputMixerStr, controlName); - errVal = LATE(snd_mixer_selem_register)(_inputMixerHandle, NULL, NULL); + errVal = LATE(snd_mixer_selem_register)(_inputMixerHandle, nullptr, nullptr); if (errVal < 0) { RTC_LOG(LS_ERROR) << "snd_mixer_selem_register(_inputMixerHandle, NULL, NULL), " "error: " << LATE(snd_strerror)(errVal); - _inputMixerHandle = NULL; + _inputMixerHandle = nullptr; return -1; } // Load and find the proper mixer element @@ -280,7 +280,7 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char* deviceName) { return -1; } - if (_inputMixerHandle != NULL) { + if (_inputMixerHandle != nullptr) { RTC_LOG(LS_VERBOSE) << "the input mixer device is now open (" << _inputMixerHandle << ")"; } @@ -291,13 +291,13 @@ int32_t AudioMixerManagerLinuxALSA::OpenMicrophone(char* deviceName) { bool AudioMixerManagerLinuxALSA::SpeakerIsInitialized() const { RTC_DLOG(LS_INFO) << __FUNCTION__; - return (_outputMixerHandle != NULL); + return (_outputMixerHandle != nullptr); } bool AudioMixerManagerLinuxALSA::MicrophoneIsInitialized() const { RTC_DLOG(LS_INFO) << __FUNCTION__; - return (_inputMixerHandle != NULL); + return (_inputMixerHandle != nullptr); } int32_t AudioMixerManagerLinuxALSA::SetSpeakerVolume(uint32_t volume) { @@ -306,7 +306,7 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerVolume(uint32_t volume) { MutexLock lock(&mutex_); - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable output mixer element exists"; return -1; } @@ -323,7 +323,7 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerVolume(uint32_t volume) { } int32_t AudioMixerManagerLinuxALSA::SpeakerVolume(uint32_t& volume) const { - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable output mixer element exists"; return -1; } @@ -347,7 +347,7 @@ int32_t AudioMixerManagerLinuxALSA::SpeakerVolume(uint32_t& volume) const { int32_t AudioMixerManagerLinuxALSA::MaxSpeakerVolume( uint32_t& maxVolume) const { - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avilable output mixer element exists"; return -1; } @@ -373,7 +373,7 @@ int32_t AudioMixerManagerLinuxALSA::MaxSpeakerVolume( int32_t AudioMixerManagerLinuxALSA::MinSpeakerVolume( uint32_t& minVolume) const { - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable output mixer element exists"; return -1; } @@ -482,7 +482,7 @@ int32_t AudioMixerManagerLinuxALSA::MinSpeakerVolume( */ int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeIsAvailable(bool& available) { - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable output mixer element exists"; return -1; } @@ -493,7 +493,7 @@ int32_t AudioMixerManagerLinuxALSA::SpeakerVolumeIsAvailable(bool& available) { } int32_t AudioMixerManagerLinuxALSA::SpeakerMuteIsAvailable(bool& available) { - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable output mixer element exists"; return -1; } @@ -509,7 +509,7 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerMute(bool enable) { MutexLock lock(&mutex_); - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable output mixer element exists"; return -1; } @@ -535,7 +535,7 @@ int32_t AudioMixerManagerLinuxALSA::SetSpeakerMute(bool enable) { } int32_t AudioMixerManagerLinuxALSA::SpeakerMute(bool& enabled) const { - if (_outputMixerElement == NULL) { + if (_outputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable output mixer exists"; return -1; } @@ -567,7 +567,7 @@ int32_t AudioMixerManagerLinuxALSA::SpeakerMute(bool& enabled) const { } int32_t AudioMixerManagerLinuxALSA::MicrophoneMuteIsAvailable(bool& available) { - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer element exists"; return -1; } @@ -582,7 +582,7 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneMute(bool enable) { MutexLock lock(&mutex_); - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer element exists"; return -1; } @@ -608,7 +608,7 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneMute(bool enable) { } int32_t AudioMixerManagerLinuxALSA::MicrophoneMute(bool& enabled) const { - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer exists"; return -1; } @@ -640,7 +640,7 @@ int32_t AudioMixerManagerLinuxALSA::MicrophoneMute(bool& enabled) const { int32_t AudioMixerManagerLinuxALSA::MicrophoneVolumeIsAvailable( bool& available) { - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer element exists"; return -1; } @@ -657,7 +657,7 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneVolume(uint32_t volume) { MutexLock lock(&mutex_); - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer element exists"; return -1; } @@ -761,7 +761,7 @@ int32_t AudioMixerManagerLinuxALSA::SetMicrophoneVolume(uint32_t volume) { */ int32_t AudioMixerManagerLinuxALSA::MicrophoneVolume(uint32_t& volume) const { - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer element exists"; return -1; } @@ -785,7 +785,7 @@ int32_t AudioMixerManagerLinuxALSA::MicrophoneVolume(uint32_t& volume) const { int32_t AudioMixerManagerLinuxALSA::MaxMicrophoneVolume( uint32_t& maxVolume) const { - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer element exists"; return -1; } @@ -816,7 +816,7 @@ int32_t AudioMixerManagerLinuxALSA::MaxMicrophoneVolume( int32_t AudioMixerManagerLinuxALSA::MinMicrophoneVolume( uint32_t& minVolume) const { - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { RTC_LOG(LS_WARNING) << "no avaliable input mixer element exists"; return -1; } @@ -848,14 +848,14 @@ int32_t AudioMixerManagerLinuxALSA::LoadMicMixerElement() const { if (errVal < 0) { RTC_LOG(LS_ERROR) << "snd_mixer_load(_inputMixerHandle), error: " << LATE(snd_strerror)(errVal); - _inputMixerHandle = NULL; + _inputMixerHandle = nullptr; return -1; } - snd_mixer_elem_t* elem = NULL; - snd_mixer_elem_t* micElem = NULL; + snd_mixer_elem_t* elem = nullptr; + snd_mixer_elem_t* micElem = nullptr; unsigned mixerIdx = 0; - const char* selemName = NULL; + const char* selemName = nullptr; // Find and store handles to the right mixer elements for (elem = LATE(snd_mixer_first_elem)(_inputMixerHandle); elem; @@ -879,13 +879,13 @@ int32_t AudioMixerManagerLinuxALSA::LoadMicMixerElement() const { } } - if (_inputMixerElement == NULL) { + if (_inputMixerElement == nullptr) { // We didn't find a Capture handle, use Mic. - if (micElem != NULL) { + if (micElem != nullptr) { _inputMixerElement = micElem; RTC_LOG(LS_VERBOSE) << "Using Mic as capture volume."; } else { - _inputMixerElement = NULL; + _inputMixerElement = nullptr; RTC_LOG(LS_ERROR) << "Could not find capture volume on the mixer."; return -1; @@ -900,15 +900,15 @@ int32_t AudioMixerManagerLinuxALSA::LoadSpeakerMixerElement() const { if (errVal < 0) { RTC_LOG(LS_ERROR) << "snd_mixer_load(_outputMixerHandle), error: " << LATE(snd_strerror)(errVal); - _outputMixerHandle = NULL; + _outputMixerHandle = nullptr; return -1; } - snd_mixer_elem_t* elem = NULL; - snd_mixer_elem_t* masterElem = NULL; - snd_mixer_elem_t* speakerElem = NULL; + snd_mixer_elem_t* elem = nullptr; + snd_mixer_elem_t* masterElem = nullptr; + snd_mixer_elem_t* speakerElem = nullptr; unsigned mixerIdx = 0; - const char* selemName = NULL; + const char* selemName = nullptr; // Find and store handles to the right mixer elements for (elem = LATE(snd_mixer_first_elem)(_outputMixerHandle); elem; @@ -938,15 +938,15 @@ int32_t AudioMixerManagerLinuxALSA::LoadSpeakerMixerElement() const { } // If we didn't find a PCM Handle, use Master or Speaker - if (_outputMixerElement == NULL) { - if (masterElem != NULL) { + if (_outputMixerElement == nullptr) { + if (masterElem != nullptr) { _outputMixerElement = masterElem; RTC_LOG(LS_VERBOSE) << "Using Master as output volume."; - } else if (speakerElem != NULL) { + } else if (speakerElem != nullptr) { _outputMixerElement = speakerElem; RTC_LOG(LS_VERBOSE) << "Using Speaker as output volume."; } else { - _outputMixerElement = NULL; + _outputMixerElement = nullptr; RTC_LOG(LS_ERROR) << "Could not find output volume in the mixer."; return -1; } diff --git a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.cc b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.cc index 91beee3c87..9f899158a9 100644 --- a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.cc +++ b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.cc @@ -43,10 +43,10 @@ class AutoPulseLock { AudioMixerManagerLinuxPulse::AudioMixerManagerLinuxPulse() : _paOutputDeviceIndex(-1), _paInputDeviceIndex(-1), - _paPlayStream(NULL), - _paRecStream(NULL), - _paMainloop(NULL), - _paContext(NULL), + _paPlayStream(nullptr), + _paRecStream(nullptr), + _paMainloop(nullptr), + _paContext(nullptr), _paVolume(0), _paMute(0), _paVolSteps(0), @@ -95,8 +95,8 @@ int32_t AudioMixerManagerLinuxPulse::Close() { CloseSpeaker(); CloseMicrophone(); - _paMainloop = NULL; - _paContext = NULL; + _paMainloop = nullptr; + _paContext = nullptr; _paObjectsSet = false; return 0; @@ -108,7 +108,7 @@ int32_t AudioMixerManagerLinuxPulse::CloseSpeaker() { // Reset the index to -1 _paOutputDeviceIndex = -1; - _paPlayStream = NULL; + _paPlayStream = nullptr; return 0; } @@ -119,7 +119,7 @@ int32_t AudioMixerManagerLinuxPulse::CloseMicrophone() { // Reset the index to -1 _paInputDeviceIndex = -1; - _paRecStream = NULL; + _paRecStream = nullptr; return 0; } @@ -226,10 +226,10 @@ int32_t AudioMixerManagerLinuxPulse::SetSpeakerVolume(uint32_t volume) { pa_cvolume cVolumes; LATE(pa_cvolume_set)(&cVolumes, spec->channels, volume); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; paOperation = LATE(pa_context_set_sink_input_volume)( _paContext, LATE(pa_stream_get_index)(_paPlayStream), &cVolumes, - PaSetVolumeCallback, NULL); + PaSetVolumeCallback, nullptr); if (!paOperation) { setFailed = true; } @@ -346,10 +346,10 @@ int32_t AudioMixerManagerLinuxPulse::SetSpeakerMute(bool enable) { // We can only really mute if we have a connected stream AutoPulseLock auto_lock(_paMainloop); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; paOperation = LATE(pa_context_set_sink_input_mute)( _paContext, LATE(pa_stream_get_index)(_paPlayStream), (int)enable, - PaSetVolumeCallback, NULL); + PaSetVolumeCallback, nullptr); if (!paOperation) { setFailed = true; } @@ -442,7 +442,7 @@ int32_t AudioMixerManagerLinuxPulse::StereoRecordingIsAvailable( deviceIndex = LATE(pa_stream_get_device_index)(_paRecStream); } - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; // Get info for this source // We want to know if the actual device can record in stereo @@ -487,7 +487,7 @@ int32_t AudioMixerManagerLinuxPulse::SetMicrophoneMute(bool enable) { } bool setFailed(false); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; uint32_t deviceIndex = (uint32_t)_paInputDeviceIndex; @@ -503,7 +503,7 @@ int32_t AudioMixerManagerLinuxPulse::SetMicrophoneMute(bool enable) { // Set mute switch for the source paOperation = LATE(pa_context_set_source_mute_by_index)( - _paContext, deviceIndex, enable, PaSetVolumeCallback, NULL); + _paContext, deviceIndex, enable, PaSetVolumeCallback, nullptr); if (!paOperation) { setFailed = true; @@ -599,7 +599,7 @@ int32_t AudioMixerManagerLinuxPulse::SetMicrophoneVolume(uint32_t volume) { } bool setFailed(false); - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; // Get the number of channels for this source paOperation = LATE(pa_context_get_source_info_by_index)( @@ -613,7 +613,7 @@ int32_t AudioMixerManagerLinuxPulse::SetMicrophoneVolume(uint32_t volume) { // Set the volume for the source paOperation = LATE(pa_context_set_source_volume_by_index)( - _paContext, deviceIndex, &cVolumes, PaSetVolumeCallback, NULL); + _paContext, deviceIndex, &cVolumes, PaSetVolumeCallback, nullptr); if (!paOperation) { setFailed = true; @@ -807,7 +807,7 @@ void AudioMixerManagerLinuxPulse::WaitForOperationCompletion( } bool AudioMixerManagerLinuxPulse::GetSinkInputInfo() const { - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; AutoPulseLock auto_lock(_paMainloop); // Get info for this stream (sink input). @@ -820,7 +820,7 @@ bool AudioMixerManagerLinuxPulse::GetSinkInputInfo() const { } bool AudioMixerManagerLinuxPulse::GetSinkInfoByIndex(int device_index) const { - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; AutoPulseLock auto_lock(_paMainloop); paOperation = LATE(pa_context_get_sink_info_by_index)( @@ -831,7 +831,7 @@ bool AudioMixerManagerLinuxPulse::GetSinkInfoByIndex(int device_index) const { } bool AudioMixerManagerLinuxPulse::GetSourceInfoByIndex(int device_index) const { - pa_operation* paOperation = NULL; + pa_operation* paOperation = nullptr; AutoPulseLock auto_lock(_paMainloop); paOperation = LATE(pa_context_get_source_info_by_index)( diff --git a/modules/audio_device/test_audio_device_impl.cc b/modules/audio_device/test_audio_device_impl.cc index 2e12be175b..32944d0539 100644 --- a/modules/audio_device/test_audio_device_impl.cc +++ b/modules/audio_device/test_audio_device_impl.cc @@ -41,8 +41,8 @@ TestAudioDevice::TestAudioDevice( rendering_(false), capturing_(false) { auto good_sample_rate = [](int sr) { - return sr == 8000 || sr == 16000 || sr == 32000 || sr == 44100 || - sr == 48000; + return sr == 8000 || sr == 16000 || sr == 24000 || sr == 32000 || + sr == 44100 || sr == 48000; }; if (renderer_) { diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc index 015a0a394f..de17a0f647 100644 --- a/modules/audio_device/win/audio_device_core_win.cc +++ b/modules/audio_device/win/audio_device_core_win.cc @@ -45,8 +45,8 @@ #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" #include "rtc_base/string_utils.h" +#include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" -#include "system_wrappers/include/sleep.h" // Macro that calls a COM method returning HRESULT value. #define EXIT_ON_ERROR(hres) \ @@ -2878,7 +2878,7 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() { // ------------------ THREAD LOOP ------------------ << - SleepMs(static_cast(endpointBufferSizeMS + 0.5)); + Thread::SleepMs(static_cast(endpointBufferSizeMS + 0.5)); hr = _ptrClientOut->Stop(); Exit: diff --git a/modules/audio_mixer/BUILD.gn b/modules/audio_mixer/BUILD.gn index 38c4e95abb..37c82ff731 100644 --- a/modules/audio_mixer/BUILD.gn +++ b/modules/audio_mixer/BUILD.gn @@ -116,6 +116,7 @@ if (rtc_include_tests) { ":audio_mixer_test_utils", "../../api:array_view", "../../api:rtp_packet_info", + "../../api/audio:audio_frame_api", "../../api/audio:audio_mixer_api", "../../api/units:timestamp", "../../audio/utility:audio_frame_operations", diff --git a/modules/audio_mixer/frame_combiner.cc b/modules/audio_mixer/frame_combiner.cc index b801ca7f8e..e9d5f0c9cc 100644 --- a/modules/audio_mixer/frame_combiner.cc +++ b/modules/audio_mixer/frame_combiner.cc @@ -12,26 +12,22 @@ #include #include +#include #include -#include #include -#include #include #include #include "api/array_view.h" -#include "api/audio/audio_processing.h" +#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" #include "api/rtp_packet_info.h" #include "api/rtp_packet_infos.h" #include "common_audio/include/audio_util.h" #include "modules/audio_mixer/audio_frame_manipulator.h" -#include "modules/audio_mixer/audio_mixer_impl.h" -#include "modules/audio_processing/include/audio_frame_view.h" +#include "modules/audio_processing/agc2/limiter.h" #include "modules/audio_processing/logging/apm_data_dumper.h" -#include "rtc_base/arraysize.h" #include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" -#include "system_wrappers/include/metrics.h" namespace webrtc { namespace { @@ -90,8 +86,7 @@ void MixToFloatFrame(ArrayView mix_list, DeinterleavedView& mixing_buffer) { const size_t number_of_channels = NumChannels(mixing_buffer); // Clear the mixing buffer. - ArrayView raw_data = mixing_buffer.data(); - ClearSamples(raw_data); + mixing_buffer.Clear(); // Convert to FloatS16 and mix. for (size_t i = 0; i < mix_list.size(); ++i) { diff --git a/modules/audio_mixer/frame_combiner_unittest.cc b/modules/audio_mixer/frame_combiner_unittest.cc index b481035b02..904417c25a 100644 --- a/modules/audio_mixer/frame_combiner_unittest.cc +++ b/modules/audio_mixer/frame_combiner_unittest.cc @@ -10,15 +10,17 @@ #include "modules/audio_mixer/frame_combiner.h" +#include #include #include #include -#include #include -#include #include #include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" +#include "api/audio/channel_layout.h" #include "api/rtp_packet_info.h" #include "api/rtp_packet_infos.h" #include "api/units/timestamp.h" @@ -145,14 +147,13 @@ TEST(FrameCombinerDeathTest, BuildCrashesWithManyChannels) { FrameCombiner combiner(true); for (const int rate : {8000, 18000, 34000, 48000}) { for (const int number_of_channels : {10, 20, 21}) { + RTC_DCHECK_LE(number_of_channels, kMaxNumberOfAudioChannels); if (static_cast(rate / 100 * number_of_channels) > AudioFrame::kMaxDataSizeSamples) { continue; } const std::vector all_frames = {&frame1, &frame2}; - // With an unsupported channel count, this will crash in - // `AudioFrame::UpdateFrame`. - EXPECT_DEATH(SetUpFrames(rate, number_of_channels), ""); + SetUpFrames(rate, number_of_channels); const int number_of_frames = 2; SCOPED_TRACE( diff --git a/modules/audio_mixer/sine_wave_generator.cc b/modules/audio_mixer/sine_wave_generator.cc index deb88468d6..be3dd0cfa6 100644 --- a/modules/audio_mixer/sine_wave_generator.cc +++ b/modules/audio_mixer/sine_wave_generator.cc @@ -13,12 +13,14 @@ #include #include +#include + #include "rtc_base/numerics/safe_conversions.h" namespace webrtc { namespace { -constexpr float kPi = 3.14159265f; +constexpr float kPi = std::numbers::pi_v; } // namespace void SineWaveGenerator::GenerateNextFrame(AudioFrame* frame) { diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index 2454689de1..2d92bc5178 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -61,6 +61,7 @@ rtc_library("audio_buffer") { "../../common_audio", "../../common_audio:common_audio_c", "../../rtc_base:checks", + "../../rtc_base:gtest_prod", ] } @@ -82,7 +83,25 @@ rtc_library("high_pass_filter") { ] } -rtc_source_set("aec_dump_interface") { +rtc_library("post_filter") { + visibility = [ "*" ] + + sources = [ + "post_filter.cc", + "post_filter.h", + ] + + defines = [] + + deps = [ + ":audio_buffer", + "../../api:array_view", + "../../rtc_base:checks", + "utility:cascaded_biquad_filter", + ] +} + +rtc_library("aec_dump_interface") { visibility = [ "*" ] sources = [ "include/aec_dump.cc", @@ -91,6 +110,7 @@ rtc_source_set("aec_dump_interface") { deps = [ ":audio_frame_view", + "../../api/audio:audio_frame_api", "../../api/audio:audio_processing", "//third_party/abseil-cpp/absl/base:core_headers", ] @@ -151,11 +171,13 @@ rtc_library("audio_processing") { ":audio_frame_view", ":gain_controller2", ":high_pass_filter", + ":post_filter", ":rms_level", "../../api:array_view", "../../api:field_trials_view", "../../api:function_view", "../../api:make_ref_counted", + "../../api:scoped_refptr", "../../api/audio:aec3_config", "../../api/audio:audio_frame_api", "../../api/audio:audio_processing", @@ -170,6 +192,7 @@ rtc_library("audio_processing") { "../../common_audio:fir_filter_factory", "../../common_audio/third_party/ooura:fft_size_256", "../../rtc_base:checks", + "../../rtc_base:denormal_disabler", "../../rtc_base:event_tracer", "../../rtc_base:gtest_prod", "../../rtc_base:logging", @@ -181,7 +204,6 @@ rtc_library("audio_processing") { "../../rtc_base/synchronization:mutex", "../../rtc_base/system:rtc_export", "../../system_wrappers", - "../../system_wrappers:denormal_disabler", "../../system_wrappers:metrics", "aec3", "aec_dump", @@ -189,6 +211,7 @@ rtc_library("audio_processing") { "agc", "agc:gain_control_interface", "agc:legacy_agc", + "agc2:input_volume_controller", "agc2:input_volume_stats_reporter", "capture_levels_adjuster", "ns", @@ -229,7 +252,7 @@ rtc_library("residual_echo_detector") { ] } -rtc_source_set("rms_level") { +rtc_library("rms_level") { visibility = [ "*" ] sources = [ "rms_level.cc", @@ -249,7 +272,10 @@ rtc_library("audio_processing_statistics") { rtc_source_set("audio_frame_view") { sources = [ "include/audio_frame_view.h" ] - deps = [ "../../api/audio:audio_frame_api" ] + deps = [ + "../../api/audio:audio_frame_api", + "../../rtc_base:checks", + ] } if (rtc_enable_protobuf) { @@ -334,6 +360,7 @@ if (rtc_include_tests) { ":gain_controller2", ":high_pass_filter", ":mocks", + ":post_filter", "../../api:array_view", "../../api:make_ref_counted", "../../api:scoped_refptr", @@ -341,6 +368,7 @@ if (rtc_include_tests) { "../../api/audio:aec3_factory", "../../api/audio:audio_frame_api", "../../api/audio:audio_processing", + "../../api/audio:audio_processing_statistics", "../../api/audio:builtin_audio_processing_builder", "../../api/audio:echo_detector_creator", "../../api/environment", @@ -348,6 +376,7 @@ if (rtc_include_tests) { "../../common_audio", "../../common_audio:common_audio_c", "../../rtc_base:checks", + "../../rtc_base:denormal_disabler", "../../rtc_base:gtest_prod", "../../rtc_base:macromagic", "../../rtc_base:platform_thread", @@ -365,7 +394,6 @@ if (rtc_include_tests) { "../../rtc_base/system:arch", "../../rtc_base/system:file_wrapper", "../../system_wrappers", - "../../system_wrappers:denormal_disabler", "../../test:field_trial", "../../test:fileutils", "../../test:rtc_expect_death", @@ -388,6 +416,7 @@ if (rtc_include_tests) { "capture_levels_adjuster", "capture_levels_adjuster:capture_levels_adjuster_unittests", "test/conversational_speech:unittest", + "utility:cascaded_biquad_filter_unittest", "utility:legacy_delay_estimator_unittest", "utility:pffft_wrapper_unittest", "vad:vad_unittests", @@ -431,6 +460,7 @@ if (rtc_include_tests) { "echo_detector/normalized_covariance_estimator_unittest.cc", "gain_control_unittest.cc", "high_pass_filter_unittest.cc", + "post_filter_unittest.cc", "residual_echo_detector_unittest.cc", "rms_level_unittest.cc", "test/debug_dump_replayer.cc", diff --git a/modules/audio_processing/aec3/adaptive_fir_filter.cc b/modules/audio_processing/aec3/adaptive_fir_filter.cc index 22c3be2b80..e6e1de47b4 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter.cc @@ -10,7 +10,15 @@ #include "modules/audio_processing/aec3/adaptive_fir_filter.h" +#include +#include +#include + // Defines WEBRTC_ARCH_X86_FAMILY, used below. +#include "api/array_view.h" +#include "modules/audio_processing/aec3/aec3_common.h" +#include "modules/audio_processing/aec3/render_buffer.h" +#include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/system/arch.h" #if defined(WEBRTC_HAS_NEON) @@ -22,7 +30,6 @@ #include #include -#include #include "modules/audio_processing/aec3/fft_data.h" #include "rtc_base/checks.h" diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc index ac973bed8f..d229abea32 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc @@ -14,9 +14,24 @@ #include #include +#include +#include +#include #include +#include #include - +#include +#include + +#include "api/array_view.h" +#include "api/audio/echo_canceller3_config.h" +#include "modules/audio_processing/aec3/aec3_common.h" +#include "modules/audio_processing/aec3/block.h" +#include "modules/audio_processing/aec3/delay_estimate.h" +#include "modules/audio_processing/aec3/echo_path_variability.h" +#include "modules/audio_processing/aec3/fft_data.h" +#include "modules/audio_processing/aec3/subtractor_output.h" +#include "rtc_base/checks.h" #include "rtc_base/system/arch.h" #if defined(WEBRTC_ARCH_X86_FAMILY) #include @@ -32,7 +47,6 @@ #include "modules/audio_processing/logging/apm_data_dumper.h" #include "modules/audio_processing/test/echo_canceller_test_tools.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" -#include "rtc_base/arraysize.h" #include "rtc_base/numerics/safe_minmax.h" #include "rtc_base/random.h" #include "rtc_base/strings/string_builder.h" @@ -498,9 +512,10 @@ TEST_P(AdaptiveFirFilterMultiChannel, FilterAndAdapt) { num_capture_channels); std::array E2_coarse; // [B,A] = butter(2,100/8000,'high') - constexpr CascadedBiQuadFilter::BiQuadCoefficients - kHighPassFilterCoefficients = {{0.97261f, -1.94523f, 0.97261f}, - {-1.94448f, 0.94598f}}; + constexpr std::array + kHighPassFilterCoefficients = {{ + {{0.97261f, -1.94523f, 0.97261f}, {-1.94448f, 0.94598f}}, + }}; for (auto& Y2_ch : Y2) { Y2_ch.fill(0.f); } @@ -521,9 +536,12 @@ TEST_P(AdaptiveFirFilterMultiChannel, FilterAndAdapt) { num_render_channels); for (size_t ch = 0; ch < num_render_channels; ++ch) { x_hp_filter[ch] = std::make_unique( - kHighPassFilterCoefficients, 1); + ArrayView( + kHighPassFilterCoefficients)); } - CascadedBiQuadFilter y_hp_filter(kHighPassFilterCoefficients, 1); + CascadedBiQuadFilter y_hp_filter( + (ArrayView( + kHighPassFilterCoefficients))); SCOPED_TRACE(ProduceDebugText(num_render_channels, delay_samples)); const size_t num_blocks_to_process = diff --git a/modules/audio_processing/aec3/block_framer_unittest.cc b/modules/audio_processing/aec3/block_framer_unittest.cc index c9b60588d1..d45b96e980 100644 --- a/modules/audio_processing/aec3/block_framer_unittest.cc +++ b/modules/audio_processing/aec3/block_framer_unittest.cc @@ -124,9 +124,9 @@ void RunWronglySizedInsertAndExtractParametersTest( num_sub_frame_bands, std::vector>( num_sub_frame_channels, std::vector(sub_frame_length, 0.f))); - std::vector>> output_sub_frame_view( + std::vector>> output_sub_frame_view( output_sub_frame.size(), - std::vector>(num_sub_frame_channels)); + std::vector>(num_sub_frame_channels)); SetupSubFrameView(&output_sub_frame, &output_sub_frame_view); BlockFramer framer(correct_num_bands, correct_num_channels); EXPECT_DEATH( @@ -147,9 +147,9 @@ void RunWronglySizedInsertParameterTest(int sample_rate_hz, correct_num_bands, std::vector>( correct_num_channels, std::vector(kSubFrameLength, 0.f))); - std::vector>> output_sub_frame_view( + std::vector>> output_sub_frame_view( output_sub_frame.size(), - std::vector>(correct_num_channels)); + std::vector>(correct_num_channels)); SetupSubFrameView(&output_sub_frame, &output_sub_frame_view); BlockFramer framer(correct_num_bands, correct_num_channels); framer.InsertBlockAndExtractSubFrame(correct_block, &output_sub_frame_view); @@ -174,9 +174,8 @@ void RunWronglyInsertOrderTest(int sample_rate_hz, correct_num_bands, std::vector>( num_channels, std::vector(kSubFrameLength, 0.f))); - std::vector>> output_sub_frame_view( - output_sub_frame.size(), - std::vector>(num_channels)); + std::vector>> output_sub_frame_view( + output_sub_frame.size(), std::vector>(num_channels)); SetupSubFrameView(&output_sub_frame, &output_sub_frame_view); BlockFramer framer(correct_num_bands, num_channels); for (size_t k = 0; k < num_preceeding_api_calls; ++k) { @@ -293,7 +292,7 @@ TEST(BlockFramerDeathTest, WrongNumberOfPreceedingApiCallsForInsertBlock) { for (size_t num_channels : {1, 2, 8}) { for (auto rate : {16000, 32000, 48000}) { for (size_t num_calls = 0; num_calls < 4; ++num_calls) { - webrtc::StringBuilder ss; + StringBuilder ss; ss << "Sample rate: " << rate; ss << ", Num channels: " << num_channels; ss << ", Num preceeding InsertBlockAndExtractSubFrame calls: " diff --git a/modules/audio_processing/aec3/block_processor_unittest.cc b/modules/audio_processing/aec3/block_processor_unittest.cc index a56eaac9fa..eece30c9a7 100644 --- a/modules/audio_processing/aec3/block_processor_unittest.cc +++ b/modules/audio_processing/aec3/block_processor_unittest.cc @@ -132,9 +132,9 @@ TEST(BlockProcessor, DISABLED_DelayControllerIntegration) { Random random_generator(42U); for (auto rate : {16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); - std::unique_ptr> + std::unique_ptr> render_delay_buffer_mock( - new StrictMock(rate, 1)); + new StrictMock(rate, 1)); EXPECT_CALL(*render_delay_buffer_mock, Insert(_)) .Times(kNumBlocks) .WillRepeatedly(Return(RenderDelayBuffer::BufferingEvent::kNone)); @@ -171,15 +171,14 @@ TEST(BlockProcessor, DISABLED_SubmoduleIntegration) { Random random_generator(42U); for (auto rate : {16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); - std::unique_ptr> + std::unique_ptr> render_delay_buffer_mock( - new StrictMock(rate, 1)); - std::unique_ptr< - ::testing::StrictMock> + new StrictMock(rate, 1)); + std::unique_ptr<::testing::StrictMock> render_delay_controller_mock( - new StrictMock()); - std::unique_ptr> - echo_remover_mock(new StrictMock()); + new StrictMock()); + std::unique_ptr> + echo_remover_mock(new StrictMock()); EXPECT_CALL(*render_delay_buffer_mock, Insert(_)) .Times(kNumBlocks - 1) @@ -291,10 +290,9 @@ TEST(BlockProcessor, ExternalDelayAppliedCorrectlyWithInitialCaptureCalls) { std::unique_ptr delay_buffer( RenderDelayBuffer::Create(config, kSampleRateHz, kNumRenderChannels)); - std::unique_ptr> - echo_remover_mock(new NiceMock()); - webrtc::test::MockEchoRemover* echo_remover_mock_pointer = - echo_remover_mock.get(); + std::unique_ptr> echo_remover_mock( + new NiceMock()); + test::MockEchoRemover* echo_remover_mock_pointer = echo_remover_mock.get(); std::unique_ptr block_processor(BlockProcessor::Create( config, kSampleRateHz, kNumRenderChannels, kNumCaptureChannels, diff --git a/modules/audio_processing/aec3/comfort_noise_generator.cc b/modules/audio_processing/aec3/comfort_noise_generator.cc index ed643f4400..17a3b70d36 100644 --- a/modules/audio_processing/aec3/comfort_noise_generator.cc +++ b/modules/audio_processing/aec3/comfort_noise_generator.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "common_audio/signal_processing/include/signal_processing_library.h" @@ -31,6 +32,8 @@ namespace webrtc { namespace { +using std::numbers::sqrt2_v; + // Computes the noise floor value that matches a WGN input of noise_floor_dbfs. float GetNoiseFloorFactor(float noise_floor_dbfs) { // kdBfsNormalization = 20.f*log10(32768.f). @@ -39,14 +42,16 @@ float GetNoiseFloorFactor(float noise_floor_dbfs) { } // Table of sqrt(2) * sin(2*pi*i/32). +// clang-format off constexpr float kSqrt2Sin[32] = { +0.0000000f, +0.2758994f, +0.5411961f, +0.7856950f, +1.0000000f, - +1.1758756f, +1.3065630f, +1.3870398f, +1.4142136f, +1.3870398f, + +1.1758756f, +1.3065630f, +1.3870398f, +sqrt2_v, +1.3870398f, +1.3065630f, +1.1758756f, +1.0000000f, +0.7856950f, +0.5411961f, +0.2758994f, +0.0000000f, -0.2758994f, -0.5411961f, -0.7856950f, - -1.0000000f, -1.1758756f, -1.3065630f, -1.3870398f, -1.4142136f, + -1.0000000f, -1.1758756f, -1.3065630f, -1.3870398f, -sqrt2_v, -1.3870398f, -1.3065630f, -1.1758756f, -1.0000000f, -0.7856950f, -0.5411961f, -0.2758994f}; +// clang-format on void GenerateComfortNoise(Aec3Optimization optimization, const std::array& N2, diff --git a/modules/audio_processing/aec3/decimator.cc b/modules/audio_processing/aec3/decimator.cc index beac73e22e..0ac9be7b5c 100644 --- a/modules/audio_processing/aec3/decimator.cc +++ b/modules/audio_processing/aec3/decimator.cc @@ -10,63 +10,61 @@ #include "modules/audio_processing/aec3/decimator.h" #include -#include +#include +#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" +#include "modules/audio_processing/utility/cascaded_biquad_filter.h" #include "rtc_base/checks.h" namespace webrtc { namespace { +// signal.ellip(6, 1, 40, 1800/8000, 'lowpass', output='sos') +constexpr std::array + kLowPassFilterDs4 = {{ + {{0.0180919877f, 0.00320961363f, 0.0180919877f}, + {-1.5183195f, 0.633165865f}}, + {{1.0f, -1.24550459f, 1.0f}, {-1.49784254f, 0.853586692f}}, + {{1.0f, -1.4221681f, 1.0f}, {-1.49791282f, 0.969572384f}}, + }}; -// signal.butter(2, 3400/8000.0, 'lowpass', analog=False) -const std::vector GetLowPassFilterDS2() { - return std::vector{ - {{-1.f, 0.f}, {0.13833231f, 0.40743176f}, 0.22711796393486466f}, - {{-1.f, 0.f}, {0.13833231f, 0.40743176f}, 0.22711796393486466f}, - {{-1.f, 0.f}, {0.13833231f, 0.40743176f}, 0.22711796393486466f}}; -} - -// signal.ellip(6, 1, 40, 1800/8000, btype='lowpass', analog=False) -const std::vector GetLowPassFilterDS4() { - return std::vector{ - {{-0.08873842f, 0.99605496f}, {0.75916227f, 0.23841065f}, 0.26250696827f}, - {{0.62273832f, 0.78243018f}, {0.74892112f, 0.5410152f}, 0.26250696827f}, - {{0.71107693f, 0.70311421f}, {0.74895534f, 0.63924616f}, 0.26250696827f}}; -} +// signal.cheby1(1, 6, [1000/8000, 2000/8000], 'bandpass', output='sos') +// repeated 5 times. +constexpr std::array + kBandPassFilterDs8 = {{ + {{0.103304783f, 0.0f, -0.103304783f}, {-1.520363f, 0.793390435f}}, + {{0.103304783f, 0.0f, -0.103304783f}, {-1.520363f, 0.793390435f}}, + {{0.103304783f, 0.0f, -0.103304783f}, {-1.520363f, 0.793390435f}}, + {{0.103304783f, 0.0f, -0.103304783f}, {-1.520363f, 0.793390435f}}, + {{0.103304783f, 0.0f, -0.103304783f}, {-1.520363f, 0.793390435f}}, + }}; -// signal.cheby1(1, 6, [1000/8000, 2000/8000], btype='bandpass', analog=False) -const std::vector GetBandPassFilterDS8() { - return std::vector{ - {{1.f, 0.f}, {0.7601815f, 0.46423542f}, 0.10330478266505948f, true}, - {{1.f, 0.f}, {0.7601815f, 0.46423542f}, 0.10330478266505948f, true}, - {{1.f, 0.f}, {0.7601815f, 0.46423542f}, 0.10330478266505948f, true}, - {{1.f, 0.f}, {0.7601815f, 0.46423542f}, 0.10330478266505948f, true}, - {{1.f, 0.f}, {0.7601815f, 0.46423542f}, 0.10330478266505948f, true}}; -} +// signal.butter(2, 1000/8000.0, 'highpass', output='sos') +constexpr std::array + kHighPassFilter = {{ + {{0.757076375f, -1.51415275f, 0.757076375f}, + {-1.45424359f, 0.574061915f}}, + }}; -// signal.butter(2, 1000/8000.0, 'highpass', analog=False) -const std::vector GetHighPassFilter() { - return std::vector{ - {{1.f, 0.f}, {0.72712179f, 0.21296904f}, 0.7570763753338849f}}; -} - -const std::vector GetPassThroughFilter() { - return std::vector{}; -} +constexpr std::array + kPassThroughFilter = {{}}; } // namespace Decimator::Decimator(size_t down_sampling_factor) : down_sampling_factor_(down_sampling_factor), - anti_aliasing_filter_(down_sampling_factor_ == 4 - ? GetLowPassFilterDS4() - : (down_sampling_factor_ == 8 - ? GetBandPassFilterDS8() - : GetLowPassFilterDS2())), - noise_reduction_filter_(down_sampling_factor_ == 8 - ? GetPassThroughFilter() - : GetHighPassFilter()) { - RTC_DCHECK(down_sampling_factor_ == 2 || down_sampling_factor_ == 4 || - down_sampling_factor_ == 8); + anti_aliasing_filter_( + down_sampling_factor_ == 4 + ? ArrayView( + kLowPassFilterDs4) + : ArrayView( + kBandPassFilterDs8)), + noise_reduction_filter_( + down_sampling_factor_ == 8 + ? (ArrayView( + kPassThroughFilter)) + : (ArrayView( + kHighPassFilter))) { + RTC_DCHECK(down_sampling_factor_ == 4 || down_sampling_factor_ == 8); } void Decimator::Decimate(ArrayView in, ArrayView out) { diff --git a/modules/audio_processing/aec3/decimator_unittest.cc b/modules/audio_processing/aec3/decimator_unittest.cc index 3ff4294fbb..69785c12b0 100644 --- a/modules/audio_processing/aec3/decimator_unittest.cc +++ b/modules/audio_processing/aec3/decimator_unittest.cc @@ -16,11 +16,14 @@ #include #include #include +#include #include #include #include +#include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" +#include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" @@ -34,8 +37,8 @@ std::string ProduceDebugText(int sample_rate_hz) { return ss.Release(); } -constexpr size_t kDownSamplingFactors[] = {2, 4, 8}; -constexpr float kPi = 3.141592f; +constexpr size_t kDownSamplingFactors[] = {4, 8}; +constexpr float kPi = std::numbers::pi_v; constexpr size_t kNumStartupBlocks = 50; constexpr size_t kNumBlocks = 1000; diff --git a/modules/audio_processing/aec3/echo_canceller3_unittest.cc b/modules/audio_processing/aec3/echo_canceller3_unittest.cc index 486c64cd3c..f0fa73de42 100644 --- a/modules/audio_processing/aec3/echo_canceller3_unittest.cc +++ b/modules/audio_processing/aec3/echo_canceller3_unittest.cc @@ -316,9 +316,8 @@ class EchoCanceller3Tester { constexpr size_t kNumFullBlocksPerFrame = 160 / kBlockSize; constexpr size_t kExpectedNumBlocksToProcess = (kNumFramesToProcess * 160) / kBlockSize; - std::unique_ptr> - block_processor_mock( - new StrictMock()); + std::unique_ptr> + block_processor_mock(new StrictMock()); EXPECT_CALL(*block_processor_mock, BufferRender(_)) .Times(kExpectedNumBlocksToProcess); EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); @@ -393,9 +392,8 @@ class EchoCanceller3Tester { EchoLeakageTestVariant leakage_report_variant) { constexpr size_t kExpectedNumBlocksToProcess = (kNumFramesToProcess * 160) / kBlockSize; - std::unique_ptr> - block_processor_mock( - new StrictMock()); + std::unique_ptr> + block_processor_mock(new StrictMock()); EXPECT_CALL(*block_processor_mock, BufferRender(_)) .Times(kExpectedNumBlocksToProcess); EXPECT_CALL(*block_processor_mock, ProcessCapture(_, _, _, _)) @@ -482,9 +480,8 @@ class EchoCanceller3Tester { const size_t kNumFullBlocksPerFrame = 160 / kBlockSize; const size_t kExpectedNumBlocksToProcess = (kNumFramesToProcess * 160) / kBlockSize; - std::unique_ptr> - block_processor_mock( - new StrictMock()); + std::unique_ptr> + block_processor_mock(new StrictMock()); EXPECT_CALL(*block_processor_mock, BufferRender(_)) .Times(kExpectedNumBlocksToProcess); EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc index 8a105041e0..1fbac7642a 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc +++ b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc @@ -11,13 +11,20 @@ #include "modules/audio_processing/aec3/echo_path_delay_estimator.h" #include +#include +#include +#include #include +#include #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" +#include "modules/audio_processing/aec3/block.h" +#include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/render_delay_buffer.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "modules/audio_processing/test/echo_canceller_test_tools.h" +#include "rtc_base/checks.h" #include "rtc_base/random.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" @@ -74,7 +81,7 @@ TEST(EchoPathDelayEstimator, DelayEstimation) { Block render(kNumBands, kNumRenderChannels); Block capture(/*num_bands=*/1, kNumCaptureChannels); ApmDataDumper data_dumper(0); - constexpr size_t kDownSamplingFactors[] = {2, 4, 8}; + constexpr size_t kDownSamplingFactors[] = {4, 8}; for (auto down_sampling_factor : kDownSamplingFactors) { EchoCanceller3Config config; config.delay.delay_headroom_samples = 0; diff --git a/modules/audio_processing/aec3/frame_blocker_unittest.cc b/modules/audio_processing/aec3/frame_blocker_unittest.cc index 135018412a..ee6296978f 100644 --- a/modules/audio_processing/aec3/frame_blocker_unittest.cc +++ b/modules/audio_processing/aec3/frame_blocker_unittest.cc @@ -199,9 +199,9 @@ void RunWronglySizedInsertAndExtractParametersTest( num_sub_frame_bands, std::vector>( num_sub_frame_channels, std::vector(sub_frame_length, 0.f))); - std::vector>> input_sub_frame_view( + std::vector>> input_sub_frame_view( input_sub_frame.size(), - std::vector>(num_sub_frame_channels)); + std::vector>(num_sub_frame_channels)); FillSubFrameView(0, 0, &input_sub_frame, &input_sub_frame_view); FrameBlocker blocker(correct_num_bands, correct_num_channels); EXPECT_DEATH( @@ -222,9 +222,9 @@ void RunWronglySizedExtractParameterTest(int sample_rate_hz, correct_num_bands, std::vector>( correct_num_channels, std::vector(kSubFrameLength, 0.f))); - std::vector>> input_sub_frame_view( + std::vector>> input_sub_frame_view( input_sub_frame.size(), - std::vector>(correct_num_channels)); + std::vector>(correct_num_channels)); FillSubFrameView(0, 0, &input_sub_frame, &input_sub_frame_view); FrameBlocker blocker(correct_num_bands, correct_num_channels); blocker.InsertSubFrameAndExtractBlock(input_sub_frame_view, &correct_block); @@ -247,9 +247,8 @@ void RunWrongExtractOrderTest(int sample_rate_hz, std::vector>> input_sub_frame( num_bands, std::vector>( num_channels, std::vector(kSubFrameLength, 0.f))); - std::vector>> input_sub_frame_view( - input_sub_frame.size(), - std::vector>(num_channels)); + std::vector>> input_sub_frame_view( + input_sub_frame.size(), std::vector>(num_channels)); FillSubFrameView(0, 0, &input_sub_frame, &input_sub_frame_view); FrameBlocker blocker(num_bands, num_channels); for (size_t k = 0; k < num_preceeding_api_calls; ++k) { @@ -367,7 +366,7 @@ TEST(FrameBlockerDeathTest, WrongNumberOfPreceedingApiCallsForExtractBlock) { for (auto rate : {16000, 32000, 48000}) { for (size_t num_channels : {1, 2, 4, 8}) { for (size_t num_calls = 0; num_calls < 4; ++num_calls) { - webrtc::StringBuilder ss; + StringBuilder ss; ss << "Sample rate: " << rate; ss << "Num channels: " << num_channels; ss << ", Num preceeding InsertSubFrameAndExtractBlock calls: " @@ -395,8 +394,7 @@ TEST(FrameBlockerDeathTest, NullBlockParameter) { std::vector>> sub_frame( 1, std::vector>( 1, std::vector(kSubFrameLength, 0.f))); - std::vector>> sub_frame_view( - sub_frame.size()); + std::vector>> sub_frame_view(sub_frame.size()); FillSubFrameView(0, 0, &sub_frame, &sub_frame_view); EXPECT_DEATH( FrameBlocker(1, 1).InsertSubFrameAndExtractBlock(sub_frame_view, nullptr), diff --git a/modules/audio_processing/aec3/matched_filter.cc b/modules/audio_processing/aec3/matched_filter.cc index 90d550a255..866f941697 100644 --- a/modules/audio_processing/aec3/matched_filter.cc +++ b/modules/audio_processing/aec3/matched_filter.cc @@ -13,7 +13,7 @@ #include // Defines WEBRTC_ARCH_X86_FAMILY, used below. -#include "rtc_base/system/arch.h" +#include "rtc_base/system/arch.h" // IWYU pragma: keep #if defined(WEBRTC_HAS_NEON) #include @@ -118,7 +118,7 @@ void MatchedFilterCoreWithAccumulatedError_NEON( } const float* x_p = chunk1 != h_size ? scratch_memory.data() : &x[x_start_index]; - const float* h_p = &h[0]; + const float* h_cp = &h[0]; float* accumulated_error_p = &accumulated_error[0]; // Initialize values for the accumulation. float32x4_t x2_sum_128 = vdupq_n_f32(0); @@ -127,10 +127,10 @@ void MatchedFilterCoreWithAccumulatedError_NEON( // Perform 128 bit vector operations. const int limit_by_4 = h_size >> 2; for (int k = limit_by_4; k > 0; - --k, h_p += 4, x_p += 4, accumulated_error_p++) { + --k, h_cp += 4, x_p += 4, accumulated_error_p++) { // Load the data into 128 bit vectors. const float32x4_t x_k = vld1q_f32(x_p); - const float32x4_t h_k = vld1q_f32(h_p); + const float32x4_t h_k = vld1q_f32(h_cp); // Compute and accumulate x * x. x2_sum_128 = vmlaq_f32(x2_sum_128, x_k, x_k); // Compute x * h @@ -154,7 +154,6 @@ void MatchedFilterCoreWithAccumulatedError_NEON( float* h_p = &h[0]; x_p = chunk1 != h_size ? scratch_memory.data() : &x[x_start_index]; // Perform 128 bit vector operations. - const int limit_by_4 = h_size >> 2; for (int k = limit_by_4; k > 0; --k, h_p += 4, x_p += 4) { // Load the data into 128 bit vectors. float32x4_t h_k = vld1q_f32(h_p); @@ -197,7 +196,7 @@ void MatchedFilterCore_NEON(size_t x_start_index, RTC_DCHECK_GT(x_size, x_start_index); const float* x_p = &x[x_start_index]; - const float* h_p = &h[0]; + const float* h_cp = &h[0]; // Initialize values for the accumulation. float32x4_t s_128 = vdupq_n_f32(0); @@ -215,20 +214,20 @@ void MatchedFilterCore_NEON(size_t x_start_index, for (int limit : {chunk1, chunk2}) { // Perform 128 bit vector operations. const int limit_by_4 = limit >> 2; - for (int k = limit_by_4; k > 0; --k, h_p += 4, x_p += 4) { + for (int k = limit_by_4; k > 0; --k, h_cp += 4, x_p += 4) { // Load the data into 128 bit vectors. const float32x4_t x_k = vld1q_f32(x_p); - const float32x4_t h_k = vld1q_f32(h_p); + const float32x4_t h_k = vld1q_f32(h_cp); // Compute and accumulate x * x and h * x. x2_sum_128 = vmlaq_f32(x2_sum_128, x_k, x_k); s_128 = vmlaq_f32(s_128, h_k, x_k); } // Perform non-vector operations for any remaining items. - for (int k = limit - limit_by_4 * 4; k > 0; --k, ++h_p, ++x_p) { + for (int k = limit - limit_by_4 * 4; k > 0; --k, ++h_cp, ++x_p) { const float x_k = *x_p; x2_sum += x_k * x_k; - s += *h_p * x_k; + s += *h_cp * x_k; } x_p = &x[0]; diff --git a/modules/audio_processing/aec3/matched_filter_unittest.cc b/modules/audio_processing/aec3/matched_filter_unittest.cc index 332f877aad..691bca4b48 100644 --- a/modules/audio_processing/aec3/matched_filter_unittest.cc +++ b/modules/audio_processing/aec3/matched_filter_unittest.cc @@ -52,7 +52,7 @@ std::string ProduceDebugText(size_t delay, size_t down_sampling_factor) { } constexpr size_t kNumMatchedFilters = 10; -constexpr size_t kDownSamplingFactors[] = {2, 4, 8}; +constexpr size_t kDownSamplingFactors[] = {4, 8}; constexpr size_t kWindowSizeSubBlocks = 32; constexpr size_t kAlignmentShiftSubBlocks = kWindowSizeSubBlocks * 3 / 4; diff --git a/modules/audio_processing/aec3/render_delay_controller_unittest.cc b/modules/audio_processing/aec3/render_delay_controller_unittest.cc index a3c308e39c..9caa2c0a25 100644 --- a/modules/audio_processing/aec3/render_delay_controller_unittest.cc +++ b/modules/audio_processing/aec3/render_delay_controller_unittest.cc @@ -11,16 +11,19 @@ #include "modules/audio_processing/aec3/render_delay_controller.h" #include +#include #include +#include #include #include +#include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" -#include "modules/audio_processing/aec3/block_processor.h" -#include "modules/audio_processing/aec3/decimator.h" +#include "modules/audio_processing/aec3/block.h" +#include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/render_delay_buffer.h" -#include "modules/audio_processing/logging/apm_data_dumper.h" #include "modules/audio_processing/test/echo_canceller_test_tools.h" +#include "rtc_base/checks.h" #include "rtc_base/random.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" @@ -45,7 +48,7 @@ std::string ProduceDebugText(int sample_rate_hz, return ss.Release(); } -constexpr size_t kDownSamplingFactors[] = {2, 4, 8}; +constexpr size_t kDownSamplingFactors[] = {4, 8}; } // namespace diff --git a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc index e51be2faac..9ef60406a3 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc +++ b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include "api/array_view.h" @@ -29,7 +30,7 @@ namespace webrtc { namespace { -constexpr float kPi = 3.141592f; +constexpr float kPi = std::numbers::pi_v; void ProduceSinusoidInNoise(int sample_rate_hz, size_t sinusoid_channel, diff --git a/modules/audio_processing/aec3/subtractor_unittest.cc b/modules/audio_processing/aec3/subtractor_unittest.cc index 1b53273304..48422895e0 100644 --- a/modules/audio_processing/aec3/subtractor_unittest.cc +++ b/modules/audio_processing/aec3/subtractor_unittest.cc @@ -11,16 +11,31 @@ #include "modules/audio_processing/aec3/subtractor.h" #include +#include +#include #include #include +#include #include +#include +#include +#include "api/array_view.h" +#include "api/audio/echo_canceller3_config.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "modules/audio_processing/aec3/aec3_common.h" +#include "modules/audio_processing/aec3/aec3_fft.h" #include "modules/audio_processing/aec3/aec_state.h" +#include "modules/audio_processing/aec3/block.h" +#include "modules/audio_processing/aec3/delay_estimate.h" +#include "modules/audio_processing/aec3/echo_path_variability.h" #include "modules/audio_processing/aec3/render_delay_buffer.h" +#include "modules/audio_processing/aec3/render_signal_analyzer.h" +#include "modules/audio_processing/aec3/subtractor_output.h" #include "modules/audio_processing/test/echo_canceller_test_tools.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" +#include "rtc_base/checks.h" #include "rtc_base/random.h" #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" @@ -83,20 +98,23 @@ std::vector RunSubtractorTest( } // [B,A] = butter(2,100/8000,'high') - constexpr CascadedBiQuadFilter::BiQuadCoefficients - kHighPassFilterCoefficients = {{0.97261f, -1.94523f, 0.97261f}, - {-1.94448f, 0.94598f}}; + constexpr std::array + kHighPassFilterCoefficients = {{ + {{0.97261f, -1.94523f, 0.97261f}, {-1.94448f, 0.94598f}}, + }}; std::vector> x_hp_filter( num_render_channels); for (size_t ch = 0; ch < num_render_channels; ++ch) { - x_hp_filter[ch] = - std::make_unique(kHighPassFilterCoefficients, 1); + x_hp_filter[ch] = std::make_unique( + ArrayView( + kHighPassFilterCoefficients)); } std::vector> y_hp_filter( num_capture_channels); for (size_t ch = 0; ch < num_capture_channels; ++ch) { - y_hp_filter[ch] = - std::make_unique(kHighPassFilterCoefficients, 1); + y_hp_filter[ch] = std::make_unique( + ArrayView( + kHighPassFilterCoefficients)); } for (int block_num = 0; block_num < num_blocks_to_process; ++block_num) { diff --git a/modules/audio_processing/aec3/suppression_filter_unittest.cc b/modules/audio_processing/aec3/suppression_filter_unittest.cc index 464f5cfed2..8ecc7ecfea 100644 --- a/modules/audio_processing/aec3/suppression_filter_unittest.cc +++ b/modules/audio_processing/aec3/suppression_filter_unittest.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include "test/gtest.h" @@ -21,7 +22,7 @@ namespace webrtc { namespace { -constexpr float kPi = 3.141592f; +constexpr float kPi = std::numbers::pi_v; void ProduceSinusoid(int sample_rate_hz, float sinusoidal_frequency_hz, diff --git a/modules/audio_processing/aec_dump/BUILD.gn b/modules/audio_processing/aec_dump/BUILD.gn index 5fb29422d8..b747aaab8f 100644 --- a/modules/audio_processing/aec_dump/BUILD.gn +++ b/modules/audio_processing/aec_dump/BUILD.gn @@ -34,6 +34,9 @@ if (rtc_include_tests) { "..:aec_dump_interface", "..:audioproc_test_utils", "../", + "../../../api/audio:audio_frame_api", + "../../../api/audio:audio_processing", + "../../../modules/audio_processing:audio_frame_view", "../../../test:test_support", ] } @@ -47,9 +50,12 @@ if (rtc_include_tests) { ":mock_aec_dump", "..:audioproc_test_utils", "../", + "../../../api:scoped_refptr", "../../../api/audio:audio_processing", "../../../api/audio:builtin_audio_processing_builder", "../../../api/environment:environment_factory", + "../../../rtc_base:checks", + "../../../test:test_support", "//testing/gtest", ] } @@ -68,7 +74,9 @@ if (rtc_enable_protobuf) { ":aec_dump", "..:aec_dump_interface", "../../../api/audio:audio_frame_api", + "../../../api/audio:audio_processing", "../../../api/task_queue", + "../../../modules/audio_processing:audio_frame_view", "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:macromagic", diff --git a/modules/audio_processing/aec_dump/aec_dump_impl.cc b/modules/audio_processing/aec_dump/aec_dump_impl.cc index 0c196506fd..92f3bd3eb3 100644 --- a/modules/audio_processing/aec_dump/aec_dump_impl.cc +++ b/modules/audio_processing/aec_dump/aec_dump_impl.cc @@ -10,21 +10,32 @@ #include "modules/audio_processing/aec_dump/aec_dump_impl.h" +#include +#include +#include #include +#include #include #include "absl/base/nullability.h" #include "absl/strings/string_view.h" +#include "api/audio/audio_processing.h" +#include "api/audio/audio_view.h" #include "api/task_queue/task_queue_base.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" +#include "modules/audio_processing/debug.pb.h" +#include "modules/audio_processing/include/aec_dump.h" +#include "modules/audio_processing/include/audio_frame_view.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" +#include "rtc_base/race_checker.h" +#include "rtc_base/system/file_wrapper.h" namespace webrtc { namespace { -void CopyFromConfigToEvent(const webrtc::InternalAPMConfig& config, - webrtc::audioproc::Config* pb_cfg) { +void CopyFromConfigToEvent(const InternalAPMConfig& config, + audioproc::Config* pb_cfg) { pb_cfg->set_aec_enabled(config.aec_enabled); pb_cfg->set_aec_delay_agnostic_enabled(config.aec_delay_agnostic_enabled); pb_cfg->set_aec_drift_compensation_enabled( @@ -105,11 +116,19 @@ void AecDumpImpl::AddCaptureStreamInput( capture_stream_info_.AddInput(src); } +void AecDumpImpl::AddCaptureStreamInput(MonoView channel) { + capture_stream_info_.AddInputChannel(channel); +} + void AecDumpImpl::AddCaptureStreamOutput( const AudioFrameView& src) { capture_stream_info_.AddOutput(src); } +void AecDumpImpl::AddCaptureStreamOutput(MonoView channel) { + capture_stream_info_.AddOutputChannel(channel); +} + void AecDumpImpl::AddCaptureStreamInput(const int16_t* const data, int num_channels, int samples_per_channel) { @@ -157,6 +176,22 @@ void AecDumpImpl::WriteRenderStreamMessage( PostWriteToFileTask(std::move(event)); } +void AecDumpImpl::WriteRenderStreamMessage(const float* const* data, + int num_channels, + int samples_per_channel) { + auto event = std::make_unique(); + event->set_type(audioproc::Event::REVERSE_STREAM); + + audioproc::ReverseStream* msg = event->mutable_reverse_stream(); + + for (int i = 0; i < num_channels; ++i) { + MonoView channel_view(data[i], samples_per_channel); + msg->add_channel(channel_view.begin(), sizeof(float) * channel_view.size()); + } + + PostWriteToFileTask(std::move(event)); +} + void AecDumpImpl::WriteConfig(const InternalAPMConfig& config) { RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); auto event = std::make_unique(); diff --git a/modules/audio_processing/aec_dump/aec_dump_impl.h b/modules/audio_processing/aec_dump/aec_dump_impl.h index 7638758dee..aa25eae4da 100644 --- a/modules/audio_processing/aec_dump/aec_dump_impl.h +++ b/modules/audio_processing/aec_dump/aec_dump_impl.h @@ -11,16 +11,18 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC_DUMP_AEC_DUMP_IMPL_H_ #define MODULES_AUDIO_PROCESSING_AEC_DUMP_AEC_DUMP_IMPL_H_ +#include #include -#include -#include +#include "absl/base/nullability.h" +#include "api/audio/audio_processing.h" +#include "api/audio/audio_view.h" #include "api/task_queue/task_queue_base.h" #include "modules/audio_processing/aec_dump/capture_stream_info.h" #include "modules/audio_processing/include/aec_dump.h" +#include "modules/audio_processing/include/audio_frame_view.h" #include "rtc_base/race_checker.h" #include "rtc_base/system/file_wrapper.h" -#include "rtc_base/thread_annotations.h" // Files generated at build-time by the protobuf compiler. #ifdef WEBRTC_ANDROID_PLATFORM_BUILD @@ -47,7 +49,9 @@ class AecDumpImpl : public AecDump { void WriteInitMessage(const ProcessingConfig& api_format, int64_t time_now_ms) override; void AddCaptureStreamInput(const AudioFrameView& src) override; + void AddCaptureStreamInput(MonoView channel) override; void AddCaptureStreamOutput(const AudioFrameView& src) override; + void AddCaptureStreamOutput(MonoView channel) override; void AddCaptureStreamInput(const int16_t* const data, int num_channels, int samples_per_channel) override; @@ -62,6 +66,9 @@ class AecDumpImpl : public AecDump { int samples_per_channel) override; void WriteRenderStreamMessage( const AudioFrameView& src) override; + void WriteRenderStreamMessage(const float* const* data, + int num_channels, + int samples_per_channel) override; void WriteConfig(const InternalAPMConfig& config) override; diff --git a/modules/audio_processing/aec_dump/aec_dump_integration_test.cc b/modules/audio_processing/aec_dump/aec_dump_integration_test.cc index 5c23c9678f..7701877199 100644 --- a/modules/audio_processing/aec_dump/aec_dump_integration_test.cc +++ b/modules/audio_processing/aec_dump/aec_dump_integration_test.cc @@ -9,18 +9,23 @@ */ #include +#include #include #include #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/environment/environment_factory.h" +#include "api/scoped_refptr.h" #include "modules/audio_processing/aec_dump/mock_aec_dump.h" -#include "modules/audio_processing/audio_processing_impl.h" +#include "rtc_base/checks.h" +#include "test/gmock.h" +#include "test/gtest.h" using ::testing::_; using ::testing::AtLeast; using ::testing::Exactly; +using ::testing::Matcher; using ::testing::StrictMock; namespace { @@ -59,7 +64,8 @@ TEST(AecDumpIntegration, frame.fill(0.f); webrtc::StreamConfig stream_config(kNumSampleRateHz, kNumChannels); - EXPECT_CALL(*mock_aec_dump.get(), WriteRenderStreamMessage(_, _, _)) + EXPECT_CALL(*mock_aec_dump.get(), + WriteRenderStreamMessage(Matcher(_), _, _)) .Times(Exactly(1)); apm->AttachAecDump(std::move(mock_aec_dump)); diff --git a/modules/audio_processing/aec_dump/aec_dump_unittest.cc b/modules/audio_processing/aec_dump/aec_dump_unittest.cc index 2a8110c4fc..935402b31d 100644 --- a/modules/audio_processing/aec_dump/aec_dump_unittest.cc +++ b/modules/audio_processing/aec_dump/aec_dump_unittest.cc @@ -21,14 +21,14 @@ namespace webrtc { TEST(AecDumper, APICallsDoNotCrash) { // Note order of initialization: Task queue has to be initialized // before AecDump. - webrtc::TaskQueueForTest file_writer_queue("file_writer_queue"); + TaskQueueForTest file_writer_queue("file_writer_queue"); const std::string filename = - webrtc::test::TempFilename(webrtc::test::OutputPath(), "aec_dump"); + test::TempFilename(test::OutputPath(), "aec_dump"); { - std::unique_ptr aec_dump = - webrtc::AecDumpFactory::Create(filename, -1, file_writer_queue.Get()); + std::unique_ptr aec_dump = + AecDumpFactory::Create(filename, -1, file_writer_queue.Get()); constexpr int kNumChannels = 1; constexpr int kNumSamplesPerChannel = 160; @@ -44,10 +44,10 @@ TEST(AecDumper, APICallsDoNotCrash) { aec_dump->WriteCaptureStreamMessage(); - webrtc::InternalAPMConfig apm_config; + InternalAPMConfig apm_config; aec_dump->WriteConfig(apm_config); - webrtc::ProcessingConfig api_format; + ProcessingConfig api_format; constexpr int64_t kTimeNowMs = 123456789ll; aec_dump->WriteInitMessage(api_format, kTimeNowMs); } @@ -56,14 +56,14 @@ TEST(AecDumper, APICallsDoNotCrash) { } TEST(AecDumper, WriteToFile) { - webrtc::TaskQueueForTest file_writer_queue("file_writer_queue"); + TaskQueueForTest file_writer_queue("file_writer_queue"); const std::string filename = - webrtc::test::TempFilename(webrtc::test::OutputPath(), "aec_dump"); + test::TempFilename(test::OutputPath(), "aec_dump"); { - std::unique_ptr aec_dump = - webrtc::AecDumpFactory::Create(filename, -1, file_writer_queue.Get()); + std::unique_ptr aec_dump = + AecDumpFactory::Create(filename, -1, file_writer_queue.Get()); constexpr int kNumChannels = 1; constexpr int kNumSamplesPerChannel = 160; @@ -77,7 +77,7 @@ TEST(AecDumper, WriteToFile) { // Verify the file has been written after the AecDump d-tor has // finished. FILE* fid = fopen(filename.c_str(), "r"); - ASSERT_TRUE(fid != NULL); + ASSERT_TRUE(fid != nullptr); // Clean it up. ASSERT_EQ(0, fclose(fid)); diff --git a/modules/audio_processing/aec_dump/capture_stream_info.cc b/modules/audio_processing/aec_dump/capture_stream_info.cc index 7d82a39729..993386658e 100644 --- a/modules/audio_processing/aec_dump/capture_stream_info.cc +++ b/modules/audio_processing/aec_dump/capture_stream_info.cc @@ -10,28 +10,37 @@ #include "modules/audio_processing/aec_dump/capture_stream_info.h" +#include +#include + +#include "api/audio/audio_view.h" +#include "modules/audio_processing/include/aec_dump.h" +#include "modules/audio_processing/include/audio_frame_view.h" + namespace webrtc { void CaptureStreamInfo::AddInput(const AudioFrameView& src) { - auto* stream = event_->mutable_stream(); - for (int i = 0; i < src.num_channels(); ++i) { - const auto& channel_view = src.channel(i); - stream->add_input_channel(channel_view.begin(), - sizeof(float) * channel_view.size()); + AddInputChannel(src.channel(i)); } } -void CaptureStreamInfo::AddOutput(const AudioFrameView& src) { +void CaptureStreamInfo::AddInputChannel(MonoView channel) { auto* stream = event_->mutable_stream(); + stream->add_input_channel(channel.begin(), sizeof(float) * channel.size()); +} +void CaptureStreamInfo::AddOutput(const AudioFrameView& src) { for (int i = 0; i < src.num_channels(); ++i) { - const auto& channel_view = src.channel(i); - stream->add_output_channel(channel_view.begin(), - sizeof(float) * channel_view.size()); + AddOutputChannel(src.channel(i)); } } +void CaptureStreamInfo::AddOutputChannel(MonoView channel) { + auto* stream = event_->mutable_stream(); + stream->add_output_channel(channel.begin(), sizeof(float) * channel.size()); +} + void CaptureStreamInfo::AddInput(const int16_t* const data, int num_channels, int samples_per_channel) { diff --git a/modules/audio_processing/aec_dump/capture_stream_info.h b/modules/audio_processing/aec_dump/capture_stream_info.h index 572990c150..bbbbb22a11 100644 --- a/modules/audio_processing/aec_dump/capture_stream_info.h +++ b/modules/audio_processing/aec_dump/capture_stream_info.h @@ -11,10 +11,13 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC_DUMP_CAPTURE_STREAM_INFO_H_ #define MODULES_AUDIO_PROCESSING_AEC_DUMP_CAPTURE_STREAM_INFO_H_ +#include #include #include +#include "api/audio/audio_view.h" #include "modules/audio_processing/include/aec_dump.h" +#include "modules/audio_processing/include/audio_frame_view.h" // Files generated at build-time by the protobuf compiler. #ifdef WEBRTC_ANDROID_PLATFORM_BUILD @@ -33,7 +36,9 @@ class CaptureStreamInfo { ~CaptureStreamInfo() = default; void AddInput(const AudioFrameView& src); + void AddInputChannel(MonoView channel); void AddOutput(const AudioFrameView& src); + void AddOutputChannel(MonoView channel); void AddInput(const int16_t* const data, int num_channels, diff --git a/modules/audio_processing/aec_dump/mock_aec_dump.h b/modules/audio_processing/aec_dump/mock_aec_dump.h index b396739de4..c192d4613f 100644 --- a/modules/audio_processing/aec_dump/mock_aec_dump.h +++ b/modules/audio_processing/aec_dump/mock_aec_dump.h @@ -11,9 +11,12 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC_DUMP_MOCK_AEC_DUMP_H_ #define MODULES_AUDIO_PROCESSING_AEC_DUMP_MOCK_AEC_DUMP_H_ -#include +#include +#include "api/audio/audio_processing.h" +#include "api/audio/audio_view.h" #include "modules/audio_processing/include/aec_dump.h" +#include "modules/audio_processing/include/audio_frame_view.h" #include "test/gmock.h" namespace webrtc { @@ -34,10 +37,18 @@ class MockAecDump : public AecDump { AddCaptureStreamInput, (const AudioFrameView& src), (override)); + MOCK_METHOD(void, + AddCaptureStreamInput, + (MonoView channel), + (override)); MOCK_METHOD(void, AddCaptureStreamOutput, (const AudioFrameView& src), (override)); + MOCK_METHOD(void, + AddCaptureStreamOutput, + (MonoView channel), + (override)); MOCK_METHOD(void, AddCaptureStreamInput, (const int16_t* const data, @@ -66,6 +77,12 @@ class MockAecDump : public AecDump { WriteRenderStreamMessage, (const AudioFrameView& src), (override)); + MOCK_METHOD(void, + WriteRenderStreamMessage, + (const float* const* data, + int num_channels, + int samples_per_channel), + (override)); MOCK_METHOD(void, WriteConfig, (const InternalAPMConfig& config), (override)); diff --git a/modules/audio_processing/aecm/aecm_core.cc b/modules/audio_processing/aecm/aecm_core.cc index 7d3cd9df55..8b1e12794c 100644 --- a/modules/audio_processing/aecm/aecm_core.cc +++ b/modules/audio_processing/aecm/aecm_core.cc @@ -193,50 +193,50 @@ AecmCore* WebRtcAecm_CreateCore() { WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); if (!aecm->farFrameBuf) { WebRtcAecm_FreeCore(aecm); - return NULL; + return nullptr; } aecm->nearNoisyFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); if (!aecm->nearNoisyFrameBuf) { WebRtcAecm_FreeCore(aecm); - return NULL; + return nullptr; } aecm->nearCleanFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); if (!aecm->nearCleanFrameBuf) { WebRtcAecm_FreeCore(aecm); - return NULL; + return nullptr; } aecm->outFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); if (!aecm->outFrameBuf) { WebRtcAecm_FreeCore(aecm); - return NULL; + return nullptr; } aecm->delay_estimator_farend = WebRtc_CreateDelayEstimatorFarend(PART_LEN1, MAX_DELAY); - if (aecm->delay_estimator_farend == NULL) { + if (aecm->delay_estimator_farend == nullptr) { WebRtcAecm_FreeCore(aecm); - return NULL; + return nullptr; } aecm->delay_estimator = WebRtc_CreateDelayEstimator(aecm->delay_estimator_farend, 0); - if (aecm->delay_estimator == NULL) { + if (aecm->delay_estimator == nullptr) { WebRtcAecm_FreeCore(aecm); - return NULL; + return nullptr; } // TODO(bjornv): Explicitly disable robust delay validation until no // performance regression has been established. Then remove the line. WebRtc_enable_robust_validation(aecm->delay_estimator, 0); aecm->real_fft = WebRtcSpl_CreateRealFFT(PART_LEN_SHIFT); - if (aecm->real_fft == NULL) { + if (aecm->real_fft == nullptr) { WebRtcAecm_FreeCore(aecm); - return NULL; + return nullptr; } // Init some aecm pointers. 16 and 32 byte alignment is only necessary @@ -491,7 +491,7 @@ int WebRtcAecm_Control(AecmCore* aecm, int delay, int nlpFlag) { } void WebRtcAecm_FreeCore(AecmCore* aecm) { - if (aecm == NULL) { + if (aecm == nullptr) { return; } @@ -516,7 +516,7 @@ int WebRtcAecm_ProcessFrame(AecmCore* aecm, int16_t* outBlock = (int16_t*)(((uintptr_t)outBlock_buf + 15) & ~15); int16_t farFrame[FRAME_LEN]; - const int16_t* out_ptr = NULL; + const int16_t* out_ptr = nullptr; int size = 0; // Buffer the current frame. @@ -528,24 +528,24 @@ int WebRtcAecm_ProcessFrame(AecmCore* aecm, // to pass the smaller blocks individually. WebRtc_WriteBuffer(aecm->farFrameBuf, farFrame, FRAME_LEN); WebRtc_WriteBuffer(aecm->nearNoisyFrameBuf, nearendNoisy, FRAME_LEN); - if (nearendClean != NULL) { + if (nearendClean != nullptr) { WebRtc_WriteBuffer(aecm->nearCleanFrameBuf, nearendClean, FRAME_LEN); } // Process as many blocks as possible. while (WebRtc_available_read(aecm->farFrameBuf) >= PART_LEN) { int16_t far_block[PART_LEN]; - const int16_t* far_block_ptr = NULL; + const int16_t* far_block_ptr = nullptr; int16_t near_noisy_block[PART_LEN]; - const int16_t* near_noisy_block_ptr = NULL; + const int16_t* near_noisy_block_ptr = nullptr; WebRtc_ReadBuffer(aecm->farFrameBuf, (void**)&far_block_ptr, far_block, PART_LEN); WebRtc_ReadBuffer(aecm->nearNoisyFrameBuf, (void**)&near_noisy_block_ptr, near_noisy_block, PART_LEN); - if (nearendClean != NULL) { + if (nearendClean != nullptr) { int16_t near_clean_block[PART_LEN]; - const int16_t* near_clean_block_ptr = NULL; + const int16_t* near_clean_block_ptr = nullptr; WebRtc_ReadBuffer(aecm->nearCleanFrameBuf, (void**)&near_clean_block_ptr, near_clean_block, PART_LEN); @@ -555,7 +555,7 @@ int WebRtcAecm_ProcessFrame(AecmCore* aecm, } } else { if (WebRtcAecm_ProcessBlock(aecm, far_block_ptr, near_noisy_block_ptr, - NULL, outBlock) == -1) { + nullptr, outBlock) == -1) { return -1; } } diff --git a/modules/audio_processing/aecm/aecm_core_c.cc b/modules/audio_processing/aecm/aecm_core_c.cc index 1d750da3fe..1a975d2adc 100644 --- a/modules/audio_processing/aecm/aecm_core_c.cc +++ b/modules/audio_processing/aecm/aecm_core_c.cc @@ -243,7 +243,7 @@ static void InverseFFTAndWindow(AecmCore* aecm, memcpy(aecm->xBuf, aecm->xBuf + PART_LEN, sizeof(int16_t) * PART_LEN); memcpy(aecm->dBufNoisy, aecm->dBufNoisy + PART_LEN, sizeof(int16_t) * PART_LEN); - if (nearendClean != NULL) { + if (nearendClean != nullptr) { memcpy(aecm->dBufClean, aecm->dBufClean + PART_LEN, sizeof(int16_t) * PART_LEN); } @@ -390,7 +390,7 @@ int RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/8200 uint16_t dfaNoisy[PART_LEN1]; uint16_t dfaClean[PART_LEN1]; uint16_t* ptrDfaClean = dfaClean; - const uint16_t* far_spectrum_ptr = NULL; + const uint16_t* far_spectrum_ptr = nullptr; // 32 byte aligned buffers (with +8 or +16). // TODO(kma): define fft with ComplexInt16. @@ -435,7 +435,7 @@ int RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/8200 // Buffer near and far end signals memcpy(aecm->xBuf + PART_LEN, farend, sizeof(int16_t) * PART_LEN); memcpy(aecm->dBufNoisy + PART_LEN, nearendNoisy, sizeof(int16_t) * PART_LEN); - if (nearendClean != NULL) { + if (nearendClean != nullptr) { memcpy(aecm->dBufClean + PART_LEN, nearendClean, sizeof(int16_t) * PART_LEN); } @@ -449,7 +449,7 @@ int RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/8200 aecm->dfaNoisyQDomainOld = aecm->dfaNoisyQDomain; aecm->dfaNoisyQDomain = (int16_t)zerosDBufNoisy; - if (nearendClean == NULL) { + if (nearendClean == nullptr) { ptrDfaClean = dfaNoisy; aecm->dfaCleanQDomainOld = aecm->dfaNoisyQDomainOld; aecm->dfaCleanQDomain = aecm->dfaNoisyQDomain; @@ -487,7 +487,7 @@ int RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/8200 // Get aligned far end spectrum far_spectrum_ptr = WebRtcAecm_AlignedFarend(aecm, &far_q, delay); zerosXBuf = (int16_t)far_q; - if (far_spectrum_ptr == NULL) { + if (far_spectrum_ptr == nullptr) { return -1; } diff --git a/modules/audio_processing/aecm/echo_control_mobile.cc b/modules/audio_processing/aecm/echo_control_mobile.cc index 14522c0f1d..1f58984441 100644 --- a/modules/audio_processing/aecm/echo_control_mobile.cc +++ b/modules/audio_processing/aecm/echo_control_mobile.cc @@ -95,13 +95,13 @@ void* WebRtcAecm_Create() { aecm->aecmCore = WebRtcAecm_CreateCore(); if (!aecm->aecmCore) { WebRtcAecm_Free(aecm); - return NULL; + return nullptr; } aecm->farendBuf = WebRtc_CreateBuffer(kBufSizeSamp, sizeof(int16_t)); if (!aecm->farendBuf) { WebRtcAecm_Free(aecm); - return NULL; + return nullptr; } #ifdef AEC_DEBUG @@ -121,7 +121,7 @@ void* WebRtcAecm_Create() { void WebRtcAecm_Free(void* aecmInst) { AecMobile* aecm = static_cast(aecmInst); - if (aecm == NULL) { + if (aecm == nullptr) { return; } @@ -145,7 +145,7 @@ int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq) { AecMobile* aecm = static_cast(aecmInst); AecmConfig aecConfig; - if (aecm == NULL) { + if (aecm == nullptr) { return -1; } @@ -199,10 +199,10 @@ int32_t WebRtcAecm_GetBufferFarendError(void* aecmInst, size_t nrOfSamples) { AecMobile* aecm = static_cast(aecmInst); - if (aecm == NULL) + if (aecm == nullptr) return -1; - if (farend == NULL) + if (farend == nullptr) return AECM_NULL_POINTER_ERROR; if (aecm->initFlag != kInitCheck) @@ -251,15 +251,15 @@ int32_t WebRtcAecm_Process(void* aecmInst, short msInAECBuf; #endif - if (aecm == NULL) { + if (aecm == nullptr) { return -1; } - if (nearendNoisy == NULL) { + if (nearendNoisy == nullptr) { return AECM_NULL_POINTER_ERROR; } - if (out == NULL) { + if (out == nullptr) { return AECM_NULL_POINTER_ERROR; } @@ -285,7 +285,7 @@ int32_t WebRtcAecm_Process(void* aecmInst, nBlocks10ms = nFrames / aecm->aecmCore->mult; if (aecm->ECstartup) { - if (nearendClean == NULL) { + if (nearendClean == nullptr) { if (out != nearendNoisy) { memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples); } @@ -362,7 +362,7 @@ int32_t WebRtcAecm_Process(void* aecmInst, // Note only 1 block supported for nb and 2 blocks for wb for (i = 0; i < nFrames; i++) { int16_t farend[FRAME_LEN]; - const int16_t* farend_ptr = NULL; + const int16_t* farend_ptr = nullptr; nmbrOfFilledBuffers = (short)WebRtc_available_read(aecm->farendBuf) / FRAME_LEN; @@ -393,7 +393,7 @@ int32_t WebRtcAecm_Process(void* aecmInst, &out[FRAME_LEN * i], aecm->knownDelay);*/ if (WebRtcAecm_ProcessFrame( aecm->aecmCore, farend_ptr, &nearendNoisy[FRAME_LEN * i], - (nearendClean ? &nearendClean[FRAME_LEN * i] : NULL), + (nearendClean ? &nearendClean[FRAME_LEN * i] : nullptr), &out[FRAME_LEN * i]) == -1) return -1; } @@ -412,7 +412,7 @@ int32_t WebRtcAecm_Process(void* aecmInst, int32_t WebRtcAecm_set_config(void* aecmInst, AecmConfig config) { AecMobile* aecm = static_cast(aecmInst); - if (aecm == NULL) { + if (aecm == nullptr) { return -1; } @@ -486,10 +486,10 @@ int32_t WebRtcAecm_InitEchoPath(void* aecmInst, AecMobile* aecm = static_cast(aecmInst); const int16_t* echo_path_ptr = static_cast(echo_path); - if (aecmInst == NULL) { + if (aecmInst == nullptr) { return -1; } - if (echo_path == NULL) { + if (echo_path == nullptr) { return AECM_NULL_POINTER_ERROR; } if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { @@ -511,10 +511,10 @@ int32_t WebRtcAecm_GetEchoPath(void* aecmInst, AecMobile* aecm = static_cast(aecmInst); int16_t* echo_path_ptr = static_cast(echo_path); - if (aecmInst == NULL) { + if (aecmInst == nullptr) { return -1; } - if (echo_path == NULL) { + if (echo_path == nullptr) { return AECM_NULL_POINTER_ERROR; } if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn index 754b807879..61a450922f 100644 --- a/modules/audio_processing/agc/BUILD.gn +++ b/modules/audio_processing/agc/BUILD.gn @@ -34,7 +34,6 @@ rtc_library("agc") { "../../../rtc_base:gtest_prod", "../../../rtc_base:logging", "../../../rtc_base:safe_minmax", - "../../../system_wrappers:field_trial", "../../../system_wrappers:metrics", "../agc2:clipping_predictor", "../agc2:gain_map", diff --git a/modules/audio_processing/agc/legacy/analog_agc.cc b/modules/audio_processing/agc/legacy/analog_agc.cc index e40a3f1629..d946060e85 100644 --- a/modules/audio_processing/agc/legacy/analog_agc.cc +++ b/modules/audio_processing/agc/legacy/analog_agc.cc @@ -265,7 +265,7 @@ int WebRtcAgc_GetAddFarendError(void* state, size_t samples) { LegacyAgc* stt; stt = reinterpret_cast(state); - if (stt == NULL) + if (stt == nullptr) return -1; if (stt->fs == 8000) { @@ -943,7 +943,7 @@ int WebRtcAgc_Analyze(void* agcInst, int32_t gains[11]) { LegacyAgc* stt = reinterpret_cast(agcInst); - if (stt == NULL) { + if (stt == nullptr) { return -1; } @@ -1005,7 +1005,7 @@ int WebRtcAgc_set_config(void* agcInst, WebRtcAgcConfig agcConfig) { LegacyAgc* stt; stt = reinterpret_cast(agcInst); - if (stt == NULL) { + if (stt == nullptr) { return -1; } @@ -1053,11 +1053,11 @@ int WebRtcAgc_get_config(void* agcInst, WebRtcAgcConfig* config) { LegacyAgc* stt; stt = reinterpret_cast(agcInst); - if (stt == NULL) { + if (stt == nullptr) { return -1; } - if (config == NULL) { + if (config == nullptr) { stt->lastError = AGC_NULL_POINTER_ERROR; return -1; } diff --git a/modules/audio_processing/agc/loudness_histogram.cc b/modules/audio_processing/agc/loudness_histogram.cc index b0a1f53b97..492d00b390 100644 --- a/modules/audio_processing/agc/loudness_histogram.cc +++ b/modules/audio_processing/agc/loudness_histogram.cc @@ -174,7 +174,7 @@ LoudnessHistogram* LoudnessHistogram::Create() { LoudnessHistogram* LoudnessHistogram::Create(int window_size) { if (window_size < 0) - return NULL; + return nullptr; return new LoudnessHistogram(window_size); } diff --git a/modules/audio_processing/agc/loudness_histogram_unittest.cc b/modules/audio_processing/agc/loudness_histogram_unittest.cc index bbc0a7ee92..a4f1020ad3 100644 --- a/modules/audio_processing/agc/loudness_histogram_unittest.cc +++ b/modules/audio_processing/agc/loudness_histogram_unittest.cc @@ -53,7 +53,7 @@ void LoudnessHistogramTest::TestClean() { void LoudnessHistogramTest::RunTest(bool enable_circular_buff, absl::string_view filename) { FILE* in_file = fopen(std::string(filename).c_str(), "rb"); - ASSERT_TRUE(in_file != NULL); + ASSERT_TRUE(in_file != nullptr); if (enable_circular_buff) { int buffer_size; EXPECT_EQ(fread(&buffer_size, sizeof(buffer_size), 1, in_file), 1u); diff --git a/modules/audio_processing/agc/utility.cc b/modules/audio_processing/agc/utility.cc index 2a87e5ce74..b8fa3605ea 100644 --- a/modules/audio_processing/agc/utility.cc +++ b/modules/audio_processing/agc/utility.cc @@ -12,9 +12,11 @@ #include +#include + namespace webrtc { -static const double kLog10 = 2.30258509299; +static const double kLog10 = std::numbers::ln10; static const double kLinear2DbScale = 20.0 / kLog10; static const double kLinear2LoudnessScale = 13.4 / kLog10; diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn index 3808a92ca2..e9d1743f4e 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn @@ -196,6 +196,7 @@ rtc_library("input_volume_controller") { ] visibility = [ + "..:audio_processing", "..:gain_controller2", "./*", ] @@ -216,7 +217,6 @@ rtc_library("input_volume_controller") { "../../../rtc_base:gtest_prod", "../../../rtc_base:logging", "../../../rtc_base:safe_minmax", - "../../../system_wrappers:field_trial", "../../../system_wrappers:metrics", ] } diff --git a/modules/audio_processing/agc2/agc2_testing_common.cc b/modules/audio_processing/agc2/agc2_testing_common.cc index 8f3e9db4c4..b9d0492fca 100644 --- a/modules/audio_processing/agc2/agc2_testing_common.cc +++ b/modules/audio_processing/agc2/agc2_testing_common.cc @@ -12,6 +12,8 @@ #include +#include + #include "rtc_base/checks.h" namespace webrtc { @@ -56,7 +58,7 @@ SineGenerator::SineGenerator(float amplitude, } float SineGenerator::operator()() { - constexpr float kPi = 3.1415926536f; + constexpr float kPi = std::numbers::pi_v; x_radians_ += frequency_hz_ / sample_rate_hz_ * 2 * kPi; if (x_radians_ >= 2 * kPi) { x_radians_ -= 2 * kPi; diff --git a/modules/audio_processing/agc2/input_volume_controller.cc b/modules/audio_processing/agc2/input_volume_controller.cc index 557c1e67d1..20fd6dc548 100644 --- a/modules/audio_processing/agc2/input_volume_controller.cc +++ b/modules/audio_processing/agc2/input_volume_controller.cc @@ -12,15 +12,19 @@ #include #include +#include +#include +#include -#include "api/array_view.h" +#include "api/audio/audio_processing.h" +#include "modules/audio_processing/agc2/clipping_predictor.h" #include "modules/audio_processing/agc2/gain_map_internal.h" #include "modules/audio_processing/agc2/input_volume_stats_reporter.h" +#include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/include/audio_frame_view.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_minmax.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" namespace webrtc { diff --git a/modules/audio_processing/agc2/limiter.cc b/modules/audio_processing/agc2/limiter.cc index 072b79ed48..c4d594ae40 100644 --- a/modules/audio_processing/agc2/limiter.cc +++ b/modules/audio_processing/agc2/limiter.cc @@ -13,10 +13,13 @@ #include #include #include +#include #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/audio/audio_view.h" #include "modules/audio_processing/agc2/agc2_common.h" +#include "modules/audio_processing/agc2/interpolated_gain_curve.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_processing/agc2/limiter.h b/modules/audio_processing/agc2/limiter.h index 55cb1a5b15..f3e4a54179 100644 --- a/modules/audio_processing/agc2/limiter.h +++ b/modules/audio_processing/agc2/limiter.h @@ -11,13 +11,14 @@ #ifndef MODULES_AUDIO_PROCESSING_AGC2_LIMITER_H_ #define MODULES_AUDIO_PROCESSING_AGC2_LIMITER_H_ -#include +#include +#include #include "absl/strings/string_view.h" -#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" +#include "modules/audio_processing/agc2/agc2_common.h" #include "modules/audio_processing/agc2/fixed_digital_level_estimator.h" #include "modules/audio_processing/agc2/interpolated_gain_curve.h" -#include "modules/audio_processing/include/audio_frame_view.h" namespace webrtc { class ApmDataDumper; diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn index 025794d262..ddec89972d 100644 --- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn +++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn @@ -77,7 +77,7 @@ rtc_library("rnn_vad_lp_residual") { ] } -rtc_source_set("rnn_vad_layers") { +rtc_library("rnn_vad_layers") { sources = [ "rnn_fc.cc", "rnn_fc.h", diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc b/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc index ff9bb18bc2..672090bad3 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_fc_unittest.cc @@ -69,7 +69,7 @@ TEST_P(RnnFcParametrization, DISABLED_BenchmarkFullyConnectedLayer) { /*layer_name=*/"FC"); constexpr int kNumTests = 10000; - ::webrtc::test::PerformanceTimer perf_timer(kNumTests); + test::PerformanceTimer perf_timer(kNumTests); for (int k = 0; k < kNumTests; ++k) { perf_timer.StartTimer(); fc.ComputeOutput(kFullyConnectedInputVector); diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc b/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc index 43b3e6885a..5afd4383d2 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_gru_unittest.cc @@ -141,7 +141,7 @@ TEST_P(RnnGruParametrization, DISABLED_BenchmarkGatedRecurrentLayer) { input_sequence.size() / kInputLayerOutputSize; constexpr int kNumTests = 100; - ::webrtc::test::PerformanceTimer perf_timer(kNumTests); + test::PerformanceTimer perf_timer(kNumTests); for (int k = 0; k < kNumTests; ++k) { perf_timer.StartTimer(); for (int i = 0; i < input_sequence_length; ++i) { diff --git a/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc b/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc index f33cd14a8a..b9991eab91 100644 --- a/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc +++ b/modules/audio_processing/agc2/rnn_vad/rnn_vad_unittest.cc @@ -135,7 +135,7 @@ TEST_P(RnnVadProbabilityParametrization, DISABLED_RnnVadPerformance) { std::array feature_vector; RnnVad rnn_vad(cpu_features); constexpr int number_of_tests = 100; - ::webrtc::test::PerformanceTimer perf_timer(number_of_tests); + test::PerformanceTimer perf_timer(number_of_tests); for (int k = 0; k < number_of_tests; ++k) { features_extractor.Reset(); rnn_vad.Reset(); diff --git a/modules/audio_processing/agc2/rnn_vad/test_utils.cc b/modules/audio_processing/agc2/rnn_vad/test_utils.cc index a3951bf260..aa78b70ecb 100644 --- a/modules/audio_processing/agc2/rnn_vad/test_utils.cc +++ b/modules/audio_processing/agc2/rnn_vad/test_utils.cc @@ -68,7 +68,7 @@ class FloatFileReader : public FileReader { } // namespace -using webrtc::test::ResourcePath; +using test::ResourcePath; void ExpectEqualFloatArray(ArrayView expected, ArrayView computed) { diff --git a/modules/audio_processing/agc2/vad_wrapper_unittest.cc b/modules/audio_processing/agc2/vad_wrapper_unittest.cc index a4c1dcba21..4cac82d2db 100644 --- a/modules/audio_processing/agc2/vad_wrapper_unittest.cc +++ b/modules/audio_processing/agc2/vad_wrapper_unittest.cc @@ -42,10 +42,7 @@ class MockVad : public VoiceActivityDetectorWrapper::MonoVad { public: MOCK_METHOD(int, SampleRateHz, (), (const, override)); MOCK_METHOD(void, Reset, (), (override)); - MOCK_METHOD(float, - Analyze, - (webrtc::ArrayView frame), - (override)); + MOCK_METHOD(float, Analyze, (ArrayView frame), (override)); }; // Checks that the ctor and `Initialize()` read the sample rate of the wrapped diff --git a/modules/audio_processing/audio_buffer.h b/modules/audio_processing/audio_buffer.h index 9369572af8..a876aa8741 100644 --- a/modules/audio_processing/audio_buffer.h +++ b/modules/audio_processing/audio_buffer.h @@ -21,6 +21,7 @@ #include "api/audio/audio_view.h" #include "common_audio/channel_buffer.h" #include "common_audio/include/audio_util.h" +#include "rtc_base/gtest_prod_util.h" namespace webrtc { @@ -62,7 +63,7 @@ class AudioBuffer { // Returns a DeinterleavedView<> over the channel data. DeinterleavedView view() { return DeinterleavedView( - num_channels_ && buffer_num_frames_ ? channels()[0] : nullptr, + num_channels_ && buffer_num_frames_ ? channels() : nullptr, buffer_num_frames_, num_channels_); } diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index 56a9149551..9a6f785657 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc @@ -11,32 +11,57 @@ #include "modules/audio_processing/audio_processing_impl.h" #include +#include +#include #include +#include #include #include #include #include -#include #include +#include #include "absl/base/nullability.h" #include "absl/strings/string_view.h" #include "api/array_view.h" -#include "api/audio/audio_frame.h" +#include "api/audio/audio_processing.h" +#include "api/audio/audio_processing_statistics.h" +#include "api/audio/audio_view.h" +#include "api/audio/echo_canceller3_config.h" +#include "api/audio/echo_control.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" +#include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" #include "common_audio/audio_converter.h" #include "common_audio/include/audio_util.h" +#include "modules/audio_processing/aec3/echo_canceller3.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" +#include "modules/audio_processing/agc/agc_manager_direct.h" +#include "modules/audio_processing/agc/gain_control.h" +#include "modules/audio_processing/agc2/input_volume_controller.h" +#include "modules/audio_processing/agc2/input_volume_stats_reporter.h" #include "modules/audio_processing/audio_buffer.h" -#include "modules/audio_processing/include/audio_frame_view.h" +#include "modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster.h" +#include "modules/audio_processing/echo_control_mobile_impl.h" +#include "modules/audio_processing/gain_control_impl.h" +#include "modules/audio_processing/gain_controller2.h" +#include "modules/audio_processing/high_pass_filter.h" +#include "modules/audio_processing/include/aec_dump.h" #include "modules/audio_processing/logging/apm_data_dumper.h" +#include "modules/audio_processing/ns/noise_suppressor.h" +#include "modules/audio_processing/ns/ns_config.h" +#include "modules/audio_processing/post_filter.h" +#include "modules/audio_processing/render_queue_item_verifier.h" +#include "modules/audio_processing/rms_level.h" #include "rtc_base/checks.h" +#include "rtc_base/denormal_disabler.h" #include "rtc_base/logging.h" +#include "rtc_base/swap_queue.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/denormal_disabler.h" #include "system_wrappers/include/metrics.h" #define RETURN_ON_ERR(expr) \ @@ -1451,6 +1476,10 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { capture_.applied_input_volume_changed, capture_buffer); } + if (submodules_.post_filter) { + submodules_.post_filter->Process(*capture_buffer); + } + if (submodules_.capture_post_processor) { submodules_.capture_post_processor->Process(capture_buffer); } @@ -1587,8 +1616,7 @@ int AudioProcessingImpl::AnalyzeReverseStreamLocked( formats_.api_format.reverse_input_stream().num_frames(); const size_t num_channels = formats_.api_format.reverse_input_stream().num_channels(); - aec_dump_->WriteRenderStreamMessage( - AudioFrameView(src, num_channels, channel_size)); + aec_dump_->WriteRenderStreamMessage(src, num_channels, channel_size); } render_.render_audio->CopyFrom(src, formats_.api_format.reverse_input_stream()); @@ -1914,6 +1942,13 @@ void AudioProcessingImpl::InitializeEchoController() { capture_nonlocked_.echo_controller_enabled = true; + if (!env_.field_trials().IsEnabled("WebRTC-PostFilterKillSwitch")) { + // Only creates a PostFilter if current sample-rate is high enough to + // require a filter. + submodules_.post_filter = PostFilter::CreateIfNeeded( + proc_sample_rate_hz(), num_proc_channels()); + } + submodules_.echo_control_mobile.reset(); aecm_render_signal_queue_.reset(); return; @@ -2201,8 +2236,10 @@ void AudioProcessingImpl::RecordUnprocessedCaptureStream( const size_t channel_size = formats_.api_format.input_stream().num_frames(); const size_t num_channels = formats_.api_format.input_stream().num_channels(); - aec_dump_->AddCaptureStreamInput( - AudioFrameView(src, num_channels, channel_size)); + for (size_t ch = 0u; ch < num_channels; ++ch) { + aec_dump_->AddCaptureStreamInput( + MonoView(src[ch], channel_size)); + } RecordAudioProcessingState(); } @@ -2224,8 +2261,11 @@ void AudioProcessingImpl::RecordProcessedCaptureStream( const size_t channel_size = formats_.api_format.output_stream().num_frames(); const size_t num_channels = formats_.api_format.output_stream().num_channels(); - aec_dump_->AddCaptureStreamOutput(AudioFrameView( - processed_capture_stream, num_channels, channel_size)); + for (size_t ch = 0u; ch < num_channels; ++ch) { + aec_dump_->AddCaptureStreamOutput( + MonoView(processed_capture_stream[ch], channel_size)); + } + aec_dump_->WriteCaptureStreamMessage(); } diff --git a/modules/audio_processing/audio_processing_impl.h b/modules/audio_processing/audio_processing_impl.h index c148d9c8a8..ffaca0151e 100644 --- a/modules/audio_processing/audio_processing_impl.h +++ b/modules/audio_processing/audio_processing_impl.h @@ -13,11 +13,12 @@ #include +#include #include -#include +#include #include #include -#include +#include #include #include "absl/base/nullability.h" @@ -25,12 +26,11 @@ #include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/audio_processing_statistics.h" +#include "api/audio/echo_control.h" #include "api/environment/environment.h" -#include "api/function_view.h" +#include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" -#include "modules/audio_processing/aec3/echo_canceller3.h" #include "modules/audio_processing/agc/agc_manager_direct.h" -#include "modules/audio_processing/agc/gain_control.h" #include "modules/audio_processing/agc2/input_volume_stats_reporter.h" #include "modules/audio_processing/audio_buffer.h" #include "modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster.h" @@ -41,6 +41,7 @@ #include "modules/audio_processing/include/aec_dump.h" #include "modules/audio_processing/include/audio_frame_proxies.h" #include "modules/audio_processing/ns/noise_suppressor.h" +#include "modules/audio_processing/post_filter.h" #include "modules/audio_processing/render_queue_item_verifier.h" #include "modules/audio_processing/rms_level.h" #include "rtc_base/gtest_prod_util.h" @@ -384,6 +385,7 @@ class AudioProcessingImpl : public AudioProcessing { std::unique_ptr echo_controller; std::unique_ptr echo_control_mobile; std::unique_ptr noise_suppressor; + std::unique_ptr post_filter; std::unique_ptr capture_levels_adjuster; } submodules_; diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc index dc1bf1287b..d9d75dccd6 100644 --- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc @@ -21,7 +21,7 @@ #include "rtc_base/platform_thread.h" #include "rtc_base/random.h" #include "rtc_base/synchronization/mutex.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" #include "test/gtest.h" namespace webrtc { @@ -441,7 +441,7 @@ class AudioProcessingImplLockTest // Sleeps a random time between 0 and max_sleep milliseconds. void SleepRandomMs(int max_sleep, RandomGenerator* rand_gen) { int sleeptime = rand_gen->RandInt(0, max_sleep); - SleepMs(sleeptime); + Thread::SleepMs(sleeptime); } // Populates a float audio frame with random data. diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc index 5d4b04e692..e761f7609b 100644 --- a/modules/audio_processing/audio_processing_impl_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_unittest.cc @@ -204,7 +204,7 @@ TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) { TEST(AudioProcessingImplTest, UpdateCapturePreGainRuntimeSetting) { scoped_refptr apm = BuiltinAudioProcessingBuilder().Build(CreateEnvironment()); - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.pre_amplifier.enabled = true; apm_config.pre_amplifier.fixed_gain_factor = 1.f; apm->ApplyConfig(apm_config); @@ -237,7 +237,7 @@ TEST(AudioProcessingImplTest, LevelAdjustmentUpdateCapturePreGainRuntimeSetting) { scoped_refptr apm = BuiltinAudioProcessingBuilder().Build(CreateEnvironment()); - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.capture_level_adjustment.enabled = true; apm_config.capture_level_adjustment.pre_gain_factor = 1.f; apm->ApplyConfig(apm_config); @@ -270,7 +270,7 @@ TEST(AudioProcessingImplTest, LevelAdjustmentUpdateCapturePostGainRuntimeSetting) { scoped_refptr apm = BuiltinAudioProcessingBuilder().Build(CreateEnvironment()); - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.capture_level_adjustment.enabled = true; apm_config.capture_level_adjustment.post_gain_factor = 1.f; apm->ApplyConfig(apm_config); @@ -393,7 +393,7 @@ TEST(AudioProcessingImplTest, .SetEchoControlFactory(std::move(echo_control_factory)) .Build(CreateEnvironment()); // Disable AGC. - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.gain_controller1.enabled = false; apm_config.gain_controller2.enabled = false; apm_config.pre_amplifier.enabled = true; @@ -436,7 +436,7 @@ TEST(AudioProcessingImplTest, .SetEchoControlFactory(std::move(echo_control_factory)) .Build(CreateEnvironment()); // Disable AGC. - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.gain_controller1.enabled = false; apm_config.gain_controller2.enabled = false; apm_config.capture_level_adjustment.enabled = true; @@ -478,7 +478,7 @@ TEST(AudioProcessingImplTest, BuiltinAudioProcessingBuilder() .SetEchoControlFactory(std::move(echo_control_factory)) .Build(CreateEnvironment()); - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; // Enable AGC1. apm_config.gain_controller1.enabled = true; apm_config.gain_controller1.analog_gain_controller.enabled = true; @@ -534,7 +534,7 @@ TEST(AudioProcessingImplTest, EchoControllerObservesPlayoutVolumeChange) { .SetEchoControlFactory(std::move(echo_control_factory)) .Build(CreateEnvironment()); // Disable AGC. - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.gain_controller1.enabled = false; apm_config.gain_controller2.enabled = false; apm->ApplyConfig(apm_config); @@ -591,7 +591,7 @@ TEST(AudioProcessingImplTest, RenderPreProcessorBeforeEchoDetector) { .SetEchoDetector(test_echo_detector) .SetRenderPreProcessing(std::move(test_render_pre_processor)) .Build(CreateEnvironment()); - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.pre_amplifier.enabled = true; apm->ApplyConfig(apm_config); @@ -643,7 +643,7 @@ class StartupInputVolumeParameterizedTest // is never modified. TEST_P(StartupInputVolumeParameterizedTest, WithNoInputVolumeControllerStartupVolumeNotModified) { - webrtc::AudioProcessing::Config config; + AudioProcessing::Config config; config.gain_controller1.enabled = false; config.gain_controller2.enabled = false; auto apm = BuiltinAudioProcessingBuilder(config).Build(CreateEnvironment()); @@ -662,7 +662,7 @@ INSTANTIATE_TEST_SUITE_P(AudioProcessingImplTest, // volume always matches the applied one. TEST(AudioProcessingImplTest, WithNoInputVolumeControllerAppliedAndRecommendedVolumesMatch) { - webrtc::AudioProcessing::Config config; + AudioProcessing::Config config; config.gain_controller1.enabled = false; config.gain_controller2.enabled = false; auto apm = BuiltinAudioProcessingBuilder(config).Build(CreateEnvironment()); diff --git a/modules/audio_processing/audio_processing_performance_unittest.cc b/modules/audio_processing/audio_processing_performance_unittest.cc index d12302cb58..820d403eee 100644 --- a/modules/audio_processing/audio_processing_performance_unittest.cc +++ b/modules/audio_processing/audio_processing_performance_unittest.cc @@ -33,10 +33,10 @@ namespace webrtc { namespace { -using ::webrtc::test::GetGlobalMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Metric; -using ::webrtc::test::Unit; +using test::GetGlobalMetricsLogger; +using test::ImprovementDirection; +using test::Metric; +using test::Unit; class CallSimulator; @@ -206,7 +206,7 @@ class TimedThreadApiProcessor { simulation_config_(simulation_config), apm_(apm), frame_data_(kMaxFrameSize), - clock_(webrtc::Clock::GetRealTimeClock()), + clock_(Clock::GetRealTimeClock()), num_durations_to_store_(num_durations_to_store), api_call_durations_(num_durations_to_store_ - kNumInitializationFrames), samples_count_(0), @@ -355,7 +355,7 @@ class TimedThreadApiProcessor { const SimulationConfig* const simulation_config_ = nullptr; AudioProcessing* apm_ = nullptr; AudioFrameData frame_data_; - webrtc::Clock* clock_; + Clock* clock_; const size_t num_durations_to_store_; SamplesStatsCounter api_call_durations_; size_t samples_count_ = 0; diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc index 8e32d34add..1f4a9eda1a 100644 --- a/modules/audio_processing/audio_processing_unittest.cc +++ b/modules/audio_processing/audio_processing_unittest.cc @@ -13,41 +13,54 @@ #include #include +#include #include +#include +#include +#include #include +#include #include #include +#include #include #include +#include +#include +#include #include "absl/flags/flag.h" #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/audio/audio_processing_statistics.h" +#include "api/audio/audio_view.h" #include "api/audio/builtin_audio_processing_builder.h" +#include "api/audio/echo_control.h" #include "api/audio/echo_detector_creator.h" +#include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "common_audio/channel_buffer.h" #include "common_audio/include/audio_util.h" #include "common_audio/resampler/include/push_resampler.h" #include "common_audio/resampler/push_sinc_resampler.h" -#include "common_audio/signal_processing/include/signal_processing_library.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" -#include "modules/audio_processing/audio_processing_impl.h" #include "modules/audio_processing/include/mock_audio_processing.h" #include "modules/audio_processing/test/protobuf_utils.h" #include "modules/audio_processing/test/test_utils.h" #include "rtc_base/arraysize.h" #include "rtc_base/checks.h" #include "rtc_base/fake_clock.h" -#include "rtc_base/gtest_prod_util.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_minmax.h" #include "rtc_base/protobuf_utils.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/swap_queue.h" -#include "rtc_base/system/arch.h" +#include "rtc_base/system/file_wrapper.h" #include "rtc_base/task_queue_for_test.h" -#include "rtc_base/thread.h" #include "system_wrappers/include/cpu_features_wrapper.h" +#include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -158,7 +171,7 @@ int16_t MaxAudioFrame(const Int16FrameData& frame) { void OpenFileAndWriteMessage(absl::string_view filename, const MessageLite& msg) { FILE* file = fopen(std::string(filename).c_str(), "wb"); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); int32_t size = checked_cast(msg.ByteSizeLong()); ASSERT_GT(size, 0); @@ -240,7 +253,7 @@ void ClearTempOutFiles() { void OpenFileAndReadMessage(absl::string_view filename, MessageLite* msg) { FILE* file = fopen(std::string(filename).c_str(), "rb"); - ASSERT_TRUE(file != NULL); + ASSERT_TRUE(file != nullptr); ReadMessageFromFile(file, msg); fclose(file); } @@ -425,9 +438,9 @@ ApmTest::ApmTest() ref_filename_(GetReferenceFilename()), output_sample_rate_hz_(0), num_output_channels_(0), - far_file_(NULL), - near_file_(NULL), - out_file_(NULL) { + far_file_(nullptr), + near_file_(nullptr), + out_file_(nullptr) { apm_ = BuiltinAudioProcessingBuilder().Build(CreateEnvironment()); AudioProcessing::Config apm_config = apm_->GetConfig(); apm_config.gain_controller1.analog_gain_controller.enabled = false; @@ -436,7 +449,7 @@ ApmTest::ApmTest() } void ApmTest::SetUp() { - ASSERT_TRUE(apm_.get() != NULL); + ASSERT_TRUE(apm_.get() != nullptr); Init(32000, 32000, 32000, 2, 2, 2, false); } @@ -445,17 +458,17 @@ void ApmTest::TearDown() { if (far_file_) { ASSERT_EQ(0, fclose(far_file_)); } - far_file_ = NULL; + far_file_ = nullptr; if (near_file_) { ASSERT_EQ(0, fclose(near_file_)); } - near_file_ = NULL; + near_file_ = nullptr; if (out_file_) { ASSERT_EQ(0, fclose(out_file_)); } - out_file_ = NULL; + out_file_ = nullptr; } void ApmTest::Init(AudioProcessing* ap) { @@ -487,14 +500,16 @@ void ApmTest::Init(int sample_rate_hz, } std::string filename = ResourceFilePath("far", sample_rate_hz); far_file_ = fopen(filename.c_str(), "rb"); - ASSERT_TRUE(far_file_ != NULL) << "Could not open file " << filename << "\n"; + ASSERT_TRUE(far_file_ != nullptr) + << "Could not open file " << filename << "\n"; if (near_file_) { ASSERT_EQ(0, fclose(near_file_)); } filename = ResourceFilePath("near", sample_rate_hz); near_file_ = fopen(filename.c_str(), "rb"); - ASSERT_TRUE(near_file_ != NULL) << "Could not open file " << filename << "\n"; + ASSERT_TRUE(near_file_ != nullptr) + << "Could not open file " << filename << "\n"; if (open_output_file) { if (out_file_) { @@ -505,7 +520,7 @@ void ApmTest::Init(int sample_rate_hz, reverse_sample_rate_hz, num_input_channels, num_output_channels, num_reverse_channels, num_reverse_channels, kForward); out_file_ = fopen(filename.c_str(), "wb"); - ASSERT_TRUE(out_file_ != NULL) + ASSERT_TRUE(out_file_ != nullptr) << "Could not open file " << filename << "\n"; } } @@ -539,7 +554,7 @@ bool ApmTest::ReadFrame(FILE* file, } bool ApmTest::ReadFrame(FILE* file, Int16FrameData* frame) { - return ReadFrame(file, frame, NULL); + return ReadFrame(file, frame, nullptr); } // If the end of the file has been reached, rewind it and attempt to read the @@ -554,7 +569,7 @@ void ApmTest::ReadFrameWithRewind(FILE* /* file */, } void ApmTest::ReadFrameWithRewind(FILE* file, Int16FrameData* frame) { - ReadFrameWithRewind(file, frame, NULL); + ReadFrameWithRewind(file, frame, nullptr); } int ApmTest::ProcessStreamChooser(Format format) { @@ -1416,7 +1431,7 @@ void ApmTest::ProcessDebugDump(absl::string_view in_filename, int max_size_bytes) { TaskQueueForTest worker_queue("ApmTest_worker_queue"); FILE* in_file = fopen(std::string(in_filename).c_str(), "rb"); - ASSERT_TRUE(in_file != NULL); + ASSERT_TRUE(in_file != nullptr); audioproc::Event event_msg; bool first_init = true; @@ -1528,9 +1543,9 @@ void ApmTest::VerifyDebugDumpTest(Format format) { FILE* ref_file = fopen(ref_filename.c_str(), "rb"); FILE* out_file = fopen(out_filename.c_str(), "rb"); FILE* limited_file = fopen(limited_filename.c_str(), "rb"); - ASSERT_TRUE(ref_file != NULL); - ASSERT_TRUE(out_file != NULL); - ASSERT_TRUE(limited_file != NULL); + ASSERT_TRUE(ref_file != nullptr); + ASSERT_TRUE(out_file != nullptr); + ASSERT_TRUE(limited_file != nullptr); std::unique_ptr ref_bytes; std::unique_ptr out_bytes; std::unique_ptr limited_bytes; @@ -1613,7 +1628,7 @@ TEST_F(ApmTest, DebugDump) { // Verify the file has been written. FILE* fid = fopen(filename.c_str(), "r"); - ASSERT_TRUE(fid != NULL); + ASSERT_TRUE(fid != nullptr); // Clean it up. ASSERT_EQ(0, fclose(fid)); @@ -1657,7 +1672,7 @@ TEST_F(ApmTest, DebugDumpFromFileHandle) { // Verify the file has been written. FILE* fid = fopen(filename.c_str(), "r"); - ASSERT_TRUE(fid != NULL); + ASSERT_TRUE(fid != nullptr); // Clean it up. ASSERT_EQ(0, fclose(fid)); @@ -1669,7 +1684,6 @@ TEST_F(ApmTest, DebugDumpFromFileHandle) { // of enabled components. TEST_F(ApmTest, Process) { - GOOGLE_PROTOBUF_VERIFY_VERSION; audioproc::OutputData ref_data; if (!absl::GetFlag(FLAGS_write_apm_ref_data)) { @@ -1977,10 +1991,10 @@ class AudioProcessingTest num_reverse_input_channels, num_reverse_output_channels, kReverse) .c_str(), "wb"); - ASSERT_TRUE(far_file != NULL); - ASSERT_TRUE(near_file != NULL); - ASSERT_TRUE(out_file != NULL); - ASSERT_TRUE(rev_out_file != NULL); + ASSERT_TRUE(far_file != nullptr); + ASSERT_TRUE(near_file != nullptr); + ASSERT_TRUE(out_file != nullptr); + ASSERT_TRUE(rev_out_file != nullptr); ChannelBuffer fwd_cb(AudioProcessing::GetFrameSize(input_rate), num_input_channels); @@ -2017,7 +2031,7 @@ class AudioProcessingTest // Dump forward output to file. RTC_DCHECK_EQ(out_cb.num_bands(), 1u); // Assumes full frequency band. DeinterleavedView deinterleaved_src( - out_cb.channels()[0], out_cb.num_frames(), out_cb.num_channels()); + out_cb.channels(), out_cb.num_frames(), out_cb.num_channels()); InterleavedView interleaved_dst( float_data.get(), out_cb.num_frames(), out_cb.num_channels()); Interleave(deinterleaved_src, interleaved_dst); @@ -2029,7 +2043,7 @@ class AudioProcessingTest // Dump reverse output to file. RTC_DCHECK_EQ(rev_out_cb.num_bands(), 1u); deinterleaved_src = DeinterleavedView( - rev_out_cb.channels()[0], rev_out_cb.num_frames(), + rev_out_cb.channels(), rev_out_cb.num_frames(), rev_out_cb.num_channels()); interleaved_dst = InterleavedView( float_data.get(), rev_out_cb.num_frames(), rev_out_cb.num_channels()); @@ -2111,8 +2125,8 @@ TEST_P(AudioProcessingTest, Formats) { cf[i].num_reverse_output, file_direction) .c_str(), "rb"); - ASSERT_TRUE(out_file != NULL); - ASSERT_TRUE(ref_file != NULL); + ASSERT_TRUE(out_file != nullptr); + ASSERT_TRUE(ref_file != nullptr); const size_t ref_samples_per_channel = AudioProcessing::GetFrameSize(ref_rate); @@ -2166,8 +2180,7 @@ TEST_P(AudioProcessingTest, Formats) { out_num); InterleavedView dst(cmp_data.get(), ref_samples_per_channel, out_num); - ASSERT_EQ(ref_length, - static_cast(resampler.Resample(src, dst))); + resampler.Resample(src, dst); out_ptr = cmp_data.get(); } @@ -2369,7 +2382,7 @@ std::string ProduceDebugText(int render_input_sample_rate_hz, void RunApmRateAndChannelTest(ArrayView sample_rates_hz, ArrayView render_channel_counts, ArrayView capture_channel_counts) { - webrtc::AudioProcessing::Config apm_config; + AudioProcessing::Config apm_config; apm_config.pipeline.multi_channel_render = true; apm_config.pipeline.multi_channel_capture = true; apm_config.echo_canceller.enabled = true; diff --git a/modules/audio_processing/echo_control_mobile_impl.cc b/modules/audio_processing/echo_control_mobile_impl.cc index aff9d4e722..e1e0d3fcfc 100644 --- a/modules/audio_processing/echo_control_mobile_impl.cc +++ b/modules/audio_processing/echo_control_mobile_impl.cc @@ -191,9 +191,9 @@ int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio, split_bands = nullptr; } - if (noisy == NULL) { + if (noisy == nullptr) { noisy = clean; - clean = NULL; + clean = nullptr; } for (size_t render = 0; render < stream_properties_->num_reverse_channels; ++render) { diff --git a/modules/audio_processing/gain_controller2.cc b/modules/audio_processing/gain_controller2.cc index 6e4a251456..8704d7bee1 100644 --- a/modules/audio_processing/gain_controller2.cc +++ b/modules/audio_processing/gain_controller2.cc @@ -10,21 +10,31 @@ #include "modules/audio_processing/gain_controller2.h" +#include +#include +#include #include -#include +#include #include "api/audio/audio_frame.h" +#include "api/audio/audio_processing.h" +#include "api/audio/audio_view.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" #include "common_audio/include/audio_util.h" +#include "modules/audio_processing/agc2/adaptive_digital_gain_controller.h" #include "modules/audio_processing/agc2/agc2_common.h" #include "modules/audio_processing/agc2/cpu_features.h" +#include "modules/audio_processing/agc2/input_volume_controller.h" +#include "modules/audio_processing/agc2/interpolated_gain_curve.h" +#include "modules/audio_processing/agc2/noise_level_estimator.h" +#include "modules/audio_processing/agc2/saturation_protector.h" +#include "modules/audio_processing/agc2/speech_level_estimator.h" +#include "modules/audio_processing/agc2/vad_wrapper.h" #include "modules/audio_processing/audio_buffer.h" -#include "modules/audio_processing/include/audio_frame_view.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/strings/string_builder.h" namespace webrtc { namespace { diff --git a/modules/audio_processing/high_pass_filter.cc b/modules/audio_processing/high_pass_filter.cc index 9d8659ee8c..45116bc7eb 100644 --- a/modules/audio_processing/high_pass_filter.cc +++ b/modules/audio_processing/high_pass_filter.cc @@ -10,47 +10,57 @@ #include "modules/audio_processing/high_pass_filter.h" +#include +#include +#include + #include "api/array_view.h" #include "modules/audio_processing/audio_buffer.h" +#include "modules/audio_processing/utility/cascaded_biquad_filter.h" #include "rtc_base/checks.h" namespace webrtc { namespace { // [B,A] = butter(2,100/8000,'high') -constexpr CascadedBiQuadFilter::BiQuadCoefficients - kHighPassFilterCoefficients16kHz = { - {0.972613898f, -1.945227797f, 0.972613898f}, - {-1.944477658f, 0.945977936f}}; +constexpr std::array + kHighPassFilterCoefficients16kHz = {{ + {{0.972613898f, -1.945227797f, 0.972613898f}, + {-1.944477658f, 0.945977936f}}, + }}; // [B,A] = butter(2,100/16000,'high') -constexpr CascadedBiQuadFilter::BiQuadCoefficients - kHighPassFilterCoefficients32kHz = { - {0.986211925f, -1.972423849f, 0.986211925f}, - {-1.972233729f, 0.972613969f}}; +constexpr std::array + kHighPassFilterCoefficients32kHz = {{ + {{0.986211925f, -1.972423849f, 0.986211925f}, + {-1.972233729f, 0.972613969f}}, + }}; // [B,A] = butter(2,100/24000,'high') -constexpr CascadedBiQuadFilter::BiQuadCoefficients - kHighPassFilterCoefficients48kHz = { - {0.990786698f, -1.981573396f, 0.990786698f}, - {-1.981488509f, 0.981658283f}}; - -constexpr size_t kNumberOfHighPassBiQuads = 1; +constexpr std::array + kHighPassFilterCoefficients48kHz = {{ + {{0.990786698f, -1.981573396f, 0.990786698f}, + {-1.981488509f, 0.981658283f}}, + }}; -const CascadedBiQuadFilter::BiQuadCoefficients& ChooseCoefficients( +ArrayView ChooseCoefficients( int sample_rate_hz) { switch (sample_rate_hz) { case 16000: - return kHighPassFilterCoefficients16kHz; + return ArrayView( + kHighPassFilterCoefficients16kHz); case 32000: - return kHighPassFilterCoefficients32kHz; + return ArrayView( + kHighPassFilterCoefficients32kHz); case 48000: - return kHighPassFilterCoefficients48kHz; + return ArrayView( + kHighPassFilterCoefficients48kHz); default: RTC_DCHECK_NOTREACHED(); } RTC_DCHECK_NOTREACHED(); - return kHighPassFilterCoefficients16kHz; + return ArrayView( + kHighPassFilterCoefficients16kHz); } } // namespace @@ -58,10 +68,9 @@ const CascadedBiQuadFilter::BiQuadCoefficients& ChooseCoefficients( HighPassFilter::HighPassFilter(int sample_rate_hz, size_t num_channels) : sample_rate_hz_(sample_rate_hz) { filters_.resize(num_channels); - const auto& coefficients = ChooseCoefficients(sample_rate_hz_); + auto coefficients = ChooseCoefficients(sample_rate_hz_); for (size_t k = 0; k < filters_.size(); ++k) { - filters_[k].reset( - new CascadedBiQuadFilter(coefficients, kNumberOfHighPassBiQuads)); + filters_[k].reset(new CascadedBiQuadFilter(coefficients)); } } @@ -109,8 +118,7 @@ void HighPassFilter::Reset(size_t num_channels) { } const auto& coefficients = ChooseCoefficients(sample_rate_hz_); for (size_t k = old_num_channels; k < filters_.size(); ++k) { - filters_[k].reset( - new CascadedBiQuadFilter(coefficients, kNumberOfHighPassBiQuads)); + filters_[k].reset(new CascadedBiQuadFilter(coefficients)); } } } diff --git a/modules/audio_processing/include/aec_dump.h b/modules/audio_processing/include/aec_dump.h index 532fa210c7..4e273d4cde 100644 --- a/modules/audio_processing/include/aec_dump.h +++ b/modules/audio_processing/include/aec_dump.h @@ -18,6 +18,7 @@ #include "absl/base/attributes.h" #include "api/audio/audio_processing.h" +#include "api/audio/audio_view.h" #include "modules/audio_processing/include/audio_frame_view.h" namespace webrtc { @@ -87,8 +88,10 @@ class AecDump { // by a WriteCaptureStreamMessage call. virtual void AddCaptureStreamInput( const AudioFrameView& src) = 0; + virtual void AddCaptureStreamInput(MonoView channel) = 0; virtual void AddCaptureStreamOutput( const AudioFrameView& src) = 0; + virtual void AddCaptureStreamOutput(MonoView channel) = 0; virtual void AddCaptureStreamInput(const int16_t* const data, int num_channels, int samples_per_channel) = 0; @@ -104,6 +107,9 @@ class AecDump { int samples_per_channel) = 0; virtual void WriteRenderStreamMessage( const AudioFrameView& src) = 0; + virtual void WriteRenderStreamMessage(const float* const* data, + int num_channels, + int samples_per_channel) = 0; virtual void WriteRuntimeSetting( const AudioProcessing::RuntimeSetting& runtime_setting) = 0; diff --git a/modules/audio_processing/include/audio_frame_view.h b/modules/audio_processing/include/audio_frame_view.h index 27e2009067..d742e93125 100644 --- a/modules/audio_processing/include/audio_frame_view.h +++ b/modules/audio_processing/include/audio_frame_view.h @@ -12,6 +12,7 @@ #define MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_FRAME_VIEW_H_ #include "api/audio/audio_view.h" +#include "rtc_base/checks.h" namespace webrtc { @@ -30,7 +31,7 @@ class AudioFrameView { // channel pointers can be calculated based on that (which is what the class // now uses `DeinterleavedView<>` internally for). AudioFrameView(T* const* audio_samples, int num_channels, int channel_size) - : view_(num_channels && channel_size ? audio_samples[0] : nullptr, + : view_(num_channels && channel_size ? audio_samples : nullptr, channel_size, num_channels) { RTC_DCHECK_GE(view_.num_channels(), 0); diff --git a/modules/audio_processing/ns/BUILD.gn b/modules/audio_processing/ns/BUILD.gn index 31ad61156d..e90ef0e06a 100644 --- a/modules/audio_processing/ns/BUILD.gn +++ b/modules/audio_processing/ns/BUILD.gn @@ -60,14 +60,13 @@ rtc_static_library("ns") { "../../../rtc_base:safe_minmax", "../../../rtc_base/system:arch", "../../../system_wrappers", - "../../../system_wrappers:field_trial", "../../../system_wrappers:metrics", "../utility:cascaded_biquad_filter", ] } if (rtc_include_tests) { - rtc_source_set("ns_unittests") { + rtc_library("ns_unittests") { testonly = true configs += [ "..:apm_debug_dump" ] diff --git a/modules/audio_processing/ns/fast_math.cc b/modules/audio_processing/ns/fast_math.cc index 72f6fb2145..7b8fe1f55b 100644 --- a/modules/audio_processing/ns/fast_math.cc +++ b/modules/audio_processing/ns/fast_math.cc @@ -13,6 +13,8 @@ #include #include +#include + #include "rtc_base/checks.h" namespace webrtc { @@ -53,7 +55,7 @@ float PowApproximation(float x, float p) { } float LogApproximation(float x) { - constexpr float kLogOf2 = 0.69314718056f; + constexpr float kLogOf2 = std::numbers::ln2_v; return FastLog2f(x) * kLogOf2; } @@ -64,7 +66,7 @@ void LogApproximation(ArrayView x, ArrayView y) { } float ExpApproximation(float x) { - constexpr float kLog10Ofe = 0.4342944819f; + constexpr float kLog10Ofe = std::numbers::log10e_v; return PowApproximation(10.f, x * kLog10Ofe); } diff --git a/modules/audio_processing/ns/noise_estimator.cc b/modules/audio_processing/ns/noise_estimator.cc index bf21d38d0b..00b647ca35 100644 --- a/modules/audio_processing/ns/noise_estimator.cc +++ b/modules/audio_processing/ns/noise_estimator.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include "api/array_view.h" #include "modules/audio_processing/ns/fast_math.h" @@ -25,10 +26,14 @@ namespace webrtc { namespace { +using std::numbers::ln10_v; + // Log(i). +// clang-format off constexpr std::array log_table = { 0.f, 0.f, 0.f, 0.f, 0.f, 1.609438f, 1.791759f, - 1.945910f, 2.079442f, 2.197225f, 2.302585f, 2.397895f, 2.484907f, 2.564949f, + 1.945910f, 2.079442f, 2.197225f, ln10_v, 2.397895f, 2.484907f, + 2.564949f, 2.639057f, 2.708050f, 2.772589f, 2.833213f, 2.890372f, 2.944439f, 2.995732f, 3.044522f, 3.091043f, 3.135494f, 3.178054f, 3.218876f, 3.258097f, 3.295837f, 3.332205f, 3.367296f, 3.401197f, 3.433987f, 3.465736f, 3.496507f, 3.526361f, @@ -46,6 +51,7 @@ constexpr std::array log_table = { 4.718499f, 4.727388f, 4.736198f, 4.744932f, 4.753591f, 4.762174f, 4.770685f, 4.779124f, 4.787492f, 4.795791f, 4.804021f, 4.812184f, 4.820282f, 4.828314f, 4.836282f, 4.844187f, 4.852030f}; +// clang-format on } // namespace diff --git a/modules/audio_processing/post_filter.cc b/modules/audio_processing/post_filter.cc new file mode 100644 index 0000000000..1fa94cb5c3 --- /dev/null +++ b/modules/audio_processing/post_filter.cc @@ -0,0 +1,69 @@ +/* + * 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 "modules/audio_processing/post_filter.h" + +#include +#include +#include +#include + +#include "api/array_view.h" +#include "modules/audio_processing/audio_buffer.h" +#include "modules/audio_processing/utility/cascaded_biquad_filter.h" +#include "rtc_base/checks.h" + +namespace webrtc { + +namespace { + +// Removes frequencies above 19.5kHz. +// sos = signal.iirdesign( +// 19200 * 2 / 48000, 19500 * 2 / 48000, +// 3, 20, ftype='cheby2', output="sos") +constexpr std::array + kPostFilterCoefficients48kHz = {{ + {{0.56142156f, 1.11499931f, 0.56142156f}, {1.57914249f, 0.63379496f}}, + {{1.00000000f, 1.88944170f, 1.00000000f}, {1.55130066f, 0.68708719f}}, + {{1.00000000f, 1.76057310f, 1.00000000f}, {1.53001328f, 0.78591224f}}, + {{1.00000000f, 1.67448535f, 1.00000000f}, {1.56506670f, 0.92096576f}}, + }}; +} // namespace + +std::unique_ptr PostFilter::CreateIfNeeded(int sample_rate_hz, + size_t num_channels) { + if (sample_rate_hz != 48000) { + return nullptr; + } + + return std::unique_ptr( + new PostFilter(kPostFilterCoefficients48kHz, num_channels)); +} + +PostFilter::PostFilter( + ArrayView coefficients, + size_t num_channels) { + RTC_DCHECK(!coefficients.empty()); + + filters_.resize(num_channels); + for (size_t k = 0; k < filters_.size(); ++k) { + filters_[k].reset(new CascadedBiQuadFilter(coefficients)); + } +} + +void PostFilter::Process(AudioBuffer& audio) { + RTC_DCHECK_EQ(filters_.size(), audio.num_channels()); + for (size_t k = 0; k < audio.num_channels(); ++k) { + ArrayView channel_data = + ArrayView(&audio.channels()[k][0], audio.num_frames()); + filters_[k]->Process(channel_data); + } +} +} // namespace webrtc diff --git a/modules/audio_processing/post_filter.h b/modules/audio_processing/post_filter.h new file mode 100644 index 0000000000..cce42608a6 --- /dev/null +++ b/modules/audio_processing/post_filter.h @@ -0,0 +1,49 @@ +/* + * 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 MODULES_AUDIO_PROCESSING_POST_FILTER_H_ +#define MODULES_AUDIO_PROCESSING_POST_FILTER_H_ + +#include +#include +#include + +#include "api/array_view.h" +#include "modules/audio_processing/audio_buffer.h" +#include "modules/audio_processing/utility/cascaded_biquad_filter.h" + +namespace webrtc { + +// Provides functionality for general enhancement and compensation of +// artefacts/shortcomings introduced by prior processing. The processing is +// applied to the fullband signal. +class PostFilter { + public: + // Creates a Post Processing Filter. + // Returns nullptr if sample_rate is low enough that no filter are required. + static std::unique_ptr CreateIfNeeded(int sample_rate_hz, + size_t num_channels); + + ~PostFilter() = default; + PostFilter(const PostFilter&) = delete; + PostFilter& operator=(const PostFilter&) = delete; + + void Process(AudioBuffer& audio); + + private: + PostFilter( + ArrayView coefficients, + size_t num_channels); + + std::vector> filters_; +}; +} // namespace webrtc + +#endif // MODULES_AUDIO_PROCESSING_POST_FILTER_H_ diff --git a/modules/audio_processing/post_filter_unittest.cc b/modules/audio_processing/post_filter_unittest.cc new file mode 100644 index 0000000000..096d734a93 --- /dev/null +++ b/modules/audio_processing/post_filter_unittest.cc @@ -0,0 +1,164 @@ +/* + * 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 "modules/audio_processing/post_filter.h" + +#include + +#include +#include +#include +#include + +#include "api/array_view.h" +#include "api/audio/audio_processing.h" +#include "modules/audio_processing/audio_buffer.h" +#include "modules/audio_processing/test/audio_buffer_tools.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { +namespace { + +using ::testing::FloatNear; +using ::testing::Le; +using ::testing::NotNull; + +// Process one frame of data via the AudioBuffer interface and produce the +// output. +std::vector ProcessOneFrameAsAudioBuffer( + const std::vector& frame_input, + const StreamConfig& stream_config, + PostFilter* filter) { + AudioBuffer audio_buffer( + stream_config.sample_rate_hz(), stream_config.num_channels(), + stream_config.sample_rate_hz(), stream_config.num_channels(), + stream_config.sample_rate_hz(), stream_config.num_channels()); + + test::CopyVectorToAudioBuffer(stream_config, frame_input, &audio_buffer); + filter->Process(audio_buffer); + std::vector frame_output; + test::ExtractVectorFromAudioBuffer(stream_config, &audio_buffer, + &frame_output); + return frame_output; +} + +float ComputePower(ArrayView audio) { + double energy = 0.0; + std::for_each(audio.begin(), audio.end(), + [&energy](float x) { energy += x * x; }); + return energy / audio.size(); +} + +float PowerDecibelToLinear(float db) { + return std::powf(10.0, db / 10.0); +} +} // namespace + +class PostFilterCreateTest : public ::testing::TestWithParam {}; + +TEST_P(PostFilterCreateTest, CreateOnlyFor48k) { + const int sample_rate_hz = GetParam(); + std::unique_ptr filter = + PostFilter::CreateIfNeeded(sample_rate_hz, /*num_channels=*/2); + if (sample_rate_hz == 48000) { + EXPECT_NE(filter, nullptr); + } else { + EXPECT_EQ(filter, nullptr); + } +} + +INSTANTIATE_TEST_SUITE_P( + _, + PostFilterCreateTest, + ::testing::Values(8000, 16000, 24000, 32000, 44100, 48000)); + +TEST(PostFilterTest, Tone19p8kHzSignalAttenuation48k) { + constexpr int sample_rate_hz = 48000; + + std::unique_ptr filter = + PostFilter::CreateIfNeeded(sample_rate_hz, 1); + ASSERT_THAT(filter, NotNull()); + + const StreamConfig stream_config(sample_rate_hz, 1); + + constexpr int num_frames = sample_rate_hz * 10 / 1000; // 10ms; + constexpr double tone_frequency = 19800; // Hz + + const double phase_increment = tone_frequency * 2.0 * M_PI / sample_rate_hz; + double phase = 0.0; + + std::vector audio_input(num_frames); + + // Prime the filter to avoid initial state effect. + std::generate(audio_input.begin(), audio_input.end(), + [&phase, phase_increment]() { + phase += phase_increment; + return std::sinf(phase); + }); + ProcessOneFrameAsAudioBuffer(audio_input, stream_config, filter.get()); + + for (int n = 0; n < 20; ++n) { + std::generate(audio_input.begin(), audio_input.end(), + [&phase, phase_increment]() { + phase += phase_increment; + return std::sinf(phase); + }); + const float input_power = ComputePower(audio_input); + + std::vector audio_output = + ProcessOneFrameAsAudioBuffer(audio_input, stream_config, filter.get()); + + float output_power = ComputePower(audio_output); + EXPECT_THAT(output_power / input_power, Le(PowerDecibelToLinear(-20.0))); + } +} + +TEST(PostFilterTest, Tone17kHzSignalNoAttenuation48k) { + constexpr int sample_rate_hz = 48000; + + std::unique_ptr filter = + PostFilter::CreateIfNeeded(sample_rate_hz, 1); + ASSERT_THAT(filter, NotNull()); + + const StreamConfig stream_config(sample_rate_hz, 1); + + constexpr int num_frames = sample_rate_hz * 10 / 1000; // 10ms; + constexpr double tone_frequency = 16800; // Hz + + const double phase_increment = tone_frequency * 2.0 * M_PI / sample_rate_hz; + double phase = 0.0; + + std::vector audio_input(num_frames); + + // Prime the filter to avoid initial state effect. + std::generate(audio_input.begin(), audio_input.end(), + [&phase, phase_increment]() { + phase += phase_increment; + return std::sinf(phase); + }); + ProcessOneFrameAsAudioBuffer(audio_input, stream_config, filter.get()); + + for (int n = 0; n < 20; ++n) { + std::generate(audio_input.begin(), audio_input.end(), + [&phase, phase_increment]() { + phase += phase_increment; + return std::sinf(phase); + }); + const float input_power = ComputePower(audio_input); + + std::vector audio_output = + ProcessOneFrameAsAudioBuffer(audio_input, stream_config, filter.get()); + + float output_power = ComputePower(audio_output); + EXPECT_THAT(10 * std::log10f(output_power / input_power), + FloatNear(0.0, 0.5f)); + } +} +} // namespace webrtc diff --git a/modules/audio_processing/test/aec_dump_based_simulator.cc b/modules/audio_processing/test/aec_dump_based_simulator.cc index 896c4b8be3..6a249eeecc 100644 --- a/modules/audio_processing/test/aec_dump_based_simulator.cc +++ b/modules/audio_processing/test/aec_dump_based_simulator.cc @@ -45,7 +45,7 @@ namespace { // Verify output bitexactness for the fixed interface. // TODO(peah): Check whether it would make sense to add a threshold // to use for checking the bitexactness in a soft manner. -bool VerifyFixedBitExactness(const webrtc::audioproc::Stream& msg, +bool VerifyFixedBitExactness(const audioproc::Stream& msg, const Int16Frame& frame) { if (sizeof(frame.data[0]) * frame.data.size() != msg.output_data().size()) { return false; @@ -61,7 +61,7 @@ bool VerifyFixedBitExactness(const webrtc::audioproc::Stream& msg, } // Verify output bitexactness for the float interface. -bool VerifyFloatBitExactness(const webrtc::audioproc::Stream& msg, +bool VerifyFloatBitExactness(const audioproc::Stream& msg, const StreamConfig& out_config, const ChannelBuffer& out_buf) { if (static_cast(msg.output_channel_size()) != @@ -86,7 +86,7 @@ bool VerifyFloatBitExactness(const webrtc::audioproc::Stream& msg, bool ReadNextMessage(bool use_dump_file, FILE* dump_input_file, std::stringstream& input, - webrtc::audioproc::Event& event_msg) { + audioproc::Event& event_msg) { if (use_dump_file) { return ReadMessageFromFile(dump_input_file, &event_msg); } @@ -105,7 +105,7 @@ AecDumpBasedSimulator::AecDumpBasedSimulator( AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; void AecDumpBasedSimulator::PrepareProcessStreamCall( - const webrtc::audioproc::Stream& msg) { + const audioproc::Stream& msg) { if (msg.has_input_data()) { // Fixed interface processing. // Verify interface invariance. @@ -196,7 +196,7 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall( } void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( - const webrtc::audioproc::Stream& msg) { + const audioproc::Stream& msg) { if (bitexact_output_) { if (interface_used_ == InterfaceType::kFixedInterface) { bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_); @@ -207,7 +207,7 @@ void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( } void AecDumpBasedSimulator::PrepareReverseProcessStreamCall( - const webrtc::audioproc::ReverseStream& msg) { + const audioproc::ReverseStream& msg) { if (msg.has_data()) { // Fixed interface processing. // Verify interface invariance. @@ -267,7 +267,7 @@ void AecDumpBasedSimulator::Process() { input << settings_.aec_dump_input_string.value(); } - webrtc::audioproc::Event event_msg; + audioproc::Event event_msg; int capture_frames_since_init = 0; int init_index = 0; while (ReadNextMessage(use_dump_file, dump_input_file_, input, event_msg)) { @@ -300,12 +300,12 @@ void AecDumpBasedSimulator::Analyze() { input << settings_.aec_dump_input_string.value(); } - webrtc::audioproc::Event event_msg; + audioproc::Event event_msg; int num_capture_frames = 0; int num_render_frames = 0; int init_index = 0; while (ReadNextMessage(use_dump_file, dump_input_file_, input, event_msg)) { - if (event_msg.type() == webrtc::audioproc::Event::INIT) { + if (event_msg.type() == audioproc::Event::INIT) { ++init_index; constexpr float kNumFramesPerSecond = 100.f; float capture_time_seconds = num_capture_frames / kNumFramesPerSecond; @@ -318,9 +318,9 @@ void AecDumpBasedSimulator::Analyze() { << num_capture_frames << " frames) " << std::endl; std::cout << " Render: " << render_time_seconds << " s (" << num_render_frames << " frames) " << std::endl; - } else if (event_msg.type() == webrtc::audioproc::Event::STREAM) { + } else if (event_msg.type() == audioproc::Event::STREAM) { ++num_capture_frames; - } else if (event_msg.type() == webrtc::audioproc::Event::REVERSE_STREAM) { + } else if (event_msg.type() == audioproc::Event::REVERSE_STREAM) { ++num_render_frames; } } @@ -330,40 +330,38 @@ void AecDumpBasedSimulator::Analyze() { } } -void AecDumpBasedSimulator::HandleEvent( - const webrtc::audioproc::Event& event_msg, - int& capture_frames_since_init, - int& init_index) { +void AecDumpBasedSimulator::HandleEvent(const audioproc::Event& event_msg, + int& capture_frames_since_init, + int& init_index) { switch (event_msg.type()) { - case webrtc::audioproc::Event::INIT: + case audioproc::Event::INIT: RTC_CHECK(event_msg.has_init()); ++init_index; capture_frames_since_init = 0; HandleMessage(event_msg.init(), init_index); break; - case webrtc::audioproc::Event::STREAM: + case audioproc::Event::STREAM: RTC_CHECK(event_msg.has_stream()); ++capture_frames_since_init; HandleMessage(event_msg.stream()); break; - case webrtc::audioproc::Event::REVERSE_STREAM: + case audioproc::Event::REVERSE_STREAM: RTC_CHECK(event_msg.has_reverse_stream()); HandleMessage(event_msg.reverse_stream()); break; - case webrtc::audioproc::Event::CONFIG: + case audioproc::Event::CONFIG: RTC_CHECK(event_msg.has_config()); HandleMessage(event_msg.config()); break; - case webrtc::audioproc::Event::RUNTIME_SETTING: + case audioproc::Event::RUNTIME_SETTING: HandleMessage(event_msg.runtime_setting()); break; - case webrtc::audioproc::Event::UNKNOWN_EVENT: + case audioproc::Event::UNKNOWN_EVENT: RTC_CHECK_NOTREACHED(); } } -void AecDumpBasedSimulator::HandleMessage( - const webrtc::audioproc::Config& msg) { +void AecDumpBasedSimulator::HandleMessage(const audioproc::Config& msg) { if (settings_.use_verbose_logging) { std::cout << "Config at frame:" << std::endl; std::cout << " Forward: " << get_num_process_stream_calls() << std::endl; @@ -403,7 +401,7 @@ void AecDumpBasedSimulator::HandleMessage( } if (msg.has_aecm_routing_mode() && - static_cast( + static_cast( msg.aecm_routing_mode()) != EchoControlMobileImpl::kSpeakerphone) { RTC_LOG(LS_ERROR) << "Ignoring deprecated setting: AECM routing mode: " << msg.aecm_routing_mode(); @@ -421,8 +419,7 @@ void AecDumpBasedSimulator::HandleMessage( if (msg.has_agc_mode() || settings_.agc_mode) { int mode = settings_.agc_mode ? *settings_.agc_mode : msg.agc_mode(); apm_config.gain_controller1.mode = - static_cast( - mode); + static_cast(mode); if (settings_.use_verbose_logging) { std::cout << " agc_mode: " << mode << std::endl; } @@ -524,7 +521,7 @@ void AecDumpBasedSimulator::HandleMessage( } } -void AecDumpBasedSimulator::HandleMessage(const webrtc::audioproc::Init& msg, +void AecDumpBasedSimulator::HandleMessage(const audioproc::Init& msg, int init_index) { RTC_CHECK(msg.has_sample_rate()); RTC_CHECK(msg.has_num_input_channels()); @@ -586,8 +583,7 @@ void AecDumpBasedSimulator::HandleMessage(const webrtc::audioproc::Init& msg, msg.num_reverse_channels(), num_reverse_output_channels); } -void AecDumpBasedSimulator::HandleMessage( - const webrtc::audioproc::Stream& msg) { +void AecDumpBasedSimulator::HandleMessage(const audioproc::Stream& msg) { if (call_order_output_file_) { *call_order_output_file_ << "c"; } @@ -596,8 +592,7 @@ void AecDumpBasedSimulator::HandleMessage( VerifyProcessStreamBitExactness(msg); } -void AecDumpBasedSimulator::HandleMessage( - const webrtc::audioproc::ReverseStream& msg) { +void AecDumpBasedSimulator::HandleMessage(const audioproc::ReverseStream& msg) { if (call_order_output_file_) { *call_order_output_file_ << "r"; } @@ -606,7 +601,7 @@ void AecDumpBasedSimulator::HandleMessage( } void AecDumpBasedSimulator::HandleMessage( - const webrtc::audioproc::RuntimeSetting& msg) { + const audioproc::RuntimeSetting& msg) { RTC_CHECK(ap_.get()); if (msg.has_capture_pre_gain()) { // Handle capture pre-gain runtime setting only if not overridden. diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index a273083720..914edb775f 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc @@ -503,7 +503,7 @@ void AudioProcessingSimulator::ConfigureAudioProcessor() { } if (settings_.agc_mode) { apm_config.gain_controller1.mode = - static_cast( + static_cast( *settings_.agc_mode); } if (settings_.use_agc_limiter) { diff --git a/modules/audio_processing/test/performance_timer.cc b/modules/audio_processing/test/performance_timer.cc index 1a82258903..cc12e00d6c 100644 --- a/modules/audio_processing/test/performance_timer.cc +++ b/modules/audio_processing/test/performance_timer.cc @@ -20,7 +20,7 @@ namespace webrtc { namespace test { PerformanceTimer::PerformanceTimer(int num_frames_to_process) - : clock_(webrtc::Clock::GetRealTimeClock()) { + : clock_(Clock::GetRealTimeClock()) { timestamps_us_.reserve(num_frames_to_process); } diff --git a/modules/audio_processing/test/runtime_setting_util.cc b/modules/audio_processing/test/runtime_setting_util.cc index 4899d2d459..2240768d74 100644 --- a/modules/audio_processing/test/runtime_setting_util.cc +++ b/modules/audio_processing/test/runtime_setting_util.cc @@ -15,7 +15,7 @@ namespace webrtc { void ReplayRuntimeSetting(AudioProcessing* apm, - const webrtc::audioproc::RuntimeSetting& setting) { + const audioproc::RuntimeSetting& setting) { RTC_CHECK(apm); // TODO(bugs.webrtc.org/9138): Add ability to handle different types // of settings. Currently CapturePreGain, CaptureFixedPostGain and diff --git a/modules/audio_processing/three_band_filter_bank.cc b/modules/audio_processing/three_band_filter_bank.cc index d69db9bf9a..45b44a7762 100644 --- a/modules/audio_processing/three_band_filter_bank.cc +++ b/modules/audio_processing/three_band_filter_bank.cc @@ -33,6 +33,7 @@ #include "modules/audio_processing/three_band_filter_bank.h" #include +#include #include "rtc_base/checks.h" @@ -88,17 +89,21 @@ const float constexpr int kZeroFilterIndex1 = 3; constexpr int kZeroFilterIndex2 = 9; +constexpr float kSqrt3 = std::numbers::sqrt3_v; + +// clang-format off const float kDctModulation[ThreeBandFilterBank::kNumNonZeroFilters][kDctSize] = {{2.f, 2.f, 2.f}, - {1.73205077f, 0.f, -1.73205077f}, + {kSqrt3, 0.f, -kSqrt3}, {1.f, -2.f, 1.f}, {-1.f, 2.f, -1.f}, - {-1.73205077f, 0.f, 1.73205077f}, + {-kSqrt3, 0.f, kSqrt3}, {-2.f, -2.f, -2.f}, - {-1.73205077f, 0.f, 1.73205077f}, + {-kSqrt3, 0.f, kSqrt3}, {-1.f, 2.f, -1.f}, {1.f, -2.f, 1.f}, - {1.73205077f, 0.f, -1.73205077f}}; + {kSqrt3, 0.f, -kSqrt3}}; +// clang-format on // Filters the input signal `in` with the filter `filter` using a shift by // `in_shift`, taking into account the previous state. diff --git a/modules/audio_processing/utility/BUILD.gn b/modules/audio_processing/utility/BUILD.gn index 4851e77b03..8dfb870cc9 100644 --- a/modules/audio_processing/utility/BUILD.gn +++ b/modules/audio_processing/utility/BUILD.gn @@ -51,6 +51,8 @@ if (rtc_include_tests) { deps = [ ":cascaded_biquad_filter", "../../../test:test_support", + "//api:array_view", + "//rtc_base:checks", "//testing/gtest", ] } diff --git a/modules/audio_processing/utility/cascaded_biquad_filter.cc b/modules/audio_processing/utility/cascaded_biquad_filter.cc index 19faadfc96..d2f4952aa8 100644 --- a/modules/audio_processing/utility/cascaded_biquad_filter.cc +++ b/modules/audio_processing/utility/cascaded_biquad_filter.cc @@ -10,62 +10,22 @@ #include "modules/audio_processing/utility/cascaded_biquad_filter.h" #include +#include +#include +#include "api/array_view.h" #include "rtc_base/checks.h" namespace webrtc { -CascadedBiQuadFilter::BiQuadParam::BiQuadParam(std::complex zero, - std::complex pole, - float gain, - bool mirror_zero_along_i_axis) - : zero(zero), - pole(pole), - gain(gain), - mirror_zero_along_i_axis(mirror_zero_along_i_axis) {} - -CascadedBiQuadFilter::BiQuadParam::BiQuadParam(const BiQuadParam&) = default; - -CascadedBiQuadFilter::BiQuad::BiQuad( - const CascadedBiQuadFilter::BiQuadParam& param) - : x(), y() { - float z_r = std::real(param.zero); - float z_i = std::imag(param.zero); - float p_r = std::real(param.pole); - float p_i = std::imag(param.pole); - float gain = param.gain; - - if (param.mirror_zero_along_i_axis) { - // Assuming zeroes at z_r and -z_r. - RTC_DCHECK(z_i == 0.f); - coefficients.b[0] = gain * 1.f; - coefficients.b[1] = 0.f; - coefficients.b[2] = gain * -(z_r * z_r); - } else { - // Assuming zeros at (z_r + z_i*i) and (z_r - z_i*i). - coefficients.b[0] = gain * 1.f; - coefficients.b[1] = gain * -2.f * z_r; - coefficients.b[2] = gain * (z_r * z_r + z_i * z_i); - } - - // Assuming poles at (p_r + p_i*i) and (p_r - p_i*i). - coefficients.a[0] = -2.f * p_r; - coefficients.a[1] = p_r * p_r + p_i * p_i; -} - void CascadedBiQuadFilter::BiQuad::BiQuad::Reset() { x[0] = x[1] = y[0] = y[1] = 0.f; } CascadedBiQuadFilter::CascadedBiQuadFilter( - const CascadedBiQuadFilter::BiQuadCoefficients& coefficients, - size_t num_biquads) - : biquads_(num_biquads, BiQuad(coefficients)) {} - -CascadedBiQuadFilter::CascadedBiQuadFilter( - const std::vector& biquad_params) { - for (const auto& param : biquad_params) { - biquads_.push_back(BiQuad(param)); + ArrayView coefficients) { + for (const auto& single_biquad_coefficients : coefficients) { + biquads_.push_back(BiQuad(single_biquad_coefficients)); } } diff --git a/modules/audio_processing/utility/cascaded_biquad_filter.h b/modules/audio_processing/utility/cascaded_biquad_filter.h index 799b439416..25d8d504ec 100644 --- a/modules/audio_processing/utility/cascaded_biquad_filter.h +++ b/modules/audio_processing/utility/cascaded_biquad_filter.h @@ -13,7 +13,6 @@ #include -#include #include #include "api/array_view.h" @@ -24,18 +23,6 @@ namespace webrtc { // is direct form 1. class CascadedBiQuadFilter { public: - struct BiQuadParam { - BiQuadParam(std::complex zero, - std::complex pole, - float gain, - bool mirror_zero_along_i_axis = false); - explicit BiQuadParam(const BiQuadParam&); - std::complex zero; - std::complex pole; - float gain; - bool mirror_zero_along_i_axis; - }; - struct BiQuadCoefficients { float b[3]; float a[2]; @@ -44,7 +31,6 @@ class CascadedBiQuadFilter { struct BiQuad { explicit BiQuad(const BiQuadCoefficients& coefficients) : coefficients(coefficients), x(), y() {} - explicit BiQuad(const CascadedBiQuadFilter::BiQuadParam& param); void Reset(); BiQuadCoefficients coefficients; float x[2]; @@ -52,10 +38,7 @@ class CascadedBiQuadFilter { }; CascadedBiQuadFilter( - const CascadedBiQuadFilter::BiQuadCoefficients& coefficients, - size_t num_biquads); - explicit CascadedBiQuadFilter( - const std::vector& biquad_params); + ArrayView coefficients); ~CascadedBiQuadFilter(); CascadedBiQuadFilter(const CascadedBiQuadFilter&) = delete; CascadedBiQuadFilter& operator=(const CascadedBiQuadFilter&) = delete; diff --git a/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc b/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc index ff7022dba4..d9ab839a93 100644 --- a/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc +++ b/modules/audio_processing/utility/cascaded_biquad_filter_unittest.cc @@ -10,8 +10,12 @@ #include "modules/audio_processing/utility/cascaded_biquad_filter.h" +#include +#include #include +#include "api/array_view.h" +#include "rtc_base/checks.h" #include "test/gtest.h" namespace webrtc { @@ -20,17 +24,26 @@ namespace { // Coefficients for a second order Butterworth high-pass filter with cutoff // frequency 100 Hz. -const CascadedBiQuadFilter::BiQuadCoefficients kHighPassFilterCoefficients = { - {0.97261f, -1.94523f, 0.97261f}, - {-1.94448f, 0.94598f}}; - -const CascadedBiQuadFilter::BiQuadCoefficients kTransparentCoefficients = { - {1.f, 0.f, 0.f}, - {0.f, 0.f}}; - -const CascadedBiQuadFilter::BiQuadCoefficients kBlockingCoefficients = { - {0.f, 0.f, 0.f}, - {0.f, 0.f}}; +constexpr std::array + kHighPassFilterCoefficients = {{ + {{0.97261f, -1.94523f, 0.97261f}, {-1.94448f, 0.94598f}}, + }}; + +constexpr std::array + kTransparentCoefficients = {{ + {{1.f, 0.f, 0.f}, {0.f, 0.f}}, + }}; + +constexpr std::array + kBlockingCoefficients = {{ + {{0.f, 0.f, 0.f}, {0.f, 0.f}}, + }}; + +constexpr std::array + kCascadedCoefficients = {{ + {{-1.f, 0.f, 0.f}, {0.f, 0.f}}, + {{0.f, 0.f, -1.f}, {0.f, 0.f}}, + }}; std::vector CreateInputWithIncreasingValues(size_t vector_length) { std::vector v(vector_length); @@ -47,7 +60,9 @@ std::vector CreateInputWithIncreasingValues(size_t vector_length) { TEST(CascadedBiquadFilter, BlockingConfiguration) { std::vector values = CreateInputWithIncreasingValues(1000); - CascadedBiQuadFilter filter(kBlockingCoefficients, 1); + CascadedBiQuadFilter filter( + (ArrayView( + kBlockingCoefficients))); filter.Process(values); EXPECT_EQ(std::vector(1000, 0.f), values); @@ -62,17 +77,21 @@ TEST(CascadedBiquadFilter, HighPassConfiguration) { values[k] = 1.f; } - CascadedBiQuadFilter filter(kHighPassFilterCoefficients, 2); + CascadedBiQuadFilter filter( + (ArrayView( + kHighPassFilterCoefficients))); filter.Process(values); for (size_t k = values.size() / 2; k < values.size(); ++k) { - EXPECT_NEAR(0.f, values[k], 1e-4); + EXPECT_NEAR(0.f, values[k], 1e-2); } } // Verifies that the reset functionality works as intended. TEST(CascadedBiquadFilter, HighPassConfigurationResetFunctionality) { - CascadedBiQuadFilter filter(kHighPassFilterCoefficients, 2); + CascadedBiQuadFilter filter( + (ArrayView( + kHighPassFilterCoefficients))); std::vector values1(100, 1.f); filter.Process(values1); @@ -94,12 +113,30 @@ TEST(CascadedBiquadFilter, TransparentConfiguration) { const std::vector input = CreateInputWithIncreasingValues(1000); std::vector output(input.size()); - CascadedBiQuadFilter filter(kTransparentCoefficients, 1); + CascadedBiQuadFilter filter( + (ArrayView( + kTransparentCoefficients))); filter.Process(input, output); EXPECT_EQ(input, output); } +// Verifies that cascading multiple biquads works as expected. +TEST(CascadedBiquadFilter, CascadedConfiguration) { + const std::vector input = CreateInputWithIncreasingValues(1000); + std::vector output(input.size()); + + CascadedBiQuadFilter filter( + (ArrayView( + kCascadedCoefficients))); + filter.Process(input, output); + + // The cascaded biquad is expected to result in a delay of two samples. + for (size_t i = 2; i < output.size(); ++i) { + EXPECT_EQ(output[i], input[i - 2]); + } +} + #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) // Verifies that the check of the lengths for the input and output works for the // non-in-place call. @@ -107,51 +144,10 @@ TEST(CascadedBiquadFilterDeathTest, InputSizeCheckVerification) { const std::vector input = CreateInputWithIncreasingValues(10); std::vector output(input.size() - 1); - CascadedBiQuadFilter filter(kTransparentCoefficients, 1); + CascadedBiQuadFilter filter( + (ArrayView( + kTransparentCoefficients))); EXPECT_DEATH(filter.Process(input, output), ""); } #endif - -// Verifies the conversion from zero, pole, gain to filter coefficients for -// lowpass filter. -TEST(CascadedBiquadFilter, BiQuadParamLowPass) { - CascadedBiQuadFilter::BiQuadParam param( - {-1.0f, 0.0f}, {0.23146901f, 0.39514232f}, 0.1866943331163784f); - CascadedBiQuadFilter::BiQuad filter(param); - const float epsilon = 1e-6f; - EXPECT_NEAR(filter.coefficients.b[0], 0.18669433f, epsilon); - EXPECT_NEAR(filter.coefficients.b[1], 0.37338867f, epsilon); - EXPECT_NEAR(filter.coefficients.b[2], 0.18669433f, epsilon); - EXPECT_NEAR(filter.coefficients.a[0], -0.46293803f, epsilon); - EXPECT_NEAR(filter.coefficients.a[1], 0.20971536f, epsilon); -} - -// Verifies the conversion from zero, pole, gain to filter coefficients for -// highpass filter. -TEST(CascadedBiquadFilter, BiQuadParamHighPass) { - CascadedBiQuadFilter::BiQuadParam param( - {1.0f, 0.0f}, {0.72712179f, 0.21296904f}, 0.75707637533388494f); - CascadedBiQuadFilter::BiQuad filter(param); - const float epsilon = 1e-6f; - EXPECT_NEAR(filter.coefficients.b[0], 0.75707638f, epsilon); - EXPECT_NEAR(filter.coefficients.b[1], -1.51415275f, epsilon); - EXPECT_NEAR(filter.coefficients.b[2], 0.75707638f, epsilon); - EXPECT_NEAR(filter.coefficients.a[0], -1.45424359f, epsilon); - EXPECT_NEAR(filter.coefficients.a[1], 0.57406192f, epsilon); -} - -// Verifies the conversion from zero, pole, gain to filter coefficients for -// bandpass filter. -TEST(CascadedBiquadFilter, BiQuadParamBandPass) { - CascadedBiQuadFilter::BiQuadParam param( - {1.0f, 0.0f}, {1.11022302e-16f, 0.71381051f}, 0.2452372752527856f, true); - CascadedBiQuadFilter::BiQuad filter(param); - const float epsilon = 1e-6f; - EXPECT_NEAR(filter.coefficients.b[0], 0.24523728f, epsilon); - EXPECT_NEAR(filter.coefficients.b[1], 0.f, epsilon); - EXPECT_NEAR(filter.coefficients.b[2], -0.24523728f, epsilon); - EXPECT_NEAR(filter.coefficients.a[0], -2.22044605e-16f, epsilon); - EXPECT_NEAR(filter.coefficients.a[1], 5.09525449e-01f, epsilon); -} - } // namespace webrtc diff --git a/modules/audio_processing/utility/delay_estimator.cc b/modules/audio_processing/utility/delay_estimator.cc index 6868392f6f..6f97b28a77 100644 --- a/modules/audio_processing/utility/delay_estimator.cc +++ b/modules/audio_processing/utility/delay_estimator.cc @@ -270,38 +270,38 @@ static int RobustValidation(const BinaryDelayEstimator* self, } void WebRtc_FreeBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) { - if (self == NULL) { + if (self == nullptr) { return; } free(self->binary_far_history); - self->binary_far_history = NULL; + self->binary_far_history = nullptr; free(self->far_bit_counts); - self->far_bit_counts = NULL; + self->far_bit_counts = nullptr; free(self); } BinaryDelayEstimatorFarend* WebRtc_CreateBinaryDelayEstimatorFarend( int history_size) { - BinaryDelayEstimatorFarend* self = NULL; + BinaryDelayEstimatorFarend* self = nullptr; if (history_size > 1) { // Sanity conditions fulfilled. self = static_cast( malloc(sizeof(BinaryDelayEstimatorFarend))); } - if (self == NULL) { - return NULL; + if (self == nullptr) { + return nullptr; } self->history_size = 0; - self->binary_far_history = NULL; - self->far_bit_counts = NULL; + self->binary_far_history = nullptr; + self->far_bit_counts = nullptr; if (WebRtc_AllocateFarendBufferMemory(self, history_size) == 0) { WebRtc_FreeBinaryDelayEstimatorFarend(self); - self = NULL; + self = nullptr; } return self; } @@ -315,7 +315,8 @@ int WebRtc_AllocateFarendBufferMemory(BinaryDelayEstimatorFarend* self, history_size * sizeof(*self->binary_far_history))); self->far_bit_counts = static_cast(realloc( self->far_bit_counts, history_size * sizeof(*self->far_bit_counts))); - if ((self->binary_far_history == NULL) || (self->far_bit_counts == NULL)) { + if ((self->binary_far_history == nullptr) || + (self->far_bit_counts == nullptr)) { history_size = 0; } // Fill with zeros if we have expanded the buffers. @@ -386,25 +387,25 @@ void WebRtc_AddBinaryFarSpectrum(BinaryDelayEstimatorFarend* handle, } void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self) { - if (self == NULL) { + if (self == nullptr) { return; } free(self->mean_bit_counts); - self->mean_bit_counts = NULL; + self->mean_bit_counts = nullptr; free(self->bit_counts); - self->bit_counts = NULL; + self->bit_counts = nullptr; free(self->binary_near_history); - self->binary_near_history = NULL; + self->binary_near_history = nullptr; free(self->histogram); - self->histogram = NULL; + self->histogram = nullptr; // BinaryDelayEstimator does not have ownership of `farend`, hence we do not // free the memory here. That should be handled separately by the user. - self->farend = NULL; + self->farend = nullptr; free(self); } @@ -412,15 +413,15 @@ void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self) { BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator( BinaryDelayEstimatorFarend* farend, int max_lookahead) { - BinaryDelayEstimator* self = NULL; + BinaryDelayEstimator* self = nullptr; - if ((farend != NULL) && (max_lookahead >= 0)) { + if ((farend != nullptr) && (max_lookahead >= 0)) { // Sanity conditions fulfilled. self = static_cast( malloc(sizeof(BinaryDelayEstimator))); } - if (self == NULL) { - return NULL; + if (self == nullptr) { + return nullptr; } self->farend = farend; @@ -432,15 +433,15 @@ BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator( self->lookahead = max_lookahead; // Allocate memory for spectrum and history buffers. - self->mean_bit_counts = NULL; - self->bit_counts = NULL; - self->histogram = NULL; + self->mean_bit_counts = nullptr; + self->bit_counts = nullptr; + self->histogram = nullptr; self->binary_near_history = static_cast( malloc((max_lookahead + 1) * sizeof(*self->binary_near_history))); - if (self->binary_near_history == NULL || + if (self->binary_near_history == nullptr || WebRtc_AllocateHistoryBufferMemory(self, farend->history_size) == 0) { WebRtc_FreeBinaryDelayEstimator(self); - self = NULL; + self = nullptr; } return self; @@ -465,8 +466,8 @@ int WebRtc_AllocateHistoryBufferMemory(BinaryDelayEstimator* self, self->histogram = static_cast( realloc(self->histogram, (history_size + 1) * sizeof(*self->histogram))); - if ((self->mean_bit_counts == NULL) || (self->bit_counts == NULL) || - (self->histogram == NULL)) { + if ((self->mean_bit_counts == nullptr) || (self->bit_counts == nullptr) || + (self->histogram == nullptr)) { history_size = 0; } // Fill with zeros if we have expanded the buffers. diff --git a/modules/audio_processing/utility/delay_estimator_unittest.cc b/modules/audio_processing/utility/delay_estimator_unittest.cc index 6052612ef3..b026088a90 100644 --- a/modules/audio_processing/utility/delay_estimator_unittest.cc +++ b/modules/audio_processing/utility/delay_estimator_unittest.cc @@ -67,12 +67,12 @@ class DelayEstimatorTest : public ::testing::Test { }; DelayEstimatorTest::DelayEstimatorTest() - : handle_(NULL), - self_(NULL), - farend_handle_(NULL), - farend_self_(NULL), - binary_(NULL), - binary_farend_(NULL), + : handle_(nullptr), + self_(nullptr), + farend_handle_(nullptr), + farend_self_(nullptr), + binary_(nullptr), + binary_farend_(nullptr), spectrum_size_(kSpectrumSize) { // Dummy input data are set with more or less arbitrary non-zero values. memset(far_f_, 1, sizeof(far_f_)); @@ -91,28 +91,28 @@ DelayEstimatorTest::DelayEstimatorTest() void DelayEstimatorTest::SetUp() { farend_handle_ = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, kHistorySize); - ASSERT_TRUE(farend_handle_ != NULL); + ASSERT_TRUE(farend_handle_ != nullptr); farend_self_ = reinterpret_cast(farend_handle_); handle_ = WebRtc_CreateDelayEstimator(farend_handle_, kLookahead); - ASSERT_TRUE(handle_ != NULL); + ASSERT_TRUE(handle_ != nullptr); self_ = reinterpret_cast(handle_); binary_farend_ = WebRtc_CreateBinaryDelayEstimatorFarend(kHistorySize); - ASSERT_TRUE(binary_farend_ != NULL); + ASSERT_TRUE(binary_farend_ != nullptr); binary_ = WebRtc_CreateBinaryDelayEstimator(binary_farend_, kLookahead); - ASSERT_TRUE(binary_ != NULL); + ASSERT_TRUE(binary_ != nullptr); } void DelayEstimatorTest::TearDown() { WebRtc_FreeDelayEstimator(handle_); - handle_ = NULL; - self_ = NULL; + handle_ = nullptr; + self_ = nullptr; WebRtc_FreeDelayEstimatorFarend(farend_handle_); - farend_handle_ = NULL; - farend_self_ = NULL; + farend_handle_ = nullptr; + farend_self_ = nullptr; WebRtc_FreeBinaryDelayEstimator(binary_); - binary_ = NULL; + binary_ = nullptr; WebRtc_FreeBinaryDelayEstimatorFarend(binary_farend_); - binary_farend_ = NULL; + binary_farend_ = nullptr; } void DelayEstimatorTest::Init() { @@ -218,7 +218,7 @@ void DelayEstimatorTest::RunBinarySpectraTest(int near_offset, RunBinarySpectra(binary_, binary2, near_offset, lookahead_offset, offset); } WebRtc_FreeBinaryDelayEstimator(binary2); - binary2 = NULL; + binary2 = nullptr; binary_->robust_validation_enabled = 0; // Reset reference. } @@ -231,29 +231,29 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // create failure. void* handle = farend_handle_; handle = WebRtc_CreateDelayEstimatorFarend(33, kHistorySize); - EXPECT_TRUE(handle == NULL); + EXPECT_TRUE(handle == nullptr); handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, 1); - EXPECT_TRUE(handle == NULL); + EXPECT_TRUE(handle == nullptr); handle = handle_; - handle = WebRtc_CreateDelayEstimator(NULL, kLookahead); - EXPECT_TRUE(handle == NULL); + handle = WebRtc_CreateDelayEstimator(nullptr, kLookahead); + EXPECT_TRUE(handle == nullptr); handle = WebRtc_CreateDelayEstimator(farend_handle_, -1); - EXPECT_TRUE(handle == NULL); + EXPECT_TRUE(handle == nullptr); // WebRtc_InitDelayEstimatorFarend() and WebRtc_InitDelayEstimator() should // return -1 if we have a NULL pointer as `handle`. - EXPECT_EQ(-1, WebRtc_InitDelayEstimatorFarend(NULL)); - EXPECT_EQ(-1, WebRtc_InitDelayEstimator(NULL)); + EXPECT_EQ(-1, WebRtc_InitDelayEstimatorFarend(nullptr)); + EXPECT_EQ(-1, WebRtc_InitDelayEstimator(nullptr)); // WebRtc_AddFarSpectrumFloat() should return -1 if we have: // 1) NULL pointer as `handle`. // 2) NULL pointer as far-end spectrum. // 3) Incorrect spectrum size. - EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(NULL, far_f_, spectrum_size_)); + EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(nullptr, far_f_, spectrum_size_)); // Use `farend_handle_` which is properly created at SetUp(). - EXPECT_EQ(-1, - WebRtc_AddFarSpectrumFloat(farend_handle_, NULL, spectrum_size_)); + EXPECT_EQ( + -1, WebRtc_AddFarSpectrumFloat(farend_handle_, nullptr, spectrum_size_)); EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, spectrum_size_ + 1)); @@ -262,9 +262,9 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // 2) NULL pointer as far-end spectrum. // 3) Incorrect spectrum size. // 4) Too high precision in far-end spectrum (Q-domain > 15). - EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(NULL, far_u16_, spectrum_size_, 0)); - EXPECT_EQ(-1, - WebRtc_AddFarSpectrumFix(farend_handle_, NULL, spectrum_size_, 0)); + EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(nullptr, far_u16_, spectrum_size_, 0)); + EXPECT_EQ( + -1, WebRtc_AddFarSpectrumFix(farend_handle_, nullptr, spectrum_size_, 0)); EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, spectrum_size_ + 1, 0)); EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, @@ -273,11 +273,11 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // WebRtc_set_history_size() should return -1 if: // 1) `handle` is a NULL. // 2) `history_size` <= 1. - EXPECT_EQ(-1, WebRtc_set_history_size(NULL, 1)); + EXPECT_EQ(-1, WebRtc_set_history_size(nullptr, 1)); EXPECT_EQ(-1, WebRtc_set_history_size(handle_, 1)); // WebRtc_history_size() should return -1 if: // 1) NULL pointer input. - EXPECT_EQ(-1, WebRtc_history_size(NULL)); + EXPECT_EQ(-1, WebRtc_history_size(nullptr)); // 2) there is a mismatch between history size. void* tmp_handle = WebRtc_CreateDelayEstimator(farend_handle_, kHistorySize); EXPECT_EQ(0, WebRtc_InitDelayEstimator(tmp_handle)); @@ -295,21 +295,21 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // WebRtc_set_allowed_offset() should return -1 if we have: // 1) NULL pointer as `handle`. // 2) `allowed_offset` < 0. - EXPECT_EQ(-1, WebRtc_set_allowed_offset(NULL, 0)); + EXPECT_EQ(-1, WebRtc_set_allowed_offset(nullptr, 0)); EXPECT_EQ(-1, WebRtc_set_allowed_offset(handle_, -1)); - EXPECT_EQ(-1, WebRtc_get_allowed_offset(NULL)); + EXPECT_EQ(-1, WebRtc_get_allowed_offset(nullptr)); // WebRtc_enable_robust_validation() should return -1 if we have: // 1) NULL pointer as `handle`. // 2) Incorrect `enable` value (not 0 or 1). - EXPECT_EQ(-1, WebRtc_enable_robust_validation(NULL, kEnable[0])); + EXPECT_EQ(-1, WebRtc_enable_robust_validation(nullptr, kEnable[0])); EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, -1)); EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, 2)); // WebRtc_is_robust_validation_enabled() should return -1 if we have NULL // pointer as `handle`. - EXPECT_EQ(-1, WebRtc_is_robust_validation_enabled(NULL)); + EXPECT_EQ(-1, WebRtc_is_robust_validation_enabled(nullptr)); // WebRtc_DelayEstimatorProcessFloat() should return -1 if we have: // 1) NULL pointer as `handle`. @@ -317,11 +317,11 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // 3) Incorrect spectrum size. // 4) Non matching history sizes if multiple delay estimators using the same // far-end reference. - EXPECT_EQ(-1, - WebRtc_DelayEstimatorProcessFloat(NULL, near_f_, spectrum_size_)); + EXPECT_EQ( + -1, WebRtc_DelayEstimatorProcessFloat(nullptr, near_f_, spectrum_size_)); // Use `handle_` which is properly created at SetUp(). - EXPECT_EQ(-1, - WebRtc_DelayEstimatorProcessFloat(handle_, NULL, spectrum_size_)); + EXPECT_EQ( + -1, WebRtc_DelayEstimatorProcessFloat(handle_, nullptr, spectrum_size_)); EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, spectrum_size_ + 1)); // `tmp_handle` is already in a non-matching state. @@ -335,10 +335,10 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { // 4) Too high precision in near-end spectrum (Q-domain > 15). // 5) Non matching history sizes if multiple delay estimators using the same // far-end reference. + EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(nullptr, near_u16_, + spectrum_size_, 0)); EXPECT_EQ( - -1, WebRtc_DelayEstimatorProcessFix(NULL, near_u16_, spectrum_size_, 0)); - EXPECT_EQ(-1, - WebRtc_DelayEstimatorProcessFix(handle_, NULL, spectrum_size_, 0)); + -1, WebRtc_DelayEstimatorProcessFix(handle_, nullptr, spectrum_size_, 0)); EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, spectrum_size_ + 1, 0)); EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, @@ -349,7 +349,7 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { WebRtc_FreeDelayEstimator(tmp_handle); // WebRtc_last_delay() should return -1 if we have a NULL pointer as `handle`. - EXPECT_EQ(-1, WebRtc_last_delay(NULL)); + EXPECT_EQ(-1, WebRtc_last_delay(nullptr)); // Free any local memory if needed. WebRtc_FreeDelayEstimator(handle); @@ -479,7 +479,7 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimatorFarend) { // Make sure we have a non-NULL value at start, so we can detect NULL after // create failure. binary = WebRtc_CreateBinaryDelayEstimatorFarend(1); - EXPECT_TRUE(binary == NULL); + EXPECT_TRUE(binary == nullptr); } TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimator) { @@ -492,10 +492,10 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimator) { // `binary_handle` should be NULL. // Make sure we have a non-NULL value at start, so we can detect NULL after // create failure. - binary_handle = WebRtc_CreateBinaryDelayEstimator(NULL, kLookahead); - EXPECT_TRUE(binary_handle == NULL); + binary_handle = WebRtc_CreateBinaryDelayEstimator(nullptr, kLookahead); + EXPECT_TRUE(binary_handle == nullptr); binary_handle = WebRtc_CreateBinaryDelayEstimator(binary_farend_, -1); - EXPECT_TRUE(binary_handle == NULL); + EXPECT_TRUE(binary_handle == nullptr); } TEST_F(DelayEstimatorTest, MeanEstimatorFix) { @@ -580,9 +580,9 @@ TEST_F(DelayEstimatorTest, AllowedOffsetNoImpactWhenRobustValidationDisabled) { TEST_F(DelayEstimatorTest, VerifyLookaheadAtCreate) { void* farend_handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, kMaxDelay); - ASSERT_TRUE(farend_handle != NULL); + ASSERT_TRUE(farend_handle != nullptr); void* handle = WebRtc_CreateDelayEstimator(farend_handle, kLookahead); - ASSERT_TRUE(handle != NULL); + ASSERT_TRUE(handle != nullptr); EXPECT_EQ(kLookahead, WebRtc_lookahead(handle)); WebRtc_FreeDelayEstimator(handle); WebRtc_FreeDelayEstimatorFarend(farend_handle); diff --git a/modules/audio_processing/utility/delay_estimator_wrapper.cc b/modules/audio_processing/utility/delay_estimator_wrapper.cc index 3b1409cc0b..216066afe0 100644 --- a/modules/audio_processing/utility/delay_estimator_wrapper.cc +++ b/modules/audio_processing/utility/delay_estimator_wrapper.cc @@ -127,21 +127,21 @@ static uint32_t BinarySpectrumFloat(const float* spectrum, void WebRtc_FreeDelayEstimatorFarend(void* handle) { DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; - if (handle == NULL) { + if (handle == nullptr) { return; } free(self->mean_far_spectrum); - self->mean_far_spectrum = NULL; + self->mean_far_spectrum = nullptr; WebRtc_FreeBinaryDelayEstimatorFarend(self->binary_farend); - self->binary_farend = NULL; + self->binary_farend = nullptr; free(self); } void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size) { - DelayEstimatorFarend* self = NULL; + DelayEstimatorFarend* self = nullptr; // Check if the sub band used in the delay estimation is small enough to fit // the binary spectra in a uint32_t. @@ -152,23 +152,23 @@ void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size) { malloc(sizeof(DelayEstimatorFarend))); } - if (self != NULL) { + if (self != nullptr) { int memory_fail = 0; // Allocate memory for the binary far-end spectrum handling. self->binary_farend = WebRtc_CreateBinaryDelayEstimatorFarend(history_size); - memory_fail |= (self->binary_farend == NULL); + memory_fail |= (self->binary_farend == nullptr); // Allocate memory for spectrum buffers. self->mean_far_spectrum = static_cast( malloc(spectrum_size * sizeof(SpectrumType))); - memory_fail |= (self->mean_far_spectrum == NULL); + memory_fail |= (self->mean_far_spectrum == nullptr); self->spectrum_size = spectrum_size; if (memory_fail) { WebRtc_FreeDelayEstimatorFarend(self); - self = NULL; + self = nullptr; } } @@ -178,7 +178,7 @@ void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size) { int WebRtc_InitDelayEstimatorFarend(void* handle) { DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; - if (self == NULL) { + if (self == nullptr) { return -1; } @@ -207,10 +207,10 @@ int WebRtc_AddFarSpectrumFix(void* handle, DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; uint32_t binary_spectrum = 0; - if (self == NULL) { + if (self == nullptr) { return -1; } - if (far_spectrum == NULL) { + if (far_spectrum == nullptr) { // Empty far end spectrum. return -1; } @@ -237,10 +237,10 @@ int WebRtc_AddFarSpectrumFloat(void* handle, DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle; uint32_t binary_spectrum = 0; - if (self == NULL) { + if (self == nullptr) { return -1; } - if (far_spectrum == NULL) { + if (far_spectrum == nullptr) { // Empty far end spectrum. return -1; } @@ -260,45 +260,45 @@ int WebRtc_AddFarSpectrumFloat(void* handle, void WebRtc_FreeDelayEstimator(void* handle) { DelayEstimator* self = (DelayEstimator*)handle; - if (handle == NULL) { + if (handle == nullptr) { return; } free(self->mean_near_spectrum); - self->mean_near_spectrum = NULL; + self->mean_near_spectrum = nullptr; WebRtc_FreeBinaryDelayEstimator(self->binary_handle); - self->binary_handle = NULL; + self->binary_handle = nullptr; free(self); } void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead) { - DelayEstimator* self = NULL; + DelayEstimator* self = nullptr; DelayEstimatorFarend* farend = (DelayEstimatorFarend*)farend_handle; - if (farend_handle != NULL) { + if (farend_handle != nullptr) { self = static_cast(malloc(sizeof(DelayEstimator))); } - if (self != NULL) { + if (self != nullptr) { int memory_fail = 0; // Allocate memory for the farend spectrum handling. self->binary_handle = WebRtc_CreateBinaryDelayEstimator(farend->binary_farend, max_lookahead); - memory_fail |= (self->binary_handle == NULL); + memory_fail |= (self->binary_handle == nullptr); // Allocate memory for spectrum buffers. self->mean_near_spectrum = static_cast( malloc(farend->spectrum_size * sizeof(SpectrumType))); - memory_fail |= (self->mean_near_spectrum == NULL); + memory_fail |= (self->mean_near_spectrum == nullptr); self->spectrum_size = farend->spectrum_size; if (memory_fail) { WebRtc_FreeDelayEstimator(self); - self = NULL; + self = nullptr; } } @@ -308,7 +308,7 @@ void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead) { int WebRtc_InitDelayEstimator(void* handle) { DelayEstimator* self = (DelayEstimator*)handle; - if (self == NULL) { + if (self == nullptr) { return -1; } @@ -333,7 +333,7 @@ int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift) { int WebRtc_set_history_size(void* handle, int history_size) { DelayEstimator* self = static_cast(handle); - if ((self == NULL) || (history_size <= 1)) { + if ((self == nullptr) || (history_size <= 1)) { return -1; } return WebRtc_AllocateHistoryBufferMemory(self->binary_handle, history_size); @@ -342,7 +342,7 @@ int WebRtc_set_history_size(void* handle, int history_size) { int WebRtc_history_size(const void* handle) { const DelayEstimator* self = static_cast(handle); - if (self == NULL) { + if (self == nullptr) { return -1; } if (self->binary_handle->farend->history_size != @@ -375,7 +375,7 @@ int WebRtc_lookahead(void* handle) { int WebRtc_set_allowed_offset(void* handle, int allowed_offset) { DelayEstimator* self = (DelayEstimator*)handle; - if ((self == NULL) || (allowed_offset < 0)) { + if ((self == nullptr) || (allowed_offset < 0)) { return -1; } self->binary_handle->allowed_offset = allowed_offset; @@ -385,7 +385,7 @@ int WebRtc_set_allowed_offset(void* handle, int allowed_offset) { int WebRtc_get_allowed_offset(const void* handle) { const DelayEstimator* self = (const DelayEstimator*)handle; - if (self == NULL) { + if (self == nullptr) { return -1; } return self->binary_handle->allowed_offset; @@ -394,7 +394,7 @@ int WebRtc_get_allowed_offset(const void* handle) { int WebRtc_enable_robust_validation(void* handle, int enable) { DelayEstimator* self = (DelayEstimator*)handle; - if (self == NULL) { + if (self == nullptr) { return -1; } if ((enable < 0) || (enable > 1)) { @@ -408,7 +408,7 @@ int WebRtc_enable_robust_validation(void* handle, int enable) { int WebRtc_is_robust_validation_enabled(const void* handle) { const DelayEstimator* self = (const DelayEstimator*)handle; - if (self == NULL) { + if (self == nullptr) { return -1; } return self->binary_handle->robust_validation_enabled; @@ -421,10 +421,10 @@ int WebRtc_DelayEstimatorProcessFix(void* handle, DelayEstimator* self = (DelayEstimator*)handle; uint32_t binary_spectrum = 0; - if (self == NULL) { + if (self == nullptr) { return -1; } - if (near_spectrum == NULL) { + if (near_spectrum == nullptr) { // Empty near end spectrum. return -1; } @@ -451,10 +451,10 @@ int WebRtc_DelayEstimatorProcessFloat(void* handle, DelayEstimator* self = (DelayEstimator*)handle; uint32_t binary_spectrum = 0; - if (self == NULL) { + if (self == nullptr) { return -1; } - if (near_spectrum == NULL) { + if (near_spectrum == nullptr) { // Empty near end spectrum. return -1; } @@ -473,7 +473,7 @@ int WebRtc_DelayEstimatorProcessFloat(void* handle, int WebRtc_last_delay(void* handle) { DelayEstimator* self = (DelayEstimator*)handle; - if (self == NULL) { + if (self == nullptr) { return -1; } diff --git a/modules/audio_processing/vad/pitch_based_vad_unittest.cc b/modules/audio_processing/vad/pitch_based_vad_unittest.cc index 4a8331a769..3b7b956fa1 100644 --- a/modules/audio_processing/vad/pitch_based_vad_unittest.cc +++ b/modules/audio_processing/vad/pitch_based_vad_unittest.cc @@ -24,22 +24,22 @@ TEST(PitchBasedVadTest, VoicingProbabilityTest) { std::string spectral_peak_file_name = test::ResourcePath("audio_processing/agc/agc_spectral_peak", "dat"); FILE* spectral_peak_file = fopen(spectral_peak_file_name.c_str(), "rb"); - ASSERT_TRUE(spectral_peak_file != NULL); + ASSERT_TRUE(spectral_peak_file != nullptr); std::string pitch_gain_file_name = test::ResourcePath("audio_processing/agc/agc_pitch_gain", "dat"); FILE* pitch_gain_file = fopen(pitch_gain_file_name.c_str(), "rb"); - ASSERT_TRUE(pitch_gain_file != NULL); + ASSERT_TRUE(pitch_gain_file != nullptr); std::string pitch_lag_file_name = test::ResourcePath("audio_processing/agc/agc_pitch_lag", "dat"); FILE* pitch_lag_file = fopen(pitch_lag_file_name.c_str(), "rb"); - ASSERT_TRUE(pitch_lag_file != NULL); + ASSERT_TRUE(pitch_lag_file != nullptr); std::string voicing_prob_file_name = test::ResourcePath("audio_processing/agc/agc_voicing_prob", "dat"); FILE* voicing_prob_file = fopen(voicing_prob_file_name.c_str(), "rb"); - ASSERT_TRUE(voicing_prob_file != NULL); + ASSERT_TRUE(voicing_prob_file != nullptr); PitchBasedVad vad_; diff --git a/modules/audio_processing/vad/pole_zero_filter.cc b/modules/audio_processing/vad/pole_zero_filter.cc index e7a611309c..97688a44cb 100644 --- a/modules/audio_processing/vad/pole_zero_filter.cc +++ b/modules/audio_processing/vad/pole_zero_filter.cc @@ -22,8 +22,8 @@ PoleZeroFilter* PoleZeroFilter::Create(const float* numerator_coefficients, size_t order_denominator) { if (order_numerator > kMaxFilterOrder || order_denominator > kMaxFilterOrder || denominator_coefficients[0] == 0 || - numerator_coefficients == NULL || denominator_coefficients == NULL) - return NULL; + numerator_coefficients == nullptr || denominator_coefficients == nullptr) + return nullptr; return new PoleZeroFilter(numerator_coefficients, order_numerator, denominator_coefficients, order_denominator); } @@ -66,7 +66,7 @@ static float FilterArPast(const T* past, int PoleZeroFilter::Filter(const int16_t* in, size_t num_input_samples, float* output) { - if (in == NULL || output == NULL) + if (in == nullptr || output == nullptr) return -1; // This is the typical case, just a memcpy. const size_t k = std::min(num_input_samples, highest_order_); diff --git a/modules/audio_processing/vad/standalone_vad_unittest.cc b/modules/audio_processing/vad/standalone_vad_unittest.cc index 0fa2ed78b1..139f49a235 100644 --- a/modules/audio_processing/vad/standalone_vad_unittest.cc +++ b/modules/audio_processing/vad/standalone_vad_unittest.cc @@ -66,11 +66,11 @@ TEST(StandaloneVadTest, ActivityDetection) { FILE* pcm_file = fopen(test::ResourcePath("audio_processing/agc/agc_audio", "pcm").c_str(), "rb"); - ASSERT_TRUE(pcm_file != NULL); + ASSERT_TRUE(pcm_file != nullptr); FILE* reference_file = fopen( test::ResourcePath("audio_processing/agc/agc_vad", "dat").c_str(), "rb"); - ASSERT_TRUE(reference_file != NULL); + ASSERT_TRUE(reference_file != nullptr); // Reference activities are prepared with 0 aggressiveness. ASSERT_EQ(0, vad->set_mode(0)); diff --git a/modules/audio_processing/vad/vad_audio_proc_unittest.cc b/modules/audio_processing/vad/vad_audio_proc_unittest.cc index 0afed84c35..9fe3dc6c03 100644 --- a/modules/audio_processing/vad/vad_audio_proc_unittest.cc +++ b/modules/audio_processing/vad/vad_audio_proc_unittest.cc @@ -31,12 +31,12 @@ TEST(AudioProcessingTest, DISABLED_ComputingFirstSpectralPeak) { std::string peak_file_name = test::ResourcePath("audio_processing/agc/agc_spectral_peak", "dat"); FILE* peak_file = fopen(peak_file_name.c_str(), "rb"); - ASSERT_TRUE(peak_file != NULL); + ASSERT_TRUE(peak_file != nullptr); std::string pcm_file_name = test::ResourcePath("audio_processing/agc/agc_audio", "pcm"); FILE* pcm_file = fopen(pcm_file_name.c_str(), "rb"); - ASSERT_TRUE(pcm_file != NULL); + ASSERT_TRUE(pcm_file != nullptr); // Read 10 ms audio in each iteration. const size_t kDataLength = kLength10Ms; diff --git a/modules/audio_processing/vad/vad_circular_buffer.cc b/modules/audio_processing/vad/vad_circular_buffer.cc index 31f14d7f64..e05b0a584f 100644 --- a/modules/audio_processing/vad/vad_circular_buffer.cc +++ b/modules/audio_processing/vad/vad_circular_buffer.cc @@ -31,7 +31,7 @@ void VadCircularBuffer::Reset() { VadCircularBuffer* VadCircularBuffer::Create(int buffer_size) { if (buffer_size <= 0) - return NULL; + return nullptr; return new VadCircularBuffer(buffer_size); } diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 326168679d..f970a33b94 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -79,7 +79,6 @@ rtc_library("alr_detector") { deps = [ "../../../api:field_trials_view", "../../../api/rtc_event_log", - "../../../api/transport:field_trial_based_config", "../../../logging:rtc_event_pacing", "../../../rtc_base:checks", "../../../rtc_base:safe_conversions", diff --git a/modules/congestion_controller/goog_cc/alr_detector_unittest.cc b/modules/congestion_controller/goog_cc/alr_detector_unittest.cc index 57c583dd67..725bd342d6 100644 --- a/modules/congestion_controller/goog_cc/alr_detector_unittest.cc +++ b/modules/congestion_controller/goog_cc/alr_detector_unittest.cc @@ -156,7 +156,7 @@ TEST(AlrDetectorTest, BandwidthEstimateChanges) { } TEST(AlrDetectorTest, ParseControlFieldTrial) { - webrtc::test::ScopedFieldTrials scoped_field_trial( + test::ScopedFieldTrials scoped_field_trial( "WebRTC-ProbingScreenshareBwe/Control/"); std::optional parsed_params = AlrExperimentSettings::CreateFromFieldTrial( @@ -165,7 +165,7 @@ TEST(AlrDetectorTest, ParseControlFieldTrial) { } TEST(AlrDetectorTest, ParseActiveFieldTrial) { - webrtc::test::ScopedFieldTrials scoped_field_trial( + test::ScopedFieldTrials scoped_field_trial( "WebRTC-ProbingScreenshareBwe/1.1,2875,85,20,-20,1/"); std::optional parsed_params = AlrExperimentSettings::CreateFromFieldTrial( @@ -180,7 +180,7 @@ TEST(AlrDetectorTest, ParseActiveFieldTrial) { } TEST(AlrDetectorTest, ParseAlrSpecificFieldTrial) { - webrtc::test::ScopedFieldTrials scoped_field_trial( + test::ScopedFieldTrials scoped_field_trial( "WebRTC-AlrDetectorParameters/" "bw_usage:90%,start:0%,stop:-10%/"); FieldTrialBasedConfig field_trials; diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc b/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc index c93bf29c51..9e22ae8682 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc @@ -58,7 +58,7 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us, if (time_now_us < next_rtp_time_) { return next_rtp_time_; } - RTC_CHECK(packets != NULL); + RTC_CHECK(packets != nullptr); size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_; size_t n_packets = std::max((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u); @@ -137,7 +137,7 @@ void StreamGenerator::SetBitrateBps(int bitrate_bps) { int64_t StreamGenerator::GenerateFrame(int64_t time_now_us, int64_t* next_sequence_number, std::vector* packets) { - RTC_CHECK(packets != NULL); + RTC_CHECK(packets != nullptr); RTC_CHECK(packets->empty()); RTC_CHECK_GT(capacity_, 0); auto it = diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index a50a9b6cc6..f318e85612 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -77,7 +77,7 @@ BandwidthLimitedCause GetBandwidthLimitedCause(LossBasedState loss_based_state, case LossBasedState::kDecreasing: // Probes may not be sent in this state. return BandwidthLimitedCause::kLossLimitedBwe; - case webrtc::LossBasedState::kIncreaseUsingPadding: + case LossBasedState::kIncreaseUsingPadding: // Probes may not be sent in this state. return BandwidthLimitedCause::kLossLimitedBwe; case LossBasedState::kIncreasing: diff --git a/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc b/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc index 81cdad512e..08bd4b3fc4 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bandwidth_estimation.cc @@ -81,7 +81,7 @@ double ExponentialUpdate(TimeDelta window, TimeDelta interval) { return 1.0f - exp(interval / window * -1.0); } -bool IsEnabled(const webrtc::FieldTrialsView& key_value_config, +bool IsEnabled(const FieldTrialsView& key_value_config, absl::string_view name) { return absl::StartsWith(key_value_config.Lookup(name), "Enabled"); } diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc index 25978593ca..bd0a81b80c 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -299,10 +299,9 @@ void LossBasedBweV2::UpdateBandwidthEstimate( } if (config_->bound_best_candidate && bounded_bandwidth_estimate < best_candidate.loss_limited_bandwidth) { - RTC_LOG(LS_INFO) << "Resetting loss based BWE to " - << bounded_bandwidth_estimate.kbps() - << "due to loss. Avg loss rate: " - << average_reported_loss_ratio_; + // If network is lossy, cap the best estimate by the instant upper bound, + // e.g. 450kbps if loss rate is 50%. + // Otherwise, cap the estimate by the delay-based estimate or max_bitrate. current_best_estimate_.loss_limited_bandwidth = bounded_bandwidth_estimate; current_best_estimate_.inherent_loss = 0; } else { @@ -402,9 +401,9 @@ std::optional LossBasedBweV2::CreateConfig( const FieldTrialsView* key_value_config) { FieldTrialParameter enabled("Enabled", true); FieldTrialParameter bandwidth_rampup_upper_bound_factor( - "BwRampupUpperBoundFactor", 1000000.0); + "BwRampupUpperBoundFactor", 1.5); FieldTrialParameter bandwidth_rampup_upper_bound_factor_in_hold( - "BwRampupUpperBoundInHoldFactor", 1000000.0); + "BwRampupUpperBoundInHoldFactor", 1.2); FieldTrialParameter bandwidth_rampup_hold_threshold( "BwRampupUpperBoundHoldThreshold", 1.3); FieldTrialParameter rampup_acceleration_max_factor( @@ -420,11 +419,11 @@ std::optional LossBasedBweV2::CreateConfig( FieldTrialParameter inherent_loss_lower_bound( "InherentLossLowerBound", 1.0e-3); FieldTrialParameter loss_threshold_of_high_bandwidth_preference( - "LossThresholdOfHighBandwidthPreference", 0.15); + "LossThresholdOfHighBandwidthPreference", 0.2); FieldTrialParameter bandwidth_preference_smoothing_factor( "BandwidthPreferenceSmoothingFactor", 0.002); FieldTrialParameter inherent_loss_upper_bound_bandwidth_balance( - "InherentLossUpperBoundBwBalance", DataRate::KilobitsPerSec(75.0)); + "InherentLossUpperBoundBwBalance", DataRate::KilobitsPerSec(100.0)); FieldTrialParameter inherent_loss_upper_bound_offset( "InherentLossUpperBoundOffset", 0.05); FieldTrialParameter initial_inherent_loss_estimate( @@ -439,13 +438,13 @@ std::optional LossBasedBweV2::CreateConfig( "UpperBoundCandidateInAlr", false); FieldTrialParameter observation_duration_lower_bound( "ObservationDurationLowerBound", TimeDelta::Millis(250)); - FieldTrialParameter observation_window_size("ObservationWindowSize", 20); + FieldTrialParameter observation_window_size("ObservationWindowSize", 15); FieldTrialParameter sending_rate_smoothing_factor( "SendingRateSmoothingFactor", 0.0); FieldTrialParameter instant_upper_bound_temporal_weight_factor( "InstantUpperBoundTemporalWeightFactor", 0.9); FieldTrialParameter instant_upper_bound_bandwidth_balance( - "InstantUpperBoundBwBalance", DataRate::KilobitsPerSec(75.0)); + "InstantUpperBoundBwBalance", DataRate::KilobitsPerSec(100.0)); FieldTrialParameter instant_upper_bound_loss_offset( "InstantUpperBoundLossOffset", 0.05); FieldTrialParameter temporal_weight_factor("TemporalWeightFactor", @@ -460,17 +459,15 @@ std::optional LossBasedBweV2::CreateConfig( "NotIncreaseIfInherentLossLessThanAverageLoss", true); FieldTrialParameter not_use_acked_rate_in_alr("NotUseAckedRateInAlr", true); - FieldTrialParameter use_in_start_phase("UseInStartPhase", false); + FieldTrialParameter use_in_start_phase("UseInStartPhase", true); FieldTrialParameter min_num_observations("MinNumObservations", 3); FieldTrialParameter lower_bound_by_acked_rate_factor( - "LowerBoundByAckedRateFactor", 0.0); - FieldTrialParameter hold_duration_factor("HoldDurationFactor", 0.0); - FieldTrialParameter use_byte_loss_rate("UseByteLossRate", false); + "LowerBoundByAckedRateFactor", 1.0); + FieldTrialParameter hold_duration_factor("HoldDurationFactor", 2.0); + FieldTrialParameter use_byte_loss_rate("UseByteLossRate", true); FieldTrialParameter padding_duration("PaddingDuration", - TimeDelta::Zero()); - FieldTrialParameter bound_best_candidate("BoundBestCandidate", false); - FieldTrialParameter pace_at_loss_based_estimate( - "PaceAtLossBasedEstimate", false); + TimeDelta::Seconds(2)); + FieldTrialParameter bound_best_candidate("BoundBestCandidate", true); FieldTrialParameter median_sending_rate_factor( "MedianSendingRateFactor", 2.0); if (key_value_config) { @@ -513,7 +510,6 @@ std::optional LossBasedBweV2::CreateConfig( &use_byte_loss_rate, &padding_duration, &bound_best_candidate, - &pace_at_loss_based_estimate, &median_sending_rate_factor}, key_value_config->Lookup("WebRTC-Bwe-LossBasedBweV2")); } @@ -579,7 +575,6 @@ std::optional LossBasedBweV2::CreateConfig( config.use_byte_loss_rate = use_byte_loss_rate.Get(); config.padding_duration = padding_duration.Get(); config.bound_best_candidate = bound_best_candidate.Get(); - config.pace_at_loss_based_estimate = pace_at_loss_based_estimate.Get(); config.median_sending_rate_factor = median_sending_rate_factor.Get(); return config; } @@ -858,6 +853,12 @@ double LossBasedBweV2::CalculateAverageReportedByteLossRatio() const { // the loss rate might not be due to a spike. return lost_bytes / total_bytes; } + + if (total_bytes == max_bytes_received + min_bytes_received) { + // It could happen if the observation window was 2. + return lost_bytes / total_bytes; + } + return (lost_bytes - min_lost_bytes - max_lost_bytes) / (total_bytes - max_bytes_received - min_bytes_received); } @@ -1216,11 +1217,6 @@ bool LossBasedBweV2::CanKeepIncreasingState(DataRate estimate) const { last_padding_info_.padding_rate < estimate; } -bool LossBasedBweV2::PaceAtLossBasedEstimate() const { - return config_->pace_at_loss_based_estimate && - loss_based_result_.state != LossBasedState::kDelayBasedEstimate; -} - DataRate LossBasedBweV2::GetMedianSendingRate() const { std::vector sending_rates; for (const Observation& observation : observations_) { diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h index 5102f463f9..b088420f19 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -75,7 +75,6 @@ class LossBasedBweV2 { void UpdateBandwidthEstimate(ArrayView packet_results, DataRate delay_based_estimate, bool in_alr); - bool PaceAtLossBasedEstimate() const; // For unit testing only. void SetBandwidthEstimate(DataRate bandwidth_estimate); diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc b/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc index f900473db8..e308ff8730 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc @@ -27,7 +27,7 @@ namespace webrtc { namespace { -using ::webrtc::test::ExplicitKeyValueConfig; +using test::ExplicitKeyValueConfig; constexpr TimeDelta kObservationDurationLowerBound = TimeDelta::Millis(250); constexpr TimeDelta kDelayedIncreaseWindow = TimeDelta::Millis(300); @@ -642,17 +642,12 @@ TEST_F(LossBasedBweV2Test, delay_based_estimate); } -TEST_F(LossBasedBweV2Test, - IncreaseByMaxIncreaseFactorAfterLossBasedBweBacksOff) { - ExplicitKeyValueConfig key_value_config(ShortObservationConfig( - "CandidateFactors:1.2|1|0.5," - "InstantUpperBoundBwBalance:10000kbps," - "MaxIncreaseFactor:1.5,NotIncreaseIfInherentLossLessThanAverageLoss:" - "false")); +TEST_F(LossBasedBweV2Test, IncreaseByHoldFactorAfterLossBasedBweBacksOff) { + ExplicitKeyValueConfig key_value_config(ShortObservationConfig("")); LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - DataRate acked_rate = DataRate::KilobitsPerSec(300); + DataRate acked_rate = DataRate::KilobitsPerSec(100); loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.SetAcknowledgedBitrate(acked_rate); @@ -668,20 +663,23 @@ TEST_F(LossBasedBweV2Test, loss_based_bandwidth_estimator.GetLossBasedResult(); // Network recovers after loss. - std::vector enough_feedback_2 = - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.SetAcknowledgedBitrate( - DataRate::KilobitsPerSec(600)); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate(enough_feedback_2, - delay_based_estimate, - /*in_alr=*/false); + int feedback_count = 2; + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kIncreaseUsingPadding) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_count), + delay_based_estimate, + /*in_alr=*/false); + feedback_count++; + } LossBasedBweV2::Result result_after_recovery = loss_based_bandwidth_estimator.GetLossBasedResult(); + // BwRampupUpperBoundInHoldFactor is 1.2. EXPECT_EQ(result_after_recovery.bandwidth_estimate, - result_at_loss.bandwidth_estimate * 1.5); + result_at_loss.bandwidth_estimate * 1.2); } TEST_F(LossBasedBweV2Test, @@ -803,7 +801,7 @@ TEST_F(LossBasedBweV2Test, loss_based_bandwidth_estimator.SetAcknowledgedBitrate(estimate_1 * 0.9); int feedback_count = 1; - while (feedback_count < 5 && result.state != LossBasedState::kIncreasing) { + while (result.state != LossBasedState::kIncreaseUsingPadding) { loss_based_bandwidth_estimator.UpdateBandwidthEstimate( CreatePacketResultsWithReceivedPackets( /*first_packet_timestamp=*/Timestamp::Zero() + @@ -812,7 +810,7 @@ TEST_F(LossBasedBweV2Test, /*in_alr=*/false); result = loss_based_bandwidth_estimator.GetLossBasedResult(); } - ASSERT_EQ(result.state, LossBasedState::kIncreasing); + ASSERT_EQ(result.state, LossBasedState::kIncreaseUsingPadding); // The estimate is capped by acked_bitrate * BwRampupUpperBoundFactor. EXPECT_EQ(result.bandwidth_estimate, estimate_1 * 0.9 * 1.2); @@ -863,7 +861,7 @@ TEST_F(LossBasedBweV2Test, EnsureIncreaseEvenIfAckedBitrateBound) { loss_based_bandwidth_estimator.SetAcknowledgedBitrate(estimate_1 / 2); int feedback_count = 1; - while (feedback_count < 5 && result.state != LossBasedState::kIncreasing) { + while (result.state != LossBasedState::kIncreaseUsingPadding) { loss_based_bandwidth_estimator.UpdateBandwidthEstimate( CreatePacketResultsWithReceivedPackets( /*first_packet_timestamp=*/Timestamp::Zero() + @@ -873,7 +871,7 @@ TEST_F(LossBasedBweV2Test, EnsureIncreaseEvenIfAckedBitrateBound) { result = loss_based_bandwidth_estimator.GetLossBasedResult(); } - ASSERT_EQ(result.state, LossBasedState::kIncreasing); + ASSERT_EQ(result.state, LossBasedState::kIncreaseUsingPadding); // The estimate increases by 1kbps. EXPECT_EQ(result.bandwidth_estimate, estimate_1 + DataRate::BitsPerSec(1)); } @@ -1238,7 +1236,7 @@ TEST_F(LossBasedBweV2Test, HasDecreaseStateBecauseOfUpperBound) { loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(500)); loss_based_bandwidth_estimator.SetAcknowledgedBitrate( - DataRate::KilobitsPerSec(500)); + DataRate::KilobitsPerSec(100)); std::vector enough_feedback_10p_loss_1 = CreatePacketResultsWith10pPacketLossRate( @@ -1287,19 +1285,19 @@ TEST_F(LossBasedBweV2Test, HasIncreaseStateBecauseOfLowerBound) { std::vector enough_feedback_50p_loss_2 = CreatePacketResultsWith50pPacketLossRate( /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); + kObservationDurationLowerBound * 2); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_50p_loss_2, /*delay_based_estimate=*/DataRate::PlusInfinity(), /*in_alr=*/false); // Verify that the instant lower bound increases the estimate, and state is - // updated to kIncreasing. + // updated to kIncreaseUsingPadding. EXPECT_EQ( loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, DataRate::KilobitsPerSec(200) * 10); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kIncreasing); + LossBasedState::kIncreaseUsingPadding); } TEST_F(LossBasedBweV2Test, @@ -1365,8 +1363,7 @@ TEST_F(LossBasedBweV2Test, HasDelayBasedStateIfLossBasedBweIsMax) { // Eventually the estimator recovers to delay based state. int feedback_count = 2; - while (feedback_count < 5 && - result.state != LossBasedState::kDelayBasedEstimate) { + while (result.state != LossBasedState::kDelayBasedEstimate) { loss_based_bandwidth_estimator.UpdateBandwidthEstimate( /*feedback = */ CreatePacketResultsWithReceivedPackets( /*first_packet_timestamp=*/Timestamp::Zero() + @@ -1394,13 +1391,17 @@ TEST_F(LossBasedBweV2Test, IncreaseUsingPaddingStateIfFieldTrial) { /*in_alr=*/false); ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, LossBasedState::kDecreasing); - - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); + int feedback_count = 1; + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kIncreaseUsingPadding) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_count), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + feedback_count++; + } EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, LossBasedState::kIncreaseUsingPadding); } @@ -1546,131 +1547,6 @@ TEST_F(LossBasedBweV2Test, DecreaseAfterPadding) { EXPECT_EQ(start_decreasing - estimate_increased, TimeDelta::Seconds(1)); } -TEST_F(LossBasedBweV2Test, IncreaseEstimateIfNotHold) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HoldDurationFactor:0")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(2500)); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWith50pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kDecreasing); - DataRate estimate = - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; - - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kIncreasing); - EXPECT_GT( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate); -} - -TEST_F(LossBasedBweV2Test, IncreaseEstimateAfterHoldDuration) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HoldDurationFactor:10")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(2500)); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWith50pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kDecreasing); - DataRate estimate = - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; - - // During the hold duration, e.g. first 300ms, the estimate cannot increase. - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kDecreasing); - EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate); - - // After the hold duration, the estimate can increase. - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * 2), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kIncreasing); - EXPECT_GE( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate); - - // Get another 50p packet loss. - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWith50pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * 3), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kDecreasing); - DataRate estimate_at_hold = - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; - - // In the hold duration, e.g. next 3s, the estimate cannot increase above the - // hold rate. Get some lost packets to get lower estimate than the HOLD rate. - for (int i = 4; i <= 6; ++i) { - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * i), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kDecreasing); - EXPECT_LT( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate_at_hold); - } - - int feedback_id = 7; - while (loss_based_bandwidth_estimator.GetLossBasedResult().state != - LossBasedState::kIncreasing) { - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * feedback_id), - /*delay_based_estimate=*/DataRate::PlusInfinity(), - /*in_alr=*/false); - if (loss_based_bandwidth_estimator.GetLossBasedResult().state == - LossBasedState::kDecreasing) { - // In the hold duration, the estimate can not go higher than estimate at - // hold. - EXPECT_LE(loss_based_bandwidth_estimator.GetLossBasedResult() - .bandwidth_estimate, - estimate_at_hold); - } else if (loss_based_bandwidth_estimator.GetLossBasedResult().state == - LossBasedState::kIncreasing) { - // After the hold duration, the estimate can increase again. - EXPECT_GT(loss_based_bandwidth_estimator.GetLossBasedResult() - .bandwidth_estimate, - estimate_at_hold); - } - feedback_id++; - } -} TEST_F(LossBasedBweV2Test, HoldRateNotLowerThanAckedRate) { ExplicitKeyValueConfig key_value_config(ShortObservationConfig( @@ -1749,8 +1625,7 @@ TEST_F(LossBasedBweV2Test, EstimateNotLowerThanAckedRate) { } TEST_F(LossBasedBweV2Test, EndHoldDurationIfDelayBasedEstimateWorks) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HoldDurationFactor:3")); + ExplicitKeyValueConfig key_value_config(ShortObservationConfig("")); LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(2500)); @@ -1770,6 +1645,12 @@ TEST_F(LossBasedBweV2Test, EndHoldDurationIfDelayBasedEstimateWorks) { kObservationDurationLowerBound), /*delay_based_estimate=*/estimate + DataRate::KilobitsPerSec(10), /*in_alr=*/false); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * 2), + /*delay_based_estimate=*/estimate + DataRate::KilobitsPerSec(10), + /*in_alr=*/false); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, LossBasedState::kDelayBasedEstimate); EXPECT_EQ( @@ -1795,7 +1676,7 @@ TEST_F(LossBasedBweV2Test, UseByteLossRate) { // The estimate is bounded by the instant upper bound due to high loss. EXPECT_LT( loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(150)); + DataRate::KilobitsPerSec(160)); } TEST_F(LossBasedBweV2Test, UseByteLossRateIgnoreLossSpike) { @@ -1881,42 +1762,6 @@ TEST_F(LossBasedBweV2Test, UseByteLossRateDoesNotIgnoreLossSpikeOnSendBurst) { kDelayBasedEstimate); } -TEST_F(LossBasedBweV2Test, PaceAtLossBasedEstimate) { - ExplicitKeyValueConfig key_value_config(ShortObservationConfig( - "PaceAtLossBasedEstimate:true,PaddingDuration:1000ms")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(1000)); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero()), - /*delay_based_estimate=*/DataRate::KilobitsPerSec(1000), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kDelayBasedEstimate); - EXPECT_FALSE(loss_based_bandwidth_estimator.PaceAtLossBasedEstimate()); - - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound), - /*delay_based_estimate=*/DataRate::KilobitsPerSec(1000), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kDecreasing); - EXPECT_TRUE(loss_based_bandwidth_estimator.PaceAtLossBasedEstimate()); - - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * 2), - /*delay_based_estimate=*/DataRate::KilobitsPerSec(1000), - /*in_alr=*/false); - EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kIncreaseUsingPadding); - EXPECT_TRUE(loss_based_bandwidth_estimator.PaceAtLossBasedEstimate()); -} - TEST_F(LossBasedBweV2Test, EstimateDoesNotBackOffDueToPacketReorderingBetweenFeedback) { ExplicitKeyValueConfig key_value_config(ShortObservationConfig("")); diff --git a/modules/congestion_controller/goog_cc/probe_controller.cc b/modules/congestion_controller/goog_cc/probe_controller.cc index bf8253ded5..0847c19734 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.cc +++ b/modules/congestion_controller/goog_cc/probe_controller.cc @@ -426,8 +426,7 @@ std::vector ProbeController::RequestProbe( return std::vector(); } -void ProbeController::SetNetworkStateEstimate( - webrtc::NetworkStateEstimate estimate) { +void ProbeController::SetNetworkStateEstimate(NetworkStateEstimate estimate) { network_estimate_ = estimate; } diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc index 7fe27bf910..c42e0152a7 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -693,9 +693,4 @@ bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV2ReadyForUse() return loss_based_bandwidth_estimator_v2_->IsReady(); } -bool SendSideBandwidthEstimation::PaceAtLossBasedEstimate() const { - return LossBasedBandwidthEstimatorV2ReadyForUse() && - loss_based_bandwidth_estimator_v2_->PaceAtLossBasedEstimate(); -} - } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h index 9a56a280ab..72123a7308 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h @@ -128,7 +128,6 @@ class SendSideBandwidthEstimation { BandwidthUsage delay_detector_state, std::optional probe_bitrate, bool in_alr); - bool PaceAtLossBasedEstimate() const; private: friend class GoogCcStatePrinter; diff --git a/modules/congestion_controller/rtp/BUILD.gn b/modules/congestion_controller/rtp/BUILD.gn index 302c3dee01..f9e230ebb9 100644 --- a/modules/congestion_controller/rtp/BUILD.gn +++ b/modules/congestion_controller/rtp/BUILD.gn @@ -55,7 +55,6 @@ rtc_library("transport_feedback") { "../../../rtc_base/synchronization:mutex", "../../../rtc_base/system:no_unique_address", "../../../system_wrappers", - "../../../system_wrappers:field_trial", "../../rtp_rtcp:ntp_time_util", "../../rtp_rtcp:rtp_rtcp_format", "//third_party/abseil-cpp/absl/algorithm:container", diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter.cc b/modules/congestion_controller/rtp/transport_feedback_adapter.cc index 53a12f1e67..3b38b6dfa6 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter.cc +++ b/modules/congestion_controller/rtp/transport_feedback_adapter.cc @@ -116,6 +116,8 @@ void TransportFeedbackAdapter::AddPacket(const RtpPacketToSend& packet_to_send, feedback.sent.pacing_info = pacing_info; feedback.ssrc = packet_to_send.Ssrc(); feedback.rtp_sequence_number = packet_to_send.SequenceNumber(); + feedback.is_retransmission = + packet_to_send.packet_type() == RtpPacketMediaType::kRetransmission; while (!history_.empty() && creation_time - history_.begin()->second.creation_time > @@ -223,14 +225,18 @@ TransportFeedbackAdapter::ProcessTransportFeedback( ++failed_lookups; return; } - if (delta_since_base.IsFinite()) { - packet_feedback->receive_time = - current_offset_ + delta_since_base.RoundDownTo(TimeDelta::Millis(1)); - } + if (packet_feedback->network_route == network_route_) { PacketResult result; result.sent_packet = packet_feedback->sent; - result.receive_time = packet_feedback->receive_time; + if (delta_since_base.IsFinite()) { + result.receive_time = current_offset_ + delta_since_base.RoundDownTo( + TimeDelta::Millis(1)); + } + result.rtp_packet_info = { + .ssrc = packet_feedback->ssrc, + .rtp_sequence_number = packet_feedback->rtp_sequence_number, + .is_retransmission = packet_feedback->is_retransmission}; packet_result_vector.push_back(result); } else { ++ignored; @@ -301,6 +307,10 @@ TransportFeedbackAdapter::ProcessCongestionControlFeedback( supports_ecn &= packet_info.ecn != EcnMarking::kNotEct; } result.ecn = packet_info.ecn; + result.rtp_packet_info = { + .ssrc = packet_feedback->ssrc, + .rtp_sequence_number = packet_feedback->rtp_sequence_number, + .is_retransmission = packet_feedback->is_retransmission}; packet_result_vector.push_back(result); } diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter.h b/modules/congestion_controller/rtp/transport_feedback_adapter.h index 7f6e9427ad..10e06cae93 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter.h +++ b/modules/congestion_controller/rtp/transport_feedback_adapter.h @@ -35,16 +35,13 @@ struct PacketFeedback { // Time corresponding to when this object was created. Timestamp creation_time = Timestamp::MinusInfinity(); SentPacket sent; - // Time corresponding to when the packet was received. Timestamped with the - // receiver's clock. For unreceived packet, Timestamp::PlusInfinity() is - // used. - Timestamp receive_time = Timestamp::PlusInfinity(); // The network route that this packet is associated with. NetworkRoute network_route; uint32_t ssrc = 0; uint16_t rtp_sequence_number = 0; + bool is_retransmission = false; }; class InFlightBytesTracker { diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc b/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc index 2ceceaea5d..813edcc84a 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc +++ b/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc @@ -112,6 +112,11 @@ void ComparePacketFeedbackVectors(const std::vector& truth, EXPECT_EQ(truth[i].packet_size, input[i].sent_packet.size); EXPECT_EQ(truth[i].pacing_info, input[i].sent_packet.pacing_info); EXPECT_EQ(truth[i].is_audio, input[i].sent_packet.audio); + EXPECT_EQ(input[i].rtp_packet_info->rtp_sequence_number, + truth[i].rtp_sequence_number); + EXPECT_EQ(input[i].rtp_packet_info->ssrc, truth[i].ssrc); + EXPECT_EQ(input[i].rtp_packet_info->is_retransmission, + truth[i].media_type == RtpPacketMediaType::kRetransmission); } } diff --git a/modules/congestion_controller/rtp/transport_feedback_demuxer.cc b/modules/congestion_controller/rtp/transport_feedback_demuxer.cc index 1c29108ffb..4b4f921395 100644 --- a/modules/congestion_controller/rtp/transport_feedback_demuxer.cc +++ b/modules/congestion_controller/rtp/transport_feedback_demuxer.cc @@ -9,22 +9,17 @@ */ #include "modules/congestion_controller/rtp/transport_feedback_demuxer.h" -#include #include #include #include #include "absl/algorithm/container.h" #include "api/sequence_checker.h" -#include "api/units/time_delta.h" +#include "api/transport/network_types.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "rtc_base/checks.h" namespace webrtc { -namespace { -static const size_t kMaxPacketsInHistory = 5000; -} TransportFeedbackDemuxer::TransportFeedbackDemuxer() { // In case the construction thread is different from where the registration @@ -53,40 +48,20 @@ void TransportFeedbackDemuxer::DeRegisterStreamFeedbackObserver( observers_.erase(it); } -void TransportFeedbackDemuxer::AddPacket(const RtpPacketSendInfo& packet_info) { - RTC_DCHECK_RUN_ON(&observer_checker_); - - StreamFeedbackObserver::StreamPacketInfo info; - info.ssrc = packet_info.media_ssrc; - info.rtp_sequence_number = packet_info.rtp_sequence_number; - info.received = false; - info.is_retransmission = - packet_info.packet_type == RtpPacketMediaType::kRetransmission; - history_.insert( - {seq_num_unwrapper_.Unwrap(packet_info.transport_sequence_number), info}); - - while (history_.size() > kMaxPacketsInHistory) { - history_.erase(history_.begin()); - } -} - void TransportFeedbackDemuxer::OnTransportFeedback( - const rtcp::TransportFeedback& feedback) { + const TransportPacketsFeedback& feedback) { RTC_DCHECK_RUN_ON(&observer_checker_); std::vector stream_feedbacks; - feedback.ForAllPackets( - [&](uint16_t sequence_number, TimeDelta delta_since_base) { - RTC_DCHECK_RUN_ON(&observer_checker_); - auto it = history_.find(seq_num_unwrapper_.PeekUnwrap(sequence_number)); - if (it != history_.end()) { - auto packet_info = it->second; - packet_info.received = delta_since_base.IsFinite(); - stream_feedbacks.push_back(std::move(packet_info)); - if (delta_since_base.IsFinite()) - history_.erase(it); - } - }); + for (const PacketResult& packet : feedback.packet_feedbacks) { + if (packet.rtp_packet_info.has_value()) { + stream_feedbacks.push_back( + {.received = packet.receive_time.IsFinite(), + .ssrc = packet.rtp_packet_info->ssrc, + .rtp_sequence_number = packet.rtp_packet_info->rtp_sequence_number, + .is_retransmission = packet.rtp_packet_info->is_retransmission}); + } + } for (auto& observer : observers_) { std::vector selected_feedback; diff --git a/modules/congestion_controller/rtp/transport_feedback_demuxer.h b/modules/congestion_controller/rtp/transport_feedback_demuxer.h index 80661176d3..8999f3c301 100644 --- a/modules/congestion_controller/rtp/transport_feedback_demuxer.h +++ b/modules/congestion_controller/rtp/transport_feedback_demuxer.h @@ -11,13 +11,12 @@ #define MODULES_CONGESTION_CONTROLLER_RTP_TRANSPORT_FEEDBACK_DEMUXER_H_ #include -#include #include #include #include "api/sequence_checker.h" +#include "api/transport/network_types.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" @@ -42,16 +41,10 @@ class TransportFeedbackDemuxer final : public StreamFeedbackProvider { StreamFeedbackObserver* observer) override; void DeRegisterStreamFeedbackObserver( StreamFeedbackObserver* observer) override; - void AddPacket(const RtpPacketSendInfo& packet_info); - void OnTransportFeedback(const rtcp::TransportFeedback& feedback); + void OnTransportFeedback(const TransportPacketsFeedback& feedback); private: RTC_NO_UNIQUE_ADDRESS SequenceChecker observer_checker_; - RtpSequenceNumberUnwrapper seq_num_unwrapper_ - RTC_GUARDED_BY(&observer_checker_); - std::map history_ - RTC_GUARDED_BY(&observer_checker_); - // Maps a set of ssrcs to corresponding observer. Vectors are used rather than // set/map to ensure that the processing order is consistent independently of // the randomized ssrcs. diff --git a/modules/congestion_controller/rtp/transport_feedback_demuxer_unittest.cc b/modules/congestion_controller/rtp/transport_feedback_demuxer_unittest.cc index 79f25a9879..f37f43817d 100644 --- a/modules/congestion_controller/rtp/transport_feedback_demuxer_unittest.cc +++ b/modules/congestion_controller/rtp/transport_feedback_demuxer_unittest.cc @@ -12,9 +12,9 @@ #include #include +#include "api/transport/network_types.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "test/gmock.h" #include "test/gtest.h" @@ -28,7 +28,7 @@ using PacketInfo = StreamFeedbackObserver::StreamPacketInfo; static constexpr uint32_t kSsrc = 8492; -class MockStreamFeedbackObserver : public webrtc::StreamFeedbackObserver { +class MockStreamFeedbackObserver : public StreamFeedbackObserver { public: MOCK_METHOD(void, OnPacketFeedbackVector, @@ -36,16 +36,19 @@ class MockStreamFeedbackObserver : public webrtc::StreamFeedbackObserver { (override)); }; -RtpPacketSendInfo CreatePacket(uint32_t ssrc, - uint16_t rtp_sequence_number, - int64_t transport_sequence_number, - bool is_retransmission) { - RtpPacketSendInfo res; - res.media_ssrc = ssrc; - res.transport_sequence_number = transport_sequence_number; - res.rtp_sequence_number = rtp_sequence_number; - res.packet_type = is_retransmission ? RtpPacketMediaType::kRetransmission - : RtpPacketMediaType::kVideo; +PacketResult CreatePacket(uint32_t ssrc, + uint16_t rtp_sequence_number, + bool received, + bool is_retransmission) { + PacketResult res; + res.rtp_packet_info = { + .ssrc = ssrc, + .rtp_sequence_number = rtp_sequence_number, + .is_retransmission = is_retransmission, + }; + res.receive_time = + received ? Timestamp::Seconds(123) : Timestamp::PlusInfinity(); + return res; } } // namespace @@ -55,49 +58,38 @@ TEST(TransportFeedbackDemuxerTest, ObserverSanity) { MockStreamFeedbackObserver mock; demuxer.RegisterStreamFeedbackObserver({kSsrc}, &mock); - const uint16_t kRtpStartSeq = 55; - const int64_t kTransportStartSeq = 1; - demuxer.AddPacket(CreatePacket(kSsrc, kRtpStartSeq, kTransportStartSeq, - /*is_retransmission=*/false)); - demuxer.AddPacket(CreatePacket(kSsrc, kRtpStartSeq + 1, - kTransportStartSeq + 1, - /*is_retransmission=*/false)); - demuxer.AddPacket(CreatePacket(kSsrc, kRtpStartSeq + 2, - kTransportStartSeq + 2, - /*is_retransmission=*/true)); - - rtcp::TransportFeedback feedback; - feedback.SetBase(kTransportStartSeq, Timestamp::Millis(1)); - ASSERT_TRUE( - feedback.AddReceivedPacket(kTransportStartSeq, Timestamp::Millis(1))); - // Drop middle packet. - ASSERT_TRUE( - feedback.AddReceivedPacket(kTransportStartSeq + 2, Timestamp::Millis(3))); - - EXPECT_CALL( - mock, OnPacketFeedbackVector(ElementsAre( - AllOf(Field(&PacketInfo::received, true), - Field(&PacketInfo::ssrc, kSsrc), - Field(&PacketInfo::rtp_sequence_number, kRtpStartSeq), - Field(&PacketInfo::is_retransmission, false)), - AllOf(Field(&PacketInfo::received, false), - Field(&PacketInfo::ssrc, kSsrc), - Field(&PacketInfo::rtp_sequence_number, kRtpStartSeq + 1), - Field(&PacketInfo::is_retransmission, false)), - AllOf(Field(&PacketInfo::received, true), - Field(&PacketInfo::ssrc, kSsrc), - Field(&PacketInfo::rtp_sequence_number, kRtpStartSeq + 2), - Field(&PacketInfo::is_retransmission, true))))); + TransportPacketsFeedback feedback; + feedback.packet_feedbacks = {CreatePacket(kSsrc, /*rtp_sequence_number=*/55, + /*received=*/true, + /*is_retransmission=*/false), + CreatePacket(kSsrc, /*rtp_sequence_number=*/56, + /*received=*/false, + /*is_retransmission=*/false), + CreatePacket(kSsrc, /*rtp_sequence_number=*/57, + /*received=*/true, + /*is_retransmission=*/true)}; + EXPECT_CALL(mock, OnPacketFeedbackVector(ElementsAre( + AllOf(Field(&PacketInfo::received, true), + Field(&PacketInfo::ssrc, kSsrc), + Field(&PacketInfo::rtp_sequence_number, 55), + Field(&PacketInfo::is_retransmission, false)), + AllOf(Field(&PacketInfo::received, false), + Field(&PacketInfo::ssrc, kSsrc), + Field(&PacketInfo::rtp_sequence_number, 56), + Field(&PacketInfo::is_retransmission, false)), + AllOf(Field(&PacketInfo::received, true), + Field(&PacketInfo::ssrc, kSsrc), + Field(&PacketInfo::rtp_sequence_number, 57), + Field(&PacketInfo::is_retransmission, true))))); demuxer.OnTransportFeedback(feedback); demuxer.DeRegisterStreamFeedbackObserver(&mock); - demuxer.AddPacket( - CreatePacket(kSsrc, kRtpStartSeq + 3, kTransportStartSeq + 3, false)); - rtcp::TransportFeedback second_feedback; - second_feedback.SetBase(kTransportStartSeq + 3, Timestamp::Millis(4)); - ASSERT_TRUE(second_feedback.AddReceivedPacket(kTransportStartSeq + 3, - Timestamp::Millis(4))); + TransportPacketsFeedback second_feedback; + second_feedback.packet_feedbacks = { + CreatePacket(kSsrc, /*rtp_sequence_number=*/58, + /*received=*/true, + /*is_retransmission=*/false)}; EXPECT_CALL(mock, OnPacketFeedbackVector).Times(0); demuxer.OnTransportFeedback(second_feedback); diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 4b004c6527..a49c24fe46 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -66,7 +66,7 @@ if (rtc_include_tests) { ":screen_drawer", "../../api:array_view", "../../rtc_base:base64", - "../../system_wrappers", + "../../rtc_base:threading", "../../test:test_support", ] sources += [ @@ -158,12 +158,9 @@ if (rtc_include_tests) { "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:random", - "../../rtc_base:timeutils", - - # TODO(bugs.webrtc.org/9987): Remove this dep on rtc_base:rtc_base once - # rtc_base:threading is fully defined. "../../rtc_base:task_queue_for_test", "../../rtc_base:threading", + "../../rtc_base:timeutils", "../../system_wrappers", "../../test:test_support", ] @@ -173,6 +170,7 @@ if (rtc_include_tests) { "win/cursor_unittest.cc", "win/cursor_unittest_resources.h", "win/cursor_unittest_resources.rc", + "win/full_screen_win_application_handler_unittest.cc", "win/screen_capture_utils_unittest.cc", "win/screen_capturer_win_directx_unittest.cc", "win/test_support/test_window.cc", @@ -235,7 +233,7 @@ if (rtc_include_tests) { "../../api:scoped_refptr", "../../rtc_base:checks", "../../rtc_base:logging", - "../../system_wrappers", + "../../rtc_base:threading", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -527,6 +525,7 @@ rtc_library("desktop_capture") { "shcore.lib", ] deps += [ + "../../rtc_base:threading", "../../rtc_base:win32", "../../rtc_base/containers:flat_map", "../../rtc_base/win:create_direct3d_device", @@ -595,6 +594,7 @@ rtc_library("desktop_capture") { libs += [ "dwmapi.lib" ] deps += [ "../../rtc_base:rtc_event", + "../../rtc_base:threading", "../../rtc_base/win:hstring", ] } diff --git a/modules/desktop_capture/cropping_window_capturer.cc b/modules/desktop_capture/cropping_window_capturer.cc index 5e0faaade9..d1cc1c8313 100644 --- a/modules/desktop_capture/cropping_window_capturer.cc +++ b/modules/desktop_capture/cropping_window_capturer.cc @@ -22,7 +22,7 @@ namespace webrtc { CroppingWindowCapturer::CroppingWindowCapturer( const DesktopCaptureOptions& options) : options_(options), - callback_(NULL), + callback_(nullptr), window_capturer_(DesktopCapturer::CreateRawWindowCapturer(options)), selected_window_(kNullWindowId), excluded_window_(kNullWindowId) {} diff --git a/modules/desktop_capture/desktop_region_unittest.cc b/modules/desktop_capture/desktop_region_unittest.cc index b8bd78e990..0cd45e9c6b 100644 --- a/modules/desktop_capture/desktop_region_unittest.cc +++ b/modules/desktop_capture/desktop_region_unittest.cc @@ -47,7 +47,7 @@ void CompareRegion(const DesktopRegion& region, // Verify that regions are empty when created. TEST(DesktopRegionTest, Empty) { DesktopRegion r; - CompareRegion(r, NULL, 0); + CompareRegion(r, nullptr, 0); } // Verify that empty rectangles are ignored. @@ -55,7 +55,7 @@ TEST(DesktopRegionTest, AddEmpty) { DesktopRegion r; DesktopRect rect = DesktopRect::MakeXYWH(1, 2, 0, 0); r.AddRect(rect); - CompareRegion(r, NULL, 0); + CompareRegion(r, nullptr, 0); } // Verify that regions with a single rectangles are handled properly. diff --git a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc index 7228063401..76340ced41 100644 --- a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc +++ b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc @@ -73,6 +73,7 @@ void BaseCapturerPipeWire::OnScreenCastRequestResult(RequestResponse result, // then it'll set it to the right value again soon enough. capturer_failed_ = false; if (result != RequestResponse::kSuccess || + !options_.screencast_stream() || !options_.screencast_stream()->StartScreenCastStream( stream_node_id, fd, options_.get_width(), options_.get_height(), options_.prefer_cursor_embedded(), diff --git a/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc b/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc index d9c7635c1d..064b98fa15 100644 --- a/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc +++ b/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc @@ -69,7 +69,7 @@ MouseCursorMonitorX11::MouseCursorMonitorX11( const DesktopCaptureOptions& options, Window window) : x_display_(options.x_display()), - callback_(NULL), + callback_(nullptr), mode_(SHAPE_AND_POSITION), window_(window), have_xfixes_(false), @@ -231,10 +231,10 @@ MouseCursorMonitor* MouseCursorMonitorX11::CreateForWindow( const DesktopCaptureOptions& options, WindowId window) { if (!options.x_display()) - return NULL; + return nullptr; window = GetTopLevelWindow(options.x_display()->display(), window); if (window == None) - return NULL; + return nullptr; return new MouseCursorMonitorX11(options, window); } @@ -242,7 +242,7 @@ MouseCursorMonitor* MouseCursorMonitorX11::CreateForScreen( const DesktopCaptureOptions& options, ScreenId screen) { if (!options.x_display()) - return NULL; + return nullptr; return new MouseCursorMonitorX11( options, DefaultRootWindow(options.x_display()->display())); } diff --git a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc index 0702c755a1..0384a0373b 100644 --- a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc +++ b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc @@ -67,8 +67,8 @@ bool ScreenCapturerX11::Init(const DesktopCaptureOptions& options) { return false; } - gc_ = XCreateGC(display(), root_window_, 0, NULL); - if (gc_ == NULL) { + gc_ = XCreateGC(display(), root_window_, 0, nullptr); + if (gc_ == nullptr) { RTC_LOG(LS_ERROR) << "Unable to get graphics context"; DeinitXlib(); return false; @@ -133,7 +133,7 @@ void ScreenCapturerX11::InitXDamage() { } // Create an XFixes server-side region to collate damage into. - damage_region_ = XFixesCreateRegion(display(), 0, 0); + damage_region_ = XFixesCreateRegion(display(), nullptr, 0); if (!damage_region_) { XDamageDestroy(display(), damage_handle_); RTC_LOG(LS_ERROR) << "Unable to create XFixes region."; diff --git a/modules/desktop_capture/linux/x11/shared_x_display.cc b/modules/desktop_capture/linux/x11/shared_x_display.cc index aee9183c53..60101b9aa4 100644 --- a/modules/desktop_capture/linux/x11/shared_x_display.cc +++ b/modules/desktop_capture/linux/x11/shared_x_display.cc @@ -34,7 +34,7 @@ SharedXDisplay::~SharedXDisplay() { scoped_refptr SharedXDisplay::Create( absl::string_view display_name) { Display* display = XOpenDisplay( - display_name.empty() ? NULL : std::string(display_name).c_str()); + display_name.empty() ? nullptr : std::string(display_name).c_str()); if (!display) { RTC_LOG(LS_ERROR) << "Unable to open display"; return nullptr; diff --git a/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc b/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc index e0b334dab1..d62a014ae8 100644 --- a/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc +++ b/modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc @@ -164,10 +164,14 @@ void XServerPixelBuffer::Release() { void XServerPixelBuffer::ReleaseSharedMemorySegment() { if (!shm_segment_info_) return; + if (xshm_attached_) { + XShmDetach(display_, shm_segment_info_); + xshm_attached_ = false; + } if (shm_segment_info_->shmaddr != nullptr) shmdt(shm_segment_info_->shmaddr); if (shm_segment_info_->shmid != -1) - shmctl(shm_segment_info_->shmid, IPC_RMID, 0); + shmctl(shm_segment_info_->shmid, IPC_RMID, nullptr); delete shm_segment_info_; shm_segment_info_ = nullptr; } @@ -211,30 +215,29 @@ void XServerPixelBuffer::InitShm(const XWindowAttributes& attributes) { return; } - bool using_shm = false; shm_segment_info_ = new XShmSegmentInfo; shm_segment_info_->shmid = -1; shm_segment_info_->shmaddr = nullptr; shm_segment_info_->readOnly = False; x_shm_image_ = XShmCreateImage(display_, default_visual, default_depth, - ZPixmap, 0, shm_segment_info_, + ZPixmap, nullptr, shm_segment_info_, window_rect_.width(), window_rect_.height()); if (x_shm_image_) { shm_segment_info_->shmid = shmget(IPC_PRIVATE, x_shm_image_->bytes_per_line * x_shm_image_->height, IPC_CREAT | 0600); if (shm_segment_info_->shmid != -1) { - void* shmat_result = shmat(shm_segment_info_->shmid, 0, 0); + void* shmat_result = shmat(shm_segment_info_->shmid, nullptr, 0); if (shmat_result != reinterpret_cast(-1)) { shm_segment_info_->shmaddr = reinterpret_cast(shmat_result); x_shm_image_->data = shm_segment_info_->shmaddr; XErrorTrap error_trap(display_); - using_shm = XShmAttach(display_, shm_segment_info_); + xshm_attached_ = XShmAttach(display_, shm_segment_info_); XSync(display_, False); if (error_trap.GetLastErrorAndDisable() != 0) - using_shm = false; - if (using_shm) { + xshm_attached_ = false; + if (xshm_attached_) { RTC_LOG(LS_VERBOSE) << "Using X shared memory segment " << shm_segment_info_->shmid; } @@ -245,7 +248,7 @@ void XServerPixelBuffer::InitShm(const XWindowAttributes& attributes) { } } - if (!using_shm) { + if (!xshm_attached_) { RTC_LOG(LS_WARNING) << "Not using shared memory. Performance may be degraded."; ReleaseSharedMemorySegment(); @@ -255,7 +258,7 @@ void XServerPixelBuffer::InitShm(const XWindowAttributes& attributes) { if (have_pixmaps) have_pixmaps = InitPixmaps(default_depth); - shmctl(shm_segment_info_->shmid, IPC_RMID, 0); + shmctl(shm_segment_info_->shmid, IPC_RMID, nullptr); shm_segment_info_->shmid = -1; RTC_LOG(LS_VERBOSE) << "Using X shared memory extension v" << major << "." @@ -292,7 +295,7 @@ bool XServerPixelBuffer::InitPixmaps(int depth) { if (error_trap.GetLastErrorAndDisable() != 0) { XFreePixmap(display_, shm_pixmap_); shm_pixmap_ = 0; - shm_gc_ = 0; // See shm_pixmap_ comment above. + shm_gc_ = nullptr; // See shm_pixmap_ comment above. return false; } } diff --git a/modules/desktop_capture/linux/x11/x_server_pixel_buffer.h b/modules/desktop_capture/linux/x11/x_server_pixel_buffer.h index 38af3a3e76..1ccf8af971 100644 --- a/modules/desktop_capture/linux/x11/x_server_pixel_buffer.h +++ b/modules/desktop_capture/linux/x11/x_server_pixel_buffer.h @@ -80,6 +80,7 @@ class XServerPixelBuffer { XImage* x_shm_image_ = nullptr; Pixmap shm_pixmap_ = 0; GC shm_gc_ = nullptr; + bool xshm_attached_ = false; bool xshm_get_image_succeeded_ = false; std::vector icc_profile_; }; diff --git a/modules/desktop_capture/mac/sck_picker_handle.mm b/modules/desktop_capture/mac/sck_picker_handle.mm index c1b4db19f6..dd5391f3f9 100644 --- a/modules/desktop_capture/mac/sck_picker_handle.mm +++ b/modules/desktop_capture/mac/sck_picker_handle.mm @@ -29,10 +29,7 @@ class API_AVAILABLE(macos(14.0)) SckPickerProxy { return g_picker; } - SckPickerProxy() : thread_checker_(SequenceChecker::kDetached) {} - - bool AtCapacity() const { - RTC_DCHECK_RUN_ON(&thread_checker_); + bool AtCapacityLocked() const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_) { return handle_count_ == kMaximumStreamCount; } @@ -42,8 +39,8 @@ bool AtCapacity() const { ABSL_MUST_USE_RESULT std::optional AcquireSourceId() { - RTC_DCHECK_RUN_ON(&thread_checker_); - if (AtCapacity()) { + MutexLock lock(&mutex_); + if (AtCapacityLocked()) { return std::nullopt; } if (handle_count_ == 0) { @@ -58,25 +55,26 @@ bool AtCapacity() const { } void RelinquishSourceId(DesktopCapturer::SourceId source) { - RTC_DCHECK_RUN_ON(&thread_checker_); + MutexLock lock(&mutex_); handle_count_ -= 1; if (handle_count_ > 0) { return; } - // Detach now in case the next user (possibly after a long time) uses a - // different thread. - thread_checker_.Detach(); GetPicker().active = NO; } private: - webrtc::SequenceChecker thread_checker_; + // SckPickerProxy is a process-wide singleton. ScreenCapturerSck and + // SckPickerHandle are largely single-threaded but may be used on different + // threads. For instance some clients use a capturer on one thread for + // enumeration and on another for frame capture. Since all those capturers + // share the same SckPickerProxy instance, it must be thread-safe. + Mutex mutex_; // 100 is an arbitrary number that seems high enough to never get reached, // while still providing a reasonably low upper bound. static constexpr size_t kMaximumStreamCount = 100; - size_t handle_count_ RTC_GUARDED_BY(thread_checker_) = 0; - DesktopCapturer::SourceId unique_source_id_ RTC_GUARDED_BY(thread_checker_) = - 0; + size_t handle_count_ RTC_GUARDED_BY(mutex_) = 0; + DesktopCapturer::SourceId unique_source_id_ RTC_GUARDED_BY(mutex_) = 0; }; class API_AVAILABLE(macos(14.0)) SckPickerHandle @@ -90,7 +88,10 @@ class API_AVAILABLE(macos(14.0)) SckPickerHandle return std::unique_ptr(new SckPickerHandle(proxy, *id)); } - ~SckPickerHandle() { proxy_->RelinquishSourceId(source_); } + ~SckPickerHandle() { + RTC_DCHECK_RUN_ON(&thread_checker_); + proxy_->RelinquishSourceId(source_); + } SCContentSharingPicker* GetPicker() const override { return proxy_->GetPicker(); @@ -100,8 +101,11 @@ class API_AVAILABLE(macos(14.0)) SckPickerHandle private: SckPickerHandle(SckPickerProxy* proxy, DesktopCapturer::SourceId source) - : proxy_(proxy), source_(source) {} + : proxy_(proxy), source_(source) { + RTC_DCHECK_RUN_ON(&thread_checker_); + } + webrtc::SequenceChecker thread_checker_; SckPickerProxy* const proxy_; const DesktopCapturer::SourceId source_; }; diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm index d6e3c2eeee..49c923e56b 100644 --- a/modules/desktop_capture/mac/screen_capturer_sck.mm +++ b/modules/desktop_capture/mac/screen_capturer_sck.mm @@ -72,6 +72,8 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final void CaptureFrame() override; bool GetSourceList(SourceList* sources) override; bool SelectSource(SourceId id) override; + // Creates the SckPickerHandle if needed and not already done. + void EnsurePickerHandle(); // Prep for implementing DelegatedSourceListController interface, for now used // by Start(). Triggers SCContentSharingPicker. Runs on the caller's thread. void EnsureVisible(); @@ -218,15 +220,6 @@ friend void AbslStringify(Sink& sink, : api_checker_(SequenceChecker::kDetached), capture_options_(options), picker_modes_(modes) { - if (capture_options_.allow_sck_system_picker()) { - picker_handle_ = CreateSckPickerHandle(); - } - RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this - << " created. allow_sck_system_picker=" - << capture_options_.allow_sck_system_picker() << ", source=" - << (picker_handle_ ? picker_handle_->Source() : -1) - << ", modes=" - << StringifiableSCContentSharingPickerMode{.modes_ = modes}; helper_ = [[SckHelper alloc] initWithCapturer:this]; } @@ -322,9 +315,25 @@ friend void AbslStringify(Sink& sink, } } +void ScreenCapturerSck::EnsurePickerHandle() { + RTC_DCHECK_RUN_ON(&api_checker_); + if (!picker_handle_ && capture_options_.allow_sck_system_picker()) { + picker_handle_ = CreateSckPickerHandle(); + RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this + << " Created picker handle. allow_sck_system_picker=" + << capture_options_.allow_sck_system_picker() + << ", source=" + << (picker_handle_ ? picker_handle_->Source() : -1) + << ", modes=" + << StringifiableSCContentSharingPickerMode{ + .modes_ = picker_modes_}; + } +} + void ScreenCapturerSck::EnsureVisible() { RTC_DCHECK_RUN_ON(&api_checker_); RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << "."; + EnsurePickerHandle(); if (picker_handle_) { if (!picker_handle_registered_) { picker_handle_registered_ = true; @@ -433,15 +442,14 @@ friend void AbslStringify(Sink& sink, bool ScreenCapturerSck::GetSourceList(SourceList* sources) { RTC_DCHECK_RUN_ON(&api_checker_); sources->clear(); - if (capture_options_.allow_sck_system_picker() && picker_handle_) { + EnsurePickerHandle(); + if (picker_handle_) { sources->push_back({picker_handle_->Source(), std::string()}); } return true; } bool ScreenCapturerSck::SelectSource(SourceId id) { - RTC_DCHECK_RUN_ON(&api_checker_); - if (capture_options_.allow_sck_system_picker()) { return true; } diff --git a/modules/desktop_capture/screen_capturer_fuchsia.cc b/modules/desktop_capture/screen_capturer_fuchsia.cc index 7294290ef8..5fb9e39058 100644 --- a/modules/desktop_capture/screen_capturer_fuchsia.cc +++ b/modules/desktop_capture/screen_capturer_fuchsia.cc @@ -387,7 +387,7 @@ void ScreenCapturerFuchsia::SetupBuffers() { const zx::vmo& virt_mem = buffer_collection_info_.buffers()[buffer_index].vmo(); virtual_memory_mapped_addrs_[buffer_index] = nullptr; - auto status = zx::vmar::root_self()->map( + status = zx::vmar::root_self()->map( ZX_VM_PERM_READ, /*vmar_offset*/ 0, virt_mem, /*vmo_offset*/ 0, virt_mem_bytes, reinterpret_cast( diff --git a/modules/desktop_capture/screen_capturer_unittest.cc b/modules/desktop_capture/screen_capturer_unittest.cc index 4654000a82..0176314551 100644 --- a/modules/desktop_capture/screen_capturer_unittest.cc +++ b/modules/desktop_capture/screen_capturer_unittest.cc @@ -101,7 +101,7 @@ ACTION_P(SaveUniquePtrArg, dest) { #define MAYBE_GetScreenListAndSelectScreen GetScreenListAndSelectScreen #endif TEST_F(ScreenCapturerTest, MAYBE_GetScreenListAndSelectScreen) { - webrtc::DesktopCapturer::SourceList screens; + DesktopCapturer::SourceList screens; EXPECT_TRUE(capturer_->GetSourceList(&screens)); for (const auto& screen : screens) { EXPECT_TRUE(capturer_->SelectSource(screen.id)); @@ -138,7 +138,7 @@ TEST_F(ScreenCapturerTest, MAYBE_Capture) { EXPECT_GT(frame->size().height(), 0); EXPECT_GE(frame->stride(), frame->size().width() * DesktopFrame::kBytesPerPixel); - EXPECT_TRUE(frame->shared_memory() == NULL); + EXPECT_TRUE(frame->shared_memory() == nullptr); // Verify that the region contains whole screen. EXPECT_FALSE(frame->updated_region().is_empty()); diff --git a/modules/desktop_capture/screen_drawer_linux.cc b/modules/desktop_capture/screen_drawer_linux.cc index 55b9570d9c..5a04d37cde 100644 --- a/modules/desktop_capture/screen_drawer_linux.cc +++ b/modules/desktop_capture/screen_drawer_linux.cc @@ -22,7 +22,7 @@ #include "modules/desktop_capture/screen_drawer.h" #include "modules/desktop_capture/screen_drawer_lock_posix.h" #include "rtc_base/checks.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" namespace webrtc { @@ -97,7 +97,7 @@ ScreenDrawerLinux::ScreenDrawerLinux() { colormap_ = DefaultColormap(display_->display(), screen_num_); BringToFront(); // Wait for window animations. - SleepMs(200); + Thread::SleepMs(200); } ScreenDrawerLinux::~ScreenDrawerLinux() { @@ -134,7 +134,7 @@ void ScreenDrawerLinux::Clear() { // TODO(zijiehe): Find the right signal from X11 to indicate the finish of all // pending paintings. void ScreenDrawerLinux::WaitForPendingDraws() { - SleepMs(50); + Thread::SleepMs(50); } bool ScreenDrawerLinux::MayDrawIncompleteShapes() { diff --git a/modules/desktop_capture/screen_drawer_unittest.cc b/modules/desktop_capture/screen_drawer_unittest.cc index f674355eb0..b832b1752c 100644 --- a/modules/desktop_capture/screen_drawer_unittest.cc +++ b/modules/desktop_capture/screen_drawer_unittest.cc @@ -20,8 +20,8 @@ #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" #include "rtc_base/random.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/sleep.h" #include "test/gtest.h" #if defined(WEBRTC_POSIX) @@ -54,7 +54,7 @@ void TestScreenDrawerLock( created_->store(true); // Wait for the main thread to get the signal of created_. while (!ready_.load()) { - SleepMs(1); + Thread::SleepMs(1); } // At this point, main thread should begin to create a second lock. Though // it's still possible the second lock won't be created before the @@ -66,7 +66,7 @@ void TestScreenDrawerLock( // But we need to ensure at least 100 ms has been passed before unlocking // `lock`. while (TimeMillis() - current_ms < kLockDurationMs) { - SleepMs(kLockDurationMs - (TimeMillis() - current_ms)); + Thread::SleepMs(kLockDurationMs - (TimeMillis() - current_ms)); } } @@ -84,7 +84,7 @@ void TestScreenDrawerLock( // lock. See // https://chromium-review.googlesource.com/c/607688/13/webrtc/modules/desktop_capture/screen_drawer_unittest.cc while (!created.load()) { - SleepMs(1); + Thread::SleepMs(1); } const int64_t start_ms = TimeMillis(); @@ -130,11 +130,11 @@ TEST(ScreenDrawerTest, DISABLED_DrawRectangles) { random.Rand(), random.Rand())); if (i == 50) { - SleepMs(10000); + Thread::SleepMs(10000); } } - SleepMs(10000); + Thread::SleepMs(10000); } #if defined(THREAD_SANITIZER) // bugs.webrtc.org/10019 diff --git a/modules/desktop_capture/screen_drawer_win.cc b/modules/desktop_capture/screen_drawer_win.cc index 7cf634fe89..76c6081a4d 100644 --- a/modules/desktop_capture/screen_drawer_win.cc +++ b/modules/desktop_capture/screen_drawer_win.cc @@ -13,7 +13,7 @@ #include #include "modules/desktop_capture/screen_drawer.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" namespace webrtc { @@ -40,7 +40,7 @@ ScreenDrawerLockWin::ScreenDrawerLockWin() { if (mutex_) { CloseHandle(mutex_); } - SleepMs(1000); + Thread::SleepMs(1000); } } } @@ -152,7 +152,7 @@ void ScreenDrawerWin::Clear() { // paintings. void ScreenDrawerWin::WaitForPendingDraws() { BringToFront(); - SleepMs(50); + Thread::SleepMs(50); } bool ScreenDrawerWin::MayDrawIncompleteShapes() { diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.cc b/modules/desktop_capture/win/dxgi_duplicator_controller.cc index bee0ba72f2..24d8ad18f0 100644 --- a/modules/desktop_capture/win/dxgi_duplicator_controller.cc +++ b/modules/desktop_capture/win/dxgi_duplicator_controller.cc @@ -20,8 +20,8 @@ #include "modules/desktop_capture/win/screen_capture_utils.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/sleep.h" namespace webrtc { @@ -531,7 +531,7 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context, // Sleep `ms_per_frame` before attempting to capture the next frame to // ensure the video adapter has time to update the screen. - webrtc::SleepMs(ms_per_frame); + Thread::SleepMs(ms_per_frame); } // When capturing multiple monitors, we need to update the captured region to // prevent flickering by re-setting context. See diff --git a/modules/desktop_capture/win/full_screen_win_application_handler.cc b/modules/desktop_capture/win/full_screen_win_application_handler.cc index 88ab8f617e..fa15b3e7e0 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler.cc +++ b/modules/desktop_capture/win/full_screen_win_application_handler.cc @@ -38,23 +38,27 @@ bool CheckWindowClassName(HWND window, const wchar_t* class_name) { WCHAR buffer[kMaxClassNameLength]; const int length = ::GetClassNameW(window, buffer, kMaxClassNameLength); - if (length <= 0) + if (length <= 0) { return false; + } - if (static_cast(length) != classNameLength) + if (static_cast(length) != classNameLength) { return false; + } return wcsncmp(buffer, class_name, classNameLength) == 0; } std::string WindowText(HWND window) { size_t len = ::GetWindowTextLength(window); - if (len == 0) + if (len == 0) { return std::string(); + } std::vector buffer(len + 1, 0); size_t copied = ::GetWindowTextW(window, buffer.data(), buffer.size()); - if (copied == 0) + if (copied == 0) { return std::string(); + } return webrtc::ToUtf8(buffer.data(), copied); } @@ -66,8 +70,9 @@ DWORD WindowProcessId(HWND window) { std::wstring FileNameFromPath(const std::wstring& path) { auto found = path.rfind(L"\\"); - if (found == std::string::npos) + if (found == std::string::npos) { return path; + } return path.substr(found + 1); } @@ -88,111 +93,101 @@ DesktopCapturer::SourceList GetProcessWindows( }); return result; } +} // namespace -class FullScreenPowerPointHandler : public FullScreenApplicationHandler { - public: - explicit FullScreenPowerPointHandler(DesktopCapturer::SourceId sourceId) - : FullScreenApplicationHandler(sourceId) {} - - ~FullScreenPowerPointHandler() override {} +FullScreenPowerPointHandler::FullScreenPowerPointHandler( + DesktopCapturer::SourceId sourceId) + : FullScreenApplicationHandler(sourceId) {} - DesktopCapturer::SourceId FindFullScreenWindow( - const DesktopCapturer::SourceList& window_list, - int64_t timestamp) const override { - if (!UseHeuristicFullscreenPowerPointWindows()) { - return 0; - } +DesktopCapturer::SourceId FullScreenPowerPointHandler::FindFullScreenWindow( + const DesktopCapturer::SourceList& window_list, + int64_t timestamp) const { + if (!UseHeuristicFullscreenPowerPointWindows() || window_list.empty()) { + return 0; + } - if (window_list.empty()) - return 0; + HWND original_window = reinterpret_cast(GetSourceId()); + if (GetWindowType(original_window) != WindowType::kEditor) { + return 0; + } - HWND original_window = reinterpret_cast(GetSourceId()); - if (GetWindowType(original_window) != WindowType::kEditor) - return 0; + DesktopCapturer::SourceList powerpoint_windows = GetProcessWindows( + window_list, WindowProcessId(original_window), original_window); - DesktopCapturer::SourceList powerpoint_windows = GetProcessWindows( - window_list, WindowProcessId(original_window), original_window); + // No relevant windows with the same process id as the `original_window` were + // found. + if (powerpoint_windows.empty()) { + return 0; + } - // No relevant window with the same process id as the `original_window` was - // found. - if (powerpoint_windows.empty()) - return 0; + const std::string original_document_title = + GetDocumentTitleFromEditor(original_window); + for (const auto& source : powerpoint_windows) { + HWND window = reinterpret_cast(source.id); - const std::string original_document_title = - GetDocumentTitleFromEditor(original_window); - for (const auto& source : powerpoint_windows) { - HWND window = reinterpret_cast(source.id); - - // Looking for fullscreen slide show window for the corresponding editor - // document - if (GetWindowType(window) == WindowType::kSlideShow && - GetDocumentTitleFromSlideShow(window) == original_document_title) { - return source.id; - } + // Looking for fullscreen slide show window for the corresponding editor + // document. + if (GetWindowType(window) == WindowType::kSlideShow && + GetDocumentTitleFromSlideShow(window) == original_document_title) { + return source.id; } - return 0; } + return 0; +} - private: - enum class WindowType { kEditor, kSlideShow, kOther }; - - WindowType GetWindowType(HWND window) const { - if (IsEditorWindow(window)) - return WindowType::kEditor; - else if (IsSlideShowWindow(window)) - return WindowType::kSlideShow; - else - return WindowType::kOther; +FullScreenPowerPointHandler::WindowType +FullScreenPowerPointHandler::GetWindowType(HWND window) const { + if (IsEditorWindow(window)) { + return WindowType::kEditor; + } else if (IsSlideShowWindow(window)) { + return WindowType::kSlideShow; } - constexpr static char kDocumentTitleSeparator = '-'; + return WindowType::kOther; +} - // This function extracts the title from the editor. It needs to be - // updated everytime PowerPoint changes its editor title format. Currently, it - // supports editor title in the format "Window - Title - PowerPoint". - std::string GetDocumentTitleFromEditor(HWND window) const { - std::string title = WindowText(window); - return std::string( - absl::StripAsciiWhitespace(absl::string_view(title).substr( - 0, title.rfind(kDocumentTitleSeparator)))); - } +constexpr static char kDocumentTitleSeparator = '-'; - // This function extracts the title from the slideshow when PowerPoint goes - // fullscreen. This function needs to be updated whenever PowerPoint changes - // its title format. Currently, it supports Fullscreen titles of the format - // "PowerPoint Slide Show - [Window - Title]" or "PowerPoint Slide Show - - // Window - Title". - std::string GetDocumentTitleFromSlideShow(HWND window) const { - std::string title = WindowText(window); - auto position = title.find(kDocumentTitleSeparator); - if (position != std::string::npos) { - title = std::string(absl::StripAsciiWhitespace( - absl::string_view(title).substr(position + 1, std::wstring::npos))); - } - - auto left_bracket_pos = title.find("["); - auto right_bracket_pos = title.rfind("]"); - if (left_bracket_pos == std::string::npos || - right_bracket_pos == std::string::npos || - right_bracket_pos <= left_bracket_pos) { - return title; - } +std::string FullScreenPowerPointHandler::GetDocumentTitleFromEditor( + HWND window) const { + std::string title = WindowText(window); + return std::string(absl::StripAsciiWhitespace(absl::string_view(title).substr( + 0, title.rfind(kDocumentTitleSeparator)))); +} - return std::string(absl::StripAsciiWhitespace(title.substr( - left_bracket_pos + 1, right_bracket_pos - left_bracket_pos - 1))); +std::string FullScreenPowerPointHandler::GetDocumentTitleFromSlideShow( + HWND window) const { + std::string title = WindowText(window); + size_t position = title.find(kDocumentTitleSeparator); + if (position != std::string::npos) { + title = absl::StripAsciiWhitespace( + absl::string_view(title).substr(position + 1, std::wstring::npos)); } - bool IsEditorWindow(HWND window) const { - return CheckWindowClassName(window, L"PPTFrameClass"); + size_t left_bracket_pos = title.find("["); + size_t right_bracket_pos = title.rfind("]"); + if (left_bracket_pos == std::string::npos || + right_bracket_pos == std::string::npos || + right_bracket_pos <= left_bracket_pos) { + return title; } - bool IsSlideShowWindow(HWND window) const { - const LONG style = ::GetWindowLong(window, GWL_STYLE); - const bool min_box = WS_MINIMIZEBOX & style; - const bool max_box = WS_MAXIMIZEBOX & style; - return !min_box && !max_box; - } -}; + return std::string(absl::StripAsciiWhitespace(title.substr( + left_bracket_pos + 1, right_bracket_pos - left_bracket_pos - 1))); +} + +bool FullScreenPowerPointHandler::IsEditorWindow(HWND window) const { + return CheckWindowClassName(window, L"PPTFrameClass"); +} + +bool FullScreenPowerPointHandler::IsSlideShowWindow(HWND window) const { + // TODO(https://crbug.com/409473386): Change this to use GetWindowLongPtr + // instead as recommended in the MS Windows API. + // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptra + const bool has_minimize_or_maximize_buttons = + ::GetWindowLong(window, GWL_STYLE) & (WS_MINIMIZEBOX | WS_MAXIMIZEBOX); + return !has_minimize_or_maximize_buttons; +} class OpenOfficeApplicationHandler : public FullScreenApplicationHandler { public: @@ -202,8 +197,9 @@ class OpenOfficeApplicationHandler : public FullScreenApplicationHandler { DesktopCapturer::SourceId FindFullScreenWindow( const DesktopCapturer::SourceList& window_list, int64_t timestamp) const override { - if (window_list.empty()) + if (window_list.empty()) { return 0; + } DWORD process_id = WindowProcessId(reinterpret_cast(GetSourceId())); @@ -235,8 +231,9 @@ class OpenOfficeApplicationHandler : public FullScreenApplicationHandler { return IsSlideShowWindow(x); }); - if (slide_show_window == app_windows.end()) + if (slide_show_window == app_windows.end()) { return 0; + } return slide_show_window->id; } @@ -266,22 +263,22 @@ std::wstring GetPathByWindowId(HWND window_id) { DWORD process_id = WindowProcessId(window_id); HANDLE process = ::OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); - if (process == NULL) + if (process == NULL) { return L""; + } DWORD path_len = MAX_PATH; WCHAR path[MAX_PATH]; std::wstring result; - if (::QueryFullProcessImageNameW(process, 0, path, &path_len)) + if (::QueryFullProcessImageNameW(process, 0, path, &path_len)) { result = std::wstring(path, path_len); - else + } else { RTC_LOG_GLE(LS_ERROR) << "QueryFullProcessImageName failed."; + } ::CloseHandle(process); return result; } -} // namespace - std::unique_ptr CreateFullScreenWinApplicationHandler(DesktopCapturer::SourceId source_id) { std::unique_ptr result; diff --git a/modules/desktop_capture/win/full_screen_win_application_handler.h b/modules/desktop_capture/win/full_screen_win_application_handler.h index 286e8e5cb9..706e96eaef 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler.h +++ b/modules/desktop_capture/win/full_screen_win_application_handler.h @@ -14,9 +14,42 @@ #include #include "modules/desktop_capture/full_screen_application_handler.h" +#include "modules/desktop_capture/win/window_capture_utils.h" namespace webrtc { +class FullScreenPowerPointHandler : public FullScreenApplicationHandler { + public: + enum class WindowType { kEditor, kSlideShow, kOther }; + + explicit FullScreenPowerPointHandler(DesktopCapturer::SourceId sourceId); + + ~FullScreenPowerPointHandler() override {} + + DesktopCapturer::SourceId FindFullScreenWindow( + const DesktopCapturer::SourceList& window_list, + int64_t timestamp) const override; + + private: + WindowType GetWindowType(HWND window) const; + + // This function extracts the title from the editor. It needs to be + // updated every time PowerPoint changes its editor title format. Currently, + // it supports editor title in the format "Window - Title - PowerPoint". + std::string GetDocumentTitleFromEditor(HWND window) const; + + // This function extracts the title from the slideshow when PowerPoint goes + // fullscreen. This function needs to be updated whenever PowerPoint changes + // its title format. Currently, it supports Fullscreen titles of the format + // "PowerPoint Slide Show - [Window - Title]" or "PowerPoint Slide Show - + // Window - Title". + std::string GetDocumentTitleFromSlideShow(HWND window) const; + + bool IsEditorWindow(HWND window) const; + + bool IsSlideShowWindow(HWND window) const; +}; + std::unique_ptr CreateFullScreenWinApplicationHandler(DesktopCapturer::SourceId sourceId); diff --git a/modules/desktop_capture/win/full_screen_win_application_handler_unittest.cc b/modules/desktop_capture/win/full_screen_win_application_handler_unittest.cc new file mode 100644 index 0000000000..1fcd13bff0 --- /dev/null +++ b/modules/desktop_capture/win/full_screen_win_application_handler_unittest.cc @@ -0,0 +1,293 @@ +/* + * 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 "modules/desktop_capture/win/full_screen_win_application_handler.h" + +#include + +#include "modules/desktop_capture/win/test_support/test_window.h" +#include "modules/desktop_capture/win/window_capture_utils.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { + +WindowInfo CreateTestWindow(const WCHAR* window_title, + const WCHAR* window_class) { + return CreateTestWindow(window_title, /*height=*/240, /*width=*/320, + /*extended_styles=*/0, window_class); +} + +class FullScreenWinApplicationHandlerTest : public ::testing::Test { + public: + void CreateEditorWindow(const WCHAR* title, + const WCHAR* window_class = L"PPTFrameClass") { + editor_window_info_ = CreateTestWindow(title, window_class); + full_screen_ppt_handler_ = std::make_unique( + reinterpret_cast(editor_window_info_.hwnd)); + } + + HWND CreateSlideShowWindow(const WCHAR* title) { + slide_show_window_info_ = + CreateTestWindow(title, /*window_class=*/L"screenClass"); + return slide_show_window_info_.hwnd; + } + + // FindFullScreenWindow returns a non-zero value when a full screen slide show + // is found. It returns NULL when it fails to find a corresponding full screen + // slide show. + HWND FindFullScreenWindow() { + DesktopCapturer::SourceList window_list; + EXPECT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list)); + EXPECT_GT(window_list.size(), 0u); // Otherwise, faulty test. + + return reinterpret_cast( + full_screen_ppt_handler_->FindFullScreenWindow(window_list, + /*timestamp=*/0)); + } + + void TearDown() override { + DestroyTestWindow(editor_window_info_); + DestroyTestWindow(slide_show_window_info_); + } + + protected: + WindowInfo editor_window_info_; + WindowInfo slide_show_window_info_; + std::unique_ptr full_screen_ppt_handler_; +}; + +TEST_F(FullScreenWinApplicationHandlerTest, FullScreenWindowFoundForEditor) { + CreateEditorWindow(L"My - Title - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasExtraSpaces) { + CreateEditorWindow(L"My Title - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My Title ]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +// This can happen in older PowerPoint versions, where full screen slide show +// title did not had brackets around the document name. +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenSlideShowTitleHasNoBrackets) { + CreateEditorWindow(L"My - Title - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - My - Title"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasUnevenlySpacedDashes) { + CreateEditorWindow(L"My -Test - Title - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My -Test - Title]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasMatchingBrackets) { + CreateEditorWindow(L"[My - Title] - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [[My - Title]]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasAFrontRightBracket) { + CreateEditorWindow(L"[My - Title - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [[My - Title]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasABackRightBracket) { + CreateEditorWindow(L"My - Title[ - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title[]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasAFrontLeftBracket) { + CreateEditorWindow(L"]My - Title - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - []My - Title]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasABackLeftBracket) { + CreateEditorWindow(L"My - Title] - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasMismatchingBrackets) { + CreateEditorWindow(L"]My - Title[ - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - []My - Title[]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasOnlyLeftBrackets) { + CreateEditorWindow(L"[[My - Title[ - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [[[My - Title[]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasOnlyRightBrackets) { + CreateEditorWindow(L"]My - Title]] - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - []My - Title]]]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasNestedBrackets) { + CreateEditorWindow(L"[[My - Title]] - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [[[My - Title]]]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasNestedBracketsInFront) { + CreateEditorWindow(L"[[My] - Title] - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [[[My] - Title]]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorTitleHasNestedBracketsInBack) { + CreateEditorWindow(L"[My - [Title]] - PowerPoint"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [[My - [Title]]]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenEditorWindowHasNoPowerPointInTitle) { + CreateEditorWindow(L"My - Title - Power"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowFoundWhenSlideShowWindowHasNoPowerPointInTitle) { + CreateEditorWindow(L"My - Title - PowerPoint"); + HWND slide_show = CreateSlideShowWindow(L"Slide Show - [My - Title]"); + + EXPECT_EQ(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowNotFoundWhenEditorWindowHasWrongWindowClass) { + // Create editor window with class name "WrongClass" instead of + // "PPTFrameClass". + CreateEditorWindow(L"My - Title - PowerPoint", + /*window_class=*/L"WrongClass"); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"); + + EXPECT_NE(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowNotFoundWhenFullScreenPPTHandlerUsesSlideShowWindow) { + CreateEditorWindow(L"My - Title - PowerPoint"); + + // Create FullScreenPowerPointHandler using the slide show WindowInfo. + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"); + full_screen_ppt_handler_.reset(new FullScreenPowerPointHandler( + reinterpret_cast(slide_show))); + + EXPECT_NE(FindFullScreenWindow(), slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + CorrectFullScreenWindowFoundWhenMultipleSlideShowsHaveSimilarTitles) { + CreateEditorWindow(L"My - Title - PowerPoint"); + HWND correct_slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"); + std::vector wrong_slide_shows = { + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"), + CreateSlideShowWindow(L"PowerPoint Slide Show - [My Title]"), + CreateSlideShowWindow(L"PowerPoint Slide Show - [My Title -]")}; + + ASSERT_THAT(wrong_slide_shows, + testing::Not(testing::Contains(correct_slide_show))); + EXPECT_EQ(FindFullScreenWindow(), correct_slide_show); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowsFoundWhenMultipleEditorsAndSlideShowsExist) { + std::vector editors = { + CreateTestWindow(L"My - Title - PowerPoint", + /*window_class=*/L"PPTFrameClass"), + CreateTestWindow(L"[[My Title] - PowerPoint", + /*window_class=*/L"PPTFrameClass"), + CreateTestWindow(L"My Ttile - PowerPoint", + /*window_class=*/L"PPTFrameClass")}; + + std::vector> handlers; + for (auto& editor : editors) { + handlers.push_back(std::make_unique( + reinterpret_cast(editor.hwnd))); + } + + std::vector slide_shows = { + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"), + CreateSlideShowWindow(L"PowerPoint Slide Show - [[[My Title]]"), + CreateSlideShowWindow(L"PowerPoint Slide Show - [My Ttile]")}; + + DesktopCapturer::SourceList window_list; + EXPECT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list)); + EXPECT_GT(window_list.size(), 0u); + + for (size_t count = 0; count < handlers.size(); count++) { + EXPECT_EQ(reinterpret_cast( + handlers[count]->FindFullScreenWindow(window_list, + /*timestamp=*/0)), + slide_shows[count]); + } +} + +} // namespace webrtc diff --git a/modules/desktop_capture/win/screen_capture_utils.cc b/modules/desktop_capture/win/screen_capture_utils.cc index 30120db3f4..8ac8bfcd0c 100644 --- a/modules/desktop_capture/win/screen_capture_utils.cc +++ b/modules/desktop_capture/win/screen_capture_utils.cc @@ -69,12 +69,7 @@ bool GetHmonitorFromDeviceIndex(const DesktopCapturer::SourceId device_index, return true; } - std::wstring device_key; - if (!IsScreenValid(device_index, &device_key)) { - return false; - } - - DesktopRect screen_rect = GetScreenRect(device_index, device_key); + DesktopRect screen_rect = GetScreenRect(device_index, std::nullopt); if (screen_rect.is_empty()) { return false; } @@ -169,7 +164,7 @@ DesktopVector GetDpiForMonitor(HMONITOR monitor) { } DesktopRect GetScreenRect(const DesktopCapturer::SourceId screen, - const std::wstring& device_key) { + const std::optional& device_key) { if (screen == kFullDesktopScreenId) { return GetFullscreenRect(); } @@ -185,7 +180,7 @@ DesktopRect GetScreenRect(const DesktopCapturer::SourceId screen, // sure we are capturing the same device when devices are added or removed. // DeviceKey is documented as reserved, but it actually contains the registry // key for the device and is unique for each monitor, while DeviceID is not. - if (device_key != device.DeviceKey) { + if (device_key.has_value() && *device_key != device.DeviceKey) { return DesktopRect(); } diff --git a/modules/desktop_capture/win/screen_capture_utils.h b/modules/desktop_capture/win/screen_capture_utils.h index 71c79b9ab3..68407f5fda 100644 --- a/modules/desktop_capture/win/screen_capture_utils.h +++ b/modules/desktop_capture/win/screen_capture_utils.h @@ -61,7 +61,9 @@ DesktopVector GetDpiForMonitor(HMONITOR monitor); // Returns true if `screen` is a valid screen. The screen device key is // returned through `device_key` if the screen is valid. The device key can be // used in GetScreenRect to verify the screen matches the previously obtained -// id. +// id. It calls the EnumDisplayDevices API to check if the screen is valid but +// EnumDisplayDevices is quite slow so the caller of this function should +// be aware of the performance impact. bool IsScreenValid(DesktopCapturer::SourceId screen, std::wstring* device_key); // Get the rect of the entire system in system coordinate system. I.e. the @@ -69,10 +71,12 @@ bool IsScreenValid(DesktopCapturer::SourceId screen, std::wstring* device_key); DesktopRect GetFullscreenRect(); // Get the rect of the screen identified by `screen`, relative to the primary -// display's top-left. If the screen device key does not match `device_key`, or -// the screen does not exist, or any error happens, an empty rect is returned. -RTC_EXPORT DesktopRect GetScreenRect(DesktopCapturer::SourceId screen, - const std::wstring& device_key); +// display's top-left. If the optional screen device key exists, and does not +// match `device_key`, or the screen does not exist, or any error happens, +// an empty rect is returned. +RTC_EXPORT DesktopRect +GetScreenRect(DesktopCapturer::SourceId screen, + const std::optional& device_key); } // namespace webrtc diff --git a/modules/desktop_capture/win/screen_capturer_win_gdi.cc b/modules/desktop_capture/win/screen_capturer_win_gdi.cc index 24716813b5..9e65b7fa41 100644 --- a/modules/desktop_capture/win/screen_capturer_win_gdi.cc +++ b/modules/desktop_capture/win/screen_capturer_win_gdi.cc @@ -112,9 +112,15 @@ bool ScreenCapturerWinGdi::GetSourceList(SourceList* sources) { } bool ScreenCapturerWinGdi::SelectSource(SourceId id) { - bool valid = IsScreenValid(id, ¤t_device_key_); - if (valid) + std::wstring device_key; + bool valid = IsScreenValid(id, &device_key); + if (valid) { current_screen_id_ = id; + current_device_key_ = device_key; + } else { + current_screen_id_ = kFullDesktopScreenId; + current_device_key_ = std::nullopt; + } return valid; } diff --git a/modules/desktop_capture/win/screen_capturer_win_gdi.h b/modules/desktop_capture/win/screen_capturer_win_gdi.h index 7c3977ed42..6e103aea4d 100644 --- a/modules/desktop_capture/win/screen_capturer_win_gdi.h +++ b/modules/desktop_capture/win/screen_capturer_win_gdi.h @@ -61,7 +61,7 @@ class ScreenCapturerWinGdi : public DesktopCapturer { Callback* callback_ = nullptr; std::unique_ptr shared_memory_factory_; SourceId current_screen_id_ = kFullDesktopScreenId; - std::wstring current_device_key_; + std::optional current_device_key_; ScopedThreadDesktop desktop_; diff --git a/modules/desktop_capture/win/screen_capturer_win_magnifier.cc b/modules/desktop_capture/win/screen_capturer_win_magnifier.cc index 9a3c9d5f53..bb445129fc 100644 --- a/modules/desktop_capture/win/screen_capturer_win_magnifier.cc +++ b/modules/desktop_capture/win/screen_capturer_win_magnifier.cc @@ -135,12 +135,16 @@ bool ScreenCapturerWinMagnifier::GetSourceList(SourceList* sources) { } bool ScreenCapturerWinMagnifier::SelectSource(SourceId id) { - if (IsScreenValid(id, ¤t_device_key_)) { + std::wstring device_key; + bool valid = IsScreenValid(id, &device_key); + if (valid) { current_screen_id_ = id; - return true; + current_device_key_ = device_key; + } else { + current_screen_id_ = kFullDesktopScreenId; + current_device_key_ = std::nullopt; } - - return false; + return valid; } void ScreenCapturerWinMagnifier::SetExcludedWindow(WindowId excluded_window) { diff --git a/modules/desktop_capture/win/screen_capturer_win_magnifier.h b/modules/desktop_capture/win/screen_capturer_win_magnifier.h index 07c5b1e9e6..80cf6d410b 100644 --- a/modules/desktop_capture/win/screen_capturer_win_magnifier.h +++ b/modules/desktop_capture/win/screen_capturer_win_magnifier.h @@ -104,7 +104,7 @@ class ScreenCapturerWinMagnifier : public DesktopCapturer { Callback* callback_ = nullptr; std::unique_ptr shared_memory_factory_; ScreenId current_screen_id_ = kFullDesktopScreenId; - std::wstring current_device_key_; + std::optional current_device_key_; HWND excluded_window_ = NULL; // Queue of the frames buffers. diff --git a/modules/desktop_capture/win/test_support/test_window.cc b/modules/desktop_capture/win/test_support/test_window.cc index c07ff74aa5..2b7d132630 100644 --- a/modules/desktop_capture/win/test_support/test_window.cc +++ b/modules/desktop_capture/win/test_support/test_window.cc @@ -13,7 +13,6 @@ namespace webrtc { namespace { -const WCHAR kWindowClass[] = L"DesktopCaptureTestWindowClass"; const int kWindowHeight = 200; const int kWindowWidth = 300; @@ -42,7 +41,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, WindowInfo CreateTestWindow(const WCHAR* window_title, const int height, const int width, - const LONG extended_styles) { + const LONG extended_styles, + const WCHAR* window_class) { WindowInfo info; ::GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, @@ -55,19 +55,20 @@ WindowInfo CreateTestWindow(const WCHAR* window_title, wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.hInstance = info.window_instance; wcex.lpfnWndProc = &WindowProc; - wcex.lpszClassName = kWindowClass; + wcex.lpszClassName = window_class; info.window_class = ::RegisterClassExW(&wcex); // Use the default height and width if the caller did not supply the optional // height and width parameters, or if they supplied invalid values. int window_height = height <= 0 ? kWindowHeight : height; int window_width = width <= 0 ? kWindowWidth : width; - info.hwnd = - ::CreateWindowExW(extended_styles, kWindowClass, window_title, - WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, - window_width, window_height, /*parent_window=*/nullptr, - /*menu_bar=*/nullptr, info.window_instance, - /*additional_params=*/nullptr); + info.hwnd = ::CreateWindowExW( + extended_styles, window_class, window_title, + (window_class == kWindowClass) ? WS_OVERLAPPEDWINDOW : WS_OVERLAPPED, + CW_USEDEFAULT, CW_USEDEFAULT, window_width, window_height, + /*parent_window=*/nullptr, + /*menu_bar=*/nullptr, info.window_instance, + /*additional_params=*/nullptr); ::ShowWindow(info.hwnd, SW_SHOWNORMAL); ::UpdateWindow(info.hwnd); diff --git a/modules/desktop_capture/win/test_support/test_window.h b/modules/desktop_capture/win/test_support/test_window.h index b055da7ccd..a30d4532c4 100644 --- a/modules/desktop_capture/win/test_support/test_window.h +++ b/modules/desktop_capture/win/test_support/test_window.h @@ -25,6 +25,8 @@ const uint8_t kTestWindowRValue = 191; const uint8_t kTestWindowGValue = 99; const uint8_t kTestWindowBValue = 12; +const WCHAR kWindowClass[] = L"DesktopCaptureTestWindowClass"; + struct WindowInfo { HWND hwnd; HINSTANCE window_instance; @@ -34,7 +36,8 @@ struct WindowInfo { WindowInfo CreateTestWindow(const WCHAR* window_title, int height = 0, int width = 0, - LONG extended_styles = 0); + LONG extended_styles = 0, + const WCHAR* window_class = kWindowClass); void ResizeTestWindow(HWND hwnd, int width, int height); diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc index b4f9425699..da9054e0eb 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include #include @@ -26,11 +24,12 @@ #include "modules/desktop_capture/win/wgc_desktop_frame.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/win/create_direct3d_device.h" #include "rtc_base/win/get_activation_factory.h" +#include "rtc_base/win/windows_version.h" #include "system_wrappers/include/metrics.h" -#include "system_wrappers/include/sleep.h" using Microsoft::WRL::ComPtr; namespace WGC = ABI::Windows::Graphics::Capture; @@ -98,6 +97,11 @@ bool SizeHasChanged(ABI::Windows::Graphics::SizeInt32 size_new, size_new.Width != size_old.Width); } +bool DoesWgcSkipStaticFrames() { + return (webrtc::rtc_win::GetVersion() >= + webrtc::rtc_win::Version::VERSION_WIN11_24H2); +} + } // namespace WgcCaptureSession::WgcCaptureSession(intptr_t source_id, @@ -252,7 +256,7 @@ void WgcCaptureSession::EnsureFrame() { int sleep_count = 0; while (!queue_.current_frame() && sleep_count < max_sleep_count) { sleep_count++; - webrtc::SleepMs(sleep_time_ms); + Thread::SleepMs(sleep_time_ms); hr = ProcessFrame(); if (FAILED(hr)) { RTC_DLOG(LS_WARNING) << "ProcessFrame failed during startup: " << hr; @@ -463,17 +467,21 @@ HRESULT WgcCaptureSession::ProcessFrame() { DesktopFrame* current_frame = queue_.current_frame(); DesktopFrame* previous_frame = queue_.previous_frame(); - HMONITOR monitor; if (is_window_source_) { // If the captured window moves to another screen, the HMONITOR associated // with the captured window will change. Therefore, we need to get the value // of HMONITOR per frame. - monitor = MonitorFromWindow(reinterpret_cast(source_id_), - /*dwFlags=*/MONITOR_DEFAULTTONEAREST); + monitor_ = ::MonitorFromWindow(reinterpret_cast(source_id_), + /*dwFlags=*/MONITOR_DEFAULTTONEAREST); } else { - if (!GetHmonitorFromDeviceIndex(source_id_, &monitor)) { - RTC_LOG(LS_ERROR) << "Failed to get HMONITOR from device index."; - return E_FAIL; + if (!monitor_.has_value()) { + HMONITOR monitor; + if (!GetHmonitorFromDeviceIndex(source_id_, &monitor)) { + RTC_LOG(LS_ERROR) << "Failed to get HMONITOR from device index."; + d3d_context->Unmap(mapped_texture_.Get(), 0); + return E_FAIL; + } + monitor_ = monitor; } } @@ -483,7 +491,7 @@ HRESULT WgcCaptureSession::ProcessFrame() { // 1, 1.5, 2.5, etc. DEVICE_SCALE_FACTOR device_scale_factor = DEVICE_SCALE_FACTOR_INVALID; HRESULT scale_factor_hr = - GetScaleFactorForMonitor(monitor, &device_scale_factor); + GetScaleFactorForMonitor(monitor_.value(), &device_scale_factor); RTC_LOG_IF(LS_ERROR, FAILED(scale_factor_hr)) << "Failed to get scale factor for monitor: " << scale_factor_hr; if (device_scale_factor != DEVICE_SCALE_FACTOR_INVALID) { @@ -496,7 +504,11 @@ HRESULT WgcCaptureSession::ProcessFrame() { // previous. The idea is to get a low-complexity indication of if the content // is static or not without performing a full/deep memory comparison when // updating the damaged region. - bool frame_content_has_changed = false; + // `DoesWgcSkipStaticFrames()`: `TryGetNextFrame()` returns a frame + // successfully only if there is a region that has changed. This means that + // we can skip the full memory comparison if the running OS is Windows 11 + // 24H2 or later. + bool frame_content_has_changed = DoesWgcSkipStaticFrames(); // Check if the queue contains two frames whose content can be compared. const bool frame_content_can_be_compared = FrameContentCanBeCompared(); diff --git a/modules/desktop_capture/win/wgc_capture_session.h b/modules/desktop_capture/win/wgc_capture_session.h index 5d3f056945..ca88b061a1 100644 --- a/modules/desktop_capture/win/wgc_capture_session.h +++ b/modules/desktop_capture/win/wgc_capture_session.h @@ -155,6 +155,11 @@ class WgcCaptureSession final { // The unique id to represent a Source of current DesktopCapturer. intptr_t source_id_; + // The monitor that is being captured when the target source_id is a + // screen. For window sources, it can't be used because the window can move + // around around the different monitors. + std::optional monitor_; + // The source type of the capture session. It can be either a window or a // screen. bool is_window_source_; diff --git a/modules/desktop_capture/win/wgc_capturer_win_unittest.cc b/modules/desktop_capture/win/wgc_capturer_win_unittest.cc index 5d0884a398..6190579753 100644 --- a/modules/desktop_capture/win/wgc_capturer_win_unittest.cc +++ b/modules/desktop_capture/win/wgc_capturer_win_unittest.cc @@ -28,7 +28,6 @@ #include "rtc_base/win/scoped_com_initializer.h" #include "rtc_base/win/windows_version.h" #include "system_wrappers/include/metrics.h" -#include "system_wrappers/include/sleep.h" #include "test/gtest.h" namespace webrtc { @@ -548,7 +547,7 @@ TEST_F(WgcCapturerWindowTest, CloseWindowMidCapture) { // Unlike GetMessage, PeekMessage will not hang if there are no messages in // the queue. PeekMessage(&msg, 0, 0, 0, PM_REMOVE); - SleepMs(1); + Thread::SleepMs(1); } EXPECT_FALSE(wgc_capturer->IsSourceBeingCaptured(source_id_)); diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn index 21d529ff04..9faa33a254 100644 --- a/modules/pacing/BUILD.gn +++ b/modules/pacing/BUILD.gn @@ -40,7 +40,6 @@ rtc_library("pacing") { "../../api/rtc_event_log", "../../api/task_queue:pending_task_safety_flag", "../../api/task_queue:task_queue", - "../../api/transport:field_trial_based_config", "../../api/transport:network_control", "../../api/units:data_rate", "../../api/units:data_size", diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 7e1fb3c60a..d328c8692e 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -221,7 +221,7 @@ void PacingController::EnqueuePacket(std::unique_ptr packet) { } } - prober_.OnIncomingPacket(DataSize::Bytes(packet->payload_size())); + prober_.OnIncomingPacket(DataSize::Bytes(packet->size())); const Timestamp now = CurrentTime(); if (packet_queue_.Empty()) { diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index 2b755ff507..27fdbd1aba 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -66,13 +66,13 @@ std::unique_ptr BuildPacket(RtpPacketMediaType type, uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, - size_t size) { + size_t payload_size) { auto packet = std::make_unique(nullptr); packet->set_packet_type(type); packet->SetSsrc(ssrc); packet->SetSequenceNumber(sequence_number); packet->set_capture_time(Timestamp::Millis(capture_time_ms)); - packet->SetPayloadSize(size); + packet->SetPayloadSize(payload_size); return packet; } @@ -140,7 +140,7 @@ class MockPacingControllerCallback : public PacingController::PacketSender { MOCK_METHOD(size_t, SendPadding, (size_t target_size)); MOCK_METHOD(void, OnAbortedRetransmissions, - (uint32_t, webrtc::ArrayView), + (uint32_t, ArrayView), (override)); MOCK_METHOD(std::optional, GetRtxSsrcForMedia, @@ -168,7 +168,7 @@ class MockPacketSender : public PacingController::PacketSender { (override)); MOCK_METHOD(void, OnAbortedRetransmissions, - (uint32_t, webrtc::ArrayView), + (uint32_t, ArrayView), (override)); MOCK_METHOD(std::optional, GetRtxSsrcForMedia, @@ -304,7 +304,7 @@ class PacingControllerTest : public ::testing::Test { type == RtpPacketMediaType::kRetransmission, false)); } - void AdvanceTimeUntil(webrtc::Timestamp time) { + void AdvanceTimeUntil(Timestamp time) { Timestamp now = clock_.CurrentTime(); clock_.AdvanceTime(std::max(TimeDelta::Zero(), time - now)); } @@ -1367,6 +1367,50 @@ TEST_F(PacingControllerTest, ProbingWithPaddingSupport) { kFirstClusterRate.bps(), kProbingErrorMargin.bps()); } +TEST_F(PacingControllerTest, PaddingPacketCanTriggerProbe) { + const int kInitialBitrateBps = 300000; + PacingControllerProbing packet_sender; + auto pacer = + std::make_unique(&clock_, &packet_sender, trials_); + + pacer->SetPacingRates( + DataRate::BitsPerSec(kInitialBitrateBps * kPaceMultiplier), + /*padding_rate*/ DataRate::KilobitsPerSec(300)); + + pacer->EnqueuePacket(BuildPacket(RtpPacketMediaType::kVideo, + /*ssrc=*/123, /*sequence_number=*/1, + clock_.TimeInMilliseconds(), + /*payload_size=*/50)); + + for (int i = 0; i < 5; ++i) { + AdvanceTimeUntil(pacer->NextSendTime()); + pacer->ProcessPackets(); + EXPECT_EQ(packet_sender.last_pacing_info().probe_cluster_id, + PacedPacketInfo::kNotAProbe); + } + ASSERT_GT(packet_sender.packets_sent(), 0); + ASSERT_GT(packet_sender.padding_sent(), 0); + + const int kProbeClusterId = 1; + std::vector probe_clusters = { + {.at_time = clock_.CurrentTime(), + .target_data_rate = DataRate::KilobitsPerSec(1000), + .target_duration = TimeDelta::Millis(15), + .target_probe_count = 5, + .id = kProbeClusterId}}; + pacer->CreateProbeClusters(probe_clusters); + bool probe_packet_seen = false; + for (int i = 0; i < 5; ++i) { + AdvanceTimeUntil(pacer->NextSendTime()); + pacer->ProcessPackets(); + if (packet_sender.last_pacing_info().probe_cluster_id == kProbeClusterId) { + probe_packet_seen = true; + break; + } + } + EXPECT_TRUE(probe_packet_seen); +} + TEST_F(PacingControllerTest, CanProbeWithPaddingBeforeFirstMediaPacket) { // const size_t kPacketSize = 1200; const int kInitialBitrateBps = 300000; diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 26c0a869da..6a830f1418 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -22,7 +22,7 @@ namespace webrtc { namespace { -using ::webrtc::test::ExplicitKeyValueConfig; +using test::ExplicitKeyValueConfig; constexpr Timestamp kInitialTime = Timestamp::Millis(123'456); diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc b/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc index bf13fa352f..fbfbf6f890 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc @@ -32,7 +32,7 @@ namespace webrtc { -constexpr DataRate kMaxFeedbackRate = webrtc::DataRate::KilobitsPerSec(500); +constexpr DataRate kMaxFeedbackRate = DataRate::KilobitsPerSec(500); CongestionControlFeedbackGenerator::CongestionControlFeedbackGenerator( const Environment& env, diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc index 5adbadd296..2d34ed67ef 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc @@ -97,7 +97,7 @@ int64_t RtpStream::next_rtp_time() const { // Generates an RTCP packet. RtpStream::RtcpPacket* RtpStream::Rtcp(int64_t time_now_us) { if (time_now_us < next_rtcp_time_) { - return NULL; + return nullptr; } RtcpPacket* rtcp = new RtcpPacket; int64_t send_time_us = time_now_us + kSendSideOffsetUs; diff --git a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc index 3c908af6bc..2f683be1ca 100644 --- a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc +++ b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc @@ -107,8 +107,7 @@ class TransportSequenceNumberFeedbackGeneneratorTest : public ::testing::Test { map.Register(1); RtpPacketReceived packet(&map, arrival_time); packet.SetSsrc(kMediaSsrc); - packet.SetExtension(seq, - feedback_request); + packet.SetExtension(seq, feedback_request); feedback_generator_.OnReceivedPacket(packet); } diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index 96ccf3713c..2a680f5567 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -339,6 +339,7 @@ rtc_library("rtp_rtcp") { "../../rtc_base:random", "../../rtc_base:rate_limiter", "../../rtc_base:rtc_numerics", + "../../rtc_base:rtp_to_ntp_estimator", "../../rtc_base:safe_conversions", "../../rtc_base:safe_minmax", "../../rtc_base:threading", @@ -361,7 +362,7 @@ rtc_library("rtp_rtcp") { ] } -rtc_source_set("rtp_rtcp_legacy") { +rtc_library("rtp_rtcp_legacy") { sources = [ "include/rtp_rtcp.h", "source/deprecated/deprecated_rtp_sender_egress.cc", @@ -473,7 +474,7 @@ rtc_library("rtp_video_header") { ] } -rtc_source_set("rtp_video_header_unittest") { +rtc_library("rtp_video_header_unittest") { testonly = true sources = [ "source/rtp_video_header_unittest.cc" ] deps = [ @@ -770,7 +771,7 @@ if (rtc_include_tests) { ] } - rtc_source_set("frame_transformer_factory_unittest") { + rtc_library("frame_transformer_factory_unittest") { testonly = true sources = [ "source/frame_transformer_factory_unittest.cc" ] deps = [ diff --git a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h index 9c8404b38e..5b08d799a1 100644 --- a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h +++ b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h @@ -18,8 +18,8 @@ #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "rtc_base/numerics/moving_percentile_filter.h" +#include "rtc_base/rtp_to_ntp_estimator.h" #include "system_wrappers/include/ntp_time.h" -#include "system_wrappers/include/rtp_to_ntp_estimator.h" namespace webrtc { diff --git a/modules/rtp_rtcp/source/fec_test_helper.cc b/modules/rtp_rtcp/source/fec_test_helper.cc index 3186a476b6..aa07e6b293 100644 --- a/modules/rtp_rtcp/source/fec_test_helper.cc +++ b/modules/rtp_rtcp/source/fec_test_helper.cc @@ -84,9 +84,9 @@ ForwardErrorCorrection::PacketList MediaPacketGenerator::ConstructMediaPackets( // Only push one (fake) frame to the FEC. data[1] &= 0x7f; - webrtc::ByteWriter::WriteBigEndian(&data[2], seq_num); - webrtc::ByteWriter::WriteBigEndian(&data[4], time_stamp); - webrtc::ByteWriter::WriteBigEndian(&data[8], ssrc_); + ByteWriter::WriteBigEndian(&data[2], seq_num); + ByteWriter::WriteBigEndian(&data[4], time_stamp); + ByteWriter::WriteBigEndian(&data[8], ssrc_); // Generate random values for payload. for (size_t j = 12; j < media_packet->data.size(); ++j) diff --git a/modules/rtp_rtcp/source/frame_transformer_factory_unittest.cc b/modules/rtp_rtcp/source/frame_transformer_factory_unittest.cc index 312bdcbb86..03a3608037 100644 --- a/modules/rtp_rtcp/source/frame_transformer_factory_unittest.cc +++ b/modules/rtp_rtcp/source/frame_transformer_factory_unittest.cc @@ -48,7 +48,7 @@ TEST(FrameTransformerFactory, CloneVideoFrame) { std::fill_n(data, 10, 5); ArrayView data_view(data); EXPECT_CALL(original_frame, GetData()).WillRepeatedly(Return(data_view)); - webrtc::VideoFrameMetadata metadata; + VideoFrameMetadata metadata; std::vector csrcs{123, 321}; // Copy csrcs rather than moving so we can compare in an EXPECT_EQ later. metadata.SetCsrcs(csrcs); diff --git a/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/modules/rtp_rtcp/source/nack_rtx_unittest.cc index 28b75a7a25..8f2265dc02 100644 --- a/modules/rtp_rtcp/source/nack_rtx_unittest.cc +++ b/modules/rtp_rtcp/source/nack_rtx_unittest.cc @@ -67,7 +67,7 @@ class VerifyingMediaStream : public RtpPacketSinkInterface { std::list sequence_numbers_; }; -class RtxLoopBackTransport : public webrtc::Transport { +class RtxLoopBackTransport : public Transport { public: explicit RtxLoopBackTransport(uint32_t rtx_ssrc) : count_(0), @@ -76,7 +76,7 @@ class RtxLoopBackTransport : public webrtc::Transport { consecutive_drop_end_(0), rtx_ssrc_(rtx_ssrc), count_rtx_ssrc_(0), - module_(NULL) {} + module_(nullptr) {} void SetSendModule(RtpRtcpInterface* rtpRtcpModule) { module_ = rtpRtcpModule; @@ -115,7 +115,8 @@ class RtxLoopBackTransport : public webrtc::Transport { return true; } - bool SendRtcp(ArrayView data) override { + bool SendRtcp(ArrayView data, + const PacketOptions& /* options */) override { module_->IncomingRtcpPacket(data); return true; } diff --git a/modules/rtp_rtcp/source/receive_statistics_unittest.cc b/modules/rtp_rtcp/source/receive_statistics_unittest.cc index 918c74de7f..5eb552be45 100644 --- a/modules/rtp_rtcp/source/receive_statistics_unittest.cc +++ b/modules/rtp_rtcp/source/receive_statistics_unittest.cc @@ -132,7 +132,7 @@ TEST_P(ReceiveStatisticsTest, TwoIncomingSsrcs) { StreamStatistician* statistician = receive_statistics_->GetStatistician(kSsrc1); - ASSERT_TRUE(statistician != NULL); + ASSERT_TRUE(statistician != nullptr); EXPECT_GT(statistician->BitrateReceived(), 0u); StreamDataCounters counters = statistician->GetReceiveStreamDataCounters(); EXPECT_EQ(176u, counters.transmitted.payload_bytes); @@ -141,7 +141,7 @@ TEST_P(ReceiveStatisticsTest, TwoIncomingSsrcs) { EXPECT_EQ(2u, counters.transmitted.packets); statistician = receive_statistics_->GetStatistician(kSsrc2); - ASSERT_TRUE(statistician != NULL); + ASSERT_TRUE(statistician != nullptr); EXPECT_GT(statistician->BitrateReceived(), 0u); counters = statistician->GetReceiveStreamDataCounters(); EXPECT_EQ(576u, counters.transmitted.payload_bytes); @@ -237,7 +237,7 @@ TEST_P(ReceiveStatisticsTest, ActiveStatisticians) { EXPECT_EQ(1u, receive_statistics_->RtcpReportBlocks(3).size()); StreamStatistician* statistician = receive_statistics_->GetStatistician(kSsrc1); - ASSERT_TRUE(statistician != NULL); + ASSERT_TRUE(statistician != nullptr); StreamDataCounters counters = statistician->GetReceiveStreamDataCounters(); EXPECT_EQ(176u, counters.transmitted.payload_bytes); EXPECT_EQ(24u, counters.transmitted.header_bytes); @@ -260,7 +260,7 @@ TEST_P(ReceiveStatisticsTest, GetReceiveStreamDataCounters) { receive_statistics_->OnRtpPacket(packet1_); StreamStatistician* statistician = receive_statistics_->GetStatistician(kSsrc1); - ASSERT_TRUE(statistician != NULL); + ASSERT_TRUE(statistician != nullptr); StreamDataCounters counters = statistician->GetReceiveStreamDataCounters(); EXPECT_TRUE(counters.first_packet_time.IsFinite()); @@ -631,7 +631,7 @@ TEST_P(ReceiveStatisticsTest, SimpleJitterComputation) { // See jitter caluculation in https://www.rfc-editor.org/rfc/rfc3550 6.4.1. const uint32_t expected_jitter = (kLateArrivalDeltaSamples) / 16; EXPECT_EQ(expected_jitter, statistician->GetStats().jitter); - EXPECT_EQ(webrtc::TimeDelta::Seconds(expected_jitter) / kCodecSampleRate, + EXPECT_EQ(TimeDelta::Seconds(expected_jitter) / kCodecSampleRate, statistician->GetStats().interarrival_jitter); } diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc index 3faca87ca8..af6e692581 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc @@ -17,9 +17,9 @@ #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/ntp_time_util.h" #include "rtc_base/logging.h" +#include "rtc_base/rtp_to_ntp_estimator.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/ntp_time.h" -#include "system_wrappers/include/rtp_to_ntp_estimator.h" namespace webrtc { diff --git a/modules/rtp_rtcp/source/rtcp_packet/app_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/app_unittest.cc index 4448f346fa..384f1c03f5 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/app_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/app_unittest.cc @@ -20,9 +20,9 @@ namespace webrtc { namespace { +using rtcp::App; using ::testing::ElementsAreArray; using ::testing::make_tuple; -using ::webrtc::rtcp::App; constexpr uint32_t kName = ((uint32_t)'n' << 24) | ((uint32_t)'a' << 16) | ((uint32_t)'m' << 8) | (uint32_t)'e'; diff --git a/modules/rtp_rtcp/source/rtcp_packet/loss_notification_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/loss_notification_unittest.cc index b7b9c54acf..312f051554 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/loss_notification_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/loss_notification_unittest.cc @@ -21,9 +21,9 @@ namespace webrtc { +using rtcp::LossNotification; using ::testing::ElementsAreArray; using ::testing::make_tuple; -using ::webrtc::rtcp::LossNotification; TEST(RtcpPacketLossNotificationTest, SetWithIllegalValuesFails) { constexpr uint16_t kLastDecoded = 0x3c7b; diff --git a/modules/rtp_rtcp/source/rtcp_packet/nack_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/nack_unittest.cc index de7b942ddf..a41700b577 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/nack_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/nack_unittest.cc @@ -23,6 +23,7 @@ namespace webrtc { namespace { +using rtcp::Nack; using ::testing::_; using ::testing::ElementsAre; using ::testing::ElementsAreArray; @@ -30,7 +31,6 @@ using ::testing::Invoke; using ::testing::make_tuple; using ::testing::MockFunction; using ::testing::UnorderedElementsAreArray; -using ::webrtc::rtcp::Nack; constexpr uint32_t kSenderSsrc = 0x12345678; constexpr uint32_t kRemoteSsrc = 0x23456789; diff --git a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index 4da2dceeb8..31d218eea2 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -68,6 +68,7 @@ namespace webrtc { namespace { using rtcp::ReceiveTimeInfo; +using test::ExplicitKeyValueConfig; using ::testing::_; using ::testing::AllOf; using ::testing::ElementsAre; @@ -83,7 +84,6 @@ using ::testing::SizeIs; using ::testing::StrEq; using ::testing::StrictMock; using ::testing::UnorderedElementsAre; -using ::webrtc::test::ExplicitKeyValueConfig; class MockRtcpPacketTypeCounterObserver : public RtcpPacketTypeCounterObserver { public: diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc index c08fd08a73..e1cbe26e24 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/modules/rtp_rtcp/source/rtcp_sender.cc @@ -22,6 +22,7 @@ #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/call/transport.h" #include "api/environment/environment.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_headers.h" @@ -238,7 +239,7 @@ int32_t RTCPSender::SendLossNotification(const FeedbackState& feedback_state, bool buffering_allowed) { int32_t error_code = -1; auto callback = [&](ArrayView packet) { - transport_->SendRtcp(packet); + transport_->SendRtcp(packet, /*packet_options=*/{}); error_code = 0; env_.event_log().Log(std::make_unique(packet)); }; @@ -596,7 +597,7 @@ int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, const uint16_t* nack_list) { int32_t error_code = -1; auto callback = [&](ArrayView packet) { - if (transport_->SendRtcp(packet)) { + if (transport_->SendRtcp(packet, /*packet_options=*/{})) { error_code = 0; env_.event_log().Log( std::make_unique(packet)); @@ -894,7 +895,7 @@ void RTCPSender::SendCombinedRtcpPacket( } RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); auto callback = [&](ArrayView packet) { - if (transport_->SendRtcp(packet)) { + if (transport_->SendRtcp(packet, /*packet_options=*/{})) { env_.event_log().Log( std::make_unique(packet)); } diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc index ffba6d76dd..e93b38e625 100644 --- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc @@ -81,7 +81,9 @@ class TestTransport : public Transport { const PacketOptions& /* options */) override { return false; } - bool SendRtcp(ArrayView data) override { + bool SendRtcp(ArrayView data, + const PacketOptions& options) override { + EXPECT_FALSE(options.is_media); parser_.Parse(data); return true; } @@ -680,8 +682,8 @@ TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndEmpty) { // of a RTCP compound packet. TEST_F(RtcpSenderTest, ByeMustBeLast) { MockTransport mock_transport; - EXPECT_CALL(mock_transport, SendRtcp(_)) - .WillOnce(Invoke([](ArrayView data) { + EXPECT_CALL(mock_transport, SendRtcp(_, _)) + .WillOnce(Invoke([](ArrayView data, ::testing::Unused) { const uint8_t* next_packet = data.data(); const uint8_t* const packet_end = data.data() + data.size(); rtcp::CommonHeader packet; diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index 3a10304b4b..be485b87da 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -59,6 +59,11 @@ namespace webrtc { namespace { +using rtcp::Bye; +using rtcp::CompoundPacket; +using rtcp::ReportBlock; +using rtcp::SenderReport; +using test::RtcpPacketParser; using ::testing::_; using ::testing::ElementsAre; using ::testing::ElementsAreArray; @@ -71,11 +76,6 @@ using ::testing::SizeIs; using ::testing::StrictMock; using ::testing::UnorderedElementsAre; using ::testing::WithArg; -using ::webrtc::rtcp::Bye; -using ::webrtc::rtcp::CompoundPacket; -using ::webrtc::rtcp::ReportBlock; -using ::webrtc::rtcp::SenderReport; -using ::webrtc::test::RtcpPacketParser; class MockReceiveStatisticsProvider : public ReceiveStatisticsProvider { public: @@ -432,7 +432,7 @@ TEST_F(RtcpTransceiverImplTest, AvoidsEmptyPacketsInReducedMode) { RtcpTransceiverConfig config = DefaultTestConfig(); config.rtcp_transport = transport.AsStdFunction(); - config.rtcp_mode = webrtc::RtcpMode::kReducedSize; + config.rtcp_mode = RtcpMode::kReducedSize; config.receive_statistics = &receive_statistics; RtcpTransceiverImpl rtcp_transceiver(config); @@ -445,7 +445,7 @@ TEST_F(RtcpTransceiverImplTest, AvoidsEmptyReceiverReportsInReducedMode) { RtcpTransceiverConfig config = DefaultTestConfig(); config.rtcp_transport = RtcpParserTransport(rtcp_parser); - config.rtcp_mode = webrtc::RtcpMode::kReducedSize; + config.rtcp_mode = RtcpMode::kReducedSize; config.receive_statistics = &receive_statistics; // Set it to produce something (RRTR) in the "periodic" rtcp packets. config.non_sender_rtt_measurement = true; @@ -545,7 +545,7 @@ TEST_F(RtcpTransceiverImplTest, const uint32_t kSenderSsrc = 12345; RtcpTransceiverConfig config = DefaultTestConfig(); config.send_remb_on_change = true; - config.rtcp_mode = webrtc::RtcpMode::kReducedSize; + config.rtcp_mode = RtcpMode::kReducedSize; config.feedback_ssrc = kSenderSsrc; RtcpPacketParser rtcp_parser; config.rtcp_transport = RtcpParserTransport(rtcp_parser); @@ -717,12 +717,12 @@ TEST_F(RtcpTransceiverImplTest, CallsObserverOnTargetBitrateBySenderSsrc) { rtcp_transceiver.AddMediaReceiverRtcpObserver(kRemoteSsrc1, &observer1); rtcp_transceiver.AddMediaReceiverRtcpObserver(kRemoteSsrc2, &observer2); - webrtc::rtcp::TargetBitrate target_bitrate; + rtcp::TargetBitrate target_bitrate; target_bitrate.AddTargetBitrate(0, 0, /*target_bitrate_kbps=*/10); target_bitrate.AddTargetBitrate(0, 1, /*target_bitrate_kbps=*/20); target_bitrate.AddTargetBitrate(1, 0, /*target_bitrate_kbps=*/40); target_bitrate.AddTargetBitrate(1, 1, /*target_bitrate_kbps=*/80); - webrtc::rtcp::ExtendedReports xr; + rtcp::ExtendedReports xr; xr.SetSenderSsrc(kRemoteSsrc1); xr.SetTargetBitrate(target_bitrate); auto raw_packet = xr.Build(); @@ -744,12 +744,12 @@ TEST_F(RtcpTransceiverImplTest, SkipsIncorrectTargetBitrateEntries) { RtcpTransceiverImpl rtcp_transceiver(config); rtcp_transceiver.AddMediaReceiverRtcpObserver(kRemoteSsrc, &observer); - webrtc::rtcp::TargetBitrate target_bitrate; + rtcp::TargetBitrate target_bitrate; target_bitrate.AddTargetBitrate(0, 0, /*target_bitrate_kbps=*/10); - target_bitrate.AddTargetBitrate(0, webrtc::kMaxTemporalStreams, 20); - target_bitrate.AddTargetBitrate(webrtc::kMaxSpatialLayers, 0, 40); + target_bitrate.AddTargetBitrate(0, kMaxTemporalStreams, 20); + target_bitrate.AddTargetBitrate(kMaxSpatialLayers, 0, 40); - webrtc::rtcp::ExtendedReports xr; + rtcp::ExtendedReports xr; xr.SetTargetBitrate(target_bitrate); xr.SetSenderSsrc(kRemoteSsrc); auto raw_packet = xr.Build(); @@ -790,7 +790,7 @@ TEST_F(RtcpTransceiverImplTest, CallsObserverOnByeBehindUnknownRtcpPacket) { CompoundPacket compound; // Use Application-Defined rtcp packet as unknown. - auto app = std::make_unique(); + auto app = std::make_unique(); compound.Append(std::move(app)); auto bye = std::make_unique(); bye->SetSenderSsrc(kRemoteSsrc); @@ -1180,7 +1180,7 @@ TEST_F(RtcpTransceiverImplTest, KeyFrameRequestCreatesCompoundPacket) { RtcpPacketParser rtcp_parser; config.rtcp_transport = RtcpParserTransport(rtcp_parser); - config.rtcp_mode = webrtc::RtcpMode::kCompound; + config.rtcp_mode = RtcpMode::kCompound; RtcpTransceiverImpl rtcp_transceiver(config); rtcp_transceiver.SendFullIntraRequest(kRemoteSsrcs, true); @@ -1198,7 +1198,7 @@ TEST_F(RtcpTransceiverImplTest, KeyFrameRequestCreatesReducedSizePacket) { RtcpPacketParser rtcp_parser; config.rtcp_transport = RtcpParserTransport(rtcp_parser); - config.rtcp_mode = webrtc::RtcpMode::kReducedSize; + config.rtcp_mode = RtcpMode::kReducedSize; RtcpTransceiverImpl rtcp_transceiver(config); rtcp_transceiver.SendFullIntraRequest(kRemoteSsrcs, true); @@ -1393,10 +1393,10 @@ TEST_F(RtcpTransceiverImplTest, IgnoresUnknownSsrcInDlrr) { RtcpTransceiverImpl rtcp_transceiver(config); Timestamp time = Timestamp::Micros(12345678); - webrtc::rtcp::ReceiveTimeInfo rti; + rtcp::ReceiveTimeInfo rti; rti.ssrc = kUnknownSsrc; rti.last_rr = CompactNtp(config.clock->ConvertTimestampToNtpTime(time)); - webrtc::rtcp::ExtendedReports xr; + rtcp::ExtendedReports xr; xr.AddDlrrItem(rti); auto raw_packet = xr.Build(); diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc index 40bfcd3b4b..8fa658019a 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc @@ -131,7 +131,8 @@ class SendTransport : public Transport, ++rtp_packets_sent_; return true; } - bool SendRtcp(ArrayView data) override { + bool SendRtcp(ArrayView data, + const PacketOptions& /* options */) override { test::RtcpPacketParser parser; parser.Parse(data); last_nack_list_ = parser.nack()->packet_ids(); diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc index 0fae24d0fb..153bc6ce3a 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc @@ -103,7 +103,8 @@ class SendTransport : public Transport { last_rtp_sequence_number_ = packet.SequenceNumber(); return true; } - bool SendRtcp(ArrayView data) override { + bool SendRtcp(ArrayView data, + const PacketOptions& /* options */) override { test::RtcpPacketParser parser; parser.Parse(data); last_nack_list_ = parser.nack()->packet_ids(); diff --git a/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc index 6ce33aeb12..2cb508497f 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc @@ -45,7 +45,7 @@ const uint64_t kStartTime = 123456789; using ::testing::ElementsAreArray; -class LoopbackTransportTest : public webrtc::Transport { +class LoopbackTransportTest : public Transport { public: LoopbackTransportTest() { receivers_extensions_.Register(kAudioLevelExtensionId); @@ -59,7 +59,10 @@ class LoopbackTransportTest : public webrtc::Transport { EXPECT_TRUE(sent_packets_.back().Parse(data)); return true; } - bool SendRtcp(ArrayView /* data */) override { return false; } + bool SendRtcp(ArrayView /* data */, + const PacketOptions& /* options */) override { + return false; + } const RtpPacketReceived& last_sent_packet() { return sent_packets_.back(); } int packets_sent() { return sent_packets_.size(); } diff --git a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc index 833a93bfce..e86296f0ac 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc @@ -115,7 +115,10 @@ class TestTransport : public Transport { return true; } - bool SendRtcp(ArrayView) override { RTC_CHECK_NOTREACHED(); } + bool SendRtcp(ArrayView /* packet */, + const PacketOptions& /* options */) override { + RTC_CHECK_NOTREACHED(); + } std::optional last_packet() { return last_packet_; } diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc index acb4c7321c..96662d1743 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -669,7 +669,7 @@ bool RTPSenderVideo::SendVideo(int payload_type, Buffer encrypted_video_payload; if (frame_encryptor_ != nullptr) { const size_t max_ciphertext_size = - frame_encryptor_->GetMaxCiphertextByteSize(webrtc::MediaType::VIDEO, + frame_encryptor_->GetMaxCiphertextByteSize(MediaType::VIDEO, payload.size()); encrypted_video_payload.SetSize(max_ciphertext_size); @@ -682,8 +682,8 @@ bool RTPSenderVideo::SendVideo(int payload_type, } if (frame_encryptor_->Encrypt( - webrtc::MediaType::VIDEO, first_packet->Ssrc(), additional_data, - payload, encrypted_video_payload, &bytes_written) != 0) { + MediaType::VIDEO, first_packet->Ssrc(), additional_data, payload, + encrypted_video_payload, &bytes_written) != 0) { return false; } diff --git a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc index b5045aee12..79432a97fa 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc @@ -115,7 +115,7 @@ constexpr int kMaxPacketLength = 1500; constexpr Timestamp kStartTime = Timestamp::Millis(123456789); constexpr TimeDelta kDefaultExpectedRetransmissionTime = TimeDelta::Millis(125); -class LoopbackTransportTest : public webrtc::Transport { +class LoopbackTransportTest : public Transport { public: LoopbackTransportTest() { receivers_extensions_.Register( @@ -147,7 +147,10 @@ class LoopbackTransportTest : public webrtc::Transport { EXPECT_TRUE(sent_packets_.back().Parse(data)); return true; } - bool SendRtcp(ArrayView /* data */) override { return false; } + bool SendRtcp(ArrayView /* data */, + const PacketOptions& /* options */) override { + return false; + } const RtpPacketReceived& last_sent_packet() { return sent_packets_.back(); } int packets_sent() { return sent_packets_.size(); } const std::vector& sent_packets() const { @@ -1574,8 +1577,7 @@ class RtpSenderVideoWithFrameTransformerTest : public ::testing::Test { std::unique_ptr CreateDefaultEncodedImage() { const uint8_t data[] = {1, 2, 3, 4}; auto encoded_image = std::make_unique(); - encoded_image->SetEncodedData( - webrtc::EncodedImageBuffer::Create(data, sizeof(data))); + encoded_image->SetEncodedData(EncodedImageBuffer::Create(data, sizeof(data))); return encoded_image; } diff --git a/modules/rtp_rtcp/test/testFec/test_fec.cc b/modules/rtp_rtcp/test/testFec/test_fec.cc index bd6998d71f..2898a47940 100644 --- a/modules/rtp_rtcp/test/testFec/test_fec.cc +++ b/modules/rtp_rtcp/test/testFec/test_fec.cc @@ -133,7 +133,7 @@ void RunTest(bool use_flexfec) { // reproduce past results. const unsigned int random_seed = static_cast(time(nullptr)); Random random(random_seed); - std::string filename = webrtc::test::OutputPath() + "randomSeedLog.txt"; + std::string filename = test::OutputPath() + "randomSeedLog.txt"; FILE* random_seed_file = fopen(filename.c_str(), "a"); fprintf(random_seed_file, "%u\n", random_seed); fclose(random_seed_file); diff --git a/modules/utility/BUILD.gn b/modules/utility/BUILD.gn index 8cefe5653c..b30cb0c6d4 100644 --- a/modules/utility/BUILD.gn +++ b/modules/utility/BUILD.gn @@ -8,7 +8,7 @@ import("../../webrtc.gni") -rtc_source_set("utility") { +rtc_library("utility") { if (is_android) { visibility = [ "*" ] sources = [ diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn index 22f5ff2acc..c3e0e5af71 100644 --- a/modules/video_capture/BUILD.gn +++ b/modules/video_capture/BUILD.gn @@ -28,6 +28,7 @@ rtc_library("video_capture_module") { ] deps = [ + "../../api:ref_count", "../../api:scoped_refptr", "../../api:sequence_checker", "../../api/video:video_frame", @@ -51,10 +52,11 @@ rtc_library("video_capture_module") { } if (!build_with_chromium || is_linux || is_chromeos) { - rtc_source_set("video_capture_internal_impl") { + rtc_library("video_capture_internal_impl") { visibility = [ "*" ] deps = [ ":video_capture_module", + "../../api:make_ref_counted", "../../api:scoped_refptr", "../../api:sequence_checker", "../../media:video_common", diff --git a/modules/video_capture/device_info_impl.cc b/modules/video_capture/device_info_impl.cc index dc49d8abb9..1d3e3ee89e 100644 --- a/modules/video_capture/device_info_impl.cc +++ b/modules/video_capture/device_info_impl.cc @@ -31,7 +31,7 @@ namespace webrtc { namespace videocapturemodule { DeviceInfoImpl::DeviceInfoImpl() - : _lastUsedDeviceName(NULL), _lastUsedDeviceNameLength(0) {} + : _lastUsedDeviceName(nullptr), _lastUsedDeviceNameLength(0) {} DeviceInfoImpl::~DeviceInfoImpl(void) { MutexLock lock(&_apiLock); diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc index 33aa452a07..243656e782 100644 --- a/modules/video_capture/linux/video_capture_v4l2.cc +++ b/modules/video_capture/linux/video_capture_v4l2.cc @@ -55,7 +55,7 @@ VideoCaptureModuleV4L2::VideoCaptureModuleV4L2() _deviceFd(-1), _buffersAllocatedByDevice(-1), _captureStarted(false), - _pool(NULL) {} + _pool(nullptr) {} int32_t VideoCaptureModuleV4L2::Init(const char* deviceUniqueIdUTF8) { RTC_DCHECK_RUN_ON(&api_checker_); @@ -366,7 +366,7 @@ bool VideoCaptureModuleV4L2::AllocateVideoBuffers() { return false; } - _pool[i].start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, + _pool[i].start = mmap(nullptr, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, _deviceFd, buffer.m.offset); if (MAP_FAILED == _pool[i].start) { @@ -420,7 +420,7 @@ bool VideoCaptureModuleV4L2::CaptureProcess() { timeout.tv_usec = 0; // _deviceFd written only in StartCapture, when this thread isn't running. - retVal = select(_deviceFd + 1, &rSet, NULL, NULL, &timeout); + retVal = select(_deviceFd + 1, &rSet, nullptr, nullptr, &timeout); { MutexLock lock(&capture_lock_); diff --git a/modules/video_capture/raw_video_sink_interface.h b/modules/video_capture/raw_video_sink_interface.h index 094e9e20bd..a22ca9811d 100644 --- a/modules/video_capture/raw_video_sink_interface.h +++ b/modules/video_capture/raw_video_sink_interface.h @@ -14,6 +14,10 @@ #ifndef MODULES_VIDEO_CAPTURE_RAW_VIDEO_SINK_INTERFACE_H_ #define MODULES_VIDEO_CAPTURE_RAW_VIDEO_SINK_INTERFACE_H_ +#include +#include + +#include "api/video/video_rotation.h" #include "modules/video_capture/video_capture_defines.h" namespace webrtc { diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc index 2019f0bf4e..e8165d9060 100644 --- a/modules/video_capture/test/video_capture_unittest.cc +++ b/modules/video_capture/test/video_capture_unittest.cc @@ -156,7 +156,7 @@ class VideoCaptureTest : public ::testing::Test { webrtc::scoped_refptr module( VideoCaptureFactory::Create(unique_name)); - if (module.get() == NULL) + if (module.get() == nullptr) return nullptr; EXPECT_FALSE(module->CaptureStarted()); @@ -193,7 +193,7 @@ TEST_F(VideoCaptureTest, MAYBE_CreateDelete) { TestVideoCaptureCallback capture_observer; webrtc::scoped_refptr module( OpenVideoCaptureDevice(0, &capture_observer)); - ASSERT_TRUE(module.get() != NULL); + ASSERT_TRUE(module.get() != nullptr); VideoCaptureCapability capability; #ifndef WEBRTC_MAC @@ -237,7 +237,7 @@ TEST_F(VideoCaptureTest, MAYBE_Capabilities) { webrtc::scoped_refptr module( OpenVideoCaptureDevice(0, &capture_observer)); - ASSERT_TRUE(module.get() != NULL); + ASSERT_TRUE(module.get() != nullptr); int number_of_capabilities = device_info_->NumberOfCapabilities(module->CurrentDeviceName()); @@ -301,7 +301,7 @@ TEST_F(VideoCaptureTest, DISABLED_TestTwoCameras) { TestVideoCaptureCallback capture_observer1; webrtc::scoped_refptr module1( OpenVideoCaptureDevice(0, &capture_observer1)); - ASSERT_TRUE(module1.get() != NULL); + ASSERT_TRUE(module1.get() != nullptr); VideoCaptureCapability capability1; #ifndef WEBRTC_MAC device_info_->GetCapability(module1->CurrentDeviceName(), 0, capability1); @@ -316,7 +316,7 @@ TEST_F(VideoCaptureTest, DISABLED_TestTwoCameras) { TestVideoCaptureCallback capture_observer2; webrtc::scoped_refptr module2( OpenVideoCaptureDevice(1, &capture_observer2)); - ASSERT_TRUE(module1.get() != NULL); + ASSERT_TRUE(module1.get() != nullptr); VideoCaptureCapability capability2; #ifndef WEBRTC_MAC @@ -353,7 +353,7 @@ TEST_F(VideoCaptureTest, MAYBE_ConcurrentAccess) { TestVideoCaptureCallback capture_observer1; webrtc::scoped_refptr module1( OpenVideoCaptureDevice(0, &capture_observer1)); - ASSERT_TRUE(module1.get() != NULL); + ASSERT_TRUE(module1.get() != nullptr); VideoCaptureCapability capability; device_info_->GetCapability(module1->CurrentDeviceName(), 0, capability); capture_observer1.SetExpectedCapability(capability); @@ -361,7 +361,7 @@ TEST_F(VideoCaptureTest, MAYBE_ConcurrentAccess) { TestVideoCaptureCallback capture_observer2; webrtc::scoped_refptr module2( OpenVideoCaptureDevice(0, &capture_observer2)); - ASSERT_TRUE(module2.get() != NULL); + ASSERT_TRUE(module2.get() != nullptr); capture_observer2.SetExpectedCapability(capability); // Starting module1 should work. diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h index fe5c09bd87..7707608dbc 100644 --- a/modules/video_capture/video_capture.h +++ b/modules/video_capture/video_capture.h @@ -11,6 +11,10 @@ #ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ +#include + +#include "api/ref_count.h" +#include "api/video/video_frame.h" #include "api/video/video_rotation.h" #include "api/video/video_sink_interface.h" #include "modules/video_capture/raw_video_sink_interface.h" diff --git a/modules/video_capture/video_capture_defines.h b/modules/video_capture/video_capture_defines.h index 63534600a9..f814e4e7f5 100644 --- a/modules/video_capture/video_capture_defines.h +++ b/modules/video_capture/video_capture_defines.h @@ -11,7 +11,8 @@ #ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_ #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_ -#include "api/video/video_frame.h" +#include + #include "common_video/libyuv/include/webrtc_libyuv.h" namespace webrtc { diff --git a/modules/video_capture/video_capture_factory.cc b/modules/video_capture/video_capture_factory.cc index 8354067f93..d7fa0fa26e 100644 --- a/modules/video_capture/video_capture_factory.cc +++ b/modules/video_capture/video_capture_factory.cc @@ -10,6 +10,8 @@ #include "modules/video_capture/video_capture_factory.h" +#include "api/scoped_refptr.h" +#include "modules/video_capture/video_capture.h" #include "modules/video_capture/video_capture_impl.h" namespace webrtc { diff --git a/modules/video_capture/video_capture_factory.h b/modules/video_capture/video_capture_factory.h index c24eaf559f..e669470e35 100644 --- a/modules/video_capture/video_capture_factory.h +++ b/modules/video_capture/video_capture_factory.h @@ -16,7 +16,6 @@ #include "api/scoped_refptr.h" #include "modules/video_capture/video_capture.h" -#include "modules/video_capture/video_capture_defines.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { diff --git a/modules/video_capture/video_capture_factory_null.cc b/modules/video_capture/video_capture_factory_null.cc index 77b7f4b75e..4dbc7b9f5c 100644 --- a/modules/video_capture/video_capture_factory_null.cc +++ b/modules/video_capture/video_capture_factory_null.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "api/scoped_refptr.h" +#include "modules/video_capture/video_capture.h" #include "modules/video_capture/video_capture_impl.h" namespace webrtc { diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc index 06f9bd3165..6e205a215f 100644 --- a/modules/video_capture/video_capture_impl.cc +++ b/modules/video_capture/video_capture_impl.cc @@ -10,17 +10,28 @@ #include "modules/video_capture/video_capture_impl.h" -#include -#include +#include +#include +#include +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" #include "api/video/i420_buffer.h" -#include "api/video/video_frame_buffer.h" +#include "api/video/video_frame.h" +#include "api/video/video_rotation.h" +#include "api/video/video_sink_interface.h" #include "common_video/libyuv/include/webrtc_libyuv.h" +#include "modules/video_capture/raw_video_sink_interface.h" #include "modules/video_capture/video_capture_config.h" +#include "modules/video_capture/video_capture_defines.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/race_checker.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" -#include "third_party/libyuv/include/libyuv.h" +#include "third_party/libyuv/include/libyuv/convert.h" +#include "third_party/libyuv/include/libyuv/rotate.h" namespace webrtc { namespace videocapturemodule { @@ -73,12 +84,12 @@ int32_t VideoCaptureImpl::RotationInDegrees(VideoRotation rotation, } VideoCaptureImpl::VideoCaptureImpl() - : _deviceUniqueId(NULL), + : _deviceUniqueId(nullptr), _requestedCapability(), _lastProcessTimeNanos(TimeNanos()), _lastFrameRateCallbackTimeNanos(TimeNanos()), - _dataCallBack(NULL), - _rawDataCallBack(NULL), + _dataCallBack(nullptr), + _rawDataCallBack(nullptr), _lastProcessFrameTimeNanos(TimeNanos()), _rotateFrame(kVideoRotation_0), apply_rotation_(false) { @@ -112,8 +123,8 @@ void VideoCaptureImpl::RegisterCaptureDataCallback( void VideoCaptureImpl::DeRegisterCaptureDataCallback() { MutexLock lock(&api_lock_); - _dataCallBack = NULL; - _rawDataCallBack = NULL; + _dataCallBack = nullptr; + _rawDataCallBack = nullptr; } int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) { RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h index 3ec832f871..d3ac5fe5ef 100644 --- a/modules/video_capture/video_capture_impl.h +++ b/modules/video_capture/video_capture_impl.h @@ -23,12 +23,14 @@ #include "api/video/video_frame.h" #include "api/video/video_rotation.h" #include "api/video/video_sink_interface.h" +#include "modules/video_capture/raw_video_sink_interface.h" #include "modules/video_capture/video_capture.h" #include "modules/video_capture/video_capture_config.h" #include "modules/video_capture/video_capture_defines.h" #include "rtc_base/race_checker.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/rtc_export.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/modules/video_capture/video_capture_options.cc b/modules/video_capture/video_capture_options.cc index 64cd6216e7..dd102df9db 100644 --- a/modules/video_capture/video_capture_options.cc +++ b/modules/video_capture/video_capture_options.cc @@ -10,6 +10,9 @@ #include "modules/video_capture/video_capture_options.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" + #if defined(WEBRTC_USE_PIPEWIRE) #include "modules/video_capture/linux/pipewire_session.h" #endif diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc index c4bef2d6ca..9a2c322137 100644 --- a/modules/video_capture/windows/device_info_ds.cc +++ b/modules/video_capture/windows/device_info_ds.cc @@ -442,17 +442,18 @@ int32_t DeviceInfoDS::CreateCapabilityMap(const char* deviceUniqueIdUTF8) LONGLONG* frameDurationList = NULL; LONGLONG maxFPS = 0; long listSize = 0; - SIZE size; - size.cx = capability.width; - size.cy = capability.height; + SIZE requested_size; + requested_size.cx = capability.width; + requested_size.cy = capability.height; // GetMaxAvailableFrameRate doesn't return max frame rate always // eg: Logitech Notebook. This may be due to a bug in that API // because GetFrameRateList array is reversed in the above camera. So // a util method written. Can't assume the first value will return // the max fps. - hrVC = videoControlConfig->GetFrameRateList( - outputCapturePin, tmp, size, &listSize, &frameDurationList); + hrVC = videoControlConfig->GetFrameRateList(outputCapturePin, tmp, + requested_size, &listSize, + &frameDurationList); if (hrVC == S_OK) { maxFPS = GetMaxOfFrameArray(frameDurationList, listSize); diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index d308040153..52c391dc3f 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -619,7 +619,7 @@ rtc_library("webrtc_vp8") { } } -rtc_source_set("webrtc_vp8_scalability") { +rtc_library("webrtc_vp8_scalability") { sources = [ "codecs/vp8/vp8_scalability.cc", "codecs/vp8/vp8_scalability.h", @@ -981,13 +981,14 @@ if (rtc_include_tests) { "../../media:media_constants", "../../media:rtc_audio_video", "../../rtc_base:checks", + "../../rtc_base:cpu_info", "../../rtc_base:logging", "../../rtc_base:rtc_base_tests_utils", "../../rtc_base:stringutils", "../../rtc_base:task_queue_for_test", + "../../rtc_base:threading", "../../rtc_base:timeutils", "../../rtc_base/system:file_wrapper", - "../../system_wrappers", "../../test:fileutils", "../../test:test_support", "../../test:video_frame_writer", diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index d0c513e91b..339a508256 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -124,10 +125,22 @@ class LibaomAv1Encoder final : public VideoEncoder { void SetSvcRefFrameConfig( const ScalableVideoController::LayerFrameConfig& layer_frame); // If pixel format doesn't match, then reallocate. - void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt); + void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt, + unsigned int width, + unsigned int height); + + // Adjust sclaing factors assuming that the top active SVC layer + // will be the input resolution. + void AdjustScalingFactorsForTopActiveLayer(); std::unique_ptr svc_controller_; std::optional scalability_mode_; + // Original scaling factors for all configured layers active and inactive. + // `svc_params_` stores factors ignoring top inactive layers. + std::vector scaling_factors_num_; + std::vector scaling_factors_den_; + int last_active_layer_ = 0; + bool inited_; bool rates_configured_; std::optional svc_params_; @@ -469,9 +482,19 @@ bool LibaomAv1Encoder::SetSvcParams( 1 << (svc_config.num_temporal_layers - tid - 1); } + scaling_factors_den_.resize(svc_config.num_spatial_layers); + scaling_factors_num_.resize(svc_config.num_spatial_layers); for (int sid = 0; sid < svc_config.num_spatial_layers; ++sid) { + scaling_factors_num_[sid] = svc_config.scaling_factor_num[sid]; svc_params.scaling_factor_num[sid] = svc_config.scaling_factor_num[sid]; + scaling_factors_den_[sid] = svc_config.scaling_factor_den[sid]; svc_params.scaling_factor_den[sid] = svc_config.scaling_factor_den[sid]; + encoder_settings_.spatialLayers[sid].width = encoder_settings_.width * + scaling_factors_num_[sid] / + scaling_factors_den_[sid]; + encoder_settings_.spatialLayers[sid].height = encoder_settings_.height * + scaling_factors_num_[sid] / + scaling_factors_den_[sid]; } // svc_params.layer_target_bitrate is set in SetRates() before svc_params is @@ -540,21 +563,61 @@ int32_t LibaomAv1Encoder::Release() { return WEBRTC_VIDEO_CODEC_OK; } -void LibaomAv1Encoder::MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt) { +void LibaomAv1Encoder::MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt, + unsigned int width, + unsigned int height) { if (!frame_for_encode_) { - frame_for_encode_ = - aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); - - } else if (frame_for_encode_->fmt != fmt) { + RTC_LOG(LS_INFO) << "Configuring AV1 encoder pixel format to " + << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420") << " " + << width << "x" << height; + frame_for_encode_ = aom_img_wrap(nullptr, fmt, width, height, 1, nullptr); + } else if (frame_for_encode_->fmt != fmt || frame_for_encode_->d_w != width || + frame_for_encode_->d_h != height) { RTC_LOG(LS_INFO) << "Switching AV1 encoder pixel format to " - << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420"); + << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420") << " " + << width << "x" << height; aom_img_free(frame_for_encode_); - frame_for_encode_ = - aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); + frame_for_encode_ = aom_img_wrap(nullptr, fmt, width, height, 1, nullptr); } // else no-op since the image is already in the right format. } +void LibaomAv1Encoder::AdjustScalingFactorsForTopActiveLayer() { + if (!SvcEnabled()) + return; + last_active_layer_ = svc_params_->number_spatial_layers - 1; + for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { + for (int tid = 0; tid < svc_params_->number_temporal_layers; ++tid) { + int layer_index = sid * svc_params_->number_temporal_layers + tid; + if (svc_params_->layer_target_bitrate[layer_index] > 0) { + last_active_layer_ = sid; + } + } + } + if (static_cast(cfg_.g_w) == + encoder_settings_.spatialLayers[last_active_layer_].width) { + return; + } + + cfg_.g_w = encoder_settings_.spatialLayers[last_active_layer_].width; + cfg_.g_h = encoder_settings_.spatialLayers[last_active_layer_].height; + + // Recalculate scaling factors ignoring top inactive layers. + // Divide all by scaling factor of the last active layer. + for (int i = 0; i <= last_active_layer_; ++i) { + int n = scaling_factors_num_[i] * scaling_factors_den_[last_active_layer_]; + int d = scaling_factors_den_[i] * scaling_factors_num_[last_active_layer_]; + int gcd = std::gcd(n, d); + svc_params_->scaling_factor_num[i] = n / gcd; + svc_params_->scaling_factor_den[i] = d / gcd; + } + for (int i = last_active_layer_ + 1; i < svc_params_->number_spatial_layers; + ++i) { + svc_params_->scaling_factor_num[i] = 1; + svc_params_->scaling_factor_den[i] = 1; + } +} + int32_t LibaomAv1Encoder::Encode( const VideoFrame& frame, const std::vector* frame_types) { @@ -578,13 +641,24 @@ int32_t LibaomAv1Encoder::Encode( absl::InlinedVector supported_formats = {VideoFrameBuffer::Type::kI420, VideoFrameBuffer::Type::kNV12}; + + scoped_refptr scaled_image; + if (!SvcEnabled() || + last_active_layer_ + 1 == svc_params_->number_spatial_layers) { + scaled_image = buffer; + } else { + scaled_image = buffer->Scale( + encoder_settings_.spatialLayers[last_active_layer_].width, + encoder_settings_.spatialLayers[last_active_layer_].height); + } + scoped_refptr mapped_buffer; - if (buffer->type() != VideoFrameBuffer::Type::kNative) { + if (scaled_image->type() != VideoFrameBuffer::Type::kNative) { // `buffer` is already mapped. - mapped_buffer = buffer; + mapped_buffer = scaled_image; } else { // Attempt to map to one of the supported formats. - mapped_buffer = buffer->GetMappedFrameBuffer(supported_formats); + mapped_buffer = scaled_image->GetMappedFrameBuffer(supported_formats); } // Convert input frame to I420, if needed. @@ -610,7 +684,8 @@ int32_t LibaomAv1Encoder::Encode( case VideoFrameBuffer::Type::kI420: case VideoFrameBuffer::Type::kI420A: { // Set frame_for_encode_ data pointers and strides. - MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420); + MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420, mapped_buffer->width(), + mapped_buffer->height()); auto i420_buffer = mapped_buffer->GetI420(); RTC_DCHECK(i420_buffer); RTC_CHECK_EQ(i420_buffer->width(), frame_for_encode_->d_w); @@ -627,7 +702,8 @@ int32_t LibaomAv1Encoder::Encode( break; } case VideoFrameBuffer::Type::kNV12: { - MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12); + MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12, mapped_buffer->width(), + mapped_buffer->height()); const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12(); RTC_DCHECK(nv12_buffer); RTC_CHECK_EQ(nv12_buffer->width(), frame_for_encode_->d_w); @@ -725,10 +801,10 @@ int32_t LibaomAv1Encoder::Encode( // If encoded image width/height info are added to aom_codec_cx_pkt_t, // use those values in lieu of the values in frame. if (svc_params_) { - int n = svc_params_->scaling_factor_num[layer_frame->SpatialId()]; - int d = svc_params_->scaling_factor_den[layer_frame->SpatialId()]; - encoded_image._encodedWidth = cfg_.g_w * n / d; - encoded_image._encodedHeight = cfg_.g_h * n / d; + int n = scaling_factors_num_[layer_frame->SpatialId()]; + int d = scaling_factors_den_[layer_frame->SpatialId()]; + encoded_image._encodedWidth = encoder_settings_.width * n / d; + encoded_image._encodedHeight = encoder_settings_.height * n / d; encoded_image.SetSpatialIndex(layer_frame->SpatialId()); encoded_image.SetTemporalIndex(layer_frame->TemporalId()); } else { @@ -762,10 +838,11 @@ int32_t LibaomAv1Encoder::Encode( if (SvcEnabled()) { resolutions.resize(svc_params_->number_spatial_layers); for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { - int n = svc_params_->scaling_factor_num[sid]; - int d = svc_params_->scaling_factor_den[sid]; + int n = scaling_factors_num_[sid]; + int d = scaling_factors_den_[sid]; resolutions[sid] = - RenderResolution(cfg_.g_w * n / d, cfg_.g_h * n / d); + RenderResolution(encoder_settings_.width * n / d, + encoder_settings_.height * n / d); } } else { resolutions = {RenderResolution(cfg_.g_w, cfg_.g_h)}; @@ -807,11 +884,6 @@ void LibaomAv1Encoder::SetRates(const RateControlParameters& parameters) { // total target bitrate is not updated first a division by zero could happen. svc_controller_->OnRatesUpdated(parameters.bitrate); cfg_.rc_target_bitrate = parameters.bitrate.get_sum_kbps(); - aom_codec_err_t error_code = aom_codec_enc_config_set(&ctx_, &cfg_); - if (error_code != AOM_CODEC_OK) { - RTC_LOG(LS_WARNING) << "Error configuring encoder, error code: " - << error_code; - } if (SvcEnabled()) { for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { @@ -824,9 +896,17 @@ void LibaomAv1Encoder::SetRates(const RateControlParameters& parameters) { parameters.bitrate.GetTemporalLayerSum(sid, tid) / 1000; } } + AdjustScalingFactorsForTopActiveLayer(); SetEncoderControlParameters(AV1E_SET_SVC_PARAMS, &*svc_params_); } + // AdjustScalingFactorsForTopActiveLayer() may update `cfg_`. + aom_codec_err_t error_code = aom_codec_enc_config_set(&ctx_, &cfg_); + if (error_code != AOM_CODEC_OK) { + RTC_LOG(LS_WARNING) << "Error configuring encoder, error code: " + << error_code; + } + framerate_fps_ = parameters.framerate_fps; rates_configured_ = true; diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc index 33b750cdc6..0bbf6a2814 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc @@ -37,6 +37,7 @@ #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/video_coding/codecs/av1/av1_svc_config.h" #include "modules/video_coding/codecs/test/encoded_video_frame_producer.h" #include "modules/video_coding/include/video_error_codes.h" #include "rtc_base/checks.h" @@ -68,6 +69,18 @@ VideoCodec DefaultCodecSettings() { return codec_settings; } +VideoCodec HDCodecSettings() { + VideoCodec codec_settings; + codec_settings.codecType = kVideoCodecAV1; + codec_settings.width = 1280; + codec_settings.height = 720; + codec_settings.maxFramerate = 30; + codec_settings.startBitrate = 2048; + codec_settings.maxBitrate = 2048; + codec_settings.qpMax = 63; + return codec_settings; +} + VideoEncoder::Settings DefaultEncoderSettings() { return VideoEncoder::Settings( VideoEncoder::Capabilities(/*loss_notification=*/false), @@ -592,5 +605,87 @@ TEST(LibaomAv1EncoderTest, PostEncodeFrameDrop) { RTC_CHECK_EQ(callback.frames_encoded(), 1); } +TEST(LibaomAv1EncoderTest, EnableDisableSpatialLayersWithSvcController) { + constexpr int kNumSpatialLayers = 3; + constexpr int kNumTemporalLayers = 1; + constexpr size_t kWidth = 1280; + constexpr size_t kHeight = 720; + + // Configure encoder to produce 3 spatial layers. Encode frames of layer 0 + // then enable layer 1 and encode more frames and so on. + // Then disable layers one by one in the same way. + // Note: bit rate allocation is high to avoid frame dropping due to rate + // control, the encoder should always produce a frame. A dropped + // frame indicates a problem and the test will fail. + std::unique_ptr encoder = + CreateLibaomAv1Encoder(CreateEnvironment()); + VideoCodec codec_settings = HDCodecSettings(); + SetAv1SvcConfig(codec_settings, kNumTemporalLayers, kNumSpatialLayers); + codec_settings.SetFrameDropEnabled(true); + EXPECT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()), + WEBRTC_VIDEO_CODEC_OK); + + EncodedVideoFrameProducer producer(*encoder); + producer.SetResolution({kWidth, kHeight}); + + VideoBitrateAllocation bitrate_allocation; + + // Set all layers active for initial allocation. + for (size_t sl_idx = 0; sl_idx < kNumSpatialLayers; ++sl_idx) { + // Allocate high bit rate to avoid frame dropping due to rate control. + bitrate_allocation.SetBitrate( + sl_idx, 0, + codec_settings.spatialLayers[sl_idx].targetBitrate * 1000 * 2); + } + + encoder->SetRates(VideoEncoder::RateControlParameters( + bitrate_allocation, codec_settings.maxFramerate)); + + // Encode a key frame to validate all other frames are delta frames. + std::vector frames = + producer.SetNumInputFrames(1).Encode(); + ASSERT_THAT(frames, Not(IsEmpty())); + EXPECT_TRUE(frames[0].codec_specific_info.template_structure); + + constexpr size_t kNumFramesToEncode = 5; + + // Disable layers one by one. + for (int sl_idx = kNumSpatialLayers - 1; sl_idx > 0; --sl_idx) { + bitrate_allocation.SetBitrate(sl_idx, 0, 0); + encoder->SetRates(VideoEncoder::RateControlParameters( + bitrate_allocation, codec_settings.maxFramerate)); + + frames = producer.SetNumInputFrames(kNumFramesToEncode).Encode(); + // With `sl_idx` spatial layer disabled, there are `sl_idx` spatial layers + // left. + ASSERT_THAT(frames, SizeIs(kNumFramesToEncode * sl_idx)); + for (size_t i = 0; i < frames.size(); ++i) { + EXPECT_TRUE(frames[i].codec_specific_info.generic_frame_info); + EXPECT_FALSE(frames[i].codec_specific_info.template_structure); + } + } + + // Enable layers back one by one. + for (size_t sl_idx = 1; sl_idx < kNumSpatialLayers; ++sl_idx) { + // Allocate high bit rate to avoid frame dropping due to rate control. + bitrate_allocation.SetBitrate( + sl_idx, 0, + codec_settings.spatialLayers[sl_idx].targetBitrate * 1000 * 2); + encoder->SetRates(VideoEncoder::RateControlParameters( + bitrate_allocation, codec_settings.maxFramerate)); + + frames = producer.SetNumInputFrames(kNumFramesToEncode).Encode(); + // With (sl_idx+1) spatial layers expect (sl_idx+1) frames per input frame. + ASSERT_THAT(frames, SizeIs(kNumFramesToEncode * (sl_idx + 1))); + // Only the first frame after enabling the layer must be a keyframe. + EXPECT_TRUE(frames[0].codec_specific_info.generic_frame_info); + EXPECT_TRUE(frames[0].codec_specific_info.template_structure); + for (size_t i = 1; i < frames.size(); ++i) { + EXPECT_TRUE(frames[i].codec_specific_info.generic_frame_info); + EXPECT_FALSE(frames[i].codec_specific_info.template_structure); + } + } +} + } // namespace } // namespace webrtc diff --git a/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc b/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc index 985224d07e..6e9e58e717 100644 --- a/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc +++ b/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc @@ -42,7 +42,7 @@ class TestH264Impl : public VideoCodecUnitTest { } void ModifyCodecSettings(VideoCodec* codec_settings) override { - webrtc::test::CodecSettings(kVideoCodecH264, codec_settings); + test::CodecSettings(kVideoCodecH264, codec_settings); } }; diff --git a/modules/video_coding/codecs/test/video_codec_unittest.cc b/modules/video_coding/codecs/test/video_codec_unittest.cc index 54be5b3c99..966da6b879 100644 --- a/modules/video_coding/codecs/test/video_codec_unittest.cc +++ b/modules/video_coding/codecs/test/video_codec_unittest.cc @@ -81,7 +81,7 @@ void VideoCodecUnitTest::FakeDecodeCompleteCallback::Decoded( } void VideoCodecUnitTest::SetUp() { - webrtc::test::CodecSettings(kVideoCodecVP8, &codec_settings_); + test::CodecSettings(kVideoCodecVP8, &codec_settings_); codec_settings_.startBitrate = kStartBitrate; codec_settings_.maxBitrate = kMaxBitrate; codec_settings_.maxFramerate = kMaxFramerate; diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_config_unittest.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_config_unittest.cc index d9d43e067b..581a6286a5 100644 --- a/modules/video_coding/codecs/test/videocodec_test_fixture_config_unittest.cc +++ b/modules/video_coding/codecs/test/videocodec_test_fixture_config_unittest.cc @@ -42,20 +42,20 @@ TEST(Config, NumberOfCoresWithoutUseSingleCore) { TEST(Config, NumberOfTemporalLayersIsOne) { Config config; - webrtc::test::CodecSettings(kVideoCodecH264, &config.codec_settings); + test::CodecSettings(kVideoCodecH264, &config.codec_settings); EXPECT_EQ(1u, config.NumberOfTemporalLayers()); } TEST(Config, NumberOfTemporalLayers_Vp8) { Config config; - webrtc::test::CodecSettings(kVideoCodecVP8, &config.codec_settings); + test::CodecSettings(kVideoCodecVP8, &config.codec_settings); config.codec_settings.VP8()->numberOfTemporalLayers = kNumTemporalLayers; EXPECT_EQ(kNumTemporalLayers, config.NumberOfTemporalLayers()); } TEST(Config, NumberOfTemporalLayers_Vp9) { Config config; - webrtc::test::CodecSettings(kVideoCodecVP9, &config.codec_settings); + test::CodecSettings(kVideoCodecVP9, &config.codec_settings); config.codec_settings.VP9()->numberOfTemporalLayers = kNumTemporalLayers; EXPECT_EQ(kNumTemporalLayers, config.NumberOfTemporalLayers()); } diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc index 5974266285..5732dccc6d 100644 --- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc +++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc @@ -65,15 +65,15 @@ #include "modules/video_coding/codecs/vp9/svc_config.h" #include "modules/video_coding/utility/ivf_file_writer.h" #include "rtc_base/checks.h" +#include "rtc_base/cpu_info.h" #include "rtc_base/cpu_time.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/system_time.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/cpu_info.h" -#include "system_wrappers/include/sleep.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" #include "test/testsupport/frame_reader.h" @@ -229,7 +229,7 @@ void VideoCodecTestFixtureImpl::Config::SetCodecSettings( size_t height) { codec_name = codec_name_to_set; VideoCodecType codec_type = PayloadStringToCodecType(codec_name); - webrtc::test::CodecSettings(codec_type, &codec_settings); + test::CodecSettings(codec_type, &codec_settings); // TODO(brandtr): Move the setting of `width` and `height` to the tests, and // DCHECK that they are set before initializing the codec instead. @@ -296,7 +296,7 @@ void VideoCodecTestFixtureImpl::Config::SetCodecSettings( } size_t VideoCodecTestFixtureImpl::Config::NumberOfCores() const { - return use_single_core ? 1 : CpuInfo::DetectNumberOfCores(); + return use_single_core ? 1 : cpu_info::DetectNumberOfCores(); } size_t VideoCodecTestFixtureImpl::Config::NumberOfTemporalLayers() const { @@ -390,22 +390,22 @@ std::string VideoCodecTestFixtureImpl::Config::CodecName() const { // TODO(kthelgason): Move this out of the test fixture impl and // make available as a shared utility class. void VideoCodecTestFixtureImpl::H264KeyframeChecker::CheckEncodedFrame( - webrtc::VideoCodecType codec, + VideoCodecType codec, const EncodedImage& encoded_frame) const { EXPECT_EQ(kVideoCodecH264, codec); bool contains_sps = false; bool contains_pps = false; bool contains_idr = false; - const std::vector nalu_indices = - webrtc::H264::FindNaluIndices(encoded_frame); - for (const webrtc::H264::NaluIndex& index : nalu_indices) { - webrtc::H264::NaluType nalu_type = webrtc::H264::ParseNaluType( - encoded_frame.data()[index.payload_start_offset]); - if (nalu_type == webrtc::H264::NaluType::kSps) { + const std::vector nalu_indices = + H264::FindNaluIndices(encoded_frame); + for (const H264::NaluIndex& index : nalu_indices) { + H264::NaluType nalu_type = + H264::ParseNaluType(encoded_frame.data()[index.payload_start_offset]); + if (nalu_type == H264::NaluType::kSps) { contains_sps = true; - } else if (nalu_type == webrtc::H264::NaluType::kPps) { + } else if (nalu_type == H264::NaluType::kPps) { contains_pps = true; - } else if (nalu_type == webrtc::H264::NaluType::kIdr) { + } else if (nalu_type == H264::NaluType::kIdr) { contains_idr = true; } } @@ -457,16 +457,18 @@ class VideoCodecTestFixtureImpl::CpuProcessTime final { }; VideoCodecTestFixtureImpl::VideoCodecTestFixtureImpl(Config config) - : encoder_factory_(std::make_unique>()), - decoder_factory_(std::make_unique>()), + : encoder_factory_( + std::make_unique< + VideoEncoderFactoryTemplate>()), + decoder_factory_( + std::make_unique< + VideoDecoderFactoryTemplate>()), env_(CreateEnvironment()), config_(config) {} @@ -537,7 +539,7 @@ void VideoCodecTestFixtureImpl::ProcessAllFrames( // Roughly pace the frames. const int frame_duration_ms = std::ceil(kNumMillisecsPerSec / rate_profile->input_fps); - SleepMs(frame_duration_ms); + Thread::SleepMs(frame_duration_ms); } } @@ -548,7 +550,7 @@ void VideoCodecTestFixtureImpl::ProcessAllFrames( // Give the VideoProcessor pipeline some time to process the last frame, // and then release the codecs. - SleepMs(1 * kNumMillisecsPerSec); + Thread::SleepMs(1 * kNumMillisecsPerSec); cpu_process_time_->Stop(); } diff --git a/modules/video_coding/codecs/test/videocodec_test_libvpx.cc b/modules/video_coding/codecs/test/videocodec_test_libvpx.cc index 481fc775c1..c67790d959 100644 --- a/modules/video_coding/codecs/test/videocodec_test_libvpx.cc +++ b/modules/video_coding/codecs/test/videocodec_test_libvpx.cc @@ -51,7 +51,7 @@ const size_t kNumFirstFramesToSkipAtRdPerfAnalysis = 60; class QpFrameChecker : public VideoCodecTestFixture::EncodedFrameChecker { public: - void CheckEncodedFrame(webrtc::VideoCodecType codec, + void CheckEncodedFrame(VideoCodecType codec, const EncodedImage& encoded_frame) const override { int qp; if (codec == kVideoCodecVP8) { diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc index 5b5c2bb80a..bec0e353c6 100644 --- a/modules/video_coding/codecs/test/videoprocessor.cc +++ b/modules/video_coding/codecs/test/videoprocessor.cc @@ -70,13 +70,13 @@ size_t GetMaxNaluSizeBytes(const EncodedImage& encoded_frame, if (config.codec_settings.codecType != kVideoCodecH264) return 0; - std::vector nalu_indices = - webrtc::H264::FindNaluIndices(encoded_frame); + std::vector nalu_indices = + H264::FindNaluIndices(encoded_frame); RTC_CHECK(!nalu_indices.empty()); size_t max_size = 0; - for (const webrtc::H264::NaluIndex& index : nalu_indices) + for (const H264::NaluIndex& index : nalu_indices) max_size = std::max(max_size, index.payload_size); return max_size; @@ -155,7 +155,7 @@ void CalculateFrameQuality(const I420BufferInterface& ref_buffer, } // namespace VideoProcessor::VideoProcessor(const Environment& env, - webrtc::VideoEncoder* encoder, + VideoEncoder* encoder, VideoDecoderList* decoders, FrameReader* input_frame_reader, const VideoCodecTestFixture::Config& config, @@ -275,7 +275,7 @@ void VideoProcessor::ProcessFrame() { .set_video_frame_buffer(buffer) .set_rtp_timestamp(static_cast(timestamp)) .set_timestamp_ms(static_cast(timestamp / kMsToRtpTimestamp)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .build(); // Store input frame as a reference for quality calculations. if (config_.decode && !config_.measure_cpu) { @@ -382,9 +382,8 @@ int32_t VideoProcessor::VideoProcessorDecodeCompleteCallback::Decoded( return 0; } -void VideoProcessor::FrameEncoded( - const webrtc::EncodedImage& encoded_image, - const webrtc::CodecSpecificInfo& codec_specific) { +void VideoProcessor::FrameEncoded(const EncodedImage& encoded_image, + const CodecSpecificInfo& codec_specific) { RTC_DCHECK_RUN_ON(&sequence_checker_); // For the highest measurement accuracy of the encode time, the start/stop @@ -457,7 +456,7 @@ void VideoProcessor::FrameEncoded( frame_stat->non_ref_for_inter_layer_pred = true; } - const webrtc::EncodedImage* encoded_image_for_decode = &encoded_image; + const EncodedImage* encoded_image_for_decode = &encoded_image; if (config_.decode || !encoded_frame_writers_->empty()) { if (num_spatial_layers > 1) { encoded_image_for_decode = BuildAndStoreSuperframe( @@ -660,7 +659,7 @@ void VideoProcessor::DecodeFrame(const EncodedImage& encoded_image, decoders_->at(spatial_idx)->Decode(encoded_image, 0); } -const webrtc::EncodedImage* VideoProcessor::BuildAndStoreSuperframe( +const EncodedImage* VideoProcessor::BuildAndStoreSuperframe( const EncodedImage& encoded_image, const VideoCodecType /* codec */, size_t /* frame_number */, diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc index 3eef8e5c11..741c4628d2 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc @@ -123,9 +123,9 @@ LibvpxVp8Decoder::LibvpxVp8Decoder(const Environment& env) kIsArm ? env.field_trials().IsEnabled(kVp8PostProcArmFieldTrial) : true), buffer_pool_(false, 300 /* max_number_of_buffers*/), - decode_complete_callback_(NULL), + decode_complete_callback_(nullptr), inited_(false), - decoder_(NULL), + decoder_(nullptr), last_frame_width_(0), last_frame_height_(0), key_frame_required_(true), @@ -143,7 +143,7 @@ bool LibvpxVp8Decoder::Configure(const Settings& settings) { if (Release() < 0) { return false; } - if (decoder_ == NULL) { + if (decoder_ == nullptr) { decoder_ = new vpx_codec_ctx_t; memset(decoder_, 0, sizeof(*decoder_)); } @@ -183,10 +183,10 @@ int LibvpxVp8Decoder::Decode(const EncodedImage& input_image, if (!inited_) { return WEBRTC_VIDEO_CODEC_UNINITIALIZED; } - if (decode_complete_callback_ == NULL) { + if (decode_complete_callback_ == nullptr) { return WEBRTC_VIDEO_CODEC_UNINITIALIZED; } - if (input_image.data() == NULL && input_image.size() > 0) { + if (input_image.data() == nullptr && input_image.size() > 0) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } @@ -242,14 +242,14 @@ int LibvpxVp8Decoder::Decode(const EncodedImage& input_image, const uint8_t* buffer = input_image.data(); if (input_image.size() == 0) { - buffer = NULL; // Triggers full frame concealment. + buffer = nullptr; // Triggers full frame concealment. } - if (vpx_codec_decode(decoder_, buffer, input_image.size(), 0, + if (vpx_codec_decode(decoder_, buffer, input_image.size(), nullptr, kDecodeDeadlineRealtime)) { return WEBRTC_VIDEO_CODEC_ERROR; } - vpx_codec_iter_t iter = NULL; + vpx_codec_iter_t iter = nullptr; vpx_image_t* img = vpx_codec_get_frame(decoder_, &iter); int qp; vpx_codec_err_t vpx_ret = @@ -263,12 +263,11 @@ int LibvpxVp8Decoder::Decode(const EncodedImage& input_image, return WEBRTC_VIDEO_CODEC_OK; } -int LibvpxVp8Decoder::ReturnFrame( - const vpx_image_t* img, - uint32_t timestamp, - int qp, - const webrtc::ColorSpace* explicit_color_space) { - if (img == NULL) { +int LibvpxVp8Decoder::ReturnFrame(const vpx_image_t* img, + uint32_t timestamp, + int qp, + const ColorSpace* explicit_color_space) { + if (img == nullptr) { // Decoder OK and NULL image => No show frame return WEBRTC_VIDEO_CODEC_NO_OUTPUT; } @@ -323,14 +322,14 @@ int LibvpxVp8Decoder::RegisterDecodeCompleteCallback( int LibvpxVp8Decoder::Release() { int ret_val = WEBRTC_VIDEO_CODEC_OK; - if (decoder_ != NULL) { + if (decoder_ != nullptr) { if (inited_) { if (vpx_codec_destroy(decoder_)) { ret_val = WEBRTC_VIDEO_CODEC_MEMORY; } } delete decoder_; - decoder_ = NULL; + decoder_ = nullptr; } buffer_pool_.Release(); inited_ = false; diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc index 1ec4ab985b..4557a4fab1 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc @@ -499,7 +499,7 @@ void LibvpxVp8Encoder::SetFecControllerOverride( // TODO(eladalon): s/inst/codec_settings/g. int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst, const VideoEncoder::Settings& settings) { - if (inst == NULL) { + if (inst == nullptr) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } if (inst->maxFramerate < 1) { @@ -696,7 +696,7 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst, // Actual pointer will be set in encode. Setting align to 1, as it // is meaningless (no memory allocation is done here). libvpx_->img_wrap(&raw_images_[0], pixel_format, inst->width, inst->height, 1, - NULL); + nullptr); // Note the order we use is different from webm, we have lowest resolution // at position 0 and they have highest resolution at position 0. @@ -778,7 +778,7 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst, // to converge somewhat. Set a minim filter size of 1.25 since some // outlier pixels deviate a bit from truth even at very low QP, // seeminly by bleeding into neighbours. - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{ + CorruptionDetectionSettingsGenerator::TransientParameters{ .max_qp = 127, .keyframe_threshold_offset = 1, .keyframe_stddev_offset = 2.0, @@ -1020,7 +1020,7 @@ int LibvpxVp8Encoder::Encode(const VideoFrame& frame, if (!inited_) return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - if (encoded_complete_callback_ == NULL) + if (encoded_complete_callback_ == nullptr) return WEBRTC_VIDEO_CODEC_UNINITIALIZED; bool key_frame_requested = false; @@ -1236,15 +1236,15 @@ int LibvpxVp8Encoder::GetEncodedPartitions(const VideoFrame& input_image, int result = WEBRTC_VIDEO_CODEC_OK; for (size_t encoder_idx = 0; encoder_idx < encoders_.size(); ++encoder_idx, --stream_idx) { - vpx_codec_iter_t iter = NULL; + vpx_codec_iter_t iter = nullptr; encoded_images_[encoder_idx].set_size(0); encoded_images_[encoder_idx]._frameType = VideoFrameType::kVideoFrameDelta; CodecSpecificInfo codec_specific; - const vpx_codec_cx_pkt_t* pkt = NULL; + const vpx_codec_cx_pkt_t* pkt = nullptr; size_t encoded_size = 0; while ((pkt = libvpx_->codec_get_cx_data(&encoders_[encoder_idx], &iter)) != - NULL) { + nullptr) { if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) { encoded_size += pkt->data.frame.sz; } @@ -1252,10 +1252,10 @@ int LibvpxVp8Encoder::GetEncodedPartitions(const VideoFrame& input_image, auto buffer = EncodedImageBuffer::Create(encoded_size); - iter = NULL; + iter = nullptr; size_t encoded_pos = 0; while ((pkt = libvpx_->codec_get_cx_data(&encoders_[encoder_idx], &iter)) != - NULL) { + nullptr) { switch (pkt->kind) { case VPX_CODEC_CX_FRAME_PKT: { RTC_CHECK_LE(encoded_pos + pkt->data.frame.sz, buffer->size()); @@ -1435,7 +1435,7 @@ void LibvpxVp8Encoder::MaybeUpdatePixelFormat(vpx_img_fmt fmt) { libvpx_->img_free(&img); // First image is wrapping the input frame, the rest are allocated. if (i == 0) { - libvpx_->img_wrap(&img, fmt, d_w, d_h, 1, NULL); + libvpx_->img_wrap(&img, fmt, d_w, d_h, 1, nullptr); } else { libvpx_->img_alloc(&img, fmt, d_w, d_h, kVp832ByteAlign); } diff --git a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc index c0aca08ca1..2f537f0a91 100644 --- a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc +++ b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc @@ -70,9 +70,8 @@ using ::testing::NiceMock; using ::testing::Return; using ::testing::Values; using ::testing::WithParamInterface; -using EncoderInfo = webrtc::VideoEncoder::EncoderInfo; -using FramerateFractions = - absl::InlinedVector; +using EncoderInfo = VideoEncoder::EncoderInfo; +using FramerateFractions = absl::InlinedVector; namespace { constexpr uint32_t kLegacyScreenshareTl0BitrateKbps = 200; @@ -103,7 +102,7 @@ class TestVp8Impl : public VideoCodecUnitTest { } void ModifyCodecSettings(VideoCodec* codec_settings) override { - webrtc::test::CodecSettings(kVideoCodecVP8, codec_settings); + test::CodecSettings(kVideoCodecVP8, codec_settings); codec_settings->width = kWidth; codec_settings->height = kHeight; codec_settings->SetVideoEncoderComplexity( diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc index 4d4e147d50..e6d9f96a8f 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc @@ -245,7 +245,7 @@ int LibvpxVp9Decoder::Decode(const EncodedImage& input_image, // `libvpx_buffer_pool_`. In practice libvpx keeps a few (~3-4) buffers alive // at a time. if (vpx_codec_decode(decoder_, buffer, - static_cast(input_image.size()), 0, + static_cast(input_image.size()), nullptr, VPX_DL_REALTIME)) { return WEBRTC_VIDEO_CODEC_ERROR; } @@ -265,11 +265,10 @@ int LibvpxVp9Decoder::Decode(const EncodedImage& input_image, return WEBRTC_VIDEO_CODEC_OK; } -int LibvpxVp9Decoder::ReturnFrame( - const vpx_image_t* img, - uint32_t timestamp, - int qp, - const webrtc::ColorSpace* explicit_color_space) { +int LibvpxVp9Decoder::ReturnFrame(const vpx_image_t* img, + uint32_t timestamp, + int qp, + const ColorSpace* explicit_color_space) { if (img == nullptr) { // Decoder OK and nullptr image => No show frame. return WEBRTC_VIDEO_CODEC_NO_OUTPUT; diff --git a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc index 3152ccbb1e..e23fe8b561 100644 --- a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc +++ b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc @@ -93,9 +93,8 @@ using ::testing::SizeIs; using ::testing::TypedEq; using ::testing::UnorderedElementsAreArray; using ::testing::WithArg; -using EncoderInfo = webrtc::VideoEncoder::EncoderInfo; -using FramerateFractions = - absl::InlinedVector; +using EncoderInfo = VideoEncoder::EncoderInfo; +using FramerateFractions = absl::InlinedVector; constexpr size_t kWidth = 1280; constexpr size_t kHeight = 720; @@ -108,7 +107,7 @@ const VideoEncoder::Settings kSettings(kCapabilities, VideoCodec DefaultCodecSettings() { VideoCodec codec_settings; - webrtc::test::CodecSettings(kVideoCodecVP9, &codec_settings); + test::CodecSettings(kVideoCodecVP9, &codec_settings); codec_settings.width = kWidth; codec_settings.height = kHeight; codec_settings.startBitrate = kBitrateKbps; @@ -145,7 +144,7 @@ class TestVp9Impl : public VideoCodecUnitTest { } void ModifyCodecSettings(VideoCodec* codec_settings) override { - webrtc::test::CodecSettings(kVideoCodecVP9, codec_settings); + test::CodecSettings(kVideoCodecVP9, codec_settings); codec_settings->width = kWidth; codec_settings->height = kHeight; ConfigureSvc(*codec_settings); @@ -2072,7 +2071,7 @@ INSTANTIATE_TEST_SUITE_P(All, class TestVp9ImplFrameDropping : public TestVp9Impl { protected: void ModifyCodecSettings(VideoCodec* codec_settings) override { - webrtc::test::CodecSettings(kVideoCodecVP9, codec_settings); + test::CodecSettings(kVideoCodecVP9, codec_settings); // We need to encode quite a lot of frames in this test. Use low resolution // to reduce execution time. codec_settings->width = 64; diff --git a/modules/video_coding/deprecated/frame_buffer.cc b/modules/video_coding/deprecated/frame_buffer.cc index 395f596f46..0b7b2a9b7f 100644 --- a/modules/video_coding/deprecated/frame_buffer.cc +++ b/modules/video_coding/deprecated/frame_buffer.cc @@ -35,7 +35,7 @@ VCMFrameBuffer::VCMFrameBuffer() VCMFrameBuffer::~VCMFrameBuffer() {} -webrtc::VideoFrameType VCMFrameBuffer::FrameType() const { +VideoFrameType VCMFrameBuffer::FrameType() const { return _sessionInfo.FrameType(); } @@ -82,8 +82,8 @@ VCMFrameBufferEnum VCMFrameBuffer::InsertPacket(const VCMPacket& packet, int64_t timeInMs, const FrameData& frame_data) { TRACE_EVENT0("webrtc", "VCMFrameBuffer::InsertPacket"); - RTC_DCHECK(!(NULL == packet.dataPtr && packet.sizeBytes > 0)); - if (packet.dataPtr != NULL) { + RTC_DCHECK(!(nullptr == packet.dataPtr && packet.sizeBytes > 0)); + if (packet.dataPtr != nullptr) { _payloadType = packet.payloadType; } diff --git a/modules/video_coding/deprecated/jitter_buffer.cc b/modules/video_coding/deprecated/jitter_buffer.cc index 2e6bd97a9b..dea2437a69 100644 --- a/modules/video_coding/deprecated/jitter_buffer.cc +++ b/modules/video_coding/deprecated/jitter_buffer.cc @@ -56,7 +56,7 @@ void FrameList::InsertFrame(VCMFrameBuffer* frame) { VCMFrameBuffer* FrameList::PopFrame(uint32_t timestamp) { FrameList::iterator it = find(timestamp); if (it == end()) - return NULL; + return nullptr; VCMFrameBuffer* frame = it->second; erase(it); return frame; @@ -271,7 +271,7 @@ VCMEncodedFrame* VCMJitterBuffer::NextCompleteFrame(uint32_t max_wait_time_ms) { VCMEncodedFrame* VCMJitterBuffer::ExtractAndSetDecode(uint32_t timestamp) { MutexLock lock(&mutex_); if (!running_) { - return NULL; + return nullptr; } // Extract the frame with the desired timestamp. VCMFrameBuffer* frame = decodable_frames_.PopFrame(timestamp); @@ -281,7 +281,7 @@ VCMEncodedFrame* VCMJitterBuffer::ExtractAndSetDecode(uint32_t timestamp) { if (frame) continuous = last_decoded_state_.ContinuousFrame(frame); else - return NULL; + return nullptr; } // Frame pulled out from jitter buffer, update the jitter estimate. const bool retransmitted = (frame->GetNackCount() > 0); @@ -330,20 +330,20 @@ VCMFrameBufferEnum VCMJitterBuffer::GetFrame(const VCMPacket& packet, VCMFrameBuffer** frame, FrameList** frame_list) { *frame = incomplete_frames_.PopFrame(packet.timestamp); - if (*frame != NULL) { + if (*frame != nullptr) { *frame_list = &incomplete_frames_; return kNoError; } *frame = decodable_frames_.PopFrame(packet.timestamp); - if (*frame != NULL) { + if (*frame != nullptr) { *frame_list = &decodable_frames_; return kNoError; } - *frame_list = NULL; + *frame_list = nullptr; // No match, return empty frame. *frame = GetEmptyFrame(); - if (*frame == NULL) { + if (*frame == nullptr) { // No free frame! Try to reclaim some... RTC_LOG(LS_WARNING) << "Unable to get empty frame; Recycling."; bool found_key_frame = RecycleFramesUntilKeyFrame(); @@ -499,7 +499,7 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet, case kOutOfBoundsPacket: case kDuplicatePacket: { // Put back the frame where it came from. - if (frame_list != NULL) { + if (frame_list != nullptr) { frame_list->InsertFrame(frame); } else { RecycleFrameBuffer(frame); @@ -686,7 +686,7 @@ VCMFrameBuffer* VCMJitterBuffer::NextFrame() const { return decodable_frames_.Front(); if (!incomplete_frames_.empty()) return incomplete_frames_.Front(); - return NULL; + return nullptr; } bool VCMJitterBuffer::UpdateNackList(uint16_t sequence_number) { @@ -772,7 +772,7 @@ void VCMJitterBuffer::DropPacketsFromNackList( VCMFrameBuffer* VCMJitterBuffer::GetEmptyFrame() { if (free_frames_.empty()) { if (!TryToIncreaseJitterBufferSize()) { - return NULL; + return nullptr; } } VCMFrameBuffer* frame = free_frames_.front(); diff --git a/modules/video_coding/deprecated/jitter_buffer_unittest.cc b/modules/video_coding/deprecated/jitter_buffer_unittest.cc index cc0eaacec7..5c7c265811 100644 --- a/modules/video_coding/deprecated/jitter_buffer_unittest.cc +++ b/modules/video_coding/deprecated/jitter_buffer_unittest.cc @@ -212,7 +212,7 @@ class TestRunningJitterBuffer : public ::testing::Test { VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(found_frame->RtpTimestamp()); - bool ret = (frame != NULL); + bool ret = (frame != nullptr); jitter_buffer_->ReleaseFrame(frame); return ret; } @@ -236,11 +236,11 @@ class TestJitterBufferNack : public TestRunningJitterBuffer { TEST_F(TestBasicJitterBuffer, StopRunning) { jitter_buffer_->Stop(); - EXPECT_TRUE(NULL == DecodeCompleteFrame()); + EXPECT_TRUE(nullptr == DecodeCompleteFrame()); jitter_buffer_->Start(); // No packets inserted. - EXPECT_TRUE(NULL == DecodeCompleteFrame()); + EXPECT_TRUE(nullptr == DecodeCompleteFrame()); } TEST_F(TestBasicJitterBuffer, SinglePacketFrame) { @@ -270,7 +270,7 @@ TEST_F(TestBasicJitterBuffer, DualPacketFrame) { jitter_buffer_->InsertPacket(*packet_, &retransmitted)); VCMEncodedFrame* frame_out = DecodeCompleteFrame(); // Should not be complete. - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); ++seq_num_; packet_->video_header.is_first_packet_in_frame = false; @@ -299,7 +299,7 @@ TEST_F(TestBasicJitterBuffer, 100PacketKeyFrame) { VCMEncodedFrame* frame_out = DecodeCompleteFrame(); // Frame should not be complete. - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); // Insert 98 frames. int loop = 0; @@ -340,7 +340,7 @@ TEST_F(TestBasicJitterBuffer, 100PacketDeltaFrame) { EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_FALSE(frame_out == NULL); + EXPECT_FALSE(frame_out == nullptr); jitter_buffer_->ReleaseFrame(frame_out); ++seq_num_; @@ -355,7 +355,7 @@ TEST_F(TestBasicJitterBuffer, 100PacketDeltaFrame) { frame_out = DecodeCompleteFrame(); // Frame should not be complete. - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); packet_->video_header.is_first_packet_in_frame = false; // Insert 98 frames. @@ -401,7 +401,7 @@ TEST_F(TestBasicJitterBuffer, PacketReorderingReverseOrder) { VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); // Insert 98 packets. int loop = 0; @@ -444,7 +444,7 @@ TEST_F(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); seq_num_++; packet_->video_header.is_first_packet_in_frame = false; @@ -456,7 +456,7 @@ TEST_F(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { // check that we fail to get frame since seqnum is not continuous frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); seq_num_ -= 3; timestamp_ -= 33 * 90; @@ -472,7 +472,7 @@ TEST_F(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { frame_out = DecodeCompleteFrame(); // It should not be complete. - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); seq_num_++; packet_->video_header.is_first_packet_in_frame = false; @@ -504,7 +504,7 @@ TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) { EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out != NULL); + EXPECT_TRUE(frame_out != nullptr); jitter_buffer_->ReleaseFrame(frame_out); // Now send in a complete delta frame (Frame C), but with a sequence number @@ -519,7 +519,7 @@ TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) { EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); // Now send in a complete delta frame (Frame B) that is continuous from A, but // doesn't fill the full gap to C. The rest of the gap is going to be padding. @@ -529,12 +529,12 @@ TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) { EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out != NULL); + EXPECT_TRUE(frame_out != nullptr); jitter_buffer_->ReleaseFrame(frame_out); // But Frame C isn't continuous yet. frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); // Add in the padding. These are empty packets (data length is 0) with no // marker bit and matching the timestamp of Frame B. @@ -555,7 +555,7 @@ TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) { // But now Frame C should be ready! frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out != NULL); + EXPECT_TRUE(frame_out != nullptr); jitter_buffer_->ReleaseFrame(frame_out); } @@ -574,7 +574,7 @@ TEST_F(TestBasicJitterBuffer, DuplicatePackets) { VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); EXPECT_EQ(1, jitter_buffer_->num_packets()); EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); @@ -593,7 +593,7 @@ TEST_F(TestBasicJitterBuffer, DuplicatePackets) { jitter_buffer_->InsertPacket(*packet_, &retransmitted)); frame_out = DecodeCompleteFrame(); - ASSERT_TRUE(frame_out != NULL); + ASSERT_TRUE(frame_out != nullptr); CheckOutFrame(frame_out, 2 * size_, false); EXPECT_EQ(VideoFrameType::kVideoFrameKey, frame_out->FrameType()); @@ -617,7 +617,7 @@ TEST_F(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) { jitter_buffer_->InsertPacket(*packet_, &retransmitted)); VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - ASSERT_TRUE(frame_out != NULL); + ASSERT_TRUE(frame_out != nullptr); CheckOutFrame(frame_out, size_, false); EXPECT_EQ(VideoFrameType::kVideoFrameKey, frame_out->FrameType()); jitter_buffer_->ReleaseFrame(frame_out); @@ -646,7 +646,7 @@ TEST_F(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) { // Should be able to decode 3 delta frames, key frame already decoded. for (size_t i = 0; i < 3; ++i) { frame_out = DecodeCompleteFrame(); - ASSERT_TRUE(frame_out != NULL); + ASSERT_TRUE(frame_out != nullptr); CheckOutFrame(frame_out, size_, false); EXPECT_EQ(VideoFrameType::kVideoFrameDelta, frame_out->FrameType()); jitter_buffer_->ReleaseFrame(frame_out); @@ -886,7 +886,7 @@ TEST_F(TestBasicJitterBuffer, H264InsertStartCode) { VCMEncodedFrame* frame_out = DecodeCompleteFrame(); // Frame should not be complete. - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); seq_num_++; packet_->video_header.is_first_packet_in_frame = false; @@ -986,7 +986,7 @@ TEST_F(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) { VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); int loop = 0; do { @@ -1000,7 +1000,7 @@ TEST_F(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) { frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); loop++; } while (loop < 98); @@ -1035,7 +1035,7 @@ TEST_F(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) { VCMEncodedFrame* frame_out = DecodeCompleteFrame(); // Should not be complete. - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); // Insert 98 frames. int loop = 0; @@ -1050,7 +1050,7 @@ TEST_F(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) { frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); loop++; } while (loop < 98); @@ -1161,7 +1161,7 @@ TEST_F(TestBasicJitterBuffer, TimestampWrap) { jitter_buffer_->InsertPacket(*packet_, &retransmitted)); VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); seq_num_++; packet_->video_header.is_first_packet_in_frame = false; @@ -1187,7 +1187,7 @@ TEST_F(TestBasicJitterBuffer, TimestampWrap) { jitter_buffer_->InsertPacket(*packet_, &retransmitted)); frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out == NULL); + EXPECT_TRUE(frame_out == nullptr); seq_num_++; packet_->video_header.is_first_packet_in_frame = false; @@ -1320,7 +1320,7 @@ TEST_F(TestBasicJitterBuffer, DeltaFrameWithMoreThanMaxNumberOfPackets) { // Insert the packet -> frame recycled. EXPECT_EQ(kSizeError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); - EXPECT_TRUE(NULL == DecodeCompleteFrame()); + EXPECT_TRUE(nullptr == DecodeCompleteFrame()); } TEST_F(TestBasicJitterBuffer, ExceedNumOfFrameWithSeqNumWrap) { @@ -1415,7 +1415,7 @@ TEST_F(TestBasicJitterBuffer, NextFrameWhenIncomplete) { EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); VCMEncodedFrame* frame_out = DecodeCompleteFrame(); - EXPECT_TRUE(frame_out != NULL); + EXPECT_TRUE(frame_out != nullptr); jitter_buffer_->ReleaseFrame(frame_out); packet_->seqNum += 2; @@ -1638,7 +1638,7 @@ TEST_F(TestJitterBufferNack, NackListBuiltBeforeFirstDecode) { InsertFrame(VideoFrameType::kVideoFrameKey); stream_generator_->GenerateFrame(VideoFrameType::kVideoFrameDelta, 2, 0, clock_->TimeInMilliseconds()); - stream_generator_->NextPacket(NULL); // Drop packet. + stream_generator_->NextPacket(nullptr); // Drop packet. EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); EXPECT_TRUE(DecodeCompleteFrame()); bool extended = false; @@ -1734,7 +1734,7 @@ TEST_F(TestJitterBufferNack, NormalOperation) { if (stream_generator_->NextSequenceNumber() % 10 != 0) { EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); } else { - stream_generator_->NextPacket(NULL); // Drop packet + stream_generator_->NextPacket(nullptr); // Drop packet } } EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); @@ -1768,7 +1768,7 @@ TEST_F(TestJitterBufferNack, NormalOperationWrap) { EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); EXPECT_FALSE(request_key_frame); } else { - stream_generator_->NextPacket(NULL); // Drop packet + stream_generator_->NextPacket(nullptr); // Drop packet } } EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); @@ -1802,7 +1802,7 @@ TEST_F(TestJitterBufferNack, NormalOperationWrap2) { EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); EXPECT_FALSE(request_key_frame); } else { - stream_generator_->NextPacket(NULL); // Drop packet + stream_generator_->NextPacket(nullptr); // Drop packet } stream_generator_->GenerateFrame(VideoFrameType::kVideoFrameDelta, 1, 0, clock_->TimeInMilliseconds()); diff --git a/modules/video_coding/deprecated/packet.cc b/modules/video_coding/deprecated/packet.cc index 6b55bc45d3..ca9bfa4eec 100644 --- a/modules/video_coding/deprecated/packet.cc +++ b/modules/video_coding/deprecated/packet.cc @@ -26,7 +26,7 @@ VCMPacket::VCMPacket() timestamp(0), ntp_time_ms_(0), seqNum(0), - dataPtr(NULL), + dataPtr(nullptr), sizeBytes(0), markerBit(false), timesNacked(-1), diff --git a/modules/video_coding/deprecated/receiver.cc b/modules/video_coding/deprecated/receiver.cc index c9b41ddd14..b42d5599c3 100644 --- a/modules/video_coding/deprecated/receiver.cc +++ b/modules/video_coding/deprecated/receiver.cc @@ -137,7 +137,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, // Timing error => reset timing and flush the jitter buffer. jitter_buffer_.Flush(); timing_->Reset(); - return NULL; + return nullptr; } if (prefer_late_decoding) { @@ -158,7 +158,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, // waiting as long as we're allowed to avoid busy looping, and then return // NULL. Next call to this function might return the frame. render_wait_event_->Wait(new_max_wait_time); - return NULL; + return nullptr; } // Wait until it's time to render. render_wait_event_->Wait(wait_time_ms); @@ -166,8 +166,8 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, // Extract the frame from the jitter buffer and set the render time. VCMEncodedFrame* frame = jitter_buffer_.ExtractAndSetDecode(frame_timestamp); - if (frame == NULL) { - return NULL; + if (frame == nullptr) { + return nullptr; } frame->SetRenderTime(render_time_ms); TRACE_EVENT_ASYNC_STEP_INTO1("webrtc", "Video", frame->RtpTimestamp(), diff --git a/modules/video_coding/deprecated/session_info.cc b/modules/video_coding/deprecated/session_info.cc index c351425dec..0c937a4734 100644 --- a/modules/video_coding/deprecated/session_info.cc +++ b/modules/video_coding/deprecated/session_info.cc @@ -54,8 +54,8 @@ VCMSessionInfo::~VCMSessionInfo() {} void VCMSessionInfo::UpdateDataPointers(const uint8_t* old_base_ptr, const uint8_t* new_base_ptr) { for (PacketIterator it = packets_.begin(); it != packets_.end(); ++it) - if ((*it).dataPtr != NULL) { - RTC_DCHECK(old_base_ptr != NULL && new_base_ptr != NULL); + if ((*it).dataPtr != nullptr) { + RTC_DCHECK(old_base_ptr != nullptr && new_base_ptr != nullptr); (*it).dataPtr = new_base_ptr + ((*it).dataPtr - old_base_ptr); } } @@ -272,7 +272,7 @@ void VCMSessionInfo::ShiftSubsequentPackets(PacketIterator it, // Calculate the total move length and move the data pointers in advance. for (; it != packets_.end(); ++it) { shift_length += (*it).sizeBytes; - if ((*it).dataPtr != NULL) + if ((*it).dataPtr != nullptr) (*it).dataPtr += steps_to_shift; } memmove(first_packet_ptr + steps_to_shift, first_packet_ptr, shift_length); @@ -334,7 +334,7 @@ size_t VCMSessionInfo::DeletePacketData(PacketIterator start, for (PacketIterator it = start; it != packet_after_end; ++it) { bytes_to_delete += (*it).sizeBytes; (*it).sizeBytes = 0; - (*it).dataPtr = NULL; + (*it).dataPtr = nullptr; } if (bytes_to_delete > 0) ShiftSubsequentPackets(end, -static_cast(bytes_to_delete)); diff --git a/modules/video_coding/deprecated/stream_generator.cc b/modules/video_coding/deprecated/stream_generator.cc index 09be3382fe..2870991505 100644 --- a/modules/video_coding/deprecated/stream_generator.cc +++ b/modules/video_coding/deprecated/stream_generator.cc @@ -97,7 +97,7 @@ bool StreamGenerator::GetPacket(VCMPacket* packet, int index) { bool StreamGenerator::NextPacket(VCMPacket* packet) { if (packets_.empty()) return false; - if (packet != NULL) + if (packet != nullptr) *packet = packets_.front(); packets_.pop_front(); return true; diff --git a/modules/video_coding/frame_helpers_unittest.cc b/modules/video_coding/frame_helpers_unittest.cc index ed319b68a3..2e5f4b33f2 100644 --- a/modules/video_coding/frame_helpers_unittest.cc +++ b/modules/video_coding/frame_helpers_unittest.cc @@ -33,11 +33,9 @@ using ::testing::ElementsAre; constexpr uint32_t kRtpTimestamp = 123456710; -webrtc::scoped_refptr CreateEncodedImageBufferOfSizeN( - size_t n, - uint8_t x) { - webrtc::scoped_refptr buffer = - EncodedImageBuffer::Create(n); +scoped_refptr CreateEncodedImageBufferOfSizeN(size_t n, + uint8_t x) { + scoped_refptr buffer = EncodedImageBuffer::Create(n); for (size_t i = 0; i < n; ++i) { buffer->data()[i] = static_cast(x + i); } diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index b3d6e51553..b6d14adf6b 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -292,7 +292,7 @@ void VCMDecodedFrameCallback::ClearTimestampMap() { } VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder) - : _callback(NULL), + : _callback(nullptr), decoder_(decoder), _last_keyframe_content_type(VideoContentType::UNSPECIFIED) { RTC_DCHECK(decoder_); diff --git a/modules/video_coding/generic_decoder_unittest.cc b/modules/video_coding/generic_decoder_unittest.cc index 52fc057956..29f8bdd59a 100644 --- a/modules/video_coding/generic_decoder_unittest.cc +++ b/modules/video_coding/generic_decoder_unittest.cc @@ -115,7 +115,7 @@ class GenericDecoderTest : public ::testing::Test { Clock* const clock_; test::ScopedKeyValueConfig field_trials_; VCMTiming timing_; - webrtc::test::FakeDecoder decoder_; + test::FakeDecoder decoder_; VCMDecodedFrameCallback vcm_callback_; VCMGenericDecoder generic_decoder_; ReceiveCallback user_callback_; diff --git a/modules/video_coding/media_opt_util.cc b/modules/video_coding/media_opt_util.cc index b0fb8f835a..1a7ba66554 100644 --- a/modules/video_coding/media_opt_util.cc +++ b/modules/video_coding/media_opt_util.cc @@ -447,10 +447,9 @@ bool VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) { int VCMFecMethod::BitsPerFrame(const VCMProtectionParameters* parameters) { // When temporal layers are available FEC will only be applied on the base // layer. - const float bitRateRatio = - webrtc::SimulcastRateAllocator::GetTemporalRateAllocation( - parameters->numLayers, 0, - rate_control_settings_.Vp8BaseHeavyTl3RateAllocation()); + const float bitRateRatio = SimulcastRateAllocator::GetTemporalRateAllocation( + parameters->numLayers, 0, + rate_control_settings_.Vp8BaseHeavyTl3RateAllocation()); float frameRateRatio = powf(1 / 2.0, parameters->numLayers - 1); float bitRate = parameters->bitRate * bitRateRatio; float frameRate = parameters->frameRate * frameRateRatio; diff --git a/modules/video_coding/packet_buffer_unittest.cc b/modules/video_coding/packet_buffer_unittest.cc index 17a0d75c3b..a75b57d6ca 100644 --- a/modules/video_coding/packet_buffer_unittest.cc +++ b/modules/video_coding/packet_buffer_unittest.cc @@ -859,9 +859,9 @@ TEST_F(PacketBufferH264FrameGap, TEST_F(PacketBufferH264FrameGap, DoesntCrashWhenTryToClearBefore1stPacket) { // Test scenario copied from the https://issues.chromium.org/370689424 - InsertH264(41087, kKeyFrame, kNotFirst, kNotLast, 123, 0, 0, false); + InsertH264(41087, kKeyFrame, kNotFirst, kNotLast, 123, nullptr, 0, false); packet_buffer_.ClearTo(30896); - InsertH264(32896, kKeyFrame, kFirst, kLast, 123, 0, 0, false); + InsertH264(32896, kKeyFrame, kFirst, kLast, 123, nullptr, 0, false); } } // namespace diff --git a/modules/video_coding/svc/BUILD.gn b/modules/video_coding/svc/BUILD.gn index 9ee0223154..81c747d536 100644 --- a/modules/video_coding/svc/BUILD.gn +++ b/modules/video_coding/svc/BUILD.gn @@ -8,7 +8,7 @@ import("../../../webrtc.gni") -rtc_source_set("scalability_mode_util") { +rtc_library("scalability_mode_util") { sources = [ "scalability_mode_util.cc", "scalability_mode_util.h", @@ -23,7 +23,7 @@ rtc_source_set("scalability_mode_util") { ] } -rtc_source_set("scalable_video_controller") { +rtc_library("scalable_video_controller") { sources = [ "scalable_video_controller.h", "scalable_video_controller_no_layering.cc", @@ -39,7 +39,7 @@ rtc_source_set("scalable_video_controller") { ] } -rtc_source_set("scalability_structures") { +rtc_library("scalability_structures") { sources = [ "create_scalability_structure.cc", "create_scalability_structure.h", @@ -66,7 +66,7 @@ rtc_source_set("scalability_structures") { ] } -rtc_source_set("svc_rate_allocator") { +rtc_library("svc_rate_allocator") { sources = [ "svc_rate_allocator.cc", "svc_rate_allocator.h", @@ -88,7 +88,7 @@ rtc_source_set("svc_rate_allocator") { ] } -rtc_source_set("simulcast_to_svc_converter") { +rtc_library("simulcast_to_svc_converter") { sources = [ "simulcast_to_svc_converter.cc", "simulcast_to_svc_converter.h", @@ -110,7 +110,7 @@ rtc_source_set("simulcast_to_svc_converter") { } if (rtc_include_tests) { - rtc_source_set("scalability_structure_tests") { + rtc_library("scalability_structure_tests") { testonly = true sources = [ "scalability_mode_util_unittest.cc", @@ -141,7 +141,7 @@ if (rtc_include_tests) { ] } - rtc_source_set("svc_rate_allocator_tests") { + rtc_library("svc_rate_allocator_tests") { testonly = true sources = [ "svc_rate_allocator_unittest.cc" ] deps = [ @@ -162,7 +162,7 @@ if (rtc_include_tests) { ] } - rtc_source_set("simulcast_to_svc_converter_tests") { + rtc_library("simulcast_to_svc_converter_tests") { testonly = true sources = [ "simulcast_to_svc_converter_unittest.cc" ] deps = [ diff --git a/modules/video_coding/utility/corruption_detection_settings_generator_unittest.cc b/modules/video_coding/utility/corruption_detection_settings_generator_unittest.cc index 7e74b32afc..59cc95f58c 100644 --- a/modules/video_coding/utility/corruption_detection_settings_generator_unittest.cc +++ b/modules/video_coding/utility/corruption_detection_settings_generator_unittest.cc @@ -29,7 +29,7 @@ TEST(CorruptionDetectionSettingsGenerator, ExponentialFunctionStdDev) { .exponent_factor = 0.01857465, .exponent_offset = -4.26470513}, CorruptionDetectionSettingsGenerator::ErrorThresholds{}, - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{}); + CorruptionDetectionSettingsGenerator::TransientParameters{}); // 0.006 * e^(0.01857465 * 20 + 4.26470513) ~= 0.612 CorruptionDetectionFilterSettings settings = @@ -49,7 +49,7 @@ TEST(CorruptionDetectionSettingsGenerator, ExponentialFunctionThresholds) { .exponent_offset = -4.26470513}, CorruptionDetectionSettingsGenerator::ErrorThresholds{.luma = 5, .chroma = 6}, - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{}); + CorruptionDetectionSettingsGenerator::TransientParameters{}); CorruptionDetectionFilterSettings settings = settings_generator.OnFrame(/*is_keyframe=*/true, /*qp=*/20); @@ -62,7 +62,7 @@ TEST(CorruptionDetectionSettingsGenerator, RationalFunctionStdDev) { CorruptionDetectionSettingsGenerator::RationalFunctionParameters{ .numerator_factor = -5.5, .denumerator_term = -97, .offset = -1}, CorruptionDetectionSettingsGenerator::ErrorThresholds{}, - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{}); + CorruptionDetectionSettingsGenerator::TransientParameters{}); // (20 * -5.5) / (20 - 97) - 1 ~= 0.429 CorruptionDetectionFilterSettings settings = @@ -80,7 +80,7 @@ TEST(CorruptionDetectionSettingsGenerator, RationalFunctionThresholds) { .numerator_factor = -5.5, .denumerator_term = -97, .offset = -1}, CorruptionDetectionSettingsGenerator::ErrorThresholds{.luma = 5, .chroma = 6}, - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{}); + CorruptionDetectionSettingsGenerator::TransientParameters{}); CorruptionDetectionFilterSettings settings = settings_generator.OnFrame(/*is_keyframe=*/true, /*qp=*/20); @@ -96,7 +96,7 @@ TEST(CorruptionDetectionSettingsGenerator, TransientStdDevOffset) { CorruptionDetectionSettingsGenerator::ErrorThresholds{}, // Two frames with adjusted settings, including the keyframe. // Adjust the keyframe std_dev by 2. - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{ + CorruptionDetectionSettingsGenerator::TransientParameters{ .keyframe_stddev_offset = 2.0, .keyframe_offset_duration_frames = 2, }); @@ -128,7 +128,7 @@ TEST(CorruptionDetectionSettingsGenerator, TransientThresholdOffsets) { .chroma = 3}, // Two frames with adjusted settings, including the keyframe. // Adjust the error thresholds by 2. - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{ + CorruptionDetectionSettingsGenerator::TransientParameters{ .keyframe_threshold_offset = 2, .keyframe_offset_duration_frames = 2, }); @@ -169,7 +169,7 @@ TEST(CorruptionDetectionSettingsGenerator, StdDevUpperBound) { CorruptionDetectionSettingsGenerator::RationalFunctionParameters{ .numerator_factor = 1, .denumerator_term = 0, .offset = 41}, CorruptionDetectionSettingsGenerator::ErrorThresholds{}, - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{}); + CorruptionDetectionSettingsGenerator::TransientParameters{}); // `std_dev` capped at max 40.0, which is the limit for the protocol. EXPECT_THAT( @@ -183,7 +183,7 @@ TEST(CorruptionDetectionSettingsGenerator, StdDevLowerBound) { CorruptionDetectionSettingsGenerator::RationalFunctionParameters{ .numerator_factor = 1, .denumerator_term = 0, .offset = 1}, CorruptionDetectionSettingsGenerator::ErrorThresholds{}, - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{ + CorruptionDetectionSettingsGenerator::TransientParameters{ .std_dev_lower_bound = 5.0}); // `std_dev` capped at lower bound of 5.0. @@ -200,7 +200,7 @@ TEST(CorruptionDetectionSettingsGenerator, TreatsLargeQpChangeAsKeyFrame) { .chroma = 3}, // Two frames with adjusted settings, including the keyframe. // Adjust the error thresholds by 2. - webrtc::CorruptionDetectionSettingsGenerator::TransientParameters{ + CorruptionDetectionSettingsGenerator::TransientParameters{ .max_qp = 100, .keyframe_threshold_offset = 2, .keyframe_offset_duration_frames = 1, diff --git a/modules/video_coding/utility/ivf_file_reader_unittest.cc b/modules/video_coding/utility/ivf_file_reader_unittest.cc index bfd2b6140f..ede43e07f4 100644 --- a/modules/video_coding/utility/ivf_file_reader_unittest.cc +++ b/modules/video_coding/utility/ivf_file_reader_unittest.cc @@ -38,10 +38,9 @@ constexpr uint8_t kDummyPayload[4] = {'0', '1', '2', '3'}; class IvfFileReaderTest : public ::testing::Test { protected: void SetUp() override { - file_name_ = - webrtc::test::TempFilename(webrtc::test::OutputPath(), "test_file.ivf"); + file_name_ = test::TempFilename(test::OutputPath(), "test_file.ivf"); } - void TearDown() override { webrtc::test::RemoveFile(file_name_); } + void TearDown() override { test::RemoveFile(file_name_); } bool WriteDummyTestFrames(IvfFileWriter* file_writer, VideoCodecType codec_type, diff --git a/modules/video_coding/utility/ivf_file_writer_unittest.cc b/modules/video_coding/utility/ivf_file_writer_unittest.cc index 6be8a6c228..007448fd14 100644 --- a/modules/video_coding/utility/ivf_file_writer_unittest.cc +++ b/modules/video_coding/utility/ivf_file_writer_unittest.cc @@ -38,10 +38,9 @@ constexpr int kDefaultHeight = 720; class IvfFileWriterTest : public ::testing::Test { protected: void SetUp() override { - file_name_ = - webrtc::test::TempFilename(webrtc::test::OutputPath(), "test_file"); + file_name_ = test::TempFilename(test::OutputPath(), "test_file"); } - void TearDown() override { webrtc::test::RemoveFile(file_name_); } + void TearDown() override { test::RemoveFile(file_name_); } bool WriteDummyTestFrames(VideoCodecType codec_type, int width, diff --git a/modules/video_coding/utility/simulcast_rate_allocator.cc b/modules/video_coding/utility/simulcast_rate_allocator.cc index 1157d1a76f..2811d52a0c 100644 --- a/modules/video_coding/utility/simulcast_rate_allocator.cc +++ b/modules/video_coding/utility/simulcast_rate_allocator.cc @@ -330,7 +330,7 @@ SimulcastRateAllocator::ScreenshareTemporalLayerAllocation( return allocation; } -const VideoCodec& webrtc::SimulcastRateAllocator::GetCodec() const { +const VideoCodec& SimulcastRateAllocator::GetCodec() const { return codec_; } diff --git a/modules/video_coding/utility/simulcast_test_fixture_impl.cc b/modules/video_coding/utility/simulcast_test_fixture_impl.cc index a8a3e80fdd..4dbc6b3da6 100644 --- a/modules/video_coding/utility/simulcast_test_fixture_impl.cc +++ b/modules/video_coding/utility/simulcast_test_fixture_impl.cc @@ -311,12 +311,12 @@ void SimulcastTestFixtureImpl::SetUpCodec(const int* temporal_layer_profile) { EXPECT_TRUE(decoder_->Configure(decoder_settings)); input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight); input_buffer_->InitializeData(); - input_frame_ = std::make_unique( - webrtc::VideoFrame::Builder() - .set_video_frame_buffer(input_buffer_) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(0) - .build()); + input_frame_ = + std::make_unique(VideoFrame::Builder() + .set_video_frame_buffer(input_buffer_) + .set_rotation(kVideoRotation_0) + .set_timestamp_us(0) + .build()); } void SimulcastTestFixtureImpl::SetUpRateAllocator() { @@ -687,12 +687,12 @@ void SimulcastTestFixtureImpl::SwitchingToOneStream(int width, int height) { input_buffer_ = I420Buffer::Create(settings_.width, settings_.height); input_buffer_->InitializeData(); - input_frame_ = std::make_unique( - webrtc::VideoFrame::Builder() - .set_video_frame_buffer(input_buffer_) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(0) - .build()); + input_frame_ = + std::make_unique(VideoFrame::Builder() + .set_video_frame_buffer(input_buffer_) + .set_rotation(kVideoRotation_0) + .set_timestamp_us(0) + .build()); // The for loop above did not set the bitrate of the highest layer. settings_.simulcastStream[settings_.numberOfSimulcastStreams - 1].maxBitrate = @@ -732,12 +732,12 @@ void SimulcastTestFixtureImpl::SwitchingToOneStream(int width, int height) { // Resize `input_frame_` to the new resolution. input_buffer_ = I420Buffer::Create(settings_.width, settings_.height); input_buffer_->InitializeData(); - input_frame_ = std::make_unique( - webrtc::VideoFrame::Builder() - .set_video_frame_buffer(input_buffer_) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(0) - .build()); + input_frame_ = + std::make_unique(VideoFrame::Builder() + .set_video_frame_buffer(input_buffer_) + .set_rotation(kVideoRotation_0) + .set_timestamp_us(0) + .build()); EXPECT_EQ(0, encoder_->Encode(*input_frame_, &frame_types)); } @@ -766,7 +766,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers333PatternEncoder() { bool expected_layer_sync[3] = {false, false, false}; // First frame: #0. - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(0, 0, 0, expected_temporal_idx); SetExpectedValues3(!is_h264, !is_h264, !is_h264, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -774,7 +774,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers333PatternEncoder() { // Next frame: #1. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(2, 2, 2, expected_temporal_idx); SetExpectedValues3(true, true, true, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -782,7 +782,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers333PatternEncoder() { // Next frame: #2. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(1, 1, 1, expected_temporal_idx); SetExpectedValues3(true, true, true, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -790,7 +790,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers333PatternEncoder() { // Next frame: #3. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(2, 2, 2, expected_temporal_idx); SetExpectedValues3(false, false, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -798,7 +798,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers333PatternEncoder() { // Next frame: #4. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(0, 0, 0, expected_temporal_idx); SetExpectedValues3(false, false, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -806,7 +806,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers333PatternEncoder() { // Next frame: #5. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(2, 2, 2, expected_temporal_idx); SetExpectedValues3(is_h264, is_h264, is_h264, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -836,7 +836,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers321PatternEncoder() { bool expected_layer_sync[3] = {false, false, false}; // First frame: #0. - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(0, 0, 255, expected_temporal_idx); SetExpectedValues3(true, true, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -844,7 +844,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers321PatternEncoder() { // Next frame: #1. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(2, 1, 255, expected_temporal_idx); SetExpectedValues3(true, true, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -852,7 +852,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers321PatternEncoder() { // Next frame: #2. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(1, 0, 255, expected_temporal_idx); SetExpectedValues3(true, false, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -860,7 +860,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers321PatternEncoder() { // Next frame: #3. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(2, 1, 255, expected_temporal_idx); SetExpectedValues3(false, false, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -868,7 +868,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers321PatternEncoder() { // Next frame: #4. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(0, 0, 255, expected_temporal_idx); SetExpectedValues3(false, false, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -876,7 +876,7 @@ void SimulcastTestFixtureImpl::TestSpatioTemporalLayers321PatternEncoder() { // Next frame: #5. input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); SetExpectedValues3(2, 1, 255, expected_temporal_idx); SetExpectedValues3(false, true, false, expected_layer_sync); VerifyTemporalIdxAndSyncForAllSpatialLayers( @@ -896,12 +896,12 @@ void SimulcastTestFixtureImpl::TestStrideEncodeDecode() { int stride_uv = ((kDefaultWidth + 1) / 2) + 5; input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight, stride_y, stride_uv, stride_uv); - input_frame_ = std::make_unique( - webrtc::VideoFrame::Builder() - .set_video_frame_buffer(input_buffer_) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(0) - .build()); + input_frame_ = + std::make_unique(VideoFrame::Builder() + .set_video_frame_buffer(input_buffer_) + .set_rotation(kVideoRotation_0) + .set_timestamp_us(0) + .build()); // Set color. int plane_offset[kNumOfPlanes]; @@ -910,7 +910,7 @@ void SimulcastTestFixtureImpl::TestStrideEncodeDecode() { plane_offset[kVPlane] = kColorV; CreateImage(input_buffer_, plane_offset); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); // Change color. plane_offset[kYPlane] += 1; @@ -918,7 +918,7 @@ void SimulcastTestFixtureImpl::TestStrideEncodeDecode() { plane_offset[kVPlane] += 1; CreateImage(input_buffer_, plane_offset); input_frame_->set_rtp_timestamp(input_frame_->rtp_timestamp() + 3000); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); EncodedImage encoded_frame; // Only encoding one frame - so will be a key frame. @@ -952,7 +952,7 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() { return EncodedImageCallback::Result( EncodedImageCallback::Result::OK, 0); })); - EXPECT_EQ(0, encoder_->Encode(*input_frame_, NULL)); + EXPECT_EQ(0, encoder_->Encode(*input_frame_, nullptr)); EXPECT_CALL(decoder_callback, Decoded(_, _, _)) .WillOnce( diff --git a/modules/video_coding/utility/simulcast_utility.cc b/modules/video_coding/utility/simulcast_utility.cc index ec1ad067cb..b6327aeeb4 100644 --- a/modules/video_coding/utility/simulcast_utility.cc +++ b/modules/video_coding/utility/simulcast_utility.cc @@ -89,8 +89,8 @@ bool SimulcastUtility::IsConferenceModeScreenshare( return encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen && encoder_config.legacy_conference_mode && - (encoder_config.codec_type == webrtc::VideoCodecType::kVideoCodecVP8 || - encoder_config.codec_type == webrtc::VideoCodecType::kVideoCodecH264); + (encoder_config.codec_type == VideoCodecType::kVideoCodecVP8 || + encoder_config.codec_type == VideoCodecType::kVideoCodecH264); } int SimulcastUtility::NumberOfTemporalLayers(const VideoCodec& codec, diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc index 849c780aca..f97bf88c58 100644 --- a/modules/video_coding/video_codec_initializer_unittest.cc +++ b/modules/video_coding/video_codec_initializer_unittest.cc @@ -84,15 +84,17 @@ class VideoCodecInitializerTest : public ::testing::Test { ASSERT_FALSE(num_spatial_streams.has_value()); VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); vp8_settings.numberOfTemporalLayers = num_temporal_streams; - config_.encoder_specific_settings = make_ref_counted< - webrtc::VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings); + config_.encoder_specific_settings = + make_ref_counted( + vp8_settings); } else if (type == VideoCodecType::kVideoCodecVP9) { ASSERT_TRUE(num_spatial_streams.has_value()); VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); vp9_settings.numberOfSpatialLayers = num_spatial_streams.value(); vp9_settings.numberOfTemporalLayers = num_temporal_streams; - config_.encoder_specific_settings = make_ref_counted< - webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); + config_.encoder_specific_settings = + make_ref_counted( + vp9_settings); } } diff --git a/modules/video_coding/video_receiver2_unittest.cc b/modules/video_coding/video_receiver2_unittest.cc index f7460a5310..8bce1de57c 100644 --- a/modules/video_coding/video_receiver2_unittest.cc +++ b/modules/video_coding/video_receiver2_unittest.cc @@ -54,7 +54,7 @@ class TestEncodedFrame : public EncodedFrame { SetPacketInfos(CreatePacketInfos(3)); } - void SetReceivedTime(webrtc::Timestamp received_time) { + void SetReceivedTime(Timestamp received_time) { received_time_ = received_time; } @@ -63,7 +63,7 @@ class TestEncodedFrame : public EncodedFrame { int64_t RenderTime() const override { return _renderTimeMs; } private: - webrtc::Timestamp received_time_ = webrtc::Timestamp::Millis(0); + Timestamp received_time_ = Timestamp::Millis(0); }; class VideoReceiver2Test : public ::testing::Test { diff --git a/net/dcsctp/public/BUILD.gn b/net/dcsctp/public/BUILD.gn index 97f7651f15..a744681942 100644 --- a/net/dcsctp/public/BUILD.gn +++ b/net/dcsctp/public/BUILD.gn @@ -21,7 +21,7 @@ rtc_source_set("types") { ] } -rtc_source_set("socket") { +rtc_library("socket") { deps = [ ":types", "../../../api:array_view", @@ -40,7 +40,7 @@ rtc_source_set("socket") { ] } -rtc_source_set("factory") { +rtc_library("factory") { deps = [ ":socket", ":types", @@ -66,7 +66,7 @@ rtc_source_set("mocks") { ] } -rtc_source_set("utils") { +rtc_library("utils") { deps = [ ":socket", ":types", diff --git a/net/dcsctp/public/dcsctp_options.h b/net/dcsctp/public/dcsctp_options.h index 6e1181f7e2..f5a9aac907 100644 --- a/net/dcsctp/public/dcsctp_options.h +++ b/net/dcsctp/public/dcsctp_options.h @@ -86,6 +86,12 @@ struct DcSctpOptions { // buffer is fully utilized. size_t max_receiver_window_buffer_size = 5 * 1024 * 1024; + // Enables receive pull mode - `DcSctpCallbacks::OnMessageReady` will be + // called when there are messages ready to be read instead of + // `DcSctpCallbacks::OnMessageReceived`. It is up to the + // caller to call `DcSctpSocket::GetNextMessage()` to receive the messages. + bool enable_receive_pull_mode = false; + // Send queue total size limit. It will not be possible to queue more data if // the queue size is larger than this number. size_t max_send_buffer_size = 2'000'000; diff --git a/net/dcsctp/public/dcsctp_socket.h b/net/dcsctp/public/dcsctp_socket.h index bce886fbbf..803bf8efe5 100644 --- a/net/dcsctp/public/dcsctp_socket.h +++ b/net/dcsctp/public/dcsctp_socket.h @@ -360,11 +360,19 @@ class DcSctpSocketCallbacks { virtual void NotifyOutgoingMessageBufferEmpty() {} // Called when the library has received an SCTP message in full and delivers - // it to the upper layer. + // it to the upper layer, given that `DcSctpOptions::enable_receive_pull_mode` + // isn't enabled. // // It is allowed to call into this library from within this callback. virtual void OnMessageReceived(DcSctpMessage message) = 0; + // Called when `DcSctpOptions::enable_receive_pull_mode` is enabled and the + // library has one or more SCTP messages ready to be received with + // `DcSctpSocket::GetNextMessage()`. + // + // It is allowed to call into this library from within this callback. + virtual void OnMessageReady() {} + // Triggered when an non-fatal error is reported by either this library or // from the other peer (by sending an ERROR command). These should be logged, // but no other action need to be taken as the association is still viable. @@ -525,6 +533,20 @@ class DcSctpSocketInterface { // To be called when an incoming SCTP packet is to be processed. virtual void ReceivePacket(webrtc::ArrayView data) = 0; + // Returns the number of received messages that can be retrieved by calling + // calling `::GetNextMessage`. + // + // Only used when `DcSctpOptions::enable_receive_pull_mode` is true (will + // always return zero if not enabled). + virtual size_t MessagesReady() const = 0; + + // To be called after `DcSctpSocketCallbacks::OnMessagesReady` has triggered + // to retrieve the next message, if any. + // + // Only used when `DcSctpOptions::enable_receive_pull_mode` is true (will + // always return empty if not enabled). + virtual std::optional GetNextMessage() = 0; + // To be called when a timeout has expired. The `timeout_id` is provided // when the timeout was initiated. virtual void HandleTimeout(TimeoutID timeout_id) = 0; diff --git a/net/dcsctp/public/mock_dcsctp_socket.h b/net/dcsctp/public/mock_dcsctp_socket.h index c1c59fea32..399a193464 100644 --- a/net/dcsctp/public/mock_dcsctp_socket.h +++ b/net/dcsctp/public/mock_dcsctp_socket.h @@ -24,6 +24,9 @@ class MockDcSctpSocket : public DcSctpSocketInterface { (webrtc::ArrayView data), (override)); + MOCK_METHOD(size_t, MessagesReady, (), (const, override)); + MOCK_METHOD(std::optional, GetNextMessage, (), (override)); + MOCK_METHOD(void, HandleTimeout, (TimeoutID timeout_id), (override)); MOCK_METHOD(void, Connect, (), (override)); diff --git a/net/dcsctp/rx/reassembly_queue.cc b/net/dcsctp/rx/reassembly_queue.cc index 439863a6cb..3d3c5a4205 100644 --- a/net/dcsctp/rx/reassembly_queue.cc +++ b/net/dcsctp/rx/reassembly_queue.cc @@ -158,9 +158,13 @@ void ReassemblyQueue::EnterDeferredReset( RTC_DCHECK(IsConsistent()); } -std::vector ReassemblyQueue::FlushMessages() { - std::vector ret; - reassembled_messages_.swap(ret); +std::optional ReassemblyQueue::GetNextMessage() { + if (reassembled_messages_.empty()) { + return std::nullopt; + } + DcSctpMessage ret = std::move(reassembled_messages_.front()); + reassembled_messages_.pop_front(); + queued_bytes_ -= ret.payload().size(); return ret; } @@ -177,6 +181,7 @@ void ReassemblyQueue::AddReassembledMessage( << ", ppid=" << *message.ppid() << ", payload=" << message.payload().size() << " bytes"; + queued_bytes_ += message.payload().size(); reassembled_messages_.emplace_back(std::move(message)); } diff --git a/net/dcsctp/rx/reassembly_queue.h b/net/dcsctp/rx/reassembly_queue.h index 7308fdd227..1cf4cb90e9 100644 --- a/net/dcsctp/rx/reassembly_queue.h +++ b/net/dcsctp/rx/reassembly_queue.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -79,11 +80,16 @@ class ReassemblyQueue { void Add(TSN tsn, Data data); // Indicates if the reassembly queue has any reassembled messages that can be - // retrieved by calling `FlushMessages`. + // retrieved by calling `GetNextMessage`. bool HasMessages() const { return !reassembled_messages_.empty(); } - // Returns any reassembled messages. - std::vector FlushMessages(); + // Returns the number of reassembled messages that are ready to be retrieved + // by calling `GetNextMessage`. + size_t MessagesReady() const { return reassembled_messages_.size(); } + + // Returns the next reassembled message or nullopt if there are no messages + // ready. + std::optional GetNextMessage(); // Handle a ForwardTSN chunk, when the sender has indicated that the received // (this class) should forget about some chunks. This is used to implement @@ -147,9 +153,9 @@ class ReassemblyQueue { const size_t watermark_bytes_; UnwrappedTSN::Unwrapper tsn_unwrapper_; - // Messages that have been reassembled, and will be returned by - // `FlushMessages`. - std::vector reassembled_messages_; + // Messages that have been reassembled, and will be consumed from by + // `GetNextMessage`. + std::deque reassembled_messages_; // If present, "deferred reset processing" mode is active. std::optional deferred_reset_streams_; diff --git a/net/dcsctp/rx/reassembly_queue_test.cc b/net/dcsctp/rx/reassembly_queue_test.cc index dc15aceb08..e619f403c8 100644 --- a/net/dcsctp/rx/reassembly_queue_test.cc +++ b/net/dcsctp/rx/reassembly_queue_test.cc @@ -74,6 +74,15 @@ MATCHER_P3(SctpMessageIs, stream_id, ppid, expected_payload, "") { return true; } +std::vector FlushMessages(ReassemblyQueue& reasm) { + std::vector messages; + while (reasm.HasMessages()) { + messages.emplace_back(reasm.GetNextMessage().value()); + } + EXPECT_EQ(reasm.queued_bytes(), 0u); + return messages; +} + class ReassemblyQueueTest : public testing::Test { protected: ReassemblyQueueTest() {} @@ -90,9 +99,8 @@ TEST_F(ReassemblyQueueTest, SingleUnorderedChunkMessage) { ReassemblyQueue reasm("log: ", kBufferSize); reasm.Add(TSN(10), gen_.Unordered({1, 2, 3, 4}, "BE")); EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kShortPayload))); - EXPECT_EQ(reasm.queued_bytes(), 0u); } TEST_F(ReassemblyQueueTest, LargeUnorderedChunkAllPermutations) { @@ -114,9 +122,8 @@ TEST_F(ReassemblyQueueTest, LargeUnorderedChunkAllPermutations) { EXPECT_FALSE(reasm.HasMessages()); } else { EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kLongPayload))); - EXPECT_EQ(reasm.queued_bytes(), 0u); } } } while (std::next_permutation(std::begin(tsns), std::end(tsns))); @@ -125,9 +132,9 @@ TEST_F(ReassemblyQueueTest, LargeUnorderedChunkAllPermutations) { TEST_F(ReassemblyQueueTest, SingleOrderedChunkMessage) { ReassemblyQueue reasm("log: ", kBufferSize); reasm.Add(TSN(10), gen_.Ordered({1, 2, 3, 4}, "BE")); - EXPECT_EQ(reasm.queued_bytes(), 0u); + EXPECT_EQ(reasm.queued_bytes(), 4u); EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kShortPayload))); } @@ -148,12 +155,11 @@ TEST_F(ReassemblyQueueTest, ManySmallOrderedMessages) { is_beginning, is_end, IsUnordered(false))); } EXPECT_THAT( - reasm.FlushMessages(), + FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, payload.subview(0, 4)), SctpMessageIs(kStreamID, kPPID, payload.subview(4, 4)), SctpMessageIs(kStreamID, kPPID, payload.subview(8, 4)), SctpMessageIs(kStreamID, kPPID, payload.subview(12, 4)))); - EXPECT_EQ(reasm.queued_bytes(), 0u); } while (std::next_permutation(std::begin(tsns), std::end(tsns))); } @@ -177,9 +183,8 @@ TEST_F(ReassemblyQueueTest, RetransmissionInLargeOrdered) { reasm.Add(TSN(20), gen_.Ordered({11, 12, 13, 14, 15, 16}, "E")); EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kLongPayload))); - EXPECT_EQ(reasm.queued_bytes(), 0u); } TEST_F(ReassemblyQueueTest, ForwardTSNRemoveUnordered) { @@ -201,7 +206,7 @@ TEST_F(ReassemblyQueueTest, ForwardTSNRemoveUnordered) { // The second lost chunk comes, message is assembled. reasm.Add(TSN(16), gen_.Unordered({7})); EXPECT_TRUE(reasm.HasMessages()); - EXPECT_EQ(reasm.queued_bytes(), 0u); + EXPECT_EQ(reasm.queued_bytes(), 4u); } TEST_F(ReassemblyQueueTest, ForwardTSNRemoveOrdered) { @@ -220,11 +225,11 @@ TEST_F(ReassemblyQueueTest, ForwardTSNRemoveOrdered) { reasm.HandleForwardTsn( TSN(13), std::vector({SkippedStream(kStreamID, kSSN)})); - EXPECT_EQ(reasm.queued_bytes(), 0u); + EXPECT_EQ(reasm.queued_bytes(), 4u); // The lost chunk comes, but too late. EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kMessage2Payload))); } @@ -244,11 +249,11 @@ TEST_F(ReassemblyQueueTest, ForwardTSNRemoveALotOrdered) { reasm.HandleForwardTsn( TSN(13), std::vector({SkippedStream(kStreamID, kSSN)})); - EXPECT_EQ(reasm.queued_bytes(), 0u); + EXPECT_EQ(reasm.queued_bytes(), 4u); // The lost chunk comes, but too late. EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kMessage2Payload))); } @@ -256,7 +261,7 @@ TEST_F(ReassemblyQueueTest, NotReadyForHandoverWhenResetStreamIsDeferred) { ReassemblyQueue reasm("log: ", kBufferSize); reasm.Add(TSN(10), gen_.Ordered({1, 2, 3, 4}, "BE", {.mid = MID(0)})); reasm.Add(TSN(11), gen_.Ordered({1, 2, 3, 4}, "BE", {.mid = MID(1)})); - EXPECT_THAT(reasm.FlushMessages(), SizeIs(2)); + EXPECT_THAT(FlushMessages(reasm), SizeIs(2)); reasm.EnterDeferredReset(TSN(12), std::vector({StreamID(1)})); EXPECT_EQ(reasm.GetHandoverReadiness(), @@ -281,13 +286,14 @@ TEST_F(ReassemblyQueueTest, HandoverInInitialState) { reasm2.RestoreFromState(state); reasm2.Add(TSN(10), gen_.Ordered({1, 2, 3, 4}, "BE")); - EXPECT_THAT(reasm2.FlushMessages(), SizeIs(1)); + EXPECT_THAT(FlushMessages(reasm2), SizeIs(1)); } TEST_F(ReassemblyQueueTest, HandoverAfterHavingAssembedOneMessage) { ReassemblyQueue reasm1("log: ", kBufferSize); reasm1.Add(TSN(10), gen_.Ordered({1, 2, 3, 4}, "BE")); - EXPECT_THAT(reasm1.FlushMessages(), SizeIs(1)); + EXPECT_TRUE(reasm1.GetNextMessage().has_value()); + EXPECT_FALSE(reasm1.HasMessages()); EXPECT_EQ(reasm1.GetHandoverReadiness(), HandoverReadinessStatus()); DcSctpSocketHandoverState state; @@ -298,7 +304,8 @@ TEST_F(ReassemblyQueueTest, HandoverAfterHavingAssembedOneMessage) { reasm2.RestoreFromState(state); reasm2.Add(TSN(11), gen_.Ordered({1, 2, 3, 4}, "BE")); - EXPECT_THAT(reasm2.FlushMessages(), SizeIs(1)); + EXPECT_TRUE(reasm2.GetNextMessage().has_value()); + EXPECT_FALSE(reasm2.HasMessages()); } TEST_F(ReassemblyQueueTest, SingleUnorderedChunkMessageInRfc8260) { @@ -307,9 +314,9 @@ TEST_F(ReassemblyQueueTest, SingleUnorderedChunkMessageInRfc8260) { reasm.Add(TSN(10), Data(StreamID(1), SSN(0), MID(0), FSN(0), kPPID, {1, 2, 3, 4}, Data::IsBeginning(true), Data::IsEnd(true), IsUnordered(true))); - EXPECT_EQ(reasm.queued_bytes(), 0u); + EXPECT_EQ(reasm.queued_bytes(), 4u); EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kShortPayload))); } @@ -326,13 +333,13 @@ TEST_F(ReassemblyQueueTest, TwoInterleavedChunks) { reasm.Add(TSN(12), Data(StreamID(1), SSN(0), MID(0), FSN(1), kPPID, {5, 6, 7, 8}, Data::IsBeginning(false), Data::IsEnd(true), IsUnordered(true))); - EXPECT_EQ(reasm.queued_bytes(), 4u); + EXPECT_EQ(reasm.queued_bytes(), 12u); reasm.Add(TSN(13), Data(StreamID(2), SSN(0), MID(0), FSN(1), kPPID, {13, 14, 15, 16}, Data::IsBeginning(false), Data::IsEnd(true), IsUnordered(true))); - EXPECT_EQ(reasm.queued_bytes(), 0u); + EXPECT_EQ(reasm.queued_bytes(), 16u); EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(StreamID(1), kPPID, kMediumPayload1), SctpMessageIs(StreamID(2), kPPID, kMediumPayload2))); } @@ -356,11 +363,10 @@ TEST_F(ReassemblyQueueTest, UnorderedInterleavedMessagesAllPermutations) { is_beginning, is_end, IsUnordered(true))); } EXPECT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), UnorderedElementsAre( SctpMessageIs(StreamID(1), kPPID, kSixBytePayload), SctpMessageIs(StreamID(2), kPPID, kSixBytePayload))); - EXPECT_EQ(reasm.queued_bytes(), 0u); } while (std::next_permutation(std::begin(indexes), std::end(indexes))); } @@ -381,11 +387,11 @@ TEST_F(ReassemblyQueueTest, IForwardTSNRemoveALotOrdered) { reasm.HandleForwardTsn(TSN(13), std::vector({SkippedStream( IsUnordered(false), kStreamID, MID(0))})); - EXPECT_EQ(reasm.queued_bytes(), 0u); + EXPECT_EQ(reasm.queued_bytes(), 4u); // The lost chunk comes, but too late. ASSERT_TRUE(reasm.HasMessages()); - EXPECT_THAT(reasm.FlushMessages(), + EXPECT_THAT(FlushMessages(reasm), ElementsAre(SctpMessageIs(kStreamID, kPPID, kMessage2Payload))); } diff --git a/net/dcsctp/socket/callback_deferrer.cc b/net/dcsctp/socket/callback_deferrer.cc index a17ba75d9f..dcd54a9a91 100644 --- a/net/dcsctp/socket/callback_deferrer.cc +++ b/net/dcsctp/socket/callback_deferrer.cc @@ -69,6 +69,15 @@ void CallbackDeferrer::OnMessageReceived(DcSctpMessage message) { std::move(message)); } +void CallbackDeferrer::OnMessageReady() { + RTC_DCHECK(prepared_); + deferred_.emplace_back( + +[](CallbackData data, DcSctpSocketCallbacks& cb) { + return cb.OnMessageReady(); + }, + std::monostate{}); +} + void CallbackDeferrer::OnError(ErrorKind error, absl::string_view message) { RTC_DCHECK(prepared_); deferred_.emplace_back( diff --git a/net/dcsctp/socket/callback_deferrer.h b/net/dcsctp/socket/callback_deferrer.h index d7cb0db2a3..1b0d23d394 100644 --- a/net/dcsctp/socket/callback_deferrer.h +++ b/net/dcsctp/socket/callback_deferrer.h @@ -69,6 +69,7 @@ class CallbackDeferrer : public DcSctpSocketCallbacks { webrtc::Timestamp Now() override { return underlying_.Now(); } uint32_t GetRandomInt(uint32_t low, uint32_t high) override; void OnMessageReceived(DcSctpMessage message) override; + void OnMessageReady() override; void OnError(ErrorKind error, absl::string_view message) override; void OnAborted(ErrorKind error, absl::string_view message) override; void OnConnected() override; diff --git a/net/dcsctp/socket/dcsctp_socket.cc b/net/dcsctp/socket/dcsctp_socket.cc index 6c889cb482..eac23dfeb2 100644 --- a/net/dcsctp/socket/dcsctp_socket.cc +++ b/net/dcsctp/socket/dcsctp_socket.cc @@ -224,7 +224,8 @@ std::string DcSctpSocket::log_prefix() const { } bool DcSctpSocket::IsConsistent() const { - if (tcb_ != nullptr && tcb_->reassembly_queue().HasMessages()) { + if (tcb_ != nullptr && (!options_.enable_receive_pull_mode && + tcb_->reassembly_queue().HasMessages())) { return false; } switch (state_) { @@ -1082,15 +1083,24 @@ void DcSctpSocket::HandleDataCommon(AnyDataChunk& chunk) { << tcb_->reassembly_queue().is_above_watermark(); if (tcb_->reassembly_queue().is_full()) { - // If the reassembly queue is full, there is nothing that can be done. The - // specification only allows dropping gap-ack-blocks, and that's not - // likely to help as the socket has been trying to fill gaps since the - // watermark was reached. - packet_sender_.Send(tcb_->PacketBuilder().Add(AbortChunk( - true, Parameters::Builder().Add(OutOfResourceErrorCause()).Build()))); - InternalClose(ErrorKind::kResourceExhaustion, - "Reassembly Queue is exhausted"); - return; + if (tcb_->reassembly_queue().HasMessages()) { + // If the reassembly queue is full but there are assembled messages + // waiting to be pulled, we can't do anything with this data except drop + // it, and hope the upper layer drains the accumulated messages soon. + RTC_DLOG(LS_VERBOSE) << log_prefix() + << "Rejected data because of full reassembly queue"; + return; + } else { + // If the reassembly queue is full and there's no messages waiting, there + // is nothing that can be done. The specification only allows dropping + // gap-ack-blocks, and that's not likely to help as the socket has been + // trying to fill gaps since the watermark was reached. + packet_sender_.Send(tcb_->PacketBuilder().Add(AbortChunk( + true, Parameters::Builder().Add(OutOfResourceErrorCause()).Build()))); + InternalClose(ErrorKind::kResourceExhaustion, + "Reassembly Queue is exhausted"); + return; + } } if (tcb_->reassembly_queue().is_above_watermark()) { @@ -1472,10 +1482,33 @@ void DcSctpSocket::HandleCookieAck( } void DcSctpSocket::MaybeDeliverMessages() { - for (auto& message : tcb_->reassembly_queue().FlushMessages()) { + if (options_.enable_receive_pull_mode) { + if (tcb_->reassembly_queue().HasMessages()) { + callbacks_.OnMessageReady(); + } + return; + } + + while (std::optional message = + tcb_->reassembly_queue().GetNextMessage()) { + ++metrics_.rx_messages_count; + callbacks_.OnMessageReceived(*std::move(message)); + } +} + +size_t DcSctpSocket::MessagesReady() const { + return tcb_ != nullptr ? tcb_->reassembly_queue().MessagesReady() : 0; +} + +std::optional DcSctpSocket::GetNextMessage() { + if (tcb_ == nullptr) { + return std::nullopt; + } + std::optional ret = tcb_->reassembly_queue().GetNextMessage(); + if (ret.has_value()) { ++metrics_.rx_messages_count; - callbacks_.OnMessageReceived(std::move(message)); } + return ret; } void DcSctpSocket::HandleSack(const CommonHeader& /* header */, diff --git a/net/dcsctp/socket/dcsctp_socket.h b/net/dcsctp/socket/dcsctp_socket.h index d68711ea1f..18435e4aa6 100644 --- a/net/dcsctp/socket/dcsctp_socket.h +++ b/net/dcsctp/socket/dcsctp_socket.h @@ -84,6 +84,8 @@ class DcSctpSocket : public DcSctpSocketInterface { // Implementation of `DcSctpSocketInterface`. void ReceivePacket(webrtc::ArrayView data) override; + size_t MessagesReady() const override; + std::optional GetNextMessage() override; void HandleTimeout(TimeoutID timeout_id) override; void Connect() override; void RestoreFromState(const DcSctpSocketHandoverState& state) override; diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc index d9c1c5768a..9e0ea0f8c5 100644 --- a/net/dcsctp/socket/dcsctp_socket_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_test.cc @@ -810,6 +810,35 @@ TEST(DcSctpSocketTest, SendMessageAfterEstablished) { std::optional msg = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); + + // Calling the pull-mode API with it not enabled just returns false. + EXPECT_EQ(z.socket.MessagesReady(), 0u); + EXPECT_FALSE(z.socket.GetNextMessage().has_value()); +} + +TEST(DcSctpSocketTest, SendMessageAfterEstablishedInPullMode) { + SocketUnderTest a("A"); + SocketUnderTest z("Z", {.enable_receive_pull_mode = true}); + + EXPECT_CALL(z.cb, OnMessageReceived).Times(0); + EXPECT_CALL(z.cb, OnMessageReady).Times(1); + + ConnectSockets(a, z); + + EXPECT_EQ(z.socket.MessagesReady(), 0u); + EXPECT_FALSE(z.socket.GetNextMessage().has_value()); + + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); + + // Not delivered by callback. + ASSERT_FALSE(z.cb.ConsumeReceivedMessage().has_value()); + + // But available by polling. + EXPECT_EQ(z.socket.MessagesReady(), 1u); + std::optional msg = z.socket.GetNextMessage(); + EXPECT_TRUE(msg.has_value()); + EXPECT_EQ(msg->stream_id(), StreamID(1)); } TEST_P(DcSctpSocketParametrizedTest, TimeoutResendsPacket) { diff --git a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h index 5dddf08d9c..9094c73814 100644 --- a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h +++ b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h @@ -100,6 +100,7 @@ class MockDcSctpSocketCallbacks : public DcSctpSocketCallbacks { } MOCK_METHOD(void, OnMessageReceived, (DcSctpMessage message), (override)); + MOCK_METHOD(void, OnMessageReady, (), (override)); MOCK_METHOD(void, OnError, (ErrorKind error, absl::string_view message), diff --git a/net/dcsctp/socket/stream_reset_handler_test.cc b/net/dcsctp/socket/stream_reset_handler_test.cc index 7b624a88d3..716eb9a649 100644 --- a/net/dcsctp/socket/stream_reset_handler_test.cc +++ b/net/dcsctp/socket/stream_reset_handler_test.cc @@ -44,6 +44,7 @@ namespace dcsctp { namespace { using ::testing::IsEmpty; using ::testing::NiceMock; +using ::testing::Optional; using ::testing::Property; using ::testing::Return; using ::testing::SizeIs; @@ -252,14 +253,15 @@ TEST_F(StreamResetHandlerTest, FailToDeliverWithoutResettingStream) { data_tracker_->Observe(kPeerInitialTsn); data_tracker_->Observe(AddTo(kPeerInitialTsn, 1)); - EXPECT_THAT(reasm_->FlushMessages(), - UnorderedElementsAre( - SctpMessageIs(StreamID(1), PPID(53), kShortPayload), - SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); gen_.ResetStream(); reasm_->Add(AddTo(kPeerInitialTsn, 2), gen_.Ordered({1, 2, 3, 4}, "BE")); - EXPECT_THAT(reasm_->FlushMessages(), IsEmpty()); + EXPECT_FALSE(reasm_->HasMessages()); } TEST_F(StreamResetHandlerTest, ResetStreamsNotDeferred) { @@ -268,10 +270,11 @@ TEST_F(StreamResetHandlerTest, ResetStreamsNotDeferred) { data_tracker_->Observe(kPeerInitialTsn); data_tracker_->Observe(AddTo(kPeerInitialTsn, 1)); - EXPECT_THAT(reasm_->FlushMessages(), - UnorderedElementsAre( - SctpMessageIs(StreamID(1), PPID(53), kShortPayload), - SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); Parameters::Builder builder; builder.Add(OutgoingSSNResetRequestParameter( @@ -285,9 +288,9 @@ TEST_F(StreamResetHandlerTest, ResetStreamsNotDeferred) { gen_.ResetStream(); reasm_->Add(AddTo(kPeerInitialTsn, 2), gen_.Ordered({1, 2, 3, 4}, "BE")); - EXPECT_THAT(reasm_->FlushMessages(), - UnorderedElementsAre( - SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(1), PPID(53), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); } TEST_F(StreamResetHandlerTest, ResetStreamsDeferred) { @@ -298,10 +301,11 @@ TEST_F(StreamResetHandlerTest, ResetStreamsDeferred) { data_tracker_->Observe(TSN(11)); reasm_->Add(TSN(11), gen_.Ordered({1, 2, 3, 4}, "BE", {.mid = MID(1)})); - EXPECT_THAT( - reasm_->FlushMessages(), - UnorderedElementsAre(SctpMessageIs(kStreamId, PPID(53), kShortPayload), - SctpMessageIs(kStreamId, PPID(53), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(kStreamId, PPID(53), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(kStreamId, PPID(53), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); Parameters::Builder builder; builder.Add(OutgoingSSNResetRequestParameter( @@ -332,12 +336,15 @@ TEST_F(StreamResetHandlerTest, ResetStreamsDeferred) { ElementsAre(Property(&ReconfigurationResponseParameter::result, ResponseResult::kSuccessPerformed))); - EXPECT_THAT( - reasm_->FlushMessages(), - UnorderedElementsAre(SctpMessageIs(kStreamId, PPID(2), kShortPayload), - SctpMessageIs(kStreamId, PPID(3), kShortPayload), - SctpMessageIs(kStreamId, PPID(4), kShortPayload), - SctpMessageIs(kStreamId, PPID(5), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(kStreamId, PPID(2), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(kStreamId, PPID(3), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(kStreamId, PPID(4), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(kStreamId, PPID(5), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); } TEST_F(StreamResetHandlerTest, ResetStreamsDeferredOnlySelectedStreams) { @@ -396,12 +403,15 @@ TEST_F(StreamResetHandlerTest, ResetStreamsDeferredOnlySelectedStreams) { .mid = MID(1), .ppid = PPID(1006)})); - EXPECT_THAT(reasm_->FlushMessages(), - UnorderedElementsAre( - SctpMessageIs(StreamID(1), PPID(1001), kShortPayload), - SctpMessageIs(StreamID(2), PPID(1002), kShortPayload), - SctpMessageIs(StreamID(3), PPID(1003), kShortPayload), - SctpMessageIs(StreamID(3), PPID(1006), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(1), PPID(1001), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(2), PPID(1002), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(3), PPID(1003), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(3), PPID(1006), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); builder.Add(OutgoingSSNResetRequestParameter(ReconfigRequestSN(11), ReconfigRequestSN(3), TSN(13), @@ -410,10 +420,11 @@ TEST_F(StreamResetHandlerTest, ResetStreamsDeferredOnlySelectedStreams) { ElementsAre(Property(&ReconfigurationResponseParameter::result, ResponseResult::kSuccessPerformed))); - EXPECT_THAT(reasm_->FlushMessages(), - UnorderedElementsAre( - SctpMessageIs(StreamID(1), PPID(1004), kShortPayload), - SctpMessageIs(StreamID(2), PPID(1005), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(1), PPID(1004), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(StreamID(2), PPID(1005), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); } TEST_F(StreamResetHandlerTest, ResetStreamsDefersForwardTsn) { @@ -469,9 +480,9 @@ TEST_F(StreamResetHandlerTest, ResetStreamsDefersForwardTsn) { ElementsAre(Property(&ReconfigurationResponseParameter::result, ResponseResult::kSuccessPerformed))); - EXPECT_THAT(reasm_->FlushMessages(), - UnorderedElementsAre( - SctpMessageIs(kStreamId, PPID(1005), kShortPayload))); + EXPECT_THAT(reasm_->GetNextMessage(), + Optional(SctpMessageIs(kStreamId, PPID(1005), kShortPayload))); + EXPECT_FALSE(reasm_->HasMessages()); } TEST_F(StreamResetHandlerTest, SendOutgoingRequestDirectly) { diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index a34e893ef0..69d876d957 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -194,7 +194,6 @@ rtc_library("connection") { "../api:sequence_checker", "../api/task_queue", "../api/transport:enums", - "../api/transport:field_trial_based_config", "../api/transport:stun_types", "../api/units:time_delta", "../api/units:timestamp", @@ -848,7 +847,6 @@ rtc_library("transport_description") { ":p2p_constants", "../api:rtc_error", "../rtc_base:logging", - "../rtc_base:macromagic", "../rtc_base:ssl", "../rtc_base:stringutils", "../rtc_base/system:rtc_export", @@ -1128,7 +1126,6 @@ if (rtc_include_tests) { "../rtc_base:gunit_helpers", "../rtc_base:ip_address", "../rtc_base:logging", - "../rtc_base:macromagic", "../rtc_base:net_helpers", "../rtc_base:network_route", "../rtc_base:rtc_base_tests_utils", @@ -1256,7 +1253,6 @@ if (rtc_include_tests) { "../rtc_base:gunit_helpers", "../rtc_base:ip_address", "../rtc_base:logging", - "../rtc_base:macromagic", "../rtc_base:mdns_responder_interface", "../rtc_base:net_helper", "../rtc_base:net_helpers", diff --git a/p2p/base/async_stun_tcp_socket.cc b/p2p/base/async_stun_tcp_socket.cc index 8eb8c3c1cf..9a1c906619 100644 --- a/p2p/base/async_stun_tcp_socket.cc +++ b/p2p/base/async_stun_tcp_socket.cc @@ -140,9 +140,9 @@ size_t AsyncStunTCPSocket::GetExpectedLength(const void* data, int* pad_bytes) { *pad_bytes = 0; PacketLength pkt_len = - webrtc::GetBE16(static_cast(data) + kPacketLenOffset); + GetBE16(static_cast(data) + kPacketLenOffset); size_t expected_pkt_len; - uint16_t msg_type = webrtc::GetBE16(data); + uint16_t msg_type = GetBE16(data); if (IsStunMessage(msg_type)) { // STUN message. expected_pkt_len = kStunHeaderSize + pkt_len; diff --git a/p2p/base/async_stun_tcp_socket_unittest.cc b/p2p/base/async_stun_tcp_socket_unittest.cc index 2730dcd1f7..bdb8bbb7e7 100644 --- a/p2p/base/async_stun_tcp_socket_unittest.cc +++ b/p2p/base/async_stun_tcp_socket_unittest.cc @@ -97,7 +97,7 @@ class AsyncStunTCPSocketTest : public ::testing::Test, client, kClientAddr, listen_socket_->GetLocalAddress())); send_socket_->SignalSentPacket.connect( this, &AsyncStunTCPSocketTest::OnSentPacket); - ASSERT_TRUE(send_socket_.get() != NULL); + ASSERT_TRUE(send_socket_.get() != nullptr); vss_->ProcessMessagesUntilIdle(); } diff --git a/p2p/base/basic_async_resolver_factory.cc b/p2p/base/basic_async_resolver_factory.cc index e66e8fb6e9..260fff3c00 100644 --- a/p2p/base/basic_async_resolver_factory.cc +++ b/p2p/base/basic_async_resolver_factory.cc @@ -20,26 +20,26 @@ namespace webrtc { -std::unique_ptr +std::unique_ptr BasicAsyncDnsResolverFactory::Create() { return std::make_unique(); } -std::unique_ptr +std::unique_ptr BasicAsyncDnsResolverFactory::CreateAndResolve( const SocketAddress& addr, absl::AnyInvocable callback) { - std::unique_ptr resolver = Create(); + std::unique_ptr resolver = Create(); resolver->Start(addr, std::move(callback)); return resolver; } -std::unique_ptr +std::unique_ptr BasicAsyncDnsResolverFactory::CreateAndResolve( const SocketAddress& addr, int family, absl::AnyInvocable callback) { - std::unique_ptr resolver = Create(); + std::unique_ptr resolver = Create(); resolver->Start(addr, family, std::move(callback)); return resolver; } diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc index 713a154c99..cea38d9270 100644 --- a/p2p/base/basic_ice_controller.cc +++ b/p2p/base/basic_ice_controller.cc @@ -116,7 +116,7 @@ void BasicIceController::OnConnectionDestroyed(const Connection* connection) { } bool BasicIceController::HasPingableConnection() const { - int64_t now = webrtc::TimeMillis(); + int64_t now = TimeMillis(); return absl::c_any_of(connections_, [this, now](const Connection* c) { return IsPingable(c, now); }); @@ -130,14 +130,14 @@ IceControllerInterface::PingResult BasicIceController::SelectConnectionToPing( bool need_more_pings_at_weak_interval = absl::c_any_of(connections_, [](const webrtc::Connection* conn) { return conn->active() && - conn->num_pings_sent() < webrtc::MIN_PINGS_AT_WEAK_PING_INTERVAL; + conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL; }); int ping_interval = (weak() || need_more_pings_at_weak_interval) ? weak_ping_interval() : strong_ping_interval(); const Connection* conn = nullptr; - if (webrtc::TimeMillis() >= last_ping_sent_ms + ping_interval) { + if (TimeMillis() >= last_ping_sent_ms + ping_interval) { conn = FindNextPingableConnection(); } PingResult res(conn, std::min(ping_interval, check_receiving_interval())); @@ -152,7 +152,7 @@ void BasicIceController::MarkConnectionPinged(const Connection* conn) { // Returns the next pingable connection to ping. const Connection* BasicIceController::FindNextPingableConnection() { - int64_t now = webrtc::TimeMillis(); + int64_t now = TimeMillis(); // Rule 1: Selected connection takes priority over non-selected ones. if (selected_connection_ && selected_connection_->connected() && @@ -274,15 +274,14 @@ int BasicIceController::CalculateActiveWritablePingInterval( int64_t now) const { // Ping each connection at a higher rate at least // MIN_PINGS_AT_WEAK_PING_INTERVAL times. - if (conn->num_pings_sent() < webrtc::MIN_PINGS_AT_WEAK_PING_INTERVAL) { + if (conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL) { return weak_ping_interval(); } int stable_interval = config_.stable_writable_connection_ping_interval_or_default(); - int weak_or_stablizing_interval = - std::min(stable_interval, - webrtc::WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); + int weak_or_stablizing_interval = std::min( + stable_interval, WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); // If the channel is weak or the connection is not stable yet, use the // weak_or_stablizing_interval. return (!weak() && conn->stable(now)) ? stable_interval @@ -453,7 +452,7 @@ BasicIceController::HandleInitialSelectDampening( return {new_connection, std::nullopt}; } - int64_t now = webrtc::TimeMillis(); + int64_t now = TimeMillis(); int64_t max_delay = 0; if (new_connection->last_ping_received() > 0 && field_trials_->initial_select_dampening_ping_received.has_value()) { @@ -521,7 +520,7 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection( bool missed_receiving_unchanged_threshold = false; std::optional receiving_unchanged_threshold( - webrtc::TimeMillis() - config_.receiving_switching_delay_or_default()); + TimeMillis() - config_.receiving_switching_delay_or_default()); int cmp = CompareConnections(selected_connection_, new_connection, receiving_unchanged_threshold, &missed_receiving_unchanged_threshold); @@ -571,7 +570,7 @@ BasicIceController::SortAndSwitchConnection(IceSwitchReason reason) { RTC_LOG(LS_VERBOSE) << "Sorting " << connections_.size() << " available connections due to: " - << webrtc::IceSwitchReasonToString(reason); + << IceSwitchReasonToString(reason); for (size_t i = 0; i < connections_.size(); ++i) { RTC_LOG(LS_VERBOSE) << connections_[i]->ToString(); } @@ -737,7 +736,7 @@ int BasicIceController::CompareConnections( return state_cmp; } - if (ice_role_func_() == webrtc::ICEROLE_CONTROLLED) { + if (ice_role_func_() == ICEROLE_CONTROLLED) { // Compare the connections based on the nomination states and the last data // received time if this is on the controlled side. if (a->remote_nomination() > b->remote_nomination()) { @@ -827,7 +826,7 @@ std::vector BasicIceController::PruneConnections() { auto best_connection_by_network = GetBestConnectionByNetwork(); for (const Connection* conn : connections_) { const Connection* best_conn = selected_connection_; - if (!webrtc::IPIsAny(conn->network()->GetBestIP())) { + if (!IPIsAny(conn->network()->GetBestIP())) { // If the connection is bound to a specific network interface (not an // "any address" network), compare it against the best connection for // that network interface rather than the best connection overall. This @@ -853,7 +852,7 @@ bool BasicIceController::GetUseCandidateAttr(const Connection* conn, // TODO(honghaiz): Implement regular nomination. return false; case NominationMode::AGGRESSIVE: - if (remote_ice_mode == webrtc::ICEMODE_LITE) { + if (remote_ice_mode == ICEMODE_LITE) { return GetUseCandidateAttr(conn, NominationMode::REGULAR, remote_ice_mode); } @@ -869,7 +868,7 @@ bool BasicIceController::GetUseCandidateAttr(const Connection* conn, // b.1) `conn` is the selected_connection AND // b.2) `conn` is writable. bool selected = conn == selected_connection_; - if (remote_ice_mode == webrtc::ICEMODE_LITE) { + if (remote_ice_mode == ICEMODE_LITE) { return selected && conn->writable(); } bool better_than_selected = diff --git a/p2p/base/basic_packet_socket_factory.cc b/p2p/base/basic_packet_socket_factory.cc index 4604570ceb..785f80b330 100644 --- a/p2p/base/basic_packet_socket_factory.cc +++ b/p2p/base/basic_packet_socket_factory.cc @@ -47,12 +47,12 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocket( // UDP sockets are simple. Socket* socket = socket_factory_->CreateSocket(address.family(), SOCK_DGRAM); if (!socket) { - return NULL; + return nullptr; } if (BindSocket(socket, address, min_port, max_port) < 0) { RTC_LOG(LS_ERROR) << "UDP bind failed with error " << socket->GetError(); delete socket; - return NULL; + return nullptr; } return new AsyncUDPSocket(socket); } @@ -65,23 +65,23 @@ AsyncListenSocket* BasicPacketSocketFactory::CreateServerTcpSocket( // Fail if TLS is required. if (opts & PacketSocketFactory::OPT_TLS) { RTC_LOG(LS_ERROR) << "TLS support currently is not available."; - return NULL; + return nullptr; } if (opts & PacketSocketFactory::OPT_TLS_FAKE) { RTC_LOG(LS_ERROR) << "Fake TLS not supported."; - return NULL; + return nullptr; } Socket* socket = socket_factory_->CreateSocket(local_address.family(), SOCK_STREAM); if (!socket) { - return NULL; + return nullptr; } if (BindSocket(socket, local_address, min_port, max_port) < 0) { RTC_LOG(LS_ERROR) << "TCP bind failed with error " << socket->GetError(); delete socket; - return NULL; + return nullptr; } RTC_CHECK(!(opts & PacketSocketFactory::OPT_STUN)); @@ -96,7 +96,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket( Socket* socket = socket_factory_->CreateSocket(local_address.family(), SOCK_STREAM); if (!socket) { - return NULL; + return nullptr; } if (BindSocket(socket, local_address, 0, 0) < 0) { @@ -109,7 +109,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket( } else { RTC_LOG(LS_ERROR) << "TCP bind failed with error " << socket->GetError(); delete socket; - return NULL; + return nullptr; } } @@ -134,7 +134,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket( // Using TLS, wrap the socket in an SSL adapter. SSLAdapter* ssl_adapter = SSLAdapter::Create(socket); if (!ssl_adapter) { - return NULL; + return nullptr; } if (tlsOpts & PacketSocketFactory::OPT_TLS_INSECURE) { @@ -149,7 +149,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket( if (ssl_adapter->StartSSL(remote_address.hostname().c_str()) != 0) { delete ssl_adapter; - return NULL; + return nullptr; } } else if (tlsOpts & PacketSocketFactory::OPT_TLS_FAKE) { @@ -160,7 +160,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket( if (socket->Connect(remote_address) < 0) { RTC_LOG(LS_ERROR) << "TCP connect failed with error " << socket->GetError(); delete socket; - return NULL; + return nullptr; } // Finally, wrap that socket in a TCP or STUN TCP packet socket. diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index e2ccfaed53..92403b4d78 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -64,8 +64,6 @@ namespace webrtc { namespace { -using webrtc::IceCandidateType; - // Determines whether we have seen at least the given maximum number of // pings fail to have a response. inline bool TooManyFailures( @@ -111,13 +109,13 @@ IceCandidateType GetRtcEventLogCandidateType(const Candidate& c) { } IceCandidatePairProtocol GetProtocolByString(absl::string_view protocol) { - if (protocol == webrtc::UDP_PROTOCOL_NAME) { + if (protocol == UDP_PROTOCOL_NAME) { return IceCandidatePairProtocol::kUdp; - } else if (protocol == webrtc::TCP_PROTOCOL_NAME) { + } else if (protocol == TCP_PROTOCOL_NAME) { return IceCandidatePairProtocol::kTcp; - } else if (protocol == webrtc::SSLTCP_PROTOCOL_NAME) { + } else if (protocol == SSLTCP_PROTOCOL_NAME) { return IceCandidatePairProtocol::kSsltcp; - } else if (protocol == webrtc::TLS_PROTOCOL_NAME) { + } else if (protocol == TLS_PROTOCOL_NAME) { return IceCandidatePairProtocol::kTls; } return IceCandidatePairProtocol::kUnknown; @@ -134,19 +132,19 @@ IceCandidatePairAddressFamily GetAddressFamilyByInt(int address_family) { IceCandidateNetworkType ConvertNetworkType(AdapterType type) { switch (type) { - case webrtc::ADAPTER_TYPE_ETHERNET: + case ADAPTER_TYPE_ETHERNET: return IceCandidateNetworkType::kEthernet; - case webrtc::ADAPTER_TYPE_LOOPBACK: + case ADAPTER_TYPE_LOOPBACK: return IceCandidateNetworkType::kLoopback; - case webrtc::ADAPTER_TYPE_WIFI: + case ADAPTER_TYPE_WIFI: return IceCandidateNetworkType::kWifi; - case webrtc::ADAPTER_TYPE_VPN: + case ADAPTER_TYPE_VPN: return IceCandidateNetworkType::kVpn; - case webrtc::ADAPTER_TYPE_CELLULAR: - case webrtc::ADAPTER_TYPE_CELLULAR_2G: - case webrtc::ADAPTER_TYPE_CELLULAR_3G: - case webrtc::ADAPTER_TYPE_CELLULAR_4G: - case webrtc::ADAPTER_TYPE_CELLULAR_5G: + case ADAPTER_TYPE_CELLULAR: + case ADAPTER_TYPE_CELLULAR_2G: + case ADAPTER_TYPE_CELLULAR_3G: + case ADAPTER_TYPE_CELLULAR_4G: + case ADAPTER_TYPE_CELLULAR_5G: return IceCandidateNetworkType::kCellular; default: return IceCandidateNetworkType::kUnknown; @@ -225,14 +223,14 @@ void Connection::ConnectionRequest::OnSent() { } int Connection::ConnectionRequest::resend_delay() { - return webrtc::CONNECTION_RESPONSE_TIMEOUT; + return CONNECTION_RESPONSE_TIMEOUT; } Connection::Connection(WeakPtr port, size_t index, const Candidate& remote_candidate) : network_thread_(port->thread()), - id_(webrtc::CreateRandomId()), + id_(CreateRandomId()), port_(std::move(port)), local_candidate_(port_->Candidates()[index]), remote_candidate_(remote_candidate), @@ -253,9 +251,8 @@ Connection::Connection(WeakPtr port, last_data_received_(0), last_ping_response_received_(0), state_(IceCandidatePairState::WAITING), - time_created_ms_(webrtc::TimeMillis()), - delta_internal_unix_epoch_ms_(webrtc::TimeUTCMillis() - - webrtc::TimeMillis()), + time_created_ms_(TimeMillis()), + delta_internal_unix_epoch_ms_(TimeUTCMillis() - TimeMillis()), field_trials_(&kDefaultFieldTrials), rtt_estimate_(DEFAULT_RTT_ESTIMATE_HALF_TIME_MS) { RTC_DCHECK_RUN_ON(network_thread_); @@ -304,10 +301,10 @@ uint64_t Connection::priority() const { // controlled agent. // pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) IceRole role = port_->GetIceRole(); - if (role != webrtc::ICEROLE_UNKNOWN) { + if (role != ICEROLE_UNKNOWN) { uint32_t g = 0; uint32_t d = 0; - if (role == webrtc::ICEROLE_CONTROLLING) { + if (role == ICEROLE_CONTROLLING) { g = local_candidate().priority(); d = remote_candidate_.priority(); } else { @@ -404,7 +401,7 @@ bool Connection::nominated() const { int Connection::unwritable_timeout() const { RTC_DCHECK_RUN_ON(network_thread_); - return unwritable_timeout_.value_or(webrtc::CONNECTION_WRITE_CONNECT_TIMEOUT); + return unwritable_timeout_.value_or(CONNECTION_WRITE_CONNECT_TIMEOUT); } void Connection::set_unwritable_timeout(const std::optional& value_ms) { @@ -414,8 +411,7 @@ void Connection::set_unwritable_timeout(const std::optional& value_ms) { int Connection::unwritable_min_checks() const { RTC_DCHECK_RUN_ON(network_thread_); - return unwritable_min_checks_.value_or( - webrtc::CONNECTION_WRITE_CONNECT_FAILURES); + return unwritable_min_checks_.value_or(CONNECTION_WRITE_CONNECT_FAILURES); } void Connection::set_unwritable_min_checks(const std::optional& value) { @@ -425,7 +421,7 @@ void Connection::set_unwritable_min_checks(const std::optional& value) { int Connection::inactive_timeout() const { RTC_DCHECK_RUN_ON(network_thread_); - return inactive_timeout_.value_or(webrtc::CONNECTION_WRITE_TIMEOUT); + return inactive_timeout_.value_or(CONNECTION_WRITE_TIMEOUT); } void Connection::set_inactive_timeout(const std::optional& value) { @@ -435,7 +431,7 @@ void Connection::set_inactive_timeout(const std::optional& value) { int Connection::receiving_timeout() const { RTC_DCHECK_RUN_ON(network_thread_); - return receiving_timeout_.value_or(webrtc::WEAK_CONNECTION_RECEIVE_TIMEOUT); + return receiving_timeout_.value_or(WEAK_CONNECTION_RECEIVE_TIMEOUT); } void Connection::set_receiving_timeout( @@ -468,8 +464,7 @@ void Connection::OnSendStunPacket(const void* data, } void Connection::RegisterReceivedPacketCallback( - absl::AnyInvocable + absl::AnyInvocable received_packet_callback) { RTC_DCHECK_RUN_ON(network_thread_); RTC_CHECK(!received_packet_callback_); @@ -496,7 +491,7 @@ void Connection::OnReadPacket(const ReceivedIpPacket& packet) { packet.payload().size(), addr, &msg, &remote_ufrag)) { // The packet did not parse as a valid STUN message // This is a data packet, pass it along. - last_data_received_ = webrtc::TimeMillis(); + last_data_received_ = TimeMillis(); UpdateReceiving(last_data_received_); recv_rate_tracker_.AddSamples(packet.payload().size()); stats_.packets_received++; @@ -642,7 +637,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) { if (field_trials_->extra_ice_ping && last_ping_response_received_ == 0) { if (local_candidate().is_relay() || local_candidate().is_prflx() || remote_candidate().is_relay() || remote_candidate().is_prflx()) { - const int64_t now = webrtc::TimeMillis(); + const int64_t now = TimeMillis(); if (last_ping_sent_ + kMinExtraPingDelayMs <= now) { RTC_LOG(LS_INFO) << ToString() << "WebRTC-ExtraICEPing/Sending extra ping" @@ -696,7 +691,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) { set_write_state(STATE_WRITE_INIT); } - if (port_->GetIceRole() == webrtc::ICEROLE_CONTROLLED) { + if (port_->GetIceRole() == ICEROLE_CONTROLLED) { const StunUInt32Attribute* nomination_attr = msg->GetUInt32(STUN_ATTR_NOMINATION); uint32_t nomination = 0; @@ -746,8 +741,8 @@ void Connection::SendStunBindingResponse(const StunMessage* message) { // Retrieve the username from the `message`. const StunByteStringAttribute* username_attr = message->GetByteString(STUN_ATTR_USERNAME); - RTC_DCHECK(username_attr != NULL); - if (username_attr == NULL) { + RTC_DCHECK(username_attr != nullptr); + if (username_attr == nullptr) { // No valid username, skip the response. return; } @@ -762,7 +757,7 @@ void Connection::SendStunBindingResponse(const StunMessage* message) { response.AddAttribute(std::make_unique( STUN_ATTR_RETRANSMIT_COUNT, retransmit_attr->value())); - if (retransmit_attr->value() > webrtc::CONNECTION_WRITE_CONNECT_FAILURES) { + if (retransmit_attr->value() > CONNECTION_WRITE_CONNECT_FAILURES) { RTC_LOG(LS_INFO) << ToString() << ": Received a remote ping with high retransmit count: " @@ -977,7 +972,7 @@ void Connection::UpdateState(int64_t now) { return; // Computes our estimate of the RTT given the current estimate. - int rtt = webrtc::SafeClamp(2 * rtt_, MINIMUM_RTT, MAXIMUM_RTT); + int rtt = SafeClamp(2 * rtt_, MINIMUM_RTT, MAXIMUM_RTT); if (RTC_LOG_CHECK_LEVEL(LS_VERBOSE)) { std::string pings; @@ -1104,14 +1099,13 @@ std::unique_ptr Connection::BuildPingRequest( // Adding ICE_CONTROLLED or ICE_CONTROLLING attribute based on the role. IceRole ice_role = port_->GetIceRole(); - RTC_DCHECK(ice_role == webrtc::ICEROLE_CONTROLLING || - ice_role == webrtc::ICEROLE_CONTROLLED); + RTC_DCHECK(ice_role == ICEROLE_CONTROLLING || ice_role == ICEROLE_CONTROLLED); message->AddAttribute(std::make_unique( - ice_role == webrtc::ICEROLE_CONTROLLING ? STUN_ATTR_ICE_CONTROLLING - : STUN_ATTR_ICE_CONTROLLED, + ice_role == ICEROLE_CONTROLLING ? STUN_ATTR_ICE_CONTROLLING + : STUN_ATTR_ICE_CONTROLLED, port_->IceTiebreaker())); - if (ice_role == webrtc::ICEROLE_CONTROLLING) { + if (ice_role == ICEROLE_CONTROLLING) { // We should have either USE_CANDIDATE attribute or ICE_NOMINATION // attribute but not both. That was enforced in p2ptransportchannel. if (use_candidate_attr()) { @@ -1181,7 +1175,7 @@ int64_t Connection::last_ping_received() const { void Connection::ReceivedPing(const std::optional& request_id) { RTC_DCHECK_RUN_ON(network_thread_); - last_ping_received_ = webrtc::TimeMillis(); + last_ping_received_ = TimeMillis(); last_ping_id_received_ = request_id; UpdateReceiving(last_ping_received_); } @@ -1203,7 +1197,7 @@ void Connection::HandlePiggybackCheckAcknowledgementIfAny(StunMessage* msg) { RTC_LOG_V(sev) << ToString() << ": Received piggyback STUN ping response, id=" << hex_encode(request_id); - const int64_t rtt = webrtc::TimeMillis() - iter->sent_time; + const int64_t rtt = TimeMillis() - iter->sent_time; ReceivedPingResponse(rtt, request_id, iter->nomination); } } @@ -1234,7 +1228,7 @@ void Connection::ReceivedPingResponse( acked_nomination_ = nomination.value(); } - int64_t now = webrtc::TimeMillis(); + int64_t now = TimeMillis(); total_round_trip_time_ms_ += rtt; current_round_trip_time_ms_ = static_cast(rtt); rtt_estimate_.AddSample(now, rtt); @@ -1299,7 +1293,7 @@ bool Connection::dead(int64_t now) const { // locally inactive (pruned) connection. This also allows the local agent to // ping with longer interval than 30s as long as it shorter than // `dead_connection_timeout_ms`. - if (now <= (last_received() + webrtc::DEAD_CONNECTION_RECEIVE_TIMEOUT)) { + if (now <= (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)) { // Not dead since we have received the last 30s. return false; } @@ -1307,7 +1301,7 @@ bool Connection::dead(int64_t now) const { // Outstanding pings: let it live until the ping is unreplied for // DEAD_CONNECTION_RECEIVE_TIMEOUT. return now > (pings_since_last_response_[0].sent_time + - webrtc::DEAD_CONNECTION_RECEIVE_TIMEOUT); + DEAD_CONNECTION_RECEIVE_TIMEOUT); } // No outstanding pings: let it live until @@ -1327,7 +1321,7 @@ bool Connection::dead(int64_t now) const { // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections // from being pruned too quickly during a network change event when two // networks would be up simultaneously but only for a brief period. - return now > (time_created_ms_ + webrtc::MIN_CONNECTION_LIFETIME); + return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME); } int Connection::rtt() const { @@ -1344,7 +1338,7 @@ bool Connection::stable(int64_t now) const { } std::string Connection::ToDebugId() const { - return webrtc::ToHex(reinterpret_cast(this)); + return ToHex(reinterpret_cast(this)); } uint32_t Connection::ComputeNetworkCost() const { @@ -1682,9 +1676,9 @@ uint32_t Connection::prflx_priority() const { // (2^8)*(local preference) + // (2^0)*(256 - component ID) IcePriorityValue type_preference = - (local_candidate_.protocol() == webrtc::TCP_PROTOCOL_NAME) - ? webrtc::ICE_TYPE_PREFERENCE_PRFLX_TCP - : webrtc::ICE_TYPE_PREFERENCE_PRFLX; + (local_candidate_.protocol() == TCP_PROTOCOL_NAME) + ? ICE_TYPE_PREFERENCE_PRFLX_TCP + : ICE_TYPE_PREFERENCE_PRFLX; return type_preference << 24 | (local_candidate_.priority() & 0x00FFFFFF); } @@ -1872,7 +1866,7 @@ int ProxyConnection::Send(const void* data, stats_.sent_total_packets++; int sent = port_->SendTo(data, size, remote_candidate_.address(), options, true); - int64_t now = webrtc::TimeMillis(); + int64_t now = TimeMillis(); if (sent <= 0) { RTC_DCHECK(sent < 0); error_ = port_->GetError(); diff --git a/p2p/base/ice_controller_interface.cc b/p2p/base/ice_controller_interface.cc index 9c8ad0bfbd..b4360b9cd7 100644 --- a/p2p/base/ice_controller_interface.cc +++ b/p2p/base/ice_controller_interface.cc @@ -17,7 +17,7 @@ namespace webrtc { std::string IceRecheckEvent::ToString() const { - std::string str = webrtc::IceSwitchReasonToString(reason); + std::string str = IceSwitchReasonToString(reason); if (recheck_delay_ms) { str += " (after delay: " + std::to_string(recheck_delay_ms) + ")"; } diff --git a/p2p/base/ice_credentials_iterator.cc b/p2p/base/ice_credentials_iterator.cc index 1dc7d41762..d02464153d 100644 --- a/p2p/base/ice_credentials_iterator.cc +++ b/p2p/base/ice_credentials_iterator.cc @@ -25,9 +25,8 @@ IceCredentialsIterator::IceCredentialsIterator( IceCredentialsIterator::~IceCredentialsIterator() = default; IceParameters IceCredentialsIterator::CreateRandomIceCredentials() { - return IceParameters(webrtc::CreateRandomString(webrtc::ICE_UFRAG_LENGTH), - webrtc::CreateRandomString(webrtc::ICE_PWD_LENGTH), - false); + return IceParameters(CreateRandomString(ICE_UFRAG_LENGTH), + CreateRandomString(ICE_PWD_LENGTH), false); } IceParameters IceCredentialsIterator::GetIceCredentials() { diff --git a/p2p/base/ice_transport_internal.cc b/p2p/base/ice_transport_internal.cc index 601da19971..6b0011b8b3 100644 --- a/p2p/base/ice_transport_internal.cc +++ b/p2p/base/ice_transport_internal.cc @@ -54,9 +54,6 @@ ContinualGatheringPolicy GetContinualGatheringPolicy( } // namespace -using webrtc::RTCError; -using webrtc::RTCErrorType; - RTCError VerifyCandidate(const Candidate& cand) { // No address zero. if (cand.address().IsNil() || cand.address().IsAnyIP()) { @@ -245,7 +242,7 @@ void IceTransportInternal::SetRemoteIceCredentials(absl::string_view ice_ufrag, void IceTransportInternal::AddGatheringStateCallback( const void* removal_tag, - absl::AnyInvocable callback) { + absl::AnyInvocable callback) { gathering_state_callback_list_.AddReceiver(removal_tag, std::move(callback)); } void IceTransportInternal::RemoveGatheringStateCallback( diff --git a/p2p/base/p2p_constants.h b/p2p/base/p2p_constants.h index fae92bfb27..80aa37639b 100644 --- a/p2p/base/p2p_constants.h +++ b/p2p/base/p2p_constants.h @@ -124,6 +124,8 @@ enum IcePriorityValue : uint8_t { ICE_TYPE_PREFERENCE_HOST = 126 }; +const int kMaxTurnUsernameLength = 509; // RFC 8489 section 14.3 + } // namespace webrtc // Re-export symbols from the webrtc namespace for backwards compatibility. diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 4b1b5e7094..ad69f37445 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -181,13 +181,13 @@ P2PTransportChannel::P2PTransportChannel( network_thread_(Thread::Current()), incoming_only_(false), error_(0), - remote_ice_mode_(webrtc::ICEMODE_FULL), - ice_role_(webrtc::ICEROLE_UNKNOWN), - gathering_state_(webrtc::kIceGatheringNew), + remote_ice_mode_(ICEMODE_FULL), + ice_role_(ICEROLE_UNKNOWN), + gathering_state_(kIceGatheringNew), weak_ping_interval_(GetWeakPingIntervalInFieldTrial(field_trials)), config_(RECEIVING_TIMEOUT, BACKUP_CONNECTION_PING_INTERVAL, - webrtc::GATHER_ONCE /* continual_gathering_policy */, + GATHER_ONCE /* continual_gathering_policy */, false /* prioritize_most_likely_candidate_pairs */, STRONG_AND_STABLE_WRITABLE_CONNECTION_PING_INTERVAL, true /* presume_writable_when_fully_relayed */, @@ -299,7 +299,7 @@ void P2PTransportChannel::AddConnection(Connection* connection) { [this](const StunByteStringAttribute* delta) { return GoogDeltaReceived(delta); }, - [this](webrtc::RTCErrorOr delta_ack) { + [this](RTCErrorOr delta_ack) { GoogDeltaAckReceived(std::move(delta_ack)); }); if (!dtls_stun_piggyback_callbacks_.empty()) { @@ -587,7 +587,7 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { config_.surface_ice_candidates_on_ice_transport_type_changed = config.surface_ice_candidates_on_ice_transport_type_changed; if (config_.surface_ice_candidates_on_ice_transport_type_changed && - config_.continual_gathering_policy != webrtc::GATHER_CONTINUALLY) { + config_.continual_gathering_policy != GATHER_CONTINUALLY) { RTC_LOG(LS_WARNING) << "surface_ice_candidates_on_ice_transport_type_changed is " "ineffective since we do not gather continually."; @@ -847,8 +847,8 @@ void P2PTransportChannel::MaybeStartGathering() { IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), allocator_sessions_.back()->ice_pwd(), ice_parameters_.ufrag, ice_parameters_.pwd)) { - if (gathering_state_ != webrtc::kIceGatheringGathering) { - gathering_state_ = webrtc::kIceGatheringGathering; + if (gathering_state_ != kIceGatheringGathering) { + gathering_state_ = kIceGatheringGathering; SendGatheringStateEvent(); } @@ -960,7 +960,7 @@ void P2PTransportChannel::OnCandidatesAllocationDone( "gathering so not changing gathering state."; return; } - gathering_state_ = webrtc::kIceGatheringComplete; + gathering_state_ = kIceGatheringComplete; RTC_LOG(LS_INFO) << "P2PTransportChannel: " << transport_name() << ", component " << component() << " gathering complete"; SendGatheringStateEvent(); @@ -1000,7 +1000,7 @@ void P2PTransportChannel::OnUnknownAddress(PortInterface* port, const Candidate* candidate = nullptr; for (const Candidate& c : remote_candidates_) { if (c.username() == remote_username && c.address() == address && - c.protocol() == webrtc::ProtoToString(proto)) { + c.protocol() == ProtoToString(proto)) { candidate = &c; break; } @@ -1052,13 +1052,12 @@ void P2PTransportChannel::OnUnknownAddress(PortInterface* port, // If the source transport address of the request does not match any // existing remote candidates, it represents a new peer reflexive remote // candidate. - remote_candidate = - Candidate(component(), webrtc::ProtoToString(proto), address, - remote_candidate_priority, remote_username, remote_password, - IceCandidateType::kPrflx, remote_generation, "", network_id, - network_cost); - if (proto == webrtc::PROTO_TCP) { - remote_candidate.set_tcptype(webrtc::TCPTYPE_ACTIVE_STR); + remote_candidate = Candidate( + component(), ProtoToString(proto), address, remote_candidate_priority, + remote_username, remote_password, IceCandidateType::kPrflx, + remote_generation, "", network_id, network_cost); + if (proto == PROTO_TCP) { + remote_candidate.set_tcptype(TCPTYPE_ACTIVE_STR); } // From RFC 5245, section-7.2.1.3: @@ -1148,7 +1147,7 @@ const IceParameters* P2PTransportChannel::FindRemoteIceFromUfrag( void P2PTransportChannel::OnNominated(Connection* conn) { RTC_DCHECK_RUN_ON(network_thread_); - RTC_DCHECK(ice_role_ == webrtc::ICEROLE_CONTROLLED); + RTC_DCHECK(ice_role_ == ICEROLE_CONTROLLED); if (selected_connection_ == conn) { return; @@ -1228,10 +1227,8 @@ void P2PTransportChannel::AddRemoteCandidate(const Candidate& candidate) { if (new_remote_candidate.address().IsUnresolvedIP()) { // Don't do DNS lookups if the IceTransportPolicy is "none" or "relay". - bool sharing_host = - ((allocator_->candidate_filter() & webrtc::CF_HOST) != 0); - bool sharing_stun = - ((allocator_->candidate_filter() & webrtc::CF_REFLEXIVE) != 0); + bool sharing_host = ((allocator_->candidate_filter() & CF_HOST) != 0); + bool sharing_stun = ((allocator_->candidate_filter() & CF_REFLEXIVE) != 0); if (sharing_host || sharing_stun) { ResolveHostnameCandidate(new_remote_candidate); } @@ -1313,7 +1310,7 @@ void P2PTransportChannel::FinishAddingRemoteCandidate( } // Create connections to this remote candidate. - CreateConnections(new_remote_candidate, NULL); + CreateConnections(new_remote_candidate, nullptr); // Resort the connections list, which may have new elements. ice_controller_->OnImmediateSortAndSwitchRequest( @@ -1374,7 +1371,7 @@ bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate, } } - if ((origin_port != NULL) && !absl::c_linear_search(ports_, origin_port)) { + if ((origin_port != nullptr) && !absl::c_linear_search(ports_, origin_port)) { if (CreateConnection(origin_port, remote_candidate, origin_port)) created = true; } @@ -1401,7 +1398,7 @@ bool P2PTransportChannel::CreateConnection(PortInterface* port, (port_type == IceCandidateType::kRelay || remote_candidate.is_relay())) { RTC_LOG(LS_INFO) << ToString() << ": skip creating connection " - << webrtc::IceCandidateTypeToString(port_type) << " to " + << IceCandidateTypeToString(port_type) << " to " << remote_candidate.type_name(); return false; } @@ -1632,7 +1629,7 @@ DiffServCodePoint P2PTransportChannel::DefaultDscpValue() const { RTC_DCHECK_RUN_ON(network_thread_); OptionMap::const_iterator it = options_.find(Socket::OPT_DSCP); if (it == options_.end()) { - return webrtc::DSCP_NO_CHANGE; + return DSCP_NO_CHANGE; } return static_cast(it->second); } @@ -1656,7 +1653,7 @@ void P2PTransportChannel::RemoveConnectionForTest(Connection* connection) { // Monitor connection states. void P2PTransportChannel::UpdateConnectionStates() { RTC_DCHECK_RUN_ON(network_thread_); - int64_t now = webrtc::TimeMillis(); + int64_t now = TimeMillis(); // We need to copy the list of connections since some may delete themselves // when we call UpdateState. @@ -1720,7 +1717,7 @@ void P2PTransportChannel::UpdateState() { bool P2PTransportChannel::AllowedToPruneConnections() const { RTC_DCHECK_RUN_ON(network_thread_); - return ice_role_ == webrtc::ICEROLE_CONTROLLING || + return ice_role_ == ICEROLE_CONTROLLING || (selected_connection_ && selected_connection_->nominated()); } @@ -1751,7 +1748,7 @@ NetworkRoute P2PTransportChannel::ConfigureNetworkRoute( .last_sent_packet_id = last_sent_packet_id_, .packet_overhead = conn->local_candidate().address().ipaddr().overhead() + - webrtc::GetProtocolOverhead(conn->local_candidate().protocol())}; + GetProtocolOverhead(conn->local_candidate().protocol())}; } void P2PTransportChannel::SwitchSelectedConnection( @@ -1800,7 +1797,7 @@ void P2PTransportChannel::SwitchSelectedConnectionInternal( RTC_LOG(LS_INFO) << ToString() << ": No selected connection"; } - if (conn != nullptr && ice_role_ == webrtc::ICEROLE_CONTROLLING && + if (conn != nullptr && ice_role_ == ICEROLE_CONTROLLING && ((ice_field_trials_.send_ping_on_switch_ice_controlling && old_selected_connection != nullptr) || ice_field_trials_.send_ping_on_selected_ice_controlling)) { @@ -1819,7 +1816,7 @@ void P2PTransportChannel::SwitchSelectedConnectionInternal( if (old_selected_connection) { pair_change.estimated_disconnected_time_ms = - ComputeEstimatedDisconnectedTimeMs(webrtc::TimeMillis(), + ComputeEstimatedDisconnectedTimeMs(TimeMillis(), old_selected_connection); } else { pair_change.estimated_disconnected_time_ms = 0; @@ -2020,7 +2017,7 @@ void P2PTransportChannel::PingConnection(Connection* conn) { RTC_DCHECK_RUN_ON(network_thread_); bool use_candidate_attr = false; uint32_t nomination = 0; - if (ice_role_ == webrtc::ICEROLE_CONTROLLING) { + if (ice_role_ == ICEROLE_CONTROLLING) { bool renomination_supported = ice_parameters_.renomination && !remote_ice_parameters_.empty() && remote_ice_parameters_.back().renomination; @@ -2032,7 +2029,7 @@ void P2PTransportChannel::PingConnection(Connection* conn) { } conn->set_nomination(nomination); conn->set_use_candidate_attr(use_candidate_attr); - last_ping_sent_ms_ = webrtc::TimeMillis(); + last_ping_sent_ms_ = TimeMillis(); conn->Ping(last_ping_sent_ms_, stun_dict_writer_.CreateDelta()); } @@ -2202,8 +2199,7 @@ void P2PTransportChannel::OnReadPacket(Connection* connection, // May need to switch the sending connection based on the receiving media // path if this is the controlled side. - if (ice_role_ == webrtc::ICEROLE_CONTROLLED && - connection != selected_connection_) { + if (ice_role_ == ICEROLE_CONTROLLED && connection != selected_connection_) { ice_controller_->OnImmediateSwitchRequest(IceSwitchReason::DATA_RECEIVED, connection); } diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index b042942f92..cceb4cc33c 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -65,6 +65,7 @@ #include "p2p/test/stun_server.h" #include "p2p/test/test_stun_server.h" #include "p2p/test/test_turn_server.h" +#include "rtc_base/async_packet_socket.h" #include "rtc_base/buffer.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/checks.h" @@ -408,7 +409,7 @@ class P2PTransportChannelTestBase : public ::testing::Test, } ChannelData* GetChannelData(PacketTransportInternal* transport) { if (!HasTransport(transport)) - return NULL; + return nullptr; if (cd1_.ch_.get() == transport) return &cd1_; else @@ -434,7 +435,7 @@ class P2PTransportChannelTestBase : public ::testing::Test, return ice_regathering_counter_[reason]; } - FakeNetworkManager network_manager_; + FakeNetworkManager network_manager_{Thread::Current()}; std::unique_ptr allocator_; AsyncDnsResolverFactoryInterface* async_dns_resolver_factory_ = nullptr; ChannelData cd1_; @@ -572,7 +573,7 @@ class P2PTransportChannelTestBase : public ::testing::Test, } else if (endpoint == 1) { return &ep2_; } else { - return NULL; + return nullptr; } } BasicPortAllocator* GetAllocator(int endpoint) { @@ -988,12 +989,12 @@ class P2PTransportChannelTestBase : public ::testing::Test, static const Candidate* LocalCandidate(P2PTransportChannel* ch) { return (ch && ch->selected_connection()) ? &ch->selected_connection()->local_candidate() - : NULL; + : nullptr; } static const Candidate* RemoteCandidate(P2PTransportChannel* ch) { return (ch && ch->selected_connection()) ? &ch->selected_connection()->remote_candidate() - : NULL; + : nullptr; } Endpoint* GetEndpoint(PacketTransportInternal* transport) { if (ep1_.HasTransport(transport)) { @@ -1001,7 +1002,7 @@ class P2PTransportChannelTestBase : public ::testing::Test, } else if (ep2_.HasTransport(transport)) { return &ep2_; } else { - return NULL; + return nullptr; } } P2PTransportChannel* GetRemoteChannel(IceTransportInternal* ch) { @@ -1014,7 +1015,7 @@ class P2PTransportChannelTestBase : public ::testing::Test, else if (ch == ep2_ch2()) return ep1_ch2(); else - return NULL; + return nullptr; } std::list& GetPacketList(PacketTransportInternal* transport) { return GetChannelData(transport)->ch_packets_; @@ -1255,21 +1256,23 @@ const P2PTransportChannelMatrixTest::Result* /*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS}, /*CO*/ - {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS}, + {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, nullptr, nullptr, LSRS}, /*AD*/ - {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS}, + {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, nullptr, nullptr, LSRS}, /*PO*/ - {SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, NULL, NULL, LSRS}, + {SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, nullptr, nullptr, LSRS}, /*SY*/ - {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS}, + {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, nullptr, nullptr, LSRS}, /*2C*/ - {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS}, + {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, nullptr, nullptr, LSRS}, /*SC*/ - {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS}, + {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, nullptr, nullptr, LSRS}, /*!U*/ - {LTPT, NULL, NULL, NULL, NULL, NULL, NULL, LTPT, LTPT, LSRS}, + {LTPT, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, LTPT, LTPT, + LSRS}, /*!T*/ - {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS}, + {PTLT, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, PTLT, LTRT, + LSRS}, /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS}, }; @@ -1828,7 +1831,7 @@ TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { ConfigureEndpoints(env, OPEN, OPEN, webrtc::kDefaultPortAllocatorFlags, webrtc::kDefaultPortAllocatorFlags); CreateChannels(env); - const Connection* selected_connection = NULL; + const Connection* selected_connection = nullptr; // Wait until the callee's connections are created. EXPECT_THAT( webrtc::WaitUntil( @@ -5691,7 +5694,7 @@ class P2PTransportChannelMostLikelyToWorkFirstTest private: std::unique_ptr port_allocator_; - FakeNetworkManager network_manager_; + FakeNetworkManager network_manager_{Thread::Current()}; TestTurnServer turn_server_; std::unique_ptr channel_; }; diff --git a/p2p/base/packet_transport_internal.cc b/p2p/base/packet_transport_internal.cc index 5f8017d8ab..7670f01d72 100644 --- a/p2p/base/packet_transport_internal.cc +++ b/p2p/base/packet_transport_internal.cc @@ -37,8 +37,8 @@ std::optional PacketTransportInternal::network_route() const { void PacketTransportInternal::RegisterReceivedPacketCallback( void* id, - absl::AnyInvocable callback) { + absl::AnyInvocable + callback) { RTC_DCHECK_RUN_ON(&network_checker_); received_packet_callback_list_.AddReceiver(id, std::move(callback)); } diff --git a/p2p/base/port.cc b/p2p/base/port.cc index 5c78a04092..f488e61106 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -76,20 +76,20 @@ PacketInfoProtocolType ConvertProtocolTypeToPacketInfoProtocolType( // The delay before we begin checking if this port is useless. We set // it to a little higher than a total STUN timeout. -const int kPortTimeoutDelay = webrtc::STUN_TOTAL_TIMEOUT + 5000; +const int kPortTimeoutDelay = STUN_TOTAL_TIMEOUT + 5000; } // namespace -static const char* const PROTO_NAMES[] = { - webrtc::UDP_PROTOCOL_NAME, webrtc::TCP_PROTOCOL_NAME, - webrtc::SSLTCP_PROTOCOL_NAME, webrtc::TLS_PROTOCOL_NAME}; +static const char* const PROTO_NAMES[] = {UDP_PROTOCOL_NAME, TCP_PROTOCOL_NAME, + SSLTCP_PROTOCOL_NAME, + TLS_PROTOCOL_NAME}; const char* ProtoToString(ProtocolType proto) { return PROTO_NAMES[proto]; } std::optional StringToProto(absl::string_view proto_name) { - for (size_t i = 0; i <= webrtc::PROTO_LAST; ++i) { + for (size_t i = 0; i <= PROTO_LAST; ++i) { if (absl::EqualsIgnoreCase(PROTO_NAMES[i], proto_name)) { return static_cast(i); } @@ -125,7 +125,7 @@ Port::Port(const PortParametersRef& args, password_(args.ice_password), timeout_delay_(kPortTimeoutDelay), enable_port_packets_(false), - ice_role_(webrtc::ICEROLE_UNKNOWN), + ice_role_(ICEROLE_UNKNOWN), tiebreaker_(0), shared_socket_(shared_socket), network_cost_(args.network->GetCost(env_.field_trials())), @@ -137,8 +137,8 @@ Port::Port(const PortParametersRef& args, // we should just create one. if (ice_username_fragment_.empty()) { RTC_DCHECK(password_.empty()); - ice_username_fragment_ = webrtc::CreateRandomString(ICE_UFRAG_LENGTH); - password_ = webrtc::CreateRandomString(ICE_PWD_LENGTH); + ice_username_fragment_ = CreateRandomString(ICE_UFRAG_LENGTH); + password_ = CreateRandomString(ICE_PWD_LENGTH); } network_->SignalTypeChanged.connect(this, &Port::OnNetworkTypeChanged); @@ -209,7 +209,7 @@ Connection* Port::GetConnection(const SocketAddress& remote_addr) { if (iter != connections_.end()) return iter->second; else - return NULL; + return nullptr; } void Port::AddAddress(const SocketAddress& address, @@ -347,7 +347,7 @@ void Port::OnReadPacket(const ReceivedIpPacket& packet, ProtocolType proto) { // STUN message handled already } else if (msg->type() == STUN_BINDING_REQUEST) { RTC_LOG(LS_INFO) << "Received " << StunMethodToString(msg->type()) - << " id=" << webrtc::hex_encode(msg->transaction_id()) + << " id=" << hex_encode(msg->transaction_id()) << " from unknown address " << addr.ToSensitiveString(); // We need to signal an unknown address before we handle any role conflict // below. Otherwise there would be no candidate pair and TURN entry created @@ -401,8 +401,8 @@ bool Port::GetStunMessage(const char* data, // NOTE: This could clearly be optimized to avoid allocating any memory. // However, at the data rates we'll be looking at on the client side, // this probably isn't worth worrying about. - RTC_DCHECK(out_msg != NULL); - RTC_DCHECK(out_username != NULL); + RTC_DCHECK(out_msg != nullptr); + RTC_DCHECK(out_username != nullptr); out_username->clear(); // Don't bother parsing the packet if we can tell it's not STUN. @@ -569,7 +569,7 @@ bool Port::IsCompatibleAddress(const SocketAddress& addr) { } // Link-local IPv6 ports can only connect to other link-local IPv6 ports. if (ip.family() == AF_INET6 && - (webrtc::IPIsLinkLocal(ip) != webrtc::IPIsLinkLocal(addr.ipaddr()))) { + (IPIsLinkLocal(ip) != IPIsLinkLocal(addr.ipaddr()))) { return false; } return true; @@ -577,7 +577,7 @@ bool Port::IsCompatibleAddress(const SocketAddress& addr) { DiffServCodePoint Port::StunDscpValue() const { // By default, inherit from whatever the MediaChannel sends. - return webrtc::DSCP_NO_CHANGE; + return DSCP_NO_CHANGE; } void Port::DestroyAllConnections() { @@ -609,7 +609,7 @@ bool Port::ParseStunUsername(const StunMessage* stun_msg, remote_ufrag->clear(); const StunByteStringAttribute* username_attr = stun_msg->GetByteString(STUN_ATTR_USERNAME); - if (username_attr == NULL) + if (username_attr == nullptr) return false; // RFRAG:LFRAG @@ -630,12 +630,12 @@ bool Port::MaybeIceRoleConflict(const SocketAddress& addr, RTC_DCHECK_RUN_ON(thread_); // Validate ICE_CONTROLLING or ICE_CONTROLLED attributes. bool ret = true; - IceRole remote_ice_role = webrtc::ICEROLE_UNKNOWN; + IceRole remote_ice_role = ICEROLE_UNKNOWN; uint64_t remote_tiebreaker = 0; const StunUInt64Attribute* stun_attr = stun_msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); if (stun_attr) { - remote_ice_role = webrtc::ICEROLE_CONTROLLING; + remote_ice_role = ICEROLE_CONTROLLING; remote_tiebreaker = stun_attr->value(); } @@ -643,7 +643,7 @@ bool Port::MaybeIceRoleConflict(const SocketAddress& addr, // tie breaker value received in the ping message matches port // tiebreaker value this must be a loopback call. // We will treat this as valid scenario. - if (remote_ice_role == webrtc::ICEROLE_CONTROLLING && + if (remote_ice_role == ICEROLE_CONTROLLING && username_fragment() == remote_ufrag && remote_tiebreaker == IceTiebreaker()) { return true; @@ -651,13 +651,13 @@ bool Port::MaybeIceRoleConflict(const SocketAddress& addr, stun_attr = stun_msg->GetUInt64(STUN_ATTR_ICE_CONTROLLED); if (stun_attr) { - remote_ice_role = webrtc::ICEROLE_CONTROLLED; + remote_ice_role = ICEROLE_CONTROLLED; remote_tiebreaker = stun_attr->value(); } switch (ice_role_) { - case webrtc::ICEROLE_CONTROLLING: - if (webrtc::ICEROLE_CONTROLLING == remote_ice_role) { + case ICEROLE_CONTROLLING: + if (ICEROLE_CONTROLLING == remote_ice_role) { if (remote_tiebreaker >= tiebreaker_) { SignalRoleConflict(this); } else { @@ -668,8 +668,8 @@ bool Port::MaybeIceRoleConflict(const SocketAddress& addr, } } break; - case webrtc::ICEROLE_CONTROLLED: - if (webrtc::ICEROLE_CONTROLLED == remote_ice_role) { + case ICEROLE_CONTROLLED: + if (ICEROLE_CONTROLLED == remote_ice_role) { if (remote_tiebreaker < tiebreaker_) { SignalRoleConflict(this); } else { @@ -824,10 +824,10 @@ void Port::PostDestroyIfDead(bool delayed) { void Port::DestroyIfDead() { RTC_DCHECK_RUN_ON(thread_); - bool dead = (state_ == State::INIT || state_ == State::PRUNED) && - connections_.empty() && - webrtc::TimeMillis() - last_time_all_connections_removed_ >= - timeout_delay_; + bool dead = + (state_ == State::INIT || state_ == State::PRUNED) && + connections_.empty() && + TimeMillis() - last_time_all_connections_removed_ >= timeout_delay_; if (dead) { Destroy(); } @@ -849,10 +849,9 @@ void Port::OnNetworkTypeChanged(const ::webrtc::Network* network) { std::string Port::ToString() const { StringBuilder ss; - ss << "Port[" << webrtc::ToHex(reinterpret_cast(this)) << ":" + ss << "Port[" << ToHex(reinterpret_cast(this)) << ":" << content_name_ << ":" << component_ << ":" << generation_ << ":" - << webrtc::IceCandidateTypeToString(type_) << ":" << network_->ToString() - << "]"; + << IceCandidateTypeToString(type_) << ":" << network_->ToString() << "]"; return ss.Release(); } @@ -897,7 +896,7 @@ bool Port::OnConnectionDestroyed(Connection* conn) { // fails and is removed before kPortTimeoutDelay, then this message will // not cause the Port to be destroyed. if (connections_.empty()) { - last_time_all_connections_removed_ = webrtc::TimeMillis(); + last_time_all_connections_removed_ = TimeMillis(); PostDestroyIfDead(/*delayed=*/true); } diff --git a/p2p/base/port_allocator.cc b/p2p/base/port_allocator.cc index c7a40d9074..0e7c1ad1df 100644 --- a/p2p/base/port_allocator.cc +++ b/p2p/base/port_allocator.cc @@ -58,12 +58,11 @@ RelayServerConfig::RelayServerConfig(absl::string_view address, absl::string_view password, ProtocolType proto, bool secure) - : RelayServerConfig( - address, - port, - username, - password, - (proto == webrtc::PROTO_TCP && secure ? webrtc::PROTO_TLS : proto)) {} + : RelayServerConfig(address, + port, + username, + password, + (proto == PROTO_TCP && secure ? PROTO_TLS : proto)) {} RelayServerConfig::RelayServerConfig(const RelayServerConfig&) = default; @@ -138,7 +137,7 @@ bool PortAllocator::SetConfiguration( TurnCustomizer* turn_customizer, const std::optional& stun_candidate_keepalive_interval) { PortPrunePolicy turn_port_prune_policy = - prune_turn_ports ? webrtc::PRUNE_BASED_ON_PRIORITY : webrtc::NO_PRUNE; + prune_turn_ports ? PRUNE_BASED_ON_PRIORITY : NO_PRUNE; return SetConfiguration(stun_servers, turn_servers, candidate_pool_size, turn_port_prune_policy, turn_customizer, stun_candidate_keepalive_interval); diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 900296a708..5bf4b43347 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -51,8 +51,6 @@ #include "p2p/test/stun_server.h" #include "p2p/test/test_stun_server.h" #include "p2p/test/test_turn_server.h" -#include "p2p/test/turn_server.h" -#include "rtc_base/arraysize.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/buffer.h" #include "rtc_base/byte_buffer.h" @@ -334,7 +332,7 @@ class TestChannel : public sigslot::has_slots<> { conn_->SignalDestroyed.disconnect(this); conn_ = nullptr; } - ASSERT_TRUE(remote_request_.get() != NULL); + ASSERT_TRUE(remote_request_.get() != nullptr); Candidate c = remote_candidate; c.set_address(remote_address_); conn_ = port_->CreateConnection(c, Port::ORIGIN_MESSAGE); @@ -375,9 +373,9 @@ class TestChannel : public sigslot::has_slots<> { msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); const StunUInt32Attribute* fingerprint_attr = msg->GetUInt32(STUN_ATTR_FINGERPRINT); - EXPECT_TRUE(priority_attr != NULL); - EXPECT_TRUE(mi_attr != NULL); - EXPECT_TRUE(fingerprint_attr != NULL); + EXPECT_TRUE(priority_attr != nullptr); + EXPECT_TRUE(mi_attr != nullptr); + EXPECT_TRUE(fingerprint_attr != nullptr); remote_address_ = addr; remote_request_ = CopyStunMessage(*msg); remote_frag_ = rf; @@ -994,7 +992,7 @@ void PortTest::TestConnectivity(absl::string_view name1, // Send a ping from src to dst. This may or may not make it. ch1.CreateConnection(GetCandidate(ch2.port())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_THAT( webrtc::WaitUntil( [&] { return ch1.conn()->connected(); }, IsTrue(), @@ -1017,7 +1015,7 @@ void PortTest::TestConnectivity(absl::string_view name1, // Send a ping from dst to src. ch2.AcceptConnection(GetCandidate(ch1.port())); - ASSERT_TRUE(ch2.conn() != NULL); + ASSERT_TRUE(ch2.conn() != nullptr); ch2.Ping(); EXPECT_THAT( webrtc::WaitUntil( @@ -1033,7 +1031,7 @@ void PortTest::TestConnectivity(absl::string_view name1, // Send a ping from dst to src. Again, this may or may not make it. ch2.CreateConnection(GetCandidate(ch1.port())); - ASSERT_TRUE(ch2.conn() != NULL); + ASSERT_TRUE(ch2.conn() != nullptr); ch2.Ping(); SIMULATED_WAIT(ch2.conn()->write_state() == Connection::STATE_WRITABLE, kShortTimeout, clock); @@ -1073,7 +1071,7 @@ void PortTest::TestConnectivity(absl::string_view name1, // Pick up the actual address and establish the connection. ch2.AcceptConnection(GetCandidate(ch1.port())); - ASSERT_TRUE(ch2.conn() != NULL); + ASSERT_TRUE(ch2.conn() != nullptr); ch2.Ping(); EXPECT_THAT( webrtc::WaitUntil( @@ -1108,8 +1106,8 @@ void PortTest::TestConnectivity(absl::string_view name1, } // Everything should be good, unless we know the situation is impossible. - ASSERT_TRUE(ch1.conn() != NULL); - ASSERT_TRUE(ch2.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); + ASSERT_TRUE(ch2.conn() != nullptr); if (possible) { EXPECT_TRUE(ch1.conn()->receiving()); EXPECT_EQ(Connection::STATE_WRITABLE, ch1.conn()->write_state()); @@ -1138,15 +1136,15 @@ void PortTest::TestConnectivity(absl::string_view name1, class FakePacketSocketFactory : public PacketSocketFactory { public: FakePacketSocketFactory() - : next_udp_socket_(NULL), next_server_tcp_socket_(NULL) {} + : next_udp_socket_(nullptr), next_server_tcp_socket_(nullptr) {} ~FakePacketSocketFactory() override {} AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address, uint16_t min_port, uint16_t max_port) override { - EXPECT_TRUE(next_udp_socket_ != NULL); + EXPECT_TRUE(next_udp_socket_ != nullptr); AsyncPacketSocket* result = next_udp_socket_; - next_udp_socket_ = NULL; + next_udp_socket_ = nullptr; return result; } @@ -1154,9 +1152,9 @@ class FakePacketSocketFactory : public PacketSocketFactory { uint16_t min_port, uint16_t max_port, int opts) override { - EXPECT_TRUE(next_server_tcp_socket_ != NULL); + EXPECT_TRUE(next_server_tcp_socket_ != nullptr); AsyncListenSocket* result = next_server_tcp_socket_; - next_server_tcp_socket_ = NULL; + next_server_tcp_socket_ = nullptr; return result; } @@ -1761,7 +1759,7 @@ TEST_F(PortTest, TestTcpNoDelay) { webrtc::IsRtcOk()); // Connect and send a ping from src to dst. ch1.CreateConnection(GetCandidate(ch2.port())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_THAT( webrtc::WaitUntil( [&] { return ch1.conn()->connected(); }, IsTrue(), @@ -1772,7 +1770,7 @@ TEST_F(PortTest, TestTcpNoDelay) { // Accept the connection. ch2.AcceptConnection(GetCandidate(ch1.port())); - ASSERT_TRUE(ch2.conn() != NULL); + ASSERT_TRUE(ch2.conn() != nullptr); option_value = -1; success = static_cast(ch1.conn()) @@ -1878,11 +1876,11 @@ void PortTest::TestCrossFamilyPorts(int type) { } Connection* c = ports[0]->CreateConnection(GetCandidate(ports[2].get()), Port::ORIGIN_MESSAGE); - EXPECT_TRUE(NULL == c); + EXPECT_TRUE(nullptr == c); EXPECT_EQ(0U, ports[0]->connections().size()); c = ports[0]->CreateConnection(GetCandidate(ports[1].get()), Port::ORIGIN_MESSAGE); - EXPECT_FALSE(NULL == c); + EXPECT_FALSE(nullptr == c); EXPECT_EQ(1U, ports[0]->connections().size()); // IPv6 Port, connects to IPv4 candidate and to IPv6 candidate. @@ -1892,11 +1890,11 @@ void PortTest::TestCrossFamilyPorts(int type) { } c = ports[2]->CreateConnection(GetCandidate(ports[0].get()), Port::ORIGIN_MESSAGE); - EXPECT_TRUE(NULL == c); + EXPECT_TRUE(nullptr == c); EXPECT_EQ(0U, ports[2]->connections().size()); c = ports[2]->CreateConnection(GetCandidate(ports[3].get()), Port::ORIGIN_MESSAGE); - EXPECT_FALSE(NULL == c); + EXPECT_FALSE(nullptr == c); EXPECT_EQ(1U, ports[2]->connections().size()); } @@ -1911,10 +1909,10 @@ TEST_F(PortTest, TestSkipCrossFamilyUdp) { void PortTest::ExpectPortsCanConnect(bool can_connect, Port* p1, Port* p2) { Connection* c = p1->CreateConnection(GetCandidate(p2), Port::ORIGIN_MESSAGE); if (can_connect) { - EXPECT_FALSE(NULL == c); + EXPECT_FALSE(nullptr == c); EXPECT_EQ(1U, p1->connections().size()); } else { - EXPECT_TRUE(NULL == c); + EXPECT_TRUE(nullptr == c); EXPECT_EQ(0U, p1->connections().size()); } } @@ -2043,27 +2041,27 @@ TEST_F(PortTest, TestSendStunMessage) { EXPECT_FALSE(msg->IsLegacy()); const StunByteStringAttribute* username_attr = msg->GetByteString(STUN_ATTR_USERNAME); - ASSERT_TRUE(username_attr != NULL); + ASSERT_TRUE(username_attr != nullptr); const StunUInt32Attribute* priority_attr = msg->GetUInt32(STUN_ATTR_PRIORITY); - ASSERT_TRUE(priority_attr != NULL); + ASSERT_TRUE(priority_attr != nullptr); EXPECT_EQ(kDefaultPrflxPriority, priority_attr->value()); EXPECT_EQ("rfrag:lfrag", username_attr->string_view()); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != nullptr); EXPECT_EQ(StunMessage::IntegrityStatus::kIntegrityOk, msg->ValidateMessageIntegrity("rpass")); const StunUInt64Attribute* ice_controlling_attr = msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); - ASSERT_TRUE(ice_controlling_attr != NULL); + ASSERT_TRUE(ice_controlling_attr != nullptr); EXPECT_EQ(lport->IceTiebreaker(), ice_controlling_attr->value()); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != NULL); - EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == nullptr); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr); + EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != nullptr); EXPECT_TRUE(StunMessage::ValidateFingerprint( reinterpret_cast(lport->last_stun_buf().data()), lport->last_stun_buf().size())); // Request should not include ping count. - ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); + ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == nullptr); // Save a copy of the BINDING-REQUEST for use below. std::unique_ptr request = CopyStunMessage(*msg); @@ -2072,7 +2070,7 @@ TEST_F(PortTest, TestSendStunMessage) { rconn->OnReadPacket( ReceivedIpPacket(lport->last_stun_buf(), SocketAddress(), std::nullopt)); msg = rport->last_stun_msg(); - ASSERT_TRUE(msg != NULL); + ASSERT_TRUE(msg != nullptr); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); // Received a BINDING-RESPONSE. lconn->OnReadPacket( @@ -2088,25 +2086,25 @@ TEST_F(PortTest, TestSendStunMessage) { EXPECT_FALSE(msg->IsLegacy()); const StunAddressAttribute* addr_attr = msg->GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - ASSERT_TRUE(addr_attr != NULL); + ASSERT_TRUE(addr_attr != nullptr); EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress()); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != nullptr); EXPECT_EQ(StunMessage::IntegrityStatus::kIntegrityOk, msg->ValidateMessageIntegrity("rpass")); - EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); + EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != nullptr); EXPECT_TRUE(StunMessage::ValidateFingerprint( reinterpret_cast(lport->last_stun_buf().data()), lport->last_stun_buf().size())); // No USERNAME or PRIORITY in ICE responses. - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == NULL); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == NULL); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MAPPED_ADDRESS) == NULL); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLING) == NULL); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == nullptr); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == nullptr); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MAPPED_ADDRESS) == nullptr); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLING) == nullptr); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == nullptr); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == nullptr); // Response should not include ping count. - ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); + ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == nullptr); // Respond with a BINDING-ERROR-RESPONSE. This wouldn't happen in real life, // but we can do it here. @@ -2114,23 +2112,23 @@ TEST_F(PortTest, TestSendStunMessage) { request.get(), lport->Candidates()[0].address(), STUN_ERROR_SERVER_ERROR, STUN_ERROR_REASON_SERVER_ERROR); msg = rport->last_stun_msg(); - ASSERT_TRUE(msg != NULL); + ASSERT_TRUE(msg != nullptr); EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type()); EXPECT_FALSE(msg->IsLegacy()); const StunErrorCodeAttribute* error_attr = msg->GetErrorCode(); - ASSERT_TRUE(error_attr != NULL); + ASSERT_TRUE(error_attr != nullptr); EXPECT_EQ(STUN_ERROR_SERVER_ERROR, error_attr->code()); EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), error_attr->reason()); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != nullptr); EXPECT_EQ(StunMessage::IntegrityStatus::kIntegrityOk, msg->ValidateMessageIntegrity("rpass")); - EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); + EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != nullptr); EXPECT_TRUE(StunMessage::ValidateFingerprint( reinterpret_cast(lport->last_stun_buf().data()), lport->last_stun_buf().size())); // No USERNAME with ICE. - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == NULL); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == nullptr); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == nullptr); // Testing STUN binding requests from rport --> lport, having ICE_CONTROLLED // and (incremented) RETRANSMIT_COUNT attributes. @@ -2147,14 +2145,14 @@ TEST_F(PortTest, TestSendStunMessage) { EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); const StunUInt64Attribute* ice_controlled_attr = msg->GetUInt64(STUN_ATTR_ICE_CONTROLLED); - ASSERT_TRUE(ice_controlled_attr != NULL); + ASSERT_TRUE(ice_controlled_attr != nullptr); EXPECT_EQ(rport->IceTiebreaker(), ice_controlled_attr->value()); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == nullptr); // Request should include ping count. const StunUInt32Attribute* retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); - ASSERT_TRUE(retransmit_attr != NULL); + ASSERT_TRUE(retransmit_attr != nullptr); EXPECT_EQ(2U, retransmit_attr->value()); // Respond with a BINDING-RESPONSE. @@ -2180,7 +2178,7 @@ TEST_F(PortTest, TestSendStunMessage) { // Response should include same ping count. retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); - ASSERT_TRUE(retransmit_attr != NULL); + ASSERT_TRUE(retransmit_attr != nullptr); EXPECT_EQ(2U, retransmit_attr->value()); } @@ -2307,10 +2305,10 @@ TEST_F(PortTest, TestUseCandidateAttribute) { IceMessage* msg = lport->last_stun_msg(); const StunUInt64Attribute* ice_controlling_attr = msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); - ASSERT_TRUE(ice_controlling_attr != NULL); + ASSERT_TRUE(ice_controlling_attr != nullptr); const StunByteStringAttribute* use_candidate_attr = msg->GetByteString(STUN_ATTR_USE_CANDIDATE); - ASSERT_TRUE(use_candidate_attr != NULL); + ASSERT_TRUE(use_candidate_attr != nullptr); } // Tests that when the network type changes, the network cost of the port will @@ -2403,7 +2401,7 @@ TEST_F(PortTest, TestNetworkInfoAttribute) { IceMessage* msg = lport->last_stun_msg(); const StunUInt32Attribute* network_info_attr = msg->GetUInt32(STUN_ATTR_GOOG_NETWORK_INFO); - ASSERT_TRUE(network_info_attr != NULL); + ASSERT_TRUE(network_info_attr != nullptr); uint32_t network_info = network_info_attr->value(); EXPECT_EQ(lnetwork_id, network_info >> 16); // Default network has unknown type and cost kNetworkCostUnknown. @@ -2423,7 +2421,7 @@ TEST_F(PortTest, TestNetworkInfoAttribute) { webrtc::IsRtcOk()); msg = rport->last_stun_msg(); network_info_attr = msg->GetUInt32(STUN_ATTR_GOOG_NETWORK_INFO); - ASSERT_TRUE(network_info_attr != NULL); + ASSERT_TRUE(network_info_attr != nullptr); network_info = network_info_attr->value(); EXPECT_EQ(rnetwork_id, network_info >> 16); EXPECT_EQ(webrtc::kNetworkCostHigh, network_info & 0xFFFF); @@ -2447,7 +2445,7 @@ TEST_F(PortTest, TestHandleStunMessage) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() != NULL); + EXPECT_TRUE(out_msg.get() != nullptr); EXPECT_EQ("lfrag", username); // BINDING-RESPONSE without username, with MESSAGE-INTEGRITY and FINGERPRINT. @@ -2459,7 +2457,7 @@ TEST_F(PortTest, TestHandleStunMessage) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() != NULL); + EXPECT_TRUE(out_msg.get() != nullptr); EXPECT_EQ("", username); // BINDING-ERROR-RESPONSE without username, with error, M-I, and FINGERPRINT. @@ -2471,9 +2469,9 @@ TEST_F(PortTest, TestHandleStunMessage) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() != NULL); + EXPECT_TRUE(out_msg.get() != nullptr); EXPECT_EQ("", username); - ASSERT_TRUE(out_msg->GetErrorCode() != NULL); + ASSERT_TRUE(out_msg->GetErrorCode() != nullptr); EXPECT_EQ(STUN_ERROR_SERVER_ERROR, out_msg->GetErrorCode()->code()); EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), out_msg->GetErrorCode()->reason()); @@ -2495,7 +2493,7 @@ TEST_F(PortTest, TestHandleStunMessageBadUsername) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() == NULL); + EXPECT_TRUE(out_msg.get() == nullptr); EXPECT_EQ("", username); EXPECT_EQ(STUN_ERROR_BAD_REQUEST, port->last_stun_error_code()); @@ -2506,7 +2504,7 @@ TEST_F(PortTest, TestHandleStunMessageBadUsername) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() == NULL); + EXPECT_TRUE(out_msg.get() == nullptr); EXPECT_EQ("", username); EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); @@ -2517,7 +2515,7 @@ TEST_F(PortTest, TestHandleStunMessageBadUsername) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() == NULL); + EXPECT_TRUE(out_msg.get() == nullptr); EXPECT_EQ("", username); EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); @@ -2528,7 +2526,7 @@ TEST_F(PortTest, TestHandleStunMessageBadUsername) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() == NULL); + EXPECT_TRUE(out_msg.get() == nullptr); EXPECT_EQ("", username); EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); @@ -2539,7 +2537,7 @@ TEST_F(PortTest, TestHandleStunMessageBadUsername) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() == NULL); + EXPECT_TRUE(out_msg.get() == nullptr); EXPECT_EQ("", username); EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); } @@ -2561,7 +2559,7 @@ TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() == NULL); + EXPECT_TRUE(out_msg.get() == nullptr); EXPECT_EQ("", username); EXPECT_EQ(STUN_ERROR_BAD_REQUEST, port->last_stun_error_code()); @@ -2573,7 +2571,7 @@ TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(port.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() == NULL); + EXPECT_TRUE(out_msg.get() == nullptr); EXPECT_EQ("", username); EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); @@ -2777,7 +2775,7 @@ TEST_F(PortTest, TestHandleStunBindingIndication) { WriteStunMessage(*in_msg, buf.get()); EXPECT_TRUE(GetStunMessageFromBufferWriter(lport.get(), buf.get(), addr, &out_msg, &username)); - EXPECT_TRUE(out_msg.get() != NULL); + EXPECT_TRUE(out_msg.get() != nullptr); EXPECT_EQ(out_msg->type(), STUN_BINDING_INDICATION); EXPECT_EQ("", username); @@ -3165,7 +3163,7 @@ TEST_F(PortTest, TestWritableState) { // Send a ping from src to dst. ch1.CreateConnection(GetCandidate(ch2.port())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); // for TCP connect EXPECT_THAT( @@ -3178,7 +3176,7 @@ TEST_F(PortTest, TestWritableState) { // Data should be sendable before the connection is accepted. char data[] = "abcd"; - int data_size = arraysize(data); + int data_size = std::ssize(data); AsyncSocketPacketOptions options; EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options)); @@ -3258,7 +3256,7 @@ TEST_F(PortTest, TestWritableStateWithConfiguredThreshold) { // Send a ping from src to dst. ch1.CreateConnection(GetCandidate(ch2.port())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); ch1.Ping(); SIMULATED_WAIT(!ch2.remote_address().IsNil(), kShortTimeout, clock); @@ -3312,7 +3310,7 @@ TEST_F(PortTest, TestTimeoutForNeverWritable) { ch2.Start(); ch1.CreateConnection(GetCandidate(ch2.port())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); // Attempt to go directly to write timeout. @@ -3349,7 +3347,7 @@ TEST_F(PortTest, TestIceLiteConnectivity) { ASSERT_FALSE(ice_lite_port->Candidates().empty()); ch1.CreateConnection(GetCandidate(ice_lite_port.get())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); // Send ping from full mode client. @@ -3363,7 +3361,7 @@ TEST_F(PortTest, TestIceLiteConnectivity) { {.timeout = TimeDelta::Millis(kDefaultTimeout)}), webrtc::IsRtcOk()); IceMessage* msg = ice_full_port_ptr->last_stun_msg(); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == nullptr); // Respond with a BINDING-RESPONSE from litemode client. // NOTE: Ideally we should't create connection at this stage from lite @@ -3399,7 +3397,7 @@ TEST_F(PortTest, TestIceLiteConnectivity) { {.timeout = TimeDelta::Millis(kDefaultTimeout)}), webrtc::IsRtcOk()); msg = ice_full_port_ptr->last_stun_msg(); - EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != NULL); + EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr); ch1.Stop(); } @@ -3476,7 +3474,7 @@ TEST_P(GoogPingTest, TestGoogPingAnnounceEnable) { ASSERT_FALSE(port2->Candidates().empty()); ch1.CreateConnection(GetCandidate(port2.get())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); ch1.conn()->SetIceFieldTrials(&trials); @@ -3575,7 +3573,7 @@ TEST_F(PortTest, TestGoogPingUnsupportedVersionInStunBinding) { ASSERT_FALSE(port2->Candidates().empty()); ch1.CreateConnection(GetCandidate(port2.get())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); ch1.conn()->SetIceFieldTrials(&trials); @@ -3650,7 +3648,7 @@ TEST_F(PortTest, TestGoogPingUnsupportedVersionInStunBindingResponse) { ASSERT_FALSE(port2->Candidates().empty()); ch1.CreateConnection(GetCandidate(port2.get())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); ch1.conn()->SetIceFieldTrials(&trials); @@ -3854,7 +3852,7 @@ TEST_F(PortTest, TestErrorResponseMakesGoogPingFallBackToStunBinding) { ASSERT_FALSE(port2->Candidates().empty()); ch1.CreateConnection(GetCandidate(port2.get())); - ASSERT_TRUE(ch1.conn() != NULL); + ASSERT_TRUE(ch1.conn() != nullptr); EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); ch1.conn()->SetIceFieldTrials(&trials); diff --git a/p2p/base/pseudo_tcp.cc b/p2p/base/pseudo_tcp.cc index 6e2e1e5eac..8564afe9a0 100644 --- a/p2p/base/pseudo_tcp.cc +++ b/p2p/base/pseudo_tcp.cc @@ -144,19 +144,19 @@ const uint32_t IDLE_TIMEOUT = 90 * 1000; // 90 seconds; ////////////////////////////////////////////////////////////////////// inline void long_to_bytes(uint32_t val, void* buf) { - *static_cast(buf) = webrtc::HostToNetwork32(val); + *static_cast(buf) = HostToNetwork32(val); } inline void short_to_bytes(uint16_t val, void* buf) { - *static_cast(buf) = webrtc::HostToNetwork16(val); + *static_cast(buf) = HostToNetwork16(val); } inline uint32_t bytes_to_long(const void* buf) { - return webrtc::NetworkToHost32(*static_cast(buf)); + return NetworkToHost32(*static_cast(buf)); } inline uint16_t bytes_to_short(const void* buf) { - return webrtc::NetworkToHost16(*static_cast(buf)); + return NetworkToHost16(*static_cast(buf)); } ////////////////////////////////////////////////////////////////////// @@ -188,7 +188,7 @@ void ReportStats() { char buffer[256]; size_t len = 0; for (int i = 0; i < S_NUM_STATS; ++i) { - len += snprintf(buffer, arraysize(buffer), "%s%s:%d", + len += snprintf(buffer, std::size(buffer), "%s%s:%d", (i == 0) ? "" : ",", STAT_NAMES[i], g_stats[i]); g_stats[i] = 0; } @@ -205,7 +205,7 @@ uint32_t PseudoTcp::Now() { #if 0 // Use this to synchronize timers with logging timestamps (easier debug) return static_cast(webrtc::TimeSince(StartTime())); #else - return webrtc::Time32(); + return Time32(); #endif } @@ -288,7 +288,7 @@ void PseudoTcp::NotifyClock(uint32_t now) { return; // Check if it's time to retransmit a segment - if (m_rto_base && (webrtc::TimeDiff32(m_rto_base + m_rx_rto, now) <= 0)) { + if (m_rto_base && (TimeDiff32(m_rto_base + m_rx_rto, now) <= 0)) { if (m_slist.empty()) { RTC_DCHECK_NOTREACHED(); } else { @@ -319,9 +319,8 @@ void PseudoTcp::NotifyClock(uint32_t now) { } // Check if it's time to probe closed windows - if ((m_snd_wnd == 0) && - (webrtc::TimeDiff32(m_lastsend + m_rx_rto, now) <= 0)) { - if (webrtc::TimeDiff32(now, m_lastrecv) >= 15000) { + if ((m_snd_wnd == 0) && (TimeDiff32(m_lastsend + m_rx_rto, now) <= 0)) { + if (TimeDiff32(now, m_lastrecv) >= 15000) { closedown(ECONNABORTED); return; } @@ -335,7 +334,7 @@ void PseudoTcp::NotifyClock(uint32_t now) { } // Check if it's time to send delayed acks - if (m_t_ack && (webrtc::TimeDiff32(m_t_ack + m_ack_delay, now) <= 0)) { + if (m_t_ack && (TimeDiff32(m_t_ack + m_ack_delay, now) <= 0)) { packet(m_snd_nxt, 0, 0, 0); } @@ -612,16 +611,16 @@ bool PseudoTcp::clock_check(uint32_t now, long& nTimeout) { nTimeout = DEFAULT_TIMEOUT; if (m_t_ack) { - nTimeout = std::min( - nTimeout, webrtc::TimeDiff32(m_t_ack + m_ack_delay, now)); + nTimeout = + std::min(nTimeout, TimeDiff32(m_t_ack + m_ack_delay, now)); } if (m_rto_base) { - nTimeout = std::min( - nTimeout, webrtc::TimeDiff32(m_rto_base + m_rx_rto, now)); + nTimeout = + std::min(nTimeout, TimeDiff32(m_rto_base + m_rx_rto, now)); } if (m_snd_wnd == 0) { - nTimeout = std::min( - nTimeout, webrtc::TimeDiff32(m_lastsend + m_rx_rto, now)); + nTimeout = + std::min(nTimeout, TimeDiff32(m_lastsend + m_rx_rto, now)); } #if PSEUDO_KEEPALIVE if (m_state == TCP_ESTABLISHED) { @@ -703,7 +702,7 @@ bool PseudoTcp::process(Segment& seg) { if ((seg.ack > m_snd_una) && (seg.ack <= m_snd_nxt)) { // Calculate round-trip time if (seg.tsecr) { - int32_t rtt = webrtc::TimeDiff32(now, seg.tsecr); + int32_t rtt = TimeDiff32(now, seg.tsecr); if (rtt >= 0) { if (m_rx_srtt == 0) { m_rx_srtt = rtt; @@ -716,8 +715,8 @@ bool PseudoTcp::process(Segment& seg) { m_rx_rttvar = (3 * m_rx_rttvar + abs_err) / 4; m_rx_srtt = (7 * m_rx_srtt + rtt) / 8; } - m_rx_rto = webrtc::SafeClamp( - m_rx_srtt + webrtc::SafeMax(1, 4 * m_rx_rttvar), MIN_RTO, MAX_RTO); + m_rx_rto = SafeClamp(m_rx_srtt + SafeMax(1, 4 * m_rx_rttvar), MIN_RTO, + MAX_RTO); #if _DEBUGMSG >= _DBG_VERBOSE RTC_LOG(LS_INFO) << "rtt: " << rtt << " srtt: " << m_rx_srtt << " rto: " << m_rx_rto; @@ -916,7 +915,7 @@ bool PseudoTcp::process(Segment& seg) { } else { uint32_t nOffset = seg.seq - m_rcv_nxt; - if (!m_rbuf.WriteOffset(seg.data, seg.len, nOffset, NULL)) { + if (!m_rbuf.WriteOffset(seg.data, seg.len, nOffset, nullptr)) { // Ignore incoming packets outside of the receive window. return false; } @@ -1049,7 +1048,7 @@ bool PseudoTcp::transmit(const SList::iterator& seg, uint32_t now) { void PseudoTcp::attemptSend(SendFlags sflags) { uint32_t now = Now(); - if (webrtc::TimeDiff32(now, m_lastsend) > static_cast(m_rx_rto)) { + if (TimeDiff32(now, m_lastsend) > static_cast(m_rx_rto)) { m_cwnd = m_mss; } diff --git a/p2p/base/pseudo_tcp_unittest.cc b/p2p/base/pseudo_tcp_unittest.cc index 1c3ae2118f..cdb794a2ba 100644 --- a/p2p/base/pseudo_tcp_unittest.cc +++ b/p2p/base/pseudo_tcp_unittest.cc @@ -358,8 +358,8 @@ class PseudoTcpTestPingPong : public PseudoTcpTestBase { public: PseudoTcpTestPingPong() : iterations_remaining_(0), - sender_(NULL), - receiver_(NULL), + sender_(nullptr), + receiver_(nullptr), bytes_per_send_(0) {} void SetBytesPerSend(int bytes) { bytes_per_send_ = bytes; } void TestPingPong(int size, int iterations) { diff --git a/p2p/base/regathering_controller_unittest.cc b/p2p/base/regathering_controller_unittest.cc index 9b1c216db4..33ead46919 100644 --- a/p2p/base/regathering_controller_unittest.cc +++ b/p2p/base/regathering_controller_unittest.cc @@ -75,7 +75,7 @@ class RegatheringControllerTest : public ::testing::Test, std::vector turn_servers(1, turn_server); allocator_->set_flags(kOnlyLocalPorts); allocator_->SetConfiguration(stun_servers, turn_servers, 0 /* pool size */, - webrtc::NO_PRUNE); + NO_PRUNE); allocator_session_ = allocator_->CreateSession( "test", ICE_CANDIDATE_COMPONENT_RTP, kIceUfrag, kIcePwd); // The gathering will take place on the current thread and the following diff --git a/p2p/base/stun_port.cc b/p2p/base/stun_port.cc index 63105bec4b..f5df2d830c 100644 --- a/p2p/base/stun_port.cc +++ b/p2p/base/stun_port.cc @@ -83,7 +83,7 @@ class StunBindingRequest : public StunRequest { } // The keep-alive requests will be stopped after its lifetime has passed. - if (WithinLifetime(webrtc::TimeMillis())) { + if (WithinLifetime(TimeMillis())) { port_->request_manager_.SendDelayed( new StunBindingRequest(port_, server_addr_, start_time_), port_->stun_keepalive_delay()); @@ -106,9 +106,8 @@ class StunBindingRequest : public StunRequest { attr ? attr->reason() : "STUN binding response with no error code attribute."); - int64_t now = webrtc::TimeMillis(); - if (WithinLifetime(now) && - webrtc::TimeDiff(now, start_time_) < RETRY_TIMEOUT) { + int64_t now = TimeMillis(); + if (WithinLifetime(now) && TimeDiff(now, start_time_) < RETRY_TIMEOUT) { port_->request_manager_.SendDelayed( new StunBindingRequest(port_, server_addr_, start_time_), port_->stun_keepalive_delay()); @@ -128,7 +127,7 @@ class StunBindingRequest : public StunRequest { // lifetime means infinite). bool WithinLifetime(int64_t now) const { int lifetime = port_->stun_keepalive_lifetime(); - return lifetime < 0 || webrtc::TimeDiff(now, start_time_) <= lifetime; + return lifetime < 0 || TimeDiff(now, start_time_) <= lifetime; } UDPPort* port_; @@ -188,7 +187,7 @@ UDPPort::UDPPort(const PortParametersRef& args, error_(0), ready_(false), stun_keepalive_delay_(STUN_KEEPALIVE_INTERVAL), - dscp_(webrtc::DSCP_NO_CHANGE), + dscp_(DSCP_NO_CHANGE), emit_local_for_anyaddress_(emit_local_for_anyaddress) {} UDPPort::UDPPort(const PortParametersRef& args, @@ -206,7 +205,7 @@ UDPPort::UDPPort(const PortParametersRef& args, error_(0), ready_(false), stun_keepalive_delay_(STUN_KEEPALIVE_INTERVAL), - dscp_(webrtc::DSCP_NO_CHANGE), + dscp_(DSCP_NO_CHANGE), emit_local_for_anyaddress_(emit_local_for_anyaddress) {} bool UDPPort::Init() { @@ -349,11 +348,11 @@ bool UDPPort::HandleIncomingPacket(AsyncPacketSocket* socket, } bool UDPPort::SupportsProtocol(absl::string_view protocol) const { - return protocol == webrtc::UDP_PROTOCOL_NAME; + return protocol == UDP_PROTOCOL_NAME; } ProtocolType UDPPort::GetProtocol() const { - return webrtc::PROTO_UDP; + return PROTO_UDP; } void UDPPort::GetStunStats(std::optional* stats) { @@ -376,7 +375,7 @@ void UDPPort::OnLocalAddressReady(AsyncPacketSocket* /* socket */, // least the port is listening. MaybeSetDefaultLocalAddress(&addr); - AddAddress(addr, addr, SocketAddress(), webrtc::UDP_PROTOCOL_NAME, "", "", + AddAddress(addr, addr, SocketAddress(), UDP_PROTOCOL_NAME, "", "", IceCandidateType::kHost, ICE_TYPE_PREFERENCE_HOST, 0, "", false); MaybePrepareStunCandidate(); } @@ -405,7 +404,7 @@ void UDPPort::OnReadPacket(AsyncPacketSocket* socket, if (Connection* conn = GetConnection(packet.source_address())) { conn->OnReadPacket(packet); } else { - Port::OnReadPacket(packet, webrtc::PROTO_UDP); + Port::OnReadPacket(packet, PROTO_UDP); } } @@ -477,7 +476,7 @@ void UDPPort::SendStunBindingRequest(const SocketAddress& stun_addr) { // Check if `server_addr_` is compatible with the port's ip. if (IsCompatibleAddress(stun_addr)) { request_manager_.Send( - new StunBindingRequest(this, stun_addr, webrtc::TimeMillis())); + new StunBindingRequest(this, stun_addr, TimeMillis())); } else { // Since we can't send stun messages to the server, we should mark this // port ready. This is not an error but similar to ignoring @@ -532,15 +531,14 @@ void UDPPort::OnStunBindingRequestSucceeded( SocketAddress related_address = socket_->GetLocalAddress(); // If we can't stamp the related address correctly, empty it to avoid leak. if (!MaybeSetDefaultLocalAddress(&related_address)) { - related_address = - webrtc::EmptySocketAddressWithFamily(related_address.family()); + related_address = EmptySocketAddressWithFamily(related_address.family()); } StringBuilder url; url << "stun:" << stun_server_addr.hostname() << ":" << stun_server_addr.port(); AddAddress(stun_reflected_addr, socket_->GetLocalAddress(), related_address, - webrtc::UDP_PROTOCOL_NAME, "", "", IceCandidateType::kSrflx, + UDP_PROTOCOL_NAME, "", "", IceCandidateType::kSrflx, ICE_TYPE_PREFERENCE_SRFLX, 0, url.str(), false); } MaybeSetPortCompleteOrError(); diff --git a/p2p/base/stun_port_unittest.cc b/p2p/base/stun_port_unittest.cc index f0d08739fd..809c435b78 100644 --- a/p2p/base/stun_port_unittest.cc +++ b/p2p/base/stun_port_unittest.cc @@ -225,7 +225,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { socket_.reset(socket_factory()->CreateUdpSocket( webrtc::SocketAddress(kPrivateIP.ipaddr(), 0), 0, 0)); } - ASSERT_TRUE(socket_ != NULL); + ASSERT_TRUE(socket_ != nullptr); socket_->RegisterReceivedPacketCallback( [&](webrtc::AsyncPacketSocket* socket, const webrtc::ReceivedIpPacket& packet) { @@ -242,7 +242,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { .ice_password = webrtc::CreateRandomString(22)}, socket_.get(), false, std::nullopt); stun_port_->set_server_addresses(stun_servers); - ASSERT_TRUE(stun_port_ != NULL); + ASSERT_TRUE(stun_port_ != nullptr); stun_port_->SetIceTiebreaker(kTiebreakerDefault); stun_port_->SignalPortComplete.connect(this, &StunPortTestBase::OnPortComplete); @@ -270,7 +270,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { protected: static void SetUpTestSuite() { // Ensure the RNG is inited. - webrtc::InitRandom(NULL, 0); + webrtc::InitRandom(nullptr, 0); } void OnPortComplete(webrtc::Port* /* port */) { diff --git a/p2p/base/stun_request.cc b/p2p/base/stun_request.cc index 952590e471..1a31df5b45 100644 --- a/p2p/base/stun_request.cc +++ b/p2p/base/stun_request.cc @@ -33,7 +33,6 @@ #include "rtc_base/time_utils.h" // For TimeMillis namespace webrtc { -using ::webrtc::SafeTask; // RFC 5389 says SHOULD be 500ms. // For years, this was 100ms, but for networks that @@ -54,7 +53,7 @@ const int STUN_MAX_RTO = 8000; // milliseconds, or 5 doublings StunRequestManager::StunRequestManager( TaskQueueBase* thread, - std::function send_packet) + std::function send_packet) : thread_(thread), send_packet_(std::move(send_packet)) {} StunRequestManager::~StunRequestManager() = default; @@ -215,8 +214,7 @@ bool StunRequestManager::CheckResponse(const char* data, size_t size) { MakeArrayView(reinterpret_cast(data), size)); std::unique_ptr response(iter->second->msg_->CreateNew()); if (!response->Read(&buf)) { - RTC_LOG(LS_WARNING) << "Failed to read STUN response " - << webrtc::hex_encode(id); + RTC_LOG(LS_WARNING) << "Failed to read STUN response " << hex_encode(id); return false; } @@ -258,7 +256,7 @@ StunRequest::StunRequest(StunRequestManager& manager, StunRequest::~StunRequest() {} int StunRequest::type() { - RTC_DCHECK(msg_ != NULL); + RTC_DCHECK(msg_ != nullptr); return msg_->type(); } @@ -268,7 +266,7 @@ const StunMessage* StunRequest::msg() const { int StunRequest::Elapsed() const { RTC_DCHECK_RUN_ON(network_thread()); - return static_cast(webrtc::TimeMillis() - tstamp_); + return static_cast(TimeMillis() - tstamp_); } void StunRequest::SendInternal() { @@ -279,7 +277,7 @@ void StunRequest::SendInternal() { return; } - tstamp_ = webrtc::TimeMillis(); + tstamp_ = TimeMillis(); ByteBufferWriter buf; msg_->Write(&buf); diff --git a/p2p/base/stun_request_unittest.cc b/p2p/base/stun_request_unittest.cc index f1745d490a..945d29b82e 100644 --- a/p2p/base/stun_request_unittest.cc +++ b/p2p/base/stun_request_unittest.cc @@ -55,7 +55,7 @@ class StunRequestTest : public ::testing::Test { OnSendPacket(data, size, request); }), request_count_(0), - response_(NULL), + response_(nullptr), success_(false), failure_(false), timeout_(false) {} @@ -143,7 +143,7 @@ TEST_F(StunRequestTest, TestUnexpected) { manager_.Send(request); EXPECT_FALSE(manager_.CheckResponse(res.get())); - EXPECT_TRUE(response_ == NULL); + EXPECT_TRUE(response_ == nullptr); EXPECT_FALSE(success_); EXPECT_FALSE(failure_); EXPECT_FALSE(timeout_); @@ -156,15 +156,14 @@ TEST_F(StunRequestTest, TestBackoff) { std::unique_ptr res = request->CreateResponseMessage(STUN_BINDING_RESPONSE); - int64_t start = webrtc::TimeMillis(); + int64_t start = TimeMillis(); manager_.Send(request); for (int i = 0; i < 9; ++i) { - EXPECT_THAT( - webrtc::WaitUntil([&] { return request_count_; }, Ne(i), + EXPECT_THAT(WaitUntil([&] { return request_count_; }, Ne(i), {.timeout = TimeDelta::Millis(STUN_TOTAL_TIMEOUT), .clock = &fake_clock}), - webrtc::IsRtcOk()); - int64_t elapsed = webrtc::TimeMillis() - start; + IsRtcOk()); + int64_t elapsed = TimeMillis() - start; RTC_DLOG(LS_INFO) << "STUN request #" << (i + 1) << " sent at " << elapsed << " ms"; EXPECT_EQ(TotalDelay(i), elapsed); @@ -188,7 +187,7 @@ TEST_F(StunRequestTest, TestTimeout) { SIMULATED_WAIT(false, STUN_TOTAL_TIMEOUT, fake_clock); EXPECT_FALSE(manager_.CheckResponse(res.get())); - EXPECT_TRUE(response_ == NULL); + EXPECT_TRUE(response_ == nullptr); EXPECT_FALSE(success_); EXPECT_FALSE(failure_); EXPECT_TRUE(timeout_); diff --git a/p2p/base/tcp_port.cc b/p2p/base/tcp_port.cc index 7b3b9fddbf..625ff766fd 100644 --- a/p2p/base/tcp_port.cc +++ b/p2p/base/tcp_port.cc @@ -102,9 +102,6 @@ #include "rtc_base/weak_ptr.h" namespace webrtc { -using ::webrtc::IceCandidateType; -using ::webrtc::SafeTask; -using ::webrtc::TimeDelta; TCPPort::TCPPort(const PortParametersRef& args, uint16_t min_port, @@ -135,31 +132,31 @@ TCPPort::~TCPPort() { Connection* TCPPort::CreateConnection(const Candidate& address, CandidateOrigin origin) { if (!SupportsProtocol(address.protocol())) { - return NULL; + return nullptr; } if ((address.tcptype() == TCPTYPE_ACTIVE_STR && !address.is_prflx()) || (address.tcptype().empty() && address.address().port() == 0)) { // It's active only candidate, we should not try to create connections // for these candidates. - return NULL; + return nullptr; } // We can't accept TCP connections incoming on other ports if (origin == ORIGIN_OTHER_PORT) - return NULL; + return nullptr; // We don't know how to act as an ssl server yet - if ((address.protocol() == webrtc::SSLTCP_PROTOCOL_NAME) && + if ((address.protocol() == SSLTCP_PROTOCOL_NAME) && (origin == ORIGIN_THIS_PORT)) { - return NULL; + return nullptr; } if (!IsCompatibleAddress(address.address())) { - return NULL; + return nullptr; } - TCPConnection* conn = NULL; + TCPConnection* conn = nullptr; if (AsyncPacketSocket* socket = GetIncoming(address.address(), true)) { // Incoming connection; we already created a socket and connected signals, // so we need to hand off the "read packet" responsibility to @@ -182,7 +179,7 @@ void TCPPort::PrepareAddress() { << static_cast(listen_socket_->GetState()); AddAddress( listen_socket_->GetLocalAddress(), listen_socket_->GetLocalAddress(), - SocketAddress(), webrtc::TCP_PROTOCOL_NAME, "", TCPTYPE_PASSIVE_STR, + SocketAddress(), TCP_PROTOCOL_NAME, "", TCPTYPE_PASSIVE_STR, IceCandidateType::kHost, ICE_TYPE_PREFERENCE_HOST_TCP, 0, "", true); } else { RTC_LOG(LS_INFO) << ToString() @@ -197,7 +194,7 @@ void TCPPort::PrepareAddress() { // see what IP we get. But that may be overkill. AddAddress(SocketAddress(Network()->GetBestIP(), DISCARD_PORT), SocketAddress(Network()->GetBestIP(), 0), SocketAddress(), - webrtc::TCP_PROTOCOL_NAME, "", TCPTYPE_ACTIVE_STR, + TCP_PROTOCOL_NAME, "", TCPTYPE_ACTIVE_STR, IceCandidateType::kHost, ICE_TYPE_PREFERENCE_HOST_TCP, 0, "", true); } @@ -208,7 +205,7 @@ int TCPPort::SendTo(const void* data, const SocketAddress& addr, const AsyncSocketPacketOptions& options, bool payload) { - AsyncPacketSocket* socket = NULL; + AsyncPacketSocket* socket = nullptr; TCPConnection* conn = static_cast(GetConnection(addr)); // For Connection, this is the code path used by Ping() to establish @@ -272,12 +269,11 @@ int TCPPort::GetError() { } bool TCPPort::SupportsProtocol(absl::string_view protocol) const { - return protocol == webrtc::TCP_PROTOCOL_NAME || - protocol == webrtc::SSLTCP_PROTOCOL_NAME; + return protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME; } ProtocolType TCPPort::GetProtocol() const { - return webrtc::PROTO_TCP; + return PROTO_TCP; } void TCPPort::OnNewConnection(AsyncListenSocket* socket, @@ -317,7 +313,7 @@ void TCPPort::TryCreateServerSocket() { AsyncPacketSocket* TCPPort::GetIncoming(const SocketAddress& addr, bool remove) { - AsyncPacketSocket* socket = NULL; + AsyncPacketSocket* socket = nullptr; for (std::list::iterator it = incoming_.begin(); it != incoming_.end(); ++it) { if (it->addr == addr) { @@ -332,7 +328,7 @@ AsyncPacketSocket* TCPPort::GetIncoming(const SocketAddress& addr, void TCPPort::OnReadPacket(AsyncPacketSocket* socket, const ReceivedIpPacket& packet) { - Port::OnReadPacket(packet, webrtc::PROTO_TCP); + Port::OnReadPacket(packet, PROTO_TCP); } void TCPPort::OnSentPacket(AsyncPacketSocket* socket, @@ -354,13 +350,13 @@ TCPConnection::TCPConnection(WeakPtr tcp_port, : Connection(std::move(tcp_port), 0, candidate), socket_(socket), error_(0), - outgoing_(socket == NULL), + outgoing_(socket == nullptr), connection_pending_(false), pretending_to_be_writable_(false), reconnection_timeout_(CONNECTION_WRITE_CONNECT_TIMEOUT) { RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_EQ(port()->GetProtocol(), - webrtc::PROTO_TCP); // Needs to be TCPPort. + PROTO_TCP); // Needs to be TCPPort. SignalDestroyed.connect(this, &TCPConnection::OnDestroyed); @@ -413,7 +409,7 @@ int TCPConnection::Send(const void* data, tcp_port()->CopyPortInformationToPacketInfo( &modified_options.info_signaled_after_sent); int sent = socket_->Send(data, size, modified_options); - int64_t now = webrtc::TimeMillis(); + int64_t now = TimeMillis(); if (sent < 0) { stats_.sent_discarded_packets++; error_ = socket_->GetError(); @@ -487,7 +483,7 @@ void TCPConnection::OnConnect(AsyncPacketSocket* socket) { << ", rather than an address associated with network:" << port_->Network()->ToString() << ". Still allowing it since it's localhost."; - } else if (webrtc::IPIsAny(port_->Network()->GetBestIP())) { + } else if (IPIsAny(port_->Network()->GetBestIP())) { RTC_LOG(LS_WARNING) << "Socket is bound to the address:" << socket_address.ipaddr().ToSensitiveString() @@ -592,7 +588,7 @@ void TCPConnection::OnDestroyed(Connection* c) { void TCPConnection::CreateOutgoingTcpSocket() { RTC_DCHECK(outgoing_); - int opts = (remote_candidate().protocol() == webrtc::SSLTCP_PROTOCOL_NAME) + int opts = (remote_candidate().protocol() == SSLTCP_PROTOCOL_NAME) ? PacketSocketFactory::OPT_TLS_FAKE : 0; diff --git a/p2p/base/transport_description.cc b/p2p/base/transport_description.cc index 0a5621a16d..b6013cdc44 100644 --- a/p2p/base/transport_description.cc +++ b/p2p/base/transport_description.cc @@ -21,7 +21,6 @@ #include "absl/strings/string_view.h" #include "api/rtc_error.h" #include "p2p/base/p2p_constants.h" -#include "rtc_base/arraysize.h" #include "rtc_base/logging.h" #include "rtc_base/ssl_fingerprint.h" #include "rtc_base/strings/string_builder.h" @@ -123,7 +122,7 @@ std::optional StringToConnectionRole( CONNECTIONROLE_ACTIVE_STR, CONNECTIONROLE_PASSIVE_STR, CONNECTIONROLE_ACTPASS_STR, CONNECTIONROLE_HOLDCONN_STR}; - for (size_t i = 0; i < arraysize(roles); ++i) { + for (size_t i = 0; i < std::size(roles); ++i) { if (absl::EqualsIgnoreCase(roles[i], role_str)) { return static_cast(CONNECTIONROLE_ACTIVE + i); } diff --git a/p2p/base/transport_description_factory.cc b/p2p/base/transport_description_factory.cc index f016afa466..6391e89d0d 100644 --- a/p2p/base/transport_description_factory.cc +++ b/p2p/base/transport_description_factory.cc @@ -58,7 +58,7 @@ std::unique_ptr TransportDescriptionFactory::CreateOffer( // Fail if we can't create the fingerprint. // If we are the initiator set role to "actpass". if (!SetSecurityInfo(desc.get(), CONNECTIONROLE_ACTPASS)) { - return NULL; + return nullptr; } return desc; @@ -74,7 +74,7 @@ std::unique_ptr TransportDescriptionFactory::CreateAnswer( if (!offer) { RTC_LOG(LS_WARNING) << "Failed to create TransportDescription answer " "because offer is NULL"; - return NULL; + return nullptr; } auto desc = std::make_unique(); @@ -103,7 +103,7 @@ std::unique_ptr TransportDescriptionFactory::CreateAnswer( // We require DTLS, but the other side didn't offer it. Fail. RTC_LOG(LS_WARNING) << "Failed to create TransportDescription answer " "because of incompatible security settings"; - return NULL; + return nullptr; } // This may be a bundled section, fingerprint may legitimately be missing. return desc; @@ -130,10 +130,10 @@ std::unique_ptr TransportDescriptionFactory::CreateAnswer( RTC_LOG(LS_ERROR) << "Remote offer connection role is " << role << " which is a protocol violation"; RTC_DCHECK_NOTREACHED(); - return NULL; + return nullptr; } if (!SetSecurityInfo(desc.get(), role)) { - return NULL; + return nullptr; } return desc; } diff --git a/p2p/base/transport_description_factory_unittest.cc b/p2p/base/transport_description_factory_unittest.cc index 1324a4fc76..fe081185ce 100644 --- a/p2p/base/transport_description_factory_unittest.cc +++ b/p2p/base/transport_description_factory_unittest.cc @@ -60,7 +60,7 @@ class TransportDescriptionFactoryTest : public ::testing::Test { absl::string_view ice_ufrag, absl::string_view ice_pwd, absl::string_view dtls_alg) { - ASSERT_TRUE(desc != NULL); + ASSERT_TRUE(desc != nullptr); EXPECT_EQ(!opt.empty(), desc->HasOption(opt)); if (ice_ufrag.empty() && ice_pwd.empty()) { EXPECT_EQ(static_cast(webrtc::ICE_UFRAG_LENGTH), @@ -72,9 +72,9 @@ class TransportDescriptionFactoryTest : public ::testing::Test { EXPECT_EQ(ice_pwd, desc->ice_pwd); } if (dtls_alg.empty()) { - EXPECT_TRUE(desc->identity_fingerprint.get() == NULL); + EXPECT_TRUE(desc->identity_fingerprint.get() == nullptr); } else { - ASSERT_TRUE(desc->identity_fingerprint.get() != NULL); + ASSERT_TRUE(desc->identity_fingerprint.get() != nullptr); EXPECT_EQ(desc->identity_fingerprint->algorithm, dtls_alg); EXPECT_GT(desc->identity_fingerprint->digest.size(), 0U); } @@ -94,9 +94,9 @@ class TransportDescriptionFactoryTest : public ::testing::Test { webrtc::TransportOptions options; // The initial offer / answer exchange. std::unique_ptr offer = - f1_.CreateOffer(options, NULL, &ice_credentials_); - std::unique_ptr answer = - f2_.CreateAnswer(offer.get(), options, true, NULL, &ice_credentials_); + f1_.CreateOffer(options, nullptr, &ice_credentials_); + std::unique_ptr answer = f2_.CreateAnswer( + offer.get(), options, true, nullptr, &ice_credentials_); // Create an updated offer where we restart ice. options.ice_restart = true; @@ -109,7 +109,7 @@ class TransportDescriptionFactoryTest : public ::testing::Test { // |options.ice_restart == true| std::unique_ptr restart_answer = f2_.CreateAnswer( restart_offer.get(), options, true, answer.get(), &ice_credentials_); - ASSERT_TRUE(restart_answer.get() != NULL); + ASSERT_TRUE(restart_answer.get() != nullptr); VerifyUfragAndPasswordChanged(dtls, answer.get(), restart_answer.get()); } @@ -193,7 +193,7 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferDtls) { ASSERT_TRUE( cert1_->GetSSLCertificate().GetSignatureDigestAlgorithm(&digest_alg)); std::unique_ptr desc = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); CheckDesc(desc.get(), "", "", "", digest_alg); } @@ -201,8 +201,8 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferDtls) { TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsWithNoIdentity) { f1_.set_certificate(nullptr); std::unique_ptr desc = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); - ASSERT_TRUE(desc.get() == NULL); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); + ASSERT_TRUE(desc.get() == nullptr); } // Test updating an offer with DTLS to pick ICE. @@ -212,8 +212,8 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsReofferDtls) { ASSERT_TRUE( cert1_->GetSSLCertificate().GetSignatureDigestAlgorithm(&digest_alg)); std::unique_ptr old_desc = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); - ASSERT_TRUE(old_desc.get() != NULL); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); + ASSERT_TRUE(old_desc.get() != nullptr); std::unique_ptr desc = f1_.CreateOffer(TransportOptions(), old_desc.get(), &ice_credentials_); CheckDesc(desc.get(), "", old_desc->ice_ufrag, old_desc->ice_pwd, digest_alg); @@ -224,12 +224,12 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerDefault) { ASSERT_TRUE( cert1_->GetSSLCertificate().GetSignatureDigestAlgorithm(&digest_alg)); std::unique_ptr offer = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); - ASSERT_TRUE(offer.get() != NULL); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); + ASSERT_TRUE(offer.get() != nullptr); std::unique_ptr desc = f2_.CreateAnswer( - offer.get(), TransportOptions(), true, NULL, &ice_credentials_); + offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); CheckDesc(desc.get(), "", "", "", digest_alg); - desc = f2_.CreateAnswer(offer.get(), TransportOptions(), true, NULL, + desc = f2_.CreateAnswer(offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); CheckDesc(desc.get(), "", "", "", digest_alg); } @@ -240,14 +240,14 @@ TEST_F(TransportDescriptionFactoryTest, TestReanswer) { ASSERT_TRUE( cert1_->GetSSLCertificate().GetSignatureDigestAlgorithm(&digest_alg)); std::unique_ptr offer = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); - ASSERT_TRUE(offer.get() != NULL); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); + ASSERT_TRUE(offer.get() != nullptr); std::unique_ptr old_desc = f2_.CreateAnswer( - offer.get(), TransportOptions(), true, NULL, &ice_credentials_); - ASSERT_TRUE(old_desc.get() != NULL); + offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); + ASSERT_TRUE(old_desc.get() != nullptr); std::unique_ptr desc = f2_.CreateAnswer( offer.get(), TransportOptions(), true, old_desc.get(), &ice_credentials_); - ASSERT_TRUE(desc.get() != NULL); + ASSERT_TRUE(desc.get() != nullptr); CheckDesc(desc.get(), "", old_desc->ice_ufrag, old_desc->ice_pwd, digest_alg); } @@ -256,10 +256,10 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToNoDtls) { f2_.SetInsecureForTesting(); f2_.set_certificate(nullptr); std::unique_ptr offer = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); - ASSERT_TRUE(offer.get() != NULL); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); + ASSERT_TRUE(offer.get() != nullptr); std::unique_ptr desc = f2_.CreateAnswer( - offer.get(), TransportOptions(), true, NULL, &ice_credentials_); + offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); CheckDesc(desc.get(), "", "", "", ""); } @@ -269,15 +269,15 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerNoDtlsToDtls) { f1_.SetInsecureForTesting(); f1_.set_certificate(nullptr); std::unique_ptr offer = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); - ASSERT_TRUE(offer.get() != NULL); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); + ASSERT_TRUE(offer.get() != nullptr); // Normal case. std::unique_ptr desc = f2_.CreateAnswer( - offer.get(), TransportOptions(), true, NULL, &ice_credentials_); - ASSERT_TRUE(desc.get() == NULL); + offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); + ASSERT_TRUE(desc.get() == nullptr); // Insecure case. f2_.SetInsecureForTesting(); - desc = f2_.CreateAnswer(offer.get(), TransportOptions(), true, NULL, + desc = f2_.CreateAnswer(offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); CheckDesc(desc.get(), "", "", "", ""); } @@ -292,14 +292,14 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToDtls) { cert2_->GetSSLCertificate().GetSignatureDigestAlgorithm(&digest_alg2)); std::unique_ptr offer = - f1_.CreateOffer(TransportOptions(), NULL, &ice_credentials_); - ASSERT_TRUE(offer.get() != NULL); + f1_.CreateOffer(TransportOptions(), nullptr, &ice_credentials_); + ASSERT_TRUE(offer.get() != nullptr); std::unique_ptr desc = f2_.CreateAnswer( - offer.get(), TransportOptions(), true, NULL, &ice_credentials_); + offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); CheckDesc(desc.get(), "", "", "", digest_alg2); f2_.SetInsecureForTesting(); - desc = f2_.CreateAnswer(offer.get(), TransportOptions(), true, NULL, + desc = f2_.CreateAnswer(offer.get(), TransportOptions(), true, nullptr, &ice_credentials_); CheckDesc(desc.get(), "", "", "", digest_alg2); } diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc index e0ef1c8384..9395fe5ee9 100644 --- a/p2p/base/turn_port.cc +++ b/p2p/base/turn_port.cc @@ -87,12 +87,12 @@ inline bool IsTurnChannelData(uint16_t msg_type) { static int GetRelayPreference(ProtocolType proto) { switch (proto) { - case webrtc::PROTO_TCP: + case PROTO_TCP: return ICE_TYPE_PREFERENCE_RELAY_TCP; - case webrtc::PROTO_TLS: + case PROTO_TLS: return ICE_TYPE_PREFERENCE_RELAY_TLS; default: - RTC_DCHECK(proto == webrtc::PROTO_UDP); + RTC_DCHECK(proto == PROTO_UDP); return ICE_TYPE_PREFERENCE_RELAY_UDP; } } @@ -240,7 +240,7 @@ TurnPort::TurnPort(const PortParametersRef& args, credentials_(credentials), socket_(socket), error_(0), - stun_dscp_value_(webrtc::DSCP_NO_CHANGE), + stun_dscp_value_(DSCP_NO_CHANGE), request_manager_( args.network_thread, [this](const void* data, size_t size, StunRequest* request) { @@ -271,7 +271,7 @@ TurnPort::TurnPort(const PortParametersRef& args, credentials_(credentials), socket_(nullptr), error_(0), - stun_dscp_value_(webrtc::DSCP_NO_CHANGE), + stun_dscp_value_(DSCP_NO_CHANGE), request_manager_( args.network_thread, [this](const void* data, size_t size, StunRequest* request) { @@ -397,7 +397,7 @@ void TurnPort::PrepareAddress() { "Failed to create TURN client socket."); return; } - if (server_address_.proto == webrtc::PROTO_UDP) { + if (server_address_.proto == PROTO_UDP) { // If its UDP, send AllocateRequest now. // For TCP and TLS AllcateRequest will be sent by OnSocketConnect. SendRequest(new TurnAllocateRequest(this), 0); @@ -408,16 +408,16 @@ void TurnPort::PrepareAddress() { bool TurnPort::CreateTurnClientSocket() { RTC_DCHECK(!socket_ || SharedSocket()); - if (server_address_.proto == webrtc::PROTO_UDP && !SharedSocket()) { + if (server_address_.proto == PROTO_UDP && !SharedSocket()) { socket_ = socket_factory()->CreateUdpSocket( SocketAddress(Network()->GetBestIP(), 0), min_port(), max_port()); - } else if (server_address_.proto == webrtc::PROTO_TCP || - server_address_.proto == webrtc::PROTO_TLS) { + } else if (server_address_.proto == PROTO_TCP || + server_address_.proto == PROTO_TLS) { RTC_DCHECK(!SharedSocket()); int opts = PacketSocketFactory::OPT_STUN; // Apply server address TLS and insecure bits to options. - if (server_address_.proto == webrtc::PROTO_TLS) { + if (server_address_.proto == PROTO_TLS) { if (tls_cert_policy_ == TlsCertPolicy::TLS_CERT_POLICY_INSECURE_NO_CHECK) { opts |= PacketSocketFactory::OPT_TLS_INSECURE; @@ -461,8 +461,8 @@ bool TurnPort::CreateTurnClientSocket() { // TCP port is ready to send stun requests after the socket is connected, // while UDP port is ready to do so once the socket is created. - if (server_address_.proto == webrtc::PROTO_TCP || - server_address_.proto == webrtc::PROTO_TLS) { + if (server_address_.proto == PROTO_TCP || + server_address_.proto == PROTO_TLS) { socket_->SignalConnect.connect(this, &TurnPort::OnSocketConnect); socket_->SubscribeCloseEvent( this, [this](AsyncPacketSocket* s, int err) { OnSocketClose(s, err); }); @@ -475,8 +475,8 @@ bool TurnPort::CreateTurnClientSocket() { void TurnPort::OnSocketConnect(AsyncPacketSocket* socket) { // This slot should only be invoked if we're using a connection-oriented // protocol. - RTC_DCHECK(server_address_.proto == webrtc::PROTO_TCP || - server_address_.proto == webrtc::PROTO_TLS); + RTC_DCHECK(server_address_.proto == PROTO_TCP || + server_address_.proto == PROTO_TLS); // Do not use this port if the socket bound to an address not associated with // the desired network interface. This is seen in Chrome, where TCP sockets @@ -503,7 +503,7 @@ void TurnPort::OnSocketConnect(AsyncPacketSocket* socket) { << ", rather than an address associated with network:" << Network()->ToString() << ". Still allowing it since it's localhost."; - } else if (webrtc::IPIsAny(Network()->GetBestIP())) { + } else if (IPIsAny(Network()->GetBestIP())) { RTC_LOG(LS_WARNING) << ToString() << ": Socket is bound to the address:" << socket_address.ToSensitiveNameAndAddressString() @@ -734,7 +734,7 @@ bool TurnPort::HandleIncomingPacket(AsyncPacketSocket* socket, // Check the message type, to see if is a Channel Data message. // The message will either be channel data, a TURN data indication, or // a response to a previous request. - uint16_t msg_type = webrtc::GetBE16(packet.payload().data()); + uint16_t msg_type = GetBE16(packet.payload().data()); if (IsTurnChannelData(msg_type)) { HandleChannelData(msg_type, data, size, packet_time_us); return true; @@ -776,7 +776,7 @@ void TurnPort::OnReadyToSend(AsyncPacketSocket* socket) { bool TurnPort::SupportsProtocol(absl::string_view protocol) const { // Turn port only connects to UDP candidates. - return protocol == webrtc::UDP_PROTOCOL_NAME; + return protocol == UDP_PROTOCOL_NAME; } // Update current server address port with the alternate server address port. @@ -831,9 +831,8 @@ void TurnPort::ResolveTurnAddress(const SocketAddress& address) { // assuming socket layer will resolve the hostname through a HTTP proxy (if // any). auto& result = resolver_->result(); - if (result.GetError() != 0 && - (server_address_.proto == webrtc::PROTO_TCP || - server_address_.proto == webrtc::PROTO_TLS)) { + if (result.GetError() != 0 && (server_address_.proto == PROTO_TCP || + server_address_.proto == PROTO_TLS)) { if (!CreateTurnClientSocket()) { OnAllocateError(STUN_ERROR_SERVER_NOT_REACHABLE, "TURN host lookup received error."); @@ -893,7 +892,7 @@ void TurnPort::OnAllocateSuccess(const SocketAddress& address, AddAddress(address, // Candidate address. address, // Base address. related_address, // Related address. - webrtc::UDP_PROTOCOL_NAME, + UDP_PROTOCOL_NAME, ProtoToString(server_address_.proto), // The first hop protocol. "", // TCP candidate type, empty for turn candidates. IceCandidateType::kRelay, @@ -909,7 +908,7 @@ void TurnPort::OnAllocateError(int error_code, absl::string_view reason) { SafeTask(task_safety_.flag(), [this] { SignalPortError(this); })); std::string address = GetLocalAddress().HostAsSensitiveURIString(); int port = GetLocalAddress().port(); - if (server_address_.proto == webrtc::PROTO_TCP && + if (server_address_.proto == PROTO_TCP && server_address_.address.IsPrivateIP()) { address.clear(); port = 0; @@ -951,10 +950,9 @@ void TurnPort::Release() { void TurnPort::Close() { if (!ready()) { - OnAllocateError(STUN_ERROR_SERVER_NOT_REACHABLE, - GetProtocol() != webrtc::PROTO_UDP - ? "Failed to establish connection" - : ""); + OnAllocateError( + STUN_ERROR_SERVER_NOT_REACHABLE, + GetProtocol() != PROTO_UDP ? "Failed to establish connection" : ""); } request_manager_.Clear(); // Stop the port from creating new connections. @@ -981,7 +979,7 @@ bool TurnPort::AllowedTurnPort(int port) { } void TurnPort::TryAlternateServer() { - if (server_address().proto == webrtc::PROTO_UDP) { + if (server_address().proto == PROTO_UDP) { // Send another allocate request to alternate server, with the received // realm and nonce values. SendRequest(new TurnAllocateRequest(this), 0); @@ -989,8 +987,8 @@ void TurnPort::TryAlternateServer() { // Since it's TCP, we have to delete the connected socket and reconnect // with the alternate server. PrepareAddress will send stun binding once // the new socket is connected. - RTC_DCHECK(server_address().proto == webrtc::PROTO_TCP || - server_address().proto == webrtc::PROTO_TLS); + RTC_DCHECK(server_address().proto == PROTO_TCP || + server_address().proto == PROTO_TLS); RTC_DCHECK(!SharedSocket()); delete socket_; socket_ = nullptr; @@ -1046,8 +1044,7 @@ void TurnPort::HandleDataIndication(const char* data, // TODO(bugs.webrtc.org/14870): rebuild DispatchPacket to take an // ArrayView DispatchPacket(reinterpret_cast(data_attr->array_view().data()), - data_attr->length(), ext_addr, webrtc::PROTO_UDP, - packet_time_us); + data_attr->length(), ext_addr, PROTO_UDP, packet_time_us); } void TurnPort::HandleChannelData(uint16_t channel_id, @@ -1069,7 +1066,7 @@ void TurnPort::HandleChannelData(uint16_t channel_id, // +-------------------------------+ // Extract header fields from the message. - uint16_t len = webrtc::GetBE16(data + 2); + uint16_t len = GetBE16(data + 2); if (len > size - TURN_CHANNEL_HEADER_SIZE) { RTC_LOG(LS_WARNING) << ToString() << ": Received TURN channel data message with " @@ -1089,7 +1086,7 @@ void TurnPort::HandleChannelData(uint16_t channel_id, } DispatchPacket(data + TURN_CHANNEL_HEADER_SIZE, len, entry->address(), - webrtc::PROTO_UDP, packet_time_us); + PROTO_UDP, packet_time_us); } void TurnPort::DispatchPacket(const char* data, @@ -1273,14 +1270,14 @@ std::string TurnPort::ReconstructServerUrl() { std::string scheme = "turn"; std::string transport = "tcp"; switch (server_address_.proto) { - case webrtc::PROTO_SSLTCP: - case webrtc::PROTO_TLS: + case PROTO_SSLTCP: + case PROTO_TLS: scheme = "turns"; break; - case webrtc::PROTO_UDP: + case PROTO_UDP: transport = "udp"; break; - case webrtc::PROTO_TCP: + case PROTO_TCP: break; } StringBuilder url; @@ -1336,15 +1333,15 @@ TurnAllocateRequest::TurnAllocateRequest(TurnPort* port) } void TurnAllocateRequest::OnSent() { - RTC_LOG(LS_INFO) << port_->ToString() << ": TURN allocate request sent, id=" - << webrtc::hex_encode(id()); + RTC_LOG(LS_INFO) << port_->ToString() + << ": TURN allocate request sent, id=" << hex_encode(id()); StunRequest::OnSent(); } void TurnAllocateRequest::OnResponse(StunMessage* response) { RTC_LOG(LS_INFO) << port_->ToString() << ": TURN allocate requested successfully, id=" - << webrtc::hex_encode(id()) + << hex_encode(id()) << ", code=0" // Makes logging easier to parse. ", rtt=" << Elapsed(); @@ -1390,7 +1387,7 @@ void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { RTC_LOG(LS_INFO) << port_->ToString() << ": Received TURN allocate error response, id=" - << webrtc::hex_encode(id()) << ", code=" << error_code + << hex_encode(id()) << ", code=" << error_code << ", rtt=" << Elapsed(); switch (error_code) { @@ -1410,7 +1407,7 @@ void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { default: RTC_LOG(LS_WARNING) << port_->ToString() << ": Received TURN allocate error response, id=" - << webrtc::hex_encode(id()) << ", code=" << error_code + << hex_encode(id()) << ", code=" << error_code << ", rtt=" << Elapsed(); const StunErrorCodeAttribute* attr = response->GetErrorCode(); port_->OnAllocateError(error_code, attr ? attr->reason() : ""); @@ -1419,7 +1416,7 @@ void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { void TurnAllocateRequest::OnTimeout() { RTC_LOG(LS_WARNING) << port_->ToString() << ": TURN allocate request " - << webrtc::hex_encode(id()) << " timeout"; + << hex_encode(id()) << " timeout"; port_->OnAllocateRequestTimeout(); } @@ -1526,15 +1523,15 @@ TurnRefreshRequest::TurnRefreshRequest(TurnPort* port, int lifetime /*= -1*/) } void TurnRefreshRequest::OnSent() { - RTC_LOG(LS_INFO) << port_->ToString() << ": TURN refresh request sent, id=" - << webrtc::hex_encode(id()); + RTC_LOG(LS_INFO) << port_->ToString() + << ": TURN refresh request sent, id=" << hex_encode(id()); StunRequest::OnSent(); } void TurnRefreshRequest::OnResponse(StunMessage* response) { RTC_LOG(LS_INFO) << port_->ToString() << ": TURN refresh requested successfully, id=" - << webrtc::hex_encode(id()) + << hex_encode(id()) << ", code=0" // Makes logging easier to parse. ", rtt=" << Elapsed(); @@ -1576,7 +1573,7 @@ void TurnRefreshRequest::OnErrorResponse(StunMessage* response) { } else { RTC_LOG(LS_WARNING) << port_->ToString() << ": Received TURN refresh error response, id=" - << webrtc::hex_encode(id()) << ", code=" << error_code + << hex_encode(id()) << ", code=" << error_code << ", rtt=" << Elapsed(); port_->OnRefreshError(); if (port_->callbacks_for_test_) { @@ -1587,7 +1584,7 @@ void TurnRefreshRequest::OnErrorResponse(StunMessage* response) { void TurnRefreshRequest::OnTimeout() { RTC_LOG(LS_WARNING) << port_->ToString() << ": TURN refresh timeout " - << webrtc::hex_encode(id()); + << hex_encode(id()); port_->OnRefreshError(); } @@ -1624,14 +1621,14 @@ TurnCreatePermissionRequest::~TurnCreatePermissionRequest() { void TurnCreatePermissionRequest::OnSent() { RTC_LOG(LS_INFO) << port_->ToString() << ": TURN create permission request sent, id=" - << webrtc::hex_encode(id()); + << hex_encode(id()); StunRequest::OnSent(); } void TurnCreatePermissionRequest::OnResponse(StunMessage* response) { RTC_LOG(LS_INFO) << port_->ToString() << ": TURN permission requested successfully, id=" - << webrtc::hex_encode(id()) + << hex_encode(id()) << ", code=0" // Makes logging easier to parse. ", rtt=" << Elapsed(); @@ -1645,7 +1642,7 @@ void TurnCreatePermissionRequest::OnErrorResponse(StunMessage* response) { int error_code = response->GetErrorCodeValue(); RTC_LOG(LS_WARNING) << port_->ToString() << ": Received TURN create permission error response, id=" - << webrtc::hex_encode(id()) << ", code=" << error_code + << hex_encode(id()) << ", code=" << error_code << ", rtt=" << Elapsed(); if (entry_) { entry_->OnCreatePermissionError(response, error_code); @@ -1655,7 +1652,7 @@ void TurnCreatePermissionRequest::OnErrorResponse(StunMessage* response) { void TurnCreatePermissionRequest::OnTimeout() { RTC_LOG(LS_WARNING) << port_->ToString() << ": TURN create permission timeout " - << webrtc::hex_encode(id()); + << hex_encode(id()); if (entry_) { entry_->OnCreatePermissionTimeout(); } @@ -1696,14 +1693,14 @@ TurnChannelBindRequest::~TurnChannelBindRequest() { void TurnChannelBindRequest::OnSent() { RTC_LOG(LS_INFO) << port_->ToString() << ": TURN channel bind request sent, id=" - << webrtc::hex_encode(id()); + << hex_encode(id()); StunRequest::OnSent(); } void TurnChannelBindRequest::OnResponse(StunMessage* response) { RTC_LOG(LS_INFO) << port_->ToString() << ": TURN channel bind requested successfully, id=" - << webrtc::hex_encode(id()) + << hex_encode(id()) << ", code=0" // Makes logging easier to parse. ", rtt=" << Elapsed(); @@ -1725,7 +1722,7 @@ void TurnChannelBindRequest::OnErrorResponse(StunMessage* response) { int error_code = response->GetErrorCodeValue(); RTC_LOG(LS_WARNING) << port_->ToString() << ": Received TURN channel bind error response, id=" - << webrtc::hex_encode(id()) << ", code=" << error_code + << hex_encode(id()) << ", code=" << error_code << ", rtt=" << Elapsed(); if (entry_) { entry_->OnChannelBindError(response, error_code); @@ -1734,7 +1731,7 @@ void TurnChannelBindRequest::OnErrorResponse(StunMessage* response) { void TurnChannelBindRequest::OnTimeout() { RTC_LOG(LS_WARNING) << port_->ToString() << ": TURN channel bind timeout " - << webrtc::hex_encode(id()); + << hex_encode(id()); if (entry_) { entry_->OnChannelBindTimeout(); } diff --git a/p2p/base/turn_port.h b/p2p/base/turn_port.h index 44a4563942..794e4a41ad 100644 --- a/p2p/base/turn_port.h +++ b/p2p/base/turn_port.h @@ -27,6 +27,7 @@ #include "api/task_queue/pending_task_safety_flag.h" #include "api/transport/stun.h" #include "p2p/base/connection.h" +#include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" #include "p2p/base/port_allocator.h" #include "p2p/base/port_interface.h" @@ -46,8 +47,6 @@ namespace webrtc { class TurnCustomizer; -const int kMaxTurnUsernameLength = 509; // RFC 8489 section 14.3 - extern const int STUN_ATTR_TURN_LOGGING_ID; extern const char TURN_PORT_TYPE[]; class TurnAllocateRequest; diff --git a/p2p/base/turn_port_unittest.cc b/p2p/base/turn_port_unittest.cc index 8f6403c966..d8f4505665 100644 --- a/p2p/base/turn_port_unittest.cc +++ b/p2p/base/turn_port_unittest.cc @@ -163,7 +163,7 @@ static int GetFDCount() { struct dirent* dp; int fd_count = 0; DIR* dir = opendir("/proc/self/fd/"); - while ((dp = readdir(dir)) != NULL) { + while ((dp = readdir(dir)) != nullptr) { if (dp->d_name[0] == '.') continue; ++fd_count; @@ -326,7 +326,7 @@ class TurnPortTest : public ::testing::Test, turn_port_->SetIceTiebreaker(kTiebreakerDefault); ConnectSignals(); - if (server_address.proto == webrtc::PROTO_TLS) { + if (server_address.proto == PROTO_TLS) { // The test TURN server has a self-signed certificate so will not pass // the normal client validation. Instruct the client to ignore certificate // errors for testing only. @@ -339,12 +339,12 @@ class TurnPortTest : public ::testing::Test, void CreateSharedTurnPort(absl::string_view username, absl::string_view password, const ProtocolAddress& server_address) { - RTC_CHECK(server_address.proto == webrtc::PROTO_UDP); + RTC_CHECK(server_address.proto == PROTO_UDP); if (!socket_) { socket_.reset(socket_factory()->CreateUdpSocket( SocketAddress(kLocalAddr1.ipaddr(), 0), 0, 0)); - ASSERT_TRUE(socket_ != NULL); + ASSERT_TRUE(socket_ != nullptr); socket_->RegisterReceivedPacketCallback( [&](AsyncPacketSocket* socket, const ReceivedIpPacket& packet) { OnSocketReadPacket(socket, packet); @@ -403,33 +403,33 @@ class TurnPortTest : public ::testing::Test, // turn_port_ should have been created. ASSERT_TRUE(turn_port_ != nullptr); turn_port_->PrepareAddress(); - ASSERT_THAT(webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), - {.timeout = TimeDelta::Millis( - TimeToGetTurnCandidate(protocol_type)), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), + {.timeout = TimeDelta::Millis( + TimeToGetTurnCandidate(protocol_type)), + .clock = &fake_clock_}), + IsRtcOk()); CreateUdpPort(); udp_port_->PrepareAddress(); - ASSERT_THAT(webrtc::WaitUntil([&] { return udp_ready_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return udp_ready_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); } // Returns the fake clock time to establish a connection over the given // protocol. int TimeToConnect(ProtocolType protocol_type) { switch (protocol_type) { - case webrtc::PROTO_TCP: + case PROTO_TCP: // The virtual socket server will delay by a fixed half a round trip // for a TCP connection. return kSimulatedRtt / 2; - case webrtc::PROTO_TLS: + case PROTO_TLS: // TLS operates over TCP and additionally has a round of HELLO for // negotiating ciphers and a round for exchanging certificates. - return 2 * kSimulatedRtt + TimeToConnect(webrtc::PROTO_TCP); - case webrtc::PROTO_UDP: + return 2 * kSimulatedRtt + TimeToConnect(PROTO_TCP); + case PROTO_UDP: default: // UDP requires no round trips to set up the connection. return 0; @@ -478,10 +478,10 @@ class TurnPortTest : public ::testing::Test, void TestTurnAllocateSucceeds(unsigned int timeout) { ASSERT_TRUE(turn_port_); turn_port_->PrepareAddress(); - EXPECT_THAT(webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), - {.timeout = TimeDelta::Millis(timeout), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), + {.timeout = TimeDelta::Millis(timeout), + .clock = &fake_clock_}), + IsRtcOk()); ASSERT_EQ(1U, turn_port_->Candidates().size()); EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), turn_port_->Candidates()[0].address().ipaddr()); @@ -492,11 +492,11 @@ class TurnPortTest : public ::testing::Test, absl::string_view expected_url) { ASSERT_TRUE(turn_port_); turn_port_->PrepareAddress(); - ASSERT_THAT(webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), - {.timeout = TimeDelta::Millis( - TimeToGetTurnCandidate(protocol_type)), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), + {.timeout = TimeDelta::Millis( + TimeToGetTurnCandidate(protocol_type)), + .clock = &fake_clock_}), + IsRtcOk()); ASSERT_EQ(1U, turn_port_->Candidates().size()); EXPECT_EQ(turn_port_->Candidates()[0].url(), expected_url); } @@ -517,12 +517,11 @@ class TurnPortTest : public ::testing::Test, const SocketAddress old_addr = turn_port_->server_address().address; turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis( TimeToGetAlternateTurnCandidate(protocol_type)), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Retrieve the address again, the turn port's address should be // changed. const SocketAddress new_addr = turn_port_->server_address().address; @@ -545,12 +544,11 @@ class TurnPortTest : public ::testing::Test, turn_port_->PrepareAddress(); // Need time to connect to TURN server, send Allocate request and receive // redirect notice. - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis( kSimulatedRtt + TimeToConnect(protocol_type)), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); } void TestTurnAlternateServerPingPong(ProtocolType protocol_type) { @@ -567,12 +565,11 @@ class TurnPortTest : public ::testing::Test, ProtocolAddress(kTurnIntAddr, protocol_type)); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis( TimeToGetAlternateTurnCandidate(protocol_type)), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(0U, turn_port_->Candidates().size()); SocketAddress address; // Verify that we have exhausted all alternate servers instead of @@ -594,12 +591,11 @@ class TurnPortTest : public ::testing::Test, ProtocolAddress(kTurnIntAddr, protocol_type)); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis( TimeToGetAlternateTurnCandidate(protocol_type)), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(0U, turn_port_->Candidates().size()); } @@ -616,17 +612,16 @@ class TurnPortTest : public ::testing::Test, // Pick an unusual address in the 127.0.0.0/8 range to make sure more than // 127.0.0.1 is covered. SocketAddress loopback_address(ipv6 ? "::1" : "127.1.2.3", - webrtc::TURN_SERVER_PORT); + TURN_SERVER_PORT); redirect_addresses.push_back(loopback_address); // Make a socket and bind it to the local port, to make extra sure no // packet is sent to this address. std::unique_ptr loopback_socket(ss_->CreateSocket( - AF_INET, - protocol_type == webrtc::PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM)); + AF_INET, protocol_type == PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM)); ASSERT_NE(nullptr, loopback_socket.get()); ASSERT_EQ(0, loopback_socket->Bind(loopback_address)); - if (protocol_type == webrtc::PROTO_TCP) { + if (protocol_type == PROTO_TCP) { ASSERT_EQ(0, loopback_socket->Listen(1)); } @@ -638,17 +633,17 @@ class TurnPortTest : public ::testing::Test, ProtocolAddress(server_address, protocol_type)); turn_port_->PrepareAddress(); - EXPECT_THAT(webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), - {.timeout = TimeDelta::Millis( - TimeToGetTurnCandidate(protocol_type)), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), + {.timeout = TimeDelta::Millis( + TimeToGetTurnCandidate(protocol_type)), + .clock = &fake_clock_}), + IsRtcOk()); // Wait for some extra time, and make sure no packets were received on the // loopback port we created (or in the case of TCP, no connection attempt // occurred). SIMULATED_WAIT(false, kSimulatedRtt, fake_clock_); - if (protocol_type == webrtc::PROTO_UDP) { + if (protocol_type == PROTO_UDP) { char buf[1]; EXPECT_EQ(-1, loopback_socket->Recv(&buf, 1, nullptr)); } else { @@ -665,7 +660,7 @@ class TurnPortTest : public ::testing::Test, ASSERT_GE(turn_port_->Candidates().size(), 1U); Connection* conn1 = udp_port_->CreateConnection(turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn1 != NULL); + ASSERT_TRUE(conn1 != nullptr); conn1->Ping(0); SIMULATED_WAIT(!turn_unknown_address_, kSimulatedRtt * 2, fake_clock_); EXPECT_FALSE(turn_unknown_address_); @@ -675,38 +670,36 @@ class TurnPortTest : public ::testing::Test, // Send ping from TURN to UDP. Connection* conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn2 != NULL); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return turn_create_permission_success_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_TRUE(conn2 != nullptr); + ASSERT_THAT( + WaitUntil([&] { return turn_create_permission_success_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); conn2->Ping(0); // Two hops from TURN port to UDP port through TURN server, thus two RTTs. - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn2->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn2->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_TRUE(conn1->receiving()); EXPECT_TRUE(conn2->receiving()); EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state()); // Send another ping from UDP to TURN. conn1->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn1->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn1->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_TRUE(conn2->receiving()); } void TestDestroyTurnConnection() { - PrepareTurnAndUdpPorts(webrtc::PROTO_UDP); + PrepareTurnAndUdpPorts(PROTO_UDP); // Create connections on both ends. Connection* conn1 = udp_port_->CreateConnection(turn_port_->Candidates()[0], @@ -718,20 +711,19 @@ class TurnPortTest : public ::testing::Test, // the TurnPort. turn_port_->set_timeout_delay(10 * 60 * 1000); - ASSERT_TRUE(conn2 != NULL); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return turn_create_permission_success_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_TRUE(conn2 != nullptr); + ASSERT_THAT( + WaitUntil([&] { return turn_create_permission_success_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); // Make sure turn connection can receive. conn1->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn1->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn1->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_FALSE(turn_unknown_address_); // Destroy the connection on the TURN port. The TurnEntry still exists, so @@ -739,11 +731,10 @@ class TurnPortTest : public ::testing::Test, turn_port_->DestroyConnection(conn2); conn1->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_unknown_address_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_unknown_address_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Wait for TurnEntry to expire. Timeout is 5 minutes. // Expect that it still processes an incoming ping and signals the @@ -775,20 +766,19 @@ class TurnPortTest : public ::testing::Test, conn1->set_remote_password_for_test(pwd); conn1->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_unknown_address_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_unknown_address_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // If the connection is created again, it will start to receive pings. conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); conn1->Ping(0); - EXPECT_THAT(webrtc::WaitUntil([&] { return conn2->receiving(); }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return conn2->receiving(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); } void TestTurnSendData(ProtocolType protocol_type) { @@ -799,8 +789,8 @@ class TurnPortTest : public ::testing::Test, Port::ORIGIN_MESSAGE); Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn1 != NULL); - ASSERT_TRUE(conn2 != NULL); + ASSERT_TRUE(conn1 != nullptr); + ASSERT_TRUE(conn2 != nullptr); conn1->RegisterReceivedPacketCallback( [&](Connection* connection, const ReceivedIpPacket& packet) { turn_packets_.push_back( @@ -816,19 +806,17 @@ class TurnPortTest : public ::testing::Test, conn2->SignalDestroyed.connect(this, &TurnPortTest::OnConnectionSignalDestroyed); conn1->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn1->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn1->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); conn2->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn2->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn2->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Send some data. size_t num_packets = 256; @@ -857,11 +845,11 @@ class TurnPortTest : public ::testing::Test, PrepareTurnAndUdpPorts(protocol_type); turn_port_.reset(); EXPECT_THAT( - webrtc::WaitUntil( - [&] { return turn_server_.server()->allocations().size(); }, Eq(0U), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + WaitUntil([&] { return turn_server_.server()->allocations().size(); }, + Eq(0U), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); } // Test that the TURN allocation is released by sending a refresh request @@ -874,8 +862,8 @@ class TurnPortTest : public ::testing::Test, Port::ORIGIN_MESSAGE); Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn1 != NULL); - ASSERT_TRUE(conn2 != NULL); + ASSERT_TRUE(conn1 != nullptr); + ASSERT_TRUE(conn2 != nullptr); conn1->RegisterReceivedPacketCallback( [&](Connection* connection, const ReceivedIpPacket& packet) { turn_packets_.push_back( @@ -892,19 +880,17 @@ class TurnPortTest : public ::testing::Test, &TurnPortTest::OnConnectionSignalDestroyed); conn1->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn1->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn1->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); conn2->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn2->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn2->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Send some data from Udp to TurnPort. unsigned char buf[256] = {0}; @@ -915,10 +901,10 @@ class TurnPortTest : public ::testing::Test, turn_port_->Release(); // Wait for the TurnPort to signal closed. - ASSERT_THAT(webrtc::WaitUntil([&] { return turn_port_closed_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return turn_port_closed_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); // But the data should have arrived first. ASSERT_EQ(1ul, turn_packets_.size()); @@ -971,32 +957,29 @@ TEST_F(TurnPortTest, TestTurnPortType) { // gathering the candidates. TEST_F(TurnPortTest, TestReconstructedServerUrlForUdpIPv4) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - TestReconstructedServerUrl(webrtc::PROTO_UDP, - "turn:99.99.99.3:3478?transport=udp"); + TestReconstructedServerUrl(PROTO_UDP, "turn:99.99.99.3:3478?transport=udp"); } TEST_F(TurnPortTest, TestReconstructedServerUrlForUdpIPv6) { - turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP); CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, kTurnUdpIPv6ProtoAddr); // Should add [] around the IPv6. TestReconstructedServerUrl( - webrtc::PROTO_UDP, + PROTO_UDP, "turn:[2400:4030:1:2c00:be30:abcd:efab:cdef]:3478?transport=udp"); } TEST_F(TurnPortTest, TestReconstructedServerUrlForTcp) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - TestReconstructedServerUrl(webrtc::PROTO_TCP, - "turn:99.99.99.4:3478?transport=tcp"); + TestReconstructedServerUrl(PROTO_TCP, "turn:99.99.99.4:3478?transport=tcp"); } TEST_F(TurnPortTest, TestReconstructedServerUrlForTls) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestReconstructedServerUrl(webrtc::PROTO_TLS, - "turns:99.99.99.4:3478?transport=tcp"); + TestReconstructedServerUrl(PROTO_TLS, "turns:99.99.99.4:3478?transport=tcp"); } TEST_F(TurnPortTest, TestReconstructedServerUrlForHostname) { @@ -1006,10 +989,9 @@ TEST_F(TurnPortTest, TestReconstructedServerUrlForHostname) { // As VSS doesn't provide DNS resolution, name resolve will fail, // the error will be set and contain the url. turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kResolverTimeout)}), - webrtc::IsRtcOk()); + IsRtcOk()); std::string server_url = "turn:" + kTurnInvalidAddr.ToString() + "?transport=udp"; ASSERT_EQ(error_event_.url, server_url); @@ -1064,18 +1046,16 @@ TEST_F(TurnPortTest, TestTurnAllocateWithoutLoggingId) { TEST_F(TurnPortTest, TestTurnBadCredentials) { CreateTurnPort(kTurnUsername, "bad", kTurnUdpProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(0U, turn_port_->Candidates().size()); - EXPECT_THAT( - webrtc::WaitUntil([&] { return error_event_.error_code; }, + EXPECT_THAT(WaitUntil([&] { return error_event_.error_code; }, Eq(STUN_ERROR_UNAUTHORIZED), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_EQ(error_event_.error_text, "Unauthorized"); } @@ -1084,11 +1064,10 @@ TEST_F(TurnPortTest, TestTurnBadCredentials) { TEST_F(TurnPortTest, TestServerAddressFamilyMismatch) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpIPv6ProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(0U, turn_port_->Candidates().size()); EXPECT_EQ(0, error_event_.error_code); } @@ -1099,18 +1078,17 @@ TEST_F(TurnPortTest, TestServerAddressFamilyMismatch6) { CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(0U, turn_port_->Candidates().size()); EXPECT_EQ(0, error_event_.error_code); } // Testing a normal UDP allocation using TCP connection. TEST_F(TurnPortTest, TestTurnTcpAllocate) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); EXPECT_EQ(0, turn_port_->SetOption(Socket::OPT_SNDBUF, 10 * 1024)); TestTurnAllocateSucceeds(kSimulatedRtt * 3); @@ -1125,7 +1103,7 @@ TEST_F(TurnPortTest, TestTurnTcpAllocationWhenProxyChangesAddressToLocalHost) { // kLocalAddr, it will end up using localhost instead. ss_->SetAlternativeLocalAddress(kLocalAddr1.ipaddr(), local_address.ipaddr()); - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kLocalAddr1, kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); EXPECT_EQ(0, turn_port_->SetOption(Socket::OPT_SNDBUF, 10 * 1024)); TestTurnAllocateSucceeds(kSimulatedRtt * 3); @@ -1148,7 +1126,7 @@ TEST_F(TurnPortTest, ss_->SetAlternativeLocalAddress(kLocalAddr1.ipaddr(), kLocalAddr2.ipaddr()); // Set up TURN server to use TCP (this logic only exists for TCP). - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); // Create TURN port and tell it to start allocation. CreateTurnPort(kLocalAddr1, kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); @@ -1156,15 +1134,15 @@ TEST_F(TurnPortTest, // Shouldn't take more than 1 RTT to realize the bound address isn't the one // expected. - EXPECT_THAT(webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); - EXPECT_THAT(webrtc::WaitUntil([&] { return error_event_.error_code; }, - Eq(STUN_ERROR_SERVER_NOT_REACHABLE), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return error_event_.error_code; }, + Eq(STUN_ERROR_SERVER_NOT_REACHABLE), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); EXPECT_NE(error_event_.error_text.find('.'), std::string::npos); EXPECT_NE(error_event_.address.find(kLocalAddr2.HostAsSensitiveURIString()), std::string::npos); @@ -1187,7 +1165,7 @@ TEST_F(TurnPortTest, TurnTcpAllocationNotDiscardedIfNotBoundToBestIP) { ASSERT_EQ(kLocalAddr1.ipaddr(), network->GetBestIP()); // Set up TURN server to use TCP (this logic only exists for TCP). - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); // Create TURN port using our special Network, and tell it to start // allocation. @@ -1196,11 +1174,10 @@ TEST_F(TurnPortTest, TurnTcpAllocationNotDiscardedIfNotBoundToBestIP) { turn_port_->PrepareAddress(); // Candidate should be gathered as normally. - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(1U, turn_port_->Candidates().size()); // Verify that the socket actually used the alternate address, otherwise this @@ -1213,48 +1190,45 @@ TEST_F(TurnPortTest, TurnTcpAllocationNotDiscardedIfNotBoundToBestIP) { // between webrtc::IPAddress and webrtc::InterfaceAddress. TEST_F(TurnPortTest, TCPPortNotDiscardedIfBoundToTemporaryIP) { networks_.emplace_back("unittest", "unittest", kLocalIPv6Addr.ipaddr(), 32); - networks_.back().AddIP(InterfaceAddress(kLocalIPv6Addr.ipaddr(), - webrtc::IPV6_ADDRESS_FLAG_TEMPORARY)); + networks_.back().AddIP( + InterfaceAddress(kLocalIPv6Addr.ipaddr(), IPV6_ADDRESS_FLAG_TEMPORARY)); // Set up TURN server to use TCP (this logic only exists for TCP). - turn_server_.AddInternalSocket(kTurnIPv6IntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnIPv6IntAddr, PROTO_TCP); // Create TURN port using our special Network, and tell it to start // allocation. - CreateTurnPortWithNetwork( - &networks_.back(), kTurnUsername, kTurnPassword, - ProtocolAddress(kTurnIPv6IntAddr, webrtc::PROTO_TCP)); + CreateTurnPortWithNetwork(&networks_.back(), kTurnUsername, kTurnPassword, + ProtocolAddress(kTurnIPv6IntAddr, PROTO_TCP)); turn_port_->PrepareAddress(); // Candidate should be gathered as normally. - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(1U, turn_port_->Candidates().size()); } // Testing turn port will attempt to create TCP socket on address resolution // failure. TEST_F(TurnPortTest, TestTurnTcpOnAddressResolveFailure) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, - ProtocolAddress(kTurnInvalidAddr, webrtc::PROTO_TCP)); + ProtocolAddress(kTurnInvalidAddr, PROTO_TCP)); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kResolverTimeout)}), - webrtc::IsRtcOk()); + IsRtcOk()); // As VSS doesn't provide DNS resolution, name resolve will fail. TurnPort // will proceed in creating a TCP socket which will fail as there is no // server on the above domain and error will be set to SOCKET_ERROR. EXPECT_EQ(SOCKET_ERROR, turn_port_->error()); - EXPECT_THAT(webrtc::WaitUntil([&] { return error_event_.error_code; }, - Eq(STUN_ERROR_SERVER_NOT_REACHABLE), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return error_event_.error_code; }, + Eq(STUN_ERROR_SERVER_NOT_REACHABLE), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); std::string server_url = "turn:" + kTurnInvalidAddr.ToString() + "?transport=tcp"; ASSERT_EQ(error_event_.url, server_url); @@ -1263,14 +1237,13 @@ TEST_F(TurnPortTest, TestTurnTcpOnAddressResolveFailure) { // Testing turn port will attempt to create TLS socket on address resolution // failure. TEST_F(TurnPortTest, TestTurnTlsOnAddressResolveFailure) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); CreateTurnPort(kTurnUsername, kTurnPassword, - ProtocolAddress(kTurnInvalidAddr, webrtc::PROTO_TLS)); + ProtocolAddress(kTurnInvalidAddr, PROTO_TLS)); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kResolverTimeout)}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_EQ(SOCKET_ERROR, turn_port_->error()); } @@ -1278,12 +1251,11 @@ TEST_F(TurnPortTest, TestTurnTlsOnAddressResolveFailure) { // and return allocate failure. TEST_F(TurnPortTest, TestTurnUdpOnAddressResolveFailure) { CreateTurnPort(kTurnUsername, kTurnPassword, - ProtocolAddress(kTurnInvalidAddr, webrtc::PROTO_UDP)); + ProtocolAddress(kTurnInvalidAddr, PROTO_UDP)); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kResolverTimeout)}), - webrtc::IsRtcOk()); + IsRtcOk()); // Error from turn port will not be socket error. EXPECT_NE(SOCKET_ERROR, turn_port_->error()); } @@ -1292,11 +1264,10 @@ TEST_F(TurnPortTest, TestTurnUdpOnAddressResolveFailure) { TEST_F(TurnPortTest, TestTurnAllocateBadPassword) { CreateTurnPort(kTurnUsername, "bad", kTurnUdpProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(0U, turn_port_->Candidates().size()); } @@ -1306,11 +1277,10 @@ TEST_F(TurnPortTest, TestTurnAllocateNonceResetAfterAllocateMismatch) { // Do a normal allocation first. CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); SocketAddress first_addr(turn_port_->socket()->GetLocalAddress()); // Destroy the turnport while keeping the drop probability to 1 to // suppress the release of the allocation at the server. @@ -1328,7 +1298,7 @@ TEST_F(TurnPortTest, TestTurnAllocateNonceResetAfterAllocateMismatch) { // using timestamp `ts_before` but then get an allocate mismatch error and // receive an even newer nonce based on the system clock. `ts_before` is // chosen so that the two NONCEs generated by the server will be different. - int64_t ts_before = webrtc::TimeMillis() - 1; + int64_t ts_before = TimeMillis() - 1; std::string first_nonce = turn_server_.server()->SetTimestampForNextNonce(ts_before); turn_port_->PrepareAddress(); @@ -1336,11 +1306,10 @@ TEST_F(TurnPortTest, TestTurnAllocateNonceResetAfterAllocateMismatch) { // Four round trips; first we'll get "stale nonce", then // "allocate mismatch", then "stale nonce" again, then finally it will // succeed. - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 4), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_NE(first_nonce, turn_port_->nonce()); } @@ -1350,11 +1319,10 @@ TEST_F(TurnPortTest, TestTurnAllocateMismatch) { // Do a normal allocation first. CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); SocketAddress first_addr(turn_port_->socket()->GetLocalAddress()); // Clear connected_ flag on turnport to suppress the release of @@ -1374,11 +1342,10 @@ TEST_F(TurnPortTest, TestTurnAllocateMismatch) { // Four round trips; first we'll get "stale nonce", then // "allocate mismatch", then "stale nonce" again, then finally it will // succeed. - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 4), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Verifies that the new port has a different address now. EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress()); @@ -1386,10 +1353,9 @@ TEST_F(TurnPortTest, TestTurnAllocateMismatch) { // Verify that all packets received from the shared socket are ignored. std::string test_packet = "Test packet"; EXPECT_FALSE(turn_port_->HandleIncomingPacket( - socket_.get(), - ReceivedIpPacket::CreateFromLegacy( - test_packet.data(), test_packet.size(), webrtc::TimeMicros(), - SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)))); + socket_.get(), ReceivedIpPacket::CreateFromLegacy( + test_packet.data(), test_packet.size(), TimeMicros(), + SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)))); } // Tests that a shared-socket-TurnPort creates its own socket after @@ -1398,11 +1364,10 @@ TEST_F(TurnPortTest, TestSharedSocketAllocateMismatch) { // Do a normal allocation first. CreateSharedTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); SocketAddress first_addr(turn_port_->socket()->GetLocalAddress()); // Clear connected_ flag on turnport to suppress the release of @@ -1418,11 +1383,10 @@ TEST_F(TurnPortTest, TestSharedSocketAllocateMismatch) { turn_port_->PrepareAddress(); // Extra 2 round trips due to allocate mismatch. - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 4), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Verifies that the new port has a different address now. EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress()); @@ -1430,16 +1394,15 @@ TEST_F(TurnPortTest, TestSharedSocketAllocateMismatch) { } TEST_F(TurnPortTest, TestTurnTcpAllocateMismatch) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); // Do a normal allocation first. turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); SocketAddress first_addr(turn_port_->socket()->GetLocalAddress()); // Clear connected_ flag on turnport to suppress the release of @@ -1457,11 +1420,10 @@ TEST_F(TurnPortTest, TestTurnTcpAllocateMismatch) { EXPECT_EQ(first_addr, turn_port_->socket()->GetLocalAddress()); // Extra 2 round trips due to allocate mismatch. - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 5), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Verifies that the new port has a different address now. EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress()); @@ -1469,7 +1431,7 @@ TEST_F(TurnPortTest, TestTurnTcpAllocateMismatch) { TEST_F(TurnPortTest, TestRefreshRequestGetsErrorResponse) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - PrepareTurnAndUdpPorts(webrtc::PROTO_UDP); + PrepareTurnAndUdpPorts(PROTO_UDP); turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); // Set bad credentials. @@ -1480,17 +1442,16 @@ TEST_F(TurnPortTest, TestRefreshRequestGetsErrorResponse) { // When this succeeds, it will schedule a new RefreshRequest with the bad // credential. turn_port_->request_manager().FlushForTest(TURN_REFRESH_REQUEST); - EXPECT_THAT(webrtc::WaitUntil([&] { return turn_refresh_success_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return turn_refresh_success_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); // Flush it again, it will receive a bad response. turn_port_->request_manager().FlushForTest(TURN_REFRESH_REQUEST); - EXPECT_THAT( - webrtc::WaitUntil( - [&] { return !turn_refresh_success_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return !turn_refresh_success_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); EXPECT_FALSE(turn_port_->connected()); EXPECT_TRUE(CheckAllConnectionsFailedAndPruned()); EXPECT_FALSE(turn_port_->HasRequests()); @@ -1500,21 +1461,20 @@ TEST_F(TurnPortTest, TestRefreshRequestGetsErrorResponse) { // closed. TEST_F(TurnPortTest, TestStopProcessingPacketsAfterClosed) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - PrepareTurnAndUdpPorts(webrtc::PROTO_UDP); + PrepareTurnAndUdpPorts(PROTO_UDP); Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn1 != NULL); - ASSERT_TRUE(conn2 != NULL); + ASSERT_TRUE(conn1 != nullptr); + ASSERT_TRUE(conn2 != nullptr); // Make sure conn2 is writable. conn2->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn2->write_state(); }, + EXPECT_THAT(WaitUntil([&] { return conn2->write_state(); }, Eq(Connection::STATE_WRITABLE), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); turn_port_->CloseForTest(); SIMULATED_WAIT(false, kSimulatedRtt, fake_clock_); @@ -1528,115 +1488,115 @@ TEST_F(TurnPortTest, TestStopProcessingPacketsAfterClosed) { // Test that CreateConnection will return null if port becomes disconnected. TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - PrepareTurnAndUdpPorts(webrtc::PROTO_TCP); + PrepareTurnAndUdpPorts(PROTO_TCP); // Create a connection. Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn1 != NULL); + ASSERT_TRUE(conn1 != nullptr); // Close the socket and create a connection again. turn_port_->OnSocketClose(turn_port_->socket(), 1); conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn1 == NULL); + ASSERT_TRUE(conn1 == nullptr); } // Tests that when a TCP socket is closed, the respective TURN connection will // be destroyed. TEST_F(TurnPortTest, TestSocketCloseWillDestroyConnection) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - PrepareTurnAndUdpPorts(webrtc::PROTO_TCP); + PrepareTurnAndUdpPorts(PROTO_TCP); Connection* conn = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); EXPECT_NE(nullptr, conn); EXPECT_TRUE(!turn_port_->connections().empty()); turn_port_->socket()->NotifyClosedForTest(1); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return turn_port_->connections().empty(); }, IsTrue(), - {.timeout = TimeDelta::Millis(kConnectionDestructionDelay), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return turn_port_->connections().empty(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kConnectionDestructionDelay), + .clock = &fake_clock_}), + IsRtcOk()); } // Test try-alternate-server feature. TEST_F(TurnPortTest, TestTurnAlternateServerUDP) { - TestTurnAlternateServer(webrtc::PROTO_UDP); + TestTurnAlternateServer(PROTO_UDP); } TEST_F(TurnPortTest, TestTurnAlternateServerTCP) { - TestTurnAlternateServer(webrtc::PROTO_TCP); + TestTurnAlternateServer(PROTO_TCP); } TEST_F(TurnPortTest, TestTurnAlternateServerTLS) { - TestTurnAlternateServer(webrtc::PROTO_TLS); + TestTurnAlternateServer(PROTO_TLS); } // Test that we fail when we redirect to an address different from // current IP family. TEST_F(TurnPortTest, TestTurnAlternateServerV4toV6UDP) { - TestTurnAlternateServerV4toV6(webrtc::PROTO_UDP); + TestTurnAlternateServerV4toV6(PROTO_UDP); } TEST_F(TurnPortTest, TestTurnAlternateServerV4toV6TCP) { - TestTurnAlternateServerV4toV6(webrtc::PROTO_TCP); + TestTurnAlternateServerV4toV6(PROTO_TCP); } TEST_F(TurnPortTest, TestTurnAlternateServerV4toV6TLS) { - TestTurnAlternateServerV4toV6(webrtc::PROTO_TLS); + TestTurnAlternateServerV4toV6(PROTO_TLS); } // Test try-alternate-server catches the case of pingpong. TEST_F(TurnPortTest, TestTurnAlternateServerPingPongUDP) { - TestTurnAlternateServerPingPong(webrtc::PROTO_UDP); + TestTurnAlternateServerPingPong(PROTO_UDP); } TEST_F(TurnPortTest, TestTurnAlternateServerPingPongTCP) { - TestTurnAlternateServerPingPong(webrtc::PROTO_TCP); + TestTurnAlternateServerPingPong(PROTO_TCP); } TEST_F(TurnPortTest, TestTurnAlternateServerPingPongTLS) { - TestTurnAlternateServerPingPong(webrtc::PROTO_TLS); + TestTurnAlternateServerPingPong(PROTO_TLS); } // Test try-alternate-server catch the case of repeated server. TEST_F(TurnPortTest, TestTurnAlternateServerDetectRepetitionUDP) { - TestTurnAlternateServerDetectRepetition(webrtc::PROTO_UDP); + TestTurnAlternateServerDetectRepetition(PROTO_UDP); } TEST_F(TurnPortTest, TestTurnAlternateServerDetectRepetitionTCP) { - TestTurnAlternateServerDetectRepetition(webrtc::PROTO_TCP); + TestTurnAlternateServerDetectRepetition(PROTO_TCP); } TEST_F(TurnPortTest, TestTurnAlternateServerDetectRepetitionTLS) { - TestTurnAlternateServerDetectRepetition(webrtc::PROTO_TCP); + TestTurnAlternateServerDetectRepetition(PROTO_TCP); } // Test catching the case of a redirect to loopback. TEST_F(TurnPortTest, TestTurnAlternateServerLoopbackUdpIpv4) { - TestTurnAlternateServerLoopback(webrtc::PROTO_UDP, false); + TestTurnAlternateServerLoopback(PROTO_UDP, false); } TEST_F(TurnPortTest, TestTurnAlternateServerLoopbackUdpIpv6) { - TestTurnAlternateServerLoopback(webrtc::PROTO_UDP, true); + TestTurnAlternateServerLoopback(PROTO_UDP, true); } TEST_F(TurnPortTest, TestTurnAlternateServerLoopbackTcpIpv4) { - TestTurnAlternateServerLoopback(webrtc::PROTO_TCP, false); + TestTurnAlternateServerLoopback(PROTO_TCP, false); } TEST_F(TurnPortTest, TestTurnAlternateServerLoopbackTcpIpv6) { - TestTurnAlternateServerLoopback(webrtc::PROTO_TCP, true); + TestTurnAlternateServerLoopback(PROTO_TCP, true); } TEST_F(TurnPortTest, TestTurnAlternateServerLoopbackTlsIpv4) { - TestTurnAlternateServerLoopback(webrtc::PROTO_TLS, false); + TestTurnAlternateServerLoopback(PROTO_TLS, false); } TEST_F(TurnPortTest, TestTurnAlternateServerLoopbackTlsIpv6) { - TestTurnAlternateServerLoopback(webrtc::PROTO_TLS, true); + TestTurnAlternateServerLoopback(PROTO_TLS, true); } // Do a TURN allocation and try to send a packet to it from the outside. @@ -1645,27 +1605,27 @@ TEST_F(TurnPortTest, TestTurnAlternateServerLoopbackTlsIpv6) { // outside. It should now work as well. TEST_F(TurnPortTest, TestTurnConnection) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - TestTurnConnection(webrtc::PROTO_UDP); + TestTurnConnection(PROTO_UDP); } // Similar to above, except that this test will use the shared socket. TEST_F(TurnPortTest, TestTurnConnectionUsingSharedSocket) { CreateSharedTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - TestTurnConnection(webrtc::PROTO_UDP); + TestTurnConnection(PROTO_UDP); } // Test that we can establish a TCP connection with TURN server. TEST_F(TurnPortTest, TestTurnTcpConnection) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - TestTurnConnection(webrtc::PROTO_TCP); + TestTurnConnection(PROTO_TCP); } // Test that we can establish a TLS connection with TURN server. TEST_F(TurnPortTest, TestTurnTlsConnection) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestTurnConnection(webrtc::PROTO_TLS); + TestTurnConnection(PROTO_TLS); } // Test that if a connection on a TURN port is destroyed, the TURN port can @@ -1688,7 +1648,7 @@ TEST_F(TurnPortTest, TestDestroyTurnConnectionUsingSharedSocket) { TEST_F(TurnPortTest, TestTurnConnectionUsingOTUNonce) { turn_server_.set_enable_otu_nonce(true); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - TestTurnConnection(webrtc::PROTO_UDP); + TestTurnConnection(PROTO_UDP); } // Test that CreatePermissionRequest will be scheduled after the success @@ -1696,16 +1656,16 @@ TEST_F(TurnPortTest, TestTurnConnectionUsingOTUNonce) { // ErrorResponse if the ufrag and pwd are incorrect. TEST_F(TurnPortTest, TestRefreshCreatePermissionRequest) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - PrepareTurnAndUdpPorts(webrtc::PROTO_UDP); + PrepareTurnAndUdpPorts(PROTO_UDP); Connection* conn = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); - ASSERT_TRUE(conn != NULL); + ASSERT_TRUE(conn != nullptr); EXPECT_THAT( - webrtc::WaitUntil( + WaitUntil( [&] { return turn_create_permission_success_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); turn_create_permission_success_ = false; // A create-permission-request should be pending. // After the next create-permission-response is received, it will schedule @@ -1714,23 +1674,23 @@ TEST_F(TurnPortTest, TestRefreshCreatePermissionRequest) { turn_port_->set_credentials(bad_credentials); turn_port_->request_manager().FlushForTest(kAllRequestsForTest); EXPECT_THAT( - webrtc::WaitUntil( + WaitUntil( [&] { return turn_create_permission_success_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Flush the requests again; the create-permission-request will fail. turn_port_->request_manager().FlushForTest(kAllRequestsForTest); EXPECT_THAT( - webrtc::WaitUntil( + WaitUntil( [&] { return !turn_create_permission_success_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_TRUE(CheckConnectionFailedAndPruned(conn)); } TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - PrepareTurnAndUdpPorts(webrtc::PROTO_UDP); + PrepareTurnAndUdpPorts(PROTO_UDP); Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); ASSERT_TRUE(conn1 != nullptr); @@ -1739,11 +1699,10 @@ TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) { ASSERT_TRUE(conn2 != nullptr); conn1->Ping(0); - EXPECT_THAT( - webrtc::WaitUntil([&] { return conn1->writable(); }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return conn1->writable(); }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Tell the TURN server to reject all bind requests from now on. turn_server_.server()->set_reject_bind_requests(true); @@ -1752,10 +1711,10 @@ TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) { conn1->Send(data.data(), data.length(), options); EXPECT_THAT( - webrtc::WaitUntil( + WaitUntil( [&] { return CheckConnectionFailedAndPruned(conn1); }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Verify that packets are allowed to be sent after a bind request error. // They'll just use a send indication instead. @@ -1767,10 +1726,10 @@ TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) { Buffer(packet.payload().data(), packet.payload().size())); }); conn1->Send(data.data(), data.length(), options); - EXPECT_THAT(webrtc::WaitUntil([&] { return !udp_packets_.empty(); }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return !udp_packets_.empty(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); conn2->DeregisterReceivedPacketCallback(); } @@ -1778,41 +1737,38 @@ TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) { TEST_F(TurnPortTest, TestTurnSendDataTurnUdpToUdp) { // Create ports and prepare addresses. CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - TestTurnSendData(webrtc::PROTO_UDP); - EXPECT_EQ(webrtc::UDP_PROTOCOL_NAME, - turn_port_->Candidates()[0].relay_protocol()); + TestTurnSendData(PROTO_UDP); + EXPECT_EQ(UDP_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol()); } // Do a TURN allocation, establish a TCP connection, and send some data. TEST_F(TurnPortTest, TestTurnSendDataTurnTcpToUdp) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); // Create ports and prepare addresses. CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - TestTurnSendData(webrtc::PROTO_TCP); - EXPECT_EQ(webrtc::TCP_PROTOCOL_NAME, - turn_port_->Candidates()[0].relay_protocol()); + TestTurnSendData(PROTO_TCP); + EXPECT_EQ(TCP_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol()); } // Do a TURN allocation, establish a TLS connection, and send some data. TEST_F(TurnPortTest, TestTurnSendDataTurnTlsToUdp) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestTurnSendData(webrtc::PROTO_TLS); - EXPECT_EQ(webrtc::TLS_PROTOCOL_NAME, - turn_port_->Candidates()[0].relay_protocol()); + TestTurnSendData(PROTO_TLS); + EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol()); } // Test TURN fails to make a connection from IPv6 address to a server which has // IPv4 address. TEST_F(TurnPortTest, TestTurnLocalIPv6AddressServerIPv4) { - turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP); CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); turn_port_->PrepareAddress(); - ASSERT_THAT(webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); EXPECT_TRUE(turn_port_->Candidates().empty()); } @@ -1820,7 +1776,7 @@ TEST_F(TurnPortTest, TestTurnLocalIPv6AddressServerIPv4) { // IPv6 intenal address. But in this test external address is a IPv4 address, // hence allocated address will be a IPv4 address. TEST_F(TurnPortTest, TestTurnLocalIPv6AddressServerIPv6ExtenalIPv4) { - turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP); CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, kTurnUdpIPv6ProtoAddr); TestTurnAllocateSucceeds(kSimulatedRtt * 2); @@ -1831,16 +1787,15 @@ TEST_F(TurnPortTest, TestTurnLocalIPv6AddressServerIPv6ExtenalIPv4) { // its local candidate will still be an IPv4 address and it can only create // connections with IPv4 remote candidates. TEST_F(TurnPortTest, TestCandidateAddressFamilyMatch) { - turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP); CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, kTurnUdpIPv6ProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 2), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_EQ(1U, turn_port_->Candidates().size()); // Create an IPv4 candidate. It will match the TURN candidate. @@ -1862,22 +1817,21 @@ TEST_F(TurnPortTest, TestCandidateAddressFamilyMatch) { // Test that a CreatePermission failure will result in the connection being // pruned and failed. TEST_F(TurnPortTest, TestConnectionFailedAndPrunedOnCreatePermissionFailure) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); turn_server_.server()->set_reject_private_addresses(true); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); turn_port_->PrepareAddress(); - EXPECT_THAT( - webrtc::WaitUntil([&] { return turn_ready_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); CreateUdpPort(SocketAddress("10.0.0.10", 0)); udp_port_->PrepareAddress(); - EXPECT_THAT(webrtc::WaitUntil([&] { return udp_ready_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kSimulatedRtt), - .clock = &fake_clock_}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return udp_ready_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kSimulatedRtt), + .clock = &fake_clock_}), + IsRtcOk()); // Create a connection. TestConnectionWrapper conn(turn_port_->CreateConnection( udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE)); @@ -1886,16 +1840,16 @@ TEST_F(TurnPortTest, TestConnectionFailedAndPrunedOnCreatePermissionFailure) { // Asynchronously, CreatePermission request should be sent and fail, which // will make the connection pruned and failed. EXPECT_THAT( - webrtc::WaitUntil( + WaitUntil( [&] { return CheckConnectionFailedAndPruned(conn.connection()); }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_THAT( - webrtc::WaitUntil( + WaitUntil( [&] { return !turn_create_permission_success_; }, IsTrue(), {.timeout = TimeDelta::Millis(kSimulatedRtt), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // Check that the connection is not deleted asynchronously. SIMULATED_WAIT(conn.connection() == nullptr, kConnectionDestructionDelay, fake_clock_); @@ -1905,38 +1859,38 @@ TEST_F(TurnPortTest, TestConnectionFailedAndPrunedOnCreatePermissionFailure) { // Test that a TURN allocation is released when the port is closed. TEST_F(TurnPortTest, TestTurnReleaseAllocation) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - TestTurnReleaseAllocation(webrtc::PROTO_UDP); + TestTurnReleaseAllocation(PROTO_UDP); } // Test that a TURN TCP allocation is released when the port is closed. TEST_F(TurnPortTest, TestTurnTCPReleaseAllocation) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - TestTurnReleaseAllocation(webrtc::PROTO_TCP); + TestTurnReleaseAllocation(PROTO_TCP); } TEST_F(TurnPortTest, TestTurnTLSReleaseAllocation) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestTurnReleaseAllocation(webrtc::PROTO_TLS); + TestTurnReleaseAllocation(PROTO_TLS); } TEST_F(TurnPortTest, TestTurnUDPGracefulReleaseAllocation) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_UDP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - TestTurnGracefulReleaseAllocation(webrtc::PROTO_UDP); + TestTurnGracefulReleaseAllocation(PROTO_UDP); } TEST_F(TurnPortTest, TestTurnTCPGracefulReleaseAllocation) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); - TestTurnGracefulReleaseAllocation(webrtc::PROTO_TCP); + TestTurnGracefulReleaseAllocation(PROTO_TCP); } TEST_F(TurnPortTest, TestTurnTLSGracefulReleaseAllocation) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestTurnGracefulReleaseAllocation(webrtc::PROTO_TLS); + TestTurnGracefulReleaseAllocation(PROTO_TLS); } // Test that nothing bad happens if we try to create a connection to the same @@ -1944,7 +1898,7 @@ TEST_F(TurnPortTest, TestTurnTLSGracefulReleaseAllocation) { // DCHECK. TEST_F(TurnPortTest, CanCreateTwoConnectionsToSameAddress) { CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); - PrepareTurnAndUdpPorts(webrtc::PROTO_UDP); + PrepareTurnAndUdpPorts(PROTO_UDP); Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); Connection* conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0], @@ -1957,23 +1911,22 @@ TEST_F(TurnPortTest, CanCreateTwoConnectionsToSameAddress) { #if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) TEST_F(TurnPortTest, TestResolverShutdown) { - turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP); int last_fd_count = GetFDCount(); // Need to supply unresolved address to kick off resolver. CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, - ProtocolAddress(kTurnInvalidAddr, webrtc::PROTO_UDP)); + ProtocolAddress(kTurnInvalidAddr, PROTO_UDP)); turn_port_->PrepareAddress(); - ASSERT_THAT( - webrtc::WaitUntil([&] { return turn_error_; }, IsTrue(), + ASSERT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), {.timeout = TimeDelta::Millis(kResolverTimeout)}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_TRUE(turn_port_->Candidates().empty()); turn_port_.reset(); Thread::Current()->PostTask([this] { test_finish_ = true; }); // Waiting for above message to be processed. - ASSERT_THAT(webrtc::WaitUntil([&] { return test_finish_; }, IsTrue(), - {.clock = &fake_clock_}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return test_finish_; }, IsTrue(), + {.clock = &fake_clock_}), + IsRtcOk()); EXPECT_EQ(last_fd_count, GetFDCount()); } #endif @@ -2029,14 +1982,13 @@ TEST_F(TurnPortTest, TestTurnCustomizerCount) { &observer_message_counter, &observer_channel_data_counter, &observer_attr_counter)); - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); turn_customizer_.reset(customizer); turn_server_.server()->SetStunMessageObserver(std::move(validator)); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestTurnSendData(webrtc::PROTO_TLS); - EXPECT_EQ(webrtc::TLS_PROTOCOL_NAME, - turn_port_->Candidates()[0].relay_protocol()); + TestTurnSendData(PROTO_TLS); + EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol()); // There should have been at least turn_packets_.size() calls to `customizer`. EXPECT_GE(customizer->modify_cnt_ + customizer->allow_channel_data_cnt_, @@ -2060,14 +2012,13 @@ TEST_F(TurnPortTest, TestTurnCustomizerDisallowChannelData) { &observer_message_counter, &observer_channel_data_counter, &observer_attr_counter)); customizer->allow_channel_data_ = false; - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); turn_customizer_.reset(customizer); turn_server_.server()->SetStunMessageObserver(std::move(validator)); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestTurnSendData(webrtc::PROTO_TLS); - EXPECT_EQ(webrtc::TLS_PROTOCOL_NAME, - turn_port_->Candidates()[0].relay_protocol()); + TestTurnSendData(PROTO_TLS); + EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol()); // There should have been at least turn_packets_.size() calls to `customizer`. EXPECT_GE(customizer->modify_cnt_, turn_packets_.size()); @@ -2091,14 +2042,13 @@ TEST_F(TurnPortTest, TestTurnCustomizerAddAttribute) { &observer_attr_counter)); customizer->allow_channel_data_ = false; customizer->add_counter_ = true; - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TLS); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TLS); turn_customizer_.reset(customizer); turn_server_.server()->SetStunMessageObserver(std::move(validator)); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTlsProtoAddr); - TestTurnSendData(webrtc::PROTO_TLS); - EXPECT_EQ(webrtc::TLS_PROTOCOL_NAME, - turn_port_->Candidates()[0].relay_protocol()); + TestTurnSendData(PROTO_TLS); + EXPECT_EQ(TLS_PROTOCOL_NAME, turn_port_->Candidates()[0].relay_protocol()); // There should have been at least turn_packets_.size() calls to `customizer`. EXPECT_GE(customizer->modify_cnt_, turn_packets_.size()); @@ -2148,7 +2098,7 @@ TEST_F(TurnPortTest, TestTurnDangerousServerPermits443) { } TEST_F(TurnPortTest, TestTurnDangerousAlternateServer) { - const ProtocolType protocol_type = webrtc::PROTO_TCP; + const ProtocolType protocol_type = PROTO_TCP; std::vector redirect_addresses; redirect_addresses.push_back(kTurnDangerousAddr); @@ -2165,12 +2115,11 @@ TEST_F(TurnPortTest, TestTurnDangerousAlternateServer) { turn_port_->PrepareAddress(); // This should result in an error event. - EXPECT_THAT( - webrtc::WaitUntil([&] { return error_event_.error_code; }, Ne(0), + EXPECT_THAT(WaitUntil([&] { return error_event_.error_code; }, Ne(0), {.timeout = TimeDelta::Millis( TimeToGetAlternateTurnCandidate(protocol_type)), .clock = &fake_clock_}), - webrtc::IsRtcOk()); + IsRtcOk()); // but should NOT result in the port turning ready, and no candidates // should be gathered. EXPECT_FALSE(turn_ready_); @@ -2214,7 +2163,7 @@ TEST_F(TurnPortWithMockDnsResolverTest, TestHostnameResolved) { // Test an allocation from a TURN server specified by a hostname on an IPv6 // network. TEST_F(TurnPortWithMockDnsResolverTest, TestHostnameResolvedIPv6Network) { - turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP); CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, kTurnPortValidHostnameProtoAddr); SetDnsResolverExpectations( diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc index ed9db392c4..fa12319c6c 100644 --- a/p2p/client/basic_port_allocator.cc +++ b/p2p/client/basic_port_allocator.cc @@ -57,10 +57,6 @@ namespace webrtc { namespace { -using ::webrtc::CreateRandomId; -using ::webrtc::IceCandidateType; -using ::webrtc::SafeTask; -using ::webrtc::TimeDelta; const int PHASE_UDP = 0; const int PHASE_RELAY = 1; @@ -71,12 +67,12 @@ const int kNumPhases = 3; // Gets protocol priority: UDP > TCP > SSLTCP == TLS. int GetProtocolPriority(ProtocolType protocol) { switch (protocol) { - case webrtc::PROTO_UDP: + case PROTO_UDP: return 2; - case webrtc::PROTO_TCP: + case PROTO_TCP: return 1; - case webrtc::PROTO_SSLTCP: - case webrtc::PROTO_TLS: + case PROTO_SSLTCP: + case PROTO_TLS: return 0; default: RTC_DCHECK_NOTREACHED(); @@ -143,15 +139,15 @@ bool IsAllowedByCandidateFilter(const Candidate& c, uint32_t filter) { } if (c.is_relay()) { - return ((filter & webrtc::CF_RELAY) != 0); + return ((filter & CF_RELAY) != 0); } if (c.is_stun()) { - return ((filter & webrtc::CF_REFLEXIVE) != 0); + return ((filter & CF_REFLEXIVE) != 0); } if (c.is_local()) { - if ((filter & webrtc::CF_REFLEXIVE) && !c.address().IsPrivateIP()) { + if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) { // We allow host candidates if the filter allows server-reflexive // candidates and the candidate is a public IP. Because we don't generate // server-reflexive candidates if they have the same IP as the host @@ -161,7 +157,7 @@ bool IsAllowedByCandidateFilter(const Candidate& c, uint32_t filter) { return true; } - return ((filter & webrtc::CF_HOST) != 0); + return ((filter & CF_HOST) != 0); } return false; @@ -178,8 +174,8 @@ std::string NetworksToString(const std::vector& networks) { } // namespace const uint32_t DISABLE_ALL_PHASES = - webrtc::PORTALLOCATOR_DISABLE_UDP | webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_STUN | webrtc::PORTALLOCATOR_DISABLE_RELAY; + PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY; BasicPortAllocator::BasicPortAllocator( const Environment& env, @@ -194,7 +190,7 @@ BasicPortAllocator::BasicPortAllocator( RTC_CHECK(socket_factory_); RTC_DCHECK(network_manager_); SetConfiguration(ServerAddresses(), std::vector(), 0, - webrtc::NO_PRUNE, turn_customizer); + NO_PRUNE, turn_customizer); } BasicPortAllocator::~BasicPortAllocator() { @@ -217,10 +213,10 @@ int BasicPortAllocator::GetNetworkIgnoreMask() const { int mask = network_ignore_mask_; switch (vpn_preference_) { case VpnPreference::kOnlyUseVpn: - mask |= ~static_cast(webrtc::ADAPTER_TYPE_VPN); + mask |= ~static_cast(ADAPTER_TYPE_VPN); break; case VpnPreference::kNeverUseVpn: - mask |= static_cast(webrtc::ADAPTER_TYPE_VPN); + mask |= static_cast(ADAPTER_TYPE_VPN); break; default: break; @@ -504,7 +500,7 @@ void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts( // IceCandidateType::kHost but uses the protocol PROTO_TCP. if (port->Type() == IceCandidateType::kSrflx || (port->Type() == IceCandidateType::kHost && - port->GetProtocol() == webrtc::PROTO_UDP)) { + port->GetProtocol() == PROTO_UDP)) { static_cast(port)->set_stun_keepalive_delay( stun_keepalive_interval); } @@ -679,13 +675,13 @@ std::vector BasicPortAllocatorSession::GetNetworks() { // been passed in. if (network_manager->enumeration_permission() == NetworkManager::ENUMERATION_BLOCKED) { - set_flags(flags() | webrtc::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); + set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); } // If the adapter enumeration is disabled, we'll just bind to any address // instead of specific NIC. This is to ensure the same routing for http // traffic by OS is also used here to avoid any local or public IP leakage // during stun process. - if (flags() & webrtc::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { + if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { networks = network_manager->GetAnyAddressNetworks(); } else { networks = network_manager->GetNetworks(); @@ -694,7 +690,7 @@ std::vector BasicPortAllocatorSession::GetNetworks() { // the OS. Or, if the PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS flag is // set, we'll use ANY address candidates either way. if (networks.empty() || - (flags() & webrtc::PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS)) { + (flags() & PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS)) { std::vector any_address_networks = network_manager->GetAnyAddressNetworks(); networks.insert(networks.end(), any_address_networks.begin(), @@ -706,10 +702,10 @@ std::vector BasicPortAllocatorSession::GetNetworks() { } } // Filter out link-local networks if needed. - if (flags() & webrtc::PORTALLOCATOR_DISABLE_LINK_LOCAL_NETWORKS) { + if (flags() & PORTALLOCATOR_DISABLE_LINK_LOCAL_NETWORKS) { NetworkFilter link_local_filter( [](const webrtc::Network* network) { - return webrtc::IPIsLinkLocal(network->prefix()); + return IPIsLinkLocal(network->prefix()); }, "link-local"); FilterNetworks(&networks, link_local_filter); @@ -722,14 +718,14 @@ std::vector BasicPortAllocatorSession::GetNetworks() { }, "ignored"); FilterNetworks(&networks, ignored_filter); - if (flags() & webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) { - uint16_t lowest_cost = webrtc::kNetworkCostMax; + if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) { + uint16_t lowest_cost = kNetworkCostMax; for (const Network* network : networks) { // Don't determine the lowest cost from a link-local network. // On iOS, a device connected to the computer will get a link-local // network for communicating with the computer, however this network can't // be used to connect to a peer outside the network. - if (webrtc::IPIsLinkLocal(network->GetBestIP())) { + if (IPIsLinkLocal(network->GetBestIP())) { continue; } lowest_cost = std::min( @@ -738,7 +734,7 @@ std::vector BasicPortAllocatorSession::GetNetworks() { NetworkFilter costly_filter( [lowest_cost, this](const Network* network) { return network->GetCost(allocator()->env().field_trials()) > - lowest_cost + webrtc::kNetworkCostLow; + lowest_cost + kNetworkCostLow; }, "costly"); FilterNetworks(&networks, costly_filter); @@ -771,10 +767,9 @@ std::vector BasicPortAllocatorSession::SelectIPv6Networks( // Adapter types are placed in priority order. Cellular type is an alias of // cellular, 2G..5G types. std::vector adapter_types = { - webrtc::ADAPTER_TYPE_ETHERNET, webrtc::ADAPTER_TYPE_LOOPBACK, - webrtc::ADAPTER_TYPE_WIFI, webrtc::ADAPTER_TYPE_CELLULAR, - webrtc::ADAPTER_TYPE_VPN, webrtc::ADAPTER_TYPE_UNKNOWN, - webrtc::ADAPTER_TYPE_ANY}; + ADAPTER_TYPE_ETHERNET, ADAPTER_TYPE_LOOPBACK, ADAPTER_TYPE_WIFI, + ADAPTER_TYPE_CELLULAR, ADAPTER_TYPE_VPN, ADAPTER_TYPE_UNKNOWN, + ADAPTER_TYPE_ANY}; int adapter_types_cnt = adapter_types.size(); std::vector selected_networks; int adapter_types_pos = 0; @@ -786,7 +781,7 @@ std::vector BasicPortAllocatorSession::SelectIPv6Networks( if (adapter_types[adapter_types_pos % adapter_types_cnt] == all_ipv6_networks[network_pos]->type() || (adapter_types[adapter_types_pos % adapter_types_cnt] == - webrtc::ADAPTER_TYPE_CELLULAR && + ADAPTER_TYPE_CELLULAR && all_ipv6_networks[network_pos]->IsCellular())) { selected_networks.push_back(all_ipv6_networks[network_pos]); all_ipv6_networks.erase(all_ipv6_networks.begin() + network_pos); @@ -825,18 +820,18 @@ void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) { if (!config || config->relays.empty()) { // No relay ports specified in this config. - sequence_flags |= webrtc::PORTALLOCATOR_DISABLE_RELAY; + sequence_flags |= PORTALLOCATOR_DISABLE_RELAY; } - if (!(sequence_flags & webrtc::PORTALLOCATOR_ENABLE_IPV6) && + if (!(sequence_flags & PORTALLOCATOR_ENABLE_IPV6) && networks[i]->GetBestIP().family() == AF_INET6) { // Skip IPv6 networks unless the flag's been set. continue; } - if (!(sequence_flags & webrtc::PORTALLOCATOR_ENABLE_IPV6_ON_WIFI) && + if (!(sequence_flags & PORTALLOCATOR_ENABLE_IPV6_ON_WIFI) && networks[i]->GetBestIP().family() == AF_INET6 && - networks[i]->type() == webrtc::ADAPTER_TYPE_WIFI) { + networks[i]->type() == ADAPTER_TYPE_WIFI) { // Skip IPv6 Wi-Fi networks unless the flag's been set. continue; } @@ -929,7 +924,7 @@ void BasicPortAllocatorSession::AddAllocatedPort(Port* port, port->set_component(component()); port->set_generation(generation()); port->set_send_retransmit_count_attribute( - (flags() & webrtc::PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0); + (flags() & PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0); PortData data(port, seq); ports_.push_back(data); @@ -960,7 +955,7 @@ void BasicPortAllocatorSession::OnCandidateReady(Port* port, const Candidate& c) { RTC_DCHECK_RUN_ON(network_thread_); PortData* data = FindPort(port); - RTC_DCHECK(data != NULL); + RTC_DCHECK(data != nullptr); RTC_LOG(LS_INFO) << port->ToString() << ": Gathered candidate: " << c.ToSensitiveString(); // Discarding any candidate signal if port allocation status is @@ -985,9 +980,9 @@ void BasicPortAllocatorSession::OnCandidateReady(Port* port, data->set_has_pairable_candidate(true); if (port->Type() == IceCandidateType::kRelay) { - if (turn_port_prune_policy_ == webrtc::KEEP_FIRST_READY) { + if (turn_port_prune_policy_ == KEEP_FIRST_READY) { pruned = PruneNewlyPairableTurnPort(data); - } else if (turn_port_prune_policy_ == webrtc::PRUNE_BASED_ON_PRIORITY) { + } else if (turn_port_prune_policy_ == PRUNE_BASED_ON_PRIORITY) { pruned = PruneTurnPorts(port); } } @@ -1109,7 +1104,7 @@ void BasicPortAllocatorSession::OnPortComplete(Port* port) { RTC_LOG(LS_INFO) << port->ToString() << ": Port completed gathering candidates."; PortData* data = FindPort(port); - RTC_DCHECK(data != NULL); + RTC_DCHECK(data != nullptr); // Ignore any late signals. if (!data->inprogress()) { @@ -1127,7 +1122,7 @@ void BasicPortAllocatorSession::OnPortError(Port* port) { RTC_LOG(LS_INFO) << port->ToString() << ": Port encountered error while gathering candidates."; PortData* data = FindPort(port); - RTC_DCHECK(data != NULL); + RTC_DCHECK(data != nullptr); // We might have already given up on this port and stopped it. if (!data->inprogress()) { return; @@ -1160,8 +1155,8 @@ bool BasicPortAllocatorSession::CandidatePairable(const Candidate& c, // both device enumeration and host candidates being disabled. bool network_enumeration_disabled = c.address().IsAnyIP(); bool can_ping_from_candidate = - (port->SharedSocket() || c.protocol() == webrtc::TCP_PROTOCOL_NAME); - bool host_candidates_disabled = !(candidate_filter_ & webrtc::CF_HOST); + (port->SharedSocket() || c.protocol() == TCP_PROTOCOL_NAME); + bool host_candidates_disabled = !(candidate_filter_ & CF_HOST); return candidate_signalable || (network_enumeration_disabled && can_ping_from_candidate && @@ -1214,7 +1209,7 @@ BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort( return &*it; } } - return NULL; + return nullptr; } std::vector @@ -1275,13 +1270,13 @@ AllocationSequence::AllocationSequence( state_(kInit), flags_(flags), udp_socket_(), - udp_port_(NULL), + udp_port_(nullptr), phase_(0), port_allocation_complete_callback_( std::move(port_allocation_complete_callback)) {} void AllocationSequence::Init() { - if (IsFlagSet(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { + if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { udp_socket_.reset(session_->socket_factory()->CreateUdpSocket( SocketAddress(network_->GetBestIP(), 0), session_->allocator()->min_port(), session_->allocator()->max_port())); @@ -1298,7 +1293,7 @@ void AllocationSequence::Init() { void AllocationSequence::Clear() { TRACE_EVENT0("webrtc", "AllocationSequence::Clear"); - udp_port_ = NULL; + udp_port_ = nullptr; relay_ports_.clear(); } @@ -1343,22 +1338,22 @@ void AllocationSequence::DisableEquivalentPhases(const Network* network, if (absl::c_any_of(session_->ports_, [this](const BasicPortAllocatorSession::PortData& p) { return !p.pruned() && p.port()->Network() == network_ && - p.port()->GetProtocol() == webrtc::PROTO_UDP && + p.port()->GetProtocol() == PROTO_UDP && p.port()->Type() == IceCandidateType::kHost && !p.error(); })) { - *flags |= webrtc::PORTALLOCATOR_DISABLE_UDP; + *flags |= PORTALLOCATOR_DISABLE_UDP; } // Similarly we need to check both the protocol used by an existing Port and // its type. if (absl::c_any_of(session_->ports_, [this](const BasicPortAllocatorSession::PortData& p) { return !p.pruned() && p.port()->Network() == network_ && - p.port()->GetProtocol() == webrtc::PROTO_TCP && + p.port()->GetProtocol() == PROTO_TCP && p.port()->Type() == IceCandidateType::kHost && !p.error(); })) { - *flags |= webrtc::PORTALLOCATOR_DISABLE_TCP; + *flags |= PORTALLOCATOR_DISABLE_TCP; } if (config_ && config) { @@ -1368,9 +1363,9 @@ void AllocationSequence::DisableEquivalentPhases(const Network* network, // 2. We will regather host candidates, hence possibly inducing new NAT // bindings. if (config_->StunServers() == config->StunServers() && - (*flags & webrtc::PORTALLOCATOR_DISABLE_UDP)) { + (*flags & PORTALLOCATOR_DISABLE_UDP)) { // Already got this STUN servers covered. - *flags |= webrtc::PORTALLOCATOR_DISABLE_STUN; + *flags |= PORTALLOCATOR_DISABLE_STUN; } if (!config_->relays.empty()) { // Already got relays covered. @@ -1378,7 +1373,7 @@ void AllocationSequence::DisableEquivalentPhases(const Network* network, // were to be given one, but that never happens in our codebase. Should // probably get rid of the list in PortConfiguration and just keep a // single relay server in each one. - *flags |= webrtc::PORTALLOCATOR_DISABLE_RELAY; + *flags |= PORTALLOCATOR_DISABLE_RELAY; } } } @@ -1447,7 +1442,7 @@ void AllocationSequence::Process(int epoch) { } void AllocationSequence::CreateUDPPorts() { - if (IsFlagSet(webrtc::PORTALLOCATOR_DISABLE_UDP)) { + if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) { RTC_LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping."; return; } @@ -1456,8 +1451,8 @@ void AllocationSequence::CreateUDPPorts() { // is enabled completely. std::unique_ptr port; bool emit_local_candidate_for_anyaddress = - !IsFlagSet(webrtc::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); - if (IsFlagSet(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) { + !IsFlagSet(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); + if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) { port = UDPPort::Create( {.env = session_->allocator()->env(), .network_thread = session_->network_thread(), @@ -1484,13 +1479,13 @@ void AllocationSequence::CreateUDPPorts() { port->SetIceTiebreaker(session_->allocator()->ice_tiebreaker()); // If shared socket is enabled, STUN candidate will be allocated by the // UDPPort. - if (IsFlagSet(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { + if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { udp_port_ = port.get(); port->SubscribePortDestroyed( [this](PortInterface* port) { OnPortDestroyed(port); }); // If STUN is not disabled, setting stun server address to port. - if (!IsFlagSet(webrtc::PORTALLOCATOR_DISABLE_STUN)) { + if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { if (config_ && !config_->StunServers().empty()) { RTC_LOG(LS_INFO) << "AllocationSequence: UDPPort will be handling the " @@ -1505,7 +1500,7 @@ void AllocationSequence::CreateUDPPorts() { } void AllocationSequence::CreateTCPPorts() { - if (IsFlagSet(webrtc::PORTALLOCATOR_DISABLE_TCP)) { + if (IsFlagSet(PORTALLOCATOR_DISABLE_TCP)) { RTC_LOG(LS_VERBOSE) << "AllocationSequence: TCP ports disabled, skipping."; return; } @@ -1528,12 +1523,12 @@ void AllocationSequence::CreateTCPPorts() { } void AllocationSequence::CreateStunPorts() { - if (IsFlagSet(webrtc::PORTALLOCATOR_DISABLE_STUN)) { + if (IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { RTC_LOG(LS_VERBOSE) << "AllocationSequence: STUN ports disabled, skipping."; return; } - if (IsFlagSet(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { + if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { return; } @@ -1562,7 +1557,7 @@ void AllocationSequence::CreateStunPorts() { } void AllocationSequence::CreateRelayPorts() { - if (IsFlagSet(webrtc::PORTALLOCATOR_DISABLE_RELAY)) { + if (IsFlagSet(PORTALLOCATOR_DISABLE_RELAY)) { RTC_LOG(LS_VERBOSE) << "AllocationSequence: Relay ports disabled, skipping."; return; @@ -1593,8 +1588,8 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config, for (relay_port = config.ports.begin(); relay_port != config.ports.end(); ++relay_port) { // Skip UDP connections to relay servers if it's disallowed. - if (IsFlagSet(webrtc::PORTALLOCATOR_DISABLE_UDP_RELAY) && - relay_port->proto == webrtc::PROTO_UDP) { + if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP_RELAY) && + relay_port->proto == PROTO_UDP) { continue; } @@ -1627,8 +1622,8 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config, // don't pass shared socket for ports which will create TCP sockets. // TODO(mallinath) - Enable shared socket mode for TURN ports. Disabled // due to webrtc bug https://code.google.com/p/webrtc/issues/detail?id=3537 - if (IsFlagSet(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET) && - relay_port->proto == webrtc::PROTO_UDP && udp_socket_) { + if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && + relay_port->proto == PROTO_UDP && udp_socket_) { port = session_->allocator()->relay_port_factory()->Create( args, udp_socket_.get()); @@ -1655,7 +1650,7 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config, continue; } } - RTC_DCHECK(port != NULL); + RTC_DCHECK(port != nullptr); port->SetIceTiebreaker(session_->allocator()->ice_tiebreaker()); session_->AddAllocatedPort(port.release(), this); } @@ -1697,7 +1692,7 @@ void AllocationSequence::OnReadPacket(AsyncPacketSocket* socket, void AllocationSequence::OnPortDestroyed(PortInterface* port) { if (udp_port_ == port) { - udp_port_ = NULL; + udp_port_ = nullptr; return; } @@ -1737,7 +1732,7 @@ ServerAddresses PortConfiguration::StunServers() { // Every UDP TURN server should also be used as a STUN server if // use_turn_server_as_stun_server is not disabled or the stun servers are // empty. - ServerAddresses turn_servers = GetRelayServerAddresses(webrtc::PROTO_UDP); + ServerAddresses turn_servers = GetRelayServerAddresses(PROTO_UDP); for (const SocketAddress& turn_server : turn_servers) { if (stun_servers.find(turn_server) == stun_servers.end()) { stun_servers.insert(turn_server); diff --git a/p2p/client/basic_port_allocator_unittest.cc b/p2p/client/basic_port_allocator_unittest.cc index 5cf1b6e5f1..c022efe33f 100644 --- a/p2p/client/basic_port_allocator_unittest.cc +++ b/p2p/client/basic_port_allocator_unittest.cc @@ -170,13 +170,14 @@ class BasicPortAllocatorTestBase : public ::testing::Test, fss_.get(), kTurnUdpIntAddr, kTurnUdpExtAddr), + network_manager_(&thread_), candidate_allocation_done_(false) { allocator_.emplace(env_, &network_manager_, &socket_factory_); - allocator_->SetConfiguration({kStunAddr}, {}, 0, webrtc::NO_PRUNE, nullptr); + allocator_->SetConfiguration({kStunAddr}, {}, 0, NO_PRUNE, nullptr); allocator_->Initialize(); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); - webrtc::metrics::Reset(); + allocator_->set_step_delay(kMinimumStepDelay); + metrics::Reset(); } void AddInterface(const SocketAddress& addr) { @@ -212,7 +213,7 @@ class BasicPortAllocatorTestBase : public ::testing::Test, void ResetWithNoServersOrNat() { allocator_.emplace(env_, &network_manager_, &socket_factory_); allocator_->Initialize(); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); } // Endpoint is behind a NAT, with STUN specified. void ResetWithStunServerAndNat(const SocketAddress& stun_server) { @@ -236,10 +237,10 @@ class BasicPortAllocatorTestBase : public ::testing::Test, turn_server.credentials = credentials; if (!udp_turn.IsNil()) { - turn_server.ports.push_back(ProtocolAddress(udp_turn, webrtc::PROTO_UDP)); + turn_server.ports.push_back(ProtocolAddress(udp_turn, PROTO_UDP)); } if (!tcp_turn.IsNil()) { - turn_server.ports.push_back(ProtocolAddress(tcp_turn, webrtc::PROTO_TCP)); + turn_server.ports.push_back(ProtocolAddress(tcp_turn, PROTO_TCP)); } return turn_server; } @@ -307,7 +308,7 @@ class BasicPortAllocatorTestBase : public ::testing::Test, const SocketAddress& pattern) { return address.ipaddr() == pattern.ipaddr() && ((pattern.port() == 0 && - (address.port() != 0 || webrtc::IPIsAny(address.ipaddr()))) || + (address.port() != 0 || IPIsAny(address.ipaddr()))) || (pattern.port() != 0 && address.port() == pattern.port())); } @@ -489,11 +490,10 @@ class BasicPortAllocatorTestBase : public ::testing::Test, stun_servers.insert(stun_server); } allocator_.emplace(env_, &network_manager_, nat_socket_factory_.get()); - allocator_->SetConfiguration(stun_servers, {}, 0, webrtc::NO_PRUNE, - nullptr); + allocator_->SetConfiguration(stun_servers, {}, 0, NO_PRUNE, nullptr); allocator_->Initialize(); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); } Environment env_ = CreateEnvironment(); @@ -542,15 +542,15 @@ class BasicPortAllocatorTest : public FakeClockBase, ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); } session_->set_flags(session_->flags() | - webrtc::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); + PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | + PORTALLOCATOR_ENABLE_SHARED_SOCKET); allocator().set_allow_tcp_listen(false); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); uint32_t total_candidates = 0; if (!host_candidate_addr.IsNil()) { @@ -561,7 +561,7 @@ class BasicPortAllocatorTest : public FakeClockBase, if (!stun_candidate_addr.IsNil()) { SocketAddress related_address(host_candidate_addr, 0); if (host_candidate_addr.IsNil()) { - related_address.SetIP(webrtc::GetAnyIP(stun_candidate_addr.family())); + related_address.SetIP(GetAnyIP(stun_candidate_addr.family())); } EXPECT_TRUE(HasCandidateWithRelatedAddr( candidates_, IceCandidateType::kSrflx, "udp", @@ -588,7 +588,7 @@ class BasicPortAllocatorTest : public FakeClockBase, } void TestIPv6TurnPortPrunesIPv4TurnPort() { - turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, PROTO_UDP); // Add two IP addresses on the same interface. AddInterface(kClientAddr, "net1"); AddInterface(kClientIPv6Addr, "net1"); @@ -596,32 +596,32 @@ class BasicPortAllocatorTest : public FakeClockBase, allocator_->Initialize(); allocator_->SetConfiguration(allocator_->stun_servers(), allocator_->turn_servers(), 0, - webrtc::PRUNE_BASED_ON_PRIORITY); + PRUNE_BASED_ON_PRIORITY); AddTurnServers(kTurnUdpIntIPv6Addr, SocketAddress()); AddTurnServers(kTurnUdpIntAddr, SocketAddress()); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); allocator_->set_flags( - allocator().flags() | webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_ENABLE_IPV6 | webrtc::PORTALLOCATOR_DISABLE_TCP); + allocator().flags() | PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Three ports (one IPv4 STUN, one IPv6 STUN and one TURN) will be ready. EXPECT_EQ(3U, session_->ReadyPorts().size()); EXPECT_EQ(3U, ports_.size()); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_UDP, - kClientAddr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_UDP, + EXPECT_EQ( + 1, CountPorts(ports_, IceCandidateType::kHost, PROTO_UDP, kClientAddr)); + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, PROTO_UDP, kClientIPv6Addr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, webrtc::PROTO_UDP, + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, PROTO_UDP, kClientIPv6Addr)); - EXPECT_EQ(0, CountPorts(ports_, IceCandidateType::kRelay, webrtc::PROTO_UDP, + EXPECT_EQ(0, CountPorts(ports_, IceCandidateType::kRelay, PROTO_UDP, kClientAddr)); // Now that we remove candidates when a TURN port is pruned, there will be @@ -638,38 +638,38 @@ class BasicPortAllocatorTest : public FakeClockBase, void TestTurnPortPrunesWithUdpAndTcpPorts(PortPrunePolicy prune_policy, bool tcp_pruned) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); AddInterface(kClientAddr); allocator_.emplace(env_, &network_manager_, &socket_factory_); allocator_->Initialize(); allocator_->SetConfiguration(allocator_->stun_servers(), allocator_->turn_servers(), 0, prune_policy); AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Only 2 ports (one STUN and one TURN) are actually being used. EXPECT_EQ(2U, session_->ReadyPorts().size()); // We have verified that each port, when it is added to `ports_`, it is // found in `ready_ports`, and when it is pruned, it is not found in // `ready_ports`, so we only need to verify the content in one of them. EXPECT_EQ(2U, ports_.size()); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_UDP, - kClientAddr)); + EXPECT_EQ( + 1, CountPorts(ports_, IceCandidateType::kHost, PROTO_UDP, kClientAddr)); int num_udp_ports = tcp_pruned ? 1 : 0; EXPECT_EQ(num_udp_ports, CountPorts(ports_, IceCandidateType::kRelay, - webrtc::PROTO_UDP, kClientAddr)); + PROTO_UDP, kClientAddr)); EXPECT_EQ(1 - num_udp_ports, CountPorts(ports_, IceCandidateType::kRelay, - webrtc::PROTO_TCP, kClientAddr)); + PROTO_TCP, kClientAddr)); // Now that we remove candidates when a TURN port is pruned, `candidates_` // should only contains two candidates regardless whether the TCP TURN port @@ -689,9 +689,9 @@ class BasicPortAllocatorTest : public FakeClockBase, } void TestEachInterfaceHasItsOwnTurnPorts() { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); - turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, webrtc::PROTO_UDP); - turn_server_.AddInternalSocket(kTurnTcpIntIPv6Addr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); + turn_server_.AddInternalSocket(kTurnUdpIntIPv6Addr, PROTO_UDP); + turn_server_.AddInternalSocket(kTurnTcpIntIPv6Addr, PROTO_TCP); // Add two interfaces both having IPv4 and IPv6 addresses. AddInterface(kClientAddr, "net1", ADAPTER_TYPE_WIFI); AddInterface(kClientIPv6Addr, "net1", ADAPTER_TYPE_WIFI); @@ -701,46 +701,45 @@ class BasicPortAllocatorTest : public FakeClockBase, allocator_->Initialize(); allocator_->SetConfiguration(allocator_->stun_servers(), allocator_->turn_servers(), 0, - webrtc::PRUNE_BASED_ON_PRIORITY); + PRUNE_BASED_ON_PRIORITY); // Have both UDP/TCP and IPv4/IPv6 TURN ports. AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); - allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_ENABLE_IPV6 | - webrtc::PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); + allocator_->set_step_delay(kMinimumStepDelay); + allocator_->set_flags( + allocator().flags() | PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // 10 ports (4 STUN and 1 TURN ports on each interface) will be ready to // use. EXPECT_EQ(10U, session_->ReadyPorts().size()); EXPECT_EQ(10U, ports_.size()); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_UDP, - kClientAddr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_UDP, + EXPECT_EQ( + 1, CountPorts(ports_, IceCandidateType::kHost, PROTO_UDP, kClientAddr)); + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, PROTO_UDP, kClientAddr2)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_UDP, + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, PROTO_UDP, kClientIPv6Addr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_UDP, + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, PROTO_UDP, kClientIPv6Addr2)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_TCP, - kClientAddr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_TCP, + EXPECT_EQ( + 1, CountPorts(ports_, IceCandidateType::kHost, PROTO_TCP, kClientAddr)); + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, PROTO_TCP, kClientAddr2)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_TCP, + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, PROTO_TCP, kClientIPv6Addr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_TCP, + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, PROTO_TCP, kClientIPv6Addr2)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, webrtc::PROTO_UDP, + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, PROTO_UDP, kClientIPv6Addr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, webrtc::PROTO_UDP, + EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, PROTO_UDP, kClientIPv6Addr2)); // Now that we remove candidates when TURN ports are pruned, there will be @@ -793,15 +792,14 @@ TEST_F(BasicPortAllocatorTest, TestIgnoreOnlyLoopbackNetworkByDefault) { AddInterface(SocketAddress(IPAddress(0x12345604U), 0), "test_lo", ADAPTER_TYPE_LOOPBACK); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP); + session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(4U, candidates_.size()); for (const Candidate& candidate : candidates_) { EXPECT_LT(candidate.address().ip(), 0x12345604U); @@ -818,15 +816,14 @@ TEST_F(BasicPortAllocatorTest, TestIgnoreNetworksAccordingToIgnoreMask) { allocator_->SetNetworkIgnoreMask(ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK | ADAPTER_TYPE_WIFI); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP); + session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(1U, candidates_.size()); EXPECT_EQ(0x12345602U, candidates_[0].address().ip()); } @@ -840,17 +837,16 @@ TEST_F(BasicPortAllocatorTest, AddInterface(wifi, "test_wlan0", ADAPTER_TYPE_WIFI); AddInterface(cell, "test_cell0", ADAPTER_TYPE_CELLULAR); // Disable all but UDP candidates to make the test simpler. - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); + allocator().set_flags( + PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Should only get one Wi-Fi candidate. EXPECT_EQ(1U, candidates_.size()); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kHost, "udp", wifi)); @@ -869,17 +865,16 @@ TEST_F(BasicPortAllocatorTest, AddInterface(unknown1, "test_unknown0", ADAPTER_TYPE_UNKNOWN); AddInterface(unknown2, "test_unknown1", ADAPTER_TYPE_UNKNOWN); // Disable all but UDP candidates to make the test simpler. - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); + allocator().set_flags( + PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Should only get two candidates, none of which is cell. EXPECT_EQ(2U, candidates_.size()); EXPECT_TRUE( @@ -902,17 +897,16 @@ TEST_F(BasicPortAllocatorTest, AddInterface(unknown1, "test_unknown0", ADAPTER_TYPE_UNKNOWN); AddInterface(unknown2, "test_unknown1", ADAPTER_TYPE_UNKNOWN); // Disable all but UDP candidates to make the test simpler. - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); + allocator().set_flags( + PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Should only get one Wi-Fi candidate. EXPECT_EQ(1U, candidates_.size()); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kHost, "udp", wifi)); @@ -926,17 +920,16 @@ TEST_F(BasicPortAllocatorTest, SocketAddress cellular(IPAddress(0x12345601U), 0); AddInterface(cellular, "test_cell0", ADAPTER_TYPE_CELLULAR); // Disable all but UDP candidates to make the test simpler. - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); + allocator().set_flags( + PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Make sure we got the cell candidate. EXPECT_EQ(1U, candidates_.size()); EXPECT_TRUE( @@ -953,17 +946,16 @@ TEST_F(BasicPortAllocatorTest, AddInterface(wifi_link_local, "test_wlan0", ADAPTER_TYPE_WIFI); AddInterface(cellular, "test_cell0", ADAPTER_TYPE_CELLULAR); - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); + allocator().set_flags( + PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Make sure we got both wifi and cell candidates. EXPECT_EQ(2U, candidates_.size()); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kHost, "udp", @@ -985,17 +977,16 @@ TEST_F(BasicPortAllocatorTest, AddInterface(wifi_link_local, "test_wlan1", ADAPTER_TYPE_WIFI); AddInterface(cellular, "test_cell0", ADAPTER_TYPE_CELLULAR); - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); + allocator().set_flags( + PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Make sure we got only wifi candidates. EXPECT_EQ(2U, candidates_.size()); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kHost, "udp", wifi)); @@ -1011,16 +1002,16 @@ TEST_F(BasicPortAllocatorTest, EthernetIsNotFilteredOutWhenCostlyNetworksDisabledAndVpnPresent) { AddInterface(kClientAddr, "eth0", ADAPTER_TYPE_ETHERNET); AddInterface(kClientAddr2, "tap0", ADAPTER_TYPE_VPN); - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP); + allocator().set_flags(PORTALLOCATOR_DISABLE_COSTLY_NETWORKS | + PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // The VPN tap0 network should be filtered out as a costly network, and we // should have a UDP port and a STUN port from the Ethernet eth0. ASSERT_EQ(2U, ports_.size()); @@ -1038,17 +1029,17 @@ TEST_F(BasicPortAllocatorTest, MaxIpv6NetworksLimitEnforced) { AddInterface(kClientIPv6Addr3, "eth2", ADAPTER_TYPE_ETHERNET); // To simplify the test, only gather UDP host candidates. - allocator().set_flags( - webrtc::PORTALLOCATOR_ENABLE_IPV6 | webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_STUN | webrtc::PORTALLOCATOR_DISABLE_RELAY); + allocator().set_flags(PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_DISABLE_RELAY); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, candidates_.size()); // Ensure the expected two interfaces (eth0 and eth1) were used. EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kHost, "udp", @@ -1068,17 +1059,17 @@ TEST_F(BasicPortAllocatorTest, MaxIpv6NetworksLimitDoesNotImpactIpv4Networks) { AddInterface(kClientAddr2, "eth3", ADAPTER_TYPE_ETHERNET); // To simplify the test, only gather UDP host candidates. - allocator().set_flags( - webrtc::PORTALLOCATOR_ENABLE_IPV6 | webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_STUN | webrtc::PORTALLOCATOR_DISABLE_RELAY); + allocator().set_flags(PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_DISABLE_RELAY); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); // Ensure that only one IPv6 interface was used, but both IPv4 interfaces // were used. @@ -1095,15 +1086,14 @@ TEST_F(BasicPortAllocatorTest, TestLoopbackNetworkInterface) { AddInterface(kLoopbackAddr, "test_loopback", ADAPTER_TYPE_LOOPBACK); allocator_->SetNetworkIgnoreMask(0); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP); + session_->set_flags(PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(1U, candidates_.size()); } @@ -1112,11 +1102,11 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_EQ(3U, ports_.size()); EXPECT_TRUE( @@ -1135,11 +1125,11 @@ TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionNotStopped) { AddInterface(kClientAddr, if_name); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_EQ(3U, ports_.size()); candidate_allocation_done_ = false; @@ -1162,11 +1152,11 @@ TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionNotStopped) { fss_->set_tcp_sockets_enabled(true); fss_->set_udp_sockets_enabled(true); AddInterface(kClientAddr, if_name); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_EQ(3U, ports_.size()); } @@ -1179,11 +1169,11 @@ TEST_F(BasicPortAllocatorTest, TestSameNetworkDownAndUpWhenSessionStopped) { AddInterface(kClientAddr, if_name); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_EQ(3U, ports_.size()); session_->StopGettingPorts(); @@ -1220,11 +1210,11 @@ TEST_F(BasicPortAllocatorTest, CandidatesRegatheredAfterBindingFails) { fss_->set_udp_sockets_enabled(false); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Make sure we actually prevented candidates from being gathered (other than // a single TCP active candidate, since that doesn't require creating a // socket). @@ -1238,11 +1228,11 @@ TEST_F(BasicPortAllocatorTest, CandidatesRegatheredAfterBindingFails) { fss_->set_tcp_sockets_enabled(true); fss_->set_udp_sockets_enabled(true); AddInterface(kClientAddr, if_name); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Should get UDP and TCP candidate. ASSERT_EQ(2U, candidates_.size()); EXPECT_TRUE( @@ -1257,21 +1247,21 @@ TEST_F(BasicPortAllocatorTest, CandidatesRegatheredAfterBindingFails) { // Verify candidates with default step delay of 1sec. TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) { AddInterface(kClientAddr); - allocator_->set_step_delay(webrtc::kDefaultStepDelay); + allocator_->set_step_delay(kDefaultStepDelay); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil([&] { return candidates_.size(); }, Eq(2U), - {.clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return candidates_.size(); }, Eq(2U), + {.clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, ports_.size()); - ASSERT_THAT(webrtc::WaitUntil([&] { return candidates_.size(); }, Eq(3U), - {.clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return candidates_.size(); }, Eq(3U), + {.clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, ports_.size()); - ASSERT_THAT(webrtc::WaitUntil([&] { return candidates_.size(); }, Eq(3U), - {.clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return candidates_.size(); }, Eq(3U), + {.clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "tcp", kClientAddr)); EXPECT_EQ(3U, ports_.size()); @@ -1284,11 +1274,11 @@ TEST_F(BasicPortAllocatorTest, TestSetupVideoRtpPortsWithNormalSendBuffers) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP, CN_VIDEO)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); // If we Stop gathering now, we shouldn't get a second "done" callback. session_->StopGettingPorts(); @@ -1303,18 +1293,18 @@ TEST_F(BasicPortAllocatorTest, TestStopGetAllPorts) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(2U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(2U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, ports_.size()); session_->StopGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); } // Test that we restrict client ports appropriately when a port range is set. @@ -1330,11 +1320,11 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsPortRange) { EXPECT_TRUE(SetPortRange(kMinPort, kMaxPort)); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_EQ(3U, ports_.size()); @@ -1355,26 +1345,26 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoAdapters) { // Default config uses GTURN and no NAT, so replace that with the // desired setup (NAT, STUN server, TURN server, UDP/TCP). ResetWithStunServerAndNat(kStunAddr); - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(4U, ports_.size()); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kSrflx, webrtc::PROTO_UDP, - kAnyAddr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kHost, webrtc::PROTO_TCP, - kAnyAddr)); + EXPECT_EQ(1, + CountPorts(ports_, IceCandidateType::kSrflx, PROTO_UDP, kAnyAddr)); + EXPECT_EQ(1, + CountPorts(ports_, IceCandidateType::kHost, PROTO_TCP, kAnyAddr)); // Two TURN ports, using UDP/TCP for the first hop to the TURN server. - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, webrtc::PROTO_UDP, - kAnyAddr)); - EXPECT_EQ(1, CountPorts(ports_, IceCandidateType::kRelay, webrtc::PROTO_TCP, - kAnyAddr)); + EXPECT_EQ(1, + CountPorts(ports_, IceCandidateType::kRelay, PROTO_UDP, kAnyAddr)); + EXPECT_EQ(1, + CountPorts(ports_, IceCandidateType::kRelay, PROTO_TCP, kAnyAddr)); // The "any" address port should be in the signaled ready ports, but the host // candidate for it is useless and shouldn't be signaled. So we only have // STUN/TURN candidates. @@ -1395,7 +1385,7 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoAdapters) { TEST_F(BasicPortAllocatorTest, TestDisableAdapterEnumerationWithoutNatRelayTransportOnly) { ResetWithStunServerNoNat(kStunAddr); - allocator().SetCandidateFilter(webrtc::CF_RELAY); + allocator().SetCandidateFilter(CF_RELAY); // Expect to see no ports and no candidates. CheckDisableAdapterEnumeration(0U, IPAddress(), IPAddress(), IPAddress(), IPAddress()); @@ -1415,7 +1405,7 @@ TEST_F(BasicPortAllocatorTest, // address set and we have no IPv6 STUN server, there should be no IPv6 // candidates. ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_ENABLE_IPV6); + session_->set_flags(PORTALLOCATOR_ENABLE_IPV6); // Expect to see 3 ports for IPv4: HOST/STUN, TURN/UDP and TCP ports, 2 ports // for IPv6: HOST, and TCP. Only IPv4 candidates: a default private, STUN and @@ -1428,7 +1418,7 @@ TEST_F(BasicPortAllocatorTest, // Test that we should get a default private, STUN, TURN/UDP and TURN/TCP // candidates when both TURN/UDP and TURN/TCP servers are specified. TEST_F(BasicPortAllocatorTest, TestDisableAdapterEnumerationBehindNatWithTcp) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); AddInterface(kPrivateAddr); ResetWithStunServerAndNat(kStunAddr); AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); @@ -1456,7 +1446,7 @@ TEST_F(BasicPortAllocatorTest, TestDisableAdapterEnumerationWithoutNatLocalhostCandidateDisabled) { ResetWithStunServerNoNat(kStunAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); + session_->set_flags(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN // candidate. CheckDisableAdapterEnumeration(2U, IPAddress(), IPAddress(), IPAddress(), @@ -1473,7 +1463,7 @@ TEST_F(BasicPortAllocatorTest, ResetWithStunServerNoNat(kStunAddr); AddInterfaceAsDefaultSourceAddresss(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); + session_->set_flags(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN // candidate. CheckDisableAdapterEnumeration(2U, IPAddress(), kClientAddr.ipaddr(), @@ -1487,7 +1477,7 @@ TEST_F(BasicPortAllocatorTest, TestDisableAdapterEnumerationWithNatLocalhostCandidateDisabled) { ResetWithStunServerAndNat(kStunAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); + session_->set_flags(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE); // Expect to see 2 ports: STUN and TCP ports, and single STUN candidate. CheckDisableAdapterEnumeration(2U, IPAddress(), kNatUdpAddr.ipaddr(), IPAddress(), IPAddress()); @@ -1496,22 +1486,21 @@ TEST_F(BasicPortAllocatorTest, // Test that we disable relay over UDP, and only TCP is used when connecting to // the relay server. TEST_F(BasicPortAllocatorTest, TestDisableUdpTurn) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); AddInterface(kClientAddr); ResetWithStunServerAndNat(kStunAddr); AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags(webrtc::PORTALLOCATOR_DISABLE_UDP_RELAY | - webrtc::PORTALLOCATOR_DISABLE_UDP | - webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); + session_->set_flags(PORTALLOCATOR_DISABLE_UDP_RELAY | + PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_ENABLE_SHARED_SOCKET); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and // TURN/TCP candidates. @@ -1521,7 +1510,7 @@ TEST_F(BasicPortAllocatorTest, TestDisableUdpTurn) { EXPECT_TRUE(FindCandidate(candidates_, IceCandidateType::kRelay, "udp", kTurnUdpExtAddr, &turn_candidate)); // The TURN candidate should use TCP to contact the TURN server. - EXPECT_EQ(webrtc::TCP_PROTOCOL_NAME, turn_candidate.relay_protocol()); + EXPECT_EQ(TCP_PROTOCOL_NAME, turn_candidate.relay_protocol()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "tcp", kClientAddr)); } @@ -1531,13 +1520,12 @@ TEST_F(BasicPortAllocatorTest, TestDisableUdpTurn) { TEST_F(BasicPortAllocatorTest, TestDisableAllPorts) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - session_->set_flags( - webrtc::PORTALLOCATOR_DISABLE_UDP | webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | webrtc::PORTALLOCATOR_DISABLE_TCP); + session_->set_flags(PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_DISABLE_RELAY | PORTALLOCATOR_DISABLE_TCP); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil([&] { return candidate_allocation_done_; }, - IsTrue(), {.clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(0U, candidates_.size()); } @@ -1547,11 +1535,11 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSockets) { fss_->set_udp_sockets_enabled(false); ASSERT_TRUE(CreateSession(1)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(1U, candidates_.size()); EXPECT_EQ(1U, ports_.size()); EXPECT_TRUE( @@ -1567,11 +1555,11 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSocketsNoTcpListen) { fss_->set_tcp_listen_enabled(false); ASSERT_TRUE(CreateSession(1)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(1U, candidates_.size()); EXPECT_EQ(1U, ports_.size()); EXPECT_TRUE( @@ -1594,15 +1582,15 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoSockets) { // Testing STUN timeout. TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpAllowed) { - fss_->AddRule(false, webrtc::FP_UDP, webrtc::FD_ANY, kClientAddr); + fss_->AddRule(false, FP_UDP, FD_ANY, kClientAddr); AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(2U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(2U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, ports_.size()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kClientAddr)); @@ -1610,11 +1598,10 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpAllowed) { HasCandidate(candidates_, IceCandidateType::kHost, "tcp", kClientAddr)); // We wait at least for a full STUN timeout, which // webrtc::STUN_TOTAL_TIMEOUT seconds. - EXPECT_THAT( - webrtc::WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + EXPECT_THAT(WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), {.timeout = TimeDelta::Millis(STUN_TOTAL_TIMEOUT), .clock = &fake_clock}), - webrtc::IsRtcOk()); + IsRtcOk()); // No additional (STUN) candidates. EXPECT_EQ(2U, candidates_.size()); } @@ -1624,16 +1611,15 @@ TEST_F(BasicPortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) { AddInterface(kClientAddr2); // Allocating only host UDP ports. This is done purely for testing // convenience. - allocator().set_flags(webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY); + allocator().set_flags(PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_DISABLE_RELAY); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); ASSERT_EQ(2U, candidates_.size()); EXPECT_EQ(2U, ports_.size()); // Candidates priorities should be different. @@ -1645,11 +1631,11 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsRestarts) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_EQ(3U, ports_.size()); // TODO(deadbeef): Extend this to verify ICE restart. @@ -1663,15 +1649,15 @@ TEST_F(BasicPortAllocatorTest, TestSessionUsesOwnCandidateFilter) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); // Set candidate filter *after* creating the session. Should have no effect. - allocator().SetCandidateFilter(webrtc::CF_RELAY); + allocator().SetCandidateFilter(CF_RELAY); session_->StartGettingPorts(); // 7 candidates and 4 ports is what we would normally get (see the // TestGetAllPorts* tests). - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_EQ(3U, ports_.size()); } @@ -1685,36 +1671,35 @@ TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) { AddInterface(kClientAddr); // GTURN is not configured here. ResetWithTurnServersNoNat(kTurnUdpIntAddr, SocketAddress()); - allocator().SetCandidateFilter(webrtc::CF_RELAY); + allocator().SetCandidateFilter(CF_RELAY); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kRelay, "udp", SocketAddress(kTurnUdpExtAddr.ipaddr(), 0))); EXPECT_EQ(1U, candidates_.size()); EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state. EXPECT_TRUE(candidates_[0].is_relay()); - EXPECT_EQ( - candidates_[0].related_address(), - webrtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); + EXPECT_EQ(candidates_[0].related_address(), + EmptySocketAddressWithFamily(candidates_[0].address().family())); } TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithHostOnly) { AddInterface(kClientAddr); - allocator().set_flags(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); - allocator().SetCandidateFilter(webrtc::CF_HOST); + allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); + allocator().SetCandidateFilter(CF_HOST); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. for (const Candidate& candidate : candidates_) { @@ -1727,37 +1712,36 @@ TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { AddInterface(kPrivateAddr); ResetWithStunServerAndNat(kStunAddr); - allocator().set_flags(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); - allocator().SetCandidateFilter(webrtc::CF_REFLEXIVE); + allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); + allocator().SetCandidateFilter(CF_REFLEXIVE); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Host is behind NAT, no private address will be exposed. Hence only UDP // port with STUN candidate will be sent outside. EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. EXPECT_EQ(1U, ports_.size()); // Only UDP port will be in ready state. EXPECT_TRUE(candidates_[0].is_stun()); - EXPECT_EQ( - candidates_[0].related_address(), - webrtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); + EXPECT_EQ(candidates_[0].related_address(), + EmptySocketAddressWithFamily(candidates_[0].address().family())); } // Host is not behind the NAT. TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { AddInterface(kClientAddr); - allocator().set_flags(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); - allocator().SetCandidateFilter(webrtc::CF_REFLEXIVE); + allocator().set_flags(PORTALLOCATOR_ENABLE_SHARED_SOCKET); + allocator().SetCandidateFilter(CF_REFLEXIVE); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Host has a public address, both UDP and TCP candidates will be exposed. EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. EXPECT_EQ(2U, ports_.size()); // UDP and TCP ports will be in ready state. @@ -1771,11 +1755,11 @@ TEST_F(BasicPortAllocatorTest, TestEnableSharedUfrag) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kClientAddr)); @@ -1797,22 +1781,22 @@ TEST_F(BasicPortAllocatorTest, TestEnableSharedUfrag) { TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNat) { AddInterface(kClientAddr); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); + PORTALLOCATOR_ENABLE_SHARED_SOCKET); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(2U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(2U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, ports_.size()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kClientAddr)); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); } // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port @@ -1823,49 +1807,49 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNat) { ResetWithStunServerAndNat(kStunAddr); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); + PORTALLOCATOR_ENABLE_SHARED_SOCKET); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(3U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(3U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); ASSERT_EQ(2U, ports_.size()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kClientAddr)); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kSrflx, "udp", SocketAddress(kNatUdpAddr.ipaddr(), 0))); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); } // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); AddInterface(kClientAddr); allocator_.emplace(env_, &network_manager_, &socket_factory_); allocator_->Initialize(); AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); ASSERT_EQ(3U, candidates_.size()); ASSERT_EQ(3U, ports_.size()); EXPECT_TRUE( @@ -1885,7 +1869,7 @@ TEST_F(BasicPortAllocatorTest, virtual_socket_server()->SetDelayOnAddress(kTurnUdpIntAddr, 200); virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 100); - TestTurnPortPrunesWithUdpAndTcpPorts(webrtc::PRUNE_BASED_ON_PRIORITY, + TestTurnPortPrunesWithUdpAndTcpPorts(PRUNE_BASED_ON_PRIORITY, true /* tcp_pruned */); } @@ -1898,7 +1882,7 @@ TEST_F(BasicPortAllocatorTest, virtual_socket_server()->SetDelayOnAddress(kTurnUdpIntAddr, 100); virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 200); - TestTurnPortPrunesWithUdpAndTcpPorts(webrtc::PRUNE_BASED_ON_PRIORITY, + TestTurnPortPrunesWithUdpAndTcpPorts(PRUNE_BASED_ON_PRIORITY, true /* tcp_pruned */); } @@ -1910,8 +1894,7 @@ TEST_F(BasicPortAllocatorTest, virtual_socket_server()->SetDelayOnAddress(kTurnUdpIntAddr, 100); virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 200); - TestTurnPortPrunesWithUdpAndTcpPorts(webrtc::KEEP_FIRST_READY, - true /* tcp_pruned */); + TestTurnPortPrunesWithUdpAndTcpPorts(KEEP_FIRST_READY, true /* tcp_pruned */); } // Test that if turn_port_prune policy is KEEP_FIRST_READY, the first ready port @@ -1922,7 +1905,7 @@ TEST_F(BasicPortAllocatorTest, virtual_socket_server()->SetDelayOnAddress(kTurnUdpIntAddr, 200); virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 100); - TestTurnPortPrunesWithUdpAndTcpPorts(webrtc::KEEP_FIRST_READY, + TestTurnPortPrunesWithUdpAndTcpPorts(KEEP_FIRST_READY, false /* tcp_pruned */); } @@ -1984,8 +1967,7 @@ TEST_F(BasicPortAllocatorTestWithRealClock, // This test relies on a real query for "localhost", so it won't work on an // IPv6-only machine. MAYBE_SKIP_IPV4; - turn_server_.AddInternalSocket(SocketAddress("127.0.0.1", 3478), - webrtc::PROTO_UDP); + turn_server_.AddInternalSocket(SocketAddress("127.0.0.1", 3478), PROTO_UDP); AddInterface(kClientAddr); allocator_.emplace(env_, &network_manager_, &socket_factory_); allocator_->Initialize(); @@ -1993,21 +1975,21 @@ TEST_F(BasicPortAllocatorTestWithRealClock, RelayCredentials credentials(kTurnUsername, kTurnPassword); turn_server.credentials = credentials; turn_server.ports.push_back( - ProtocolAddress(SocketAddress("localhost", 3478), webrtc::PROTO_UDP)); + ProtocolAddress(SocketAddress("localhost", 3478), PROTO_UDP)); allocator_->AddTurnServerForTesting(turn_server); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return ports_.size(); }, Eq(2U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout)}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return ports_.size(); }, Eq(2U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout)}), + IsRtcOk()); } // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port @@ -2020,17 +2002,17 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurn) { AddTurnServers(kTurnUdpIntAddr, SocketAddress()); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); ASSERT_EQ(2U, ports_.size()); EXPECT_TRUE( @@ -2039,11 +2021,11 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurn) { SocketAddress(kNatUdpAddr.ipaddr(), 0))); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kRelay, "udp", SocketAddress(kTurnUdpExtAddr.ipaddr(), 0))); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Local port will be created first and then TURN port. // TODO(deadbeef): This isn't something the BasicPortAllocator API contract // guarantees... @@ -2066,17 +2048,17 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { // webrtc issue 3537. allocator_->set_step_delay(0); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kClientAddr)); @@ -2099,23 +2081,23 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { // a UDP STUN server, as this could leak our IP address. Thus we should only // expect two ports, a UDPPort and TurnPort. TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); AddInterface(kClientAddr); ResetWithStunServerAndNat(SocketAddress()); AddTurnServers(SocketAddress(), kTurnTcpIntAddr); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, candidates_.size()); ASSERT_EQ(2U, ports_.size()); EXPECT_TRUE( @@ -2137,17 +2119,16 @@ TEST_F(BasicPortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { ResetWithStunServerAndNat(SocketAddress()); AddTurnServers(kTurnUdpIntAddr, SocketAddress()); - allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_DISABLE_TCP); + allocator_->set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); ASSERT_EQ(3U, ports_.size()); EXPECT_TRUE( @@ -2180,17 +2161,17 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { AddTurnServers(kTurnUdpIntAddr, SocketAddress()); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(3U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(3U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kClientAddr)); Candidate stun_candidate; @@ -2209,28 +2190,26 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { // and fail to generate STUN candidate, local UDP candidate is generated // properly. TEST_F(BasicPortAllocatorTest, TestSharedSocketNoUdpAllowed) { - allocator().set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); - fss_->AddRule(false, webrtc::FP_UDP, webrtc::FD_ANY, kClientAddr); + allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_ENABLE_SHARED_SOCKET); + fss_->AddRule(false, FP_UDP, FD_ANY, kClientAddr); AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return ports_.size(); }, Eq(1U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return ports_.size(); }, Eq(1U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(1U, candidates_.size()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kClientAddr)); // STUN timeout is 9.5sec. We need to wait to get candidate done signal. - EXPECT_THAT( - webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kStunTimeoutMs), .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kStunTimeoutMs), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(1U, candidates_.size()); } @@ -2242,44 +2221,40 @@ TEST_F(BasicPortAllocatorTest, TestNetworkPermissionBlocked) { IPAddress()); network_manager_.set_enumeration_permission( NetworkManager::ENUMERATION_BLOCKED); - allocator().set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); - EXPECT_EQ(0U, allocator_->flags() & - webrtc::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); + allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_ENABLE_SHARED_SOCKET); + EXPECT_EQ(0U, + allocator_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); - EXPECT_EQ(0U, session_->flags() & - webrtc::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); + EXPECT_EQ(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return ports_.size(); }, Eq(1U), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return ports_.size(); }, Eq(1U), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(1U, candidates_.size()); EXPECT_TRUE( HasCandidate(candidates_, IceCandidateType::kHost, "udp", kPrivateAddr)); - EXPECT_NE(0U, session_->flags() & - webrtc::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); + EXPECT_NE(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); } // This test verifies allocator can use IPv6 addresses along with IPv4. TEST_F(BasicPortAllocatorTest, TestEnableIPv6Addresses) { - allocator().set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_ENABLE_IPV6 | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); + allocator().set_flags(allocator().flags() | PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_ENABLE_IPV6 | + PORTALLOCATOR_ENABLE_SHARED_SOCKET); AddInterface(kClientIPv6Addr); AddInterface(kClientAddr); - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(4U, ports_.size()); EXPECT_EQ(4U, candidates_.size()); EXPECT_TRUE(HasCandidate(candidates_, IceCandidateType::kHost, "udp", @@ -2294,21 +2269,21 @@ TEST_F(BasicPortAllocatorTest, TestEnableIPv6Addresses) { TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) { AddInterface(kClientAddr); - allocator_->set_step_delay(webrtc::kDefaultStepDelay); + allocator_->set_step_delay(kDefaultStepDelay); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil([&] { return candidates_.size(); }, Eq(2U), - {.clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return candidates_.size(); }, Eq(2U), + {.clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, ports_.size()); session_->StopGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil([&] { return candidate_allocation_done_; }, - IsTrue(), {.clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.clock = &fake_clock}), + IsRtcOk()); // After stopping getting ports, adding a new interface will not start // getting ports again. - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); candidates_.clear(); ports_.clear(); candidate_allocation_done_ = false; @@ -2320,34 +2295,34 @@ TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) { TEST_F(BasicPortAllocatorTest, TestClearGettingPorts) { AddInterface(kClientAddr); - allocator_->set_step_delay(webrtc::kDefaultStepDelay); + allocator_->set_step_delay(kDefaultStepDelay); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil([&] { return candidates_.size(); }, Eq(2U), - {.clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return candidates_.size(); }, Eq(2U), + {.clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, ports_.size()); session_->ClearGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil([&] { return candidate_allocation_done_; }, - IsTrue(), {.clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.clock = &fake_clock}), + IsRtcOk()); // After clearing getting ports, adding a new interface will start getting // ports again. - allocator_->set_step_delay(webrtc::kMinimumStepDelay); + allocator_->set_step_delay(kMinimumStepDelay); candidates_.clear(); ports_.clear(); candidate_allocation_done_ = false; network_manager_.AddInterface(kClientAddr2); - ASSERT_THAT(webrtc::WaitUntil([&] { return candidates_.size(); }, Eq(2U), - {.clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return candidates_.size(); }, Eq(2U), + {.clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, ports_.size()); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); } // Test that the ports and candidates are updated with new ufrag/pwd/etc. when @@ -2356,16 +2331,15 @@ TEST_F(BasicPortAllocatorTest, TestTransportInformationUpdated) { AddInterface(kClientAddr); int pool_size = 1; allocator_->SetConfiguration(allocator_->stun_servers(), - allocator_->turn_servers(), pool_size, - webrtc::NO_PRUNE); + allocator_->turn_servers(), pool_size, NO_PRUNE); const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); ASSERT_NE(nullptr, peeked_session); EXPECT_THAT( - webrtc::WaitUntil( - [&] { return peeked_session->CandidatesAllocationDone(); }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + WaitUntil([&] { return peeked_session->CandidatesAllocationDone(); }, + IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); // Expect that when TakePooledSession is called, // UpdateTransportInformationInternal will be called and the // BasicPortAllocatorSession will update the ufrag/pwd of ports and @@ -2397,19 +2371,18 @@ TEST_F(BasicPortAllocatorTest, TestSetCandidateFilterAfterCandidatesGathered) { AddInterface(kClientAddr); int pool_size = 1; allocator_->SetConfiguration(allocator_->stun_servers(), - allocator_->turn_servers(), pool_size, - webrtc::NO_PRUNE); + allocator_->turn_servers(), pool_size, NO_PRUNE); const PortAllocatorSession* peeked_session = allocator_->GetPooledSession(); ASSERT_NE(nullptr, peeked_session); EXPECT_THAT( - webrtc::WaitUntil( - [&] { return peeked_session->CandidatesAllocationDone(); }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + WaitUntil([&] { return peeked_session->CandidatesAllocationDone(); }, + IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); size_t initial_candidates_size = peeked_session->ReadyCandidates().size(); size_t initial_ports_size = peeked_session->ReadyPorts().size(); - allocator_->SetCandidateFilter(webrtc::CF_RELAY); + allocator_->SetCandidateFilter(CF_RELAY); // Assume that when TakePooledSession is called, the candidate filter will be // applied to the pooled session. This is tested by PortAllocatorTest. session_ = @@ -2428,8 +2401,8 @@ TEST_F(BasicPortAllocatorTest, TestSetCandidateFilterAfterCandidatesGathered) { // Expect only relay candidates now that the filter is applied. EXPECT_TRUE(candidate.is_relay()); // Expect that the raddr is emptied due to the CF_RELAY filter. - EXPECT_EQ(candidate.related_address(), webrtc::EmptySocketAddressWithFamily( - candidate.address().family())); + EXPECT_EQ(candidate.related_address(), + EmptySocketAddressWithFamily(candidate.address().family())); } } @@ -2447,47 +2420,47 @@ TEST_F(BasicPortAllocatorTest, AddTurnServers(kTurnUdpIntAddr, SocketAddress()); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); - allocator_->SetCandidateFilter(webrtc::CF_NONE); + allocator_->SetCandidateFilter(CF_NONE); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.empty()); EXPECT_TRUE(ports_.empty()); // Surface the relay candidate previously gathered but not signaled. - session_->SetCandidateFilter(webrtc::CF_RELAY); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(1u), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + session_->SetCandidateFilter(CF_RELAY); + ASSERT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(1u), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.back().is_relay()); EXPECT_EQ(1u, ports_.size()); // Surface the srflx candidate previously gathered but not signaled. - session_->SetCandidateFilter(webrtc::CF_RELAY | webrtc::CF_REFLEXIVE); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(2u), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + session_->SetCandidateFilter(CF_RELAY | CF_REFLEXIVE); + ASSERT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(2u), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.back().is_stun()); EXPECT_EQ(2u, ports_.size()); // Surface the srflx candidate previously gathered but not signaled. - session_->SetCandidateFilter(webrtc::CF_ALL); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(3u), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + session_->SetCandidateFilter(CF_ALL); + ASSERT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(3u), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.back().is_local()); EXPECT_EQ(2u, ports_.size()); } @@ -2509,47 +2482,47 @@ TEST_F( AddTurnServers(kTurnUdpIntAddr, SocketAddress()); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); - allocator_->SetCandidateFilter(webrtc::CF_NONE); + allocator_->SetCandidateFilter(CF_NONE); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.empty()); EXPECT_TRUE(ports_.empty()); // Surface the relay candidate previously gathered but not signaled. - session_->SetCandidateFilter(webrtc::CF_RELAY); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(1u), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + session_->SetCandidateFilter(CF_RELAY); + EXPECT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(1u), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.back().is_relay()); EXPECT_EQ(1u, ports_.size()); // Surface the srflx candidate previously gathered but not signaled. - session_->SetCandidateFilter(webrtc::CF_REFLEXIVE); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(2u), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + session_->SetCandidateFilter(CF_REFLEXIVE); + EXPECT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(2u), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.back().is_stun()); EXPECT_EQ(2u, ports_.size()); // Surface the host candidate previously gathered but not signaled. - session_->SetCandidateFilter(webrtc::CF_HOST); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidates_.size(); }, Eq(3u), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + session_->SetCandidateFilter(CF_HOST); + EXPECT_THAT( + WaitUntil([&] { return candidates_.size(); }, Eq(3u), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_TRUE(candidates_.back().is_local()); // We use a shared socket and webrtc::UDPPort handles the srflx candidate. EXPECT_EQ(2u, ports_.size()); @@ -2566,17 +2539,17 @@ TEST_F(BasicPortAllocatorTest, AddTurnServers(kTurnUdpIntAddr, SocketAddress()); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET | - webrtc::PORTALLOCATOR_DISABLE_TCP); + PORTALLOCATOR_ENABLE_SHARED_SOCKET | + PORTALLOCATOR_DISABLE_TCP); - allocator_->SetCandidateFilter(webrtc::CF_NONE); + allocator_->SetCandidateFilter(CF_NONE); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); auto test_invariants = [this]() { EXPECT_TRUE(candidates_.empty()); EXPECT_TRUE(ports_.empty()); @@ -2586,15 +2559,15 @@ TEST_F(BasicPortAllocatorTest, session_->StopGettingPorts(); - session_->SetCandidateFilter(webrtc::CF_RELAY); + session_->SetCandidateFilter(CF_RELAY); SIMULATED_WAIT(false, kDefaultAllocationTimeout, fake_clock); test_invariants(); - session_->SetCandidateFilter(webrtc::CF_RELAY | webrtc::CF_REFLEXIVE); + session_->SetCandidateFilter(CF_RELAY | CF_REFLEXIVE); SIMULATED_WAIT(false, kDefaultAllocationTimeout, fake_clock); test_invariants(); - session_->SetCandidateFilter(webrtc::CF_ALL); + session_->SetCandidateFilter(CF_ALL); SIMULATED_WAIT(false, kDefaultAllocationTimeout, fake_clock); test_invariants(); } @@ -2603,17 +2576,17 @@ TEST_F(BasicPortAllocatorTest, SetStunKeepaliveIntervalForPorts) { const int pool_size = 1; const int expected_stun_keepalive_interval = 123; AddInterface(kClientAddr); - allocator_->SetConfiguration( - allocator_->stun_servers(), allocator_->turn_servers(), pool_size, - webrtc::NO_PRUNE, nullptr, expected_stun_keepalive_interval); + allocator_->SetConfiguration(allocator_->stun_servers(), + allocator_->turn_servers(), pool_size, NO_PRUNE, + nullptr, expected_stun_keepalive_interval); auto* pooled_session = allocator_->GetPooledSession(); ASSERT_NE(nullptr, pooled_session); EXPECT_THAT( - webrtc::WaitUntil( - [&] { return pooled_session->CandidatesAllocationDone(); }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + WaitUntil([&] { return pooled_session->CandidatesAllocationDone(); }, + IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); CheckStunKeepaliveIntervalOfAllReadyPorts(pooled_session, expected_stun_keepalive_interval); } @@ -2622,21 +2595,21 @@ TEST_F(BasicPortAllocatorTest, ChangeStunKeepaliveIntervalForPortsAfterInitialConfig) { const int pool_size = 1; AddInterface(kClientAddr); - allocator_->SetConfiguration( - allocator_->stun_servers(), allocator_->turn_servers(), pool_size, - webrtc::NO_PRUNE, nullptr, 123 /* stun keepalive interval */); + allocator_->SetConfiguration(allocator_->stun_servers(), + allocator_->turn_servers(), pool_size, NO_PRUNE, + nullptr, 123 /* stun keepalive interval */); auto* pooled_session = allocator_->GetPooledSession(); ASSERT_NE(nullptr, pooled_session); EXPECT_THAT( - webrtc::WaitUntil( - [&] { return pooled_session->CandidatesAllocationDone(); }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + WaitUntil([&] { return pooled_session->CandidatesAllocationDone(); }, + IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); const int expected_stun_keepalive_interval = 321; - allocator_->SetConfiguration( - allocator_->stun_servers(), allocator_->turn_servers(), pool_size, - webrtc::NO_PRUNE, nullptr, expected_stun_keepalive_interval); + allocator_->SetConfiguration(allocator_->stun_servers(), + allocator_->turn_servers(), pool_size, NO_PRUNE, + nullptr, expected_stun_keepalive_interval); CheckStunKeepaliveIntervalOfAllReadyPorts(pooled_session, expected_stun_keepalive_interval); } @@ -2647,17 +2620,17 @@ TEST_F(BasicPortAllocatorTest, const int expected_stun_keepalive_interval = 123; AddInterface(kClientAddr); allocator_->set_flags(allocator().flags() | - webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET); - allocator_->SetConfiguration( - allocator_->stun_servers(), allocator_->turn_servers(), pool_size, - webrtc::NO_PRUNE, nullptr, expected_stun_keepalive_interval); + PORTALLOCATOR_ENABLE_SHARED_SOCKET); + allocator_->SetConfiguration(allocator_->stun_servers(), + allocator_->turn_servers(), pool_size, NO_PRUNE, + nullptr, expected_stun_keepalive_interval); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); CheckStunKeepaliveIntervalOfAllReadyPorts(session_.get(), expected_stun_keepalive_interval); } @@ -2668,17 +2641,17 @@ TEST_F(BasicPortAllocatorTest, const int expected_stun_keepalive_interval = 123; AddInterface(kClientAddr); allocator_->set_flags(allocator().flags() & - ~(webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET)); - allocator_->SetConfiguration( - allocator_->stun_servers(), allocator_->turn_servers(), pool_size, - webrtc::NO_PRUNE, nullptr, expected_stun_keepalive_interval); + ~(PORTALLOCATOR_ENABLE_SHARED_SOCKET)); + allocator_->SetConfiguration(allocator_->stun_servers(), + allocator_->turn_servers(), pool_size, NO_PRUNE, + nullptr, expected_stun_keepalive_interval); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); CheckStunKeepaliveIntervalOfAllReadyPorts(session_.get(), expected_stun_keepalive_interval); } @@ -2690,7 +2663,7 @@ TEST_F(BasicPortAllocatorTest, HostCandidateAddressIsReplacedByHostname) { // Default config uses GTURN and no NAT, so replace that with the // desired setup (NAT, STUN server, TURN server, UDP/TCP). ResetWithStunServerAndNat(kStunAddr); - turn_server_.AddInternalSocket(kTurnTcpIntAddr, webrtc::PROTO_TCP); + turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); AddTurnServers(kTurnUdpIntIPv6Addr, kTurnTcpIntIPv6Addr); @@ -2700,11 +2673,11 @@ TEST_F(BasicPortAllocatorTest, HostCandidateAddressIsReplacedByHostname) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(5u, candidates_.size()); int num_host_udp_candidates = 0; int num_host_tcp_candidates = 0; @@ -2716,7 +2689,7 @@ TEST_F(BasicPortAllocatorTest, HostCandidateAddressIsReplacedByHostname) { if (candidate.is_local()) { EXPECT_FALSE(candidate.address().hostname().empty()); EXPECT_TRUE(raddr.IsNil()); - if (candidate.protocol() == webrtc::UDP_PROTOCOL_NAME) { + if (candidate.protocol() == UDP_PROTOCOL_NAME) { ++num_host_udp_candidates; } else { ++num_host_tcp_candidates; @@ -2724,7 +2697,7 @@ TEST_F(BasicPortAllocatorTest, HostCandidateAddressIsReplacedByHostname) { } else if (candidate.is_stun()) { // For a srflx candidate, the related address should be set to 0.0.0.0 or // ::0 - EXPECT_TRUE(webrtc::IPIsAny(raddr.ipaddr())); + EXPECT_TRUE(IPIsAny(raddr.ipaddr())); EXPECT_EQ(raddr.port(), 0); ++num_srflx_candidates; } else if (candidate.is_relay()) { @@ -2770,7 +2743,7 @@ TEST_F(BasicPortAllocatorTest, TestDoNotUseTurnServerAsStunSever) { // Test that candidates from different servers get assigned a unique local // preference (the middle 16 bits of the priority) TEST_F(BasicPortAllocatorTest, AssignsUniqueLocalPreferencetoRelayCandidates) { - allocator_->SetCandidateFilter(webrtc::CF_RELAY); + allocator_->SetCandidateFilter(CF_RELAY); allocator_->AddTurnServerForTesting( CreateTurnServers(kTurnUdpIntAddr, SocketAddress())); allocator_->AddTurnServerForTesting( @@ -2781,11 +2754,11 @@ TEST_F(BasicPortAllocatorTest, AssignsUniqueLocalPreferencetoRelayCandidates) { AddInterface(kClientAddr); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - ASSERT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3u, candidates_.size()); EXPECT_GT((candidates_[0].priority() >> 8) & 0xFFFF, (candidates_[1].priority() >> 8) & 0xFFFF); @@ -2925,18 +2898,18 @@ TEST_F(BasicPortAllocatorTest, Select2DifferentIntefaces) { AddInterface(kClientIPv6Addr5, "cell1", ADAPTER_TYPE_CELLULAR_3G); // To simplify the test, only gather UDP host candidates. - allocator().set_flags( - webrtc::PORTALLOCATOR_ENABLE_IPV6 | webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_STUN | webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); + allocator().set_flags(PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(2U, candidates_.size()); // ethe1 and wifi1 were selected. @@ -2955,18 +2928,18 @@ TEST_F(BasicPortAllocatorTest, Select3DifferentIntefaces) { AddInterface(kClientIPv6Addr5, "cell1", ADAPTER_TYPE_CELLULAR_3G); // To simplify the test, only gather UDP host candidates. - allocator().set_flags( - webrtc::PORTALLOCATOR_ENABLE_IPV6 | webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_STUN | webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); + allocator().set_flags(PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(3U, candidates_.size()); // ethe1, wifi1, and cell1 were selected. @@ -2987,18 +2960,18 @@ TEST_F(BasicPortAllocatorTest, Select4DifferentIntefaces) { AddInterface(kClientIPv6Addr5, "cell1", ADAPTER_TYPE_CELLULAR_3G); // To simplify the test, only gather UDP host candidates. - allocator().set_flags( - webrtc::PORTALLOCATOR_ENABLE_IPV6 | webrtc::PORTALLOCATOR_DISABLE_TCP | - webrtc::PORTALLOCATOR_DISABLE_STUN | webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); + allocator().set_flags(PORTALLOCATOR_ENABLE_IPV6 | PORTALLOCATOR_DISABLE_TCP | + PORTALLOCATOR_DISABLE_STUN | + PORTALLOCATOR_DISABLE_RELAY | + PORTALLOCATOR_ENABLE_IPV6_ON_WIFI); ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); session_->StartGettingPorts(); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return candidate_allocation_done_; }, IsTrue(), - {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), - .clock = &fake_clock}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), + {.timeout = TimeDelta::Millis(kDefaultAllocationTimeout), + .clock = &fake_clock}), + IsRtcOk()); EXPECT_EQ(4U, candidates_.size()); // ethe1, ethe2, wifi1, and cell1 were selected. diff --git a/p2p/dtls/dtls_ice_integrationtest.cc b/p2p/dtls/dtls_ice_integrationtest.cc index d45eeda2e0..8a638faab1 100644 --- a/p2p/dtls/dtls_ice_integrationtest.cc +++ b/p2p/dtls/dtls_ice_integrationtest.cc @@ -15,7 +15,6 @@ #include #include -#include "absl/strings/str_cat.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/environment/environment.h" @@ -82,9 +81,8 @@ class DtlsIceIntegrationTest : public ::testing::TestWithParam client_certificate, const scoped_refptr server_certificate) { thread(ep)->BlockingCall([&]() { + if (!network_manager_) { + network_manager_ = + std::make_unique(Thread::Current()); + } if (network_emulation_manager_ == nullptr) { ep.allocator = std::make_unique( - ep.env, &network_manager_, socket_factory_.get()); + ep.env, network_manager_.get(), socket_factory_.get()); } else { ep.network_manager = ep.emulated_network_manager->ReleaseNetworkManager(); @@ -167,8 +169,14 @@ class DtlsIceIntegrationTest : public ::testing::TestWithParam( client ? "client_transport" : "server_transport", 0, ep.allocator.get(), &ep.env.field_trials()); + CryptoOptions crypto_options; + if (ep.pqc) { + FieldTrials field_trials("WebRTC-EnableDtlsPqc/Enabled/"); + crypto_options.ephemeral_key_exchange_cipher_groups.Update( + &field_trials); + } ep.dtls = std::make_unique( - ep.ice.get(), webrtc::CryptoOptions(), + ep.ice.get(), crypto_options, /*event_log=*/nullptr, std::get<2>(GetParam())); // Enable(or disable) the dtls_in_stun parameter before @@ -230,7 +238,7 @@ class DtlsIceIntegrationTest : public ::testing::TestWithParamAddInterface(webrtc::SocketAddress("192.168.1.1", 0)); } client_thread()->BlockingCall([&]() { client_.allocator->Initialize(); }); @@ -331,11 +339,11 @@ class DtlsIceIntegrationTest : public ::testing::TestWithParam ss_; std::unique_ptr socket_factory_; std::unique_ptr network_emulation_manager_; std::unique_ptr thread_; + std::unique_ptr network_manager_; Endpoint client_; Endpoint server_; @@ -382,7 +390,7 @@ TEST_P(DtlsIceIntegrationTest, SmokeTest) { } // Validate that we can add new Connections (that become writable). - network_manager_.AddInterface(webrtc::SocketAddress("192.168.2.1", 0)); + network_manager_->AddInterface(webrtc::SocketAddress("192.168.2.1", 0)); EXPECT_THAT(webrtc::WaitUntil( [&] { return CountWritableConnections(client_.ice.get()) > 1 && diff --git a/p2p/dtls/dtls_stun_piggyback_controller.cc b/p2p/dtls/dtls_stun_piggyback_controller.cc index 447257a52e..4cc5ffc612 100644 --- a/p2p/dtls/dtls_stun_piggyback_controller.cc +++ b/p2p/dtls/dtls_stun_piggyback_controller.cc @@ -31,8 +31,7 @@ namespace webrtc { DtlsStunPiggybackController::DtlsStunPiggybackController( - absl::AnyInvocable)> - dtls_data_callback) + absl::AnyInvocable)> dtls_data_callback) : dtls_data_callback_(std::move(dtls_data_callback)) {} DtlsStunPiggybackController::~DtlsStunPiggybackController() {} @@ -59,6 +58,17 @@ void DtlsStunPiggybackController::SetDtlsHandshakeComplete(bool is_dtls_client, state_ = State::PENDING; } +void DtlsStunPiggybackController::SetDtlsFailed() { + RTC_DCHECK_RUN_ON(&sequence_checker_); + + if (state_ == State::TENTATIVE || state_ == State::CONFIRMED || + state_ == State::PENDING) { + RTC_LOG(LS_INFO) + << "DTLS-STUN piggybacking DTLS failed during negotiation."; + } + state_ = State::OFF; +} + void DtlsStunPiggybackController::CapturePacket(ArrayView data) { RTC_DCHECK_RUN_ON(&sequence_checker_); if (!IsDtlsPacket(data)) { diff --git a/p2p/dtls/dtls_stun_piggyback_controller.h b/p2p/dtls/dtls_stun_piggyback_controller.h index 13a422d72e..9f9c3e9868 100644 --- a/p2p/dtls/dtls_stun_piggyback_controller.h +++ b/p2p/dtls/dtls_stun_piggyback_controller.h @@ -62,8 +62,10 @@ class DtlsStunPiggybackController { return state_; } - // Called by DtlsTransport when handshake is complete. + // Called by DtlsTransport when the handshake is complete. void SetDtlsHandshakeComplete(bool is_dtls_client, bool is_dtls13); + // Called by DtlsTransport when DTLS failed. + void SetDtlsFailed(); // Intercepts DTLS packets which should go into the STUN packets during the // handshake. diff --git a/p2p/dtls/dtls_transport.cc b/p2p/dtls/dtls_transport.cc index f8d118a8ac..bcbf7ec681 100644 --- a/p2p/dtls/dtls_transport.cc +++ b/p2p/dtls/dtls_transport.cc @@ -59,24 +59,24 @@ namespace webrtc { template -void AbslStringify(Sink& sink, webrtc::DtlsTransportState state) { +void AbslStringify(Sink& sink, DtlsTransportState state) { switch (state) { - case webrtc::DtlsTransportState::kNew: + case DtlsTransportState::kNew: sink.Append("kNew"); break; - case webrtc::DtlsTransportState::kConnecting: + case DtlsTransportState::kConnecting: sink.Append("kConnecting"); break; - case webrtc::DtlsTransportState::kConnected: + case DtlsTransportState::kConnected: sink.Append("kConnected"); break; - case webrtc::DtlsTransportState::kClosed: + case DtlsTransportState::kClosed: sink.Append("kClosed"); break; - case webrtc::DtlsTransportState::kFailed: + case DtlsTransportState::kFailed: sink.Append("kFailed"); break; - case webrtc::DtlsTransportState::kNumValues: + case DtlsTransportState::kNumValues: sink.Append("kNumValues"); break; } @@ -107,13 +107,13 @@ static bool IsRtpPacket(ArrayView payload) { } StreamInterfaceChannel::StreamInterfaceChannel( - webrtc::IceTransportInternal* ice_transport) + IceTransportInternal* ice_transport) : ice_transport_(ice_transport), - state_(webrtc::SS_OPEN), - packets_(kMaxPendingPackets, webrtc::kMaxDtlsPacketLen) {} + state_(SS_OPEN), + packets_(kMaxPendingPackets, kMaxDtlsPacketLen) {} void StreamInterfaceChannel::SetDtlsStunPiggybackController( - webrtc::DtlsStunPiggybackController* dtls_stun_piggyback_controller) { + DtlsStunPiggybackController* dtls_stun_piggyback_controller) { dtls_stun_piggyback_controller_ = dtls_stun_piggyback_controller; } @@ -122,16 +122,16 @@ StreamResult StreamInterfaceChannel::Read(ArrayView buffer, int& /* error */) { RTC_DCHECK_RUN_ON(&callback_sequence_); - if (state_ == webrtc::SS_CLOSED) - return webrtc::SR_EOS; - if (state_ == webrtc::SS_OPENING) - return webrtc::SR_BLOCK; + if (state_ == SS_CLOSED) + return SR_EOS; + if (state_ == SS_OPENING) + return SR_BLOCK; if (!packets_.ReadFront(buffer.data(), buffer.size(), &read)) { - return webrtc::SR_BLOCK; + return SR_BLOCK; } - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } StreamResult StreamInterfaceChannel::Write(ArrayView data, @@ -149,7 +149,7 @@ StreamResult StreamInterfaceChannel::Write(ArrayView data, ice_transport_->SendPacket(reinterpret_cast(data.data()), data.size(), packet_options); written = data.size(); - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } bool StreamInterfaceChannel::Flush() { @@ -166,7 +166,7 @@ bool StreamInterfaceChannel::OnPacketReceived(const char* data, size_t size) { if (packets_.size() > 0) { RTC_LOG(LS_WARNING) << "Packet already in queue."; } - bool ret = packets_.WriteBack(data, size, NULL); + bool ret = packets_.WriteBack(data, size, nullptr); if (!ret) { // Somehow we received another packet before the SSLStreamAdapter read the // previous one out of our temporary buffer. In this case, we'll log an @@ -174,7 +174,7 @@ bool StreamInterfaceChannel::OnPacketReceived(const char* data, size_t size) { // packet currently in packets_. RTC_LOG(LS_ERROR) << "Failed to write packet to queue."; } - FireEvent(webrtc::SE_READ, 0); + FireEvent(SE_READ, 0); return ret; } @@ -186,18 +186,20 @@ StreamState StreamInterfaceChannel::GetState() const { void StreamInterfaceChannel::Close() { RTC_DCHECK_RUN_ON(&callback_sequence_); packets_.Clear(); - state_ = webrtc::SS_CLOSED; + state_ = SS_CLOSED; } DtlsTransportInternalImpl::DtlsTransportInternalImpl( - webrtc::IceTransportInternal* ice_transport, - const webrtc::CryptoOptions& crypto_options, - webrtc::RtcEventLog* event_log, - webrtc::SSLProtocolVersion max_version) + IceTransportInternal* ice_transport, + const CryptoOptions& crypto_options, + RtcEventLog* event_log, + SSLProtocolVersion max_version) : component_(ice_transport->component()), ice_transport_(ice_transport), downward_(nullptr), srtp_ciphers_(crypto_options.GetSupportedDtlsSrtpCryptoSuites()), + ephemeral_key_exchange_cipher_groups_( + crypto_options.ephemeral_key_exchange_cipher_groups.GetEnabled()), ssl_max_version_(max_version), event_log_(event_log), dtls_stun_piggyback_controller_( @@ -206,8 +208,8 @@ DtlsTransportInternalImpl::DtlsTransportInternalImpl( return; } piggybacked_dtls_callback_( - this, ReceivedIpPacket(piggybacked_dtls_packet, - webrtc::SocketAddress())); + this, + ReceivedIpPacket(piggybacked_dtls_packet, SocketAddress())); }) { RTC_DCHECK(ice_transport_); ConnectToIceTransport(); @@ -227,7 +229,7 @@ DtlsTransportInternalImpl::~DtlsTransportInternalImpl() { } } -webrtc::DtlsTransportState DtlsTransportInternalImpl::dtls_state() const { +DtlsTransportState DtlsTransportInternalImpl::dtls_state() const { return dtls_state_; } @@ -244,7 +246,7 @@ bool DtlsTransportInternalImpl::IsDtlsActive() const { } bool DtlsTransportInternalImpl::SetLocalCertificate( - const scoped_refptr& certificate) { + const scoped_refptr& certificate) { if (dtls_active_) { if (certificate == local_certificate_) { // This may happen during renegotiation. @@ -268,12 +270,12 @@ bool DtlsTransportInternalImpl::SetLocalCertificate( return true; } -scoped_refptr -DtlsTransportInternalImpl::GetLocalCertificate() const { +scoped_refptr DtlsTransportInternalImpl::GetLocalCertificate() + const { return local_certificate_; } -bool DtlsTransportInternalImpl::SetDtlsRole(webrtc::SSLRole role) { +bool DtlsTransportInternalImpl::SetDtlsRole(SSLRole role) { if (dtls_) { RTC_DCHECK(dtls_role_); if (*dtls_role_ != role) { @@ -288,7 +290,7 @@ bool DtlsTransportInternalImpl::SetDtlsRole(webrtc::SSLRole role) { return true; } -bool DtlsTransportInternalImpl::GetDtlsRole(webrtc::SSLRole* role) const { +bool DtlsTransportInternalImpl::GetDtlsRole(SSLRole* role) const { if (!dtls_role_) { return false; } @@ -297,7 +299,7 @@ bool DtlsTransportInternalImpl::GetDtlsRole(webrtc::SSLRole* role) const { } bool DtlsTransportInternalImpl::GetSslCipherSuite(int* cipher) const { - if (dtls_state() != webrtc::DtlsTransportState::kConnected) { + if (dtls_state() != DtlsTransportState::kConnected) { return false; } @@ -306,17 +308,17 @@ bool DtlsTransportInternalImpl::GetSslCipherSuite(int* cipher) const { std::optional DtlsTransportInternalImpl::GetTlsCipherSuiteName() const { - if (dtls_state() != webrtc::DtlsTransportState::kConnected) { + if (dtls_state() != DtlsTransportState::kConnected) { return std::nullopt; } return dtls_->GetTlsCipherSuiteName(); } -webrtc::RTCError DtlsTransportInternalImpl::SetRemoteParameters( +RTCError DtlsTransportInternalImpl::SetRemoteParameters( absl::string_view digest_alg, const uint8_t* digest, size_t digest_len, - std::optional role) { + std::optional role) { Buffer remote_fingerprint_value(digest, digest_len); bool is_dtls_restart = dtls_active_ && remote_fingerprint_value_ != remote_fingerprint_value; @@ -327,17 +329,17 @@ webrtc::RTCError DtlsTransportInternalImpl::SetRemoteParameters( dtls_role_ = *role; } else { if (!SetDtlsRole(*role)) { - return webrtc::RTCError(webrtc::RTCErrorType::INVALID_PARAMETER, - "Failed to set SSL role for the transport."); + return RTCError(RTCErrorType::INVALID_PARAMETER, + "Failed to set SSL role for the transport."); } } } // Apply remote fingerprint. if (!SetRemoteFingerprint(digest_alg, digest, digest_len)) { - return webrtc::RTCError(webrtc::RTCErrorType::INVALID_PARAMETER, - "Failed to apply remote fingerprint."); + return RTCError(RTCErrorType::INVALID_PARAMETER, + "Failed to apply remote fingerprint."); } - return webrtc::RTCError::OK(); + return RTCError::OK(); } bool DtlsTransportInternalImpl::SetRemoteFingerprint( @@ -385,17 +387,17 @@ bool DtlsTransportInternalImpl::SetRemoteFingerprint( // This can occur if DTLS is set up before a remote fingerprint is // received. For instance, if we set up DTLS due to receiving an early // ClientHello. - webrtc::SSLPeerCertificateDigestError err = dtls_->SetPeerCertificateDigest( + SSLPeerCertificateDigestError err = dtls_->SetPeerCertificateDigest( remote_fingerprint_algorithm_, remote_fingerprint_value_); - if (err != webrtc::SSLPeerCertificateDigestError::NONE) { + if (err != SSLPeerCertificateDigestError::NONE) { RTC_LOG(LS_ERROR) << ToString() << ": Couldn't set DTLS certificate digest."; - set_dtls_state(webrtc::DtlsTransportState::kFailed); + set_dtls_state(DtlsTransportState::kFailed); // If the error is "verification failed", don't return false, because // this means the fingerprint was formatted correctly but didn't match // the certificate from the DTLS handshake. Thus the DTLS state should go // to "failed", but SetRemoteDescription shouldn't fail. - return err == webrtc::SSLPeerCertificateDigestError::VERIFICATION_FAILED; + return err == SSLPeerCertificateDigestError::VERIFICATION_FAILED; } return true; } @@ -404,20 +406,20 @@ bool DtlsTransportInternalImpl::SetRemoteFingerprint( // create a new one, resetting our state. if (dtls_ && fingerprint_changing) { dtls_.reset(nullptr); - set_dtls_state(webrtc::DtlsTransportState::kNew); + set_dtls_state(DtlsTransportState::kNew); set_writable(false); } if (!SetupDtls()) { - set_dtls_state(webrtc::DtlsTransportState::kFailed); + set_dtls_state(DtlsTransportState::kFailed); return false; } return true; } -std::unique_ptr -DtlsTransportInternalImpl::GetRemoteSSLCertChain() const { +std::unique_ptr DtlsTransportInternalImpl::GetRemoteSSLCertChain() + const { if (!dtls_) { return nullptr; } @@ -442,7 +444,7 @@ bool DtlsTransportInternalImpl::SetupDtls() { downward_ptr->SetDtlsStunPiggybackController( &dtls_stun_piggyback_controller_); } - dtls_ = webrtc::SSLStreamAdapter::Create( + dtls_ = SSLStreamAdapter::Create( std::move(downward), [this](SSLHandshakeError error) { OnDtlsHandshakeError(error); }, ice_transport_->field_trials()); @@ -471,7 +473,7 @@ bool DtlsTransportInternalImpl::SetupDtls() { if (remote_fingerprint_value_.size() && dtls_->SetPeerCertificateDigest(remote_fingerprint_algorithm_, remote_fingerprint_value_) != - webrtc::SSLPeerCertificateDigestError::NONE) { + SSLPeerCertificateDigestError::NONE) { RTC_LOG(LS_ERROR) << ToString() << ": Couldn't set DTLS certificate digest."; return false; @@ -487,6 +489,11 @@ bool DtlsTransportInternalImpl::SetupDtls() { RTC_LOG(LS_INFO) << ToString() << ": Not using DTLS-SRTP."; } + if (!dtls_->SetSslGroupIds(ephemeral_key_exchange_cipher_groups_)) { + RTC_LOG(LS_ERROR) << ToString() << ": Couldn't set DTLS SSL Group Ids."; + return false; + } + RTC_LOG(LS_INFO) << ToString() << ": DTLS setup complete, dtls_in_stun: " << dtls_in_stun_; @@ -497,7 +504,7 @@ bool DtlsTransportInternalImpl::SetupDtls() { } bool DtlsTransportInternalImpl::GetSrtpCryptoSuite(int* cipher) const { - if (dtls_state() != webrtc::DtlsTransportState::kConnected) { + if (dtls_state() != DtlsTransportState::kConnected) { return false; } @@ -505,16 +512,20 @@ bool DtlsTransportInternalImpl::GetSrtpCryptoSuite(int* cipher) const { } bool DtlsTransportInternalImpl::GetSslVersionBytes(int* version) const { - if (dtls_state() != webrtc::DtlsTransportState::kConnected) { + if (dtls_state() != DtlsTransportState::kConnected) { return false; } return dtls_->GetSslVersionBytes(version); } +uint16_t DtlsTransportInternalImpl::GetSslGroupId() const { + return dtls_->GetSslGroupId(); +} + uint16_t DtlsTransportInternalImpl::GetSslPeerSignatureAlgorithm() const { - if (dtls_state() != webrtc::DtlsTransportState::kConnected) { - return webrtc::kSslSignatureAlgorithmUnknown; // "not applicable" + if (dtls_state() != DtlsTransportState::kConnected) { + return kSslSignatureAlgorithmUnknown; // "not applicable" } return dtls_->GetPeerSignatureAlgorithm(); } @@ -531,15 +542,15 @@ int DtlsTransportInternalImpl::SendPacket( } switch (dtls_state()) { - case webrtc::DtlsTransportState::kNew: + case DtlsTransportState::kNew: // Can't send data until the connection is active. // TODO(ekr@rtfm.com): assert here if dtls_ is NULL? return -1; - case webrtc::DtlsTransportState::kConnecting: + case DtlsTransportState::kConnecting: // Can't send data until the connection is active. return -1; - case webrtc::DtlsTransportState::kConnected: - if (flags & webrtc::PF_SRTP_BYPASS) { + case DtlsTransportState::kConnected: + if (flags & PF_SRTP_BYPASS) { RTC_DCHECK(!srtp_ciphers_.empty()); if (!IsRtpPacket( MakeArrayView(reinterpret_cast(data), size))) { @@ -552,17 +563,17 @@ int DtlsTransportInternalImpl::SendPacket( int error; return (dtls_->WriteAll( MakeArrayView(reinterpret_cast(data), size), - written, error) == webrtc::SR_SUCCESS) + written, error) == SR_SUCCESS) ? static_cast(size) : -1; } - case webrtc::DtlsTransportState::kFailed: + case DtlsTransportState::kFailed: // Can't send anything when we're failed. RTC_LOG(LS_ERROR) << ToString() << ": Couldn't send packet due to " "webrtc::DtlsTransportState::kFailed."; return -1; - case webrtc::DtlsTransportState::kClosed: + case DtlsTransportState::kClosed: // Can't send anything when we're closed. RTC_LOG(LS_ERROR) << ToString() << ": Couldn't send packet due to " @@ -574,7 +585,7 @@ int DtlsTransportInternalImpl::SendPacket( } } -webrtc::IceTransportInternal* DtlsTransportInternalImpl::ice_transport() { +IceTransportInternal* DtlsTransportInternalImpl::ice_transport() { return ice_transport_; } @@ -594,18 +605,15 @@ int DtlsTransportInternalImpl::GetError() { return ice_transport_->GetError(); } -std::optional DtlsTransportInternalImpl::network_route() - const { +std::optional DtlsTransportInternalImpl::network_route() const { return ice_transport_->network_route(); } -bool DtlsTransportInternalImpl::GetOption(webrtc::Socket::Option opt, - int* value) { +bool DtlsTransportInternalImpl::GetOption(Socket::Option opt, int* value) { return ice_transport_->GetOption(opt, value); } -int DtlsTransportInternalImpl::SetOption(webrtc::Socket::Option opt, - int value) { +int DtlsTransportInternalImpl::SetOption(Socket::Option opt, int value) { return ice_transport_->SetOption(opt, value); } @@ -628,7 +636,7 @@ void DtlsTransportInternalImpl::ConnectToIceTransport() { ice_transport_->SignalNetworkRouteChanged.connect( this, &DtlsTransportInternalImpl::OnNetworkRouteChanged); ice_transport_->SetDtlsStunPiggybackCallbacks( - webrtc::DtlsStunPiggybackCallbacks( + DtlsStunPiggybackCallbacks( [&](auto stun_message_type) { std::optional data; std::optional ack; @@ -649,12 +657,12 @@ void DtlsTransportInternalImpl::ConnectToIceTransport() { SetPiggybackDtlsDataCallback([this](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { RTC_DCHECK(dtls_active_); - RTC_DCHECK(webrtc::IsDtlsPacket(packet.payload())); + RTC_DCHECK(IsDtlsPacket(packet.payload())); if (!dtls_active_) { // Not doing DTLS. return; } - if (!webrtc::IsDtlsPacket(packet.payload())) { + if (!IsDtlsPacket(packet.payload())) { return; } OnReadPacket(ice_transport_, packet, /* piggybacked= */ true); @@ -672,7 +680,7 @@ void DtlsTransportInternalImpl::ConnectToIceTransport() { // - Once the DTLS handshake completes, the state is that of the // impl again void DtlsTransportInternalImpl::OnWritableState( - webrtc::PacketTransportInternal* transport) { + PacketTransportInternal* transport) { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(transport == ice_transport_); RTC_LOG(LS_INFO) << ToString() << ": ice_transport writable state changed to " @@ -695,10 +703,10 @@ void DtlsTransportInternalImpl::OnWritableState( } switch (dtls_state()) { - case webrtc::DtlsTransportState::kNew: + case DtlsTransportState::kNew: MaybeStartDtls(); break; - case webrtc::DtlsTransportState::kConnected: + case DtlsTransportState::kConnected: // Note: SignalWritableState fired by set_writable. if (dtls_in_stun_ && dtls_ && first_ice_writable) { // Dtls1.3 has one remaining packet after it has become kConnected (?), @@ -708,7 +716,7 @@ void DtlsTransportInternalImpl::OnWritableState( } set_writable(ice_transport_->writable()); break; - case webrtc::DtlsTransportState::kConnecting: + case DtlsTransportState::kConnecting: if (dtls_in_stun_ && dtls_) { // If DTLS piggybacking is enabled, we set the timeout // on the DTLS object (which is then different from the @@ -717,42 +725,41 @@ void DtlsTransportInternalImpl::OnWritableState( PeriodicRetransmitDtlsPacketUntilDtlsConnected(); } break; - case webrtc::DtlsTransportState::kFailed: + case DtlsTransportState::kFailed: // Should not happen. Do nothing. RTC_LOG(LS_ERROR) << ToString() << ": OnWritableState() called in state " "webrtc::DtlsTransportState::kFailed."; break; - case webrtc::DtlsTransportState::kClosed: + case DtlsTransportState::kClosed: // Should not happen. Do nothing. RTC_LOG(LS_ERROR) << ToString() << ": OnWritableState() called in state " "webrtc::DtlsTransportState::kClosed."; break; - case webrtc::DtlsTransportState::kNumValues: + case DtlsTransportState::kNumValues: RTC_DCHECK_NOTREACHED(); break; } } void DtlsTransportInternalImpl::OnReceivingState( - webrtc::PacketTransportInternal* transport) { + PacketTransportInternal* transport) { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(transport == ice_transport_); RTC_LOG(LS_VERBOSE) << ToString() << ": ice_transport " "receiving state changed to " << ice_transport_->receiving(); - if (!dtls_active_ || dtls_state() == webrtc::DtlsTransportState::kConnected) { + if (!dtls_active_ || dtls_state() == DtlsTransportState::kConnected) { // Note: SignalReceivingState fired by set_receiving. set_receiving(ice_transport_->receiving()); } } -void DtlsTransportInternalImpl::OnReadPacket( - webrtc::PacketTransportInternal* transport, - const ReceivedIpPacket& packet, - bool piggybacked) { +void DtlsTransportInternalImpl::OnReadPacket(PacketTransportInternal* transport, + const ReceivedIpPacket& packet, + bool piggybacked) { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(transport == ice_transport_); @@ -763,7 +770,7 @@ void DtlsTransportInternalImpl::OnReadPacket( } switch (dtls_state()) { - case webrtc::DtlsTransportState::kNew: + case DtlsTransportState::kNew: if (dtls_) { RTC_LOG(LS_INFO) << ToString() << ": Packet received before DTLS started."; @@ -773,7 +780,7 @@ void DtlsTransportInternalImpl::OnReadPacket( "doing DTLS or not."; } // Cache a client hello packet received before DTLS has actually started. - if (webrtc::IsDtlsClientHelloPacket(packet.payload())) { + if (IsDtlsClientHelloPacket(packet.payload())) { RTC_LOG(LS_INFO) << ToString() << ": Caching DTLS ClientHello packet until DTLS is " "started."; @@ -784,7 +791,7 @@ void DtlsTransportInternalImpl::OnReadPacket( // the peer has chosen the client role, and proceed with the handshake. // The fingerprint will be verified when it's set. if (!dtls_ && local_certificate_) { - SetDtlsRole(webrtc::SSL_SERVER); + SetDtlsRole(SSL_SERVER); SetupDtls(); } } else { @@ -793,18 +800,18 @@ void DtlsTransportInternalImpl::OnReadPacket( } break; - case webrtc::DtlsTransportState::kConnecting: - case webrtc::DtlsTransportState::kConnected: + case DtlsTransportState::kConnecting: + case DtlsTransportState::kConnected: // We should only get DTLS or SRTP packets; STUN's already been demuxed. // Is this potentially a DTLS packet? - if (webrtc::IsDtlsPacket(packet.payload())) { + if (IsDtlsPacket(packet.payload())) { if (!HandleDtlsPacket(packet.payload())) { RTC_LOG(LS_ERROR) << ToString() << ": Failed to handle DTLS packet."; return; } } else { // Not a DTLS packet; our handshake should be complete by now. - if (dtls_state() != webrtc::DtlsTransportState::kConnected) { + if (dtls_state() != DtlsTransportState::kConnected) { RTC_LOG(LS_ERROR) << ToString() << ": Received non-DTLS packet before DTLS " "complete."; @@ -826,23 +833,23 @@ void DtlsTransportInternalImpl::OnReadPacket( packet.CopyAndSet(ReceivedIpPacket::kSrtpEncrypted)); } break; - case webrtc::DtlsTransportState::kFailed: - case webrtc::DtlsTransportState::kClosed: - case webrtc::DtlsTransportState::kNumValues: + case DtlsTransportState::kFailed: + case DtlsTransportState::kClosed: + case DtlsTransportState::kNumValues: // This shouldn't be happening. Drop the packet. break; } } void DtlsTransportInternalImpl::OnSentPacket( - webrtc::PacketTransportInternal* /* transport */, + PacketTransportInternal* /* transport */, const SentPacketInfo& sent_packet) { RTC_DCHECK_RUN_ON(&thread_checker_); SignalSentPacket(this, sent_packet); } void DtlsTransportInternalImpl::OnReadyToSend( - webrtc::PacketTransportInternal* /* transport */) { + PacketTransportInternal* /* transport */) { RTC_DCHECK_RUN_ON(&thread_checker_); if (writable()) { SignalReadyToSend(this); @@ -853,25 +860,24 @@ void DtlsTransportInternalImpl::OnDtlsEvent(int sig, int err) { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(dtls_); - if (sig & webrtc::SE_OPEN) { + if (sig & SE_OPEN) { // This is the first time. RTC_LOG(LS_INFO) << ToString() << ": DTLS handshake complete."; // The check for OPEN shouldn't be necessary but let's make // sure we don't accidentally frob the state if it's closed. - if (dtls_->GetState() == webrtc::SS_OPEN) { + if (dtls_->GetState() == SS_OPEN) { int ssl_version_bytes; bool ret = dtls_->GetSslVersionBytes(&ssl_version_bytes); RTC_DCHECK(ret); dtls_stun_piggyback_controller_.SetDtlsHandshakeComplete( - dtls_role_ == webrtc::SSL_CLIENT, - ssl_version_bytes == webrtc::kDtls13VersionBytes); + dtls_role_ == SSL_CLIENT, ssl_version_bytes == kDtls13VersionBytes); downward_->SetDtlsStunPiggybackController(nullptr); - set_dtls_state(webrtc::DtlsTransportState::kConnected); + set_dtls_state(DtlsTransportState::kConnected); set_writable(true); } } - if (sig & webrtc::SE_READ) { - uint8_t buf[webrtc::kMaxDtlsPacketLen]; + if (sig & SE_READ) { + uint8_t buf[kMaxDtlsPacketLen]; size_t read; int read_error; StreamResult ret; @@ -879,47 +885,47 @@ void DtlsTransportInternalImpl::OnDtlsEvent(int sig, int err) { // one packet, so read all of them. do { ret = dtls_->Read(buf, read, read_error); - if (ret == webrtc::SR_SUCCESS) { + if (ret == SR_SUCCESS) { // TODO(bugs.webrtc.org/15368): It should be possible to use information // from the original packet here to populate socket address and // timestamp. NotifyPacketReceived(ReceivedIpPacket( - MakeArrayView(buf, read), webrtc::SocketAddress(), - webrtc::Timestamp::Micros(webrtc::TimeMicros()), - EcnMarking::kNotEct, ReceivedIpPacket::kDtlsDecrypted)); - } else if (ret == webrtc::SR_EOS) { + MakeArrayView(buf, read), SocketAddress(), + Timestamp::Micros(TimeMicros()), EcnMarking::kNotEct, + ReceivedIpPacket::kDtlsDecrypted)); + } else if (ret == SR_EOS) { // Remote peer shut down the association with no error. RTC_LOG(LS_INFO) << ToString() << ": DTLS transport closed by remote"; set_writable(false); - set_dtls_state(webrtc::DtlsTransportState::kClosed); + set_dtls_state(DtlsTransportState::kClosed); NotifyOnClose(); - } else if (ret == webrtc::SR_ERROR) { + } else if (ret == SR_ERROR) { // Remote peer shut down the association with an error. RTC_LOG(LS_INFO) << ToString() << ": Closed by remote with DTLS transport error, code=" << read_error; set_writable(false); - set_dtls_state(webrtc::DtlsTransportState::kFailed); + set_dtls_state(DtlsTransportState::kFailed); NotifyOnClose(); } - } while (ret == webrtc::SR_SUCCESS); + } while (ret == SR_SUCCESS); } - if (sig & webrtc::SE_CLOSE) { - RTC_DCHECK(sig == webrtc::SE_CLOSE); // SE_CLOSE should be by itself. + if (sig & SE_CLOSE) { + RTC_DCHECK(sig == SE_CLOSE); // SE_CLOSE should be by itself. set_writable(false); if (!err) { RTC_LOG(LS_INFO) << ToString() << ": DTLS transport closed"; - set_dtls_state(webrtc::DtlsTransportState::kClosed); + set_dtls_state(DtlsTransportState::kClosed); } else { RTC_LOG(LS_INFO) << ToString() << ": DTLS transport error, code=" << err; - set_dtls_state(webrtc::DtlsTransportState::kFailed); + set_dtls_state(DtlsTransportState::kFailed); } } } void DtlsTransportInternalImpl::OnNetworkRouteChanged( - std::optional network_route) { + std::optional network_route) { RTC_DCHECK_RUN_ON(&thread_checker_); SignalNetworkRouteChanged(network_route); } @@ -940,7 +946,7 @@ void DtlsTransportInternalImpl::MaybeStartDtls() { // configuration and therefore are our fault. RTC_DCHECK_NOTREACHED() << "StartSSL failed."; RTC_LOG(LS_ERROR) << ToString() << ": Couldn't start DTLS handshake"; - set_dtls_state(webrtc::DtlsTransportState::kFailed); + set_dtls_state(DtlsTransportState::kFailed); return; } RTC_LOG(LS_INFO) @@ -948,11 +954,11 @@ void DtlsTransportInternalImpl::MaybeStartDtls() { << ": DtlsTransportInternalImpl: Started DTLS handshake active=" << IsDtlsActive() << " role=" << (*dtls_role_ == SSL_SERVER ? "server" : "client"); - set_dtls_state(webrtc::DtlsTransportState::kConnecting); + set_dtls_state(DtlsTransportState::kConnecting); // Now that the handshake has started, we can process a cached ClientHello // (if one exists). if (!cached_client_hello_.empty()) { - if (*dtls_role_ == webrtc::SSL_SERVER) { + if (*dtls_role_ == SSL_SERVER) { int size = cached_client_hello_.size(); RTC_LOG(LS_INFO) << ToString() << ": Handling #" << size << " cached DTLS ClientHello packet(s)."; @@ -1005,8 +1011,7 @@ void DtlsTransportInternalImpl::set_writable(bool writable) { } if (event_log_) { - event_log_->Log( - std::make_unique(writable)); + event_log_->Log(std::make_unique(writable)); } RTC_LOG(LS_VERBOSE) << ToString() << ": set_writable to: " << writable; writable_ = writable; @@ -1016,24 +1021,24 @@ void DtlsTransportInternalImpl::set_writable(bool writable) { SignalWritableState(this); } -void DtlsTransportInternalImpl::set_dtls_state( - webrtc::DtlsTransportState state) { +void DtlsTransportInternalImpl::set_dtls_state(DtlsTransportState state) { if (dtls_state_ == state) { return; } if (event_log_) { - event_log_->Log( - std::make_unique(state)); + event_log_->Log(std::make_unique(state)); } RTC_LOG(LS_VERBOSE) << ToString() << ": set_dtls_state from:" << static_cast(dtls_state_) << " to " << static_cast(state); dtls_state_ = state; + if (dtls_state_ == DtlsTransportState::kFailed) { + dtls_stun_piggyback_controller_.SetDtlsFailed(); + } SendDtlsState(this, state); } -void DtlsTransportInternalImpl::OnDtlsHandshakeError( - webrtc::SSLHandshakeError error) { +void DtlsTransportInternalImpl::OnDtlsHandshakeError(SSLHandshakeError error) { SendDtlsHandshakeError(error); } @@ -1067,8 +1072,8 @@ void DtlsTransportInternalImpl::ConfigureHandshakeTimeout() { } void DtlsTransportInternalImpl::SetPiggybackDtlsDataCallback( - absl::AnyInvocable callback) { + absl::AnyInvocable callback) { RTC_DCHECK(callback == nullptr || !piggybacked_dtls_callback_); piggybacked_dtls_callback_ = std::move(callback); } @@ -1077,17 +1082,16 @@ bool DtlsTransportInternalImpl::IsDtlsPiggybackSupportedByPeer() { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(ice_transport_); return dtls_in_stun_ && (dtls_stun_piggyback_controller_.state() != - webrtc::DtlsStunPiggybackController::State::OFF); + DtlsStunPiggybackController::State::OFF); } bool DtlsTransportInternalImpl::WasDtlsCompletedByPiggybacking() { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(ice_transport_); - return dtls_in_stun_ && - (dtls_stun_piggyback_controller_.state() == - webrtc::DtlsStunPiggybackController::State::COMPLETE || - dtls_stun_piggyback_controller_.state() == - webrtc::DtlsStunPiggybackController::State::PENDING); + return dtls_in_stun_ && (dtls_stun_piggyback_controller_.state() == + DtlsStunPiggybackController::State::COMPLETE || + dtls_stun_piggyback_controller_.state() == + DtlsStunPiggybackController::State::PENDING); } // TODO (jonaso, webrtc:367395350): Switch to upcoming @@ -1106,7 +1110,7 @@ void DtlsTransportInternalImpl:: } if (ice_transport_->writable() && dtls_in_stun_) { auto data_to_send = dtls_stun_piggyback_controller_.GetDataToPiggyback( - webrtc::STUN_BINDING_INDICATION); + STUN_BINDING_INDICATION); if (!data_to_send) { // No data to send, we're done. return; @@ -1121,15 +1125,15 @@ void DtlsTransportInternalImpl:: // Set pending before we post task. pending_periodic_retransmit_dtls_packet_ = true; - webrtc::Thread::Current()->PostDelayedHighPrecisionTask( - webrtc::SafeTask(safety_flag_.flag(), - [this] { - RTC_DCHECK_RUN_ON(&thread_checker_); - // Clear pending then the PostTask runs. - pending_periodic_retransmit_dtls_packet_ = false; - PeriodicRetransmitDtlsPacketUntilDtlsConnected(); - }), - webrtc::TimeDelta::Millis(delay_ms)); + Thread::Current()->PostDelayedHighPrecisionTask( + SafeTask(safety_flag_.flag(), + [this] { + RTC_DCHECK_RUN_ON(&thread_checker_); + // Clear pending then the PostTask runs. + pending_periodic_retransmit_dtls_packet_ = false; + PeriodicRetransmitDtlsPacketUntilDtlsConnected(); + }), + TimeDelta::Millis(delay_ms)); RTC_LOG(LS_INFO) << ToString() << ": Scheduled retransmit of DTLS packet, delay_ms: " << delay_ms; diff --git a/p2p/dtls/dtls_transport.h b/p2p/dtls/dtls_transport.h index 1f099ee757..a7fb055adb 100644 --- a/p2p/dtls/dtls_transport.h +++ b/p2p/dtls/dtls_transport.h @@ -178,6 +178,9 @@ class DtlsTransportInternalImpl : public webrtc::DtlsTransportInternal { // Find out which TLS version was negotiated bool GetSslVersionBytes(int* version) const override; + // Return the the ID of the group used by the adapters most recently + // completed handshake, or 0 if not applicable (e.g. before the handshake). + uint16_t GetSslGroupId() const override; // Find out which DTLS-SRTP cipher was negotiated bool GetSrtpCryptoSuite(int* cipher) const override; @@ -280,6 +283,8 @@ class DtlsTransportInternalImpl : public webrtc::DtlsTransportInternal { StreamInterfaceChannel* downward_; // Wrapper for ice_transport_, owned by dtls_. const std::vector srtp_ciphers_; // SRTP ciphers to use with DTLS. + // Cipher groups used for DTLS handshake to establish ephemeral key. + const std::vector ephemeral_key_exchange_cipher_groups_; bool dtls_active_ = false; scoped_refptr local_certificate_; std::optional dtls_role_; diff --git a/p2p/dtls/dtls_transport_internal.h b/p2p/dtls/dtls_transport_internal.h index df17ac600f..c5df3c51cf 100644 --- a/p2p/dtls/dtls_transport_internal.h +++ b/p2p/dtls/dtls_transport_internal.h @@ -64,6 +64,9 @@ class DtlsTransportInternal : public PacketTransportInternal { // Finds out which TLS/DTLS version is running. virtual bool GetSslVersionBytes(int* version) const = 0; + // Return the the ID of the group used by the adapters most recently + // completed handshake, or 0 if not applicable (e.g. before the handshake). + virtual uint16_t GetSslGroupId() const = 0; // Finds out which DTLS-SRTP cipher was negotiated. // TODO(zhihuang): Remove this once all dependencies implement this. virtual bool GetSrtpCryptoSuite(int* cipher) const = 0; diff --git a/p2p/dtls/dtls_transport_unittest.cc b/p2p/dtls/dtls_transport_unittest.cc index 0440516458..0fc2814016 100644 --- a/p2p/dtls/dtls_transport_unittest.cc +++ b/p2p/dtls/dtls_transport_unittest.cc @@ -28,6 +28,7 @@ #include "api/array_view.h" #include "api/crypto/crypto_options.h" #include "api/dtls_transport_interface.h" +#include "api/field_trials.h" #include "api/scoped_refptr.h" #include "api/test/rtc_error_matchers.h" #include "api/transport/stun.h" @@ -107,19 +108,19 @@ class DtlsTestClient : public sigslot::has_slots<> { void set_async_delay(int async_delay_ms) { async_delay_ms_ = async_delay_ms; } // Set up fake ICE transport and real DTLS transport under test. - void SetupTransports(IceRole role, - bool rtt_estimate = true, - absl::string_view field_trials_string = "") { + void SetupTransports(IceRole role, bool rtt_estimate = true) { dtls_transport_ = nullptr; fake_ice_transport_ = nullptr; - if (field_trials_string.empty() && pqc_) { - field_trials_string = "WebRTC-EnableDtlsPqc/Enabled/"; + webrtc::CryptoOptions crypto_options; + if (pqc_) { + FieldTrials field_trials("WebRTC-EnableDtlsPqc/Enabled/"); + crypto_options.ephemeral_key_exchange_cipher_groups.Update(&field_trials); } fake_ice_transport_.reset(new FakeIceTransport( absl::StrCat("fake-", name_), 0, - /* network_thread= */ nullptr, field_trials_string)); + /* network_thread= */ nullptr, /* field_trials_string= */ "")); if (rtt_estimate) { fake_ice_transport_->set_rtt_estimate( async_delay_ms_ ? std::optional(async_delay_ms_) : std::nullopt, @@ -137,7 +138,7 @@ class DtlsTestClient : public sigslot::has_slots<> { }); dtls_transport_ = std::make_unique( - fake_ice_transport_.get(), CryptoOptions(), + fake_ice_transport_.get(), crypto_options, /*event_log=*/nullptr, ssl_max_version_); // Note: Certificate may be null here if testing passthrough. dtls_transport_->SetLocalCertificate(certificate_); @@ -368,7 +369,7 @@ class DtlsTestClient : public sigslot::has_slots<> { RTC_LOG(LS_INFO) << "Found DTLS ACK"; } else if (dtls_transport_->IsDtlsActive()) { if (IsRtpLeadByte(data[0])) { - ASSERT_TRUE(VerifyPacket(packet.payload(), NULL)); + ASSERT_TRUE(VerifyPacket(packet.payload(), nullptr)); } else if (packet_size_ && packet.payload().size() >= packet_size_) { ASSERT_TRUE(VerifyEncryptedPacket(data, packet.payload().size())); } @@ -789,12 +790,13 @@ class DtlsTransportInternalImplVersionTest client1_.set_async_delay(50); client2_.set_async_delay(50); - client1_.SetupTransports( - config1.ice_role.value_or(ICEROLE_CONTROLLING), rtt_estimate, - config1.pqc ? "WebRTC-EnableDtlsPqc/Enabled/" : ""); - client2_.SetupTransports( - config2.ice_role.value_or(ICEROLE_CONTROLLED), rtt_estimate, - config2.pqc ? "WebRTC-EnableDtlsPqc/Enabled/" : ""); + client1_.SetPqc(config1.pqc); + client2_.SetPqc(config2.pqc); + + client1_.SetupTransports(config1.ice_role.value_or(ICEROLE_CONTROLLING), + rtt_estimate); + client2_.SetupTransports(config2.ice_role.value_or(ICEROLE_CONTROLLED), + rtt_estimate); client1_.dtls_transport()->SetDtlsRole( config1.ssl_role.value_or(SSL_CLIENT)); client2_.dtls_transport()->SetDtlsRole( @@ -1487,9 +1489,9 @@ INSTANTIATE_TEST_SUITE_P( std::vector{ CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, HANDSHAKE_FINISHES, CALLER_RECEIVES_FINGERPRINT}), - ::testing::Bool(), + /*valid_fingerprint=*/::testing::Bool(), ::testing::Values(SSL_PROTOCOL_DTLS_12, SSL_PROTOCOL_DTLS_13), - ::testing::Bool())); + /*pqc=*/::testing::Bool())); class DtlsTransportInternalImplDtlsInStunTest : public DtlsTransportInternalImplVersionTest { diff --git a/p2p/dtls/dtls_utils.cc b/p2p/dtls/dtls_utils.cc index c1b3a0ab10..9522d1d302 100644 --- a/p2p/dtls/dtls_utils.cc +++ b/p2p/dtls/dtls_utils.cc @@ -13,13 +13,11 @@ #include #include #include -#include #include #include "absl/container/flat_hash_set.h" #include "api/array_view.h" #include "rtc_base/buffer.h" -#include "rtc_base/byte_buffer.h" #include "rtc_base/checks.h" #include "rtc_base/crc32.h" @@ -28,11 +26,6 @@ namespace { const uint8_t kDtlsChangeCipherSpecRecord = 20; const uint8_t kDtlsHandshakeRecord = 22; -// https://www.rfc-editor.org/rfc/rfc9147.html#section-4 -const uint8_t kFixedBitmask = 0b00100000; -const uint8_t kConnectionBitmask = 0b00010000; -const uint8_t kSequenceNumberBitmask = 0b00001000; -const uint8_t kLengthPresentBitmask = 0b00000100; } // namespace namespace webrtc { @@ -62,92 +55,8 @@ bool IsDtlsHandshakePacket(ArrayView payload) { payload[0] == kDtlsChangeCipherSpecRecord); } -// Returns a (unsorted) list of (msg_seq) received as part of the handshake. -std::optional> GetDtlsHandshakeAcks( - ArrayView dtls_packet) { - std::vector acks; - ByteBufferReader record_buf(dtls_packet); - // https://datatracker.ietf.org/doc/html/rfc6347#section-4.1 - while (record_buf.Length() >= kDtlsRecordHeaderLen) { - uint8_t content_type; - uint64_t epoch_and_seq; - uint16_t len; - // Read content_type(1). - if (!record_buf.ReadUInt8(&content_type)) { - return std::nullopt; - } - - // DTLS 1.3 rules: - // https://www.rfc-editor.org/rfc/rfc9147.html#section-4.1 - if ((content_type & kFixedBitmask) == kFixedBitmask) { - // Interpret as DTLSCipherText: - // https://www.rfc-editor.org/rfc/rfc9147.html#appendix-A.1 - // We assume no connection id is used so C must be 0. - if ((content_type & kConnectionBitmask) != 0) { - return std::nullopt; - } - // Skip sequence_number(1 or 2 bytes depending on S bit). - if (!record_buf.Consume((content_type & kSequenceNumberBitmask) == - kSequenceNumberBitmask - ? 2 - : 1)) { - return std::nullopt; - } - // If the L bit is set, consume the 16 bit length field. - if ((content_type & kLengthPresentBitmask) == kLengthPresentBitmask) { - if (!(record_buf.ReadUInt16(&len) && record_buf.Consume(len))) { - return std::nullopt; - } - } - // DTLSCipherText is encrypted so we can not read it. - continue; - } - // Skip version(2), read epoch+seq(2+6), read len(2) - if (!(record_buf.Consume(2) && record_buf.ReadUInt64(&epoch_and_seq) && - record_buf.ReadUInt16(&len) && record_buf.Length() >= len)) { - return std::nullopt; - } - if (content_type != kDtlsHandshakeRecord) { - record_buf.Consume(len); - continue; - } - // Epoch 1+ is encrypted so we can not parse it. - if (epoch_and_seq >> 6 != 0) { - record_buf.Consume(len); - continue; - } - - // https://www.rfc-editor.org/rfc/rfc6347.html#section-4.2.2 - ByteBufferReader handshake_buf(record_buf.DataView().subview(0, len)); - while (handshake_buf.Length() > 0) { - uint16_t msg_seq; - uint32_t fragment_len; - uint32_t fragment_offset; - // Skip msg_type(1) and length(3), read msg_seq(2), skip - // fragment_offset(3), read fragment_length(3) and consume it. - if (!(handshake_buf.Consume(1 + 3) && - handshake_buf.ReadUInt16(&msg_seq) && - handshake_buf.ReadUInt24(&fragment_offset) && - handshake_buf.ReadUInt24(&fragment_len) && - handshake_buf.Consume(fragment_len))) { - return std::nullopt; - } - acks.push_back(msg_seq); - // Advance outer buffer. - record_buf.Consume(12 + fragment_len); - } - RTC_DCHECK(handshake_buf.Length() == 0); - } - - // Should have consumed everything. - if (record_buf.Length() != 0) { - return std::nullopt; - } - return acks; -} - uint32_t ComputeDtlsPacketHash(ArrayView dtls_packet) { - return webrtc::ComputeCrc32(dtls_packet.data(), dtls_packet.size()); + return ComputeCrc32(dtls_packet.data(), dtls_packet.size()); } bool PacketStash::AddIfUnique(ArrayView packet) { @@ -157,16 +66,16 @@ bool PacketStash::AddIfUnique(ArrayView packet) { return false; } } - packets_.push_back({.hash = h, - .buffer = std::make_unique( - packet.data(), packet.size())}); + packets_.push_back( + {.hash = h, + .buffer = std::make_unique(packet.data(), packet.size())}); return true; } void PacketStash::Add(ArrayView packet) { - packets_.push_back({.hash = ComputeDtlsPacketHash(packet), - .buffer = std::make_unique( - packet.data(), packet.size())}); + packets_.push_back( + {.hash = ComputeDtlsPacketHash(packet), + .buffer = std::make_unique(packet.data(), packet.size())}); } void PacketStash::Prune(const absl::flat_hash_set& hashes) { diff --git a/p2p/dtls/dtls_utils_unittest.cc b/p2p/dtls/dtls_utils_unittest.cc index 5dc15621c9..15d4739d4e 100644 --- a/p2p/dtls/dtls_utils_unittest.cc +++ b/p2p/dtls/dtls_utils_unittest.cc @@ -11,195 +11,14 @@ #include "p2p/dtls/dtls_utils.h" #include -#include #include #include "absl/container/flat_hash_set.h" #include "api/array_view.h" -#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { -TEST(DtlsUtils, GetDtlsHandshakeAcksRejectsTooShort) { - std::vector packet = { - 0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xde, 0xad // Length given but bytes not present. - }; - EXPECT_FALSE(GetDtlsHandshakeAcks(packet)); -} - -TEST(DtlsUtils, GetDtlsHandshakeAcksRejectsInvalidContent) { - std::vector packet = {0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - // Correct length given but data is garbage. - 0x04, 0xde, 0xad, 0xbe, 0xef}; - EXPECT_FALSE(GetDtlsHandshakeAcks(packet)); -} - -TEST(DtlsUtils, GetDtlsHandshakeAcksRejectsTrailingData) { - std::vector packet = { - 0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Server hello done. - 0xde, 0xad, 0xbe, 0xef // Trailing data. - }; - EXPECT_FALSE(GetDtlsHandshakeAcks(packet)); -} - -TEST(DtlsUtils, GetDtlsHandshakeAcksBasic) { - std::vector packet = { - 0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Server hello done. - }; - std::optional> acks = GetDtlsHandshakeAcks(packet); - ASSERT_TRUE(acks); - EXPECT_EQ(acks->size(), 1u); - EXPECT_THAT(*acks, ::testing::ElementsAreArray({0xac})); -} - -TEST(DtlsUtils, GetDtlsHandshakeAcksPackedRecords) { - // Flight two from server to client but with fragment packing per - // https://boringssl.googlesource.com/boringssl/+/5245371a08528f7fb21ab20bd7a479d8e395b61c - std::vector packet = { - 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x43, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x60, 0xfe, 0xfd, 0x67, 0x2a, 0x87, 0x84, 0xf8, 0xe5, 0xbc, 0xe5, 0xd1, - 0x2b, 0xfe, 0x53, 0x20, 0xd2, 0xd4, 0x53, 0xa5, 0xbe, 0xd8, 0x38, 0x58, - 0x91, 0xdf, 0x76, 0x21, 0x81, 0x60, 0x7c, 0x6d, 0x8c, 0xdb, 0x93, 0x20, - 0x91, 0xc8, 0xf6, 0x9c, 0xaa, 0xbe, 0x79, 0xa3, 0x28, 0xa6, 0x84, 0xc9, - 0xfa, 0xee, 0x59, 0x22, 0x5d, 0xe2, 0x11, 0x28, 0xf4, 0x80, 0xd6, 0x1a, - 0x3a, 0xb5, 0x3d, 0xb6, 0x61, 0x74, 0xb6, 0x1d, 0xc0, 0x2b, 0x00, 0x00, - 0x18, 0x00, 0x17, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0b, - 0x00, 0x02, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x05, 0x00, 0x02, 0x00, 0x01, - 0x00, 0x0b, 0x00, 0x01, 0x1f, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x1f, 0x00, 0x01, 0x1c, 0x00, 0x01, 0x19, 0x30, 0x82, 0x01, 0x15, 0x30, - 0x81, 0xbd, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x9d, 0x2a, - 0x69, 0x9b, 0x1d, 0x5a, 0x38, 0xe5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, - 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x11, 0x31, 0x0f, 0x30, 0x0d, - 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x06, 0x57, 0x65, 0x62, 0x52, 0x54, - 0x43, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x34, 0x31, 0x31, 0x30, 0x34, 0x32, - 0x31, 0x30, 0x30, 0x35, 0x31, 0x5a, 0x17, 0x0d, 0x32, 0x34, 0x31, 0x32, - 0x30, 0x35, 0x32, 0x31, 0x30, 0x30, 0x35, 0x31, 0x5a, 0x30, 0x11, 0x31, - 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x06, 0x57, 0x65, - 0x62, 0x52, 0x54, 0x43, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, - 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, - 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x1e, 0xd8, 0xad, 0x96, 0x82, - 0xd0, 0xfb, 0xc8, 0xaa, 0xff, 0x84, 0x40, 0x84, 0xfc, 0x1e, 0x4a, 0xfd, - 0x8b, 0xfc, 0x13, 0xbb, 0xee, 0x93, 0xea, 0x91, 0x55, 0x61, 0x7d, 0xc3, - 0x96, 0x66, 0x38, 0x6d, 0x51, 0x59, 0x57, 0xbd, 0xc3, 0xd2, 0x03, 0xf4, - 0xde, 0x48, 0x3f, 0x61, 0x5e, 0x59, 0x2b, 0xfa, 0xfe, 0x68, 0xc0, 0x98, - 0xa3, 0x33, 0xe7, 0xd6, 0xb4, 0x0e, 0xbe, 0x56, 0x48, 0x50, 0x4b, 0x30, - 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, - 0x47, 0x00, 0x30, 0x44, 0x02, 0x20, 0x4d, 0xff, 0x9f, 0xf3, 0xc4, 0x08, - 0x15, 0xe0, 0xdd, 0x76, 0x64, 0x0d, 0x50, 0x42, 0x30, 0xbb, 0xf7, 0xca, - 0x78, 0xff, 0xe7, 0x86, 0x05, 0x0f, 0x23, 0x6e, 0xd2, 0x69, 0xd3, 0xc5, - 0xbd, 0xaa, 0x02, 0x20, 0x43, 0x71, 0x52, 0x2f, 0x74, 0x25, 0x78, 0xcd, - 0x62, 0x62, 0x62, 0x0b, 0xbf, 0x76, 0x35, 0xe1, 0xfe, 0x8c, 0x03, 0x6b, - 0x56, 0xb8, 0x96, 0x1f, 0xb1, 0x3a, 0x9f, 0xd9, 0x78, 0x05, 0x66, 0xa7, - 0x0c, 0x00, 0x00, 0x6f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, - 0x03, 0x00, 0x1d, 0x20, 0xf5, 0x50, 0xad, 0x14, 0x55, 0xd1, 0xbc, 0x82, - 0xa8, 0xb0, 0x2b, 0x81, 0x3d, 0x18, 0xf4, 0xba, 0x11, 0x54, 0xbb, 0x24, - 0x8b, 0x07, 0xa7, 0x17, 0xf1, 0x33, 0xca, 0x45, 0xc0, 0x6a, 0x16, 0x0a, - 0x04, 0x03, 0x00, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xad, 0xb6, 0x59, - 0x0c, 0xe0, 0x56, 0x42, 0xb8, 0x9f, 0x40, 0x43, 0xd3, 0x7f, 0x9f, 0xa0, - 0x1d, 0xbc, 0x78, 0xf5, 0xc3, 0x38, 0x99, 0x02, 0xde, 0x11, 0x85, 0x0f, - 0x50, 0xd6, 0x5b, 0x82, 0x7c, 0x02, 0x20, 0x57, 0x2e, 0x0a, 0x82, 0xf7, - 0x14, 0xb6, 0xd6, 0xb2, 0x4b, 0xd7, 0x1a, 0xd6, 0x1b, 0xc2, 0xf6, 0xc2, - 0x4f, 0x3f, 0xe2, 0x8a, 0x06, 0x97, 0xf3, 0x84, 0xc8, 0x60, 0xf1, 0xab, - 0x2d, 0x29, 0xaf, 0x0d, 0x00, 0x00, 0x19, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x19, 0x02, 0x01, 0x40, 0x00, 0x12, 0x04, 0x03, 0x08, 0x04, - 0x04, 0x01, 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, - 0x02, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00}; - - std::optional> acks = GetDtlsHandshakeAcks(packet); - ASSERT_TRUE(acks); - EXPECT_EQ(acks->size(), 5u); - EXPECT_THAT(*acks, ::testing::ElementsAreArray({0, 1, 2, 3, 4})); - - std::vector packet2 = { - 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x6c, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x60, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0xb2, 0xeb, 0x05, 0xc9, 0xba, - 0x39, 0xd0, 0xf6, 0x4b, 0xc9, 0x7e, 0xee, 0x57, 0xfc, 0x2b, 0x90, 0x93, - 0x09, 0xfd, 0x05, 0x80, 0xb3, 0xf5, 0xfc, 0x06, 0x68, 0x38, 0xa8, 0x20, - 0x42, 0x1d, 0x78, 0xe1, 0x97, 0x73, 0x55, 0x0a, 0x16, 0x2d, 0xc1, 0x3e, - 0x4f, 0x71, 0x55, 0xb4, 0x9f, 0xf8, 0x61, 0xe1, 0xbd, 0xe3, 0xf2, 0x2e, - 0x40, 0x29, 0x30, 0x58, 0x37, 0x26, 0x0d, 0xe8, 0xc0, 0x2b, 0x00, 0x00, - 0x18, 0x00, 0x17, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0b, - 0x00, 0x02, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x05, 0x00, 0x02, 0x00, 0x01, - 0x00, // - 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x28, 0x0b, 0x00, 0x01, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x1c, 0x00, 0x01, 0x19, 0x00, 0x01, 0x16, 0x30, 0x82, 0x01, 0x12, 0x30, - 0x81, 0xb8, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x15, 0xc9, 0xcc, - 0xd0, 0x55, 0x57, 0xa2, 0x32, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, - 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x0f, 0x31, 0x0d, 0x30, 0x0b, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x74, 0x65, 0x73, 0x74, 0x30, 0x1e, - 0x17, 0x0d, 0x32, 0x34, 0x31, 0x31, 0x30, 0x35, 0x32, 0x30, 0x35, 0x33, - 0x34, 0x38, 0x5a, 0x17, 0x0d, 0x32, 0x34, 0x31, 0x32, 0x30, 0x36, 0x32, - 0x30, 0x35, 0x33, 0x34, 0x38, 0x5a, 0x30, 0x0f, 0x31, 0x0d, 0x30, 0x0b, - 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x74, 0x65, 0x73, 0x74, 0x30, - 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, - 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, - 0x00, 0x04, 0x8f, 0x43, 0xeb, 0x7b, 0x88, 0x73, 0x4f, 0xe7, 0x69, 0x06, - 0x81, 0xb6, 0xb9, 0xf3, 0xca, 0x73, 0x32, 0x69, 0xb2, 0xc5, 0xe6, 0x4e, - 0xf0, 0x8c, 0xf4, 0xdd, 0x4e, 0x5b, 0xea, 0x06, 0x52, 0x94, 0x9a, 0x12, - 0x77, 0x11, 0xde, 0xf9, 0x12, 0x9a, 0xeb, 0x3c, 0x7c, 0xe4, 0xcf, 0x58, - 0x4c, 0x74, 0x44, 0x84, 0x0a, 0x84, 0xeb, 0xe6, 0xa4, 0xd5, 0xd3, 0x06, - 0xca, 0x52, 0x15, 0x7e, 0xeb, 0x19, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, - 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x49, 0x00, 0x30, 0x46, 0x02, - 0x21, 0x00, 0xab, 0xc7, 0x06, 0x7e, 0x36, 0x9b, 0xad, 0xe0, 0x26, 0x61, - 0x6b, 0x59, 0xa0, 0x1c, 0x70, 0x0c, 0xa6, 0xd3, 0xff, 0x8a, 0xc7, 0xba, - 0xe4, 0x23, 0x0a, 0x8b, 0x22, 0x82, 0xcd, 0x5a, 0x5c, 0x56, 0x02, 0x21, - 0x00, 0xc7, 0xe8, 0x57, 0x04, 0xb5, 0x44, 0x69, 0x42, 0xa2, 0xa2, 0x1e, - 0xde, 0x7f, 0xc4, 0x44, 0x98, 0xa4, 0x5c, 0x84, 0x41, 0xa1, 0x31, 0x38, - 0x3c, 0xe5, 0x4f, 0xf5, 0xc0, 0xa9, 0xa8, 0xbc, 0x16, // - 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x7a, 0x0c, 0x00, 0x00, 0x6e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x6e, 0x03, 0x00, 0x1d, 0x20, 0x89, 0xb9, 0xeb, 0x39, 0x29, 0xa0, 0x31, - 0x08, 0x9a, 0xbf, 0xc3, 0xc0, 0x20, 0x60, 0xbb, 0xea, 0x73, 0x19, 0xcf, - 0x63, 0xe4, 0x5a, 0xa8, 0xa9, 0x56, 0x77, 0xe8, 0x81, 0x48, 0xae, 0x9f, - 0x34, 0x04, 0x03, 0x00, 0x46, 0x30, 0x44, 0x02, 0x20, 0x23, 0x34, 0xc6, - 0x39, 0x94, 0x84, 0xcc, 0x67, 0xeb, 0x44, 0xf9, 0xc3, 0x5c, 0x52, 0xb3, - 0x99, 0x52, 0xf7, 0x4f, 0xff, 0x8b, 0xc5, 0xea, 0xb5, 0xd0, 0xf9, 0x36, - 0xb3, 0xe6, 0xfc, 0x37, 0x50, 0x02, 0x20, 0x4c, 0xe2, 0x29, 0xf5, 0x4a, - 0x4c, 0x7a, 0x01, 0x37, 0xce, 0xc1, 0xb0, 0x15, 0x23, 0xfd, 0xa5, 0xd9, - 0xac, 0x75, 0xcb, 0x55, 0x56, 0x99, 0x97, 0xe3, 0x13, 0xbd, 0x5b, 0xcc, - 0x5d, 0x0c, - 0xa8, // - 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, - 0x25, 0x0d, 0x00, 0x00, 0x19, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x19, 0x02, 0x01, 0x40, 0x00, 0x12, 0x04, 0x03, 0x08, 0x04, 0x04, 0x01, - 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, 0x02, 0x01, - 0x00, 0x00, // - 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - std::optional> acks2 = GetDtlsHandshakeAcks(packet2); - ASSERT_TRUE(acks2); - EXPECT_EQ(acks2->size(), 5u); - EXPECT_THAT(*acks2, ::testing::ElementsAreArray({0, 1, 2, 3, 4})); -} - -TEST(DtlsUtils, GetDtls13HandshakeAcks) { - // DTLS 1.3 encrypted data, captured with Wireshark. This is a single - // encrypted record which can not be parsed and should be skipped. - std::vector packet = { - 0x2f, 0x5b, 0x4c, 0x00, 0x23, 0x47, 0xab, 0xe7, 0x90, 0x96, - 0xc0, 0xac, 0x2f, 0x25, 0x40, 0x35, 0x35, 0xa3, 0x81, 0x50, - 0x0c, 0x38, 0x0a, 0xf6, 0xd4, 0xd5, 0x7d, 0xbe, 0x9a, 0xa3, - 0xcb, 0xcb, 0x67, 0xb0, 0x77, 0x79, 0x8b, 0x48, 0x60, 0xf8, - }; - - std::optional> acks = GetDtlsHandshakeAcks(packet); - ASSERT_TRUE(acks); - EXPECT_EQ(acks->size(), 0u); -} - std::vector ToVector(ArrayView array) { return std::vector(array.begin(), array.end()); } diff --git a/p2p/dtls/fake_dtls_transport.h b/p2p/dtls/fake_dtls_transport.h index e75e5e6bca..a0f7596439 100644 --- a/p2p/dtls/fake_dtls_transport.h +++ b/p2p/dtls/fake_dtls_transport.h @@ -207,6 +207,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { *version = 0x0102; return true; } + uint16_t GetSslGroupId() const override { return 0; } bool GetSrtpCryptoSuite(int* crypto_suite) const override { if (!do_dtls_) { return false; diff --git a/p2p/test/nat_server.cc b/p2p/test/nat_server.cc index 655357240a..7aa4007ba7 100644 --- a/p2p/test/nat_server.cc +++ b/p2p/test/nat_server.cc @@ -13,13 +13,13 @@ #include #include #include -#include #include "api/array_view.h" #include "p2p/test/nat_socket_factory.h" #include "p2p/test/nat_types.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/async_udp_socket.h" +#include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/ip_address.h" #include "rtc_base/logging.h" @@ -65,7 +65,7 @@ AddrCmp::AddrCmp(NAT* nat) size_t AddrCmp::operator()(const SocketAddress& a) const { size_t h = 0; if (use_ip) - h ^= webrtc::HashIP(a.ipaddr()); + h ^= HashIP(a.ipaddr()); if (use_port) h ^= a.port() | (a.port() << 16); return h; @@ -89,7 +89,7 @@ bool AddrCmp::operator()(const SocketAddress& a1, class NATProxyServerSocket : public AsyncProxyServerSocket { public: explicit NATProxyServerSocket(Socket* socket) - : AsyncProxyServerSocket(socket, webrtc::kNATEncodedIPv6AddressSize) { + : AsyncProxyServerSocket(socket, kNATEncodedIPv6AddressSize) { BufferInput(true); } @@ -106,13 +106,13 @@ class NATProxyServerSocket : public AsyncProxyServerSocket { int family = data[1]; RTC_DCHECK(family == AF_INET || family == AF_INET6); - if ((family == AF_INET && *len < webrtc::kNATEncodedIPv4AddressSize) || - (family == AF_INET6 && *len < webrtc::kNATEncodedIPv6AddressSize)) { + if ((family == AF_INET && *len < kNATEncodedIPv4AddressSize) || + (family == AF_INET6 && *len < kNATEncodedIPv6AddressSize)) { return; } SocketAddress dest_addr; - size_t address_length = webrtc::UnpackAddressFromNAT( + size_t address_length = UnpackAddressFromNAT( MakeArrayView(reinterpret_cast(data), *len), &dest_addr); *len -= address_length; @@ -189,7 +189,7 @@ void NATServer::OnInternalUDPPacket(AsyncPacketSocket* socket, RTC_DCHECK(internal_socket_thread_.IsCurrent()); // Read the intended destination from the wire. SocketAddress dest_addr; - size_t length = webrtc::UnpackAddressFromNAT(packet.payload(), &dest_addr); + size_t length = UnpackAddressFromNAT(packet.payload(), &dest_addr); // Find the translation for these addresses (allocating one if necessary). SocketAddressPair route(packet.source_address(), dest_addr); @@ -229,18 +229,12 @@ void NATServer::OnExternalUDPPacket(AsyncPacketSocket* socket, // Forward this packet to the internal address. // First prepend the address in a quasi-STUN format. - std::unique_ptr real_buf( - new char[packet.payload().size() + webrtc::kNATEncodedIPv6AddressSize]); - size_t addrlength = webrtc::PackAddressForNAT( - real_buf.get(), - packet.payload().size() + webrtc::kNATEncodedIPv6AddressSize, - packet.source_address()); + Buffer real_buf(packet.payload().size() + kNATEncodedIPv6AddressSize); + PackAddressForNAT(packet.source_address(), real_buf); // Copy the data part after the address. AsyncSocketPacketOptions options; - memcpy(real_buf.get() + addrlength, packet.payload().data(), - packet.payload().size()); - udp_server_socket_->SendTo(real_buf.get(), - packet.payload().size() + addrlength, + real_buf.AppendData(packet.payload()); + udp_server_socket_->SendTo(real_buf.data(), real_buf.size(), iter->second->route.source(), options); } diff --git a/p2p/test/nat_socket_factory.cc b/p2p/test/nat_socket_factory.cc index f7fbf21784..a38b4bb8d9 100644 --- a/p2p/test/nat_socket_factory.cc +++ b/p2p/test/nat_socket_factory.cc @@ -21,7 +21,6 @@ #include "api/units/timestamp.h" #include "p2p/test/nat_server.h" #include "p2p/test/nat_types.h" -#include "rtc_base/arraysize.h" #include "rtc_base/buffer.h" #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" @@ -41,28 +40,27 @@ namespace webrtc { // Packs the given socketaddress into the buffer in buf, in the quasi-STUN // format that the natserver uses. // Returns 0 if an invalid address is passed. -size_t PackAddressForNAT(char* buf, - size_t buf_size, - const SocketAddress& remote_addr) { +void PackAddressForNAT(const SocketAddress& remote_addr, Buffer& buf) { + RTC_DCHECK_GE(buf.capacity(), 4); const IPAddress& ip = remote_addr.ipaddr(); int family = ip.family(); buf[0] = 0; buf[1] = family; // Writes the port. - *(reinterpret_cast(&buf[2])) = - webrtc::HostToNetwork16(remote_addr.port()); + *(reinterpret_cast(&buf[2])) = HostToNetwork16(remote_addr.port()); if (family == AF_INET) { - RTC_DCHECK(buf_size >= kNATEncodedIPv4AddressSize); + RTC_DCHECK_GE(buf.capacity(), kNATEncodedIPv4AddressSize); in_addr v4addr = ip.ipv4_address(); memcpy(&buf[4], &v4addr, kNATEncodedIPv4AddressSize - 4); - return kNATEncodedIPv4AddressSize; + buf.SetSize(kNATEncodedIPv4AddressSize); } else if (family == AF_INET6) { - RTC_DCHECK(buf_size >= kNATEncodedIPv6AddressSize); + RTC_DCHECK_GE(buf.capacity(), kNATEncodedIPv6AddressSize); in6_addr v6addr = ip.ipv6_address(); memcpy(&buf[4], &v6addr, kNATEncodedIPv6AddressSize - 4); - return kNATEncodedIPv6AddressSize; + buf.SetSize(kNATEncodedIPv6AddressSize); + } else { + buf.SetSize(0); } - return 0U; } // Decodes the remote address from a packet that has been encoded with the nat's @@ -73,8 +71,8 @@ size_t UnpackAddressFromNAT(ArrayView buf, RTC_CHECK(buf.size() >= 8); RTC_DCHECK(buf.data()[0] == 0); int family = buf[1]; - uint16_t port = webrtc::NetworkToHost16( - *(reinterpret_cast(&buf.data()[2]))); + uint16_t port = + NetworkToHost16(*(reinterpret_cast(&buf.data()[2]))); if (family == AF_INET) { const in_addr* v4addr = reinterpret_cast(&buf.data()[4]); *remote_addr = SocketAddress(IPAddress(*v4addr), port); @@ -121,7 +119,7 @@ class NATSocket : public Socket, public sigslot::has_slots<> { // If we're not already bound (meaning `socket_` is null), bind to ANY // address. if (!socket_) { - result = BindInternal(SocketAddress(webrtc::GetAnyIP(family_), 0)); + result = BindInternal(SocketAddress(GetAnyIP(family_), 0)); if (result < 0) { return result; } @@ -153,12 +151,12 @@ class NATSocket : public Socket, public sigslot::has_slots<> { return socket_->SendTo(data, size, addr); } // This array will be too large for IPv4 packets, but only by 12 bytes. - std::unique_ptr buf(new char[size + kNATEncodedIPv6AddressSize]); - size_t addrlength = - PackAddressForNAT(buf.get(), size + kNATEncodedIPv6AddressSize, addr); - size_t encoded_size = size + addrlength; - memcpy(buf.get() + addrlength, data, size); - int result = socket_->SendTo(buf.get(), encoded_size, server_addr_); + Buffer buf(/*size=*/size + kNATEncodedIPv6AddressSize); + PackAddressForNAT(addr, buf); + size_t addrlength = buf.size(); + buf.AppendData(static_cast(data), size); + size_t encoded_size = buf.size(); + int result = socket_->SendTo(buf.data(), buf.size(), server_addr_); if (result >= 0) { RTC_DCHECK(result == static_cast(encoded_size)); result = result - static_cast(addrlength); @@ -299,9 +297,9 @@ class NATSocket : public Socket, public sigslot::has_slots<> { // Sends the destination address to the server to tell it to connect. void SendConnectRequest() { - char buf[kNATEncodedIPv6AddressSize]; - size_t length = PackAddressForNAT(buf, arraysize(buf), remote_addr_); - socket_->Send(buf, length); + Buffer buf(kNATEncodedIPv6AddressSize); + PackAddressForNAT(remote_addr_, buf); + socket_->Send(buf.data(), buf.size()); } // Handles the byte sent back from the server and fires the appropriate event. diff --git a/p2p/test/nat_socket_factory.h b/p2p/test/nat_socket_factory.h index d73cc99ea6..2da761dfb8 100644 --- a/p2p/test/nat_socket_factory.h +++ b/p2p/test/nat_socket_factory.h @@ -22,6 +22,7 @@ #include "api/units/time_delta.h" #include "p2p/test/nat_server.h" #include "p2p/test/nat_types.h" +#include "rtc_base/buffer.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" #include "rtc_base/socket_factory.h" @@ -172,9 +173,7 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory { }; // Free-standing NAT helper functions. -size_t PackAddressForNAT(char* buf, - size_t buf_size, - const SocketAddress& remote_addr); +void PackAddressForNAT(const SocketAddress& remote_addr, Buffer& buf); size_t UnpackAddressFromNAT(ArrayView buf, SocketAddress* remote_addr); } // namespace webrtc diff --git a/p2p/test/nat_types.cc b/p2p/test/nat_types.cc index 6fbc973280..1b7504e2a3 100644 --- a/p2p/test/nat_types.cc +++ b/p2p/test/nat_types.cc @@ -54,7 +54,7 @@ NAT* NAT::Create(NATType type) { return new SymmetricNAT(); default: RTC_DCHECK_NOTREACHED(); - return 0; + return nullptr; } } diff --git a/p2p/test/nat_unittest.cc b/p2p/test/nat_unittest.cc index bb00fbacf5..b9dddc1da5 100644 --- a/p2p/test/nat_unittest.cc +++ b/p2p/test/nat_unittest.cc @@ -49,7 +49,7 @@ bool CheckReceive(webrtc::TestClient* client, bool should_receive, const char* buf, size_t size) { - return (should_receive) ? client->CheckNextPacket(buf, size, 0) + return (should_receive) ? client->CheckNextPacket(buf, size, nullptr) : client->CheckNoPacket(); } diff --git a/p2p/test/stun_server_unittest.cc b/p2p/test/stun_server_unittest.cc index 1a270d8b02..1a86a3059b 100644 --- a/p2p/test/stun_server_unittest.cc +++ b/p2p/test/stun_server_unittest.cc @@ -53,7 +53,7 @@ class StunServerTest : public ::testing::Test { } bool ReceiveFails() { return (client_->CheckNoPacket()); } StunMessage* Receive() { - StunMessage* msg = NULL; + StunMessage* msg = nullptr; std::unique_ptr packet = client_->NextPacket(TestClient::kTimeoutMs); if (packet) { @@ -78,13 +78,13 @@ TEST_F(StunServerTest, TestGood) { Send(req); StunMessage* msg = Receive(); - ASSERT_TRUE(msg != NULL); + ASSERT_TRUE(msg != nullptr); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); EXPECT_EQ(req.transaction_id(), msg->transaction_id()); const StunAddressAttribute* mapped_addr = msg->GetAddress(STUN_ATTR_MAPPED_ADDRESS); - EXPECT_TRUE(mapped_addr != NULL); + EXPECT_TRUE(mapped_addr != nullptr); EXPECT_EQ(1, mapped_addr->family()); EXPECT_EQ(client_addr.port(), mapped_addr->port()); @@ -99,13 +99,13 @@ TEST_F(StunServerTest, TestGoodXorMappedAddr) { Send(req); StunMessage* msg = Receive(); - ASSERT_TRUE(msg != NULL); + ASSERT_TRUE(msg != nullptr); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); EXPECT_EQ(req.transaction_id(), msg->transaction_id()); const StunAddressAttribute* mapped_addr = msg->GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - EXPECT_TRUE(mapped_addr != NULL); + EXPECT_TRUE(mapped_addr != nullptr); EXPECT_EQ(1, mapped_addr->family()); EXPECT_EQ(client_addr.port(), mapped_addr->port()); @@ -120,13 +120,13 @@ TEST_F(StunServerTest, TestNoXorMappedAddr) { Send(req); StunMessage* msg = Receive(); - ASSERT_TRUE(msg != NULL); + ASSERT_TRUE(msg != nullptr); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); EXPECT_EQ(req.transaction_id(), msg->transaction_id()); const StunAddressAttribute* mapped_addr = msg->GetAddress(STUN_ATTR_XOR_MAPPED_ADDRESS); - EXPECT_TRUE(mapped_addr == NULL); + EXPECT_TRUE(mapped_addr == nullptr); delete msg; } diff --git a/p2p/test/test_stun_server.cc b/p2p/test/test_stun_server.cc index f440d1e186..404dcf055b 100644 --- a/p2p/test/test_stun_server.cc +++ b/p2p/test/test_stun_server.cc @@ -24,7 +24,7 @@ namespace webrtc { -std::unique_ptr> +std::unique_ptr> TestStunServer::Create(SocketServer* ss, const SocketAddress& addr, Thread& network_thread) { @@ -35,8 +35,8 @@ TestStunServer::Create(SocketServer* ss, TestStunServer* server = nullptr; network_thread.BlockingCall( [&]() { server = new TestStunServer(udp_socket, network_thread); }); - std::unique_ptr> - result(server, [&](TestStunServer* server) { + std::unique_ptr> result( + server, [&](TestStunServer* server) { network_thread.BlockingCall([server]() { delete server; }); }); return result; diff --git a/p2p/test/turn_server.cc b/p2p/test/turn_server.cc index cfc38acc67..57fb0fd271 100644 --- a/p2p/test/turn_server.cc +++ b/p2p/test/turn_server.cc @@ -48,7 +48,6 @@ namespace webrtc { namespace { -using ::webrtc::TimeDelta; // TODO(juberti): Move this all to a future turnmessage.h // static const int IPPROTO_UDP = 17; @@ -90,8 +89,8 @@ static void InitErrorResponse(int code, TurnServer::TurnServer(TaskQueueBase* thread) : thread_(thread), nonce_key_(CreateRandomString(kNonceKeySize)), - auth_hook_(NULL), - redirect_hook_(NULL), + auth_hook_(nullptr), + redirect_hook_(nullptr), enable_otu_nonce_(false) {} TurnServer::~TurnServer() { @@ -153,7 +152,7 @@ void TurnServer::AcceptConnection(Socket* server_socket) { // Check if someone is trying to connect to us. SocketAddress accept_addr; Socket* accepted_socket = server_socket->Accept(&accept_addr); - if (accepted_socket != NULL) { + if (accepted_socket != nullptr) { const ServerSocketInfo& info = server_listen_sockets_[server_socket]; if (info.ssl_adapter_factory) { SSLAdapter* ssl_adapter = @@ -187,7 +186,7 @@ void TurnServer::OnInternalPacket(AsyncPacketSocket* socket, InternalSocketMap::iterator iter = server_sockets_.find(socket); RTC_DCHECK(iter != server_sockets_.end()); TurnServerConnection conn(packet.source_address(), iter->second, socket); - uint16_t msg_type = webrtc::GetBE16(packet.payload().data()); + uint16_t msg_type = GetBE16(packet.payload().data()); if (!IsTurnChannelData(msg_type)) { // This is a STUN message. HandleStunMessage(&conn, packet.payload()); @@ -223,7 +222,7 @@ void TurnServer::HandleStunMessage(TurnServerConnection* conn, return; } - if (redirect_hook_ != NULL && msg.type() == STUN_ALLOCATE_REQUEST) { + if (redirect_hook_ != nullptr && msg.type() == STUN_ALLOCATE_REQUEST) { SocketAddress address; if (redirect_hook_->ShouldRedirect(conn->src(), &address)) { SendErrorResponseWithAlternateServer(conn, &msg, address); @@ -277,7 +276,7 @@ bool TurnServer::GetKey(const StunMessage* msg, std::string* key) { return false; } - return (auth_hook_ != NULL && + return (auth_hook_ != nullptr && auth_hook_->GetKey(std::string(username_attr->string_view()), realm_, key)); } @@ -430,9 +429,9 @@ TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn, AsyncPacketSocket* external_socket = (external_socket_factory_) ? external_socket_factory_->CreateUdpSocket(external_addr_, 0, 0) - : NULL; + : nullptr; if (!external_socket) { - return NULL; + return nullptr; } // The Allocation takes ownership of the socket. @@ -512,7 +511,7 @@ void TurnServer::DestroyAllocation(TurnServerAllocation* allocation) { // by all allocations. // Note: We may not find a socket if it's a TCP socket that was closed, and // the allocation is only now timing out. - if (iter != server_sockets_.end() && iter->second != webrtc::PROTO_UDP) { + if (iter != server_sockets_.end() && iter->second != PROTO_UDP) { DestroyInternalSocket(socket); } @@ -590,7 +589,7 @@ std::string TurnServerAllocation::ToString() const { void TurnServerAllocation::HandleTurnMessage(const TurnMessage* msg) { RTC_DCHECK_RUN_ON(thread_); - RTC_DCHECK(msg != NULL); + RTC_DCHECK(msg != nullptr); switch (msg->type()) { case STUN_ALLOCATE_REQUEST: HandleAllocateRequest(msg); @@ -620,7 +619,7 @@ void TurnServerAllocation::HandleAllocateRequest(const TurnMessage* msg) { transaction_id_ = msg->transaction_id(); const StunByteStringAttribute* username_attr = msg->GetByteString(STUN_ATTR_USERNAME); - RTC_DCHECK(username_attr != NULL); + RTC_DCHECK(username_attr != nullptr); username_ = std::string(username_attr->string_view()); // Figure out the lifetime and start the allocation timer. @@ -703,7 +702,7 @@ void TurnServerAllocation::HandleCreatePermissionRequest( } if (server_->reject_private_addresses_ && - webrtc::IPIsPrivate(peer_attr->GetAddress().ipaddr())) { + IPIsPrivate(peer_attr->GetAddress().ipaddr())) { SendErrorResponse(msg, STUN_ERROR_FORBIDDEN, STUN_ERROR_REASON_FORBIDDEN); return; } @@ -781,7 +780,7 @@ void TurnServerAllocation::HandleChannelBindRequest(const TurnMessage* msg) { void TurnServerAllocation::HandleChannelData(ArrayView payload) { // Extract the channel number from the data. - uint16_t channel_id = webrtc::GetBE16(payload.data()); + uint16_t channel_id = GetBE16(payload.data()); auto channel = FindChannel(channel_id); if (channel != channels_.end()) { // Send the data to the peer address. diff --git a/pc/BUILD.gn b/pc/BUILD.gn index d6b0acbe56..704aa2ad87 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -60,7 +60,7 @@ rtc_source_set("proxy") { ] } -rtc_source_set("channel") { +rtc_library("channel") { visibility = [ ":*", "../test/peer_scenario", @@ -126,7 +126,7 @@ rtc_source_set("channel_interface") { ] } -rtc_source_set("dtls_srtp_transport") { +rtc_library("dtls_srtp_transport") { visibility = [ ":*" ] sources = [ "dtls_srtp_transport.cc", @@ -145,7 +145,7 @@ rtc_source_set("dtls_srtp_transport") { ] } -rtc_source_set("dtls_transport") { +rtc_library("dtls_transport") { visibility = [ ":*", "../test/*", @@ -171,7 +171,7 @@ rtc_source_set("dtls_transport") { ] } -rtc_source_set("external_hmac") { +rtc_library("external_hmac") { visibility = [ ":*" ] sources = [ "external_hmac.cc", @@ -186,7 +186,7 @@ rtc_source_set("external_hmac") { } } -rtc_source_set("ice_transport") { +rtc_library("ice_transport") { visibility = [ ":*" ] sources = [ "ice_transport.cc", @@ -201,7 +201,7 @@ rtc_source_set("ice_transport") { ] } -rtc_source_set("jsep_transport") { +rtc_library("jsep_transport") { visibility = [ ":*" ] sources = [ "jsep_transport.cc", @@ -245,7 +245,7 @@ rtc_source_set("jsep_transport") { ] } -rtc_source_set("jsep_transport_collection") { +rtc_library("jsep_transport_collection") { visibility = [ ":*" ] sources = [ "jsep_transport_collection.cc", @@ -265,7 +265,7 @@ rtc_source_set("jsep_transport_collection") { ] } -rtc_source_set("jsep_transport_controller") { +rtc_library("jsep_transport_controller") { visibility = [ ":*", "../test/peer_scenario:*", @@ -342,7 +342,7 @@ rtc_source_set("media_factory") { ] } -rtc_source_set("media_session") { +rtc_library("media_session") { visibility = [ "*" ] # Used by Chrome sources = [ "media_session.cc", @@ -511,7 +511,7 @@ rtc_source_set("peer_connection_proxy") { ] } -rtc_source_set("rtcp_mux_filter") { +rtc_library("rtcp_mux_filter") { visibility = [ ":*" ] sources = [ "rtcp_mux_filter.cc", @@ -523,7 +523,7 @@ rtc_source_set("rtcp_mux_filter") { ] } -rtc_source_set("rtp_media_utils") { +rtc_library("rtp_media_utils") { visibility = [ ":*" ] sources = [ "rtp_media_utils.cc", @@ -560,7 +560,7 @@ rtc_source_set("rtp_sender_proxy") { ] } -rtc_source_set("rtp_transport") { +rtc_library("rtp_transport") { visibility = [ ":*" ] sources = [ "rtp_transport.cc", @@ -614,7 +614,7 @@ rtc_source_set("rtp_transport_internal") { ] } -rtc_source_set("sctp_transport") { +rtc_library("sctp_transport") { visibility = [ ":*" ] sources = [ "sctp_transport.cc", @@ -639,7 +639,7 @@ rtc_source_set("sctp_transport") { ] } -rtc_source_set("sctp_utils") { +rtc_library("sctp_utils") { visibility = [ ":*", "../test/fuzzers:*", @@ -661,7 +661,7 @@ rtc_source_set("sctp_utils") { "../rtc_base:ssl_adapter", ] } -rtc_source_set("srtp_session") { +rtc_library("srtp_session") { visibility = [ ":*" ] sources = [ "srtp_session.cc", @@ -691,7 +691,7 @@ rtc_source_set("srtp_session") { deps += [ "//third_party/libsrtp" ] } } -rtc_source_set("srtp_transport") { +rtc_library("srtp_transport") { visibility = [ ":*" ] sources = [ "srtp_transport.cc", @@ -717,7 +717,7 @@ rtc_source_set("srtp_transport") { ] } -rtc_source_set("transport_stats") { +rtc_library("transport_stats") { visibility = [ ":*" ] sources = [ "transport_stats.cc", @@ -742,7 +742,7 @@ rtc_source_set("used_ids") { ] } -rtc_source_set("video_track_source_proxy") { +rtc_library("video_track_source_proxy") { visibility = [ "*" ] # Used by Chrome sources = [ "video_track_source_proxy.cc", @@ -760,7 +760,7 @@ rtc_source_set("video_track_source_proxy") { ] } -rtc_source_set("session_description") { +rtc_library("session_description") { # TODO(bugs.webrtc.org/13661): Reduce visibility if possible visibility = [ "*" ] # Used by Chrome and others @@ -791,7 +791,7 @@ rtc_source_set("session_description") { ] } -rtc_source_set("simulcast_description") { +rtc_library("simulcast_description") { sources = [ "simulcast_description.cc", "simulcast_description.h", @@ -897,7 +897,7 @@ rtc_library("connection_context") { ] } -rtc_source_set("data_channel_controller") { +rtc_library("data_channel_controller") { visibility = [ ":*" ] sources = [ "data_channel_controller.cc", @@ -962,7 +962,7 @@ rtc_source_set("peer_connection_internal") { ] } -rtc_source_set("rtc_stats_collector") { +rtc_library("rtc_stats_collector") { visibility = [ ":*", "../api:*", @@ -1037,7 +1037,7 @@ rtc_source_set("rtc_stats_collector") { ] } -rtc_source_set("rtc_stats_traversal") { +rtc_library("rtc_stats_traversal") { visibility = [ ":*" ] sources = [ "rtc_stats_traversal.cc", @@ -1050,7 +1050,7 @@ rtc_source_set("rtc_stats_traversal") { ] } -rtc_source_set("sdp_munging_detector") { +rtc_library("sdp_munging_detector") { visibility = [ ":*" ] sources = [ "sdp_munging_detector.cc", @@ -1070,7 +1070,7 @@ rtc_source_set("sdp_munging_detector") { "//third_party/abseil-cpp/absl/algorithm:container", ] } -rtc_source_set("sdp_offer_answer") { +rtc_library("sdp_offer_answer") { visibility = [ ":*" ] sources = [ "sdp_offer_answer.cc", @@ -1160,7 +1160,7 @@ rtc_source_set("jsep_ice_candidate") { rtc_source_set("jsep_session_description") { visibility = [ ":*" ] } -rtc_source_set("local_audio_source") { +rtc_library("local_audio_source") { visibility = [ ":*" ] sources = [ "local_audio_source.cc", @@ -1173,7 +1173,7 @@ rtc_source_set("local_audio_source") { "../api:scoped_refptr", ] } -rtc_source_set("peer_connection") { +rtc_library("peer_connection") { visibility = [ ":*" ] sources = [ "peer_connection.cc", @@ -1279,7 +1279,7 @@ rtc_source_set("peer_connection") { ] } -rtc_source_set("simulcast_sdp_serializer") { +rtc_library("simulcast_sdp_serializer") { visibility = [ ":*" ] sources = [ "simulcast_sdp_serializer.cc", @@ -1300,7 +1300,7 @@ rtc_source_set("simulcast_sdp_serializer") { "//third_party/abseil-cpp/absl/strings:string_view", ] } -rtc_source_set("sdp_utils") { +rtc_library("sdp_utils") { sources = [ "sdp_utils.cc", "sdp_utils.h", @@ -1313,7 +1313,7 @@ rtc_source_set("sdp_utils") { "../rtc_base/system:rtc_export", ] } -rtc_source_set("legacy_stats_collector") { +rtc_library("legacy_stats_collector") { visibility = [ ":*" ] sources = [ "legacy_stats_collector.cc", @@ -1367,7 +1367,7 @@ rtc_source_set("stream_collection") { sources = [ "stream_collection.h" ] deps = [ "../api:libjingle_peerconnection_api" ] } -rtc_source_set("track_media_info_map") { +rtc_library("track_media_info_map") { visibility = [ ":*" ] sources = [ "track_media_info_map.cc", @@ -1387,7 +1387,7 @@ rtc_source_set("track_media_info_map") { "../rtc_base:threading", ] } -rtc_source_set("webrtc_sdp") { +rtc_library("webrtc_sdp") { # TODO(bugs.webrtc.org/13661): Reduce visibility if possible visibility = [ "*" ] # Used by Chrome and more @@ -1408,6 +1408,7 @@ rtc_source_set("webrtc_sdp") { "../api:rtc_error", "../api:rtp_parameters", "../api:rtp_transceiver_direction", + "../api/audio:audio_frame_api", "../media:codec", "../media:media_constants", "../media:rid_description", @@ -1437,7 +1438,7 @@ rtc_source_set("webrtc_sdp") { "//third_party/abseil-cpp/absl/strings:string_view", ] } -rtc_source_set("webrtc_session_description_factory") { +rtc_library("webrtc_session_description_factory") { visibility = [ ":*" ] sources = [ "webrtc_session_description_factory.cc", @@ -1483,6 +1484,7 @@ rtc_library("ice_server_parsing") { "../api:candidate", "../api:libjingle_peerconnection_api", "../api:rtc_error", + "../p2p:p2p_constants", "../p2p:port", "../p2p:port_allocator", "../p2p:port_interface", @@ -1508,7 +1510,7 @@ rtc_library("media_stream_observer") { "//third_party/abseil-cpp/absl/algorithm:container", ] } -rtc_source_set("peer_connection_factory") { +rtc_library("peer_connection_factory") { # TODO(bugs.webrtc.org/13661): Reduce visibility if possible visibility = [ "*" ] # Known to be used externally allow_poison = [ "environment_construction" ] @@ -2375,6 +2377,7 @@ if (rtc_include_tests && !build_with_chromium) { "rtp_sender_receiver_unittest.cc", "rtp_transceiver_unittest.cc", "sctp_utils_unittest.cc", + "sdp_munging_detector_unittest.cc", "sdp_offer_answer_unittest.cc", "simulcast_sdp_serializer_unittest.cc", "test/fake_audio_capture_module_unittest.cc", @@ -2681,6 +2684,7 @@ if (rtc_include_tests && !build_with_chromium) { ":video_track_source", "../api:audio_options_api", "../api:candidate", + "../api:dtls_transport_interface", "../api:enable_media_with_defaults", "../api:field_trials", "../api:field_trials_view", @@ -2699,10 +2703,10 @@ if (rtc_include_tests && !build_with_chromium) { "../api:sequence_checker", "../api/audio:builtin_audio_processing_builder", "../api/crypto:options", + "../api/environment:environment_factory", "../api/metronome", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue", - "../api/task_queue:default_task_queue_factory", "../api/task_queue:pending_task_safety_flag", "../api/units:time_delta", "../api/video:video_rtp_headers", diff --git a/pc/OWNERS b/pc/OWNERS index 4b662f76a0..8f054a6427 100644 --- a/pc/OWNERS +++ b/pc/OWNERS @@ -8,3 +8,6 @@ deadbeef@webrtc.org per-file webrtc_sdp.cc = set noparent per-file webrtc_sdp.cc = hta@webrtc.org per-file webrtc_sdp.cc = hbos@webrtc.org +# If none of the above are present, may also try one of these +per-file webrtc_sdp.cc = tommi@webrtc.org +per-file webrtc_sdp.cc = guidou@webrtc.org diff --git a/pc/audio_rtp_receiver_unittest.cc b/pc/audio_rtp_receiver_unittest.cc index 91614d7d69..b056bdf07e 100644 --- a/pc/audio_rtp_receiver_unittest.cc +++ b/pc/audio_rtp_receiver_unittest.cc @@ -83,7 +83,7 @@ TEST_F(AudioRtpReceiverTest, SetOutputVolumeIsCalled) { receiver_->OnSetVolume(kVolume); EXPECT_THAT(WaitUntil([&] { return set_volume_calls.load(); }, Eq(2), - {.timeout = webrtc::TimeDelta::Millis(kTimeOut)}), + {.timeout = TimeDelta::Millis(kTimeOut)}), IsRtcOk()); } diff --git a/pc/channel.cc b/pc/channel.cc index deeb8b7103..1ab970f245 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -55,8 +55,6 @@ namespace webrtc { namespace { -using ::webrtc::UniqueRandomIdGenerator; - // Finds a stream based on target's Primary SSRC or RIDs. // This struct is used in BaseChannel::UpdateLocalStreams_w. struct StreamFinder { @@ -117,7 +115,7 @@ void RtpSendParametersFromMediaDescription( RtpHeaderExtensions extensions = RtpExtension::DeduplicateHeaderExtensions( desc->rtp_header_extensions(), extensions_filter); const bool is_stream_active = - webrtc::RtpTransceiverDirectionHasRecv(desc->direction()); + RtpTransceiverDirectionHasRecv(desc->direction()); MediaChannelParametersFromMediaDescription(desc, extensions, is_stream_active, send_params); send_params->max_bandwidth_bps = desc->bandwidth(); @@ -166,7 +164,7 @@ BaseChannel::~BaseChannel() { } std::string BaseChannel::ToString() const { - return webrtc::StringFormat( + return StringFormat( "{mid: %s, media_type: %s}", mid().c_str(), MediaTypeToString(media_send_channel_->media_type()).c_str()); } @@ -303,8 +301,8 @@ bool BaseChannel::IsReadyToSendMedia_w() const { // Send outgoing data if we are enabled, have local and remote content, // and we have had some form of connectivity. return enabled_ && - webrtc::RtpTransceiverDirectionHasRecv(remote_content_direction_) && - webrtc::RtpTransceiverDirectionHasSend(local_content_direction_) && + RtpTransceiverDirectionHasRecv(remote_content_direction_) && + RtpTransceiverDirectionHasSend(local_content_direction_) && was_ever_writable_; } @@ -501,9 +499,9 @@ bool BaseChannel::MaybeUpdateDemuxerAndRtpExtensions_w( return true; if (!rtp_transport_->RegisterRtpDemuxerSink(demuxer_criteria_, this)) { - error_desc = webrtc::StringFormat( - "Failed to apply demuxer criteria for '%s': '%s'.", mid().c_str(), - demuxer_criteria_.ToString().c_str()); + error_desc = + StringFormat("Failed to apply demuxer criteria for '%s': '%s'.", + mid().c_str(), demuxer_criteria_.ToString().c_str()); return false; } return true; @@ -659,7 +657,7 @@ bool BaseChannel::UpdateLocalStreams_w(const std::vector& streams, continue; } if (!media_send_channel()->RemoveSendStream(old_stream.first_ssrc())) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to remove send stream with ssrc %u from m-section with " "mid='%s'.", old_stream.first_ssrc(), mid().c_str()); @@ -685,7 +683,7 @@ bool BaseChannel::UpdateLocalStreams_w(const std::vector& streams, RTC_DCHECK(new_stream.has_ssrcs() || new_stream.has_rids()); if (new_stream.has_ssrcs() && new_stream.has_rids()) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to add send stream: %u into m-section with mid='%s'. Stream " "has both SSRCs and RIDs.", new_stream.first_ssrc(), mid().c_str()); @@ -705,7 +703,7 @@ bool BaseChannel::UpdateLocalStreams_w(const std::vector& streams, RTC_LOG(LS_INFO) << "Add send stream ssrc: " << new_stream.ssrcs[0] << " into " << ToString(); } else { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to add send stream ssrc: %u into m-section with mid='%s'", new_stream.first_ssrc(), mid().c_str()); ret = false; @@ -720,7 +718,7 @@ bool BaseChannel::UpdateRemoteStreams_w(const MediaContentDescription* content, std::string& error_desc) { RTC_LOG_THREAD_BLOCK_COUNT(); bool needs_re_registration = false; - if (!webrtc::RtpTransceiverDirectionHasSend(content->direction())) { + if (!RtpTransceiverDirectionHasSend(content->direction())) { RTC_DLOG(LS_VERBOSE) << "UpdateRemoteStreams_w: remote side will not send " "- disable payload type demuxing for " << ToString(); @@ -747,7 +745,7 @@ bool BaseChannel::UpdateRemoteStreams_w(const MediaContentDescription* content, RTC_LOG(LS_INFO) << "Remove remote ssrc: " << old_stream.first_ssrc() << " from " << ToString() << "."; } else { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to remove remote stream with ssrc %u from m-section with " "mid='%s'.", old_stream.first_ssrc(), mid().c_str()); @@ -771,12 +769,12 @@ bool BaseChannel::UpdateRemoteStreams_w(const MediaContentDescription* content, : "unsignaled") << " to " << ToString(); } else { - error_desc = webrtc::StringFormat( - "Failed to add remote stream ssrc: %s to %s", - new_stream.has_ssrcs() - ? std::to_string(new_stream.first_ssrc()).c_str() - : "unsignaled", - ToString().c_str()); + error_desc = + StringFormat("Failed to add remote stream ssrc: %s to %s", + new_stream.has_ssrcs() + ? std::to_string(new_stream.first_ssrc()).c_str() + : "unsignaled", + ToString().c_str()); return false; } } @@ -793,8 +791,8 @@ bool BaseChannel::UpdateRemoteStreams_w(const MediaContentDescription* content, // Re-register the sink to update after changing the demuxer criteria. if (needs_re_registration && !RegisterRtpDemuxerSink_w()) { - error_desc = webrtc::StringFormat( - "Failed to set up audio demuxing for mid='%s'.", mid().c_str()); + error_desc = StringFormat("Failed to set up audio demuxing for mid='%s'.", + mid().c_str()); return false; } @@ -869,8 +867,8 @@ VoiceChannel::~VoiceChannel() { void VoiceChannel::UpdateMediaSendRecvState_w() { // Render incoming data if we're the active call, and we have the local // content. We receive data on the default channel and multiplexed streams. - bool receive = enabled() && webrtc::RtpTransceiverDirectionHasRecv( - local_content_direction()); + bool receive = + enabled() && RtpTransceiverDirectionHasRecv(local_content_direction()); media_receive_channel()->SetPlayout(receive); // Send outgoing data if we're the active call, we have the remote content, @@ -898,12 +896,11 @@ bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content, AudioReceiverParameters recv_params = last_recv_params_; MediaChannelParametersFromMediaDescription( content, header_extensions, - webrtc::RtpTransceiverDirectionHasRecv(content->direction()), - &recv_params); + RtpTransceiverDirectionHasRecv(content->direction()), &recv_params); recv_params.mid = mid(); if (!media_receive_channel()->SetReceiverParameters(recv_params)) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set local audio description recv parameters for m-section " "with mid='%s'.", mid().c_str()); @@ -911,7 +908,7 @@ bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content, } bool criteria_modified = false; - if (webrtc::RtpTransceiverDirectionHasRecv(content->direction())) { + if (RtpTransceiverDirectionHasRecv(content->direction())) { for (const Codec& codec : content->codecs()) { if (MaybeAddHandledPayloadType(codec.id)) { criteria_modified = true; @@ -959,7 +956,7 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content, bool parameters_applied = media_send_channel()->SetSenderParameters(send_params); if (!parameters_applied) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set remote audio description send parameters for m-section " "with mid='%s'.", mid().c_str()); @@ -1021,8 +1018,8 @@ VideoChannel::~VideoChannel() { void VideoChannel::UpdateMediaSendRecvState_w() { // Send outgoing data if we're the active call, we have the remote content, // and we have had some form of connectivity. - bool receive = enabled() && webrtc::RtpTransceiverDirectionHasRecv( - local_content_direction()); + bool receive = + enabled() && RtpTransceiverDirectionHasRecv(local_content_direction()); media_receive_channel()->SetReceive(receive); bool send = IsReadyToSendMedia_w(); @@ -1048,8 +1045,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, MediaChannelParametersFromMediaDescription( content, header_extensions, - webrtc::RtpTransceiverDirectionHasRecv(content->direction()), - &recv_params); + RtpTransceiverDirectionHasRecv(content->direction()), &recv_params); VideoSenderParameters send_params = last_send_params_; @@ -1090,7 +1086,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, send_codec.packetization = std::nullopt; needs_send_params_update = true; } else if (!has_matching_packetization) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set local answer due to incompatible codec " "packetization for pt='%d' specified in m-section with mid='%s'.", send_codec.id, mid().c_str()); @@ -1104,7 +1100,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, } if (!media_receive_channel()->SetReceiverParameters(recv_params)) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set local video description recv parameters for m-section " "with mid='%s'.", mid().c_str()); @@ -1112,7 +1108,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, } bool criteria_modified = false; - if (webrtc::RtpTransceiverDirectionHasRecv(content->direction())) { + if (RtpTransceiverDirectionHasRecv(content->direction())) { for (const Codec& codec : content->codecs()) { if (MaybeAddHandledPayloadType(codec.id)) criteria_modified = true; @@ -1123,7 +1119,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, if (needs_send_params_update) { if (!media_send_channel()->SetSenderParameters(send_params)) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set send parameters for m-section with mid='%s'.", mid().c_str()); return false; @@ -1204,7 +1200,7 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, recv_codec.packetization = std::nullopt; needs_recv_params_update = true; } else if (!has_matching_packetization) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set remote answer due to incompatible codec " "packetization for pt='%d' specified in m-section with mid='%s'.", recv_codec.id, mid().c_str()); @@ -1218,7 +1214,7 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, } if (!media_send_channel()->SetSenderParameters(send_params)) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set remote video description send parameters for m-section " "with mid='%s'.", mid().c_str()); @@ -1234,7 +1230,7 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, if (needs_recv_params_update) { if (!media_receive_channel()->SetReceiverParameters(recv_params)) { - error_desc = webrtc::StringFormat( + error_desc = StringFormat( "Failed to set recv parameters for m-section with mid='%s'.", mid().c_str()); return false; diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index bdb4a05a9d..0f52078245 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -45,11 +45,11 @@ #include "p2p/dtls/fake_dtls_transport.h" #include "p2p/test/fake_packet_transport.h" #include "pc/dtls_srtp_transport.h" -#include "pc/jsep_transport.h" #include "pc/rtp_transport.h" #include "pc/rtp_transport_internal.h" #include "pc/session_description.h" #include "rtc_base/arraysize.h" +#include "rtc_base/async_packet_socket.h" #include "rtc_base/buffer.h" #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" @@ -103,14 +103,14 @@ template class Traits { public: - typedef ChannelT Channel; - typedef MediaSendChannelT MediaSendChannel; - typedef MediaReceiveChannelT MediaReceiveChannel; - typedef MediaSendChannelInterfaceT MediaSendChannelInterface; - typedef MediaReceiveChannelInterfaceT MediaReceiveChannelInterface; - typedef ContentT Content; - typedef MediaInfoT MediaInfo; - typedef OptionsT Options; + using Channel = ChannelT; + using MediaSendChannel = MediaSendChannelT; + using MediaReceiveChannel = MediaReceiveChannelT; + using MediaSendChannelInterface = MediaSendChannelInterfaceT; + using MediaReceiveChannelInterface = MediaReceiveChannelInterfaceT; + using Content = ContentT; + using MediaInfo = MediaInfoT; + using Options = OptionsT; }; class VoiceTraits : public Traits::AddLegacyStreamInContent( class VoiceChannelSingleThreadTest : public ChannelTest { public: - typedef ChannelTest Base; + using Base = ChannelTest; VoiceChannelSingleThreadTest() : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {} }; class VoiceChannelDoubleThreadTest : public ChannelTest { public: - typedef ChannelTest Base; + using Base = ChannelTest; VoiceChannelDoubleThreadTest() : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {} }; @@ -1659,7 +1659,7 @@ class VoiceChannelDoubleThreadTest : public ChannelTest { class VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest : public ChannelTest { public: - typedef ChannelTest Base; + using Base = ChannelTest; VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest() : Base(true, kPcmuFrameWithExtensions, @@ -1670,7 +1670,7 @@ class VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest class VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest : public ChannelTest { public: - typedef ChannelTest Base; + using Base = ChannelTest; VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest() : Base(true, kPcmuFrameWithExtensions, kRtcpReport, NetworkIsWorker::No) { } @@ -1724,14 +1724,14 @@ void ChannelTest::AddLegacyStreamInContent( class VideoChannelSingleThreadTest : public ChannelTest { public: - typedef ChannelTest Base; + using Base = ChannelTest; VideoChannelSingleThreadTest() : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::Yes) {} }; class VideoChannelDoubleThreadTest : public ChannelTest { public: - typedef ChannelTest Base; + using Base = ChannelTest; VideoChannelDoubleThreadTest() : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::No) {} }; diff --git a/pc/data_channel_controller_unittest.cc b/pc/data_channel_controller_unittest.cc index 88f8a9e6c7..71ab9b4b18 100644 --- a/pc/data_channel_controller_unittest.cc +++ b/pc/data_channel_controller_unittest.cc @@ -64,7 +64,7 @@ class MockDataChannelTransport : public DataChannelTransportInterface { SendData, (int channel_id, const SendDataParams& params, - const webrtc::CopyOnWriteBuffer& buffer), + const CopyOnWriteBuffer& buffer), (override)); MOCK_METHOD(RTCError, CloseChannel, (int channel_id), (override)); MOCK_METHOD(void, SetDataSink, (DataChannelSink * sink), (override)); diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc index de87405b30..e9476573b1 100644 --- a/pc/data_channel_integrationtest.cc +++ b/pc/data_channel_integrationtest.cc @@ -325,10 +325,10 @@ TEST_P(DataChannelIntegrationTest, caller()->data_channel()->Close(); EXPECT_THAT(WaitUntil([&] { return caller()->data_observer()->state(); }, - Eq(webrtc::DataChannelInterface::kClosed)), + Eq(DataChannelInterface::kClosed)), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return callee()->data_observer()->state(); }, - Eq(webrtc::DataChannelInterface::kClosed)), + Eq(DataChannelInterface::kClosed)), IsRtcOk()); } @@ -359,7 +359,7 @@ TEST_P(DataChannelIntegrationTest, EndToEndCallWithSctpDataChannelFullBuffer) { std::string data(256 * 1024, 'a'); for (size_t queued_size = 0; - queued_size < webrtc::DataChannelInterface::MaxSendQueueSize(); + queued_size < DataChannelInterface::MaxSendQueueSize(); queued_size += data.size()) { caller()->data_channel()->SendAsync(DataBuffer(data), nullptr); } diff --git a/pc/data_channel_unittest.cc b/pc/data_channel_unittest.cc index 293d33f4ba..9b4802afa3 100644 --- a/pc/data_channel_unittest.cc +++ b/pc/data_channel_unittest.cc @@ -752,12 +752,12 @@ TEST(DataChannelInterfaceTest, Coverage) { #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) TEST(DataChannelInterfaceDeathTest, SendDefaultImplDchecks) { - auto channel = webrtc::make_ref_counted(); + auto channel = make_ref_counted(); RTC_EXPECT_DEATH(channel->Send(DataBuffer("Foo")), "Check failed: false"); } TEST(DataChannelInterfaceDeathTest, SendAsyncDefaultImplDchecks) { - auto channel = webrtc::make_ref_counted(); + auto channel = make_ref_counted(); RTC_EXPECT_DEATH(channel->SendAsync(DataBuffer("Foo"), nullptr), "Check failed: false"); } diff --git a/pc/dtls_transport.cc b/pc/dtls_transport.cc index f79f1bb203..e95a5cfe67 100644 --- a/pc/dtls_transport.cc +++ b/pc/dtls_transport.cc @@ -134,14 +134,16 @@ void DtlsTransport::UpdateInformation() { set_info(DtlsTransportInformation( internal_dtls_transport_->dtls_state(), role, tls_version, ssl_cipher_suite, srtp_cipher, - internal_dtls_transport_->GetRemoteSSLCertChain())); + internal_dtls_transport_->GetRemoteSSLCertChain(), + internal_dtls_transport_->GetSslGroupId())); } else { RTC_LOG(LS_ERROR) << "DtlsTransport in connected state has incomplete " "TLS information"; set_info(DtlsTransportInformation( internal_dtls_transport_->dtls_state(), role, std::nullopt, std::nullopt, std::nullopt, - internal_dtls_transport_->GetRemoteSSLCertChain())); + internal_dtls_transport_->GetRemoteSSLCertChain(), + /* ssl_group_id= */ std::nullopt)); } } else { set_info( diff --git a/pc/dtmf_sender_unittest.cc b/pc/dtmf_sender_unittest.cc index d121809129..6c442e1419 100644 --- a/pc/dtmf_sender_unittest.cc +++ b/pc/dtmf_sender_unittest.cc @@ -306,7 +306,7 @@ TEST_F(DtmfSenderTest, InsertDtmfWhileSenderIsDeleted) { .clock = &fake_clock_}), webrtc::IsRtcOk()); // Delete the sender. - dtmf_ = NULL; + dtmf_ = nullptr; // The queue should be discontinued so no more tone callbacks. fake_clock_.AdvanceTime(webrtc::TimeDelta::Millis(200)); EXPECT_EQ(1U, observer_->tones().size()); diff --git a/pc/external_hmac.cc b/pc/external_hmac.cc index 6ee917d2ba..77f11a32d7 100644 --- a/pc/external_hmac.cc +++ b/pc/external_hmac.cc @@ -39,7 +39,7 @@ static const srtp_auth_test_case_t kExternalHmacTestCase0 = { const_cast(kExternalHmacTestCase0Data), // Data 10, // Octets in tag const_cast(kExternalHmacFakeTag), // Tag - NULL // Pointer to next + nullptr // Pointer to next // testcase }; @@ -75,7 +75,7 @@ srtp_err_status_t external_hmac_alloc(srtp_auth_t** a, // Allocate memory for auth and hmac_ctx_t structures. pointer = new uint8_t[(sizeof(ExternalHmacContext) + sizeof(srtp_auth_t))]; - if (pointer == NULL) + if (pointer == nullptr) return srtp_err_status_alloc_fail; // Set pointers diff --git a/pc/external_hmac.h b/pc/external_hmac.h index 3319beaed4..7dec6360df 100644 --- a/pc/external_hmac.h +++ b/pc/external_hmac.h @@ -40,10 +40,10 @@ // The HMAC context structure used to store authentication keys. // The pointer to the key will be allocated in the external_hmac_init function. // This pointer is owned by srtp_t in a template context. -typedef struct { +struct ExternalHmacContext { uint8_t key[HMAC_KEY_LENGTH]; int key_length; -} ExternalHmacContext; +}; srtp_err_status_t external_hmac_alloc(srtp_auth_t** a, int key_len, diff --git a/pc/ice_server_parsing.cc b/pc/ice_server_parsing.cc index 02612eb23a..c929a2f1cd 100644 --- a/pc/ice_server_parsing.cc +++ b/pc/ice_server_parsing.cc @@ -22,6 +22,7 @@ #include "api/candidate.h" #include "api/peer_connection_interface.h" #include "api/rtc_error.h" +#include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" #include "p2p/base/port_allocator.h" #include "p2p/base/port_interface.h" @@ -276,6 +277,12 @@ RTCError ParseIceServerUrl(const PeerConnectionInterface::IceServer& server, "ICE server parsing failed: TURN server with empty " "username or password"); } + // RFC 8489 limits the size of the STUN username field to 509 characters. + if (server.username.size() > kMaxTurnUsernameLength) { + LOG_AND_RETURN_ERROR( + RTCErrorType::INVALID_PARAMETER, + "ICE server parsing failed: TURN server username is too long"); + } // If the hostname field is not empty, then the server address must be // the resolved IP for that host, the hostname is needed later for TLS // handshake (SNI and Certificate verification). diff --git a/pc/ice_server_parsing_unittest.cc b/pc/ice_server_parsing_unittest.cc index df459e6ddd..4bc4f266f1 100644 --- a/pc/ice_server_parsing_unittest.cc +++ b/pc/ice_server_parsing_unittest.cc @@ -14,6 +14,7 @@ #include #include "api/peer_connection_interface.h" +#include "api/rtc_error.h" #include "p2p/base/port.h" #include "p2p/base/port_allocator.h" #include "p2p/base/port_interface.h" @@ -239,4 +240,33 @@ TEST_F(IceServerParsingTest, ParseMultipleUrls) { EXPECT_EQ(1U, turn_servers_.size()); } +TEST_F(IceServerParsingTest, TooLongUsername) { + // 509 characters is the maximum length of the username field in RFC 8489. + std::string k509Characters = + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaa"; + ASSERT_EQ(k509Characters.size(), 509u); + // 509 characters is supported. + EXPECT_TRUE(ParseUrl("turn:hostname", k509Characters, "password")); + + // 510 is not supported. + PeerConnectionInterface::IceServers servers; + PeerConnectionInterface::IceServer server; + server.urls.push_back("turn:hostname"); + server.username = k509Characters + "b"; + server.password = "password"; + servers.push_back(server); + stun_servers_.clear(); + turn_servers_.clear(); + auto error = ParseIceServersOrError(servers, &stun_servers_, &turn_servers_); + EXPECT_FALSE(error.ok()); + EXPECT_EQ(error.type(), RTCErrorType::INVALID_PARAMETER); +} + } // namespace webrtc diff --git a/pc/jsep_ice_candidate.cc b/pc/jsep_ice_candidate.cc index 0b0a282431..3245f45584 100644 --- a/pc/jsep_ice_candidate.cc +++ b/pc/jsep_ice_candidate.cc @@ -31,7 +31,7 @@ IceCandidateInterface* CreateIceCandidate(const std::string& sdp_mid, JsepIceCandidate* jsep_ice = new JsepIceCandidate(sdp_mid, sdp_mline_index); if (!jsep_ice->Initialize(sdp, error)) { delete jsep_ice; - return NULL; + return nullptr; } return jsep_ice; } diff --git a/pc/jsep_session_description.cc b/pc/jsep_session_description.cc index fe4bd79afc..48feb1012a 100644 --- a/pc/jsep_session_description.cc +++ b/pc/jsep_session_description.cc @@ -287,7 +287,7 @@ size_t JsepSessionDescription::number_of_mediasections() const { const IceCandidateCollection* JsepSessionDescription::candidates( size_t mediasection_index) const { if (mediasection_index >= candidate_collection_.size()) - return NULL; + return nullptr; return &candidate_collection_[mediasection_index]; } diff --git a/pc/jsep_session_description_unittest.cc b/pc/jsep_session_description_unittest.cc index 60247df538..789ece47fb 100644 --- a/pc/jsep_session_description_unittest.cc +++ b/pc/jsep_session_description_unittest.cc @@ -74,12 +74,12 @@ CreateCricketSessionDescription() { webrtc::CN_AUDIO, webrtc::TransportDescription( std::vector(), kCandidateUfragVoice, kCandidatePwdVoice, - webrtc::ICEMODE_FULL, webrtc::CONNECTIONROLE_NONE, NULL))); + webrtc::ICEMODE_FULL, webrtc::CONNECTIONROLE_NONE, nullptr))); desc->AddTransportInfo(webrtc::TransportInfo( webrtc::CN_VIDEO, webrtc::TransportDescription( std::vector(), kCandidateUfragVideo, kCandidatePwdVideo, - webrtc::ICEMODE_FULL, webrtc::CONNECTIONROLE_NONE, NULL))); + webrtc::ICEMODE_FULL, webrtc::CONNECTIONROLE_NONE, nullptr))); return desc; } @@ -173,10 +173,10 @@ TEST_F(JsepSessionDescriptionTest, AddCandidateWithoutMid) { JsepIceCandidate jsep_candidate("", 0, candidate_); EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0); - ASSERT_TRUE(ice_candidates != NULL); + ASSERT_TRUE(ice_candidates != nullptr); EXPECT_EQ(1u, ice_candidates->count()); const IceCandidateInterface* ice_candidate = ice_candidates->at(0); - ASSERT_TRUE(ice_candidate != NULL); + ASSERT_TRUE(ice_candidate != nullptr); candidate_.set_username(kCandidateUfragVoice); candidate_.set_password(kCandidatePwdVoice); EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_)); @@ -193,10 +193,10 @@ TEST_F(JsepSessionDescriptionTest, AddAndRemoveCandidatesWithMid) { EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); EXPECT_EQ(0u, jsep_desc_->candidates(0)->count()); const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(1); - ASSERT_TRUE(ice_candidates != NULL); + ASSERT_TRUE(ice_candidates != nullptr); EXPECT_EQ(1u, ice_candidates->count()); const IceCandidateInterface* ice_candidate = ice_candidates->at(0); - ASSERT_TRUE(ice_candidate != NULL); + ASSERT_TRUE(ice_candidate != nullptr); candidate_.set_username(kCandidateUfragVideo); candidate_.set_password(kCandidatePwdVideo); EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_)); @@ -216,10 +216,10 @@ TEST_F(JsepSessionDescriptionTest, AddCandidateAlreadyHasUfrag) { JsepIceCandidate jsep_candidate("audio", 0, candidate_); EXPECT_TRUE(jsep_desc_->AddCandidate(&jsep_candidate)); const IceCandidateCollection* ice_candidates = jsep_desc_->candidates(0); - ASSERT_TRUE(ice_candidates != NULL); + ASSERT_TRUE(ice_candidates != nullptr); EXPECT_EQ(1u, ice_candidates->count()); const IceCandidateInterface* ice_candidate = ice_candidates->at(0); - ASSERT_TRUE(ice_candidate != NULL); + ASSERT_TRUE(ice_candidate != nullptr); candidate_.set_username(kCandidateUfrag); candidate_.set_password(kCandidatePwd); EXPECT_TRUE(ice_candidate->candidate().IsEquivalent(candidate_)); diff --git a/pc/jsep_transport.cc b/pc/jsep_transport.cc index 8f0a3979c4..b1f179cef6 100644 --- a/pc/jsep_transport.cc +++ b/pc/jsep_transport.cc @@ -366,7 +366,7 @@ RTCError JsepTransport::VerifyCertificateFingerprint( } std::unique_ptr fp_tmp = SSLFingerprint::CreateUnique( fingerprint->algorithm, *certificate->identity()); - RTC_DCHECK(fp_tmp.get() != NULL); + RTC_DCHECK(fp_tmp.get() != nullptr); if (*fp_tmp == *fingerprint) { return RTCError::OK(); } @@ -625,9 +625,9 @@ RTCError JsepTransport::NegotiateDtlsRole( break; } } else { - if ((*current_dtls_role == webrtc::SSL_CLIENT && + if ((*current_dtls_role == SSL_CLIENT && remote_connection_role == CONNECTIONROLE_ACTIVE) || - (*current_dtls_role == webrtc::SSL_SERVER && + (*current_dtls_role == SSL_SERVER && remote_connection_role == CONNECTIONROLE_PASSIVE)) { return RTCError(RTCErrorType::INVALID_PARAMETER, "Offerer must use current negotiated role for " @@ -648,8 +648,7 @@ RTCError JsepTransport::NegotiateDtlsRole( // If local is passive, local will act as server. } - *negotiated_dtls_role = - (is_remote_server ? webrtc::SSL_CLIENT : webrtc::SSL_SERVER); + *negotiated_dtls_role = (is_remote_server ? SSL_CLIENT : SSL_SERVER); return RTCError::OK(); } diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc index e8d811769f..fa42946900 100644 --- a/pc/jsep_transport_controller_unittest.cc +++ b/pc/jsep_transport_controller_unittest.cc @@ -406,7 +406,7 @@ class JsepTransportControllerTest : public JsepTransportController::Observer, // signaled correctly. std::map changed_rtp_transport_by_mid_; std::map changed_dtls_transport_by_mid_; - webrtc::PayloadTypePicker payload_type_picker_; + PayloadTypePicker payload_type_picker_; // Transport controller needs to be destroyed first, because it may issue // callbacks that modify the changed_*_by_mid in the destructor. std::unique_ptr transport_controller_; @@ -563,7 +563,7 @@ TEST_F(JsepTransportControllerTest, MaybeStartGathering) { transport_controller_->MaybeStartGathering(); EXPECT_THAT(WaitUntil([&] { return kIceGatheringGathering; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, gathering_state_signal_count_); } @@ -711,20 +711,20 @@ TEST_F(JsepTransportControllerTest, SignalConnectionStateFailed) { fake_ice->SetConnectionCount(0); EXPECT_THAT(WaitUntil([&] { return kIceConnectionFailed; }, ::testing::Eq(connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, connection_state_signal_count_); EXPECT_THAT( WaitUntil([&] { return PeerConnectionInterface::kIceConnectionFailed; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, ice_connection_state_signal_count_); EXPECT_THAT( WaitUntil( [&] { return PeerConnectionInterface::PeerConnectionState::kFailed; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, combined_connection_state_signal_count_); } @@ -756,20 +756,20 @@ TEST_F(JsepTransportControllerTest, EXPECT_THAT(WaitUntil([&] { return kIceConnectionFailed; }, ::testing::Eq(connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, connection_state_signal_count_); EXPECT_THAT( WaitUntil([&] { return PeerConnectionInterface::kIceConnectionFailed; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, ice_connection_state_signal_count_); EXPECT_THAT( WaitUntil( [&] { return PeerConnectionInterface::PeerConnectionState::kFailed; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, combined_connection_state_signal_count_); @@ -781,14 +781,14 @@ TEST_F(JsepTransportControllerTest, fake_video_dtls->SetWritable(true); EXPECT_THAT(WaitUntil([&] { return kIceConnectionConnected; }, ::testing::Eq(connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, connection_state_signal_count_); EXPECT_THAT( WaitUntil( [&] { return PeerConnectionInterface::kIceConnectionConnected; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, ice_connection_state_signal_count_); EXPECT_THAT( @@ -797,7 +797,7 @@ TEST_F(JsepTransportControllerTest, return PeerConnectionInterface::PeerConnectionState::kConnected; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, combined_connection_state_signal_count_); } @@ -827,7 +827,7 @@ TEST_F(JsepTransportControllerTest, SignalConnectionStateComplete) { EXPECT_THAT( WaitUntil([&] { return PeerConnectionInterface::kIceConnectionChecking; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, ice_connection_state_signal_count_); EXPECT_THAT( @@ -836,7 +836,7 @@ TEST_F(JsepTransportControllerTest, SignalConnectionStateComplete) { return PeerConnectionInterface::PeerConnectionState::kConnecting; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, combined_connection_state_signal_count_); @@ -846,20 +846,20 @@ TEST_F(JsepTransportControllerTest, SignalConnectionStateComplete) { EXPECT_THAT(WaitUntil([&] { return kIceConnectionFailed; }, ::testing::Eq(connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, connection_state_signal_count_); EXPECT_THAT( WaitUntil([&] { return PeerConnectionInterface::kIceConnectionFailed; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, ice_connection_state_signal_count_); EXPECT_THAT( WaitUntil( [&] { return PeerConnectionInterface::PeerConnectionState::kFailed; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, combined_connection_state_signal_count_); @@ -873,14 +873,14 @@ TEST_F(JsepTransportControllerTest, SignalConnectionStateComplete) { fake_video_dtls->SetWritable(true); EXPECT_THAT(WaitUntil([&] { return kIceConnectionCompleted; }, ::testing::Eq(connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, connection_state_signal_count_); EXPECT_THAT( WaitUntil( [&] { return PeerConnectionInterface::kIceConnectionCompleted; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, ice_connection_state_signal_count_); EXPECT_THAT( @@ -889,7 +889,7 @@ TEST_F(JsepTransportControllerTest, SignalConnectionStateComplete) { return PeerConnectionInterface::PeerConnectionState::kConnected; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, combined_connection_state_signal_count_); } @@ -908,7 +908,7 @@ TEST_F(JsepTransportControllerTest, SignalIceGatheringStateGathering) { // Should be in the gathering state as soon as any transport starts gathering. EXPECT_THAT(WaitUntil([&] { return kIceGatheringGathering; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, gathering_state_signal_count_); } @@ -929,7 +929,7 @@ TEST_F(JsepTransportControllerTest, SignalIceGatheringStateComplete) { fake_audio_dtls->fake_ice_transport()->MaybeStartGathering(); EXPECT_THAT(WaitUntil([&] { return kIceGatheringGathering; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, gathering_state_signal_count_); @@ -941,14 +941,14 @@ TEST_F(JsepTransportControllerTest, SignalIceGatheringStateComplete) { fake_video_dtls->fake_ice_transport()->MaybeStartGathering(); EXPECT_THAT(WaitUntil([&] { return kIceGatheringGathering; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, gathering_state_signal_count_); fake_video_dtls->fake_ice_transport()->SetCandidatesGatheringComplete(); EXPECT_THAT(WaitUntil([&] { return kIceGatheringComplete; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, gathering_state_signal_count_); } @@ -973,9 +973,9 @@ TEST_F(JsepTransportControllerTest, EXPECT_NE(fake_audio_dtls, fake_video_dtls); fake_audio_dtls->fake_ice_transport()->MaybeStartGathering(); - EXPECT_THAT(WaitUntil([&] { return webrtc::kIceGatheringGathering; }, + EXPECT_THAT(WaitUntil([&] { return kIceGatheringGathering; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, gathering_state_signal_count_); @@ -998,7 +998,7 @@ TEST_F(JsepTransportControllerTest, EXPECT_EQ(fake_audio_dtls, fake_video_dtls); EXPECT_THAT(WaitUntil([&] { return kIceConnectionCompleted; }, ::testing::Eq(connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(PeerConnectionInterface::kIceConnectionCompleted, ice_connection_state_); @@ -1006,7 +1006,7 @@ TEST_F(JsepTransportControllerTest, combined_connection_state_); EXPECT_THAT(WaitUntil([&] { return kIceGatheringComplete; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, gathering_state_signal_count_); } @@ -1039,7 +1039,7 @@ TEST_F(JsepTransportControllerTest, EXPECT_THAT( WaitUntil([&] { return PeerConnectionInterface::kIceConnectionChecking; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, ice_connection_state_signal_count_); EXPECT_THAT( @@ -1048,12 +1048,12 @@ TEST_F(JsepTransportControllerTest, return PeerConnectionInterface::PeerConnectionState::kConnecting; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, combined_connection_state_signal_count_); EXPECT_THAT(WaitUntil([&] { return kIceGatheringGathering; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1, gathering_state_signal_count_); @@ -1067,19 +1067,19 @@ TEST_F(JsepTransportControllerTest, EXPECT_THAT( WaitUntil([&] { return PeerConnectionInterface::kIceConnectionNew; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, ice_connection_state_signal_count_); EXPECT_THAT( WaitUntil( [&] { return PeerConnectionInterface::PeerConnectionState::kNew; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, combined_connection_state_signal_count_); EXPECT_THAT(WaitUntil([&] { return kIceGatheringNew; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, gathering_state_signal_count_); @@ -1089,7 +1089,7 @@ TEST_F(JsepTransportControllerTest, EXPECT_THAT( WaitUntil([&] { return PeerConnectionInterface::kIceConnectionChecking; }, ::testing::Eq(ice_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, ice_connection_state_signal_count_); EXPECT_THAT( @@ -1098,12 +1098,12 @@ TEST_F(JsepTransportControllerTest, return PeerConnectionInterface::PeerConnectionState::kConnecting; }, ::testing::Eq(combined_connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, combined_connection_state_signal_count_); EXPECT_THAT(WaitUntil([&] { return kIceGatheringGathering; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(3, gathering_state_signal_count_); } @@ -1123,7 +1123,7 @@ TEST_F(JsepTransportControllerTest, SignalCandidatesGathered) { fake_audio_dtls->fake_ice_transport(), CreateCandidate(kAudioMid1, 1)); EXPECT_THAT( WaitUntil([&] { return 1; }, ::testing::Eq(candidates_signal_count_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(1u, candidates_[kAudioMid1].size()); } @@ -1140,25 +1140,25 @@ TEST_F(JsepTransportControllerTest, IceSignalingOccursOnNetworkThread) { // connecting --> connected --> completed EXPECT_THAT(WaitUntil([&] { return kIceConnectionCompleted; }, ::testing::Eq(connection_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, connection_state_signal_count_); // new --> gathering --> complete EXPECT_THAT(WaitUntil([&] { return kIceGatheringComplete; }, ::testing::Eq(gathering_state_), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_EQ(2, gathering_state_signal_count_); - EXPECT_THAT(WaitUntil([&] { return candidates_[kAudioMid1].size(); }, - ::testing::Eq(1u), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), - IsRtcOk()); - EXPECT_THAT(WaitUntil([&] { return candidates_[kVideoMid1].size(); }, - ::testing::Eq(1u), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidates_[kAudioMid1].size(); }, + ::testing::Eq(1u), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return candidates_[kVideoMid1].size(); }, + ::testing::Eq(1u), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); EXPECT_EQ(2, candidates_signal_count_); EXPECT_EQ(ice_signaled_on_thread_, network_thread_.get()); diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc index f11d41625d..1b46142e29 100644 --- a/pc/jsep_transport_unittest.cc +++ b/pc/jsep_transport_unittest.cc @@ -60,8 +60,7 @@ namespace webrtc { namespace { -using webrtc::SdpType; -using ::webrtc::test::ScopedKeyValueConfig; +using test::ScopedKeyValueConfig; static const char kIceUfrag1[] = "U001"; static const char kIcePwd1[] = "TESTICEPWD00000000000001"; @@ -185,7 +184,7 @@ class JsepTransport2Test : public ::testing::Test, public sigslot::has_slots<> { Candidate c; c.set_address(SocketAddress("192.168.1.1", 8000)); c.set_component(component); - c.set_protocol(webrtc::UDP_PROTOCOL_NAME); + c.set_protocol(UDP_PROTOCOL_NAME); c.set_priority(1); return c; } @@ -261,9 +260,9 @@ TEST_P(JsepTransport2WithRtcpMux, SetDtlsParameters) { // Create certificates. scoped_refptr local_cert = - RTCCertificate::Create(SSLIdentity::Create("local", webrtc::KT_DEFAULT)); + RTCCertificate::Create(SSLIdentity::Create("local", KT_DEFAULT)); scoped_refptr remote_cert = - RTCCertificate::Create(SSLIdentity::Create("remote", webrtc::KT_DEFAULT)); + RTCCertificate::Create(SSLIdentity::Create("remote", KT_DEFAULT)); jsep_transport_->SetLocalCertificate(local_cert); // Apply offer. @@ -287,7 +286,7 @@ TEST_P(JsepTransport2WithRtcpMux, SetDtlsParameters) { // transport descriptions. auto role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); - EXPECT_EQ(webrtc::SSL_SERVER, + EXPECT_EQ(SSL_SERVER, role); // Because remote description was "active". auto fake_dtls = static_cast(jsep_transport_->rtp_dtls_transport()); @@ -311,9 +310,9 @@ TEST_P(JsepTransport2WithRtcpMux, SetDtlsParametersWithPassiveAnswer) { // Create certificates. scoped_refptr local_cert = - RTCCertificate::Create(SSLIdentity::Create("local", webrtc::KT_DEFAULT)); + RTCCertificate::Create(SSLIdentity::Create("local", KT_DEFAULT)); scoped_refptr remote_cert = - RTCCertificate::Create(SSLIdentity::Create("remote", webrtc::KT_DEFAULT)); + RTCCertificate::Create(SSLIdentity::Create("remote", KT_DEFAULT)); jsep_transport_->SetLocalCertificate(local_cert); // Apply offer. @@ -337,7 +336,7 @@ TEST_P(JsepTransport2WithRtcpMux, SetDtlsParametersWithPassiveAnswer) { // transport descriptions. auto role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); - EXPECT_EQ(webrtc::SSL_CLIENT, + EXPECT_EQ(SSL_CLIENT, role); // Because remote description was "passive". auto fake_dtls = static_cast(jsep_transport_->rtp_dtls_transport()); @@ -422,7 +421,7 @@ TEST_P(JsepTransport2WithRtcpMux, VerifyCertificateFingerprint) { EXPECT_FALSE( jsep_transport_->VerifyCertificateFingerprint(nullptr, nullptr).ok()); - KeyType key_types[] = {webrtc::KT_RSA, webrtc::KT_ECDSA}; + KeyType key_types[] = {KT_RSA, KT_ECDSA}; for (auto& key_type : key_types) { scoped_refptr certificate = @@ -465,7 +464,7 @@ TEST_P(JsepTransport2WithRtcpMux, ValidDtlsRoleNegotiation) { // Just use the same certificate for both sides; doesn't really matter in a // non end-to-end test. scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing", KT_ECDSA)); JsepTransportDescription local_description = MakeJsepTransportDescription( rtcp_mux_enabled, kIceUfrag1, kIcePwd1, certificate); @@ -516,7 +515,7 @@ TEST_P(JsepTransport2WithRtcpMux, ValidDtlsRoleNegotiation) { param.local_type) .ok()); } - EXPECT_EQ(webrtc::SSL_CLIENT, *jsep_transport_->GetDtlsRole()); + EXPECT_EQ(SSL_CLIENT, *jsep_transport_->GetDtlsRole()); } // Parameters which set the SSL role to SSL_SERVER. @@ -561,7 +560,7 @@ TEST_P(JsepTransport2WithRtcpMux, ValidDtlsRoleNegotiation) { param.local_type) .ok()); } - EXPECT_EQ(webrtc::SSL_SERVER, *jsep_transport_->GetDtlsRole()); + EXPECT_EQ(SSL_SERVER, *jsep_transport_->GetDtlsRole()); } } @@ -571,7 +570,7 @@ TEST_P(JsepTransport2WithRtcpMux, InvalidDtlsRoleNegotiation) { // Just use the same certificate for both sides; doesn't really matter in a // non end-to-end test. scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing", KT_ECDSA)); JsepTransportDescription local_description = MakeJsepTransportDescription( rtcp_mux_enabled, kIceUfrag1, kIcePwd1, certificate); @@ -698,7 +697,7 @@ TEST_F(JsepTransport2Test, ValidDtlsReofferFromAnswerer) { // Just use the same certificate for both sides; doesn't really matter in a // non end-to-end test. scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing", KT_ECDSA)); bool rtcp_mux_enabled = true; jsep_transport_ = CreateJsepTransport2(rtcp_mux_enabled); jsep_transport_->SetLocalCertificate(certificate); @@ -744,7 +743,7 @@ TEST_F(JsepTransport2Test, InvalidDtlsReofferFromAnswerer) { // Just use the same certificate for both sides; doesn't really matter in a // non end-to-end test. scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing", KT_ECDSA)); bool rtcp_mux_enabled = true; jsep_transport_ = CreateJsepTransport2(rtcp_mux_enabled); jsep_transport_->SetLocalCertificate(certificate); @@ -789,7 +788,7 @@ TEST_F(JsepTransport2Test, InvalidDtlsReofferFromAnswerer) { // since JSEP requires generating "actpass". TEST_F(JsepTransport2Test, RemoteOfferWithCurrentNegotiatedDtlsRole) { scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing", KT_ECDSA)); bool rtcp_mux_enabled = true; jsep_transport_ = CreateJsepTransport2(rtcp_mux_enabled); jsep_transport_->SetLocalCertificate(certificate); @@ -815,7 +814,7 @@ TEST_F(JsepTransport2Test, RemoteOfferWithCurrentNegotiatedDtlsRole) { // Sanity check that role was actually negotiated. std::optional role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); - EXPECT_EQ(webrtc::SSL_CLIENT, *role); + EXPECT_EQ(SSL_CLIENT, *role); // Subsequent offer with current negotiated role of "passive". remote_desc.transport_desc.connection_role = CONNECTIONROLE_PASSIVE; @@ -833,7 +832,7 @@ TEST_F(JsepTransport2Test, RemoteOfferWithCurrentNegotiatedDtlsRole) { // role is rejected. TEST_F(JsepTransport2Test, RemoteOfferThatChangesNegotiatedDtlsRole) { scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing", KT_ECDSA)); bool rtcp_mux_enabled = true; jsep_transport_ = CreateJsepTransport2(rtcp_mux_enabled); jsep_transport_->SetLocalCertificate(certificate); @@ -859,7 +858,7 @@ TEST_F(JsepTransport2Test, RemoteOfferThatChangesNegotiatedDtlsRole) { // Sanity check that role was actually negotiated. std::optional role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); - EXPECT_EQ(webrtc::SSL_CLIENT, *role); + EXPECT_EQ(SSL_CLIENT, *role); // Subsequent offer with current negotiated role of "passive". remote_desc.transport_desc.connection_role = CONNECTIONROLE_ACTIVE; @@ -876,9 +875,9 @@ TEST_F(JsepTransport2Test, RemoteOfferThatChangesNegotiatedDtlsRole) { // Test that a remote offer which changes both fingerprint and role is accepted. TEST_F(JsepTransport2Test, RemoteOfferThatChangesFingerprintAndDtlsRole) { scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing1", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing1", KT_ECDSA)); scoped_refptr certificate2 = - RTCCertificate::Create(SSLIdentity::Create("testing2", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing2", KT_ECDSA)); bool rtcp_mux_enabled = true; jsep_transport_ = CreateJsepTransport2(rtcp_mux_enabled); jsep_transport_->SetLocalCertificate(certificate); @@ -908,7 +907,7 @@ TEST_F(JsepTransport2Test, RemoteOfferThatChangesFingerprintAndDtlsRole) { // Sanity check that role was actually negotiated. std::optional role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); - EXPECT_EQ(webrtc::SSL_CLIENT, *role); + EXPECT_EQ(SSL_CLIENT, *role); // Subsequent exchange with new remote fingerprint and different role. local_desc.transport_desc.connection_role = CONNECTIONROLE_PASSIVE; @@ -923,14 +922,14 @@ TEST_F(JsepTransport2Test, RemoteOfferThatChangesFingerprintAndDtlsRole) { role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); - EXPECT_EQ(webrtc::SSL_SERVER, *role); + EXPECT_EQ(SSL_SERVER, *role); } // Testing that a legacy client that doesn't use the setup attribute will be // interpreted as having an active role. TEST_F(JsepTransport2Test, DtlsSetupWithLegacyAsAnswerer) { scoped_refptr certificate = - RTCCertificate::Create(SSLIdentity::Create("testing", webrtc::KT_ECDSA)); + RTCCertificate::Create(SSLIdentity::Create("testing", KT_ECDSA)); bool rtcp_mux_enabled = true; jsep_transport_ = CreateJsepTransport2(rtcp_mux_enabled); jsep_transport_->SetLocalCertificate(certificate); @@ -958,7 +957,7 @@ TEST_F(JsepTransport2Test, DtlsSetupWithLegacyAsAnswerer) { ASSERT_TRUE(role); // Since legacy answer omitted setup atribute, and we offered actpass, we // should act as passive (server). - EXPECT_EQ(webrtc::SSL_SERVER, *role); + EXPECT_EQ(SSL_SERVER, *role); } // Tests that when the RTCP mux is successfully negotiated, the RTCP transport @@ -1060,11 +1059,11 @@ class JsepTransport2HeaderExtensionTest OnReadPacket2(transport, packet); }); - auto cert1 = RTCCertificate::Create( - SSLIdentity::Create("session1", webrtc::KT_DEFAULT)); + auto cert1 = + RTCCertificate::Create(SSLIdentity::Create("session1", KT_DEFAULT)); jsep_transport1_->rtp_dtls_transport()->SetLocalCertificate(cert1); - auto cert2 = RTCCertificate::Create( - SSLIdentity::Create("session1", webrtc::KT_DEFAULT)); + auto cert2 = + RTCCertificate::Create(SSLIdentity::Create("session1", KT_DEFAULT)); jsep_transport2_->rtp_dtls_transport()->SetLocalCertificate(cert2); } @@ -1122,8 +1121,8 @@ class JsepTransport2HeaderExtensionTest memcpy(rtp_packet_data, kPcmuFrameWithExtensions, rtp_len); // In order to be able to run this test function multiple times we can not // use the same sequence number twice. Increase the sequence number by one. - webrtc::SetBE16(reinterpret_cast(rtp_packet_data) + 2, - ++sequence_number_); + SetBE16(reinterpret_cast(rtp_packet_data) + 2, + ++sequence_number_); CopyOnWriteBuffer rtp_packet(rtp_packet_data, rtp_len, packet_size); int packet_count_before = received_packet_count_; @@ -1158,8 +1157,8 @@ TEST_P(JsepTransport2HeaderExtensionTest, EncryptedHeaderExtensionNegotiation) { auto fake_dtls2 = static_cast(jsep_transport2_->rtp_dtls_transport()); - fake_dtls1->SetSrtpCryptoSuite(webrtc::kSrtpAeadAes256Gcm); - fake_dtls2->SetSrtpCryptoSuite(webrtc::kSrtpAeadAes256Gcm); + fake_dtls1->SetSrtpCryptoSuite(kSrtpAeadAes256Gcm); + fake_dtls2->SetSrtpCryptoSuite(kSrtpAeadAes256Gcm); } if (scenario == Scenario::kDtlsBeforeCallerSendOffer) { diff --git a/pc/legacy_stats_collector.cc b/pc/legacy_stats_collector.cc index 87cc3eb7f8..e871468183 100644 --- a/pc/legacy_stats_collector.cc +++ b/pc/legacy_stats_collector.cc @@ -97,10 +97,10 @@ struct TypeForAdd { const ValueType& value; }; -typedef TypeForAdd BoolForAdd; -typedef TypeForAdd FloatForAdd; -typedef TypeForAdd Int64ForAdd; -typedef TypeForAdd IntForAdd; +using BoolForAdd = TypeForAdd; +using FloatForAdd = TypeForAdd; +using Int64ForAdd = TypeForAdd; +using IntForAdd = TypeForAdd; StatsReport* AddTrackReport(StatsCollection* reports, const std::string& track_id) { @@ -576,7 +576,7 @@ double LegacyStatsCollector::GetTimeNow() { // to GetStats. void LegacyStatsCollector::AddStream(MediaStreamInterface* stream) { RTC_DCHECK_RUN_ON(pc_->signaling_thread()); - RTC_DCHECK(stream != NULL); + RTC_DCHECK(stream != nullptr); CreateTrackReports(stream->GetAudioTracks(), &reports_, &track_ids_); @@ -599,7 +599,7 @@ void LegacyStatsCollector::AddTrack(MediaStreamTrackInterface* track) { void LegacyStatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc) { RTC_DCHECK_RUN_ON(pc_->signaling_thread()); - RTC_DCHECK(audio_track != NULL); + RTC_DCHECK(audio_track != nullptr); #if RTC_DCHECK_IS_ON for (const auto& track : local_audio_tracks_) RTC_DCHECK(track.first != audio_track || track.second != ssrc); @@ -621,7 +621,7 @@ void LegacyStatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track, void LegacyStatsCollector::RemoveLocalAudioTrack( AudioTrackInterface* audio_track, uint32_t ssrc) { - RTC_DCHECK(audio_track != NULL); + RTC_DCHECK(audio_track != nullptr); local_audio_tracks_.erase( std::remove_if( local_audio_tracks_.begin(), local_audio_tracks_.end(), @@ -634,7 +634,7 @@ void LegacyStatsCollector::RemoveLocalAudioTrack( void LegacyStatsCollector::GetStats(MediaStreamTrackInterface* track, StatsReports* reports) { RTC_DCHECK_RUN_ON(pc_->signaling_thread()); - RTC_DCHECK(reports != NULL); + RTC_DCHECK(reports != nullptr); RTC_DCHECK(reports->empty()); Thread::ScopedDisallowBlockingCalls no_blocking_calls; @@ -934,7 +934,7 @@ LegacyStatsCollector::SessionStats LegacyStatsCollector::ExtractSessionInfo_n( transport_names.insert(entry.second); } - std::map transport_stats_by_name = + std::map transport_stats_by_name = pc_->GetTransportStatsByNames(transport_names); for (auto& entry : transport_stats_by_name) { @@ -1067,7 +1067,7 @@ void LegacyStatsCollector::ExtractBweInfo() { auto transceivers = pc_->GetTransceiversInternal(); std::vector video_media_channels; for (const auto& transceiver : transceivers) { - if (transceiver->media_type() != webrtc::MediaType::VIDEO) { + if (transceiver->media_type() != MediaType::VIDEO) { continue; } auto* video_channel = transceiver->internal()->channel(); @@ -1200,11 +1200,11 @@ class VideoChannelStatsGatherer final : public ChannelStatsGatherer { std::unique_ptr CreateChannelStatsGatherer( ChannelInterface* channel) { RTC_DCHECK(channel); - if (channel->media_type() == webrtc::MediaType::AUDIO) { + if (channel->media_type() == MediaType::AUDIO) { return std::make_unique( channel->AsVoiceChannel()); } else { - RTC_DCHECK_EQ(channel->media_type(), webrtc::MediaType::VIDEO); + RTC_DCHECK_EQ(channel->media_type(), MediaType::VIDEO); return std::make_unique( channel->AsVideoChannel()); } @@ -1360,7 +1360,7 @@ void LegacyStatsCollector::UpdateStatsFromExistingLocalAudioTracks( uint32_t ssrc = it.second; StatsReport* report = GetReport(StatsReport::kStatsReportTypeSsrc, absl::StrCat(ssrc), StatsReport::kSend); - if (report == NULL) { + if (report == nullptr) { // This can happen if a local audio track is added to a stream on the // fly and the report has not been set up yet. Do nothing in this case. RTC_LOG(LS_ERROR) << "Stats report does not exist for ssrc " << ssrc; @@ -1383,7 +1383,7 @@ void LegacyStatsCollector::UpdateReportFromAudioTrack( StatsReport* report, bool has_remote_tracks) { RTC_DCHECK_RUN_ON(pc_->signaling_thread()); - RTC_DCHECK(track != NULL); + RTC_DCHECK(track != nullptr); // Don't overwrite report values if they're not available. int signal_level; diff --git a/pc/legacy_stats_collector_unittest.cc b/pc/legacy_stats_collector_unittest.cc index 1f02180733..f9af394c63 100644 --- a/pc/legacy_stats_collector_unittest.cc +++ b/pc/legacy_stats_collector_unittest.cc @@ -111,7 +111,7 @@ class FakeAudioTrack : public MediaStreamTrack { : MediaStreamTrack(id), processor_(make_ref_counted()) {} std::string kind() const override { return "audio"; } - AudioSourceInterface* GetSource() const override { return NULL; } + AudioSourceInterface* GetSource() const override { return nullptr; } void AddSink(AudioTrackSinkInterface* sink) override {} void RemoveSink(AudioTrackSinkInterface* sink) override {} bool GetSignalLevel(int* level) override { @@ -148,7 +148,7 @@ class FakeAudioTrackWithInitValue : MediaStreamTrack(id), processor_(make_ref_counted()) {} std::string kind() const override { return "audio"; } - AudioSourceInterface* GetSource() const override { return NULL; } + AudioSourceInterface* GetSource() const override { return nullptr; } void AddSink(AudioTrackSinkInterface* sink) override {} void RemoveSink(AudioTrackSinkInterface* sink) override {} bool GetSignalLevel(int* level) override { @@ -295,7 +295,7 @@ void CheckCertChainReports(const StatsReports& reports, size_t i = 0; while (true) { const StatsReport* report = FindReportById(reports, *certificate_id); - ASSERT_TRUE(report != NULL); + ASSERT_TRUE(report != nullptr); std::string der_base64; EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameDer, &der_base64)); @@ -745,8 +745,8 @@ static scoped_refptr CreateMockSender( EXPECT_CALL(*sender, media_type()) .WillRepeatedly( Return(track->kind() == MediaStreamTrackInterface::kAudioKind - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO)); + ? MediaType::AUDIO + : MediaType::VIDEO)); EXPECT_CALL(*sender, SetMediaChannel(_)).Times(AtMost(2)); EXPECT_CALL(*sender, SetTransceiverAsStopped()).Times(AtMost(1)); EXPECT_CALL(*sender, Stop()); @@ -762,8 +762,8 @@ static scoped_refptr CreateMockReceiver( EXPECT_CALL(*receiver, media_type()) .WillRepeatedly( Return(track->kind() == MediaStreamTrackInterface::kAudioKind - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO)); + ? MediaType::AUDIO + : MediaType::VIDEO)); EXPECT_CALL(*receiver, SetMediaChannel(_)).WillRepeatedly(Return()); EXPECT_CALL(*receiver, Stop()).WillRepeatedly(Return()); return receiver; @@ -1644,7 +1644,7 @@ TEST_P(StatsCollectorTrackTest, GetStatsFromLocalAudioTrack) { // we did not set it up. const StatsReport* remote_report = FindNthReportByType(reports, StatsReport::kStatsReportTypeRemoteSsrc, 1); - EXPECT_TRUE(remote_report == NULL); + EXPECT_TRUE(remote_report == nullptr); } // This test verifies that audio receive streams populate stats reports diff --git a/pc/media_session.cc b/pc/media_session.cc index cd03330175..12a6c0f032 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc @@ -134,16 +134,15 @@ bool IsComfortNoiseCodec(const Codec& codec) { RtpTransceiverDirection NegotiateRtpTransceiverDirection( RtpTransceiverDirection offer, RtpTransceiverDirection wants) { - bool offer_send = webrtc::RtpTransceiverDirectionHasSend(offer); - bool offer_recv = webrtc::RtpTransceiverDirectionHasRecv(offer); - bool wants_send = webrtc::RtpTransceiverDirectionHasSend(wants); - bool wants_recv = webrtc::RtpTransceiverDirectionHasRecv(wants); - return webrtc::RtpTransceiverDirectionFromSendRecv(offer_recv && wants_send, - offer_send && wants_recv); + bool offer_send = RtpTransceiverDirectionHasSend(offer); + bool offer_recv = RtpTransceiverDirectionHasRecv(offer); + bool wants_send = RtpTransceiverDirectionHasSend(wants); + bool wants_recv = RtpTransceiverDirectionHasRecv(wants); + return RtpTransceiverDirectionFromSendRecv(offer_recv && wants_send, + offer_send && wants_recv); } -bool IsMediaContentOfType(const ContentInfo* content, - webrtc::MediaType media_type) { +bool IsMediaContentOfType(const ContentInfo* content, MediaType media_type) { if (!content || !content->media_description()) { return false; } @@ -242,8 +241,8 @@ void AddSimulcastToMediaDescription( RTC_DCHECK_EQ(1, description->streams().size()) << "RIDs are only supported in Unified Plan semantics."; RTC_DCHECK_EQ(1, media_description_options.sender_options.size()); - RTC_DCHECK(description->type() == webrtc::MediaType::AUDIO || - description->type() == webrtc::MediaType::VIDEO); + RTC_DCHECK(description->type() == MediaType::AUDIO || + description->type() == MediaType::VIDEO); // One RID or less indicates that simulcast is not needed. if (description->streams()[0].rids().size() <= 1) { @@ -494,7 +493,7 @@ void NegotiateRtpHeaderExtensions(const RtpHeaderExtensions& local_extensions, bool dependency_descriptor_in_local = false; bool abs_capture_time_in_local = false; - for (const webrtc::RtpExtension& ours : local_extensions) { + for (const RtpExtension& ours : local_extensions) { if (ours.uri == RtpExtension::kGenericFrameDescriptorUri00) frame_descriptor_in_local = true; else if (ours.uri == RtpExtension::kDependencyDescriptorUri) @@ -546,8 +545,8 @@ bool SetCodecsInAnswer(const MediaContentDescription* offer, StreamParamsVec* current_streams, MediaContentDescription* answer, const FieldTrialsView& field_trials) { - RTC_DCHECK(offer->type() == webrtc::MediaType::AUDIO || - offer->type() == webrtc::MediaType::VIDEO); + RTC_DCHECK(offer->type() == MediaType::AUDIO || + offer->type() == MediaType::VIDEO); answer->AddCodecs(local_codecs); answer->set_protocol(offer->protocol()); if (!AddStreamParams(media_description_options.sender_options, @@ -615,7 +614,7 @@ bool CreateMediaContentAnswer( return true; } -bool IsMediaProtocolSupported(webrtc::MediaType type, +bool IsMediaProtocolSupported(MediaType type, const std::string& protocol, bool secure_transport) { // Since not all applications serialize and deserialize the media protocol, @@ -624,7 +623,7 @@ bool IsMediaProtocolSupported(webrtc::MediaType type, return true; } - if (type == webrtc::MediaType::DATA) { + if (type == MediaType::DATA) { // Check for SCTP if (secure_transport) { // Most likely scenarios first. @@ -656,7 +655,7 @@ void SetMediaProtocol(bool secure_transport, MediaContentDescription* desc) { const TransportDescription* GetTransportDescription( const std::string& content_name, const SessionDescription* current_description) { - const TransportDescription* desc = NULL; + const TransportDescription* desc = nullptr; if (current_description) { const TransportInfo* info = current_description->GetTransportInfoByName(content_name); @@ -744,23 +743,23 @@ MediaSessionDescriptionFactory::CreateOfferOrError( } RTCError error; switch (media_description_options.type) { - case webrtc::MediaType::AUDIO: - case webrtc::MediaType::VIDEO: + case MediaType::AUDIO: + case MediaType::VIDEO: error = AddRtpContentForOffer( media_description_options, session_options, current_content, current_description, - media_description_options.type == webrtc::MediaType::AUDIO + media_description_options.type == MediaType::AUDIO ? extensions_with_ids.audio : extensions_with_ids.video, ¤t_streams, offer.get(), &ice_credentials); break; - case webrtc::MediaType::DATA: + case MediaType::DATA: error = AddDataContentForOffer(media_description_options, session_options, current_content, current_description, ¤t_streams, offer.get(), &ice_credentials); break; - case webrtc::MediaType::UNSUPPORTED: + case MediaType::UNSUPPORTED: error = AddUnsupportedContentForOffer( media_description_options, session_options, current_content, current_description, offer.get(), &ice_credentials); @@ -921,21 +920,21 @@ MediaSessionDescriptionFactory::CreateAnswerOrError( UnstoppedRtpHeaderExtensionCapabilities(header_extensions_in)); RTCError error; switch (media_description_options.type) { - case webrtc::MediaType::AUDIO: - case webrtc::MediaType::VIDEO: + case MediaType::AUDIO: + case MediaType::VIDEO: error = AddRtpContentForAnswer( media_description_options, session_options, offer_content, offer, current_content, current_description, bundle_transport, header_extensions, ¤t_streams, answer.get(), &ice_credentials); break; - case webrtc::MediaType::DATA: + case MediaType::DATA: error = AddDataContentForAnswer( media_description_options, session_options, offer_content, offer, current_content, current_description, bundle_transport, ¤t_streams, answer.get(), &ice_credentials); break; - case webrtc::MediaType::UNSUPPORTED: + case MediaType::UNSUPPORTED: error = AddUnsupportedContentForAnswer( media_description_options, session_options, offer_content, offer, current_content, current_description, bundle_transport, @@ -1052,12 +1051,12 @@ MediaSessionDescriptionFactory::GetOfferedRtpHeaderExtensionsWithIds( // Add them to `used_ids` so the local ids are not reused if a new media // type is added. for (const ContentInfo* content : current_active_contents) { - if (IsMediaContentOfType(content, webrtc::MediaType::AUDIO)) { + if (IsMediaContentOfType(content, MediaType::AUDIO)) { MergeRtpHdrExts(content->media_description()->rtp_header_extensions(), enable_encrypted_rtp_header_extensions_, &offered_extensions.audio, &all_encountered_extensions, &used_ids); - } else if (IsMediaContentOfType(content, webrtc::MediaType::VIDEO)) { + } else if (IsMediaContentOfType(content, MediaType::VIDEO)) { MergeRtpHdrExts(content->media_description()->rtp_header_extensions(), enable_encrypted_rtp_header_extensions_, &offered_extensions.video, &all_encountered_extensions, @@ -1072,11 +1071,11 @@ MediaSessionDescriptionFactory::GetOfferedRtpHeaderExtensionsWithIds( RtpHeaderExtensions filtered_extensions = filtered_rtp_header_extensions(UnstoppedOrPresentRtpHeaderExtensions( entry.header_extensions, all_encountered_extensions)); - if (entry.type == webrtc::MediaType::AUDIO) + if (entry.type == MediaType::AUDIO) MergeRtpHdrExts( filtered_extensions, enable_encrypted_rtp_header_extensions_, &offered_extensions.audio, &all_encountered_extensions, &used_ids); - else if (entry.type == webrtc::MediaType::VIDEO) + else if (entry.type == MediaType::VIDEO) MergeRtpHdrExts( filtered_extensions, enable_encrypted_rtp_header_extensions_, &offered_extensions.video, &all_encountered_extensions, &used_ids); @@ -1154,8 +1153,8 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForOffer( StreamParamsVec* current_streams, SessionDescription* session_description, IceCredentialsIterator* ice_credentials) const { - RTC_DCHECK(media_description_options.type == webrtc::MediaType::AUDIO || - media_description_options.type == webrtc::MediaType::VIDEO); + RTC_DCHECK(media_description_options.type == MediaType::AUDIO || + media_description_options.type == MediaType::VIDEO); std::vector codecs_to_include; std::string mid = media_description_options.mid; @@ -1168,7 +1167,7 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForOffer( } codecs_to_include = error_or_filtered_codecs.MoveValue(); std::unique_ptr content_description; - if (media_description_options.type == webrtc::MediaType::AUDIO) { + if (media_description_options.type == MediaType::AUDIO) { content_description = std::make_unique(); } else { content_description = std::make_unique(); @@ -1222,7 +1221,7 @@ RTCError MediaSessionDescriptionFactory::AddDataContentForOffer( data->set_protocol(secure_transport ? kMediaProtocolUdpDtlsSctp : kMediaProtocolSctp); data->set_use_sctpmap(session_options.use_obsolete_sctp_sdp); - data->set_max_message_size(webrtc::kSctpSendBufferSize); + data->set_max_message_size(kSctpSendBufferSize); auto error = CreateContentOffer(media_description_options, session_options, RtpHeaderExtensions(), ssrc_generator(), @@ -1245,8 +1244,7 @@ RTCError MediaSessionDescriptionFactory::AddUnsupportedContentForOffer( const SessionDescription* current_description, SessionDescription* desc, IceCredentialsIterator* ice_credentials) const { - RTC_CHECK( - IsMediaContentOfType(current_content, webrtc::MediaType::UNSUPPORTED)); + RTC_CHECK(IsMediaContentOfType(current_content, MediaType::UNSUPPORTED)); const UnsupportedContentDescription* current_unsupported_description = current_content->media_description()->as_unsupported(); @@ -1285,12 +1283,12 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForAnswer( StreamParamsVec* current_streams, SessionDescription* answer, IceCredentialsIterator* ice_credentials) const { - RTC_DCHECK(media_description_options.type == webrtc::MediaType::AUDIO || - media_description_options.type == webrtc::MediaType::VIDEO); + RTC_DCHECK(media_description_options.type == MediaType::AUDIO || + media_description_options.type == MediaType::VIDEO); RTC_CHECK( IsMediaContentOfType(offer_content, media_description_options.type)); const RtpMediaContentDescription* offer_content_description; - if (media_description_options.type == webrtc::MediaType::AUDIO) { + if (media_description_options.type == MediaType::AUDIO) { offer_content_description = offer_content->media_description()->as_audio(); } else { offer_content_description = offer_content->media_description()->as_video(); @@ -1336,7 +1334,7 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForAnswer( bool bundle_enabled = offer_description->HasGroup(GROUP_TYPE_BUNDLE) && session_options.bundle_enabled; std::unique_ptr answer_content; - if (media_description_options.type == webrtc::MediaType::AUDIO) { + if (media_description_options.type == MediaType::AUDIO) { answer_content = std::make_unique(); } else { answer_content = std::make_unique(); @@ -1372,7 +1370,7 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForAnswer( : transport->secure(); bool rejected = media_description_options.stopped || offer_content->rejected || !has_usable_media_codecs || - !IsMediaProtocolSupported(webrtc::MediaType::AUDIO, + !IsMediaProtocolSupported(MediaType::AUDIO, answer_content->protocol(), secure); if (rejected) { RTC_LOG(LS_INFO) << "m= section '" << media_description_options.mid @@ -1413,7 +1411,7 @@ RTCError MediaSessionDescriptionFactory::AddDataContentForAnswer( bool bundle_enabled = offer_description->HasGroup(GROUP_TYPE_BUNDLE) && session_options.bundle_enabled; - RTC_CHECK(IsMediaContentOfType(offer_content, webrtc::MediaType::DATA)); + RTC_CHECK(IsMediaContentOfType(offer_content, MediaType::DATA)); std::unique_ptr data_answer; if (offer_content->media_description()->as_sctp()) { // SCTP data content @@ -1428,11 +1426,10 @@ RTCError MediaSessionDescriptionFactory::AddDataContentForAnswer( // we do not implement infinite size messages, reply with // kSctpSendBufferSize. if (offer_data_description->max_message_size() <= 0) { - data_answer->as_sctp()->set_max_message_size(webrtc::kSctpSendBufferSize); + data_answer->as_sctp()->set_max_message_size(kSctpSendBufferSize); } else { - data_answer->as_sctp()->set_max_message_size( - std::min(offer_data_description->max_message_size(), - webrtc::kSctpSendBufferSize)); + data_answer->as_sctp()->set_max_message_size(std::min( + offer_data_description->max_message_size(), kSctpSendBufferSize)); } if (!CreateMediaContentAnswer( offer_data_description, media_description_options, session_options, @@ -1454,7 +1451,7 @@ RTCError MediaSessionDescriptionFactory::AddDataContentForAnswer( bool rejected = media_description_options.stopped || offer_content->rejected || - !IsMediaProtocolSupported(webrtc::MediaType::DATA, + !IsMediaProtocolSupported(MediaType::DATA, data_answer->protocol(), secure); auto error = AddTransportAnswer(media_description_options.mid, *data_transport, answer); @@ -1487,8 +1484,7 @@ RTCError MediaSessionDescriptionFactory::AddUnsupportedContentForAnswer( RTCErrorType::INTERNAL_ERROR, "Failed to create transport answer, unsupported transport is missing"); } - RTC_CHECK( - IsMediaContentOfType(offer_content, webrtc::MediaType::UNSUPPORTED)); + RTC_CHECK(IsMediaContentOfType(offer_content, MediaType::UNSUPPORTED)); const UnsupportedContentDescription* offer_unsupported_description = offer_content->media_description()->as_unsupported(); @@ -1514,23 +1510,23 @@ bool IsMediaContent(const ContentInfo* content) { } bool IsAudioContent(const ContentInfo* content) { - return IsMediaContentOfType(content, webrtc::MediaType::AUDIO); + return IsMediaContentOfType(content, MediaType::AUDIO); } bool IsVideoContent(const ContentInfo* content) { - return IsMediaContentOfType(content, webrtc::MediaType::VIDEO); + return IsMediaContentOfType(content, MediaType::VIDEO); } bool IsDataContent(const ContentInfo* content) { - return IsMediaContentOfType(content, webrtc::MediaType::DATA); + return IsMediaContentOfType(content, MediaType::DATA); } bool IsUnsupportedContent(const ContentInfo* content) { - return IsMediaContentOfType(content, webrtc::MediaType::UNSUPPORTED); + return IsMediaContentOfType(content, MediaType::UNSUPPORTED); } const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, - webrtc::MediaType media_type) { + MediaType media_type) { for (const ContentInfo& content : contents) { if (IsMediaContentOfType(&content, media_type)) { return &content; @@ -1540,19 +1536,19 @@ const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, } const ContentInfo* GetFirstAudioContent(const ContentInfos& contents) { - return GetFirstMediaContent(contents, webrtc::MediaType::AUDIO); + return GetFirstMediaContent(contents, MediaType::AUDIO); } const ContentInfo* GetFirstVideoContent(const ContentInfos& contents) { - return GetFirstMediaContent(contents, webrtc::MediaType::VIDEO); + return GetFirstMediaContent(contents, MediaType::VIDEO); } const ContentInfo* GetFirstDataContent(const ContentInfos& contents) { - return GetFirstMediaContent(contents, webrtc::MediaType::DATA); + return GetFirstMediaContent(contents, MediaType::DATA); } const ContentInfo* GetFirstMediaContent(const SessionDescription* sdesc, - webrtc::MediaType media_type) { + MediaType media_type) { if (sdesc == nullptr) { return nullptr; } @@ -1561,39 +1557,39 @@ const ContentInfo* GetFirstMediaContent(const SessionDescription* sdesc, } const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc) { - return GetFirstMediaContent(sdesc, webrtc::MediaType::AUDIO); + return GetFirstMediaContent(sdesc, MediaType::AUDIO); } const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc) { - return GetFirstMediaContent(sdesc, webrtc::MediaType::VIDEO); + return GetFirstMediaContent(sdesc, MediaType::VIDEO); } const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc) { - return GetFirstMediaContent(sdesc, webrtc::MediaType::DATA); + return GetFirstMediaContent(sdesc, MediaType::DATA); } const MediaContentDescription* GetFirstMediaContentDescription( const SessionDescription* sdesc, - webrtc::MediaType media_type) { + MediaType media_type) { const ContentInfo* content = GetFirstMediaContent(sdesc, media_type); return (content ? content->media_description() : nullptr); } const AudioContentDescription* GetFirstAudioContentDescription( const SessionDescription* sdesc) { - auto desc = GetFirstMediaContentDescription(sdesc, webrtc::MediaType::AUDIO); + auto desc = GetFirstMediaContentDescription(sdesc, MediaType::AUDIO); return desc ? desc->as_audio() : nullptr; } const VideoContentDescription* GetFirstVideoContentDescription( const SessionDescription* sdesc) { - auto desc = GetFirstMediaContentDescription(sdesc, webrtc::MediaType::VIDEO); + auto desc = GetFirstMediaContentDescription(sdesc, MediaType::VIDEO); return desc ? desc->as_video() : nullptr; } const SctpDataContentDescription* GetFirstSctpDataContentDescription( const SessionDescription* sdesc) { - auto desc = GetFirstMediaContentDescription(sdesc, webrtc::MediaType::DATA); + auto desc = GetFirstMediaContentDescription(sdesc, MediaType::DATA); return desc ? desc->as_sctp() : nullptr; } @@ -1602,7 +1598,7 @@ const SctpDataContentDescription* GetFirstSctpDataContentDescription( // ContentInfo* GetFirstMediaContent(ContentInfos* contents, - webrtc::MediaType media_type) { + MediaType media_type) { for (ContentInfo& content : *contents) { if (IsMediaContentOfType(&content, media_type)) { return &content; @@ -1612,19 +1608,19 @@ ContentInfo* GetFirstMediaContent(ContentInfos* contents, } ContentInfo* GetFirstAudioContent(ContentInfos* contents) { - return GetFirstMediaContent(contents, webrtc::MediaType::AUDIO); + return GetFirstMediaContent(contents, MediaType::AUDIO); } ContentInfo* GetFirstVideoContent(ContentInfos* contents) { - return GetFirstMediaContent(contents, webrtc::MediaType::VIDEO); + return GetFirstMediaContent(contents, MediaType::VIDEO); } ContentInfo* GetFirstDataContent(ContentInfos* contents) { - return GetFirstMediaContent(contents, webrtc::MediaType::DATA); + return GetFirstMediaContent(contents, MediaType::DATA); } ContentInfo* GetFirstMediaContent(SessionDescription* sdesc, - webrtc::MediaType media_type) { + MediaType media_type) { if (sdesc == nullptr) { return nullptr; } @@ -1633,39 +1629,39 @@ ContentInfo* GetFirstMediaContent(SessionDescription* sdesc, } ContentInfo* GetFirstAudioContent(SessionDescription* sdesc) { - return GetFirstMediaContent(sdesc, webrtc::MediaType::AUDIO); + return GetFirstMediaContent(sdesc, MediaType::AUDIO); } ContentInfo* GetFirstVideoContent(SessionDescription* sdesc) { - return GetFirstMediaContent(sdesc, webrtc::MediaType::VIDEO); + return GetFirstMediaContent(sdesc, MediaType::VIDEO); } ContentInfo* GetFirstDataContent(SessionDescription* sdesc) { - return GetFirstMediaContent(sdesc, webrtc::MediaType::DATA); + return GetFirstMediaContent(sdesc, MediaType::DATA); } MediaContentDescription* GetFirstMediaContentDescription( SessionDescription* sdesc, - webrtc::MediaType media_type) { + MediaType media_type) { ContentInfo* content = GetFirstMediaContent(sdesc, media_type); return (content ? content->media_description() : nullptr); } AudioContentDescription* GetFirstAudioContentDescription( SessionDescription* sdesc) { - auto desc = GetFirstMediaContentDescription(sdesc, webrtc::MediaType::AUDIO); + auto desc = GetFirstMediaContentDescription(sdesc, MediaType::AUDIO); return desc ? desc->as_audio() : nullptr; } VideoContentDescription* GetFirstVideoContentDescription( SessionDescription* sdesc) { - auto desc = GetFirstMediaContentDescription(sdesc, webrtc::MediaType::VIDEO); + auto desc = GetFirstMediaContentDescription(sdesc, MediaType::VIDEO); return desc ? desc->as_video() : nullptr; } SctpDataContentDescription* GetFirstSctpDataContentDescription( SessionDescription* sdesc) { - auto desc = GetFirstMediaContentDescription(sdesc, webrtc::MediaType::DATA); + auto desc = GetFirstMediaContentDescription(sdesc, MediaType::DATA); return desc ? desc->as_sctp() : nullptr; } diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index 475dfd916a..7c782eb26b 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -827,8 +827,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, ASSERT_TRUE(offer.get()); const ContentInfo* ac = offer->GetContentByName("audio"); const ContentInfo* vc = offer->GetContentByName("video"); - ASSERT_TRUE(ac != NULL); - ASSERT_TRUE(vc == NULL); + ASSERT_TRUE(ac != nullptr); + ASSERT_TRUE(vc == nullptr); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); const MediaContentDescription* acd = ac->media_description(); EXPECT_EQ(webrtc::MediaType::AUDIO, acd->type()); @@ -855,8 +855,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOfferWithRedForOpus) { ASSERT_TRUE(offer.get()); const ContentInfo* ac = offer->GetContentByName("audio"); const ContentInfo* vc = offer->GetContentByName("video"); - ASSERT_TRUE(ac != NULL); - ASSERT_TRUE(vc == NULL); + ASSERT_TRUE(ac != nullptr); + ASSERT_TRUE(vc == nullptr); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); const MediaContentDescription* acd = ac->media_description(); EXPECT_EQ(webrtc::MediaType::AUDIO, acd->type()); diff --git a/pc/media_stream.cc b/pc/media_stream.cc index 7c62bff9d0..ceafb52c31 100644 --- a/pc/media_stream.cc +++ b/pc/media_stream.cc @@ -84,7 +84,7 @@ bool MediaStream::AddTrack(TrackVector* tracks, scoped_refptr track) { template bool MediaStream::RemoveTrack(TrackVector* tracks, scoped_refptr track) { - RTC_DCHECK(tracks != NULL); + RTC_DCHECK(tracks != nullptr); if (!track) return false; typename TrackVector::iterator it = FindTrack(tracks, track->id()); diff --git a/pc/media_stream_unittest.cc b/pc/media_stream_unittest.cc index 9647080f49..3a8820664b 100644 --- a/pc/media_stream_unittest.cc +++ b/pc/media_stream_unittest.cc @@ -56,16 +56,16 @@ class MediaStreamTest : public ::testing::Test { protected: virtual void SetUp() { stream_ = MediaStream::Create(kStreamId1); - ASSERT_TRUE(stream_.get() != NULL); + ASSERT_TRUE(stream_.get() != nullptr); video_track_ = VideoTrack::Create( kVideoTrackId, FakeVideoTrackSource::Create(), Thread::Current()); - ASSERT_TRUE(video_track_.get() != NULL); + ASSERT_TRUE(video_track_.get() != nullptr); EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state()); audio_track_ = AudioTrack::Create(kAudioTrackId, nullptr); - ASSERT_TRUE(audio_track_.get() != NULL); + ASSERT_TRUE(audio_track_.get() != nullptr); EXPECT_EQ(MediaStreamTrackInterface::kLive, audio_track_->state()); EXPECT_TRUE(stream_->AddTrack(video_track_)); diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 74c4c4531e..630ab4db09 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -691,6 +691,10 @@ JsepTransportController* PeerConnection::InitializeTransportController_n( config.crypto_options = configuration.crypto_options.has_value() ? *configuration.crypto_options : options_.crypto_options; + + // Maybe enable PQC from FieldTrials + config.crypto_options.ephemeral_key_exchange_cipher_groups.Update( + &context_->env().field_trials()); config.transport_observer = this; config.rtcp_handler = InitializeRtcpCallback(); config.un_demuxable_packet_handler = InitializeUnDemuxablePacketHandler(); @@ -2502,9 +2506,16 @@ std::optional PeerConnection::SetupDataChannelTransport_n( DataChannelTransportInterface* transport = transport_controller_->GetDataChannelTransport(*sctp_mid_n_); if (!transport) { +#ifndef WEBRTC_HAVE_SCTP + RTC_LOG(LS_ERROR) << "Data channel transport is not available" + << " as WebRTC has been compiled without SCTP support " + "(WEBRTC_HAVE_SCTP), mid=" + << mid; +#else RTC_LOG(LS_ERROR) << "Data channel transport is not available for data channels, mid=" << mid; +#endif sctp_mid_n_ = std::nullopt; return std::nullopt; } @@ -2547,7 +2558,7 @@ bool PeerConnection::ValidateBundleSettings( for (ContentInfos::const_iterator citer = contents.begin(); citer != contents.end(); ++citer) { const ContentInfo* content = (&*citer); - RTC_DCHECK(content != NULL); + RTC_DCHECK(content != nullptr); auto it = bundle_groups_by_mid.find(content->mid()); if (it != bundle_groups_by_mid.end() && !(content->rejected || content->bundle_only) && diff --git a/pc/peer_connection_bundle_unittest.cc b/pc/peer_connection_bundle_unittest.cc index e0f5643e17..b3be6d85bc 100644 --- a/pc/peer_connection_bundle_unittest.cc +++ b/pc/peer_connection_bundle_unittest.cc @@ -88,6 +88,9 @@ using ::testing::Values; class FakeNetworkManagerWithNoAnyNetwork : public FakeNetworkManager { public: + FakeNetworkManagerWithNoAnyNetwork() + : FakeNetworkManager(Thread::Current()) {} + std::vector GetAnyAddressNetworks() override { // This function allocates networks that are owned by the // NetworkManager. But some tests assume that they can release @@ -103,8 +106,7 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper { public: using PeerConnectionWrapper::PeerConnectionWrapper; - bool AddIceCandidateToMedia(Candidate* candidate, - webrtc::MediaType media_type) { + bool AddIceCandidateToMedia(Candidate* candidate, MediaType media_type) { auto* desc = pc()->remote_description()->description(); for (size_t i = 0; i < desc->contents().size(); i++) { const auto& content = desc->contents()[i]; @@ -126,7 +128,7 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper { VoiceChannel* voice_channel() { auto transceivers = GetInternalPeerConnection()->GetTransceiversInternal(); for (const auto& transceiver : transceivers) { - if (transceiver->media_type() == webrtc::MediaType::AUDIO) { + if (transceiver->media_type() == MediaType::AUDIO) { return static_cast(transceiver->internal()->channel()); } } @@ -140,7 +142,7 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper { VideoChannel* video_channel() { auto transceivers = GetInternalPeerConnection()->GetTransceiversInternal(); for (const auto& transceiver : transceivers) { - if (transceiver->media_type() == webrtc::MediaType::VIDEO) { + if (transceiver->media_type() == MediaType::VIDEO) { return static_cast(transceiver->internal()->channel()); } } @@ -658,16 +660,16 @@ TEST_P(PeerConnectionBundleTest, // that messages are executed in the order they were posted. Candidate audio_candidate1 = CreateLocalUdpCandidate(kAudioAddress1); - ASSERT_TRUE(caller->AddIceCandidateToMedia(&audio_candidate1, - webrtc::MediaType::AUDIO)); + ASSERT_TRUE( + caller->AddIceCandidateToMedia(&audio_candidate1, MediaType::AUDIO)); Candidate video_candidate = CreateLocalUdpCandidate(kVideoAddress); - ASSERT_TRUE(caller->AddIceCandidateToMedia(&video_candidate, - webrtc::MediaType::VIDEO)); + ASSERT_TRUE( + caller->AddIceCandidateToMedia(&video_candidate, MediaType::VIDEO)); Candidate audio_candidate2 = CreateLocalUdpCandidate(kAudioAddress2); - ASSERT_TRUE(caller->AddIceCandidateToMedia(&audio_candidate2, - webrtc::MediaType::AUDIO)); + ASSERT_TRUE( + caller->AddIceCandidateToMedia(&audio_candidate2, MediaType::AUDIO)); EXPECT_THAT( WaitUntil( diff --git a/pc/peer_connection_crypto_unittest.cc b/pc/peer_connection_crypto_unittest.cc index fd0f3f6526..1a4eab3ee2 100644 --- a/pc/peer_connection_crypto_unittest.cc +++ b/pc/peer_connection_crypto_unittest.cc @@ -379,7 +379,7 @@ TEST_P(PeerConnectionCryptoDtlsCertGenTest, TestCertificateGeneration) { fake_certificate_generator->generated_failures(); }, ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kGenerateCertTimeout)}), + {.timeout = TimeDelta::Millis(kGenerateCertTimeout)}), IsRtcOk()); } else { ASSERT_EQ(fake_certificate_generator->generated_certificates(), 0); diff --git a/pc/peer_connection_data_channel_unittest.cc b/pc/peer_connection_data_channel_unittest.cc index 47a85a5e48..707c34b3ef 100644 --- a/pc/peer_connection_data_channel_unittest.cc +++ b/pc/peer_connection_data_channel_unittest.cc @@ -19,7 +19,6 @@ #include "api/peer_connection_interface.h" #include "api/scoped_refptr.h" #include "api/sctp_transport_interface.h" -#include "api/task_queue/default_task_queue_factory.h" #include "p2p/base/p2p_constants.h" #include "pc/media_session.h" #include "pc/peer_connection.h" @@ -56,7 +55,6 @@ PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies() { deps.network_thread = Thread::Current(); deps.worker_thread = Thread::Current(); deps.signaling_thread = Thread::Current(); - deps.task_queue_factory = CreateDefaultTaskQueueFactory(); EnableFakeMedia(deps); deps.sctp_factory = std::make_unique(); return deps; @@ -210,11 +208,9 @@ TEST_P(PeerConnectionDataChannelTest, SctpContentAndTransportNameSetCorrectly) { auto offer = caller->CreateOffer(); const auto& offer_contents = offer->description()->contents(); - ASSERT_EQ(webrtc::MediaType::AUDIO, - offer_contents[0].media_description()->type()); + ASSERT_EQ(MediaType::AUDIO, offer_contents[0].media_description()->type()); auto audio_mid = offer_contents[0].mid(); - ASSERT_EQ(webrtc::MediaType::DATA, - offer_contents[2].media_description()->type()); + ASSERT_EQ(MediaType::DATA, offer_contents[2].media_description()->type()); auto data_mid = offer_contents[2].mid(); ASSERT_TRUE( diff --git a/pc/peer_connection_encodings_integrationtest.cc b/pc/peer_connection_encodings_integrationtest.cc index 2834f4c598..86dbb44936 100644 --- a/pc/peer_connection_encodings_integrationtest.cc +++ b/pc/peer_connection_encodings_integrationtest.cc @@ -260,7 +260,7 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test { absl::string_view codec_name) { std::vector codecs = pc_wrapper->pc_factory() - ->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpReceiverCapabilities(MediaType::VIDEO) .codecs; return std::find_if(codecs.begin(), codecs.end(), [&codec_name](const RtpCodecCapability& codec) { @@ -273,7 +273,7 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test { absl::string_view codec_name) { std::vector codecs = pc_wrapper->pc_factory() - ->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpReceiverCapabilities(MediaType::VIDEO) .codecs; codecs.erase(std::remove_if(codecs.begin(), codecs.end(), [&codec_name](const RtpCodecCapability& codec) { @@ -581,7 +581,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, // codec preferences because we want the sender to think SVC is a possibility. std::vector codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpSenderCapabilities(MediaType::VIDEO) .codecs; EXPECT_THAT(codecs[0].name, StrCaseEq("VP8")); // Attempt SVC (L3T3_KEY), which is not possible with VP8, but the sender does @@ -1355,7 +1355,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr local_pc_wrapper = CreatePc(); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::AUDIO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::AUDIO); scoped_refptr audio_transceiver = transceiver_or_error.MoveValue(); RtpParameters parameters = audio_transceiver->sender()->GetParameters(); @@ -1367,7 +1367,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr local_pc_wrapper = CreatePc(); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO); scoped_refptr video_transceiver = transceiver_or_error.MoveValue(); RtpParameters parameters = video_transceiver->sender()->GetParameters(); @@ -1385,8 +1385,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr track = stream->GetAudioTracks()[0]; std::optional pcmu = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "pcmu"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "pcmu"); ASSERT_TRUE(pcmu); RtpTransceiverInit init; @@ -1425,8 +1424,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr track = stream->GetVideoTracks()[0]; std::optional vp9 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp9"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp9"); ASSERT_TRUE(vp9); RtpTransceiverInit init; @@ -1471,8 +1469,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr track = stream->GetAudioTracks()[0]; std::optional pcmu = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "pcmu"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "pcmu"); auto transceiver_or_error = local_pc_wrapper->pc()->AddTransceiver(track); scoped_refptr audio_transceiver = @@ -1507,8 +1504,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr track = stream->GetAudioTracks()[0]; std::optional pcmu = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "pcmu"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "pcmu"); auto transceiver_or_error = local_pc_wrapper->pc()->AddTransceiver(track); scoped_refptr audio_transceiver = @@ -1555,8 +1551,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr track = stream->GetVideoTracks()[0]; std::optional vp9 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp9"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp9"); auto transceiver_or_error = local_pc_wrapper->pc()->AddTransceiver(track); scoped_refptr video_transceiver = @@ -1598,8 +1593,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr track = stream->GetVideoTracks()[0]; std::optional vp9 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp9"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp9"); auto transceiver_or_error = local_pc_wrapper->pc()->AddTransceiver(track); scoped_refptr video_transceiver = @@ -1644,7 +1638,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr local_pc_wrapper = CreatePc(); RtpCodec dummy_codec; - dummy_codec.kind = webrtc::MediaType::AUDIO; + dummy_codec.kind = MediaType::AUDIO; dummy_codec.name = "FOOBAR"; dummy_codec.clock_rate = 90000; dummy_codec.num_channels = 2; @@ -1656,7 +1650,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::AUDIO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::AUDIO, init); EXPECT_FALSE(transceiver_or_error.ok()); EXPECT_EQ(transceiver_or_error.error().type(), RTCErrorType::UNSUPPORTED_OPERATION); @@ -1667,7 +1661,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr local_pc_wrapper = CreatePc(); RtpCodec dummy_codec; - dummy_codec.kind = webrtc::MediaType::VIDEO; + dummy_codec.kind = MediaType::VIDEO; dummy_codec.name = "FOOBAR"; dummy_codec.clock_rate = 90000; @@ -1678,7 +1672,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); EXPECT_FALSE(transceiver_or_error.ok()); EXPECT_EQ(transceiver_or_error.error().type(), RTCErrorType::UNSUPPORTED_OPERATION); @@ -1689,13 +1683,13 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr local_pc_wrapper = CreatePc(); RtpCodec dummy_codec; - dummy_codec.kind = webrtc::MediaType::AUDIO; + dummy_codec.kind = MediaType::AUDIO; dummy_codec.name = "FOOBAR"; dummy_codec.clock_rate = 90000; dummy_codec.num_channels = 2; auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::AUDIO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr audio_transceiver = transceiver_or_error.MoveValue(); @@ -1711,12 +1705,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr local_pc_wrapper = CreatePc(); RtpCodec dummy_codec; - dummy_codec.kind = webrtc::MediaType::VIDEO; + dummy_codec.kind = MediaType::VIDEO; dummy_codec.name = "FOOBAR"; dummy_codec.clock_rate = 90000; auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr video_transceiver = transceiver_or_error.MoveValue(); @@ -1734,13 +1728,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional opus = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "opus"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "opus"); ASSERT_TRUE(opus); std::vector not_opus_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) + ->GetRtpSenderCapabilities(MediaType::AUDIO) .codecs; not_opus_codecs.erase( std::remove_if(not_opus_codecs.begin(), not_opus_codecs.end(), @@ -1750,7 +1743,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, not_opus_codecs.end()); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::AUDIO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr audio_transceiver = transceiver_or_error.MoveValue(); @@ -1773,13 +1766,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional opus = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "opus"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "opus"); ASSERT_TRUE(opus); std::vector not_opus_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) + ->GetRtpSenderCapabilities(MediaType::AUDIO) .codecs; not_opus_codecs.erase( std::remove_if(not_opus_codecs.begin(), not_opus_codecs.end(), @@ -1789,7 +1781,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, not_opus_codecs.end()); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::AUDIO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr audio_transceiver = transceiver_or_error.MoveValue(); @@ -1840,7 +1832,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr video_transceiver = transceiver_or_error.MoveValue(); @@ -1901,13 +1893,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional vp8 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp8"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp8"); ASSERT_TRUE(vp8); std::vector not_vp8_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpSenderCapabilities(MediaType::VIDEO) .codecs; not_vp8_codecs.erase( std::remove_if(not_vp8_codecs.begin(), not_vp8_codecs.end(), @@ -1917,7 +1908,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, not_vp8_codecs.end()); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr video_transceiver = transceiver_or_error.MoveValue(); @@ -1940,13 +1931,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional vp8 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp8"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp8"); ASSERT_TRUE(vp8); std::vector not_vp8_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpSenderCapabilities(MediaType::VIDEO) .codecs; not_vp8_codecs.erase( std::remove_if(not_vp8_codecs.begin(), not_vp8_codecs.end(), @@ -1956,7 +1946,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, not_vp8_codecs.end()); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr video_transceiver = transceiver_or_error.MoveValue(); @@ -2002,13 +1992,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional opus = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "opus"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "opus"); ASSERT_TRUE(opus); std::vector not_opus_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) + ->GetRtpSenderCapabilities(MediaType::AUDIO) .codecs; not_opus_codecs.erase( std::remove_if(not_opus_codecs.begin(), not_opus_codecs.end(), @@ -2024,7 +2013,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::AUDIO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::AUDIO, init); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr audio_transceiver = transceiver_or_error.MoveValue(); @@ -2051,17 +2040,15 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, std::vector send_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) + ->GetRtpSenderCapabilities(MediaType::AUDIO) .codecs; std::optional opus = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "opus"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "opus"); ASSERT_TRUE(opus); std::optional red = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::AUDIO, - "red"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::AUDIO, "red"); ASSERT_TRUE(red); RtpTransceiverInit init; @@ -2071,7 +2058,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::AUDIO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::AUDIO, init); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr audio_transceiver = transceiver_or_error.MoveValue(); @@ -2106,8 +2093,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, scoped_refptr local_pc_wrapper = CreatePc(); std::optional vp8 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp8"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp8"); ASSERT_TRUE(vp8); RtpTransceiverInit init; @@ -2118,7 +2104,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr video_transceiver = transceiver_or_error.MoveValue(); @@ -2136,13 +2122,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional vp8 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp8"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp8"); ASSERT_TRUE(vp8); std::vector not_vp8_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpSenderCapabilities(MediaType::VIDEO) .codecs; not_vp8_codecs.erase( std::remove_if(not_vp8_codecs.begin(), not_vp8_codecs.end(), @@ -2163,7 +2148,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); ASSERT_TRUE(transceiver_or_error.ok()); scoped_refptr video_transceiver = transceiver_or_error.MoveValue(); @@ -2194,12 +2179,10 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional vp8 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp8"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp8"); ASSERT_TRUE(vp8); std::optional vp9 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp9"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp9"); ASSERT_TRUE(vp9); RtpTransceiverInit init; @@ -2215,7 +2198,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); ASSERT_FALSE(transceiver_or_error.ok()); EXPECT_EQ(transceiver_or_error.error().type(), RTCErrorType::UNSUPPORTED_OPERATION); @@ -2232,12 +2215,10 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); std::optional vp8 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp8"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp8"); ASSERT_TRUE(vp8); std::optional vp9 = - local_pc_wrapper->FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, - "vp9"); + local_pc_wrapper->FindFirstSendCodecWithName(MediaType::VIDEO, "vp9"); ASSERT_TRUE(vp9); RtpTransceiverInit init; @@ -2253,7 +2234,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, init.send_encodings.push_back(encoding_parameters); auto transceiver_or_error = - local_pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); ASSERT_TRUE(transceiver_or_error.ok()); } @@ -2269,7 +2250,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ScaleToParameterChecking) { encoding.scale_resolution_down_to = {.width = 1280, .height = 720}; init.send_encodings.push_back(encoding); auto transceiver_or_error = - pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); EXPECT_FALSE(transceiver_or_error.ok()); EXPECT_EQ(transceiver_or_error.error().type(), RTCErrorType::UNSUPPORTED_OPERATION); @@ -2279,7 +2260,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ScaleToParameterChecking) { .height = 0}; init.send_encodings[1].scale_resolution_down_to = {.width = 0, .height = 720}; transceiver_or_error = - pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); EXPECT_FALSE(transceiver_or_error.ok()); EXPECT_EQ(transceiver_or_error.error().type(), RTCErrorType::UNSUPPORTED_OPERATION); @@ -2293,7 +2274,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ScaleToParameterChecking) { .height = 720}; init.send_encodings[1].scale_resolution_down_by = 2.0; transceiver_or_error = - pc_wrapper->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO, init); ASSERT_TRUE(transceiver_or_error.ok()); // SetParameters: If `scale_resolution_down_to` is specified on any active @@ -3139,9 +3120,7 @@ TEST_F(PeerConnectionEncodingsFakeCodecsIntegrationTest, H265Singlecast) { ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); scoped_refptr transceiver = - local_pc_wrapper->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO) - .MoveValue(); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO).MoveValue(); std::vector preferred_codecs = GetCapabilitiesAndRestrictToCodec(local_pc_wrapper, "H265"); transceiver->SetCodecPreferences(preferred_codecs); @@ -3226,7 +3205,7 @@ TEST_F(PeerConnectionEncodingsFakeCodecsIntegrationTest, // H265. std::vector sender_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpSenderCapabilities(MediaType::VIDEO) .codecs; auto it = std::find_if(sender_codecs.begin(), sender_codecs.end(), [](const RtpCodecCapability codec_capability) { @@ -3271,16 +3250,14 @@ TEST_F(PeerConnectionEncodingsFakeCodecsIntegrationTest, ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); scoped_refptr transceiver = - local_pc_wrapper->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO) - .MoveValue(); + local_pc_wrapper->pc()->AddTransceiver(MediaType::VIDEO).MoveValue(); // Filter on codec name and assert that sender capabilities have codecs for // {sendrecv, sendonly} and the receiver capabilities have codecs for // {sendrecv, recvonly}. std::vector send_codecs = local_pc_wrapper->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpSenderCapabilities(MediaType::VIDEO) .codecs; send_codecs.erase(std::remove_if(send_codecs.begin(), send_codecs.end(), [](const RtpCodecCapability& codec) { @@ -3289,7 +3266,7 @@ TEST_F(PeerConnectionEncodingsFakeCodecsIntegrationTest, send_codecs.end()); std::vector recv_codecs = local_pc_wrapper->pc_factory() - ->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpReceiverCapabilities(MediaType::VIDEO) .codecs; recv_codecs.erase(std::remove_if(recv_codecs.begin(), recv_codecs.end(), [](const RtpCodecCapability& codec) { diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index e62d25af0b..e42457667f 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,28 @@ #include "rtc_base/system/file_wrapper.h" namespace webrtc { +namespace { + +Environment AssembleEnvironment(PeerConnectionFactoryDependencies& deps) { + // Assemble Environment here rather than in ConnectionContext::Create + // to avoid dependency on EnvironmentFactory by ConnectionContext and thus its + // users. + EnvironmentFactory env_factory = deps.env.has_value() + ? EnvironmentFactory(*deps.env) + : EnvironmentFactory(); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + env_factory.Set(std::move(deps.trials)); + env_factory.Set(std::move(deps.task_queue_factory)); +#pragma clang diagnostic pop + + // Clear Environment from `deps` to avoid accidental usage of the wrong + // Environment. + deps.env = std::nullopt; + return env_factory.Create(); +} + +} // namespace scoped_refptr CreateModularPeerConnectionFactory( @@ -93,10 +116,8 @@ CreateModularPeerConnectionFactory( // Static scoped_refptr PeerConnectionFactory::Create( PeerConnectionFactoryDependencies dependencies) { - auto context = ConnectionContext::Create( - CreateEnvironment(std::move(dependencies.trials), - std::move(dependencies.task_queue_factory)), - &dependencies); + auto context = ConnectionContext::Create(AssembleEnvironment(dependencies), + &dependencies); if (!context) { return nullptr; } @@ -128,10 +149,8 @@ PeerConnectionFactory::PeerConnectionFactory( PeerConnectionFactory::PeerConnectionFactory( PeerConnectionFactoryDependencies dependencies) : PeerConnectionFactory( - ConnectionContext::Create( - CreateEnvironment(std::move(dependencies.trials), - std::move(dependencies.task_queue_factory)), - &dependencies), + ConnectionContext::Create(AssembleEnvironment(dependencies), + &dependencies), &dependencies) {} PeerConnectionFactory::~PeerConnectionFactory() { @@ -149,17 +168,17 @@ void PeerConnectionFactory::SetOptions(const Options& options) { } RtpCapabilities PeerConnectionFactory::GetRtpSenderCapabilities( - webrtc::MediaType kind) const { + MediaType kind) const { RTC_DCHECK_RUN_ON(signaling_thread()); switch (kind) { - case webrtc::MediaType::AUDIO: { + case MediaType::AUDIO: { Codecs cricket_codecs; cricket_codecs = codec_vendor_.audio_send_codecs().codecs(); auto extensions = GetDefaultEnabledRtpHeaderExtensions(media_engine()->voice()); return ToRtpCapabilities(cricket_codecs, extensions); } - case webrtc::MediaType::VIDEO: { + case MediaType::VIDEO: { Codecs cricket_codecs; cricket_codecs = codec_vendor_.video_send_codecs().codecs(); auto extensions = @@ -174,17 +193,17 @@ RtpCapabilities PeerConnectionFactory::GetRtpSenderCapabilities( } RtpCapabilities PeerConnectionFactory::GetRtpReceiverCapabilities( - webrtc::MediaType kind) const { + MediaType kind) const { RTC_DCHECK_RUN_ON(signaling_thread()); switch (kind) { - case webrtc::MediaType::AUDIO: { + case MediaType::AUDIO: { Codecs cricket_codecs; cricket_codecs = codec_vendor_.audio_recv_codecs().codecs(); auto extensions = GetDefaultEnabledRtpHeaderExtensions(media_engine()->voice()); return ToRtpCapabilities(cricket_codecs, extensions); } - case webrtc::MediaType::VIDEO: { + case MediaType::VIDEO: { Codecs cricket_codecs = codec_vendor_.video_recv_codecs().codecs(); auto extensions = GetDefaultEnabledRtpHeaderExtensions(media_engine()->video()); diff --git a/pc/peer_connection_factory_unittest.cc b/pc/peer_connection_factory_unittest.cc index f895496257..816360376f 100644 --- a/pc/peer_connection_factory_unittest.cc +++ b/pc/peer_connection_factory_unittest.cc @@ -25,6 +25,8 @@ #include "api/enable_media.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" +#include "api/field_trials_view.h" #include "api/jsep.h" #include "api/make_ref_counted.h" #include "api/media_stream_interface.h" @@ -32,7 +34,6 @@ #include "api/peer_connection_interface.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/test/mock_packet_socket_factory.h" #include "api/units/time_delta.h" #include "api/video_codecs/scalability_mode.h" @@ -75,15 +76,16 @@ namespace webrtc { namespace { +using test::MockAudioProcessing; +using test::MockAudioProcessingBuilder; using ::testing::_; using ::testing::A; using ::testing::AtLeast; using ::testing::InvokeWithoutArgs; using ::testing::NiceMock; +using ::testing::NotNull; using ::testing::Return; using ::testing::UnorderedElementsAre; -using ::webrtc::test::MockAudioProcessing; -using ::webrtc::test::MockAudioProcessingBuilder; static const char kStunIceServer[] = "stun:stun.l.google.com:19302"; static const char kTurnIceServer[] = "turn:test.com:1234"; @@ -160,7 +162,7 @@ class PeerConnectionFactoryTest : public ::testing::Test { OpenH264DecoderTemplateAdapter, Dav1dDecoderTemplateAdapter>>(), nullptr /* audio_mixer */, nullptr /* audio_processing */); - ASSERT_TRUE(factory_.get() != NULL); + ASSERT_TRUE(factory_.get() != nullptr); port_allocator_ = std::make_unique(CreateEnvironment(), socket_server_.get()); raw_port_allocator_ = port_allocator_.get(); @@ -189,7 +191,7 @@ class PeerConnectionFactoryTest : public ::testing::Test { } void VerifyAudioCodecCapability(const RtpCodecCapability& codec) { - EXPECT_EQ(codec.kind, webrtc::MediaType::AUDIO); + EXPECT_EQ(codec.kind, MediaType::AUDIO); EXPECT_FALSE(codec.name.empty()); EXPECT_GT(codec.clock_rate, 0); EXPECT_GT(codec.num_channels, 0); @@ -197,7 +199,7 @@ class PeerConnectionFactoryTest : public ::testing::Test { void VerifyVideoCodecCapability(const RtpCodecCapability& codec, bool sender) { - EXPECT_EQ(codec.kind, webrtc::MediaType::VIDEO); + EXPECT_EQ(codec.kind, MediaType::VIDEO); EXPECT_FALSE(codec.name.empty()); EXPECT_GT(codec.clock_rate, 0); if (sender) { @@ -275,7 +277,6 @@ CreatePeerConnectionFactoryWithRtxDisabled() { pcf_dependencies.signaling_thread = Thread::Current(); pcf_dependencies.worker_thread = Thread::Current(); pcf_dependencies.network_thread = Thread::Current(); - pcf_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); pcf_dependencies.adm = FakeAudioCaptureModule::Create(); pcf_dependencies.audio_encoder_factory = CreateBuiltinAudioEncoderFactory(); @@ -333,7 +334,7 @@ TEST(PeerConnectionFactoryTestInternal, DISABLED_CreatePCUsingInternalModules) { TEST_F(PeerConnectionFactoryTest, CheckRtpSenderAudioCapabilities) { RtpCapabilities audio_capabilities = - factory_->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO); + factory_->GetRtpSenderCapabilities(MediaType::AUDIO); EXPECT_FALSE(audio_capabilities.codecs.empty()); for (const auto& codec : audio_capabilities.codecs) { VerifyAudioCodecCapability(codec); @@ -346,7 +347,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpSenderAudioCapabilities) { TEST_F(PeerConnectionFactoryTest, CheckRtpSenderVideoCapabilities) { RtpCapabilities video_capabilities = - factory_->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO); + factory_->GetRtpSenderCapabilities(MediaType::VIDEO); EXPECT_FALSE(video_capabilities.codecs.empty()); for (const auto& codec : video_capabilities.codecs) { VerifyVideoCodecCapability(codec, true); @@ -359,7 +360,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpSenderVideoCapabilities) { TEST_F(PeerConnectionFactoryTest, CheckRtpSenderRtxEnabledCapabilities) { RtpCapabilities video_capabilities = - factory_->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO); + factory_->GetRtpSenderCapabilities(MediaType::VIDEO); const auto it = std::find_if( video_capabilities.codecs.begin(), video_capabilities.codecs.end(), [](const auto& c) { return c.name == kRtxCodecName; }); @@ -369,7 +370,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpSenderRtxEnabledCapabilities) { TEST(PeerConnectionFactoryTestInternal, CheckRtpSenderRtxDisabledCapabilities) { auto factory = CreatePeerConnectionFactoryWithRtxDisabled(); RtpCapabilities video_capabilities = - factory->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO); + factory->GetRtpSenderCapabilities(MediaType::VIDEO); const auto it = std::find_if( video_capabilities.codecs.begin(), video_capabilities.codecs.end(), [](const auto& c) { return c.name == kRtxCodecName; }); @@ -378,14 +379,14 @@ TEST(PeerConnectionFactoryTestInternal, CheckRtpSenderRtxDisabledCapabilities) { TEST_F(PeerConnectionFactoryTest, CheckRtpSenderDataCapabilities) { RtpCapabilities data_capabilities = - factory_->GetRtpSenderCapabilities(webrtc::MediaType::DATA); + factory_->GetRtpSenderCapabilities(MediaType::DATA); EXPECT_TRUE(data_capabilities.codecs.empty()); EXPECT_TRUE(data_capabilities.header_extensions.empty()); } TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverAudioCapabilities) { RtpCapabilities audio_capabilities = - factory_->GetRtpReceiverCapabilities(webrtc::MediaType::AUDIO); + factory_->GetRtpReceiverCapabilities(MediaType::AUDIO); EXPECT_FALSE(audio_capabilities.codecs.empty()); for (const auto& codec : audio_capabilities.codecs) { VerifyAudioCodecCapability(codec); @@ -398,7 +399,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverAudioCapabilities) { TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverVideoCapabilities) { RtpCapabilities video_capabilities = - factory_->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO); + factory_->GetRtpReceiverCapabilities(MediaType::VIDEO); EXPECT_FALSE(video_capabilities.codecs.empty()); for (const auto& codec : video_capabilities.codecs) { VerifyVideoCodecCapability(codec, false); @@ -411,7 +412,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverVideoCapabilities) { TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverRtxEnabledCapabilities) { RtpCapabilities video_capabilities = - factory_->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO); + factory_->GetRtpReceiverCapabilities(MediaType::VIDEO); const auto it = std::find_if( video_capabilities.codecs.begin(), video_capabilities.codecs.end(), [](const auto& c) { return c.name == kRtxCodecName; }); @@ -422,7 +423,7 @@ TEST(PeerConnectionFactoryTestInternal, CheckRtpReceiverRtxDisabledCapabilities) { auto factory = CreatePeerConnectionFactoryWithRtxDisabled(); RtpCapabilities video_capabilities = - factory->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO); + factory->GetRtpReceiverCapabilities(MediaType::VIDEO); const auto it = std::find_if( video_capabilities.codecs.begin(), video_capabilities.codecs.end(), [](const auto& c) { return c.name == kRtxCodecName; }); @@ -431,7 +432,7 @@ TEST(PeerConnectionFactoryTestInternal, TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverDataCapabilities) { RtpCapabilities data_capabilities = - factory_->GetRtpReceiverCapabilities(webrtc::MediaType::DATA); + factory_->GetRtpReceiverCapabilities(MediaType::DATA); EXPECT_TRUE(data_capabilities.codecs.empty()); EXPECT_TRUE(data_capabilities.header_extensions.empty()); } @@ -640,10 +641,10 @@ TEST_F(PeerConnectionFactoryTest, LocalRendering) { FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); - ASSERT_TRUE(source.get() != NULL); + ASSERT_TRUE(source.get() != nullptr); scoped_refptr track( factory_->CreateVideoTrack(source, "testlabel")); - ASSERT_TRUE(track.get() != NULL); + ASSERT_TRUE(track.get() != nullptr); FakeVideoTrackRenderer local_renderer(track.get()); EXPECT_EQ(0, local_renderer.num_rendered_frames()); @@ -662,6 +663,46 @@ TEST_F(PeerConnectionFactoryTest, LocalRendering) { EXPECT_FALSE(local_renderer.black_frame()); } +TEST(PeerConnectionFactoryDependenciesTest, + CanInjectFieldTrialsWithEnvironment) { + std::unique_ptr field_trials = + FieldTrials::CreateNoGlobal(""); + ASSERT_THAT(field_trials, NotNull()); + FieldTrialsView* raw_field_trials = field_trials.get(); + + PeerConnectionFactoryDependencies pcf_dependencies; + pcf_dependencies.env = CreateEnvironment(std::move(field_trials)); + pcf_dependencies.adm = FakeAudioCaptureModule::Create(); + EnableMediaWithDefaults(pcf_dependencies); + + scoped_refptr pcf = + PeerConnectionFactory::Create(std::move(pcf_dependencies)); + EXPECT_EQ(&pcf->field_trials(), raw_field_trials); +} + +TEST(PeerConnectionFactoryDependenciesTest, + PreferFieldTrialsInjectedExplicetly) { + std::unique_ptr env_field_trials = + FieldTrials::CreateNoGlobal(""); + std::unique_ptr explicit_field_trials = + FieldTrials::CreateNoGlobal(""); + ASSERT_FALSE(env_field_trials.get() == explicit_field_trials.get()); + FieldTrialsView* raw_explicit_field_trials = explicit_field_trials.get(); + + PeerConnectionFactoryDependencies pcf_dependencies; + pcf_dependencies.env = CreateEnvironment(std::move(env_field_trials)); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + pcf_dependencies.trials = std::move(explicit_field_trials); +#pragma clang diagnostic pop + pcf_dependencies.adm = FakeAudioCaptureModule::Create(); + EnableMediaWithDefaults(pcf_dependencies); + + scoped_refptr pcf = + PeerConnectionFactory::Create(std::move(pcf_dependencies)); + EXPECT_EQ(&pcf->field_trials(), raw_explicit_field_trials); +} + TEST(PeerConnectionFactoryDependenciesTest, UsesNetworkManager) { constexpr TimeDelta kWaitTimeout = TimeDelta::Seconds(10); auto mock_network_manager = std::make_unique>(); @@ -723,7 +764,7 @@ TEST(PeerConnectionFactoryDependenciesTest, UsesPacketSocketFactory) { } TEST(PeerConnectionFactoryDependenciesTest, - CreatesAudioProcessingWithProvidedFactory) { + CreatesAudioProcessingWithProvidedBuilder) { auto ap_factory = std::make_unique(); auto audio_processing = make_ref_counted>(); // Validate that provided audio_processing is used by expecting that a request @@ -742,25 +783,5 @@ TEST(PeerConnectionFactoryDependenciesTest, pcf->StartAecDump(nullptr, 24'242); } -TEST(PeerConnectionFactoryDependenciesTest, UsesAudioProcessingWhenProvided) { - // Test legacy way of providing audio_processing. - // TODO: bugs.webrtc.org/369904700 - Delete this test when webrtc users no - // longer set PeerConnectionFactoryDependencies::audio_processing. - auto audio_processing = make_ref_counted>(); - EXPECT_CALL(*audio_processing, CreateAndAttachAecDump(A(), 24'242, _)); - - PeerConnectionFactoryDependencies pcf_dependencies; - pcf_dependencies.adm = FakeAudioCaptureModule::Create(); -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - pcf_dependencies.audio_processing = std::move(audio_processing); -#pragma clang diagnostic pop - EnableMediaWithDefaults(pcf_dependencies); - - scoped_refptr pcf = - CreateModularPeerConnectionFactory(std::move(pcf_dependencies)); - pcf->StartAecDump(nullptr, 24'242); -} - } // namespace } // namespace webrtc diff --git a/pc/peer_connection_field_trial_tests.cc b/pc/peer_connection_field_trial_tests.cc index 9ce3f16415..3d99c3020c 100644 --- a/pc/peer_connection_field_trial_tests.cc +++ b/pc/peer_connection_field_trial_tests.cc @@ -17,13 +17,13 @@ #include "absl/algorithm/container.h" #include "api/enable_media_with_defaults.h" +#include "api/environment/environment_factory.h" #include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" #include "pc/peer_connection_wrapper.h" #include "pc/session_description.h" #include "pc/test/fake_audio_capture_module.h" @@ -65,8 +65,7 @@ class PeerConnectionFieldTrialTest : public ::testing::Test { void CreatePCFactory(std::unique_ptr field_trials) { PeerConnectionFactoryDependencies pcf_deps; pcf_deps.signaling_thread = Thread::Current(); - pcf_deps.trials = std::move(field_trials); - pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); + pcf_deps.env = CreateEnvironment(std::move(field_trials)); pcf_deps.adm = FakeAudioCaptureModule::Create(); EnableMediaWithDefaults(pcf_deps); pc_factory_ = CreateModularPeerConnectionFactory(std::move(pcf_deps)); @@ -104,7 +103,7 @@ TEST_F(PeerConnectionFieldTrialTest, EnableDependencyDescriptorAdvertised) { "WebRTC-DependencyDescriptorAdvertised/Enabled/")); WrapperPtr caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO); auto offer = caller->CreateOffer(); auto contents1 = offer->description()->contents(); @@ -112,7 +111,7 @@ TEST_F(PeerConnectionFieldTrialTest, EnableDependencyDescriptorAdvertised) { const MediaContentDescription* media_description1 = contents1[0].media_description(); - EXPECT_EQ(webrtc::MediaType::VIDEO, media_description1->type()); + EXPECT_EQ(MediaType::VIDEO, media_description1->type()); const RtpHeaderExtensions& rtp_header_extensions1 = media_description1->rtp_header_extensions(); @@ -138,7 +137,7 @@ TEST_F(PeerConnectionFieldTrialTest, MAYBE_InjectDependencyDescriptor) { WrapperPtr caller = CreatePeerConnection(); WrapperPtr callee = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO); auto offer = caller->CreateOffer(); ContentInfos& contents1 = offer->description()->contents(); @@ -146,7 +145,7 @@ TEST_F(PeerConnectionFieldTrialTest, MAYBE_InjectDependencyDescriptor) { MediaContentDescription* media_description1 = contents1[0].media_description(); - EXPECT_EQ(webrtc::MediaType::VIDEO, media_description1->type()); + EXPECT_EQ(MediaType::VIDEO, media_description1->type()); RtpHeaderExtensions rtp_header_extensions1 = media_description1->rtp_header_extensions(); @@ -190,7 +189,7 @@ TEST_F(PeerConnectionFieldTrialTest, MAYBE_InjectDependencyDescriptor) { MediaContentDescription* media_description2 = contents2[0].media_description(); - EXPECT_EQ(webrtc::MediaType::VIDEO, media_description2->type()); + EXPECT_EQ(MediaType::VIDEO, media_description2->type()); RtpHeaderExtensions rtp_header_extensions2 = media_description2->rtp_header_extensions(); diff --git a/pc/peer_connection_header_extension_unittest.cc b/pc/peer_connection_header_extension_unittest.cc index b62d68b7aa..def77de11d 100644 --- a/pc/peer_connection_header_extension_unittest.cc +++ b/pc/peer_connection_header_extension_unittest.cc @@ -26,7 +26,6 @@ #include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" #include "media/base/fake_media_engine.h" #include "p2p/test/fake_port_allocator.h" #include "pc/peer_connection_wrapper.h" @@ -82,7 +81,6 @@ class PeerConnectionHeaderExtensionTest factory_dependencies.network_thread = Thread::Current(); factory_dependencies.worker_thread = Thread::Current(); factory_dependencies.signaling_thread = Thread::Current(); - factory_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); EnableFakeMedia(factory_dependencies, std::move(media_engine)); factory_dependencies.event_log_factory = diff --git a/pc/peer_connection_histogram_unittest.cc b/pc/peer_connection_histogram_unittest.cc index ea428e4193..5b1da41863 100644 --- a/pc/peer_connection_histogram_unittest.cc +++ b/pc/peer_connection_histogram_unittest.cc @@ -51,8 +51,7 @@ using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; using ::testing::NiceMock; static const char kUsagePatternMetric[] = "WebRTC.PeerConnection.UsagePattern"; -static constexpr webrtc::TimeDelta kDefaultTimeout = - webrtc::TimeDelta::Millis(10000); +static constexpr TimeDelta kDefaultTimeout = TimeDelta::Millis(10000); static const SocketAddress kLocalAddrs[2] = {SocketAddress("1.1.1.1", 0), SocketAddress("2.2.2.2", 0)}; static const SocketAddress kPrivateLocalAddress("10.1.1.1", 0); @@ -227,8 +226,7 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test { PeerConnectionDependencies deps(nullptr /* observer_in */); deps.async_dns_resolver_factory = std::make_unique>(); - - auto fake_network = std::make_unique(); + auto fake_network = std::make_unique(Thread::Current()); fake_network->set_mdns_responder( std::make_unique(Thread::Current())); fake_network->AddInterface(NextLocalAddress()); @@ -246,7 +244,7 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test { } WrapperPtr CreatePeerConnectionWithPrivateLocalAddresses() { - auto fake_network = std::make_unique(); + auto fake_network = std::make_unique(Thread::Current()); fake_network->AddInterface(NextLocalAddress()); fake_network->AddInterface(kPrivateLocalAddress); @@ -258,7 +256,7 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test { } WrapperPtr CreatePeerConnectionWithPrivateIpv6LocalAddresses() { - auto fake_network = std::make_unique(); + auto fake_network = std::make_unique(Thread::Current()); fake_network->AddInterface(NextLocalAddress()); fake_network->AddInterface(kPrivateIpv6LocalAddress); @@ -284,7 +282,8 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test { } else { // If no network manager is provided, one will be created that uses the // host network. This doesn't work on all trybots. - auto fake_network = std::make_unique(); + auto fake_network = + std::make_unique(pcf_deps.network_thread); fake_network->AddInterface(NextLocalAddress()); pcf_deps.network_manager = std::move(fake_network); } diff --git a/pc/peer_connection_ice_unittest.cc b/pc/peer_connection_ice_unittest.cc index 7d763db112..9e70705544 100644 --- a/pc/peer_connection_ice_unittest.cc +++ b/pc/peer_connection_ice_unittest.cc @@ -158,7 +158,8 @@ class PeerConnectionIceBaseTest : public ::testing::Test { pcf_deps.worker_thread = Thread::Current(); pcf_deps.signaling_thread = Thread::Current(); pcf_deps.socket_factory = &vss_; - auto network_manager = std::make_unique(); + auto network_manager = + std::make_unique(pcf_deps.network_thread); auto* fake_network = network_manager.get(); pcf_deps.network_manager = std::move(network_manager); pcf_deps.adm = FakeAudioCaptureModule::Create(); @@ -269,7 +270,7 @@ class PeerConnectionIceBaseTest : public ::testing::Test { pc_wrapper_ptr->pc()); PeerConnection* pc = static_cast(pc_proxy->internal()); for (const auto& transceiver : pc->GetTransceiversInternal()) { - if (transceiver->media_type() == webrtc::MediaType::AUDIO) { + if (transceiver->media_type() == MediaType::AUDIO) { auto dtls_transport = pc->LookupDtlsTransportByMidInternal( transceiver->internal()->channel()->mid()); return dtls_transport->ice_transport()->internal()->GetIceRole(); @@ -361,11 +362,10 @@ TEST_P(PeerConnectionIceTest, OfferContainsGatheredCandidates) { // Start ICE candidate gathering by setting the local offer. ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer())); - EXPECT_THAT( - WaitUntil([&] { return caller->IsIceGatheringDone(); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); }, + ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), + IsRtcOk()); auto offer = caller->CreateOffer(); EXPECT_LT(0u, caller->observer()->GetCandidatesByMline(0).size()); @@ -386,11 +386,10 @@ TEST_P(PeerConnectionIceTest, AnswerContainsGatheredCandidates) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); ASSERT_TRUE(callee->SetLocalDescription(callee->CreateAnswer())); - EXPECT_THAT( - WaitUntil([&] { return callee->IsIceGatheringDone(); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee->IsIceGatheringDone(); }, + ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), + IsRtcOk()); auto* answer = callee->pc()->local_description(); EXPECT_LT(0u, caller->observer()->GetCandidatesByMline(0).size()); @@ -717,11 +716,10 @@ TEST_P(PeerConnectionIceTest, CandidatesGeneratedForEachLocalInterface) { caller->network()->AddInterface(kLocalAddress2); caller->CreateOfferAndSetAsLocal(); - EXPECT_THAT( - WaitUntil([&] { return caller->IsIceGatheringDone(); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); }, + ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), + IsRtcOk()); auto candidates = caller->observer()->GetCandidatesByMline(0); EXPECT_PRED_FORMAT2(AssertIpInCandidates, kLocalAddress1, candidates); @@ -787,7 +785,7 @@ TEST_P(PeerConnectionIceTest, AsyncAddIceCandidateIsAddedToRemoteDescription) { }); EXPECT_THAT( WaitUntil([&] { return operation_completed; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); auto candidates = callee->GetIceCandidatesFromRemoteDescription(); @@ -839,7 +837,7 @@ TEST_P(PeerConnectionIceTest, EXPECT_FALSE(operation_completed); EXPECT_THAT( WaitUntil([&] { return answer_observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); // As soon as it does, AddIceCandidate() will execute without delay, so it // must also have completed. @@ -864,7 +862,7 @@ TEST_P(PeerConnectionIceTest, }); EXPECT_THAT( WaitUntil([&] { return operation_completed; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); } @@ -901,7 +899,7 @@ TEST_P(PeerConnectionIceTest, callee = nullptr; EXPECT_THAT( WaitUntil([&] { return operation_completed; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); } @@ -925,7 +923,7 @@ TEST_P(PeerConnectionIceTest, LocalDescriptionUpdatedWhenContinualGathering) { return caller->pc()->local_description()->candidates(0)->count(); }, ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}), + {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), IsRtcOk()); } @@ -952,7 +950,7 @@ TEST_P(PeerConnectionIceTest, return caller->pc()->local_description()->candidates(0)->count(); }, ::testing::Gt(0), - {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}), + {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), IsRtcOk()); // Remove the only network interface, causing the PeerConnection to signal @@ -965,7 +963,7 @@ TEST_P(PeerConnectionIceTest, return caller->pc()->local_description()->candidates(0)->count(); }, ::testing::Eq(0u), - {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}), + {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), IsRtcOk()); EXPECT_LT(0, caller->observer()->num_candidates_removed_); } @@ -983,11 +981,10 @@ TEST_P(PeerConnectionIceTest, // Start ICE candidate gathering by setting the local offer. ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer())); - EXPECT_THAT( - WaitUntil([&] { return caller->IsIceGatheringDone(); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kIceCandidatesTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); }, + ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), + IsRtcOk()); caller->network()->RemoveInterface(kLocalAddress); diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 95bd835301..506495b616 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -620,9 +621,7 @@ TEST_P(PeerConnectionIntegrationTest, AudioToVideoUpgrade) { callee()->SetOfferAnswerOptions(options); } else { callee()->SetRemoteOfferHandler([this] { - callee() - ->GetFirstTransceiverOfType(webrtc::MediaType::VIDEO) - ->StopInternal(); + callee()->GetFirstTransceiverOfType(MediaType::VIDEO)->StopInternal(); }); } // Do offer/answer and make sure audio is still received end-to-end. @@ -657,8 +656,7 @@ TEST_P(PeerConnectionIntegrationTest, AudioToVideoUpgrade) { // the offer, but by default it is send only. auto transceivers = caller()->pc()->GetTransceivers(); ASSERT_EQ(2U, transceivers.size()); - ASSERT_EQ(webrtc::MediaType::VIDEO, - transceivers[1]->receiver()->media_type()); + ASSERT_EQ(MediaType::VIDEO, transceivers[1]->receiver()->media_type()); transceivers[1]->sender()->SetTrack( caller()->CreateLocalVideoTrack().get()); transceivers[1]->SetDirectionWithError( @@ -841,9 +839,7 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsAudioSection) { // Stopping the audio RtpTransceiver will cause the media section to be // rejected in the answer. callee()->SetRemoteOfferHandler([this] { - callee() - ->GetFirstTransceiverOfType(webrtc::MediaType::AUDIO) - ->StopInternal(); + callee()->GetFirstTransceiverOfType(MediaType::AUDIO)->StopInternal(); }); } callee()->AddTrack(callee()->CreateLocalVideoTrack()); @@ -866,8 +862,7 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsAudioSection) { if (sdp_semantics_ == SdpSemantics::kUnifiedPlan) { // The caller's transceiver should have stopped after receiving the answer, // and thus no longer listed in transceivers. - EXPECT_EQ(nullptr, - caller()->GetFirstTransceiverOfType(webrtc::MediaType::AUDIO)); + EXPECT_EQ(nullptr, caller()->GetFirstTransceiverOfType(MediaType::AUDIO)); } } @@ -887,9 +882,7 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsVideoSection) { // Stopping the video RtpTransceiver will cause the media section to be // rejected in the answer. callee()->SetRemoteOfferHandler([this] { - callee() - ->GetFirstTransceiverOfType(webrtc::MediaType::VIDEO) - ->StopInternal(); + callee()->GetFirstTransceiverOfType(MediaType::VIDEO)->StopInternal(); }); } callee()->AddTrack(callee()->CreateLocalAudioTrack()); @@ -912,8 +905,7 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsVideoSection) { if (sdp_semantics_ == SdpSemantics::kUnifiedPlan) { // The caller's transceiver should have stopped after receiving the answer, // and thus is no longer present. - EXPECT_EQ(nullptr, - caller()->GetFirstTransceiverOfType(webrtc::MediaType::VIDEO)); + EXPECT_EQ(nullptr, caller()->GetFirstTransceiverOfType(MediaType::VIDEO)); } } @@ -988,9 +980,7 @@ TEST_P(PeerConnectionIntegrationTest, VideoRejectedInSubsequentOffer) { } }); } else { - caller() - ->GetFirstTransceiverOfType(webrtc::MediaType::VIDEO) - ->StopInternal(); + caller()->GetFirstTransceiverOfType(MediaType::VIDEO)->StopInternal(); } caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT( @@ -2326,9 +2316,7 @@ TEST_P(PeerConnectionIntegrationTest, callee()->SetOfferAnswerOptions(options); } else { callee()->SetRemoteOfferHandler([this] { - callee() - ->GetFirstTransceiverOfType(webrtc::MediaType::VIDEO) - ->StopInternal(); + callee()->GetFirstTransceiverOfType(MediaType::VIDEO)->StopInternal(); }); } caller()->CreateAndSetAndSignalOffer(); @@ -2350,7 +2338,7 @@ TEST_P(PeerConnectionIntegrationTest, } else { // The caller's transceiver is stopped, so we need to add another track. auto caller_transceiver = - caller()->GetFirstTransceiverOfType(webrtc::MediaType::VIDEO); + caller()->GetFirstTransceiverOfType(MediaType::VIDEO); EXPECT_EQ(nullptr, caller_transceiver.get()); caller()->AddVideoTrack(); } @@ -2421,10 +2409,10 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, MediaFlowsAfterEarlyWarmupWithAddTransceiver) { ASSERT_TRUE(CreatePeerConnectionWrappers()); ConnectFakeSignaling(); - auto audio_result = caller()->pc()->AddTransceiver(webrtc::MediaType::AUDIO); + auto audio_result = caller()->pc()->AddTransceiver(MediaType::AUDIO); ASSERT_EQ(RTCErrorType::NONE, audio_result.error().type()); auto caller_audio_sender = audio_result.MoveValue()->sender(); - auto video_result = caller()->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + auto video_result = caller()->pc()->AddTransceiver(MediaType::VIDEO); ASSERT_EQ(RTCErrorType::NONE, video_result.error().type()); auto caller_video_sender = video_result.MoveValue()->sender(); callee()->SetRemoteOfferHandler([this] { @@ -2577,11 +2565,10 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock, options.offer_to_receive_video = 1; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - EXPECT_THAT( - WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(total_connection_time_ms), - .clock = &FakeClock()}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(total_connection_time_ms), + .clock = &FakeClock()}), + IsRtcOk()); // Closing the PeerConnections destroys the ports before the ScopedFakeClock. // If this is not done a DCHECK can be hit in ports.cc, because a large // negative number is calculated for the rtt due to the global clock changing. @@ -2913,7 +2900,7 @@ TEST_P(PeerConnectionIntegrationTest, GetSourcesAudio) { ASSERT_TRUE(ExpectNewFrames(media_expectations)); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); auto receiver = callee()->pc()->GetReceivers()[0]; - ASSERT_EQ(receiver->media_type(), webrtc::MediaType::AUDIO); + ASSERT_EQ(receiver->media_type(), MediaType::AUDIO); auto sources = receiver->GetSources(); ASSERT_GT(receiver->GetParameters().encodings.size(), 0u); EXPECT_EQ(receiver->GetParameters().encodings[0].ssrc, @@ -2936,7 +2923,7 @@ TEST_P(PeerConnectionIntegrationTest, GetSourcesVideo) { ASSERT_TRUE(ExpectNewFrames(media_expectations)); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); auto receiver = callee()->pc()->GetReceivers()[0]; - ASSERT_EQ(receiver->media_type(), webrtc::MediaType::VIDEO); + ASSERT_EQ(receiver->media_type(), MediaType::VIDEO); auto sources = receiver->GetSources(); ASSERT_GT(receiver->GetParameters().encodings.size(), 0u); ASSERT_GT(sources.size(), 0u); @@ -3649,7 +3636,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, config.sdp_semantics = SdpSemantics::kUnifiedPlan; ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config)); ConnectFakeSignaling(); - caller()->pc()->AddTransceiver(webrtc::MediaType::AUDIO); + caller()->pc()->AddTransceiver(MediaType::AUDIO); caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT( @@ -3663,7 +3650,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, while (current_size < 8) { // Double the number of tracks for (int i = 0; i < current_size; i++) { - caller()->pc()->AddTransceiver(webrtc::MediaType::AUDIO); + caller()->pc()->AddTransceiver(MediaType::AUDIO); } current_size = caller()->pc()->GetTransceivers().size(); RTC_LOG(LS_INFO) << "Renegotiating with " << current_size << " tracks"; @@ -3687,7 +3674,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, config.sdp_semantics = SdpSemantics::kUnifiedPlan; ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config)); ConnectFakeSignaling(); - caller()->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + caller()->pc()->AddTransceiver(MediaType::VIDEO); caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT( @@ -3703,7 +3690,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, while (current_size < 8) { // Double the number of tracks for (int i = 0; i < current_size; i++) { - caller()->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + caller()->pc()->AddTransceiver(MediaType::VIDEO); } current_size = caller()->pc()->GetTransceivers().size(); RTC_LOG(LS_INFO) << "Renegotiating with " << current_size << " tracks"; @@ -3749,7 +3736,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, while (current_size < 16) { // Double the number of tracks for (int i = 0; i < current_size; i++) { - caller()->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + caller()->pc()->AddTransceiver(MediaType::VIDEO); } current_size = caller()->pc()->GetTransceivers().size(); RTC_LOG(LS_INFO) << "Renegotiating with " << current_size << " tracks"; @@ -3773,7 +3760,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, TEST_F(PeerConnectionIntegrationTestUnifiedPlan, GetParametersHasEncodingsBeforeNegotiation) { ASSERT_TRUE(CreatePeerConnectionWrappers()); - auto result = caller()->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + auto result = caller()->pc()->AddTransceiver(MediaType::VIDEO); auto transceiver = result.MoveValue(); auto parameters = transceiver->sender()->GetParameters(); EXPECT_EQ(parameters.encodings.size(), 1u); @@ -3785,7 +3772,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, RtpTransceiverInit init; init.send_encodings.push_back({}); init.send_encodings[0].max_bitrate_bps = 12345; - auto result = caller()->pc()->AddTransceiver(webrtc::MediaType::VIDEO, init); + auto result = caller()->pc()->AddTransceiver(MediaType::VIDEO, init); auto transceiver = result.MoveValue(); auto parameters = transceiver->sender()->GetParameters(); ASSERT_EQ(parameters.encodings.size(), 1u); @@ -3850,7 +3837,7 @@ TEST_P(PeerConnectionIntegrationInteropTest, OneAudioLocalToNoMediaRemote) { // has the same track ID as the sending track. auto receivers = callee()->pc()->GetReceivers(); ASSERT_EQ(1u, receivers.size()); - EXPECT_EQ(webrtc::MediaType::AUDIO, receivers[0]->media_type()); + EXPECT_EQ(MediaType::AUDIO, receivers[0]->media_type()); EXPECT_EQ(receivers[0]->track()->id(), audio_sender->track()->id()); MediaExpectations media_expectations; @@ -3871,10 +3858,10 @@ TEST_P(PeerConnectionIntegrationInteropTest, OneAudioOneVideoToNoMediaRemote) { // Verify that one audio and one video receiver have been created on the // remote and that they have the same track IDs as the sending tracks. - auto audio_receivers = callee()->GetReceiversOfType(webrtc::MediaType::AUDIO); + auto audio_receivers = callee()->GetReceiversOfType(MediaType::AUDIO); ASSERT_EQ(1u, audio_receivers.size()); EXPECT_EQ(audio_receivers[0]->track()->id(), audio_sender->track()->id()); - auto video_receivers = callee()->GetReceiversOfType(webrtc::MediaType::VIDEO); + auto video_receivers = callee()->GetReceiversOfType(MediaType::VIDEO); ASSERT_EQ(1u, video_receivers.size()); EXPECT_EQ(video_receivers[0]->track()->id(), video_sender->track()->id()); @@ -3913,7 +3900,7 @@ TEST_P(PeerConnectionIntegrationInteropTest, IsRtcOk()); // Verify that only the audio track has been negotiated. - EXPECT_EQ(0u, caller()->GetReceiversOfType(webrtc::MediaType::VIDEO).size()); + EXPECT_EQ(0u, caller()->GetReceiversOfType(MediaType::VIDEO).size()); // Might also check that the callee's NegotiationNeeded flag is set. // Reverse roles. @@ -4496,7 +4483,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, RTCConfiguration config; ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config)); ConnectFakeSignaling(); - webrtc::RtpEncodingParameters init_send_encodings; + RtpEncodingParameters init_send_encodings; init_send_encodings.active = false; caller()->pc()->AddTrack(caller()->CreateLocalAudioTrack(), {"name"}, {init_send_encodings}); @@ -4793,6 +4780,107 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, EXPECT_TRUE(caller()->SetLocalDescriptionAndSendSdpMessage(std::move(offer))); } +TEST_F(PeerConnectionIntegrationTestUnifiedPlan, + MungeOfferCodecAndReOfferWorksWithSetCodecPreferencesIsAFootgun) { + ASSERT_TRUE(CreatePeerConnectionWrappers()); + ConnectFakeSignaling(); + caller()->AddVideoTrack(); + bool has_munged = false; + auto munger = + [&has_munged](std::unique_ptr& sdp) { + auto video = GetFirstVideoContentDescription(sdp->description()); + auto codecs = video->codecs(); + std::optional replacement_codec; + for (auto&& codec : codecs) { + if (codec.name == "VP9") { + replacement_codec = codec; + break; + } + } + if (replacement_codec) { + for (auto&& codec : codecs) { + if (codec.name == "VP8") { + RTC_LOG(LS_INFO) << "Remapping VP8 codec " << codec << " to VP9"; + codec.name = replacement_codec->name; + codec.params = replacement_codec->params; + has_munged = true; + break; + } + } + video->set_codecs(codecs); + } else { + RTC_LOG(LS_INFO) << "Skipping munge, no VP9 codec found "; + } + }; + caller()->SetGeneratedSdpMunger(munger); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT( + WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), + IsRtcOk()); + caller()->SetGeneratedSdpMunger(nullptr); + + if (!has_munged) { + GTEST_SKIP() << "SDP munging did not replace codec, skipping."; + } + + // Note currently negotiated codecs and count VP8 and VP9. + auto codecs_after_munge = caller() + ->pc() + ->local_description() + ->description() + ->contents()[0] + .media_description() + ->codecs(); + size_t vp8_munge = 0; + size_t vp9_munge = 0; + for (const auto& codec : codecs_after_munge) { + if (codec.name == "VP8") + vp8_munge++; + else if (codec.name == "VP9") + vp9_munge++; + } + // We should have replaced VP8 with VP9. + EXPECT_EQ(vp8_munge, 0u); + EXPECT_GE(vp9_munge, 2u); + + // Call setCodecPreferences. + std::vector codecs = + caller() + ->pc_factory() + ->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO) + .codecs; + auto transceivers = caller()->pc()->GetTransceivers(); + ASSERT_EQ(transceivers.size(), 1u); + transceivers[0]->SetCodecPreferences(codecs); + + auto offer = caller()->CreateOfferAndWait(); + ASSERT_NE(offer, nullptr); + // The offer should be acceptable. + EXPECT_TRUE(caller()->SetLocalDescriptionAndSendSdpMessage(std::move(offer))); + + auto codecs_after_scp = caller() + ->pc() + ->local_description() + ->description() + ->contents()[0] + .media_description() + ->codecs(); + size_t vp8_scp = 0; + size_t vp9_scp = 0; + for (const auto& codec : codecs_after_scp) { + if (codec.name == "VP8") + vp8_scp++; + else if (codec.name == "VP9") + vp9_scp++; + } + // The SDP munging modification was reverted by sCP. + // This is a footgun but please do not mix such munging with + // setCodecPreferences, munging is on the way out. + EXPECT_EQ(vp8_scp, 1u); + EXPECT_GE(vp9_scp, 1u); + EXPECT_GT(vp9_munge, vp9_scp); +} + TEST_F(PeerConnectionIntegrationTestUnifiedPlan, SensibleRtxWithDuplicateCodecs) { ASSERT_TRUE(CreatePeerConnectionWrappers()); @@ -4837,7 +4925,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, // associated RTX codec. std::unique_ptr answer = caller()->CreateAnswerForTest(); - ASSERT_THAT(answer, NotNull()); + ASSERT_NE(answer, nullptr); RTC_LOG(LS_ERROR) << "Answer is " << *answer; ASSERT_THAT(answer->description()->contents().size(), Eq(1)); auto codecs = @@ -4896,7 +4984,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->AddVideoTrack(); auto offer2 = caller()->CreateOfferAndWait(); // Observe that packetization is raw on BOTH media sections. - ASSERT_THAT(offer2, NotNull()); + ASSERT_NE(offer2, nullptr); EXPECT_EQ(offer2->description()->contents().size(), 2U); for (const auto& content : offer2->description()->contents()) { for (const auto& codec : content.media_description()->codecs()) { @@ -4909,6 +4997,98 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, } } +#ifdef WEBRTC_HAVE_SCTP + +TEST_P(PeerConnectionIntegrationTest, DtlsPqc) { + CryptoOptions crypto_options; + crypto_options.ephemeral_key_exchange_cipher_groups.AddFirst( + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768); + + PeerConnectionInterface::RTCConfiguration config; + config.crypto_options = crypto_options; + + PeerConnectionFactoryInterface::Options options; + options.ssl_max_version = SSL_PROTOCOL_DTLS_13; + + const bool create_media_engine = false; + SetCallerPcWrapperAndReturnCurrent(CreatePeerConnectionWrapper( + "caller", &options, &config, PeerConnectionDependencies(nullptr), + /* event_log_factory= */ nullptr, + /* reset_encoder_factory= */ false, + /* reset_decoder_factory= */ false, create_media_engine)); + SetCalleePcWrapperAndReturnCurrent(CreatePeerConnectionWrapper( + "callee", &options, &config, PeerConnectionDependencies(nullptr), + /* event_log_factory= */ nullptr, + /* reset_encoder_factory= */ false, + /* reset_decoder_factory= */ false, create_media_engine)); + + ConnectFakeSignaling(); + + caller()->CreateDataChannel(); + + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT( + WaitUntil( + [&] { + return PeerConnectionStateIs( + PeerConnectionInterface::PeerConnectionState::kConnected); + }, + ::testing::IsTrue()), + IsRtcOk()); + + uint16_t expected = + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519_MLKEM768; + if (!SSLStreamAdapter::IsBoringSsl()) { + expected = webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519; + } + EXPECT_EQ(caller()->dtls_transport_information().ssl_group_id(), expected); + EXPECT_EQ(caller()->dtls_transport_information().ssl_group_id(), expected); +} + +TEST_P(PeerConnectionIntegrationTest, DtlsPqcFieldTrial) { + SetFieldTrials("WebRTC-EnableDtlsPqc/Enabled/"); + PeerConnectionInterface::RTCConfiguration config; + PeerConnectionFactoryInterface::Options options; + options.ssl_max_version = SSL_PROTOCOL_DTLS_13; + + const bool create_media_engine = false; + SetCallerPcWrapperAndReturnCurrent(CreatePeerConnectionWrapper( + "caller", &options, &config, PeerConnectionDependencies(nullptr), + /* event_log_factory= */ nullptr, + /* reset_encoder_factory= */ false, + /* reset_decoder_factory= */ false, create_media_engine)); + SetCalleePcWrapperAndReturnCurrent(CreatePeerConnectionWrapper( + "callee", &options, &config, PeerConnectionDependencies(nullptr), + /* event_log_factory= */ nullptr, + /* reset_encoder_factory= */ false, + /* reset_decoder_factory= */ false, create_media_engine)); + + ConnectFakeSignaling(); + + caller()->CreateDataChannel(); + + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT( + WaitUntil( + [&] { + return PeerConnectionStateIs( + PeerConnectionInterface::PeerConnectionState::kConnected); + }, + ::testing::IsTrue()), + IsRtcOk()); + + uint16_t expected = + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519_MLKEM768; + if (!SSLStreamAdapter::IsBoringSsl()) { + expected = webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519; + } + EXPECT_EQ(caller()->dtls_transport_information().ssl_group_id(), expected); + EXPECT_EQ(caller()->dtls_transport_information().ssl_group_id(), expected); +} + +#endif // WEBRTC_HAVE_SCTP + } // namespace } // namespace webrtc diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc index d56492afde..4e6bc33395 100644 --- a/pc/peer_connection_interface_unittest.cc +++ b/pc/peer_connection_interface_unittest.cc @@ -42,11 +42,9 @@ #include "api/rtp_sender_interface.h" #include "api/rtp_transceiver_direction.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/test/rtc_error_matchers.h" #include "api/transport/bitrate_settings.h" #include "api/transport/enums.h" -#include "api/transport/field_trial_based_config.h" #include "api/units/time_delta.h" #include "api/video_codecs/video_decoder_factory_template.h" #include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h" @@ -612,8 +610,6 @@ class PeerConnectionFactoryForTest : public PeerConnectionFactory { dependencies.worker_thread = Thread::Current(); dependencies.network_thread = Thread::Current(); dependencies.signaling_thread = Thread::Current(); - dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); - dependencies.trials = std::make_unique(); // Use fake audio device module since we're only testing the interface // level, and using a real one could make tests flaky when run in parallel. dependencies.adm = FakeAudioCaptureModule::Create(); @@ -834,7 +830,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { } scoped_refptr GetFirstReceiverOfType( - webrtc::MediaType media_type) { + MediaType media_type) { for (auto receiver : pc_->GetReceivers()) { if (receiver->media_type() == media_type) { return receiver; @@ -856,7 +852,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { } EXPECT_THAT( WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); *desc = observer->MoveDescription(); return observer->result(); @@ -884,7 +880,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { if (pc_->signaling_state() != PeerConnectionInterface::kClosed) { EXPECT_THAT( WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } return observer->result(); @@ -910,7 +906,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { return false; EXPECT_THAT( WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); return observer->called(); } @@ -921,7 +917,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { pc_->GetStats(callback.get()); EXPECT_THAT( WaitUntil([&] { return callback->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); return callback->called(); } @@ -1029,7 +1025,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { // Wait for the ice_complete message, so that SDP will have candidates. EXPECT_THAT(WaitUntil([&] { return observer_.ice_gathering_complete_; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } @@ -1062,13 +1058,13 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { // Verify that both OnAddStream and OnAddTrack are called. EXPECT_THAT(WaitUntil([&] { return observer_.GetLastAddedStreamId(); }, ::testing::Eq(stream_id), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_THAT( WaitUntil( [&] { return observer_.CountAddTrackEventsForStream(stream_id); }, ::testing::Eq(expected_num_tracks), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } @@ -1186,7 +1182,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { pc_->CreateOffer(observer.get(), offer_answer_options); EXPECT_THAT( WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); return observer->MoveDescription(); } @@ -1767,12 +1763,12 @@ TEST_P(PeerConnectionInterfaceTest, IceCandidates) { EXPECT_THAT(WaitUntil([&] { return observer_.last_candidate(); }, ::testing::Ne(nullptr), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), - IsRtcOk()); - EXPECT_THAT(WaitUntil([&] { return observer_.ice_gathering_complete_; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return observer_.ice_gathering_complete_; }, + ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate())); } @@ -1915,7 +1911,7 @@ TEST_P(PeerConnectionInterfaceTest, GetStatsForSpecificTrack) { // Test that we can get stats on a video track. TEST_P(PeerConnectionInterfaceTest, GetStatsForVideoTrack) { InitiateCall(); - auto video_receiver = GetFirstReceiverOfType(webrtc::MediaType::VIDEO); + auto video_receiver = GetFirstReceiverOfType(MediaType::VIDEO); ASSERT_TRUE(video_receiver); EXPECT_TRUE(DoGetStats(video_receiver->track().get())); } @@ -2068,7 +2064,7 @@ TEST_P(PeerConnectionInterfaceTest, DISABLED_TestRejectSctpDataChannelInAnswer) RTCConfiguration rtc_config; CreatePeerConnection(rtc_config); - auto offer_channel = pc_->CreateDataChannelOrError("offer_channel", NULL); + auto offer_channel = pc_->CreateDataChannelOrError("offer_channel", nullptr); CreateOfferAsLocalDescription(); @@ -2441,19 +2437,19 @@ TEST_P(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { EXPECT_EQ(2u, pc_->GetTransceivers().size()); } - auto audio_receiver = GetFirstReceiverOfType(webrtc::MediaType::AUDIO); - auto video_receiver = GetFirstReceiverOfType(webrtc::MediaType::VIDEO); + auto audio_receiver = GetFirstReceiverOfType(MediaType::AUDIO); + auto video_receiver = GetFirstReceiverOfType(MediaType::VIDEO); if (sdp_semantics_ == SdpSemantics::kPlanB_DEPRECATED) { ASSERT_TRUE(audio_receiver); ASSERT_TRUE(video_receiver); // Track state may be updated asynchronously. EXPECT_THAT(WaitUntil([&] { return audio_receiver->track()->state(); }, ::testing::Eq(MediaStreamTrackInterface::kEnded), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return video_receiver->track()->state(); }, ::testing::Eq(MediaStreamTrackInterface::kEnded), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } else { ASSERT_FALSE(audio_receiver); @@ -2478,7 +2474,7 @@ TEST_F(PeerConnectionInterfaceTestPlanB, CloseAndTestMethods) { pc_->RemoveStream(local_stream.get()); EXPECT_FALSE(pc_->AddStream(local_stream.get())); - EXPECT_FALSE(pc_->CreateDataChannelOrError("test", NULL).ok()); + EXPECT_FALSE(pc_->CreateDataChannelOrError("test", nullptr).ok()); EXPECT_TRUE(pc_->local_description() != nullptr); EXPECT_TRUE(pc_->remote_description() != nullptr); @@ -2575,11 +2571,11 @@ TEST_F(PeerConnectionInterfaceTestPlanB, // Track state may be updated asynchronously. EXPECT_THAT(WaitUntil([&] { return audio_track2->state(); }, ::testing::Eq(MediaStreamTrackInterface::kEnded), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return video_track2->state(); }, ::testing::Eq(MediaStreamTrackInterface::kEnded), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } @@ -2591,9 +2587,9 @@ TEST_P(PeerConnectionInterfaceTest, RejectMediaContent) { // First create and set a remote offer, then reject its video content in our // answer. CreateAndSetRemoteOffer(kSdpStringWithStream1PlanB); - auto audio_receiver = GetFirstReceiverOfType(webrtc::MediaType::AUDIO); + auto audio_receiver = GetFirstReceiverOfType(MediaType::AUDIO); ASSERT_TRUE(audio_receiver); - auto video_receiver = GetFirstReceiverOfType(webrtc::MediaType::VIDEO); + auto video_receiver = GetFirstReceiverOfType(MediaType::VIDEO); ASSERT_TRUE(video_receiver); scoped_refptr remote_audio = @@ -2626,11 +2622,11 @@ TEST_P(PeerConnectionInterfaceTest, RejectMediaContent) { // Track state may be updated asynchronously. EXPECT_THAT(WaitUntil([&] { return remote_audio->state(); }, ::testing::Eq(MediaStreamTrackInterface::kEnded), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return remote_video->state(); }, ::testing::Eq(MediaStreamTrackInterface::kEnded), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), + {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } @@ -3617,34 +3613,34 @@ TEST_F(PeerConnectionInterfaceTestPlanB, scoped_refptr video_track( CreateVideoTrack("video_track")); stream->AddTrack(audio_track); - EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return observer_.renegotiation_needed_; }, + ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); observer_.renegotiation_needed_ = false; CreateOfferReceiveAnswer(); stream->AddTrack(video_track); - EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return observer_.renegotiation_needed_; }, + ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); observer_.renegotiation_needed_ = false; CreateOfferReceiveAnswer(); stream->RemoveTrack(audio_track); - EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return observer_.renegotiation_needed_; }, + ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); observer_.renegotiation_needed_ = false; CreateOfferReceiveAnswer(); stream->RemoveTrack(video_track); - EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return observer_.renegotiation_needed_; }, + ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); observer_.renegotiation_needed_ = false; } @@ -3702,7 +3698,7 @@ TEST_P(PeerConnectionInterfaceTest, std::vector> rtp_senders = pc_->GetSenders(); ASSERT_EQ(rtp_senders.size(), 1u); - ASSERT_EQ(rtp_senders[0]->media_type(), webrtc::MediaType::VIDEO); + ASSERT_EQ(rtp_senders[0]->media_type(), MediaType::VIDEO); scoped_refptr video_rtp_sender = rtp_senders[0]; RtpParameters parameters = video_rtp_sender->GetParameters(); ASSERT_NE(parameters.degradation_preference, diff --git a/pc/peer_connection_jsep_unittest.cc b/pc/peer_connection_jsep_unittest.cc index 27aba158e4..90016662d6 100644 --- a/pc/peer_connection_jsep_unittest.cc +++ b/pc/peer_connection_jsep_unittest.cc @@ -32,8 +32,7 @@ #include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" -#include "api/transport/field_trial_based_config.h" +#include "api/test/rtc_error_matchers.h" #include "media/base/stream_params.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/transport_info.h" @@ -60,7 +59,6 @@ namespace webrtc { -using webrtc::MediaContentDescription; using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; using ::testing::Combine; using ::testing::ElementsAre; @@ -72,8 +70,6 @@ PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies() { dependencies.worker_thread = Thread::Current(); dependencies.network_thread = Thread::Current(); dependencies.signaling_thread = Thread::Current(); - dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); - dependencies.trials = std::make_unique(); dependencies.adm = FakeAudioCaptureModule::Create(); EnableMediaWithDefaults(dependencies); dependencies.sctp_factory = std::make_unique(); @@ -132,24 +128,24 @@ TEST_F(PeerConnectionJsepTest, EmptyInitialOffer) { // section. TEST_F(PeerConnectionJsepTest, AudioOnlyInitialOffer) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); - EXPECT_EQ(webrtc::MediaType::AUDIO, contents[0].media_description()->type()); + EXPECT_EQ(MediaType::AUDIO, contents[0].media_description()->type()); } // Test than an initial offer with one video track generates one video media // section TEST_F(PeerConnectionJsepTest, VideoOnlyInitialOffer) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO); auto offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); - EXPECT_EQ(webrtc::MediaType::VIDEO, contents[0].media_description()->type()); + EXPECT_EQ(MediaType::VIDEO, contents[0].media_description()->type()); } // Test that an initial offer with one data channel generates one data media @@ -161,7 +157,7 @@ TEST_F(PeerConnectionJsepTest, DataOnlyInitialOffer) { auto offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); - EXPECT_EQ(webrtc::MediaType::DATA, contents[0].media_description()->type()); + EXPECT_EQ(MediaType::DATA, contents[0].media_description()->type()); } // Test that creating multiple data channels only results in one data section @@ -181,11 +177,11 @@ TEST_F(PeerConnectionJsepTest, MultipleDataChannelsCreateOnlyOneDataSection) { // JSEP section 5.2.1. TEST_F(PeerConnectionJsepTest, MediaSectionsInInitialOfferOrderedCorrectly) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::VIDEO); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::VIDEO); + caller->AddTransceiver(MediaType::AUDIO); RtpTransceiverInit init; init.direction = RtpTransceiverDirection::kSendOnly; - caller->AddTransceiver(webrtc::MediaType::VIDEO, init); + caller->AddTransceiver(MediaType::VIDEO, init); auto offer = caller->CreateOffer(); auto contents = offer->description()->contents(); @@ -193,19 +189,19 @@ TEST_F(PeerConnectionJsepTest, MediaSectionsInInitialOfferOrderedCorrectly) { const MediaContentDescription* media_description1 = contents[0].media_description(); - EXPECT_EQ(webrtc::MediaType::VIDEO, media_description1->type()); + EXPECT_EQ(MediaType::VIDEO, media_description1->type()); EXPECT_EQ(RtpTransceiverDirection::kSendRecv, media_description1->direction()); const MediaContentDescription* media_description2 = contents[1].media_description(); - EXPECT_EQ(webrtc::MediaType::AUDIO, media_description2->type()); + EXPECT_EQ(MediaType::AUDIO, media_description2->type()); EXPECT_EQ(RtpTransceiverDirection::kSendRecv, media_description2->direction()); const MediaContentDescription* media_description3 = contents[2].media_description(); - EXPECT_EQ(webrtc::MediaType::VIDEO, media_description3->type()); + EXPECT_EQ(MediaType::VIDEO, media_description3->type()); EXPECT_EQ(RtpTransceiverDirection::kSendOnly, media_description3->direction()); } @@ -213,8 +209,8 @@ TEST_F(PeerConnectionJsepTest, MediaSectionsInInitialOfferOrderedCorrectly) { // Test that media sections in the initial offer have different mids. TEST_F(PeerConnectionJsepTest, MediaSectionsInInitialOfferHaveDifferentMids) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto offer = caller->CreateOffer(); auto contents = offer->description()->contents(); @@ -225,7 +221,7 @@ TEST_F(PeerConnectionJsepTest, MediaSectionsInInitialOfferHaveDifferentMids) { TEST_F(PeerConnectionJsepTest, StoppedTransceiverHasNoMediaSectionInInitialOffer) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->StopInternal(); auto offer = caller->CreateOffer(); @@ -246,8 +242,8 @@ TEST_F(PeerConnectionJsepTest, SetLocalEmptyOfferCreatesNoTransceivers) { TEST_F(PeerConnectionJsepTest, SetLocalOfferSetsTransceiverMid) { auto caller = CreatePeerConnection(); - auto audio_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); - auto video_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); + auto video_transceiver = caller->AddTransceiver(MediaType::VIDEO); auto offer = caller->CreateOffer(); auto audio_mid = offer->description()->contents()[0].mid(); @@ -265,8 +261,8 @@ TEST_F(PeerConnectionJsepTest, SetLocalOfferSetsTransceiverMid) { // transceivers, one for receiving audio and one for receiving video. TEST_F(PeerConnectionJsepTest, SetRemoteOfferCreatesTransceivers) { auto caller = CreatePeerConnection(); - auto caller_audio = caller->AddTransceiver(webrtc::MediaType::AUDIO); - auto caller_video = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto caller_audio = caller->AddTransceiver(MediaType::AUDIO); + auto caller_video = caller->AddTransceiver(MediaType::VIDEO); auto callee = CreatePeerConnection(); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -274,12 +270,12 @@ TEST_F(PeerConnectionJsepTest, SetRemoteOfferCreatesTransceivers) { auto transceivers = callee->pc()->GetTransceivers(); ASSERT_EQ(2u, transceivers.size()); - EXPECT_EQ(webrtc::MediaType::AUDIO, transceivers[0]->media_type()); + EXPECT_EQ(MediaType::AUDIO, transceivers[0]->media_type()); EXPECT_EQ(caller_audio->mid(), transceivers[0]->mid()); EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, transceivers[0]->direction()); EXPECT_EQ(0u, transceivers[0]->sender()->stream_ids().size()); - EXPECT_EQ(webrtc::MediaType::VIDEO, transceivers[1]->media_type()); + EXPECT_EQ(MediaType::VIDEO, transceivers[1]->media_type()); EXPECT_EQ(caller_video->mid(), transceivers[1]->mid()); EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, transceivers[1]->direction()); EXPECT_EQ(0u, transceivers[1]->sender()->stream_ids().size()); @@ -334,7 +330,7 @@ TEST_F(PeerConnectionJsepTest, auto caller = CreatePeerConnection(); caller->AddAudioTrack("a"); auto callee = CreatePeerConnection(); - auto transceiver = callee->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = callee->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -414,9 +410,9 @@ TEST_F(PeerConnectionJsepTest, SetRemoteOfferReusesTransceiversOfBothTypes) { // offered media in the same order and with the same mids. TEST_F(PeerConnectionJsepTest, CreateAnswerHasSameMidsAsOffer) { auto caller = CreatePeerConnection(); - auto first_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); - auto second_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); - auto third_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto first_transceiver = caller->AddTransceiver(MediaType::VIDEO); + auto second_transceiver = caller->AddTransceiver(MediaType::AUDIO); + auto third_transceiver = caller->AddTransceiver(MediaType::VIDEO); caller->CreateDataChannel("dc"); auto callee = CreatePeerConnection(); @@ -429,13 +425,13 @@ TEST_F(PeerConnectionJsepTest, CreateAnswerHasSameMidsAsOffer) { auto answer = callee->CreateAnswer(); auto contents = answer->description()->contents(); ASSERT_EQ(4u, contents.size()); - EXPECT_EQ(webrtc::MediaType::VIDEO, contents[0].media_description()->type()); + EXPECT_EQ(MediaType::VIDEO, contents[0].media_description()->type()); EXPECT_EQ(first_transceiver->mid(), contents[0].mid()); - EXPECT_EQ(webrtc::MediaType::AUDIO, contents[1].media_description()->type()); + EXPECT_EQ(MediaType::AUDIO, contents[1].media_description()->type()); EXPECT_EQ(second_transceiver->mid(), contents[1].mid()); - EXPECT_EQ(webrtc::MediaType::VIDEO, contents[2].media_description()->type()); + EXPECT_EQ(MediaType::VIDEO, contents[2].media_description()->type()); EXPECT_EQ(third_transceiver->mid(), contents[2].mid()); - EXPECT_EQ(webrtc::MediaType::DATA, contents[3].media_description()->type()); + EXPECT_EQ(MediaType::DATA, contents[3].media_description()->type()); EXPECT_EQ(offer_data->mid(), contents[3].mid()); } @@ -463,7 +459,7 @@ TEST_F(PeerConnectionJsepTest, CreateAnswerNegotiatesDirection) { auto caller = CreatePeerConnection(); RtpTransceiverInit init; init.direction = RtpTransceiverDirection::kSendOnly; - caller->AddTransceiver(webrtc::MediaType::AUDIO, init); + caller->AddTransceiver(MediaType::AUDIO, init); auto callee = CreatePeerConnection(); callee->AddAudioTrack("a"); @@ -484,7 +480,7 @@ TEST_F(PeerConnectionJsepTest, CreateAnswerNegotiatesDirection) { // property of the transceivers mentioned in the session description. TEST_F(PeerConnectionJsepTest, SetLocalAnswerUpdatesCurrentDirection) { auto caller = CreatePeerConnection(); - auto caller_audio = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto caller_audio = caller->AddTransceiver(MediaType::AUDIO); caller_audio->SetDirectionWithError(RtpTransceiverDirection::kRecvOnly); auto callee = CreatePeerConnection(); callee->AddAudioTrack("a"); @@ -528,7 +524,7 @@ TEST_F(PeerConnectionJsepTest, SetRemoteAnswerUpdatesCurrentDirection) { TEST_F(PeerConnectionJsepTest, ChangeDirectionFromRecvOnlyToSendRecvDoesNotBreakVideoNegotiation) { auto caller = CreatePeerConnection(); - auto caller_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto caller_transceiver = caller->AddTransceiver(MediaType::VIDEO); auto callee = CreatePeerConnection(); caller_transceiver->SetDirectionWithError(RtpTransceiverDirection::kRecvOnly); @@ -546,7 +542,7 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, ChangeDirectionFromRecvOnlyToSendRecvDoesNotBreakAudioNegotiation) { auto caller = CreatePeerConnection(); - auto caller_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto caller_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); caller_transceiver->SetDirectionWithError(RtpTransceiverDirection::kRecvOnly); @@ -587,7 +583,7 @@ TEST_F(PeerConnectionJsepTest, SettingTransceiverInactiveDoesNotStopIt) { TEST_F(PeerConnectionJsepTest, ReOfferMediaSectionForAssociatedStoppedTransceiverIsRejected) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -609,7 +605,7 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, StoppingTransceiverInOfferStopsTransceiverOnRemoteSide) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -632,14 +628,14 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, CreateOfferDoesNotRecycleMediaSectionIfFirstStopped) { auto caller = CreatePeerConnection(); - auto first_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto first_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); ASSERT_TRUE( caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal())); - auto second_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto second_transceiver = caller->AddTransceiver(MediaType::AUDIO); first_transceiver->StopInternal(); auto reoffer = caller->CreateOffer(); @@ -655,7 +651,7 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, RecycleMediaSectionWhenStoppingTransceiverOnAnswerer) { auto caller = CreatePeerConnection(); - auto first_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto first_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -717,7 +713,7 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, CreateOfferRecyclesWhenOfferingTwice) { // Do a negotiation with a port 0 for the media section. auto caller = CreatePeerConnection(); - auto first_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto first_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); first_transceiver->StopInternal(); @@ -763,16 +759,15 @@ TEST_F(PeerConnectionJsepTest, CreateOfferRecyclesWhenOfferingTwice) { // - The new transceiver is associated with the new MID value. class RecycleMediaSectionTest : public PeerConnectionJsepTest, - public ::testing::WithParamInterface< - std::tuple> { + public ::testing::WithParamInterface> { protected: RecycleMediaSectionTest() { first_type_ = std::get<0>(GetParam()); second_type_ = std::get<1>(GetParam()); } - webrtc::MediaType first_type_; - webrtc::MediaType second_type_; + MediaType first_type_; + MediaType second_type_; }; // Test that recycling works properly when a new transceiver recycles an m= @@ -1114,18 +1109,17 @@ TEST_P(RecycleMediaSectionTest, PendingRemoteRejectedAndNotRejectedLocal) { // for the media section. This is needed for full test coverage because // MediaSession has separate functions for processing audio and video media // sections. -INSTANTIATE_TEST_SUITE_P( - PeerConnectionJsepTest, - RecycleMediaSectionTest, - Combine(Values(webrtc::MediaType::AUDIO, webrtc::MediaType::VIDEO), - Values(webrtc::MediaType::AUDIO, webrtc::MediaType::VIDEO))); +INSTANTIATE_TEST_SUITE_P(PeerConnectionJsepTest, + RecycleMediaSectionTest, + Combine(Values(MediaType::AUDIO, MediaType::VIDEO), + Values(MediaType::AUDIO, MediaType::VIDEO))); // Test that a new data channel section will not reuse a recycleable audio or // video media section. Additionally, tests that the new section is added to the // end of the session description. TEST_F(PeerConnectionJsepTest, DataChannelDoesNotRecycleMediaSection) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); @@ -1139,10 +1133,8 @@ TEST_F(PeerConnectionJsepTest, DataChannelDoesNotRecycleMediaSection) { auto offer = caller->CreateOffer(); auto offer_contents = offer->description()->contents(); ASSERT_EQ(2u, offer_contents.size()); - EXPECT_EQ(webrtc::MediaType::AUDIO, - offer_contents[0].media_description()->type()); - EXPECT_EQ(webrtc::MediaType::DATA, - offer_contents[1].media_description()->type()); + EXPECT_EQ(MediaType::AUDIO, offer_contents[0].media_description()->type()); + EXPECT_EQ(MediaType::DATA, offer_contents[1].media_description()->type()); ASSERT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); @@ -1151,10 +1143,8 @@ TEST_F(PeerConnectionJsepTest, DataChannelDoesNotRecycleMediaSection) { auto answer = callee->CreateAnswer(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(2u, answer_contents.size()); - EXPECT_EQ(webrtc::MediaType::AUDIO, - answer_contents[0].media_description()->type()); - EXPECT_EQ(webrtc::MediaType::DATA, - answer_contents[1].media_description()->type()); + EXPECT_EQ(MediaType::AUDIO, answer_contents[0].media_description()->type()); + EXPECT_EQ(MediaType::DATA, answer_contents[1].media_description()->type()); } // Test that if a new track is added to an existing session that has a data, @@ -1172,8 +1162,8 @@ TEST_F(PeerConnectionJsepTest, AudioTrackAddedAfterDataSectionInReoffer) { auto offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(2u, contents.size()); - EXPECT_EQ(webrtc::MediaType::DATA, contents[0].media_description()->type()); - EXPECT_EQ(webrtc::MediaType::AUDIO, contents[1].media_description()->type()); + EXPECT_EQ(MediaType::DATA, contents[0].media_description()->type()); + EXPECT_EQ(MediaType::AUDIO, contents[1].media_description()->type()); } // Tests for MID properties. @@ -1344,7 +1334,7 @@ TEST_F(PeerConnectionJsepTest, const std::string kTrackId = "audio_track"; auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->sender()->SetTrack(caller->CreateAudioTrack(kTrackId).get()); auto offer = caller->CreateOffer(); @@ -1362,11 +1352,11 @@ TEST_F(PeerConnectionJsepTest, NoMsidInOfferIfTransceiverDirectionHasNoSend) { RtpTransceiverInit init_recvonly; init_recvonly.direction = RtpTransceiverDirection::kRecvOnly; - ASSERT_TRUE(caller->AddTransceiver(webrtc::MediaType::AUDIO, init_recvonly)); + ASSERT_TRUE(caller->AddTransceiver(MediaType::AUDIO, init_recvonly)); RtpTransceiverInit init_inactive; init_inactive.direction = RtpTransceiverDirection::kInactive; - ASSERT_TRUE(caller->AddTransceiver(webrtc::MediaType::VIDEO, init_inactive)); + ASSERT_TRUE(caller->AddTransceiver(MediaType::VIDEO, init_inactive)); auto offer = caller->CreateOffer(); auto contents = offer->description()->contents(); @@ -1386,13 +1376,13 @@ TEST_F(PeerConnectionJsepTest, NoMsidInAnswerIfNoRespondingTracks) { // no tracks to send in response. RtpTransceiverInit init_recvonly; init_recvonly.direction = RtpTransceiverDirection::kRecvOnly; - caller->AddTransceiver(webrtc::MediaType::AUDIO, init_recvonly); + caller->AddTransceiver(MediaType::AUDIO, init_recvonly); // sendrecv transceiver will get negotiated to recvonly since the callee has // no tracks to send in response. RtpTransceiverInit init_sendrecv; init_sendrecv.direction = RtpTransceiverDirection::kSendRecv; - caller->AddTransceiver(webrtc::MediaType::VIDEO, init_sendrecv); + caller->AddTransceiver(MediaType::VIDEO, init_sendrecv); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -1437,7 +1427,7 @@ TEST_F(PeerConnectionJsepTest, IncludeMsidEvenIfDirectionHasChanged) { // any MSID information for that section. TEST_F(PeerConnectionJsepTest, RemoveMsidIfTransceiverStopped) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); @@ -1594,7 +1584,7 @@ TEST_F(PeerConnectionJsepTest, CurrentDirectionResetWhenRtpTransceiverStopped) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); @@ -1906,7 +1896,7 @@ TEST_F(PeerConnectionJsepTest, AttemptToRollbackImplicitly) { TEST_F(PeerConnectionJsepTest, RollbackRemovesTransceiver) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); ASSERT_EQ(callee->pc()->GetTransceivers().size(), 1u); @@ -1924,7 +1914,7 @@ TEST_F(PeerConnectionJsepTest, RollbackRemovesTransceiver) { TEST_F(PeerConnectionJsepTest, RollbackKeepsTransceiverAndClearsMid) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); callee->AddAudioTrack("a"); @@ -1950,7 +1940,7 @@ TEST_F(PeerConnectionJsepTest, RollbackKeepsTransceiverAndClearsMid) { TEST_F(PeerConnectionJsepTest, RollbackKeepsTransceiverAfterAddTrackEvenWhenTrackIsNulled) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); callee->AddAudioTrack("a"); @@ -1970,7 +1960,7 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, RollbackRestoresMid) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); callee->AddAudioTrack("a"); auto offer = callee->CreateOffer(); @@ -1993,7 +1983,7 @@ TEST_F(PeerConnectionJsepTest, RollbackRestoresInitSendEncodings) { init.send_encodings.push_back(encoding); encoding.rid = "lo"; init.send_encodings.push_back(encoding); - caller->AddTransceiver(webrtc::MediaType::VIDEO, init); + caller->AddTransceiver(MediaType::VIDEO, init); auto encodings = caller->pc()->GetTransceivers()[0]->sender()->init_send_encodings(); EXPECT_TRUE(caller->SetLocalDescription(caller->CreateOffer())); @@ -2016,8 +2006,8 @@ TEST_F(PeerConnectionJsepTest, RollbackDoesNotAffectSendEncodings) { init.send_encodings.push_back(encoding); encoding.rid = "lo"; init.send_encodings.push_back(encoding); - caller->AddTransceiver(webrtc::MediaType::VIDEO, init); - callee->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO, init); + callee->AddTransceiver(MediaType::VIDEO); callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()); caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal()); auto params = caller->pc()->GetTransceivers()[0]->sender()->GetParameters(); @@ -2057,8 +2047,7 @@ TEST_F(PeerConnectionJsepTest, RollbackRestoresMidAndRemovesTransceiver) { EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateRollback())); EXPECT_EQ(callee->pc()->GetTransceivers().size(), 1u); EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), mid); - EXPECT_EQ(callee->pc()->GetTransceivers()[0]->media_type(), - webrtc::MediaType::VIDEO); + EXPECT_EQ(callee->pc()->GetTransceivers()[0]->media_type(), MediaType::VIDEO); EXPECT_TRUE(callee->SetLocalDescription(std::move(offer))); EXPECT_EQ(callee->observer()->remove_track_events_.size(), callee->observer()->add_track_events_.size()); @@ -2094,9 +2083,9 @@ TEST_F(PeerConnectionJsepTest, ImplicitlyRollbackTransceiversWithSameMids) { config.sdp_semantics = SdpSemantics::kUnifiedPlan; config.enable_implicit_rollback = true; auto caller = CreatePeerConnection(config); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO); auto callee = CreatePeerConnection(config); - callee->AddTransceiver(webrtc::MediaType::VIDEO); + callee->AddTransceiver(MediaType::VIDEO); EXPECT_TRUE(callee->CreateOfferAndSetAsLocal()); auto initial_mid = callee->pc()->GetTransceivers()[0]->mid(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -2114,7 +2103,7 @@ TEST_F(PeerConnectionJsepTest, RollbackToNegotiatedStableState) { config.sdp_semantics = SdpSemantics::kUnifiedPlan; config.bundle_policy = PeerConnectionInterface::kBundlePolicyMaxBundle; auto caller = CreatePeerConnection(config); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(config); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); EXPECT_TRUE(callee->CreateAnswerAndSetAsLocal()); @@ -2165,7 +2154,7 @@ TEST_F(PeerConnectionJsepTest, RollbackHasToDestroyTransport) { TEST_F(PeerConnectionJsepTest, RollbackLocalDirectionChange) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); EXPECT_TRUE( @@ -2188,7 +2177,7 @@ TEST_F(PeerConnectionJsepTest, RollbackLocalDirectionChange) { TEST_F(PeerConnectionJsepTest, RollbackRemoteDirectionChange) { auto caller = CreatePeerConnection(); - auto caller_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto caller_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); callee->AddAudioTrack("a"); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -2218,7 +2207,7 @@ TEST_F(PeerConnectionJsepTest, RollbackRemoteDirectionChange) { TEST_F(PeerConnectionJsepTest, RollbackRestoresFiredDirectionAndOnTrackCanFireAgain) { auto caller = CreatePeerConnection(); - auto caller_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto caller_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); callee->AddAudioTrack("a"); ASSERT_EQ(callee->pc()->GetTransceivers().size(), 1u); @@ -2248,7 +2237,7 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, RollbackFromInactiveToReceivingMakesOnTrackFire) { auto caller = CreatePeerConnection(); - auto caller_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto caller_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); // Perform full O/A so that transceiver is associated. Ontrack fires. EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); @@ -2271,9 +2260,9 @@ TEST_F(PeerConnectionJsepTest, TEST_F(PeerConnectionJsepTest, RollbackAfterMultipleSLD) { auto callee = CreatePeerConnection(); - callee->AddTransceiver(webrtc::MediaType::AUDIO); + callee->AddTransceiver(MediaType::AUDIO); EXPECT_TRUE(callee->CreateOfferAndSetAsLocal()); - callee->AddTransceiver(webrtc::MediaType::VIDEO); + callee->AddTransceiver(MediaType::VIDEO); EXPECT_TRUE(callee->CreateOfferAndSetAsLocal()); callee->observer()->clear_legacy_renegotiation_needed(); callee->observer()->clear_latest_negotiation_needed_event(); @@ -2287,9 +2276,9 @@ TEST_F(PeerConnectionJsepTest, RollbackAfterMultipleSLD) { TEST_F(PeerConnectionJsepTest, NoRollbackNeeded) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); - callee->AddTransceiver(webrtc::MediaType::AUDIO); + callee->AddTransceiver(MediaType::AUDIO); EXPECT_TRUE(caller->CreateOfferAndSetAsLocal()); EXPECT_TRUE(caller->CreateOfferAndSetAsLocal()); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); @@ -2322,7 +2311,7 @@ TEST_F(PeerConnectionJsepTest, DataChannelImplicitRollback) { config.sdp_semantics = SdpSemantics::kUnifiedPlan; config.enable_implicit_rollback = true; auto caller = CreatePeerConnection(config); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO); auto callee = CreatePeerConnection(config); callee->CreateDataChannel("dummy"); EXPECT_TRUE(callee->CreateOfferAndSetAsLocal()); @@ -2339,7 +2328,7 @@ TEST_F(PeerConnectionJsepTest, RollbackRemoteDataChannelThenAddTransceiver) { caller->CreateDataChannel("dummy"); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_TRUE(callee->SetRemoteDescription(callee->CreateRollback())); - callee->AddTransceiver(webrtc::MediaType::VIDEO); + callee->AddTransceiver(MediaType::VIDEO); EXPECT_TRUE(callee->CreateOfferAndSetAsLocal()); } @@ -2350,7 +2339,7 @@ TEST_F(PeerConnectionJsepTest, caller->CreateDataChannel("dummy"); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_TRUE(callee->SetRemoteDescription(callee->CreateRollback())); - callee->AddTransceiver(webrtc::MediaType::VIDEO); + callee->AddTransceiver(MediaType::VIDEO); callee->CreateDataChannel("dummy"); EXPECT_TRUE(callee->CreateOfferAndSetAsLocal()); } @@ -2368,7 +2357,7 @@ TEST_F(PeerConnectionJsepTest, RollbackRemoteDataChannelThenAddDataChannel) { TEST_F(PeerConnectionJsepTest, RollbackRemoteTransceiverThenAddDataChannel) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_TRUE(callee->SetRemoteDescription(callee->CreateRollback())); callee->CreateDataChannel("dummy"); @@ -2379,19 +2368,19 @@ TEST_F(PeerConnectionJsepTest, RollbackRemoteTransceiverThenAddDataChannelAndTransceiver) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::VIDEO); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_TRUE(callee->SetRemoteDescription(callee->CreateRollback())); callee->CreateDataChannel("dummy"); - callee->AddTransceiver(webrtc::MediaType::VIDEO); + callee->AddTransceiver(MediaType::VIDEO); EXPECT_TRUE(callee->CreateOfferAndSetAsLocal()); } TEST_F(PeerConnectionJsepTest, BundleOnlySectionDoesNotNeedRtcpMux) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); - caller->AddTransceiver(webrtc::MediaType::VIDEO); + caller->AddTransceiver(MediaType::AUDIO); + caller->AddTransceiver(MediaType::VIDEO); auto offer = caller->CreateOffer(); // Remove rtcp-mux and set bundle-only on the second content. offer->description()->contents()[1].media_description()->set_rtcp_mux(false); @@ -2400,4 +2389,17 @@ TEST_F(PeerConnectionJsepTest, BundleOnlySectionDoesNotNeedRtcpMux) { EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); } +// This test is a regression test for crbug.com/410960672 +TEST_F(PeerConnectionJsepTest, OfferRollbackRemoveReoffer) { + auto caller = CreatePeerConnection(); + // Add first video track. + auto sender = caller->AddVideoTrack("foo"); + caller->SetLocalDescription(caller->CreateOffer()); + caller->SetRemoteDescription(caller->CreateRollback()); + RTCError error = caller->pc()->RemoveTrackOrError(sender); + EXPECT_THAT(error, IsRtcOk()); + auto offer = caller->CreateOffer(); + caller->SetLocalDescription(std::move(offer)); +} + } // namespace webrtc diff --git a/pc/peer_connection_media_unittest.cc b/pc/peer_connection_media_unittest.cc index 242984a675..b47febc085 100644 --- a/pc/peer_connection_media_unittest.cc +++ b/pc/peer_connection_media_unittest.cc @@ -35,7 +35,6 @@ #include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" #include "media/base/codec.h" #include "media/base/fake_media_engine.h" #include "media/base/media_channel.h" @@ -169,7 +168,6 @@ class PeerConnectionMediaBaseTest : public ::testing::Test { factory_dependencies.network_thread = Thread::Current(); factory_dependencies.worker_thread = Thread::Current(); factory_dependencies.signaling_thread = Thread::Current(); - factory_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); EnableFakeMedia(factory_dependencies, std::move(media_engine)); factory_dependencies.event_log_factory = std::make_unique(); @@ -237,7 +235,7 @@ class PeerConnectionMediaBaseTest : public ::testing::Test { RtpTransceiverDirection GetMediaContentDirection( const SessionDescriptionInterface* sdesc, - webrtc::MediaType media_type) { + MediaType media_type) { auto* content = GetFirstMediaContent(sdesc->description(), media_type); RTC_DCHECK(content); return content->media_description()->direction(); @@ -391,7 +389,7 @@ TEST_F(PeerConnectionMediaTestPlanB, SimulcastOffer) { options.num_simulcast_layers = 3; auto offer = caller->CreateOffer(options); auto* description = - GetFirstMediaContent(offer->description(), webrtc::MediaType::VIDEO) + GetFirstMediaContent(offer->description(), MediaType::VIDEO) ->media_description(); ASSERT_EQ(1u, description->streams().size()); ASSERT_TRUE(description->streams()[0].get_ssrc_group("SIM")); @@ -401,7 +399,7 @@ TEST_F(PeerConnectionMediaTestPlanB, SimulcastOffer) { caller->SetLocalDescription(std::move(offer)); auto senders = caller->pc()->GetSenders(); ASSERT_EQ(1u, senders.size()); - EXPECT_EQ(webrtc::MediaType::VIDEO, senders[0]->media_type()); + EXPECT_EQ(MediaType::VIDEO, senders[0]->media_type()); EXPECT_EQ(3u, senders[0]->GetParameters().encodings.size()); } @@ -418,7 +416,7 @@ TEST_F(PeerConnectionMediaTestPlanB, SimulcastAnswer) { options.num_simulcast_layers = 3; auto answer = callee->CreateAnswer(options); auto* description = - GetFirstMediaContent(answer->description(), webrtc::MediaType::VIDEO) + GetFirstMediaContent(answer->description(), MediaType::VIDEO) ->media_description(); ASSERT_EQ(1u, description->streams().size()); ASSERT_TRUE(description->streams()[0].get_ssrc_group("SIM")); @@ -428,7 +426,7 @@ TEST_F(PeerConnectionMediaTestPlanB, SimulcastAnswer) { callee->SetLocalDescription(std::move(answer)); auto senders = callee->pc()->GetSenders(); ASSERT_EQ(1u, senders.size()); - EXPECT_EQ(webrtc::MediaType::VIDEO, senders[0]->media_type()); + EXPECT_EQ(MediaType::VIDEO, senders[0]->media_type()); EXPECT_EQ(3u, senders[0]->GetParameters().encodings.size()); } @@ -692,8 +690,7 @@ TEST_P(PeerConnectionMediaOfferDirectionTest, VerifyDirection) { options.offer_to_receive_audio = offer_to_receive_; auto offer = caller->CreateOffer(options); - auto* content = - GetFirstMediaContent(offer->description(), webrtc::MediaType::AUDIO); + auto* content = GetFirstMediaContent(offer->description(), MediaType::AUDIO); if (expected_direction_ == RtpTransceiverDirection::kInactive) { EXPECT_FALSE(content); } else { @@ -779,7 +776,7 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyDirection) { auto expected_direction = RtpTransceiverDirectionFromSendRecv(negotiate_send, negotiate_recv); EXPECT_EQ(expected_direction, - GetMediaContentDirection(answer.get(), webrtc::MediaType::AUDIO)); + GetMediaContentDirection(answer.get(), MediaType::AUDIO)); } // Tests that the media section is rejected if and only if the callee has no @@ -840,9 +837,9 @@ TEST_P(PeerConnectionMediaTest, OfferHasDifferentDirectionForAudioVideo) { auto offer = caller->CreateOffer(options); EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, - GetMediaContentDirection(offer.get(), webrtc::MediaType::AUDIO)); + GetMediaContentDirection(offer.get(), MediaType::AUDIO)); EXPECT_EQ(RtpTransceiverDirection::kSendOnly, - GetMediaContentDirection(offer.get(), webrtc::MediaType::VIDEO)); + GetMediaContentDirection(offer.get(), MediaType::VIDEO)); } TEST_P(PeerConnectionMediaTest, AnswerHasDifferentDirectionsForAudioVideo) { @@ -864,9 +861,9 @@ TEST_P(PeerConnectionMediaTest, AnswerHasDifferentDirectionsForAudioVideo) { auto answer = callee->CreateAnswer(options); EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, - GetMediaContentDirection(answer.get(), webrtc::MediaType::AUDIO)); + GetMediaContentDirection(answer.get(), MediaType::AUDIO)); EXPECT_EQ(RtpTransceiverDirection::kSendOnly, - GetMediaContentDirection(answer.get(), webrtc::MediaType::VIDEO)); + GetMediaContentDirection(answer.get(), MediaType::VIDEO)); } void AddComfortNoiseCodecsToSend(FakeMediaEngine* media_engine) { @@ -984,11 +981,11 @@ TEST_P(PeerConnectionMediaTest, class PeerConnectionMediaInvalidMediaTest : public PeerConnectionMediaBaseTest, - public ::testing::WithParamInterface, - std::string>>> { + public ::testing::WithParamInterface< + std::tuple, + std::string>>> { protected: PeerConnectionMediaInvalidMediaTest() : PeerConnectionMediaBaseTest(std::get<0>(GetParam())) { @@ -997,7 +994,7 @@ class PeerConnectionMediaInvalidMediaTest expected_error_ = std::get<2>(param); } - std::function mutator_; + std::function mutator_; std::string expected_error_; }; @@ -1128,7 +1125,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, } void RenameContent(SessionDescription* desc, - webrtc::MediaType media_type, + MediaType media_type, const std::string& new_name) { auto* content = GetFirstMediaContent(desc, media_type); RTC_DCHECK(content); @@ -1155,8 +1152,8 @@ TEST_P(PeerConnectionMediaTest, AnswerHasSameMidsAsOffer) { auto callee = CreatePeerConnectionWithAudioVideo(); auto offer = caller->CreateOffer(); - RenameContent(offer->description(), webrtc::MediaType::AUDIO, kAudioMid); - RenameContent(offer->description(), webrtc::MediaType::VIDEO, kVideoMid); + RenameContent(offer->description(), MediaType::AUDIO, kAudioMid); + RenameContent(offer->description(), MediaType::VIDEO, kVideoMid); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); auto answer = callee->CreateAnswer(); @@ -1174,8 +1171,8 @@ TEST_P(PeerConnectionMediaTest, ReOfferHasSameMidsAsFirstOffer) { auto callee = CreatePeerConnectionWithAudioVideo(); auto offer = caller->CreateOffer(); - RenameContent(offer->description(), webrtc::MediaType::AUDIO, kAudioMid); - RenameContent(offer->description(), webrtc::MediaType::VIDEO, kVideoMid); + RenameContent(offer->description(), MediaType::AUDIO, kAudioMid); + RenameContent(offer->description(), MediaType::VIDEO, kVideoMid); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); ASSERT_TRUE(callee->SetLocalDescription(callee->CreateAnswer())); @@ -1191,8 +1188,8 @@ TEST_P(PeerConnectionMediaTest, SetRemoteDescriptionFailsWithDuplicateMids) { auto callee = CreatePeerConnectionWithAudioVideo(); auto offer = caller->CreateOffer(); - RenameContent(offer->description(), webrtc::MediaType::AUDIO, "same"); - RenameContent(offer->description(), webrtc::MediaType::VIDEO, "same"); + RenameContent(offer->description(), MediaType::AUDIO, "same"); + RenameContent(offer->description(), MediaType::VIDEO, "same"); std::string error; EXPECT_FALSE(callee->SetRemoteDescription(std::move(offer), &error)); @@ -1206,14 +1203,17 @@ TEST_P(PeerConnectionMediaTest, SetRemoteDescriptionFailsWithDuplicateMids) { // fmtp line is modified to refer to the correct payload type. TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeReassigned) { std::vector caller_fake_codecs; - caller_fake_codecs.push_back(CreateAudioCodec(100, "foo", 0, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); auto caller_fake_engine = std::make_unique(); caller_fake_engine->SetAudioCodecs(caller_fake_codecs); auto caller = CreatePeerConnectionWithAudio(std::move(caller_fake_engine)); std::vector callee_fake_codecs; - callee_fake_codecs.push_back(CreateAudioCodec(120, "foo", 0, 1)); - callee_fake_codecs.push_back(CreateAudioCodec(121, kRedCodecName, 0, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(120, "foo", kDefaultAudioClockRateHz, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(121, kRedCodecName, kDefaultAudioClockRateHz, 1)); callee_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "120/120"); auto callee_fake_engine = std::make_unique(); @@ -1248,15 +1248,19 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeReassigned) { // Test that RED without fmtp does match RED without fmtp. TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeNoFmtpMatchNoFmtp) { std::vector caller_fake_codecs; - caller_fake_codecs.push_back(CreateAudioCodec(100, "foo", 0, 1)); - caller_fake_codecs.push_back(CreateAudioCodec(101, kRedCodecName, 0, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(101, kRedCodecName, kDefaultAudioClockRateHz, 1)); auto caller_fake_engine = std::make_unique(); caller_fake_engine->SetAudioCodecs(caller_fake_codecs); auto caller = CreatePeerConnectionWithAudio(std::move(caller_fake_engine)); std::vector callee_fake_codecs; - callee_fake_codecs.push_back(CreateAudioCodec(120, "foo", 0, 1)); - callee_fake_codecs.push_back(CreateAudioCodec(121, kRedCodecName, 0, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(120, "foo", kDefaultAudioClockRateHz, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(121, kRedCodecName, kDefaultAudioClockRateHz, 1)); auto callee_fake_engine = std::make_unique(); callee_fake_engine->SetAudioCodecs(callee_fake_codecs); auto callee = CreatePeerConnectionWithAudio(std::move(callee_fake_engine)); @@ -1288,15 +1292,19 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeNoFmtpMatchNoFmtp) { // Test that RED without fmtp does not match RED with fmtp. TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeNoFmtpNoMatchFmtp) { std::vector caller_fake_codecs; - caller_fake_codecs.push_back(CreateAudioCodec(100, "foo", 0, 1)); - caller_fake_codecs.push_back(CreateAudioCodec(101, kRedCodecName, 0, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(101, kRedCodecName, kDefaultAudioClockRateHz, 1)); auto caller_fake_engine = std::make_unique(); caller_fake_engine->SetAudioCodecs(caller_fake_codecs); auto caller = CreatePeerConnectionWithAudio(std::move(caller_fake_engine)); std::vector callee_fake_codecs; - callee_fake_codecs.push_back(CreateAudioCodec(120, "foo", 0, 1)); - callee_fake_codecs.push_back(CreateAudioCodec(121, kRedCodecName, 0, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(120, "foo", kDefaultAudioClockRateHz, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(121, kRedCodecName, kDefaultAudioClockRateHz, 1)); callee_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "120/120"); auto callee_fake_engine = std::make_unique(); @@ -1332,8 +1340,10 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeNoFmtpNoMatchFmtp) { // Test that RED with fmtp must match base codecs. TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeMustMatchBaseCodecs) { std::vector caller_fake_codecs; - caller_fake_codecs.push_back(CreateAudioCodec(100, "foo", 0, 1)); - caller_fake_codecs.push_back(CreateAudioCodec(101, kRedCodecName, 0, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(101, kRedCodecName, kDefaultAudioClockRateHz, 1)); caller_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "100/100"); auto caller_fake_engine = std::make_unique(); @@ -1341,9 +1351,12 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeMustMatchBaseCodecs) { auto caller = CreatePeerConnectionWithAudio(std::move(caller_fake_engine)); std::vector callee_fake_codecs; - callee_fake_codecs.push_back(CreateAudioCodec(120, "foo", 0, 1)); - callee_fake_codecs.push_back(CreateAudioCodec(121, kRedCodecName, 0, 1)); - callee_fake_codecs.push_back(CreateAudioCodec(122, "bar", 0, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(120, "foo", kDefaultAudioClockRateHz, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(121, kRedCodecName, kDefaultAudioClockRateHz, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(122, "bar", kDefaultAudioClockRateHz, 1)); callee_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "122/122"); auto callee_fake_engine = std::make_unique(); @@ -1364,9 +1377,12 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeMustMatchBaseCodecs) { // which is not supported. TEST_P(PeerConnectionMediaTest, RedFmtpPayloadMixed) { std::vector caller_fake_codecs; - caller_fake_codecs.push_back(CreateAudioCodec(100, "foo", 0, 1)); - caller_fake_codecs.push_back(CreateAudioCodec(102, "bar", 0, 1)); - caller_fake_codecs.push_back(CreateAudioCodec(101, kRedCodecName, 0, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(102, "bar", kDefaultAudioClockRateHz, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(101, kRedCodecName, kDefaultAudioClockRateHz, 1)); caller_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "100/102"); auto caller_fake_engine = std::make_unique(); @@ -1374,8 +1390,10 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadMixed) { auto caller = CreatePeerConnectionWithAudio(std::move(caller_fake_engine)); std::vector callee_fake_codecs; - callee_fake_codecs.push_back(CreateAudioCodec(120, "foo", 0, 1)); - callee_fake_codecs.push_back(CreateAudioCodec(121, kRedCodecName, 0, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(120, "foo", kDefaultAudioClockRateHz, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(121, kRedCodecName, kDefaultAudioClockRateHz, 1)); callee_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "120/120"); auto callee_fake_engine = std::make_unique(); @@ -1396,8 +1414,10 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadMixed) { // redundancy. TEST_P(PeerConnectionMediaTest, RedFmtpPayloadDifferentRedundancy) { std::vector caller_fake_codecs; - caller_fake_codecs.push_back(CreateAudioCodec(100, "foo", 0, 1)); - caller_fake_codecs.push_back(CreateAudioCodec(101, kRedCodecName, 0, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); + caller_fake_codecs.push_back( + CreateAudioCodec(101, kRedCodecName, kDefaultAudioClockRateHz, 1)); caller_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "100/100"); auto caller_fake_engine = std::make_unique(); @@ -1405,8 +1425,10 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadDifferentRedundancy) { auto caller = CreatePeerConnectionWithAudio(std::move(caller_fake_engine)); std::vector callee_fake_codecs; - callee_fake_codecs.push_back(CreateAudioCodec(120, "foo", 0, 1)); - callee_fake_codecs.push_back(CreateAudioCodec(121, kRedCodecName, 0, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(120, "foo", kDefaultAudioClockRateHz, 1)); + callee_fake_codecs.push_back( + CreateAudioCodec(121, kRedCodecName, kDefaultAudioClockRateHz, 1)); callee_fake_codecs.back().SetParam(kCodecParamNotInNameValueFormat, "120/120/120"); auto callee_fake_engine = std::make_unique(); @@ -1471,15 +1493,16 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAudioMissingRecvCodec) { auto fake_engine = std::make_unique(); auto send_codecs = fake_engine->voice().LegacySendCodecs(); - send_codecs.push_back( - CreateAudioCodec(send_codecs.back().id + 1, "send_only_codec", 0, 1)); + send_codecs.push_back(CreateAudioCodec(send_codecs.back().id + 1, + "send_only_codec", + kDefaultAudioClockRateHz, 1)); fake_engine->SetAudioSendCodecs(send_codecs); auto caller = CreatePeerConnectionWithAudio(std::move(fake_engine)); auto transceiver = caller->pc()->GetTransceivers().front(); auto capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO); std::vector codecs; absl::c_copy_if(capabilities.codecs, std::back_inserter(codecs), @@ -1497,12 +1520,10 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithAudio(); auto transceiver = caller->pc()->GetTransceivers().front(); - auto video_codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; - auto codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) - .codecs; + auto video_codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; + auto codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO).codecs; codecs.insert(codecs.end(), video_codecs.begin(), video_codecs.end()); auto result = transceiver->SetCodecPreferences(codecs); EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, result.type()); @@ -1514,19 +1535,19 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto audio_codecs = fake_engine->voice().LegacySendCodecs(); audio_codecs.push_back( CreateAudioRtxCodec(audio_codecs.back().id + 1, audio_codecs.back().id)); - audio_codecs.push_back( - CreateAudioCodec(audio_codecs.back().id + 1, kRedCodecName, 0, 1)); - audio_codecs.push_back( - CreateAudioCodec(audio_codecs.back().id + 1, kUlpfecCodecName, 0, 1)); + audio_codecs.push_back(CreateAudioCodec( + audio_codecs.back().id + 1, kRedCodecName, kDefaultAudioClockRateHz, 1)); + audio_codecs.push_back(CreateAudioCodec(audio_codecs.back().id + 1, + kUlpfecCodecName, + kDefaultAudioClockRateHz, 1)); fake_engine->SetAudioCodecs(audio_codecs); auto caller = CreatePeerConnectionWithAudio(std::move(fake_engine)); auto transceiver = RtpTransceiverInternal(caller->pc()->GetTransceivers().front()); - auto codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) - .codecs; + auto codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO).codecs; auto codecs_only_rtx_red_fec = codecs; auto it = std::remove_if( codecs_only_rtx_red_fec.begin(), codecs_only_rtx_red_fec.end(), @@ -1544,9 +1565,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllAudioCodecs) { auto caller = CreatePeerConnectionWithAudio(); auto sender_audio_codecs = - caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) - .codecs; + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO).codecs; auto audio_transceiver = caller->pc()->GetTransceivers().front(); @@ -1563,9 +1582,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithAudio(); auto sender_audio_codecs = - caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) - .codecs; + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO).codecs; std::vector empty_codecs = {}; auto audio_transceiver = caller->pc()->GetTransceivers().front(); @@ -1583,12 +1600,10 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithVideo(); auto transceiver = caller->pc()->GetTransceivers().front(); - auto audio_codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO) - .codecs; - auto codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + auto audio_codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO).codecs; + auto codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; codecs.insert(codecs.end(), audio_codecs.begin(), audio_codecs.end()); auto result = transceiver->SetCodecPreferences(codecs); EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, result.type()); @@ -1609,9 +1624,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithVideo(std::move(fake_engine)); auto transceiver = caller->pc()->GetTransceivers().front(); - auto codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + auto codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; auto codecs_only_rtx_red_fec = codecs; auto it = std::remove_if( codecs_only_rtx_red_fec.begin(), codecs_only_rtx_red_fec.end(), @@ -1629,9 +1643,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllVideoCodecs) { auto caller = CreatePeerConnectionWithVideo(); auto sender_video_codecs = - caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; auto video_transceiver = caller->pc()->GetTransceivers().front(); @@ -1648,9 +1660,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithVideo(); auto sender_video_codecs = - caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; std::vector empty_codecs = {}; @@ -1669,9 +1679,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithVideo(); auto sender_video_codecs = - caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; auto video_transceiver = caller->pc()->GetTransceivers().front(); @@ -1706,9 +1714,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesVideoWithRtx) { auto caller = CreatePeerConnectionWithVideo(std::move(caller_fake_engine)); auto sender_video_codecs = - caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; auto video_transceiver = caller->pc()->GetTransceivers().front(); @@ -1753,9 +1759,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithVideo(std::move(caller_fake_engine)); auto callee = CreatePeerConnection(std::move(callee_fake_engine)); - auto video_codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + auto video_codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; auto send_transceiver = caller->pc()->GetTransceivers().front(); @@ -1817,9 +1822,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithVideo(std::move(caller_fake_engine)); auto callee = CreatePeerConnection(std::move(callee_fake_engine)); - auto video_codecs = caller->pc_factory() - ->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO) - .codecs; + auto video_codecs = + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO).codecs; auto send_transceiver = caller->pc()->GetTransceivers().front(); @@ -1867,7 +1871,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto transceiver = caller->pc()->GetTransceivers().front(); auto capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO); EXPECT_TRUE(transceiver->SetCodecPreferences(capabilities.codecs).ok()); options.voice_activity_detection = false; @@ -1884,7 +1888,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto fake_engine = std::make_unique(); std::vector audio_codecs; - audio_codecs.emplace_back(CreateAudioCodec(100, "foo", 0, 1)); + audio_codecs.emplace_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); audio_codecs.emplace_back(CreateAudioRtxCodec(101, 100)); fake_engine->SetAudioCodecs(audio_codecs); @@ -1899,12 +1904,12 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto audio_transceiver = caller->pc()->GetTransceivers()[0]; auto capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO); EXPECT_TRUE(audio_transceiver->SetCodecPreferences(capabilities.codecs).ok()); auto video_transceiver = caller->pc()->GetTransceivers()[1]; capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO); EXPECT_TRUE(video_transceiver->SetCodecPreferences(capabilities.codecs).ok()); RTCOfferAnswerOptions options; @@ -1925,7 +1930,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto fake_engine = std::make_unique(); std::vector audio_codecs; - audio_codecs.emplace_back(CreateAudioCodec(100, "foo", 0, 1)); + audio_codecs.emplace_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); audio_codecs.emplace_back(CreateAudioRtxCodec(101, 100)); fake_engine->SetAudioCodecs(audio_codecs); @@ -1944,12 +1950,12 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto audio_transceiver = caller->pc()->GetTransceivers()[0]; auto capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO); EXPECT_TRUE(audio_transceiver->SetCodecPreferences(capabilities.codecs).ok()); auto video_transceiver = caller->pc()->GetTransceivers()[1]; capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO); EXPECT_TRUE(video_transceiver->SetCodecPreferences(capabilities.codecs).ok()); auto answer = caller->CreateAnswer(options); @@ -1970,7 +1976,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto fake_engine = std::make_unique(); std::vector audio_codecs; - audio_codecs.emplace_back(CreateAudioCodec(100, "foo", 0, 1)); + audio_codecs.emplace_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); audio_codecs.emplace_back(CreateAudioRtxCodec(101, 100)); fake_engine->SetAudioCodecs(audio_codecs); @@ -1990,12 +1997,12 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto audio_transceiver = caller->pc()->GetTransceivers()[0]; auto capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::AUDIO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::AUDIO); EXPECT_TRUE(audio_transceiver->SetCodecPreferences(capabilities.codecs).ok()); auto video_transceiver = caller->pc()->GetTransceivers()[1]; capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO); EXPECT_TRUE(video_transceiver->SetCodecPreferences(capabilities.codecs).ok()); auto reoffer = caller->CreateOffer(options); @@ -2016,7 +2023,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto fake_engine = std::make_unique(); std::vector audio_codecs; - audio_codecs.emplace_back(CreateAudioCodec(100, "foo", 0, 1)); + audio_codecs.emplace_back( + CreateAudioCodec(100, "foo", kDefaultAudioClockRateHz, 1)); fake_engine->SetAudioRecvCodecs(audio_codecs); auto caller = CreatePeerConnectionWithAudio(std::move(fake_engine)); @@ -2028,8 +2036,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto error = audio_transceiver->SetDirectionWithError( RtpTransceiverDirection::kSendOnly); ASSERT_TRUE(error.ok()); - auto capabilities = caller->pc_factory()->GetRtpReceiverCapabilities( - webrtc::MediaType::AUDIO); + auto capabilities = + caller->pc_factory()->GetRtpReceiverCapabilities(MediaType::AUDIO); EXPECT_TRUE(audio_transceiver->SetCodecPreferences(capabilities.codecs).ok()); RTCOfferAnswerOptions options; EXPECT_TRUE(caller->SetLocalDescription(caller->CreateOffer(options))); @@ -2058,7 +2066,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesVideoNoRtx) { ->SetDirectionWithError(RtpTransceiverDirection::kRecvOnly) .ok()); auto capabilities = - caller->pc_factory()->GetRtpSenderCapabilities(webrtc::MediaType::VIDEO); + caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO); auto it = std::remove_if(capabilities.codecs.begin(), capabilities.codecs.end(), [](const RtpCodecCapability& codec) { diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc index 17cc3a2e0d..8b928531c6 100644 --- a/pc/peer_connection_rampup_tests.cc +++ b/pc/peer_connection_rampup_tests.cc @@ -63,9 +63,9 @@ namespace webrtc { namespace { -using ::webrtc::test::GetGlobalMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::GetGlobalMetricsLogger; +using test::ImprovementDirection; +using test::Unit; static const int kDefaultTestTimeMs = 15000; static const int kRampUpTimeMs = 5000; @@ -178,7 +178,8 @@ class PeerConnectionRampUpTest : public ::testing::Test { pcf_deps.worker_thread = worker_thread_.get(); pcf_deps.signaling_thread = Thread::Current(); pcf_deps.socket_factory = &firewall_socket_server_; - auto network_manager = std::make_unique(); + auto network_manager = + std::make_unique(network_thread()); network_manager->AddInterface(kDefaultLocalAddress); pcf_deps.network_manager = std::move(network_manager); pcf_deps.adm = FakeAudioCaptureModule::Create(); diff --git a/pc/peer_connection_rtp_unittest.cc b/pc/peer_connection_rtp_unittest.cc index ad39b76e31..a07bfc4c32 100644 --- a/pc/peer_connection_rtp_unittest.cc +++ b/pc/peer_connection_rtp_unittest.cc @@ -346,11 +346,11 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTransceiverCallsOnTrack) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto audio_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); RtpTransceiverInit video_transceiver_init; video_transceiver_init.stream_ids = {kStreamId1, kStreamId2}; auto video_transceiver = - caller->AddTransceiver(webrtc::MediaType::VIDEO, video_transceiver_init); + caller->AddTransceiver(MediaType::VIDEO, video_transceiver_init); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); @@ -400,7 +400,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, SetDirectionCallsOnTrack) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); EXPECT_TRUE( transceiver->SetDirectionWithError(RtpTransceiverDirection::kInactive) .ok()); @@ -431,7 +431,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, SetDirectionHoldCallsOnTrackTwice) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); EXPECT_EQ(0u, caller->observer()->on_track_transceivers_.size()); @@ -502,7 +502,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, TEST_F(PeerConnectionRtpTestUnifiedPlan, ChangeDirectionInAnswerResultsInRemoveTrackEvent) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); callee->AddAudioTrack("audio_track", {}); @@ -803,8 +803,8 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, TracksDoNotEndWhenSsrcChanges) { // Caller offers to receive audio and video. RtpTransceiverInit init; init.direction = RtpTransceiverDirection::kRecvOnly; - caller->AddTransceiver(webrtc::MediaType::AUDIO, init); - caller->AddTransceiver(webrtc::MediaType::VIDEO, init); + caller->AddTransceiver(MediaType::AUDIO, init); + caller->AddTransceiver(MediaType::VIDEO, init); // Callee wants to send audio and video tracks. callee->AddTrack(callee->CreateAudioTrack("audio_track"), {}); @@ -957,7 +957,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTransceiverHasCorrectInitProperties) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); EXPECT_EQ(std::nullopt, transceiver->mid()); EXPECT_FALSE(transceiver->stopped()); EXPECT_EQ(RtpTransceiverDirection::kSendRecv, transceiver->direction()); @@ -970,14 +970,14 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddAudioTransceiverCreatesAudioSenderAndReceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); - EXPECT_EQ(webrtc::MediaType::AUDIO, transceiver->media_type()); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); + EXPECT_EQ(MediaType::AUDIO, transceiver->media_type()); ASSERT_TRUE(transceiver->sender()); - EXPECT_EQ(webrtc::MediaType::AUDIO, transceiver->sender()->media_type()); + EXPECT_EQ(MediaType::AUDIO, transceiver->sender()->media_type()); ASSERT_TRUE(transceiver->receiver()); - EXPECT_EQ(webrtc::MediaType::AUDIO, transceiver->receiver()->media_type()); + EXPECT_EQ(MediaType::AUDIO, transceiver->receiver()->media_type()); auto track = transceiver->receiver()->track(); ASSERT_TRUE(track); @@ -991,14 +991,14 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddAudioTransceiverCreatesVideoSenderAndReceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); - EXPECT_EQ(webrtc::MediaType::VIDEO, transceiver->media_type()); + auto transceiver = caller->AddTransceiver(MediaType::VIDEO); + EXPECT_EQ(MediaType::VIDEO, transceiver->media_type()); ASSERT_TRUE(transceiver->sender()); - EXPECT_EQ(webrtc::MediaType::VIDEO, transceiver->sender()->media_type()); + EXPECT_EQ(MediaType::VIDEO, transceiver->sender()->media_type()); ASSERT_TRUE(transceiver->receiver()); - EXPECT_EQ(webrtc::MediaType::VIDEO, transceiver->receiver()->media_type()); + EXPECT_EQ(MediaType::VIDEO, transceiver->receiver()->media_type()); auto track = transceiver->receiver()->track(); ASSERT_TRUE(track); @@ -1012,7 +1012,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTransceiverShowsInLists) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); EXPECT_EQ(std::vector>{transceiver}, caller->pc()->GetTransceivers()); EXPECT_EQ( @@ -1031,7 +1031,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, RtpTransceiverInit init; init.direction = RtpTransceiverDirection::kSendOnly; - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO, init); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO, init); EXPECT_EQ(RtpTransceiverDirection::kSendOnly, transceiver->direction()); } @@ -1086,7 +1086,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTransceiverWithInvalidKindReturnsError) { auto caller = CreatePeerConnection(); - auto result = caller->pc()->AddTransceiver(webrtc::MediaType::DATA); + auto result = caller->pc()->AddTransceiver(MediaType::DATA); EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, result.error().type()); } @@ -1108,7 +1108,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddAudioTrackCreatesAudioSender) { auto sender = caller->AddTrack(audio_track); ASSERT_TRUE(sender); - EXPECT_EQ(webrtc::MediaType::AUDIO, sender->media_type()); + EXPECT_EQ(MediaType::AUDIO, sender->media_type()); EXPECT_EQ(audio_track, sender->track()); } @@ -1121,7 +1121,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddVideoTrackCreatesVideoSender) { auto sender = caller->AddTrack(video_track); ASSERT_TRUE(sender); - EXPECT_EQ(webrtc::MediaType::VIDEO, sender->media_type()); + EXPECT_EQ(MediaType::VIDEO, sender->media_type()); EXPECT_EQ(video_track, sender->track()); } @@ -1145,7 +1145,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddFirstTrackCreatesTransceiver) { TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTrackReusesTransceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); auto audio_track = caller->CreateAudioTrack("a"); auto sender = caller->AddTrack(audio_track); ASSERT_TRUE(sender); @@ -1161,7 +1161,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTrackWithSendEncodingDoesNotReuseTransceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); auto audio_track = caller->CreateAudioTrack("a"); RtpEncodingParameters encoding; auto sender = caller->AddTrack(audio_track, {}, {encoding}); @@ -1195,8 +1195,8 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, TwoAddTrackCreatesTwoTransceivers) { TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTrackReusesTransceiverOfType) { auto caller = CreatePeerConnection(); - auto audio_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); - auto video_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); + auto video_transceiver = caller->AddTransceiver(MediaType::VIDEO); auto sender = caller->AddVideoTrack("v"); ASSERT_EQ(2u, caller->pc()->GetTransceivers().size()); @@ -1211,7 +1211,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTrackDoesNotReuseTransceiverOfWrongType) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto sender = caller->AddVideoTrack("v"); auto transceivers = caller->pc()->GetTransceivers(); @@ -1226,8 +1226,8 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, AddTrackReusesFirstMatchingTransceiver) { auto caller = CreatePeerConnection(); - caller->AddTransceiver(webrtc::MediaType::AUDIO); - caller->AddTransceiver(webrtc::MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); + caller->AddTransceiver(MediaType::AUDIO); auto sender = caller->AddAudioTrack("a"); auto transceivers = caller->pc()->GetTransceivers(); @@ -1245,7 +1245,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, RtpTransceiverInit init; init.direction = RtpTransceiverDirection::kInactive; - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO, init); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO, init); EXPECT_TRUE(caller->observer()->legacy_renegotiation_needed()); EXPECT_TRUE(caller->observer()->has_negotiation_needed_event()); @@ -1268,7 +1268,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, RtpTransceiverInit init; init.direction = RtpTransceiverDirection::kRecvOnly; - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO, init); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO, init); EXPECT_TRUE(caller->observer()->legacy_renegotiation_needed()); EXPECT_TRUE(caller->observer()->has_negotiation_needed_event()); @@ -1489,8 +1489,8 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, CreateAnswerSameTrackLabel) { RtpTransceiverInit recvonly; recvonly.direction = RtpTransceiverDirection::kRecvOnly; - caller->AddTransceiver(webrtc::MediaType::AUDIO, recvonly); - caller->AddTransceiver(webrtc::MediaType::VIDEO, recvonly); + caller->AddTransceiver(MediaType::AUDIO, recvonly); + caller->AddTransceiver(MediaType::VIDEO, recvonly); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); @@ -1539,7 +1539,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, EXPECT_FALSE(caller->observer()->legacy_renegotiation_needed()); EXPECT_FALSE(caller->observer()->has_negotiation_needed_event()); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); EXPECT_TRUE(caller->observer()->legacy_renegotiation_needed()); EXPECT_TRUE(caller->observer()->has_negotiation_needed_event()); @@ -1558,7 +1558,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, NoRenegotiationNeededAfterTransceiverSetSameDirection) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); caller->observer()->clear_legacy_renegotiation_needed(); caller->observer()->clear_latest_negotiation_needed_event(); @@ -1573,7 +1573,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, NoRenegotiationNeededAfterSetDirectionOnStoppedTransceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->StopInternal(); caller->observer()->clear_legacy_renegotiation_needed(); @@ -1588,7 +1588,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, CheckStoppedCurrentDirectionOnStoppedTransceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->StopInternal(); EXPECT_TRUE(transceiver->stopping()); @@ -1602,7 +1602,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, CheckForInvalidStateOnStoppingTransceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->StopStandard(); EXPECT_TRUE(transceiver->stopping()); @@ -1618,7 +1618,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, CheckForInvalidStateOnStoppedTransceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->StopInternal(); EXPECT_TRUE(transceiver->stopping()); @@ -1634,7 +1634,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, CheckForTypeErrorForStoppedOnTransceiver) { auto caller = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); EXPECT_EQ( RTCErrorType::INVALID_PARAMETER, transceiver->SetDirectionWithError(RtpTransceiverDirection::kStopped) @@ -1647,7 +1647,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, SetLocalDescriptionWithStoppedMediaSection) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); callee->pc()->GetTransceivers()[0]->StopStandard(); ASSERT_TRUE(callee->ExchangeOfferAnswerWith(caller.get())); @@ -1660,7 +1660,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, StopAndNegotiateCausesTransceiverToDisappear) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto transceiver = caller->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); callee->pc()->GetTransceivers()[0]->StopStandard(); ASSERT_TRUE(callee->ExchangeOfferAnswerWith(caller.get())); @@ -1724,11 +1724,9 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, // Unimplemented RtpParameters: ssrc, codec_payload_type, fec, rtx, dtx, // ptime, scale_framerate_down_by, dependency_rids. init.send_encodings[0].ssrc = 1; - EXPECT_EQ(RTCErrorType::UNSUPPORTED_PARAMETER, - caller->pc() - ->AddTransceiver(webrtc::MediaType::AUDIO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::UNSUPPORTED_PARAMETER, + caller->pc()->AddTransceiver(MediaType::AUDIO, init).error().type()); init.send_encodings = default_send_encodings; } @@ -1743,74 +1741,58 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, CheckForInvalidEncodingParameters) { auto default_send_encodings = init.send_encodings; init.send_encodings[0].scale_resolution_down_by = 0.5; - EXPECT_EQ(RTCErrorType::INVALID_RANGE, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::INVALID_RANGE, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; init.send_encodings[0].bitrate_priority = 0; - EXPECT_EQ(RTCErrorType::INVALID_RANGE, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::INVALID_RANGE, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; init.send_encodings[0].min_bitrate_bps = 200000; init.send_encodings[0].max_bitrate_bps = 100000; - EXPECT_EQ(RTCErrorType::INVALID_RANGE, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::INVALID_RANGE, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; init.send_encodings[0].num_temporal_layers = 0; - EXPECT_EQ(RTCErrorType::INVALID_RANGE, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::INVALID_RANGE, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; init.send_encodings[0].num_temporal_layers = 5; - EXPECT_EQ(RTCErrorType::INVALID_RANGE, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::INVALID_RANGE, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; init.send_encodings[0].scalability_mode = std::nullopt; init.send_encodings[0].codec = CreateVideoCodec(SdpVideoFormat("VP8", {})).ToCodecParameters(); - EXPECT_EQ(RTCErrorType::NONE, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::NONE, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; init.send_encodings[0].scalability_mode = "L1T2"; init.send_encodings[0].codec = CreateVideoCodec(SdpVideoFormat("VP8", {})).ToCodecParameters(); - EXPECT_EQ(RTCErrorType::NONE, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::NONE, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; init.send_encodings[0].scalability_mode = "L2T2"; init.send_encodings[0].codec = CreateVideoCodec(SdpVideoFormat("VP8", {})).ToCodecParameters(); - EXPECT_EQ(RTCErrorType::UNSUPPORTED_OPERATION, - caller->pc() - ->AddTransceiver(webrtc::MediaType::VIDEO, init) - .error() - .type()); + EXPECT_EQ( + RTCErrorType::UNSUPPORTED_OPERATION, + caller->pc()->AddTransceiver(MediaType::VIDEO, init).error().type()); init.send_encodings = default_send_encodings; } @@ -1824,7 +1806,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, SendEncodingsPassedToSender) { init.send_encodings[0].active = false; init.send_encodings[0].max_bitrate_bps = 180000; - auto result = caller->pc()->AddTransceiver(webrtc::MediaType::AUDIO, init); + auto result = caller->pc()->AddTransceiver(MediaType::AUDIO, init); ASSERT_TRUE(result.ok()); auto init_send_encodings = result.value()->sender()->init_send_encodings(); diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc index 645d62dc35..2412660fb3 100644 --- a/pc/peer_connection_signaling_unittest.cc +++ b/pc/peer_connection_signaling_unittest.cc @@ -587,7 +587,7 @@ TEST_P(PeerConnectionSignalingTest, CreateOffersAndShutdown) { // must have received a notification. EXPECT_THAT( WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); } } @@ -603,7 +603,7 @@ TEST_P(PeerConnectionSignalingTest, CloseCreateOfferAndShutdown) { caller->pc()->CreateOffer(observer.get(), RTCOfferAnswerOptions()); caller.reset(nullptr); EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); } @@ -697,7 +697,7 @@ TEST_P(PeerConnectionSignalingTest, Thread::Current()->PostTask( [&checkpoint_reached] { checkpoint_reached = true; }); EXPECT_THAT(WaitUntil([&] { return checkpoint_reached; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); // If resolving the observer was pending, it must now have been called. EXPECT_TRUE(observer->called()); @@ -742,7 +742,7 @@ TEST_P(PeerConnectionSignalingTest, CreateOfferBlocksSetRemoteDescription) { // EXPECT_TRUE_WAIT causes messages to be processed... EXPECT_THAT( WaitUntil([&] { return offer_observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); // Now that the offer has been completed, SetRemoteDescription() will have // been executed next in the chain. @@ -764,7 +764,7 @@ TEST_P(PeerConnectionSignalingTest, // Wait for messages to be processed. EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); EXPECT_TRUE(observer->result()); EXPECT_TRUE(caller->pc()->pending_local_description()); @@ -791,7 +791,7 @@ TEST_P(PeerConnectionSignalingTest, // Wait for messages to be processed. EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); EXPECT_TRUE(observer->result()); EXPECT_TRUE(callee->pc()->current_local_description()); @@ -813,7 +813,7 @@ TEST_P(PeerConnectionSignalingTest, EXPECT_THAT( WaitUntil([&] { return caller_set_local_description_observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); ASSERT_TRUE(caller->pc()->pending_local_description()); @@ -833,7 +833,7 @@ TEST_P(PeerConnectionSignalingTest, EXPECT_THAT( WaitUntil([&] { return callee_set_local_description_observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); // Chaining guarantees SetRemoteDescription() happened before // SetLocalDescription(). @@ -850,8 +850,7 @@ TEST_P(PeerConnectionSignalingTest, EXPECT_THAT( WaitUntil( [&] { return caller_set_remote_description_observer->called(); }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); EXPECT_EQ(PeerConnection::kStable, caller->signaling_state()); @@ -869,7 +868,7 @@ TEST_P(PeerConnectionSignalingTest, // The operation should fail asynchronously. EXPECT_FALSE(observer->called()); EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); EXPECT_FALSE(observer->result()); // This did not affect the signaling state. @@ -891,7 +890,7 @@ TEST_P(PeerConnectionSignalingTest, // The operation should fail asynchronously. EXPECT_FALSE(observer->called()); EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); EXPECT_FALSE(observer->result()); // This did not affect the signaling state. @@ -1185,7 +1184,7 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, caller->pc()->CreateOffer(offer_observer.get(), RTCOfferAnswerOptions()); EXPECT_THAT(WaitUntil([&] { return offer_observer->was_called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); } @@ -1257,7 +1256,7 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, auto caller = CreatePeerConnection(); EXPECT_FALSE(caller->observer()->has_negotiation_needed_event()); auto transceiver = - caller->AddTransceiver(webrtc::MediaType::AUDIO, RtpTransceiverInit()); + caller->AddTransceiver(MediaType::AUDIO, RtpTransceiverInit()); EXPECT_TRUE(caller->observer()->has_negotiation_needed_event()); EXPECT_TRUE(caller->pc()->ShouldFireNegotiationNeededEvent( caller->observer()->latest_negotiation_needed_event())); @@ -1268,7 +1267,7 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, auto caller = CreatePeerConnection(); EXPECT_FALSE(caller->observer()->has_negotiation_needed_event()); auto transceiver = - caller->AddTransceiver(webrtc::MediaType::AUDIO, RtpTransceiverInit()); + caller->AddTransceiver(MediaType::AUDIO, RtpTransceiverInit()); EXPECT_TRUE(caller->observer()->has_negotiation_needed_event()); auto observer = make_ref_counted(); @@ -1284,7 +1283,7 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, // When the Operations Chain becomes empty again, a new negotiation needed // event will be generated that is not suppressed. EXPECT_THAT(WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kWaitTimeout)}), + {.timeout = TimeDelta::Millis(kWaitTimeout)}), IsRtcOk()); EXPECT_TRUE(caller->observer()->has_negotiation_needed_event()); EXPECT_TRUE(caller->pc()->ShouldFireNegotiationNeededEvent( @@ -1299,7 +1298,7 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, EXPECT_FALSE(caller->observer()->has_negotiation_needed_event()); auto transceiver = - callee->AddTransceiver(webrtc::MediaType::AUDIO, RtpTransceiverInit()); + callee->AddTransceiver(MediaType::AUDIO, RtpTransceiverInit()); EXPECT_TRUE(callee->observer()->has_negotiation_needed_event()); // Change signaling state (to "have-remote-offer") by setting a remote offer. @@ -1376,7 +1375,7 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, LoopbackSdpIsPossible) { // and triggered surprising behavior. auto caller = CreatePeerConnection(); auto transceiver = - caller->AddTransceiver(webrtc::MediaType::AUDIO, RtpTransceiverInit()); + caller->AddTransceiver(MediaType::AUDIO, RtpTransceiverInit()); auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); std::string offer_sdp; diff --git a/pc/peer_connection_simulcast_unittest.cc b/pc/peer_connection_simulcast_unittest.cc index 7ff413d497..802cc41740 100644 --- a/pc/peer_connection_simulcast_unittest.cc +++ b/pc/peer_connection_simulcast_unittest.cc @@ -138,7 +138,7 @@ class PeerConnectionSimulcastTests : public ::testing::Test { scoped_refptr AddTransceiver( PeerConnectionWrapper* pc, const std::vector& layers, - webrtc::MediaType media_type = webrtc::MediaType::VIDEO) { + MediaType media_type = MediaType::VIDEO) { auto init = CreateTransceiverInit(layers); return pc->AddTransceiver(media_type, init); } @@ -196,7 +196,7 @@ TEST_F(PeerConnectionSimulcastTests, RidsAreAutogeneratedIfNotProvided) { for (RtpEncodingParameters& parameters : init.send_encodings) { parameters.rid = ""; } - auto transceiver = pc->AddTransceiver(webrtc::MediaType::VIDEO, init); + auto transceiver = pc->AddTransceiver(MediaType::VIDEO, init); auto parameters = transceiver->sender()->GetParameters(); ASSERT_EQ(3u, parameters.encodings.size()); EXPECT_THAT(parameters.encodings, @@ -212,7 +212,7 @@ TEST_F(PeerConnectionSimulcastTests, MustSupplyAllOrNoRidsInSimulcast) { auto layers = CreateLayers({"f", "h", "remove"}, true); auto init = CreateTransceiverInit(layers); init.send_encodings[2].rid = ""; - auto error = pc->AddTransceiver(webrtc::MediaType::VIDEO, init); + auto error = pc->AddTransceiver(MediaType::VIDEO, init); EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, error.error().type()); } @@ -222,7 +222,7 @@ TEST_F(PeerConnectionSimulcastTests, ChecksForIllegalRidValues) { auto pc = pc_wrapper->pc(); auto layers = CreateLayers({"f", "h", "~q"}, true); auto init = CreateTransceiverInit(layers); - auto error = pc->AddTransceiver(webrtc::MediaType::VIDEO, init); + auto error = pc->AddTransceiver(MediaType::VIDEO, init); EXPECT_EQ(RTCErrorType::INVALID_PARAMETER, error.error().type()); } @@ -514,8 +514,7 @@ TEST_F(PeerConnectionSimulcastTests, SimulcastAudioRejected) { auto local = CreatePeerConnectionWrapper(); auto remote = CreatePeerConnectionWrapper(); auto layers = CreateLayers({"1", "2", "3", "4"}, true); - auto transceiver = - AddTransceiver(local.get(), layers, webrtc::MediaType::AUDIO); + auto transceiver = AddTransceiver(local.get(), layers, MediaType::AUDIO); // Should only have the first layer. auto parameters = transceiver->sender()->GetParameters(); EXPECT_EQ(1u, parameters.encodings.size()); diff --git a/pc/peer_connection_svc_integrationtest.cc b/pc/peer_connection_svc_integrationtest.cc index de3b035431..9e61012710 100644 --- a/pc/peer_connection_svc_integrationtest.cc +++ b/pc/peer_connection_svc_integrationtest.cc @@ -45,8 +45,7 @@ class PeerConnectionSVCIntegrationTest scoped_refptr transceiver, absl::string_view codec_name) { RtpCapabilities capabilities = - caller()->pc_factory()->GetRtpReceiverCapabilities( - webrtc::MediaType::VIDEO); + caller()->pc_factory()->GetRtpReceiverCapabilities(MediaType::VIDEO); std::vector codecs; for (const RtpCodecCapability& codec_capability : capabilities.codecs) { if (codec_capability.name == codec_name) @@ -100,8 +99,7 @@ TEST_F(PeerConnectionSVCIntegrationTest, SetParametersAcceptsL1T3WithVP8) { ConnectFakeSignaling(); RtpCapabilities capabilities = - caller()->pc_factory()->GetRtpReceiverCapabilities( - webrtc::MediaType::VIDEO); + caller()->pc_factory()->GetRtpReceiverCapabilities(MediaType::VIDEO); std::vector vp8_codec; for (const RtpCodecCapability& codec_capability : capabilities.codecs) { if (codec_capability.name == kVp8CodecName) @@ -243,8 +241,7 @@ TEST_F(PeerConnectionSVCIntegrationTest, FallbackToL1Tx) { auto caller_transceiver = transceiver_or_error.MoveValue(); RtpCapabilities capabilities = - caller()->pc_factory()->GetRtpReceiverCapabilities( - webrtc::MediaType::VIDEO); + caller()->pc_factory()->GetRtpReceiverCapabilities(MediaType::VIDEO); std::vector send_codecs = capabilities.codecs; // Only keep VP9 in the caller send_codecs.erase(std::partition(send_codecs.begin(), send_codecs.end(), diff --git a/pc/peer_connection_wrapper.cc b/pc/peer_connection_wrapper.cc index 4f547c77e7..d95538b733 100644 --- a/pc/peer_connection_wrapper.cc +++ b/pc/peer_connection_wrapper.cc @@ -277,7 +277,7 @@ bool PeerConnectionWrapper::ExchangeOfferAnswerWith( } scoped_refptr PeerConnectionWrapper::AddTransceiver( - webrtc::MediaType media_type) { + MediaType media_type) { RTCErrorOr> result = pc()->AddTransceiver(media_type); EXPECT_EQ(RTCErrorType::NONE, result.error().type()); @@ -285,7 +285,7 @@ scoped_refptr PeerConnectionWrapper::AddTransceiver( } scoped_refptr PeerConnectionWrapper::AddTransceiver( - webrtc::MediaType media_type, + MediaType media_type, const RtpTransceiverInit& init) { RTCErrorOr> result = pc()->AddTransceiver(media_type, init); diff --git a/pc/remote_audio_source.cc b/pc/remote_audio_source.cc index ecebff5d04..706c7f410f 100644 --- a/pc/remote_audio_source.cc +++ b/pc/remote_audio_source.cc @@ -125,13 +125,13 @@ void RemoteAudioSource::SetVolume(double volume) { } void RemoteAudioSource::RegisterAudioObserver(AudioObserver* observer) { - RTC_DCHECK(observer != NULL); + RTC_DCHECK(observer != nullptr); RTC_DCHECK(!absl::c_linear_search(audio_observers_, observer)); audio_observers_.push_back(observer); } void RemoteAudioSource::UnregisterAudioObserver(AudioObserver* observer) { - RTC_DCHECK(observer != NULL); + RTC_DCHECK(observer != nullptr); audio_observers_.remove(observer); } diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index a2df878987..780fe49c47 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -132,52 +132,47 @@ std::string RTCTransportStatsIDFromTransportChannel( } std::string RTCInboundRtpStreamStatsIDFromSSRC(const std::string& transport_id, - webrtc::MediaType media_type, + MediaType media_type, uint32_t ssrc) { char buf[1024]; SimpleStringBuilder sb(buf); - sb << 'I' << transport_id - << (media_type == webrtc::MediaType::AUDIO ? 'A' : 'V') << ssrc; + sb << 'I' << transport_id << (media_type == MediaType::AUDIO ? 'A' : 'V') + << ssrc; return sb.str(); } std::string RTCOutboundRtpStreamStatsIDFromSSRC(const std::string& transport_id, - webrtc::MediaType media_type, + MediaType media_type, uint32_t ssrc) { char buf[1024]; SimpleStringBuilder sb(buf); - sb << 'O' << transport_id - << (media_type == webrtc::MediaType::AUDIO ? 'A' : 'V') << ssrc; + sb << 'O' << transport_id << (media_type == MediaType::AUDIO ? 'A' : 'V') + << ssrc; return sb.str(); } std::string RTCRemoteInboundRtpStreamStatsIdFromSourceSsrc( - webrtc::MediaType media_type, + MediaType media_type, uint32_t source_ssrc) { char buf[1024]; SimpleStringBuilder sb(buf); - sb << "RI" << (media_type == webrtc::MediaType::AUDIO ? 'A' : 'V') - << source_ssrc; + sb << "RI" << (media_type == MediaType::AUDIO ? 'A' : 'V') << source_ssrc; return sb.str(); } -std::string RTCRemoteOutboundRTPStreamStatsIDFromSSRC( - webrtc::MediaType media_type, - uint32_t source_ssrc) { +std::string RTCRemoteOutboundRTPStreamStatsIDFromSSRC(MediaType media_type, + uint32_t source_ssrc) { char buf[1024]; SimpleStringBuilder sb(buf); - sb << "RO" << (media_type == webrtc::MediaType::AUDIO ? 'A' : 'V') - << source_ssrc; + sb << "RO" << (media_type == MediaType::AUDIO ? 'A' : 'V') << source_ssrc; return sb.str(); } -std::string RTCMediaSourceStatsIDFromKindAndAttachment( - webrtc::MediaType media_type, - int attachment_id) { +std::string RTCMediaSourceStatsIDFromKindAndAttachment(MediaType media_type, + int attachment_id) { char buf[1024]; SimpleStringBuilder sb(buf); - sb << 'S' << (media_type == webrtc::MediaType::AUDIO ? 'A' : 'V') - << attachment_id; + sb << 'S' << (media_type == MediaType::AUDIO ? 'A' : 'V') << attachment_id; return sb.str(); } @@ -452,8 +447,8 @@ std::unique_ptr CreateInboundAudioStreamStats( Timestamp timestamp, RTCStatsReport* report) { auto inbound_audio = std::make_unique( - /*id=*/RTCInboundRtpStreamStatsIDFromSSRC( - transport_id, webrtc::MediaType::AUDIO, voice_receiver_info.ssrc()), + /*id=*/RTCInboundRtpStreamStatsIDFromSSRC(transport_id, MediaType::AUDIO, + voice_receiver_info.ssrc()), timestamp); SetInboundRTPStreamStatsFromMediaReceiverInfo(voice_receiver_info, inbound_audio.get()); @@ -536,7 +531,7 @@ std::unique_ptr CreateRemoteOutboundMediaStreamStats( const MediaReceiverInfo& media_receiver_info, const std::string& mid, - webrtc::MediaType media_type, + MediaType media_type, const RTCInboundRtpStreamStats& inbound_audio_stats, const std::string& transport_id, const bool stats_timestamp_with_environment_clock) { @@ -561,7 +556,7 @@ CreateRemoteOutboundMediaStreamStats( // Populate. // - RTCRtpStreamStats. stats->ssrc = media_receiver_info.ssrc(); - stats->kind = webrtc::MediaTypeToString(media_type); + stats->kind = MediaTypeToString(media_type); stats->transport_id = transport_id; if (inbound_audio_stats.codec_id.has_value()) { stats->codec_id = *inbound_audio_stats.codec_id; @@ -599,7 +594,7 @@ CreateInboundRTPStreamStatsFromVideoReceiverInfo( Timestamp timestamp, RTCStatsReport* report) { auto inbound_video = std::make_unique( - RTCInboundRtpStreamStatsIDFromSSRC(transport_id, webrtc::MediaType::VIDEO, + RTCInboundRtpStreamStatsIDFromSSRC(transport_id, MediaType::VIDEO, video_receiver_info.ssrc()), timestamp); SetInboundRTPStreamStatsFromMediaReceiverInfo(video_receiver_info, @@ -748,8 +743,8 @@ CreateOutboundRTPStreamStatsFromVoiceSenderInfo( Timestamp timestamp, RTCStatsReport* report) { auto outbound_audio = std::make_unique( - RTCOutboundRtpStreamStatsIDFromSSRC( - transport_id, webrtc::MediaType::AUDIO, voice_sender_info.ssrc()), + RTCOutboundRtpStreamStatsIDFromSSRC(transport_id, MediaType::AUDIO, + voice_sender_info.ssrc()), timestamp); SetOutboundRTPStreamStatsFromMediaSenderInfo(voice_sender_info, outbound_audio.get()); @@ -783,8 +778,8 @@ CreateOutboundRTPStreamStatsFromVideoSenderInfo( Timestamp timestamp, RTCStatsReport* report) { auto outbound_video = std::make_unique( - RTCOutboundRtpStreamStatsIDFromSSRC( - transport_id, webrtc::MediaType::VIDEO, video_sender_info.ssrc()), + RTCOutboundRtpStreamStatsIDFromSSRC(transport_id, MediaType::VIDEO, + video_sender_info.ssrc()), timestamp); SetOutboundRTPStreamStatsFromMediaSenderInfo(video_sender_info, outbound_video.get()); @@ -874,7 +869,7 @@ std::unique_ptr ProduceRemoteInboundRtpStreamStatsFromReportBlockData( const std::string& transport_id, const ReportBlockData& report_block, - webrtc::MediaType media_type, + MediaType media_type, const std::map& outbound_rtps, const RTCStatsReport& report, const bool stats_timestamp_with_environment_clock) { @@ -889,8 +884,7 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData( media_type, report_block.source_ssrc()), arrival_timestamp); remote_inbound->ssrc = report_block.source_ssrc(); - remote_inbound->kind = - media_type == webrtc::MediaType::AUDIO ? "audio" : "video"; + remote_inbound->kind = media_type == MediaType::AUDIO ? "audio" : "video"; remote_inbound->packets_lost = report_block.cumulative_lost(); remote_inbound->fraction_lost = report_block.fraction_lost(); if (report_block.num_rtts() > 0) { @@ -1605,7 +1599,7 @@ void RTCStatsCollector::ProduceMediaSourceStats_s( static_cast(track.get()); auto audio_source_stats = std::make_unique( RTCMediaSourceStatsIDFromKindAndAttachment( - webrtc::MediaType::AUDIO, sender_internal->AttachmentId()), + MediaType::AUDIO, sender_internal->AttachmentId()), timestamp); // TODO(https://crbug.com/webrtc/10771): We shouldn't need to have an // SSRC assigned (there shouldn't need to exist a send-stream, created @@ -1643,7 +1637,7 @@ void RTCStatsCollector::ProduceMediaSourceStats_s( RTC_DCHECK_EQ(MediaStreamTrackInterface::kVideoKind, track->kind()); auto video_source_stats = std::make_unique( RTCMediaSourceStatsIDFromKindAndAttachment( - webrtc::MediaType::VIDEO, sender_internal->AttachmentId()), + MediaType::VIDEO, sender_internal->AttachmentId()), timestamp); auto* video_track = static_cast(track.get()); auto* video_source = video_track->GetSource(); @@ -1707,9 +1701,9 @@ void RTCStatsCollector::ProduceRTPStreamStats_n( Thread::ScopedDisallowBlockingCalls no_blocking_calls; for (const RtpTransceiverStatsInfo& stats : transceiver_stats_infos) { - if (stats.media_type == webrtc::MediaType::AUDIO) { + if (stats.media_type == MediaType::AUDIO) { ProduceAudioRTPStreamStats_n(timestamp, stats, report); - } else if (stats.media_type == webrtc::MediaType::VIDEO) { + } else if (stats.media_type == MediaType::VIDEO) { ProduceVideoRTPStreamStats_n(timestamp, stats, report); } else { RTC_DCHECK_NOTREACHED(); @@ -1748,7 +1742,7 @@ void RTCStatsCollector::ProduceAudioRTPStreamStats_n( if (audio_track) { inbound_audio->track_identifier = audio_track->id(); } - if (audio_device_stats_ && stats.media_type == webrtc::MediaType::AUDIO && + if (audio_device_stats_ && stats.media_type == MediaType::AUDIO && stats.current_direction && (*stats.current_direction == RtpTransceiverDirection::kSendRecv || *stats.current_direction == RtpTransceiverDirection::kRecvOnly)) { @@ -1762,7 +1756,7 @@ void RTCStatsCollector::ProduceAudioRTPStreamStats_n( } // Remote-outbound. auto remote_outbound_audio = CreateRemoteOutboundMediaStreamStats( - voice_receiver_info, mid, webrtc::MediaType::AUDIO, *inbound_audio_ptr, + voice_receiver_info, mid, MediaType::AUDIO, *inbound_audio_ptr, transport_id, stats_timestamp_with_environment_clock_); // Add stats. if (remote_outbound_audio) { @@ -1794,7 +1788,7 @@ void RTCStatsCollector::ProduceAudioRTPStreamStats_n( stats.track_media_info_map.GetAttachmentIdByTrack(audio_track.get()) .value(); outbound_audio->media_source_id = - RTCMediaSourceStatsIDFromKindAndAttachment(webrtc::MediaType::AUDIO, + RTCMediaSourceStatsIDFromKindAndAttachment(MediaType::AUDIO, attachment_id); } auto audio_outbound_pair = @@ -1815,7 +1809,7 @@ void RTCStatsCollector::ProduceAudioRTPStreamStats_n( stats.track_media_info_map.voice_media_info()->senders) { for (const auto& report_block_data : voice_sender_info.report_block_datas) { report->AddStats(ProduceRemoteInboundRtpStreamStatsFromReportBlockData( - transport_id, report_block_data, webrtc::MediaType::AUDIO, + transport_id, report_block_data, MediaType::AUDIO, audio_outbound_rtps, *report, stats_timestamp_with_environment_clock_)); } @@ -1857,7 +1851,7 @@ void RTCStatsCollector::ProduceVideoRTPStreamStats_n( } // Remote-outbound. auto remote_outbound_video = CreateRemoteOutboundMediaStreamStats( - video_receiver_info, mid, webrtc::MediaType::VIDEO, *inbound_video_ptr, + video_receiver_info, mid, MediaType::VIDEO, *inbound_video_ptr, transport_id, stats_timestamp_with_environment_clock_); // Add stats. if (remote_outbound_video) { @@ -1889,7 +1883,7 @@ void RTCStatsCollector::ProduceVideoRTPStreamStats_n( stats.track_media_info_map.GetAttachmentIdByTrack(video_track.get()) .value(); outbound_video->media_source_id = - RTCMediaSourceStatsIDFromKindAndAttachment(webrtc::MediaType::VIDEO, + RTCMediaSourceStatsIDFromKindAndAttachment(MediaType::VIDEO, attachment_id); } auto video_outbound_pair = @@ -1910,7 +1904,7 @@ void RTCStatsCollector::ProduceVideoRTPStreamStats_n( stats.track_media_info_map.video_media_info()->senders) { for (const auto& report_block_data : video_sender_info.report_block_datas) { report->AddStats(ProduceRemoteInboundRtpStreamStatsFromReportBlockData( - transport_id, report_block_data, webrtc::MediaType::VIDEO, + transport_id, report_block_data, MediaType::VIDEO, video_outbound_rtps, *report, stats_timestamp_with_environment_clock_)); } @@ -2095,7 +2089,7 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() { for (const auto& transceiver_proxy : transceivers) { RtpTransceiver* transceiver = transceiver_proxy->internal(); - webrtc::MediaType media_type = transceiver->media_type(); + MediaType media_type = transceiver->media_type(); // Prepare stats entry. The TrackMediaInfoMap will be filled in after the // stats have been fetched on the worker thread. @@ -2113,7 +2107,7 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() { stats.mid = channel->mid(); stats.transport_name = std::string(channel->transport_name()); - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { auto voice_send_channel = channel->voice_media_send_channel(); RTC_DCHECK(voice_send_stats.find(voice_send_channel) == voice_send_stats.end()); @@ -2125,7 +2119,7 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() { voice_receive_stats.end()); voice_receive_stats.insert( std::make_pair(voice_receive_channel, VoiceMediaReceiveInfo())); - } else if (media_type == webrtc::MediaType::VIDEO) { + } else if (media_type == MediaType::VIDEO) { auto video_send_channel = channel->video_media_send_channel(); RTC_DCHECK(video_send_stats.find(video_send_channel) == video_send_stats.end()); @@ -2180,14 +2174,14 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() { std::optional video_media_info; auto channel = transceiver->channel(); if (channel) { - webrtc::MediaType media_type = transceiver->media_type(); - if (media_type == webrtc::MediaType::AUDIO) { + MediaType media_type = transceiver->media_type(); + if (media_type == MediaType::AUDIO) { auto voice_send_channel = channel->voice_media_send_channel(); auto voice_receive_channel = channel->voice_media_receive_channel(); voice_media_info = VoiceMediaInfo( std::move(voice_send_stats[voice_send_channel]), std::move(voice_receive_stats[voice_receive_channel])); - } else if (media_type == webrtc::MediaType::VIDEO) { + } else if (media_type == MediaType::VIDEO) { auto video_send_channel = channel->video_media_send_channel(); auto video_receive_channel = channel->video_media_receive_channel(); video_media_info = VideoMediaInfo( @@ -2207,7 +2201,7 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() { stats.track_media_info_map.Initialize(std::move(voice_media_info), std::move(video_media_info), senders, receivers); - if (transceiver->media_type() == webrtc::MediaType::AUDIO) { + if (transceiver->media_type() == MediaType::AUDIO) { has_audio_receiver |= !receivers.empty(); } } diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 7ec09911ef..29216e1d7f 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -314,30 +314,30 @@ class FakeVideoTrackForStats : public MediaStreamTrack { }; scoped_refptr CreateFakeTrack( - webrtc::MediaType media_type, + MediaType media_type, const std::string& track_id, MediaStreamTrackInterface::TrackState track_state, bool create_fake_audio_processor = false) { - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { return FakeAudioTrackForStats::Create(track_id, track_state, create_fake_audio_processor); } else { - RTC_DCHECK_EQ(media_type, webrtc::MediaType::VIDEO); + RTC_DCHECK_EQ(media_type, MediaType::VIDEO); return FakeVideoTrackForStats::Create(track_id, track_state, nullptr); } } scoped_refptr CreateMockSender( - webrtc::MediaType media_type, + MediaType media_type, scoped_refptr track, uint32_t ssrc, int attachment_id, std::vector local_stream_ids) { RTC_DCHECK(!track || (track->kind() == MediaStreamTrackInterface::kAudioKind && - media_type == webrtc::MediaType::AUDIO) || + media_type == MediaType::AUDIO) || (track->kind() == MediaStreamTrackInterface::kVideoKind && - media_type == webrtc::MediaType::VIDEO)); + media_type == MediaType::VIDEO)); auto sender = make_ref_counted(); EXPECT_CALL(*sender, track()).WillRepeatedly(Return(track)); EXPECT_CALL(*sender, ssrc()).WillRepeatedly(Return(ssrc)); @@ -373,8 +373,8 @@ scoped_refptr CreateMockReceiver( EXPECT_CALL(*receiver, media_type()) .WillRepeatedly( Return(track->kind() == MediaStreamTrackInterface::kAudioKind - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO)); + ? MediaType::AUDIO + : MediaType::VIDEO)); EXPECT_CALL(*receiver, GetParameters()).WillRepeatedly(Invoke([ssrc]() { RtpParameters params; params.encodings.push_back(RtpEncodingParameters()); @@ -427,7 +427,7 @@ class RTCStatsCollectorWrapper { } scoped_refptr SetupLocalTrackAndSender( - webrtc::MediaType media_type, + MediaType media_type, const std::string& track_id, uint32_t ssrc, bool add_stream, @@ -439,7 +439,7 @@ class RTCStatsCollectorWrapper { } scoped_refptr track; - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { track = CreateFakeTrack(media_type, track_id, MediaStreamTrackInterface::kLive); if (add_stream) { @@ -465,7 +465,7 @@ class RTCStatsCollectorWrapper { } scoped_refptr SetupRemoteTrackAndReceiver( - webrtc::MediaType media_type, + MediaType media_type, const std::string& track_id, const std::string& stream_id, uint32_t ssrc) { @@ -473,7 +473,7 @@ class RTCStatsCollectorWrapper { pc_->mutable_remote_streams()->AddStream(remote_stream); scoped_refptr track; - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { track = CreateFakeTrack(media_type, track_id, MediaStreamTrackInterface::kLive); remote_stream->AddTrack(scoped_refptr( @@ -528,7 +528,7 @@ class RTCStatsCollectorWrapper { voice_media_info.senders.push_back(voice_sender_info); scoped_refptr rtp_sender = CreateMockSender( - webrtc::MediaType::AUDIO, + MediaType::AUDIO, scoped_refptr(local_audio_track), voice_sender_info.local_stats[0].ssrc, voice_sender_info.local_stats[0].ssrc + 10, local_stream_ids); @@ -566,7 +566,7 @@ class RTCStatsCollectorWrapper { video_media_info.senders.push_back(video_sender_info); video_media_info.aggregated_senders.push_back(video_sender_info); scoped_refptr rtp_sender = CreateMockSender( - webrtc::MediaType::VIDEO, + MediaType::VIDEO, scoped_refptr(local_video_track), video_sender_info.local_stats[0].ssrc, video_sender_info.local_stats[0].ssrc + 10, local_stream_ids); @@ -602,9 +602,9 @@ class RTCStatsCollectorWrapper { scoped_refptr WaitForReport( scoped_refptr callback) { EXPECT_THAT( - WaitUntil( - [&] { return callback->report() != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return callback->report() != nullptr; }, + ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); int64_t after = TimeUTCMicros(); for (const RTCStats& stats : *callback->report()) { @@ -719,10 +719,10 @@ class RTCStatsCollectorTest : public ::testing::Test { pc_->AddVideoChannel("VideoMid", "TransportName", video_media_info); // outbound-rtp's sender graph.sender = stats_->SetupLocalTrackAndSender( - webrtc::MediaType::VIDEO, "LocalVideoTrackID", 3, false, 50); + MediaType::VIDEO, "LocalVideoTrackID", 3, false, 50); // inbound-rtp's receiver graph.receiver = stats_->SetupRemoteTrackAndReceiver( - webrtc::MediaType::VIDEO, "RemoteVideoTrackID", "RemoteStreamId", 4); + MediaType::VIDEO, "RemoteVideoTrackID", "RemoteStreamId", 4); // peer-connection graph.peer_connection_id = "P"; // media-source (kind: video) @@ -820,11 +820,10 @@ class RTCStatsCollectorTest : public ::testing::Test { pc_->AddVoiceChannel("VoiceMid", "TransportName", media_info); // outbound-rtp's sender graph.sender = stats_->SetupLocalTrackAndSender( - webrtc::MediaType::AUDIO, "LocalAudioTrackID", kLocalSsrc, false, 50); + MediaType::AUDIO, "LocalAudioTrackID", kLocalSsrc, false, 50); // inbound-rtp's receiver graph.receiver = stats_->SetupRemoteTrackAndReceiver( - webrtc::MediaType::AUDIO, "RemoteAudioTrackID", "RemoteStreamId", - kRemoteSsrc); + MediaType::AUDIO, "RemoteAudioTrackID", "RemoteStreamId", kRemoteSsrc); // peer-connection graph.peer_connection_id = "P"; // media-source (kind: video) @@ -883,9 +882,8 @@ TEST_F(RTCStatsCollectorTest, SingleCallback) { scoped_refptr result; stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&result)); EXPECT_THAT( - WaitUntil( - [&] { return result != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return result != nullptr; }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); } @@ -895,19 +893,16 @@ TEST_F(RTCStatsCollectorTest, MultipleCallbacks) { stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&b)); stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&c)); EXPECT_THAT( - WaitUntil( - [&] { return a != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return a != nullptr; }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); EXPECT_THAT( - WaitUntil( - [&] { return b != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return b != nullptr; }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); EXPECT_THAT( - WaitUntil( - [&] { return c != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return c != nullptr; }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); EXPECT_EQ(a.get(), b.get()); @@ -938,19 +933,16 @@ TEST_F(RTCStatsCollectorTest, MultipleCallbacksWithInvalidatedCacheInBetween) { fake_clock_.AdvanceTime(TimeDelta::Millis(51)); stats_->stats_collector()->GetStatsReport(RTCStatsObtainer::Create(&c)); EXPECT_THAT( - WaitUntil( - [&] { return a != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return a != nullptr; }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); EXPECT_THAT( - WaitUntil( - [&] { return b != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return b != nullptr; }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); EXPECT_THAT( - WaitUntil( - [&] { return c != nullptr; }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return c != nullptr; }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); EXPECT_EQ(a.get(), b.get()); // The act of doing `AdvanceTime` processes all messages. If this was not the @@ -1077,7 +1069,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStatsOnlyIfReferenced) { RtpCodecParameters inbound_audio_codec; inbound_audio_codec.payload_type = 1; - inbound_audio_codec.kind = webrtc::MediaType::AUDIO; + inbound_audio_codec.kind = MediaType::AUDIO; inbound_audio_codec.name = "opus"; inbound_audio_codec.clock_rate = 1337; inbound_audio_codec.num_channels = 1; @@ -1087,7 +1079,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStatsOnlyIfReferenced) { RtpCodecParameters outbound_audio_codec; outbound_audio_codec.payload_type = 2; - outbound_audio_codec.kind = webrtc::MediaType::AUDIO; + outbound_audio_codec.kind = MediaType::AUDIO; outbound_audio_codec.name = "isac"; outbound_audio_codec.clock_rate = 1338; outbound_audio_codec.num_channels = 2; @@ -1099,7 +1091,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStatsOnlyIfReferenced) { RtpCodecParameters inbound_video_codec; inbound_video_codec.payload_type = 3; - inbound_video_codec.kind = webrtc::MediaType::VIDEO; + inbound_video_codec.kind = MediaType::VIDEO; inbound_video_codec.name = "H264"; inbound_video_codec.clock_rate = 1339; inbound_video_codec.parameters = {{"level-asymmetry-allowed", "1"}, @@ -1110,7 +1102,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStatsOnlyIfReferenced) { RtpCodecParameters outbound_video_codec; outbound_video_codec.payload_type = 4; - outbound_video_codec.kind = webrtc::MediaType::VIDEO; + outbound_video_codec.kind = MediaType::VIDEO; outbound_video_codec.name = "VP8"; outbound_video_codec.clock_rate = 1340; video_media_info.send_codecs.insert( @@ -1222,14 +1214,14 @@ TEST_F(RTCStatsCollectorTest, CodecStatsAreCollectedPerTransport) { // PT=10 RtpCodecParameters outbound_codec_pt10; outbound_codec_pt10.payload_type = 10; - outbound_codec_pt10.kind = webrtc::MediaType::VIDEO; + outbound_codec_pt10.kind = MediaType::VIDEO; outbound_codec_pt10.name = "VP8"; outbound_codec_pt10.clock_rate = 9000; // PT=11 RtpCodecParameters outbound_codec_pt11; outbound_codec_pt11.payload_type = 11; - outbound_codec_pt11.kind = webrtc::MediaType::VIDEO; + outbound_codec_pt11.kind = MediaType::VIDEO; outbound_codec_pt11.name = "VP8"; outbound_codec_pt11.clock_rate = 9000; @@ -1287,7 +1279,7 @@ TEST_F(RTCStatsCollectorTest, SamePayloadTypeButDifferentFmtpLines) { // PT=111, useinbandfec=0 RtpCodecParameters inbound_codec_pt111_nofec; inbound_codec_pt111_nofec.payload_type = 111; - inbound_codec_pt111_nofec.kind = webrtc::MediaType::AUDIO; + inbound_codec_pt111_nofec.kind = MediaType::AUDIO; inbound_codec_pt111_nofec.name = "opus"; inbound_codec_pt111_nofec.clock_rate = 48000; inbound_codec_pt111_nofec.parameters.insert( @@ -1296,7 +1288,7 @@ TEST_F(RTCStatsCollectorTest, SamePayloadTypeButDifferentFmtpLines) { // PT=111, useinbandfec=1 RtpCodecParameters inbound_codec_pt111_fec; inbound_codec_pt111_fec.payload_type = 111; - inbound_codec_pt111_fec.kind = webrtc::MediaType::AUDIO; + inbound_codec_pt111_fec.kind = MediaType::AUDIO; inbound_codec_pt111_fec.name = "opus"; inbound_codec_pt111_fec.clock_rate = 48000; inbound_codec_pt111_fec.parameters.insert( @@ -1344,7 +1336,7 @@ TEST_F(RTCStatsCollectorTest, SamePayloadTypeButDifferentFmtpLines) { // PT=112, useinbandfec=1 RtpCodecParameters inbound_codec_pt112_fec; inbound_codec_pt112_fec.payload_type = 112; - inbound_codec_pt112_fec.kind = webrtc::MediaType::AUDIO; + inbound_codec_pt112_fec.kind = MediaType::AUDIO; inbound_codec_pt112_fec.name = "opus"; inbound_codec_pt112_fec.clock_rate = 48000; inbound_codec_pt112_fec.parameters.insert( @@ -2186,7 +2178,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Audio) { RtpCodecParameters codec_parameters; codec_parameters.payload_type = 42; - codec_parameters.kind = webrtc::MediaType::AUDIO; + codec_parameters.kind = MediaType::AUDIO; codec_parameters.name = "dummy"; codec_parameters.clock_rate = 0; voice_media_info.receive_codecs.insert( @@ -2194,8 +2186,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Audio) { auto voice_media_channels = pc_->AddVoiceChannel("AudioMid", "TransportName", voice_media_info); - stats_->SetupRemoteTrackAndReceiver( - webrtc::MediaType::AUDIO, "RemoteAudioTrackID", "RemoteStreamId", 1); + stats_->SetupRemoteTrackAndReceiver(MediaType::AUDIO, "RemoteAudioTrackID", + "RemoteStreamId", 1); // Needed for playoutId to be populated. pc_->SetAudioDeviceStats(AudioDeviceModule::Stats()); @@ -2274,8 +2266,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Audio_PlayoutId) { voice_media_info.receivers[0].local_stats[0].ssrc = 1; pc_->AddVoiceChannel("AudioMid", "TransportName", voice_media_info); - stats_->SetupRemoteTrackAndReceiver( - webrtc::MediaType::AUDIO, "RemoteAudioTrackID", "RemoteStreamId", 1); + stats_->SetupRemoteTrackAndReceiver(MediaType::AUDIO, "RemoteAudioTrackID", + "RemoteStreamId", 1); // Needed for playoutId to be populated. pc_->SetAudioDeviceStats(AudioDeviceModule::Stats()); @@ -2361,7 +2353,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Video) { RtpCodecParameters codec_parameters; codec_parameters.payload_type = 42; - codec_parameters.kind = webrtc::MediaType::VIDEO; + codec_parameters.kind = MediaType::VIDEO; codec_parameters.name = "dummy"; codec_parameters.clock_rate = 0; video_media_info.receive_codecs.insert( @@ -2369,8 +2361,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Video) { auto video_media_channels = pc_->AddVideoChannel("VideoMid", "TransportName", video_media_info); - stats_->SetupRemoteTrackAndReceiver( - webrtc::MediaType::VIDEO, "RemoteVideoTrackID", "RemoteStreamId", 1); + stats_->SetupRemoteTrackAndReceiver(MediaType::VIDEO, "RemoteVideoTrackID", + "RemoteStreamId", 1); scoped_refptr report = stats_->GetStatsReport(); @@ -2470,8 +2462,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCAudioPlayoutStats) { pc_->SetAudioDeviceStats(audio_device_stats); pc_->AddVoiceChannel("AudioMid", "TransportName", {}); - stats_->SetupRemoteTrackAndReceiver( - webrtc::MediaType::AUDIO, "RemoteAudioTrackID", "RemoteStreamId", 1); + stats_->SetupRemoteTrackAndReceiver(MediaType::AUDIO, "RemoteAudioTrackID", + "RemoteStreamId", 1); scoped_refptr report = stats_->GetStatsReport(); auto stats_of_track_type = report->GetStatsOfType(); @@ -2514,8 +2506,8 @@ TEST_F(RTCStatsCollectorTest, CollectGoogTimingFrameInfo) { video_media_info.receivers[0].timing_frame_info = timing_frame_info; pc_->AddVideoChannel("Mid0", "Transport0", video_media_info); - stats_->SetupRemoteTrackAndReceiver( - webrtc::MediaType::VIDEO, "RemoteVideoTrackID", "RemoteStreamId", 1); + stats_->SetupRemoteTrackAndReceiver(MediaType::VIDEO, "RemoteVideoTrackID", + "RemoteStreamId", 1); scoped_refptr report = stats_->GetStatsReport(); auto inbound_rtps = report->GetStatsOfType(); @@ -2544,15 +2536,15 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRtpStreamStats_Audio) { RtpCodecParameters codec_parameters; codec_parameters.payload_type = 42; - codec_parameters.kind = webrtc::MediaType::AUDIO; + codec_parameters.kind = MediaType::AUDIO; codec_parameters.name = "dummy"; codec_parameters.clock_rate = 0; voice_media_info.send_codecs.insert( std::make_pair(codec_parameters.payload_type, codec_parameters)); pc_->AddVoiceChannel("AudioMid", "TransportName", voice_media_info); - stats_->SetupLocalTrackAndSender(webrtc::MediaType::AUDIO, - "LocalAudioTrackID", 1, true, + stats_->SetupLocalTrackAndSender(MediaType::AUDIO, "LocalAudioTrackID", 1, + true, /*attachment_id=*/50); scoped_refptr report = stats_->GetStatsReport(); @@ -2633,7 +2625,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRtpStreamStats_Video) { video_media_info.aggregated_senders.push_back(video_media_info.senders[0]); RtpCodecParameters codec_parameters; codec_parameters.payload_type = 42; - codec_parameters.kind = webrtc::MediaType::AUDIO; + codec_parameters.kind = MediaType::AUDIO; codec_parameters.name = "dummy"; codec_parameters.clock_rate = 0; video_media_info.send_codecs.insert( @@ -2647,8 +2639,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRtpStreamStats_Video) { auto video_media_channels = pc_->AddVideoChannel("VideoMid", "TransportName", video_media_info); - stats_->SetupLocalTrackAndSender(webrtc::MediaType::VIDEO, - "LocalVideoTrackID", 1, true, + stats_->SetupLocalTrackAndSender(MediaType::VIDEO, "LocalVideoTrackID", 1, + true, /*attachment_id=*/50); scoped_refptr report = stats_->GetStatsReport(); @@ -2991,7 +2983,7 @@ TEST_F(RTCStatsCollectorTest, CollectNoStreamRTCOutboundRtpStreamStats_Audio) { RtpCodecParameters codec_parameters; codec_parameters.payload_type = 42; - codec_parameters.kind = webrtc::MediaType::AUDIO; + codec_parameters.kind = MediaType::AUDIO; codec_parameters.name = "dummy"; codec_parameters.clock_rate = 0; voice_media_info.send_codecs.insert( @@ -2999,8 +2991,8 @@ TEST_F(RTCStatsCollectorTest, CollectNoStreamRTCOutboundRtpStreamStats_Audio) { // Emulates the case where AddTrack is used without an associated MediaStream pc_->AddVoiceChannel("AudioMid", "TransportName", voice_media_info); - stats_->SetupLocalTrackAndSender(webrtc::MediaType::AUDIO, - "LocalAudioTrackID", 1, false, + stats_->SetupLocalTrackAndSender(MediaType::AUDIO, "LocalAudioTrackID", 1, + false, /*attachment_id=*/50); scoped_refptr report = stats_->GetStatsReport(); @@ -3045,9 +3037,8 @@ TEST_F(RTCStatsCollectorTest, RTCAudioSourceStatsCollectedForSenderWithTrack) { voice_media_info.senders[0].apm_statistics.echo_return_loss_enhancement = 52.0; pc_->AddVoiceChannel("AudioMid", "TransportName", voice_media_info); - stats_->SetupLocalTrackAndSender(webrtc::MediaType::AUDIO, - "LocalAudioTrackID", kSsrc, false, - kAttachmentId); + stats_->SetupLocalTrackAndSender(MediaType::AUDIO, "LocalAudioTrackID", kSsrc, + false, kAttachmentId); scoped_refptr report = stats_->GetStatsReport(); @@ -3088,8 +3079,8 @@ TEST_F(RTCStatsCollectorTest, RTCVideoSourceStatsCollectedForSenderWithTrack) { kVideoSourceHeight); auto video_track = FakeVideoTrackForStats::Create( "LocalVideoTrackID", MediaStreamTrackInterface::kLive, video_source); - scoped_refptr sender = CreateMockSender( - webrtc::MediaType::VIDEO, video_track, kSsrc, kAttachmentId, {}); + scoped_refptr sender = + CreateMockSender(MediaType::VIDEO, video_track, kSsrc, kAttachmentId, {}); EXPECT_CALL(*sender, Stop()); EXPECT_CALL(*sender, SetMediaChannel(_)); EXPECT_CALL(*sender, SetSendCodecs(_)); @@ -3134,7 +3125,7 @@ TEST_F(RTCStatsCollectorTest, auto video_track = FakeVideoTrackForStats::Create( "LocalVideoTrackID", MediaStreamTrackInterface::kLive, video_source); scoped_refptr sender = CreateMockSender( - webrtc::MediaType::VIDEO, video_track, kNoSsrc, kAttachmentId, {}); + MediaType::VIDEO, video_track, kNoSsrc, kAttachmentId, {}); EXPECT_CALL(*sender, Stop()); EXPECT_CALL(*sender, SetMediaChannel(_)); EXPECT_CALL(*sender, SetSendCodecs(_)); @@ -3164,8 +3155,8 @@ TEST_F(RTCStatsCollectorTest, auto video_track = FakeVideoTrackForStats::Create( "LocalVideoTrackID", MediaStreamTrackInterface::kLive, /*source=*/nullptr); - scoped_refptr sender = CreateMockSender( - webrtc::MediaType::VIDEO, video_track, kSsrc, kAttachmentId, {}); + scoped_refptr sender = + CreateMockSender(MediaType::VIDEO, video_track, kSsrc, kAttachmentId, {}); EXPECT_CALL(*sender, Stop()); EXPECT_CALL(*sender, SetMediaChannel(_)); EXPECT_CALL(*sender, SetSendCodecs(_)); @@ -3189,7 +3180,7 @@ TEST_F(RTCStatsCollectorTest, voice_media_info.senders[0].local_stats[0].ssrc = kSsrc; pc_->AddVoiceChannel("AudioMid", "TransportName", voice_media_info); scoped_refptr sender = CreateMockSender( - webrtc::MediaType::AUDIO, /*track=*/nullptr, kSsrc, kAttachmentId, {}); + MediaType::AUDIO, /*track=*/nullptr, kSsrc, kAttachmentId, {}); EXPECT_CALL(*sender, Stop()); EXPECT_CALL(*sender, SetMediaChannel(_)); EXPECT_CALL(*sender, SetSendCodecs(_)); @@ -3202,18 +3193,18 @@ TEST_F(RTCStatsCollectorTest, // Parameterized tests on webrtc::MediaType (audio or video). class RTCStatsCollectorTestWithParamKind : public RTCStatsCollectorTest, - public ::testing::WithParamInterface { + public ::testing::WithParamInterface { public: RTCStatsCollectorTestWithParamKind() : media_type_(GetParam()) { - RTC_DCHECK(media_type_ == webrtc::MediaType::AUDIO || - media_type_ == webrtc::MediaType::VIDEO); + RTC_DCHECK(media_type_ == MediaType::AUDIO || + media_type_ == MediaType::VIDEO); } std::string MediaTypeCharStr() const { switch (media_type_) { - case webrtc::MediaType::AUDIO: + case MediaType::AUDIO: return "A"; - case webrtc::MediaType::VIDEO: + case MediaType::VIDEO: return "V"; default: RTC_DCHECK_NOTREACHED(); @@ -3223,9 +3214,9 @@ class RTCStatsCollectorTestWithParamKind std::string MediaTypeKind() const { switch (media_type_) { - case webrtc::MediaType::AUDIO: + case MediaType::AUDIO: return "audio"; - case webrtc::MediaType::VIDEO: + case MediaType::VIDEO: return "video"; default: RTC_DCHECK_NOTREACHED(); @@ -3240,7 +3231,7 @@ class RTCStatsCollectorTestWithParamKind const std::vector& report_block_datas, std::optional codec) { switch (media_type_) { - case webrtc::MediaType::AUDIO: { + case MediaType::AUDIO: { VoiceMediaInfo voice_media_info; for (const auto& report_block_data : report_block_datas) { VoiceSenderInfo sender; @@ -3257,7 +3248,7 @@ class RTCStatsCollectorTestWithParamKind pc_->AddVoiceChannel("mid", transport_name, voice_media_info); return; } - case webrtc::MediaType::VIDEO: { + case MediaType::VIDEO: { VideoMediaInfo video_media_info; for (const auto& report_block_data : report_block_datas) { VideoSenderInfo sender; @@ -3275,14 +3266,14 @@ class RTCStatsCollectorTestWithParamKind pc_->AddVideoChannel("mid", transport_name, video_media_info); return; } - case webrtc::MediaType::DATA: + case MediaType::DATA: default: RTC_DCHECK_NOTREACHED(); } } protected: - webrtc::MediaType media_type_; + MediaType media_type_; }; // Verifies RTCRemoteInboundRtpStreamStats members that don't require @@ -3496,8 +3487,8 @@ TEST_P(RTCStatsCollectorTestWithParamKind, INSTANTIATE_TEST_SUITE_P(All, RTCStatsCollectorTestWithParamKind, - ::testing::Values(webrtc::MediaType::AUDIO, // "/0" - webrtc::MediaType::VIDEO)); // "/1" + ::testing::Values(MediaType::AUDIO, // "/0" + MediaType::VIDEO)); // "/1" // Checks that no remote outbound stats are collected if not available in // `VoiceMediaInfo`. @@ -3548,7 +3539,7 @@ TEST_F(RTCStatsCollectorTest, pc_->AddVideoChannel("VideoMid", "TransportName", video_media_info); scoped_refptr sender = CreateMockSender( - webrtc::MediaType::VIDEO, /*track=*/nullptr, kSsrc, kAttachmentId, {}); + MediaType::VIDEO, /*track=*/nullptr, kSsrc, kAttachmentId, {}); EXPECT_CALL(*sender, Stop()); EXPECT_CALL(*sender, SetMediaChannel(_)); EXPECT_CALL(*sender, SetSendCodecs(_)); @@ -3566,10 +3557,9 @@ TEST_F(RTCStatsCollectorTest, CollectEchoReturnLossFromTrackAudioProcessor) { pc_->mutable_local_streams()->AddStream(local_stream); // Local audio track - scoped_refptr local_audio_track = - CreateFakeTrack(webrtc::MediaType::AUDIO, "LocalAudioTrackID", - MediaStreamTrackInterface::kEnded, - /*create_fake_audio_processor=*/true); + scoped_refptr local_audio_track = CreateFakeTrack( + MediaType::AUDIO, "LocalAudioTrackID", MediaStreamTrackInterface::kEnded, + /*create_fake_audio_processor=*/true); local_stream->AddTrack(scoped_refptr( static_cast(local_audio_track.get()))); @@ -3668,9 +3658,9 @@ TEST_F(RTCStatsCollectorTest, GetStatsWithNullReceiverSelector) { // To simulate this case we create a mock sender with SSRC=0. TEST_F(RTCStatsCollectorTest, RtpIsMissingWhileSsrcIsZero) { scoped_refptr track = CreateFakeTrack( - webrtc::MediaType::AUDIO, "audioTrack", MediaStreamTrackInterface::kLive); + MediaType::AUDIO, "audioTrack", MediaStreamTrackInterface::kLive); scoped_refptr sender = - CreateMockSender(webrtc::MediaType::AUDIO, track, 0, 49, {}); + CreateMockSender(MediaType::AUDIO, track, 0, 49, {}); EXPECT_CALL(*sender, Stop()); EXPECT_CALL(*sender, SetSendCodecs(_)); pc_->AddSender(sender); @@ -3685,9 +3675,9 @@ TEST_F(RTCStatsCollectorTest, RtpIsMissingWhileSsrcIsZero) { // `voice_sender_info` stats exist yet. TEST_F(RTCStatsCollectorTest, DoNotCrashIfSsrcIsKnownButInfosAreStillMissing) { scoped_refptr track = CreateFakeTrack( - webrtc::MediaType::AUDIO, "audioTrack", MediaStreamTrackInterface::kLive); + MediaType::AUDIO, "audioTrack", MediaStreamTrackInterface::kLive); scoped_refptr sender = - CreateMockSender(webrtc::MediaType::AUDIO, track, 4711, 49, {}); + CreateMockSender(MediaType::AUDIO, track, 4711, 49, {}); EXPECT_CALL(*sender, Stop()); EXPECT_CALL(*sender, SetSendCodecs(_)); pc_->AddSender(sender); @@ -3724,14 +3714,12 @@ TEST_F(RTCStatsCollectorTest, DoNotCrashWhenGetStatsCalledDuringCallback) { stats_->stats_collector()->GetStatsReport(callback1); stats_->stats_collector()->GetStatsReport(callback2); EXPECT_THAT( - WaitUntil( - [&] { return callback1->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return callback1->called(); }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); EXPECT_THAT( - WaitUntil( - [&] { return callback2->called(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return callback2->called(); }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); } @@ -3785,9 +3773,8 @@ class FakeRTCStatsCollector : public RTCStatsCollector, void VerifyThreadUsageAndResultsMerging() { GetStatsReport(scoped_refptr(this)); EXPECT_THAT( - WaitUntil( - [&] { return HasVerifiedResults(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsReportTimeoutMs)}), + WaitUntil([&] { return HasVerifiedResults(); }, ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsReportTimeoutMs)}), IsRtcOk()); } diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 7562f803a1..2e3b69dc5f 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -125,11 +125,10 @@ class RTCStatsIntegrationTest : public ::testing::Test { PeerConnectionInterface* pc) { scoped_refptr stats_obtainer = RTCStatsObtainer::Create(); pc->GetStats(stats_obtainer.get()); - EXPECT_THAT( - WaitUntil([&] { return stats_obtainer->report() != nullptr; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsTimeoutMs)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return stats_obtainer->report() != nullptr; }, + ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsTimeoutMs)}), + IsRtcOk()); return stats_obtainer->report(); } @@ -139,11 +138,10 @@ class RTCStatsIntegrationTest : public ::testing::Test { scoped_refptr selector) { scoped_refptr stats_obtainer = RTCStatsObtainer::Create(); pc->GetStats(selector, stats_obtainer); - EXPECT_THAT( - WaitUntil([&] { return stats_obtainer->report() != nullptr; }, - ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kGetStatsTimeoutMs)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return stats_obtainer->report() != nullptr; }, + ::testing::IsTrue(), + {.timeout = TimeDelta::Millis(kGetStatsTimeoutMs)}), + IsRtcOk()); return stats_obtainer->report(); } @@ -1040,7 +1038,7 @@ TEST_F(RTCStatsIntegrationTest, GetStatsFromCallee) { EXPECT_THAT( WaitUntil([&] { return GetStatsReportAndReturnTrueIfRttIsDefined(); }, ::testing::IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kMaxWaitMs)}), + {.timeout = TimeDelta::Millis(kMaxWaitMs)}), IsRtcOk()); RTCStatsReportVerifier(report.get()).VerifyReport({}); } diff --git a/pc/rtcp_mux_filter.cc b/pc/rtcp_mux_filter.cc index 7680c8d193..f3f1cdf97f 100644 --- a/pc/rtcp_mux_filter.cc +++ b/pc/rtcp_mux_filter.cc @@ -45,7 +45,7 @@ bool RtcpMuxFilter::SetOffer(bool offer_enable, ContentSource src) { } offer_enable_ = offer_enable; - state_ = (src == webrtc::CS_LOCAL) ? ST_SENTOFFER : ST_RECEIVEDOFFER; + state_ = (src == CS_LOCAL) ? ST_SENTOFFER : ST_RECEIVEDOFFER; return true; } @@ -63,7 +63,7 @@ bool RtcpMuxFilter::SetProvisionalAnswer(bool answer_enable, if (offer_enable_) { if (answer_enable) { - if (src == webrtc::CS_REMOTE) + if (src == CS_REMOTE) state_ = ST_RECEIVEDPRANSWER; else // CS_LOCAL state_ = ST_SENTPRANSWER; @@ -71,7 +71,7 @@ bool RtcpMuxFilter::SetProvisionalAnswer(bool answer_enable, // The provisional answer doesn't want to use RTCP mux. // Go back to the original state after the offer was set and wait for next // provisional or final answer. - if (src == webrtc::CS_REMOTE) + if (src == CS_REMOTE) state_ = ST_SENTOFFER; else // CS_LOCAL state_ = ST_RECEIVEDOFFER; @@ -111,15 +111,15 @@ bool RtcpMuxFilter::SetAnswer(bool answer_enable, ContentSource src) { bool RtcpMuxFilter::ExpectOffer(bool offer_enable, ContentSource source) { return ((state_ == ST_INIT) || (state_ == ST_ACTIVE && offer_enable == offer_enable_) || - (state_ == ST_SENTOFFER && source == webrtc::CS_LOCAL) || - (state_ == ST_RECEIVEDOFFER && source == webrtc::CS_REMOTE)); + (state_ == ST_SENTOFFER && source == CS_LOCAL) || + (state_ == ST_RECEIVEDOFFER && source == CS_REMOTE)); } bool RtcpMuxFilter::ExpectAnswer(ContentSource source) { - return ((state_ == ST_SENTOFFER && source == webrtc::CS_REMOTE) || - (state_ == ST_RECEIVEDOFFER && source == webrtc::CS_LOCAL) || - (state_ == ST_SENTPRANSWER && source == webrtc::CS_LOCAL) || - (state_ == ST_RECEIVEDPRANSWER && source == webrtc::CS_REMOTE)); + return ((state_ == ST_SENTOFFER && source == CS_REMOTE) || + (state_ == ST_RECEIVEDOFFER && source == CS_LOCAL) || + (state_ == ST_SENTPRANSWER && source == CS_LOCAL) || + (state_ == ST_RECEIVEDPRANSWER && source == CS_REMOTE)); } } // namespace webrtc diff --git a/pc/rtp_parameters_conversion.cc b/pc/rtp_parameters_conversion.cc index 75a69bcaa9..63d50d23cc 100644 --- a/pc/rtp_parameters_conversion.cc +++ b/pc/rtp_parameters_conversion.cc @@ -78,9 +78,8 @@ std::optional ToRtcpFeedback( RtpCodecCapability ToRtpCodecCapability(const Codec& cricket_codec) { RtpCodecCapability codec; codec.name = cricket_codec.name; - codec.kind = cricket_codec.type == Codec::Type::kAudio - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO; + codec.kind = cricket_codec.type == Codec::Type::kAudio ? MediaType::AUDIO + : MediaType::VIDEO; codec.clock_rate.emplace(cricket_codec.clockrate); codec.preferred_payload_type.emplace(cricket_codec.id); for (const FeedbackParam& cricket_feedback : diff --git a/pc/rtp_parameters_conversion_unittest.cc b/pc/rtp_parameters_conversion_unittest.cc index 407c535173..74f370e30b 100644 --- a/pc/rtp_parameters_conversion_unittest.cc +++ b/pc/rtp_parameters_conversion_unittest.cc @@ -86,7 +86,7 @@ TEST(RtpParametersConversionTest, ToAudioRtpCodecCapability) { RtpCodecCapability codec = ToRtpCodecCapability(cricket_codec); EXPECT_EQ("foo", codec.name); - EXPECT_EQ(webrtc::MediaType::AUDIO, codec.kind); + EXPECT_EQ(MediaType::AUDIO, codec.kind); EXPECT_EQ(50, codec.preferred_payload_type); EXPECT_EQ(22222, codec.clock_rate); EXPECT_EQ(4, codec.num_channels); @@ -108,7 +108,7 @@ TEST(RtpParametersConversionTest, ToVideoRtpCodecCapability) { RtpCodecCapability codec = ToRtpCodecCapability(cricket_codec); EXPECT_EQ("VID", codec.name); - EXPECT_EQ(webrtc::MediaType::VIDEO, codec.kind); + EXPECT_EQ(MediaType::VIDEO, codec.kind); EXPECT_EQ(101, codec.preferred_payload_type); EXPECT_EQ(80000, codec.clock_rate); ASSERT_EQ(2u, codec.parameters.size()); diff --git a/pc/rtp_sender.cc b/pc/rtp_sender.cc index 31bbba0493..0645133275 100644 --- a/pc/rtp_sender.cc +++ b/pc/rtp_sender.cc @@ -264,8 +264,8 @@ void RtpSenderBase::SetParametersInternal(const RtpParameters& parameters, RTCError error( RTCErrorType::UNSUPPORTED_PARAMETER, "Attempted to set an unimplemented parameter of RtpParameters."); - RTC_LOG(LS_ERROR) << error.message() << " (" - << ::webrtc::ToString(error.type()) << ")"; + RTC_LOG(LS_ERROR) << error.message() << " (" << ToString(error.type()) + << ")"; InvokeSetParametersCallback(callback, error); return; } @@ -528,17 +528,23 @@ void RtpSenderBase::SetSsrc(uint32_t ssrc) { // we need to copy. RtpParameters current_parameters = media_channel_->GetRtpSendParameters(ssrc_); - RTC_CHECK_GE(current_parameters.encodings.size(), - init_parameters_.encodings.size()); - for (size_t i = 0; i < init_parameters_.encodings.size(); ++i) { - init_parameters_.encodings[i].ssrc = - current_parameters.encodings[i].ssrc; - init_parameters_.encodings[i].rid = current_parameters.encodings[i].rid; - current_parameters.encodings[i] = init_parameters_.encodings[i]; + // SSRC 0 has special meaning as "no stream". + // In this case, current_parameters may have size 0. + if (ssrc != 0) { + RTC_CHECK_GE(current_parameters.encodings.size(), + init_parameters_.encodings.size()); + for (size_t i = 0; i < init_parameters_.encodings.size(); ++i) { + init_parameters_.encodings[i].ssrc = + current_parameters.encodings[i].ssrc; + init_parameters_.encodings[i].rid = + current_parameters.encodings[i].rid; + current_parameters.encodings[i] = init_parameters_.encodings[i]; + } + current_parameters.degradation_preference = + init_parameters_.degradation_preference; + media_channel_->SetRtpSendParameters(ssrc_, current_parameters, + nullptr); } - current_parameters.degradation_preference = - init_parameters_.degradation_preference; - media_channel_->SetRtpSendParameters(ssrc_, current_parameters, nullptr); init_parameters_.encodings.clear(); init_parameters_.degradation_preference = std::nullopt; }); @@ -672,7 +678,7 @@ void LocalAudioSinkAdapter::SetSink(AudioSource::Sink* sink) { } scoped_refptr AudioRtpSender::Create( - const webrtc::Environment& env, + const Environment& env, Thread* worker_thread, const std::string& id, LegacyStatsCollectorInterface* stats, @@ -681,7 +687,7 @@ scoped_refptr AudioRtpSender::Create( set_streams_observer); } -AudioRtpSender::AudioRtpSender(const webrtc::Environment& env, +AudioRtpSender::AudioRtpSender(const Environment& env, Thread* worker_thread, const std::string& id, LegacyStatsCollectorInterface* legacy_stats, diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index 6dae6e6146..dadc9de064 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc @@ -114,7 +114,7 @@ TaskQueueBase* GetCurrentTaskQueueOrThread() { } // namespace -RtpTransceiver::RtpTransceiver(webrtc::MediaType media_type, +RtpTransceiver::RtpTransceiver(MediaType media_type, ConnectionContext* context, CodecLookupHelper* codec_lookup_helper) : thread_(GetCurrentTaskQueueOrThread()), @@ -122,8 +122,7 @@ RtpTransceiver::RtpTransceiver(webrtc::MediaType media_type, media_type_(media_type), context_(context), codec_lookup_helper_(codec_lookup_helper) { - RTC_DCHECK(media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO); + RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO); RTC_DCHECK(context_); RTC_DCHECK(codec_lookup_helper_); } @@ -144,11 +143,11 @@ RtpTransceiver::RtpTransceiver( std::move(header_extensions_to_negotiate)), on_negotiation_needed_(std::move(on_negotiation_needed)) { RTC_DCHECK(context_); - RTC_DCHECK(media_type_ == webrtc::MediaType::AUDIO || - media_type_ == webrtc::MediaType::VIDEO); + RTC_DCHECK(media_type_ == MediaType::AUDIO || + media_type_ == MediaType::VIDEO); RTC_DCHECK_EQ(sender->media_type(), receiver->media_type()); sender->internal()->SetSendCodecs( - sender->media_type() == webrtc::MediaType::VIDEO + sender->media_type() == MediaType::VIDEO ? codec_vendor().video_send_codecs().codecs() : codec_vendor().audio_send_codecs().codecs()); senders_.push_back(sender); @@ -170,7 +169,7 @@ RtpTransceiver::RtpTransceiver( header_extensions_to_negotiate_, [](const RtpHeaderExtensionCapability& ext) { return ext.uri == RtpExtension::kGenericFrameDescriptorUri00 && - ext.direction != webrtc::RtpTransceiverDirection::kStopped; + ext.direction != RtpTransceiverDirection::kStopped; }) != header_extensions_to_negotiate_.end(); if (!uses_gfd) { for (RtpHeaderExtensionCapability& ext : @@ -216,7 +215,7 @@ RTCError RtpTransceiver::CreateChannel( } std::unique_ptr new_channel; - if (media_type() == webrtc::MediaType::AUDIO) { + if (media_type() == MediaType::AUDIO) { // TODO(bugs.webrtc.org/11992): CreateVideoChannel internally switches to // the worker thread. We shouldn't be using the `call_ptr_` hack here but // simply be on the worker thread and use `call_` (update upstream code). @@ -252,7 +251,7 @@ RTCError RtpTransceiver::CreateChannel( context()->ssrc_generator()); }); } else { - RTC_DCHECK_EQ(webrtc::MediaType::VIDEO, media_type()); + RTC_DCHECK_EQ(MediaType::VIDEO, media_type()); // TODO(bugs.webrtc.org/11992): CreateVideoChannel internally switches to // the worker thread. We shouldn't be using the `call_ptr_` hack here but @@ -403,7 +402,7 @@ void RtpTransceiver::AddSender( RTC_DCHECK(!absl::c_linear_search(senders_, sender)); std::vector send_codecs = - media_type() == webrtc::MediaType::VIDEO + media_type() == MediaType::VIDEO ? codec_vendor().video_send_codecs().codecs() : codec_vendor().audio_send_codecs().codecs(); sender->internal()->SetSendCodecs(send_codecs); @@ -468,7 +467,7 @@ scoped_refptr RtpTransceiver::receiver_internal() const { return scoped_refptr(receivers_[0]->internal()); } -webrtc::MediaType RtpTransceiver::media_type() const { +MediaType RtpTransceiver::media_type() const { return media_type_; } @@ -678,10 +677,10 @@ RTCError RtpTransceiver::UpdateCodecPreferencesCaches( const std::vector& codecs) { // Get codec capabilities from media engine. std::vector send_codecs, recv_codecs; - if (media_type_ == webrtc::MediaType::AUDIO) { + if (media_type_ == MediaType::AUDIO) { send_codecs = codec_vendor().audio_send_codecs().codecs(); recv_codecs = codec_vendor().audio_recv_codecs().codecs(); - } else if (media_type_ == webrtc::MediaType::VIDEO) { + } else if (media_type_ == MediaType::VIDEO) { send_codecs = codec_vendor().video_send_codecs().codecs(); recv_codecs = codec_vendor().video_recv_codecs().codecs(); } diff --git a/pc/rtp_transceiver_unittest.cc b/pc/rtp_transceiver_unittest.cc index c9b42be8e0..0bb9c5824b 100644 --- a/pc/rtp_transceiver_unittest.cc +++ b/pc/rtp_transceiver_unittest.cc @@ -106,10 +106,9 @@ class RtpTransceiverTest : public testing::Test { TEST_F(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) { const std::string content_name("my_mid"); auto transceiver = make_ref_counted( - webrtc::MediaType::AUDIO, context(), codec_lookup_helper()); + MediaType::AUDIO, context(), codec_lookup_helper()); auto channel1 = std::make_unique>(); - EXPECT_CALL(*channel1, media_type()) - .WillRepeatedly(Return(webrtc::MediaType::AUDIO)); + EXPECT_CALL(*channel1, media_type()).WillRepeatedly(Return(MediaType::AUDIO)); EXPECT_CALL(*channel1, mid()).WillRepeatedly(ReturnRef(content_name)); EXPECT_CALL(*channel1, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(*channel1, SetRtpTransport(_)).WillRepeatedly(Return(true)); @@ -125,8 +124,7 @@ TEST_F(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) { EXPECT_EQ(channel1_ptr, transceiver->channel()); auto channel2 = std::make_unique>(); - EXPECT_CALL(*channel2, media_type()) - .WillRepeatedly(Return(webrtc::MediaType::AUDIO)); + EXPECT_CALL(*channel2, media_type()).WillRepeatedly(Return(MediaType::AUDIO)); // Clear the current channel - required to allow SetChannel() EXPECT_CALL(*channel1_ptr, SetFirstPacketReceivedCallback(_)); @@ -142,10 +140,9 @@ TEST_F(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) { TEST_F(RtpTransceiverTest, CanUnsetChannelOnStoppedTransceiver) { const std::string content_name("my_mid"); auto transceiver = make_ref_counted( - webrtc::MediaType::VIDEO, context(), codec_lookup_helper()); + MediaType::VIDEO, context(), codec_lookup_helper()); auto channel = std::make_unique>(); - EXPECT_CALL(*channel, media_type()) - .WillRepeatedly(Return(webrtc::MediaType::VIDEO)); + EXPECT_CALL(*channel, media_type()).WillRepeatedly(Return(MediaType::VIDEO)); EXPECT_CALL(*channel, mid()).WillRepeatedly(ReturnRef(content_name)); EXPECT_CALL(*channel, SetFirstPacketReceivedCallback(_)) .WillRepeatedly(testing::Return()); @@ -170,15 +167,14 @@ TEST_F(RtpTransceiverTest, CanUnsetChannelOnStoppedTransceiver) { class RtpTransceiverUnifiedPlanTest : public RtpTransceiverTest { public: static scoped_refptr MockReceiver( - webrtc::MediaType media_type) { + MediaType media_type) { auto receiver = make_ref_counted>(); EXPECT_CALL(*receiver.get(), media_type()) .WillRepeatedly(Return(media_type)); return receiver; } - static scoped_refptr MockSender( - webrtc::MediaType media_type) { + static scoped_refptr MockSender(MediaType media_type) { auto sender = make_ref_counted>(); EXPECT_CALL(*sender.get(), media_type()).WillRepeatedly(Return(media_type)); return sender; @@ -204,9 +200,8 @@ class RtpTransceiverUnifiedPlanTest : public RtpTransceiverTest { // Basic tests for Stop() TEST_F(RtpTransceiverUnifiedPlanTest, StopSetsDirection) { scoped_refptr receiver = - MockReceiver(webrtc::MediaType::AUDIO); - scoped_refptr sender = - MockSender(webrtc::MediaType::AUDIO); + MockReceiver(MediaType::AUDIO); + scoped_refptr sender = MockSender(MediaType::AUDIO); scoped_refptr transceiver = CreateTransceiver(sender, receiver); @@ -231,9 +226,8 @@ class RtpTransceiverFilteredCodecPreferencesTest : public RtpTransceiverUnifiedPlanTest { public: RtpTransceiverFilteredCodecPreferencesTest() - : transceiver_( - CreateTransceiver(MockSender(webrtc::MediaType::VIDEO), - MockReceiver(webrtc::MediaType::VIDEO))) {} + : transceiver_(CreateTransceiver(MockSender(MediaType::VIDEO), + MockReceiver(MediaType::VIDEO))) {} struct H264CodecCapabilities { Codec cricket_sendrecv_codec; @@ -251,8 +245,8 @@ class RtpTransceiverFilteredCodecPreferencesTest // at transceiver create time. void RecreateTransceiver() { fake_codec_lookup_helper()->Reset(); - transceiver_ = CreateTransceiver(MockSender(webrtc::MediaType::VIDEO), - MockReceiver(webrtc::MediaType::VIDEO)); + transceiver_ = CreateTransceiver(MockSender(MediaType::VIDEO), + MockReceiver(MediaType::VIDEO)); } // For H264, the profile and level IDs are entangled. This function uses @@ -596,9 +590,8 @@ class RtpTransceiverTestForHeaderExtensions } scoped_refptr receiver_ = - MockReceiver(webrtc::MediaType::AUDIO); - scoped_refptr sender_ = - MockSender(webrtc::MediaType::AUDIO); + MockReceiver(MediaType::AUDIO); + scoped_refptr sender_ = MockSender(MediaType::AUDIO); std::vector extensions_; scoped_refptr transceiver_; @@ -744,7 +737,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, auto mock_channel_ptr = mock_channel.get(); EXPECT_CALL(*mock_channel, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(*mock_channel, media_type()) - .WillRepeatedly(Return(webrtc::MediaType::AUDIO)); + .WillRepeatedly(Return(MediaType::AUDIO)); EXPECT_CALL(*mock_channel, voice_media_send_channel()) .WillRepeatedly(Return(nullptr)); EXPECT_CALL(*mock_channel, mid()).WillRepeatedly(ReturnRef(content_name)); @@ -777,7 +770,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, ReturnsNegotiatedHdrExts) { auto mock_channel_ptr = mock_channel.get(); EXPECT_CALL(*mock_channel, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(*mock_channel, media_type()) - .WillRepeatedly(Return(webrtc::MediaType::AUDIO)); + .WillRepeatedly(Return(MediaType::AUDIO)); EXPECT_CALL(*mock_channel, voice_media_send_channel()) .WillRepeatedly(Return(nullptr)); EXPECT_CALL(*mock_channel, mid()).WillRepeatedly(ReturnRef(content_name)); @@ -860,7 +853,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, Thread::Current(), Thread::Current(), receiver_), context(), codec_lookup_helper(), extensions, /* on_negotiation_needed= */ [] {}); - std::vector header_extensions = + std::vector header_extensions = transceiver->GetHeaderExtensionsToNegotiate(); ASSERT_EQ(header_extensions.size(), 2u); EXPECT_EQ(header_extensions[0].uri, RtpExtension::kDependencyDescriptorUri); @@ -894,7 +887,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, RtpTransceiverDirection::kSendRecv); // SVC, a single encoding with a scalabilityMode other than L1T1. - webrtc::RtpParameters svc_parameters; + RtpParameters svc_parameters; svc_parameters.encodings.resize(1); svc_parameters.encodings[0].scalability_mode = "L3T3"; @@ -908,7 +901,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, Thread::Current(), Thread::Current(), receiver_), context(), codec_lookup_helper(), extensions, /* on_negotiation_needed= */ [] {}); - std::vector svc_extensions = + std::vector svc_extensions = svc_transceiver->GetHeaderExtensionsToNegotiate(); ASSERT_EQ(svc_extensions.size(), 2u); EXPECT_EQ(svc_extensions[0].uri, RtpExtension::kDependencyDescriptorUri); diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index 8c6d2a8fa8..1779ad422c 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc @@ -172,10 +172,9 @@ RtpTransmissionManager::AddTrackPlanB( if (adjusted_stream_ids.empty()) { adjusted_stream_ids.push_back(CreateRandomUuid()); } - webrtc::MediaType media_type = - (track->kind() == MediaStreamTrackInterface::kAudioKind - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO); + MediaType media_type = (track->kind() == MediaStreamTrackInterface::kAudioKind + ? MediaType::AUDIO + : MediaType::VIDEO); auto new_sender = CreateSender( media_type, track->id(), track, adjusted_stream_ids, init_send_encodings @@ -213,7 +212,7 @@ RtpTransmissionManager::AddTrackUnifiedPlan( FindFirstTransceiverForAddedTrack(track, init_send_encodings); if (transceiver) { RTC_LOG(LS_INFO) << "Reusing an existing " - << webrtc::MediaTypeToString(transceiver->media_type()) + << MediaTypeToString(transceiver->media_type()) << " transceiver for AddTrack."; if (transceiver->stopping()) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, @@ -231,11 +230,11 @@ RtpTransmissionManager::AddTrackUnifiedPlan( transceiver->internal()->sender_internal()->set_stream_ids(stream_ids); transceiver->internal()->set_reused_for_addtrack(true); } else { - webrtc::MediaType media_type = + MediaType media_type = (track->kind() == MediaStreamTrackInterface::kAudioKind - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO); - RTC_LOG(LS_INFO) << "Adding " << webrtc::MediaTypeToString(media_type) + ? MediaType::AUDIO + : MediaType::VIDEO); + RTC_LOG(LS_INFO) << "Adding " << MediaTypeToString(media_type) << " transceiver in response to a call to AddTrack."; std::string sender_id = track->id(); // Avoid creating a sender with an existing ID by generating a random ID. @@ -259,14 +258,14 @@ RtpTransmissionManager::AddTrackUnifiedPlan( scoped_refptr> RtpTransmissionManager::CreateSender( - webrtc::MediaType media_type, + MediaType media_type, const std::string& id, scoped_refptr track, const std::vector& stream_ids, const std::vector& send_encodings) { RTC_DCHECK_RUN_ON(signaling_thread()); scoped_refptr> sender; - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { RTC_DCHECK(!track || (track->kind() == MediaStreamTrackInterface::kAudioKind)); sender = RtpSenderProxyWithInternal::Create( @@ -274,7 +273,7 @@ RtpTransmissionManager::CreateSender( AudioRtpSender::Create(env_, worker_thread(), id, legacy_stats_, this)); NoteUsageEvent(UsageEvent::AUDIO_ADDED); } else { - RTC_DCHECK_EQ(media_type, webrtc::MediaType::VIDEO); + RTC_DCHECK_EQ(media_type, MediaType::VIDEO); RTC_DCHECK(!track || (track->kind() == MediaStreamTrackInterface::kVideoKind)); sender = RtpSenderProxyWithInternal::Create( @@ -290,11 +289,11 @@ RtpTransmissionManager::CreateSender( } scoped_refptr> -RtpTransmissionManager::CreateReceiver(webrtc::MediaType media_type, +RtpTransmissionManager::CreateReceiver(MediaType media_type, const std::string& receiver_id) { RTC_DCHECK_RUN_ON(signaling_thread()); scoped_refptr> receiver; - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { receiver = RtpReceiverProxyWithInternal::Create( signaling_thread(), worker_thread(), make_ref_counted(worker_thread(), receiver_id, @@ -302,7 +301,7 @@ RtpTransmissionManager::CreateReceiver(webrtc::MediaType media_type, IsUnifiedPlan())); NoteUsageEvent(UsageEvent::AUDIO_ADDED); } else { - RTC_DCHECK_EQ(media_type, webrtc::MediaType::VIDEO); + RTC_DCHECK_EQ(media_type, MediaType::VIDEO); receiver = RtpReceiverProxyWithInternal::Create( signaling_thread(), worker_thread(), make_ref_counted(worker_thread(), receiver_id, @@ -326,7 +325,7 @@ RtpTransmissionManager::CreateAndAddTransceiver( signaling_thread(), make_ref_counted( sender, receiver, context_, codec_lookup_helper_, - sender->media_type() == webrtc::MediaType::AUDIO + sender->media_type() == MediaType::AUDIO ? media_engine()->voice().GetRtpHeaderExtensions() : media_engine()->video().GetRtpHeaderExtensions(), [this_weak_ptr = weak_ptr_factory_.GetWeakPtr()]() { @@ -349,7 +348,7 @@ RtpTransmissionManager::FindFirstTransceiverForAddedTrack( } for (auto transceiver : transceivers()->List()) { if (!transceiver->sender()->track() && - webrtc::MediaTypeToString(transceiver->media_type()) == track->kind() && + MediaTypeToString(transceiver->media_type()) == track->kind() && !transceiver->internal()->has_ever_been_used_to_send() && !transceiver->stopped()) { return transceiver; @@ -396,7 +395,7 @@ RtpTransmissionManager::GetAudioTransceiver() const { // audio/video transceiver. RTC_DCHECK(!IsUnifiedPlan()); for (auto transceiver : transceivers_.List()) { - if (transceiver->media_type() == webrtc::MediaType::AUDIO) { + if (transceiver->media_type() == MediaType::AUDIO) { return transceiver; } } @@ -411,7 +410,7 @@ RtpTransmissionManager::GetVideoTransceiver() const { // audio/video transceiver. RTC_DCHECK(!IsUnifiedPlan()); for (auto transceiver : transceivers_.List()) { - if (transceiver->media_type() == webrtc::MediaType::VIDEO) { + if (transceiver->media_type() == MediaType::VIDEO) { return transceiver; } } @@ -433,7 +432,7 @@ void RtpTransmissionManager::AddAudioTrack(AudioTrackInterface* track, } // Normal case; we've never seen this track before. - auto new_sender = CreateSender(webrtc::MediaType::AUDIO, track->id(), + auto new_sender = CreateSender(MediaType::AUDIO, track->id(), scoped_refptr(track), {stream->id()}, {{}}); new_sender->internal()->SetMediaChannel(voice_media_send_channel()); @@ -480,7 +479,7 @@ void RtpTransmissionManager::AddVideoTrack(VideoTrackInterface* track, } // Normal case; we've never seen this track before. - auto new_sender = CreateSender(webrtc::MediaType::VIDEO, track->id(), + auto new_sender = CreateSender(MediaType::VIDEO, track->id(), scoped_refptr(track), {stream->id()}, {{}}); new_sender->internal()->SetMediaChannel(video_media_send_channel()); @@ -564,7 +563,7 @@ RtpTransmissionManager::RemoveAndStopReceiver( << remote_sender_info.sender_id << " doesn't exist."; return nullptr; } - if (receiver->media_type() == webrtc::MediaType::AUDIO) { + if (receiver->media_type() == MediaType::AUDIO) { GetAudioTransceiver()->internal()->RemoveReceiver(receiver.get()); } else { GetVideoTransceiver()->internal()->RemoveReceiver(receiver.get()); @@ -575,15 +574,15 @@ RtpTransmissionManager::RemoveAndStopReceiver( void RtpTransmissionManager::OnRemoteSenderAdded( const RtpSenderInfo& sender_info, MediaStreamInterface* stream, - webrtc::MediaType media_type) { + MediaType media_type) { RTC_DCHECK_RUN_ON(signaling_thread()); - RTC_LOG(LS_INFO) << "Creating " << webrtc::MediaTypeToString(media_type) + RTC_LOG(LS_INFO) << "Creating " << MediaTypeToString(media_type) << " receiver for track_id=" << sender_info.sender_id << " and stream_id=" << sender_info.stream_id; - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { CreateAudioReceiver(stream, sender_info); - } else if (media_type == webrtc::MediaType::VIDEO) { + } else if (media_type == MediaType::VIDEO) { CreateVideoReceiver(stream, sender_info); } else { RTC_DCHECK_NOTREACHED() << "Invalid media type"; @@ -593,14 +592,14 @@ void RtpTransmissionManager::OnRemoteSenderAdded( void RtpTransmissionManager::OnRemoteSenderRemoved( const RtpSenderInfo& sender_info, MediaStreamInterface* stream, - webrtc::MediaType media_type) { + MediaType media_type) { RTC_DCHECK_RUN_ON(signaling_thread()); - RTC_LOG(LS_INFO) << "Removing " << webrtc::MediaTypeToString(media_type) + RTC_LOG(LS_INFO) << "Removing " << MediaTypeToString(media_type) << " receiver for track_id=" << sender_info.sender_id << " and stream_id=" << sender_info.stream_id; scoped_refptr receiver; - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { // When the MediaEngine audio channel is destroyed, the RemoteAudioSource // will be notified which will end the AudioRtpReceiver::track(). receiver = RemoveAndStopReceiver(sender_info); @@ -609,7 +608,7 @@ void RtpTransmissionManager::OnRemoteSenderRemoved( if (audio_track) { stream->RemoveTrack(audio_track); } - } else if (media_type == webrtc::MediaType::VIDEO) { + } else if (media_type == MediaType::VIDEO) { // Stopping or destroying a VideoRtpReceiver will end the // VideoRtpReceiver::track(). receiver = RemoveAndStopReceiver(sender_info); @@ -631,7 +630,7 @@ void RtpTransmissionManager::OnRemoteSenderRemoved( void RtpTransmissionManager::OnLocalSenderAdded( const RtpSenderInfo& sender_info, - webrtc::MediaType media_type) { + MediaType media_type) { RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(!IsUnifiedPlan()); auto sender = FindSenderById(sender_info.sender_id); @@ -654,7 +653,7 @@ void RtpTransmissionManager::OnLocalSenderAdded( void RtpTransmissionManager::OnLocalSenderRemoved( const RtpSenderInfo& sender_info, - webrtc::MediaType media_type) { + MediaType media_type) { RTC_DCHECK_RUN_ON(signaling_thread()); auto sender = FindSenderById(sender_info.sender_id); if (!sender) { @@ -676,19 +675,17 @@ void RtpTransmissionManager::OnLocalSenderRemoved( } std::vector* RtpTransmissionManager::GetRemoteSenderInfos( - webrtc::MediaType media_type) { - RTC_DCHECK(media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO); - return (media_type == webrtc::MediaType::AUDIO) ? &remote_audio_sender_infos_ - : &remote_video_sender_infos_; + MediaType media_type) { + RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO); + return (media_type == MediaType::AUDIO) ? &remote_audio_sender_infos_ + : &remote_video_sender_infos_; } std::vector* RtpTransmissionManager::GetLocalSenderInfos( - webrtc::MediaType media_type) { - RTC_DCHECK(media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO); - return (media_type == webrtc::MediaType::AUDIO) ? &local_audio_sender_infos_ - : &local_video_sender_infos_; + MediaType media_type) { + RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO); + return (media_type == MediaType::AUDIO) ? &local_audio_sender_infos_ + : &local_video_sender_infos_; } const RtpSenderInfo* RtpTransmissionManager::FindSenderInfo( diff --git a/pc/rtp_transport.cc b/pc/rtp_transport.cc index 2ab4ef55a7..b0cef00f74 100644 --- a/pc/rtp_transport.cc +++ b/pc/rtp_transport.cc @@ -205,7 +205,7 @@ flat_set RtpTransport::GetSsrcsForSink(RtpPacketSinkInterface* sink) { } void RtpTransport::DemuxPacket(CopyOnWriteBuffer packet, - webrtc::Timestamp arrival_time, + Timestamp arrival_time, EcnMarking ecn) { RtpPacketReceived parsed_packet(&header_extension_map_); parsed_packet.set_arrival_time(arrival_time); diff --git a/pc/rtp_transport_unittest.cc b/pc/rtp_transport_unittest.cc index c4d207d6c4..b5fe2296bc 100644 --- a/pc/rtp_transport_unittest.cc +++ b/pc/rtp_transport_unittest.cc @@ -411,7 +411,7 @@ TEST(RtpTransportTest, RecursiveSetSendDoesNotCrash) { // After the wait, the ready-to-send false is observed. EXPECT_THAT(WaitUntil([&] { return observer.ready_to_send_signal_count(); }, ::testing::Eq(2), - {.timeout = webrtc::TimeDelta::Millis(kShortTimeout)}), + {.timeout = TimeDelta::Millis(kShortTimeout)}), IsRtcOk()); EXPECT_FALSE(observer.ready_to_send()); } @@ -439,7 +439,7 @@ TEST(RtpTransportTest, RecursiveOnSentPacketDoesNotCrash) { EXPECT_EQ(observer.sent_packet_count(), 1); EXPECT_THAT( WaitUntil([&] { return observer.sent_packet_count(); }, ::testing::Eq(2), - {.timeout = webrtc::TimeDelta::Millis(kShortTimeout)}), + {.timeout = TimeDelta::Millis(kShortTimeout)}), IsRtcOk()); } diff --git a/pc/scenario_tests/goog_cc_test.cc b/pc/scenario_tests/goog_cc_test.cc index 2e8ff64e8f..057267c7f9 100644 --- a/pc/scenario_tests/goog_cc_test.cc +++ b/pc/scenario_tests/goog_cc_test.cc @@ -74,7 +74,7 @@ TEST(GoogCcPeerScenarioTest, MAYBE_NoBweChangeFromVideoUnmute) { ASSERT_EQ(num_video_streams, 1); // Exactly 1 video stream. auto get_bwe = [&] { - auto callback = make_ref_counted(); + auto callback = make_ref_counted(); caller->pc()->GetStats(callback.get()); s.net()->time_controller()->Wait([&] { return callback->called(); }); auto stats = diff --git a/pc/sctp_utils.cc b/pc/sctp_utils.cc index bc248cd2c3..edf15721ea 100644 --- a/pc/sctp_utils.cc +++ b/pc/sctp_utils.cc @@ -197,7 +197,7 @@ bool WriteDataChannelOpenMessage(const std::string& label, } } - ByteBufferWriter buffer(NULL, 20 + label.length() + protocol.length()); + ByteBufferWriter buffer(nullptr, 20 + label.length() + protocol.length()); // TODO(tommi): Add error handling and check resulting length. buffer.WriteUInt8(DATA_CHANNEL_OPEN_MESSAGE_TYPE); buffer.WriteUInt8(channel_type); diff --git a/pc/sdp_munging_detector.cc b/pc/sdp_munging_detector.cc index 2497a3066d..95e29d575d 100644 --- a/pc/sdp_munging_detector.cc +++ b/pc/sdp_munging_detector.cc @@ -279,6 +279,22 @@ SdpMungingType DetermineVideoSdpMungingType( } if (last_created_media_description->codecs().size() < media_description_to_set->codecs().size()) { + // Nonstandard a=packetization:raw + bool created_raw_packetization = + absl::c_find_if(last_created_media_description->codecs(), + [](const Codec codec) { + return codec.packetization.has_value(); + }) != last_created_media_description->codecs().end(); + bool set_raw_packetization = + absl::c_find_if(media_description_to_set->codecs(), + [](const Codec codec) { + return codec.packetization.has_value(); + }) != media_description_to_set->codecs().end(); + if (!created_raw_packetization && set_raw_packetization) { + RTC_LOG(LS_WARNING) + << "SDP munging: video codecs with raw packetization added."; + return SdpMungingType::kVideoCodecsAddedWithRawPacketization; + } RTC_LOG(LS_WARNING) << "SDP munging: video codecs added."; return SdpMungingType::kVideoCodecsAdded; } @@ -391,14 +407,14 @@ SdpMungingType DetermineSdpMungingType( continue; } // Validate video and audio contents. - webrtc::MediaType media_type = last_created_media_description->type(); - if (media_type == webrtc::MediaType::VIDEO) { + MediaType media_type = last_created_media_description->type(); + if (media_type == MediaType::VIDEO) { type = DetermineVideoSdpMungingType(last_created_media_description, media_description_to_set); if (type != SdpMungingType::kNoModification) { return type; } - } else if (media_type == webrtc::MediaType::AUDIO) { + } else if (media_type == MediaType::AUDIO) { type = DetermineAudioSdpMungingType(last_created_media_description, media_description_to_set); if (type != SdpMungingType::kNoModification) { @@ -418,7 +434,7 @@ SdpMungingType DetermineSdpMungingType( // Codec position swapped. for (size_t j = i + 1; j < last_created_codecs.size(); j++) { if (last_created_codecs[i] == codecs_to_set[j]) { - return media_type == webrtc::MediaType::AUDIO + return media_type == MediaType::AUDIO ? SdpMungingType::kAudioCodecsReordered : SdpMungingType::kVideoCodecsReordered; } @@ -429,21 +445,33 @@ SdpMungingType DetermineSdpMungingType( return SdpMungingType::kPayloadTypes; } if (last_created_codecs[i].params != codecs_to_set[i].params) { - return media_type == webrtc::MediaType::AUDIO + return media_type == MediaType::AUDIO ? SdpMungingType::kAudioCodecsFmtp : SdpMungingType::kVideoCodecsFmtp; } if (last_created_codecs[i].feedback_params != codecs_to_set[i].feedback_params) { - return media_type == webrtc::MediaType::AUDIO + return media_type == MediaType::AUDIO ? SdpMungingType::kAudioCodecsRtcpFb : SdpMungingType::kVideoCodecsRtcpFb; } + // Nonstandard a=packetization:raw added by munging + if (media_type == MediaType::VIDEO && + last_created_codecs[i].packetization != + codecs_to_set[i].packetization) { + return SdpMungingType::kVideoCodecsModifiedWithRawPacketization; + } // At this point clockrate or channels changed. This should already be // rejected later in the process so ignore for munging. } } + if (last_created_media_description->direction() != + media_description_to_set->direction()) { + RTC_LOG(LS_WARNING) << "SDP munging: transceiver direction modified."; + return SdpMungingType::kDirection; + } + // Validate media streams. if (last_created_media_description->streams().size() != media_description_to_set->streams().size()) { diff --git a/pc/sdp_munging_detector_unittest.cc b/pc/sdp_munging_detector_unittest.cc new file mode 100644 index 0000000000..caf28dd5f2 --- /dev/null +++ b/pc/sdp_munging_detector_unittest.cc @@ -0,0 +1,1226 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_replace.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "api/audio_codecs/audio_format.h" +#include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/create_peerconnection_factory.h" +#include "api/field_trials.h" +#include "api/field_trials_view.h" +#include "api/jsep.h" +#include "api/media_types.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/rtp_parameters.h" +#include "api/rtp_transceiver_direction.h" +#include "api/scoped_refptr.h" +#include "api/test/rtc_error_matchers.h" +#include "api/uma_metrics.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_decoder_factory_template.h" +#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h" +#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h" +#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h" +#include "api/video_codecs/video_decoder_factory_template_open_h264_adapter.h" +#include "api/video_codecs/video_encoder_factory_template.h" +#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h" +#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h" +#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h" +#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h" +#include "media/base/codec.h" +#include "media/base/media_constants.h" +#include "media/base/stream_params.h" +#include "p2p/base/transport_description.h" +#include "pc/peer_connection_wrapper.h" +#include "pc/test/fake_audio_capture_module.h" +#include "pc/test/fake_rtc_certificate_generator.h" +#include "pc/test/integration_test_helpers.h" +#include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/strings/string_format.h" +#include "rtc_base/thread.h" +#include "system_wrappers/include/metrics.h" +#include "test/gmock.h" +#include "test/gtest.h" +#include "test/wait_until.h" + +// This file contains unit tests that relate to the behavior of the +// SDP munging detector module. +// Tests are written as integration tests with PeerConnection, since the +// behaviors are still linked so closely that it is hard to test them in +// isolation. + +namespace webrtc { + +using ::testing::Eq; +using ::testing::IsTrue; +using ::testing::Pair; + +namespace { + +std::unique_ptr CreateAndStartThread() { + auto thread = Thread::Create(); + thread->Start(); + return thread; +} + +} // namespace + +class SdpMungingTest : public ::testing::Test { + public: + SdpMungingTest() + // Note: We use a PeerConnectionFactory with a distinct + // signaling thread, so that thread handling can be tested. + : signaling_thread_(CreateAndStartThread()), + pc_factory_(CreatePeerConnectionFactory( + nullptr, + nullptr, + signaling_thread_.get(), + FakeAudioCaptureModule::Create(), + CreateBuiltinAudioEncoderFactory(), + CreateBuiltinAudioDecoderFactory(), + std::make_unique< + VideoEncoderFactoryTemplate>(), + std::make_unique< + VideoDecoderFactoryTemplate>(), + nullptr /* audio_mixer */, + nullptr /* audio_processing */, + nullptr /* audio_frame_processor */)) { + metrics::Reset(); + } + + std::unique_ptr CreatePeerConnection( + std::unique_ptr field_trials = nullptr) { + RTCConfiguration config; + config.sdp_semantics = SdpSemantics::kUnifiedPlan; + return CreatePeerConnection(config, std::move(field_trials)); + } + + std::unique_ptr CreatePeerConnection( + const RTCConfiguration& config, + std::unique_ptr field_trials) { + auto observer = std::make_unique(); + PeerConnectionDependencies pc_deps(observer.get()); + pc_deps.trials = std::move(field_trials); + auto result = + pc_factory_->CreatePeerConnectionOrError(config, std::move(pc_deps)); + EXPECT_TRUE(result.ok()); + observer->SetPeerConnectionInterface(result.value().get()); + return std::make_unique( + pc_factory_, result.MoveValue(), std::move(observer)); + } + + protected: + std::unique_ptr signaling_thread_; + scoped_refptr pc_factory_; + + private: + AutoThread main_thread_; +}; + +TEST_F(SdpMungingTest, DISABLED_ReportUMAMetricsWithNoMunging) { + auto caller = CreatePeerConnection(); + auto callee = CreatePeerConnection(); + + caller->AddTransceiver(MediaType::AUDIO); + caller->AddTransceiver(MediaType::VIDEO); + + // Negotiate, gather candidates, then exchange ICE candidates. + ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kNoModification, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Answer.Initial"), + ElementsAre(Pair(SdpMungingType::kNoModification, 1))); + + EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); }, IsTrue(), + {.timeout = kDefaultTimeout}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee->IsIceGatheringDone(); }, IsTrue(), + {.timeout = kDefaultTimeout}), + IsRtcOk()); + for (const auto& candidate : caller->observer()->GetAllCandidates()) { + callee->pc()->AddIceCandidate(candidate); + } + for (const auto& candidate : callee->observer()->GetAllCandidates()) { + caller->pc()->AddIceCandidate(candidate); + } + EXPECT_THAT( + WaitUntil([&] { return caller->pc()->peer_connection_state(); }, + Eq(PeerConnectionInterface::PeerConnectionState::kConnected), + {.timeout = kDefaultTimeout}), + IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return callee->pc()->peer_connection_state(); }, + Eq(PeerConnectionInterface::PeerConnectionState::kConnected), + {.timeout = kDefaultTimeout}), + IsRtcOk()); + + caller->pc()->Close(); + callee->pc()->Close(); + + EXPECT_THAT( + metrics::Samples( + "WebRTC.PeerConnection.SdpMunging.Offer.ConnectionEstablished"), + ElementsAre(Pair(SdpMungingType::kNoModification, 1))); + EXPECT_THAT( + metrics::Samples( + "WebRTC.PeerConnection.SdpMunging.Answer.ConnectionEstablished"), + ElementsAre(Pair(SdpMungingType::kNoModification, 1))); + + EXPECT_THAT(metrics::Samples( + "WebRTC.PeerConnection.SdpMunging.Offer.ConnectionClosed"), + ElementsAre(Pair(SdpMungingType::kNoModification, 1))); + EXPECT_THAT(metrics::Samples( + "WebRTC.PeerConnection.SdpMunging.Answer.ConnectionClosed"), + ElementsAre(Pair(SdpMungingType::kNoModification, 1))); +} + +TEST_F(SdpMungingTest, InitialSetLocalDescriptionWithoutCreateOffer) { + RTCConfiguration config; + config.certificates.push_back( + FakeRTCCertificateGenerator::GenerateCertificate()); + auto pc = CreatePeerConnection(config, nullptr); + std::string sdp = + "v=0\r\n" + "o=- 0 3 IN IP4 127.0.0.1\r\n" + "s=-\r\n" + "t=0 0\r\n" + "a=fingerprint:sha-1 " + "D9:AB:00:AA:12:7B:62:54:CF:AD:3B:55:F7:60:BC:F3:40:A7:0B:5B\r\n" + "a=setup:actpass\r\n" + "a=ice-ufrag:ETEn\r\n" + "a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n"; + auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kWithoutCreateOffer, 1))); +} + +TEST_F(SdpMungingTest, InitialSetLocalDescriptionWithoutCreateAnswer) { + RTCConfiguration config; + config.certificates.push_back( + FakeRTCCertificateGenerator::GenerateCertificate()); + auto pc = CreatePeerConnection(config, nullptr); + std::string sdp = + "v=0\r\n" + "o=- 0 3 IN IP4 127.0.0.1\r\n" + "s=-\r\n" + "t=0 0\r\n" + "a=fingerprint:sha-1 " + "D9:AB:00:AA:12:7B:62:54:CF:AD:3B:55:F7:60:BC:F3:40:A7:0B:5B\r\n" + "a=setup:actpass\r\n" + "a=ice-ufrag:ETEn\r\n" + "a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n" + "m=audio 9 UDP/TLS/RTP/SAVPF 111\r\n" + "c=IN IP4 0.0.0.0\r\n" + "a=rtcp-mux\r\n" + "a=sendrecv\r\n" + "a=mid:0\r\n" + "a=rtpmap:111 opus/48000/2\r\n"; + auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); + + RTCError error; + auto answer = CreateSessionDescription(SdpType::kAnswer, sdp); + answer->description()->transport_infos()[0].description.connection_role = + CONNECTIONROLE_ACTIVE; + EXPECT_TRUE(pc->SetLocalDescription(std::move(answer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Answer.Initial"), + ElementsAre(Pair(SdpMungingType::kWithoutCreateAnswer, 1))); +} + +TEST_F(SdpMungingTest, IceUfrag) { + auto pc = CreatePeerConnection( + FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Enabled/")); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_ufrag = + "amungediceufragthisshouldberejected"; + RTCError error; + // Ufrag is rejected. + EXPECT_FALSE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.SdpOutcome.Rejected"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Outcome"), + ElementsAre(Pair(static_cast(SdpMungingOutcome::kRejected), 1))); +} + +TEST_F(SdpMungingTest, IceUfragCheckDisabledByFieldTrial) { + auto pc = CreatePeerConnection( + FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Disabled/")); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_ufrag = + "amungediceufragthisshouldberejected"; + RTCError error; + // Ufrag is not rejected. + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.SdpOutcome.Accepted"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Outcome"), + ElementsAre(Pair(static_cast(SdpMungingOutcome::kAccepted), 1))); +} + +TEST_F(SdpMungingTest, IceUfragWithCheckDisabledForTesting) { + auto pc = CreatePeerConnection(); + pc->GetInternalPeerConnection()->DisableSdpMungingChecksForTesting(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_ufrag = + "amungediceufragthisshouldberejected"; + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); +} + +TEST_F(SdpMungingTest, IcePwdCheckDisabledByFieldTrial) { + auto pc = CreatePeerConnection( + FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Disabled/")); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_pwd = "amungedicepwdthisshouldberejected"; + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIcePwd, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.SdpOutcome.Accepted"), + ElementsAre(Pair(SdpMungingType::kIcePwd, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Outcome"), + ElementsAre(Pair(static_cast(SdpMungingOutcome::kAccepted), 1))); +} + +TEST_F(SdpMungingTest, IcePwd) { + auto pc = CreatePeerConnection( + FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Enabled/")); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_pwd = "amungedicepwdthisshouldberejected"; + RTCError error; + EXPECT_FALSE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIcePwd, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.SdpOutcome.Rejected"), + ElementsAre(Pair(SdpMungingType::kIcePwd, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Outcome"), + ElementsAre(Pair(static_cast(SdpMungingOutcome::kRejected), 1))); +} + +TEST_F(SdpMungingTest, IceUfragRestrictedAddresses) { + RTCConfiguration config; + config.certificates.push_back( + FakeRTCCertificateGenerator::GenerateCertificate()); + auto caller = CreatePeerConnection( + config, + FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfragRestrictedAddresses/" + "127.0.0.1:12345|127.0.0.*:23456|*:34567/")); + auto callee = CreatePeerConnection(); + caller->AddAudioTrack("audio_track", {}); + auto offer = caller->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_ufrag = "amungediceufrag"; + + EXPECT_TRUE(caller->SetLocalDescription(offer->Clone())); + EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); + + auto answer = callee->CreateAnswer(); + EXPECT_TRUE(callee->SetLocalDescription(answer->Clone())); + EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); + + static constexpr const char tmpl[] = + "candidate:a0+B/1 1 udp 2130706432 %s typ host"; + + // Addresses to test. First field is the address in string format, + // second field is the expected outcome (success or failure). + const std::vector> address_tests = { + {"127.0.0.1:12345", false}, {"127.0.0.2:23456", false}, + {"8.8.8.8:34567", false}, {"127.0.0.2:12345", true}, + {"127.0.1.1:23456", true}, {"8.8.8.8:3456", true}, + }; + + int num_blocked = 0; + for (const auto& address_test : address_tests) { + std::optional result; + const std::string candidate = StringFormat( + tmpl, absl::StrReplaceAll(address_test.first, {{":", " "}}).c_str()); + caller->pc()->AddIceCandidate( + std::unique_ptr( + CreateIceCandidate("", 0, candidate, nullptr)), + [&result](RTCError error) { result = error; }); + + ASSERT_THAT( + WaitUntil([&] { return result.has_value(); }, ::testing::IsTrue()), + IsRtcOk()); + if (address_test.second == true) { + EXPECT_TRUE(result.value().ok()); + } else { + std::pair host = + absl::StrSplit(address_test.first, ":"); + int port; + ASSERT_TRUE(absl::SimpleAtoi(host.second, &port)); + EXPECT_FALSE(result.value().ok()); + EXPECT_EQ(result.value().type(), RTCErrorType::UNSUPPORTED_OPERATION); + num_blocked++; + EXPECT_THAT( + metrics::Samples( + "WebRTC.PeerConnection.RestrictedCandidates.SdpMungingType"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, num_blocked))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.RestrictedCandidates.Port"), + Contains(Pair(port, 1))); + } + } +} + +TEST_F(SdpMungingTest, IceUfragSdpRejectedAndRestrictedAddresses) { + RTCConfiguration config; + config.certificates.push_back( + FakeRTCCertificateGenerator::GenerateCertificate()); + auto caller = CreatePeerConnection( + config, + FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfragRestrictedAddresses/" + "127.0.0.1:12345|127.0.0.*:23456|*:34567/" + "WebRTC-NoSdpMangleUfrag/Enabled/")); + auto callee = CreatePeerConnection(); + caller->AddAudioTrack("audio_track", {}); + auto offer = caller->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_ufrag = "amungediceufrag"; + + EXPECT_FALSE(caller->SetLocalDescription(offer->Clone())); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.SdpOutcome.Rejected"), + ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Outcome"), + ElementsAre(Pair(static_cast(SdpMungingOutcome::kRejected), 1))); +} + +TEST_F(SdpMungingTest, IceMode) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.ice_mode = ICEMODE_LITE; + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceMode, 1))); +} + +TEST_F(SdpMungingTest, IceOptions) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.transport_options.push_back( + "something-unsupported"); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceOptions, 1))); +} + +TEST_F(SdpMungingTest, IceOptionsRenomination) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.transport_options.push_back( + ICE_OPTION_RENOMINATION); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceOptionsRenomination, 1))); +} + +TEST_F(SdpMungingTest, DtlsRole) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].description.connection_role = CONNECTIONROLE_PASSIVE; + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kDtlsSetup, 1))); +} + +TEST_F(SdpMungingTest, RemoveContentDefault) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto name = contents[0].mid(); + EXPECT_TRUE(offer->description()->RemoveContentByName(contents[0].mid())); + std::string sdp; + offer->ToString(&sdp); + auto modified_offer = CreateSessionDescription( + SdpType::kOffer, + absl::StrReplaceAll(sdp, {{"a=group:BUNDLE " + name, "a=group:BUNDLE"}})); + + RTCError error; + EXPECT_FALSE(pc->SetLocalDescription(std::move(modified_offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kNumberOfContents, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.SdpOutcome.Rejected"), + ElementsAre(Pair(SdpMungingType::kNumberOfContents, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Outcome"), + ElementsAre(Pair(static_cast(SdpMungingOutcome::kRejected), 1))); +} + +TEST_F(SdpMungingTest, RemoveContentKillswitch) { + auto pc = CreatePeerConnection(FieldTrials::CreateNoGlobal( + "WebRTC-NoSdpMangleNumberOfContents/Disabled/")); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto name = contents[0].mid(); + EXPECT_TRUE(offer->description()->RemoveContentByName(contents[0].mid())); + std::string sdp; + offer->ToString(&sdp); + auto modified_offer = CreateSessionDescription( + SdpType::kOffer, + absl::StrReplaceAll(sdp, {{"a=group:BUNDLE " + name, "a=group:BUNDLE"}})); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(modified_offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kNumberOfContents, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.SdpOutcome.Accepted"), + ElementsAre(Pair(SdpMungingType::kNumberOfContents, 1))); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Outcome"), + ElementsAre(Pair(static_cast(SdpMungingOutcome::kAccepted), 1))); +} + +TEST_F(SdpMungingTest, TransceiverDirection) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto direction = media_description->direction(); + if (direction == RtpTransceiverDirection::kInactive) { + media_description->set_direction(RtpTransceiverDirection::kSendRecv); + } else { + media_description->set_direction(RtpTransceiverDirection::kInactive); + } + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kDirection, 1))); +} + +TEST_F(SdpMungingTest, Mid) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + std::string name(contents[0].mid()); + contents[0].set_mid("amungedmid"); + + auto& transport_infos = offer->description()->transport_infos(); + ASSERT_EQ(transport_infos.size(), 1u); + transport_infos[0].content_name = "amungedmid"; + std::string sdp; + offer->ToString(&sdp); + auto modified_offer = CreateSessionDescription( + SdpType::kOffer, + absl::StrReplaceAll( + sdp, {{"a=group:BUNDLE " + name, "a=group:BUNDLE amungedmid"}})); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(modified_offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kMid, 1))); +} + +TEST_F(SdpMungingTest, LegacySimulcast) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + uint32_t ssrc = media_description->first_ssrc(); + ASSERT_EQ(media_description->streams().size(), 1u); + const std::string& cname = media_description->streams()[0].cname; + + std::string sdp; + offer->ToString(&sdp); + sdp += "a=ssrc-group:SIM " + absl::StrCat(ssrc) + " " + + absl::StrCat(ssrc + 1) + "\r\n" + // + "a=ssrc-group:FID " + absl::StrCat(ssrc + 1) + " " + + absl::StrCat(ssrc + 2) + "\r\n" + // + "a=ssrc:" + absl::StrCat(ssrc + 1) + " msid:- video_track\r\n" + // + "a=ssrc:" + absl::StrCat(ssrc + 1) + " cname:" + cname + "\r\n" + // + "a=ssrc:" + absl::StrCat(ssrc + 2) + " msid:- video_track\r\n" + // + "a=ssrc:" + absl::StrCat(ssrc + 2) + " cname:" + cname + "\r\n"; + auto modified_offer = CreateSessionDescription(SdpType::kOffer, sdp); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(modified_offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kVideoCodecsLegacySimulcast, 1))); +} + +#ifdef WEBRTC_USE_H264 +TEST_F(SdpMungingTest, H264SpsPpsIdrInKeyFrame) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + for (auto& codec : codecs) { + if (codec.name == webrtc::kH264CodecName) { + codec.SetParam(webrtc::kH264FmtpSpsPpsIdrInKeyframe, + webrtc::kParamValueTrue); + } + } + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre( + Pair(SdpMungingType::kVideoCodecsFmtpH264SpsPpsIdrInKeyframe, 1))); +} +#endif // WEBRTC_USE_H264 + +TEST_F(SdpMungingTest, OpusStereo) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + for (auto& codec : codecs) { + if (codec.name == kOpusCodecName) { + codec.SetParam(kCodecParamStereo, kParamValueTrue); + } + } + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusStereo, 1))); +} + +TEST_F(SdpMungingTest, OpusFec) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + for (auto& codec : codecs) { + if (codec.name == kOpusCodecName) { + // Enabled by default so we need to remove the parameter. + EXPECT_TRUE(codec.RemoveParam(kCodecParamUseInbandFec)); + } + } + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusFec, 1))); +} + +TEST_F(SdpMungingTest, OpusDtx) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + for (auto& codec : codecs) { + if (codec.name == kOpusCodecName) { + codec.SetParam(kCodecParamUseDtx, kParamValueTrue); + } + } + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusDtx, 1))); +} + +TEST_F(SdpMungingTest, OpusCbr) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + for (auto& codec : codecs) { + if (codec.name == kOpusCodecName) { + codec.SetParam(kCodecParamCbr, kParamValueTrue); + } + } + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusCbr, 1))); +} + +TEST_F(SdpMungingTest, AudioCodecsRemoved) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + codecs.pop_back(); + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsRemoved, 1))); +} + +TEST_F(SdpMungingTest, AudioCodecsAdded) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + auto codec = CreateAudioCodec(SdpAudioFormat("pcmu", 8000, 1, {})); + codec.id = 19; // IANA reserved payload type, should not conflict. + codecs.push_back(codec); + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsAdded, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsRemoved) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + codecs.pop_back(); + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kVideoCodecsRemoved, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsAdded) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + auto codec = CreateVideoCodec(SdpVideoFormat("VP8", {})); + codec.id = 19; // IANA reserved payload type, should not conflict. + codecs.push_back(codec); + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kVideoCodecsAdded, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsAddedWithRawPacketization) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + auto codec = CreateVideoCodec(SdpVideoFormat("VP8", {})); + codec.id = 19; // IANA reserved payload type, should not conflict. + codec.packetization = "raw"; + codecs.push_back(codec); + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre( + Pair(SdpMungingType::kVideoCodecsAddedWithRawPacketization, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsModifiedWithRawPacketization) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + ASSERT_TRUE(!codecs.empty()); + codecs[0].packetization = "raw"; + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre( + Pair(SdpMungingType::kVideoCodecsModifiedWithRawPacketization, 1))); +} + +TEST_F(SdpMungingTest, MultiOpus) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + auto multiopus = + CreateAudioCodec(SdpAudioFormat("multiopus", 48000, 4, + {{"channel_mapping", "0,1,2,3"}, + {"coupled_streams", "2"}, + {"num_streams", "2"}})); + multiopus.id = 19; // IANA reserved payload type, should not conflict. + codecs.push_back(multiopus); + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsAddedMultiOpus, 1))); +} + +TEST_F(SdpMungingTest, L16) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + std::vector codecs = media_description->codecs(); + auto l16 = CreateAudioCodec(SdpAudioFormat("L16", 48000, 2, {})); + l16.id = 19; // IANA reserved payload type, should not conflict. + codecs.push_back(l16); + media_description->set_codecs(codecs); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsAddedL16, 1))); +} + +TEST_F(SdpMungingTest, AudioSsrc) { + // Note: same applies to video but is harder to write since one needs to + // modify the ssrc-group too. + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + ASSERT_EQ(media_description->streams().size(), 1u); + media_description->mutable_streams()[0].ssrcs[0] = 4404; + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kSsrcs, 1))); +} + +TEST_F(SdpMungingTest, HeaderExtensionAdded) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + // VLA is off by default, id=42 should be unused. + media_description->AddRtpHeaderExtension( + {RtpExtension::kVideoLayersAllocationUri, 42}); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kRtpHeaderExtensionAdded, 1))); +} + +TEST_F(SdpMungingTest, HeaderExtensionRemoved) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + media_description->ClearRtpHeaderExtensions(); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kRtpHeaderExtensionRemoved, 1))); +} + +TEST_F(SdpMungingTest, HeaderExtensionModified) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto extensions = media_description->rtp_header_extensions(); + ASSERT_GT(extensions.size(), 0u); + extensions[0].id = 42; // id=42 should be unused. + media_description->set_rtp_header_extensions(extensions); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kRtpHeaderExtensionModified, 1))); +} + +TEST_F(SdpMungingTest, PayloadTypeChanged) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 0u); + codecs[0].id = 19; // IANA reserved payload type, should not conflict. + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kPayloadTypes, 1))); +} + +TEST_F(SdpMungingTest, AudioCodecsReordered) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 1u); + std::swap(codecs[0], codecs[1]); + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsReordered, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsReordered) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 1u); + std::swap(codecs[0], codecs[1]); + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kVideoCodecsReordered, 1))); +} + +TEST_F(SdpMungingTest, AudioCodecsFmtp) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 0u); + codecs[0].params["dont"] = "munge"; + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtp, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsFmtp) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 0u); + codecs[0].params["dont"] = "munge"; + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kVideoCodecsFmtp, 1))); +} + +TEST_F(SdpMungingTest, AudioCodecsRtcpFb) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 0u); + codecs[0].feedback_params.Add({"dont", "munge"}); + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpFb, 1))); +} + +TEST_F(SdpMungingTest, AudioCodecsRtcpFbNack) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 0u); + codecs[0].feedback_params.Add(FeedbackParam("nack")); + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpFbAudioNack, 1))); +} + +TEST_F(SdpMungingTest, AudioCodecsRtcpFbRrtr) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 0u); + codecs[0].feedback_params.Add(FeedbackParam("rrtr")); + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpFbRrtr, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsRtcpFb) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + auto offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + auto codecs = media_description->codecs(); + ASSERT_GT(codecs.size(), 0u); + codecs[0].feedback_params.Add({"dont", "munge"}); + media_description->set_codecs(codecs); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kVideoCodecsRtcpFb, 1))); +} + +} // namespace webrtc diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 2423fa8c33..d155d1d5a1 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -460,8 +460,7 @@ RTCError ValidateBundledPayloadTypes(const SessionDescription& description) { continue; } const auto type = media_description->type(); - if (type == webrtc::MediaType::AUDIO || - type == webrtc::MediaType::VIDEO) { + if (type == MediaType::AUDIO || type == MediaType::VIDEO) { for (const auto& c : media_description->codecs()) { auto error = FindDuplicateCodecParameters( c.ToCodecParameters(), payload_to_codec_parameters); @@ -593,7 +592,7 @@ RTCError ValidatePayloadTypes(const SessionDescription& description) { continue; } const auto type = media_description->type(); - if (type == webrtc::MediaType::AUDIO || type == webrtc::MediaType::VIDEO) { + if (type == MediaType::AUDIO || type == MediaType::VIDEO) { for (const auto& codec : media_description->codecs()) { if (!PayloadType::IsValid(codec.id, media_description->rtcp_mux())) { LOG_AND_RETURN_ERROR( @@ -719,15 +718,15 @@ RTCError DisableSimulcastInSender(scoped_refptr sender) { // The SDP parser used to populate these values by default for the 'content // name' if an a=mid line was absent. -absl::string_view GetDefaultMidForPlanB(webrtc::MediaType media_type) { +absl::string_view GetDefaultMidForPlanB(MediaType media_type) { switch (media_type) { - case webrtc::MediaType::AUDIO: + case MediaType::AUDIO: return CN_AUDIO; - case webrtc::MediaType::VIDEO: + case MediaType::VIDEO: return CN_VIDEO; - case webrtc::MediaType::DATA: + case MediaType::DATA: return CN_DATA; - case webrtc::MediaType::UNSUPPORTED: + case MediaType::UNSUPPORTED: return "not supported"; default: // Fall through to RTC_CHECK_NOTREACHED @@ -745,13 +744,13 @@ void AddPlanBRtpSenderOptions( MediaDescriptionOptions* video_media_description_options, int num_sim_layers) { for (const auto& sender : senders) { - if (sender->media_type() == webrtc::MediaType::AUDIO) { + if (sender->media_type() == MediaType::AUDIO) { if (audio_media_description_options) { audio_media_description_options->AddAudioSender( sender->id(), sender->internal()->stream_ids()); } } else { - RTC_DCHECK(sender->media_type() == webrtc::MediaType::VIDEO); + RTC_DCHECK(sender->media_type() == MediaType::VIDEO); if (video_media_description_options) { video_media_description_options->AddVideoSender( sender->id(), sender->internal()->stream_ids(), {}, @@ -1440,7 +1439,7 @@ std::unique_ptr SdpOfferAnswerHandler::Create( PeerConnectionSdpMethods* pc, const PeerConnectionInterface::RTCConfiguration& configuration, std::unique_ptr cert_generator, - std::unique_ptr + std::unique_ptr video_bitrate_allocator_factory, ConnectionContext* context, CodecLookupHelper* codec_lookup_helper) { @@ -1454,7 +1453,7 @@ std::unique_ptr SdpOfferAnswerHandler::Create( void SdpOfferAnswerHandler::Initialize( const PeerConnectionInterface::RTCConfiguration& configuration, std::unique_ptr cert_generator, - std::unique_ptr + std::unique_ptr video_bitrate_allocator_factory, ConnectionContext* context, CodecLookupHelper* codec_lookup_helper) { @@ -1962,7 +1961,7 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( GetFirstAudioContent(local_description()->description()); if (audio_content) { if (audio_content->rejected) { - RemoveSenders(webrtc::MediaType::AUDIO); + RemoveSenders(MediaType::AUDIO); } else { const MediaContentDescription* audio_desc = audio_content->media_description(); @@ -1974,7 +1973,7 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( GetFirstVideoContent(local_description()->description()); if (video_content) { if (video_content->rejected) { - RemoveSenders(webrtc::MediaType::VIDEO); + RemoveSenders(MediaType::VIDEO); } else { const MediaContentDescription* video_desc = video_content->media_description(); @@ -2348,7 +2347,7 @@ void SdpOfferAnswerHandler::PlanBUpdateSendersAndReceivers( // and MediaStreams. if (audio_content) { if (audio_content->rejected) { - RemoveSenders(webrtc::MediaType::AUDIO); + RemoveSenders(MediaType::AUDIO); } else { bool default_audio_track_needed = !remote_peer_supports_msid_ && @@ -2363,7 +2362,7 @@ void SdpOfferAnswerHandler::PlanBUpdateSendersAndReceivers( // and MediaStreams. if (video_content) { if (video_content->rejected) { - RemoveSenders(webrtc::MediaType::VIDEO); + RemoveSenders(MediaType::VIDEO); } else { bool default_video_track_needed = !remote_peer_supports_msid_ && @@ -2473,18 +2472,40 @@ void SdpOfferAnswerHandler::DoSetLocalDescription( SdpMungingType sdp_munging_type = DetermineSdpMungingType(desc.get(), last_created_desc); - if (!disable_sdp_munging_checks_ && - HasUfragSdpMunging(desc.get(), last_created_desc)) { - has_sdp_munged_ufrag_ = true; - if (pc_->trials().IsEnabled("WebRTC-NoSdpMangleUfrag")) { - RTC_LOG(LS_ERROR) << "Rejecting SDP because of ufrag modification"; + if (!disable_sdp_munging_checks_) { + bool reject_error = false; + if (HasUfragSdpMunging(desc.get(), last_created_desc)) { + has_sdp_munged_ufrag_ = true; + if (pc_->trials().IsEnabled("WebRTC-NoSdpMangleUfrag")) { + RTC_LOG(LS_ERROR) << "Rejecting SDP because of ufrag modification"; + reject_error = true; + } + } else if (sdp_munging_type == kNumberOfContents && + !pc_->trials().IsDisabled( + "WebRTC-NoSdpMangleNumberOfContents")) { + reject_error = true; + } + SdpMungingOutcome outcome = reject_error ? SdpMungingOutcome::kRejected + : SdpMungingOutcome::kAccepted; + RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.SdpMunging.Outcome", + static_cast(outcome), + static_cast(SdpMungingOutcome::kMaxValue)); + if (reject_error) { observer->OnSetLocalDescriptionComplete( RTCError(RTCErrorType::INVALID_MODIFICATION, "SDP is modified in a non-acceptable way")); last_sdp_munging_type_ = sdp_munging_type; ReportInitialSdpMunging(had_local_description, desc->GetType()); + RTC_HISTOGRAM_ENUMERATION_SPARSE( + "WebRTC.PeerConnection.SdpMunging.SdpOutcome.Rejected", + sdp_munging_type, SdpMungingType::kMaxValue); return; } + if (sdp_munging_type != kNoModification) { + RTC_HISTOGRAM_ENUMERATION_SPARSE( + "WebRTC.PeerConnection.SdpMunging.SdpOutcome.Accepted", + sdp_munging_type, SdpMungingType::kMaxValue); + } } // Workaround for isses.webrtc.org/412904801 - detect if packetization:raw @@ -3859,8 +3880,8 @@ RTCError SdpOfferAnswerHandler::ValidateSessionDescription( // media section. for (const ContentInfo& content : sdesc->description()->contents()) { const MediaContentDescription& desc = *content.media_description(); - if ((desc.type() == webrtc::MediaType::AUDIO || - desc.type() == webrtc::MediaType::VIDEO) && + if ((desc.type() == MediaType::AUDIO || + desc.type() == MediaType::VIDEO) && desc.streams().size() > 1u) { LOG_AND_RETURN_ERROR( RTCErrorType::INVALID_PARAMETER, @@ -3907,13 +3928,12 @@ RTCError SdpOfferAnswerHandler::UpdateTransceiversAndDataChannels( const ContentInfos& new_contents = new_session.description()->contents(); for (size_t i = 0; i < new_contents.size(); ++i) { const ContentInfo& new_content = new_contents[i]; - webrtc::MediaType media_type = new_content.media_description()->type(); + MediaType media_type = new_content.media_description()->type(); mid_generator_.AddKnownId(new_content.mid()); auto it = bundle_groups_by_mid.find(new_content.mid()); const ContentGroup* bundle_group = it != bundle_groups_by_mid.end() ? it->second : nullptr; - if (media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO) { + if (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO) { const ContentInfo* old_local_content = nullptr; if (old_local_description && i < old_local_description->description()->contents().size()) { @@ -3974,7 +3994,7 @@ RTCError SdpOfferAnswerHandler::UpdateTransceiversAndDataChannels( if (!error.ok()) { return error; } - } else if (media_type == webrtc::MediaType::DATA) { + } else if (media_type == MediaType::DATA) { const auto data_mid = pc_->sctp_mid(); if (data_mid && new_content.mid() != data_mid.value()) { // Ignore all but the first data section. @@ -3987,7 +4007,7 @@ RTCError SdpOfferAnswerHandler::UpdateTransceiversAndDataChannels( if (!error.ok()) { return error; } - } else if (media_type == webrtc::MediaType::UNSUPPORTED) { + } else if (media_type == MediaType::UNSUPPORTED) { RTC_LOG(LS_INFO) << "Ignoring unsupported media type"; } else { LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, @@ -4052,8 +4072,7 @@ SdpOfferAnswerHandler::AssociateTransceiver( // If no RtpTransceiver was found in the previous step, create one with a // recvonly direction. if (!transceiver) { - RTC_LOG(LS_INFO) << "Adding " - << webrtc::MediaTypeToString(media_desc->type()) + RTC_LOG(LS_INFO) << "Adding " << MediaTypeToString(media_desc->type()) << " transceiver for MID=" << content.mid() << " at i=" << mline_index << " in response to the remote description."; @@ -4252,7 +4271,7 @@ void SdpOfferAnswerHandler::FillInMissingRemoteMids( scoped_refptr> SdpOfferAnswerHandler::FindAvailableTransceiverToReceive( - webrtc::MediaType media_type) const { + MediaType media_type) const { RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(IsUnifiedPlan()); // From JSEP section 5.10 (Applying a Remote Description): @@ -4383,7 +4402,7 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer( // Add audio/video/data m= sections to the end if needed. if (!audio_index && offer_new_audio_description) { MediaDescriptionOptions options( - webrtc::MediaType::AUDIO, CN_AUDIO, + MediaType::AUDIO, CN_AUDIO, RtpTransceiverDirectionFromSendRecv(send_audio, recv_audio), false); options.header_extensions = media_engine()->voice().GetRtpHeaderExtensions(); @@ -4392,7 +4411,7 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer( } if (!video_index && offer_new_video_description) { MediaDescriptionOptions options( - webrtc::MediaType::VIDEO, CN_VIDEO, + MediaType::VIDEO, CN_VIDEO, RtpTransceiverDirectionFromSendRecv(send_video, recv_video), false); options.header_extensions = media_engine()->video().GetRtpHeaderExtensions(); @@ -4455,11 +4474,10 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanOffer( (current_remote_content && current_remote_content->rejected); const std::string& mid = (local_content ? local_content->mid() : remote_content->mid()); - webrtc::MediaType media_type = + MediaType media_type = (local_content ? local_content->media_description()->type() : remote_content->media_description()->type()); - if (media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO) { + if (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO) { // A media section is considered eligible for recycling if it is marked as // rejected in either the current local or current remote description. auto transceiver = transceivers()->FindByMid(mid); @@ -4493,14 +4511,14 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanOffer( transceiver->internal()->set_mline_index(i); } } - } else if (media_type == webrtc::MediaType::UNSUPPORTED) { + } else if (media_type == MediaType::UNSUPPORTED) { RTC_DCHECK(local_content->rejected); session_options->media_description_options.push_back( MediaDescriptionOptions(media_type, mid, RtpTransceiverDirection::kInactive, /*stopped=*/true)); } else { - RTC_CHECK_EQ(webrtc::MediaType::DATA, media_type); + RTC_CHECK_EQ(MediaType::DATA, media_type); if (had_been_rejected) { session_options->media_description_options.push_back( GetMediaDescriptionOptionsForRejectedData(mid)); @@ -4558,7 +4576,7 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanOffer( for (size_t i = 0; i < session_options->media_description_options.size(); i++) { auto media_description = session_options->media_description_options[i]; - if (media_description.type == webrtc::MediaType::DATA && + if (media_description.type == MediaType::DATA && media_description.stopped) { session_options->media_description_options[i] = GetMediaDescriptionOptionsForActiveData(media_description.mid); @@ -4667,9 +4685,8 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanAnswer( RTC_DCHECK(remote_description()->GetType() == SdpType::kOffer); for (const ContentInfo& content : remote_description()->description()->contents()) { - webrtc::MediaType media_type = content.media_description()->type(); - if (media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO) { + MediaType media_type = content.media_description()->type(); + if (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO) { auto transceiver = transceivers()->FindByMid(content.mid()); if (transceiver) { session_options->media_description_options.push_back( @@ -4684,14 +4701,14 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanAnswer( RtpTransceiverDirection::kInactive, /*stopped=*/true)); } - } else if (media_type == webrtc::MediaType::UNSUPPORTED) { + } else if (media_type == MediaType::UNSUPPORTED) { RTC_DCHECK(content.rejected); session_options->media_description_options.push_back( MediaDescriptionOptions(media_type, content.mid(), RtpTransceiverDirection::kInactive, /*stopped=*/true)); } else { - RTC_CHECK_EQ(webrtc::MediaType::DATA, media_type); + RTC_CHECK_EQ(MediaType::DATA, media_type); // Reject all data sections if data channels are disabled. // Reject a data section if it has already been rejected. // Reject all data sections except for the first one. @@ -4745,20 +4762,18 @@ RTCError SdpOfferAnswerHandler::HandleLegacyOfferOptions( RTC_DCHECK(IsUnifiedPlan()); if (options.offer_to_receive_audio == 0) { - RemoveRecvDirectionFromReceivingTransceiversOfType( - webrtc::MediaType::AUDIO); + RemoveRecvDirectionFromReceivingTransceiversOfType(MediaType::AUDIO); } else if (options.offer_to_receive_audio == 1) { - AddUpToOneReceivingTransceiverOfType(webrtc::MediaType::AUDIO); + AddUpToOneReceivingTransceiverOfType(MediaType::AUDIO); } else if (options.offer_to_receive_audio > 1) { LOG_AND_RETURN_ERROR(RTCErrorType::UNSUPPORTED_PARAMETER, "offer_to_receive_audio > 1 is not supported."); } if (options.offer_to_receive_video == 0) { - RemoveRecvDirectionFromReceivingTransceiversOfType( - webrtc::MediaType::VIDEO); + RemoveRecvDirectionFromReceivingTransceiversOfType(MediaType::VIDEO); } else if (options.offer_to_receive_video == 1) { - AddUpToOneReceivingTransceiverOfType(webrtc::MediaType::VIDEO); + AddUpToOneReceivingTransceiverOfType(MediaType::VIDEO); } else if (options.offer_to_receive_video > 1) { LOG_AND_RETURN_ERROR(RTCErrorType::UNSUPPORTED_PARAMETER, "offer_to_receive_video > 1 is not supported."); @@ -4768,12 +4783,12 @@ RTCError SdpOfferAnswerHandler::HandleLegacyOfferOptions( } void SdpOfferAnswerHandler::RemoveRecvDirectionFromReceivingTransceiversOfType( - webrtc::MediaType media_type) { + MediaType media_type) { for (const auto& transceiver : GetReceivingTransceiversOfType(media_type)) { RtpTransceiverDirection new_direction = RtpTransceiverDirectionWithRecvSet(transceiver->direction(), false); if (new_direction != transceiver->direction()) { - RTC_LOG(LS_INFO) << "Changing " << webrtc::MediaTypeToString(media_type) + RTC_LOG(LS_INFO) << "Changing " << MediaTypeToString(media_type) << " transceiver (MID=" << transceiver->mid().value_or("") << ") from " << RtpTransceiverDirectionToString( @@ -4787,11 +4802,11 @@ void SdpOfferAnswerHandler::RemoveRecvDirectionFromReceivingTransceiversOfType( } void SdpOfferAnswerHandler::AddUpToOneReceivingTransceiverOfType( - webrtc::MediaType media_type) { + MediaType media_type) { RTC_DCHECK_RUN_ON(signaling_thread()); if (GetReceivingTransceiversOfType(media_type).empty()) { RTC_LOG(LS_INFO) - << "Adding one recvonly " << webrtc::MediaTypeToString(media_type) + << "Adding one recvonly " << MediaTypeToString(media_type) << " transceiver since CreateOffer specified offer_to_receive=1"; RtpTransceiverInit init; init.direction = RtpTransceiverDirection::kRecvOnly; @@ -4801,8 +4816,7 @@ void SdpOfferAnswerHandler::AddUpToOneReceivingTransceiverOfType( } std::vector>> -SdpOfferAnswerHandler::GetReceivingTransceiversOfType( - webrtc::MediaType media_type) { +SdpOfferAnswerHandler::GetReceivingTransceiversOfType(MediaType media_type) { std::vector>> receiving_transceivers; for (const auto& transceiver : transceivers()->List()) { @@ -4845,7 +4859,7 @@ void SdpOfferAnswerHandler::RemoveRemoteStreamsIfEmpty( } } -void SdpOfferAnswerHandler::RemoveSenders(webrtc::MediaType media_type) { +void SdpOfferAnswerHandler::RemoveSenders(MediaType media_type) { RTC_DCHECK_RUN_ON(signaling_thread()); UpdateLocalSenders(std::vector(), media_type); UpdateRemoteSendersList(std::vector(), false, media_type, @@ -4854,7 +4868,7 @@ void SdpOfferAnswerHandler::RemoveSenders(webrtc::MediaType media_type) { void SdpOfferAnswerHandler::UpdateLocalSenders( const std::vector& streams, - webrtc::MediaType media_type) { + MediaType media_type) { TRACE_EVENT0("webrtc", "SdpOfferAnswerHandler::UpdateLocalSenders"); RTC_DCHECK_RUN_ON(signaling_thread()); std::vector* current_senders = @@ -4895,7 +4909,7 @@ void SdpOfferAnswerHandler::UpdateLocalSenders( void SdpOfferAnswerHandler::UpdateRemoteSendersList( const StreamParamsVec& streams, bool default_sender_needed, - webrtc::MediaType media_type, + MediaType media_type, StreamCollection* new_streams) { TRACE_EVENT0("webrtc", "SdpOfferAnswerHandler::UpdateRemoteSendersList"); RTC_DCHECK_RUN_ON(signaling_thread()); @@ -4981,7 +4995,7 @@ void SdpOfferAnswerHandler::UpdateRemoteSendersList( remote_streams_->AddStream(default_stream); new_streams->AddStream(default_stream); } - std::string default_sender_id = (media_type == webrtc::MediaType::AUDIO) + std::string default_sender_id = (media_type == MediaType::AUDIO) ? kDefaultAudioSenderId : kDefaultVideoSenderId; const RtpSenderInfo* default_sender_info = rtp_manager()->FindSenderInfo( @@ -5455,12 +5469,12 @@ void SdpOfferAnswerHandler::DestroyMediaChannels() { RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(0); for (const auto& transceiver : list) { - if (transceiver->media_type() == webrtc::MediaType::VIDEO) { + if (transceiver->media_type() == MediaType::VIDEO) { transceiver->internal()->ClearChannel(); } } for (const auto& transceiver : list) { - if (transceiver->media_type() == webrtc::MediaType::AUDIO) { + if (transceiver->media_type() == MediaType::AUDIO) { transceiver->internal()->ClearChannel(); } } @@ -5480,13 +5494,13 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions( // If we already have an audio m= section, reject this extra one. if (*audio_index) { session_options->media_description_options.push_back( - MediaDescriptionOptions(webrtc::MediaType::AUDIO, content.mid(), + MediaDescriptionOptions(MediaType::AUDIO, content.mid(), RtpTransceiverDirection::kInactive, /*stopped=*/true)); } else { bool stopped = (audio_direction == RtpTransceiverDirection::kInactive); session_options->media_description_options.push_back( - MediaDescriptionOptions(webrtc::MediaType::AUDIO, content.mid(), + MediaDescriptionOptions(MediaType::AUDIO, content.mid(), audio_direction, stopped)); *audio_index = session_options->media_description_options.size() - 1; } @@ -5496,13 +5510,13 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions( // If we already have an video m= section, reject this extra one. if (*video_index) { session_options->media_description_options.push_back( - MediaDescriptionOptions(webrtc::MediaType::VIDEO, content.mid(), + MediaDescriptionOptions(MediaType::VIDEO, content.mid(), RtpTransceiverDirection::kInactive, /*stopped=*/true)); } else { bool stopped = (video_direction == RtpTransceiverDirection::kInactive); session_options->media_description_options.push_back( - MediaDescriptionOptions(webrtc::MediaType::VIDEO, content.mid(), + MediaDescriptionOptions(MediaType::VIDEO, content.mid(), video_direction, stopped)); *video_index = session_options->media_description_options.size() - 1; } @@ -5510,7 +5524,7 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions( media_engine()->video().GetRtpHeaderExtensions(); } else if (IsUnsupportedContent(&content)) { session_options->media_description_options.push_back( - MediaDescriptionOptions(webrtc::MediaType::UNSUPPORTED, content.mid(), + MediaDescriptionOptions(MediaType::UNSUPPORTED, content.mid(), RtpTransceiverDirection::kInactive, /*stopped=*/true)); } else { @@ -5534,7 +5548,7 @@ SdpOfferAnswerHandler::GetMediaDescriptionOptionsForActiveData( RTC_DCHECK_RUN_ON(signaling_thread()); // Direction for data sections is meaningless, but legacy endpoints might // expect sendrecv. - MediaDescriptionOptions options(webrtc::MediaType::DATA, mid, + MediaDescriptionOptions options(MediaType::DATA, mid, RtpTransceiverDirection::kSendRecv, /*stopped=*/false); return options; @@ -5544,7 +5558,7 @@ MediaDescriptionOptions SdpOfferAnswerHandler::GetMediaDescriptionOptionsForRejectedData( const std::string& mid) const { RTC_DCHECK_RUN_ON(signaling_thread()); - MediaDescriptionOptions options(webrtc::MediaType::DATA, mid, + MediaDescriptionOptions options(MediaType::DATA, mid, RtpTransceiverDirection::kInactive, /*stopped=*/true); return options; @@ -5597,15 +5611,13 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState( // Ignore transceivers that are not receiving. continue; } - const webrtc::MediaType media_type = - content_info.media_description()->type(); - if (media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO) { - if (media_type == webrtc::MediaType::AUDIO && + const MediaType media_type = content_info.media_description()->type(); + if (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO) { + if (media_type == MediaType::AUDIO && !mid_header_extension_missing_audio) { mid_header_extension_missing_audio = !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri); - } else if (media_type == webrtc::MediaType::VIDEO && + } else if (media_type == MediaType::VIDEO && !mid_header_extension_missing_video) { mid_header_extension_missing_video = !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri); @@ -5613,16 +5625,16 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState( const MediaContentDescription* media_desc = content_info.media_description(); for (const Codec& codec : media_desc->codecs()) { - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { if (payload_types->audio_payload_types.count(codec.id)) { // Two m= sections are using the same payload type, thus demuxing // by payload type is not possible. - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { payload_types->pt_demuxing_possible_audio = false; } } payload_types->audio_payload_types.insert(codec.id); - } else if (media_type == webrtc::MediaType::VIDEO) { + } else if (media_type == MediaType::VIDEO) { if (payload_types->video_payload_types.count(codec.id)) { // Two m= sections are using the same payload type, thus demuxing // by payload type is not possible. @@ -5664,9 +5676,8 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState( continue; } - const webrtc::MediaType media_type = channel->media_type(); - if (media_type != webrtc::MediaType::AUDIO && - media_type != webrtc::MediaType::VIDEO) { + const MediaType media_type = channel->media_type(); + if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) { continue; } @@ -5680,7 +5691,7 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState( const ContentGroup* bundle_group = bundle_it != bundle_groups_by_mid.end() ? bundle_it->second : nullptr; bool pt_demux_enabled = RtpTransceiverDirectionHasRecv(local_direction); - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { pt_demux_enabled &= !bundle_group || (bundled_pt_demux_allowed_audio && @@ -5689,7 +5700,7 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState( pt_demuxing_has_been_used_audio_ = true; } } else { - RTC_DCHECK_EQ(media_type, webrtc::MediaType::VIDEO); + RTC_DCHECK_EQ(media_type, MediaType::VIDEO); pt_demux_enabled &= !bundle_group || (bundled_pt_demux_allowed_video && diff --git a/pc/sdp_offer_answer_unittest.cc b/pc/sdp_offer_answer_unittest.cc index 6eeda1b195..8371a57f07 100644 --- a/pc/sdp_offer_answer_unittest.cc +++ b/pc/sdp_offer_answer_unittest.cc @@ -21,9 +21,6 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" -#include "absl/strings/string_view.h" -#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" @@ -37,8 +34,6 @@ #include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" -#include "api/test/rtc_error_matchers.h" -#include "api/uma_metrics.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_decoder_factory_template.h" #include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h" @@ -53,10 +48,8 @@ #include "media/base/codec.h" #include "media/base/media_constants.h" #include "media/base/stream_params.h" -#include "p2p/base/transport_description.h" #include "pc/peer_connection_wrapper.h" #include "pc/test/fake_audio_capture_module.h" -#include "pc/test/fake_rtc_certificate_generator.h" #include "pc/test/integration_test_helpers.h" #include "pc/test/mock_peer_connection_observers.h" #include "rtc_base/strings/string_format.h" @@ -64,22 +57,21 @@ #include "system_wrappers/include/metrics.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/wait_until.h" // This file contains unit tests that relate to the behavior of the // SdpOfferAnswer module. -// Tests are writen as integration tests with PeerConnection, since the +// Tests are written as integration tests with PeerConnection, since the // behaviors are still linked so closely that it is hard to test them in // isolation. namespace webrtc { +using ::testing::ElementsAre; using ::testing::Eq; using ::testing::IsTrue; -using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; -using ::testing::ElementsAre; using ::testing::Pair; using ::testing::SizeIs; +using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; namespace { @@ -142,7 +134,7 @@ class SdpOfferAnswerTest : public ::testing::Test { } std::optional FindFirstSendCodecWithName( - webrtc::MediaType media_type, + MediaType media_type, const std::string& name) const { std::vector codecs = pc_factory_->GetRtpSenderCapabilities(media_type).codecs; @@ -166,7 +158,7 @@ TEST_F(SdpOfferAnswerTest, OnTrackReturnsProxiedObject) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto audio_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); + auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); // Verify that caller->observer->OnTrack() has been called with a @@ -610,7 +602,7 @@ TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithNoRidsIsRejected) { rid2.rid = "2"; init.send_encodings.push_back(rid2); - auto transceiver = pc->AddTransceiver(webrtc::MediaType::VIDEO, init); + auto transceiver = pc->AddTransceiver(MediaType::VIDEO, init); EXPECT_TRUE(pc->CreateOfferAndSetAsLocal()); auto mid = pc->pc()->local_description()->description()->contents()[0].mid(); @@ -662,10 +654,10 @@ TEST_F(SdpOfferAnswerTest, SimulcastOfferWithMixedCodec) { FieldTrials::CreateNoGlobal("WebRTC-MixedCodecSimulcast/Enabled/")); std::optional vp8_codec_capability = - FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, kVp8CodecName); + FindFirstSendCodecWithName(MediaType::VIDEO, kVp8CodecName); ASSERT_TRUE(vp8_codec_capability); std::optional vp9_codec_capability = - FindFirstSendCodecWithName(webrtc::MediaType::VIDEO, kVp9CodecName); + FindFirstSendCodecWithName(MediaType::VIDEO, kVp9CodecName); ASSERT_TRUE(vp9_codec_capability); RtpTransceiverInit init; @@ -678,7 +670,7 @@ TEST_F(SdpOfferAnswerTest, SimulcastOfferWithMixedCodec) { rid2.codec = *vp9_codec_capability; init.send_encodings.push_back(rid2); - auto transceiver = pc->AddTransceiver(webrtc::MediaType::VIDEO, init); + auto transceiver = pc->AddTransceiver(MediaType::VIDEO, init); auto offer = pc->CreateOffer(); auto& offer_contents = offer->description()->contents(); auto send_codecs = offer_contents[0].media_description()->codecs(); @@ -1621,8 +1613,8 @@ TEST_F(SdpOfferAnswerTest, ReducedSizeNegotiated) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto audio_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); - auto video_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); + auto video_transceiver = caller->AddTransceiver(MediaType::VIDEO); ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); auto receivers = callee->pc()->GetReceivers(); @@ -1644,8 +1636,8 @@ TEST_F(SdpOfferAnswerTest, ReducedSizeNotNegotiated) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto audio_transceiver = caller->AddTransceiver(webrtc::MediaType::AUDIO); - auto video_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); + auto video_transceiver = caller->AddTransceiver(MediaType::VIDEO); auto offer = caller->CreateOfferAndSetAsLocal(); ASSERT_NE(offer, nullptr); @@ -1679,9 +1671,9 @@ TEST_F(SdpOfferAnswerTest, PayloadTypeMatchingWithSubsequentOfferAnswer) { // 1. Restrict codecs and set a local description and remote description. // with a different payload type. - auto video_transceiver = caller->AddTransceiver(webrtc::MediaType::VIDEO); + auto video_transceiver = caller->AddTransceiver(MediaType::VIDEO); std::vector codec_caps = - pc_factory_->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO).codecs; + pc_factory_->GetRtpReceiverCapabilities(MediaType::VIDEO).codecs; codec_caps.erase(std::remove_if(codec_caps.begin(), codec_caps.end(), [](const RtpCodecCapability& codec) { return !absl::EqualsIgnoreCase(codec.name, @@ -1710,8 +1702,7 @@ TEST_F(SdpOfferAnswerTest, PayloadTypeMatchingWithSubsequentOfferAnswer) { EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer1))); // 3. sCP to reenable that codec. Payload type is not matched at this point. - codec_caps = - pc_factory_->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO).codecs; + codec_caps = pc_factory_->GetRtpReceiverCapabilities(MediaType::VIDEO).codecs; codec_caps.erase( std::remove_if(codec_caps.begin(), codec_caps.end(), [](const RtpCodecCapability& codec) { @@ -1746,958 +1737,4 @@ TEST_F(SdpOfferAnswerTest, PayloadTypeMatchingWithSubsequentOfferAnswer) { EXPECT_EQ(codecs[1].id, av1.id); } -class SdpOfferAnswerMungingTest : public SdpOfferAnswerTest { - public: - SdpOfferAnswerMungingTest() : SdpOfferAnswerTest() { metrics::Reset(); } -}; - -TEST_F(SdpOfferAnswerMungingTest, DISABLED_ReportUMAMetricsWithNoMunging) { - auto caller = CreatePeerConnection(); - auto callee = CreatePeerConnection(); - - caller->AddTransceiver(webrtc::MediaType::AUDIO); - caller->AddTransceiver(webrtc::MediaType::VIDEO); - - // Negotiate, gather candidates, then exchange ICE candidates. - ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kNoModification, 1))); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Answer.Initial"), - ElementsAre(Pair(SdpMungingType::kNoModification, 1))); - - EXPECT_THAT(WaitUntil([&] { return caller->IsIceGatheringDone(); }, IsTrue(), - {.timeout = kDefaultTimeout}), - IsRtcOk()); - EXPECT_THAT(WaitUntil([&] { return callee->IsIceGatheringDone(); }, IsTrue(), - {.timeout = kDefaultTimeout}), - IsRtcOk()); - for (const auto& candidate : caller->observer()->GetAllCandidates()) { - callee->pc()->AddIceCandidate(candidate); - } - for (const auto& candidate : callee->observer()->GetAllCandidates()) { - caller->pc()->AddIceCandidate(candidate); - } - EXPECT_THAT( - WaitUntil([&] { return caller->pc()->peer_connection_state(); }, - Eq(PeerConnectionInterface::PeerConnectionState::kConnected), - {.timeout = kDefaultTimeout}), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee->pc()->peer_connection_state(); }, - Eq(PeerConnectionInterface::PeerConnectionState::kConnected), - {.timeout = kDefaultTimeout}), - IsRtcOk()); - - caller->pc()->Close(); - callee->pc()->Close(); - - EXPECT_THAT( - metrics::Samples( - "WebRTC.PeerConnection.SdpMunging.Offer.ConnectionEstablished"), - ElementsAre(Pair(SdpMungingType::kNoModification, 1))); - EXPECT_THAT( - metrics::Samples( - "WebRTC.PeerConnection.SdpMunging.Answer.ConnectionEstablished"), - ElementsAre(Pair(SdpMungingType::kNoModification, 1))); - - EXPECT_THAT(metrics::Samples( - "WebRTC.PeerConnection.SdpMunging.Offer.ConnectionClosed"), - ElementsAre(Pair(SdpMungingType::kNoModification, 1))); - EXPECT_THAT(metrics::Samples( - "WebRTC.PeerConnection.SdpMunging.Answer.ConnectionClosed"), - ElementsAre(Pair(SdpMungingType::kNoModification, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, - InitialSetLocalDescriptionWithoutCreateOffer) { - RTCConfiguration config; - config.certificates.push_back( - FakeRTCCertificateGenerator::GenerateCertificate()); - auto pc = CreatePeerConnection(config, nullptr); - std::string sdp = - "v=0\r\n" - "o=- 0 3 IN IP4 127.0.0.1\r\n" - "s=-\r\n" - "t=0 0\r\n" - "a=fingerprint:sha-1 " - "D9:AB:00:AA:12:7B:62:54:CF:AD:3B:55:F7:60:BC:F3:40:A7:0B:5B\r\n" - "a=setup:actpass\r\n" - "a=ice-ufrag:ETEn\r\n" - "a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kWithoutCreateOffer, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, - InitialSetLocalDescriptionWithoutCreateAnswer) { - RTCConfiguration config; - config.certificates.push_back( - FakeRTCCertificateGenerator::GenerateCertificate()); - auto pc = CreatePeerConnection(config, nullptr); - std::string sdp = - "v=0\r\n" - "o=- 0 3 IN IP4 127.0.0.1\r\n" - "s=-\r\n" - "t=0 0\r\n" - "a=fingerprint:sha-1 " - "D9:AB:00:AA:12:7B:62:54:CF:AD:3B:55:F7:60:BC:F3:40:A7:0B:5B\r\n" - "a=setup:actpass\r\n" - "a=ice-ufrag:ETEn\r\n" - "a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n" - "m=audio 9 UDP/TLS/RTP/SAVPF 111\r\n" - "c=IN IP4 0.0.0.0\r\n" - "a=rtcp-mux\r\n" - "a=sendrecv\r\n" - "a=mid:0\r\n" - "a=rtpmap:111 opus/48000/2\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); - EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); - - RTCError error; - auto answer = CreateSessionDescription(SdpType::kAnswer, sdp); - answer->description()->transport_infos()[0].description.connection_role = - CONNECTIONROLE_ACTIVE; - EXPECT_TRUE(pc->SetLocalDescription(std::move(answer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Answer.Initial"), - ElementsAre(Pair(SdpMungingType::kWithoutCreateAnswer, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IceUfrag) { - auto pc = CreatePeerConnection( - FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Enabled/")); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_ufrag = - "amungediceufragthisshouldberejected"; - RTCError error; - // Ufrag is rejected. - EXPECT_FALSE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IceUfragCheckDisabledByFieldTrial) { - auto pc = CreatePeerConnection( - FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Disabled/")); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_ufrag = - "amungediceufragthisshouldberejected"; - RTCError error; - // Ufrag is not rejected. - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IceUfragWithCheckDisabledForTesting) { - auto pc = CreatePeerConnection(); - pc->GetInternalPeerConnection()->DisableSdpMungingChecksForTesting(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_ufrag = - "amungediceufragthisshouldberejected"; - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IcePwdCheckDisabledByFieldTrial) { - auto pc = CreatePeerConnection( - FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Disabled/")); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_pwd = "amungedicepwdthisshouldberejected"; - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIcePwd, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IcePwd) { - auto pc = CreatePeerConnection( - FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfrag/Enabled/")); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_pwd = "amungedicepwdthisshouldberejected"; - RTCError error; - EXPECT_FALSE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIcePwd, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IceUfragRestrictedAddresses) { - RTCConfiguration config; - config.certificates.push_back( - FakeRTCCertificateGenerator::GenerateCertificate()); - auto caller = CreatePeerConnection( - config, - FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfragRestrictedAddresses/" - "127.0.0.1:12345|127.0.0.*:23456|*:34567/")); - auto callee = CreatePeerConnection(); - caller->AddAudioTrack("audio_track", {}); - auto offer = caller->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_ufrag = "amungediceufrag"; - - EXPECT_TRUE(caller->SetLocalDescription(offer->Clone())); - EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); - - auto answer = callee->CreateAnswer(); - EXPECT_TRUE(callee->SetLocalDescription(answer->Clone())); - EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); - - static constexpr const char tmpl[] = - "candidate:a0+B/1 1 udp 2130706432 %s typ host"; - - // Addresses to test. First field is the address in string format, - // second field is the expected outcome (success or failure). - const std::vector> address_tests = { - {"127.0.0.1:12345", false}, {"127.0.0.2:23456", false}, - {"8.8.8.8:34567", false}, {"127.0.0.2:12345", true}, - {"127.0.1.1:23456", true}, {"8.8.8.8:3456", true}, - }; - - int num_blocked = 0; - for (const auto& address_test : address_tests) { - std::optional result; - const std::string candidate = StringFormat( - tmpl, absl::StrReplaceAll(address_test.first, {{":", " "}}).c_str()); - caller->pc()->AddIceCandidate( - std::unique_ptr( - CreateIceCandidate("", 0, candidate, nullptr)), - [&result](RTCError error) { result = error; }); - - ASSERT_THAT( - WaitUntil([&] { return result.has_value(); }, ::testing::IsTrue()), - IsRtcOk()); - if (address_test.second == true) { - EXPECT_TRUE(result.value().ok()); - } else { - std::pair host = - absl::StrSplit(address_test.first, ":"); - int port; - ASSERT_TRUE(absl::SimpleAtoi(host.second, &port)); - EXPECT_FALSE(result.value().ok()); - EXPECT_EQ(result.value().type(), RTCErrorType::UNSUPPORTED_OPERATION); - num_blocked++; - EXPECT_THAT( - metrics::Samples( - "WebRTC.PeerConnection.RestrictedCandidates.SdpMungingType"), - ElementsAre(Pair(SdpMungingType::kIceUfrag, num_blocked))); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.RestrictedCandidates.Port"), - Contains(Pair(port, 1))); - } - } -} - -TEST_F(SdpOfferAnswerMungingTest, IceUfragSdpRejectedAndRestrictedAddresses) { - RTCConfiguration config; - config.certificates.push_back( - FakeRTCCertificateGenerator::GenerateCertificate()); - auto caller = CreatePeerConnection( - config, - FieldTrials::CreateNoGlobal("WebRTC-NoSdpMangleUfragRestrictedAddresses/" - "127.0.0.1:12345|127.0.0.*:23456|*:34567/" - "WebRTC-NoSdpMangleUfrag/Enabled/")); - auto callee = CreatePeerConnection(); - caller->AddAudioTrack("audio_track", {}); - auto offer = caller->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_ufrag = "amungediceufrag"; - - EXPECT_FALSE(caller->SetLocalDescription(offer->Clone())); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIceUfrag, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IceMode) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.ice_mode = ICEMODE_LITE; - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIceMode, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IceOptions) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.transport_options.push_back( - "something-unsupported"); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIceOptions, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, IceOptionsRenomination) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.transport_options.push_back( - ICE_OPTION_RENOMINATION); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kIceOptionsRenomination, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, DtlsRole) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].description.connection_role = CONNECTIONROLE_PASSIVE; - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kDtlsSetup, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, RemoveContent) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto name = contents[0].mid(); - EXPECT_TRUE(offer->description()->RemoveContentByName(contents[0].mid())); - std::string sdp; - offer->ToString(&sdp); - auto modified_offer = CreateSessionDescription( - SdpType::kOffer, - absl::StrReplaceAll(sdp, {{"a=group:BUNDLE " + name, "a=group:BUNDLE"}})); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(modified_offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kNumberOfContents, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, Mid) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - std::string name(contents[0].mid()); - contents[0].set_mid("amungedmid"); - - auto& transport_infos = offer->description()->transport_infos(); - ASSERT_EQ(transport_infos.size(), 1u); - transport_infos[0].content_name = "amungedmid"; - std::string sdp; - offer->ToString(&sdp); - auto modified_offer = CreateSessionDescription( - SdpType::kOffer, - absl::StrReplaceAll( - sdp, {{"a=group:BUNDLE " + name, "a=group:BUNDLE amungedmid"}})); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(modified_offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kMid, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, LegacySimulcast) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - uint32_t ssrc = media_description->first_ssrc(); - ASSERT_EQ(media_description->streams().size(), 1u); - const std::string& cname = media_description->streams()[0].cname; - - std::string sdp; - offer->ToString(&sdp); - sdp += "a=ssrc-group:SIM " + absl::StrCat(ssrc) + " " + - absl::StrCat(ssrc + 1) + "\r\n" + // - "a=ssrc-group:FID " + absl::StrCat(ssrc + 1) + " " + - absl::StrCat(ssrc + 2) + "\r\n" + // - "a=ssrc:" + absl::StrCat(ssrc + 1) + " msid:- video_track\r\n" + // - "a=ssrc:" + absl::StrCat(ssrc + 1) + " cname:" + cname + "\r\n" + // - "a=ssrc:" + absl::StrCat(ssrc + 2) + " msid:- video_track\r\n" + // - "a=ssrc:" + absl::StrCat(ssrc + 2) + " cname:" + cname + "\r\n"; - auto modified_offer = CreateSessionDescription(SdpType::kOffer, sdp); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(modified_offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kVideoCodecsLegacySimulcast, 1))); -} - -#ifdef WEBRTC_USE_H264 -TEST_F(SdpOfferAnswerMungingTest, H264SpsPpsIdrInKeyFrame) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - for (auto& codec : codecs) { - if (codec.name == webrtc::kH264CodecName) { - codec.SetParam(webrtc::kH264FmtpSpsPpsIdrInKeyframe, - webrtc::kParamValueTrue); - } - } - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre( - Pair(SdpMungingType::kVideoCodecsFmtpH264SpsPpsIdrInKeyframe, 1))); -} -#endif // WEBRTC_USE_H264 - -TEST_F(SdpOfferAnswerMungingTest, OpusStereo) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - for (auto& codec : codecs) { - if (codec.name == kOpusCodecName) { - codec.SetParam(kCodecParamStereo, kParamValueTrue); - } - } - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusStereo, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, OpusFec) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - for (auto& codec : codecs) { - if (codec.name == kOpusCodecName) { - // Enabled by default so we need to remove the parameter. - EXPECT_TRUE(codec.RemoveParam(kCodecParamUseInbandFec)); - } - } - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusFec, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, OpusDtx) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - for (auto& codec : codecs) { - if (codec.name == kOpusCodecName) { - codec.SetParam(kCodecParamUseDtx, kParamValueTrue); - } - } - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusDtx, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, OpusCbr) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - for (auto& codec : codecs) { - if (codec.name == kOpusCodecName) { - codec.SetParam(kCodecParamCbr, kParamValueTrue); - } - } - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusCbr, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioCodecsRemoved) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - codecs.pop_back(); - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsRemoved, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioCodecsAdded) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - auto codec = CreateAudioCodec(SdpAudioFormat("pcmu", 8000, 1, {})); - codec.id = 19; // IANA reserved payload type, should not conflict. - codecs.push_back(codec); - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsAdded, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, VideoCodecsRemoved) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - codecs.pop_back(); - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kVideoCodecsRemoved, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, VideoCodecsAdded) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - auto codec = CreateVideoCodec(SdpVideoFormat("VP8", {})); - codec.id = 19; // IANA reserved payload type, should not conflict. - codecs.push_back(codec); - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kVideoCodecsAdded, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, MultiOpus) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - auto multiopus = - CreateAudioCodec(SdpAudioFormat("multiopus", 48000, 4, - {{"channel_mapping", "0,1,2,3"}, - {"coupled_streams", "2"}, - {"num_streams", "2"}})); - multiopus.id = 19; // IANA reserved payload type, should not conflict. - codecs.push_back(multiopus); - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsAddedMultiOpus, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, L16) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - std::vector codecs = media_description->codecs(); - auto l16 = CreateAudioCodec(SdpAudioFormat("L16", 48000, 2, {})); - l16.id = 19; // IANA reserved payload type, should not conflict. - codecs.push_back(l16); - media_description->set_codecs(codecs); - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsAddedL16, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioSsrc) { - // Note: same applies to video but is harder to write since one needs to - // modify the ssrc-group too. - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - ASSERT_EQ(media_description->streams().size(), 1u); - media_description->mutable_streams()[0].ssrcs[0] = 4404; - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kSsrcs, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, HeaderExtensionAdded) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - // VLA is off by default, id=42 should be unused. - media_description->AddRtpHeaderExtension( - {RtpExtension::kVideoLayersAllocationUri, 42}); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kRtpHeaderExtensionAdded, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, HeaderExtensionRemoved) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - media_description->ClearRtpHeaderExtensions(); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kRtpHeaderExtensionRemoved, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, HeaderExtensionModified) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto extensions = media_description->rtp_header_extensions(); - ASSERT_GT(extensions.size(), 0u); - extensions[0].id = 42; // id=42 should be unused. - media_description->set_rtp_header_extensions(extensions); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kRtpHeaderExtensionModified, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, PayloadTypeChanged) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 0u); - codecs[0].id = 19; // IANA reserved payload type, should not conflict. - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kPayloadTypes, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioCodecsReordered) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 1u); - std::swap(codecs[0], codecs[1]); - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsReordered, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, VideoCodecsReordered) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 1u); - std::swap(codecs[0], codecs[1]); - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kVideoCodecsReordered, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioCodecsFmtp) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 0u); - codecs[0].params["dont"] = "munge"; - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtp, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, VideoCodecsFmtp) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 0u); - codecs[0].params["dont"] = "munge"; - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kVideoCodecsFmtp, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioCodecsRtcpFb) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 0u); - codecs[0].feedback_params.Add({"dont", "munge"}); - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpFb, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioCodecsRtcpFbNack) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 0u); - codecs[0].feedback_params.Add(FeedbackParam("nack")); - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpFbAudioNack, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, AudioCodecsRtcpFbRrtr) { - auto pc = CreatePeerConnection(); - pc->AddAudioTrack("audio_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 0u); - codecs[0].feedback_params.Add(FeedbackParam("rrtr")); - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpFbRrtr, 1))); -} - -TEST_F(SdpOfferAnswerMungingTest, VideoCodecsRtcpFb) { - auto pc = CreatePeerConnection(); - pc->AddVideoTrack("video_track", {}); - - auto offer = pc->CreateOffer(); - auto& contents = offer->description()->contents(); - ASSERT_EQ(contents.size(), 1u); - auto* media_description = contents[0].media_description(); - ASSERT_TRUE(media_description); - auto codecs = media_description->codecs(); - ASSERT_GT(codecs.size(), 0u); - codecs[0].feedback_params.Add({"dont", "munge"}); - media_description->set_codecs(codecs); - - RTCError error; - EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); - EXPECT_THAT( - metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), - ElementsAre(Pair(SdpMungingType::kVideoCodecsRtcpFb, 1))); -} - } // namespace webrtc diff --git a/pc/session_description.cc b/pc/session_description.cc index 96ea3d9deb..29897769cd 100644 --- a/pc/session_description.cc +++ b/pc/session_description.cc @@ -45,7 +45,7 @@ const ContentInfo* FindContentInfoByName(const ContentInfos& contents, return &(*content); } } - return NULL; + return nullptr; } const ContentInfo* FindContentInfoByType(const ContentInfos& contents, @@ -70,7 +70,7 @@ ContentGroup& ContentGroup::operator=(ContentGroup&&) = default; ContentGroup::~ContentGroup() = default; const std::string* ContentGroup::FirstContentName() const { - return (!content_names_.empty()) ? &(*content_names_.begin()) : NULL; + return (!content_names_.empty()) ? &(*content_names_.begin()) : nullptr; } bool ContentGroup::HasContentName(absl::string_view content_name) const { @@ -127,8 +127,8 @@ ContentInfo* SessionDescription::GetContentByName(const std::string& name) { const MediaContentDescription* SessionDescription::GetContentDescriptionByName( absl::string_view name) const { const ContentInfo* cinfo = FindContentInfoByName(contents_, name); - if (cinfo == NULL) { - return NULL; + if (cinfo == nullptr) { + return nullptr; } return cinfo->media_description(); @@ -137,8 +137,8 @@ const MediaContentDescription* SessionDescription::GetContentDescriptionByName( MediaContentDescription* SessionDescription::GetContentDescriptionByName( absl::string_view name) { ContentInfo* cinfo = FindContentInfoByName(&contents_, name); - if (cinfo == NULL) { - return NULL; + if (cinfo == nullptr) { + return nullptr; } return cinfo->media_description(); @@ -150,7 +150,7 @@ const ContentInfo* SessionDescription::FirstContentByType( } const ContentInfo* SessionDescription::FirstContent() const { - return (contents_.empty()) ? NULL : &(*contents_.begin()); + return (contents_.empty()) ? nullptr : &(*contents_.begin()); } void SessionDescription::AddContent( @@ -222,7 +222,7 @@ const TransportInfo* SessionDescription::GetTransportInfoByName( return &(*iter); } } - return NULL; + return nullptr; } TransportInfo* SessionDescription::GetTransportInfoByName( @@ -233,7 +233,7 @@ TransportInfo* SessionDescription::GetTransportInfoByName( return &(*iter); } } - return NULL; + return nullptr; } void SessionDescription::RemoveGroupByName(const std::string& name) { @@ -264,7 +264,7 @@ const ContentGroup* SessionDescription::GetGroupByName( return &(*iter); } } - return NULL; + return nullptr; } std::vector SessionDescription::GetGroupsByName( diff --git a/pc/session_description.h b/pc/session_description.h index b60acdd3b0..3c9575f1a7 100644 --- a/pc/session_description.h +++ b/pc/session_description.h @@ -14,21 +14,18 @@ #include #include -#include #include #include -#include #include #include +#include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/media_types.h" #include "api/rtp_parameters.h" #include "api/rtp_transceiver_direction.h" -#include "api/rtp_transceiver_interface.h" #include "media/base/codec.h" -#include "media/base/media_channel.h" #include "media/base/media_constants.h" #include "media/base/rid_description.h" #include "media/base/stream_params.h" @@ -438,7 +435,7 @@ class RTC_EXPORT ContentInfo { std::unique_ptr description_; }; -typedef std::vector ContentNames; +using ContentNames = std::vector; // This class provides a mechanism to aggregate different media contents into a // group. This group can also be shared with the peers in a pre-defined format. @@ -468,8 +465,8 @@ class ContentGroup { ContentNames content_names_; }; -typedef std::vector ContentInfos; -typedef std::vector ContentGroups; +using ContentInfos = std::vector; +using ContentGroups = std::vector; // Determines how the MSID will be signaled in the SDP. // These can be used as bit flags to indicate both or the special value none. diff --git a/pc/simulcast_sdp_serializer.cc b/pc/simulcast_sdp_serializer.cc index ba90556d6c..9f3539923d 100644 --- a/pc/simulcast_sdp_serializer.cc +++ b/pc/simulcast_sdp_serializer.cc @@ -145,9 +145,9 @@ RTCErrorOr ParseSimulcastLayerList(const std::string& str) { return std::move(result); } -webrtc::RTCError ParseRidPayloadList(const std::string& payload_list, - RidDescription* rid_description, - std::vector* rid_payload_types) { +RTCError ParseRidPayloadList(const std::string& payload_list, + RidDescription* rid_description, + std::vector* rid_payload_types) { RTC_DCHECK(rid_description); RTC_DCHECK(rid_payload_types); // Check that the description doesn't have any payload types or restrictions. diff --git a/pc/slow_peer_connection_integration_test.cc b/pc/slow_peer_connection_integration_test.cc index d306989bc9..8666edc077 100644 --- a/pc/slow_peer_connection_integration_test.cc +++ b/pc/slow_peer_connection_integration_test.cc @@ -471,7 +471,7 @@ TEST_P(PeerConnectionIntegrationTest, CallTransferredForCallee) { // receiving client. These SRTP packets will be dropped. std::unique_ptr original_peer( SetCallerPcWrapperAndReturnCurrent( - CreatePeerConnectionWrapperWithAlternateKey().release())); + CreatePeerConnectionWrapperWithAlternateKey())); // TODO(deadbeef): Why do we call Close here? That goes against the comment // directly above. original_peer->pc()->Close(); @@ -504,7 +504,7 @@ TEST_P(PeerConnectionIntegrationTest, CallTransferredForCaller) { // receiving client. These SRTP packets will be dropped. std::unique_ptr original_peer( SetCalleePcWrapperAndReturnCurrent( - CreatePeerConnectionWrapperWithAlternateKey().release())); + CreatePeerConnectionWrapperWithAlternateKey())); // TODO(deadbeef): Why do we call Close here? That goes against the comment // directly above. original_peer->pc()->Close(); diff --git a/pc/srtp_session.cc b/pc/srtp_session.cc index 7fe7e04f56..6d94c4921a 100644 --- a/pc/srtp_session.cc +++ b/pc/srtp_session.cc @@ -221,7 +221,7 @@ bool SrtpSession::ProtectRtp(CopyOnWriteBuffer& buffer) { int out_len = buffer.size(); int err = srtp_protect(session_, buffer.MutableData(), &out_len); - int seq_num = webrtc::ParseRtpSequenceNumber(buffer); + int seq_num = ParseRtpSequenceNumber(buffer); if (err != srtp_err_status_ok) { RTC_LOG(LS_WARNING) << "Failed to protect SRTP packet, seqnum=" << seq_num << ", err=" << err @@ -256,7 +256,7 @@ bool SrtpSession::ProtectRtp(void* p, int in_len, int max_len, int* out_len) { *out_len = in_len; int err = srtp_protect(session_, p, out_len); - int seq_num = webrtc::ParseRtpSequenceNumber( + int seq_num = ParseRtpSequenceNumber( MakeArrayView(reinterpret_cast(p), in_len)); if (err != srtp_err_status_ok) { RTC_LOG(LS_WARNING) << "Failed to protect SRTP packet, seqnum=" << seq_num @@ -508,18 +508,17 @@ bool SrtpSession::GetSendStreamPacketIndex(CopyOnWriteBuffer& buffer, int64_t* index) { RTC_DCHECK(thread_checker_.IsCurrent()); - uint32_t ssrc = webrtc::ParseRtpSsrc(buffer); + uint32_t ssrc = ParseRtpSsrc(buffer); uint32_t roc; if (srtp_get_stream_roc(session_, ssrc, &roc) != srtp_err_status_ok) { return false; } // Calculate the extended sequence number. - uint16_t seq_num = webrtc::ParseRtpSequenceNumber(buffer); + uint16_t seq_num = ParseRtpSequenceNumber(buffer); int64_t extended_seq_num = (roc << 16) + seq_num; // Shift extended sequence number, put into network byte order - *index = - static_cast(webrtc::NetworkToHost64(extended_seq_num << 16)); + *index = static_cast(NetworkToHost64(extended_seq_num << 16)); return true; } @@ -561,7 +560,7 @@ bool SrtpSession::DoSetKey(int type, // Enable external HMAC authentication only for outgoing streams and only // for cipher suites that support it (i.e. only non-GCM cipher suites). if (type == ssrc_any_outbound && IsExternalAuthEnabled() && - !webrtc::IsGcmCryptoSuite(crypto_suite)) { + !IsGcmCryptoSuite(crypto_suite)) { policy.rtp.auth_type = EXTERNAL_HMAC_SHA1; } if (!extension_ids.empty()) { @@ -672,7 +671,7 @@ void SrtpSession::HandleEventThunk(srtp_event_data_t* ev) { // The resulting file can be replayed using the WebRTC video_replay tool and // be inspected in Wireshark using the RTP, VP8 and H264 dissectors. void SrtpSession::DumpPacket(const CopyOnWriteBuffer& buffer, bool outbound) { - int64_t time_of_day = webrtc::TimeUTCMillis() % (24 * 3600 * 1000); + int64_t time_of_day = TimeUTCMillis() % (24 * 3600 * 1000); int64_t hours = time_of_day / (3600 * 1000); int64_t minutes = (time_of_day / (60 * 1000)) % 60; int64_t seconds = (time_of_day / 1000) % 60; @@ -683,7 +682,7 @@ void SrtpSession::DumpPacket(const CopyOnWriteBuffer& buffer, bool outbound) { << hours << ":" << std::setfill('0') << std::setw(2) << minutes << ":" << std::setfill('0') << std::setw(2) << seconds << "." << std::setfill('0') << std::setw(3) << millis << " " << "000000 " - << webrtc::hex_encode_with_delimiter( + << hex_encode_with_delimiter( absl::string_view(buffer.data(), buffer.size()), ' ') << " # RTP_DUMP"; } diff --git a/pc/srtp_session_unittest.cc b/pc/srtp_session_unittest.cc index fd58ce79b5..56a38dc1f0 100644 --- a/pc/srtp_session_unittest.cc +++ b/pc/srtp_session_unittest.cc @@ -39,7 +39,7 @@ std::vector kEncryptedHeaderExtensionIds; class SrtpSessionTest : public ::testing::Test { public: SrtpSessionTest() : s1_(field_trials_), s2_(field_trials_) { - webrtc::metrics::Reset(); + metrics::Reset(); } protected: @@ -53,8 +53,7 @@ class SrtpSessionTest : public ::testing::Test { } void TestProtectRtp(int crypto_suite) { EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_)); - EXPECT_EQ(rtp_packet_.size(), - rtp_len_ + webrtc::rtp_auth_tag_len(crypto_suite)); + EXPECT_EQ(rtp_packet_.size(), rtp_len_ + rtp_auth_tag_len(crypto_suite)); // Check that Protect changed the content (up to the original length). EXPECT_NE(0, std::memcmp(kPcmuFrame, rtp_packet_.data(), rtp_len_)); rtp_len_ = rtp_packet_.size(); @@ -62,7 +61,7 @@ class SrtpSessionTest : public ::testing::Test { void TestProtectRtcp(int crypto_suite) { EXPECT_TRUE(s1_.ProtectRtcp(rtcp_packet_)); EXPECT_EQ(rtcp_packet_.size(), - rtcp_len_ + 4 + webrtc::rtcp_auth_tag_len(crypto_suite)); + rtcp_len_ + 4 + rtcp_auth_tag_len(crypto_suite)); // Check that Protect changed the content (up to the original length). EXPECT_NE(0, std::memcmp(kRtcpReport, rtcp_packet_.data(), rtcp_len_)); rtcp_len_ = rtcp_packet_.size(); @@ -90,110 +89,108 @@ class SrtpSessionTest : public ::testing::Test { // Test that we can set up the session and keys properly. TEST_F(SrtpSessionTest, TestGoodSetup) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); } // Test that we can't change the keys once set. TEST_F(SrtpSessionTest, TestBadSetup) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_FALSE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey2, + EXPECT_FALSE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey2, kEncryptedHeaderExtensionIds)); - EXPECT_FALSE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey2, + EXPECT_FALSE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey2, kEncryptedHeaderExtensionIds)); } // Test that we fail keys of the wrong length. TEST_F(SrtpSessionTest, TestKeysTooShort) { - EXPECT_FALSE( - s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, - ZeroOnFreeBuffer(webrtc::kTestKey1.data(), 1), - kEncryptedHeaderExtensionIds)); - EXPECT_FALSE( - s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, - ZeroOnFreeBuffer(webrtc::kTestKey1.data(), 1), - kEncryptedHeaderExtensionIds)); + EXPECT_FALSE(s1_.SetSend(kSrtpAes128CmSha1_80, + ZeroOnFreeBuffer(kTestKey1.data(), 1), + kEncryptedHeaderExtensionIds)); + EXPECT_FALSE(s2_.SetReceive(kSrtpAes128CmSha1_80, + ZeroOnFreeBuffer(kTestKey1.data(), 1), + kEncryptedHeaderExtensionIds)); } // Test that we can encrypt and decrypt RTP/RTCP using AES_CM_128_HMAC_SHA1_80. TEST_F(SrtpSessionTest, TestProtect_AES_CM_128_HMAC_SHA1_80) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - TestProtectRtp(webrtc::kSrtpAes128CmSha1_80); - TestProtectRtcp(webrtc::kSrtpAes128CmSha1_80); - TestUnprotectRtp(webrtc::kSrtpAes128CmSha1_80); - TestUnprotectRtcp(webrtc::kSrtpAes128CmSha1_80); + TestProtectRtp(kSrtpAes128CmSha1_80); + TestProtectRtcp(kSrtpAes128CmSha1_80); + TestUnprotectRtp(kSrtpAes128CmSha1_80); + TestUnprotectRtcp(kSrtpAes128CmSha1_80); } // Test that we can encrypt and decrypt RTP/RTCP using AES_CM_128_HMAC_SHA1_32. TEST_F(SrtpSessionTest, TestProtect_AES_CM_128_HMAC_SHA1_32) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_32, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_32, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_32, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_32, kTestKey1, kEncryptedHeaderExtensionIds)); - TestProtectRtp(webrtc::kSrtpAes128CmSha1_32); - TestProtectRtcp(webrtc::kSrtpAes128CmSha1_32); - TestUnprotectRtp(webrtc::kSrtpAes128CmSha1_32); - TestUnprotectRtcp(webrtc::kSrtpAes128CmSha1_32); + TestProtectRtp(kSrtpAes128CmSha1_32); + TestProtectRtcp(kSrtpAes128CmSha1_32); + TestUnprotectRtp(kSrtpAes128CmSha1_32); + TestUnprotectRtcp(kSrtpAes128CmSha1_32); } TEST_F(SrtpSessionTest, TestGetSendStreamPacketIndex) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_32, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_32, kTestKey1, kEncryptedHeaderExtensionIds)); int64_t index; EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, &index)); // `index` will be shifted by 16. - int64_t be64_index = static_cast(webrtc::NetworkToHost64(1 << 16)); + int64_t be64_index = static_cast(NetworkToHost64(1 << 16)); EXPECT_EQ(be64_index, index); } // Test that we fail to unprotect if someone tampers with the RTP/RTCP paylaods. TEST_F(SrtpSessionTest, TestTamperReject) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - TestProtectRtp(webrtc::kSrtpAes128CmSha1_80); + TestProtectRtp(kSrtpAes128CmSha1_80); rtp_packet_.MutableData()[0] = 0x12; EXPECT_FALSE(s2_.UnprotectRtp(rtp_packet_)); EXPECT_METRIC_THAT( - webrtc::metrics::Samples("WebRTC.PeerConnection.SrtpUnprotectError"), + metrics::Samples("WebRTC.PeerConnection.SrtpUnprotectError"), ElementsAre(Pair(srtp_err_status_bad_param, 1))); - TestProtectRtcp(webrtc::kSrtpAes128CmSha1_80); + TestProtectRtcp(kSrtpAes128CmSha1_80); rtcp_packet_.MutableData()[1] = 0x34; EXPECT_FALSE(s2_.UnprotectRtcp(rtcp_packet_)); EXPECT_METRIC_THAT( - webrtc::metrics::Samples("WebRTC.PeerConnection.SrtcpUnprotectError"), + metrics::Samples("WebRTC.PeerConnection.SrtcpUnprotectError"), ElementsAre(Pair(srtp_err_status_auth_fail, 1))); } // Test that we fail to unprotect if the payloads are not authenticated. TEST_F(SrtpSessionTest, TestUnencryptReject) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); EXPECT_FALSE(s2_.UnprotectRtp(rtp_packet_)); EXPECT_METRIC_THAT( - webrtc::metrics::Samples("WebRTC.PeerConnection.SrtpUnprotectError"), + metrics::Samples("WebRTC.PeerConnection.SrtpUnprotectError"), ElementsAre(Pair(srtp_err_status_auth_fail, 1))); EXPECT_FALSE(s2_.UnprotectRtcp(rtcp_packet_)); EXPECT_METRIC_THAT( - webrtc::metrics::Samples("WebRTC.PeerConnection.SrtcpUnprotectError"), + metrics::Samples("WebRTC.PeerConnection.SrtcpUnprotectError"), ElementsAre(Pair(srtp_err_status_cant_check, 1))); } // Test that we fail when using buffers that are too small. TEST_F(SrtpSessionTest, TestBuffersTooSmall) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); // This buffer does not have extra capacity which we treat as an error. CopyOnWriteBuffer rtp_packet(rtp_packet_.data(), rtp_packet_.size(), @@ -211,41 +208,41 @@ TEST_F(SrtpSessionTest, TestReplay) { static const uint16_t seqnum_small = 10; static const uint16_t replay_window = 1024; - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); // Initial sequence number. - webrtc::SetBE16(rtp_packet_.MutableData() + 2, seqnum_big); + SetBE16(rtp_packet_.MutableData() + 2, seqnum_big); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_)); rtp_packet_.SetData(kPcmuFrame, sizeof(kPcmuFrame)); // Replay within the 1024 window should succeed. - webrtc::SetBE16(rtp_packet_.MutableData() + 2, - seqnum_big - replay_window + 1); + SetBE16(rtp_packet_.MutableData() + 2, + seqnum_big - replay_window + 1); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_)); rtp_packet_.SetData(kPcmuFrame, sizeof(kPcmuFrame)); // Replay out side of the 1024 window should fail. - webrtc::SetBE16(rtp_packet_.MutableData() + 2, - seqnum_big - replay_window - 1); + SetBE16(rtp_packet_.MutableData() + 2, + seqnum_big - replay_window - 1); EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_)); rtp_packet_.SetData(kPcmuFrame, sizeof(kPcmuFrame)); // Increment sequence number to a small number. - webrtc::SetBE16(rtp_packet_.MutableData() + 2, seqnum_small); + SetBE16(rtp_packet_.MutableData() + 2, seqnum_small); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_)); // Replay around 0 but out side of the 1024 window should fail. - webrtc::SetBE16(rtp_packet_.MutableData() + 2, - kMaxSeqnum + seqnum_small - replay_window - 1); + SetBE16(rtp_packet_.MutableData() + 2, + kMaxSeqnum + seqnum_small - replay_window - 1); EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_)); rtp_packet_.SetData(kPcmuFrame, sizeof(kPcmuFrame)); // Replay around 0 but within the 1024 window should succeed. for (uint16_t seqnum = 65000; seqnum < 65003; ++seqnum) { - webrtc::SetBE16(rtp_packet_.MutableData() + 2, seqnum); + SetBE16(rtp_packet_.MutableData() + 2, seqnum); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_)); rtp_packet_.SetData(kPcmuFrame, sizeof(kPcmuFrame)); } @@ -255,14 +252,14 @@ TEST_F(SrtpSessionTest, TestReplay) { // without the fix, the loop above would keep incrementing local sequence // number in libsrtp, eventually the new sequence number would go out side // of the window. - webrtc::SetBE16(rtp_packet_.MutableData() + 2, seqnum_small + 1); + SetBE16(rtp_packet_.MutableData() + 2, seqnum_small + 1); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_)); } TEST_F(SrtpSessionTest, RemoveSsrc) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); // Encrypt and decrypt the packet once. EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_)); @@ -294,9 +291,9 @@ TEST_F(SrtpSessionTest, ProtectUnprotectWrapAroundRocMismatch) { // failures when it wraps around with packet loss. Pick your starting // sequence number in the lower half of the range for robustness reasons, // see packet_sequencer.cc for the code doing so. - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); // Buffers include enough room for the 10 byte SRTP auth tag so we can // encrypt in place. @@ -349,9 +346,9 @@ TEST_F(SrtpSessionTest, ProtectUnprotectWrapAroundRocMismatch) { } TEST_F(SrtpSessionTest, ProtectGetPacketIndex) { - EXPECT_TRUE(s1_.SetSend(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); - EXPECT_TRUE(s2_.SetReceive(webrtc::kSrtpAes128CmSha1_80, webrtc::kTestKey1, + EXPECT_TRUE(s2_.SetReceive(kSrtpAes128CmSha1_80, kTestKey1, kEncryptedHeaderExtensionIds)); // Buffers include enough room for the 10 byte SRTP auth tag so we can // encrypt in place. diff --git a/pc/test/fake_audio_capture_module_unittest.cc b/pc/test/fake_audio_capture_module_unittest.cc index 8a81e88bbc..b4249166e5 100644 --- a/pc/test/fake_audio_capture_module_unittest.cc +++ b/pc/test/fake_audio_capture_module_unittest.cc @@ -36,7 +36,7 @@ class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport { void SetUp() override { fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); - EXPECT_TRUE(fake_audio_capture_module_.get() != NULL); + EXPECT_TRUE(fake_audio_capture_module_.get() != nullptr); } // Callbacks inherited from webrtc::AudioTransport. diff --git a/pc/test/integration_test_helpers.cc b/pc/test/integration_test_helpers.cc index 23a712a3c8..ecd2aa311e 100644 --- a/pc/test/integration_test_helpers.cc +++ b/pc/test/integration_test_helpers.cc @@ -20,18 +20,20 @@ #include "absl/functional/any_invocable.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/enable_media_with_defaults.h" +#include "api/environment/environment_factory.h" #include "api/field_trials_view.h" #include "api/jsep.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/sequence_checker.h" #include "api/stats/rtcstats_objects.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/fake_rtc_event_log_factory.h" +#include "media/base/stream_params.h" #include "pc/peer_connection_factory.h" +#include "pc/session_description.h" #include "pc/test/fake_audio_capture_module.h" #include "rtc_base/checks.h" #include "rtc_base/fake_network.h" @@ -229,7 +231,7 @@ bool PeerConnectionIntegrationWrapper::Init( RTC_DCHECK(!peer_connection_); RTC_DCHECK(!peer_connection_factory_); - auto network_manager = std::make_unique(); + auto network_manager = std::make_unique(network_thread); fake_network_manager_ = network_manager.get(); fake_network_manager_->AddInterface(kDefaultLocalAddress); @@ -247,8 +249,7 @@ bool PeerConnectionIntegrationWrapper::Init( pc_factory_dependencies.signaling_thread = signaling_thread; pc_factory_dependencies.socket_factory = socket_server; pc_factory_dependencies.network_manager = std::move(network_manager); - pc_factory_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); - pc_factory_dependencies.trials = std::move(field_trials); + pc_factory_dependencies.env = CreateEnvironment(std::move(field_trials)); pc_factory_dependencies.decode_metronome = std::make_unique(TimeDelta::Millis(8)); diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 63ba2108b4..8eda1f5783 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -33,6 +33,7 @@ #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/data_channel_interface.h" +#include "api/dtls_transport_interface.h" #include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/ice_transport_interface.h" @@ -739,18 +740,16 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, } std::optional tls_version() { - return network_thread_->BlockingCall([&] { - return pc() - ->GetSctpTransport() - ->dtls_transport() - ->Information() - .tls_version(); - }); + return dtls_transport_information().tls_version(); } std::optional dtls_transport_role() { + return dtls_transport_information().role(); + } + + DtlsTransportInformation dtls_transport_information() { return network_thread_->BlockingCall([&] { - return pc()->GetSctpTransport()->dtls_transport()->Information().role(); + return pc()->GetSctpTransport()->dtls_transport()->Information(); }); } @@ -1385,12 +1384,12 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { if (caller_) { caller_->set_signaling_message_receiver(nullptr); caller_->pc()->Close(); - delete SetCallerPcWrapperAndReturnCurrent(nullptr); + caller_.reset(); } if (callee_) { callee_->set_signaling_message_receiver(nullptr); callee_->pc()->Close(); - delete SetCalleePcWrapperAndReturnCurrent(nullptr); + callee_.reset(); } // If turn servers were created for the test they need to be destroyed on @@ -1405,6 +1404,12 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { return caller_->SignalingStateStable() && callee_->SignalingStateStable(); } + bool PeerConnectionStateIs( + PeerConnectionInterface::PeerConnectionState state) { + return caller_->pc()->peer_connection_state() == state && + callee_->pc()->peer_connection_state() == state; + } + bool DtlsConnected() { // TODO(deadbeef): kIceConnectionConnected currently means both ICE and DTLS // are connected. This is an important distinction. Once we have separate @@ -1720,9 +1725,9 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { // Set the `caller_` to the `wrapper` passed in and return the // original `caller_`. PeerConnectionIntegrationWrapper* SetCallerPcWrapperAndReturnCurrent( - PeerConnectionIntegrationWrapper* wrapper) { + std::unique_ptr wrapper) { PeerConnectionIntegrationWrapper* old = caller_.release(); - caller_.reset(wrapper); + caller_ = std::move(wrapper); return old; } @@ -1731,9 +1736,9 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { // Set the `callee_` to the `wrapper` passed in and return the // original `callee_`. PeerConnectionIntegrationWrapper* SetCalleePcWrapperAndReturnCurrent( - PeerConnectionIntegrationWrapper* wrapper) { + std::unique_ptr wrapper) { PeerConnectionIntegrationWrapper* old = callee_.release(); - callee_.reset(wrapper); + callee_ = std::move(wrapper); return old; } diff --git a/pc/test/peer_connection_test_wrapper.cc b/pc/test/peer_connection_test_wrapper.cc index 94f9b6530e..37877d6387 100644 --- a/pc/test/peer_connection_test_wrapper.cc +++ b/pc/test/peer_connection_test_wrapper.cc @@ -359,7 +359,7 @@ void PeerConnectionTestWrapper::AddIceCandidate(const std::string& sdp_mid, int sdp_mline_index, const std::string& candidate) { std::unique_ptr owned_candidate( - webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, candidate, NULL)); + webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, candidate, nullptr)); EXPECT_TRUE(peer_connection_->AddIceCandidate(owned_candidate.get())); } diff --git a/pc/test/svc_e2e_tests.cc b/pc/test/svc_e2e_tests.cc index 60469c76b5..a5496822fb 100644 --- a/pc/test/svc_e2e_tests.cc +++ b/pc/test/svc_e2e_tests.cc @@ -60,12 +60,12 @@ using ::testing::Optional; using ::testing::UnitTest; using ::testing::Values; using ::testing::ValuesIn; -using ::webrtc::webrtc_pc_e2e::EmulatedSFUConfig; -using ::webrtc::webrtc_pc_e2e::PeerConfigurer; -using ::webrtc::webrtc_pc_e2e::RunParams; -using ::webrtc::webrtc_pc_e2e::ScreenShareConfig; -using ::webrtc::webrtc_pc_e2e::VideoCodecConfig; -using ::webrtc::webrtc_pc_e2e::VideoConfig; +using webrtc_pc_e2e::EmulatedSFUConfig; +using webrtc_pc_e2e::PeerConfigurer; +using webrtc_pc_e2e::RunParams; +using webrtc_pc_e2e::ScreenShareConfig; +using webrtc_pc_e2e::VideoCodecConfig; +using webrtc_pc_e2e::VideoConfig; std::unique_ptr CreateTestFixture(absl::string_view test_case_name, diff --git a/pc/track_media_info_map.cc b/pc/track_media_info_map.cc index a1eef98fe7..6cd24448bb 100644 --- a/pc/track_media_info_map.cc +++ b/pc/track_media_info_map.cc @@ -58,7 +58,7 @@ void GetAudioAndVideoTrackBySsrc( RTC_DCHECK(remote_audio_track_by_ssrc->empty()); RTC_DCHECK(remote_video_track_by_ssrc->empty()); for (const auto& rtp_sender : rtp_senders) { - webrtc::MediaType media_type = rtp_sender->media_type(); + MediaType media_type = rtp_sender->media_type(); MediaStreamTrackInterface* track = rtp_sender->track().get(); if (!track) { continue; @@ -66,7 +66,7 @@ void GetAudioAndVideoTrackBySsrc( // TODO(deadbeef): `ssrc` should be removed in favor of `GetParameters`. uint32_t ssrc = rtp_sender->ssrc(); if (ssrc != 0) { - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { RTC_DCHECK(local_audio_track_by_ssrc->find(ssrc) == local_audio_track_by_ssrc->end()); (*local_audio_track_by_ssrc)[ssrc] = @@ -80,21 +80,21 @@ void GetAudioAndVideoTrackBySsrc( } } for (const auto& rtp_receiver : rtp_receivers) { - webrtc::MediaType media_type = rtp_receiver->media_type(); + MediaType media_type = rtp_receiver->media_type(); MediaStreamTrackInterface* track = rtp_receiver->track().get(); RTC_DCHECK(track); RtpParameters params = rtp_receiver->GetParameters(); for (const RtpEncodingParameters& encoding : params.encodings) { if (!encoding.ssrc) { - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { *unsignaled_audio_track = static_cast(track); } else { - RTC_DCHECK(media_type == webrtc::MediaType::VIDEO); + RTC_DCHECK(media_type == MediaType::VIDEO); *unsignaled_video_track = static_cast(track); } continue; } - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { RTC_DCHECK(remote_audio_track_by_ssrc->find(*encoding.ssrc) == remote_audio_track_by_ssrc->end()); (*remote_audio_track_by_ssrc)[*encoding.ssrc] = diff --git a/pc/track_media_info_map_unittest.cc b/pc/track_media_info_map_unittest.cc index a9487cc507..cd6bf36a2e 100644 --- a/pc/track_media_info_map_unittest.cc +++ b/pc/track_media_info_map_unittest.cc @@ -55,7 +55,7 @@ RtpParameters CreateRtpParametersWithSsrcs( } scoped_refptr CreateMockRtpSender( - webrtc::MediaType media_type, + MediaType media_type, std::initializer_list ssrcs, scoped_refptr track) { uint32_t first_ssrc; @@ -77,7 +77,7 @@ scoped_refptr CreateMockRtpSender( } scoped_refptr CreateMockRtpReceiver( - webrtc::MediaType media_type, + MediaType media_type, std::initializer_list ssrcs, scoped_refptr track) { auto receiver = make_ref_counted(); @@ -121,8 +121,8 @@ class TrackMediaInfoMapTest : public ::testing::Test { MediaStreamTrackInterface* local_track) { scoped_refptr rtp_sender = CreateMockRtpSender( local_track->kind() == MediaStreamTrackInterface::kAudioKind - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO, + ? MediaType::AUDIO + : MediaType::VIDEO, ssrcs, scoped_refptr(local_track)); rtp_senders_.push_back(rtp_sender); @@ -150,8 +150,8 @@ class TrackMediaInfoMapTest : public ::testing::Test { MediaStreamTrackInterface* remote_track) { auto rtp_receiver = CreateMockRtpReceiver( remote_track->kind() == MediaStreamTrackInterface::kAudioKind - ? webrtc::MediaType::AUDIO - : webrtc::MediaType::VIDEO, + ? MediaType::AUDIO + : MediaType::VIDEO, ssrcs, scoped_refptr(remote_track)); rtp_receivers_.push_back(rtp_receiver); diff --git a/pc/used_ids_unittest.cc b/pc/used_ids_unittest.cc index fd73501ab2..4b2b3c20ab 100644 --- a/pc/used_ids_unittest.cc +++ b/pc/used_ids_unittest.cc @@ -15,15 +15,15 @@ #include "rtc_base/checks.h" #include "test/gtest.h" -using ::webrtc::UsedIds; -using ::webrtc::UsedRtpHeaderExtensionIds; +namespace webrtc { +namespace { struct Foo { int id; }; TEST(UsedIdsTest, UniqueIdsAreUnchanged) { - webrtc::UsedIds used_ids(1, 5); + UsedIds used_ids(1, 5); for (int i = 1; i <= 5; ++i) { Foo id = {i}; used_ids.FindAndSetIdUsed(&id); @@ -32,7 +32,7 @@ TEST(UsedIdsTest, UniqueIdsAreUnchanged) { } TEST(UsedIdsTest, IdsOutsideRangeAreUnchanged) { - webrtc::UsedIds used_ids(1, 5); + UsedIds used_ids(1, 5); Foo id_11 = {11}; Foo id_12 = {12}; @@ -53,7 +53,7 @@ TEST(UsedIdsTest, IdsOutsideRangeAreUnchanged) { } TEST(UsedIdsTest, CollisionsAreReassignedIdsInReverseOrder) { - webrtc::UsedIds used_ids(1, 10); + UsedIds used_ids(1, 10); Foo id_1 = {1}; Foo id_2 = {2}; Foo id_2_collision = {2}; @@ -92,7 +92,7 @@ TEST_P(UsedRtpHeaderExtensionIdsTest, UniqueIdsAreUnchanged) { // Fill all IDs. for (int j = 1; j <= GetParam().max_id; ++j) { - webrtc::RtpExtension extension("", j); + RtpExtension extension("", j); used_ids.FindAndSetIdUsed(&extension); EXPECT_EQ(extension.id, j); } @@ -100,11 +100,11 @@ TEST_P(UsedRtpHeaderExtensionIdsTest, UniqueIdsAreUnchanged) { TEST_P(UsedRtpHeaderExtensionIdsTest, PrioritizeReassignmentToOneByteIds) { UsedRtpHeaderExtensionIds used_ids(GetParam().id_domain); - webrtc::RtpExtension id_1("", 1); - webrtc::RtpExtension id_2("", 2); - webrtc::RtpExtension id_2_collision("", 2); - webrtc::RtpExtension id_3("", 3); - webrtc::RtpExtension id_3_collision("", 3); + RtpExtension id_1("", 1); + RtpExtension id_2("", 2); + RtpExtension id_2_collision("", 2); + RtpExtension id_3("", 3); + RtpExtension id_3_collision("", 3); // Expect that colliding IDs are reassigned to one-byte IDs. used_ids.FindAndSetIdUsed(&id_1); @@ -121,16 +121,15 @@ TEST_F(UsedRtpHeaderExtensionIdsTest, TwoByteIdsAllowed) { UsedRtpHeaderExtensionIds::IdDomain::kTwoByteAllowed); // Fill all one byte IDs. - for (int i = 1; i <= webrtc::RtpExtension::kOneByteHeaderExtensionMaxId; - ++i) { - webrtc::RtpExtension id("", i); + for (int i = 1; i <= RtpExtension::kOneByteHeaderExtensionMaxId; ++i) { + RtpExtension id("", i); used_ids.FindAndSetIdUsed(&id); } // Add new extensions with colliding IDs. - webrtc::RtpExtension id1_collision("", 1); - webrtc::RtpExtension id2_collision("", 2); - webrtc::RtpExtension id3_collision("", 3); + RtpExtension id1_collision("", 1); + RtpExtension id2_collision("", 2); + RtpExtension id3_collision("", 3); // Expect to reassign to two-byte header extension IDs. used_ids.FindAndSetIdUsed(&id1_collision); @@ -166,16 +165,19 @@ TEST_P(UsedRtpHeaderExtensionIdsDeathTest, DieWhenAllIdsAreOccupied) { // Fill all IDs. for (int j = 1; j <= GetParam().max_id; ++j) { - webrtc::RtpExtension id("", j); + RtpExtension id("", j); used_ids.FindAndSetIdUsed(&id); } - webrtc::RtpExtension id1_collision("", 1); - webrtc::RtpExtension id2_collision("", 2); - webrtc::RtpExtension id3_collision("", GetParam().max_id); + RtpExtension id1_collision("", 1); + RtpExtension id2_collision("", 2); + RtpExtension id3_collision("", GetParam().max_id); EXPECT_DEATH(used_ids.FindAndSetIdUsed(&id1_collision), ""); EXPECT_DEATH(used_ids.FindAndSetIdUsed(&id2_collision), ""); EXPECT_DEATH(used_ids.FindAndSetIdUsed(&id3_collision), ""); } #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) + +} // namespace +} // namespace webrtc diff --git a/pc/video_rtp_receiver.h b/pc/video_rtp_receiver.h index 5bd2e6a766..04a1aac70c 100644 --- a/pc/video_rtp_receiver.h +++ b/pc/video_rtp_receiver.h @@ -29,7 +29,6 @@ #include "api/transport/rtp/rtp_source.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" -#include "api/video/video_source_interface.h" #include "media/base/media_channel.h" #include "pc/jitter_buffer_delay.h" #include "pc/media_stream_track_proxy.h" @@ -67,9 +66,7 @@ class VideoRtpReceiver : public RtpReceiverInternal { scoped_refptr dtls_transport() const override; std::vector stream_ids() const override; std::vector> streams() const override; - webrtc::MediaType media_type() const override { - return webrtc::MediaType::VIDEO; - } + MediaType media_type() const override { return MediaType::VIDEO; } std::string id() const override { return id_; } diff --git a/pc/video_track_unittest.cc b/pc/video_track_unittest.cc index c003a51bb5..bdf8f72881 100644 --- a/pc/video_track_unittest.cc +++ b/pc/video_track_unittest.cc @@ -18,34 +18,28 @@ #include "media/base/fake_frame_source.h" #include "pc/test/fake_video_track_renderer.h" #include "pc/test/fake_video_track_source.h" -#include "pc/video_track_source.h" #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "test/gtest.h" -using webrtc::FakeVideoTrackRenderer; -using webrtc::FakeVideoTrackSource; -using webrtc::MediaSourceInterface; -using webrtc::MediaStreamTrackInterface; -using webrtc::VideoTrack; -using webrtc::VideoTrackInterface; -using webrtc::VideoTrackSource; +namespace webrtc { +namespace { class VideoTrackTest : public ::testing::Test { public: - VideoTrackTest() : frame_source_(640, 480, webrtc::kNumMicrosecsPerSec / 30) { + VideoTrackTest() : frame_source_(640, 480, kNumMicrosecsPerSec / 30) { static const char kVideoTrackId[] = "track_id"; - video_track_source_ = webrtc::make_ref_counted( + video_track_source_ = make_ref_counted( /*is_screencast=*/false); video_track_ = VideoTrack::Create(kVideoTrackId, video_track_source_, - webrtc::Thread::Current()); + Thread::Current()); } protected: - webrtc::AutoThread main_thread_; - webrtc::scoped_refptr video_track_source_; - webrtc::scoped_refptr video_track_; - webrtc::FakeFrameSource frame_source_; + AutoThread main_thread_; + scoped_refptr video_track_source_; + scoped_refptr video_track_; + FakeFrameSource frame_source_; }; // VideoTrack::Create will create an API proxy around the source object. @@ -105,3 +99,6 @@ TEST_F(VideoTrackTest, DisableTrackBlackout) { EXPECT_EQ(3, renderer->num_rendered_frames()); EXPECT_FALSE(renderer->black_frame()); } + +} // namespace +} // namespace webrtc diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index a87a82c6a9..958287c5e7 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -30,6 +30,7 @@ #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include "api/audio/audio_view.h" #include "api/candidate.h" #include "api/jsep.h" #include "api/jsep_ice_candidate.h" @@ -68,34 +69,6 @@ #include "rtc_base/string_encode.h" #include "rtc_base/strings/string_builder.h" -using ::webrtc::AudioContentDescription; -using webrtc::Candidate; -using ::webrtc::Candidates; -using ::webrtc::ContentInfo; -using ::webrtc::ICE_CANDIDATE_COMPONENT_RTCP; -using ::webrtc::ICE_CANDIDATE_COMPONENT_RTP; -using ::webrtc::kApplicationSpecificBandwidth; -using ::webrtc::kCodecParamMaxPTime; -using ::webrtc::kCodecParamMinPTime; -using ::webrtc::kCodecParamPTime; -using ::webrtc::kTransportSpecificBandwidth; -using ::webrtc::MediaContentDescription; -using ::webrtc::MediaProtocolType; -using ::webrtc::RidDescription; -using ::webrtc::RtpHeaderExtensions; -using ::webrtc::SctpDataContentDescription; -using ::webrtc::SimulcastDescription; -using ::webrtc::SimulcastLayer; -using ::webrtc::SimulcastLayerList; -using ::webrtc::SocketAddress; -using ::webrtc::SsrcGroup; -using ::webrtc::StreamParams; -using ::webrtc::StreamParamsVec; -using ::webrtc::TransportDescription; -using ::webrtc::TransportInfo; -using ::webrtc::UnsupportedContentDescription; -using ::webrtc::VideoContentDescription; - // TODO(deadbeef): Switch to using anonymous namespace rather than declaring // everything "static". namespace webrtc { @@ -203,8 +176,8 @@ static const char kCandidatePrflx[] = "prflx"; static const char kCandidateRelay[] = "relay"; static const char kTcpCandidateType[] = "tcptype"; -// webrtc::StringBuilder doesn't have a << overload for chars, while -// webrtc::split and webrtc::tokenize_first both take a char delimiter. To +// StringBuilder doesn't have a << overload for chars, while +// split and tokenize_first both take a char delimiter. To // handle both cases these constants come in pairs of a chars and length-one // strings. static const char kSdpDelimiterEqual[] = "="; @@ -254,9 +227,6 @@ static const char kDefaultSctpmapProtocol[] = "webrtc-datachannel"; // types. const int kWildcardPayloadType = -1; -// Maximum number of channels allowed. -static const size_t kMaxNumberOfChannels = 24; - struct SsrcInfo { uint32_t ssrc_id; std::string cname; @@ -268,22 +238,22 @@ using SsrcGroupVec = std::vector; static void BuildMediaDescription(const ContentInfo* content_info, const TransportInfo* transport_info, - const webrtc::MediaType media_type, + const MediaType media_type, const std::vector& candidates, int msid_signaling, std::string* message); -static void BuildMediaLine(const webrtc::MediaType media_type, +static void BuildMediaLine(const MediaType media_type, const ContentInfo* content_info, const MediaContentDescription* media_desc, std::string* message); static void BuildRtpContentAttributes(const MediaContentDescription* media_desc, - const webrtc::MediaType media_type, + const MediaType media_type, int msid_signaling, std::string* message); static void BuildRtpHeaderExtensions(const RtpHeaderExtensions& extensions, std::string* message); static void BuildRtpmap(const MediaContentDescription* media_desc, - const webrtc::MediaType media_type, + const MediaType media_type, std::string* message); static void BuildCandidate(const std::vector& candidates, bool include_ufrag, @@ -314,7 +284,7 @@ static bool ParseMediaDescription( SdpParseError* error); static bool ParseContent( absl::string_view message, - const webrtc::MediaType media_type, + const MediaType media_type, int mline_index, absl::string_view protocol, const std::vector& payload_types, @@ -337,12 +307,12 @@ static bool ParseSsrcGroupAttribute(absl::string_view line, SsrcGroupVec* ssrc_groups, SdpParseError* error); static bool ParseRtpmapAttribute(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, const std::vector& payload_types, MediaContentDescription* media_desc, SdpParseError* error); static bool ParseFmtpAttributes(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error); static bool ParseFmtpParam(absl::string_view line, @@ -350,11 +320,11 @@ static bool ParseFmtpParam(absl::string_view line, std::string* value, SdpParseError* error); static bool ParsePacketizationAttribute(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error); static bool ParseRtcpFbAttribute(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error); static bool ParseIceOptions(absl::string_view line, @@ -876,7 +846,7 @@ std::string SdpSerialize(const JsepSessionDescription& jdesc) { desc->GetGroupsByName(GROUP_TYPE_BUNDLE); for (const ContentGroup* group : groups) { std::string group_line = kAttrGroup; - RTC_DCHECK(group != NULL); + RTC_DCHECK(group != nullptr); for (const std::string& content_name : group->content_names()) { group_line.append(" "); group_line.append(content_name); @@ -891,7 +861,7 @@ std::string SdpSerialize(const JsepSessionDescription& jdesc) { } // MediaStream semantics. - // TODO(bugs.webrtc.org/10421): Change to & webrtc::kMsidSignalingSemantic + // TODO(bugs.webrtc.org/10421): Change to & kMsidSignalingSemantic // when we think it's safe to do so, so that we gradually fade out this old // line that was removed from the specification. if (desc->msid_signaling() != kMsidSignalingNotUsed) { @@ -998,7 +968,7 @@ bool SdpDeserialize(absl::string_view message, bool SdpDeserializeCandidate(absl::string_view message, JsepIceCandidate* jcandidate, SdpParseError* error) { - RTC_DCHECK(jcandidate != NULL); + RTC_DCHECK(jcandidate != nullptr); Candidate candidate; if (!ParseCandidate(message, &candidate, error, true)) { return false; @@ -1023,7 +993,7 @@ bool ParseCandidate(absl::string_view message, Candidate* candidate, SdpParseError* error, bool is_raw) { - RTC_DCHECK(candidate != NULL); + RTC_DCHECK(candidate != nullptr); // Makes sure `message` contains only one line. absl::string_view first_line; @@ -1320,8 +1290,14 @@ bool ParseExtmap(absl::string_view line, } static void BuildSctpContentAttributes( - std::string* message, - const SctpDataContentDescription* data_desc) { + const MediaContentDescription* media_desc, + std::string* message) { + const SctpDataContentDescription* data_desc = media_desc->as_sctp(); + if (!data_desc) { + // Ignore unsupported media types with the SCTP protocol. + return; + } + StringBuilder os; if (data_desc->use_sctpmap()) { // draft-ietf-mmusic-sctp-sdp-04 @@ -1398,7 +1374,7 @@ void BuildDtlsFingerprintSetup(const TransportInfo* transport_info, } } -void BuildMediaLine(const webrtc::MediaType media_type, +void BuildMediaLine(const MediaType media_type, const ContentInfo* content_info, const MediaContentDescription* media_desc, std::string* message) { @@ -1409,15 +1385,14 @@ void BuildMediaLine(const webrtc::MediaType media_type, // fmt is a list of payload type numbers that MAY be used in the session. std::string type; std::string fmt; - if (media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO) { - type = media_type == webrtc::MediaType::AUDIO ? kSdpMediaTypeAudio - : kSdpMediaTypeVideo; + if (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO) { + type = media_type == MediaType::AUDIO ? kSdpMediaTypeAudio + : kSdpMediaTypeVideo; for (const Codec& codec : media_desc->codecs()) { fmt.append(" "); fmt.append(absl::StrCat(codec.id)); } - } else if (media_type == webrtc::MediaType::DATA) { + } else if (media_type == MediaType::DATA) { type = kSdpMediaTypeData; const SctpDataContentDescription* sctp_data_desc = media_desc->as_sctp(); if (sctp_data_desc) { @@ -1431,7 +1406,7 @@ void BuildMediaLine(const webrtc::MediaType media_type, } else { RTC_DCHECK_NOTREACHED() << "Data description without SCTP"; } - } else if (media_type == webrtc::MediaType::UNSUPPORTED) { + } else if (media_type == MediaType::UNSUPPORTED) { const UnsupportedContentDescription* unsupported_desc = media_desc->as_unsupported(); type = unsupported_desc->media_type(); @@ -1469,7 +1444,7 @@ void BuildMediaLine(const webrtc::MediaType media_type, void BuildMediaDescription(const ContentInfo* content_info, const TransportInfo* transport_info, - const webrtc::MediaType media_type, + const MediaType media_type, const std::vector& candidates, int msid_signaling, std::string* message) { @@ -1553,15 +1528,14 @@ void BuildMediaDescription(const ContentInfo* content_info, AddLine(os.str(), message); if (IsDtlsSctp(media_desc->protocol())) { - const SctpDataContentDescription* data_desc = media_desc->as_sctp(); - BuildSctpContentAttributes(message, data_desc); + BuildSctpContentAttributes(media_desc, message); } else if (IsRtpProtocol(media_desc->protocol())) { BuildRtpContentAttributes(media_desc, media_type, msid_signaling, message); } } void BuildRtpContentAttributes(const MediaContentDescription* media_desc, - const webrtc::MediaType media_type, + const MediaType media_type, int msid_signaling, std::string* message) { SimulcastSdpSerializer serializer; @@ -1798,7 +1772,7 @@ bool IsFmtpParam(absl::string_view name) { return name != kCodecParamPTime && name != kCodecParamMaxPTime; } -bool WriteFmtpParameters(const webrtc::CodecParameterMap& parameters, +bool WriteFmtpParameters(const CodecParameterMap& parameters, StringBuilder* os) { bool empty = true; const char* delimiter = ""; // No delimiter before first parameter. @@ -1861,7 +1835,7 @@ bool GetMinValue(const std::vector& values, int* value) { } bool GetParameter(const std::string& name, - const webrtc::CodecParameterMap& params, + const CodecParameterMap& params, int* value) { std::map::const_iterator found = params.find(name); if (found == params.end()) { @@ -1874,12 +1848,12 @@ bool GetParameter(const std::string& name, } void BuildRtpmap(const MediaContentDescription* media_desc, - const webrtc::MediaType media_type, + const MediaType media_type, std::string* message) { - RTC_DCHECK(message != NULL); - RTC_DCHECK(media_desc != NULL); + RTC_DCHECK(message != nullptr); + RTC_DCHECK(media_desc != nullptr); StringBuilder os; - if (media_type == webrtc::MediaType::VIDEO) { + if (media_type == MediaType::VIDEO) { for (const Codec& codec : media_desc->codecs()) { // RFC 4566 // a=rtpmap: / @@ -1894,7 +1868,7 @@ void BuildRtpmap(const MediaContentDescription* media_desc, AddRtcpFbLines(codec, message); AddFmtpLine(codec, message); } - } else if (media_type == webrtc::MediaType::AUDIO) { + } else if (media_type == MediaType::AUDIO) { std::vector ptimes; std::vector maxptimes; int max_minptime = 0; @@ -2256,7 +2230,7 @@ bool ParseSessionDescription(absl::string_view message, bool ParseGroupAttribute(absl::string_view line, SessionDescription* desc, SdpParseError* error) { - RTC_DCHECK(desc != NULL); + RTC_DCHECK(desc != nullptr); // RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00 // a=group:BUNDLE video voice @@ -2580,7 +2554,7 @@ static void BackfillCodecParameters(std::vector& codecs) { static std::unique_ptr ParseContentDescription( absl::string_view message, - const webrtc::MediaType media_type, + const MediaType media_type, int mline_index, absl::string_view protocol, const std::vector& payload_types, @@ -2592,9 +2566,9 @@ static std::unique_ptr ParseContentDescription( std::vector>* candidates, SdpParseError* error) { std::unique_ptr media_desc; - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { media_desc = std::make_unique(); - } else if (media_type == webrtc::MediaType::VIDEO) { + } else if (media_type == MediaType::VIDEO) { media_desc = std::make_unique(); } else { RTC_DCHECK_NOTREACHED(); @@ -2651,7 +2625,7 @@ bool ParseMediaDescription( SessionDescription* desc, std::vector>* candidates, SdpParseError* error) { - RTC_DCHECK(desc != NULL); + RTC_DCHECK(desc != nullptr); int mline_index = -1; int msid_signaling = desc->msid_signaling(); @@ -2714,14 +2688,14 @@ bool ParseMediaDescription( } if (media_type == kSdpMediaTypeVideo) { content = ParseContentDescription( - message, webrtc::MediaType::VIDEO, mline_index, protocol, - payload_types, pos, &content_name, &bundle_only, - §ion_msid_signaling, &transport, candidates, error); + message, MediaType::VIDEO, mline_index, protocol, payload_types, pos, + &content_name, &bundle_only, §ion_msid_signaling, &transport, + candidates, error); } else if (media_type == kSdpMediaTypeAudio) { content = ParseContentDescription( - message, webrtc::MediaType::AUDIO, mline_index, protocol, - payload_types, pos, &content_name, &bundle_only, - §ion_msid_signaling, &transport, candidates, error); + message, MediaType::AUDIO, mline_index, protocol, payload_types, pos, + &content_name, &bundle_only, §ion_msid_signaling, &transport, + candidates, error); } else if (media_type == kSdpMediaTypeData && IsDtlsSctp(protocol)) { // The draft-03 format is: // m=application DTLS/SCTP ... @@ -2739,7 +2713,7 @@ bool ParseMediaDescription( } else if (fields[3] == kDefaultSctpmapProtocol) { data_desc->set_use_sctpmap(false); } - if (!ParseContent(message, webrtc::MediaType::DATA, mline_index, protocol, + if (!ParseContent(message, MediaType::DATA, mline_index, protocol, payload_types, pos, &content_name, &bundle_only, §ion_msid_signaling, data_desc.get(), &transport, candidates, error)) { @@ -2751,11 +2725,10 @@ bool ParseMediaDescription( RTC_LOG(LS_WARNING) << "Unsupported media type: " << *mline; auto unsupported_desc = std::make_unique(media_type); - if (!ParseContent(message, webrtc::MediaType::UNSUPPORTED, mline_index, - protocol, payload_types, pos, &content_name, - &bundle_only, §ion_msid_signaling, - unsupported_desc.get(), &transport, candidates, - error)) { + if (!ParseContent(message, MediaType::UNSUPPORTED, mline_index, protocol, + payload_types, pos, &content_name, &bundle_only, + §ion_msid_signaling, unsupported_desc.get(), + &transport, candidates, error)) { return false; } unsupported_desc->set_protocol(protocol); @@ -2841,7 +2814,7 @@ bool ParseMediaDescription( return true; } -void AddParameters(const webrtc::CodecParameterMap& parameters, Codec* codec) { +void AddParameters(const CodecParameterMap& parameters, Codec* codec) { for (const auto& entry : parameters) { const std::string& key = entry.first; const std::string& value = entry.second; @@ -2863,15 +2836,15 @@ void AddFeedbackParameters(const FeedbackParams& feedback_params, // Gets the current codec setting associated with `payload_type`. If there // is no Codec associated with that payload type it returns an empty codec // with that payload type. -Codec GetCodecWithPayloadType(webrtc::MediaType type, +Codec GetCodecWithPayloadType(MediaType type, const std::vector& codecs, int payload_type) { const Codec* codec = FindCodecById(codecs, payload_type); if (codec) return *codec; // Return empty codec with `payload_type`. - if (type == webrtc::MediaType::AUDIO) { - return CreateAudioCodec(payload_type, "", 0, 0); + if (type == MediaType::AUDIO) { + return CreateAudioCodec(payload_type, "", kDefaultAudioClockRateHz, 0); } else { return CreateVideoCodec(payload_type, ""); } @@ -2901,7 +2874,7 @@ void AddOrReplaceCodec(MediaContentDescription* content_desc, // to `parameters`. void UpdateCodec(MediaContentDescription* content_desc, int payload_type, - const webrtc::CodecParameterMap& parameters) { + const CodecParameterMap& parameters) { // Codec might already have been populated (from rtpmap). Codec new_codec = GetCodecWithPayloadType( content_desc->type(), content_desc->codecs(), payload_type); @@ -2982,7 +2955,7 @@ void AddAudioAttribute(const std::string& name, } bool ParseContent(absl::string_view message, - const webrtc::MediaType media_type, + const MediaType media_type, int mline_index, absl::string_view protocol, const std::vector& payload_types, @@ -2994,11 +2967,11 @@ bool ParseContent(absl::string_view message, TransportDescription* transport, std::vector>* candidates, SdpParseError* error) { - RTC_DCHECK(media_desc != NULL); - RTC_DCHECK(content_name != NULL); - RTC_DCHECK(transport != NULL); + RTC_DCHECK(media_desc != nullptr); + RTC_DCHECK(content_name != nullptr); + RTC_DCHECK(transport != nullptr); - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { MaybeCreateStaticPayloadAudioCodecs(payload_types, media_desc); } @@ -3142,7 +3115,7 @@ bool ParseContent(absl::string_view message, if (!ParseDtlsSetup(*line, &(transport->connection_role), error)) { return false; } - } else if (IsDtlsSctp(protocol) && media_type == webrtc::MediaType::DATA) { + } else if (IsDtlsSctp(protocol) && media_type == MediaType::DATA) { // // SCTP specific attributes // @@ -3344,7 +3317,7 @@ bool ParseContent(absl::string_view message, if (!ssrc_infos.empty()) { CreateTracksFromSsrcInfos(ssrc_infos, stream_ids, track_id, &tracks, *msid_signaling); - } else if (media_type != webrtc::MediaType::DATA && + } else if (media_type != MediaType::DATA && (*msid_signaling & kMsidSignalingMediaSection)) { // If the stream_ids/track_id was signaled but SSRCs were unsignaled we // still create a track. This isn't done for data media types because @@ -3383,7 +3356,7 @@ bool ParseContent(absl::string_view message, [](const Codec codec) { return !codec.name.empty(); })) { return ParseFailed("Failed to parse codecs correctly.", error); } - if (media_type == webrtc::MediaType::AUDIO) { + if (media_type == MediaType::AUDIO) { AddAudioAttribute(kCodecParamMaxPTime, maxptime_as_string, media_desc); AddAudioAttribute(kCodecParamPTime, ptime_as_string, media_desc); } @@ -3407,7 +3380,7 @@ bool ParseSsrcAttribute(absl::string_view line, SsrcInfoVec* ssrc_infos, int* msid_signaling, SdpParseError* error) { - RTC_DCHECK(ssrc_infos != NULL); + RTC_DCHECK(ssrc_infos != nullptr); // RFC 5576 // a=ssrc: // a=ssrc: : @@ -3479,7 +3452,7 @@ bool ParseSsrcAttribute(absl::string_view line, bool ParseSsrcGroupAttribute(absl::string_view line, SsrcGroupVec* ssrc_groups, SdpParseError* error) { - RTC_DCHECK(ssrc_groups != NULL); + RTC_DCHECK(ssrc_groups != nullptr); // RFC 5576 // a=ssrc-group: ... std::vector fields = @@ -3542,7 +3515,7 @@ void UpdateCodec(int payload_type, } bool ParseRtpmapAttribute(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, const std::vector& payload_types, MediaContentDescription* media_desc, SdpParseError* error) { @@ -3586,7 +3559,7 @@ bool ParseRtpmapAttribute(absl::string_view line, return false; } - if (media_type == webrtc::MediaType::VIDEO) { + if (media_type == MediaType::VIDEO) { for (const Codec& existing_codec : media_desc->codecs()) { if (!existing_codec.name.empty() && payload_type == existing_codec.id && (!absl::EqualsIgnoreCase(encoding_name, existing_codec.name) || @@ -3602,7 +3575,7 @@ bool ParseRtpmapAttribute(absl::string_view line, } } UpdateCodec(payload_type, encoding_name, media_desc); - } else if (media_type == webrtc::MediaType::AUDIO) { + } else if (media_type == MediaType::AUDIO) { // RFC 4566 // For audio streams, indicates the number // of audio channels. This parameter is OPTIONAL and may be @@ -3614,8 +3587,11 @@ bool ParseRtpmapAttribute(absl::string_view line, return false; } } - if (channels > kMaxNumberOfChannels) { - return ParseFailed(line, "At most 24 channels are supported.", error); + if (channels > kMaxNumberOfAudioChannels) { + StringBuilder description; + description << "At most " << kMaxNumberOfAudioChannels + << " channels are supported."; + return ParseFailed(line, description.Release(), error); } for (const Codec& existing_codec : media_desc->codecs()) { @@ -3654,7 +3630,7 @@ bool ParseFmtpParam(absl::string_view line, } bool ParseFmtpParameterSet(absl::string_view line_params, - webrtc::CodecParameterMap& codec_params, + CodecParameterMap& codec_params, SdpParseError* error) { // Parse out format specific parameters. for (absl::string_view param : @@ -3675,11 +3651,10 @@ bool ParseFmtpParameterSet(absl::string_view line_params, } bool ParseFmtpAttributes(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error) { - if (media_type != webrtc::MediaType::AUDIO && - media_type != webrtc::MediaType::VIDEO) { + if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) { return true; } @@ -3709,23 +3684,22 @@ bool ParseFmtpAttributes(absl::string_view line, } // Parse out format specific parameters. - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; if (!ParseFmtpParameterSet(line_params, codec_params, error)) { return false; } - if (media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO) { + if (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO) { UpdateCodec(media_desc, payload_type, codec_params); } return true; } bool ParsePacketizationAttribute(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error) { - if (media_type != webrtc::MediaType::VIDEO) { + if (media_type != MediaType::VIDEO) { return true; } std::vector packetization_fields = @@ -3749,11 +3723,10 @@ bool ParsePacketizationAttribute(absl::string_view line, } bool ParseRtcpFbAttribute(absl::string_view line, - const webrtc::MediaType media_type, + const MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error) { - if (media_type != webrtc::MediaType::AUDIO && - media_type != webrtc::MediaType::VIDEO) { + if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) { return true; } std::vector rtcp_fb_fields = @@ -3781,8 +3754,7 @@ bool ParseRtcpFbAttribute(absl::string_view line, } const FeedbackParam feedback_param(id, param); - if (media_type == webrtc::MediaType::AUDIO || - media_type == webrtc::MediaType::VIDEO) { + if (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO) { UpdateCodec(media_desc, payload_type, feedback_param); } return true; diff --git a/pc/webrtc_sdp.h b/pc/webrtc_sdp.h index 884b45414a..f44df2aa46 100644 --- a/pc/webrtc_sdp.h +++ b/pc/webrtc_sdp.h @@ -27,7 +27,7 @@ #include "api/jsep.h" #include "api/jsep_ice_candidate.h" #include "api/jsep_session_description.h" -#include "media/base/codec.h" +#include "api/rtp_parameters.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/system/rtc_export.h" @@ -100,12 +100,12 @@ RTC_EXPORT bool ParseCandidate(absl::string_view message, // parameters are not considered to be part of the FMTP line, see the function // IsFmtpParam(). Returns true if the set of FMTP parameters is nonempty, false // otherwise. -bool WriteFmtpParameters(const webrtc::CodecParameterMap& parameters, +bool WriteFmtpParameters(const CodecParameterMap& parameters, StringBuilder* os); // Parses a string into an FMTP parameter set, in key-value format. bool ParseFmtpParameterSet(absl::string_view line_params, - webrtc::CodecParameterMap& codec_params, + CodecParameterMap& codec_params, SdpParseError* error); } // namespace webrtc diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc index ba696d4b41..844973a53f 100644 --- a/pc/webrtc_sdp_unittest.cc +++ b/pc/webrtc_sdp_unittest.cc @@ -56,37 +56,13 @@ #endif #include "pc/webrtc_sdp.h" +namespace webrtc { + +namespace { + using ::testing::ElementsAre; using ::testing::Field; using ::testing::Property; -using ::webrtc::AudioContentDescription; -using webrtc::Candidate; -using ::webrtc::ContentGroup; -using ::webrtc::ContentInfo; -using ::webrtc::ICE_CANDIDATE_COMPONENT_RTCP; -using ::webrtc::ICE_CANDIDATE_COMPONENT_RTP; -using webrtc::IceCandidateCollection; -using webrtc::IceCandidateInterface; -using webrtc::IceCandidateType; -using webrtc::JsepIceCandidate; -using webrtc::JsepSessionDescription; -using ::webrtc::kFecSsrcGroupSemantics; -using ::webrtc::MediaProtocolType; -using ::webrtc::RidDescription; -using ::webrtc::RidDirection; -using webrtc::RtpExtension; -using webrtc::RtpTransceiverDirection; -using ::webrtc::SctpDataContentDescription; -using webrtc::SdpParseError; -using webrtc::SdpType; -using ::webrtc::SessionDescription; -using webrtc::SessionDescriptionInterface; -using ::webrtc::SimulcastDescription; -using ::webrtc::SimulcastLayer; -using ::webrtc::StreamParams; -using ::webrtc::TransportDescription; -using ::webrtc::TransportInfo; -using ::webrtc::VideoContentDescription; static const uint32_t kDefaultSctpPort = 5000; static const uint16_t kUnusualSctpPort = 9556; @@ -860,12 +836,12 @@ static SdpType kDummyType = SdpType::kOffer; static bool SdpDeserialize(const std::string& message, JsepSessionDescription* jdesc) { - return webrtc::SdpDeserialize(message, jdesc, NULL); + return SdpDeserialize(message, jdesc, nullptr); } static bool SdpDeserializeCandidate(const std::string& message, JsepIceCandidate* candidate) { - return webrtc::SdpDeserializeCandidate(message, candidate, NULL); + return SdpDeserializeCandidate(message, candidate, nullptr); } // Add some extra `newlines` to the `message` after `line`. @@ -887,7 +863,7 @@ static void ExpectParseFailure(const std::string& bad_sdp, const std::string& bad_part) { JsepSessionDescription desc(kDummyType); SdpParseError error; - bool ret = webrtc::SdpDeserialize(bad_sdp, &desc, &error); + bool ret = SdpDeserialize(bad_sdp, &desc, &error); ASSERT_FALSE(ret); EXPECT_NE(std::string::npos, error.line.find(bad_part.c_str())) << "Did not find " << bad_part << " in " << error.line; @@ -951,10 +927,9 @@ static void ReplaceRejected(bool audio_rejected, static TransportDescription MakeTransportDescription(std::string ufrag, std::string pwd) { - webrtc::SSLFingerprint fingerprint(webrtc::DIGEST_SHA_1, kIdentityDigest); + SSLFingerprint fingerprint(DIGEST_SHA_1, kIdentityDigest); return TransportDescription(std::vector(), ufrag, pwd, - webrtc::ICEMODE_FULL, webrtc::CONNECTIONROLE_NONE, - &fingerprint); + ICEMODE_FULL, CONNECTIONROLE_NONE, &fingerprint); } // WebRtcSdpTest @@ -963,7 +938,7 @@ class WebRtcSdpTest : public ::testing::Test { public: WebRtcSdpTest() : jdesc_(kDummyType) { #ifdef WEBRTC_ANDROID - webrtc::InitializeAndroidObjects(); + InitializeAndroidObjects(); #endif // AudioContentDescription audio_desc_ = CreateAudioContentDescription(); @@ -973,7 +948,7 @@ class WebRtcSdpTest : public ::testing::Test { audio_stream.set_stream_ids({kStreamId1}); audio_stream.ssrcs.push_back(kAudioTrack1Ssrc); audio_desc_->AddStream(audio_stream); - webrtc::SocketAddress audio_addr("74.125.127.126", 2345); + SocketAddress audio_addr("74.125.127.126", 2345); audio_desc_->set_connection_address(audio_addr); desc_.AddContent(kAudioContentName, MediaProtocolType::kRtp, absl::WrapUnique(audio_desc_)); @@ -986,17 +961,16 @@ class WebRtcSdpTest : public ::testing::Test { video_stream.set_stream_ids({kStreamId1}); video_stream.ssrcs.push_back(kVideoTrack1Ssrc1); video_stream.ssrcs.push_back(kVideoTrack1Ssrc2); - webrtc::SsrcGroup ssrc_group(webrtc::kFecSsrcGroupSemantics, - video_stream.ssrcs); + SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs); video_stream.ssrc_groups.push_back(ssrc_group); video_desc_->AddStream(video_stream); - webrtc::SocketAddress video_addr("74.125.224.39", 3457); + SocketAddress video_addr("74.125.224.39", 3457); video_desc_->set_connection_address(video_addr); desc_.AddContent(kVideoContentName, MediaProtocolType::kRtp, absl::WrapUnique(video_desc_)); // TransportInfo, with fingerprint - webrtc::SSLFingerprint fingerprint(webrtc::DIGEST_SHA_1, kIdentityDigest); + SSLFingerprint fingerprint(DIGEST_SHA_1, kIdentityDigest); desc_.AddTransportInfo(TransportInfo( kAudioContentName, MakeTransportDescription(kUfragVoice, kPwdVoice))); desc_.AddTransportInfo(TransportInfo( @@ -1004,75 +978,67 @@ class WebRtcSdpTest : public ::testing::Test { // v4 host int port = 1234; - webrtc::SocketAddress address("192.168.1.5", port++); - Candidate candidate1(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", address, + SocketAddress address("192.168.1.5", port++); + Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "udp", address, kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation1); address.SetPort(port++); - Candidate candidate2(webrtc::ICE_CANDIDATE_COMPONENT_RTCP, "udp", address, + Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address, kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation1); address.SetPort(port++); - Candidate candidate3(webrtc::ICE_CANDIDATE_COMPONENT_RTCP, "udp", address, + Candidate candidate3(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address, kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation1); address.SetPort(port++); - Candidate candidate4(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", address, + Candidate candidate4(ICE_CANDIDATE_COMPONENT_RTP, "udp", address, kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation1); // v6 host - webrtc::SocketAddress v6_address("::1", port++); - webrtc::Candidate candidate5(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - v6_address, kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, - kCandidateFoundation2); + SocketAddress v6_address("::1", port++); + Candidate candidate5(ICE_CANDIDATE_COMPONENT_RTP, "udp", v6_address, + kCandidatePriority, "", "", IceCandidateType::kHost, + kCandidateGeneration, kCandidateFoundation2); v6_address.SetPort(port++); - webrtc::Candidate candidate6(webrtc::ICE_CANDIDATE_COMPONENT_RTCP, "udp", - v6_address, kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, - kCandidateFoundation2); + Candidate candidate6(ICE_CANDIDATE_COMPONENT_RTCP, "udp", v6_address, + kCandidatePriority, "", "", IceCandidateType::kHost, + kCandidateGeneration, kCandidateFoundation2); v6_address.SetPort(port++); - webrtc::Candidate candidate7(webrtc::ICE_CANDIDATE_COMPONENT_RTCP, "udp", - v6_address, kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, - kCandidateFoundation2); + Candidate candidate7(ICE_CANDIDATE_COMPONENT_RTCP, "udp", v6_address, + kCandidatePriority, "", "", IceCandidateType::kHost, + kCandidateGeneration, kCandidateFoundation2); v6_address.SetPort(port++); - webrtc::Candidate candidate8(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - v6_address, kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, - kCandidateFoundation2); + Candidate candidate8(ICE_CANDIDATE_COMPONENT_RTP, "udp", v6_address, + kCandidatePriority, "", "", IceCandidateType::kHost, + kCandidateGeneration, kCandidateFoundation2); // stun int port_stun = 2345; - webrtc::SocketAddress address_stun("74.125.127.126", port_stun++); - webrtc::SocketAddress rel_address_stun("192.168.1.5", port_stun++); - webrtc::Candidate candidate9(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - address_stun, kCandidatePriority, "", "", - IceCandidateType::kSrflx, kCandidateGeneration, - kCandidateFoundation3); + SocketAddress address_stun("74.125.127.126", port_stun++); + SocketAddress rel_address_stun("192.168.1.5", port_stun++); + Candidate candidate9(ICE_CANDIDATE_COMPONENT_RTP, "udp", address_stun, + kCandidatePriority, "", "", IceCandidateType::kSrflx, + kCandidateGeneration, kCandidateFoundation3); candidate9.set_related_address(rel_address_stun); address_stun.SetPort(port_stun++); rel_address_stun.SetPort(port_stun++); - webrtc::Candidate candidate10(webrtc::ICE_CANDIDATE_COMPONENT_RTCP, "udp", - address_stun, kCandidatePriority, "", "", - IceCandidateType::kSrflx, - kCandidateGeneration, kCandidateFoundation3); + Candidate candidate10(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address_stun, + kCandidatePriority, "", "", IceCandidateType::kSrflx, + kCandidateGeneration, kCandidateFoundation3); candidate10.set_related_address(rel_address_stun); // relay int port_relay = 3456; - webrtc::SocketAddress address_relay("74.125.224.39", port_relay++); - webrtc::Candidate candidate11(webrtc::ICE_CANDIDATE_COMPONENT_RTCP, "udp", - address_relay, kCandidatePriority, "", "", - IceCandidateType::kRelay, - kCandidateGeneration, kCandidateFoundation4); + SocketAddress address_relay("74.125.224.39", port_relay++); + Candidate candidate11(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address_relay, + kCandidatePriority, "", "", IceCandidateType::kRelay, + kCandidateGeneration, kCandidateFoundation4); address_relay.SetPort(port_relay++); - webrtc::Candidate candidate12(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - address_relay, kCandidatePriority, "", "", - IceCandidateType::kRelay, - kCandidateGeneration, kCandidateFoundation4); + Candidate candidate12(ICE_CANDIDATE_COMPONENT_RTP, "udp", address_relay, + kCandidatePriority, "", "", IceCandidateType::kRelay, + kCandidateGeneration, kCandidateFoundation4); // voice candidates_.push_back(candidate1); @@ -1112,9 +1078,9 @@ class WebRtcSdpTest : public ::testing::Test { const IceCandidateCollection* video_candidates_collection = jdesc_.candidates(1); ASSERT_NE(nullptr, video_candidates_collection); - std::vector video_candidates; + std::vector video_candidates; for (size_t i = 0; i < video_candidates_collection->count(); ++i) { - webrtc::Candidate c = video_candidates_collection->at(i)->candidate(); + Candidate c = video_candidates_collection->at(i)->candidate(); c.set_transport_name("video_content_name"); video_candidates.push_back(c); } @@ -1131,13 +1097,13 @@ class WebRtcSdpTest : public ::testing::Test { desc_.transport_infos()[1].description.ice_ufrag.clear(); desc_.transport_infos()[1].description.ice_pwd.clear(); desc_.transport_infos()[1].description.connection_role = - webrtc::CONNECTIONROLE_NONE; + CONNECTIONROLE_NONE; // Set bundle-only flag. desc_.contents()[1].bundle_only = true; // Add BUNDLE group. - ContentGroup group(webrtc::GROUP_TYPE_BUNDLE); + ContentGroup group(GROUP_TYPE_BUNDLE); group.AddContentName(kAudioContentName); group.AddContentName(kVideoContentName); desc_.AddGroup(group); @@ -1179,8 +1145,8 @@ class WebRtcSdpTest : public ::testing::Test { absl::WrapUnique(audio_desc_)); desc_.AddContent(kVideoContentName, MediaProtocolType::kRtp, absl::WrapUnique(video_desc_)); - desc_.set_msid_signaling(webrtc::kMsidSignalingSsrcAttribute | - webrtc::kMsidSignalingSemantic); + desc_.set_msid_signaling(kMsidSignalingSsrcAttribute | + kMsidSignalingSemantic); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); } @@ -1234,8 +1200,8 @@ class WebRtcSdpTest : public ::testing::Test { desc_.AddTransportInfo( TransportInfo(kVideoContentName3, MakeTransportDescription(kUfragVideo3, kPwdVideo3))); - desc_.set_msid_signaling(webrtc::kMsidSignalingMediaSection | - webrtc::kMsidSignalingSemantic); + desc_.set_msid_signaling(kMsidSignalingMediaSection | + kMsidSignalingSemantic); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); @@ -1247,10 +1213,10 @@ class WebRtcSdpTest : public ::testing::Test { AudioContentDescription* audio = new AudioContentDescription(); audio->set_rtcp_mux(true); audio->set_rtcp_reduced_size(true); - audio->set_protocol(webrtc::kMediaProtocolSavpf); - audio->AddCodec(webrtc::CreateAudioCodec(111, "opus", 48000, 2)); - audio->AddCodec(webrtc::CreateAudioCodec(103, "ISAC", 16000, 1)); - audio->AddCodec(webrtc::CreateAudioCodec(104, "ISAC", 32000, 1)); + audio->set_protocol(kMediaProtocolSavpf); + audio->AddCodec(CreateAudioCodec(111, "opus", 48000, 2)); + audio->AddCodec(CreateAudioCodec(103, "ISAC", 16000, 1)); + audio->AddCodec(CreateAudioCodec(104, "ISAC", 32000, 1)); return audio; } @@ -1313,8 +1279,8 @@ class WebRtcSdpTest : public ::testing::Test { absl::WrapUnique(audio_desc)); // Enable signaling a=msid lines. - desc_.set_msid_signaling(webrtc::kMsidSignalingMediaSection | - webrtc::kMsidSignalingSemantic); + desc_.set_msid_signaling(kMsidSignalingMediaSection | + kMsidSignalingSemantic); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); } @@ -1323,14 +1289,13 @@ class WebRtcSdpTest : public ::testing::Test { // configuration. VideoContentDescription* CreateVideoContentDescription() { VideoContentDescription* video = new VideoContentDescription(); - video->set_protocol(webrtc::kMediaProtocolSavpf); - video->AddCodec(webrtc::CreateVideoCodec(120, "VP8")); + video->set_protocol(kMediaProtocolSavpf); + video->AddCodec(CreateVideoCodec(120, "VP8")); return video; } - void CompareMediaContentDescription( - const webrtc::MediaContentDescription* cd1, - const webrtc::MediaContentDescription* cd2) { + void CompareMediaContentDescription(const MediaContentDescription* cd1, + const MediaContentDescription* cd2) { // type EXPECT_EQ(cd1->type(), cd2->type()); @@ -1346,13 +1311,13 @@ class WebRtcSdpTest : public ::testing::Test { // protocol // Use an equivalence class here, for old and new versions of the // protocol description. - if (cd1->protocol() == webrtc::kMediaProtocolDtlsSctp || - cd1->protocol() == webrtc::kMediaProtocolUdpDtlsSctp || - cd1->protocol() == webrtc::kMediaProtocolTcpDtlsSctp) { + if (cd1->protocol() == kMediaProtocolDtlsSctp || + cd1->protocol() == kMediaProtocolUdpDtlsSctp || + cd1->protocol() == kMediaProtocolTcpDtlsSctp) { const bool cd2_is_also_dtls_sctp = - cd2->protocol() == webrtc::kMediaProtocolDtlsSctp || - cd2->protocol() == webrtc::kMediaProtocolUdpDtlsSctp || - cd2->protocol() == webrtc::kMediaProtocolTcpDtlsSctp; + cd2->protocol() == kMediaProtocolDtlsSctp || + cd2->protocol() == kMediaProtocolUdpDtlsSctp || + cd2->protocol() == kMediaProtocolTcpDtlsSctp; EXPECT_TRUE(cd2_is_also_dtls_sctp); } else { EXPECT_EQ(cd1->protocol(), cd2->protocol()); @@ -1416,27 +1381,27 @@ class WebRtcSdpTest : public ::testing::Test { return; } for (size_t i = 0; i < desc1.contents().size(); ++i) { - const webrtc::ContentInfo& c1 = desc1.contents().at(i); - const webrtc::ContentInfo& c2 = desc2.contents().at(i); + const ContentInfo& c1 = desc1.contents().at(i); + const ContentInfo& c2 = desc2.contents().at(i); // ContentInfo properties. EXPECT_EQ(c1.mid(), c2.mid()); EXPECT_EQ(c1.type, c2.type); EXPECT_EQ(c1.rejected, c2.rejected); EXPECT_EQ(c1.bundle_only, c2.bundle_only); - ASSERT_EQ(webrtc::IsAudioContent(&c1), webrtc::IsAudioContent(&c2)); - if (webrtc::IsAudioContent(&c1)) { + ASSERT_EQ(IsAudioContent(&c1), IsAudioContent(&c2)); + if (IsAudioContent(&c1)) { CompareMediaContentDescription(c1.media_description(), c2.media_description()); } - ASSERT_EQ(webrtc::IsVideoContent(&c1), webrtc::IsVideoContent(&c2)); - if (webrtc::IsVideoContent(&c1)) { + ASSERT_EQ(IsVideoContent(&c1), IsVideoContent(&c2)); + if (IsVideoContent(&c1)) { CompareMediaContentDescription(c1.media_description(), c2.media_description()); } - ASSERT_EQ(webrtc::IsDataContent(&c1), webrtc::IsDataContent(&c2)); + ASSERT_EQ(IsDataContent(&c1), IsDataContent(&c2)); if (c1.media_description()->as_sctp()) { ASSERT_TRUE(c2.media_description()->as_sctp()); const SctpDataContentDescription* scd1 = @@ -1452,42 +1417,42 @@ class WebRtcSdpTest : public ::testing::Test { } // group - const webrtc::ContentGroups groups1 = desc1.groups(); - const webrtc::ContentGroups groups2 = desc2.groups(); + const ContentGroups groups1 = desc1.groups(); + const ContentGroups groups2 = desc2.groups(); EXPECT_EQ(groups1.size(), groups1.size()); if (groups1.size() != groups2.size()) { ADD_FAILURE(); return; } for (size_t i = 0; i < groups1.size(); ++i) { - const webrtc::ContentGroup group1 = groups1.at(i); - const webrtc::ContentGroup group2 = groups2.at(i); + const ContentGroup group1 = groups1.at(i); + const ContentGroup group2 = groups2.at(i); EXPECT_EQ(group1.semantics(), group2.semantics()); - const webrtc::ContentNames names1 = group1.content_names(); - const webrtc::ContentNames names2 = group2.content_names(); + const ContentNames names1 = group1.content_names(); + const ContentNames names2 = group2.content_names(); EXPECT_EQ(names1.size(), names2.size()); if (names1.size() != names2.size()) { ADD_FAILURE(); return; } - webrtc::ContentNames::const_iterator iter1 = names1.begin(); - webrtc::ContentNames::const_iterator iter2 = names2.begin(); + ContentNames::const_iterator iter1 = names1.begin(); + ContentNames::const_iterator iter2 = names2.begin(); while (iter1 != names1.end()) { EXPECT_EQ(*iter1++, *iter2++); } } // transport info - const webrtc::TransportInfos transports1 = desc1.transport_infos(); - const webrtc::TransportInfos transports2 = desc2.transport_infos(); + const TransportInfos transports1 = desc1.transport_infos(); + const TransportInfos transports2 = desc2.transport_infos(); EXPECT_EQ(transports1.size(), transports2.size()); if (transports1.size() != transports2.size()) { ADD_FAILURE(); return; } for (size_t i = 0; i < transports1.size(); ++i) { - const webrtc::TransportInfo transport1 = transports1.at(i); - const webrtc::TransportInfo transport2 = transports2.at(i); + const TransportInfo transport1 = transports1.at(i); + const TransportInfo transport2 = transports2.at(i); EXPECT_EQ(transport1.content_name, transport2.content_name); EXPECT_EQ(transport1.description.ice_ufrag, transport2.description.ice_ufrag); @@ -1582,8 +1547,8 @@ class WebRtcSdpTest : public ::testing::Test { void AddIceOptions(const std::string& content_name, const std::vector& transport_options) { - ASSERT_TRUE(desc_.GetTransportInfoByName(content_name) != NULL); - webrtc::TransportInfo transport_info = + ASSERT_TRUE(desc_.GetTransportInfoByName(content_name) != nullptr); + TransportInfo transport_info = *(desc_.GetTransportInfoByName(content_name)); desc_.RemoveTransportInfoByName(content_name); transport_info.description.transport_options = transport_options; @@ -1593,8 +1558,8 @@ class WebRtcSdpTest : public ::testing::Test { void SetIceUfragPwd(const std::string& content_name, const std::string& ice_ufrag, const std::string& ice_pwd) { - ASSERT_TRUE(desc_.GetTransportInfoByName(content_name) != NULL); - webrtc::TransportInfo transport_info = + ASSERT_TRUE(desc_.GetTransportInfoByName(content_name) != nullptr); + TransportInfo transport_info = *(desc_.GetTransportInfoByName(content_name)); desc_.RemoveTransportInfoByName(content_name); transport_info.description.ice_ufrag = ice_ufrag; @@ -1620,7 +1585,7 @@ class WebRtcSdpTest : public ::testing::Test { // Removes everything in StreamParams from the session description that is // used for a=ssrc lines. void RemoveSsrcSignalingFromStreamParams() { - for (webrtc::ContentInfo& content_info : jdesc_.description()->contents()) { + for (ContentInfo& content_info : jdesc_.description()->contents()) { // With Unified Plan there should be one StreamParams per m= section. StreamParams& stream = content_info.media_description()->mutable_streams()[0]; @@ -1672,7 +1637,7 @@ class WebRtcSdpTest : public ::testing::Test { jdesc_.session_version())) { return false; } - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); EXPECT_EQ(new_sdp, message); return true; } @@ -1697,7 +1662,7 @@ class WebRtcSdpTest : public ::testing::Test { JsepSessionDescription jdesc_no_candidates(kDummyType); MakeDescriptionWithoutCandidates(&jdesc_no_candidates); - std::string message = webrtc::SdpSerialize(jdesc_no_candidates); + std::string message = SdpSerialize(jdesc_no_candidates); EXPECT_EQ(new_sdp, message); return true; } @@ -1707,7 +1672,7 @@ class WebRtcSdpTest : public ::testing::Test { new SctpDataContentDescription()); sctp_desc_ = data.get(); sctp_desc_->set_use_sctpmap(use_sctpmap); - sctp_desc_->set_protocol(webrtc::kMediaProtocolUdpDtlsSctp); + sctp_desc_->set_protocol(kMediaProtocolUdpDtlsSctp); sctp_desc_->set_port(kDefaultSctpPort); desc_.AddContent(kDataContentName, MediaProtocolType::kSctp, std::move(data)); @@ -1788,8 +1753,7 @@ class WebRtcSdpTest : public ::testing::Test { // media level. if (session_level && media_level) { SdpParseError error; - EXPECT_FALSE( - webrtc::SdpDeserialize(sdp_with_extmap, &jdesc_with_extmap, &error)); + EXPECT_FALSE(SdpDeserialize(sdp_with_extmap, &jdesc_with_extmap, &error)); EXPECT_NE(std::string::npos, error.description.find("a=extmap")); } else { EXPECT_TRUE(SdpDeserialize(sdp_with_extmap, &jdesc_with_extmap)); @@ -1797,10 +1761,10 @@ class WebRtcSdpTest : public ::testing::Test { } } - void VerifyCodecParameter(const webrtc::CodecParameterMap& params, + void VerifyCodecParameter(const CodecParameterMap& params, const std::string& name, int expected_value) { - webrtc::CodecParameterMap::const_iterator found = params.find(name); + CodecParameterMap::const_iterator found = params.find(name); ASSERT_TRUE(found != params.end()); EXPECT_EQ(found->second, absl::StrCat(expected_value)); } @@ -1851,13 +1815,13 @@ class WebRtcSdpTest : public ::testing::Test { // Deserialize SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, jdesc_output, &error)); + EXPECT_TRUE(SdpDeserialize(sdp, jdesc_output, &error)); const AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(jdesc_output->description()); + GetFirstAudioContentDescription(jdesc_output->description()); ASSERT_TRUE(acd); ASSERT_FALSE(acd->codecs().empty()); - webrtc::Codec opus = acd->codecs()[0]; + Codec opus = acd->codecs()[0]; EXPECT_EQ("opus", opus.name); EXPECT_EQ(111, opus.id); VerifyCodecParameter(opus.params, "minptime", params.min_ptime); @@ -1871,7 +1835,7 @@ class WebRtcSdpTest : public ::testing::Test { VerifyCodecParameter(codec.params, "maxptime", params.max_ptime); } - webrtc::Codec dtmf = acd->codecs()[3]; + Codec dtmf = acd->codecs()[3]; EXPECT_EQ("telephone-event", dtmf.name); EXPECT_EQ(105, dtmf.id); EXPECT_EQ(3u, @@ -1880,18 +1844,18 @@ class WebRtcSdpTest : public ::testing::Test { EXPECT_EQ(dtmf.params.begin()->second, "0-15,66,70"); const VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(jdesc_output->description()); + GetFirstVideoContentDescription(jdesc_output->description()); ASSERT_TRUE(vcd); ASSERT_FALSE(vcd->codecs().empty()); - webrtc::Codec vp8 = vcd->codecs()[0]; + Codec vp8 = vcd->codecs()[0]; EXPECT_EQ("VP8", vp8.name); EXPECT_EQ(99, vp8.id); - webrtc::Codec rtx = vcd->codecs()[1]; + Codec rtx = vcd->codecs()[1]; EXPECT_EQ("RTX", rtx.name); EXPECT_EQ(95, rtx.id); VerifyCodecParameter(rtx.params, "apt", vp8.id); // VP9 is listed last in the m= line so should come after VP8 and RTX. - webrtc::Codec vp9 = vcd->codecs()[2]; + Codec vp9 = vcd->codecs()[2]; EXPECT_EQ("VP9", vp9.name); EXPECT_EQ(96, vp9.id); } @@ -1924,33 +1888,33 @@ class WebRtcSdpTest : public ::testing::Test { std::string sdp = os.str(); // Deserialize SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, jdesc_output, &error)); + EXPECT_TRUE(SdpDeserialize(sdp, jdesc_output, &error)); const AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(jdesc_output->description()); + GetFirstAudioContentDescription(jdesc_output->description()); ASSERT_TRUE(acd); ASSERT_FALSE(acd->codecs().empty()); - webrtc::Codec opus = acd->codecs()[0]; + Codec opus = acd->codecs()[0]; EXPECT_EQ(111, opus.id); - EXPECT_TRUE(opus.HasFeedbackParam(webrtc::FeedbackParam( - webrtc::kRtcpFbParamNack, webrtc::kParamValueEmpty))); + EXPECT_TRUE(opus.HasFeedbackParam( + FeedbackParam(kRtcpFbParamNack, kParamValueEmpty))); const VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(jdesc_output->description()); + GetFirstVideoContentDescription(jdesc_output->description()); ASSERT_TRUE(vcd); ASSERT_FALSE(vcd->codecs().empty()); - webrtc::Codec vp8 = vcd->codecs()[0]; + Codec vp8 = vcd->codecs()[0]; EXPECT_EQ(vp8.name, "VP8"); EXPECT_EQ(101, vp8.id); - EXPECT_TRUE(vp8.HasFeedbackParam(webrtc::FeedbackParam( - webrtc::kRtcpFbParamLntf, webrtc::kParamValueEmpty))); - EXPECT_TRUE(vp8.HasFeedbackParam(webrtc::FeedbackParam( - webrtc::kRtcpFbParamNack, webrtc::kParamValueEmpty))); - EXPECT_TRUE(vp8.HasFeedbackParam(webrtc::FeedbackParam( - webrtc::kRtcpFbParamNack, webrtc::kRtcpFbNackParamPli))); - EXPECT_TRUE(vp8.HasFeedbackParam(webrtc::FeedbackParam( - webrtc::kRtcpFbParamRemb, webrtc::kParamValueEmpty))); - EXPECT_TRUE(vp8.HasFeedbackParam(webrtc::FeedbackParam( - webrtc::kRtcpFbParamCcm, webrtc::kRtcpFbCcmParamFir))); + EXPECT_TRUE(vp8.HasFeedbackParam( + FeedbackParam(kRtcpFbParamLntf, kParamValueEmpty))); + EXPECT_TRUE(vp8.HasFeedbackParam( + FeedbackParam(kRtcpFbParamNack, kParamValueEmpty))); + EXPECT_TRUE(vp8.HasFeedbackParam( + FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli))); + EXPECT_TRUE(vp8.HasFeedbackParam( + FeedbackParam(kRtcpFbParamRemb, kParamValueEmpty))); + EXPECT_TRUE(vp8.HasFeedbackParam( + FeedbackParam(kRtcpFbParamCcm, kRtcpFbCcmParamFir))); } // Two SDP messages can mean the same thing but be different strings, e.g. @@ -1960,10 +1924,10 @@ class WebRtcSdpTest : public ::testing::Test { // deserializing and comparing JsepSessionDescription will test // the serializer sufficiently. void TestSerialize(const JsepSessionDescription& jdesc) { - std::string message = webrtc::SdpSerialize(jdesc); + std::string message = SdpSerialize(jdesc); JsepSessionDescription jdesc_output_des(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(message, &jdesc_output_des, &error)); + EXPECT_TRUE(SdpDeserialize(message, &jdesc_output_des, &error)); EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output_des)); } @@ -1972,8 +1936,8 @@ class WebRtcSdpTest : public ::testing::Test { // 'connection address' field, previously set from the candidates, must also // be reset. void MakeDescriptionWithoutCandidates(JsepSessionDescription* jdesc) { - webrtc::SocketAddress audio_addr("0.0.0.0", 9); - webrtc::SocketAddress video_addr("0.0.0.0", 9); + SocketAddress audio_addr("0.0.0.0", 9); + SocketAddress video_addr("0.0.0.0", 9); audio_desc_->set_connection_address(audio_addr); video_desc_->set_connection_address(video_addr); ASSERT_TRUE(jdesc->Initialize(desc_.Clone(), kSessionId, kSessionVersion)); @@ -2008,34 +1972,34 @@ void TestMismatch(const std::string& string1, const std::string& string2) { TEST_F(WebRtcSdpTest, SerializeSessionDescription) { // SessionDescription with desc and candidates. - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); TestMismatch(std::string(kSdpFullString), message); } TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) { JsepSessionDescription jdesc_empty(kDummyType); - EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty)); + EXPECT_EQ("", SdpSerialize(jdesc_empty)); } TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithoutCandidates) { // JsepSessionDescription with desc but without candidates. JsepSessionDescription jdesc_no_candidates(kDummyType); MakeDescriptionWithoutCandidates(&jdesc_no_candidates); - std::string message = webrtc::SdpSerialize(jdesc_no_candidates); + std::string message = SdpSerialize(jdesc_no_candidates); EXPECT_EQ(std::string(kSdpString), message); } TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundles) { - ContentGroup group1(webrtc::GROUP_TYPE_BUNDLE); + ContentGroup group1(GROUP_TYPE_BUNDLE); group1.AddContentName(kAudioContentName); group1.AddContentName(kVideoContentName); desc_.AddGroup(group1); - ContentGroup group2(webrtc::GROUP_TYPE_BUNDLE); + ContentGroup group2(GROUP_TYPE_BUNDLE); group2.AddContentName(kAudioContentName2); desc_.AddGroup(group2); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_bundle = kSdpFullString; InjectAfter(kSessionTime, "a=group:BUNDLE audio_content_name video_content_name\r\n" @@ -2045,17 +2009,15 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundles) { } TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBandwidth) { - VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(&desc_); + VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); vcd->set_bandwidth(100 * 1000 + 755); // Integer division will drop the 755. vcd->set_bandwidth_type("AS"); - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); acd->set_bandwidth(555); acd->set_bandwidth_type("TIAS"); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_bandwidth = kSdpFullString; InjectAfter("c=IN IP4 74.125.224.39\r\n", "b=AS:100\r\n", &sdp_with_bandwidth); @@ -2066,12 +2028,11 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBandwidth) { // Should default to b=AS if bandwidth_type isn't set. TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithMissingBandwidthType) { - VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(&desc_); + VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); vcd->set_bandwidth(100 * 1000); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_bandwidth = kSdpFullString; InjectAfter("c=IN IP4 74.125.224.39\r\n", "b=AS:100\r\n", &sdp_with_bandwidth); @@ -2089,7 +2050,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithIceOptions) { AddIceOptions(kVideoContentName, transport_options); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_ice_options = kSdpFullString; InjectAfter(kAttributeIcePwdVoice, "a=ice-options:iceoption1 iceoption3\r\n", &sdp_with_ice_options); @@ -2128,7 +2089,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) { JsepSessionDescription jsep_desc(kDummyType); MakeDescriptionWithoutCandidates(&jsep_desc); - std::string message = webrtc::SdpSerialize(jsep_desc); + std::string message = SdpSerialize(jsep_desc); std::string expected_sdp = kSdpString; expected_sdp.append(kSdpSctpDataChannelString); @@ -2139,7 +2100,7 @@ void MutateJsepSctpPort(JsepSessionDescription* jdesc, const SessionDescription& desc, int port) { // Take our pre-built session description and change the SCTP port. - std::unique_ptr mutant = desc.Clone(); + std::unique_ptr mutant = desc.Clone(); SctpDataContentDescription* dcdesc = mutant->GetContentDescriptionByName(kDataContentName)->as_sctp(); dcdesc->set_port(port); @@ -2156,7 +2117,7 @@ TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) { const int kNewPort = 1234; MutateJsepSctpPort(&jsep_desc, desc_, kNewPort); - std::string message = webrtc::SdpSerialize(jsep_desc); + std::string message = SdpSerialize(jsep_desc); std::string expected_sdp = kSdpString; expected_sdp.append(kSdpSctpDataChannelString); @@ -2174,16 +2135,14 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmapAllowMixed) { } TEST_F(WebRtcSdpTest, SerializeMediaContentDescriptionWithExtmapAllowMixed) { - webrtc::MediaContentDescription* video_desc = + MediaContentDescription* video_desc = jdesc_.description()->GetContentDescriptionByName(kVideoContentName); ASSERT_TRUE(video_desc); - webrtc::MediaContentDescription* audio_desc = + MediaContentDescription* audio_desc = jdesc_.description()->GetContentDescriptionByName(kAudioContentName); ASSERT_TRUE(audio_desc); - video_desc->set_extmap_allow_mixed_enum( - webrtc::MediaContentDescription::kMedia); - audio_desc->set_extmap_allow_mixed_enum( - webrtc::MediaContentDescription::kMedia); + video_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia); + audio_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia); TestSerialize(jdesc_); } @@ -2192,7 +2151,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { AddExtmap(encrypted); JsepSessionDescription desc_with_extmap(kDummyType); MakeDescriptionWithoutCandidates(&desc_with_extmap); - std::string message = webrtc::SdpSerialize(desc_with_extmap); + std::string message = SdpSerialize(desc_with_extmap); std::string sdp_with_extmap = kSdpString; InjectAfter("a=mid:audio_content_name\r\n", kExtmap, &sdp_with_extmap); @@ -2211,51 +2170,50 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmapEncrypted) { } TEST_F(WebRtcSdpTest, SerializeCandidates) { - std::string message = webrtc::SdpSerializeCandidate(*jcandidate_); + std::string message = SdpSerializeCandidate(*jcandidate_); EXPECT_EQ(std::string(kRawCandidate), message); Candidate candidate_with_ufrag(candidates_.front()); candidate_with_ufrag.set_username("ABC"); jcandidate_.reset(new JsepIceCandidate(std::string("audio_content_name"), 0, candidate_with_ufrag)); - message = webrtc::SdpSerializeCandidate(*jcandidate_); + message = SdpSerializeCandidate(*jcandidate_); EXPECT_EQ(std::string(kRawCandidate) + " ufrag ABC", message); Candidate candidate_with_network_info(candidates_.front()); candidate_with_network_info.set_network_id(1); jcandidate_.reset(new JsepIceCandidate(std::string("audio"), 0, candidate_with_network_info)); - message = webrtc::SdpSerializeCandidate(*jcandidate_); + message = SdpSerializeCandidate(*jcandidate_); EXPECT_EQ(std::string(kRawCandidate) + " network-id 1", message); candidate_with_network_info.set_network_cost(999); jcandidate_.reset(new JsepIceCandidate(std::string("audio"), 0, candidate_with_network_info)); - message = webrtc::SdpSerializeCandidate(*jcandidate_); + message = SdpSerializeCandidate(*jcandidate_); EXPECT_EQ(std::string(kRawCandidate) + " network-id 1 network-cost 999", message); } TEST_F(WebRtcSdpTest, SerializeHostnameCandidate) { - webrtc::SocketAddress address("a.test", 1234); - webrtc::Candidate candidate(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - address, kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, - kCandidateFoundation1); + SocketAddress address("a.test", 1234); + Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "udp", address, + kCandidatePriority, "", "", IceCandidateType::kHost, + kCandidateGeneration, kCandidateFoundation1); JsepIceCandidate jcandidate(std::string("audio_content_name"), 0, candidate); - std::string message = webrtc::SdpSerializeCandidate(jcandidate); + std::string message = SdpSerializeCandidate(jcandidate); EXPECT_EQ(std::string(kRawHostnameCandidate), message); } TEST_F(WebRtcSdpTest, SerializeTcpCandidates) { - Candidate candidate(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "tcp", - webrtc::SocketAddress("192.168.1.5", 9), - kCandidatePriority, "", "", IceCandidateType::kHost, - kCandidateGeneration, kCandidateFoundation1); - candidate.set_tcptype(webrtc::TCPTYPE_ACTIVE_STR); + Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "tcp", + SocketAddress("192.168.1.5", 9), kCandidatePriority, "", + "", IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation1); + candidate.set_tcptype(TCPTYPE_ACTIVE_STR); std::unique_ptr jcandidate( new JsepIceCandidate(std::string("audio_content_name"), 0, candidate)); - std::string message = webrtc::SdpSerializeCandidate(*jcandidate); + std::string message = SdpSerializeCandidate(*jcandidate); EXPECT_EQ(std::string(kSdpTcpActiveCandidate), message); } @@ -2271,8 +2229,7 @@ TEST_F(WebRtcSdpTest, ParseTcpCandidateWithoutTcptype) { JsepIceCandidate jcandidate(kDummyMid, kDummyIndex); EXPECT_TRUE(SdpDeserializeCandidate(missing_tcptype, &jcandidate)); - EXPECT_EQ(std::string(webrtc::TCPTYPE_PASSIVE_STR), - jcandidate.candidate().tcptype()); + EXPECT_EQ(std::string(TCPTYPE_PASSIVE_STR), jcandidate.candidate().tcptype()); } TEST_F(WebRtcSdpTest, ParseSslTcpCandidate) { @@ -2286,7 +2243,7 @@ TEST_F(WebRtcSdpTest, ParseSslTcpCandidate) { } TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithH264) { - webrtc::Codec h264_codec = webrtc::CreateVideoCodec("H264"); + Codec h264_codec = CreateVideoCodec("H264"); // Id must be valid, but value doesn't matter. h264_codec.id = 123; h264_codec.SetParam("profile-level-id", "42e01f"); @@ -2296,7 +2253,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithH264) { jdesc_.Initialize(desc_.Clone(), kSessionId, kSessionVersion); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); size_t after_pt = message.find(" H264/90000"); ASSERT_NE(after_pt, std::string::npos); size_t before_pt = message.rfind("a=rtpmap:", after_pt); @@ -2374,14 +2331,14 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmap) { JsepSessionDescription jdesc(kDummyType); EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc)); - webrtc::AudioContentDescription* audio = - webrtc::GetFirstAudioContentDescription(jdesc.description()); - webrtc::Codecs ref_codecs; + AudioContentDescription* audio = + GetFirstAudioContentDescription(jdesc.description()); + Codecs ref_codecs; // The codecs in the AudioContentDescription should be in the same order as // the payload types (s) on the m= line. - ref_codecs.push_back(webrtc::CreateAudioCodec(0, "PCMU", 8000, 1)); - ref_codecs.push_back(webrtc::CreateAudioCodec(18, "G729", 8000, 1)); - ref_codecs.push_back(webrtc::CreateAudioCodec(103, "ISAC", 16000, 1)); + ref_codecs.push_back(CreateAudioCodec(0, "PCMU", 8000, 1)); + ref_codecs.push_back(CreateAudioCodec(18, "G729", 8000, 1)); + ref_codecs.push_back(CreateAudioCodec(103, "ISAC", 16000, 1)); EXPECT_EQ(ref_codecs, audio->codecs()); } @@ -2397,18 +2354,18 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmapButWithFmtp) { JsepSessionDescription jdesc(kDummyType); EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc)); - webrtc::AudioContentDescription* audio = - webrtc::GetFirstAudioContentDescription(jdesc.description()); + AudioContentDescription* audio = + GetFirstAudioContentDescription(jdesc.description()); - webrtc::Codec g729 = audio->codecs()[0]; + Codec g729 = audio->codecs()[0]; EXPECT_EQ("G729", g729.name); EXPECT_EQ(8000, g729.clockrate); EXPECT_EQ(18, g729.id); - webrtc::CodecParameterMap::iterator found = g729.params.find("annexb"); + CodecParameterMap::iterator found = g729.params.find("annexb"); ASSERT_TRUE(found != g729.params.end()); EXPECT_EQ(found->second, "yes"); - webrtc::Codec isac = audio->codecs()[1]; + Codec isac = audio->codecs()[1]; EXPECT_EQ("ISAC", isac.name); EXPECT_EQ(103, isac.id); EXPECT_EQ(16000, isac.clockrate); @@ -2435,7 +2392,7 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBundle) { "a=group:BUNDLE audio_content_name video_content_name\r\n", &sdp_with_bundle); EXPECT_TRUE(SdpDeserialize(sdp_with_bundle, &jdesc_with_bundle)); - ContentGroup group(webrtc::GROUP_TYPE_BUNDLE); + ContentGroup group(GROUP_TYPE_BUNDLE); group.AddContentName(kAudioContentName); group.AddContentName(kVideoContentName); desc_.AddGroup(group); @@ -2452,11 +2409,9 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBandwidth) { InjectAfter("a=mid:audio_content_name\r\na=sendrecv\r\n", "b=AS:50\r\n", &sdp_with_bandwidth); EXPECT_TRUE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth)); - VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(&desc_); + VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); vcd->set_bandwidth(100 * 1000); - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); acd->set_bandwidth(50 * 1000); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); @@ -2471,11 +2426,9 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithTiasBandwidth) { InjectAfter("a=mid:audio_content_name\r\na=sendrecv\r\n", "b=TIAS:50000\r\n", &sdp_with_bandwidth); EXPECT_TRUE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth)); - VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(&desc_); + VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); vcd->set_bandwidth(100 * 1000); - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); acd->set_bandwidth(50 * 1000); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); @@ -2491,11 +2444,9 @@ TEST_F(WebRtcSdpTest, InjectAfter("a=mid:audio_content_name\r\na=sendrecv\r\n", "b=unknown:50000\r\n", &sdp_with_bandwidth); EXPECT_TRUE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth)); - VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(&desc_); + VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); vcd->set_bandwidth(-1); - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); acd->set_bandwidth(-1); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); @@ -2596,16 +2547,14 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutExtmapAllowMixed) { } TEST_F(WebRtcSdpTest, DeserializeMediaContentDescriptionWithExtmapAllowMixed) { - webrtc::MediaContentDescription* video_desc = + MediaContentDescription* video_desc = jdesc_.description()->GetContentDescriptionByName(kVideoContentName); ASSERT_TRUE(video_desc); - webrtc::MediaContentDescription* audio_desc = + MediaContentDescription* audio_desc = jdesc_.description()->GetContentDescriptionByName(kAudioContentName); ASSERT_TRUE(audio_desc); - video_desc->set_extmap_allow_mixed_enum( - webrtc::MediaContentDescription::kMedia); - audio_desc->set_extmap_allow_mixed_enum( - webrtc::MediaContentDescription::kMedia); + video_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia); + audio_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia); std::string sdp_with_extmap_allow_mixed = kSdpFullString; InjectAfter("a=mid:audio_content_name\r\n", kExtmapAllowMixed, @@ -2658,11 +2607,11 @@ TEST_F(WebRtcSdpTest, DeserializeCandidate) { sdp = kSdpTcpActiveCandidate; EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate)); - // Make a webrtc::Candidate equivalent to kSdpTcpCandidate string. - Candidate candidate(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "tcp", - webrtc::SocketAddress("192.168.1.5", 9), - kCandidatePriority, "", "", IceCandidateType::kHost, - kCandidateGeneration, kCandidateFoundation1); + // Make a Candidate equivalent to kSdpTcpCandidate string. + Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "tcp", + SocketAddress("192.168.1.5", 9), kCandidatePriority, "", + "", IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation1); std::unique_ptr jcandidate_template( new JsepIceCandidate(std::string("audio_content_name"), 0, candidate)); EXPECT_TRUE( @@ -2809,7 +2758,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsButWrongMediaType) { void MutateJsepSctpMaxMessageSize(const SessionDescription& desc, int new_value, JsepSessionDescription* jdesc) { - std::unique_ptr mutant = desc.Clone(); + std::unique_ptr mutant = desc.Clone(); SctpDataContentDescription* dcdesc = mutant->GetContentDescriptionByName(kDataContentName)->as_sctp(); dcdesc->set_max_message_size(new_value); @@ -2836,7 +2785,7 @@ TEST_F(WebRtcSdpTest, SerializeSdpWithSctpDataChannelWithMaxMessageSize) { AddSctpDataChannel(use_sctpmap); JsepSessionDescription jdesc(kDummyType); MutateJsepSctpMaxMessageSize(desc_, 12345, &jdesc); - std::string message = webrtc::SdpSerialize(jdesc); + std::string message = SdpSerialize(jdesc); EXPECT_NE(std::string::npos, message.find("\r\na=max-message-size:12345\r\n")); JsepSessionDescription jdesc_output(kDummyType); @@ -2852,7 +2801,7 @@ TEST_F(WebRtcSdpTest, AddSctpDataChannel(use_sctpmap); JsepSessionDescription jdesc(kDummyType); MutateJsepSctpMaxMessageSize(desc_, 65536, &jdesc); - std::string message = webrtc::SdpSerialize(jdesc); + std::string message = SdpSerialize(jdesc); EXPECT_EQ(std::string::npos, message.find("\r\na=max-message-size:")); JsepSessionDescription jdesc_output(kDummyType); EXPECT_TRUE(SdpDeserialize(message, &jdesc_output)); @@ -2948,8 +2897,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) { bool use_sctpmap = true; AddSctpDataChannel(use_sctpmap); JsepSessionDescription jdesc(kDummyType); - SctpDataContentDescription* dcd = - webrtc::GetFirstSctpDataContentDescription(&desc_); + SctpDataContentDescription* dcd = GetFirstSctpDataContentDescription(&desc_); dcd->set_bandwidth(100 * 1000); ASSERT_TRUE(jdesc.Initialize(desc_.Clone(), kSessionId, kSessionVersion)); @@ -2994,7 +2942,7 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutEndLineBreak) { sdp = sdp.substr(0, sdp.size() - 2); // Remove \r\n at the end. // Deserialize SdpParseError error; - EXPECT_FALSE(webrtc::SdpDeserialize(sdp, &jdesc, &error)); + EXPECT_FALSE(SdpDeserialize(sdp, &jdesc, &error)); const std::string lastline = "a=ssrc:3 cname:stream_1_cname"; EXPECT_EQ(lastline, error.line); EXPECT_EQ("Invalid SDP line.", error.description); @@ -3032,12 +2980,12 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithConferenceFlag) { EXPECT_TRUE(SdpDeserialize(kSdpConferenceString, &jdesc)); // Verify - webrtc::AudioContentDescription* audio = - webrtc::GetFirstAudioContentDescription(jdesc.description()); + AudioContentDescription* audio = + GetFirstAudioContentDescription(jdesc.description()); EXPECT_TRUE(audio->conference_mode()); - webrtc::VideoContentDescription* video = - webrtc::GetFirstVideoContentDescription(jdesc.description()); + VideoContentDescription* video = + GetFirstVideoContentDescription(jdesc.description()); EXPECT_TRUE(video->conference_mode()); } @@ -3047,16 +2995,16 @@ TEST_F(WebRtcSdpTest, SerializeSdpWithConferenceFlag) { // We tested deserialization already above, so just test that if we serialize // and deserialize the flag doesn't disappear. EXPECT_TRUE(SdpDeserialize(kSdpConferenceString, &jdesc)); - std::string reserialized = webrtc::SdpSerialize(jdesc); + std::string reserialized = SdpSerialize(jdesc); EXPECT_TRUE(SdpDeserialize(reserialized, &jdesc)); // Verify. - webrtc::AudioContentDescription* audio = - webrtc::GetFirstAudioContentDescription(jdesc.description()); + AudioContentDescription* audio = + GetFirstAudioContentDescription(jdesc.description()); EXPECT_TRUE(audio->conference_mode()); - webrtc::VideoContentDescription* video = - webrtc::GetFirstVideoContentDescription(jdesc.description()); + VideoContentDescription* video = + GetFirstVideoContentDescription(jdesc.description()); EXPECT_TRUE(video->conference_mode()); } @@ -3064,18 +3012,18 @@ TEST_F(WebRtcSdpTest, SerializeAndDeserializeRemoteNetEstimate) { { // By default remote estimates are disabled. JsepSessionDescription dst(kDummyType); - SdpDeserialize(webrtc::SdpSerialize(jdesc_), &dst); - EXPECT_FALSE(webrtc::GetFirstVideoContentDescription(dst.description()) - ->remote_estimate()); + SdpDeserialize(SdpSerialize(jdesc_), &dst); + EXPECT_FALSE( + GetFirstVideoContentDescription(dst.description())->remote_estimate()); } { // When remote estimate is enabled, the setting is propagated via SDP. - webrtc::GetFirstVideoContentDescription(jdesc_.description()) + GetFirstVideoContentDescription(jdesc_.description()) ->set_remote_estimate(true); JsepSessionDescription dst(kDummyType); - SdpDeserialize(webrtc::SdpSerialize(jdesc_), &dst); - EXPECT_TRUE(webrtc::GetFirstVideoContentDescription(dst.description()) - ->remote_estimate()); + SdpDeserialize(SdpSerialize(jdesc_), &dst); + EXPECT_TRUE( + GetFirstVideoContentDescription(dst.description())->remote_estimate()); } } @@ -3190,7 +3138,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithReorderedPltypes) { EXPECT_TRUE(SdpDeserialize(kSdpWithReorderedPlTypesString, &jdesc_output)); const AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(jdesc_output.description()); + GetFirstAudioContentDescription(jdesc_output.description()); ASSERT_TRUE(acd); ASSERT_FALSE(acd->codecs().empty()); EXPECT_EQ("ISAC", acd->codecs()[0].name); @@ -3240,18 +3188,16 @@ TEST_F(WebRtcSdpTest, DeserializeVideoFmtp) { // Deserialize SdpParseError error; - EXPECT_TRUE( - webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error)); + EXPECT_TRUE(SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error)); const VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(jdesc_output.description()); + GetFirstVideoContentDescription(jdesc_output.description()); ASSERT_TRUE(vcd); ASSERT_FALSE(vcd->codecs().empty()); - webrtc::Codec vp8 = vcd->codecs()[0]; + Codec vp8 = vcd->codecs()[0]; EXPECT_EQ("VP8", vp8.name); EXPECT_EQ(120, vp8.id); - webrtc::CodecParameterMap::iterator found = - vp8.params.find("x-google-min-bitrate"); + CodecParameterMap::iterator found = vp8.params.find("x-google-min-bitrate"); ASSERT_TRUE(found != vp8.params.end()); EXPECT_EQ(found->second, "10"); found = vp8.params.find("x-google-max-quantization"); @@ -3274,17 +3220,16 @@ TEST_F(WebRtcSdpTest, DeserializeVideoFmtpWithSprops) { // Deserialize. SdpParseError error; - EXPECT_TRUE( - webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error)); + EXPECT_TRUE(SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error)); const VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(jdesc_output.description()); + GetFirstVideoContentDescription(jdesc_output.description()); ASSERT_TRUE(vcd); ASSERT_FALSE(vcd->codecs().empty()); - webrtc::Codec h264 = vcd->codecs()[0]; + Codec h264 = vcd->codecs()[0]; EXPECT_EQ("H264", h264.name); EXPECT_EQ(98, h264.id); - webrtc::CodecParameterMap::const_iterator found = + CodecParameterMap::const_iterator found = h264.params.find("profile-level-id"); ASSERT_TRUE(found != h264.params.end()); EXPECT_EQ(found->second, "42A01E"); @@ -3307,18 +3252,16 @@ TEST_F(WebRtcSdpTest, DeserializeVideoFmtpWithSpace) { // Deserialize SdpParseError error; - EXPECT_TRUE( - webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error)); + EXPECT_TRUE(SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error)); const VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(jdesc_output.description()); + GetFirstVideoContentDescription(jdesc_output.description()); ASSERT_TRUE(vcd); ASSERT_FALSE(vcd->codecs().empty()); - webrtc::Codec vp8 = vcd->codecs()[0]; + Codec vp8 = vcd->codecs()[0]; EXPECT_EQ("VP8", vp8.name); EXPECT_EQ(120, vp8.id); - webrtc::CodecParameterMap::iterator found = - vp8.params.find("x-google-min-bitrate"); + CodecParameterMap::iterator found = vp8.params.find("x-google-min-bitrate"); ASSERT_TRUE(found != vp8.params.end()); EXPECT_EQ(found->second, "10"); found = vp8.params.find("x-google-max-quantization"); @@ -3345,46 +3288,45 @@ TEST_F(WebRtcSdpTest, DeserializePacketizationAttributeWithIllegalValue) { "a=packetization:122 unknownpacketizationattributevalue\r\n"; SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(kSdpWithPacketizationString, &jdesc_output, - &error)); + EXPECT_TRUE( + SdpDeserialize(kSdpWithPacketizationString, &jdesc_output, &error)); AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(jdesc_output.description()); + GetFirstAudioContentDescription(jdesc_output.description()); ASSERT_TRUE(acd); ASSERT_THAT(acd->codecs(), testing::SizeIs(1)); - webrtc::Codec opus = acd->codecs()[0]; + Codec opus = acd->codecs()[0]; EXPECT_EQ(opus.name, "opus"); EXPECT_EQ(opus.id, 111); const VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(jdesc_output.description()); + GetFirstVideoContentDescription(jdesc_output.description()); ASSERT_TRUE(vcd); ASSERT_THAT(vcd->codecs(), testing::SizeIs(3)); - webrtc::Codec vp8 = vcd->codecs()[0]; + Codec vp8 = vcd->codecs()[0]; EXPECT_EQ(vp8.name, "VP8"); EXPECT_EQ(vp8.id, 120); EXPECT_EQ(vp8.packetization, "raw"); - webrtc::Codec vp9 = vcd->codecs()[1]; + Codec vp9 = vcd->codecs()[1]; EXPECT_EQ(vp9.name, "VP9"); EXPECT_EQ(vp9.id, 121); EXPECT_EQ(vp9.packetization, std::nullopt); - webrtc::Codec h264 = vcd->codecs()[2]; + Codec h264 = vcd->codecs()[2]; EXPECT_EQ(h264.name, "H264"); EXPECT_EQ(h264.id, 122); EXPECT_EQ(h264.packetization, std::nullopt); } TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithUnknownParameter) { - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); - webrtc::Codecs codecs = acd->codecs(); + Codecs codecs = acd->codecs(); codecs[0].params["unknown-future-parameter"] = "SomeFutureValue"; acd->set_codecs(codecs); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; InjectAfter("a=rtpmap:111 opus/48000/2\r\n", "a=fmtp:111 unknown-future-parameter=SomeFutureValue\r\n", @@ -3393,16 +3335,15 @@ TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithUnknownParameter) { } TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithKnownFmtpParameter) { - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); - webrtc::Codecs codecs = acd->codecs(); + Codecs codecs = acd->codecs(); codecs[0].params["stereo"] = "1"; acd->set_codecs(codecs); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; InjectAfter("a=rtpmap:111 opus/48000/2\r\n", "a=fmtp:111 stereo=1\r\n", &sdp_with_fmtp); @@ -3410,17 +3351,16 @@ TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithKnownFmtpParameter) { } TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithPTimeAndMaxPTime) { - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); - webrtc::Codecs codecs = acd->codecs(); + Codecs codecs = acd->codecs(); codecs[0].params["ptime"] = "20"; codecs[0].params["maxptime"] = "120"; acd->set_codecs(codecs); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; InjectAfter("a=rtpmap:104 ISAC/32000\r\n", "a=maxptime:120\r\n" // No comma here. String merging! @@ -3430,19 +3370,17 @@ TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithPTimeAndMaxPTime) { } TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithTelephoneEvent) { - AudioContentDescription* acd = - webrtc::GetFirstAudioContentDescription(&desc_); + AudioContentDescription* acd = GetFirstAudioContentDescription(&desc_); - webrtc::Codecs codecs = acd->codecs(); - webrtc::Codec dtmf = - webrtc::CreateAudioCodec(105, "telephone-event", 8000, 1); + Codecs codecs = acd->codecs(); + Codec dtmf = CreateAudioCodec(105, "telephone-event", 8000, 1); dtmf.params[""] = "0-15"; codecs.push_back(dtmf); acd->set_codecs(codecs); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; InjectAfter("m=audio 2345 RTP/SAVPF 111 103 104", " 105", &sdp_with_fmtp); InjectAfter( @@ -3454,16 +3392,15 @@ TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithTelephoneEvent) { } TEST_F(WebRtcSdpTest, SerializeVideoFmtp) { - VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(&desc_); + VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); - webrtc::Codecs codecs = vcd->codecs(); + Codecs codecs = vcd->codecs(); codecs[0].params["x-google-min-bitrate"] = "10"; vcd->set_codecs(codecs); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_fmtp = kSdpFullString; InjectAfter("a=rtpmap:120 VP8/90000\r\n", "a=fmtp:120 x-google-min-bitrate=10\r\n", &sdp_with_fmtp); @@ -3471,16 +3408,15 @@ TEST_F(WebRtcSdpTest, SerializeVideoFmtp) { } TEST_F(WebRtcSdpTest, SerializeVideoPacketizationAttribute) { - VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(&desc_); + VideoContentDescription* vcd = GetFirstVideoContentDescription(&desc_); - webrtc::Codecs codecs = vcd->codecs(); + Codecs codecs = vcd->codecs(); codecs[0].packetization = "raw"; vcd->set_codecs(codecs); ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_packetization = kSdpFullString; InjectAfter("a=rtpmap:120 VP8/90000\r\n", "a=packetization:120 raw\r\n", &sdp_with_packetization); @@ -3492,24 +3428,24 @@ TEST_F(WebRtcSdpTest, DeserializeAndSerializeSdpWithIceLite) { JsepSessionDescription jdesc_with_icelite(kDummyType); std::string sdp_with_icelite = kSdpFullString; EXPECT_TRUE(SdpDeserialize(sdp_with_icelite, &jdesc_with_icelite)); - webrtc::SessionDescription* desc = jdesc_with_icelite.description(); - const webrtc::TransportInfo* tinfo1 = + SessionDescription* desc = jdesc_with_icelite.description(); + const TransportInfo* tinfo1 = desc->GetTransportInfoByName("audio_content_name"); - EXPECT_EQ(webrtc::ICEMODE_FULL, tinfo1->description.ice_mode); - const webrtc::TransportInfo* tinfo2 = + EXPECT_EQ(ICEMODE_FULL, tinfo1->description.ice_mode); + const TransportInfo* tinfo2 = desc->GetTransportInfoByName("video_content_name"); - EXPECT_EQ(webrtc::ICEMODE_FULL, tinfo2->description.ice_mode); + EXPECT_EQ(ICEMODE_FULL, tinfo2->description.ice_mode); // Add "a=ice-lite" and deserialize, making sure it's ICE lite. InjectAfter(kSessionTime, "a=ice-lite\r\n", &sdp_with_icelite); EXPECT_TRUE(SdpDeserialize(sdp_with_icelite, &jdesc_with_icelite)); desc = jdesc_with_icelite.description(); - const webrtc::TransportInfo* atinfo = + const TransportInfo* atinfo = desc->GetTransportInfoByName("audio_content_name"); - EXPECT_EQ(webrtc::ICEMODE_LITE, atinfo->description.ice_mode); - const webrtc::TransportInfo* vtinfo = + EXPECT_EQ(ICEMODE_LITE, atinfo->description.ice_mode); + const TransportInfo* vtinfo = desc->GetTransportInfoByName("video_content_name"); - EXPECT_EQ(webrtc::ICEMODE_LITE, vtinfo->description.ice_mode); + EXPECT_EQ(ICEMODE_LITE, vtinfo->description.ice_mode); // Now that we know deserialization works, we can use TestSerialize to test // serialization. @@ -3524,23 +3460,21 @@ TEST_F(WebRtcSdpTest, RoundTripSdpWithSctpDataChannelsWithCandidates) { JsepSessionDescription jdesc_output(kDummyType); EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); - EXPECT_EQ(sdp_with_data, webrtc::SdpSerialize(jdesc_output)); + EXPECT_EQ(sdp_with_data, SdpSerialize(jdesc_output)); } TEST_F(WebRtcSdpTest, SerializeDtlsSetupAttribute) { TransportInfo audio_transport_info = *(desc_.GetTransportInfoByName(kAudioContentName)); - EXPECT_EQ(webrtc::CONNECTIONROLE_NONE, + EXPECT_EQ(CONNECTIONROLE_NONE, audio_transport_info.description.connection_role); - audio_transport_info.description.connection_role = - webrtc::CONNECTIONROLE_ACTIVE; + audio_transport_info.description.connection_role = CONNECTIONROLE_ACTIVE; TransportInfo video_transport_info = *(desc_.GetTransportInfoByName(kVideoContentName)); - EXPECT_EQ(webrtc::CONNECTIONROLE_NONE, + EXPECT_EQ(CONNECTIONROLE_NONE, video_transport_info.description.connection_role); - video_transport_info.description.connection_role = - webrtc::CONNECTIONROLE_ACTIVE; + video_transport_info.description.connection_role = CONNECTIONROLE_ACTIVE; desc_.RemoveTransportInfoByName(kAudioContentName); desc_.RemoveTransportInfoByName(kVideoContentName); @@ -3550,7 +3484,7 @@ TEST_F(WebRtcSdpTest, SerializeDtlsSetupAttribute) { ASSERT_TRUE(jdesc_.Initialize(desc_.Clone(), jdesc_.session_id(), jdesc_.session_version())); - std::string message = webrtc::SdpSerialize(jdesc_); + std::string message = SdpSerialize(jdesc_); std::string sdp_with_dtlssetup = kSdpFullString; // Now adding `setup` attribute. @@ -3563,15 +3497,13 @@ TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttributeActpass) { std::string sdp_with_dtlssetup = kSdpFullString; InjectAfter(kSessionTime, "a=setup:actpass\r\n", &sdp_with_dtlssetup); EXPECT_TRUE(SdpDeserialize(sdp_with_dtlssetup, &jdesc_with_dtlssetup)); - webrtc::SessionDescription* desc = jdesc_with_dtlssetup.description(); - const webrtc::TransportInfo* atinfo = + SessionDescription* desc = jdesc_with_dtlssetup.description(); + const TransportInfo* atinfo = desc->GetTransportInfoByName("audio_content_name"); - EXPECT_EQ(webrtc::CONNECTIONROLE_ACTPASS, - atinfo->description.connection_role); - const webrtc::TransportInfo* vtinfo = + EXPECT_EQ(CONNECTIONROLE_ACTPASS, atinfo->description.connection_role); + const TransportInfo* vtinfo = desc->GetTransportInfoByName("video_content_name"); - EXPECT_EQ(webrtc::CONNECTIONROLE_ACTPASS, - vtinfo->description.connection_role); + EXPECT_EQ(CONNECTIONROLE_ACTPASS, vtinfo->description.connection_role); } TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttributeActive) { @@ -3579,28 +3511,26 @@ TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttributeActive) { std::string sdp_with_dtlssetup = kSdpFullString; InjectAfter(kSessionTime, "a=setup:active\r\n", &sdp_with_dtlssetup); EXPECT_TRUE(SdpDeserialize(sdp_with_dtlssetup, &jdesc_with_dtlssetup)); - webrtc::SessionDescription* desc = jdesc_with_dtlssetup.description(); - const webrtc::TransportInfo* atinfo = + SessionDescription* desc = jdesc_with_dtlssetup.description(); + const TransportInfo* atinfo = desc->GetTransportInfoByName("audio_content_name"); - EXPECT_EQ(webrtc::CONNECTIONROLE_ACTIVE, atinfo->description.connection_role); - const webrtc::TransportInfo* vtinfo = + EXPECT_EQ(CONNECTIONROLE_ACTIVE, atinfo->description.connection_role); + const TransportInfo* vtinfo = desc->GetTransportInfoByName("video_content_name"); - EXPECT_EQ(webrtc::CONNECTIONROLE_ACTIVE, vtinfo->description.connection_role); + EXPECT_EQ(CONNECTIONROLE_ACTIVE, vtinfo->description.connection_role); } TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttributePassive) { JsepSessionDescription jdesc_with_dtlssetup(kDummyType); std::string sdp_with_dtlssetup = kSdpFullString; InjectAfter(kSessionTime, "a=setup:passive\r\n", &sdp_with_dtlssetup); EXPECT_TRUE(SdpDeserialize(sdp_with_dtlssetup, &jdesc_with_dtlssetup)); - webrtc::SessionDescription* desc = jdesc_with_dtlssetup.description(); - const webrtc::TransportInfo* atinfo = + SessionDescription* desc = jdesc_with_dtlssetup.description(); + const TransportInfo* atinfo = desc->GetTransportInfoByName("audio_content_name"); - EXPECT_EQ(webrtc::CONNECTIONROLE_PASSIVE, - atinfo->description.connection_role); - const webrtc::TransportInfo* vtinfo = + EXPECT_EQ(CONNECTIONROLE_PASSIVE, atinfo->description.connection_role); + const TransportInfo* vtinfo = desc->GetTransportInfoByName("video_content_name"); - EXPECT_EQ(webrtc::CONNECTIONROLE_PASSIVE, - vtinfo->description.connection_role); + EXPECT_EQ(CONNECTIONROLE_PASSIVE, vtinfo->description.connection_role); } // Verifies that the order of the serialized m-lines follows the order of the @@ -3609,9 +3539,8 @@ TEST_F(WebRtcSdpTest, MediaContentOrderMaintainedRoundTrip) { JsepSessionDescription jdesc(kDummyType); const std::string media_content_sdps[3] = {kSdpAudioString, kSdpVideoString, kSdpSctpDataChannelString}; - const webrtc::MediaType media_types[3] = {webrtc::MediaType::AUDIO, - webrtc::MediaType::VIDEO, - webrtc::MediaType::DATA}; + const MediaType media_types[3] = {MediaType::AUDIO, MediaType::VIDEO, + MediaType::DATA}; // Verifies all 6 permutations. for (size_t i = 0; i < 6; ++i) { @@ -3628,16 +3557,16 @@ TEST_F(WebRtcSdpTest, MediaContentOrderMaintainedRoundTrip) { sdp_string += media_content_sdps[media_content_in_sdp[j]]; EXPECT_TRUE(SdpDeserialize(sdp_string, &jdesc)); - webrtc::SessionDescription* desc = jdesc.description(); + SessionDescription* desc = jdesc.description(); EXPECT_EQ(3u, desc->contents().size()); for (size_t j = 0; j < 3; ++j) { - const webrtc::MediaContentDescription* mdesc = + const MediaContentDescription* mdesc = desc->contents()[j].media_description(); EXPECT_EQ(media_types[media_content_in_sdp[j]], mdesc->type()); } - std::string serialized_sdp = webrtc::SdpSerialize(jdesc); + std::string serialized_sdp = SdpSerialize(jdesc); EXPECT_EQ(sdp_string, serialized_sdp); } } @@ -3707,18 +3636,17 @@ TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) { // lines do not support multiple stream ids and no stream ids. TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionSpecialMsid) { // Create both msid lines for Plan B and Unified Plan support. - MakeUnifiedPlanDescriptionMultipleStreamIds( - webrtc::kMsidSignalingMediaSection | webrtc::kMsidSignalingSsrcAttribute | - webrtc::kMsidSignalingSemantic); + MakeUnifiedPlanDescriptionMultipleStreamIds(kMsidSignalingMediaSection | + kMsidSignalingSsrcAttribute | + kMsidSignalingSemantic); JsepSessionDescription deserialized_description(kDummyType); EXPECT_TRUE(SdpDeserialize(kUnifiedPlanSdpFullStringWithSpecialMsid, &deserialized_description)); EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description)); - EXPECT_EQ(webrtc::kMsidSignalingMediaSection | - webrtc::kMsidSignalingSsrcAttribute | - webrtc::kMsidSignalingSemantic, + EXPECT_EQ(kMsidSignalingMediaSection | kMsidSignalingSsrcAttribute | + kMsidSignalingSemantic, deserialized_description.description()->msid_signaling()); } @@ -3728,10 +3656,10 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionSpecialMsid) { // multiple stream ids. TEST_F(WebRtcSdpTest, SerializeSessionDescriptionSpecialMsid) { // Create both msid lines for Plan B and Unified Plan support. - MakeUnifiedPlanDescriptionMultipleStreamIds( - webrtc::kMsidSignalingMediaSection | webrtc::kMsidSignalingSsrcAttribute | - webrtc::kMsidSignalingSemantic); - std::string serialized_sdp = webrtc::SdpSerialize(jdesc_); + MakeUnifiedPlanDescriptionMultipleStreamIds(kMsidSignalingMediaSection | + kMsidSignalingSsrcAttribute | + kMsidSignalingSemantic); + std::string serialized_sdp = SdpSerialize(jdesc_); // We explicitly test that the serialized SDP string is equal to the hard // coded SDP string. This is necessary, because in the parser "a=msid" lines // take priority over "a=ssrc msid" lines. This means if we just used @@ -3745,8 +3673,8 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionSpecialMsid) { // no stream ids and multiple stream ids. TEST_F(WebRtcSdpTest, UnifiedPlanDeserializeSessionDescriptionSpecialMsid) { // Only create a=msid lines for strictly Unified Plan stream ID support. - MakeUnifiedPlanDescriptionMultipleStreamIds( - webrtc::kMsidSignalingMediaSection | webrtc::kMsidSignalingSemantic); + MakeUnifiedPlanDescriptionMultipleStreamIds(kMsidSignalingMediaSection | + kMsidSignalingSemantic); JsepSessionDescription deserialized_description(kDummyType); std::string unified_plan_sdp_string = @@ -3763,8 +3691,8 @@ TEST_F(WebRtcSdpTest, UnifiedPlanDeserializeSessionDescriptionSpecialMsid) { // stream ids and multiple stream ids. TEST_F(WebRtcSdpTest, UnifiedPlanSerializeSessionDescriptionSpecialMsid) { // Only create a=msid lines for strictly Unified Plan stream ID support. - MakeUnifiedPlanDescriptionMultipleStreamIds( - webrtc::kMsidSignalingMediaSection | webrtc::kMsidSignalingSemantic); + MakeUnifiedPlanDescriptionMultipleStreamIds(kMsidSignalingMediaSection | + kMsidSignalingSemantic); TestSerialize(jdesc_); } @@ -3796,8 +3724,7 @@ TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescriptionNoSsrcSignaling) { TEST_F(WebRtcSdpTest, EmptyDescriptionHasNoMsidSignaling) { JsepSessionDescription jsep_desc(kDummyType); ASSERT_TRUE(SdpDeserialize(kSdpSessionString, &jsep_desc)); - EXPECT_EQ(webrtc::kMsidSignalingSemantic, - jsep_desc.description()->msid_signaling()); + EXPECT_EQ(kMsidSignalingSemantic, jsep_desc.description()->msid_signaling()); } TEST_F(WebRtcSdpTest, DataChannelOnlyHasNoMsidSignaling) { @@ -3805,22 +3732,20 @@ TEST_F(WebRtcSdpTest, DataChannelOnlyHasNoMsidSignaling) { std::string sdp = kSdpSessionString; sdp += kSdpSctpDataChannelString; ASSERT_TRUE(SdpDeserialize(sdp, &jsep_desc)); - EXPECT_EQ(webrtc::kMsidSignalingSemantic, - jsep_desc.description()->msid_signaling()); + EXPECT_EQ(kMsidSignalingSemantic, jsep_desc.description()->msid_signaling()); } TEST_F(WebRtcSdpTest, PlanBHasSsrcAttributeMsidSignaling) { JsepSessionDescription jsep_desc(kDummyType); ASSERT_TRUE(SdpDeserialize(kPlanBSdpFullString, &jsep_desc)); - EXPECT_EQ( - webrtc::kMsidSignalingSsrcAttribute | webrtc::kMsidSignalingSemantic, - jsep_desc.description()->msid_signaling()); + EXPECT_EQ(kMsidSignalingSsrcAttribute | kMsidSignalingSemantic, + jsep_desc.description()->msid_signaling()); } TEST_F(WebRtcSdpTest, UnifiedPlanHasMediaSectionMsidSignaling) { JsepSessionDescription jsep_desc(kDummyType); ASSERT_TRUE(SdpDeserialize(kUnifiedPlanSdpFullString, &jsep_desc)); - EXPECT_EQ(webrtc::kMsidSignalingMediaSection | webrtc::kMsidSignalingSemantic, + EXPECT_EQ(kMsidSignalingMediaSection | kMsidSignalingSemantic, jsep_desc.description()->msid_signaling()); } @@ -3829,33 +3754,33 @@ const char kSsrcAttributeMsidLine[] = "a=ssrc:1 msid:local_stream_1 audio_track_id_1"; TEST_F(WebRtcSdpTest, SerializeOnlyMediaSectionMsid) { - jdesc_.description()->set_msid_signaling(webrtc::kMsidSignalingMediaSection); - std::string sdp = webrtc::SdpSerialize(jdesc_); + jdesc_.description()->set_msid_signaling(kMsidSignalingMediaSection); + std::string sdp = SdpSerialize(jdesc_); EXPECT_NE(std::string::npos, sdp.find(kMediaSectionMsidLine)); EXPECT_EQ(std::string::npos, sdp.find(kSsrcAttributeMsidLine)); } TEST_F(WebRtcSdpTest, SerializeOnlySsrcAttributeMsid) { - jdesc_.description()->set_msid_signaling(webrtc::kMsidSignalingSsrcAttribute); - std::string sdp = webrtc::SdpSerialize(jdesc_); + jdesc_.description()->set_msid_signaling(kMsidSignalingSsrcAttribute); + std::string sdp = SdpSerialize(jdesc_); EXPECT_EQ(std::string::npos, sdp.find(kMediaSectionMsidLine)); EXPECT_NE(std::string::npos, sdp.find(kSsrcAttributeMsidLine)); } TEST_F(WebRtcSdpTest, SerializeBothMediaSectionAndSsrcAttributeMsid) { - jdesc_.description()->set_msid_signaling(webrtc::kMsidSignalingMediaSection | - webrtc::kMsidSignalingSsrcAttribute); - std::string sdp = webrtc::SdpSerialize(jdesc_); + jdesc_.description()->set_msid_signaling(kMsidSignalingMediaSection | + kMsidSignalingSsrcAttribute); + std::string sdp = SdpSerialize(jdesc_); EXPECT_NE(std::string::npos, sdp.find(kMediaSectionMsidLine)); EXPECT_NE(std::string::npos, sdp.find(kSsrcAttributeMsidLine)); } TEST_F(WebRtcSdpTest, SerializeWithoutMsidSemantics) { - jdesc_.description()->set_msid_signaling(webrtc::kMsidSignalingNotUsed); - std::string sdp = webrtc::SdpSerialize(jdesc_); + jdesc_.description()->set_msid_signaling(kMsidSignalingNotUsed); + std::string sdp = SdpSerialize(jdesc_); EXPECT_EQ(std::string::npos, sdp.find("a=msid-semantic:")); } @@ -3909,9 +3834,9 @@ TEST_F(WebRtcSdpTest, BandwidthLimitOfNegativeOneIgnored) { JsepSessionDescription jdesc_output(kDummyType); EXPECT_TRUE(SdpDeserialize(kSdpWithBandwidthOfNegativeOne, &jdesc_output)); const VideoContentDescription* vcd = - webrtc::GetFirstVideoContentDescription(jdesc_output.description()); + GetFirstVideoContentDescription(jdesc_output.description()); ASSERT_TRUE(vcd); - EXPECT_EQ(webrtc::kAutoBandwidth, vcd->bandwidth()); + EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); } // Test that "ufrag"/"pwd" in the candidate line itself are ignored, and only @@ -3939,7 +3864,7 @@ TEST_F(WebRtcSdpTest, IceCredentialsInCandidateStringIgnored) { const IceCandidateCollection* candidates = jdesc_output.candidates(0); ASSERT_NE(nullptr, candidates); ASSERT_EQ(1U, candidates->count()); - webrtc::Candidate c = candidates->at(0)->candidate(); + Candidate c = candidates->at(0)->candidate(); EXPECT_EQ("ufrag_voice", c.username()); EXPECT_EQ("pwd_voice", c.password()); } @@ -3968,7 +3893,7 @@ TEST_F(WebRtcSdpTest, AttributeWithPartialMatchingNameIsIgnored) { const IceCandidateCollection* candidates = jdesc_output.candidates(0); ASSERT_NE(nullptr, candidates); ASSERT_EQ(1U, candidates->count()); - webrtc::Candidate c = candidates->at(0)->candidate(); + Candidate c = candidates->at(0)->candidate(); EXPECT_EQ("ufrag_voice", c.username()); EXPECT_EQ("pwd_voice", c.password()); } @@ -4420,7 +4345,7 @@ TEST_F(WebRtcSdpTest, SerializeAndDeserializeWithConnectionAddress) { JsepSessionDescription expected_jsep(kDummyType); MakeDescriptionWithoutCandidates(&expected_jsep); // Serialization. - std::string message = webrtc::SdpSerialize(expected_jsep); + std::string message = SdpSerialize(expected_jsep); // Deserialization. JsepSessionDescription jdesc(kDummyType); EXPECT_TRUE(SdpDeserialize(message, &jdesc)); @@ -4470,10 +4395,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeSimulcastAttribute) { sdp += "a=simulcast:send 1,2;3 recv 4;5;6\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); EXPECT_EQ(2ul, media->simulcast_description().send_layers().size()); EXPECT_EQ(3ul, media->simulcast_description().receive_layers().size()); @@ -4491,10 +4415,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeSimulcastAttributeRemovesUnknownRids) { sdp += "a=simulcast:send 1,2;3 recv 4;5,6\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); const SimulcastDescription& simulcast = media->simulcast_description(); EXPECT_EQ(2ul, simulcast.send_layers().size()); @@ -4529,10 +4452,9 @@ TEST_F(WebRtcSdpTest, sdp += "a=simulcast:send 1;2;3 recv 2;4\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); const SimulcastDescription& simulcast = media->simulcast_description(); EXPECT_EQ(2ul, simulcast.send_layers().size()); @@ -4555,10 +4477,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeIgnoresEmptyRidLines) { sdp += "a=simulcast:send 1;2\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); const SimulcastDescription& simulcast = media->simulcast_description(); EXPECT_TRUE(simulcast.receive_layers().empty()); @@ -4581,10 +4502,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeIgnoresMalformedRidLines) { sdp += "a=simulcast:send 1,2,3;4,5\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); const SimulcastDescription& simulcast = media->simulcast_description(); EXPECT_TRUE(simulcast.receive_layers().empty()); @@ -4604,10 +4524,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeIgnoresInvalidPayloadTypesInRid) { sdp += "a=simulcast:send 1;2\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); const SimulcastDescription& simulcast = media->simulcast_description(); EXPECT_TRUE(simulcast.receive_layers().empty()); @@ -4635,10 +4554,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeIgnoresDuplicateRidLines) { sdp += "a=simulcast:send 1,2;3 recv 4\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); const SimulcastDescription& simulcast = media->simulcast_description(); EXPECT_EQ(2ul, simulcast.send_layers().size()); @@ -4658,10 +4576,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeRidSendDirection) { sdp += "a=simulcast:send 1;2\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_FALSE(media->HasSimulcast()); } @@ -4672,10 +4589,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeRidRecvDirection) { sdp += "a=simulcast:recv 1;2\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_FALSE(media->HasSimulcast()); } @@ -4690,10 +4606,9 @@ TEST_F(WebRtcSdpTest, TestDeserializeIgnoresWrongRidDirectionLines) { sdp += "a=simulcast:send 1;5;3 recv 4;2;6\r\n"; JsepSessionDescription output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); - const webrtc::ContentInfos& contents = output.description()->contents(); - const webrtc::MediaContentDescription* media = - contents.back().media_description(); + EXPECT_TRUE(SdpDeserialize(sdp, &output, &error)); + const ContentInfos& contents = output.description()->contents(); + const MediaContentDescription* media = contents.back().media_description(); EXPECT_TRUE(media->HasSimulcast()); const SimulcastDescription& simulcast = media->simulcast_description(); EXPECT_EQ(2ul, simulcast.send_layers().size()); @@ -4749,35 +4664,34 @@ TEST_F(WebRtcSdpTest, ParseNoMid) { JsepSessionDescription output(kDummyType); SdpParseError error; - ASSERT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); + ASSERT_TRUE(SdpDeserialize(sdp, &output, &error)); EXPECT_THAT(output.description()->contents(), - ElementsAre(Property("name", &webrtc::ContentInfo::mid, ""), - Property("name", &webrtc::ContentInfo::mid, ""))); + ElementsAre(Property("name", &ContentInfo::mid, ""), + Property("name", &ContentInfo::mid, ""))); } TEST_F(WebRtcSdpTest, SerializeWithDefaultSctpProtocol) { AddSctpDataChannel(false); // Don't use sctpmap JsepSessionDescription jsep_desc(kDummyType); MakeDescriptionWithoutCandidates(&jsep_desc); - std::string message = webrtc::SdpSerialize(jsep_desc); - EXPECT_NE(std::string::npos, message.find(webrtc::kMediaProtocolUdpDtlsSctp)); + std::string message = SdpSerialize(jsep_desc); + EXPECT_NE(std::string::npos, message.find(kMediaProtocolUdpDtlsSctp)); } TEST_F(WebRtcSdpTest, DeserializeWithAllSctpProtocols) { AddSctpDataChannel(false); - std::string protocols[] = {webrtc::kMediaProtocolDtlsSctp, - webrtc::kMediaProtocolUdpDtlsSctp, - webrtc::kMediaProtocolTcpDtlsSctp}; + std::string protocols[] = {kMediaProtocolDtlsSctp, kMediaProtocolUdpDtlsSctp, + kMediaProtocolTcpDtlsSctp}; for (const auto& protocol : protocols) { sctp_desc_->set_protocol(protocol); JsepSessionDescription jsep_desc(kDummyType); MakeDescriptionWithoutCandidates(&jsep_desc); - std::string message = webrtc::SdpSerialize(jsep_desc); + std::string message = SdpSerialize(jsep_desc); EXPECT_NE(std::string::npos, message.find(protocol)); JsepSessionDescription jsep_output(kDummyType); SdpParseError error; - EXPECT_TRUE(webrtc::SdpDeserialize(message, &jsep_output, &error)); + EXPECT_TRUE(SdpDeserialize(message, &jsep_output, &error)); } } @@ -4971,7 +4885,7 @@ TEST_F(WebRtcSdpTest, ParseIgnoreUnknownSsrcSpecificAttribute) { JsepSessionDescription output(kDummyType); SdpParseError error; - ASSERT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); + ASSERT_TRUE(SdpDeserialize(sdp, &output, &error)); } TEST_F(WebRtcSdpTest, ParseSessionLevelExtmapAttributes) { @@ -5114,7 +5028,7 @@ TEST_F(WebRtcSdpTest, BackfillsDefaultFmtpValues) { const auto content = jdesc.description()->contents()[0]; const auto* description = content.media_description(); ASSERT_NE(description, nullptr); - const std::vector codecs = description->codecs(); + const std::vector codecs = description->codecs(); ASSERT_EQ(codecs.size(), 4u); std::string value; @@ -5143,10 +5057,10 @@ TEST_F(WebRtcSdpTest, BackfillsDefaultFmtpValues) { TEST_F(WebRtcSdpTest, ParsesKeyValueFmtpParameterSet) { std::string params = "key1=value1;key2=value2"; - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; SdpParseError error; - ASSERT_TRUE(webrtc::ParseFmtpParameterSet(params, codec_params, &error)); + ASSERT_TRUE(ParseFmtpParameterSet(params, codec_params, &error)); EXPECT_EQ(2U, codec_params.size()); EXPECT_EQ(codec_params["key1"], "value1"); EXPECT_EQ(codec_params["key2"], "value2"); @@ -5154,10 +5068,37 @@ TEST_F(WebRtcSdpTest, ParsesKeyValueFmtpParameterSet) { TEST_F(WebRtcSdpTest, ParsesNonKeyValueFmtpParameterSet) { std::string params = "not-in-key-value-format"; - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; SdpParseError error; - ASSERT_TRUE(webrtc::ParseFmtpParameterSet(params, codec_params, &error)); + ASSERT_TRUE(ParseFmtpParameterSet(params, codec_params, &error)); EXPECT_EQ(1U, codec_params.size()); EXPECT_EQ(codec_params[""], "not-in-key-value-format"); } + +TEST_F(WebRtcSdpTest, SctpProtocolWithNonApplication) { + std::string sdp = + "v=0\r\n" + "o=- 0 3 IN IP4 127.0.0.1\r\n" + "s=-\r\n" + "t=0 0\r\n" + "a=group:BUNDLE 0\r\n" + "a=fingerprint:sha-1 " + "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n" + "a=setup:actpass\r\n" + "a=ice-ufrag:ETEn\r\n" + "a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n" + "m=unsupported 9 UDP/DTLS/SCTP webrtc-datachannel\r\n" + "c=IN IP4 0.0.0.0\r\n" + "a=mid:0\r\n" + "a=sctp-port:5000\r\n" + "a=max-message-size:262144\r\n"; + + auto desc = CreateSessionDescription(SdpType::kOffer, sdp); + ASSERT_NE(desc, nullptr); + std::string serialized; + EXPECT_TRUE(desc->ToString(&serialized)); +} + +} // namespace +} // namespace webrtc diff --git a/pc/webrtc_session_description_factory.cc b/pc/webrtc_session_description_factory.cc index 0ca42e4802..5c90efd063 100644 --- a/pc/webrtc_session_description_factory.cc +++ b/pc/webrtc_session_description_factory.cc @@ -43,10 +43,6 @@ #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/ssl_stream_adapter.h" -#include "rtc_base/unique_id_generator.h" - -using ::webrtc::MediaSessionOptions; -using webrtc::UniqueRandomIdGenerator; namespace webrtc { namespace { @@ -116,7 +112,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( bool dtls_enabled, std::unique_ptr cert_generator, scoped_refptr certificate, - std::function&)> + std::function&)> on_certificate_ready, CodecLookupHelper* codec_lookup_helper, const FieldTrialsView& field_trials) diff --git a/pc/webrtc_session_description_factory.h b/pc/webrtc_session_description_factory.h index 3f3e6b62aa..c897a81ac2 100644 --- a/pc/webrtc_session_description_factory.h +++ b/pc/webrtc_session_description_factory.h @@ -53,7 +53,7 @@ class WebRtcSessionDescriptionFactory { bool dtls_enabled, std::unique_ptr cert_generator, scoped_refptr certificate, - std::function&)> + std::function&)> on_certificate_ready, CodecLookupHelper* codec_lookup_helper, const FieldTrialsView& field_trials); @@ -145,7 +145,7 @@ class WebRtcSessionDescriptionFactory { CertificateRequestState certificate_request_state_; std::queue> callbacks_; - std::function&)> + std::function&)> on_certificate_ready_; WeakPtrFactory weak_factory_{this}; diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 88164115c4..1211f0c856 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -21,7 +21,7 @@ rtc_source_set("protobuf_utils") { } } -rtc_source_set("bitstream_reader") { +rtc_library("bitstream_reader") { sources = [ "bitstream_reader.cc", "bitstream_reader.h", @@ -49,7 +49,7 @@ rtc_source_set("untyped_function") { deps = [ "system:assume" ] } -rtc_source_set("callback_list") { +rtc_library("callback_list") { sources = [ "callback_list.cc", "callback_list.h", @@ -182,6 +182,19 @@ rtc_library("copy_on_write_buffer") { ] } +rtc_library("denormal_disabler") { + visibility = [ "*" ] + public = [ "denormal_disabler.h" ] + sources = [ "denormal_disabler.cc" ] + deps = [ + "../rtc_base:checks", + "../rtc_base/system:arch", + ] + if (is_clang) { + cflags_cc = [ "-Wno-unused-private-field" ] + } +} + rtc_library("event_tracer") { visibility = [ "*" ] sources = [ @@ -607,7 +620,7 @@ rtc_source_set("type_traits") { sources = [ "type_traits.h" ] } -rtc_source_set("rtc_operations_chain") { +rtc_library("rtc_operations_chain") { visibility = [ "*" ] sources = [ "operations_chain.cc", @@ -703,10 +716,10 @@ if (rtc_include_tests) { ":logging", ":rtc_event", ":rtc_task_queue_stdlib", + ":threading", "../api/task_queue", "../api/task_queue:task_queue_test", "../api/units:time_delta", - "../system_wrappers", "../test:test_main", "../test:test_support", ] @@ -986,7 +999,6 @@ rtc_library("threading") { "../api/transport:ecn_marking", "../api/units:time_delta", "../api/units:timestamp", - "../system_wrappers:field_trial", "./network:ecn_marking", "synchronization:mutex", "system:no_unique_address", @@ -1050,7 +1062,7 @@ rtc_library("socket") { } } -rtc_source_set("network_constants") { +rtc_library("network_constants") { visibility = [ "*" ] sources = [ "network_constants.cc", @@ -1287,7 +1299,6 @@ rtc_library("async_udp_socket") { "../api:sequence_checker", "../api/units:time_delta", "../api/units:timestamp", - "../system_wrappers:field_trial", "network:received_packet", "network:sent_packet", "system:no_unique_address", @@ -1461,7 +1472,7 @@ rtc_source_set("ssl_header") { } } -rtc_source_set("digest") { +rtc_library("digest") { visibility = [ "*" ] sources = [ "message_digest.cc", @@ -1746,6 +1757,7 @@ rtc_library("rtc_base_tests_utils") { "../api:scoped_refptr", "../api:sequence_checker", "../api/task_queue", + "../api/task_queue:pending_task_safety_flag", "../api/units:time_delta", "../api/units:timestamp", "../test:scoped_key_value_config", @@ -1758,12 +1770,28 @@ rtc_library("rtc_base_tests_utils") { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", + "//third_party/abseil-cpp/absl/strings:strings", ] if (is_fuchsia) { deps += [ "//third_party/fuchsia-sdk/sdk/pkg/zx" ] } } +rtc_library("rtp_to_ntp_estimator") { + visibility = [ "*" ] + sources = [ + "rtp_to_ntp_estimator.cc", + "rtp_to_ntp_estimator.h", + ] + deps = [ + ":checks", + ":logging", + ":rtc_numerics", + ":safe_conversions", + "../system_wrappers", + ] +} + rtc_library("task_queue_for_test") { testonly = true @@ -1795,6 +1823,78 @@ rtc_library("base64") { ] } +if (rtc_rusty_base64) { + import("//build/config/rust.gni") + import("//build/rust/rust_static_library.gni") + + rtc_source_set("base64_header") { + sources = [ "base64.h" ] + deps = [ + "../api:array_view", + "//third_party/abseil-cpp/absl/strings:string_view", + ] + } + + rust_static_library("base64_rust_bridge") { + allow_unsafe = true # Needed for FFI with cxx crate. + crate_root = "base64.rs" + sources = [ "base64.rs" ] + cxx_bindings = [ "base64.rs" ] + deps = [ + ":base64_header", + "//third_party/rust/base64/v0_22:lib", + ] + visibility = [ ":rusty_base64" ] + } + + rtc_library("rusty_base64") { + sources = [ "base64_rust.cc" ] + deps = [ + ":base64_header", + ":base64_rust_bridge", + "//build/rust:cxx_cppdeps", + "//third_party/abseil-cpp/absl/strings:string_view", + ] + } + + if (rtc_include_tests) { + rtc_test("rusty_base64_unittest") { + sources = [ "base64_unittest.cc" ] + deps = [ + ":base64_header", + ":rusty_base64", + "../test:test_main", + "../test:test_support", + "//third_party/abseil-cpp/absl/strings:string_view", + ] + } + + if (rtc_enable_google_benchmarks) { + rtc_test("rusty_base64_benchmark") { + sources = [ "base64_benchmark.cc" ] + deps = [ + ":base64_header", + ":rusty_base64", + "../test:benchmark_main", + "//third_party/google_benchmark", + ] + } + } + } +} + +rtc_library("cpu_info") { + visibility = [ "*" ] + sources = [ + "cpu_info.cc", + "cpu_info.h", + ] + deps = [ + ":checks", + ":logging", + ] +} + if (rtc_include_tests) { if (rtc_enable_google_benchmarks) { rtc_test("base64_benchmark") { @@ -2110,15 +2210,18 @@ if (rtc_include_tests) { "crc32_unittest.cc", "crypto_random_unittest.cc", "data_rate_limiter_unittest.cc", + "denormal_disabler_unittest.cc", "fake_clock_unittest.cc", "ip_address_unittest.cc", "memory_usage_unittest.cc", "message_digest_unittest.cc", "network_route_unittest.cc", "network_unittest.cc", + "openssl_stream_adapter_unittest.cc", "rolling_accumulator_unittest.cc", "rtc_certificate_generator_unittest.cc", "rtc_certificate_unittest.cc", + "rtp_to_ntp_estimator_unittest.cc", "test_client_unittest.cc", "thread_unittest.cc", "unique_id_generator_unittest.cc", @@ -2133,6 +2236,7 @@ if (rtc_include_tests) { ":crc32", ":crypto_random", ":data_rate_limiter", + ":denormal_disabler", ":digest", ":gunit_helpers", ":ifaddrs_converter", @@ -2145,11 +2249,13 @@ if (rtc_include_tests) { ":network_constants", ":network_route", ":null_socket_server", + ":random", ":refcount", ":rolling_accumulator", ":rtc_base_tests_utils", ":rtc_certificate_generator", ":rtc_event", + ":rtp_to_ntp_estimator", ":safe_conversions", ":socket", ":socket_adapters", @@ -2171,12 +2277,14 @@ if (rtc_include_tests) { "../api:rtc_error_matchers", "../api:scoped_refptr", "../api:sequence_checker", + "../api/crypto:options", "../api/environment", "../api/environment:environment_factory", "../api/task_queue", "../api/task_queue:pending_task_safety_flag", "../api/task_queue:task_queue_test", "../api/units:time_delta", + "../system_wrappers", "../test:field_trial", "../test:fileutils", "../test:rtc_expect_death", diff --git a/rtc_base/DEPS b/rtc_base/DEPS index 0e7237d329..9e8908ceb2 100644 --- a/rtc_base/DEPS +++ b/rtc_base/DEPS @@ -41,4 +41,7 @@ specific_include_rules = { "base64_benchmark\.cc": [ "+benchmark", ], + "base64_rust\.cc": [ + "+third_party/rust/chromium_crates_io/vendor/cxx-v1/include/cxx.h", + ], } diff --git a/rtc_base/async_dns_resolver.cc b/rtc_base/async_dns_resolver.cc index 625721a2d9..9c9610d47d 100644 --- a/rtc_base/async_dns_resolver.cc +++ b/rtc_base/async_dns_resolver.cc @@ -112,7 +112,7 @@ class AsyncDnsResolver::State : public RefCountedBase { // Execute the passed function if the state is Active. void Finish(absl::AnyInvocable function) { - webrtc::MutexLock lock(&mutex_); + MutexLock lock(&mutex_); if (status_ != Status::kActive) { return; } @@ -120,12 +120,12 @@ class AsyncDnsResolver::State : public RefCountedBase { function(); } void Kill() { - webrtc::MutexLock lock(&mutex_); + MutexLock lock(&mutex_); status_ = Status::kDead; } private: - webrtc::Mutex mutex_; + Mutex mutex_; Status status_ RTC_GUARDED_BY(mutex_) = Status::kActive; }; @@ -148,7 +148,7 @@ void AsyncDnsResolver::Start(const SocketAddress& addr, result_.addr_ = addr; callback_ = std::move(callback); auto thread_function = [this, addr, family, flag = safety_.flag(), - caller_task_queue = webrtc::TaskQueueBase::Current(), + caller_task_queue = TaskQueueBase::Current(), state = state_] { std::vector addresses; int error = ResolveHostname(addr.hostname(), family, addresses); diff --git a/rtc_base/async_dns_resolver_unittest.cc b/rtc_base/async_dns_resolver_unittest.cc index e9f1d2b463..5c4d65415d 100644 --- a/rtc_base/async_dns_resolver_unittest.cc +++ b/rtc_base/async_dns_resolver_unittest.cc @@ -17,7 +17,6 @@ #include "rtc_base/logging.h" #include "rtc_base/net_helpers.h" #include "rtc_base/socket_address.h" -#include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/run_loop.h" @@ -28,7 +27,7 @@ namespace { using ::testing::IsTrue; -const webrtc::TimeDelta kDefaultTimeout = webrtc::TimeDelta::Millis(1000); +const TimeDelta kDefaultTimeout = TimeDelta::Millis(1000); const int kPortNumber = 3027; TEST(AsyncDnsResolver, ConstructorWorks) { @@ -64,7 +63,7 @@ TEST(AsyncDnsResolver, ResolveAfterDeleteDoesNotReturn) { bool done = false; resolver->Start(address, [&done] { done = true; }); resolver.reset(); // Deletes resolver. - Thread::Current()->SleepMs(1); // Allows callback to execute + loop.Flush(); // Allows callback to execute EXPECT_FALSE(done); // Expect no result. } diff --git a/rtc_base/async_packet_socket.cc b/rtc_base/async_packet_socket.cc index 2ead920705..397e197ec6 100644 --- a/rtc_base/async_packet_socket.cc +++ b/rtc_base/async_packet_socket.cc @@ -41,7 +41,7 @@ AsyncPacketSocket::~AsyncPacketSocket() = default; void AsyncPacketSocket::SubscribeCloseEvent( const void* removal_tag, - std::function callback) { + std::function callback) { RTC_DCHECK_RUN_ON(&network_checker_); on_close_.AddReceiver(removal_tag, std::move(callback)); } @@ -52,8 +52,7 @@ void AsyncPacketSocket::UnsubscribeCloseEvent(const void* removal_tag) { } void AsyncPacketSocket::RegisterReceivedPacketCallback( - absl::AnyInvocable + absl::AnyInvocable received_packet_callback) { RTC_DCHECK_RUN_ON(&network_checker_); RTC_CHECK(!received_packet_callback_); diff --git a/rtc_base/async_packet_socket_unittest.cc b/rtc_base/async_packet_socket_unittest.cc index 9ed491efb5..b37334aa4e 100644 --- a/rtc_base/async_packet_socket_unittest.cc +++ b/rtc_base/async_packet_socket_unittest.cc @@ -30,7 +30,7 @@ class MockAsyncPacketSocket : public AsyncPacketSocket { Send, (const void* pv, size_t cb, - const webrtc::AsyncSocketPacketOptions& options), + const AsyncSocketPacketOptions& options), (override)); MOCK_METHOD(int, @@ -38,7 +38,7 @@ class MockAsyncPacketSocket : public AsyncPacketSocket { (const void* pv, size_t cb, const SocketAddress& addr, - const webrtc::AsyncSocketPacketOptions& options), + const AsyncSocketPacketOptions& options), (override)); MOCK_METHOD(int, Close, (), (override)); MOCK_METHOD(State, GetState, (), (const, override)); @@ -52,8 +52,7 @@ class MockAsyncPacketSocket : public AsyncPacketSocket { TEST(AsyncPacketSocket, RegisteredCallbackReceivePacketsFromNotify) { MockAsyncPacketSocket mock_socket; - MockFunction + MockFunction received_packet; EXPECT_CALL(received_packet, Call); diff --git a/rtc_base/async_tcp_socket.cc b/rtc_base/async_tcp_socket.cc index 420d3595ca..e07bfc1f20 100644 --- a/rtc_base/async_tcp_socket.cc +++ b/rtc_base/async_tcp_socket.cc @@ -266,7 +266,7 @@ int AsyncTCPSocket::Send(const void* pv, if (!IsOutBufferEmpty()) return static_cast(cb); - PacketLength pkt_len = webrtc::HostToNetwork16(static_cast(cb)); + PacketLength pkt_len = HostToNetwork16(static_cast(cb)); AppendToOutBuffer(&pkt_len, kPacketLenSize); AppendToOutBuffer(pv, cb); @@ -295,7 +295,7 @@ size_t AsyncTCPSocket::ProcessInput(ArrayView data) { if (bytes_left < kPacketLenSize) return processed_bytes; - PacketLength pkt_len = webrtc::GetBE16(data.data() + processed_bytes); + PacketLength pkt_len = GetBE16(data.data() + processed_bytes); if (bytes_left < kPacketLenSize + pkt_len) return processed_bytes; diff --git a/rtc_base/async_udp_socket.cc b/rtc_base/async_udp_socket.cc index f0846875f9..652c104933 100644 --- a/rtc_base/async_udp_socket.cc +++ b/rtc_base/async_udp_socket.cc @@ -67,7 +67,7 @@ int AsyncUDPSocket::Send(const void* pv, const AsyncSocketPacketOptions& options) { SentPacketInfo sent_packet(options.packet_id, TimeMillis(), options.info_signaled_after_sent); - webrtc::CopySocketInformationToPacketInfo(cb, *this, &sent_packet.info); + CopySocketInformationToPacketInfo(cb, *this, &sent_packet.info); int ret = socket_->Send(pv, cb); SignalSentPacket(this, sent_packet); return ret; @@ -79,7 +79,7 @@ int AsyncUDPSocket::SendTo(const void* pv, const AsyncSocketPacketOptions& options) { SentPacketInfo sent_packet(options.packet_id, TimeMillis(), options.info_signaled_after_sent); - webrtc::CopySocketInformationToPacketInfo(cb, *this, &sent_packet.info); + CopySocketInformationToPacketInfo(cb, *this, &sent_packet.info); if (has_set_ect1_options_ != options.ecn_1) { // It is unclear what is most efficient, setting options on every sent // packet or when changed. Potentially, can separate send sockets be used? diff --git a/rtc_base/base64.cc b/rtc_base/base64.cc index eaa4d2bfd6..e9fc5d05c8 100644 --- a/rtc_base/base64.cc +++ b/rtc_base/base64.cc @@ -29,6 +29,10 @@ bool IsStrictBase64(absl::string_view data) { } } // namespace +std::string Base64Encode(absl::string_view data) { + return absl::Base64Escape(data); +} + std::optional Base64Decode(absl::string_view data, Base64DecodeOptions options) { // absl::Base64Unescape is forgiving. Return nullopt if the input is not diff --git a/rtc_base/base64.h b/rtc_base/base64.h index 24c1d97e0c..9a83d8b07d 100644 --- a/rtc_base/base64.h +++ b/rtc_base/base64.h @@ -15,22 +15,19 @@ #include #include -#include "absl/strings/escaping.h" #include "absl/strings/string_view.h" #include "api/array_view.h" namespace webrtc { +std::string Base64Encode(absl::string_view data); + inline std::string Base64Encode(ArrayView data) { - return absl::Base64Escape(absl::string_view( + return Base64Encode(absl::string_view( reinterpret_cast(data.data()), data.size())); } -inline std::string Base64Encode(absl::string_view data) { - return absl::Base64Escape(data); -} - -enum class Base64DecodeOptions { +enum class Base64DecodeOptions : uint8_t { kStrict, // Matches https://infra.spec.whatwg.org/#forgiving-base64-decode. kForgiving, diff --git a/rtc_base/base64.rs b/rtc_base/base64.rs new file mode 100644 index 0000000000..f9397dd457 --- /dev/null +++ b/rtc_base/base64.rs @@ -0,0 +1,73 @@ +/* + * 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. + */ + +use base64::alphabet; +use base64::engine::general_purpose; +use base64::engine::DecodePaddingMode; +use base64::Engine; +use cxx::CxxString; +use std::pin::Pin; + +#[cxx::bridge(namespace = "webrtc")] +mod ffi { + #[repr(u8)] + enum Base64DecodeOptions { + kStrict, + kForgiving, + } + + extern "C++" { + include!("rtc_base/base64.h"); + type Base64DecodeOptions; + } + + extern "Rust" { + fn rs_base64_encode(data: &[u8]) -> String; + fn rs_base64_decode( + data: &[u8], + options: Base64DecodeOptions, + output: Pin<&mut CxxString>, + ) -> bool; + } +} + +fn rs_base64_encode(data: &[u8]) -> String { + general_purpose::STANDARD.encode(data) +} + +const FORGIVING_ENGINE: general_purpose::GeneralPurpose = general_purpose::GeneralPurpose::new( + &alphabet::STANDARD, + general_purpose::GeneralPurposeConfig::new() + .with_decode_padding_mode(DecodePaddingMode::Indifferent), +); + +fn rs_base64_decode( + data: &[u8], + options: ffi::Base64DecodeOptions, + output: Pin<&mut CxxString>, +) -> bool { + let result = match options { + ffi::Base64DecodeOptions::kStrict => general_purpose::STANDARD.decode(data), + ffi::Base64DecodeOptions::kForgiving => { + let data_without_whitespace: Vec = + data.iter().filter(|&c| !c.is_ascii_whitespace()).copied().collect(); + FORGIVING_ENGINE.decode(data_without_whitespace) + } + _ => unreachable!(), + }; + + match result { + Ok(vec) => { + output.push_bytes(vec.as_slice()); + true + } + Err(_) => false, + } +} diff --git a/rtc_base/base64_rust.cc b/rtc_base/base64_rust.cc new file mode 100644 index 0000000000..30061046c9 --- /dev/null +++ b/rtc_base/base64_rust.cc @@ -0,0 +1,41 @@ +/* + * 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 +#include +#include + +#include "absl/strings/string_view.h" +#include "rtc_base/base64.h" +#include "rtc_base/base64.rs.h" +#include "third_party/rust/chromium_crates_io/vendor/cxx-v1/include/cxx.h" + +namespace webrtc { + +std::string Base64Encode(absl::string_view data) { + rust::Slice input_slice( + reinterpret_cast(data.data()), data.size()); + rust::Vec output_slice; + rust::String str = rs_base64_encode(input_slice); + return std::string(str); +} + +std::optional Base64Decode(absl::string_view data, + Base64DecodeOptions options) { + rust::Slice input_slice( + reinterpret_cast(data.data()), data.size()); + std::string output; + if (!rs_base64_decode(input_slice, options, output)) { + return std::nullopt; + } + return output; +} + +} // namespace webrtc diff --git a/rtc_base/bit_buffer_unittest.cc b/rtc_base/bit_buffer_unittest.cc index 923a3df30a..670275c879 100644 --- a/rtc_base/bit_buffer_unittest.cc +++ b/rtc_base/bit_buffer_unittest.cc @@ -22,7 +22,6 @@ namespace webrtc { using ::testing::ElementsAre; -using ::webrtc::BitstreamReader; TEST(BitBufferWriterTest, ConsumeBits) { uint8_t bytes[64] = {0}; diff --git a/rtc_base/boringssl_certificate.cc b/rtc_base/boringssl_certificate.cc index 016b4dabba..4a34d05448 100644 --- a/rtc_base/boringssl_certificate.cc +++ b/rtc_base/boringssl_certificate.cc @@ -265,7 +265,7 @@ std::unique_ptr BoringSSLCertificate::Generate( SSLIdentityParams actual_params(params); if (actual_params.common_name.empty()) { // Use a random string, arbitrarily 8 chars long. - actual_params.common_name = webrtc::CreateRandomString(8); + actual_params.common_name = CreateRandomString(8); } bssl::UniquePtr cert_buffer = MakeCertificate(key_pair->pkey(), actual_params); diff --git a/rtc_base/boringssl_identity.cc b/rtc_base/boringssl_identity.cc index 5c8f60e362..4406962fac 100644 --- a/rtc_base/boringssl_identity.cc +++ b/rtc_base/boringssl_identity.cc @@ -116,9 +116,8 @@ std::unique_ptr BoringSSLIdentity::CreateFromPEMStrings( std::unique_ptr BoringSSLIdentity::CreateFromPEMChainStrings( absl::string_view private_key, absl::string_view certificate_chain) { - bssl::UniquePtr bio( - BIO_new_mem_buf(certificate_chain.data(), - webrtc::dchecked_cast(certificate_chain.size()))); + bssl::UniquePtr bio(BIO_new_mem_buf( + certificate_chain.data(), dchecked_cast(certificate_chain.size()))); if (!bio) { return nullptr; } diff --git a/rtc_base/byte_buffer.cc b/rtc_base/byte_buffer.cc index 0f5ea525f6..0cf153fe7e 100644 --- a/rtc_base/byte_buffer.cc +++ b/rtc_base/byte_buffer.cc @@ -56,7 +56,7 @@ bool ByteBufferReader::ReadUInt16(uint16_t* val) { if (!ReadBytes(reinterpret_cast(&v), 2)) { return false; } else { - *val = webrtc::NetworkToHost16(v); + *val = NetworkToHost16(v); return true; } } @@ -72,7 +72,7 @@ bool ByteBufferReader::ReadUInt24(uint32_t* val) { if (!ReadBytes(read_into, 3)) { return false; } else { - *val = webrtc::NetworkToHost32(v); + *val = NetworkToHost32(v); return true; } } @@ -85,7 +85,7 @@ bool ByteBufferReader::ReadUInt32(uint32_t* val) { if (!ReadBytes(reinterpret_cast(&v), 4)) { return false; } else { - *val = webrtc::NetworkToHost32(v); + *val = NetworkToHost32(v); return true; } } @@ -98,7 +98,7 @@ bool ByteBufferReader::ReadUInt64(uint64_t* val) { if (!ReadBytes(reinterpret_cast(&v), 8)) { return false; } else { - *val = webrtc::NetworkToHost64(v); + *val = NetworkToHost64(v); return true; } } diff --git a/rtc_base/byte_buffer_unittest.cc b/rtc_base/byte_buffer_unittest.cc index 6bf532deb9..d0b93e2e22 100644 --- a/rtc_base/byte_buffer_unittest.cc +++ b/rtc_base/byte_buffer_unittest.cc @@ -46,35 +46,35 @@ TEST(ByteBufferTest, TestByteOrder) { uint32_t n32 = 1; uint64_t n64 = 1; - EXPECT_EQ(n16, webrtc::NetworkToHost16(webrtc::HostToNetwork16(n16))); - EXPECT_EQ(n32, webrtc::NetworkToHost32(webrtc::HostToNetwork32(n32))); - EXPECT_EQ(n64, webrtc::NetworkToHost64(webrtc::HostToNetwork64(n64))); + EXPECT_EQ(n16, NetworkToHost16(HostToNetwork16(n16))); + EXPECT_EQ(n32, NetworkToHost32(HostToNetwork32(n32))); + EXPECT_EQ(n64, NetworkToHost64(HostToNetwork64(n64))); - if (webrtc::IsHostBigEndian()) { + if (IsHostBigEndian()) { // The host is the network (big) endian. - EXPECT_EQ(n16, webrtc::HostToNetwork16(n16)); - EXPECT_EQ(n32, webrtc::HostToNetwork32(n32)); - EXPECT_EQ(n64, webrtc::HostToNetwork64(n64)); + EXPECT_EQ(n16, HostToNetwork16(n16)); + EXPECT_EQ(n32, HostToNetwork32(n32)); + EXPECT_EQ(n64, HostToNetwork64(n64)); // GetBE converts big endian to little endian here. - EXPECT_EQ(n16 >> 8, webrtc::GetBE16(&n16)); - EXPECT_EQ(n32 >> 24, webrtc::GetBE32(&n32)); - EXPECT_EQ(n64 >> 56, webrtc::GetBE64(&n64)); + EXPECT_EQ(n16 >> 8, GetBE16(&n16)); + EXPECT_EQ(n32 >> 24, GetBE32(&n32)); + EXPECT_EQ(n64 >> 56, GetBE64(&n64)); } else { // The host is little endian. - EXPECT_NE(n16, webrtc::HostToNetwork16(n16)); - EXPECT_NE(n32, webrtc::HostToNetwork32(n32)); - EXPECT_NE(n64, webrtc::HostToNetwork64(n64)); + EXPECT_NE(n16, HostToNetwork16(n16)); + EXPECT_NE(n32, HostToNetwork32(n32)); + EXPECT_NE(n64, HostToNetwork64(n64)); // GetBE converts little endian to big endian here. - EXPECT_EQ(webrtc::GetBE16(&n16), webrtc::HostToNetwork16(n16)); - EXPECT_EQ(webrtc::GetBE32(&n32), webrtc::HostToNetwork32(n32)); - EXPECT_EQ(webrtc::GetBE64(&n64), webrtc::HostToNetwork64(n64)); + EXPECT_EQ(GetBE16(&n16), HostToNetwork16(n16)); + EXPECT_EQ(GetBE32(&n32), HostToNetwork32(n32)); + EXPECT_EQ(GetBE64(&n64), HostToNetwork64(n64)); // GetBE converts little endian to big endian here. - EXPECT_EQ(n16 << 8, webrtc::GetBE16(&n16)); - EXPECT_EQ(n32 << 24, webrtc::GetBE32(&n32)); - EXPECT_EQ(n64 << 56, webrtc::GetBE64(&n64)); + EXPECT_EQ(n16 << 8, GetBE16(&n16)); + EXPECT_EQ(n32 << 24, GetBE32(&n32)); + EXPECT_EQ(n64 << 56, GetBE64(&n64)); } } diff --git a/rtc_base/containers/BUILD.gn b/rtc_base/containers/BUILD.gn index a2a21157b7..c4d9f28f9f 100644 --- a/rtc_base/containers/BUILD.gn +++ b/rtc_base/containers/BUILD.gn @@ -12,7 +12,6 @@ rtc_library("flat_containers_internal") { sources = [ "flat_tree.cc", "flat_tree.h", - "identity.h", "invoke.h", "move_only_int.h", ] @@ -51,5 +50,6 @@ rtc_library("unittests") { "../../test:test_support", "//testing/gmock:gmock", "//testing/gtest:gtest", + "//third_party/abseil-cpp/absl/algorithm:container", ] } diff --git a/rtc_base/containers/flat_set.h b/rtc_base/containers/flat_set.h index 355690b09d..22001d3d5c 100644 --- a/rtc_base/containers/flat_set.h +++ b/rtc_base/containers/flat_set.h @@ -17,7 +17,6 @@ #include #include "rtc_base/containers/flat_tree.h" // IWYU pragma: export -#include "rtc_base/containers/identity.h" namespace webrtc { @@ -159,7 +158,7 @@ template , class Container = std::vector> using flat_set = typename ::webrtc::flat_containers_internal:: - flat_tree; + flat_tree; // ---------------------------------------------------------------------------- // General operations. diff --git a/rtc_base/containers/flat_set_unittest.cc b/rtc_base/containers/flat_set_unittest.cc index 617db92440..6b0a2f7203 100644 --- a/rtc_base/containers/flat_set_unittest.cc +++ b/rtc_base/containers/flat_set_unittest.cc @@ -12,7 +12,6 @@ #include "rtc_base/containers/flat_set.h" -#include #include #include #include @@ -100,7 +99,7 @@ TEST(FlatSet, CopySwap) { } TEST(FlatSet, UsingTransparentCompare) { - using ExplicitInt = webrtc::MoveOnlyInt; + using ExplicitInt = MoveOnlyInt; flat_set s; const auto& s1 = s; int x = 0; diff --git a/rtc_base/containers/flat_tree_unittest.cc b/rtc_base/containers/flat_tree_unittest.cc index 9bb803d16d..eb45cc7c2a 100644 --- a/rtc_base/containers/flat_tree_unittest.cc +++ b/rtc_base/containers/flat_tree_unittest.cc @@ -36,6 +36,7 @@ // * No tests with min_allocator and no tests counting allocations. // Flat sets currently don't support allocators. +#include #include #include #include @@ -43,9 +44,12 @@ #include #include #include +#include +#include +#include #include -#include "rtc_base/containers/identity.h" +#include "absl/algorithm/container.h" #include "rtc_base/containers/move_only_int.h" #include "test/gmock.h" #include "test/gtest.h" @@ -157,22 +161,30 @@ struct LessByFirst { // Common test trees. template using TypedTree = flat_tree, ContainerT>; using IntTree = TypedTree>; using IntPair = std::pair; -using IntPairTree = - flat_tree, std::vector>; -using MoveOnlyTree = - flat_tree, std::vector>; -using EmplaceableTree = - flat_tree, std::vector>; +using IntPairTree = flat_tree, + std::vector>; +using MoveOnlyTree = flat_tree, + std::vector>; +using EmplaceableTree = flat_tree, + std::vector>; using ReversedTree = - flat_tree, std::vector>; + flat_tree, std::vector>; -using TreeWithStrangeCompare = - flat_tree>; +using TreeWithStrangeCompare = flat_tree>; using ::testing::ElementsAre; using ::testing::IsEmpty; @@ -203,8 +215,8 @@ TEST(FlatTree, NoExcept) { MoveThrows& operator=(MoveThrows&&) noexcept(false) { return *this; } }; - using MoveThrowsTree = - flat_tree, std::array>; + using MoveThrowsTree = flat_tree, + std::array>; static_assert(std::is_nothrow_move_constructible::value, "Error: IntTree is not nothrow move constructible"); @@ -225,7 +237,7 @@ TEST(FlatTree, NoExcept) { TEST(FlatTree, IncompleteType) { struct A { - using Tree = flat_tree, std::vector>; + using Tree = flat_tree, std::vector>; int data; Tree set_with_incomplete_type; Tree::iterator it; @@ -240,7 +252,8 @@ TEST(FlatTree, IncompleteType) { TEST(FlatTree, Stability) { using Pair = std::pair; - using Tree = flat_tree, std::vector>; + using Tree = + flat_tree, std::vector>; // Constructors are stable. Tree cont({{0, 0}, {1, 0}, {0, 1}, {2, 0}, {0, 2}, {1, 1}}); @@ -388,7 +401,8 @@ TEST(FlatTree, ContainerMoveConstructor) { storage.push_back(Pair(1, MoveOnlyInt(0))); storage.push_back(Pair(2, MoveOnlyInt(1))); - using Tree = flat_tree, std::vector>; + using Tree = + flat_tree, std::vector>; Tree tree(std::move(storage)); // The list should be two items long, with only the first "2" saved. @@ -470,7 +484,8 @@ TEST(FlatTree, SortedUniqueVectorMoveConstructor) { storage.push_back(Pair(1, MoveOnlyInt(0))); storage.push_back(Pair(2, MoveOnlyInt(0))); - using Tree = flat_tree, std::vector>; + using Tree = + flat_tree, std::vector>; Tree tree(sorted_unique, std::move(storage)); ASSERT_EQ(2u, tree.size()); @@ -997,7 +1012,7 @@ TYPED_TEST_P(FlatTreeTest, ErasePosition) { { using T = TemplateConstructor; - flat_tree, std::vector> cont; + flat_tree, std::vector> cont; T v(0); auto it = cont.find(v); diff --git a/rtc_base/containers/identity.h b/rtc_base/containers/identity.h deleted file mode 100644 index 29592931bd..0000000000 --- a/rtc_base/containers/identity.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 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. - */ - -// This implementation is borrowed from Chromium. - -#ifndef RTC_BASE_CONTAINERS_IDENTITY_H_ -#define RTC_BASE_CONTAINERS_IDENTITY_H_ - -#include - -namespace webrtc { - -// Implementation of C++20's std::identity. -// -// Reference: -// - https://en.cppreference.com/w/cpp/utility/functional/identity -// - https://wg21.link/func.identity -struct identity { - template - constexpr T&& operator()(T&& t) const noexcept { - return std::forward(t); - } - - using is_transparent = void; -}; - -} // namespace webrtc - -#endif // RTC_BASE_CONTAINERS_IDENTITY_H_ diff --git a/system_wrappers/source/cpu_info.cc b/rtc_base/cpu_info.cc similarity index 83% rename from system_wrappers/source/cpu_info.cc rename to rtc_base/cpu_info.cc index 8f72653269..99a5bc8f8a 100644 --- a/system_wrappers/source/cpu_info.cc +++ b/rtc_base/cpu_info.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * 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 @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/include/cpu_info.h" +#include "rtc_base/cpu_info.h" #include @@ -25,9 +25,10 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" -namespace internal { -static int DetectNumberOfCores() { - int number_of_cores; +namespace { + +uint32_t DetectNumberOfCores() { + int number_of_cores = 0; #if defined(WEBRTC_WIN) SYSTEM_INFO si; @@ -56,20 +57,24 @@ static int DetectNumberOfCores() { RTC_LOG(LS_INFO) << "Available number of cores: " << number_of_cores; RTC_CHECK_GT(number_of_cores, 0); - return number_of_cores; + return static_cast(number_of_cores); } -} // namespace internal + +} // namespace namespace webrtc { -uint32_t CpuInfo::DetectNumberOfCores() { +namespace cpu_info { + +uint32_t DetectNumberOfCores() { // Statically cache the number of system cores available since if the process // is running in a sandbox, we may only be able to read the value once (before // the sandbox is initialized) and not thereafter. // For more information see crbug.com/176522. - static const uint32_t logical_cpus = - static_cast(::internal::DetectNumberOfCores()); + static const uint32_t logical_cpus = ::DetectNumberOfCores(); return logical_cpus; } +} // namespace cpu_info + } // namespace webrtc diff --git a/test/fuzzers/dtls_utils_fuzzer.cc b/rtc_base/cpu_info.h similarity index 59% rename from test/fuzzers/dtls_utils_fuzzer.cc rename to rtc_base/cpu_info.h index 622955864e..9a4f569f3f 100644 --- a/test/fuzzers/dtls_utils_fuzzer.cc +++ b/rtc_base/cpu_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. + * 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 @@ -7,15 +7,21 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -#include -#include -#include "api/array_view.h" -#include "p2p/dtls/dtls_utils.h" +#ifndef RTC_BASE_CPU_INFO_H_ +#define RTC_BASE_CPU_INFO_H_ + +#include namespace webrtc { -void FuzzOneInput(const uint8_t* data, size_t size) { - webrtc::GetDtlsHandshakeAcks(webrtc::MakeArrayView(data, size)); -} + +namespace cpu_info { + +// Returned number of cores is always >= 1. +uint32_t DetectNumberOfCores(); + +} // namespace cpu_info } // namespace webrtc + +#endif // RTC_BASE_CPU_INFO_H_ diff --git a/rtc_base/cpu_time.cc b/rtc_base/cpu_time.cc index b0d187c411..0ae890632e 100644 --- a/rtc_base/cpu_time.cc +++ b/rtc_base/cpu_time.cc @@ -58,7 +58,7 @@ int64_t GetProcessCpuTimeNanos() { #elif defined(WEBRTC_LINUX) struct timespec ts; if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) { - return ts.tv_sec * webrtc::kNumNanosecsPerSec + ts.tv_nsec; + return ts.tv_sec * kNumNanosecsPerSec + ts.tv_nsec; } else { RTC_LOG_ERR(LS_ERROR) << "clock_gettime() failed."; } @@ -106,7 +106,7 @@ int64_t GetThreadCpuTimeNanos() { #elif defined(WEBRTC_LINUX) struct timespec ts; if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) == 0) { - return ts.tv_sec * webrtc::kNumNanosecsPerSec + ts.tv_nsec; + return ts.tv_sec * kNumNanosecsPerSec + ts.tv_nsec; } else { RTC_LOG_ERR(LS_ERROR) << "clock_gettime() failed."; } diff --git a/rtc_base/cpu_time_unittest.cc b/rtc_base/cpu_time_unittest.cc index fbdd5faa39..591ae8001d 100644 --- a/rtc_base/cpu_time_unittest.cc +++ b/rtc_base/cpu_time_unittest.cc @@ -13,8 +13,8 @@ #include #include "rtc_base/platform_thread.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/sleep.h" #include "test/gtest.h" // Only run these tests on non-instrumented builds, because timing on @@ -80,25 +80,25 @@ TEST(CpuTimeTest, MAYBE_TEST(TwoThreads)) { // Therefore GetThreadCpuTime is not a wall clock. EXPECT_LE(thread_duration_nanos, (kProcessingTimeMillisecs - kAllowedErrorMillisecs) * - webrtc::kNumNanosecsPerMillisec); + kNumNanosecsPerMillisec); // Total process time is at least twice working threads' CPU time. // Therefore process and thread times are correctly related. EXPECT_GE(process_duration_nanos, kWorkingThreads * (kProcessingTimeMillisecs - kAllowedErrorMillisecs) * - webrtc::kNumNanosecsPerMillisec); + kNumNanosecsPerMillisec); } TEST(CpuTimeTest, MAYBE_TEST(Sleeping)) { int64_t process_start_time_nanos = GetProcessCpuTimeNanos(); - webrtc::SleepMs(kProcessingTimeMillisecs); + Thread::SleepMs(kProcessingTimeMillisecs); int64_t process_duration_nanos = GetProcessCpuTimeNanos() - process_start_time_nanos; // Sleeping should not introduce any additional CPU time. // Therefore GetProcessCpuTime is not a wall clock. EXPECT_LE(process_duration_nanos, (kProcessingTimeMillisecs - kAllowedErrorMillisecs) * - webrtc::kNumNanosecsPerMillisec); + kNumNanosecsPerMillisec); } } // namespace webrtc diff --git a/system_wrappers/source/denormal_disabler.cc b/rtc_base/denormal_disabler.cc similarity index 98% rename from system_wrappers/source/denormal_disabler.cc rename to rtc_base/denormal_disabler.cc index bb9c05643c..6f2ebb2857 100644 --- a/system_wrappers/source/denormal_disabler.cc +++ b/rtc_base/denormal_disabler.cc @@ -8,9 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/include/denormal_disabler.h" +#include "rtc_base/denormal_disabler.h" #include "rtc_base/checks.h" +#include "rtc_base/system/arch.h" namespace webrtc { namespace { diff --git a/system_wrappers/include/denormal_disabler.h b/rtc_base/denormal_disabler.h similarity index 90% rename from system_wrappers/include/denormal_disabler.h rename to rtc_base/denormal_disabler.h index bd3d401327..8c6363acf5 100644 --- a/system_wrappers/include/denormal_disabler.h +++ b/rtc_base/denormal_disabler.h @@ -8,10 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_INCLUDE_DENORMAL_DISABLER_H_ -#define SYSTEM_WRAPPERS_INCLUDE_DENORMAL_DISABLER_H_ - -#include "rtc_base/system/arch.h" +#ifndef RTC_BASE_DENORMAL_DISABLER_H_ +#define RTC_BASE_DENORMAL_DISABLER_H_ namespace webrtc { @@ -53,4 +51,4 @@ class DenormalDisabler { } // namespace webrtc -#endif // SYSTEM_WRAPPERS_INCLUDE_DENORMAL_DISABLER_H_ +#endif // RTC_BASE_DENORMAL_DISABLER_H_ diff --git a/system_wrappers/source/denormal_disabler_unittest.cc b/rtc_base/denormal_disabler_unittest.cc similarity index 99% rename from system_wrappers/source/denormal_disabler_unittest.cc rename to rtc_base/denormal_disabler_unittest.cc index a2849f853f..5d5f249b7e 100644 --- a/system_wrappers/source/denormal_disabler_unittest.cc +++ b/rtc_base/denormal_disabler_unittest.cc @@ -8,11 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/include/denormal_disabler.h" +#include "rtc_base/denormal_disabler.h" #include #include -#include #include "rtc_base/checks.h" #include "test/gtest.h" diff --git a/rtc_base/event.cc b/rtc_base/event.cc index b78e249cc0..7338670d66 100644 --- a/rtc_base/event.cc +++ b/rtc_base/event.cc @@ -30,8 +30,6 @@ namespace webrtc { -using ::webrtc::TimeDelta; - Event::Event() : Event(false, false) {} #if defined(WEBRTC_WIN) @@ -189,7 +187,7 @@ bool Event::Wait(TimeDelta give_up_after, TimeDelta warn_after) { } else { error = wait(warn_ts); if (error == ETIMEDOUT) { - webrtc::WarnThatTheCurrentThreadIsProbablyDeadlocked(); + WarnThatTheCurrentThreadIsProbablyDeadlocked(); error = wait(give_up_ts); } } diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn index 9f5573c0a1..a9f5c7d5cf 100644 --- a/rtc_base/experiments/BUILD.gn +++ b/rtc_base/experiments/BUILD.gn @@ -62,9 +62,10 @@ rtc_library("quality_scaling_experiment") { "quality_scaling_experiment.h", ] deps = [ + "..:checks", "..:logging", "../../api:field_trials_view", - "../../api/transport:field_trial_based_config", + "../../api/video:video_frame", "../../api/video_codecs:video_codecs_api", "../../rtc_base/experiments:field_trial_parser", "//third_party/abseil-cpp/absl/strings", @@ -92,7 +93,6 @@ rtc_library("balanced_degradation_settings") { "..:logging", "../../api:field_trials_view", "../../api/video_codecs:video_codecs_api", - "../../system_wrappers:field_trial", ] } diff --git a/rtc_base/experiments/balanced_degradation_settings_unittest.cc b/rtc_base/experiments/balanced_degradation_settings_unittest.cc index a9ad43398a..4f4ef11b69 100644 --- a/rtc_base/experiments/balanced_degradation_settings_unittest.cc +++ b/rtc_base/experiments/balanced_degradation_settings_unittest.cc @@ -58,7 +58,7 @@ void VerifyIsDefault( } // namespace TEST(BalancedDegradationSettings, GetsDefaultConfigIfNoList) { - webrtc::test::ScopedKeyValueConfig field_trials(""); + test::ScopedKeyValueConfig field_trials(""); BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); EXPECT_TRUE(settings.CanAdaptUp(kVideoCodecVP8, 1, /*bitrate_bps*/ 1)); @@ -73,7 +73,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfNoList) { } TEST(BalancedDegradationSettings, GetsConfig) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,other:4|5|6/"); BalancedDegradationSettings settings(field_trials); @@ -115,7 +115,7 @@ TEST(BalancedDegradationSettings, GetsConfig) { } TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroFpsValue) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:0|15|25/"); BalancedDegradationSettings settings(field_trials); @@ -123,7 +123,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroFpsValue) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfPixelsDecreases) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|999|3000,fps:5|15|25/"); BalancedDegradationSettings settings(field_trials); @@ -131,7 +131,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfPixelsDecreases) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfFramerateDecreases) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|4|25/"); BalancedDegradationSettings settings(field_trials); @@ -139,7 +139,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfFramerateDecreases) { } TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|8|9,vp9_fps:9|10|11," "h264_fps:11|12|13,av1_fps:1|2|3,generic_fps:13|14|15/"); @@ -182,7 +182,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { } TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroVp8FpsValue) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:7|15|25,vp8_fps:0|15|25/"); BalancedDegradationSettings settings(field_trials); @@ -190,7 +190,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroVp8FpsValue) { } TEST(BalancedDegradationSettings, GetsDefaultConfigForInvalidFpsValue) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:7|15|25,vp8_fps:10|15|2000/"); BalancedDegradationSettings settings(field_trials); @@ -198,7 +198,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigForInvalidFpsValue) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfVp8FramerateDecreases) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:4|5|25,vp8_fps:5|4|25/"); BalancedDegradationSettings settings(field_trials); @@ -206,7 +206,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfVp8FramerateDecreases) { } TEST(BalancedDegradationSettings, GetsMinFps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25/"); BalancedDegradationSettings settings(field_trials); @@ -221,7 +221,7 @@ TEST(BalancedDegradationSettings, GetsMinFps) { } TEST(BalancedDegradationSettings, GetsVp8MinFps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|10|12/"); BalancedDegradationSettings settings(field_trials); @@ -236,7 +236,7 @@ TEST(BalancedDegradationSettings, GetsVp8MinFps) { } TEST(BalancedDegradationSettings, GetsMaxFps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25/"); BalancedDegradationSettings settings(field_trials); @@ -249,7 +249,7 @@ TEST(BalancedDegradationSettings, GetsMaxFps) { } TEST(BalancedDegradationSettings, GetsVp8MaxFps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|10|12/"); BalancedDegradationSettings settings(field_trials); @@ -262,7 +262,7 @@ TEST(BalancedDegradationSettings, GetsVp8MaxFps) { } TEST(BalancedDegradationSettings, GetsVp9Fps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp9_fps:7|10|12/"); BalancedDegradationSettings settings(field_trials); @@ -271,7 +271,7 @@ TEST(BalancedDegradationSettings, GetsVp9Fps) { } TEST(BalancedDegradationSettings, GetsH264Fps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,h264_fps:8|11|13/"); BalancedDegradationSettings settings(field_trials); @@ -280,7 +280,7 @@ TEST(BalancedDegradationSettings, GetsH264Fps) { } TEST(BalancedDegradationSettings, GetsGenericFps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,generic_fps:9|12|14/"); BalancedDegradationSettings settings(field_trials); @@ -290,7 +290,7 @@ TEST(BalancedDegradationSettings, GetsGenericFps) { } TEST(BalancedDegradationSettings, GetsUnlimitedForMaxValidFps) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|100,vp8_fps:30|100|100/"); const int kUnlimitedFps = std::numeric_limits::max(); @@ -302,7 +302,7 @@ TEST(BalancedDegradationSettings, GetsUnlimitedForMaxValidFps) { } TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,kbps:44|88|99,kbps_res:55|111|222," "vp8_kbps:11|12|13,vp8_kbps_res:14|15|16," @@ -349,7 +349,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfBitrateDecreases) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,kbps:44|43|99/"); BalancedDegradationSettings settings(field_trials); @@ -358,7 +358,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfBitrateDecreases) { TEST(BalancedDegradationSettings, GetsDefaultConfigIfBitrateDecreasesWithUnsetValue) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,kbps:44|0|43/"); BalancedDegradationSettings settings(field_trials); @@ -367,7 +367,7 @@ TEST(BalancedDegradationSettings, TEST(BalancedDegradationSettings, CanAdaptUp) { VideoCodecType vp8 = kVideoCodecVP8; - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,kbps:0|80|0|90," "vp9_kbps:40|50|60|70/"); @@ -382,7 +382,7 @@ TEST(BalancedDegradationSettings, CanAdaptUp) { } TEST(BalancedDegradationSettings, CanAdaptUpWithCodecType) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,vp8_kbps:0|30|40|50," "vp9_kbps:0|60|70|80,h264_kbps:0|55|65|75,av1_kbps:0|77|88|99," @@ -402,7 +402,7 @@ TEST(BalancedDegradationSettings, CanAdaptUpWithCodecType) { TEST(BalancedDegradationSettings, CanAdaptUpResolution) { VideoCodecType vp8 = kVideoCodecVP8; - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,kbps_res:0|80|0|90," "vp9_kbps_res:40|50|60|70/"); @@ -417,7 +417,7 @@ TEST(BalancedDegradationSettings, CanAdaptUpResolution) { } TEST(BalancedDegradationSettings, CanAdaptUpResolutionWithCodecType) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,vp8_kbps_res:0|30|40|50," "vp9_kbps_res:0|60|70|80,h264_kbps_res:0|55|65|75," @@ -436,7 +436,7 @@ TEST(BalancedDegradationSettings, CanAdaptUpResolutionWithCodecType) { } TEST(BalancedDegradationSettings, GetsFpsDiff) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,fps_diff:0|-2|3/"); BalancedDegradationSettings settings(field_trials); @@ -450,7 +450,7 @@ TEST(BalancedDegradationSettings, GetsFpsDiff) { } TEST(BalancedDegradationSettings, GetsNoFpsDiffIfValueBelowMinSetting) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,fps_diff:-100|-99|-101/"); // Min valid fps_diff setting: -99. @@ -461,7 +461,7 @@ TEST(BalancedDegradationSettings, GetsNoFpsDiffIfValueBelowMinSetting) { } TEST(BalancedDegradationSettings, QpThresholdsNotSetByDefault) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25/"); BalancedDegradationSettings settings(field_trials); @@ -473,7 +473,7 @@ TEST(BalancedDegradationSettings, QpThresholdsNotSetByDefault) { } TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_low:89|90|88," "vp8_qp_high:90|91|92,vp9_qp_low:27|28|29,vp9_qp_high:120|130|140," @@ -518,7 +518,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasLowThreshold) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_low:89|90|88/"); BalancedDegradationSettings settings(field_trials); @@ -526,7 +526,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasLowThreshold) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasHighThreshold) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_high:90|91|92/"); BalancedDegradationSettings settings(field_trials); @@ -534,7 +534,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasHighThreshold) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowEqualsHigh) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|90|88,vp8_qp_high:90|91|88/"); @@ -543,7 +543,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowEqualsHigh) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowGreaterThanHigh) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|90|88,vp8_qp_high:90|91|87/"); @@ -552,7 +552,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowGreaterThanHigh) { } TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroQpValue) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|0|88,vp8_qp_high:90|91|92/"); @@ -561,7 +561,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroQpValue) { } TEST(BalancedDegradationSettings, GetsVp8QpThresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|90|88,vp8_qp_high:90|91|92/"); @@ -577,7 +577,7 @@ TEST(BalancedDegradationSettings, GetsVp8QpThresholds) { } TEST(BalancedDegradationSettings, GetsVp9QpThresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp9_qp_low:55|56|57,vp9_qp_high:155|156|157/"); @@ -589,7 +589,7 @@ TEST(BalancedDegradationSettings, GetsVp9QpThresholds) { } TEST(BalancedDegradationSettings, GetsH264QpThresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "h264_qp_low:21|22|23,h264_qp_high:41|43|42/"); @@ -601,7 +601,7 @@ TEST(BalancedDegradationSettings, GetsH264QpThresholds) { } TEST(BalancedDegradationSettings, GetsGenericQpThresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "generic_qp_low:2|3|4,generic_qp_high:22|23|24/"); diff --git a/rtc_base/experiments/field_trial_parser.cc b/rtc_base/experiments/field_trial_parser.cc index 1288c72c78..fa00c4e32f 100644 --- a/rtc_base/experiments/field_trial_parser.cc +++ b/rtc_base/experiments/field_trial_parser.cc @@ -193,7 +193,7 @@ bool FieldTrialFlag::Get() const { return value_; } -webrtc::FieldTrialFlag::operator bool() const { +FieldTrialFlag::operator bool() const { return value_; } diff --git a/rtc_base/experiments/min_video_bitrate_experiment.cc b/rtc_base/experiments/min_video_bitrate_experiment.cc index dd216b8b27..2bd8911f36 100644 --- a/rtc_base/experiments/min_video_bitrate_experiment.cc +++ b/rtc_base/experiments/min_video_bitrate_experiment.cc @@ -68,22 +68,21 @@ std::optional GetExperimentalMinVideoBitrate( } if (field_trials.IsEnabled(kMinVideoBitrateExperiment)) { - webrtc::FieldTrialFlag enabled("Enabled"); + FieldTrialFlag enabled("Enabled"); // Backwards-compatibility with an old experiment - a generic minimum which, // if set, applies to all codecs. - webrtc::FieldTrialOptional min_video_bitrate("br"); + FieldTrialOptional min_video_bitrate("br"); // New experiment - per-codec minimum bitrate. - webrtc::FieldTrialOptional min_bitrate_vp8("vp8_br"); - webrtc::FieldTrialOptional min_bitrate_vp9("vp9_br"); - webrtc::FieldTrialOptional min_bitrate_av1("av1_br"); - webrtc::FieldTrialOptional min_bitrate_h264("h264_br"); - - webrtc::ParseFieldTrial( - {&enabled, &min_video_bitrate, &min_bitrate_vp8, &min_bitrate_vp9, - &min_bitrate_av1, &min_bitrate_h264}, - field_trials.Lookup(kMinVideoBitrateExperiment)); + FieldTrialOptional min_bitrate_vp8("vp8_br"); + FieldTrialOptional min_bitrate_vp9("vp9_br"); + FieldTrialOptional min_bitrate_av1("av1_br"); + FieldTrialOptional min_bitrate_h264("h264_br"); + + ParseFieldTrial({&enabled, &min_video_bitrate, &min_bitrate_vp8, + &min_bitrate_vp9, &min_bitrate_av1, &min_bitrate_h264}, + field_trials.Lookup(kMinVideoBitrateExperiment)); if (min_video_bitrate) { if (min_bitrate_vp8 || min_bitrate_vp9 || min_bitrate_av1 || diff --git a/rtc_base/experiments/quality_scaler_settings_unittest.cc b/rtc_base/experiments/quality_scaler_settings_unittest.cc index 578fe97b03..06d0dab80a 100644 --- a/rtc_base/experiments/quality_scaler_settings_unittest.cc +++ b/rtc_base/experiments/quality_scaler_settings_unittest.cc @@ -17,7 +17,7 @@ namespace webrtc { namespace { TEST(QualityScalerSettingsTest, ValuesNotSetByDefault) { - webrtc::test::ScopedKeyValueConfig field_trials(""); + test::ScopedKeyValueConfig field_trials(""); const auto settings = QualityScalerSettings(field_trials); EXPECT_FALSE(settings.MinFrames()); EXPECT_FALSE(settings.InitialScaleFactor()); diff --git a/rtc_base/experiments/quality_scaling_experiment.cc b/rtc_base/experiments/quality_scaling_experiment.cc index be563639e0..30a80d3b64 100644 --- a/rtc_base/experiments/quality_scaling_experiment.cc +++ b/rtc_base/experiments/quality_scaling_experiment.cc @@ -11,11 +11,14 @@ #include +#include #include #include "absl/strings/match.h" #include "api/field_trials_view.h" -#include "api/transport/field_trial_based_config.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/video_encoder.h" +#include "rtc_base/checks.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/logging.h" diff --git a/rtc_base/experiments/quality_scaling_experiment_unittest.cc b/rtc_base/experiments/quality_scaling_experiment_unittest.cc index 0c1450557a..c8dab44565 100644 --- a/rtc_base/experiments/quality_scaling_experiment_unittest.cc +++ b/rtc_base/experiments/quality_scaling_experiment_unittest.cc @@ -41,7 +41,7 @@ void ExpectEqualConfig(QualityScalingExperiment::Config a, #if !defined(WEBRTC_IOS) // TODO(bugs.webrtc.org/12401): investigate why QualityScaler kicks in on iOS. TEST(QualityScalingExperimentTest, DefaultEnabledWithoutFieldTrial) { - webrtc::test::ScopedKeyValueConfig field_trials(""); + test::ScopedKeyValueConfig field_trials(""); EXPECT_TRUE(QualityScalingExperiment::Enabled(field_trials)); } #else @@ -52,7 +52,7 @@ TEST(QualityScalingExperimentTest, DefaultDisabledWithoutFieldTrialIOS) { #endif TEST(QualityScalingExperimentTest, EnabledWithFieldTrial) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled/"); EXPECT_TRUE(QualityScalingExperiment::Enabled(field_trials)); } @@ -60,7 +60,7 @@ TEST(QualityScalingExperimentTest, EnabledWithFieldTrial) { TEST(QualityScalingExperimentTest, ParseSettings) { const QualityScalingExperiment::Settings kExpected = {1, 2, 3, 4, 5, 6, 7, 8, 0.9f, 0.99f, 1}; - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,7,8,0.9,0.99,1/"); const auto settings = QualityScalingExperiment::ParseSettings(field_trials); EXPECT_TRUE(settings); @@ -70,7 +70,7 @@ TEST(QualityScalingExperimentTest, ParseSettings) { #if !defined(WEBRTC_IOS) // TODO(bugs.webrtc.org/12401): investigate why QualityScaler kicks in on iOS. TEST(QualityScalingExperimentTest, ParseSettingsUsesDefaultsWithoutFieldTrial) { - webrtc::test::ScopedKeyValueConfig field_trials(""); + test::ScopedKeyValueConfig field_trials(""); // Uses some default hard coded values. EXPECT_TRUE(QualityScalingExperiment::ParseSettings(field_trials)); } @@ -82,13 +82,13 @@ TEST(QualityScalingExperimentTest, ParseSettingsFailsWithoutFieldTrial) { #endif TEST(QualityScalingExperimentTest, ParseSettingsFailsWithInvalidFieldTrial) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-invalid/"); EXPECT_FALSE(QualityScalingExperiment::ParseSettings(field_trials)); } TEST(QualityScalingExperimentTest, GetConfig) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,7,8,0.9,0.99,0/"); const auto config = QualityScalingExperiment::GetConfig(field_trials); EXPECT_EQ(0.9f, config.alpha_high); @@ -97,7 +97,7 @@ TEST(QualityScalingExperimentTest, GetConfig) { } TEST(QualityScalingExperimentTest, GetsDefaultConfigForInvalidFieldTrial) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-invalid/"); const auto config = QualityScalingExperiment::GetConfig(field_trials); ExpectEqualConfig(config, QualityScalingExperiment::Config()); @@ -106,14 +106,14 @@ TEST(QualityScalingExperimentTest, GetsDefaultConfigForInvalidFieldTrial) { TEST(QualityScalingExperimentTest, GetsDefaultAlphaForInvalidValue) { QualityScalingExperiment::Config expected_config; expected_config.use_all_drop_reasons = true; - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,7,8,0.99,0.9,1/"); const auto config = QualityScalingExperiment::GetConfig(field_trials); ExpectEqualConfig(config, expected_config); } TEST(QualityScalingExperimentTest, GetVp8Thresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,0,0,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds(kVideoCodecVP8, field_trials); @@ -123,7 +123,7 @@ TEST(QualityScalingExperimentTest, GetVp8Thresholds) { } TEST(QualityScalingExperimentTest, GetThresholdsFailsForInvalidVp8Value) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-0,0,3,4,5,6,7,8,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds(kVideoCodecVP8, field_trials); @@ -131,7 +131,7 @@ TEST(QualityScalingExperimentTest, GetThresholdsFailsForInvalidVp8Value) { } TEST(QualityScalingExperimentTest, GetVp9Thresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,0,0,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds(kVideoCodecVP9, field_trials); @@ -141,7 +141,7 @@ TEST(QualityScalingExperimentTest, GetVp9Thresholds) { } TEST(QualityScalingExperimentTest, GetThresholdsFailsForInvalidVp9Value) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,0,0,5,6,7,8,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds(kVideoCodecVP9, field_trials); @@ -149,7 +149,7 @@ TEST(QualityScalingExperimentTest, GetThresholdsFailsForInvalidVp9Value) { } TEST(QualityScalingExperimentTest, GetH264Thresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,0,0,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds(kVideoCodecH264, field_trials); @@ -159,7 +159,7 @@ TEST(QualityScalingExperimentTest, GetH264Thresholds) { } TEST(QualityScalingExperimentTest, GetThresholdsFailsForInvalidH264Value) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,0,0,7,8,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds(kVideoCodecH264, field_trials); @@ -167,7 +167,7 @@ TEST(QualityScalingExperimentTest, GetThresholdsFailsForInvalidH264Value) { } TEST(QualityScalingExperimentTest, GetGenericThresholds) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,0,0,7,8,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds( kVideoCodecGeneric, field_trials); @@ -177,7 +177,7 @@ TEST(QualityScalingExperimentTest, GetGenericThresholds) { } TEST(QualityScalingExperimentTest, GetThresholdsFailsForInvalidGenericValue) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,0,0,0.9,0.99,1/"); const auto thresholds = QualityScalingExperiment::GetQpThresholds( kVideoCodecGeneric, field_trials); diff --git a/rtc_base/experiments/struct_parameters_parser.cc b/rtc_base/experiments/struct_parameters_parser.cc index bb46453a87..f999601afe 100644 --- a/rtc_base/experiments/struct_parameters_parser.cc +++ b/rtc_base/experiments/struct_parameters_parser.cc @@ -38,13 +38,13 @@ inline void StringEncode(std::string* target, unsigned val) { *target += absl::StrCat(val); } inline void StringEncode(std::string* target, DataRate val) { - *target += webrtc::ToString(val); + *target += ToString(val); } inline void StringEncode(std::string* target, DataSize val) { - *target += webrtc::ToString(val); + *target += ToString(val); } inline void StringEncode(std::string* target, TimeDelta val) { - *target += webrtc::ToString(val); + *target += ToString(val); } template diff --git a/rtc_base/fake_network.h b/rtc_base/fake_network.h index 6e1521a54c..b8c22136d9 100644 --- a/rtc_base/fake_network.h +++ b/rtc_base/fake_network.h @@ -17,14 +17,17 @@ #include #include +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "rtc_base/ip_address.h" #include "rtc_base/mdns_responder_interface.h" #include "rtc_base/net_helpers.h" #include "rtc_base/network.h" #include "rtc_base/network_constants.h" #include "rtc_base/socket_address.h" -#include "rtc_base/string_encode.h" #include "rtc_base/thread.h" namespace webrtc { @@ -35,7 +38,18 @@ const int kFakeIPv6NetworkPrefixLength = 64; // Fake network manager that allows us to manually specify the IPs to use. class FakeNetworkManager : public NetworkManagerBase { public: - FakeNetworkManager() {} + explicit FakeNetworkManager(Thread* network_thread) + : network_thread_(network_thread) {} + ~FakeNetworkManager() override { + if (network_thread_) { + network_thread_->BlockingCall([this]() { + if (safety_flag_) { + safety_flag_->SetNotAlive(); + safety_flag_ = nullptr; + } + }); + } + } struct Iface { SocketAddress socket_address; @@ -75,12 +89,18 @@ class FakeNetworkManager : public NetworkManagerBase { } void StartUpdating() override { + RTC_DCHECK_RUN_ON(network_thread_); + if (!safety_flag_) { + safety_flag_ = PendingTaskSafetyFlag::Create(); + } ++start_count_; if (start_count_ == 1) { sent_first_update_ = false; - Thread::Current()->PostTask([this] { DoUpdateNetworks(); }); + network_thread_->PostTask( + SafeTask(safety_flag_, [this] { DoUpdateNetworks(); })); } else if (sent_first_update_) { - Thread::Current()->PostTask([this] { SignalNetworksChanged(); }); + network_thread_->PostTask( + SafeTask(safety_flag_, [this] { SignalNetworksChanged(); })); } } @@ -131,6 +151,9 @@ class FakeNetworkManager : public NetworkManagerBase { } } + Thread* const network_thread_; + scoped_refptr safety_flag_; + IfaceList ifaces_; int next_index_ = 0; int start_count_ = 0; diff --git a/rtc_base/file_rotating_stream_unittest.cc b/rtc_base/file_rotating_stream_unittest.cc index 1422fd1db1..4ee54dc0a4 100644 --- a/rtc_base/file_rotating_stream_unittest.cc +++ b/rtc_base/file_rotating_stream_unittest.cc @@ -30,7 +30,7 @@ namespace { void CleanupLogDirectory(const FileRotatingStream& stream) { for (size_t i = 0; i < stream.GetNumFiles(); ++i) { // Ignore return value, not all files are expected to exist. - webrtc::test::RemoveFile(stream.GetFilePath(i)); + test::RemoveFile(stream.GetFilePath(i)); } } @@ -53,14 +53,14 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test { size_t max_file_size, size_t num_log_files, bool ensure_trailing_delimiter = true) { - dir_path_ = webrtc::test::OutputPath(); + dir_path_ = test::OutputPath(); // Append per-test output path in order to run within gtest parallel. dir_path_.append(dir_name.begin(), dir_name.end()); if (ensure_trailing_delimiter) { - dir_path_.append(std::string(webrtc::test::kPathDelimiter)); + dir_path_.append(std::string(test::kPathDelimiter)); } - ASSERT_TRUE(webrtc::test::CreateDir(dir_path_)); + ASSERT_TRUE(test::CreateDir(dir_path_)); stream_.reset(new FileRotatingStream(dir_path_, file_prefix, max_file_size, num_log_files)); } @@ -69,7 +69,7 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test { // On windows, open files can't be removed. stream_->Close(); CleanupLogDirectory(*stream_); - EXPECT_TRUE(webrtc::test::RemoveDir(dir_path_)); + EXPECT_TRUE(test::RemoveDir(dir_path_)); stream_.reset(); } @@ -158,12 +158,12 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteAndRead) { } // Check that exactly three files exist. for (size_t i = 0; i < arraysize(messages); ++i) { - EXPECT_TRUE(webrtc::test::FileExists(stream_->GetFilePath(i))); + EXPECT_TRUE(test::FileExists(stream_->GetFilePath(i))); } std::string message("d"); WriteAndFlush(message.c_str(), message.size()); for (size_t i = 0; i < arraysize(messages); ++i) { - EXPECT_TRUE(webrtc::test::FileExists(stream_->GetFilePath(i))); + EXPECT_TRUE(test::FileExists(stream_->GetFilePath(i))); } // TODO(tkchin): Maybe check all the files in the dir. @@ -193,8 +193,7 @@ TEST_F(MAYBE_FileRotatingStreamTest, WriteWithoutDelimiterAndRead) { // Reopen for read. std::string expected_contents("bbccd"); VerifyStreamRead(expected_contents, - dir_path_ + std::string(webrtc::test::kPathDelimiter), - kFilePrefix); + dir_path_ + std::string(test::kPathDelimiter), kFilePrefix); } // Tests that a write operation followed by a read (without trailing delimiter) @@ -258,12 +257,12 @@ TEST_F(MAYBE_FileRotatingStreamTest, GetFilePath) { class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test { protected: void Init(absl::string_view dir_name, size_t max_total_log_size) { - dir_path_ = webrtc::test::OutputPath(); + dir_path_ = test::OutputPath(); // Append per-test output path in order to run within gtest parallel. dir_path_.append(dir_name.begin(), dir_name.end()); - dir_path_.append(std::string(webrtc::test::kPathDelimiter)); - ASSERT_TRUE(webrtc::test::CreateDir(dir_path_)); + dir_path_.append(std::string(test::kPathDelimiter)); + ASSERT_TRUE(test::CreateDir(dir_path_)); stream_.reset( new CallSessionFileRotatingStream(dir_path_, max_total_log_size)); } @@ -272,7 +271,7 @@ class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test { // On windows, open files can't be removed. stream_->Close(); CleanupLogDirectory(*stream_); - EXPECT_TRUE(webrtc::test::RemoveDir(dir_path_)); + EXPECT_TRUE(test::RemoveDir(dir_path_)); stream_.reset(); } diff --git a/rtc_base/firewall_socket_server.cc b/rtc_base/firewall_socket_server.cc index 1301081bdf..24b1ec8d11 100644 --- a/rtc_base/firewall_socket_server.cc +++ b/rtc_base/firewall_socket_server.cc @@ -110,7 +110,7 @@ class FirewallSocket : public AsyncSocketAdapter { << addr.ToSensitiveString() << " to " << GetLocalAddress().ToSensitiveString() << " denied"; } - return 0; + return nullptr; } private: diff --git a/rtc_base/ifaddrs_converter.cc b/rtc_base/ifaddrs_converter.cc index de949aa575..8b50e3d508 100644 --- a/rtc_base/ifaddrs_converter.cc +++ b/rtc_base/ifaddrs_converter.cc @@ -31,7 +31,7 @@ bool IfAddrsConverter::ConvertIfAddrsToIPAddress( return true; } case AF_INET6: { - int ip_attributes = webrtc::IPV6_ADDRESS_FLAG_NONE; + int ip_attributes = IPV6_ADDRESS_FLAG_NONE; if (!ConvertNativeAttributesToIPAttributes(interface, &ip_attributes)) { return false; } @@ -51,7 +51,7 @@ bool IfAddrsConverter::ConvertIfAddrsToIPAddress( bool IfAddrsConverter::ConvertNativeAttributesToIPAttributes( const struct ifaddrs* /* interface */, int* ip_attributes) { - *ip_attributes = webrtc::IPV6_ADDRESS_FLAG_NONE; + *ip_attributes = IPV6_ADDRESS_FLAG_NONE; return true; } diff --git a/rtc_base/ip_address.cc b/rtc_base/ip_address.cc index 92be158e70..5c349dc1f8 100644 --- a/rtc_base/ip_address.cc +++ b/rtc_base/ip_address.cc @@ -46,7 +46,7 @@ static in_addr ExtractMappedAddress(const in6_addr& addr); uint32_t IPAddress::v4AddressAsHostOrderInteger() const { if (family_ == AF_INET) { - return webrtc::NetworkToHost32(u_.ip4.s_addr); + return NetworkToHost32(u_.ip4.s_addr); } else { return 0; } @@ -112,8 +112,8 @@ bool IPAddress::operator<(const IPAddress& other) const { // Comparing addresses of the same family. switch (family_) { case AF_INET: { - return webrtc::NetworkToHost32(u_.ip4.s_addr) < - webrtc::NetworkToHost32(other.u_.ip4.s_addr); + return NetworkToHost32(u_.ip4.s_addr) < + NetworkToHost32(other.u_.ip4.s_addr); } case AF_INET6: { return memcmp(&u_.ip6.s6_addr, &other.u_.ip6.s6_addr, 16) < 0; @@ -371,9 +371,9 @@ IPAddress TruncateIP(const IPAddress& ip, int length) { return IPAddress(INADDR_ANY); } int mask = (0xFFFFFFFF << (32 - length)); - uint32_t host_order_ip = webrtc::NetworkToHost32(ip.ipv4_address().s_addr); + uint32_t host_order_ip = NetworkToHost32(ip.ipv4_address().s_addr); in_addr masked; - masked.s_addr = webrtc::HostToNetwork32(host_order_ip & mask); + masked.s_addr = HostToNetwork32(host_order_ip & mask); return IPAddress(masked); } else if (ip.family() == AF_INET6) { if (length > 127) { @@ -390,8 +390,8 @@ IPAddress TruncateIP(const IPAddress& ip, int length) { uint32_t* v6_as_ints = reinterpret_cast(&v6addr.s6_addr); for (int i = 0; i < 4; ++i) { if (i == position) { - uint32_t host_order_inner = webrtc::NetworkToHost32(v6_as_ints[i]); - v6_as_ints[i] = webrtc::HostToNetwork32(host_order_inner & inner_mask); + uint32_t host_order_inner = NetworkToHost32(v6_as_ints[i]); + v6_as_ints[i] = HostToNetwork32(host_order_inner & inner_mask); } else if (i > position) { v6_as_ints[i] = 0; } @@ -406,7 +406,7 @@ int CountIPMaskBits(const IPAddress& mask) { int bits = 0; switch (mask.family()) { case AF_INET: { - word_to_count = webrtc::NetworkToHost32(mask.ipv4_address().s_addr); + word_to_count = NetworkToHost32(mask.ipv4_address().s_addr); break; } case AF_INET6: { @@ -420,7 +420,7 @@ int CountIPMaskBits(const IPAddress& mask) { } } if (i < 4) { - word_to_count = webrtc::NetworkToHost32(v6_as_ints[i]); + word_to_count = NetworkToHost32(v6_as_ints[i]); } bits = (i * 32); break; diff --git a/rtc_base/ip_address_unittest.cc b/rtc_base/ip_address_unittest.cc index 5f5988d260..ff6a1829a9 100644 --- a/rtc_base/ip_address_unittest.cc +++ b/rtc_base/ip_address_unittest.cc @@ -522,7 +522,7 @@ TEST(IPAddressTest, TestIPFromAddrInfo) { test_info.ai_next = &next_info; // Check that we can get an IPv4 address out. test_info.ai_addr = reinterpret_cast(&expected4); - expected4.sin_addr.s_addr = webrtc::HostToNetwork32(kIPv4PublicAddr); + expected4.sin_addr.s_addr = HostToNetwork32(kIPv4PublicAddr); expected4.sin_family = AF_INET; IPAddress expected(kIPv4PublicAddr); IPAddress addr; diff --git a/rtc_base/memory/aligned_malloc.cc b/rtc_base/memory/aligned_malloc.cc index 7add079398..e0bae74dc3 100644 --- a/rtc_base/memory/aligned_malloc.cc +++ b/rtc_base/memory/aligned_malloc.cc @@ -41,10 +41,10 @@ bool ValidAlignment(size_t alignment) { void* GetRightAlign(const void* pointer, size_t alignment) { if (!pointer) { - return NULL; + return nullptr; } if (!ValidAlignment(alignment)) { - return NULL; + return nullptr; } uintptr_t start_pos = reinterpret_cast(pointer); return reinterpret_cast(GetRightAlign(start_pos, alignment)); @@ -52,10 +52,10 @@ void* GetRightAlign(const void* pointer, size_t alignment) { void* AlignedMalloc(size_t size, size_t alignment) { if (size == 0) { - return NULL; + return nullptr; } if (!ValidAlignment(alignment)) { - return NULL; + return nullptr; } // The memory is aligned towards the lowest address that so only @@ -83,7 +83,7 @@ void* AlignedMalloc(size_t size, size_t alignment) { } void AlignedFree(void* mem_block) { - if (mem_block == NULL) { + if (mem_block == nullptr) { return; } uintptr_t aligned_pos = reinterpret_cast(mem_block); diff --git a/rtc_base/memory/aligned_malloc_unittest.cc b/rtc_base/memory/aligned_malloc_unittest.cc index 8e750035f0..5c3f02d15c 100644 --- a/rtc_base/memory/aligned_malloc_unittest.cc +++ b/rtc_base/memory/aligned_malloc_unittest.cc @@ -26,7 +26,7 @@ namespace webrtc { bool CorrectUsage(size_t size, size_t alignment) { std::unique_ptr scoped( static_cast(AlignedMalloc(size, alignment))); - if (scoped.get() == NULL) { + if (scoped.get() == nullptr) { return false; } const uintptr_t scoped_address = reinterpret_cast(scoped.get()); @@ -39,7 +39,7 @@ TEST(AlignedMalloc, GetRightAlign) { const size_t left_misalignment = 1; std::unique_ptr scoped( static_cast(AlignedMalloc(size, alignment))); - EXPECT_TRUE(scoped.get() != NULL); + EXPECT_TRUE(scoped.get() != nullptr); const uintptr_t aligned_address = reinterpret_cast(scoped.get()); const uintptr_t misaligned_address = aligned_address - left_misalignment; const char* misaligned_ptr = diff --git a/rtc_base/memory/fifo_buffer.cc b/rtc_base/memory/fifo_buffer.cc index 8c102001e3..4eb0dfa054 100644 --- a/rtc_base/memory/fifo_buffer.cc +++ b/rtc_base/memory/fifo_buffer.cc @@ -24,7 +24,7 @@ namespace webrtc { FifoBuffer::FifoBuffer(size_t size) - : state_(webrtc::SS_OPEN), + : state_(SS_OPEN), buffer_(new char[size]), buffer_length_(size), data_length_(0), @@ -34,7 +34,7 @@ FifoBuffer::FifoBuffer(size_t size) } FifoBuffer::FifoBuffer(size_t size, Thread* owner) - : state_(webrtc::SS_OPEN), + : state_(SS_OPEN), buffer_(new char[size]), buffer_length_(size), data_length_(0), @@ -64,7 +64,7 @@ StreamResult FifoBuffer::Read(ArrayView buffer, size_t copy = 0; StreamResult result = ReadLocked(buffer.data(), buffer.size(), ©); - if (result == webrtc::SR_SUCCESS) { + if (result == SR_SUCCESS) { // If read was successful then adjust the read position and number of // bytes buffered. read_position_ = (read_position_ + copy) % buffer_length_; @@ -73,7 +73,7 @@ StreamResult FifoBuffer::Read(ArrayView buffer, // if we were full before, and now we're not, post an event if (!was_writable && copy > 0) { - PostEvent(webrtc::SE_WRITE, 0); + PostEvent(SE_WRITE, 0); } } return result; @@ -88,13 +88,13 @@ StreamResult FifoBuffer::Write(ArrayView buffer, size_t copy = 0; StreamResult result = WriteLocked(buffer.data(), buffer.size(), ©); - if (result == webrtc::SR_SUCCESS) { + if (result == SR_SUCCESS) { // If write was successful then adjust the number of readable bytes. data_length_ += copy; bytes_written = copy; // if we didn't have any data to read before, and now we do, post an event if (!was_readable && copy > 0) { - PostEvent(webrtc::SE_READ, 0); + PostEvent(SE_READ, 0); } } return result; @@ -102,7 +102,7 @@ StreamResult FifoBuffer::Write(ArrayView buffer, void FifoBuffer::Close() { RTC_DCHECK_RUN_ON(&callback_sequence_); - state_ = webrtc::SS_CLOSED; + state_ = SS_CLOSED; } const void* FifoBuffer::GetReadData(size_t* size) { @@ -120,14 +120,14 @@ void FifoBuffer::ConsumeReadData(size_t size) { read_position_ = (read_position_ + size) % buffer_length_; data_length_ -= size; if (!was_writable && size > 0) { - PostEvent(webrtc::SE_WRITE, 0); + PostEvent(SE_WRITE, 0); } } void* FifoBuffer::GetWriteBuffer(size_t* size) { RTC_DCHECK_RUN_ON(&callback_sequence_); - if (state_ == webrtc::SS_CLOSED) { + if (state_ == SS_CLOSED) { return nullptr; } @@ -151,7 +151,7 @@ void FifoBuffer::ConsumeWriteBuffer(size_t size) { const bool was_readable = (data_length_ > 0); data_length_ += size; if (!was_readable && size > 0) { - PostEvent(webrtc::SE_READ, 0); + PostEvent(SE_READ, 0); } } @@ -159,7 +159,7 @@ StreamResult FifoBuffer::ReadLocked(void* buffer, size_t bytes, size_t* bytes_read) { if (data_length_ == 0) { - return (state_ != webrtc::SS_CLOSED) ? webrtc::SR_BLOCK : webrtc::SR_EOS; + return (state_ != SS_CLOSED) ? SR_BLOCK : SR_EOS; } const size_t available = data_length_; @@ -173,18 +173,18 @@ StreamResult FifoBuffer::ReadLocked(void* buffer, if (bytes_read) { *bytes_read = copy; } - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } StreamResult FifoBuffer::WriteLocked(const void* buffer, size_t bytes, size_t* bytes_written) { - if (state_ == webrtc::SS_CLOSED) { - return webrtc::SR_EOS; + if (state_ == SS_CLOSED) { + return SR_EOS; } if (data_length_ >= buffer_length_) { - return webrtc::SR_BLOCK; + return SR_BLOCK; } const size_t available = buffer_length_ - data_length_; @@ -199,7 +199,7 @@ StreamResult FifoBuffer::WriteLocked(const void* buffer, if (bytes_written) { *bytes_written = copy; } - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } } // namespace webrtc diff --git a/rtc_base/memory_stream.cc b/rtc_base/memory_stream.cc index ad6793e07c..d0b6acbff6 100644 --- a/rtc_base/memory_stream.cc +++ b/rtc_base/memory_stream.cc @@ -23,14 +23,14 @@ namespace webrtc { StreamState MemoryStream::GetState() const { - return webrtc::SS_OPEN; + return SS_OPEN; } StreamResult MemoryStream::Read(ArrayView buffer, size_t& bytes_read, int& error) { if (seek_position_ >= data_length_) { - return webrtc::SR_EOS; + return SR_EOS; } size_t available = data_length_ - seek_position_; size_t bytes; @@ -43,7 +43,7 @@ StreamResult MemoryStream::Read(ArrayView buffer, memcpy(buffer.data(), &buffer_[seek_position_], bytes); seek_position_ += bytes; bytes_read = bytes; - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } StreamResult MemoryStream::Write(ArrayView buffer, @@ -57,7 +57,7 @@ StreamResult MemoryStream::Write(ArrayView buffer, size_t new_buffer_length = std::max( ((seek_position_ + buffer.size()) | 0xFF) + 1, buffer_length_ * 2); StreamResult result = DoReserve(new_buffer_length, &error); - if (webrtc::SR_SUCCESS != result) { + if (SR_SUCCESS != result) { return result; } RTC_DCHECK(buffer_length_ >= new_buffer_length); @@ -74,7 +74,7 @@ StreamResult MemoryStream::Write(ArrayView buffer, data_length_ = seek_position_; } bytes_written = bytes; - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } void MemoryStream::Close() { @@ -105,7 +105,7 @@ bool MemoryStream::GetSize(size_t* size) const { } bool MemoryStream::ReserveSize(size_t size) { - return (webrtc::SR_SUCCESS == DoReserve(size, nullptr)); + return (SR_SUCCESS == DoReserve(size, nullptr)); } /////////////////////////////////////////////////////////////////////////////// @@ -126,7 +126,7 @@ void MemoryStream::SetData(const void* data, size_t length) { StreamResult MemoryStream::DoReserve(size_t size, int* error) { if (buffer_length_ >= size) - return webrtc::SR_SUCCESS; + return SR_SUCCESS; if (char* new_buffer = new char[size]) { if (buffer_ != nullptr && data_length_ > 0) { @@ -135,13 +135,13 @@ StreamResult MemoryStream::DoReserve(size_t size, int* error) { delete[] buffer_; buffer_ = new_buffer; buffer_length_ = size; - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } if (error) { *error = ENOMEM; } - return webrtc::SR_ERROR; + return SR_ERROR; } } // namespace webrtc diff --git a/rtc_base/network.cc b/rtc_base/network.cc index 19741366f8..edb78eb4a4 100644 --- a/rtc_base/network.cc +++ b/rtc_base/network.cc @@ -62,10 +62,6 @@ namespace webrtc { namespace { -using ::webrtc::Environment; -using ::webrtc::SafeTask; -using ::webrtc::SocketFactory; -using ::webrtc::TimeDelta; // List of MAC addresses of known VPN (for windows). constexpr uint8_t kVpns[3][6] = { @@ -101,9 +97,8 @@ bool SortNetworks(const Network* a, const Network* b) { // After type, networks are sorted by IP address precedence values // from RFC 3484-bis - if (webrtc::IPAddressPrecedence(ip_a) != webrtc::IPAddressPrecedence(ip_b)) { - return webrtc::IPAddressPrecedence(ip_a) > - webrtc::IPAddressPrecedence(ip_b); + if (IPAddressPrecedence(ip_a) != IPAddressPrecedence(ip_b)) { + return IPAddressPrecedence(ip_a) > IPAddressPrecedence(ip_b); } // TODO(mallinath) - Add VPN and Link speed conditions while sorting. @@ -118,37 +113,32 @@ uint16_t ComputeNetworkCostByType(int type, bool add_network_cost_to_vpn) { // TODO(jonaso) : Rollout support for cellular network cost using A/B // experiment to make sure it does not introduce regressions. - int vpnCost = - (is_vpn && add_network_cost_to_vpn) ? webrtc::kNetworkCostVpn : 0; + int vpnCost = (is_vpn && add_network_cost_to_vpn) ? kNetworkCostVpn : 0; switch (type) { - case webrtc::ADAPTER_TYPE_ETHERNET: - case webrtc::ADAPTER_TYPE_LOOPBACK: - return webrtc::kNetworkCostMin + vpnCost; - case webrtc::ADAPTER_TYPE_WIFI: - return webrtc::kNetworkCostLow + vpnCost; - case webrtc::ADAPTER_TYPE_CELLULAR: - return webrtc::kNetworkCostCellular + vpnCost; - case webrtc::ADAPTER_TYPE_CELLULAR_2G: - return (use_differentiated_cellular_costs - ? webrtc::kNetworkCostCellular2G - : webrtc::kNetworkCostCellular) + + case ADAPTER_TYPE_ETHERNET: + case ADAPTER_TYPE_LOOPBACK: + return kNetworkCostMin + vpnCost; + case ADAPTER_TYPE_WIFI: + return kNetworkCostLow + vpnCost; + case ADAPTER_TYPE_CELLULAR: + return kNetworkCostCellular + vpnCost; + case ADAPTER_TYPE_CELLULAR_2G: + return (use_differentiated_cellular_costs ? kNetworkCostCellular2G + : kNetworkCostCellular) + vpnCost; - case webrtc::ADAPTER_TYPE_CELLULAR_3G: - return (use_differentiated_cellular_costs - ? webrtc::kNetworkCostCellular3G - : webrtc::kNetworkCostCellular) + + case ADAPTER_TYPE_CELLULAR_3G: + return (use_differentiated_cellular_costs ? kNetworkCostCellular3G + : kNetworkCostCellular) + vpnCost; - case webrtc::ADAPTER_TYPE_CELLULAR_4G: - return (use_differentiated_cellular_costs - ? webrtc::kNetworkCostCellular4G - : webrtc::kNetworkCostCellular) + + case ADAPTER_TYPE_CELLULAR_4G: + return (use_differentiated_cellular_costs ? kNetworkCostCellular4G + : kNetworkCostCellular) + vpnCost; - case webrtc::ADAPTER_TYPE_CELLULAR_5G: - return (use_differentiated_cellular_costs - ? webrtc::kNetworkCostCellular5G - : webrtc::kNetworkCostCellular) + + case ADAPTER_TYPE_CELLULAR_5G: + return (use_differentiated_cellular_costs ? kNetworkCostCellular5G + : kNetworkCostCellular) + vpnCost; - case webrtc::ADAPTER_TYPE_ANY: + case ADAPTER_TYPE_ANY: // Candidates gathered from the any-address/wildcard ports, as backups, // are given the maximum cost so that if there are other candidates with // known interface types, we would not select candidate pairs using these @@ -158,13 +148,13 @@ uint16_t ComputeNetworkCostByType(int type, // ADAPTER_TYPE_CELLULAR would then have a higher cost. See // P2PTransportChannel::SortConnectionsAndUpdateState for how we rank and // select candidate pairs, where the network cost is among the criteria. - return webrtc::kNetworkCostMax + vpnCost; - case webrtc::ADAPTER_TYPE_VPN: + return kNetworkCostMax + vpnCost; + case ADAPTER_TYPE_VPN: // The cost of a VPN should be computed using its underlying network type. RTC_DCHECK_NOTREACHED(); - return webrtc::kNetworkCostUnknown; + return kNetworkCostUnknown; default: - return webrtc::kNetworkCostUnknown + vpnCost; + return kNetworkCostUnknown + vpnCost; } } @@ -177,19 +167,19 @@ bool IsIgnoredIPv6(bool allow_mac_based_ipv6, const InterfaceAddress& ip) { // Link-local addresses require scope id to be bound successfully. // However, our IPAddress structure doesn't carry that so the // information is lost and causes binding failure. - if (webrtc::IPIsLinkLocal(ip)) { + if (IPIsLinkLocal(ip)) { RTC_LOG(LS_VERBOSE) << "Ignore link local IP:" << ip.ToSensitiveString(); return true; } // Any MAC based IPv6 should be avoided to prevent the MAC tracking. - if (webrtc::IPIsMacBased(ip) && !allow_mac_based_ipv6) { + if (IPIsMacBased(ip) && !allow_mac_based_ipv6) { RTC_LOG(LS_INFO) << "Ignore Mac based IP:" << ip.ToSensitiveString(); return true; } // Ignore deprecated IPv6. - if (ip.ipv6_flags() & webrtc::IPV6_ADDRESS_FLAG_DEPRECATED) { + if (ip.ipv6_flags() & IPV6_ADDRESS_FLAG_DEPRECATED) { RTC_LOG(LS_INFO) << "Ignore deprecated IP:" << ip.ToSensitiveString(); return true; } @@ -275,23 +265,23 @@ AdapterType GetAdapterTypeFromName(absl::string_view network_name) { // Note that we have a more robust way to determine if a network interface // is a loopback interface by checking the flag IFF_LOOPBACK in ifa_flags of // an ifaddr struct. See ConvertIfAddrs in this file. - return webrtc::ADAPTER_TYPE_LOOPBACK; + return ADAPTER_TYPE_LOOPBACK; } if (MatchTypeNameWithIndexPattern(network_name, "eth")) { - return webrtc::ADAPTER_TYPE_ETHERNET; + return ADAPTER_TYPE_ETHERNET; } if (MatchTypeNameWithIndexPattern(network_name, "wlan") || MatchTypeNameWithIndexPattern(network_name, "v4-wlan")) { - return webrtc::ADAPTER_TYPE_WIFI; + return ADAPTER_TYPE_WIFI; } if (MatchTypeNameWithIndexPattern(network_name, "ipsec") || MatchTypeNameWithIndexPattern(network_name, "tun") || MatchTypeNameWithIndexPattern(network_name, "utun") || MatchTypeNameWithIndexPattern(network_name, "tap")) { - return webrtc::ADAPTER_TYPE_VPN; + return ADAPTER_TYPE_VPN; } #if defined(WEBRTC_IOS) // Cell networks are pdp_ipN on iOS. @@ -316,7 +306,7 @@ AdapterType GetAdapterTypeFromName(absl::string_view network_name) { } #endif - return webrtc::ADAPTER_TYPE_UNKNOWN; + return ADAPTER_TYPE_UNKNOWN; } NetworkManager::EnumerationPermission NetworkManager::enumeration_permission() @@ -355,8 +345,8 @@ std::vector NetworkManagerBase::GetAnyAddressNetworks() { std::vector networks; if (!ipv4_any_address_network_) { const IPAddress ipv4_any_address(INADDR_ANY); - ipv4_any_address_network_ = CreateNetwork("any", "any", ipv4_any_address, 0, - webrtc::ADAPTER_TYPE_ANY); + ipv4_any_address_network_ = + CreateNetwork("any", "any", ipv4_any_address, 0, ADAPTER_TYPE_ANY); ipv4_any_address_network_->set_default_local_address_provider(this); ipv4_any_address_network_->set_mdns_responder_provider(this); ipv4_any_address_network_->AddIP(ipv4_any_address); @@ -365,8 +355,8 @@ std::vector NetworkManagerBase::GetAnyAddressNetworks() { if (!ipv6_any_address_network_) { const IPAddress ipv6_any_address(in6addr_any); - ipv6_any_address_network_ = CreateNetwork("any", "any", ipv6_any_address, 0, - webrtc::ADAPTER_TYPE_ANY); + ipv6_any_address_network_ = + CreateNetwork("any", "any", ipv6_any_address, 0, ADAPTER_TYPE_ANY); ipv6_any_address_network_->set_default_local_address_provider(this); ipv6_any_address_network_->set_mdns_responder_provider(this); ipv6_any_address_network_->AddIP(ipv6_any_address); @@ -446,7 +436,7 @@ void NetworkManagerBase::MergeNetworkList( Network* existing_net = existing->second.get(); *changed = existing_net->SetIPs(kv.second.ips, *changed); merged_list.push_back(existing_net); - if (net->type() != webrtc::ADAPTER_TYPE_UNKNOWN && + if (net->type() != ADAPTER_TYPE_UNKNOWN && net->type() != existing_net->type()) { if (ShouldAdapterChangeTriggerNetworkChange(existing_net->type(), net->type())) { @@ -599,8 +589,8 @@ NetworkMonitorInterface::InterfaceInfo BasicNetworkManager::GetInterfaceInfo( struct ifaddrs* cursor) const { if (cursor->ifa_flags & IFF_LOOPBACK) { return { - .adapter_type = webrtc::ADAPTER_TYPE_LOOPBACK, - .underlying_type_for_vpn = webrtc::ADAPTER_TYPE_UNKNOWN, + .adapter_type = ADAPTER_TYPE_LOOPBACK, + .underlying_type_for_vpn = ADAPTER_TYPE_UNKNOWN, .network_preference = NetworkPreference::NEUTRAL, .available = true, }; @@ -608,7 +598,7 @@ NetworkMonitorInterface::InterfaceInfo BasicNetworkManager::GetInterfaceInfo( return network_monitor_->GetInterfaceInfo(cursor->ifa_name); } else { return {.adapter_type = GetAdapterTypeFromName(cursor->ifa_name), - .underlying_type_for_vpn = webrtc::ADAPTER_TYPE_UNKNOWN, + .underlying_type_for_vpn = ADAPTER_TYPE_UNKNOWN, .network_preference = NetworkPreference::NEUTRAL, .available = true}; } @@ -658,8 +648,8 @@ void BasicNetworkManager::ConvertIfAddrs( reinterpret_cast(cursor->ifa_addr)->sin6_scope_id; } - int prefix_length = webrtc::CountIPMaskBits(mask); - prefix = webrtc::TruncateIP(ip, prefix_length); + int prefix_length = CountIPMaskBits(mask); + prefix = TruncateIP(ip, prefix_length); std::string key = MakeNetworkKey(std::string(cursor->ifa_name), prefix, prefix_length); @@ -694,10 +684,10 @@ void BasicNetworkManager::ConvertIfAddrs( NetworkMonitorInterface::InterfaceInfo if_info = GetInterfaceInfo(cursor); // Check manually configured VPN override. - if (if_info.adapter_type != webrtc::ADAPTER_TYPE_VPN && + if (if_info.adapter_type != ADAPTER_TYPE_VPN && IsConfiguredVpn(prefix, prefix_length)) { if_info.underlying_type_for_vpn = if_info.adapter_type; - if_info.adapter_type = webrtc::ADAPTER_TYPE_VPN; + if_info.adapter_type = ADAPTER_TYPE_VPN; } auto network = CreateNetwork(cursor->ifa_name, cursor->ifa_name, prefix, @@ -907,18 +897,18 @@ bool BasicNetworkManager::CreateNetworks( adapter_type = ADAPTER_TYPE_VPN; } - auto network = CreateNetwork(name, description, prefix, prefix_length, - adapter_type); - network->set_underlying_type_for_vpn(underlying_type_for_vpn); - network->set_default_local_address_provider(this); - network->set_mdns_responder_provider(this); - network->set_scope_id(scope_id); - network->AddIP(ip); - bool ignored = IsIgnoredNetwork(*network); - network->set_ignored(ignored); - if (include_ignored || !network->ignored()) { - current_networks[key] = network.get(); - networks->push_back(std::move(network)); + auto new_network = CreateNetwork(name, description, prefix, + prefix_length, adapter_type); + new_network->set_underlying_type_for_vpn(underlying_type_for_vpn); + new_network->set_default_local_address_provider(this); + new_network->set_mdns_responder_provider(this); + new_network->set_scope_id(scope_id); + new_network->AddIP(ip); + bool ignored = IsIgnoredNetwork(*new_network); + new_network->set_ignored(ignored); + if (include_ignored || !new_network->ignored()) { + current_networks[key] = new_network.get(); + networks->push_back(std::move(new_network)); } } else { (*existing_network).second->AddIP(ip); @@ -1177,32 +1167,32 @@ IPAddress Network::GetBestIP() const { for (const InterfaceAddress& ip : ips_) { // Ignore any address which has been deprecated already. - if (ip.ipv6_flags() & webrtc::IPV6_ADDRESS_FLAG_DEPRECATED) + if (ip.ipv6_flags() & IPV6_ADDRESS_FLAG_DEPRECATED) continue; - if (webrtc::IPIsLinkLocal(ip)) { + if (IPIsLinkLocal(ip)) { link_local_ip = ip; continue; } // ULA address should only be returned when we have no other // global IP. - if (webrtc::IPIsULA(static_cast(ip))) { + if (IPIsULA(static_cast(ip))) { ula_ip = ip; continue; } selected_ip = ip; // Search could stop once a temporary non-deprecated one is found. - if (ip.ipv6_flags() & webrtc::IPV6_ADDRESS_FLAG_TEMPORARY) + if (ip.ipv6_flags() & IPV6_ADDRESS_FLAG_TEMPORARY) break; } - if (webrtc::IPIsUnspec(selected_ip)) { - if (!webrtc::IPIsUnspec(link_local_ip)) { + if (IPIsUnspec(selected_ip)) { + if (!IPIsUnspec(link_local_ip)) { // No proper global IPv6 address found, use link local address instead. selected_ip = link_local_ip; - } else if (!webrtc::IPIsUnspec(ula_ip)) { + } else if (!IPIsUnspec(ula_ip)) { // No proper global and link local address found, use ULA instead. selected_ip = ula_ip; } @@ -1233,45 +1223,45 @@ uint16_t Network::GetCost(const FieldTrialsView& field_trials) const { std::pair Network::GuessAdapterFromNetworkCost( int network_cost) { switch (network_cost) { - case webrtc::kNetworkCostMin: - return {webrtc::ADAPTER_TYPE_ETHERNET, false}; - case webrtc::kNetworkCostMin + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_ETHERNET, true}; - case webrtc::kNetworkCostLow: - return {webrtc::ADAPTER_TYPE_WIFI, false}; - case webrtc::kNetworkCostLow + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_WIFI, true}; - case webrtc::kNetworkCostCellular: - return {webrtc::ADAPTER_TYPE_CELLULAR, false}; - case webrtc::kNetworkCostCellular + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_CELLULAR, true}; - case webrtc::kNetworkCostCellular2G: - return {webrtc::ADAPTER_TYPE_CELLULAR_2G, false}; - case webrtc::kNetworkCostCellular2G + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_CELLULAR_2G, true}; - case webrtc::kNetworkCostCellular3G: - return {webrtc::ADAPTER_TYPE_CELLULAR_3G, false}; - case webrtc::kNetworkCostCellular3G + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_CELLULAR_3G, true}; - case webrtc::kNetworkCostCellular4G: - return {webrtc::ADAPTER_TYPE_CELLULAR_4G, false}; - case webrtc::kNetworkCostCellular4G + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_CELLULAR_4G, true}; - case webrtc::kNetworkCostCellular5G: - return {webrtc::ADAPTER_TYPE_CELLULAR_5G, false}; - case webrtc::kNetworkCostCellular5G + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_CELLULAR_5G, true}; - case webrtc::kNetworkCostUnknown: - return {webrtc::ADAPTER_TYPE_UNKNOWN, false}; - case webrtc::kNetworkCostUnknown + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_UNKNOWN, true}; - case webrtc::kNetworkCostMax: - return {webrtc::ADAPTER_TYPE_ANY, false}; - case webrtc::kNetworkCostMax + webrtc::kNetworkCostVpn: - return {webrtc::ADAPTER_TYPE_ANY, true}; + case kNetworkCostMin: + return {ADAPTER_TYPE_ETHERNET, false}; + case kNetworkCostMin + kNetworkCostVpn: + return {ADAPTER_TYPE_ETHERNET, true}; + case kNetworkCostLow: + return {ADAPTER_TYPE_WIFI, false}; + case kNetworkCostLow + kNetworkCostVpn: + return {ADAPTER_TYPE_WIFI, true}; + case kNetworkCostCellular: + return {ADAPTER_TYPE_CELLULAR, false}; + case kNetworkCostCellular + kNetworkCostVpn: + return {ADAPTER_TYPE_CELLULAR, true}; + case kNetworkCostCellular2G: + return {ADAPTER_TYPE_CELLULAR_2G, false}; + case kNetworkCostCellular2G + kNetworkCostVpn: + return {ADAPTER_TYPE_CELLULAR_2G, true}; + case kNetworkCostCellular3G: + return {ADAPTER_TYPE_CELLULAR_3G, false}; + case kNetworkCostCellular3G + kNetworkCostVpn: + return {ADAPTER_TYPE_CELLULAR_3G, true}; + case kNetworkCostCellular4G: + return {ADAPTER_TYPE_CELLULAR_4G, false}; + case kNetworkCostCellular4G + kNetworkCostVpn: + return {ADAPTER_TYPE_CELLULAR_4G, true}; + case kNetworkCostCellular5G: + return {ADAPTER_TYPE_CELLULAR_5G, false}; + case kNetworkCostCellular5G + kNetworkCostVpn: + return {ADAPTER_TYPE_CELLULAR_5G, true}; + case kNetworkCostUnknown: + return {ADAPTER_TYPE_UNKNOWN, false}; + case kNetworkCostUnknown + kNetworkCostVpn: + return {ADAPTER_TYPE_UNKNOWN, true}; + case kNetworkCostMax: + return {ADAPTER_TYPE_ANY, false}; + case kNetworkCostMax + kNetworkCostVpn: + return {ADAPTER_TYPE_ANY, true}; } RTC_LOG(LS_VERBOSE) << "Unknown network cost: " << network_cost; - return {webrtc::ADAPTER_TYPE_UNKNOWN, false}; + return {ADAPTER_TYPE_UNKNOWN, false}; } std::string Network::ToString() const { @@ -1280,9 +1270,9 @@ std::string Network::ToString() const { // the IP address. ss << "Net[" << description_.substr(0, description_.find(' ')) << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ << ":" - << webrtc::AdapterTypeToString(type_); + << AdapterTypeToString(type_); if (IsVpn()) { - ss << "/" << webrtc::AdapterTypeToString(underlying_type_for_vpn_); + ss << "/" << AdapterTypeToString(underlying_type_for_vpn_); } ss << ":id=" << id_ << "]"; return ss.Release(); @@ -1301,7 +1291,7 @@ bool BasicNetworkManager::IsConfiguredVpn(IPAddress prefix, RTC_DCHECK_RUN_ON(thread_); for (const auto& vpn : vpn_) { if (prefix_length >= vpn.prefix_length()) { - auto copy = webrtc::TruncateIP(prefix, vpn.prefix_length()); + auto copy = TruncateIP(prefix, vpn.prefix_length()); if (copy == vpn.address()) { return true; } diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc index 02c6ee0013..35795edd20 100644 --- a/rtc_base/network_unittest.cc +++ b/rtc_base/network_unittest.cc @@ -79,7 +79,7 @@ namespace { IPAddress IPFromString(absl::string_view str) { IPAddress ip; - RTC_CHECK(webrtc::IPFromString(str, &ip)); + RTC_CHECK(IPFromString(str, &ip)); return ip; } @@ -90,13 +90,13 @@ class FakeNetworkMonitor : public NetworkMonitorInterface { bool started() { return started_; } InterfaceInfo GetInterfaceInfo(absl::string_view if_name) override { InterfaceInfo if_info = { - .adapter_type = webrtc::ADAPTER_TYPE_UNKNOWN, + .adapter_type = ADAPTER_TYPE_UNKNOWN, .available = absl::c_count(unavailable_adapters_, if_name) == 0, }; if (absl::StartsWith(if_name, "wifi")) { - if_info.adapter_type = webrtc::ADAPTER_TYPE_WIFI; + if_info.adapter_type = ADAPTER_TYPE_WIFI; } else if (absl::StartsWith(if_name, "cellular")) { - if_info.adapter_type = webrtc::ADAPTER_TYPE_CELLULAR; + if_info.adapter_type = ADAPTER_TYPE_CELLULAR; } return if_info; } @@ -247,7 +247,7 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { ipv6_addr->sin6_family = AF_INET6; ipv6_addr->sin6_scope_id = scope_id; IPAddress ip; - webrtc::IPFromString(ip_string, &ip); + IPFromString(ip_string, &ip); ipv6_addr->sin6_addr = ip.ipv6_address(); return ipv6_addr; } @@ -290,7 +290,7 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { memset(ipv4_addr, 0, sizeof(struct sockaddr_in)); ipv4_addr->sin_family = AF_INET; IPAddress ip; - webrtc::IPFromString(ip_string, &ip); + IPFromString(ip_string, &ip); ipv4_addr->sin_addr = ip.ipv4_address(); return ipv4_addr; } @@ -365,11 +365,9 @@ TEST_F(NetworkTest, TestNetworkConstruct) { TEST_F(NetworkTest, TestIsIgnoredNetworkIgnoresIPsStartingWith0) { Network ipv4_network1("test_eth0", "Test Network Adapter 1", - IPAddress(0x12345600U), 24, - webrtc::ADAPTER_TYPE_ETHERNET); + IPAddress(0x12345600U), 24, ADAPTER_TYPE_ETHERNET); Network ipv4_network2("test_eth1", "Test Network Adapter 2", - IPAddress(0x010000U), 24, - webrtc::ADAPTER_TYPE_ETHERNET); + IPAddress(0x010000U), 24, ADAPTER_TYPE_ETHERNET); PhysicalSocketServer socket_server; BasicNetworkManager network_manager(CreateEnvironment(), &socket_server); network_manager.StartUpdating(); @@ -553,25 +551,24 @@ TEST_F(NetworkTest, TestBasicMergeNetworkList) { void SetupNetworks(std::vector>* list) { IPAddress ip; IPAddress prefix; - EXPECT_TRUE(webrtc::IPFromString("abcd::1234:5678:abcd:ef12", &ip)); - EXPECT_TRUE(webrtc::IPFromString("abcd::", &prefix)); + EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:ef12", &ip)); + EXPECT_TRUE(IPFromString("abcd::", &prefix)); // First, fake link-locals. Network ipv6_eth0_linklocalnetwork("test_eth0", "Test NetworkAdapter 1", prefix, 64); ipv6_eth0_linklocalnetwork.AddIP(ip); - EXPECT_TRUE(webrtc::IPFromString("abcd::5678:abcd:ef12:3456", &ip)); + EXPECT_TRUE(IPFromString("abcd::5678:abcd:ef12:3456", &ip)); Network ipv6_eth1_linklocalnetwork("test_eth1", "Test NetworkAdapter 2", prefix, 64); ipv6_eth1_linklocalnetwork.AddIP(ip); // Public networks: - EXPECT_TRUE(webrtc::IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c3", &ip)); - prefix = webrtc::TruncateIP(ip, 64); + EXPECT_TRUE(IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c3", &ip)); + prefix = TruncateIP(ip, 64); Network ipv6_eth0_publicnetwork1_ip1("test_eth0", "Test NetworkAdapter 1", prefix, 64); ipv6_eth0_publicnetwork1_ip1.AddIP(ip); - EXPECT_TRUE( - webrtc::IPFromString("2400:4030:1:2c00:be30:abcd:efab:cdef", &ip)); - prefix = webrtc::TruncateIP(ip, 64); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:abcd:efab:cdef", &ip)); + prefix = TruncateIP(ip, 64); Network ipv6_eth1_publicnetwork1_ip1("test_eth1", "Test NetworkAdapter 1", prefix, 64); ipv6_eth1_publicnetwork1_ip1.AddIP(ip); @@ -644,16 +641,15 @@ TEST_F(NetworkTest, MergeWithChangedIP) { SetupNetworks(&original_list); // Make a network that we're going to change. IPAddress ip; - EXPECT_TRUE(webrtc::IPFromString("2401:fa01:4:1000:be30:faa:fee:faa", &ip)); - IPAddress prefix = webrtc::TruncateIP(ip, 64); + EXPECT_TRUE(IPFromString("2401:fa01:4:1000:be30:faa:fee:faa", &ip)); + IPAddress prefix = TruncateIP(ip, 64); std::unique_ptr network_to_change = std::make_unique( "test_eth0", "Test Network Adapter 1", prefix, 64); std::unique_ptr changed_network = std::make_unique(*network_to_change); network_to_change->AddIP(ip); IPAddress changed_ip; - EXPECT_TRUE( - webrtc::IPFromString("2401:fa01:4:1000:be30:f00:f00:f00", &changed_ip)); + EXPECT_TRUE(IPFromString("2401:fa01:4:1000:be30:f00:f00:f00", &changed_ip)); changed_network->AddIP(changed_ip); const Network* const network_to_change_ptr = network_to_change.get(); original_list.push_back(std::move(network_to_change)); @@ -688,13 +684,12 @@ TEST_F(NetworkTest, TestMultipleIPMergeNetworkList) { IPAddress check_ip; IPAddress prefix; // Add a second IP to the public network on eth0 (2401:fa00:4:1000/64). - EXPECT_TRUE(webrtc::IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c6", &ip)); - prefix = webrtc::TruncateIP(ip, 64); + EXPECT_TRUE(IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c6", &ip)); + prefix = TruncateIP(ip, 64); Network ipv6_eth0_publicnetwork1_ip2("test_eth0", "Test NetworkAdapter 1", prefix, 64); // This is the IP that already existed in the public network on eth0. - EXPECT_TRUE( - webrtc::IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c3", &check_ip)); + EXPECT_TRUE(IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c3", &check_ip)); ipv6_eth0_publicnetwork1_ip2.AddIP(ip); std::vector> second_list; @@ -741,8 +736,8 @@ TEST_F(NetworkTest, TestMultiplePublicNetworksOnOneInterfaceMerge) { IPAddress ip; IPAddress prefix; // A second network for eth0. - EXPECT_TRUE(webrtc::IPFromString("2400:4030:1:2c00:be30:5bff:fee5:c3", &ip)); - prefix = webrtc::TruncateIP(ip, 64); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:5bff:fee5:c3", &ip)); + prefix = TruncateIP(ip, 64); Network ipv6_eth0_publicnetwork2_ip1("test_eth0", "Test NetworkAdapter 1", prefix, 64); ipv6_eth0_publicnetwork2_ip1.AddIP(ip); @@ -806,9 +801,8 @@ TEST_F(NetworkTest, IPv6NetworksPreferredOverIPv4) { IPAddress ip; IPAddress prefix; - EXPECT_TRUE( - webrtc::IPFromString("2400:4030:1:2c00:be30:abcd:efab:cdef", &ip)); - prefix = webrtc::TruncateIP(ip, 64); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:abcd:efab:cdef", &ip)); + prefix = TruncateIP(ip, 64); Network ipv6_eth1_publicnetwork1_ip1("test_eth1", "Test NetworkAdapter 2", prefix, 64); ipv6_eth1_publicnetwork1_ip1.AddIP(ip); @@ -854,20 +848,20 @@ TEST_F(NetworkTest, NetworksSortedByInterfaceName) { TEST_F(NetworkTest, TestNetworkAdapterTypes) { Network wifi("wlan0", "Wireless Adapter", IPAddress(0x12345600U), 24, - webrtc::ADAPTER_TYPE_WIFI); - EXPECT_EQ(webrtc::ADAPTER_TYPE_WIFI, wifi.type()); + ADAPTER_TYPE_WIFI); + EXPECT_EQ(ADAPTER_TYPE_WIFI, wifi.type()); Network ethernet("eth0", "Ethernet", IPAddress(0x12345600U), 24, - webrtc::ADAPTER_TYPE_ETHERNET); - EXPECT_EQ(webrtc::ADAPTER_TYPE_ETHERNET, ethernet.type()); + ADAPTER_TYPE_ETHERNET); + EXPECT_EQ(ADAPTER_TYPE_ETHERNET, ethernet.type()); Network cellular("test_cell", "Cellular Adapter", IPAddress(0x12345600U), 24, - webrtc::ADAPTER_TYPE_CELLULAR); - EXPECT_EQ(webrtc::ADAPTER_TYPE_CELLULAR, cellular.type()); + ADAPTER_TYPE_CELLULAR); + EXPECT_EQ(ADAPTER_TYPE_CELLULAR, cellular.type()); Network vpn("bridge_test", "VPN Adapter", IPAddress(0x12345600U), 24, - webrtc::ADAPTER_TYPE_VPN); - EXPECT_EQ(webrtc::ADAPTER_TYPE_VPN, vpn.type()); + ADAPTER_TYPE_VPN); + EXPECT_EQ(ADAPTER_TYPE_VPN, vpn.type()); Network unknown("test", "Test Adapter", IPAddress(0x12345600U), 24, - webrtc::ADAPTER_TYPE_UNKNOWN); - EXPECT_EQ(webrtc::ADAPTER_TYPE_UNKNOWN, unknown.type()); + ADAPTER_TYPE_UNKNOWN); + EXPECT_EQ(ADAPTER_TYPE_UNKNOWN, unknown.type()); } #if defined(WEBRTC_POSIX) @@ -953,8 +947,7 @@ TEST_F(NetworkTest, TestGetAdapterTypeFromNetworkMonitor) { // A network created without a network monitor will get UNKNOWN type. ifaddrs* addr_list = InstallIpv6Network(if_name, ipv6_address, ipv6_mask, manager_without_monitor); - EXPECT_EQ(webrtc::ADAPTER_TYPE_UNKNOWN, - GetAdapterType(manager_without_monitor)); + EXPECT_EQ(ADAPTER_TYPE_UNKNOWN, GetAdapterType(manager_without_monitor)); ReleaseIfAddrs(addr_list); // With the fake network monitor the type should be correctly determined. @@ -965,7 +958,7 @@ TEST_F(NetworkTest, TestGetAdapterTypeFromNetworkMonitor) { // detected by the network monitor now. addr_list = InstallIpv6Network(if_name, ipv6_address, ipv6_mask, manager_with_monitor); - EXPECT_EQ(webrtc::ADAPTER_TYPE_WIFI, GetAdapterType(manager_with_monitor)); + EXPECT_EQ(ADAPTER_TYPE_WIFI, GetAdapterType(manager_with_monitor)); ReleaseIfAddrs(addr_list); } @@ -986,25 +979,25 @@ TEST_F(NetworkTest, TestGetAdapterTypeFromNameMatching) { char if_name[20] = "ipsec11"; ifaddrs* addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager); - EXPECT_EQ(webrtc::ADAPTER_TYPE_VPN, GetAdapterType(manager)); + EXPECT_EQ(ADAPTER_TYPE_VPN, GetAdapterType(manager)); ClearNetworks(manager); ReleaseIfAddrs(addr_list); strcpy(if_name, "lo0"); addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager); - EXPECT_EQ(webrtc::ADAPTER_TYPE_LOOPBACK, GetAdapterType(manager)); + EXPECT_EQ(ADAPTER_TYPE_LOOPBACK, GetAdapterType(manager)); ClearNetworks(manager); ReleaseIfAddrs(addr_list); strcpy(if_name, "eth0"); addr_list = InstallIpv4Network(if_name, ipv4_address1, ipv4_mask, manager); - EXPECT_EQ(webrtc::ADAPTER_TYPE_ETHERNET, GetAdapterType(manager)); + EXPECT_EQ(ADAPTER_TYPE_ETHERNET, GetAdapterType(manager)); ClearNetworks(manager); ReleaseIfAddrs(addr_list); strcpy(if_name, "wlan0"); addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager); - EXPECT_EQ(webrtc::ADAPTER_TYPE_WIFI, GetAdapterType(manager)); + EXPECT_EQ(ADAPTER_TYPE_WIFI, GetAdapterType(manager)); ClearNetworks(manager); ReleaseIfAddrs(addr_list); @@ -1088,14 +1081,12 @@ TEST_F(NetworkTest, TestMergeNetworkList) { // Create 2 IPAddress classes with only last digit different. IPAddress ip1, ip2; - EXPECT_TRUE(webrtc::IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); - EXPECT_TRUE(webrtc::IPFromString("2400:4030:1:2c00:be30:0:0:2", &ip2)); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:0:0:2", &ip2)); // Create 2 networks with the same prefix and length. - auto net1 = - std::make_unique("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); - auto net2 = - std::make_unique("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); + auto net1 = std::make_unique("em1", "em1", TruncateIP(ip1, 64), 64); + auto net2 = std::make_unique("em1", "em1", TruncateIP(ip1, 64), 64); // Add different IP into each. net1->AddIP(ip1); @@ -1170,18 +1161,17 @@ TEST_F(NetworkTest, TestIPv6Selection) { std::string ipstr; ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c3"; - ASSERT_TRUE( - webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_DEPRECATED, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_DEPRECATED, &ip)); // Create a network with this prefix. - Network ipv6_network("test_eth0", "Test NetworkAdapter", - webrtc::TruncateIP(ip, 64), 64); + Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip, 64), + 64); EXPECT_EQ(AF_INET6, ipv6_network.family()); // When there is no address added, it should return an unspecified // address. EXPECT_EQ(ipv6_network.GetBestIP(), IPAddress()); - EXPECT_TRUE(webrtc::IPIsUnspec(ipv6_network.GetBestIP())); + EXPECT_TRUE(IPIsUnspec(ipv6_network.GetBestIP())); // Deprecated one should not be returned. ipv6_network.AddIP(ip); @@ -1190,20 +1180,19 @@ TEST_F(NetworkTest, TestIPv6Selection) { // Add ULA one. ULA is unique local address which is starting either // with 0xfc or 0xfd. ipstr = "fd00:fa00:4:1000:be30:5bff:fee5:c4"; - ASSERT_TRUE(webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_NONE, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_NONE, &ip)); ipv6_network.AddIP(ip); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); // Add global one. ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c5"; - ASSERT_TRUE(webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_NONE, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_NONE, &ip)); ipv6_network.AddIP(ip); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); // Add global dynamic temporary one. ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c6"; - ASSERT_TRUE( - webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_TEMPORARY, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_TEMPORARY, &ip)); ipv6_network.AddIP(ip); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); } @@ -1214,18 +1203,16 @@ TEST_F(NetworkTest, TestGetBestIPWithPreferGlobalIPv6ToLinkLocalEnabled) { std::string ipstr; ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c3"; - ASSERT_TRUE( - webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_DEPRECATED, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_DEPRECATED, &ip)); // Create a network with this prefix. - Network ipv6_network("test_eth0", "Test NetworkAdapter", - webrtc::TruncateIP(ip, 64), 64, - webrtc::ADAPTER_TYPE_UNKNOWN); + Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip, 64), + 64, ADAPTER_TYPE_UNKNOWN); // When there is no address added, it should return an unspecified // address. EXPECT_EQ(ipv6_network.GetBestIP(), IPAddress()); - EXPECT_TRUE(webrtc::IPIsUnspec(ipv6_network.GetBestIP())); + EXPECT_TRUE(IPIsUnspec(ipv6_network.GetBestIP())); // Deprecated one should not be returned. ipv6_network.AddIP(ip); @@ -1234,43 +1221,39 @@ TEST_F(NetworkTest, TestGetBestIPWithPreferGlobalIPv6ToLinkLocalEnabled) { // Add ULA one. ULA is unique local address which is starting either // with 0xfc or 0xfd. ipstr = "fd00:fa00:4:1000:be30:5bff:fee5:c4"; - ASSERT_TRUE(webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_NONE, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_NONE, &ip)); ipv6_network.AddIP(ip); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); // Add link local one. ipstr = "fe80::aabb:ccff:fedd:eeff"; - ASSERT_TRUE( - webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_NONE, &link_local)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_NONE, &link_local)); ipv6_network.AddIP(link_local); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(link_local)); // Add global one. ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c5"; - ASSERT_TRUE(webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_NONE, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_NONE, &ip)); ipv6_network.AddIP(ip); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); // Add another link local address, then the compatible address is still global // one. ipstr = "fe80::aabb:ccff:fedd:eedd"; - ASSERT_TRUE( - webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_NONE, &link_local)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_NONE, &link_local)); ipv6_network.AddIP(link_local); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); // Add global dynamic temporary one. ipstr = "2401:fa00:4:1000:be30:5bff:fee5:c6"; - ASSERT_TRUE( - webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_TEMPORARY, &ip)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_TEMPORARY, &ip)); ipv6_network.AddIP(ip); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); // Add another link local address, then the compatible address is still global // dynamic one. ipstr = "fe80::aabb:ccff:fedd:eedd"; - ASSERT_TRUE( - webrtc::IPFromString(ipstr, webrtc::IPV6_ADDRESS_FLAG_NONE, &link_local)); + ASSERT_TRUE(IPFromString(ipstr, IPV6_ADDRESS_FLAG_NONE, &link_local)); ipv6_network.AddIP(link_local); EXPECT_EQ(ipv6_network.GetBestIP(), static_cast(ip)); } @@ -1284,8 +1267,7 @@ TEST_F(NetworkTest, TestNetworkMonitoring) { manager.StartUpdating(); FakeNetworkMonitor* network_monitor = GetNetworkMonitor(manager); EXPECT_TRUE(network_monitor && network_monitor->started()); - EXPECT_THAT(webrtc::WaitUntil([&] { return callback_called_; }, IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callback_called_; }, IsTrue()), IsRtcOk()); callback_called_ = false; // Clear the networks so that there will be network changes below. @@ -1293,8 +1275,7 @@ TEST_F(NetworkTest, TestNetworkMonitoring) { // Network manager is started, so the callback is called when the network // monitor fires the network-change event. network_monitor->InovkeNetworksChangedCallbackForTesting(); - EXPECT_THAT(webrtc::WaitUntil([&] { return callback_called_; }, IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callback_called_; }, IsTrue()), IsRtcOk()); // Network manager is stopped. manager.StopUpdating(); @@ -1317,8 +1298,7 @@ TEST_F(NetworkTest, MAYBE_DefaultLocalAddress) { manager.SignalNetworksChanged.connect(static_cast(this), &NetworkTest::OnNetworksChanged); manager.StartUpdating(); - EXPECT_THAT(webrtc::WaitUntil([&] { return callback_called_; }, IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callback_called_; }, IsTrue()), IsRtcOk()); // Make sure we can query default local address when an address for such // address family exists. @@ -1328,7 +1308,7 @@ TEST_F(NetworkTest, MAYBE_DefaultLocalAddress) { if (network->GetBestIP().family() == AF_INET) { EXPECT_TRUE(QueryDefaultLocalAddress(manager, AF_INET) != IPAddress()); } else if (network->GetBestIP().family() == AF_INET6 && - !webrtc::IPIsLoopback(network->GetBestIP())) { + !IPIsLoopback(network->GetBestIP())) { // Existence of an IPv6 loopback address doesn't mean it has IPv6 network // enabled. EXPECT_TRUE(QueryDefaultLocalAddress(manager, AF_INET6) != IPAddress()); @@ -1336,23 +1316,23 @@ TEST_F(NetworkTest, MAYBE_DefaultLocalAddress) { } // GetDefaultLocalAddress should return the valid default address after set. - manager.set_default_local_addresses(webrtc::GetLoopbackIP(AF_INET), - webrtc::GetLoopbackIP(AF_INET6)); + manager.set_default_local_addresses(GetLoopbackIP(AF_INET), + GetLoopbackIP(AF_INET6)); EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET, &ip)); - EXPECT_EQ(ip, webrtc::GetLoopbackIP(AF_INET)); + EXPECT_EQ(ip, GetLoopbackIP(AF_INET)); EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); - EXPECT_EQ(ip, webrtc::GetLoopbackIP(AF_INET6)); + EXPECT_EQ(ip, GetLoopbackIP(AF_INET6)); // More tests on GetDefaultLocalAddress with ipv6 addresses where the set // default address may be different from the best IP address of any network. InterfaceAddress ip1; - EXPECT_TRUE(webrtc::IPFromString("abcd::1234:5678:abcd:1111", - webrtc::IPV6_ADDRESS_FLAG_TEMPORARY, &ip1)); + EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:1111", + IPV6_ADDRESS_FLAG_TEMPORARY, &ip1)); // Create a network with a prefix of ip1. - Network ipv6_network("test_eth0", "Test NetworkAdapter", - webrtc::TruncateIP(ip1, 64), 64); + Network ipv6_network("test_eth0", "Test NetworkAdapter", TruncateIP(ip1, 64), + 64); IPAddress ip2; - EXPECT_TRUE(webrtc::IPFromString("abcd::1234:5678:abcd:2222", &ip2)); + EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:2222", &ip2)); ipv6_network.AddIP(ip1); ipv6_network.AddIP(ip2); std::vector> list; @@ -1362,13 +1342,13 @@ TEST_F(NetworkTest, MAYBE_DefaultLocalAddress) { // If the set default address is not in any network, GetDefaultLocalAddress // should return it. IPAddress ip3; - EXPECT_TRUE(webrtc::IPFromString("abcd::1234:5678:abcd:3333", &ip3)); - manager.set_default_local_addresses(webrtc::GetLoopbackIP(AF_INET), ip3); + EXPECT_TRUE(IPFromString("abcd::1234:5678:abcd:3333", &ip3)); + manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip3); EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); EXPECT_EQ(ip3, ip); // If the set default address is in a network, GetDefaultLocalAddress will // return the best IP in that network. - manager.set_default_local_addresses(webrtc::GetLoopbackIP(AF_INET), ip2); + manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip2); EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); EXPECT_EQ(static_cast(ip1), ip); @@ -1382,10 +1362,9 @@ TEST_F(NetworkTest, TestWhenNetworkListChangeReturnsChangedFlag) { BasicNetworkManager manager(CreateEnvironment(), &socket_server); IPAddress ip1; - EXPECT_TRUE(webrtc::IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); - auto net1 = - std::make_unique("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); - net1->set_type(webrtc::ADAPTER_TYPE_CELLULAR_3G); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); + auto net1 = std::make_unique("em1", "em1", TruncateIP(ip1, 64), 64); + net1->set_type(ADAPTER_TYPE_CELLULAR_3G); net1->AddIP(ip1); std::vector> list; list.push_back(std::move(net1)); @@ -1396,14 +1375,14 @@ TEST_F(NetworkTest, TestWhenNetworkListChangeReturnsChangedFlag) { EXPECT_TRUE(changed); std::vector list2 = manager.GetNetworks(); EXPECT_EQ(list2.size(), 1uL); - EXPECT_EQ(webrtc::ADAPTER_TYPE_CELLULAR_3G, list2[0]->type()); + EXPECT_EQ(ADAPTER_TYPE_CELLULAR_3G, list2[0]->type()); } // Modify net1 from 3G to 4G { - auto net2 = std::make_unique("em1", "em1", - webrtc::TruncateIP(ip1, 64), 64); - net2->set_type(webrtc::ADAPTER_TYPE_CELLULAR_4G); + auto net2 = + std::make_unique("em1", "em1", TruncateIP(ip1, 64), 64); + net2->set_type(ADAPTER_TYPE_CELLULAR_4G); net2->AddIP(ip1); list.clear(); list.push_back(std::move(net2)); @@ -1415,14 +1394,14 @@ TEST_F(NetworkTest, TestWhenNetworkListChangeReturnsChangedFlag) { EXPECT_FALSE(changed); std::vector list2 = manager.GetNetworks(); ASSERT_EQ(list2.size(), 1uL); - EXPECT_EQ(webrtc::ADAPTER_TYPE_CELLULAR_4G, list2[0]->type()); + EXPECT_EQ(ADAPTER_TYPE_CELLULAR_4G, list2[0]->type()); } // Don't modify. { - auto net2 = std::make_unique("em1", "em1", - webrtc::TruncateIP(ip1, 64), 64); - net2->set_type(webrtc::ADAPTER_TYPE_CELLULAR_4G); + auto net2 = + std::make_unique("em1", "em1", TruncateIP(ip1, 64), 64); + net2->set_type(ADAPTER_TYPE_CELLULAR_4G); net2->AddIP(ip1); list.clear(); list.push_back(std::move(net2)); @@ -1433,7 +1412,7 @@ TEST_F(NetworkTest, TestWhenNetworkListChangeReturnsChangedFlag) { EXPECT_FALSE(changed); std::vector list2 = manager.GetNetworks(); ASSERT_EQ(list2.size(), 1uL); - EXPECT_EQ(webrtc::ADAPTER_TYPE_CELLULAR_4G, list2[0]->type()); + EXPECT_EQ(ADAPTER_TYPE_CELLULAR_4G, list2[0]->type()); } } @@ -1500,9 +1479,9 @@ TEST_F(NetworkTest, WebRTC_BindUsingInterfaceName) { FakeNetworkMonitor* network_monitor = GetNetworkMonitor(manager); IPAddress ipv6; - EXPECT_TRUE(webrtc::IPFromString("1000:2000:3000:4000:0:0:0:1", &ipv6)); + EXPECT_TRUE(IPFromString("1000:2000:3000:4000:0:0:0:1", &ipv6)); IPAddress ipv4; - EXPECT_TRUE(webrtc::IPFromString("192.168.0.2", &ipv4)); + EXPECT_TRUE(IPFromString("192.168.0.2", &ipv4)); // The network monitor only knwos about the ipv6 address, interface. network_monitor->set_adapters({"wlan0"}); @@ -1518,15 +1497,15 @@ TEST_F(NetworkTest, WebRTC_BindUsingInterfaceName) { TEST_F(NetworkTest, NetworkCostVpn_Default) { IPAddress ip1; - EXPECT_TRUE(webrtc::IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); ScopedKeyValueConfig field_trials; - Network* net1 = new Network("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); - net1->set_type(webrtc::ADAPTER_TYPE_VPN); - net1->set_underlying_type_for_vpn(webrtc::ADAPTER_TYPE_ETHERNET); + Network* net1 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); + net1->set_type(ADAPTER_TYPE_VPN); + net1->set_underlying_type_for_vpn(ADAPTER_TYPE_ETHERNET); - Network* net2 = new Network("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); - net2->set_type(webrtc::ADAPTER_TYPE_ETHERNET); + Network* net2 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); + net2->set_type(ADAPTER_TYPE_ETHERNET); EXPECT_EQ(net1->GetCost(field_trials), net2->GetCost(field_trials)); delete net1; @@ -1537,14 +1516,14 @@ TEST_F(NetworkTest, NetworkCostVpn_VpnMoreExpensive) { ScopedKeyValueConfig field_trials("WebRTC-AddNetworkCostToVpn/Enabled/"); IPAddress ip1; - EXPECT_TRUE(webrtc::IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); - Network* net1 = new Network("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); - net1->set_type(webrtc::ADAPTER_TYPE_VPN); - net1->set_underlying_type_for_vpn(webrtc::ADAPTER_TYPE_ETHERNET); + Network* net1 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); + net1->set_type(ADAPTER_TYPE_VPN); + net1->set_underlying_type_for_vpn(ADAPTER_TYPE_ETHERNET); - Network* net2 = new Network("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); - net2->set_type(webrtc::ADAPTER_TYPE_ETHERNET); + Network* net2 = new Network("em1", "em1", TruncateIP(ip1, 64), 64); + net2->set_type(ADAPTER_TYPE_ETHERNET); EXPECT_GT(net1->GetCost(field_trials), net2->GetCost(field_trials)); delete net1; @@ -1557,35 +1536,35 @@ TEST_F(NetworkTest, GuessAdapterFromNetworkCost) { "WebRTC-UseDifferentiatedCellularCosts/Enabled/"); IPAddress ip1; - EXPECT_TRUE(webrtc::IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); + EXPECT_TRUE(IPFromString("2400:4030:1:2c00:be30:0:0:1", &ip1)); - for (auto type : webrtc::kAllAdapterTypes) { - if (type == webrtc::ADAPTER_TYPE_VPN) + for (auto type : kAllAdapterTypes) { + if (type == ADAPTER_TYPE_VPN) continue; - Network net1("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); + Network net1("em1", "em1", TruncateIP(ip1, 64), 64); net1.set_type(type); auto [guess, vpn] = Network::GuessAdapterFromNetworkCost(net1.GetCost(field_trials)); EXPECT_FALSE(vpn); - if (type == webrtc::ADAPTER_TYPE_LOOPBACK) { - EXPECT_EQ(guess, webrtc::ADAPTER_TYPE_ETHERNET); + if (type == ADAPTER_TYPE_LOOPBACK) { + EXPECT_EQ(guess, ADAPTER_TYPE_ETHERNET); } else { EXPECT_EQ(type, guess); } } // VPN - for (auto type : webrtc::kAllAdapterTypes) { - if (type == webrtc::ADAPTER_TYPE_VPN) + for (auto type : kAllAdapterTypes) { + if (type == ADAPTER_TYPE_VPN) continue; - Network net1("em1", "em1", webrtc::TruncateIP(ip1, 64), 64); - net1.set_type(webrtc::ADAPTER_TYPE_VPN); + Network net1("em1", "em1", TruncateIP(ip1, 64), 64); + net1.set_type(ADAPTER_TYPE_VPN); net1.set_underlying_type_for_vpn(type); auto [guess, vpn] = Network::GuessAdapterFromNetworkCost(net1.GetCost(field_trials)); EXPECT_TRUE(vpn); - if (type == webrtc::ADAPTER_TYPE_LOOPBACK) { - EXPECT_EQ(guess, webrtc::ADAPTER_TYPE_ETHERNET); + if (type == ADAPTER_TYPE_LOOPBACK) { + EXPECT_EQ(guess, ADAPTER_TYPE_ETHERNET); } else { EXPECT_EQ(type, guess); } @@ -1630,8 +1609,8 @@ TEST_F(NetworkTest, VpnListOverrideAdapterType) { std::vector list = manager.GetNetworks(); ASSERT_EQ(1u, list.size()); - EXPECT_EQ(webrtc::ADAPTER_TYPE_VPN, list[0]->type()); - EXPECT_EQ(webrtc::ADAPTER_TYPE_ETHERNET, list[0]->underlying_type_for_vpn()); + EXPECT_EQ(ADAPTER_TYPE_VPN, list[0]->type()); + EXPECT_EQ(ADAPTER_TYPE_ETHERNET, list[0]->underlying_type_for_vpn()); ClearNetworks(manager); ReleaseIfAddrs(addr_list); } diff --git a/rtc_base/null_socket_server_unittest.cc b/rtc_base/null_socket_server_unittest.cc index b89a2415e6..81da9c3128 100644 --- a/rtc_base/null_socket_server_unittest.cc +++ b/rtc_base/null_socket_server_unittest.cc @@ -33,10 +33,10 @@ TEST(NullSocketServerTest, WaitAndSet) { thread->PostTask([&ss] { ss.WakeUp(); }); // The process_io will be ignored. const bool process_io = true; - EXPECT_THAT(webrtc::WaitUntil( - [&] { return ss.Wait(SocketServer::kForever, process_io); }, - ::testing::IsTrue(), {.timeout = TimeDelta::Millis(5'000)}), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return ss.Wait(SocketServer::kForever, process_io); }, + ::testing::IsTrue(), {.timeout = TimeDelta::Millis(5'000)}), + IsRtcOk()); } TEST(NullSocketServerTest, TestWait) { diff --git a/rtc_base/numerics/event_based_exponential_moving_average.cc b/rtc_base/numerics/event_based_exponential_moving_average.cc index 27b2066a97..419902dc52 100644 --- a/rtc_base/numerics/event_based_exponential_moving_average.cc +++ b/rtc_base/numerics/event_based_exponential_moving_average.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include "rtc_base/checks.h" @@ -35,7 +36,7 @@ EventBasedExponentialMovingAverage::EventBasedExponentialMovingAverage( } void EventBasedExponentialMovingAverage::SetHalfTime(int half_time) { - tau_ = static_cast(half_time) / log(2); + tau_ = static_cast(half_time) / std::numbers::ln2; Reset(); } diff --git a/rtc_base/numerics/percentile_filter_unittest.cc b/rtc_base/numerics/percentile_filter_unittest.cc index d6baa32001..d6826f42e1 100644 --- a/rtc_base/numerics/percentile_filter_unittest.cc +++ b/rtc_base/numerics/percentile_filter_unittest.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "absl/algorithm/container.h" @@ -58,10 +59,10 @@ TEST(PercentileFilterTest, MaxFilter) { TEST(PercentileFilterTest, MedianFilterDouble) { PercentileFilter filter(0.5f); - filter.Insert(2.71828); - filter.Insert(3.14159); - filter.Insert(1.41421); - EXPECT_EQ(2.71828, filter.GetPercentileValue()); + filter.Insert(std::numbers::e); + filter.Insert(std::numbers::pi); + filter.Insert(std::numbers::sqrt2); + EXPECT_FLOAT_EQ(std::numbers::e, filter.GetPercentileValue()); } TEST(PercentileFilterTest, MedianFilterInt) { diff --git a/rtc_base/openssl_adapter.cc b/rtc_base/openssl_adapter.cc index cb5dfc6a85..b25e9fb027 100644 --- a/rtc_base/openssl_adapter.cc +++ b/rtc_base/openssl_adapter.cc @@ -102,7 +102,7 @@ static BIO* BIO_new_socket(webrtc::Socket* socket) { static int socket_new(BIO* b) { BIO_set_shutdown(b, 0); BIO_set_init(b, 1); - BIO_set_data(b, 0); + BIO_set_data(b, nullptr); return 1; } @@ -184,7 +184,6 @@ static void LogSslError() { namespace webrtc { -using ::webrtc::TimeDelta; bool OpenSSLAdapter::InitializeSSL() { // TODO: https://issues.webrtc.org/issues/339300437 - remove once @@ -206,12 +205,12 @@ OpenSSLAdapter::OpenSSLAdapter(Socket* socket, ssl_session_cache_(ssl_session_cache), ssl_cert_verifier_(ssl_cert_verifier), state_(SSL_NONE), - role_(webrtc::SSL_CLIENT), + role_(SSL_CLIENT), ssl_read_needs_write_(false), ssl_write_needs_read_(false), ssl_(nullptr), ssl_ctx_(nullptr), - ssl_mode_(webrtc::SSL_MODE_TLS), + ssl_mode_(SSL_MODE_TLS), ignore_bad_cert_(false), custom_cert_verifier_status_(false) { // If a factory is used, take a reference on the factory's SSL_CTX. @@ -365,12 +364,12 @@ int OpenSSLAdapter::BeginSSL() { if (!tls_alpn_string.empty()) { SSL_set_alpn_protos( ssl_, reinterpret_cast(tls_alpn_string.data()), - webrtc::dchecked_cast(tls_alpn_string.size())); + dchecked_cast(tls_alpn_string.size())); } } if (!elliptic_curves_.empty()) { - SSL_set1_curves_list(ssl_, webrtc::StrJoin(elliptic_curves_, ":").c_str()); + SSL_set1_curves_list(ssl_, StrJoin(elliptic_curves_, ":").c_str()); } // Now that the initial config is done, transfer ownership of `bio` to the @@ -393,8 +392,7 @@ int OpenSSLAdapter::ContinueSSL() { // Clear the DTLS timer timer_.reset(); - int code = - (role_ == webrtc::SSL_CLIENT) ? SSL_connect(ssl_) : SSL_accept(ssl_); + int code = (role_ == SSL_CLIENT) ? SSL_connect(ssl_) : SSL_accept(ssl_); switch (SSL_get_error(ssl_, code)) { case SSL_ERROR_NONE: if (!SSLPostConnectionCheck(ssl_, ssl_host_name_)) { @@ -480,7 +478,7 @@ int OpenSSLAdapter::DoSslWrite(const void* pv, size_t cb, int* error) { RTC_DCHECK(error != nullptr); ssl_write_needs_read_ = false; - int ret = SSL_write(ssl_, pv, webrtc::checked_cast(cb)); + int ret = SSL_write(ssl_, pv, checked_cast(cb)); *error = SSL_get_error(ssl_, ret); switch (*error) { case SSL_ERROR_NONE: @@ -574,7 +572,7 @@ int OpenSSLAdapter::Send(const void* pv, size_t cb) { pending_data_.SetData(static_cast(pv), cb); // Since we're taking responsibility for sending this data, return its full // size. The user of this class can consider it sent. - return webrtc::dchecked_cast(cb); + return dchecked_cast(cb); } return ret; } @@ -612,7 +610,7 @@ int OpenSSLAdapter::Recv(void* pv, size_t cb, int64_t* timestamp) { } ssl_read_needs_write_ = false; - int code = SSL_read(ssl_, pv, webrtc::checked_cast(cb)); + int code = SSL_read(ssl_, pv, checked_cast(cb)); int error = SSL_get_error(ssl_, code); switch (error) { @@ -944,7 +942,7 @@ SSL_CTX* OpenSSLAdapter::CreateContext(SSLMode mode, bool enable_cache) { : TLS_with_buffers_method()); #else SSL_CTX* ctx = - SSL_CTX_new(mode == webrtc::SSL_MODE_DTLS ? DTLS_method() : TLS_method()); + SSL_CTX_new(mode == SSL_MODE_DTLS ? DTLS_method() : TLS_method()); #endif if (ctx == nullptr) { unsigned long error = ERR_get_error(); // NOLINT: type used by OpenSSL. diff --git a/rtc_base/openssl_digest.cc b/rtc_base/openssl_digest.cc index 96cac43031..ce0c6c1cb6 100644 --- a/rtc_base/openssl_digest.cc +++ b/rtc_base/openssl_digest.cc @@ -59,17 +59,17 @@ size_t OpenSSLDigest::Finish(void* buf, size_t len) { bool OpenSSLDigest::GetDigestEVP(absl::string_view algorithm, const EVP_MD** mdp) { const EVP_MD* md; - if (algorithm == webrtc::DIGEST_MD5) { + if (algorithm == DIGEST_MD5) { md = EVP_md5(); - } else if (algorithm == webrtc::DIGEST_SHA_1) { + } else if (algorithm == DIGEST_SHA_1) { md = EVP_sha1(); - } else if (algorithm == webrtc::DIGEST_SHA_224) { + } else if (algorithm == DIGEST_SHA_224) { md = EVP_sha224(); - } else if (algorithm == webrtc::DIGEST_SHA_256) { + } else if (algorithm == DIGEST_SHA_256) { md = EVP_sha256(); - } else if (algorithm == webrtc::DIGEST_SHA_384) { + } else if (algorithm == DIGEST_SHA_384) { md = EVP_sha384(); - } else if (algorithm == webrtc::DIGEST_SHA_512) { + } else if (algorithm == DIGEST_SHA_512) { md = EVP_sha512(); } else { return false; @@ -87,17 +87,17 @@ bool OpenSSLDigest::GetDigestName(const EVP_MD* md, std::string* algorithm) { int md_type = EVP_MD_type(md); if (md_type == NID_md5) { - *algorithm = webrtc::DIGEST_MD5; + *algorithm = DIGEST_MD5; } else if (md_type == NID_sha1) { - *algorithm = webrtc::DIGEST_SHA_1; + *algorithm = DIGEST_SHA_1; } else if (md_type == NID_sha224) { - *algorithm = webrtc::DIGEST_SHA_224; + *algorithm = DIGEST_SHA_224; } else if (md_type == NID_sha256) { - *algorithm = webrtc::DIGEST_SHA_256; + *algorithm = DIGEST_SHA_256; } else if (md_type == NID_sha384) { - *algorithm = webrtc::DIGEST_SHA_384; + *algorithm = DIGEST_SHA_384; } else if (md_type == NID_sha512) { - *algorithm = webrtc::DIGEST_SHA_512; + *algorithm = DIGEST_SHA_512; } else { algorithm->clear(); return false; diff --git a/rtc_base/openssl_stream_adapter.cc b/rtc_base/openssl_stream_adapter.cc index b46faff911..944567b43c 100644 --- a/rtc_base/openssl_stream_adapter.cc +++ b/rtc_base/openssl_stream_adapter.cc @@ -72,7 +72,6 @@ static constexpr absl::string_view kDtlsSrtpExporterLabel = namespace webrtc { namespace { -using ::webrtc::SafeTask; // SRTP cipher suite table. `internal_name` is used to construct a // colon-separated profile strings which is needed by // SSL_CTX_set_tlsext_use_srtp(). @@ -83,10 +82,10 @@ struct SrtpCipherMapEntry { // This isn't elegant, but it's better than an external reference constexpr SrtpCipherMapEntry kSrtpCipherMap[] = { - {"SRTP_AES128_CM_SHA1_80", webrtc::kSrtpAes128CmSha1_80}, - {"SRTP_AES128_CM_SHA1_32", webrtc::kSrtpAes128CmSha1_32}, - {"SRTP_AEAD_AES_128_GCM", webrtc::kSrtpAeadAes128Gcm}, - {"SRTP_AEAD_AES_256_GCM", webrtc::kSrtpAeadAes256Gcm}}; + {"SRTP_AES128_CM_SHA1_80", kSrtpAes128CmSha1_80}, + {"SRTP_AES128_CM_SHA1_32", kSrtpAes128CmSha1_32}, + {"SRTP_AEAD_AES_128_GCM", kSrtpAeadAes128Gcm}, + {"SRTP_AEAD_AES_256_GCM", kSrtpAeadAes256Gcm}}; #ifdef OPENSSL_IS_BORINGSSL // Enabled by EnableTimeCallbackForTesting. Should never be set in production @@ -94,38 +93,37 @@ constexpr SrtpCipherMapEntry kSrtpCipherMap[] = { bool g_use_time_callback_for_testing = false; // Not used in production code. Actual time should be relative to Jan 1, 1970. void TimeCallbackForTesting(const SSL* ssl, struct timeval* out_clock) { - int64_t time = webrtc::TimeNanos(); - out_clock->tv_sec = time / webrtc::kNumNanosecsPerSec; - out_clock->tv_usec = - (time % webrtc::kNumNanosecsPerSec) / webrtc::kNumNanosecsPerMicrosec; + int64_t time = TimeNanos(); + out_clock->tv_sec = time / kNumNanosecsPerSec; + out_clock->tv_usec = (time % kNumNanosecsPerSec) / kNumNanosecsPerMicrosec; } #endif uint16_t GetMaxVersion(SSLMode ssl_mode, SSLProtocolVersion version) { switch (ssl_mode) { - case webrtc::SSL_MODE_TLS: + case SSL_MODE_TLS: switch (version) { default: - case webrtc::SSL_PROTOCOL_NOT_GIVEN: - case webrtc::SSL_PROTOCOL_TLS_10: - case webrtc::SSL_PROTOCOL_TLS_11: - case webrtc::SSL_PROTOCOL_TLS_12: + case SSL_PROTOCOL_NOT_GIVEN: + case SSL_PROTOCOL_TLS_10: + case SSL_PROTOCOL_TLS_11: + case SSL_PROTOCOL_TLS_12: return TLS1_2_VERSION; - case webrtc::SSL_PROTOCOL_TLS_13: + case SSL_PROTOCOL_TLS_13: #ifdef TLS1_3_VERSION return TLS1_3_VERSION; #else return TLS1_2_VERSION; #endif } - case webrtc::SSL_MODE_DTLS: + case SSL_MODE_DTLS: switch (version) { default: - case webrtc::SSL_PROTOCOL_NOT_GIVEN: - case webrtc::SSL_PROTOCOL_DTLS_10: - case webrtc::SSL_PROTOCOL_DTLS_12: + case SSL_PROTOCOL_NOT_GIVEN: + case SSL_PROTOCOL_DTLS_10: + case SSL_PROTOCOL_DTLS_12: return DTLS1_2_VERSION; - case webrtc::SSL_PROTOCOL_DTLS_13: + case SSL_PROTOCOL_DTLS_13: #ifdef DTLS1_3_VERSION return DTLS1_3_VERSION; #else @@ -198,7 +196,7 @@ static BIO* BIO_new_stream(StreamInterface* stream) { static int stream_new(BIO* b) { BIO_set_shutdown(b, 0); BIO_set_init(b, 1); - BIO_set_data(b, 0); + BIO_set_data(b, nullptr); return 1; } @@ -219,9 +217,9 @@ static int stream_read(BIO* b, char* out, int outl) { int error; StreamResult result = stream->Read( MakeArrayView(reinterpret_cast(out), outl), read, error); - if (result == webrtc::SR_SUCCESS) { - return webrtc::checked_cast(read); - } else if (result == webrtc::SR_BLOCK) { + if (result == SR_SUCCESS) { + return checked_cast(read); + } else if (result == SR_BLOCK) { BIO_set_retry_read(b); } return -1; @@ -237,16 +235,16 @@ static int stream_write(BIO* b, const char* in, int inl) { int error; StreamResult result = stream->Write( MakeArrayView(reinterpret_cast(in), inl), written, error); - if (result == webrtc::SR_SUCCESS) { - return webrtc::checked_cast(written); - } else if (result == webrtc::SR_BLOCK) { + if (result == SR_SUCCESS) { + return checked_cast(written); + } else if (result == SR_BLOCK) { BIO_set_retry_write(b); } return -1; } static int stream_puts(BIO* b, const char* str) { - return stream_write(b, str, webrtc::checked_cast(strlen(str))); + return stream_write(b, str, checked_cast(strlen(str))); } static long stream_ctrl(BIO* b, int cmd, long num, void* ptr) { @@ -256,7 +254,7 @@ static long stream_ctrl(BIO* b, int cmd, long num, void* ptr) { case BIO_CTRL_EOF: { StreamInterface* stream = static_cast(ptr); // 1 means end-of-stream. - return (stream->GetState() == webrtc::SS_CLOSED) ? 1 : 0; + return (stream->GetState() == SS_CLOSED) ? 1 : 0; } case BIO_CTRL_WPENDING: case BIO_CTRL_PENDING: @@ -295,16 +293,16 @@ OpenSSLStreamAdapter::OpenSSLStreamAdapter( handshake_error_(std::move(handshake_error)), owner_(Thread::Current()), state_(SSL_NONE), - role_(webrtc::SSL_CLIENT), + role_(SSL_CLIENT), ssl_read_needs_write_(false), ssl_write_needs_read_(false), ssl_(nullptr), ssl_ctx_(nullptr), - ssl_mode_(webrtc::SSL_MODE_DTLS), - ssl_max_version_(webrtc::SSL_PROTOCOL_DTLS_12), + ssl_mode_(SSL_MODE_DTLS), + ssl_max_version_(SSL_PROTOCOL_DTLS_12), force_dtls_13_(GetForceDtls13(field_trials)), - enable_dtls_pqc_(field_trials && - field_trials->IsEnabled("WebRTC-EnableDtlsPqc")) { + disable_ssl_group_ids_(field_trials && field_trials->IsEnabled( + "WebRTC-DisableSslGroupIds")) { stream_->SetEventCallback( [this](int events, int err) { OnEvent(events, err); }); } @@ -364,7 +362,7 @@ SSLPeerCertificateDigestError OpenSSLStreamAdapter::SetPeerCertificateDigest( // Post the event asynchronously to unwind the stack. The caller // of ContinueSSL may be the same object listening for these // events and may not be prepared for reentrancy. - PostEvent(webrtc::SE_OPEN | webrtc::SE_READ | webrtc::SE_WRITE, 0); + PostEvent(SE_OPEN | SE_READ | SE_WRITE, 0); } return SSLPeerCertificateDigestError::NONE; } @@ -395,37 +393,37 @@ bool OpenSSLStreamAdapter::GetSslCipherSuite(int* cipher_suite) const { SSLProtocolVersion OpenSSLStreamAdapter::GetSslVersion() const { if (state_ != SSL_CONNECTED) { - return webrtc::SSL_PROTOCOL_NOT_GIVEN; + return SSL_PROTOCOL_NOT_GIVEN; } int ssl_version = SSL_version(ssl_); - if (ssl_mode_ == webrtc::SSL_MODE_DTLS) { + if (ssl_mode_ == SSL_MODE_DTLS) { if (ssl_version == DTLS1_VERSION) { - return webrtc::SSL_PROTOCOL_DTLS_10; + return SSL_PROTOCOL_DTLS_10; } else if (ssl_version == DTLS1_2_VERSION) { - return webrtc::SSL_PROTOCOL_DTLS_12; + return SSL_PROTOCOL_DTLS_12; } #ifdef DTLS1_3_VERSION if (ssl_version == DTLS1_3_VERSION) { - return webrtc::SSL_PROTOCOL_DTLS_13; + return SSL_PROTOCOL_DTLS_13; } #endif } else { if (ssl_version == TLS1_VERSION) { - return webrtc::SSL_PROTOCOL_TLS_10; + return SSL_PROTOCOL_TLS_10; } else if (ssl_version == TLS1_1_VERSION) { - return webrtc::SSL_PROTOCOL_TLS_11; + return SSL_PROTOCOL_TLS_11; } else if (ssl_version == TLS1_2_VERSION) { - return webrtc::SSL_PROTOCOL_TLS_12; + return SSL_PROTOCOL_TLS_12; } #ifdef TLS1_3_VERSION if (ssl_version == TLS1_3_VERSION) { - return webrtc::SSL_PROTOCOL_TLS_13; + return SSL_PROTOCOL_TLS_13; } #endif } - return webrtc::SSL_PROTOCOL_NOT_GIVEN; + return SSL_PROTOCOL_NOT_GIVEN; } bool OpenSSLStreamAdapter::GetSslVersionBytes(int* version) const { @@ -436,7 +434,7 @@ bool OpenSSLStreamAdapter::GetSslVersionBytes(int* version) const { return true; } -uint16_t OpenSSLStreamAdapter::GetSslGroupIdForTesting() const { +uint16_t OpenSSLStreamAdapter::GetSslGroupId() const { if (state_ != SSL_CONNECTED) { return 0; } @@ -524,7 +522,7 @@ bool OpenSSLStreamAdapter::GetDtlsSrtpCryptoSuite(int* crypto_suite) const { } *crypto_suite = srtp_profile->id; - RTC_DCHECK(!webrtc::SrtpCryptoSuiteToName(*crypto_suite).empty()); + RTC_DCHECK(!SrtpCryptoSuiteToName(*crypto_suite).empty()); return true; } @@ -538,7 +536,7 @@ int OpenSSLStreamAdapter::StartSSL() { return -1; } - if (stream_->GetState() != webrtc::SS_OPEN) { + if (stream_->GetState() != SS_OPEN) { state_ = SSL_WAIT; return 0; } @@ -565,7 +563,7 @@ void OpenSSLStreamAdapter::SetMaxProtocolVersion(SSLProtocolVersion version) { void OpenSSLStreamAdapter::SetInitialRetransmissionTimeout(int timeout_ms) { dtls_handshake_timeout_ms_ = timeout_ms; #ifdef OPENSSL_IS_BORINGSSL - if (ssl_ctx_ != nullptr && ssl_mode_ == webrtc::SSL_MODE_DTLS) { + if (ssl_ctx_ != nullptr && ssl_mode_ == SSL_MODE_DTLS) { // TODO (jonaso, webrtc:367395350): Switch to upcoming // DTLSv1_set_timeout_duration. DTLSv1_set_initial_timeout_duration(ssl_, dtls_handshake_timeout_ms_); @@ -594,29 +592,28 @@ StreamResult OpenSSLStreamAdapter::Write(ArrayView data, return stream_->Write(data, written, error); case SSL_WAIT: case SSL_CONNECTING: - return webrtc::SR_BLOCK; + return SR_BLOCK; case SSL_CONNECTED: if (WaitingToVerifyPeerCertificate()) { - return webrtc::SR_BLOCK; + return SR_BLOCK; } break; case SSL_ERROR: case SSL_CLOSED: default: error = ssl_error_code_; - return webrtc::SR_ERROR; + return SR_ERROR; } // OpenSSL will return an error if we try to write zero bytes if (data.size() == 0) { written = 0; - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } ssl_write_needs_read_ = false; - int code = - SSL_write(ssl_, data.data(), webrtc::checked_cast(data.size())); + int code = SSL_write(ssl_, data.data(), checked_cast(data.size())); int ssl_error = SSL_get_error(ssl_, code); switch (ssl_error) { case SSL_ERROR_NONE: @@ -624,19 +621,19 @@ StreamResult OpenSSLStreamAdapter::Write(ArrayView data, RTC_DCHECK_GT(code, 0); RTC_DCHECK_LE(code, data.size()); written = code; - return webrtc::SR_SUCCESS; + return SR_SUCCESS; case SSL_ERROR_WANT_READ: RTC_DLOG(LS_VERBOSE) << " -- error want read"; ssl_write_needs_read_ = true; - return webrtc::SR_BLOCK; + return SR_BLOCK; case SSL_ERROR_WANT_WRITE: RTC_DLOG(LS_VERBOSE) << " -- error want write"; - return webrtc::SR_BLOCK; + return SR_BLOCK; case SSL_ERROR_ZERO_RETURN: default: Error("SSL_write", (ssl_error ? ssl_error : -1), 0, false); error = ssl_error_code_; - return webrtc::SR_ERROR; + return SR_ERROR; } // not reached } @@ -651,30 +648,29 @@ StreamResult OpenSSLStreamAdapter::Read(ArrayView data, return stream_->Read(data, read, error); case SSL_WAIT: case SSL_CONNECTING: - return webrtc::SR_BLOCK; + return SR_BLOCK; case SSL_CONNECTED: if (WaitingToVerifyPeerCertificate()) { - return webrtc::SR_BLOCK; + return SR_BLOCK; } break; case SSL_CLOSED: - return webrtc::SR_EOS; + return SR_EOS; case SSL_ERROR: default: error = ssl_error_code_; - return webrtc::SR_ERROR; + return SR_ERROR; } // Don't trust OpenSSL with zero byte reads if (data.size() == 0) { read = 0; - return webrtc::SR_SUCCESS; + return SR_SUCCESS; } ssl_read_needs_write_ = false; - const int code = - SSL_read(ssl_, data.data(), webrtc::checked_cast(data.size())); + const int code = SSL_read(ssl_, data.data(), checked_cast(data.size())); const int ssl_error = SSL_get_error(ssl_, code); switch (ssl_error) { @@ -684,33 +680,33 @@ StreamResult OpenSSLStreamAdapter::Read(ArrayView data, RTC_DCHECK_LE(code, data.size()); read = code; - if (ssl_mode_ == webrtc::SSL_MODE_DTLS) { + if (ssl_mode_ == SSL_MODE_DTLS) { // Enforce atomic reads -- this is a short read unsigned int pending = SSL_pending(ssl_); if (pending) { RTC_DLOG(LS_INFO) << " -- short DTLS read. flushing"; FlushInput(pending); - error = webrtc::SSE_MSG_TRUNC; - return webrtc::SR_ERROR; + error = SSE_MSG_TRUNC; + return SR_ERROR; } } - return webrtc::SR_SUCCESS; + return SR_SUCCESS; case SSL_ERROR_WANT_READ: RTC_DLOG(LS_VERBOSE) << " -- error want read"; - return webrtc::SR_BLOCK; + return SR_BLOCK; case SSL_ERROR_WANT_WRITE: RTC_DLOG(LS_VERBOSE) << " -- error want write"; ssl_read_needs_write_ = true; - return webrtc::SR_BLOCK; + return SR_BLOCK; case SSL_ERROR_ZERO_RETURN: RTC_DLOG(LS_VERBOSE) << " -- remote side closed"; Close(); - return webrtc::SR_EOS; + return SR_EOS; default: Error("SSL_read", (ssl_error ? ssl_error : -1), 0, false); error = ssl_error_code_; - return webrtc::SR_ERROR; + return SR_ERROR; } // not reached } @@ -750,14 +746,14 @@ StreamState OpenSSLStreamAdapter::GetState() const { switch (state_) { case SSL_WAIT: case SSL_CONNECTING: - return webrtc::SS_OPENING; + return SS_OPENING; case SSL_CONNECTED: if (WaitingToVerifyPeerCertificate()) { - return webrtc::SS_OPENING; + return SS_OPENING; } - return webrtc::SS_OPEN; + return SS_OPEN; default: - return webrtc::SS_CLOSED; + return SS_CLOSED; } // not reached } @@ -767,11 +763,11 @@ void OpenSSLStreamAdapter::OnEvent(int events, int err) { int events_to_signal = 0; int signal_error = 0; - if ((events & webrtc::SE_OPEN)) { + if ((events & SE_OPEN)) { RTC_DLOG(LS_VERBOSE) << "OpenSSLStreamAdapter::OnEvent SE_OPEN"; if (state_ != SSL_WAIT) { RTC_DCHECK(state_ == SSL_NONE); - events_to_signal |= webrtc::SE_OPEN; + events_to_signal |= SE_OPEN; } else { state_ = SSL_CONNECTING; if (int error = BeginSSL()) { @@ -781,36 +777,36 @@ void OpenSSLStreamAdapter::OnEvent(int events, int err) { } } - if ((events & (webrtc::SE_READ | webrtc::SE_WRITE))) { + if ((events & (SE_READ | SE_WRITE))) { RTC_DLOG(LS_VERBOSE) << "OpenSSLStreamAdapter::OnEvent" - << ((events & webrtc::SE_READ) ? " SE_READ" : "") - << ((events & webrtc::SE_WRITE) ? " SE_WRITE" : ""); + << ((events & SE_READ) ? " SE_READ" : "") + << ((events & SE_WRITE) ? " SE_WRITE" : ""); if (state_ == SSL_NONE) { - events_to_signal |= events & (webrtc::SE_READ | webrtc::SE_WRITE); + events_to_signal |= events & (SE_READ | SE_WRITE); } else if (state_ == SSL_CONNECTING) { if (int error = ContinueSSL()) { Error("ContinueSSL", error, 0, true); return; } } else if (state_ == SSL_CONNECTED) { - if (((events & webrtc::SE_READ) && ssl_write_needs_read_) || - (events & webrtc::SE_WRITE)) { + if (((events & SE_READ) && ssl_write_needs_read_) || + (events & SE_WRITE)) { RTC_DLOG(LS_VERBOSE) << " -- onStreamWriteable"; - events_to_signal |= webrtc::SE_WRITE; + events_to_signal |= SE_WRITE; } - if (((events & webrtc::SE_WRITE) && ssl_read_needs_write_) || - (events & webrtc::SE_READ)) { + if (((events & SE_WRITE) && ssl_read_needs_write_) || + (events & SE_READ)) { RTC_DLOG(LS_VERBOSE) << " -- onStreamReadable"; - events_to_signal |= webrtc::SE_READ; + events_to_signal |= SE_READ; } } } - if ((events & webrtc::SE_CLOSE)) { + if ((events & SE_CLOSE)) { RTC_DLOG(LS_VERBOSE) << "OpenSSLStreamAdapter::OnEvent(SE_CLOSE, " << err << ")"; Cleanup(0); - events_to_signal |= webrtc::SE_CLOSE; + events_to_signal |= SE_CLOSE; // SE_CLOSE is the only event that uses the final parameter to OnEvent(). RTC_DCHECK(signal_error == 0); signal_error = err; @@ -899,15 +895,13 @@ int OpenSSLStreamAdapter::BeginSSL() { SSL_set_mtu(ssl_, dtls_mtu_); #ifdef OPENSSL_IS_BORINGSSL - if (ssl_mode_ == webrtc::SSL_MODE_DTLS) { + if (ssl_mode_ == SSL_MODE_DTLS) { DTLSv1_set_initial_timeout_duration(ssl_, dtls_handshake_timeout_ms_); } - // Experimental code guarded by WebRTC-EnableDtlsPqc. - if (enable_dtls_pqc_) { - const uint16_t kGroups[] = {SSL_GROUP_X25519_MLKEM768, SSL_GROUP_X25519, - SSL_GROUP_SECP256R1, SSL_GROUP_SECP384R1}; - if (!SSL_set1_group_ids(ssl_, kGroups, std::size(kGroups))) { + if (!disable_ssl_group_ids_) { + if (!SSL_set1_group_ids(ssl_, ssl_cipher_groups_.data(), + ssl_cipher_groups_.size())) { RTC_LOG(LS_WARNING) << "Failed to call SSL_set1_group_ids."; return -1; } @@ -929,8 +923,7 @@ int OpenSSLStreamAdapter::ContinueSSL() { // Clear the DTLS timer timeout_task_.Stop(); - const int code = - (role_ == webrtc::SSL_CLIENT) ? SSL_connect(ssl_) : SSL_accept(ssl_); + const int code = (role_ == SSL_CLIENT) ? SSL_connect(ssl_) : SSL_accept(ssl_); const int ssl_error = SSL_get_error(ssl_, code); switch (ssl_error) { @@ -950,7 +943,7 @@ int OpenSSLStreamAdapter::ContinueSSL() { // The caller of ContinueSSL may be the same object listening for these // events and may not be prepared for reentrancy. // PostEvent(SE_OPEN | SE_READ | SE_WRITE, 0); - FireEvent(webrtc::SE_OPEN | webrtc::SE_READ | webrtc::SE_WRITE, 0); + FireEvent(SE_OPEN | SE_READ | SE_WRITE, 0); } break; case SSL_ERROR_WANT_READ: @@ -997,7 +990,7 @@ void OpenSSLStreamAdapter::Error(absl::string_view context, ssl_error_code_ = err; Cleanup(alert); if (signal) { - FireEvent(webrtc::SE_CLOSE, err); + FireEvent(SE_CLOSE, err); } } @@ -1047,9 +1040,9 @@ SSL_CTX* OpenSSLStreamAdapter::SetupSSLContext() { #ifdef OPENSSL_IS_BORINGSSL // If X509 objects aren't used, we can use these methods to avoid // linking the sizable crypto/x509 code, using CRYPTO_BUFFER instead. - SSL_CTX* ctx = SSL_CTX_new(ssl_mode_ == webrtc::SSL_MODE_DTLS - ? DTLS_with_buffers_method() - : TLS_with_buffers_method()); + SSL_CTX* ctx = + SSL_CTX_new(ssl_mode_ == SSL_MODE_DTLS ? DTLS_with_buffers_method() + : TLS_with_buffers_method()); #else SSL_CTX* ctx = SSL_CTX_new(ssl_mode_ == SSL_MODE_DTLS ? DTLS_method() : TLS_method()); @@ -1059,7 +1052,7 @@ SSL_CTX* OpenSSLStreamAdapter::SetupSSLContext() { } auto min_version = - ssl_mode_ == webrtc::SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION; + ssl_mode_ == SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION; auto max_version = GetMaxVersion(ssl_mode_, ssl_max_version_); #ifdef DTLS1_3_VERSION if (force_dtls_13_ == kForceDtls13Enabled) { @@ -1350,10 +1343,18 @@ void OpenSSLStreamAdapter::EnableTimeCallbackForTesting() { SSLProtocolVersion OpenSSLStreamAdapter::GetMaxSupportedDTLSProtocolVersion() { #if defined(OPENSSL_IS_BORINGSSL) && defined(DTLS1_3_VERSION) - return webrtc::SSL_PROTOCOL_DTLS_13; + return SSL_PROTOCOL_DTLS_13; #else return SSL_PROTOCOL_DTLS_12; #endif } +bool OpenSSLStreamAdapter::SetSslGroupIds(const std::vector& groups) { + if (state_ != SSL_NONE) { + return false; + } + ssl_cipher_groups_ = groups; + return true; +} + } // namespace webrtc diff --git a/rtc_base/openssl_stream_adapter.h b/rtc_base/openssl_stream_adapter.h index 4259f8c1b5..257f100ef5 100644 --- a/rtc_base/openssl_stream_adapter.h +++ b/rtc_base/openssl_stream_adapter.h @@ -136,9 +136,13 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { // Used for testing (and maybe put into stats?). int GetRetransmissionCount() const override { return retransmission_count_; } + // Set cipher group ids to use during DTLS handshake to establish ephemeral + // key, see CryptoOptions::EphemeralKeyExchangeCipherGroups. + bool SetSslGroupIds(const std::vector& group_ids) override; + // Return the the ID of the group used by the adapters most recently // completed handshake, or 0 if not applicable (e.g. before the handshake). - uint16_t GetSslGroupIdForTesting() const override; + uint16_t GetSslGroupId() const override; private: enum SSLState { @@ -241,6 +245,9 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { // The DtlsSrtp ciphers std::string srtp_ciphers_; + // The ssl cipher groups to be used for DTLS handshake. + std::vector ssl_cipher_groups_; + // Do DTLS or not SSLMode ssl_mode_; @@ -261,8 +268,9 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { int retransmission_count_ = 0; - // Experimental flag to enable Post-Quantum Cryptography TLS. - const bool enable_dtls_pqc_ = false; + // Kill switch (from field-trial) flag to disable the use of + // SSL_set_group_ids. + const bool disable_ssl_group_ids_ = false; }; ///////////////////////////////////////////////////////////////////////////// diff --git a/rtc_base/openssl_stream_adapter_unittest.cc b/rtc_base/openssl_stream_adapter_unittest.cc new file mode 100644 index 0000000000..9513ad60ab --- /dev/null +++ b/rtc_base/openssl_stream_adapter_unittest.cc @@ -0,0 +1,129 @@ +/* + * 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 "rtc_base/openssl_stream_adapter.h" + +#include + +#include +#include +#include + +#include "rtc_base/logging.h" +#include "rtc_base/ssl_stream_adapter.h" +#include "test/gtest.h" +#include "test/scoped_key_value_config.h" + +TEST(OpenSSLStreamAdapterTest, GetSupportedEphemeralKeyExchangeCipherGroups) { + RTC_LOG(LS_INFO) << "OpenSSLStreamAdapter::IsBoringSsl(): " + << webrtc::OpenSSLStreamAdapter::IsBoringSsl(); + std::set 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 + }; + EXPECT_EQ( + webrtc::SSLStreamAdapter::GetSupportedEphemeralKeyExchangeCipherGroups(), + expected); +} + +TEST(OpenSSLStreamAdapterTest, GetEphemeralKeyExchangeCipherGroupName) { +#ifdef SSL_GROUP_SECP224R1 + EXPECT_EQ(*webrtc::SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName( + SSL_GROUP_SECP224R1), + "P-224"); +#endif +#ifdef SSL_GROUP_SECP256R1 + EXPECT_EQ(*webrtc::SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName( + SSL_GROUP_SECP256R1), + "P-256"); +#endif +#ifdef SSL_GROUP_SECP384R1 + EXPECT_EQ(*webrtc::SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName( + SSL_GROUP_SECP384R1), + "P-384"); +#endif +#ifdef SSL_GROUP_SECP521R1 + EXPECT_EQ(*webrtc::SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName( + SSL_GROUP_SECP521R1), + "P-521"); +#endif +#ifdef SSL_GROUP_X25519 + EXPECT_EQ(*webrtc::SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName( + SSL_GROUP_X25519), + "X25519"); +#endif +#ifdef SSL_GROUP_X25519_MLKEM768 + EXPECT_EQ(*webrtc::SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName( + SSL_GROUP_X25519_MLKEM768), + "X25519MLKEM768"); +#endif + + EXPECT_FALSE( + webrtc::SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName(0) + .has_value()); +} + +TEST(OpenSSLStreamAdapterTest, GetDefaultEphemeralKeyExchangeCipherGroups) { + std::vector 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 + }; + EXPECT_EQ( + webrtc::SSLStreamAdapter::GetDefaultEphemeralKeyExchangeCipherGroups( + /* field_trials= */ nullptr), + expected); +} + +TEST(OpenSSLStreamAdapterTest, + GetDefaultEphemeralKeyExchangeCipherGroupsWithPQC) { + std::vector expected = { +#ifdef SSL_GROUP_X25519_MLKEM768 + SSL_GROUP_X25519_MLKEM768, +#endif +#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::test::ScopedKeyValueConfig field_trials( + "WebRTC-EnableDtlsPqc/Enabled/"); + EXPECT_EQ( + webrtc::SSLStreamAdapter::GetDefaultEphemeralKeyExchangeCipherGroups( + &field_trials), + expected); +} diff --git a/rtc_base/openssl_utility.cc b/rtc_base/openssl_utility.cc index 906127f932..9c6dcf8448 100644 --- a/rtc_base/openssl_utility.cc +++ b/rtc_base/openssl_utility.cc @@ -152,8 +152,8 @@ bool ParseCertificate(CRYPTO_BUFFER* cert_buffer, return false; } if (expiration_time) { - *expiration_time = webrtc::ASN1TimeToSec(CBS_data(¬_after), - CBS_len(¬_after), long_format); + *expiration_time = + ASN1TimeToSec(CBS_data(¬_after), CBS_len(¬_after), long_format); } // subject Name, if (!CBS_get_asn1_element(&tbs_certificate, nullptr, CBS_ASN1_SEQUENCE)) { @@ -248,9 +248,8 @@ bool LoadBuiltinSSLRootCertificates(SSL_CTX* ctx) { for (size_t i = 0; i < arraysize(kSSLCertCertificateList); i++) { const unsigned char* cert_buffer = kSSLCertCertificateList[i]; size_t cert_buffer_len = kSSLCertCertificateSizeList[i]; - X509* cert = - d2i_X509(nullptr, &cert_buffer, - webrtc::checked_cast(cert_buffer_len)); // NOLINT + X509* cert = d2i_X509(nullptr, &cert_buffer, + checked_cast(cert_buffer_len)); // NOLINT if (cert) { int return_value = X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), cert); if (return_value == 0) { diff --git a/rtc_base/openssl_utility_unittest.cc b/rtc_base/openssl_utility_unittest.cc index 1f0fcd9af0..3008147ac3 100644 --- a/rtc_base/openssl_utility_unittest.cc +++ b/rtc_base/openssl_utility_unittest.cc @@ -187,7 +187,7 @@ SSL* CreateSSLWithPeerCertificate(const unsigned char* cert, size_t cert_len) { const unsigned char* key_ptr = kFakeSSLPrivateKey; EVP_PKEY* key = d2i_PrivateKey( EVP_PKEY_EC, nullptr, &key_ptr, - webrtc::checked_cast(arraysize(kFakeSSLPrivateKey))); // NOLINT + checked_cast(arraysize(kFakeSSLPrivateKey))); // NOLINT RTC_CHECK(key); #ifdef OPENSSL_IS_BORINGSSL diff --git a/rtc_base/operations_chain_unittest.cc b/rtc_base/operations_chain_unittest.cc index ed5cd40e18..9f7ce22758 100644 --- a/rtc_base/operations_chain_unittest.cc +++ b/rtc_base/operations_chain_unittest.cc @@ -415,10 +415,9 @@ TEST(OperationsChainTest, OnChainEmptyCallback) { // Completing the operation empties the chain, invoking the callback. unblock_async_operation_event0.Set(); async_operation_completed_event0->Wait(Event::kForever); - EXPECT_THAT( - webrtc::WaitUntil([&] { return on_empty_callback_counter == 1u; }, + EXPECT_THAT(WaitUntil([&] { return on_empty_callback_counter == 1u; }, ::testing::IsTrue(), {.timeout = kDefaultTimeout}), - webrtc::IsRtcOk()); + IsRtcOk()); // Chain multiple events. Event unblock_async_operation_event1; @@ -430,25 +429,22 @@ TEST(OperationsChainTest, OnChainEmptyCallback) { operation_tracker_proxy.PostAsynchronousOperation( &unblock_async_operation_event2); // Again, the callback is not invoked until the operation has completed. - EXPECT_THAT( - webrtc::WaitUntil([&] { return on_empty_callback_counter == 1u; }, + EXPECT_THAT(WaitUntil([&] { return on_empty_callback_counter == 1u; }, ::testing::IsTrue(), {.timeout = kDefaultTimeout}), - webrtc::IsRtcOk()); + IsRtcOk()); // Upon completing the first event, the chain is still not empty, so the // callback must not be invoked yet. unblock_async_operation_event1.Set(); async_operation_completed_event1->Wait(Event::kForever); - EXPECT_THAT( - webrtc::WaitUntil([&] { return on_empty_callback_counter == 1u; }, + EXPECT_THAT(WaitUntil([&] { return on_empty_callback_counter == 1u; }, ::testing::IsTrue(), {.timeout = kDefaultTimeout}), - webrtc::IsRtcOk()); + IsRtcOk()); // Completing the last event empties the chain, invoking the callback. unblock_async_operation_event2.Set(); async_operation_completed_event2->Wait(Event::kForever); - EXPECT_THAT( - webrtc::WaitUntil([&] { return on_empty_callback_counter == 2u; }, + EXPECT_THAT(WaitUntil([&] { return on_empty_callback_counter == 2u; }, ::testing::IsTrue(), {.timeout = kDefaultTimeout}), - webrtc::IsRtcOk()); + IsRtcOk()); } TEST(OperationsChainTest, diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc index e69311b790..b18052a0a7 100644 --- a/rtc_base/physical_socket_server.cc +++ b/rtc_base/physical_socket_server.cc @@ -204,7 +204,7 @@ SocketAddress PhysicalSocket::GetLocalAddress() const { int result = ::getsockname(s_, addr, &addrlen); SocketAddress address; if (result >= 0) { - webrtc::SocketAddressFromSockAddrStorage(addr_storage, &address); + SocketAddressFromSockAddrStorage(addr_storage, &address); } else { RTC_LOG(LS_WARNING) << "GetLocalAddress: unable to get local addr, socket=" << s_; @@ -219,7 +219,7 @@ SocketAddress PhysicalSocket::GetRemoteAddress() const { int result = ::getpeername(s_, addr, &addrlen); SocketAddress address; if (result >= 0) { - webrtc::SocketAddressFromSockAddrStorage(addr_storage, &address); + SocketAddressFromSockAddrStorage(addr_storage, &address); } else { RTC_LOG(LS_WARNING) << "GetRemoteAddress: unable to get remote addr, socket=" << s_; @@ -239,8 +239,7 @@ int PhysicalSocket::Bind(const SocketAddress& bind_addr) { // Since the network binder handled binding the socket to the desired // network interface, we don't need to (and shouldn't) include an IP in // the bind() call; bind() just needs to assign a port. - copied_bind_addr.SetIP( - webrtc::GetAnyIP(copied_bind_addr.ipaddr().family())); + copied_bind_addr.SetIP(GetAnyIP(copied_bind_addr.ipaddr().family())); } else if (result == NetworkBindingResult::NOT_IMPLEMENTED) { RTC_LOG(LS_INFO) << "Can't bind socket to network because " "network binding is not implemented for this OS."; @@ -305,7 +304,7 @@ int PhysicalSocket::DoConnect(const SocketAddress& connect_addr) { uint8_t events = DE_READ | DE_WRITE; if (err == 0) { state_ = CS_CONNECTED; - } else if (webrtc::IsBlockingError(GetError())) { + } else if (IsBlockingError(GetError())) { state_ = CS_CONNECTING; events |= DE_CONNECT; } else { @@ -417,7 +416,7 @@ int PhysicalSocket::Send(const void* pv, size_t cb) { // We have seen minidumps where this may be false. RTC_DCHECK(sent <= static_cast(cb)); if ((sent > 0 && sent < static_cast(cb)) || - (sent < 0 && webrtc::IsBlockingError(GetError()))) { + (sent < 0 && IsBlockingError(GetError()))) { EnableEvents(DE_WRITE); } return sent; @@ -442,7 +441,7 @@ int PhysicalSocket::SendTo(const void* buffer, // We have seen minidumps where this may be false. RTC_DCHECK(sent <= static_cast(length)); if ((sent > 0 && sent < static_cast(length)) || - (sent < 0 && webrtc::IsBlockingError(GetError()))) { + (sent < 0 && IsBlockingError(GetError()))) { EnableEvents(DE_WRITE); } return sent; @@ -465,7 +464,7 @@ int PhysicalSocket::Recv(void* buffer, size_t length, int64_t* timestamp) { UpdateLastError(); int error = GetError(); - bool success = (received >= 0) || webrtc::IsBlockingError(error); + bool success = (received >= 0) || IsBlockingError(error); if (udp_ || success) { EnableEvents(DE_READ); } @@ -483,7 +482,7 @@ int PhysicalSocket::RecvFrom(void* buffer, UpdateLastError(); int error = GetError(); - bool success = (received >= 0) || webrtc::IsBlockingError(error); + bool success = (received >= 0) || IsBlockingError(error); if (udp_ || success) { EnableEvents(DE_READ); } @@ -507,7 +506,7 @@ int PhysicalSocket::RecvFrom(ReceiveBuffer& buffer) { } UpdateLastError(); int error = GetError(); - bool success = (received >= 0) || webrtc::IsBlockingError(error); + bool success = (received >= 0) || IsBlockingError(error); if (udp_ || success) { EnableEvents(DE_READ); } @@ -569,7 +568,7 @@ int PhysicalSocket::DoReadFromSocket(void* buffer, } } if (out_addr) { - webrtc::SocketAddressFromSockAddrStorage(addr_storage, out_addr); + SocketAddressFromSockAddrStorage(addr_storage, out_addr); } return received; @@ -616,7 +615,7 @@ Socket* PhysicalSocket::Accept(SocketAddress* out_addr) { if (s == INVALID_SOCKET) return nullptr; if (out_addr != nullptr) - webrtc::SocketAddressFromSockAddrStorage(addr_storage, out_addr); + SocketAddressFromSockAddrStorage(addr_storage, out_addr); return ss_->WrapSocket(s); } @@ -1901,7 +1900,7 @@ bool PhysicalSocketServer::Wait(webrtc::TimeDelta max_wait_duration, bool process_io) { // We don't support reentrant waiting. RTC_DCHECK(!waiting_); - ScopedSetTrue s(&waiting_); + ScopedSetTrue set(&waiting_); int cmsWait = ToCmsWait(max_wait_duration); int64_t cmsTotal = cmsWait; diff --git a/rtc_base/physical_socket_server_unittest.cc b/rtc_base/physical_socket_server_unittest.cc index ac1743e0f9..56ec60903a 100644 --- a/rtc_base/physical_socket_server_unittest.cc +++ b/rtc_base/physical_socket_server_unittest.cc @@ -208,13 +208,13 @@ void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { server_.CreateSocket(loopback.family(), SOCK_STREAM)); sink.Monitor(client1.get()); EXPECT_EQ(Socket::CS_CLOSED, client1->GetState()); - EXPECT_TRUE(webrtc::IsUnspecOrEmptyIP(client1->GetLocalAddress().ipaddr())); + EXPECT_TRUE(IsUnspecOrEmptyIP(client1->GetLocalAddress().ipaddr())); std::unique_ptr client2( server_.CreateSocket(loopback.family(), SOCK_STREAM)); sink.Monitor(client2.get()); EXPECT_EQ(Socket::CS_CLOSED, client2->GetState()); - EXPECT_TRUE(webrtc::IsUnspecOrEmptyIP(client2->GetLocalAddress().ipaddr())); + EXPECT_TRUE(IsUnspecOrEmptyIP(client2->GetLocalAddress().ipaddr())); // Create server and listen. std::unique_ptr server( @@ -225,7 +225,7 @@ void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { EXPECT_EQ(Socket::CS_CONNECTING, server->GetState()); // Ensure no pending server connections, since we haven't done anything yet. - EXPECT_FALSE(sink.Check(server.get(), webrtc::testing::SSE_READ)); + EXPECT_FALSE(sink.Check(server.get(), testing::SSE_READ)); EXPECT_TRUE(nullptr == server->Accept(&accept_addr)); EXPECT_TRUE(accept_addr.IsNil()); @@ -236,15 +236,14 @@ void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { // Client is connecting, outcome not yet determined. EXPECT_EQ(Socket::CS_CONNECTING, client1->GetState()); - EXPECT_FALSE(sink.Check(client1.get(), webrtc::testing::SSE_OPEN)); - EXPECT_FALSE(sink.Check(client1.get(), webrtc::testing::SSE_CLOSE)); + EXPECT_FALSE(sink.Check(client1.get(), testing::SSE_OPEN)); + EXPECT_FALSE(sink.Check(client1.get(), testing::SSE_CLOSE)); // Server has pending connection, try to accept it (will fail). EXPECT_THAT( - webrtc::WaitUntil( - [&] { return (sink.Check(server.get(), webrtc::testing::SSE_READ)); }, - ::testing::IsTrue()), - webrtc::IsRtcOk()); + WaitUntil([&] { return (sink.Check(server.get(), testing::SSE_READ)); }, + ::testing::IsTrue()), + IsRtcOk()); // Simulate "::accept" returning an error. SetFailAccept(true); std::unique_ptr accepted(server->Accept(&accept_addr)); @@ -252,7 +251,7 @@ void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { ASSERT_TRUE(accept_addr.IsNil()); // Ensure no more pending server connections. - EXPECT_FALSE(sink.Check(server.get(), webrtc::testing::SSE_READ)); + EXPECT_FALSE(sink.Check(server.get(), testing::SSE_READ)); EXPECT_TRUE(nullptr == server->Accept(&accept_addr)); EXPECT_TRUE(accept_addr.IsNil()); @@ -263,15 +262,14 @@ void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { // Client is connecting, outcome not yet determined. EXPECT_EQ(Socket::CS_CONNECTING, client2->GetState()); - EXPECT_FALSE(sink.Check(client2.get(), webrtc::testing::SSE_OPEN)); - EXPECT_FALSE(sink.Check(client2.get(), webrtc::testing::SSE_CLOSE)); + EXPECT_FALSE(sink.Check(client2.get(), testing::SSE_OPEN)); + EXPECT_FALSE(sink.Check(client2.get(), testing::SSE_CLOSE)); // Server has pending connection, try to accept it (will succeed). EXPECT_THAT( - webrtc::WaitUntil( - [&] { return (sink.Check(server.get(), webrtc::testing::SSE_READ)); }, - ::testing::IsTrue()), - webrtc::IsRtcOk()); + WaitUntil([&] { return (sink.Check(server.get(), testing::SSE_READ)); }, + ::testing::IsTrue()), + IsRtcOk()); SetFailAccept(false); std::unique_ptr accepted2(server->Accept(&accept_addr)); ASSERT_TRUE(accepted2); diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc index 53381a4d4e..7f11696b21 100644 --- a/rtc_base/platform_thread.cc +++ b/rtc_base/platform_thread.cc @@ -108,7 +108,7 @@ void* RunPlatformThread(void* param) { auto function = static_cast*>(param); (*function)(); delete function; - return 0; + return nullptr; } #endif // defined(WEBRTC_WIN) diff --git a/rtc_base/platform_thread_unittest.cc b/rtc_base/platform_thread_unittest.cc index b25e06a67f..921138de22 100644 --- a/rtc_base/platform_thread_unittest.cc +++ b/rtc_base/platform_thread_unittest.cc @@ -13,7 +13,6 @@ #include #include "rtc_base/event.h" -#include "system_wrappers/include/sleep.h" #include "test/gmock.h" namespace webrtc { diff --git a/rtc_base/random.cc b/rtc_base/random.cc index 55b8749cb7..28e48f0d3d 100644 --- a/rtc_base/random.cc +++ b/rtc_base/random.cc @@ -11,6 +11,8 @@ #include +#include + #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" @@ -71,7 +73,7 @@ double Random::Gaussian(double mean, double standard_deviation) { // interval (0, 1]. Note that we rely on NextOutput to generate integers // in the range [1, 2^64-1]. Normally this behavior is a bit frustrating, // but here it is exactly what we need. - const double kPi = 3.14159265358979323846; + const double kPi = std::numbers::pi; double u1 = static_cast(NextOutput()) / static_cast(0xFFFFFFFFFFFFFFFFull); double u2 = static_cast(NextOutput()) / diff --git a/rtc_base/random_unittest.cc b/rtc_base/random_unittest.cc index 4eb6f754eb..ffcd3ed72a 100644 --- a/rtc_base/random_unittest.cc +++ b/rtc_base/random_unittest.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include "rtc_base/numerics/math_utils.h" // unsigned difference @@ -286,7 +287,7 @@ TEST(RandomNumberGeneratorTest, Gaussian) { } } - const double kPi = 3.14159265358979323846; + const double kPi = std::numbers::pi; const double kScale = 1 / (kStddev * sqrt(2.0 * kPi)); const double kDiv = -2.0 * kStddev * kStddev; for (int n = 0; n < kBuckets; ++n) { diff --git a/rtc_base/rate_tracker.cc b/rtc_base/rate_tracker.cc index 83481c196d..f6f4cf32b9 100644 --- a/rtc_base/rate_tracker.cc +++ b/rtc_base/rate_tracker.cc @@ -64,7 +64,7 @@ double RateTracker::ComputeRateForInterval( buckets_to_skip = bucket_count_ - current_bucket_; milliseconds_to_skip = 0; available_interval_milliseconds = - webrtc::TimeDiff(current_time, initialization_time_milliseconds_); + TimeDiff(current_time, initialization_time_milliseconds_); // Let one bucket interval pass after initialization before reporting. if (available_interval_milliseconds < bucket_milliseconds_) { return 0.0; @@ -102,7 +102,7 @@ double RateTracker::ComputeTotalRate() const { } return static_cast(total_sample_count_ * 1000) / static_cast( - webrtc::TimeDiff(current_time, initialization_time_milliseconds_)); + TimeDiff(current_time, initialization_time_milliseconds_)); } int64_t RateTracker::TotalSampleCount() const { @@ -139,7 +139,7 @@ void RateTracker::AddSamplesAtTime(int64_t current_time_ms, } int64_t RateTracker::Time() const { - return webrtc::TimeMillis(); + return TimeMillis(); } void RateTracker::EnsureInitialized() { diff --git a/rtc_base/rtc_certificate_generator_unittest.cc b/rtc_base/rtc_certificate_generator_unittest.cc index a4388f566f..06bb5812e4 100644 --- a/rtc_base/rtc_certificate_generator_unittest.cc +++ b/rtc_base/rtc_certificate_generator_unittest.cc @@ -97,10 +97,9 @@ TEST_F(RTCCertificateGeneratorTest, GenerateAsyncECDSA) { // posted to this thread (which is done by `EXPECT_TRUE_WAIT`). EXPECT_FALSE(fixture_.GenerateAsyncCompleted()); EXPECT_FALSE(fixture_.certificate()); - EXPECT_THAT( - webrtc::WaitUntil([&] { return fixture_.GenerateAsyncCompleted(); }, + EXPECT_THAT(WaitUntil([&] { return fixture_.GenerateAsyncCompleted(); }, ::testing::IsTrue(), {.timeout = kGenerationTimeoutMs}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_TRUE(fixture_.certificate()); } @@ -140,10 +139,9 @@ TEST_F(RTCCertificateGeneratorTest, GenerateWithInvalidParamsShouldFail) { fixture_.generator()->GenerateCertificateAsync(invalid_params, std::nullopt, fixture_.OnGenerated()); - EXPECT_THAT( - webrtc::WaitUntil([&] { return fixture_.GenerateAsyncCompleted(); }, + EXPECT_THAT(WaitUntil([&] { return fixture_.GenerateAsyncCompleted(); }, ::testing::IsTrue(), {.timeout = kGenerationTimeoutMs}), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_FALSE(fixture_.certificate()); } diff --git a/rtc_base/rtc_certificate_unittest.cc b/rtc_base/rtc_certificate_unittest.cc index 67f7e2cb3a..5233a80d27 100644 --- a/rtc_base/rtc_certificate_unittest.cc +++ b/rtc_base/rtc_certificate_unittest.cc @@ -68,7 +68,7 @@ class RTCCertificateTest : public ::testing::Test { // or later. scoped_refptr GenerateCertificateWithExpires( uint64_t expires_s) const { - RTC_CHECK(webrtc::IsValueInRangeForNumericType(expires_s)); + RTC_CHECK(IsValueInRangeForNumericType(expires_s)); SSLIdentityParams params; params.common_name = kTestCertCommonName; diff --git a/system_wrappers/source/rtp_to_ntp_estimator.cc b/rtc_base/rtp_to_ntp_estimator.cc similarity index 96% rename from system_wrappers/source/rtp_to_ntp_estimator.cc rename to rtc_base/rtp_to_ntp_estimator.cc index 549967c0da..d5f41f2f83 100644 --- a/system_wrappers/source/rtp_to_ntp_estimator.cc +++ b/rtc_base/rtp_to_ntp_estimator.cc @@ -8,17 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/include/rtp_to_ntp_estimator.h" - -#include +#include "rtc_base/rtp_to_ntp_estimator.h" #include -#include +#include +#include +#include -#include "api/array_view.h" -#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" +#include "system_wrappers/include/ntp_time.h" namespace webrtc { namespace { diff --git a/system_wrappers/include/rtp_to_ntp_estimator.h b/rtc_base/rtp_to_ntp_estimator.h similarity index 90% rename from system_wrappers/include/rtp_to_ntp_estimator.h rename to rtc_base/rtp_to_ntp_estimator.h index 2f3698176f..a279def51f 100644 --- a/system_wrappers/include/rtp_to_ntp_estimator.h +++ b/rtc_base/rtp_to_ntp_estimator.h @@ -8,15 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_ESTIMATOR_H_ -#define SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_ESTIMATOR_H_ - -#include +#ifndef RTC_BASE_RTP_TO_NTP_ESTIMATOR_H_ +#define RTC_BASE_RTP_TO_NTP_ESTIMATOR_H_ +#include #include #include -#include "rtc_base/checks.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" #include "system_wrappers/include/ntp_time.h" @@ -69,4 +67,4 @@ class RtpToNtpEstimator { }; } // namespace webrtc -#endif // SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_ESTIMATOR_H_ +#endif // RTC_BASE_RTP_TO_NTP_ESTIMATOR_H_ diff --git a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc b/rtc_base/rtp_to_ntp_estimator_unittest.cc similarity index 98% rename from system_wrappers/source/rtp_to_ntp_estimator_unittest.cc rename to rtc_base/rtp_to_ntp_estimator_unittest.cc index 81effd9452..e74624dc8c 100644 --- a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc +++ b/rtc_base/rtp_to_ntp_estimator_unittest.cc @@ -8,11 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/include/rtp_to_ntp_estimator.h" +#include "rtc_base/rtp_to_ntp_estimator.h" -#include +#include +#include #include "rtc_base/random.h" +#include "system_wrappers/include/ntp_time.h" #include "test/gtest.h" namespace webrtc { diff --git a/rtc_base/socket_address.cc b/rtc_base/socket_address.cc index 1e7d9418b8..7c08bf42ef 100644 --- a/rtc_base/socket_address.cc +++ b/rtc_base/socket_address.cc @@ -65,11 +65,11 @@ void SocketAddress::Clear() { } bool SocketAddress::IsNil() const { - return hostname_.empty() && webrtc::IPIsUnspec(ip_) && 0 == port_; + return hostname_.empty() && IPIsUnspec(ip_) && 0 == port_; } bool SocketAddress::IsComplete() const { - return (!webrtc::IPIsAny(ip_)) && (0 != port_); + return (!IPIsAny(ip_)) && (0 != port_); } SocketAddress& SocketAddress::operator=(const SocketAddress& addr) { @@ -97,7 +97,7 @@ void SocketAddress::SetIP(const IPAddress& ip) { void SocketAddress::SetIP(absl::string_view hostname) { hostname_ = std::string(hostname); - literal_ = webrtc::IPFromString(hostname, &ip_); + literal_ = IPFromString(hostname, &ip_); if (!literal_) { ip_ = IPAddress(); } @@ -115,7 +115,7 @@ void SocketAddress::SetResolvedIP(const IPAddress& ip) { } void SocketAddress::SetPort(int port) { - port_ = webrtc::dchecked_cast(port); + port_ = dchecked_cast(port); } uint32_t SocketAddress::ip() const { @@ -214,20 +214,20 @@ bool SocketAddress::FromString(absl::string_view str) { } bool SocketAddress::IsAnyIP() const { - return webrtc::IPIsAny(ip_); + return IPIsAny(ip_); } bool SocketAddress::IsLoopbackIP() const { - return webrtc::IPIsLoopback(ip_) || - (webrtc::IPIsAny(ip_) && 0 == strcmp(hostname_.c_str(), "localhost")); + return IPIsLoopback(ip_) || + (IPIsAny(ip_) && 0 == strcmp(hostname_.c_str(), "localhost")); } bool SocketAddress::IsPrivateIP() const { - return webrtc::IPIsPrivate(ip_); + return IPIsPrivate(ip_); } bool SocketAddress::IsUnresolvedIP() const { - return webrtc::IPIsUnspec(ip_) && !literal_ && !hostname_.empty(); + return IPIsUnspec(ip_) && !literal_ && !hostname_.empty(); } bool SocketAddress::operator==(const SocketAddress& addr) const { @@ -240,8 +240,7 @@ bool SocketAddress::operator<(const SocketAddress& addr) const { // We only check hostnames if both IPs are ANY or unspecified. This matches // EqualIPs(). - if ((webrtc::IPIsAny(ip_) || webrtc::IPIsUnspec(ip_)) && - hostname_ != addr.hostname_) + if ((IPIsAny(ip_) || IPIsUnspec(ip_)) && hostname_ != addr.hostname_) return hostname_ < addr.hostname_; return port_ < addr.port_; @@ -249,8 +248,7 @@ bool SocketAddress::operator<(const SocketAddress& addr) const { bool SocketAddress::EqualIPs(const SocketAddress& addr) const { return (ip_ == addr.ip_) && - ((!webrtc::IPIsAny(ip_) && !webrtc::IPIsUnspec(ip_)) || - (hostname_ == addr.hostname_)); + ((!IPIsAny(ip_) && !IPIsUnspec(ip_)) || (hostname_ == addr.hostname_)); } bool SocketAddress::EqualPorts(const SocketAddress& addr) const { @@ -259,7 +257,7 @@ bool SocketAddress::EqualPorts(const SocketAddress& addr) const { size_t SocketAddress::Hash() const { size_t h = 0; - h ^= webrtc::HashIP(ip_); + h ^= HashIP(ip_); h ^= port_ | (port_ << 16); return h; } @@ -271,8 +269,8 @@ void SocketAddress::ToSockAddr(sockaddr_in* saddr) const { return; } saddr->sin_family = AF_INET; - saddr->sin_port = webrtc::HostToNetwork16(port_); - if (webrtc::IPIsAny(ip_)) { + saddr->sin_port = HostToNetwork16(port_); + if (IPIsAny(ip_)) { saddr->sin_addr.s_addr = INADDR_ANY; } else { saddr->sin_addr = ip_.ipv4_address(); @@ -282,8 +280,8 @@ void SocketAddress::ToSockAddr(sockaddr_in* saddr) const { bool SocketAddress::FromSockAddr(const sockaddr_in& saddr) { if (saddr.sin_family != AF_INET) return false; - SetIP(webrtc::NetworkToHost32(saddr.sin_addr.s_addr)); - SetPort(webrtc::NetworkToHost16(saddr.sin_port)); + SetIP(NetworkToHost32(saddr.sin_addr.s_addr)); + SetPort(NetworkToHost16(saddr.sin_port)); literal_ = false; return true; } @@ -297,13 +295,13 @@ static size_t ToSockAddrStorageHelper(sockaddr_storage* addr, if (addr->ss_family == AF_INET6) { sockaddr_in6* saddr = reinterpret_cast(addr); saddr->sin6_addr = ip.ipv6_address(); - saddr->sin6_port = webrtc::HostToNetwork16(port); + saddr->sin6_port = HostToNetwork16(port); saddr->sin6_scope_id = scope_id; return sizeof(sockaddr_in6); } else if (addr->ss_family == AF_INET) { sockaddr_in* saddr = reinterpret_cast(addr); saddr->sin_addr = ip.ipv4_address(); - saddr->sin_port = webrtc::HostToNetwork16(port); + saddr->sin_port = HostToNetwork16(port); return sizeof(sockaddr_in); } return 0; @@ -325,12 +323,12 @@ bool SocketAddressFromSockAddrStorage(const sockaddr_storage& addr, if (addr.ss_family == AF_INET) { const sockaddr_in* saddr = reinterpret_cast(&addr); *out = SocketAddress(IPAddress(saddr->sin_addr), - webrtc::NetworkToHost16(saddr->sin_port)); + NetworkToHost16(saddr->sin_port)); return true; } else if (addr.ss_family == AF_INET6) { const sockaddr_in6* saddr = reinterpret_cast(&addr); *out = SocketAddress(IPAddress(saddr->sin6_addr), - webrtc::NetworkToHost16(saddr->sin6_port)); + NetworkToHost16(saddr->sin6_port)); out->SetScopeID(saddr->sin6_scope_id); return true; } diff --git a/rtc_base/socket_unittest.cc b/rtc_base/socket_unittest.cc index c7fd137505..4f5d219a4f 100644 --- a/rtc_base/socket_unittest.cc +++ b/rtc_base/socket_unittest.cc @@ -52,12 +52,12 @@ namespace webrtc { -using webrtc::testing::SSE_CLOSE; -using webrtc::testing::SSE_ERROR; -using webrtc::testing::SSE_OPEN; -using webrtc::testing::SSE_READ; -using webrtc::testing::SSE_WRITE; -using webrtc::testing::StreamSink; +using testing::SSE_CLOSE; +using testing::SSE_ERROR; +using testing::SSE_OPEN; +using testing::SSE_READ; +using testing::SSE_WRITE; +using testing::StreamSink; // Data size to be used in TcpInternal tests. static const size_t kTcpInternalDataSize = 1024 * 1024; // bytes @@ -253,7 +253,7 @@ void SocketTest::TestSocketSendRecvWithEcnIPV6() { // values on Windows, but an empty address of the same family on Linux/MacOS X. bool IsUnspecOrEmptyIP(const IPAddress& address) { #if !defined(WEBRTC_WIN) - return webrtc::IPIsAny(address); + return IPIsAny(address); #else return address.family() == AF_UNSPEC; #endif @@ -294,10 +294,9 @@ void SocketTest::ConnectInternal(const IPAddress& loopback) { EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); // Server has pending connection, accept it. - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(accepted); EXPECT_FALSE(accept_addr.IsNil()); @@ -309,9 +308,9 @@ void SocketTest::ConnectInternal(const IPAddress& loopback) { EXPECT_EQ(client->GetLocalAddress(), accepted->GetRemoteAddress()); // Connected from client perspective, check the addresses are correct. - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_OPEN)); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); EXPECT_EQ(client->GetRemoteAddress(), server->GetLocalAddress()); @@ -348,10 +347,9 @@ void SocketTest::ConnectWithDnsLookupInternal(const IPAddress& loopback, EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); // Server has pending connection, accept it. - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(accepted); EXPECT_FALSE(accept_addr.IsNil()); @@ -363,9 +361,9 @@ void SocketTest::ConnectWithDnsLookupInternal(const IPAddress& loopback, EXPECT_EQ(client->GetLocalAddress(), accepted->GetRemoteAddress()); // Connected from client perspective, check the addresses are correct. - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_OPEN)); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); EXPECT_EQ(client->GetRemoteAddress(), server->GetLocalAddress()); @@ -394,9 +392,9 @@ void SocketTest::ConnectFailInternal(const IPAddress& loopback) { EXPECT_EQ(0, client->Connect(bogus_addr)); // Wait for connection to fail (ECONNREFUSED). - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CLOSED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CLOSED)), + IsRtcOk()); EXPECT_FALSE(sink.Check(client.get(), SSE_OPEN)); EXPECT_TRUE(sink.Check(client.get(), SSE_ERROR)); EXPECT_TRUE(client->GetRemoteAddress().IsNil()); @@ -437,9 +435,9 @@ void SocketTest::ConnectWithDnsLookupFailInternal(const IPAddress& loopback) { return; } - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CLOSED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CLOSED)), + IsRtcOk()); EXPECT_FALSE(sink.Check(client.get(), SSE_OPEN)); EXPECT_TRUE(sink.Check(client.get(), SSE_ERROR)); EXPECT_TRUE(client->GetRemoteAddress().IsNil()); @@ -486,10 +484,9 @@ void SocketTest::ConnectWhileNotClosedInternal(const IPAddress& loopback) { // Accept the original connection. SocketAddress accept_addr; - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(accepted); EXPECT_FALSE(accept_addr.IsNil()); @@ -498,9 +495,9 @@ void SocketTest::ConnectWhileNotClosedInternal(const IPAddress& loopback) { EXPECT_EQ(Socket::CS_CONNECTED, accepted->GetState()); EXPECT_EQ(server->GetLocalAddress(), accepted->GetLocalAddress()); EXPECT_EQ(client->GetLocalAddress(), accepted->GetRemoteAddress()); - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_EQ(client->GetRemoteAddress(), server->GetLocalAddress()); EXPECT_EQ(client->GetRemoteAddress(), accepted->GetLocalAddress()); @@ -533,16 +530,15 @@ void SocketTest::ServerCloseDuringConnectInternal(const IPAddress& loopback) { EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); // Close down the server while the socket is in the accept queue. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(server.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(server.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); server->Close(); // This should fail the connection for the client. Clean up. - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CLOSED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CLOSED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_ERROR)); client->Close(); } @@ -567,10 +563,9 @@ void SocketTest::ClientCloseDuringConnectInternal(const IPAddress& loopback) { EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); // Close down the client while the socket is in the accept queue. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(server.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(server.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); client->Close(); // The connection should still be able to be accepted. @@ -580,9 +575,9 @@ void SocketTest::ClientCloseDuringConnectInternal(const IPAddress& loopback) { EXPECT_EQ(Socket::CS_CONNECTED, accepted->GetState()); // The accepted socket should then close (possibly with err, timing-related) - EXPECT_THAT(webrtc::WaitUntil([&] { return accepted->GetState(); }, - ::testing::Eq(Socket::CS_CLOSED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return accepted->GetState(); }, + ::testing::Eq(Socket::CS_CLOSED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(accepted.get(), SSE_CLOSE) || sink.Check(accepted.get(), SSE_ERROR)); @@ -610,18 +605,17 @@ void SocketTest::ServerCloseInternal(const IPAddress& loopback) { EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); // Accept connection. - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(accepted); sink.Monitor(accepted.get()); // Both sides are now connected. - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_OPEN)); EXPECT_EQ(client->GetRemoteAddress(), accepted->GetLocalAddress()); EXPECT_EQ(accepted->GetRemoteAddress(), client->GetLocalAddress()); @@ -632,10 +626,9 @@ void SocketTest::ServerCloseInternal(const IPAddress& loopback) { EXPECT_EQ(Socket::CS_CLOSED, accepted->GetState()); // Expect that the client is notified, and has not yet closed. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(client.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(client.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); EXPECT_EQ(Socket::CS_CONNECTED, client->GetState()); @@ -645,9 +638,9 @@ void SocketTest::ServerCloseInternal(const IPAddress& loopback) { EXPECT_EQ('a', buffer[0]); // Now we should close, but the remote address will remain. - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CLOSED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CLOSED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_CLOSE)); EXPECT_FALSE(client->GetRemoteAddress().IsAnyIP()); @@ -695,18 +688,17 @@ void SocketTest::CloseInClosedCallbackInternal(const IPAddress& loopback) { EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); // Accept connection. - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(accepted); sink.Monitor(accepted.get()); // Both sides are now connected. - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_OPEN)); EXPECT_EQ(client->GetRemoteAddress(), accepted->GetLocalAddress()); EXPECT_EQ(accepted->GetRemoteAddress(), client->GetLocalAddress()); @@ -720,9 +712,9 @@ void SocketTest::CloseInClosedCallbackInternal(const IPAddress& loopback) { EXPECT_EQ(Socket::CS_CONNECTED, client->GetState()); // Now we should be closed and invalidated - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CLOSED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CLOSED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_CLOSE)); EXPECT_TRUE(Socket::CS_CLOSED == client->GetState()); } @@ -760,9 +752,8 @@ void SocketTest::DeleteInReadCallbackInternal(const IPAddress& loopback) { // event. SocketDeleter deleter(std::move(socket2)); socket1->SignalReadEvent.connect(&deleter, &SocketDeleter::Delete); - EXPECT_THAT( - webrtc::WaitUntil([&] { return deleter.deleted(); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return deleter.deleted(); }, ::testing::IsTrue()), + IsRtcOk()); } void SocketTest::SocketServerWaitInternal(const IPAddress& loopback) { @@ -780,10 +771,9 @@ void SocketTest::SocketServerWaitInternal(const IPAddress& loopback) { EXPECT_EQ(0, server->Listen(5)); EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(accepted); @@ -792,9 +782,9 @@ void SocketTest::SocketServerWaitInternal(const IPAddress& loopback) { EXPECT_EQ(server->GetLocalAddress(), accepted->GetLocalAddress()); EXPECT_EQ(client->GetLocalAddress(), accepted->GetRemoteAddress()); - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_OPEN)); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); EXPECT_EQ(client->GetRemoteAddress(), server->GetLocalAddress()); @@ -814,10 +804,9 @@ void SocketTest::SocketServerWaitInternal(const IPAddress& loopback) { EXPECT_FALSE(sink.Check(accepted.get(), SSE_READ)); // But should signal when process_io is true. - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(accepted.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(accepted.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); EXPECT_LT(0, accepted->Recv(buf, 1024, nullptr)); } @@ -843,18 +832,17 @@ void SocketTest::TcpInternal(const IPAddress& loopback, EXPECT_EQ(0, receiver->Connect(server->GetLocalAddress())); // Accept connection which will be used for sending. - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr sender(server->Accept(&accept_addr)); ASSERT_TRUE(sender); sink.Monitor(sender.get()); // Both sides are now connected. - EXPECT_THAT(webrtc::WaitUntil([&] { return receiver->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return receiver->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(receiver.get(), SSE_OPEN)); EXPECT_EQ(receiver->GetRemoteAddress(), sender->GetLocalAddress()); EXPECT_EQ(sender->GetRemoteAddress(), receiver->GetLocalAddress()); @@ -907,10 +895,10 @@ void SocketTest::TcpInternal(const IPAddress& loopback, while (recv_buffer.size() < sent_size) { if (!readable) { // Wait until data is available. - EXPECT_THAT(webrtc::WaitUntil( - [&] { return sink.Check(receiver.get(), SSE_READ); }, - ::testing::IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return sink.Check(receiver.get(), SSE_READ); }, + ::testing::IsTrue()), + IsRtcOk()); readable = true; recv_called = false; } @@ -939,10 +927,9 @@ void SocketTest::TcpInternal(const IPAddress& loopback, // Once all that we've sent has been received, expect to be able to send // again. if (!writable) { - ASSERT_THAT( - webrtc::WaitUntil([&] { return sink.Check(sender.get(), SSE_WRITE); }, + ASSERT_THAT(WaitUntil([&] { return sink.Check(sender.get(), SSE_WRITE); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); writable = true; send_called = false; } @@ -955,9 +942,9 @@ void SocketTest::TcpInternal(const IPAddress& loopback, // Close down. sender->Close(); - EXPECT_THAT(webrtc::WaitUntil([&] { return receiver->GetState(); }, - ::testing::Eq(Socket::CS_CLOSED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return receiver->GetState(); }, + ::testing::Eq(Socket::CS_CLOSED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(receiver.get(), SSE_CLOSE)); receiver->Close(); } @@ -982,27 +969,25 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) { EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); // Accept connection. - EXPECT_THAT( - webrtc::WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, + EXPECT_THAT(WaitUntil([&] { return (sink.Check(server.get(), SSE_READ)); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(accepted); sink.Monitor(accepted.get()); // Both sides are now connected. - EXPECT_THAT(webrtc::WaitUntil([&] { return client->GetState(); }, - ::testing::Eq(Socket::CS_CONNECTED)), - webrtc::IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return client->GetState(); }, + ::testing::Eq(Socket::CS_CONNECTED)), + IsRtcOk()); EXPECT_TRUE(sink.Check(client.get(), SSE_OPEN)); EXPECT_EQ(client->GetRemoteAddress(), accepted->GetLocalAddress()); EXPECT_EQ(accepted->GetRemoteAddress(), client->GetLocalAddress()); // Expect a writable callback from the connect. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(accepted.get(), SSE_WRITE); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(accepted.get(), SSE_WRITE); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); // Fill the socket buffer. char buf[1024 * 16] = {0}; @@ -1012,10 +997,9 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) { EXPECT_TRUE(accepted->IsBlocking()); // Wait until data is available. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(client.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(client.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); // Pull data. for (int i = 0; i < sends; ++i) { @@ -1023,10 +1007,9 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) { } // Expect at least one additional writable callback. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(accepted.get(), SSE_WRITE); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(accepted.get(), SSE_WRITE); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); // Adding data in response to the writeable callback shouldn't cause infinite // callbacks. @@ -1046,7 +1029,7 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) { } void SocketTest::UdpInternal(const IPAddress& loopback) { - SocketAddress empty = webrtc::EmptySocketAddressWithFamily(loopback.family()); + SocketAddress empty = EmptySocketAddressWithFamily(loopback.family()); // Test basic bind and connect behavior. Socket* socket = socket_factory_->CreateSocket(loopback.family(), SOCK_DGRAM); EXPECT_EQ(Socket::CS_CLOSED, socket->GetState()); @@ -1092,7 +1075,7 @@ void SocketTest::UdpInternal(const IPAddress& loopback) { } void SocketTest::UdpReadyToSend(const IPAddress& loopback) { - SocketAddress empty = webrtc::EmptySocketAddressWithFamily(loopback.family()); + SocketAddress empty = EmptySocketAddressWithFamily(loopback.family()); // RFC 5737 - The blocks 192.0.2.0/24 (TEST-NET-1) ... are provided for use in // documentation. // RFC 3849 - 2001:DB8::/32 as a documentation-only prefix. @@ -1133,9 +1116,9 @@ void SocketTest::UdpReadyToSend(const IPAddress& loopback) { } EXPECT_EQ(expected_error, error); EXPECT_FALSE(client->ready_to_send()); - EXPECT_THAT(webrtc::WaitUntil([&] { return client->ready_to_send(); }, - ::testing::IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return client->ready_to_send(); }, ::testing::IsTrue()), + IsRtcOk()); RTC_LOG(LS_INFO) << "Got SignalReadyToSend"; } @@ -1244,10 +1227,9 @@ void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) { socket->SendTo("foo", 3, address); // Wait until data is available. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); Buffer buffer; Socket::ReceiveBuffer receive_buffer_1(buffer); ASSERT_GT(socket->RecvFrom(receive_buffer_1), 0); @@ -1258,10 +1240,9 @@ void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) { int64_t send_time_2 = TimeMicros(); socket->SendTo("bar", 3, address); // Wait until data is available. - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); Socket::ReceiveBuffer receive_buffer_2(buffer); ASSERT_GT(socket->RecvFrom(receive_buffer_2), 0); @@ -1274,7 +1255,7 @@ void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) { } void SocketTest::UdpSocketRecvTimestampUseRtcEpoch(const IPAddress& loopback) { - SocketAddress empty = webrtc::EmptySocketAddressWithFamily(loopback.family()); + SocketAddress empty = EmptySocketAddressWithFamily(loopback.family()); std::unique_ptr socket( socket_factory_->CreateSocket(loopback.family(), SOCK_DGRAM)); ASSERT_EQ(socket->Bind(SocketAddress(loopback, 0)), 0); @@ -1311,10 +1292,9 @@ void SocketTest::SocketSendRecvWithEcn(const IPAddress& loopback) { Socket::ReceiveBuffer receive_buffer(buffer); socket->SendTo("foo", 3, address); - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_GT(socket->RecvFrom(receive_buffer), 0); EXPECT_EQ(receive_buffer.ecn, EcnMarking::kNotEct); @@ -1322,28 +1302,25 @@ void SocketTest::SocketSendRecvWithEcn(const IPAddress& loopback) { socket->SetOption(Socket::OPT_RECV_ECN, 1); socket->SendTo("bar", 3, address); - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_GT(socket->RecvFrom(receive_buffer), 0); EXPECT_EQ(receive_buffer.ecn, EcnMarking::kEct1); socket->SetOption(Socket::OPT_SEND_ECN, 2); // Ect(0) socket->SendTo("bar", 3, address); - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_GT(socket->RecvFrom(receive_buffer), 0); EXPECT_EQ(receive_buffer.ecn, EcnMarking::kEct0); socket->SetOption(Socket::OPT_SEND_ECN, 3); // Ce socket->SendTo("bar", 3, address); - EXPECT_THAT( - webrtc::WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, + EXPECT_THAT(WaitUntil([&] { return sink.Check(socket.get(), SSE_READ); }, ::testing::IsTrue()), - webrtc::IsRtcOk()); + IsRtcOk()); ASSERT_GT(socket->RecvFrom(receive_buffer), 0); EXPECT_EQ(receive_buffer.ecn, EcnMarking::kCe); } diff --git a/rtc_base/ssl_fingerprint.cc b/rtc_base/ssl_fingerprint.cc index daca55873d..ca15d11bda 100644 --- a/rtc_base/ssl_fingerprint.cc +++ b/rtc_base/ssl_fingerprint.cc @@ -61,7 +61,7 @@ SSLFingerprint* SSLFingerprint::CreateFromRfc4572( std::unique_ptr SSLFingerprint::CreateUniqueFromRfc4572( absl::string_view algorithm, absl::string_view fingerprint) { - if (algorithm.empty() || !webrtc::IsFips180DigestAlgorithm(algorithm)) + if (algorithm.empty() || !IsFips180DigestAlgorithm(algorithm)) return nullptr; if (fingerprint.empty()) diff --git a/rtc_base/ssl_identity.cc b/rtc_base/ssl_identity.cc index 9e16cb1ac9..35930f8fe1 100644 --- a/rtc_base/ssl_identity.cc +++ b/rtc_base/ssl_identity.cc @@ -108,7 +108,7 @@ int64_t ASN1TimeToSec(const unsigned char* s, size_t length, bool long_format) { if (bytes_left != 1) { return -1; } - return webrtc::TmToSeconds(tm); + return TmToSeconds(tm); } ////////////////////////////////////////////////////////////////////// diff --git a/rtc_base/ssl_stream_adapter.cc b/rtc_base/ssl_stream_adapter.cc index 4f74d87274..d02318bc68 100644 --- a/rtc_base/ssl_stream_adapter.cc +++ b/rtc_base/ssl_stream_adapter.cc @@ -13,8 +13,11 @@ #include #include #include +#include +#include #include #include +#include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" @@ -83,7 +86,7 @@ bool IsGcmCryptoSuite(int crypto_suite) { std::unique_ptr SSLStreamAdapter::Create( std::unique_ptr stream, - absl::AnyInvocable handshake_error, + absl::AnyInvocable handshake_error, const FieldTrialsView* field_trials) { return std::make_unique( std::move(stream), std::move(handshake_error), field_trials); @@ -100,6 +103,76 @@ bool SSLStreamAdapter::IsAcceptableCipher(absl::string_view cipher, return OpenSSLStreamAdapter::IsAcceptableCipher(cipher, key_type); } +std::optional +SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName(uint16_t group_id) { +#if defined(OPENSSL_IS_BORINGSSL) + auto val = SSL_get_group_name(group_id); + if (val != nullptr) { + return std::string(val); + } +#endif + return std::nullopt; +} + +std::set +SSLStreamAdapter::GetSupportedEphemeralKeyExchangeCipherGroups() { + return { + // It would be nice if BoringSSL had a function like this! +#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 + }; +} + +std::vector +SSLStreamAdapter::GetDefaultEphemeralKeyExchangeCipherGroups( + const FieldTrialsView* field_trials) { + // It would be nice if BoringSSL had a function like this! + // from boringssl/src/ssl/extensions.cc kDefaultGroups. + if (field_trials && field_trials->IsEnabled("WebRTC-EnableDtlsPqc")) { + return { +#ifdef SSL_GROUP_X25519_MLKEM768 + SSL_GROUP_X25519_MLKEM768, +#endif +#ifdef SSL_GROUP_X25519 + SSL_GROUP_X25519, +#endif +#ifdef SSL_GROUP_SECP256R1 + SSL_GROUP_SECP256R1, +#endif +#ifdef SSL_GROUP_SECP384R1 + SSL_GROUP_SECP384R1, +#endif + }; + } + return { +#ifdef SSL_GROUP_X25519 + SSL_GROUP_X25519, +#endif +#ifdef SSL_GROUP_SECP256R1 + SSL_GROUP_SECP256R1, +#endif +#ifdef SSL_GROUP_SECP384R1 + SSL_GROUP_SECP384R1, +#endif + }; +} + // Default shim for backward compat. bool SSLStreamAdapter::SetPeerCertificateDigest( absl::string_view digest_alg, diff --git a/rtc_base/ssl_stream_adapter.h b/rtc_base/ssl_stream_adapter.h index bc62f8eacb..f8f817337a 100644 --- a/rtc_base/ssl_stream_adapter.h +++ b/rtc_base/ssl_stream_adapter.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -244,6 +245,12 @@ class SSLStreamAdapter : public StreamInterface { static bool IsAcceptableCipher(int cipher, KeyType key_type); static bool IsAcceptableCipher(absl::string_view cipher, KeyType key_type); + static std::set GetSupportedEphemeralKeyExchangeCipherGroups(); + static std::optional GetEphemeralKeyExchangeCipherGroupName( + uint16_t); + static std::vector GetDefaultEphemeralKeyExchangeCipherGroups( + const FieldTrialsView* field_trials); + //////////////////////////////////////////////////////////////////////////// // Testing only member functions //////////////////////////////////////////////////////////////////////////// @@ -270,9 +277,13 @@ class SSLStreamAdapter : public StreamInterface { // Used for testing (and maybe put into stats?). virtual int GetRetransmissionCount() const = 0; + // Set cipher group ids to use during DTLS handshake to establish ephemeral + // key, see CryptoOptions::EphemeralKeyExchangeCipherGroups. + virtual bool SetSslGroupIds(const std::vector& group_ids) = 0; + // Return the the ID of the group used by the adapters most recently // completed handshake, or 0 if not applicable (e.g. before the handshake). - virtual uint16_t GetSslGroupIdForTesting() const = 0; + virtual uint16_t GetSslGroupId() const = 0; private: // If true (default), the client is required to provide a certificate during diff --git a/rtc_base/ssl_stream_adapter_unittest.cc b/rtc_base/ssl_stream_adapter_unittest.cc index 8334934b06..fe2430ee35 100644 --- a/rtc_base/ssl_stream_adapter_unittest.cc +++ b/rtc_base/ssl_stream_adapter_unittest.cc @@ -33,6 +33,7 @@ #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/crypto/crypto_options.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/test/rtc_error_matchers.h" @@ -1589,35 +1590,44 @@ TEST_P(SSLStreamAdapterTestDTLSHandshakeVersion, TestGetSslCipherSuite) { } #ifdef OPENSSL_IS_BORINGSSL -class SSLStreamAdapterTestDTLSPqc : public SSLStreamAdapterTestDTLSBase { - public: - SSLStreamAdapterTestDTLSPqc() : SSLStreamAdapterTestDTLSBase("", "") {} - - protected: - void SetUp() override { - std::string pqc_trial = "WebRTC-EnableDtlsPqc/Enabled/"; - - InitializeClientAndServerStreams(pqc_trial, pqc_trial); - - auto client_identity = - webrtc::SSLIdentity::Create("client", client_key_type_); - auto server_identity = - webrtc::SSLIdentity::Create("server", server_key_type_); - - client_ssl_->SetIdentity(std::move(client_identity)); - server_ssl_->SetIdentity(std::move(server_identity)); +TEST_P(SSLStreamAdapterTestDTLSHandshakeVersion, TestGetSslGroupIdWithPqc) { + auto client_version = ::testing::get<0>(GetParam()); + auto server_version = ::testing::get<1>(GetParam()); + SetupProtocolVersions(client_version, server_version); + + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups groups; + std::vector enabled = groups.GetEnabled(); + std::vector groups_with_pqc; + if (std::find(enabled.begin(), enabled.end(), + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768) == enabled.end()) { + groups_with_pqc.push_back( + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768); } -}; - -TEST_F(SSLStreamAdapterTestDTLSPqc, TestGetSslGroupId) { - EXPECT_EQ(client_ssl_->GetSslGroupIdForTesting(), 0); - EXPECT_EQ(server_ssl_->GetSslGroupIdForTesting(), 0); + for (auto val : enabled) { + groups_with_pqc.push_back(val); + } + RTC_CHECK(client_ssl_->SetSslGroupIds(groups_with_pqc)); + RTC_CHECK(server_ssl_->SetSslGroupIds(groups_with_pqc)); - SetupProtocolVersions(webrtc::SSL_PROTOCOL_DTLS_13, - webrtc::SSL_PROTOCOL_DTLS_13); + EXPECT_EQ(client_ssl_->GetSslGroupId(), 0); + EXPECT_EQ(server_ssl_->GetSslGroupId(), 0); TestHandshake(); - EXPECT_EQ(client_ssl_->GetSslGroupIdForTesting(), SSL_GROUP_X25519_MLKEM768); - EXPECT_EQ(server_ssl_->GetSslGroupIdForTesting(), SSL_GROUP_X25519_MLKEM768); + if (client_version == webrtc::SSL_PROTOCOL_DTLS_13 && + server_version == webrtc::SSL_PROTOCOL_DTLS_13) { + EXPECT_EQ(client_ssl_->GetSslGroupId(), + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768); + EXPECT_EQ(server_ssl_->GetSslGroupId(), + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768); + } else { + EXPECT_EQ(client_ssl_->GetSslGroupId(), + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519); + EXPECT_EQ(server_ssl_->GetSslGroupId(), + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kX25519); + } } #endif diff --git a/rtc_base/strings/string_builder_unittest.cc b/rtc_base/strings/string_builder_unittest.cc index 44c6c4b633..d04e0eb4d9 100644 --- a/rtc_base/strings/string_builder_unittest.cc +++ b/rtc_base/strings/string_builder_unittest.cc @@ -20,7 +20,7 @@ namespace webrtc { TEST(SimpleStringBuilder, Limit) { char sb_buf[10]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); EXPECT_EQ(0u, strlen(sb.str())); // Test that for a SSB with a buffer size of 10, that we can write 9 chars @@ -31,7 +31,7 @@ TEST(SimpleStringBuilder, Limit) { TEST(SimpleStringBuilder, NumbersAndChars) { char sb_buf[100]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); sb << 1 << ':' << 2.1 << ":" << 2.2f << ':' << 78187493520ll << ':' << 78187493520ul; EXPECT_EQ(0, strcmp(sb.str(), "1:2.1:2.2:78187493520:78187493520")); @@ -39,7 +39,7 @@ TEST(SimpleStringBuilder, NumbersAndChars) { TEST(SimpleStringBuilder, Format) { char sb_buf[100]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); sb << "Here we go - "; sb.AppendFormat("This is a hex formatted value: 0x%08llx", 3735928559ULL); EXPECT_EQ(0, @@ -49,7 +49,7 @@ TEST(SimpleStringBuilder, Format) { TEST(SimpleStringBuilder, StdString) { char sb_buf[100]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); std::string str = "does this work?"; sb << str; EXPECT_EQ(str, sb.str()); @@ -61,7 +61,7 @@ TEST(SimpleStringBuilder, StdString) { TEST(SimpleStringBuilderDeathTest, BufferOverrunConstCharP) { char sb_buf[4]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); const char* const msg = "This is just too much"; #if RTC_DCHECK_IS_ON EXPECT_DEATH(sb << msg, ""); @@ -73,7 +73,7 @@ TEST(SimpleStringBuilderDeathTest, BufferOverrunConstCharP) { TEST(SimpleStringBuilderDeathTest, BufferOverrunStdString) { char sb_buf[4]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); sb << 12; const std::string msg = "Aw, come on!"; #if RTC_DCHECK_IS_ON @@ -86,7 +86,7 @@ TEST(SimpleStringBuilderDeathTest, BufferOverrunStdString) { TEST(SimpleStringBuilderDeathTest, BufferOverrunInt) { char sb_buf[4]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); constexpr int num = -12345; #if RTC_DCHECK_IS_ON EXPECT_DEATH(sb << num, ""); @@ -102,7 +102,7 @@ TEST(SimpleStringBuilderDeathTest, BufferOverrunInt) { TEST(SimpleStringBuilderDeathTest, BufferOverrunDouble) { char sb_buf[5]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); constexpr double num = 123.456; #if RTC_DCHECK_IS_ON EXPECT_DEATH(sb << num, ""); @@ -115,7 +115,7 @@ TEST(SimpleStringBuilderDeathTest, BufferOverrunDouble) { TEST(SimpleStringBuilderDeathTest, BufferOverrunConstCharPAlreadyFull) { char sb_buf[4]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); sb << 123; const char* const msg = "This is just too much"; #if RTC_DCHECK_IS_ON @@ -128,7 +128,7 @@ TEST(SimpleStringBuilderDeathTest, BufferOverrunConstCharPAlreadyFull) { TEST(SimpleStringBuilderDeathTest, BufferOverrunIntAlreadyFull) { char sb_buf[4]; - webrtc::SimpleStringBuilder sb(sb_buf); + SimpleStringBuilder sb(sb_buf); sb << "xyz"; constexpr int num = -12345; #if RTC_DCHECK_IS_ON @@ -145,7 +145,7 @@ TEST(SimpleStringBuilderDeathTest, BufferOverrunIntAlreadyFull) { // StringBuilder. TEST(StringBuilder, Limit) { - webrtc::StringBuilder sb; + StringBuilder sb; EXPECT_EQ(0u, sb.str().size()); sb << "012345678"; @@ -153,7 +153,7 @@ TEST(StringBuilder, Limit) { } TEST(StringBuilder, NumbersAndChars) { - webrtc::StringBuilder sb; + StringBuilder sb; sb << 1 << ":" << 2.1 << ":" << 2.2f << ":" << 78187493520ll << ":" << 78187493520ul; EXPECT_THAT(sb.str(), @@ -161,21 +161,21 @@ TEST(StringBuilder, NumbersAndChars) { } TEST(StringBuilder, Format) { - webrtc::StringBuilder sb; + StringBuilder sb; sb << "Here we go - "; sb.AppendFormat("This is a hex formatted value: 0x%08llx", 3735928559ULL); EXPECT_EQ(sb.str(), "Here we go - This is a hex formatted value: 0xdeadbeef"); } TEST(StringBuilder, StdString) { - webrtc::StringBuilder sb; + StringBuilder sb; std::string str = "does this work?"; sb << str; EXPECT_EQ(str, sb.str()); } TEST(StringBuilder, Release) { - webrtc::StringBuilder sb; + StringBuilder sb; std::string str = "This string has to be of a moderate length, or we might " "run into problems with small object optimizations."; @@ -190,7 +190,7 @@ TEST(StringBuilder, Release) { } TEST(StringBuilder, Reset) { - webrtc::StringBuilder sb("abc"); + StringBuilder sb("abc"); sb << "def"; EXPECT_EQ("abcdef", sb.str()); sb.Clear(); diff --git a/rtc_base/strong_alias_unittest.cc b/rtc_base/strong_alias_unittest.cc index 711c805e89..c663cad837 100644 --- a/rtc_base/strong_alias_unittest.cc +++ b/rtc_base/strong_alias_unittest.cc @@ -282,7 +282,7 @@ TEST(StrongAliasTest, CanWrapComplexStructures) { TYPED_TEST(StrongAliasTest, CanBeKeysInFlatMap) { using FooAlias = StrongAlias; - webrtc::flat_map map; + flat_map map; FooAlias k1(GetExampleValue(0)); FooAlias k2(GetExampleValue(1)); diff --git a/rtc_base/synchronization/mutex_unittest.cc b/rtc_base/synchronization/mutex_unittest.cc index 06938a21f2..cafd24cf7e 100644 --- a/rtc_base/synchronization/mutex_unittest.cc +++ b/rtc_base/synchronization/mutex_unittest.cc @@ -30,8 +30,6 @@ namespace webrtc { namespace { -using ::webrtc::Event; -using ::webrtc::Thread; constexpr int kNumThreads = 16; diff --git a/rtc_base/synchronization/sequence_checker_internal.cc b/rtc_base/synchronization/sequence_checker_internal.cc index 007acacd14..3b0a0b123d 100644 --- a/rtc_base/synchronization/sequence_checker_internal.cc +++ b/rtc_base/synchronization/sequence_checker_internal.cc @@ -56,7 +56,7 @@ void SequenceCheckerImpl::Detach() { #if RTC_DCHECK_IS_ON std::string SequenceCheckerImpl::ExpectationToString() const { const TaskQueueBase* const current_queue = TaskQueueBase::Current(); - const webrtc::PlatformThreadRef current_thread = webrtc::CurrentThreadRef(); + const PlatformThreadRef current_thread = CurrentThreadRef(); MutexLock scoped_lock(&lock_); if (!attached_) return "Checker currently not attached."; @@ -68,7 +68,7 @@ std::string SequenceCheckerImpl::ExpectationToString() const { // # Actual: TQ: 0x7fa8f0604190 SysQ: 0x7fa8f0604a30 Thread: 0x700006f1a000 // TaskQueue doesn't match - webrtc::StringBuilder message; + StringBuilder message; message.AppendFormat( "# Expected: TQ: %p Thread: %p\n" "# Actual: TQ: %p Thread: %p\n", @@ -77,7 +77,7 @@ std::string SequenceCheckerImpl::ExpectationToString() const { if ((valid_queue_ || current_queue) && valid_queue_ != current_queue) { message << "TaskQueue doesn't match\n"; - } else if (!webrtc::IsThreadRefEqual(valid_thread_, current_thread)) { + } else if (!IsThreadRefEqual(valid_thread_, current_thread)) { message << "Threads don't match\n"; } diff --git a/rtc_base/system/BUILD.gn b/rtc_base/system/BUILD.gn index b18114f107..c1181618e9 100644 --- a/rtc_base/system/BUILD.gn +++ b/rtc_base/system/BUILD.gn @@ -98,7 +98,7 @@ if (is_mac || is_ios) { } } -rtc_source_set("warn_current_thread_is_deadlocked") { +rtc_library("warn_current_thread_is_deadlocked") { sources = [ "warn_current_thread_is_deadlocked.h" ] deps = [] if (is_android && !build_with_chromium) { diff --git a/rtc_base/task_queue_stdlib_unittest.cc b/rtc_base/task_queue_stdlib_unittest.cc index c090b5e497..3218a08cb7 100644 --- a/rtc_base/task_queue_stdlib_unittest.cc +++ b/rtc_base/task_queue_stdlib_unittest.cc @@ -18,14 +18,14 @@ #include "api/units/time_delta.h" #include "rtc_base/event.h" #include "rtc_base/logging.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" #include "test/gtest.h" namespace webrtc { namespace { std::unique_ptr CreateTaskQueueFactory( - const webrtc::FieldTrialsView*) { + const FieldTrialsView*) { return CreateTaskQueueStdlibFactory(); } @@ -54,7 +54,7 @@ TEST(TaskQueueStdlib, AvoidsSpammingLogOnInactivity) { auto task_queue = CreateTaskQueueStdlibFactory()->CreateTaskQueue( "test", TaskQueueFactory::Priority::NORMAL); auto wait_duration = Event::kDefaultWarnDuration + TimeDelta::Seconds(1); - SleepMs(wait_duration.ms()); + Thread::SleepMs(wait_duration.ms()); EXPECT_EQ(log_output.length(), 0u); task_queue = nullptr; LogMessage::RemoveLogToStream(&stream); diff --git a/rtc_base/test_client.cc b/rtc_base/test_client.cc index 3798c595d8..a204d1c80e 100644 --- a/rtc_base/test_client.cc +++ b/rtc_base/test_client.cc @@ -138,7 +138,7 @@ void TestClient::AdvanceTime(int ms) { // advance time. Otherwise, ProcessMessages will work. if (fake_clock_) { for (int64_t start = TimeMillis(); TimeMillis() < start + ms;) { - fake_clock_->AdvanceTime(webrtc::TimeDelta::Millis(1)); + fake_clock_->AdvanceTime(TimeDelta::Millis(1)); }; } else { Thread::Current()->ProcessMessages(1); diff --git a/rtc_base/test_client_unittest.cc b/rtc_base/test_client_unittest.cc index c585a8e532..4a87ae36d4 100644 --- a/rtc_base/test_client_unittest.cc +++ b/rtc_base/test_client_unittest.cc @@ -57,7 +57,7 @@ void TestUdpInternal(const SocketAddress& loopback) { void TestTcpInternal(const SocketAddress& loopback) { PhysicalSocketServer socket_server; AutoSocketServerThread main_thread(&socket_server); - webrtc::TestEchoServer server(&main_thread, loopback); + TestEchoServer server(&main_thread, loopback); Socket* socket = socket_server.CreateSocket(loopback.family(), SOCK_STREAM); std::unique_ptr tcp_socket = absl::WrapUnique( diff --git a/rtc_base/third_party/base64/BUILD.gn b/rtc_base/third_party/base64/BUILD.gn deleted file mode 100644 index fac16ff881..0000000000 --- a/rtc_base/third_party/base64/BUILD.gn +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the ../../../LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -import("../../../webrtc.gni") - -rtc_library("base64") { - sources = [ - "base64.cc", - "base64.h", - ] - deps = [ - "../..:checks", - "../../system:rtc_export", - "//third_party/abseil-cpp/absl/strings:string_view", - ] -} - -if (rtc_include_tests) { - rtc_library("base64_unittest") { - testonly = true - sources = [ - "base64_unittest.cc", - "test_base64.h", - ] - deps = [ - ":base64", - "../..:logging", - "../../../test:test_main", - "../../../test:test_support", - "//third_party/abseil-cpp/absl/strings:string_view", - ] - } -} diff --git a/rtc_base/third_party/base64/LICENSE b/rtc_base/third_party/base64/LICENSE deleted file mode 100644 index 4ad21d1b71..0000000000 --- a/rtc_base/third_party/base64/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ -//********************************************************************* -//* Base64 - a simple base64 encoder and decoder. -//* -//* Copyright (c) 1999, Bob Withers - bwit@pobox.com -//* -//* This code may be freely used for any purpose, either personal -//* or commercial, provided the authors copyright notice remains -//* intact. -//* -//* Enhancements by Stanley Yamane: -//* o reverse lookup table for the decode function -//* o reserve string buffer space in advance -//* -//********************************************************************* diff --git a/rtc_base/third_party/base64/README.chromium b/rtc_base/third_party/base64/README.chromium deleted file mode 100644 index 1f01511fee..0000000000 --- a/rtc_base/third_party/base64/README.chromium +++ /dev/null @@ -1,12 +0,0 @@ -Name: A simple base64 encoder and decoder -Short Name: base64 -URL: -Version: 0 -Date: 2018-06-20 -License: Custom license -License File: LICENSE -Security Critical: yes -Shipped: yes - -Description: -A simple base64 encoder and decoder diff --git a/rtc_base/third_party/base64/base64.cc b/rtc_base/third_party/base64/base64.cc deleted file mode 100644 index cc579ade91..0000000000 --- a/rtc_base/third_party/base64/base64.cc +++ /dev/null @@ -1,279 +0,0 @@ - -//********************************************************************* -//* Base64 - a simple base64 encoder and decoder. -//* -//* Copyright (c) 1999, Bob Withers - bwit@pobox.com -//* -//* This code may be freely used for any purpose, either personal -//* or commercial, provided the authors copyright notice remains -//* intact. -//* -//* Enhancements by Stanley Yamane: -//* o reverse lookup table for the decode function -//* o reserve string buffer space in advance -//* -//********************************************************************* - -#include "rtc_base/third_party/base64/base64.h" - -#include - -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" - -using std::vector; - -namespace webrtc { - -static const char kPad = '='; -static const unsigned char pd = 0xFD; // Padding -static const unsigned char sp = 0xFE; // Whitespace -static const unsigned char il = 0xFF; // Illegal base64 character - -const char Base64::Base64Table[] = - // 0000000000111111111122222222223333333333444444444455555555556666 - // 0123456789012345678901234567890123456789012345678901234567890123 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -// Decode Table gives the index of any valid base64 character in the -// Base64 table -// 65 == A, 97 == a, 48 == 0, 43 == +, 47 == / - -const unsigned char Base64::DecodeTable[] = { - // 0 1 2 3 4 5 6 7 8 9 - il, il, il, il, il, il, il, il, il, sp, // 0 - 9 - sp, sp, sp, sp, il, il, il, il, il, il, // 10 - 19 - il, il, il, il, il, il, il, il, il, il, // 20 - 29 - il, il, sp, il, il, il, il, il, il, il, // 30 - 39 - il, il, il, 62, il, il, il, 63, 52, 53, // 40 - 49 - 54, 55, 56, 57, 58, 59, 60, 61, il, il, // 50 - 59 - il, pd, il, il, il, 0, 1, 2, 3, 4, // 60 - 69 - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 70 - 79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 80 - 89 - 25, il, il, il, il, il, il, 26, 27, 28, // 90 - 99 - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // 100 - 109 - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, // 110 - 119 - 49, 50, 51, il, il, il, il, il, il, il, // 120 - 129 - il, il, il, il, il, il, il, il, il, il, // 130 - 139 - il, il, il, il, il, il, il, il, il, il, // 140 - 149 - il, il, il, il, il, il, il, il, il, il, // 150 - 159 - il, il, il, il, il, il, il, il, il, il, // 160 - 169 - il, il, il, il, il, il, il, il, il, il, // 170 - 179 - il, il, il, il, il, il, il, il, il, il, // 180 - 189 - il, il, il, il, il, il, il, il, il, il, // 190 - 199 - il, il, il, il, il, il, il, il, il, il, // 200 - 209 - il, il, il, il, il, il, il, il, il, il, // 210 - 219 - il, il, il, il, il, il, il, il, il, il, // 220 - 229 - il, il, il, il, il, il, il, il, il, il, // 230 - 239 - il, il, il, il, il, il, il, il, il, il, // 240 - 249 - il, il, il, il, il, il // 250 - 255 -}; - -bool Base64::IsBase64Char(char ch) { - return (('A' <= ch) && (ch <= 'Z')) || (('a' <= ch) && (ch <= 'z')) || - (('0' <= ch) && (ch <= '9')) || (ch == '+') || (ch == '/'); -} - -bool Base64::GetNextBase64Char(char ch, char* next_ch) { - if (next_ch == nullptr) { - return false; - } - const char* p = strchr(Base64Table, ch); - if (!p) - return false; - ++p; - *next_ch = (*p) ? *p : Base64Table[0]; - return true; -} - -bool Base64::IsBase64Encoded(absl::string_view str) { - for (size_t i = 0; i < str.size(); ++i) { - if (!IsBase64Char(str.at(i))) - return false; - } - return true; -} - -void Base64::EncodeFromArray(const void* data, - size_t len, - std::string* result) { - RTC_DCHECK(result); - result->clear(); - result->resize(((len + 2) / 3) * 4); - const unsigned char* byte_data = static_cast(data); - - unsigned char c; - size_t i = 0; - size_t dest_ix = 0; - while (i < len) { - c = (byte_data[i] >> 2) & 0x3f; - (*result)[dest_ix++] = Base64Table[c]; - - c = (byte_data[i] << 4) & 0x3f; - if (++i < len) { - c |= (byte_data[i] >> 4) & 0x0f; - } - (*result)[dest_ix++] = Base64Table[c]; - - if (i < len) { - c = (byte_data[i] << 2) & 0x3f; - if (++i < len) { - c |= (byte_data[i] >> 6) & 0x03; - } - (*result)[dest_ix++] = Base64Table[c]; - } else { - (*result)[dest_ix++] = kPad; - } - - if (i < len) { - c = byte_data[i] & 0x3f; - (*result)[dest_ix++] = Base64Table[c]; - ++i; - } else { - (*result)[dest_ix++] = kPad; - } - } -} - -size_t Base64::GetNextQuantum(DecodeFlags parse_flags, - bool illegal_pads, - const char* data, - size_t len, - size_t* dpos, - unsigned char qbuf[4], - bool* padded) { - size_t byte_len = 0, pad_len = 0, pad_start = 0; - for (; (byte_len < 4) && (*dpos < len); ++*dpos) { - qbuf[byte_len] = DecodeTable[static_cast(data[*dpos])]; - if ((il == qbuf[byte_len]) || (illegal_pads && (pd == qbuf[byte_len]))) { - if (parse_flags != DO_PARSE_ANY) - break; - // Ignore illegal characters - } else if (sp == qbuf[byte_len]) { - if (parse_flags == DO_PARSE_STRICT) - break; - // Ignore spaces - } else if (pd == qbuf[byte_len]) { - if (byte_len < 2) { - if (parse_flags != DO_PARSE_ANY) - break; - // Ignore unexpected padding - } else if (byte_len + pad_len >= 4) { - if (parse_flags != DO_PARSE_ANY) - break; - // Ignore extra pads - } else { - if (1 == ++pad_len) { - pad_start = *dpos; - } - } - } else { - if (pad_len > 0) { - if (parse_flags != DO_PARSE_ANY) - break; - // Ignore pads which are followed by data - pad_len = 0; - } - ++byte_len; - } - } - for (size_t i = byte_len; i < 4; ++i) { - qbuf[i] = 0; - } - if (4 == byte_len + pad_len) { - *padded = true; - } else { - *padded = false; - if (pad_len) { - // Roll back illegal padding - *dpos = pad_start; - } - } - return byte_len; -} - -bool Base64::DecodeFromArray(const char* data, - size_t len, - DecodeFlags flags, - std::string* result, - size_t* data_used) { - return DecodeFromArrayTemplate(data, len, flags, result, - data_used); -} - -bool Base64::DecodeFromArray(const char* data, - size_t len, - DecodeFlags flags, - vector* result, - size_t* data_used) { - return DecodeFromArrayTemplate>(data, len, flags, result, - data_used); -} - -bool Base64::DecodeFromArray(const char* data, - size_t len, - DecodeFlags flags, - vector* result, - size_t* data_used) { - return DecodeFromArrayTemplate>(data, len, flags, result, - data_used); -} - -template -bool Base64::DecodeFromArrayTemplate(const char* data, - size_t len, - DecodeFlags flags, - T* result, - size_t* data_used) { - RTC_DCHECK(result); - RTC_DCHECK_LE(flags, (DO_PARSE_MASK | DO_PAD_MASK | DO_TERM_MASK)); - - const DecodeFlags parse_flags = flags & DO_PARSE_MASK; - const DecodeFlags pad_flags = flags & DO_PAD_MASK; - const DecodeFlags term_flags = flags & DO_TERM_MASK; - RTC_DCHECK_NE(0, parse_flags); - RTC_DCHECK_NE(0, pad_flags); - RTC_DCHECK_NE(0, term_flags); - - result->clear(); - result->reserve(len); - - size_t dpos = 0; - bool success = true, padded; - unsigned char c, qbuf[4]; - while (dpos < len) { - size_t qlen = GetNextQuantum(parse_flags, (DO_PAD_NO == pad_flags), data, - len, &dpos, qbuf, &padded); - c = (qbuf[0] << 2) | ((qbuf[1] >> 4) & 0x3); - if (qlen >= 2) { - result->push_back(c); - c = ((qbuf[1] << 4) & 0xf0) | ((qbuf[2] >> 2) & 0xf); - if (qlen >= 3) { - result->push_back(c); - c = ((qbuf[2] << 6) & 0xc0) | qbuf[3]; - if (qlen >= 4) { - result->push_back(c); - c = 0; - } - } - } - if (qlen < 4) { - if ((DO_TERM_ANY != term_flags) && (0 != c)) { - success = false; // unused bits - } - if ((DO_PAD_YES == pad_flags) && !padded) { - success = false; // expected padding - } - break; - } - } - if ((DO_TERM_BUFFER == term_flags) && (dpos != len)) { - success = false; // unused chars - } - if (data_used) { - *data_used = dpos; - } - return success; -} - -} // namespace webrtc diff --git a/rtc_base/third_party/base64/base64.h b/rtc_base/third_party/base64/base64.h deleted file mode 100644 index 7a4b1e6209..0000000000 --- a/rtc_base/third_party/base64/base64.h +++ /dev/null @@ -1,135 +0,0 @@ - -//********************************************************************* -//* C_Base64 - a simple base64 encoder and decoder. -//* -//* Copyright (c) 1999, Bob Withers - bwit@pobox.com -//* -//* This code may be freely used for any purpose, either personal -//* or commercial, provided the authors copyright notice remains -//* intact. -//********************************************************************* - -#ifndef RTC_BASE_THIRD_PARTY_BASE64_BASE64_H_ -#define RTC_BASE_THIRD_PARTY_BASE64_BASE64_H_ - -#include -#include -#include -#include - -#include "absl/strings/string_view.h" - -namespace webrtc { - -class Base64 { - public: - enum DecodeOption { - DO_PARSE_STRICT = 1, // Parse only base64 characters - DO_PARSE_WHITE = 2, // Parse only base64 and whitespace characters - DO_PARSE_ANY = 3, // Parse all characters - DO_PARSE_MASK = 3, - - DO_PAD_YES = 4, // Padding is required - DO_PAD_ANY = 8, // Padding is optional - DO_PAD_NO = 12, // Padding is disallowed - DO_PAD_MASK = 12, - - DO_TERM_BUFFER = 16, // Must termiante at end of buffer - DO_TERM_CHAR = 32, // May terminate at any character boundary - DO_TERM_ANY = 48, // May terminate at a sub-character bit offset - DO_TERM_MASK = 48, - - // Strictest interpretation - DO_STRICT = DO_PARSE_STRICT | DO_PAD_YES | DO_TERM_BUFFER, - - DO_LAX = DO_PARSE_ANY | DO_PAD_ANY | DO_TERM_CHAR, - }; - typedef int DecodeFlags; - - static bool IsBase64Char(char ch); - - // Get the char next to the `ch` from the Base64Table. - // If the `ch` is the last one in the Base64Table then returns - // the first one from the table. - // Expects the `ch` be a base64 char. - // The result will be saved in `next_ch`. - // Returns true on success. - static bool GetNextBase64Char(char ch, char* next_ch); - - // Determines whether the given string consists entirely of valid base64 - // encoded characters. - static bool IsBase64Encoded(absl::string_view str); - - static void EncodeFromArray(const void* data, - size_t len, - std::string* result); - static bool DecodeFromArray(const char* data, - size_t len, - DecodeFlags flags, - std::string* result, - size_t* data_used); - static bool DecodeFromArray(const char* data, - size_t len, - DecodeFlags flags, - std::vector* result, - size_t* data_used); - static bool DecodeFromArray(const char* data, - size_t len, - DecodeFlags flags, - std::vector* result, - size_t* data_used); - - // Convenience Methods - static inline std::string Encode(absl::string_view data) { - std::string result; - EncodeFromArray(data.data(), data.size(), &result); - return result; - } - static inline std::string Decode(absl::string_view data, DecodeFlags flags) { - std::string result; - DecodeFromArray(data.data(), data.size(), flags, &result, nullptr); - return result; - } - static inline bool Decode(absl::string_view data, - DecodeFlags flags, - std::string* result, - size_t* data_used) { - return DecodeFromArray(data.data(), data.size(), flags, result, data_used); - } - static inline bool Decode(absl::string_view data, - DecodeFlags flags, - std::vector* result, - size_t* data_used) { - return DecodeFromArray(data.data(), data.size(), flags, result, data_used); - } - - private: - static const char Base64Table[]; - static const unsigned char DecodeTable[]; - - static size_t GetNextQuantum(DecodeFlags parse_flags, - bool illegal_pads, - const char* data, - size_t len, - size_t* dpos, - unsigned char qbuf[4], - bool* padded); - template - static bool DecodeFromArrayTemplate(const char* data, - size_t len, - DecodeFlags flags, - T* result, - size_t* data_used); -}; - -} // 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 rtc { -using ::webrtc::Base64; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES - -#endif /* RTC_BASE_THIRD_PARTY_BASE64_BASE64_H_ */ diff --git a/rtc_base/third_party/base64/base64_unittest.cc b/rtc_base/third_party/base64/base64_unittest.cc deleted file mode 100644 index f753bf689f..0000000000 --- a/rtc_base/third_party/base64/base64_unittest.cc +++ /dev/null @@ -1,1459 +0,0 @@ -/* - * Copyright 2011 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "rtc_base/third_party/base64/base64.h" - -#include -#include - -#include -#include - -#include "rtc_base/logging.h" -#include "rtc_base/third_party/base64/test_base64.h" -#include "test/gtest.h" - -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { -namespace { - -static struct { - size_t plain_length; - const char* plaintext; - const char* cyphertext; -} base64_tests[] = { - - // Basic bit patterns; - // values obtained with "echo -n '...' | uuencode -m test" - - {1, "\000", "AA=="}, - {1, "\001", "AQ=="}, - {1, "\002", "Ag=="}, - {1, "\004", "BA=="}, - {1, "\010", "CA=="}, - {1, "\020", "EA=="}, - {1, "\040", "IA=="}, - {1, "\100", "QA=="}, - {1, "\200", "gA=="}, - - {1, "\377", "/w=="}, - {1, "\376", "/g=="}, - {1, "\375", "/Q=="}, - {1, "\373", "+w=="}, - {1, "\367", "9w=="}, - {1, "\357", "7w=="}, - {1, "\337", "3w=="}, - {1, "\277", "vw=="}, - {1, "\177", "fw=="}, - {2, "\000\000", "AAA="}, - {2, "\000\001", "AAE="}, - {2, "\000\002", "AAI="}, - {2, "\000\004", "AAQ="}, - {2, "\000\010", "AAg="}, - {2, "\000\020", "ABA="}, - {2, "\000\040", "ACA="}, - {2, "\000\100", "AEA="}, - {2, "\000\200", "AIA="}, - {2, "\001\000", "AQA="}, - {2, "\002\000", "AgA="}, - {2, "\004\000", "BAA="}, - {2, "\010\000", "CAA="}, - {2, "\020\000", "EAA="}, - {2, "\040\000", "IAA="}, - {2, "\100\000", "QAA="}, - {2, "\200\000", "gAA="}, - - {2, "\377\377", "//8="}, - {2, "\377\376", "//4="}, - {2, "\377\375", "//0="}, - {2, "\377\373", "//s="}, - {2, "\377\367", "//c="}, - {2, "\377\357", "/+8="}, - {2, "\377\337", "/98="}, - {2, "\377\277", "/78="}, - {2, "\377\177", "/38="}, - {2, "\376\377", "/v8="}, - {2, "\375\377", "/f8="}, - {2, "\373\377", "+/8="}, - {2, "\367\377", "9/8="}, - {2, "\357\377", "7/8="}, - {2, "\337\377", "3/8="}, - {2, "\277\377", "v/8="}, - {2, "\177\377", "f/8="}, - - {3, "\000\000\000", "AAAA"}, - {3, "\000\000\001", "AAAB"}, - {3, "\000\000\002", "AAAC"}, - {3, "\000\000\004", "AAAE"}, - {3, "\000\000\010", "AAAI"}, - {3, "\000\000\020", "AAAQ"}, - {3, "\000\000\040", "AAAg"}, - {3, "\000\000\100", "AABA"}, - {3, "\000\000\200", "AACA"}, - {3, "\000\001\000", "AAEA"}, - {3, "\000\002\000", "AAIA"}, - {3, "\000\004\000", "AAQA"}, - {3, "\000\010\000", "AAgA"}, - {3, "\000\020\000", "ABAA"}, - {3, "\000\040\000", "ACAA"}, - {3, "\000\100\000", "AEAA"}, - {3, "\000\200\000", "AIAA"}, - {3, "\001\000\000", "AQAA"}, - {3, "\002\000\000", "AgAA"}, - {3, "\004\000\000", "BAAA"}, - {3, "\010\000\000", "CAAA"}, - {3, "\020\000\000", "EAAA"}, - {3, "\040\000\000", "IAAA"}, - {3, "\100\000\000", "QAAA"}, - {3, "\200\000\000", "gAAA"}, - - {3, "\377\377\377", "////"}, - {3, "\377\377\376", "///+"}, - {3, "\377\377\375", "///9"}, - {3, "\377\377\373", "///7"}, - {3, "\377\377\367", "///3"}, - {3, "\377\377\357", "///v"}, - {3, "\377\377\337", "///f"}, - {3, "\377\377\277", "//+/"}, - {3, "\377\377\177", "//9/"}, - {3, "\377\376\377", "//7/"}, - {3, "\377\375\377", "//3/"}, - {3, "\377\373\377", "//v/"}, - {3, "\377\367\377", "//f/"}, - {3, "\377\357\377", "/+//"}, - {3, "\377\337\377", "/9//"}, - {3, "\377\277\377", "/7//"}, - {3, "\377\177\377", "/3//"}, - {3, "\376\377\377", "/v//"}, - {3, "\375\377\377", "/f//"}, - {3, "\373\377\377", "+///"}, - {3, "\367\377\377", "9///"}, - {3, "\357\377\377", "7///"}, - {3, "\337\377\377", "3///"}, - {3, "\277\377\377", "v///"}, - {3, "\177\377\377", "f///"}, - - // Random numbers: values obtained with - // - // #! /bin/bash - // dd bs=$1 count=1 if=/dev/random of=/tmp/bar.random - // od -N $1 -t o1 /tmp/bar.random - // uuencode -m test < /tmp/bar.random - // - // where $1 is the number of bytes (2, 3) - - {2, "\243\361", "o/E="}, - {2, "\024\167", "FHc="}, - {2, "\313\252", "y6o="}, - {2, "\046\041", "JiE="}, - {2, "\145\236", "ZZ4="}, - {2, "\254\325", "rNU="}, - {2, "\061\330", "Mdg="}, - {2, "\245\032", "pRo="}, - {2, "\006\000", "BgA="}, - {2, "\375\131", "/Vk="}, - {2, "\303\210", "w4g="}, - {2, "\040\037", "IB8="}, - {2, "\261\372", "sfo="}, - {2, "\335\014", "3Qw="}, - {2, "\233\217", "m48="}, - {2, "\373\056", "+y4="}, - {2, "\247\232", "p5o="}, - {2, "\107\053", "Rys="}, - {2, "\204\077", "hD8="}, - {2, "\276\211", "vok="}, - {2, "\313\110", "y0g="}, - {2, "\363\376", "8/4="}, - {2, "\251\234", "qZw="}, - {2, "\103\262", "Q7I="}, - {2, "\142\312", "Yso="}, - {2, "\067\211", "N4k="}, - {2, "\220\001", "kAE="}, - {2, "\152\240", "aqA="}, - {2, "\367\061", "9zE="}, - {2, "\133\255", "W60="}, - {2, "\176\035", "fh0="}, - {2, "\032\231", "Gpk="}, - - {3, "\013\007\144", "Cwdk"}, - {3, "\030\112\106", "GEpG"}, - {3, "\047\325\046", "J9Um"}, - {3, "\310\160\022", "yHAS"}, - {3, "\131\100\237", "WUCf"}, - {3, "\064\342\134", "NOJc"}, - {3, "\010\177\004", "CH8E"}, - {3, "\345\147\205", "5WeF"}, - {3, "\300\343\360", "wOPw"}, - {3, "\061\240\201", "MaCB"}, - {3, "\225\333\044", "ldsk"}, - {3, "\215\137\352", "jV/q"}, - {3, "\371\147\160", "+Wdw"}, - {3, "\030\320\051", "GNAp"}, - {3, "\044\174\241", "JHyh"}, - {3, "\260\127\037", "sFcf"}, - {3, "\111\045\033", "SSUb"}, - {3, "\202\114\107", "gkxH"}, - {3, "\057\371\042", "L/ki"}, - {3, "\223\247\244", "k6ek"}, - {3, "\047\216\144", "J45k"}, - {3, "\203\070\327", "gzjX"}, - {3, "\247\140\072", "p2A6"}, - {3, "\124\115\116", "VE1O"}, - {3, "\157\162\050", "b3Io"}, - {3, "\357\223\004", "75ME"}, - {3, "\052\117\156", "Kk9u"}, - {3, "\347\154\000", "52wA"}, - {3, "\303\012\142", "wwpi"}, - {3, "\060\035\362", "MB3y"}, - {3, "\130\226\361", "WJbx"}, - {3, "\173\013\071", "ews5"}, - {3, "\336\004\027", "3gQX"}, - {3, "\357\366\234", "7/ac"}, - {3, "\353\304\111", "68RJ"}, - {3, "\024\264\131", "FLRZ"}, - {3, "\075\114\251", "PUyp"}, - {3, "\315\031\225", "zRmV"}, - {3, "\154\201\276", "bIG+"}, - {3, "\200\066\072", "gDY6"}, - {3, "\142\350\267", "Yui3"}, - {3, "\033\000\166", "GwB2"}, - {3, "\210\055\077", "iC0/"}, - {3, "\341\037\124", "4R9U"}, - {3, "\161\103\152", "cUNq"}, - {3, "\270\142\131", "uGJZ"}, - {3, "\337\076\074", "3z48"}, - {3, "\375\106\362", "/Uby"}, - {3, "\227\301\127", "l8FX"}, - {3, "\340\002\234", "4AKc"}, - {3, "\121\064\033", "UTQb"}, - {3, "\157\134\143", "b1xj"}, - {3, "\247\055\327", "py3X"}, - {3, "\340\142\005", "4GIF"}, - {3, "\060\260\143", "MLBj"}, - {3, "\075\203\170", "PYN4"}, - {3, "\143\160\016", "Y3AO"}, - {3, "\313\013\063", "ywsz"}, - {3, "\174\236\135", "fJ5d"}, - {3, "\103\047\026", "QycW"}, - {3, "\365\005\343", "9QXj"}, - {3, "\271\160\223", "uXCT"}, - {3, "\362\255\172", "8q16"}, - {3, "\113\012\015", "SwoN"}, - - // various lengths, generated by this python script: - // - // from string import lowercase as lc - // for i in range(27): - // print '{ %2d, "%s",%s "%s" },' % (i, lc[:i], ' ' * (26-i), - // lc[:i].encode('base64').strip()) - - {0, "abcdefghijklmnopqrstuvwxyz", ""}, - {1, "abcdefghijklmnopqrstuvwxyz", "YQ=="}, - {2, "abcdefghijklmnopqrstuvwxyz", "YWI="}, - {3, "abcdefghijklmnopqrstuvwxyz", "YWJj"}, - {4, "abcdefghijklmnopqrstuvwxyz", "YWJjZA=="}, - {5, "abcdefghijklmnopqrstuvwxyz", "YWJjZGU="}, - {6, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVm"}, - {7, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZw=="}, - {8, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2g="}, - {9, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hp"}, - {10, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpag=="}, - {11, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpams="}, - {12, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamts"}, - {13, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbQ=="}, - {14, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW4="}, - {15, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5v"}, - {16, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcA=="}, - {17, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHE="}, - {18, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFy"}, - {19, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFycw=="}, - {20, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3Q="}, - {21, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1"}, - {22, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dg=="}, - {23, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnc="}, - {24, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4"}, - {25, "abcdefghijklmnopqrstuvwxy", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eQ=="}, - {26, "abcdefghijklmnopqrstuvwxyz", "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="}, -}; -#if 0 -static struct { - const char* plaintext; - const char* cyphertext; -} base64_strings[] = { - - // The first few Google quotes - // Cyphertext created with "uuencode - GNU sharutils 4.2.1" - { - "Everyone! We're teetering on the brink of disaster." - " - Sergey Brin, 6/24/99, regarding the company's state " - "after the unleashing of Netscape/Google search", - - "RXZlcnlvbmUhICBXZSdyZSB0ZWV0ZXJpbmcgb24gdGhlIGJyaW5rIG9mIGRp" - "c2FzdGVyLiAtIFNlcmdleSBCcmluLCA2LzI0Lzk5LCByZWdhcmRpbmcgdGhl" - "IGNvbXBhbnkncyBzdGF0ZSBhZnRlciB0aGUgdW5sZWFzaGluZyBvZiBOZXRz" - "Y2FwZS9Hb29nbGUgc2VhcmNo" }, - - { - "I'm not sure why we're still alive, but we seem to be." - " - Larry Page, 6/24/99, while hiding in the kitchenette " - "during the Netscape traffic overflow", - - "SSdtIG5vdCBzdXJlIHdoeSB3ZSdyZSBzdGlsbCBhbGl2ZSwgYnV0IHdlIHNl" - "ZW0gdG8gYmUuIC0gTGFycnkgUGFnZSwgNi8yNC85OSwgd2hpbGUgaGlkaW5n" - "IGluIHRoZSBraXRjaGVuZXR0ZSBkdXJpbmcgdGhlIE5ldHNjYXBlIHRyYWZm" - "aWMgb3ZlcmZsb3c" }, - - { - "I think kids want porn." - " - Sergey Brin, 6/99, on why Google shouldn't prioritize a " - "filtered search for children and families", - - "SSB0aGluayBraWRzIHdhbnQgcG9ybi4gLSBTZXJnZXkgQnJpbiwgNi85OSwg" - "b24gd2h5IEdvb2dsZSBzaG91bGRuJ3QgcHJpb3JpdGl6ZSBhIGZpbHRlcmVk" - "IHNlYXJjaCBmb3IgY2hpbGRyZW4gYW5kIGZhbWlsaWVz" }, -}; -#endif -// Compare bytes 0..len-1 of x and y. If not equal, abort with verbose error -// message showing position and numeric value that differed. -// Handles embedded nulls just like any other byte. -// Only added because string.compare() in gcc-3.3.3 seems to misbehave with -// embedded nulls. -// TODO: switch back to string.compare() if/when gcc is fixed -#define EXPECT_EQ_ARRAY(len, x, y, msg) \ - for (size_t j = 0; j < len; ++j) { \ - if (x[j] != y[j]) { \ - RTC_LOG(LS_ERROR) << "" #x << " != " #y << " byte " << j \ - << " msg: " << msg; \ - } \ - } - -size_t Base64Escape(const unsigned char* src, - size_t szsrc, - char* dest, - size_t szdest) { - std::string escaped; - webrtc::Base64::EncodeFromArray((const char*)src, szsrc, &escaped); - memcpy(dest, escaped.data(), std::min(escaped.size(), szdest)); - return escaped.size(); -} - -size_t Base64Unescape(const char* src, - size_t szsrc, - char* dest, - size_t szdest) { - std::string unescaped; - EXPECT_TRUE(webrtc::Base64::DecodeFromArray( - src, szsrc, webrtc::Base64::DO_LAX, &unescaped, nullptr)); - memcpy(dest, unescaped.data(), std::min(unescaped.size(), szdest)); - return unescaped.size(); -} - -size_t Base64Unescape(const char* src, size_t szsrc, std::string* s) { - EXPECT_TRUE(webrtc::Base64::DecodeFromArray( - src, szsrc, webrtc::Base64::DO_LAX, s, nullptr)); - return s->size(); -} - -TEST(Base64, EncodeDecodeBattery) { - RTC_LOG(LS_VERBOSE) << "Testing base-64"; - - size_t i; - - // Check the short strings; this tests the math (and boundaries) - for (i = 0; i < sizeof(base64_tests) / sizeof(base64_tests[0]); ++i) { - char encode_buffer[100]; - size_t encode_length; - char decode_buffer[100]; - size_t decode_length; - size_t cypher_length; - - RTC_LOG(LS_VERBOSE) << "B64: " << base64_tests[i].cyphertext; - - const unsigned char* unsigned_plaintext = - reinterpret_cast(base64_tests[i].plaintext); - - cypher_length = strlen(base64_tests[i].cyphertext); - - // The basic escape function: - memset(encode_buffer, 0, sizeof(encode_buffer)); - encode_length = - Base64Escape(unsigned_plaintext, base64_tests[i].plain_length, - encode_buffer, sizeof(encode_buffer)); - // Is it of the expected length? - EXPECT_EQ(encode_length, cypher_length); - - // Is it the expected encoded value? - EXPECT_STREQ(encode_buffer, base64_tests[i].cyphertext); - - // If we encode it into a buffer of exactly the right length... - memset(encode_buffer, 0, sizeof(encode_buffer)); - encode_length = - Base64Escape(unsigned_plaintext, base64_tests[i].plain_length, - encode_buffer, cypher_length); - // Is it still of the expected length? - EXPECT_EQ(encode_length, cypher_length); - - // And is the value still correct? (i.e., not losing the last byte) - EXPECT_STREQ(encode_buffer, base64_tests[i].cyphertext); - - // If we decode it back: - memset(decode_buffer, 0, sizeof(decode_buffer)); - decode_length = Base64Unescape(encode_buffer, cypher_length, decode_buffer, - sizeof(decode_buffer)); - - // Is it of the expected length? - EXPECT_EQ(decode_length, base64_tests[i].plain_length); - - // Is it the expected decoded value? - EXPECT_EQ(0, - memcmp(decode_buffer, base64_tests[i].plaintext, decode_length)); - - // Our decoder treats the padding '=' characters at the end as - // optional. If encode_buffer has any, run some additional - // tests that fiddle with them. - char* first_equals = strchr(encode_buffer, '='); - if (first_equals) { - // How many equals signs does the string start with? - int equals = (*(first_equals + 1) == '=') ? 2 : 1; - - // Try chopping off the equals sign(s) entirely. The decoder - // should still be okay with this. - std::string decoded2("this junk should also be ignored"); - *first_equals = '\0'; - EXPECT_NE(0U, Base64Unescape(encode_buffer, first_equals - encode_buffer, - &decoded2)); - EXPECT_EQ(decoded2.size(), base64_tests[i].plain_length); - EXPECT_EQ_ARRAY(decoded2.size(), decoded2.data(), - base64_tests[i].plaintext, i); - - size_t len; - - // try putting some extra stuff after the equals signs, or in between them - if (equals == 2) { - snprintf(first_equals, 6, " = = "); - len = first_equals - encode_buffer + 5; - } else { - snprintf(first_equals, 6, " = "); - len = first_equals - encode_buffer + 3; - } - decoded2.assign("this junk should be ignored"); - EXPECT_NE(0U, Base64Unescape(encode_buffer, len, &decoded2)); - EXPECT_EQ(decoded2.size(), base64_tests[i].plain_length); - EXPECT_EQ_ARRAY(decoded2.size(), decoded2, base64_tests[i].plaintext, i); - } - } -} - -// here's a weird case: a giant base64 encoded stream which broke our base64 -// decoding. Let's test it explicitly. -const char SpecificTest[] = - "/9j/4AAQSkZJRgABAgEASABIAAD/" - "4Q0HRXhpZgAATU0AKgAAAAgADAEOAAIAAAAgAAAAngEPAAI\n" - "AAAAFAAAAvgEQAAIAAAAJAAAAwwESAAMAAAABAAEAAAEaAAUAAAABAAAAzAEbAAUAAAABAAAA1" - "A\n" - "EoAAMAAAABAAIAAAExAAIAAAAUAAAA3AEyAAIAAAAUAAAA8AE8AAIAAAAQAAABBAITAAMAAAAB" - "A\n" - "AIAAIdpAAQAAAABAAABFAAAAsQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgAFNPTlk" - "A\n" - "RFNDLVAyMDAAAAAASAAAAAEAAABIAAAAAUFkb2JlIFBob3Rvc2hvcCA3LjAAMjAwNzowMTozMC" - "A\n" - "yMzoxMDowNABNYWMgT1MgWCAxMC40LjgAAByCmgAFAAAAAQAAAmqCnQAFAAAAAQAAAnKIIgADA" - "A\n" - "AAAQACAACIJwADAAAAAQBkAACQAAAHAAAABDAyMjCQAwACAAAAFAAAAnqQBAACAAAAFAAAAo6R" - "A\n" - "QAHAAAABAECAwCRAgAFAAAAAQAAAqKSBAAKAAAAAQAAAqqSBQAFAAAAAQAAArKSBwADAAAAAQA" - "F\n" - "AACSCAADAAAAAQAAAACSCQADAAAAAQAPAACSCgAFAAAAAQAAArqgAAAHAAAABDAxMDCgAQADAA" - "A\n" - "AAf//" - "AACgAgAEAAAAAQAAAGSgAwAEAAAAAQAAAGSjAAAHAAAAAQMAAACjAQAHAAAAAQEAAACkAQ\n" - "ADAAAAAQAAAACkAgADAAAAAQAAAACkAwADAAAAAQAAAACkBgADAAAAAQAAAACkCAADAAAAAQAA" - "A\n" - "ACkCQADAAAAAQAAAACkCgADAAAAAQAAAAAAAAAAAAAACgAAAZAAAAAcAAAACjIwMDc6MDE6MjA" - "g\n" - "MjM6MDU6NTIAMjAwNzowMToyMCAyMzowNTo1MgAAAAAIAAAAAQAAAAAAAAAKAAAAMAAAABAAAA" - "B\n" - "PAAAACgAAAAYBAwADAAAAAQAGAAABGgAFAAAAAQAAAxIBGwAFAAAAAQAAAxoBKAADAAAAAQACA" - "A\n" - "ACAQAEAAAAAQAAAyICAgAEAAAAAQAACd0AAAAAAAAASAAAAAEAAABIAAAAAf/Y/" - "+AAEEpGSUYAA\n" - "QIBAEgASAAA/+0ADEFkb2JlX0NNAAL/7gAOQWRvYmUAZIAAAAAB/" - "9sAhAAMCAgICQgMCQkMEQsK\n" - "CxEVDwwMDxUYExMVExMYEQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMAQ0LCw" - "0\n" - "ODRAODhAUDg4OFBQODg4OFBEMDAwMDBERDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD" - "A\n" - "wMDAz/wAARCABkAGQDASIAAhEBAxEB/90ABAAH/" - "8QBPwAAAQUBAQEBAQEAAAAAAAAAAwABAgQFB\n" - "gcICQoLAQABBQEBAQEBAQAAAAAAAAABAAIDBAUGBwgJCgsQAAEEAQMCBAIFBwYIBQMMMwEAAhE" - "D\n" - "BCESMQVBUWETInGBMgYUkaGxQiMkFVLBYjM0coLRQwclklPw4fFjczUWorKDJkSTVGRFwqN0Nh" - "f\n" - "SVeJl8rOEw9N14/" - "NGJ5SkhbSVxNTk9KW1xdXl9VZmdoaWprbG1ub2N0dXZ3eHl6e3x9fn9xEAAg\n" - "IBAgQEAwQFBgcHBgU1AQACEQMhMRIEQVFhcSITBTKBkRShsUIjwVLR8DMkYuFygpJDUxVjczTx" - "J\n" - "QYWorKDByY1wtJEk1SjF2RFVTZ0ZeLys4TD03Xj80aUpIW0lcTU5PSltcXV5fVWZnaGlqa2xtb" - "m\n" - "9ic3R1dnd4eXp7fH/" - "9oADAMBAAIRAxEAPwDy7bKNTUXNLz9EaJPDWMjxH4ozhtpYwaACT8ShaaW\n" - "bW0uEc9/JFfjj0Q4Hk/PRDxwX7y47W9z/" - "AN9Cv4+O3ILK2DcRqT2CaSvEbcl1Jbz37KG1dBldLo\n" - "qaS4l9xGjG9v6yoDAdYIaIjUk+AREgo4y5sapirb8Yl0NHHdKvBNm4yA1o5Pc+" - "SPEFvCWqB3HZF\n" - "Hj2SbWQ/" - "afGFP0bHP8ATY0uc4w1o1JPkkimGiS2KvqlnmBkOZQTyydzgPMM9v8A0lp4v1Nx9gF1\n" - "tpdqJaGtH/S3I0i3lISXW/8AMqnd/O2bfg2eUkqVYf/" - "Q8zuncO4Bj7lZ+n7f5Mj5KsJcY8NUZ4d\n" - "uEDVo1HkeU0rg3Om4H2rabCWUN7DQuK1n5FWKW4uCwG92gDRJBS6exhxmMboQI+" - "Cv4WFTQ42Bs2\n" - "fvnkkqEmy2YxoMMbpVzaz6jt+RbpHZs8lzkHqrasKkYOKP0jgDfZ4N/" - "wDM1tNrcWfSPmRyq9uNV\n" - "DnFg2s97i7UkjxKVrq0eVz3spZsja+ASDzwsh9jnOk/" - "JFzb3XZD3v1c4yT8UACTCniKDUnKz5Nj\n" - "G33XV1DV73BrT8dF23SejV4zg9g33cOsPb+SxVvqv9ViwNy8vS0iWs/" - "daf8A0Y5dpTi1sADGxCR\n" - "K1o0YBEmInlXWYbDBcDLdPJXa8f71Yrx2jnUoAqLnfZK5hJaW2vdwEk5a/wD/0fN6Ia/" - "e76IiVf\n" - "xavUL7CPpnT4LNbYXAVjuQt/AqDmNYO/" - "Kjnoy4hr5J8SwMhrRMaeSvbsxrfUazcOw4UX0Cisem2\n" - "SBoD4+" - "Kz8nC6llbSLCRrubJA8kwUWbUDa29X1PMa7aQWjuDC0MXMdbDbhI7eazBiUfZ6GOYRe1s\n" - "WvGgJ8Vbw2+m4Bx9s6JpNHuuGo1FF53r/" - "SHYua61gLse0lzXeBP5rkvqx0o5vVWz7WY49QkiQSP\n" - "oN/tLoevW/ogxv0HA7tJ0AnhT+pdDGYVl/wCdcTPkGn2NU0JWNWvlgAbHV6fEqdu2gR/" - "r2WlWwt\n" - "AA5VXAEsLXTqJafArQY5rRr9LiPBJiZsZCI1pJjxCi0j4oncSICSkWwzwkjeaSch//" - "0vO7sP7Lm\n" - "enO9ogtd5FbPT3Q5pCpZVc4ld3Lmn3O8j9EI2BYdunKjOobMQIyI+rusc2wx4d0eutwGnHh/" - "uQc\n" - "Ha7ladj6mVANGvcqOgz0Go7HJ12/GEHcwvB/dPY6ImbbaMaASGuIBjkN7qofs9Ubg9g7OI9p/" - "t/\n" - "RTSmhTHr0v6eSz6UgCPP2/wAVu9Ex2V49dVY2iACB4BZeVXQ/" - "AJ3gzGnnOi2+kACpru8flUsNmt\n" - "zHRf6xfWCnoeAfTh2ZaQKazx/" - "Ke7+QxcKz61fWA2uuObaC4zGhaPJrXBL64ZFmR124O09ENraPK\n" - "N3/AH5GqxIrZVUyp2K2vfdkENsDnxuex9m4Ox9n82xSgNd9D+p/XR1npgseR9ppOy4Dx/NfH/" - "CL\n" - "oQJGunmvMv8AFq3KHVcq3HkYQbD2nuSf0I/rMavSg6TLjLigQhJ7Z58v9QkmlsTOqSCn/" - "9PzL7R\n" - "d6Qq3n0wZ2zotXpT9xLfFYvkr/S7jXeB8E0jRkhKpC3q8LcJ/kmCrTnkuAPCq4do9Q/" - "ytVbuAeY\n" - "Gg5lQybQK+" - "82GBqEQUA1kOHPYf3LLsoyN36G5w8iUfHxepbXE2l0cApALgLHzBq9UxhTXU5hMC1\n" - "ktnSCup6S4Ctk+C5XqVGcaHPfuiuHkeTTuWz0+9zaKiH6CC0/yXBSQ2a/" - "MxojV57634rq+v2PLY\n" - "be1r2nsYG13/" - "AFKxbfCBMcr0brGAzrGEwCG31ncx0SfBzf7S4+zoHUWWsJq3hz9oLfcBH77R9H+\n" - "0pA13u/qPgDp/Q6ri39JlfpXkDx+h/" - "msWn1L6wdO6bSbcrIbU2Q0xLnSe21kuVejJspbVS5+4bd\n" - "ocBAkD/orG+tP1ar67Wy7GtZTm1SCXfRsb+a18fRe38x6SG3/44H1Z3f0y2I+l6DoSXD/" - "8xPrDs\n" - "3enVu3bdnqN3R+//USSVo//" - "1PLohhce+gRWS0Nsby3lRgFkKxQyW7SgUh3em5Tbq2uB9wWw1wey\n" - "J1XGV2XYdm5k7e4WzidXY9oMwo5RZ4T6Hd1ixwfp96PWbAJBVTHzK7O6Ky5oJB1HZMqmUEFlkG" - "y\n" - "xpa4zI1Hkq31dy7bMN9BAc3HeWAnnbyxEycmuup1jiAGglZ31PyrmZ9tQg1WtNj54EHR3/" - "S2qTH\n" - "1Yc5GgD1FFtzPdWGkd2AyflogZmRmsz6PSrbXbdo+" - "txOrP337f3fzVo15DK2uyrTtqpBOnBKx6b\n" - "7MjJsz7tHWOAYP3WD6LU6cqGjFCNl1MmvLcxv6YtDTLSAqP27LrdtYHXFnJZI+" - "Tp3MWg68OpDPv\n" - "UMUM2lkQBoouKQ6swjE9Nml+1sz1PW+z6xt27zuj+skrX2ZvqR5z8kkuOfdPt43/1fMm/" - "grFG6f\n" - "Lss9JA7JG7tnZs/SfJUrfS3foJ9TvHCopJsV8nWx/t24bJn8Fo/5TjWJXMJIS+i+G36TsZ/" - "7Q9P\n" - "8ATfzfeOFofVSZv2/zvt+O3X/v65dJPjt/BiyfN1/wn0zre79nVej/ADG8ep4x2/" - "6Srjd6TdviF\n" - "52ko8m6/Ht9X1KnftEo+POwxzK8mSTF46vrH6T1/OEl5Okkl//Z/" - "+0uHFBob3Rvc2hvcCAzLjAA\n" - "OEJJTQQEAAAAAAArHAIAAAIAAhwCeAAfICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA" - "A\n" - "4QklNBCUAAAAAABD7Caa9B0wqNp2P4sxXqayFOEJJTQPqAAAAAB2wPD94bWwgdmVyc2lvbj0iM" - "S\n" - "4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUg" - "Q\n" - "29tcHV0ZXIvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9" - "Q\n" - "cm9wZXJ0eUxpc3QtMS4wLmR0ZCI+" - "CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk\n" - "+Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1Ib3Jpem9udGFsUmVzPC9rZXk+" - "Cgk8ZGljdD\n" - "4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCTxzdHJpbmc+" - "Y\n" - "29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50\n" - "LnRpY2tldC5pdGVtQXJyYXk8L2tleT4KCQk8YXJyYXk+" - "CgkJCTxkaWN0PgoJCQkJPGtleT5jb20\n" - "uYXBwbGUucHJpbnQuUGFnZUZvcm1hdC5QTUhvcml6b250YWxSZXM8L2tleT4KCQkJCTxyZWFsP" - "j\n" - "cyPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJ" - "C\n" - "QkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJpbmc+" - "CgkJCQk8a2V5PmNv\n" - "bS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGRhdGU+" - "MjAwNy0wMS0zMFQ\n" - "yMjowODo0MVo8L2RhdGU+" - "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuc3RhdGVGbG\n" - "FnPC9rZXk+CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY3Q+" - "CgkJPC9hcnJheT4KC\n" - "TwvZGljdD4KCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwv\n" - "a2V5PgoJPGRpY3Q+" - "CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4\n" - "KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvb" - "S\n" - "5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" - "CgkJPGFycmF5PgoJCQk8ZGljdD4KC\n" - "QkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1PcmllbnRhdGlvbjwva2V5PgoJ\n" - "CQkJPGludGVnZXI+MTwvaW50ZWdlcj4KCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LnRpY2tldC5\n" - "jbGllbnQ8L2tleT4KCQkJCTxzdHJpbmc+" - "Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW\n" - "5nPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lm1vZERhdGU8L2tleT4KCQkJCTxk" - "Y\n" - "XRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQ" - "u\n" - "dGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJPGludGVnZXI+" - "MDwvaW50ZWdlcj4KCQkJPC9kaWN\n" - "0PgoJCTwvYXJyYXk+Cgk8L2RpY3Q+" - "Cgk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0Ll\n" - "BNU2NhbGluZzwva2V5PgoJPGRpY3Q+" - "CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZ\n" - "WF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4" - "K\n" - "CQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" - "CgkJPGFycmF5Pgo\n" - "JCQk8ZGljdD4KCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1TY2FsaW5nPC\n" - "9rZXk+" - "CgkJCQk8cmVhbD4xPC9yZWFsPgoJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0L\n" - "mNsaWVudDwva2V5PgoJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnRpbmdtYW5hZ2VyPC9zdHJ" - "p\n" - "bmc+" - "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJCQkJPGR\n" - "hdGU+MjAwNy0wMS0zMFQyMjowODo0MVo8L2RhdGU+" - "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC\n" - "50aWNrZXQuc3RhdGVGbGFnPC9rZXk+" - "CgkJCQk8aW50ZWdlcj4wPC9pbnRlZ2VyPgoJCQk8L2RpY\n" - "3Q+CgkJPC9hcnJheT4KCTwvZGljdD4KCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQu\n" - "UE1WZXJ0aWNhbFJlczwva2V5PgoJPGRpY3Q+" - "CgkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V\n" - "0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0c" - "m\n" - "luZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" - "CgkJPGFyc\n" - "mF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYXQuUE1WZXJ0\n" - "aWNhbFJlczwva2V5PgoJCQkJPHJlYWw+NzI8L3JlYWw+" - "CgkJCQk8a2V5PmNvbS5hcHBsZS5wcml\n" - "udC50aWNrZXQuY2xpZW50PC9rZXk+" - "CgkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbm\n" - "FnZXI8L3N0cmluZz4KCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZ\n" - "Xk+CgkJCQk8ZGF0ZT4yMDA3LTAxLTMwVDIyOjA4OjQxWjwvZGF0ZT4KCQkJCTxrZXk+" - "Y29tLmFw\n" - "cGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpbnRlZ2VyPjA8L2ludGVnZX" - "I\n" - "+CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5jb20uYXBwbGUucHJpbnQuU" - "G\n" - "FnZUZvcm1hdC5QTVZlcnRpY2FsU2NhbGluZzwva2V5PgoJPGRpY3Q+" - "CgkJPGtleT5jb20uYXBwb\n" - "GUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGl" - "u\n" - "Z21hbmFnZXI8L3N0cmluZz4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycm" - "F\n" - "5PC9rZXk+CgkJPGFycmF5PgoJCQk8ZGljdD4KCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhZ2\n" - "VGb3JtYXQuUE1WZXJ0aWNhbFNjYWxpbmc8L2tleT4KCQkJCTxyZWFsPjE8L3JlYWw+" - "CgkJCQk8a\n" - "2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW50PC9rZXk+" - "CgkJCQk8c3RyaW5nPmNvbS5h\n" - "cHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LnR\n" - "pY2tldC5tb2REYXRlPC9rZXk+" - "CgkJCQk8ZGF0ZT4yMDA3LTAxLTMwVDIyOjA4OjQxWjwvZGF0ZT\n" - "4KCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCTxpb\n" - "nRlZ2VyPjA8L2ludGVnZXI+" - "CgkJCTwvZGljdD4KCQk8L2FycmF5PgoJPC9kaWN0PgoJPGtleT5j\n" - "b20uYXBwbGUucHJpbnQuc3ViVGlja2V0LnBhcGVyX2luZm9fdGlja2V0PC9rZXk+" - "Cgk8ZGljdD4\n" - "KCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlUmVjdDwva" - "2\n" - "V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY3JlYXRvcjwva2V5" - "P\n" - "goJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJPGtleT5" - "j\n" - "b20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+" - "CgkJCQk8ZGl\n" - "jdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYWdlRm9ybWF0LlBNQWRqdXN0ZWRQYWdlU" - "m\n" - "VjdDwva2V5PgoJCQkJCTxhcnJheT4KCQkJCQkJPHJlYWw+" - "MC4wPC9yZWFsPgoJCQkJCQk8cmVhb\n" - "D4wLjA8L3JlYWw+CgkJCQkJCTxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+" - "NTc2PC9yZWFs\n" - "PgoJCQkJCTwvYXJyYXk+" - "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDw\n" - "va2V5PgoJCQkJCTxzdHJpbmc+" - "Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQ\n" - "kJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+" - "M\n" - "jAwNy0wMS0zMFQyMjowODo0MVo8L2RhdGU+" - "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlj\n" - "a2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+" - "CgkJCQk8L2RpY3Q\n" - "+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhZ2VGb3JtYX\n" - "QuUE1BZGp1c3RlZFBhcGVyUmVjdDwva2V5PgoJCTxkaWN0PgoJCQk8a2V5PmNvbS5hcHBsZS5w" - "c\n" - "mludC50aWNrZXQuY3JlYXRvcjwva2V5PgoJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21" - "h\n" - "bmFnZXI8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0Lml0ZW1BcnJheT" - "w\n" - "va2V5PgoJCQk8YXJyYXk+" - "CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC5QYW\n" - "dlRm9ybWF0LlBNQWRqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+" - "CgkJCQkJCTxyZ\n" - "WFsPi0xODwvcmVhbD4KCQkJCQkJPHJlYWw+" - "LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3Jl\n" - "YWw+CgkJCQkJCTxyZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+" - "Y29tLmF\n" - "wcGxlLnByaW50LnRpY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wc" - "m\n" - "ludGluZ21hbmFnZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQu" - "b\n" - "W9kRGF0ZTwva2V5PgoJCQkJCTxkYXRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQk" - "J\n" - "CTxrZXk+" - "Y29tLmFwcGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWd\n" - "lcj4wPC9pbnRlZ2VyPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5P" - "m\n" - "NvbS5hcHBsZS5wcmludC5QYXBlckluZm8uUE1QYXBlck5hbWU8L2tleT4KCQk8ZGljdD4KCQkJ" - "P\n" - "GtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20" - "u\n" - "YXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcm" - "l\n" - "udC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" - "CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZX\n" - "k+" - "Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVBhcGVyTmFtZTwva2V5PgoJCQkJCTxzdHJpb" - "\n" - "mc+bmEtbGV0dGVyPC9zdHJpbmc+" - "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNs\n" - "aWVudDwva2V5PgoJCQkJCTxzdHJpbmc+" - "Y29tLmFwcGxlLnByaW50LnBtLlBvc3RTY3JpcHQ8L3N\n" - "0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5PgoJC" - "Q\n" - "kJCTxkYXRlPjIwMDMtMDctMDFUMTc6NDk6MzZaPC9kYXRlPgoJCQkJCTxrZXk+" - "Y29tLmFwcGxlL\n" - "nByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4xPC9pbnRlZ2VyPgo" - "J\n" - "CQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wcmludC" - "5\n" - "QYXBlckluZm8uUE1VbmFkanVzdGVkUGFnZVJlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb" - "2\n" - "0uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0b3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUu" - "c\n" - "HJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5nPgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWN" - "r\n" - "ZXQuaXRlbUFycmF5PC9rZXk+CgkJCTxhcnJheT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+" - "Y29tLmF\n" - "wcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYWdlUmVjdDwva2V5PgoJCQkJCTxhc" - "n\n" - "JheT4KCQkJCQkJPHJlYWw+MC4wPC9yZWFsPgoJCQkJCQk8cmVhbD4wLjA8L3JlYWw+" - "CgkJCQkJC\n" - "TxyZWFsPjczNDwvcmVhbD4KCQkJCQkJPHJlYWw+NTc2PC9yZWFsPgoJCQkJCTwvYXJyYXk+" - "CgkJ\n" - "CQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNsaWVudDwva2V5PgoJCQkJCTxzdHJpbm" - "c\n" - "+Y29tLmFwcGxlLnByaW50aW5nbWFuYWdlcjwvc3RyaW5nPgoJCQkJCTxrZXk+" - "Y29tLmFwcGxlLn\n" - "ByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+CgkJCQkJPGRhdGU+" - "MjAwNy0wMS0zMFQyMjowODo0M\n" - "Vo8L2RhdGU+" - "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LnN0YXRlRmxhZzwva2V5\n" - "PgoJCQkJCTxpbnRlZ2VyPjA8L2ludGVnZXI+CgkJCQk8L2RpY3Q+CgkJCTwvYXJyYXk+" - "CgkJPC9\n" - "kaWN0PgoJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYWRqdXN0ZWRQYXBlcl\n" - "JlY3Q8L2tleT4KCQk8ZGljdD4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2V0LmNyZWF0" - "b\n" - "3I8L2tleT4KCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5" - "n\n" - "PgoJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuaXRlbUFycmF5PC9rZXk+" - "CgkJCTxhcnJ\n" - "heT4KCQkJCTxkaWN0PgoJCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LlBhcGVySW5mby5QTVVuYW\n" - "RqdXN0ZWRQYXBlclJlY3Q8L2tleT4KCQkJCQk8YXJyYXk+" - "CgkJCQkJCTxyZWFsPi0xODwvcmVhb\n" - "D4KCQkJCQkJPHJlYWw+LTE4PC9yZWFsPgoJCQkJCQk8cmVhbD43NzQ8L3JlYWw+" - "CgkJCQkJCTxy\n" - "ZWFsPjU5NDwvcmVhbD4KCQkJCQk8L2FycmF5PgoJCQkJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LnR\n" - "pY2tldC5jbGllbnQ8L2tleT4KCQkJCQk8c3RyaW5nPmNvbS5hcHBsZS5wcmludGluZ21hbmFnZ" - "X\n" - "I8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQubW9kRGF0ZTwva2V5" - "P\n" - "goJCQkJCTxkYXRlPjIwMDctMDEtMzBUMjI6MDg6NDFaPC9kYXRlPgoJCQkJCTxrZXk+" - "Y29tLmFw\n" - "cGxlLnByaW50LnRpY2tldC5zdGF0ZUZsYWc8L2tleT4KCQkJCQk8aW50ZWdlcj4wPC9pbnRlZ2" - "V\n" - "yPgoJCQkJPC9kaWN0PgoJCQk8L2FycmF5PgoJCTwvZGljdD4KCQk8a2V5PmNvbS5hcHBsZS5wc" - "m\n" - "ludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+CgkJPGRpY3Q+CgkJCTxrZXk+" - "Y29tL\n" - "mFwcGxlLnByaW50LnRpY2tldC5jcmVhdG9yPC9rZXk+CgkJCTxzdHJpbmc+" - "Y29tLmFwcGxlLnBy\n" - "aW50LnBtLlBvc3RTY3JpcHQ8L3N0cmluZz4KCQkJPGtleT5jb20uYXBwbGUucHJpbnQudGlja2" - "V\n" - "0Lml0ZW1BcnJheTwva2V5PgoJCQk8YXJyYXk+" - "CgkJCQk8ZGljdD4KCQkJCQk8a2V5PmNvbS5hcH\n" - "BsZS5wcmludC5QYXBlckluZm8ucHBkLlBNUGFwZXJOYW1lPC9rZXk+" - "CgkJCQkJPHN0cmluZz5VU\n" - "yBMZXR0ZXI8L3N0cmluZz4KCQkJCQk8a2V5PmNvbS5hcHBsZS5wcmludC50aWNrZXQuY2xpZW5" - "0\n" - "PC9rZXk+" - "CgkJCQkJPHN0cmluZz5jb20uYXBwbGUucHJpbnQucG0uUG9zdFNjcmlwdDwvc3RyaW5\n" - "nPgoJCQkJCTxrZXk+Y29tLmFwcGxlLnByaW50LnRpY2tldC5tb2REYXRlPC9rZXk+" - "CgkJCQkJPG\n" - "RhdGU+MjAwMy0wNy0wMVQxNzo0OTozNlo8L2RhdGU+" - "CgkJCQkJPGtleT5jb20uYXBwbGUucHJpb\n" - "nQudGlja2V0LnN0YXRlRmxhZzwva2V5PgoJCQkJCTxpbnRlZ2VyPjE8L2ludGVnZXI+" - "CgkJCQk8\n" - "L2RpY3Q+CgkJCTwvYXJyYXk+CgkJPC9kaWN0PgoJCTxrZXk+" - "Y29tLmFwcGxlLnByaW50LnRpY2t\n" - "ldC5BUElWZXJzaW9uPC9rZXk+CgkJPHN0cmluZz4wMC4yMDwvc3RyaW5nPgoJCTxrZXk+" - "Y29tLm\n" - "FwcGxlLnByaW50LnRpY2tldC5wcml2YXRlTG9jazwva2V5PgoJCTxmYWxzZS8+" - "CgkJPGtleT5jb\n" - "20uYXBwbGUucHJpbnQudGlja2V0LnR5cGU8L2tleT4KCQk8c3RyaW5nPmNvbS5hcHBsZS5wcml" - "u\n" - "dC5QYXBlckluZm9UaWNrZXQ8L3N0cmluZz4KCTwvZGljdD4KCTxrZXk+" - "Y29tLmFwcGxlLnByaW5\n" - "0LnRpY2tldC5BUElWZXJzaW9uPC9rZXk+Cgk8c3RyaW5nPjAwLjIwPC9zdHJpbmc+" - "Cgk8a2V5Pm\n" - "NvbS5hcHBsZS5wcmludC50aWNrZXQucHJpdmF0ZUxvY2s8L2tleT4KCTxmYWxzZS8+" - "Cgk8a2V5P\n" - "mNvbS5hcHBsZS5wcmludC50aWNrZXQudHlwZTwva2V5PgoJPHN0cmluZz5jb20uYXBwbGUucHJ" - "p\n" - "bnQuUGFnZUZvcm1hdFRpY2tldDwvc3RyaW5nPgo8L2RpY3Q+CjwvcGxpc3Q+" - "CjhCSU0D6QAAAAA\n" - "AeAADAAAASABIAAAAAALeAkD/7v/uAwYCUgNnBSgD/" - "AACAAAASABIAAAAAALYAigAAQAAAGQAAA\n" - "ABAAMDAwAAAAF//" - "wABAAEAAAAAAAAAAAAAAABoCAAZAZAAAAAAACAAAAAAAAAAAAAAAAAAAAAAA\n" - "AAAAAAAAAAAADhCSU0D7QAAAAAAEABIAAAAAQABAEgAAAABAAE4QklNBCYAAAAAAA4AAAAAAAA" - "A\n" - "AAAAP4AAADhCSU0EDQAAAAAABAAAAB44QklNBBkAAAAAAAQAAAAeOEJJTQPzAAAAAAAJAAAAAA" - "A\n" - "AAAABADhCSU0ECgAAAAAAAQAAOEJJTScQAAAAAAAKAAEAAAAAAAAAAThCSU0D9QAAAAAASAAvZ" - "m\n" - "YAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQAyAAAAAQBaAAAABgAAAAAAAQA1AAAA" - "A\n" - "QAtAAAABgAAAAAAAThCSU0D+AAAAAAAcAAA/////////////////////////////wPoAAAAAP/" - "/\n" - "//////////////////////////8D6AAAAAD/////////////////////////////A+gAAAAA//" - "/\n" - "//////////////////////////" - "wPoAAA4QklNBAgAAAAAABAAAAABAAACQAAAAkAAAAAAOEJJTQ\n" - "QeAAAAAAAEAAAAADhCSU0EGgAAAAADRQAAAAYAAAAAAAAAAAAAAGQAAABkAAAACABEAFMAQwAw" - "A\n" - "DIAMwAyADUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAGQAAABkAAAAAAAAAAA" - "A\n" - "AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAABudWxsAAAAAgAAAAZib3VuZH" - "N\n" - "PYmpjAAAAAQAAAAAAAFJjdDEAAAAEAAAAAFRvcCBsb25nAAAAAAAAAABMZWZ0bG9uZwAAAAAAA" - "A\n" - "AAQnRvbWxvbmcAAABkAAAAAFJnaHRsb25nAAAAZAAAAAZzbGljZXNWbExzAAAAAU9iamMAAAAB" - "A\n" - "AAAAAAFc2xpY2UAAAASAAAAB3NsaWNlSURsb25nAAAAAAAAAAdncm91cElEbG9uZwAAAAAAAAA" - "G\n" - "b3JpZ2luZW51bQAAAAxFU2xpY2VPcmlnaW4AAAANYXV0b0dlbmVyYXRlZAAAAABUeXBlZW51bQ" - "A\n" - "AAApFU2xpY2VUeXBlAAAAAEltZyAAAAAGYm91bmRzT2JqYwAAAAEAAAAAAABSY3QxAAAABAAAA" - "A\n" - "BUb3AgbG9uZwAAAAAAAAAATGVmdGxvbmcAAAAAAAAAAEJ0b21sb25nAAAAZAAAAABSZ2h0bG9u" - "Z\n" - "wAAAGQAAAADdXJsVEVYVAAAAAEAAAAAAABudWxsVEVYVAAAAAEAAAAAAABNc2dlVEVYVAAAAAE" - "A\n" - "AAAAAAZhbHRUYWdURVhUAAAAAQAAAAAADmNlbGxUZXh0SXNIVE1MYm9vbAEAAAAIY2VsbFRleH" - "R\n" - "URVhUAAAAAQAAAAAACWhvcnpBbGlnbmVudW0AAAAPRVNsaWNlSG9yekFsaWduAAAAB2RlZmF1b" - "H\n" - "QAAAAJdmVydEFsaWduZW51bQAAAA9FU2xpY2VWZXJ0QWxpZ24AAAAHZGVmYXVsdAAAAAtiZ0Nv" - "b\n" - "G9yVHlwZWVudW0AAAARRVNsaWNlQkdDb2xvclR5cGUAAAAATm9uZQAAAAl0b3BPdXRzZXRsb25" - "n\n" - "AAAAAAAAAApsZWZ0T3V0c2V0bG9uZwAAAAAAAAAMYm90dG9tT3V0c2V0bG9uZwAAAAAAAAALcm" - "l\n" - "naHRPdXRzZXRsb25nAAAAAAA4QklNBBEAAAAAAAEBADhCSU0EFAAAAAAABAAAAAE4QklNBAwAA" - "A\n" - "AACfkAAAABAAAAZAAAAGQAAAEsAAB1MAAACd0AGAAB/9j/4AAQSkZJRgABAgEASABIAAD/" - "7QAMQ\n" - "WRvYmVfQ00AAv/uAA5BZG9iZQBkgAAAAAH/" - "2wCEAAwICAgJCAwJCQwRCwoLERUPDAwPFRgTExUT\n" - "ExgRDAwMDAwMEQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwBDQsLDQ4NEA4OEBQODg4UFA" - "4\n" - "ODg4UEQwMDAwMEREMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/" - "AABEIAGQAZA\n" - "MBIgACEQEDEQH/3QAEAAf/xAE/" - "AAABBQEBAQEBAQAAAAAAAAADAAECBAUGBwgJCgsBAAEFAQEBA\n" - "QEBAAAAAAAAAAEAAgMEBQYHCAkKCxAAAQQBAwIEAgUHBggFAwwzAQACEQMEIRIxBUFRYRMicYE" - "y\n" - "BhSRobFCIyQVUsFiMzRygtFDByWSU/" - "Dh8WNzNRaisoMmRJNUZEXCo3Q2F9JV4mXys4TD03Xj80Y\n" - "nlKSFtJXE1OT0pbXF1eX1VmZ2hpamtsbW5vY3R1dnd4eXp7fH1+" - "f3EQACAgECBAQDBAUGBwcGBT\n" - "UBAAIRAyExEgRBUWFxIhMFMoGRFKGxQiPBUtHwMyRi4XKCkkNTFWNzNPElBhaisoMHJjXC0kST" - "V\n" - "KMXZEVVNnRl4vKzhMPTdePzRpSkhbSVxNTk9KW1xdXl9VZmdoaWprbG1ub2JzdHV2d3h5ent8f" - "/\n" - "2gAMAwEAAhEDEQA/" - "APLtso1NRc0vP0Rok8NYyPEfijOG2ljBoAJPxKFppZtbS4Rz38kV+OPRDge\n" - "T89EPHBfvLjtb3P8A30K/j47cgsrYNxGpPYJpK8RtyXUlvPfsobV0GV0uippLiX3EaMb2/" - "rKgMB\n" - "1ghoiNST4BESCjjLmxqmKtvxiXQ0cd0q8E2bjIDWjk9z5I8QW8JaoHcdkUePZJtZD9p8YU/" - "Rsc/\n" - "wBNjS5zjDWjUk+SSKYaJLYq+qWeYGQ5lBPLJ3OA8wz2/wDSWni/" - "U3H2AXW2l2oloa0f9LcjSLeU\n" - "hJdb/wAyqd387Zt+DZ5SSpVh/9DzO6dw7gGPuVn6ft/" - "kyPkqwlxjw1Rnh24QNWjUeR5TSuDc6bg\n" - "fatpsJZQ3sNC4rWfkVYpbi4LAb3aANEkFLp7GHGYxuhAj4K/" - "hYVNDjYGzZ++eSSoSbLZjGgwxul\n" - "XNrPqO35FukdmzyXOQeqtqwqRg4o/SOAN9ng3/" - "AMzW02txZ9I+ZHKr241UOcWDaz3uLtSSPEpWu\n" - "rR5XPeylmyNr4BIPPCyH2Oc6T8kXNvddkPe/" - "VzjJPxQAJMKeIoNScrPk2MbfddXUNXvcGtPx0Xb\n" - "dJ6NXjOD2Dfdw6w9v5LFW+q/1WLA3Ly9LSJaz91p/" - "wDRjl2lOLWwAMbEJErWjRgESYieVdZhsMF\n" - "wMt08ldrx/vVivHaOdSgCoud9krmElpba93ASTlr/AP/R83ohr97voiJV/" - "Fq9QvsI+mdPgs1thc\n" - "BWO5C38CoOY1g78qOejLiGvknxLAyGtExp5K9uzGt9RrNw7DhRfQKKx6bZIGgPj4rPycLqWVtI" - "s\n" - "JGu5skDyTBRZtQNrb1fU8xrtpBaO4MLQxcx1sNuEjt5rMGJR9noY5hF7Wxa8aAnxVvDb6bgHH2" - "z\n" - "omk0e64ajUUXnev9Idi5rrWAux7SXNd4E/muS+rHSjm9VbPtZjj1CSJBI+g3+0uh69b+iDG/" - "QcD\n" - "u0nQCeFP6l0MZhWX/" - "AJ1xM+QafY1TQlY1a+WABsdXp8Sp27aBH+vZaVbC0ADlVcASwtdOolp8Ct\n" - "BjmtGv0uI8EmJmxkIjWkmPEKLSPiidxIgJKRbDPCSN5pJyH//S87uw/" - "suZ6c72iC13kVs9PdDmk\n" - "KllVziV3cuafc7yP0QjYFh26cqM6hsxAjIj6u6xzbDHh3R663AaceH+" - "5BwdruVp2PqZUA0a9yo6\n" - "DPQajscnXb8YQdzC8H909joiZttoxoBIa4gGOQ3uqh+z1RuD2Ds4j2n+39FNKaFMevS/" - "p5LPpSA\n" - "I8/b/ABW70THZXj11VjaIAIHgFl5VdD8AneDMaec6Lb6QAKmu7x+VSw2a3MdF/" - "rF9YKeh4B9OHZ\n" - "lpAprPH8p7v5DFwrPrV9YDa645toLjMaFo8mtcEvrhkWZHXbg7T0Q2to8o3f8AfkarEitlVTKn" - "Y\n" - "ra992QQ2wOfG57H2bg7H2fzbFKA130P6n9dHWemCx5H2mk7LgPH818f8IuhAka6ea8y/" - "wAWrcod\n" - "VyrceRhBsPae5J/Qj+sxq9KDpMuMuKBCEntnny/1CSaWxM6pIKf/0/" - "MvtF3pCrefTBnbOi1elP3\n" - "Et8Vi+Sv9LuNd4HwTSNGSEqkLerwtwn+SYKtOeS4A8Krh2j1D/" - "K1Vu4B5gaDmVDJtAr7zYYGoRB\n" - "QDWQ4c9h/" - "csuyjI3fobnDyJR8fF6ltcTaXRwCkAuAsfMGr1TGFNdTmEwLWS2dIK6npLgK2T4Lle\n" - "pUZxoc9+6K4eR5NO5bPT73NoqIfoILT/JcFJDZr8zGiNXnvrfiur6/" - "Y8tht7WvaexgbXf8AUrFt\n" - "8IExyvRusYDOsYTAIbfWdzHRJ8HN/" - "tLj7OgdRZawmreHP2gt9wEfvtH0f7SkDXe7+o+AOn9DquL\n" - "f0mV+leQPH6H+axafUvrB07ptJtyshtTZDTEudJ7bWS5V6MmyltVLn7ht2hwECQP+isb60/" - "Vqvr\n" - "tbLsa1lObVIJd9Gxv5rXx9F7fzHpIbf/jgfVnd/TLYj6XoOhJcP/zE+sOzd6dW7dt2eo3dH7/" - "9R\n" - "JJWj//" - "U8uiGFx76BFZLQ2xvLeVGAWQrFDJbtKBSHd6blNura4H3BbDXB7InVcZXZdh2bmTt7hbO\n" - "J1dj2gzCjlFnhPod3WLHB+" - "n3o9ZsAkFVMfMrs7orLmgkHUdkyqZQQWWQbLGlrjMjUeSrfV3Ltsw\n" - "30EBzcd5YCedvLETJya66nWOIAaCVnfU/" - "KuZn21CDVa02PngQdHf9LapMfVhzkaAPUUW3M91YaR\n" - "3YDJ+WiBmZGazPo9Kttdt2j63E6s/fft/d/NWjXkMra7KtO2qkE6cErHpvsyMmzPu0dY4Bg/" - "dYP\n" - "otTpyoaMUI2XUya8tzG/pi0NMtICo/" - "bsut21gdcWclkj5OncxaDrw6kM+9QxQzaWRAGii4pDqzC\n" - "MT02aX7WzPU9b7PrG3bvO6P6yStfZm+pHnPySS4590+3jf/" - "V8yb+CsUbp8uyz0kDskbu2dmz9J8\n" - "lSt9Ld+gn1O8cKikmxXydbH+3bhsmfwWj/lONYlcwkhL6L4bfpOxn/tD0/wBN/N944Wh9VJm/" - "b/\n" - "O+347df+/rl0k+O38GLJ83X/CfTOt7v2dV6P8AMbx6njHb/" - "pKuN3pN2+IXnaSjybr8e31fUqd+0\n" - "Sj487DHMryZJMXjq+sfpPX84SXk6SSX/" - "9kAOEJJTQQhAAAAAABVAAAAAQEAAAAPAEEAZABvAGIA\n" - "ZQAgAFAAaABvAHQAbwBzAGgAbwBwAAAAEwBBAGQAbwBiAGUAIABQAGgAbwB0AG8AcwBoAG8AcA" - "A\n" - "gADcALgAwAAAAAQA4QklNBAYAAAAAAAcABQAAAAEBAP/" - "hFWdodHRwOi8vbnMuYWRvYmUuY29tL3\n" - "hhcC8xLjAvADw/eHBhY2tldCBiZWdpbj0n77u/" - "JyBpZD0nVzVNME1wQ2VoaUh6cmVTek5UY3prY\n" - "zlkJz8+Cjw/YWRvYmUteGFwLWZpbHRlcnMgZXNjPSJDUiI/" - "Pgo8eDp4YXBtZXRhIHhtbG5zOng9\n" - "J2Fkb2JlOm5zOm1ldGEvJyB4OnhhcHRrPSdYTVAgdG9vbGtpdCAyLjguMi0zMywgZnJhbWV3b3" - "J\n" - "rIDEuNSc+" - "CjxyZGY6UkRGIHhtbG5zOnJkZj0naHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi\n" - "1yZGYtc3ludGF4LW5zIycgeG1sbnM6aVg9J2h0dHA6Ly9ucy5hZG9iZS5jb20vaVgvMS4wLyc+" - "C\n" - "gogPHJkZjpEZXNjcmlwdGlvbiBhYm91dD0ndXVpZDoyMmQwMmIwYS1iMjQ5LTExZGItOGFmOC0" - "5\n" - "MWQ1NDAzZjkyZjknCiAgeG1sbnM6cGRmPSdodHRwOi8vbnMuYWRvYmUuY29tL3BkZi8xLjMvJz" - "4\n" - "KICA8IS0tIHBkZjpTdWJqZWN0IGlzIGFsaWFzZWQgLS0+" - "CiA8L3JkZjpEZXNjcmlwdGlvbj4KCi\n" - "A8cmRmOkRlc2NyaXB0aW9uIGFib3V0PSd1dWlkOjIyZDAyYjBhLWIyNDktMTFkYi04YWY4LTkx" - "Z\n" - "DU0MDNmOTJmOScKICB4bWxuczpwaG90b3Nob3A9J2h0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9" - "z\n" - "aG9wLzEuMC8nPgogIDwhLS0gcGhvdG9zaG9wOkNhcHRpb24gaXMgYWxpYXNlZCAtLT4KIDwvcm" - "R\n" - "mOkRlc2NyaXB0aW9uPgoKIDxyZGY6RGVzY3JpcHRpb24gYWJvdXQ9J3V1aWQ6MjJkMDJiMGEtY" - "j\n" - "I0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5JwogIHhtbG5zOnhhcD0naHR0cDovL25zLmFkb2Jl" - "L\n" - "mNvbS94YXAvMS4wLyc+" - "CiAgPCEtLSB4YXA6RGVzY3JpcHRpb24gaXMgYWxpYXNlZCAtLT4KIDwv\n" - "cmRmOkRlc2NyaXB0aW9uPgoKIDxyZGY6RGVzY3JpcHRpb24gYWJvdXQ9J3V1aWQ6MjJkMDJiMG" - "E\n" - "tYjI0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5JwogIHhtbG5zOnhhcE1NPSdodHRwOi8vbnMuY" - "W\n" - "RvYmUuY29tL3hhcC8xLjAvbW0vJz4KICA8eGFwTU06RG9jdW1lbnRJRD5hZG9iZTpkb2NpZDpw" - "a\n" - "G90b3Nob3A6MjJkMDJiMDYtYjI0OS0xMWRiLThhZjgtOTFkNTQwM2Y5MmY5PC94YXBNTTpEb2N" - "1\n" - "bWVudElEPgogPC9yZGY6RGVzY3JpcHRpb24+" - "CgogPHJkZjpEZXNjcmlwdGlvbiBhYm91dD0ndXV\n" - "pZDoyMmQwMmIwYS1iMjQ5LTExZGItOGFmOC05MWQ1NDAzZjkyZjknCiAgeG1sbnM6ZGM9J2h0d" - "H\n" - "A6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvJz4KICA8ZGM6ZGVzY3JpcHRpb24+" - "CiAgIDxyZ\n" - "GY6QWx0PgogICAgPHJkZjpsaSB4bWw6bGFuZz0neC1kZWZhdWx0Jz4gICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgPC9yZGY6bGk+" - "CiAgIDwvcmRmOkFsdD4KICA8L2RjOmRlc2NyaXB0aW9\n" - "uPgogPC9yZGY6RGVzY3JpcHRpb24+Cgo8L3JkZjpSREY+" - "CjwveDp4YXBtZXRhPgogICAgICAgIC\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "A\n" - "ogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAK" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg" - "I\n" - "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICA" - "g\n" - "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC" - "A\n" - "gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgI" - "C\n" - "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0ndyc/" - "P\n" - "v/uAA5BZG9iZQBkQAAAAAH/" - "2wCEAAQDAwMDAwQDAwQGBAMEBgcFBAQFBwgGBgcGBggKCAkJCQkI\n" - "CgoMDAwMDAoMDAwMDAwMDAwMDAwMDAwMDAwMDAwBBAUFCAcIDwoKDxQODg4UFA4ODg4UEQwMDA" - "w\n" - "MEREMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/" - "AABEIAGQAZAMBEQACEQEDEQ\n" - "H/3QAEAA3/" - "xAGiAAAABwEBAQEBAAAAAAAAAAAEBQMCBgEABwgJCgsBAAICAwEBAQEBAAAAAAAAA\n" - "AEAAgMEBQYHCAkKCxAAAgEDAwIEAgYHAwQCBgJzAQIDEQQABSESMUFRBhNhInGBFDKRoQcVsUI" - "j\n" - "wVLR4TMWYvAkcoLxJUM0U5KismNzwjVEJ5OjszYXVGR0w9LiCCaDCQoYGYSURUaktFbTVSga8u" - "P\n" - "zxNTk9GV1hZWltcXV5fVmdoaWprbG1ub2N0dXZ3eHl6e3x9fn9zhIWGh4iJiouMjY6PgpOUlZa" - "X\n" - "mJmam5ydnp+" - "So6SlpqeoqaqrrK2ur6EQACAgECAwUFBAUGBAgDA20BAAIRAwQhEjFBBVETYSIGc\n" - "YGRMqGx8BTB0eEjQhVSYnLxMyQ0Q4IWklMlomOywgdz0jXiRIMXVJMICQoYGSY2RRonZHRVN/" - "Kj\n" - "s8MoKdPj84SUpLTE1OT0ZXWFlaW1xdXl9UZWZnaGlqa2xtbm9kdXZ3eHl6e3x9fn9zhIWGh4iJ" - "i\n" - "ouMjY6Pg5SVlpeYmZqbnJ2en5KjpKWmp6ipqqusra6vr/2gAMAwEAAhEDEQA/" - "APBnplwPAdR+GB\n" - "KY6dYtNG1w39yh4+xb+zIksgEfFaRSSoIx8f7RPRRkSWQimM+lRmwWVXFWYigHxUUVoMiJM+" - "Fj0\n" - "tg0RBegLE0Wu+3c+GTBazFCGI7HtSp9slbFYYzyoBsegw2hY1Afl3wqqRqahk+" - "0tDgKpgu4DAUU\n" - "+HY+GRS2ePiMKtUB3G+KGuONq//" - "Q8OzpFbW5WnxMop4k9crG5ZnZNJkEOn21utVRYw7HxZtz+OR\n" - "vdsrZ2lRtci4aVxFEQA0neg/" - "ZXxJpTITNNuOFss0vSotYNvZ2qGRkPKSTqiU8Sdqk5SZU5Ix8XJ\n" - "NNZ8k6bp8TtM73OputUtYq0Unux/" - "hkRkJOzZLCAN2KR+VpbtSkCBaDnIzdlWu59u+XeJTjeASk8\n" - "+juZOESEAVqx8BvU/" - "PJibScTrTy09560hkWOGFd2YgFnPQKD19zhOSkxw2l8Vm6XAiYb8gg+k5O\n" - "9mnhoon9H3cs5s7WF5pp29OGGMFndyaAKBuTiEEPQLD8h/" - "NDmNdYlttNkYjlbFjcXCr3LLH8II8\n" - "C2WUGviZvon/OPWkm3RNSv72SYllMkKxQRV67CQMSKYQAxMkR/" - "wBC56d61P0heel4cYuVOXWvTp\n" - "h4Qjjf/9Hw5qBYyISaqjBV+QpvkAzKcki4HomnIxck/" - "wBhtlR2bhunvlDywddMUl4zW+kQ9FQ8X\n" - "nfuSewrtmPkycPvc/" - "DhMhvyegXOrWWhmLQPKlsj6xIAiLCoZkY96nv7npmJvI2XOjQFMl0fyRqM\n" - "NoxvZvrGt33wlATwiMnVnY1LEdSfuyXF3KIDmUu88w2XlnTl8raAlb2ZFfVL0jdYRtQnxc7BfD" - "C\n" - "OaJR7nm3me5tdOtjbMvp3ZRXkV6chVQRX79hmVjgZG+" - "jgZ5jHGhzecXF5LPL6jEjstSSaDM51Ka\n" - "6MZ9S1C0sEBe8uZo4YCBXdjxGw60wEWyEqfUHkT8vLXRJFuLdTcaqfhlvWUErtukZ3ABPUjIXT" - "E\n" - "m3rGmeV2Tk5UKz/AG/E/wAcgZKya20C3b02kjYtH8AqCygbkUH0nLYlgUb+gbWtPbpXt/" - "n2ybB/\n" - "/9Lw4oaVxGd+PxH3qBkGaY3KyiSP01IkiUclH8sg+LKydm6INvZvKsFu+" - "kWtvD8LRoFNRup6moO\n" - "aqd277HsGW+XPLmn6XM17FF6l7vW4fd2Zuu+" - "RFls2tmUNrLJb7TSBertGQGqetDkxE0na0pvtHs\n" - "QkszWyiGAG5laYlnkeMVHJj8sA5rPk+SvMepTalqlxd3B5zTOXdj/" - "MxqafLpm5xioh5nPK5kpRG\n" - "pkcKAST0A6k5NpfUP5K/ki1ssHmHzF+71KRQ8Nud/Qibb/kYw6/" - "yjbrXISlSH07YaHbWyxx2kXE\n" - "KACB2zHJtLI7XSelBRvH2xCpvaaTDHXkOTVBPcUG2479RlsdmJVPRtvV+ylenQ0y62FP/" - "9PxRpo\n" - "WG5FxKKxKFDA+GVS5NsebLdFsRePc3siVW4f4QR0QVAGYeSXR2unhtZ6s60K6jt+MMSFwtF2+" - "xX\n" - "wr7eGUGLlRPQMsE2vxQm7itxKg3VCfT2+" - "nb8cDYaCDtfOXmCCcROrQrUhkkCHYn6emRMqZxjbLd\n" - "F1+W/" - "4xajHzjNCtQKMffETWUdngX5p+QZ9A8xS6hbo0ui37NNDPT7DOalHpsCD08Rmyw5ARTpdV\n" - "gIPEF35MeRn80ed4S5EdrpKm9kZ15K0iH92hB7Me/tmS60vt/" - "QrCYyekiBdgSTXcjqV9q9MokFD\n" - "N7S3aFVVR8RoK9zldqndvAY6nffr/AGYQqLhjdpCoIAZW22HavU/LJBUP9WblX0xTw7fOmWsX/" - "9\n" - "Tw7FdvMqWkQ3Z1qfED+mQIbI77PX/" - "LFis9vBajZm2Y+x65rMh3t30Bsze400aVaIbSLk6r8CMRT\n" - "l/" - "NmOcllnGDD9Y8uecNfEEiXrMgDGWAyGOOu5WlB+" - "vMrHODTlxZCdjsyFdB006VpVtLasurQxBL\n" - "64WiLI4/" - "aFT1ANOXemV5piR2b9NiljB4yyHy9CLOVI5GJhB+CvXY9R8xmINzs5HNZ+Z96BZpbxA\n" - "fVJo39UFefwopYgL4nMiMd2qZoIn/AJx00u3t/" - "Lt7qpp9Yv5GLf5MUTERqfbvmzBeezjd9H+VlL\n" - "wSQzBqsvOGQD7L12rXsemPNxmXQSxxIPU2nFV4HYqR1xEUWj4ZAxBryr2G+" - "J2VGDZlLrxUH6KZA\n" - "Fkqb15VFelfwy+2FP8A/" - "9Xxlf6AdA182Yk9eFeLxSjoVfcfSMo4uIOfkweFOnpvlWYrLEwNFAA+\n" - "nMOYdrhFvQLeSO7coBXiK8iKiv07Zj8Ac4QtNrW1njUcKcT+yAR/" - "xGmR4WcsStLpTuPU9IFaEsV\n" - "BP3k4m2AgBzSwyQNcIwNTE1aI3wnam9O2Ug7s5Ckk/" - "NDndeVXa2H78MqqV6jmeBp9+ZWKXqDjZ4\n" - "+gvVvy30qCy0qzsLRBCnBI2VdgUTqPvOZ7y+Q7pz+bn5q6d+VflZxZlJ/" - "NN4ypptk5qtB9qRwDX\n" - "gn/AAx2y2ItpfKFv+eH5qNeTajJ5ovVaVywSqvEtTUKqupAA6D2y0BNPtv/AJx//" - "M5PzL8mJeXT\n" - "L+ndPf6rqarSpkAqsnEAAeoN6DpkJRYci9lROSgSUUH9o9K5Tw0ztfSHnXkOtK9q+PHwydq//" - "9b\n" - "yxrVoZNBtNSA5zRMPXmH8j0CLXuBmHE+" - "qneamHpEuqYeV7pzFVTRgQK5XMNmnlb1vyyY5QA1OwJ\n" - "+eUF2seTOLu5s7azVIVAkpVn/" - "hhnIALG73Yz5jvb1dICqzpDNIqyFD8SxH7R28cxibZCiWOsdJs\n" - "PTM6XNstPhnkjIhcHuJBVfvOCiUSn0TfWrTTLjyw8guA/PifTO3xcxxA8a5ZAbimvJP0m3p/" - "kFF\n" - "WxhmpWQJ9NW3zZPHz5vlb/nIDVbrWfzO1RJhxGnpDaRL/" - "khA1T7ktmSOTAJhZaAUtLawsbayl8v\n" - "xWi3Gpay0cF3HPcFRJJHJMXVrcJ8UaAFG5LWjF8tAYW9H/wCcOo9bTzxrt/" - "owkTyksZW5gkIKvI\n" - "7k26nvyReRJHyyBWT7dWQyOWlbnK2526e1O1MqIUFE84uPLkOdK9RXI0E2/wD/1/DA1bURZLY/" - "W\n" - "ZDZqwb0eXw7dMgIi7bjllVXsz7yNcfWC0Vd3Ip92Y2UOz0cnsPlwyx8xQ/" - "u24sMxCadoJp9LOXk\n" - "VX/" - "uwRUE0BI8cokbLMyoKouHu2MaKGXw7fLDwgoGSkbHpaNZyLLHRSKcFFQQRvUdMlwUFOQyLzr\n" - "ztpCaba6fPau4ijv4OURY8AjVFKV7ZZiO+7Vnh6XvXkSWNbW2WTb92KDxIFMzwHlZc3zX+" - "fuizW\n" - "f5p3ty8XGDU4YLmCQiisyII3+4rvl8UB5ffEghRGvOm7AbnvWvjk1fen/" - "ONPldPKP5aWOpPCfr2\n" - "uE31y6q2wbaMEn+VAMDSdyzrzj+avlHyTp0l/r2rxWFuHWJuIeacu4qFCRgsajfBwsty89/" - "6Gr/\n" - "ACa9an+JL/hSnrfoubhXwpXpjwhaL//" - "Q8E1AqtcAZMs8l6i1nqMa1oSVP0VynKLDmaWdSfQXl69\n" - "jF1Jv8MhDb5rpB3AO7INRRLhhGp4R05FgaGvTMU8200xS70zVDMRp2pTIOvBmB3PgQP15kxIcn" - "D\n" - "LH/" - "EEz0rRvOJhldr9pQtCqyd6VrShGTqw5d4ARv9jHfOGl+ZJNMluLkyenaFbiRdqFYW5nrWuwO\n" - "MKB5MdSMRxnhlu9N8p6lLFpti63FUjCtFJTrDKvse2bEDZ4XJ9RZB+YPli2/" - "Mjy5bxoUi1a0YS2\n" - "85UOwIXiy9jRu+TBppfOF1+V3m22vrdpNPM8cs/oo0VJlUqQPjValR3+IZNNvtLS9Yu9Mi0/" - "TJr\n" - "kyp6QhWVVCIWRATsKBemwwFrDzT87fybs/" - "wA1bW21PRb+DTvNlgGSRp6iC8i3KJJx+y6n7D0Pwm\n" - "hxBZXT55/6Fi/Nf0PW+qWXq+t6X1X67F6vD/ftK04V/wBl344U8b//" - "0fBapxheVh9ocV+nviqY2\n" - "/qQJDew/" - "bioWHiuQ8m0bbvaPKGtQ6jaxSo9JloCK75gZI0Xb4sgkHo8MouoAvP94BsRmGY7uWJU\n" - "gzbypOQpNOvIdK4Nw2WCE2tXulTkjEEbdafgclxMhFBas93dwyQzsWDghlJFONKHJCZtjOFBJf" - "y\n" - "j1y9vPL9zpbIs0WkXL2sUjA8hDXlGCRXtt07ZuYvL5KJeo6bfajbkzWkcToR8dqshZ6in2fhNK" - "/\n" - "PDTUlXmHVvMdr5o0v9H2kdrqGpfu7m0nkY87Uf7tkKAU4/" - "s03ynLkEBbfihx7dGT6va67LbRMNR\n" - "aKOBuUTKgIBXoK1BOYR1M3aQ0mOt9yxUeZNdtJhFapLqMluSXkg5oxJrUMW5KevQ9MmNXXNqOi" - "H\n" - "Rr/Hmv8A1r9I/oj95w+r+j9Yf1+NP5+nXtTD+dF8tkfkOlv/0vC3ph7f0/" - "alcVTbS4A8QibuKb5\n" - "RI05EBYRFpdX3ly79a2qYCavH/" - "EY7TCYyMD5PSdD8+wXUSn1ArDqOhBzFlipz4ZwWbaV5htbsgF\n" - "qg9crMXKErGyYwajFGzxyHlGSePbbwyqg5UZlCaxrFpaWU95LIqrEjMAT4Dp9OShGy1ZslBhv/" - "A\n" - "Dj9rd/a+aL+xUK+m38L3d0HrxRo2HFtu5D8c27y8t30raarbWkU+u6g4gsNORn+EcUaSh2Pc0/" - "4\n" - "lgtAjezzbT9SutY1i782al8Nxdyotqh6xWybIg+jc5q8s+I27bFDgFPQp9RE+nrag70+" - "L6crrZu\n" - "4jajokdv6LW/Dii1Wo61PXKQN3KPK0L+h4/rnD/K5V78a5LhXxd3/0/" - "DMXXtwxVNtL9Xkaf3f7N\n" - "etfbKMjdjtkZ9D6ufrlK0+HpX8coF9HJ26sXvfqXrf7i/U+uften/d/" - "wCyrmQL6uOav0pvpP8Ai\n" - "b1F+rV59+vH6a5XLhcjH4nRmY/xpxHP0/UptWvT6Mx/RbmjxWK+aP8AFf1M/" - "pCv1Kvxen9inavf\n" - "MrFwXtzcLUeLXq5Mv/I3nz1b0v8AjofuKVry9KrUpTanOlf9jmQ68va/zH9b/COn/o7/" - "AI431mP\n" - "65SvLh+zWvbl9rMfNfC34K4kmj9T6lD6FKclp/DNYXZx5srsPrHor6nXvkgxTPS/" - "U+rv6dPU5mt\n" - "fngFN5ulv+l/pL/Lp/scerHo//2Q==\n"; - -static std::string gCommandLine; - -TEST(Base64, LargeSample) { - RTC_LOG(LS_VERBOSE) << "Testing specific base64 file"; - - char unescaped[64 * 1024]; - - // unescape that massive blob above - size_t size = Base64Unescape(SpecificTest, sizeof(SpecificTest), unescaped, - sizeof(unescaped)); - - EXPECT_EQ(size, sizeof(testbase64)); - EXPECT_EQ(0, memcmp(testbase64, unescaped, sizeof(testbase64))); -} - -bool DecodeTest(const char* encoded, - size_t expect_unparsed, - const char* decoded, - webrtc::Base64::DecodeFlags flags) { - std::string result; - size_t consumed = 0, encoded_len = strlen(encoded); - bool success = webrtc::Base64::DecodeFromArray(encoded, encoded_len, flags, - &result, &consumed); - size_t unparsed = encoded_len - consumed; - EXPECT_EQ(expect_unparsed, unparsed) - << "\"" << encoded << "\" -> \"" << decoded << "\""; - EXPECT_STREQ(decoded, result.c_str()); - return success; -} - -#define Flags(x, y, z) \ - webrtc::Base64::DO_PARSE_##x | webrtc::Base64::DO_PAD_##y | \ - webrtc::Base64::DO_TERM_##z - -TEST(Base64, DecodeParseOptions) { - // Trailing whitespace - EXPECT_TRUE(DecodeTest("YWJjZA== ", 1, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA== ", 0, "abcd", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA== ", 0, "abcd", Flags(ANY, YES, CHAR))); - - // Embedded whitespace - EXPECT_FALSE(DecodeTest("YWJjZA= =", 3, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA= =", 0, "abcd", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA= =", 0, "abcd", Flags(ANY, YES, CHAR))); - - // Embedded non-base64 characters - EXPECT_FALSE(DecodeTest("YWJjZA=*=", 3, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_FALSE(DecodeTest("YWJjZA=*=", 3, "abcd", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA=*=", 0, "abcd", Flags(ANY, YES, CHAR))); - - // Unexpected padding characters - EXPECT_FALSE(DecodeTest("YW=JjZA==", 7, "a", Flags(STRICT, YES, CHAR))); - EXPECT_FALSE(DecodeTest("YW=JjZA==", 7, "a", Flags(WHITE, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YW=JjZA==", 0, "abcd", Flags(ANY, YES, CHAR))); -} - -TEST(Base64, DecodePadOptions) { - // Padding - EXPECT_TRUE(DecodeTest("YWJjZA==", 0, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA==", 0, "abcd", Flags(STRICT, ANY, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA==", 2, "abcd", Flags(STRICT, NO, CHAR))); - - // Incomplete padding - EXPECT_FALSE(DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, ANY, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA=", 1, "abcd", Flags(STRICT, NO, CHAR))); - - // No padding - EXPECT_FALSE(DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, YES, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, ANY, CHAR))); - EXPECT_TRUE(DecodeTest("YWJjZA", 0, "abcd", Flags(STRICT, NO, CHAR))); -} - -TEST(Base64, DecodeTerminateOptions) { - // Complete quantum - EXPECT_TRUE(DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, BUFFER))); - EXPECT_TRUE(DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, CHAR))); - EXPECT_TRUE(DecodeTest("YWJj", 0, "abc", Flags(STRICT, NO, ANY))); - - // Complete quantum with trailing data - EXPECT_FALSE(DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, BUFFER))); - EXPECT_TRUE(DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, CHAR))); - EXPECT_TRUE(DecodeTest("YWJj*", 1, "abc", Flags(STRICT, NO, ANY))); - - // Incomplete quantum - EXPECT_FALSE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, BUFFER))); - EXPECT_FALSE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, CHAR))); - EXPECT_TRUE(DecodeTest("YWJ", 0, "ab", Flags(STRICT, NO, ANY))); -} - -TEST(Base64, GetNextBase64Char) { - // The table looks like this: - // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" - char next_char; - EXPECT_TRUE(webrtc::Base64::GetNextBase64Char('A', &next_char)); - EXPECT_EQ('B', next_char); - EXPECT_TRUE(webrtc::Base64::GetNextBase64Char('Z', &next_char)); - EXPECT_EQ('a', next_char); - EXPECT_TRUE(webrtc::Base64::GetNextBase64Char('/', &next_char)); - EXPECT_EQ('A', next_char); - EXPECT_FALSE(webrtc::Base64::GetNextBase64Char('&', &next_char)); - EXPECT_FALSE(webrtc::Base64::GetNextBase64Char('Z', nullptr)); -} - -} // namespace -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES diff --git a/rtc_base/third_party/base64/test_base64.h b/rtc_base/third_party/base64/test_base64.h deleted file mode 100644 index 51d8c58113..0000000000 --- a/rtc_base/third_party/base64/test_base64.h +++ /dev/null @@ -1,2111 +0,0 @@ -/* - * Copyright 2004 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 RTC_BASE_TEST_BASE64_H_ -#define RTC_BASE_TEST_BASE64_H_ - -/* This file was generated by googleclient/talk/binary2header.sh */ - -static unsigned char testbase64[] = { - 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, - 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xe1, 0x0d, 0x07, - 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x0c, 0x01, 0x0e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x00, 0x9e, 0x01, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, - 0x00, 0x00, 0x00, 0xbe, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, - 0x00, 0x00, 0x00, 0xc3, 0x01, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x01, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0xcc, 0x01, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0xd4, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x00, 0x00, 0x01, 0x31, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, - 0x00, 0x00, 0x00, 0xdc, 0x01, 0x32, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, - 0x00, 0x00, 0x00, 0xf0, 0x01, 0x3c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, - 0x00, 0x00, 0x01, 0x04, 0x02, 0x13, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x00, 0x00, 0x87, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x02, 0xc4, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x00, 0x53, 0x4f, 0x4e, 0x59, 0x00, 0x44, 0x53, 0x43, - 0x2d, 0x50, 0x32, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x41, 0x64, - 0x6f, 0x62, 0x65, 0x20, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, - 0x70, 0x20, 0x37, 0x2e, 0x30, 0x00, 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, - 0x31, 0x3a, 0x33, 0x30, 0x20, 0x32, 0x33, 0x3a, 0x31, 0x30, 0x3a, 0x30, - 0x34, 0x00, 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58, 0x20, 0x31, - 0x30, 0x2e, 0x34, 0x2e, 0x38, 0x00, 0x00, 0x1c, 0x82, 0x9a, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x6a, 0x82, 0x9d, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x72, 0x88, 0x22, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x88, 0x27, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x64, 0x00, 0x00, 0x90, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x04, 0x30, 0x32, 0x32, 0x30, 0x90, 0x03, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x7a, 0x90, 0x04, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x02, 0x8e, 0x91, 0x01, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x04, 0x01, 0x02, 0x03, 0x00, 0x91, 0x02, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xa2, 0x92, 0x04, 0x00, 0x0a, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xaa, 0x92, 0x05, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xb2, 0x92, 0x07, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x92, 0x08, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x92, 0x09, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x00, 0x00, 0x92, 0x0a, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0xba, 0xa0, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x04, 0x30, 0x31, 0x30, 0x30, 0xa0, 0x01, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0xa0, 0x03, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0xa3, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0xa3, 0x01, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0xa4, 0x01, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x03, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x06, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x08, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x09, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x0a, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, 0x1c, - 0x00, 0x00, 0x00, 0x0a, 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, 0x31, 0x3a, - 0x32, 0x30, 0x20, 0x32, 0x33, 0x3a, 0x30, 0x35, 0x3a, 0x35, 0x32, 0x00, - 0x32, 0x30, 0x30, 0x37, 0x3a, 0x30, 0x31, 0x3a, 0x32, 0x30, 0x20, 0x32, - 0x33, 0x3a, 0x30, 0x35, 0x3a, 0x35, 0x32, 0x00, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x4f, - 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x12, 0x01, 0x1b, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x1a, 0x01, 0x28, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x22, 0x02, 0x02, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x09, 0xdd, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, - 0x00, 0x00, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, - 0x49, 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, - 0xff, 0xed, 0x00, 0x0c, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x5f, 0x43, 0x4d, - 0x00, 0x02, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x00, - 0x64, 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0c, - 0x08, 0x08, 0x08, 0x09, 0x08, 0x0c, 0x09, 0x09, 0x0c, 0x11, 0x0b, 0x0a, - 0x0b, 0x11, 0x15, 0x0f, 0x0c, 0x0c, 0x0f, 0x15, 0x18, 0x13, 0x13, 0x15, - 0x13, 0x13, 0x18, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x01, 0x0d, 0x0b, 0x0b, 0x0d, 0x0e, 0x0d, 0x10, 0x0e, - 0x0e, 0x10, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, 0x0e, 0x0e, - 0x14, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, - 0x08, 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, - 0x03, 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x07, 0xff, 0xc4, 0x01, - 0x3f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x01, 0x05, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, - 0x00, 0x01, 0x04, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x07, 0x06, 0x08, - 0x05, 0x03, 0x0c, 0x33, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, 0x12, - 0x31, 0x05, 0x41, 0x51, 0x61, 0x13, 0x22, 0x71, 0x81, 0x32, 0x06, 0x14, - 0x91, 0xa1, 0xb1, 0x42, 0x23, 0x24, 0x15, 0x52, 0xc1, 0x62, 0x33, 0x34, - 0x72, 0x82, 0xd1, 0x43, 0x07, 0x25, 0x92, 0x53, 0xf0, 0xe1, 0xf1, 0x63, - 0x73, 0x35, 0x16, 0xa2, 0xb2, 0x83, 0x26, 0x44, 0x93, 0x54, 0x64, 0x45, - 0xc2, 0xa3, 0x74, 0x36, 0x17, 0xd2, 0x55, 0xe2, 0x65, 0xf2, 0xb3, 0x84, - 0xc3, 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x27, 0x94, 0xa4, 0x85, 0xb4, 0x95, - 0xc4, 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, - 0x76, 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, - 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x11, 0x00, - 0x02, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, - 0x06, 0x05, 0x35, 0x01, 0x00, 0x02, 0x11, 0x03, 0x21, 0x31, 0x12, 0x04, - 0x41, 0x51, 0x61, 0x71, 0x22, 0x13, 0x05, 0x32, 0x81, 0x91, 0x14, 0xa1, - 0xb1, 0x42, 0x23, 0xc1, 0x52, 0xd1, 0xf0, 0x33, 0x24, 0x62, 0xe1, 0x72, - 0x82, 0x92, 0x43, 0x53, 0x15, 0x63, 0x73, 0x34, 0xf1, 0x25, 0x06, 0x16, - 0xa2, 0xb2, 0x83, 0x07, 0x26, 0x35, 0xc2, 0xd2, 0x44, 0x93, 0x54, 0xa3, - 0x17, 0x64, 0x45, 0x55, 0x36, 0x74, 0x65, 0xe2, 0xf2, 0xb3, 0x84, 0xc3, - 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, - 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, - 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x27, 0x37, 0x47, 0x57, 0x67, - 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, - 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf2, 0xed, 0xb2, 0x8d, - 0x4d, 0x45, 0xcd, 0x2f, 0x3f, 0x44, 0x68, 0x93, 0xc3, 0x58, 0xc8, 0xf1, - 0x1f, 0x8a, 0x33, 0x86, 0xda, 0x58, 0xc1, 0xa0, 0x02, 0x4f, 0xc4, 0xa1, - 0x69, 0xa5, 0x9b, 0x5b, 0x4b, 0x84, 0x73, 0xdf, 0xc9, 0x15, 0xf8, 0xe3, - 0xd1, 0x0e, 0x07, 0x93, 0xf3, 0xd1, 0x0f, 0x1c, 0x17, 0xef, 0x2e, 0x3b, - 0x5b, 0xdc, 0xff, 0x00, 0xdf, 0x42, 0xbf, 0x8f, 0x8e, 0xdc, 0x82, 0xca, - 0xd8, 0x37, 0x11, 0xa9, 0x3d, 0x82, 0x69, 0x2b, 0xc4, 0x6d, 0xc9, 0x75, - 0x25, 0xbc, 0xf7, 0xec, 0xa1, 0xb5, 0x74, 0x19, 0x5d, 0x2e, 0x8a, 0x9a, - 0x4b, 0x89, 0x7d, 0xc4, 0x68, 0xc6, 0xf6, 0xfe, 0xb2, 0xa0, 0x30, 0x1d, - 0x60, 0x86, 0x88, 0x8d, 0x49, 0x3e, 0x01, 0x11, 0x20, 0xa3, 0x8c, 0xb9, - 0xb1, 0xaa, 0x62, 0xad, 0xbf, 0x18, 0x97, 0x43, 0x47, 0x1d, 0xd2, 0xaf, - 0x04, 0xd9, 0xb8, 0xc8, 0x0d, 0x68, 0xe4, 0xf7, 0x3e, 0x48, 0xf1, 0x05, - 0xbc, 0x25, 0xaa, 0x07, 0x71, 0xd9, 0x14, 0x78, 0xf6, 0x49, 0xb5, 0x90, - 0xfd, 0xa7, 0xc6, 0x14, 0xfd, 0x1b, 0x1c, 0xff, 0x00, 0x4d, 0x8d, 0x2e, - 0x73, 0x8c, 0x35, 0xa3, 0x52, 0x4f, 0x92, 0x48, 0xa6, 0x1a, 0x24, 0xb6, - 0x2a, 0xfa, 0xa5, 0x9e, 0x60, 0x64, 0x39, 0x94, 0x13, 0xcb, 0x27, 0x73, - 0x80, 0xf3, 0x0c, 0xf6, 0xff, 0x00, 0xd2, 0x5a, 0x78, 0xbf, 0x53, 0x71, - 0xf6, 0x01, 0x75, 0xb6, 0x97, 0x6a, 0x25, 0xa1, 0xad, 0x1f, 0xf4, 0xb7, - 0x23, 0x48, 0xb7, 0x94, 0x84, 0x97, 0x5b, 0xff, 0x00, 0x32, 0xa9, 0xdd, - 0xfc, 0xed, 0x9b, 0x7e, 0x0d, 0x9e, 0x52, 0x4a, 0x95, 0x61, 0xff, 0xd0, - 0xf3, 0x3b, 0xa7, 0x70, 0xee, 0x01, 0x8f, 0xb9, 0x59, 0xfa, 0x7e, 0xdf, - 0xe4, 0xc8, 0xf9, 0x2a, 0xc2, 0x5c, 0x63, 0xc3, 0x54, 0x67, 0x87, 0x6e, - 0x10, 0x35, 0x68, 0xd4, 0x79, 0x1e, 0x53, 0x4a, 0xe0, 0xdc, 0xe9, 0xb8, - 0x1f, 0x6a, 0xda, 0x6c, 0x25, 0x94, 0x37, 0xb0, 0xd0, 0xb8, 0xad, 0x67, - 0xe4, 0x55, 0x8a, 0x5b, 0x8b, 0x82, 0xc0, 0x6f, 0x76, 0x80, 0x34, 0x49, - 0x05, 0x2e, 0x9e, 0xc6, 0x1c, 0x66, 0x31, 0xba, 0x10, 0x23, 0xe0, 0xaf, - 0xe1, 0x61, 0x53, 0x43, 0x8d, 0x81, 0xb3, 0x67, 0xef, 0x9e, 0x49, 0x2a, - 0x12, 0x6c, 0xb6, 0x63, 0x1a, 0x0c, 0x31, 0xba, 0x55, 0xcd, 0xac, 0xfa, - 0x8e, 0xdf, 0x91, 0x6e, 0x91, 0xd9, 0xb3, 0xc9, 0x73, 0x90, 0x7a, 0xab, - 0x6a, 0xc2, 0xa4, 0x60, 0xe2, 0x8f, 0xd2, 0x38, 0x03, 0x7d, 0x9e, 0x0d, - 0xff, 0x00, 0xcc, 0xd6, 0xd3, 0x6b, 0x71, 0x67, 0xd2, 0x3e, 0x64, 0x72, - 0xab, 0xdb, 0x8d, 0x54, 0x39, 0xc5, 0x83, 0x6b, 0x3d, 0xee, 0x2e, 0xd4, - 0x92, 0x3c, 0x4a, 0x56, 0xba, 0xb4, 0x79, 0x5c, 0xf7, 0xb2, 0x96, 0x6c, - 0x8d, 0xaf, 0x80, 0x48, 0x3c, 0xf0, 0xb2, 0x1f, 0x63, 0x9c, 0xe9, 0x3f, - 0x24, 0x5c, 0xdb, 0xdd, 0x76, 0x43, 0xde, 0xfd, 0x5c, 0xe3, 0x24, 0xfc, - 0x50, 0x00, 0x93, 0x0a, 0x78, 0x8a, 0x0d, 0x49, 0xca, 0xcf, 0x93, 0x63, - 0x1b, 0x7d, 0xd7, 0x57, 0x50, 0xd5, 0xef, 0x70, 0x6b, 0x4f, 0xc7, 0x45, - 0xdb, 0x74, 0x9e, 0x8d, 0x5e, 0x33, 0x83, 0xd8, 0x37, 0xdd, 0xc3, 0xac, - 0x3d, 0xbf, 0x92, 0xc5, 0x5b, 0xea, 0xbf, 0xd5, 0x62, 0xc0, 0xdc, 0xbc, - 0xbd, 0x2d, 0x22, 0x5a, 0xcf, 0xdd, 0x69, 0xff, 0x00, 0xd1, 0x8e, 0x5d, - 0xa5, 0x38, 0xb5, 0xb0, 0x00, 0xc6, 0xc4, 0x24, 0x4a, 0xd6, 0x8d, 0x18, - 0x04, 0x49, 0x88, 0x9e, 0x55, 0xd6, 0x61, 0xb0, 0xc1, 0x70, 0x32, 0xdd, - 0x3c, 0x95, 0xda, 0xf1, 0xfe, 0xf5, 0x62, 0xbc, 0x76, 0x8e, 0x75, 0x28, - 0x02, 0xa2, 0xe7, 0x7d, 0x92, 0xb9, 0x84, 0x96, 0x96, 0xda, 0xf7, 0x70, - 0x12, 0x4e, 0x5a, 0xff, 0x00, 0xff, 0xd1, 0xf3, 0x7a, 0x21, 0xaf, 0xde, - 0xef, 0xa2, 0x22, 0x55, 0xfc, 0x5a, 0xbd, 0x42, 0xfb, 0x08, 0xfa, 0x67, - 0x4f, 0x82, 0xcd, 0x6d, 0x85, 0xc0, 0x56, 0x3b, 0x90, 0xb7, 0xf0, 0x2a, - 0x0e, 0x63, 0x58, 0x3b, 0xf2, 0xa3, 0x9e, 0x8c, 0xb8, 0x86, 0xbe, 0x49, - 0xf1, 0x2c, 0x0c, 0x86, 0xb4, 0x4c, 0x69, 0xe4, 0xaf, 0x6e, 0xcc, 0x6b, - 0x7d, 0x46, 0xb3, 0x70, 0xec, 0x38, 0x51, 0x7d, 0x02, 0x8a, 0xc7, 0xa6, - 0xd9, 0x20, 0x68, 0x0f, 0x8f, 0x8a, 0xcf, 0xc9, 0xc2, 0xea, 0x59, 0x5b, - 0x48, 0xb0, 0x91, 0xae, 0xe6, 0xc9, 0x03, 0xc9, 0x30, 0x51, 0x66, 0xd4, - 0x0d, 0xad, 0xbd, 0x5f, 0x53, 0xcc, 0x6b, 0xb6, 0x90, 0x5a, 0x3b, 0x83, - 0x0b, 0x43, 0x17, 0x31, 0xd6, 0xc3, 0x6e, 0x12, 0x3b, 0x79, 0xac, 0xc1, - 0x89, 0x47, 0xd9, 0xe8, 0x63, 0x98, 0x45, 0xed, 0x6c, 0x5a, 0xf1, 0xa0, - 0x27, 0xc5, 0x5b, 0xc3, 0x6f, 0xa6, 0xe0, 0x1c, 0x7d, 0xb3, 0xa2, 0x69, - 0x34, 0x7b, 0xae, 0x1a, 0x8d, 0x45, 0x17, 0x9d, 0xeb, 0xfd, 0x21, 0xd8, - 0xb9, 0xae, 0xb5, 0x80, 0xbb, 0x1e, 0xd2, 0x5c, 0xd7, 0x78, 0x13, 0xf9, - 0xae, 0x4b, 0xea, 0xc7, 0x4a, 0x39, 0xbd, 0x55, 0xb3, 0xed, 0x66, 0x38, - 0xf5, 0x09, 0x22, 0x41, 0x23, 0xe8, 0x37, 0xfb, 0x4b, 0xa1, 0xeb, 0xd6, - 0xfe, 0x88, 0x31, 0xbf, 0x41, 0xc0, 0xee, 0xd2, 0x74, 0x02, 0x78, 0x53, - 0xfa, 0x97, 0x43, 0x19, 0x85, 0x65, 0xff, 0x00, 0x9d, 0x71, 0x33, 0xe4, - 0x1a, 0x7d, 0x8d, 0x53, 0x42, 0x56, 0x35, 0x6b, 0xe5, 0x80, 0x06, 0xc7, - 0x57, 0xa7, 0xc4, 0xa9, 0xdb, 0xb6, 0x81, 0x1f, 0xeb, 0xd9, 0x69, 0x56, - 0xc2, 0xd0, 0x00, 0xe5, 0x55, 0xc0, 0x12, 0xc2, 0xd7, 0x4e, 0xa2, 0x5a, - 0x7c, 0x0a, 0xd0, 0x63, 0x9a, 0xd1, 0xaf, 0xd2, 0xe2, 0x3c, 0x12, 0x62, - 0x66, 0xc6, 0x42, 0x23, 0x5a, 0x49, 0x8f, 0x10, 0xa2, 0xd2, 0x3e, 0x28, - 0x9d, 0xc4, 0x88, 0x09, 0x29, 0x16, 0xc3, 0x3c, 0x24, 0x8d, 0xe6, 0x92, - 0x72, 0x1f, 0xff, 0xd2, 0xf3, 0xbb, 0xb0, 0xfe, 0xcb, 0x99, 0xe9, 0xce, - 0xf6, 0x88, 0x2d, 0x77, 0x91, 0x5b, 0x3d, 0x3d, 0xd0, 0xe6, 0x90, 0xa9, - 0x65, 0x57, 0x38, 0x95, 0xdd, 0xcb, 0x9a, 0x7d, 0xce, 0xf2, 0x3f, 0x44, - 0x23, 0x60, 0x58, 0x76, 0xe9, 0xca, 0x8c, 0xea, 0x1b, 0x31, 0x02, 0x32, - 0x23, 0xea, 0xee, 0xb1, 0xcd, 0xb0, 0xc7, 0x87, 0x74, 0x7a, 0xeb, 0x70, - 0x1a, 0x71, 0xe1, 0xfe, 0xe4, 0x1c, 0x1d, 0xae, 0xe5, 0x69, 0xd8, 0xfa, - 0x99, 0x50, 0x0d, 0x1a, 0xf7, 0x2a, 0x3a, 0x0c, 0xf4, 0x1a, 0x8e, 0xc7, - 0x27, 0x5d, 0xbf, 0x18, 0x41, 0xdc, 0xc2, 0xf0, 0x7f, 0x74, 0xf6, 0x3a, - 0x22, 0x66, 0xdb, 0x68, 0xc6, 0x80, 0x48, 0x6b, 0x88, 0x06, 0x39, 0x0d, - 0xee, 0xaa, 0x1f, 0xb3, 0xd5, 0x1b, 0x83, 0xd8, 0x3b, 0x38, 0x8f, 0x69, - 0xfe, 0xdf, 0xd1, 0x4d, 0x29, 0xa1, 0x4c, 0x7a, 0xf4, 0xbf, 0xa7, 0x92, - 0xcf, 0xa5, 0x20, 0x08, 0xf3, 0xf6, 0xff, 0x00, 0x15, 0xbb, 0xd1, 0x31, - 0xd9, 0x5e, 0x3d, 0x75, 0x56, 0x36, 0x88, 0x00, 0x81, 0xe0, 0x16, 0x5e, - 0x55, 0x74, 0x3f, 0x00, 0x9d, 0xe0, 0xcc, 0x69, 0xe7, 0x3a, 0x2d, 0xbe, - 0x90, 0x00, 0xa9, 0xae, 0xef, 0x1f, 0x95, 0x4b, 0x0d, 0x9a, 0xdc, 0xc7, - 0x45, 0xfe, 0xb1, 0x7d, 0x60, 0xa7, 0xa1, 0xe0, 0x1f, 0x4e, 0x1d, 0x99, - 0x69, 0x02, 0x9a, 0xcf, 0x1f, 0xca, 0x7b, 0xbf, 0x90, 0xc5, 0xc2, 0xb3, - 0xeb, 0x57, 0xd6, 0x03, 0x6b, 0xae, 0x39, 0xb6, 0x82, 0xe3, 0x31, 0xa1, - 0x68, 0xf2, 0x6b, 0x5c, 0x12, 0xfa, 0xe1, 0x91, 0x66, 0x47, 0x5d, 0xb8, - 0x3b, 0x4f, 0x44, 0x36, 0xb6, 0x8f, 0x28, 0xdd, 0xff, 0x00, 0x7e, 0x46, - 0xab, 0x12, 0x2b, 0x65, 0x55, 0x32, 0xa7, 0x62, 0xb6, 0xbd, 0xf7, 0x64, - 0x10, 0xdb, 0x03, 0x9f, 0x1b, 0x9e, 0xc7, 0xd9, 0xb8, 0x3b, 0x1f, 0x67, - 0xf3, 0x6c, 0x52, 0x80, 0xd7, 0x7d, 0x0f, 0xea, 0x7f, 0x5d, 0x1d, 0x67, - 0xa6, 0x0b, 0x1e, 0x47, 0xda, 0x69, 0x3b, 0x2e, 0x03, 0xc7, 0xf3, 0x5f, - 0x1f, 0xf0, 0x8b, 0xa1, 0x02, 0x46, 0xba, 0x79, 0xaf, 0x32, 0xff, 0x00, - 0x16, 0xad, 0xca, 0x1d, 0x57, 0x2a, 0xdc, 0x79, 0x18, 0x41, 0xb0, 0xf6, - 0x9e, 0xe4, 0x9f, 0xd0, 0x8f, 0xeb, 0x31, 0xab, 0xd2, 0x83, 0xa4, 0xcb, - 0x8c, 0xb8, 0xa0, 0x42, 0x12, 0x7b, 0x67, 0x9f, 0x2f, 0xf5, 0x09, 0x26, - 0x96, 0xc4, 0xce, 0xa9, 0x20, 0xa7, 0xff, 0xd3, 0xf3, 0x2f, 0xb4, 0x5d, - 0xe9, 0x0a, 0xb7, 0x9f, 0x4c, 0x19, 0xdb, 0x3a, 0x2d, 0x5e, 0x94, 0xfd, - 0xc4, 0xb7, 0xc5, 0x62, 0xf9, 0x2b, 0xfd, 0x2e, 0xe3, 0x5d, 0xe0, 0x7c, - 0x13, 0x48, 0xd1, 0x92, 0x12, 0xa9, 0x0b, 0x7a, 0xbc, 0x2d, 0xc2, 0x7f, - 0x92, 0x60, 0xab, 0x4e, 0x79, 0x2e, 0x00, 0xf0, 0xaa, 0xe1, 0xda, 0x3d, - 0x43, 0xfc, 0xad, 0x55, 0xbb, 0x80, 0x79, 0x81, 0xa0, 0xe6, 0x54, 0x32, - 0x6d, 0x02, 0xbe, 0xf3, 0x61, 0x81, 0xa8, 0x44, 0x14, 0x03, 0x59, 0x0e, - 0x1c, 0xf6, 0x1f, 0xdc, 0xb2, 0xec, 0xa3, 0x23, 0x77, 0xe8, 0x6e, 0x70, - 0xf2, 0x25, 0x1f, 0x1f, 0x17, 0xa9, 0x6d, 0x71, 0x36, 0x97, 0x47, 0x00, - 0xa4, 0x02, 0xe0, 0x2c, 0x7c, 0xc1, 0xab, 0xd5, 0x31, 0x85, 0x35, 0xd4, - 0xe6, 0x13, 0x02, 0xd6, 0x4b, 0x67, 0x48, 0x2b, 0xa9, 0xe9, 0x2e, 0x02, - 0xb6, 0x4f, 0x82, 0xe5, 0x7a, 0x95, 0x19, 0xc6, 0x87, 0x3d, 0xfb, 0xa2, - 0xb8, 0x79, 0x1e, 0x4d, 0x3b, 0x96, 0xcf, 0x4f, 0xbd, 0xcd, 0xa2, 0xa2, - 0x1f, 0xa0, 0x82, 0xd3, 0xfc, 0x97, 0x05, 0x24, 0x36, 0x6b, 0xf3, 0x31, - 0xa2, 0x35, 0x79, 0xef, 0xad, 0xf8, 0xae, 0xaf, 0xaf, 0xd8, 0xf2, 0xd8, - 0x6d, 0xed, 0x6b, 0xda, 0x7b, 0x18, 0x1b, 0x5d, 0xff, 0x00, 0x52, 0xb1, - 0x6d, 0xf0, 0x81, 0x31, 0xca, 0xf4, 0x6e, 0xb1, 0x80, 0xce, 0xb1, 0x84, - 0xc0, 0x21, 0xb7, 0xd6, 0x77, 0x31, 0xd1, 0x27, 0xc1, 0xcd, 0xfe, 0xd2, - 0xe3, 0xec, 0xe8, 0x1d, 0x45, 0x96, 0xb0, 0x9a, 0xb7, 0x87, 0x3f, 0x68, - 0x2d, 0xf7, 0x01, 0x1f, 0xbe, 0xd1, 0xf4, 0x7f, 0xb4, 0xa4, 0x0d, 0x77, - 0xbb, 0xfa, 0x8f, 0x80, 0x3a, 0x7f, 0x43, 0xaa, 0xe2, 0xdf, 0xd2, 0x65, - 0x7e, 0x95, 0xe4, 0x0f, 0x1f, 0xa1, 0xfe, 0x6b, 0x16, 0x9f, 0x52, 0xfa, - 0xc1, 0xd3, 0xba, 0x6d, 0x26, 0xdc, 0xac, 0x86, 0xd4, 0xd9, 0x0d, 0x31, - 0x2e, 0x74, 0x9e, 0xdb, 0x59, 0x2e, 0x55, 0xe8, 0xc9, 0xb2, 0x96, 0xd5, - 0x4b, 0x9f, 0xb8, 0x6d, 0xda, 0x1c, 0x04, 0x09, 0x03, 0xfe, 0x8a, 0xc6, - 0xfa, 0xd3, 0xf5, 0x6a, 0xbe, 0xbb, 0x5b, 0x2e, 0xc6, 0xb5, 0x94, 0xe6, - 0xd5, 0x20, 0x97, 0x7d, 0x1b, 0x1b, 0xf9, 0xad, 0x7c, 0x7d, 0x17, 0xb7, - 0xf3, 0x1e, 0x92, 0x1b, 0x7f, 0xf8, 0xe0, 0x7d, 0x59, 0xdd, 0xfd, 0x32, - 0xd8, 0x8f, 0xa5, 0xe8, 0x3a, 0x12, 0x5c, 0x3f, 0xfc, 0xc4, 0xfa, 0xc3, - 0xb3, 0x77, 0xa7, 0x56, 0xed, 0xdb, 0x76, 0x7a, 0x8d, 0xdd, 0x1f, 0xbf, - 0xfd, 0x44, 0x92, 0x56, 0x8f, 0xff, 0xd4, 0xf2, 0xe8, 0x86, 0x17, 0x1e, - 0xfa, 0x04, 0x56, 0x4b, 0x43, 0x6c, 0x6f, 0x2d, 0xe5, 0x46, 0x01, 0x64, - 0x2b, 0x14, 0x32, 0x5b, 0xb4, 0xa0, 0x52, 0x1d, 0xde, 0x9b, 0x94, 0xdb, - 0xab, 0x6b, 0x81, 0xf7, 0x05, 0xb0, 0xd7, 0x07, 0xb2, 0x27, 0x55, 0xc6, - 0x57, 0x65, 0xd8, 0x76, 0x6e, 0x64, 0xed, 0xee, 0x16, 0xce, 0x27, 0x57, - 0x63, 0xda, 0x0c, 0xc2, 0x8e, 0x51, 0x67, 0x84, 0xfa, 0x1d, 0xdd, 0x62, - 0xc7, 0x07, 0xe9, 0xf7, 0xa3, 0xd6, 0x6c, 0x02, 0x41, 0x55, 0x31, 0xf3, - 0x2b, 0xb3, 0xba, 0x2b, 0x2e, 0x68, 0x24, 0x1d, 0x47, 0x64, 0xca, 0xa6, - 0x50, 0x41, 0x65, 0x90, 0x6c, 0xb1, 0xa5, 0xae, 0x33, 0x23, 0x51, 0xe4, - 0xab, 0x7d, 0x5d, 0xcb, 0xb6, 0xcc, 0x37, 0xd0, 0x40, 0x73, 0x71, 0xde, - 0x58, 0x09, 0xe7, 0x6f, 0x2c, 0x44, 0xc9, 0xc9, 0xae, 0xba, 0x9d, 0x63, - 0x88, 0x01, 0xa0, 0x95, 0x9d, 0xf5, 0x3f, 0x2a, 0xe6, 0x67, 0xdb, 0x50, - 0x83, 0x55, 0xad, 0x36, 0x3e, 0x78, 0x10, 0x74, 0x77, 0xfd, 0x2d, 0xaa, - 0x4c, 0x7d, 0x58, 0x73, 0x91, 0xa0, 0x0f, 0x51, 0x45, 0xb7, 0x33, 0xdd, - 0x58, 0x69, 0x1d, 0xd8, 0x0c, 0x9f, 0x96, 0x88, 0x19, 0x99, 0x19, 0xac, - 0xcf, 0xa3, 0xd2, 0xad, 0xb5, 0xdb, 0x76, 0x8f, 0xad, 0xc4, 0xea, 0xcf, - 0xdf, 0x7e, 0xdf, 0xdd, 0xfc, 0xd5, 0xa3, 0x5e, 0x43, 0x2b, 0x6b, 0xb2, - 0xad, 0x3b, 0x6a, 0xa4, 0x13, 0xa7, 0x04, 0xac, 0x7a, 0x6f, 0xb3, 0x23, - 0x26, 0xcc, 0xfb, 0xb4, 0x75, 0x8e, 0x01, 0x83, 0xf7, 0x58, 0x3e, 0x8b, - 0x53, 0xa7, 0x2a, 0x1a, 0x31, 0x42, 0x36, 0x5d, 0x4c, 0x9a, 0xf2, 0xdc, - 0xc6, 0xfe, 0x98, 0xb4, 0x34, 0xcb, 0x48, 0x0a, 0x8f, 0xdb, 0xb2, 0xeb, - 0x76, 0xd6, 0x07, 0x5c, 0x59, 0xc9, 0x64, 0x8f, 0x93, 0xa7, 0x73, 0x16, - 0x83, 0xaf, 0x0e, 0xa4, 0x33, 0xef, 0x50, 0xc5, 0x0c, 0xda, 0x59, 0x10, - 0x06, 0x8a, 0x2e, 0x29, 0x0e, 0xac, 0xc2, 0x31, 0x3d, 0x36, 0x69, 0x7e, - 0xd6, 0xcc, 0xf5, 0x3d, 0x6f, 0xb3, 0xeb, 0x1b, 0x76, 0xef, 0x3b, 0xa3, - 0xfa, 0xc9, 0x2b, 0x5f, 0x66, 0x6f, 0xa9, 0x1e, 0x73, 0xf2, 0x49, 0x2e, - 0x39, 0xf7, 0x4f, 0xb7, 0x8d, 0xff, 0xd5, 0xf3, 0x26, 0xfe, 0x0a, 0xc5, - 0x1b, 0xa7, 0xcb, 0xb2, 0xcf, 0x49, 0x03, 0xb2, 0x46, 0xee, 0xd9, 0xd9, - 0xb3, 0xf4, 0x9f, 0x25, 0x4a, 0xdf, 0x4b, 0x77, 0xe8, 0x27, 0xd4, 0xef, - 0x1c, 0x2a, 0x29, 0x26, 0xc5, 0x7c, 0x9d, 0x6c, 0x7f, 0xb7, 0x6e, 0x1b, - 0x26, 0x7f, 0x05, 0xa3, 0xfe, 0x53, 0x8d, 0x62, 0x57, 0x30, 0x92, 0x12, - 0xfa, 0x2f, 0x86, 0xdf, 0xa4, 0xec, 0x67, 0xfe, 0xd0, 0xf4, 0xff, 0x00, - 0x4d, 0xfc, 0xdf, 0x78, 0xe1, 0x68, 0x7d, 0x54, 0x99, 0xbf, 0x6f, 0xf3, - 0xbe, 0xdf, 0x8e, 0xdd, 0x7f, 0xef, 0xeb, 0x97, 0x49, 0x3e, 0x3b, 0x7f, - 0x06, 0x2c, 0x9f, 0x37, 0x5f, 0xf0, 0x9f, 0x4c, 0xeb, 0x7b, 0xbf, 0x67, - 0x55, 0xe8, 0xff, 0x00, 0x31, 0xbc, 0x7a, 0x9e, 0x31, 0xdb, 0xfe, 0x92, - 0xae, 0x37, 0x7a, 0x4d, 0xdb, 0xe2, 0x17, 0x9d, 0xa4, 0xa3, 0xc9, 0xba, - 0xfc, 0x7b, 0x7d, 0x5f, 0x52, 0xa7, 0x7e, 0xd1, 0x28, 0xf8, 0xf3, 0xb0, - 0xc7, 0x32, 0xbc, 0x99, 0x24, 0xc5, 0xe3, 0xab, 0xeb, 0x1f, 0xa4, 0xf5, - 0xfc, 0xe1, 0x25, 0xe4, 0xe9, 0x24, 0x97, 0xff, 0xd9, 0xff, 0xed, 0x2e, - 0x1c, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x20, 0x33, - 0x2e, 0x30, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2b, 0x1c, 0x02, 0x00, 0x00, 0x02, 0x00, 0x02, 0x1c, 0x02, - 0x78, 0x00, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x38, - 0x42, 0x49, 0x4d, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xfb, - 0x09, 0xa6, 0xbd, 0x07, 0x4c, 0x2a, 0x36, 0x9d, 0x8f, 0xe2, 0xcc, 0x57, - 0xa9, 0xac, 0x85, 0x38, 0x42, 0x49, 0x4d, 0x03, 0xea, 0x00, 0x00, 0x00, - 0x00, 0x1d, 0xb0, 0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x20, 0x65, - 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x55, 0x54, 0x46, - 0x2d, 0x38, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, - 0x59, 0x50, 0x45, 0x20, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, - 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x41, 0x70, 0x70, - 0x6c, 0x65, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x72, 0x2f, - 0x2f, 0x44, 0x54, 0x44, 0x20, 0x50, 0x4c, 0x49, 0x53, 0x54, 0x20, 0x31, - 0x2e, 0x30, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, - 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x54, 0x44, 0x73, 0x2f, 0x50, - 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x2d, - 0x31, 0x2e, 0x30, 0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e, 0x0a, 0x3c, 0x70, - 0x6c, 0x69, 0x73, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, - 0x50, 0x4d, 0x48, 0x6f, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x74, 0x61, 0x6c, - 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, - 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, - 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, - 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, - 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, - 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, - 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, - 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, - 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, - 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x48, 0x6f, 0x72, 0x69, 0x7a, - 0x6f, 0x6e, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, - 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, - 0x3e, 0x37, 0x32, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, - 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, - 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, - 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, - 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, - 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, - 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, - 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, - 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, - 0x50, 0x4d, 0x4f, 0x72, 0x69, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, - 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, - 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, - 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, - 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, - 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, - 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x4f, 0x72, 0x69, 0x65, 0x6e, 0x74, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, - 0x31, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, - 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, - 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, - 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, - 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, - 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, - 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, - 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x2e, 0x50, 0x4d, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, - 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, - 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, - 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, - 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, - 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, - 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, - 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, - 0x50, 0x4d, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, - 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, - 0x6c, 0x3e, 0x31, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, - 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, - 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, - 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, - 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, - 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, - 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, - 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, - 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, - 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x65, - 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, - 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, - 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, - 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, - 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, - 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, - 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, - 0x6c, 0x52, 0x65, 0x73, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x32, 0x3c, - 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, - 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, - 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, - 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, - 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, - 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, - 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, - 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, - 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, - 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, - 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, - 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, - 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, - 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, - 0x72, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, - 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x64, 0x69, - 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, - 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, - 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, - 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x61, 0x72, - 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, - 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x56, 0x65, 0x72, 0x74, 0x69, 0x63, 0x61, - 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x3c, 0x2f, 0x6b, 0x65, - 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, - 0x3e, 0x31, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, - 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, - 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, - 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, - 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, - 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, 0x30, - 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, 0x2f, - 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, - 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, - 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, - 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, - 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, - 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, - 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x73, 0x75, 0x62, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x61, - 0x70, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, - 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, - 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, - 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, - 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, - 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, - 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, - 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, - 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, - 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, - 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, - 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, - 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, - 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, 0x2e, 0x30, 0x3c, - 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x33, 0x34, 0x3c, 0x2f, - 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x37, 0x36, 0x3c, 0x2f, 0x72, - 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, - 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, - 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, - 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, - 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, - 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, - 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, 0x33, - 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, 0x3c, - 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, - 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, 0x3c, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, 0x41, 0x64, 0x6a, 0x75, - 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, 0x63, - 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, - 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, - 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, - 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, - 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, - 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x50, 0x4d, - 0x41, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, - 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, - 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, - 0x3e, 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, - 0x2d, 0x31, 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, - 0x37, 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x39, - 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, - 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, - 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, - 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, - 0x30, 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, - 0x34, 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, - 0x72, 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, - 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, - 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, - 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, - 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, - 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x50, - 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, - 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, - 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, - 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, - 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x50, 0x61, - 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, - 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x3e, 0x6e, 0x61, 0x2d, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x72, - 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, - 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, - 0x30, 0x33, 0x2d, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x54, 0x31, 0x37, 0x3a, - 0x34, 0x39, 0x3a, 0x33, 0x36, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, - 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, - 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, - 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, - 0x65, 0x67, 0x65, 0x72, 0x3e, 0x31, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, - 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, - 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, - 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, - 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, - 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, - 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, - 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, - 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, - 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, - 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x67, 0x65, - 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, - 0x30, 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x30, - 0x2e, 0x30, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x33, - 0x34, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x37, 0x36, - 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x69, 0x6e, 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, - 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, - 0x31, 0x2d, 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, - 0x31, 0x5a, 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x46, 0x6c, 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, - 0x3e, 0x30, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, - 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, - 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, - 0x0a, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, - 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, - 0x61, 0x64, 0x6a, 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, - 0x72, 0x52, 0x65, 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3c, - 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, - 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, 0x72, 0x72, 0x61, 0x79, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x61, - 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, - 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, - 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x50, 0x4d, 0x55, 0x6e, 0x61, 0x64, 0x6a, - 0x75, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x70, 0x65, 0x72, 0x52, 0x65, - 0x63, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, - 0x38, 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x2d, 0x31, 0x38, - 0x3c, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x37, 0x37, 0x34, 0x3c, - 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x35, 0x39, 0x34, 0x3c, 0x2f, - 0x72, 0x65, 0x61, 0x6c, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, - 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, - 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x69, 0x6e, - 0x67, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, - 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, - 0x61, 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x37, 0x2d, 0x30, 0x31, 0x2d, - 0x33, 0x30, 0x54, 0x32, 0x32, 0x3a, 0x30, 0x38, 0x3a, 0x34, 0x31, 0x5a, - 0x3c, 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, - 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, - 0x61, 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x30, - 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, - 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x70, 0x64, 0x2e, 0x50, 0x4d, - 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3c, 0x2f, 0x6b, - 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, - 0x0a, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x6f, 0x72, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x53, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, - 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x69, 0x74, 0x65, 0x6d, 0x41, - 0x72, 0x72, 0x61, 0x79, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x09, 0x09, 0x3c, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x50, - 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x70, 0x64, - 0x2e, 0x50, 0x4d, 0x50, 0x61, 0x70, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x55, 0x53, 0x20, 0x4c, - 0x65, 0x74, 0x74, 0x65, 0x72, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, 0x65, 0x79, - 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, - 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x6d, 0x2e, 0x50, 0x6f, 0x73, - 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, - 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x44, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x6b, - 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, 0x3c, 0x64, 0x61, - 0x74, 0x65, 0x3e, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x30, 0x37, 0x2d, 0x30, - 0x31, 0x54, 0x31, 0x37, 0x3a, 0x34, 0x39, 0x3a, 0x33, 0x36, 0x5a, 0x3c, - 0x2f, 0x64, 0x61, 0x74, 0x65, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x61, - 0x67, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x31, 0x3c, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, - 0x09, 0x3c, 0x2f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3e, 0x0a, 0x09, 0x09, - 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, - 0x74, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x73, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x30, 0x30, 0x2e, 0x32, 0x30, 0x3c, 0x2f, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, - 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, - 0x74, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x63, - 0x6b, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x66, - 0x61, 0x6c, 0x73, 0x65, 0x2f, 0x3e, 0x0a, 0x09, 0x09, 0x3c, 0x6b, 0x65, - 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, - 0x2e, 0x74, 0x79, 0x70, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, - 0x09, 0x09, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x2e, 0x50, 0x61, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x54, - 0x69, 0x63, 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x3e, 0x0a, 0x09, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, - 0x09, 0x3c, 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, - 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x30, 0x30, 0x2e, 0x32, 0x30, - 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x0a, 0x09, 0x3c, - 0x6b, 0x65, 0x79, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, - 0x65, 0x74, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4c, 0x6f, - 0x63, 0x6b, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, 0x3c, 0x66, - 0x61, 0x6c, 0x73, 0x65, 0x2f, 0x3e, 0x0a, 0x09, 0x3c, 0x6b, 0x65, 0x79, - 0x3e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, - 0x74, 0x79, 0x70, 0x65, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x3e, 0x0a, 0x09, - 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3e, 0x63, 0x6f, 0x6d, 0x2e, - 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, - 0x50, 0x61, 0x67, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x54, 0x69, - 0x63, 0x6b, 0x65, 0x74, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x3e, 0x0a, 0x3c, 0x2f, 0x64, 0x69, 0x63, 0x74, 0x3e, 0x0a, 0x3c, 0x2f, - 0x70, 0x6c, 0x69, 0x73, 0x74, 0x3e, 0x0a, 0x38, 0x42, 0x49, 0x4d, 0x03, - 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x02, 0xde, 0x02, 0x40, 0xff, - 0xee, 0xff, 0xee, 0x03, 0x06, 0x02, 0x52, 0x03, 0x67, 0x05, 0x28, 0x03, - 0xfc, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x00, 0x02, 0xd8, 0x02, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x01, 0x7f, - 0xff, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x08, 0x00, 0x19, 0x01, 0x90, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x03, - 0xed, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x38, - 0x42, 0x49, 0x4d, 0x04, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, - 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x1e, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x19, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x38, 0x42, 0x49, - 0x4d, 0x03, 0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, - 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x38, 0x42, 0x49, - 0x4d, 0x27, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x03, - 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x2f, 0x66, 0x66, 0x00, - 0x01, 0x00, 0x6c, 0x66, 0x66, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x2f, 0x66, 0x66, 0x00, 0x01, 0x00, 0xa1, 0x99, 0x9a, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x32, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x35, 0x00, 0x00, 0x00, 0x01, 0x00, 0x2d, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x38, 0x42, 0x49, 0x4d, 0x03, - 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, - 0xe8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe8, 0x00, 0x00, 0x38, - 0x42, 0x49, 0x4d, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x1e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, - 0x1a, 0x00, 0x00, 0x00, 0x00, 0x03, 0x45, 0x00, 0x00, 0x00, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, - 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x08, 0x00, 0x44, 0x00, 0x53, 0x00, - 0x43, 0x00, 0x30, 0x00, 0x32, 0x00, 0x33, 0x00, 0x32, 0x00, 0x35, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, - 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x6e, 0x75, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x4f, 0x62, 0x6a, 0x63, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x63, - 0x74, 0x31, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x54, 0x6f, - 0x70, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x4c, 0x65, 0x66, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x74, 0x6f, 0x6d, 0x6c, 0x6f, - 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x52, 0x67, - 0x68, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, - 0x00, 0x06, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x73, 0x56, 0x6c, 0x4c, 0x73, - 0x00, 0x00, 0x00, 0x01, 0x4f, 0x62, 0x6a, 0x63, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x00, - 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x73, 0x6c, 0x69, 0x63, 0x65, - 0x49, 0x44, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x44, 0x6c, 0x6f, 0x6e, - 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, - 0x67, 0x69, 0x6e, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x45, - 0x53, 0x6c, 0x69, 0x63, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x00, - 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x6f, 0x47, 0x65, 0x6e, 0x65, 0x72, - 0x61, 0x74, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00, 0x54, 0x79, 0x70, 0x65, - 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0a, 0x45, 0x53, 0x6c, 0x69, - 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x49, 0x6d, - 0x67, 0x20, 0x00, 0x00, 0x00, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, - 0x4f, 0x62, 0x6a, 0x63, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x52, 0x63, 0x74, 0x31, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x54, 0x6f, 0x70, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x65, 0x66, 0x74, 0x6c, 0x6f, - 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x74, - 0x6f, 0x6d, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, - 0x00, 0x00, 0x52, 0x67, 0x68, 0x74, 0x6c, 0x6f, 0x6e, 0x67, 0x00, 0x00, - 0x00, 0x64, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72, 0x6c, 0x54, 0x45, 0x58, - 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, - 0x75, 0x6c, 0x6c, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x73, 0x67, 0x65, 0x54, 0x45, 0x58, - 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x61, - 0x6c, 0x74, 0x54, 0x61, 0x67, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x63, 0x65, 0x6c, 0x6c, 0x54, - 0x65, 0x78, 0x74, 0x49, 0x73, 0x48, 0x54, 0x4d, 0x4c, 0x62, 0x6f, 0x6f, - 0x6c, 0x01, 0x00, 0x00, 0x00, 0x08, 0x63, 0x65, 0x6c, 0x6c, 0x54, 0x65, - 0x78, 0x74, 0x54, 0x45, 0x58, 0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x09, 0x68, 0x6f, 0x72, 0x7a, 0x41, 0x6c, 0x69, 0x67, - 0x6e, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0f, 0x45, 0x53, 0x6c, - 0x69, 0x63, 0x65, 0x48, 0x6f, 0x72, 0x7a, 0x41, 0x6c, 0x69, 0x67, 0x6e, - 0x00, 0x00, 0x00, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, - 0x00, 0x00, 0x09, 0x76, 0x65, 0x72, 0x74, 0x41, 0x6c, 0x69, 0x67, 0x6e, - 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x0f, 0x45, 0x53, 0x6c, 0x69, - 0x63, 0x65, 0x56, 0x65, 0x72, 0x74, 0x41, 0x6c, 0x69, 0x67, 0x6e, 0x00, - 0x00, 0x00, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, - 0x00, 0x0b, 0x62, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x79, 0x70, - 0x65, 0x65, 0x6e, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x11, 0x45, 0x53, 0x6c, - 0x69, 0x63, 0x65, 0x42, 0x47, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x54, 0x79, - 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x6f, 0x6e, 0x65, 0x00, 0x00, - 0x00, 0x09, 0x74, 0x6f, 0x70, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, - 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x6c, - 0x65, 0x66, 0x74, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, - 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x62, 0x6f, 0x74, - 0x74, 0x6f, 0x6d, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, - 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x72, 0x69, 0x67, - 0x68, 0x74, 0x4f, 0x75, 0x74, 0x73, 0x65, 0x74, 0x6c, 0x6f, 0x6e, 0x67, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x11, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, - 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x38, - 0x42, 0x49, 0x4d, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x09, 0xf9, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x64, 0x00, - 0x00, 0x01, 0x2c, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0x09, 0xdd, 0x00, - 0x18, 0x00, 0x01, 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, - 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, - 0xed, 0x00, 0x0c, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x5f, 0x43, 0x4d, 0x00, - 0x02, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x00, 0x64, - 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0c, 0x08, - 0x08, 0x08, 0x09, 0x08, 0x0c, 0x09, 0x09, 0x0c, 0x11, 0x0b, 0x0a, 0x0b, - 0x11, 0x15, 0x0f, 0x0c, 0x0c, 0x0f, 0x15, 0x18, 0x13, 0x13, 0x15, 0x13, - 0x13, 0x18, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x01, 0x0d, 0x0b, 0x0b, 0x0d, 0x0e, 0x0d, 0x10, 0x0e, 0x0e, - 0x10, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, 0x0e, 0x0e, 0x14, - 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, 0x00, 0x11, 0x08, - 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, - 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x07, 0xff, 0xc4, 0x01, 0x3f, - 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00, - 0x01, 0x04, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x07, 0x06, 0x08, 0x05, - 0x03, 0x0c, 0x33, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, 0x12, 0x31, - 0x05, 0x41, 0x51, 0x61, 0x13, 0x22, 0x71, 0x81, 0x32, 0x06, 0x14, 0x91, - 0xa1, 0xb1, 0x42, 0x23, 0x24, 0x15, 0x52, 0xc1, 0x62, 0x33, 0x34, 0x72, - 0x82, 0xd1, 0x43, 0x07, 0x25, 0x92, 0x53, 0xf0, 0xe1, 0xf1, 0x63, 0x73, - 0x35, 0x16, 0xa2, 0xb2, 0x83, 0x26, 0x44, 0x93, 0x54, 0x64, 0x45, 0xc2, - 0xa3, 0x74, 0x36, 0x17, 0xd2, 0x55, 0xe2, 0x65, 0xf2, 0xb3, 0x84, 0xc3, - 0xd3, 0x75, 0xe3, 0xf3, 0x46, 0x27, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, - 0xd4, 0xe4, 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, - 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, 0x67, - 0x77, 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x11, 0x00, 0x02, - 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x06, - 0x05, 0x35, 0x01, 0x00, 0x02, 0x11, 0x03, 0x21, 0x31, 0x12, 0x04, 0x41, - 0x51, 0x61, 0x71, 0x22, 0x13, 0x05, 0x32, 0x81, 0x91, 0x14, 0xa1, 0xb1, - 0x42, 0x23, 0xc1, 0x52, 0xd1, 0xf0, 0x33, 0x24, 0x62, 0xe1, 0x72, 0x82, - 0x92, 0x43, 0x53, 0x15, 0x63, 0x73, 0x34, 0xf1, 0x25, 0x06, 0x16, 0xa2, - 0xb2, 0x83, 0x07, 0x26, 0x35, 0xc2, 0xd2, 0x44, 0x93, 0x54, 0xa3, 0x17, - 0x64, 0x45, 0x55, 0x36, 0x74, 0x65, 0xe2, 0xf2, 0xb3, 0x84, 0xc3, 0xd3, - 0x75, 0xe3, 0xf3, 0x46, 0x94, 0xa4, 0x85, 0xb4, 0x95, 0xc4, 0xd4, 0xe4, - 0xf4, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x56, 0x66, 0x76, 0x86, 0x96, - 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, - 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, - 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf2, 0xed, 0xb2, 0x8d, 0x4d, - 0x45, 0xcd, 0x2f, 0x3f, 0x44, 0x68, 0x93, 0xc3, 0x58, 0xc8, 0xf1, 0x1f, - 0x8a, 0x33, 0x86, 0xda, 0x58, 0xc1, 0xa0, 0x02, 0x4f, 0xc4, 0xa1, 0x69, - 0xa5, 0x9b, 0x5b, 0x4b, 0x84, 0x73, 0xdf, 0xc9, 0x15, 0xf8, 0xe3, 0xd1, - 0x0e, 0x07, 0x93, 0xf3, 0xd1, 0x0f, 0x1c, 0x17, 0xef, 0x2e, 0x3b, 0x5b, - 0xdc, 0xff, 0x00, 0xdf, 0x42, 0xbf, 0x8f, 0x8e, 0xdc, 0x82, 0xca, 0xd8, - 0x37, 0x11, 0xa9, 0x3d, 0x82, 0x69, 0x2b, 0xc4, 0x6d, 0xc9, 0x75, 0x25, - 0xbc, 0xf7, 0xec, 0xa1, 0xb5, 0x74, 0x19, 0x5d, 0x2e, 0x8a, 0x9a, 0x4b, - 0x89, 0x7d, 0xc4, 0x68, 0xc6, 0xf6, 0xfe, 0xb2, 0xa0, 0x30, 0x1d, 0x60, - 0x86, 0x88, 0x8d, 0x49, 0x3e, 0x01, 0x11, 0x20, 0xa3, 0x8c, 0xb9, 0xb1, - 0xaa, 0x62, 0xad, 0xbf, 0x18, 0x97, 0x43, 0x47, 0x1d, 0xd2, 0xaf, 0x04, - 0xd9, 0xb8, 0xc8, 0x0d, 0x68, 0xe4, 0xf7, 0x3e, 0x48, 0xf1, 0x05, 0xbc, - 0x25, 0xaa, 0x07, 0x71, 0xd9, 0x14, 0x78, 0xf6, 0x49, 0xb5, 0x90, 0xfd, - 0xa7, 0xc6, 0x14, 0xfd, 0x1b, 0x1c, 0xff, 0x00, 0x4d, 0x8d, 0x2e, 0x73, - 0x8c, 0x35, 0xa3, 0x52, 0x4f, 0x92, 0x48, 0xa6, 0x1a, 0x24, 0xb6, 0x2a, - 0xfa, 0xa5, 0x9e, 0x60, 0x64, 0x39, 0x94, 0x13, 0xcb, 0x27, 0x73, 0x80, - 0xf3, 0x0c, 0xf6, 0xff, 0x00, 0xd2, 0x5a, 0x78, 0xbf, 0x53, 0x71, 0xf6, - 0x01, 0x75, 0xb6, 0x97, 0x6a, 0x25, 0xa1, 0xad, 0x1f, 0xf4, 0xb7, 0x23, - 0x48, 0xb7, 0x94, 0x84, 0x97, 0x5b, 0xff, 0x00, 0x32, 0xa9, 0xdd, 0xfc, - 0xed, 0x9b, 0x7e, 0x0d, 0x9e, 0x52, 0x4a, 0x95, 0x61, 0xff, 0xd0, 0xf3, - 0x3b, 0xa7, 0x70, 0xee, 0x01, 0x8f, 0xb9, 0x59, 0xfa, 0x7e, 0xdf, 0xe4, - 0xc8, 0xf9, 0x2a, 0xc2, 0x5c, 0x63, 0xc3, 0x54, 0x67, 0x87, 0x6e, 0x10, - 0x35, 0x68, 0xd4, 0x79, 0x1e, 0x53, 0x4a, 0xe0, 0xdc, 0xe9, 0xb8, 0x1f, - 0x6a, 0xda, 0x6c, 0x25, 0x94, 0x37, 0xb0, 0xd0, 0xb8, 0xad, 0x67, 0xe4, - 0x55, 0x8a, 0x5b, 0x8b, 0x82, 0xc0, 0x6f, 0x76, 0x80, 0x34, 0x49, 0x05, - 0x2e, 0x9e, 0xc6, 0x1c, 0x66, 0x31, 0xba, 0x10, 0x23, 0xe0, 0xaf, 0xe1, - 0x61, 0x53, 0x43, 0x8d, 0x81, 0xb3, 0x67, 0xef, 0x9e, 0x49, 0x2a, 0x12, - 0x6c, 0xb6, 0x63, 0x1a, 0x0c, 0x31, 0xba, 0x55, 0xcd, 0xac, 0xfa, 0x8e, - 0xdf, 0x91, 0x6e, 0x91, 0xd9, 0xb3, 0xc9, 0x73, 0x90, 0x7a, 0xab, 0x6a, - 0xc2, 0xa4, 0x60, 0xe2, 0x8f, 0xd2, 0x38, 0x03, 0x7d, 0x9e, 0x0d, 0xff, - 0x00, 0xcc, 0xd6, 0xd3, 0x6b, 0x71, 0x67, 0xd2, 0x3e, 0x64, 0x72, 0xab, - 0xdb, 0x8d, 0x54, 0x39, 0xc5, 0x83, 0x6b, 0x3d, 0xee, 0x2e, 0xd4, 0x92, - 0x3c, 0x4a, 0x56, 0xba, 0xb4, 0x79, 0x5c, 0xf7, 0xb2, 0x96, 0x6c, 0x8d, - 0xaf, 0x80, 0x48, 0x3c, 0xf0, 0xb2, 0x1f, 0x63, 0x9c, 0xe9, 0x3f, 0x24, - 0x5c, 0xdb, 0xdd, 0x76, 0x43, 0xde, 0xfd, 0x5c, 0xe3, 0x24, 0xfc, 0x50, - 0x00, 0x93, 0x0a, 0x78, 0x8a, 0x0d, 0x49, 0xca, 0xcf, 0x93, 0x63, 0x1b, - 0x7d, 0xd7, 0x57, 0x50, 0xd5, 0xef, 0x70, 0x6b, 0x4f, 0xc7, 0x45, 0xdb, - 0x74, 0x9e, 0x8d, 0x5e, 0x33, 0x83, 0xd8, 0x37, 0xdd, 0xc3, 0xac, 0x3d, - 0xbf, 0x92, 0xc5, 0x5b, 0xea, 0xbf, 0xd5, 0x62, 0xc0, 0xdc, 0xbc, 0xbd, - 0x2d, 0x22, 0x5a, 0xcf, 0xdd, 0x69, 0xff, 0x00, 0xd1, 0x8e, 0x5d, 0xa5, - 0x38, 0xb5, 0xb0, 0x00, 0xc6, 0xc4, 0x24, 0x4a, 0xd6, 0x8d, 0x18, 0x04, - 0x49, 0x88, 0x9e, 0x55, 0xd6, 0x61, 0xb0, 0xc1, 0x70, 0x32, 0xdd, 0x3c, - 0x95, 0xda, 0xf1, 0xfe, 0xf5, 0x62, 0xbc, 0x76, 0x8e, 0x75, 0x28, 0x02, - 0xa2, 0xe7, 0x7d, 0x92, 0xb9, 0x84, 0x96, 0x96, 0xda, 0xf7, 0x70, 0x12, - 0x4e, 0x5a, 0xff, 0x00, 0xff, 0xd1, 0xf3, 0x7a, 0x21, 0xaf, 0xde, 0xef, - 0xa2, 0x22, 0x55, 0xfc, 0x5a, 0xbd, 0x42, 0xfb, 0x08, 0xfa, 0x67, 0x4f, - 0x82, 0xcd, 0x6d, 0x85, 0xc0, 0x56, 0x3b, 0x90, 0xb7, 0xf0, 0x2a, 0x0e, - 0x63, 0x58, 0x3b, 0xf2, 0xa3, 0x9e, 0x8c, 0xb8, 0x86, 0xbe, 0x49, 0xf1, - 0x2c, 0x0c, 0x86, 0xb4, 0x4c, 0x69, 0xe4, 0xaf, 0x6e, 0xcc, 0x6b, 0x7d, - 0x46, 0xb3, 0x70, 0xec, 0x38, 0x51, 0x7d, 0x02, 0x8a, 0xc7, 0xa6, 0xd9, - 0x20, 0x68, 0x0f, 0x8f, 0x8a, 0xcf, 0xc9, 0xc2, 0xea, 0x59, 0x5b, 0x48, - 0xb0, 0x91, 0xae, 0xe6, 0xc9, 0x03, 0xc9, 0x30, 0x51, 0x66, 0xd4, 0x0d, - 0xad, 0xbd, 0x5f, 0x53, 0xcc, 0x6b, 0xb6, 0x90, 0x5a, 0x3b, 0x83, 0x0b, - 0x43, 0x17, 0x31, 0xd6, 0xc3, 0x6e, 0x12, 0x3b, 0x79, 0xac, 0xc1, 0x89, - 0x47, 0xd9, 0xe8, 0x63, 0x98, 0x45, 0xed, 0x6c, 0x5a, 0xf1, 0xa0, 0x27, - 0xc5, 0x5b, 0xc3, 0x6f, 0xa6, 0xe0, 0x1c, 0x7d, 0xb3, 0xa2, 0x69, 0x34, - 0x7b, 0xae, 0x1a, 0x8d, 0x45, 0x17, 0x9d, 0xeb, 0xfd, 0x21, 0xd8, 0xb9, - 0xae, 0xb5, 0x80, 0xbb, 0x1e, 0xd2, 0x5c, 0xd7, 0x78, 0x13, 0xf9, 0xae, - 0x4b, 0xea, 0xc7, 0x4a, 0x39, 0xbd, 0x55, 0xb3, 0xed, 0x66, 0x38, 0xf5, - 0x09, 0x22, 0x41, 0x23, 0xe8, 0x37, 0xfb, 0x4b, 0xa1, 0xeb, 0xd6, 0xfe, - 0x88, 0x31, 0xbf, 0x41, 0xc0, 0xee, 0xd2, 0x74, 0x02, 0x78, 0x53, 0xfa, - 0x97, 0x43, 0x19, 0x85, 0x65, 0xff, 0x00, 0x9d, 0x71, 0x33, 0xe4, 0x1a, - 0x7d, 0x8d, 0x53, 0x42, 0x56, 0x35, 0x6b, 0xe5, 0x80, 0x06, 0xc7, 0x57, - 0xa7, 0xc4, 0xa9, 0xdb, 0xb6, 0x81, 0x1f, 0xeb, 0xd9, 0x69, 0x56, 0xc2, - 0xd0, 0x00, 0xe5, 0x55, 0xc0, 0x12, 0xc2, 0xd7, 0x4e, 0xa2, 0x5a, 0x7c, - 0x0a, 0xd0, 0x63, 0x9a, 0xd1, 0xaf, 0xd2, 0xe2, 0x3c, 0x12, 0x62, 0x66, - 0xc6, 0x42, 0x23, 0x5a, 0x49, 0x8f, 0x10, 0xa2, 0xd2, 0x3e, 0x28, 0x9d, - 0xc4, 0x88, 0x09, 0x29, 0x16, 0xc3, 0x3c, 0x24, 0x8d, 0xe6, 0x92, 0x72, - 0x1f, 0xff, 0xd2, 0xf3, 0xbb, 0xb0, 0xfe, 0xcb, 0x99, 0xe9, 0xce, 0xf6, - 0x88, 0x2d, 0x77, 0x91, 0x5b, 0x3d, 0x3d, 0xd0, 0xe6, 0x90, 0xa9, 0x65, - 0x57, 0x38, 0x95, 0xdd, 0xcb, 0x9a, 0x7d, 0xce, 0xf2, 0x3f, 0x44, 0x23, - 0x60, 0x58, 0x76, 0xe9, 0xca, 0x8c, 0xea, 0x1b, 0x31, 0x02, 0x32, 0x23, - 0xea, 0xee, 0xb1, 0xcd, 0xb0, 0xc7, 0x87, 0x74, 0x7a, 0xeb, 0x70, 0x1a, - 0x71, 0xe1, 0xfe, 0xe4, 0x1c, 0x1d, 0xae, 0xe5, 0x69, 0xd8, 0xfa, 0x99, - 0x50, 0x0d, 0x1a, 0xf7, 0x2a, 0x3a, 0x0c, 0xf4, 0x1a, 0x8e, 0xc7, 0x27, - 0x5d, 0xbf, 0x18, 0x41, 0xdc, 0xc2, 0xf0, 0x7f, 0x74, 0xf6, 0x3a, 0x22, - 0x66, 0xdb, 0x68, 0xc6, 0x80, 0x48, 0x6b, 0x88, 0x06, 0x39, 0x0d, 0xee, - 0xaa, 0x1f, 0xb3, 0xd5, 0x1b, 0x83, 0xd8, 0x3b, 0x38, 0x8f, 0x69, 0xfe, - 0xdf, 0xd1, 0x4d, 0x29, 0xa1, 0x4c, 0x7a, 0xf4, 0xbf, 0xa7, 0x92, 0xcf, - 0xa5, 0x20, 0x08, 0xf3, 0xf6, 0xff, 0x00, 0x15, 0xbb, 0xd1, 0x31, 0xd9, - 0x5e, 0x3d, 0x75, 0x56, 0x36, 0x88, 0x00, 0x81, 0xe0, 0x16, 0x5e, 0x55, - 0x74, 0x3f, 0x00, 0x9d, 0xe0, 0xcc, 0x69, 0xe7, 0x3a, 0x2d, 0xbe, 0x90, - 0x00, 0xa9, 0xae, 0xef, 0x1f, 0x95, 0x4b, 0x0d, 0x9a, 0xdc, 0xc7, 0x45, - 0xfe, 0xb1, 0x7d, 0x60, 0xa7, 0xa1, 0xe0, 0x1f, 0x4e, 0x1d, 0x99, 0x69, - 0x02, 0x9a, 0xcf, 0x1f, 0xca, 0x7b, 0xbf, 0x90, 0xc5, 0xc2, 0xb3, 0xeb, - 0x57, 0xd6, 0x03, 0x6b, 0xae, 0x39, 0xb6, 0x82, 0xe3, 0x31, 0xa1, 0x68, - 0xf2, 0x6b, 0x5c, 0x12, 0xfa, 0xe1, 0x91, 0x66, 0x47, 0x5d, 0xb8, 0x3b, - 0x4f, 0x44, 0x36, 0xb6, 0x8f, 0x28, 0xdd, 0xff, 0x00, 0x7e, 0x46, 0xab, - 0x12, 0x2b, 0x65, 0x55, 0x32, 0xa7, 0x62, 0xb6, 0xbd, 0xf7, 0x64, 0x10, - 0xdb, 0x03, 0x9f, 0x1b, 0x9e, 0xc7, 0xd9, 0xb8, 0x3b, 0x1f, 0x67, 0xf3, - 0x6c, 0x52, 0x80, 0xd7, 0x7d, 0x0f, 0xea, 0x7f, 0x5d, 0x1d, 0x67, 0xa6, - 0x0b, 0x1e, 0x47, 0xda, 0x69, 0x3b, 0x2e, 0x03, 0xc7, 0xf3, 0x5f, 0x1f, - 0xf0, 0x8b, 0xa1, 0x02, 0x46, 0xba, 0x79, 0xaf, 0x32, 0xff, 0x00, 0x16, - 0xad, 0xca, 0x1d, 0x57, 0x2a, 0xdc, 0x79, 0x18, 0x41, 0xb0, 0xf6, 0x9e, - 0xe4, 0x9f, 0xd0, 0x8f, 0xeb, 0x31, 0xab, 0xd2, 0x83, 0xa4, 0xcb, 0x8c, - 0xb8, 0xa0, 0x42, 0x12, 0x7b, 0x67, 0x9f, 0x2f, 0xf5, 0x09, 0x26, 0x96, - 0xc4, 0xce, 0xa9, 0x20, 0xa7, 0xff, 0xd3, 0xf3, 0x2f, 0xb4, 0x5d, 0xe9, - 0x0a, 0xb7, 0x9f, 0x4c, 0x19, 0xdb, 0x3a, 0x2d, 0x5e, 0x94, 0xfd, 0xc4, - 0xb7, 0xc5, 0x62, 0xf9, 0x2b, 0xfd, 0x2e, 0xe3, 0x5d, 0xe0, 0x7c, 0x13, - 0x48, 0xd1, 0x92, 0x12, 0xa9, 0x0b, 0x7a, 0xbc, 0x2d, 0xc2, 0x7f, 0x92, - 0x60, 0xab, 0x4e, 0x79, 0x2e, 0x00, 0xf0, 0xaa, 0xe1, 0xda, 0x3d, 0x43, - 0xfc, 0xad, 0x55, 0xbb, 0x80, 0x79, 0x81, 0xa0, 0xe6, 0x54, 0x32, 0x6d, - 0x02, 0xbe, 0xf3, 0x61, 0x81, 0xa8, 0x44, 0x14, 0x03, 0x59, 0x0e, 0x1c, - 0xf6, 0x1f, 0xdc, 0xb2, 0xec, 0xa3, 0x23, 0x77, 0xe8, 0x6e, 0x70, 0xf2, - 0x25, 0x1f, 0x1f, 0x17, 0xa9, 0x6d, 0x71, 0x36, 0x97, 0x47, 0x00, 0xa4, - 0x02, 0xe0, 0x2c, 0x7c, 0xc1, 0xab, 0xd5, 0x31, 0x85, 0x35, 0xd4, 0xe6, - 0x13, 0x02, 0xd6, 0x4b, 0x67, 0x48, 0x2b, 0xa9, 0xe9, 0x2e, 0x02, 0xb6, - 0x4f, 0x82, 0xe5, 0x7a, 0x95, 0x19, 0xc6, 0x87, 0x3d, 0xfb, 0xa2, 0xb8, - 0x79, 0x1e, 0x4d, 0x3b, 0x96, 0xcf, 0x4f, 0xbd, 0xcd, 0xa2, 0xa2, 0x1f, - 0xa0, 0x82, 0xd3, 0xfc, 0x97, 0x05, 0x24, 0x36, 0x6b, 0xf3, 0x31, 0xa2, - 0x35, 0x79, 0xef, 0xad, 0xf8, 0xae, 0xaf, 0xaf, 0xd8, 0xf2, 0xd8, 0x6d, - 0xed, 0x6b, 0xda, 0x7b, 0x18, 0x1b, 0x5d, 0xff, 0x00, 0x52, 0xb1, 0x6d, - 0xf0, 0x81, 0x31, 0xca, 0xf4, 0x6e, 0xb1, 0x80, 0xce, 0xb1, 0x84, 0xc0, - 0x21, 0xb7, 0xd6, 0x77, 0x31, 0xd1, 0x27, 0xc1, 0xcd, 0xfe, 0xd2, 0xe3, - 0xec, 0xe8, 0x1d, 0x45, 0x96, 0xb0, 0x9a, 0xb7, 0x87, 0x3f, 0x68, 0x2d, - 0xf7, 0x01, 0x1f, 0xbe, 0xd1, 0xf4, 0x7f, 0xb4, 0xa4, 0x0d, 0x77, 0xbb, - 0xfa, 0x8f, 0x80, 0x3a, 0x7f, 0x43, 0xaa, 0xe2, 0xdf, 0xd2, 0x65, 0x7e, - 0x95, 0xe4, 0x0f, 0x1f, 0xa1, 0xfe, 0x6b, 0x16, 0x9f, 0x52, 0xfa, 0xc1, - 0xd3, 0xba, 0x6d, 0x26, 0xdc, 0xac, 0x86, 0xd4, 0xd9, 0x0d, 0x31, 0x2e, - 0x74, 0x9e, 0xdb, 0x59, 0x2e, 0x55, 0xe8, 0xc9, 0xb2, 0x96, 0xd5, 0x4b, - 0x9f, 0xb8, 0x6d, 0xda, 0x1c, 0x04, 0x09, 0x03, 0xfe, 0x8a, 0xc6, 0xfa, - 0xd3, 0xf5, 0x6a, 0xbe, 0xbb, 0x5b, 0x2e, 0xc6, 0xb5, 0x94, 0xe6, 0xd5, - 0x20, 0x97, 0x7d, 0x1b, 0x1b, 0xf9, 0xad, 0x7c, 0x7d, 0x17, 0xb7, 0xf3, - 0x1e, 0x92, 0x1b, 0x7f, 0xf8, 0xe0, 0x7d, 0x59, 0xdd, 0xfd, 0x32, 0xd8, - 0x8f, 0xa5, 0xe8, 0x3a, 0x12, 0x5c, 0x3f, 0xfc, 0xc4, 0xfa, 0xc3, 0xb3, - 0x77, 0xa7, 0x56, 0xed, 0xdb, 0x76, 0x7a, 0x8d, 0xdd, 0x1f, 0xbf, 0xfd, - 0x44, 0x92, 0x56, 0x8f, 0xff, 0xd4, 0xf2, 0xe8, 0x86, 0x17, 0x1e, 0xfa, - 0x04, 0x56, 0x4b, 0x43, 0x6c, 0x6f, 0x2d, 0xe5, 0x46, 0x01, 0x64, 0x2b, - 0x14, 0x32, 0x5b, 0xb4, 0xa0, 0x52, 0x1d, 0xde, 0x9b, 0x94, 0xdb, 0xab, - 0x6b, 0x81, 0xf7, 0x05, 0xb0, 0xd7, 0x07, 0xb2, 0x27, 0x55, 0xc6, 0x57, - 0x65, 0xd8, 0x76, 0x6e, 0x64, 0xed, 0xee, 0x16, 0xce, 0x27, 0x57, 0x63, - 0xda, 0x0c, 0xc2, 0x8e, 0x51, 0x67, 0x84, 0xfa, 0x1d, 0xdd, 0x62, 0xc7, - 0x07, 0xe9, 0xf7, 0xa3, 0xd6, 0x6c, 0x02, 0x41, 0x55, 0x31, 0xf3, 0x2b, - 0xb3, 0xba, 0x2b, 0x2e, 0x68, 0x24, 0x1d, 0x47, 0x64, 0xca, 0xa6, 0x50, - 0x41, 0x65, 0x90, 0x6c, 0xb1, 0xa5, 0xae, 0x33, 0x23, 0x51, 0xe4, 0xab, - 0x7d, 0x5d, 0xcb, 0xb6, 0xcc, 0x37, 0xd0, 0x40, 0x73, 0x71, 0xde, 0x58, - 0x09, 0xe7, 0x6f, 0x2c, 0x44, 0xc9, 0xc9, 0xae, 0xba, 0x9d, 0x63, 0x88, - 0x01, 0xa0, 0x95, 0x9d, 0xf5, 0x3f, 0x2a, 0xe6, 0x67, 0xdb, 0x50, 0x83, - 0x55, 0xad, 0x36, 0x3e, 0x78, 0x10, 0x74, 0x77, 0xfd, 0x2d, 0xaa, 0x4c, - 0x7d, 0x58, 0x73, 0x91, 0xa0, 0x0f, 0x51, 0x45, 0xb7, 0x33, 0xdd, 0x58, - 0x69, 0x1d, 0xd8, 0x0c, 0x9f, 0x96, 0x88, 0x19, 0x99, 0x19, 0xac, 0xcf, - 0xa3, 0xd2, 0xad, 0xb5, 0xdb, 0x76, 0x8f, 0xad, 0xc4, 0xea, 0xcf, 0xdf, - 0x7e, 0xdf, 0xdd, 0xfc, 0xd5, 0xa3, 0x5e, 0x43, 0x2b, 0x6b, 0xb2, 0xad, - 0x3b, 0x6a, 0xa4, 0x13, 0xa7, 0x04, 0xac, 0x7a, 0x6f, 0xb3, 0x23, 0x26, - 0xcc, 0xfb, 0xb4, 0x75, 0x8e, 0x01, 0x83, 0xf7, 0x58, 0x3e, 0x8b, 0x53, - 0xa7, 0x2a, 0x1a, 0x31, 0x42, 0x36, 0x5d, 0x4c, 0x9a, 0xf2, 0xdc, 0xc6, - 0xfe, 0x98, 0xb4, 0x34, 0xcb, 0x48, 0x0a, 0x8f, 0xdb, 0xb2, 0xeb, 0x76, - 0xd6, 0x07, 0x5c, 0x59, 0xc9, 0x64, 0x8f, 0x93, 0xa7, 0x73, 0x16, 0x83, - 0xaf, 0x0e, 0xa4, 0x33, 0xef, 0x50, 0xc5, 0x0c, 0xda, 0x59, 0x10, 0x06, - 0x8a, 0x2e, 0x29, 0x0e, 0xac, 0xc2, 0x31, 0x3d, 0x36, 0x69, 0x7e, 0xd6, - 0xcc, 0xf5, 0x3d, 0x6f, 0xb3, 0xeb, 0x1b, 0x76, 0xef, 0x3b, 0xa3, 0xfa, - 0xc9, 0x2b, 0x5f, 0x66, 0x6f, 0xa9, 0x1e, 0x73, 0xf2, 0x49, 0x2e, 0x39, - 0xf7, 0x4f, 0xb7, 0x8d, 0xff, 0xd5, 0xf3, 0x26, 0xfe, 0x0a, 0xc5, 0x1b, - 0xa7, 0xcb, 0xb2, 0xcf, 0x49, 0x03, 0xb2, 0x46, 0xee, 0xd9, 0xd9, 0xb3, - 0xf4, 0x9f, 0x25, 0x4a, 0xdf, 0x4b, 0x77, 0xe8, 0x27, 0xd4, 0xef, 0x1c, - 0x2a, 0x29, 0x26, 0xc5, 0x7c, 0x9d, 0x6c, 0x7f, 0xb7, 0x6e, 0x1b, 0x26, - 0x7f, 0x05, 0xa3, 0xfe, 0x53, 0x8d, 0x62, 0x57, 0x30, 0x92, 0x12, 0xfa, - 0x2f, 0x86, 0xdf, 0xa4, 0xec, 0x67, 0xfe, 0xd0, 0xf4, 0xff, 0x00, 0x4d, - 0xfc, 0xdf, 0x78, 0xe1, 0x68, 0x7d, 0x54, 0x99, 0xbf, 0x6f, 0xf3, 0xbe, - 0xdf, 0x8e, 0xdd, 0x7f, 0xef, 0xeb, 0x97, 0x49, 0x3e, 0x3b, 0x7f, 0x06, - 0x2c, 0x9f, 0x37, 0x5f, 0xf0, 0x9f, 0x4c, 0xeb, 0x7b, 0xbf, 0x67, 0x55, - 0xe8, 0xff, 0x00, 0x31, 0xbc, 0x7a, 0x9e, 0x31, 0xdb, 0xfe, 0x92, 0xae, - 0x37, 0x7a, 0x4d, 0xdb, 0xe2, 0x17, 0x9d, 0xa4, 0xa3, 0xc9, 0xba, 0xfc, - 0x7b, 0x7d, 0x5f, 0x52, 0xa7, 0x7e, 0xd1, 0x28, 0xf8, 0xf3, 0xb0, 0xc7, - 0x32, 0xbc, 0x99, 0x24, 0xc5, 0xe3, 0xab, 0xeb, 0x1f, 0xa4, 0xf5, 0xfc, - 0xe1, 0x25, 0xe4, 0xe9, 0x24, 0x97, 0xff, 0xd9, 0x00, 0x38, 0x42, 0x49, - 0x4d, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6f, - 0x00, 0x62, 0x00, 0x65, 0x00, 0x20, 0x00, 0x50, 0x00, 0x68, 0x00, 0x6f, - 0x00, 0x74, 0x00, 0x6f, 0x00, 0x73, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x70, - 0x00, 0x00, 0x00, 0x13, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x62, - 0x00, 0x65, 0x00, 0x20, 0x00, 0x50, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x74, - 0x00, 0x6f, 0x00, 0x73, 0x00, 0x68, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x20, - 0x00, 0x37, 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x38, - 0x42, 0x49, 0x4d, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0xff, 0xe1, 0x15, 0x67, 0x68, - 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, - 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x61, 0x70, 0x2f, 0x31, - 0x2e, 0x30, 0x2f, 0x00, 0x3c, 0x3f, 0x78, 0x70, 0x61, 0x63, 0x6b, 0x65, - 0x74, 0x20, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x3d, 0x27, 0xef, 0xbb, 0xbf, - 0x27, 0x20, 0x69, 0x64, 0x3d, 0x27, 0x57, 0x35, 0x4d, 0x30, 0x4d, 0x70, - 0x43, 0x65, 0x68, 0x69, 0x48, 0x7a, 0x72, 0x65, 0x53, 0x7a, 0x4e, 0x54, - 0x63, 0x7a, 0x6b, 0x63, 0x39, 0x64, 0x27, 0x3f, 0x3e, 0x0a, 0x3c, 0x3f, - 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2d, 0x78, 0x61, 0x70, 0x2d, 0x66, 0x69, - 0x6c, 0x74, 0x65, 0x72, 0x73, 0x20, 0x65, 0x73, 0x63, 0x3d, 0x22, 0x43, - 0x52, 0x22, 0x3f, 0x3e, 0x0a, 0x3c, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x6d, - 0x65, 0x74, 0x61, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x3d, - 0x27, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x3a, 0x6e, 0x73, 0x3a, 0x6d, 0x65, - 0x74, 0x61, 0x2f, 0x27, 0x20, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x74, 0x6b, - 0x3d, 0x27, 0x58, 0x4d, 0x50, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x6b, 0x69, - 0x74, 0x20, 0x32, 0x2e, 0x38, 0x2e, 0x32, 0x2d, 0x33, 0x33, 0x2c, 0x20, - 0x66, 0x72, 0x61, 0x6d, 0x65, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x31, 0x2e, - 0x35, 0x27, 0x3e, 0x0a, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x52, 0x44, 0x46, - 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x72, 0x64, 0x66, 0x3d, 0x27, - 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, - 0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x31, 0x39, 0x39, 0x39, 0x2f, 0x30, - 0x32, 0x2f, 0x32, 0x32, 0x2d, 0x72, 0x64, 0x66, 0x2d, 0x73, 0x79, 0x6e, - 0x74, 0x61, 0x78, 0x2d, 0x6e, 0x73, 0x23, 0x27, 0x20, 0x78, 0x6d, 0x6c, - 0x6e, 0x73, 0x3a, 0x69, 0x58, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, - 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x69, 0x58, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x27, 0x3e, - 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, - 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, - 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, - 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, - 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, - 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x70, 0x64, 0x66, 0x3d, 0x27, 0x68, - 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, - 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x64, 0x66, 0x2f, 0x31, - 0x2e, 0x33, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x21, 0x2d, 0x2d, - 0x20, 0x70, 0x64, 0x66, 0x3a, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x20, 0x69, 0x73, 0x20, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, - 0x2d, 0x2d, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, - 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, - 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, - 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, - 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, - 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, - 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, - 0x6f, 0x70, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, - 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x2f, 0x31, 0x2e, - 0x30, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x21, 0x2d, 0x2d, 0x20, - 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x3a, 0x43, 0x61, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6c, 0x69, - 0x61, 0x73, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, - 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, - 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, - 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, - 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, - 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, - 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, - 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x61, - 0x70, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6e, 0x73, - 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, - 0x61, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, - 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0x78, 0x61, 0x70, 0x3a, 0x44, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, - 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x3e, 0x0a, - 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, - 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, - 0x69, 0x64, 0x3a, 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, - 0x62, 0x32, 0x34, 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, - 0x66, 0x38, 0x2d, 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, - 0x32, 0x66, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, - 0x3a, 0x78, 0x61, 0x70, 0x4d, 0x4d, 0x3d, 0x27, 0x68, 0x74, 0x74, 0x70, - 0x3a, 0x2f, 0x2f, 0x6e, 0x73, 0x2e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x61, 0x70, 0x2f, 0x31, 0x2e, 0x30, 0x2f, - 0x6d, 0x6d, 0x2f, 0x27, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x78, 0x61, 0x70, - 0x4d, 0x4d, 0x3a, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x49, - 0x44, 0x3e, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x3a, 0x64, 0x6f, 0x63, 0x69, - 0x64, 0x3a, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x73, 0x68, 0x6f, 0x70, 0x3a, - 0x32, 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x36, 0x2d, 0x62, 0x32, 0x34, - 0x39, 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, - 0x39, 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, - 0x3c, 0x2f, 0x78, 0x61, 0x70, 0x4d, 0x4d, 0x3a, 0x44, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, - 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x20, 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x44, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, - 0x62, 0x6f, 0x75, 0x74, 0x3d, 0x27, 0x75, 0x75, 0x69, 0x64, 0x3a, 0x32, - 0x32, 0x64, 0x30, 0x32, 0x62, 0x30, 0x61, 0x2d, 0x62, 0x32, 0x34, 0x39, - 0x2d, 0x31, 0x31, 0x64, 0x62, 0x2d, 0x38, 0x61, 0x66, 0x38, 0x2d, 0x39, - 0x31, 0x64, 0x35, 0x34, 0x30, 0x33, 0x66, 0x39, 0x32, 0x66, 0x39, 0x27, - 0x0a, 0x20, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x64, 0x63, 0x3d, - 0x27, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x70, 0x75, 0x72, 0x6c, - 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x64, 0x63, 0x2f, 0x65, 0x6c, 0x65, 0x6d, - 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x31, 0x2e, 0x31, 0x2f, 0x27, 0x3e, 0x0a, - 0x20, 0x20, 0x3c, 0x64, 0x63, 0x3a, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x72, - 0x64, 0x66, 0x3a, 0x41, 0x6c, 0x74, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x3c, 0x72, 0x64, 0x66, 0x3a, 0x6c, 0x69, 0x20, 0x78, 0x6d, 0x6c, 0x3a, - 0x6c, 0x61, 0x6e, 0x67, 0x3d, 0x27, 0x78, 0x2d, 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x27, 0x3e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x6c, 0x69, 0x3e, 0x0a, 0x20, 0x20, - 0x20, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x41, 0x6c, 0x74, 0x3e, 0x0a, - 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x63, 0x3a, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x3c, 0x2f, 0x72, - 0x64, 0x66, 0x3a, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x3e, 0x0a, 0x0a, 0x3c, 0x2f, 0x72, 0x64, 0x66, 0x3a, 0x52, - 0x44, 0x46, 0x3e, 0x0a, 0x3c, 0x2f, 0x78, 0x3a, 0x78, 0x61, 0x70, 0x6d, - 0x65, 0x74, 0x61, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x3c, 0x3f, 0x78, - 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x65, 0x6e, 0x64, 0x3d, 0x27, - 0x77, 0x27, 0x3f, 0x3e, 0xff, 0xee, 0x00, 0x0e, 0x41, 0x64, 0x6f, 0x62, - 0x65, 0x00, 0x64, 0x40, 0x00, 0x00, 0x00, 0x01, 0xff, 0xdb, 0x00, 0x84, - 0x00, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x06, - 0x04, 0x03, 0x04, 0x06, 0x07, 0x05, 0x04, 0x04, 0x05, 0x07, 0x08, 0x06, - 0x06, 0x07, 0x06, 0x06, 0x08, 0x0a, 0x08, 0x09, 0x09, 0x09, 0x09, 0x08, - 0x0a, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0a, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x01, 0x04, 0x05, 0x05, 0x08, 0x07, 0x08, - 0x0f, 0x0a, 0x0a, 0x0f, 0x14, 0x0e, 0x0e, 0x0e, 0x14, 0x14, 0x0e, 0x0e, - 0x0e, 0x0e, 0x14, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x11, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x11, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xc0, - 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x64, 0x03, 0x01, 0x11, 0x00, 0x02, - 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xdd, 0x00, 0x04, 0x00, 0x0d, 0xff, - 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x00, 0x07, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x03, 0x02, - 0x06, 0x01, 0x00, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x00, 0x02, 0x02, - 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, - 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x02, 0x06, 0x07, - 0x03, 0x04, 0x02, 0x06, 0x02, 0x73, 0x01, 0x02, 0x03, 0x11, 0x04, 0x00, - 0x05, 0x21, 0x12, 0x31, 0x41, 0x51, 0x06, 0x13, 0x61, 0x22, 0x71, 0x81, - 0x14, 0x32, 0x91, 0xa1, 0x07, 0x15, 0xb1, 0x42, 0x23, 0xc1, 0x52, 0xd1, - 0xe1, 0x33, 0x16, 0x62, 0xf0, 0x24, 0x72, 0x82, 0xf1, 0x25, 0x43, 0x34, - 0x53, 0x92, 0xa2, 0xb2, 0x63, 0x73, 0xc2, 0x35, 0x44, 0x27, 0x93, 0xa3, - 0xb3, 0x36, 0x17, 0x54, 0x64, 0x74, 0xc3, 0xd2, 0xe2, 0x08, 0x26, 0x83, - 0x09, 0x0a, 0x18, 0x19, 0x84, 0x94, 0x45, 0x46, 0xa4, 0xb4, 0x56, 0xd3, - 0x55, 0x28, 0x1a, 0xf2, 0xe3, 0xf3, 0xc4, 0xd4, 0xe4, 0xf4, 0x65, 0x75, - 0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x66, 0x76, 0x86, 0x96, - 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, - 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8, 0x29, 0x39, 0x49, 0x59, - 0x69, 0x79, 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9, 0x2a, 0x3a, - 0x4a, 0x5a, 0x6a, 0x7a, 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa, - 0x11, 0x00, 0x02, 0x02, 0x01, 0x02, 0x03, 0x05, 0x05, 0x04, 0x05, 0x06, - 0x04, 0x08, 0x03, 0x03, 0x6d, 0x01, 0x00, 0x02, 0x11, 0x03, 0x04, 0x21, - 0x12, 0x31, 0x41, 0x05, 0x51, 0x13, 0x61, 0x22, 0x06, 0x71, 0x81, 0x91, - 0x32, 0xa1, 0xb1, 0xf0, 0x14, 0xc1, 0xd1, 0xe1, 0x23, 0x42, 0x15, 0x52, - 0x62, 0x72, 0xf1, 0x33, 0x24, 0x34, 0x43, 0x82, 0x16, 0x92, 0x53, 0x25, - 0xa2, 0x63, 0xb2, 0xc2, 0x07, 0x73, 0xd2, 0x35, 0xe2, 0x44, 0x83, 0x17, - 0x54, 0x93, 0x08, 0x09, 0x0a, 0x18, 0x19, 0x26, 0x36, 0x45, 0x1a, 0x27, - 0x64, 0x74, 0x55, 0x37, 0xf2, 0xa3, 0xb3, 0xc3, 0x28, 0x29, 0xd3, 0xe3, - 0xf3, 0x84, 0x94, 0xa4, 0xb4, 0xc4, 0xd4, 0xe4, 0xf4, 0x65, 0x75, 0x85, - 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5, 0x46, 0x56, 0x66, 0x76, 0x86, - 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6, 0x47, 0x57, 0x67, 0x77, 0x87, - 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8, 0x39, 0x49, 0x59, 0x69, - 0x79, 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9, 0x2a, 0x3a, 0x4a, - 0x5a, 0x6a, 0x7a, 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa, 0xff, - 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, - 0x00, 0xf0, 0x67, 0xa6, 0x5c, 0x0f, 0x01, 0xd4, 0x7e, 0x18, 0x12, 0x98, - 0xe9, 0xd6, 0x2d, 0x34, 0x6d, 0x70, 0xdf, 0xdc, 0xa1, 0xe3, 0xec, 0x5b, - 0xfb, 0x32, 0x24, 0xb2, 0x01, 0x1f, 0x15, 0xa4, 0x52, 0x4a, 0x82, 0x31, - 0xf1, 0xfe, 0xd1, 0x3d, 0x14, 0x64, 0x49, 0x64, 0x22, 0x98, 0xcf, 0xa5, - 0x46, 0x6c, 0x16, 0x55, 0x71, 0x56, 0x62, 0x28, 0x07, 0xc5, 0x45, 0x15, - 0xa0, 0xc8, 0x89, 0x33, 0xe1, 0x63, 0xd2, 0xd8, 0x34, 0x44, 0x17, 0xa0, - 0x2c, 0x4d, 0x16, 0xbb, 0xed, 0xdc, 0xf8, 0x64, 0xc1, 0x6b, 0x31, 0x42, - 0x18, 0x8e, 0xc7, 0xb5, 0x2a, 0x7d, 0xb2, 0x56, 0xc5, 0x61, 0x8c, 0xf2, - 0xa0, 0x1b, 0x1e, 0x83, 0x0d, 0xa1, 0x63, 0x50, 0x1f, 0x97, 0x7c, 0x2a, - 0xa9, 0x1a, 0x9a, 0x86, 0x4f, 0xb4, 0xb4, 0x38, 0x0a, 0xa6, 0x0b, 0xb8, - 0x0c, 0x05, 0x14, 0xf8, 0x76, 0x3e, 0x19, 0x14, 0xb6, 0x78, 0xf8, 0x8c, - 0x2a, 0xd5, 0x01, 0xdc, 0x6f, 0x8a, 0x1a, 0xe3, 0x8d, 0xab, 0xff, 0xd0, - 0xf0, 0xec, 0xe9, 0x15, 0xb5, 0xb9, 0x5a, 0x7c, 0x4c, 0xa2, 0x9e, 0x24, - 0xf5, 0xca, 0xc6, 0xe5, 0x99, 0xd9, 0x34, 0x99, 0x04, 0x3a, 0x7d, 0xb5, - 0xba, 0xd5, 0x51, 0x63, 0x0e, 0xc7, 0xc5, 0x9b, 0x73, 0xf8, 0xe4, 0x6f, - 0x76, 0xca, 0xd9, 0xda, 0x54, 0x6d, 0x72, 0x2e, 0x1a, 0x57, 0x11, 0x44, - 0x40, 0x0d, 0x27, 0x7a, 0x0f, 0xd9, 0x5f, 0x12, 0x69, 0x4c, 0x84, 0xcd, - 0x36, 0xe3, 0x85, 0xb2, 0xcd, 0x2f, 0x4a, 0x8b, 0x58, 0x36, 0xf6, 0x76, - 0xa8, 0x64, 0x64, 0x3c, 0xa4, 0x93, 0xaa, 0x25, 0x3c, 0x49, 0xda, 0xa4, - 0xe5, 0x26, 0x54, 0xe4, 0x8c, 0x7c, 0x5c, 0x93, 0x4d, 0x67, 0xc9, 0x3a, - 0x6e, 0x9f, 0x13, 0xb4, 0xce, 0xf7, 0x3a, 0x9b, 0xad, 0x52, 0xd6, 0x2a, - 0xd1, 0x49, 0xee, 0xc7, 0xf8, 0x64, 0x46, 0x42, 0x4e, 0xcd, 0x92, 0xc2, - 0x00, 0xdd, 0x8a, 0x47, 0xe5, 0x69, 0x6e, 0xd4, 0xa4, 0x08, 0x16, 0x83, - 0x9c, 0x8c, 0xdd, 0x95, 0x6b, 0xb9, 0xf6, 0xef, 0x97, 0x78, 0x94, 0xe3, - 0x78, 0x04, 0xa4, 0xf3, 0xe8, 0xee, 0x64, 0xe1, 0x12, 0x10, 0x05, 0x6a, - 0xc7, 0xc0, 0x6f, 0x53, 0xf3, 0xc9, 0x89, 0xb4, 0x9c, 0x4e, 0xb4, 0xf2, - 0xd3, 0xde, 0x7a, 0xd2, 0x19, 0x16, 0x38, 0x61, 0x5d, 0xd9, 0x88, 0x05, - 0x9c, 0xf4, 0x0a, 0x0f, 0x5f, 0x73, 0x84, 0xe4, 0xa4, 0xc7, 0x0d, 0xa5, - 0xf1, 0x59, 0xba, 0x5c, 0x08, 0x98, 0x6f, 0xc8, 0x20, 0xfa, 0x4e, 0x4e, - 0xf6, 0x69, 0xe1, 0xa2, 0x89, 0xfd, 0x1f, 0x77, 0x2c, 0xe6, 0xce, 0xd6, - 0x17, 0x9a, 0x69, 0xdb, 0xd3, 0x86, 0x18, 0xc1, 0x67, 0x77, 0x26, 0x80, - 0x28, 0x1b, 0x93, 0x88, 0x41, 0x0f, 0x40, 0xb0, 0xfc, 0x87, 0xf3, 0x43, - 0x98, 0xd7, 0x58, 0x96, 0xdb, 0x4d, 0x91, 0x88, 0xe5, 0x6c, 0x58, 0xdc, - 0x5c, 0x2a, 0xf7, 0x2c, 0xb1, 0xfc, 0x20, 0x8f, 0x02, 0xd9, 0x65, 0x06, - 0xbe, 0x26, 0x6f, 0xa2, 0x7f, 0xce, 0x3d, 0x69, 0x26, 0xdd, 0x13, 0x52, - 0xbf, 0xbd, 0x92, 0x62, 0x59, 0x4c, 0x90, 0xac, 0x50, 0x45, 0x5e, 0xbb, - 0x09, 0x03, 0x12, 0x29, 0x84, 0x00, 0xc4, 0xc9, 0x11, 0xff, 0x00, 0x42, - 0xe7, 0xa7, 0x7a, 0xd4, 0xfd, 0x21, 0x79, 0xe9, 0x78, 0x71, 0x8b, 0x95, - 0x39, 0x75, 0xaf, 0x4e, 0x98, 0x78, 0x42, 0x38, 0xdf, 0xff, 0xd1, 0xf0, - 0xe6, 0xa0, 0x58, 0xc8, 0x84, 0x9a, 0xaa, 0x30, 0x55, 0xf9, 0x0a, 0x6f, - 0x90, 0x0c, 0xca, 0x72, 0x48, 0xb8, 0x1e, 0x89, 0xa7, 0x23, 0x17, 0x24, - 0xff, 0x00, 0x61, 0xb6, 0x54, 0x76, 0x6e, 0x1b, 0xa7, 0xbe, 0x50, 0xf2, - 0xc1, 0xd7, 0x4c, 0x52, 0x5e, 0x33, 0x5b, 0xe9, 0x10, 0xf4, 0x54, 0x3c, - 0x5e, 0x77, 0xee, 0x49, 0xec, 0x2b, 0xb6, 0x63, 0xe4, 0xc9, 0xc3, 0xef, - 0x73, 0xf0, 0xe1, 0x32, 0x1b, 0xf2, 0x7a, 0x05, 0xce, 0xad, 0x65, 0xa1, - 0x98, 0xb4, 0x0f, 0x2a, 0x5b, 0x23, 0xeb, 0x12, 0x00, 0x88, 0xb0, 0xa8, - 0x66, 0x46, 0x3d, 0xea, 0x7b, 0xfb, 0x9e, 0x99, 0x89, 0xbc, 0x8d, 0x97, - 0x3a, 0x34, 0x05, 0x32, 0x5d, 0x1f, 0xc9, 0x1a, 0x8c, 0x36, 0x8c, 0x6f, - 0x66, 0xfa, 0xc6, 0xb7, 0x7d, 0xf0, 0x94, 0x04, 0xf0, 0x88, 0xc9, 0xd5, - 0x9d, 0x8d, 0x4b, 0x11, 0xd4, 0x9f, 0xbb, 0x25, 0xc5, 0xdc, 0xa2, 0x03, - 0x99, 0x4b, 0xbc, 0xf3, 0x0d, 0x97, 0x96, 0x74, 0xe5, 0xf2, 0xb6, 0x80, - 0x95, 0xbd, 0x99, 0x15, 0xf5, 0x4b, 0xd2, 0x37, 0x58, 0x46, 0xd4, 0x27, - 0xc5, 0xce, 0xc1, 0x7c, 0x30, 0x8e, 0x68, 0x94, 0x7b, 0x9e, 0x6d, 0xe6, - 0x7b, 0x9b, 0x5d, 0x3a, 0xd8, 0xdb, 0x32, 0xfa, 0x77, 0x65, 0x15, 0xe4, - 0x57, 0xa7, 0x21, 0x55, 0x04, 0x57, 0xef, 0xd8, 0x66, 0x56, 0x38, 0x19, - 0x1b, 0xe8, 0xe0, 0x67, 0x98, 0xc7, 0x1a, 0x1c, 0xde, 0x71, 0x71, 0x79, - 0x2c, 0xf2, 0xfa, 0x8c, 0x48, 0xec, 0xb5, 0x24, 0x9a, 0x0c, 0xce, 0x75, - 0x29, 0xae, 0x8c, 0x67, 0xd4, 0xb5, 0x0b, 0x4b, 0x04, 0x05, 0xef, 0x2e, - 0x66, 0x8e, 0x18, 0x08, 0x15, 0xdd, 0x8f, 0x11, 0xb0, 0xeb, 0x4c, 0x04, - 0x5b, 0x21, 0x2a, 0x7d, 0x41, 0xe4, 0x4f, 0xcb, 0xcb, 0x5d, 0x12, 0x45, - 0xb8, 0xb7, 0x53, 0x71, 0xaa, 0x9f, 0x86, 0x5b, 0xd6, 0x50, 0x4a, 0xed, - 0xba, 0x46, 0x77, 0x00, 0x13, 0xd4, 0x8c, 0x85, 0xd3, 0x12, 0x6d, 0xeb, - 0x1a, 0x67, 0x95, 0xd9, 0x39, 0x39, 0x50, 0xac, 0xff, 0x00, 0x6f, 0xc4, - 0xff, 0x00, 0x1c, 0x81, 0x92, 0xb2, 0x6b, 0x6d, 0x02, 0xdd, 0xbd, 0x36, - 0x92, 0x36, 0x2d, 0x1f, 0xc0, 0x2a, 0x0b, 0x28, 0x1b, 0x91, 0x41, 0xf4, - 0x9c, 0xb6, 0x25, 0x81, 0x46, 0xfe, 0x81, 0xb5, 0xad, 0x3d, 0xba, 0x57, - 0xb7, 0xf9, 0xf6, 0xc9, 0xb0, 0x7f, 0xff, 0xd2, 0xf0, 0xe2, 0x86, 0x95, - 0xc4, 0x67, 0x7e, 0x3f, 0x11, 0xf7, 0xa8, 0x19, 0x06, 0x69, 0x8d, 0xca, - 0xca, 0x24, 0x8f, 0xd3, 0x52, 0x24, 0x89, 0x47, 0x25, 0x1f, 0xcb, 0x20, - 0xf8, 0xb2, 0xb2, 0x76, 0x6e, 0x88, 0x36, 0xf6, 0x6f, 0x2a, 0xc1, 0x6e, - 0xfa, 0x45, 0xad, 0xbc, 0x3f, 0x0b, 0x46, 0x81, 0x4d, 0x46, 0xea, 0x7a, - 0x9a, 0x83, 0x9a, 0xa9, 0xdd, 0xbb, 0xec, 0x7b, 0x06, 0x5b, 0xe5, 0xcf, - 0x2e, 0x69, 0xfa, 0x5c, 0xcd, 0x7b, 0x14, 0x5e, 0xa5, 0xee, 0xf5, 0xb8, - 0x7d, 0xdd, 0x99, 0xba, 0xef, 0x91, 0x16, 0x5b, 0x36, 0xb6, 0x65, 0x0d, - 0xac, 0xb2, 0x5b, 0xed, 0x34, 0x81, 0x7a, 0xbb, 0x46, 0x40, 0x6a, 0x9e, - 0xb4, 0x39, 0x31, 0x13, 0x49, 0xda, 0xd2, 0x9b, 0xed, 0x1e, 0xc4, 0x24, - 0xb3, 0x35, 0xb2, 0x88, 0x60, 0x06, 0xe6, 0x56, 0x98, 0x96, 0x79, 0x1e, - 0x31, 0x51, 0xc9, 0x8f, 0xcb, 0x00, 0xe6, 0xb3, 0xe4, 0xf9, 0x2b, 0xcc, - 0x7a, 0x94, 0xda, 0x96, 0xa9, 0x71, 0x77, 0x70, 0x79, 0xcd, 0x33, 0x97, - 0x76, 0x3f, 0xcc, 0xc6, 0xa6, 0x9f, 0x2e, 0x99, 0xb9, 0xc6, 0x2a, 0x21, - 0xe6, 0x73, 0xca, 0xe6, 0x4a, 0x51, 0x1a, 0x99, 0x1c, 0x28, 0x04, 0x93, - 0xd0, 0x0e, 0xa4, 0xe4, 0xda, 0x5f, 0x50, 0xfe, 0x4a, 0xfe, 0x48, 0xb5, - 0xb2, 0xc1, 0xe6, 0x1f, 0x31, 0x7e, 0xef, 0x52, 0x91, 0x43, 0xc3, 0x6e, - 0x77, 0xf4, 0x22, 0x6d, 0xbf, 0xe4, 0x63, 0x0e, 0xbf, 0xca, 0x36, 0xeb, - 0x5c, 0x84, 0xa5, 0x48, 0x7d, 0x3b, 0x61, 0xa1, 0xdb, 0x5b, 0x2c, 0x71, - 0xda, 0x45, 0xc4, 0x28, 0x00, 0x81, 0xdb, 0x31, 0xc9, 0xb4, 0xb2, 0x3b, - 0x5d, 0x27, 0xa5, 0x05, 0x1b, 0xc7, 0xdb, 0x10, 0xa9, 0xbd, 0xa6, 0x93, - 0x0c, 0x75, 0xe4, 0x39, 0x35, 0x41, 0x3d, 0xc5, 0x06, 0xdb, 0x8e, 0xfd, - 0x46, 0x5b, 0x1d, 0x98, 0x95, 0x4f, 0x46, 0xdb, 0xd5, 0xfb, 0x29, 0x5e, - 0x9d, 0x0d, 0x32, 0xeb, 0x61, 0x4f, 0xff, 0xd3, 0xf1, 0x46, 0x9a, 0x16, - 0x1b, 0x91, 0x71, 0x28, 0xac, 0x4a, 0x14, 0x30, 0x3e, 0x19, 0x54, 0xb9, - 0x36, 0xc7, 0x9b, 0x2d, 0xd1, 0x6c, 0x45, 0xe3, 0xdc, 0xde, 0xc8, 0x95, - 0x5b, 0x87, 0xf8, 0x41, 0x1d, 0x10, 0x54, 0x01, 0x98, 0x79, 0x25, 0xd1, - 0xda, 0xe9, 0xe1, 0xb5, 0x9e, 0xac, 0xeb, 0x42, 0xba, 0x8e, 0xdf, 0x8c, - 0x31, 0x21, 0x70, 0xb4, 0x5d, 0xbe, 0xc5, 0x7c, 0x2b, 0xed, 0xe1, 0x94, - 0x18, 0xb9, 0x51, 0x3d, 0x03, 0x2c, 0x13, 0x6b, 0xf1, 0x42, 0x6e, 0xe2, - 0xb7, 0x12, 0xa0, 0xdd, 0x50, 0x9f, 0x4f, 0x6f, 0xa7, 0x6f, 0xc7, 0x03, - 0x61, 0xa0, 0x83, 0xb5, 0xf3, 0x97, 0x98, 0x20, 0x9c, 0x44, 0xea, 0xd0, - 0xad, 0x48, 0x64, 0x90, 0x21, 0xd8, 0x9f, 0xa7, 0xa6, 0x44, 0xca, 0x99, - 0xc6, 0x36, 0xcb, 0x74, 0x5d, 0x7e, 0x5b, 0xfe, 0x31, 0x6a, 0x31, 0xf3, - 0x8c, 0xd0, 0xad, 0x40, 0xa3, 0x1f, 0x7c, 0x44, 0xd6, 0x51, 0xd9, 0xe0, - 0x5f, 0x9a, 0x7e, 0x41, 0x9f, 0x40, 0xf3, 0x14, 0xba, 0x85, 0xba, 0x34, - 0xba, 0x2d, 0xfb, 0x34, 0xd0, 0xcf, 0x4f, 0xb0, 0xce, 0x6a, 0x51, 0xe9, - 0xb0, 0x20, 0xf4, 0xf1, 0x19, 0xb2, 0xc3, 0x90, 0x11, 0x4e, 0x97, 0x55, - 0x80, 0x83, 0xc4, 0x17, 0x7e, 0x4c, 0x79, 0x19, 0xfc, 0xd1, 0xe7, 0x78, - 0x4b, 0x91, 0x1d, 0xae, 0x92, 0xa6, 0xf6, 0x46, 0x75, 0xe4, 0xad, 0x22, - 0x1f, 0xdd, 0xa1, 0x07, 0xb3, 0x1e, 0xfe, 0xd9, 0x92, 0xeb, 0x4b, 0xed, - 0xfd, 0x0a, 0xc2, 0x63, 0x27, 0xa4, 0x88, 0x17, 0x60, 0x49, 0x35, 0xdc, - 0x8e, 0xa5, 0x7d, 0xab, 0xd3, 0x28, 0x90, 0x50, 0xcd, 0xed, 0x2d, 0xda, - 0x15, 0x55, 0x51, 0xf1, 0x1a, 0x0a, 0xf7, 0x39, 0x5d, 0xaa, 0x77, 0x6f, - 0x01, 0x8e, 0xa7, 0x7d, 0xfa, 0xff, 0x00, 0x66, 0x10, 0xa8, 0xb8, 0x63, - 0x76, 0x90, 0xa8, 0x20, 0x06, 0x56, 0xdb, 0x61, 0xda, 0xbd, 0x4f, 0xcb, - 0x24, 0x15, 0x0f, 0xf5, 0x66, 0xe5, 0x5f, 0x4c, 0x53, 0xc3, 0xb7, 0xce, - 0x99, 0x6b, 0x17, 0xff, 0xd4, 0xf0, 0xec, 0x57, 0x6f, 0x32, 0xa5, 0xa4, - 0x43, 0x76, 0x75, 0xa9, 0xf1, 0x03, 0xfa, 0x64, 0x08, 0x6c, 0x8e, 0xfb, - 0x3d, 0x7f, 0xcb, 0x16, 0x2b, 0x3d, 0xbc, 0x16, 0xa3, 0x66, 0x6d, 0x98, - 0xfb, 0x1e, 0xb9, 0xac, 0xc8, 0x77, 0xb7, 0x7d, 0x01, 0xb3, 0x37, 0xb8, - 0xd3, 0x46, 0x95, 0x68, 0x86, 0xd2, 0x2e, 0x4e, 0xab, 0xf0, 0x23, 0x11, - 0x4e, 0x5f, 0xcd, 0x98, 0xe7, 0x25, 0x96, 0x71, 0x83, 0x0f, 0xd6, 0x3c, - 0xb9, 0xe7, 0x0d, 0x7c, 0x41, 0x22, 0x5e, 0xb3, 0x20, 0x0c, 0x65, 0x80, - 0xc8, 0x63, 0x8e, 0xbb, 0x95, 0xa5, 0x07, 0xeb, 0xcc, 0xac, 0x73, 0x83, - 0x4e, 0x5c, 0x59, 0x09, 0xd8, 0xec, 0xc8, 0x57, 0x41, 0xd3, 0x4e, 0x95, - 0xa5, 0x5b, 0x4b, 0x6a, 0xcb, 0xab, 0x43, 0x10, 0x4b, 0xeb, 0x85, 0xa2, - 0x2c, 0x8e, 0x3f, 0x68, 0x54, 0xf5, 0x00, 0xd3, 0x97, 0x7a, 0x65, 0x79, - 0xa6, 0x24, 0x76, 0x6f, 0xd3, 0x62, 0x96, 0x30, 0x78, 0xcb, 0x21, 0xf2, - 0xf4, 0x22, 0xce, 0x54, 0x8e, 0x46, 0x26, 0x10, 0x7e, 0x0a, 0xf5, 0xd8, - 0xf5, 0x1f, 0x31, 0x98, 0x83, 0x73, 0xb3, 0x91, 0xcd, 0x67, 0xe6, 0x7d, - 0xe8, 0x16, 0x69, 0x6f, 0x10, 0x1f, 0x54, 0x9a, 0x37, 0xf5, 0x41, 0x5e, - 0x7f, 0x0a, 0x29, 0x62, 0x02, 0xf8, 0x9c, 0xc8, 0x8c, 0x77, 0x6a, 0x99, - 0xa0, 0x89, 0xff, 0x00, 0x9c, 0x74, 0xd2, 0xed, 0xed, 0xfc, 0xbb, 0x7b, - 0xaa, 0x9a, 0x7d, 0x62, 0xfe, 0x46, 0x2d, 0xfe, 0x4c, 0x51, 0x31, 0x11, - 0xa9, 0xf6, 0xef, 0x9b, 0x30, 0x5e, 0x7b, 0x38, 0xdd, 0xf4, 0x7f, 0x95, - 0x94, 0xbc, 0x12, 0x43, 0x30, 0x6a, 0xb2, 0xf3, 0x86, 0x40, 0x3e, 0xcb, - 0xd7, 0x6a, 0xd7, 0xb1, 0xe9, 0x8f, 0x37, 0x19, 0x97, 0x41, 0x2c, 0x71, - 0x20, 0xf5, 0x36, 0x9c, 0x55, 0x78, 0x1d, 0x8a, 0x91, 0xd7, 0x11, 0x14, - 0x5a, 0x3e, 0x19, 0x03, 0x10, 0x6b, 0xca, 0xbd, 0x86, 0xf8, 0x9d, 0x95, - 0x18, 0x36, 0x65, 0x2e, 0xbc, 0x54, 0x1f, 0xa2, 0x99, 0x00, 0x59, 0x2a, - 0x6f, 0x5e, 0x55, 0x15, 0xe9, 0x5f, 0xc3, 0x2f, 0xb6, 0x14, 0xff, 0x00, - 0xff, 0xd5, 0xf1, 0x95, 0xfe, 0x80, 0x74, 0x0d, 0x7c, 0xd9, 0x89, 0x3d, - 0x78, 0x57, 0x8b, 0xc5, 0x28, 0xe8, 0x55, 0xf7, 0x1f, 0x48, 0xca, 0x38, - 0xb8, 0x83, 0x9f, 0x93, 0x07, 0x85, 0x3a, 0x7a, 0x6f, 0x95, 0x66, 0x2b, - 0x2c, 0x4c, 0x0d, 0x14, 0x00, 0x3e, 0x9c, 0xc3, 0x98, 0x76, 0xb8, 0x45, - 0xbd, 0x02, 0xde, 0x48, 0xee, 0xdc, 0xa0, 0x15, 0xe2, 0x2b, 0xc8, 0x8a, - 0x8a, 0xfd, 0x3b, 0x66, 0x3f, 0x00, 0x73, 0x84, 0x2d, 0x36, 0xb5, 0xb5, - 0x9e, 0x35, 0x1c, 0x29, 0xc4, 0xfe, 0xc8, 0x04, 0x7f, 0xc4, 0x69, 0x91, - 0xe1, 0x67, 0x2c, 0x4a, 0xd2, 0xe9, 0x4e, 0xe3, 0xd4, 0xf4, 0x81, 0x5a, - 0x12, 0xc5, 0x41, 0x3f, 0x79, 0x38, 0x9b, 0x60, 0x20, 0x07, 0x34, 0xb0, - 0xc9, 0x03, 0x5c, 0x23, 0x03, 0x53, 0x13, 0x56, 0x88, 0xdf, 0x09, 0xda, - 0x9b, 0xd3, 0xb6, 0x52, 0x0e, 0xec, 0xe4, 0x29, 0x24, 0xfc, 0xd0, 0xe7, - 0x75, 0xe5, 0x57, 0x6b, 0x61, 0xfb, 0xf0, 0xca, 0xaa, 0x57, 0xa8, 0xe6, - 0x78, 0x1a, 0x7d, 0xf9, 0x95, 0x8a, 0x5e, 0xa0, 0xe3, 0x67, 0x8f, 0xa0, - 0xbd, 0x5b, 0xf2, 0xdf, 0x4a, 0x82, 0xcb, 0x4a, 0xb3, 0xb0, 0xb4, 0x41, - 0x0a, 0x70, 0x48, 0xd9, 0x57, 0x60, 0x51, 0x3a, 0x8f, 0xbc, 0xe6, 0x7b, - 0xcb, 0xe4, 0x3b, 0xa7, 0x3f, 0x9b, 0x9f, 0x9a, 0xba, 0x77, 0xe5, 0x5f, - 0x95, 0x9c, 0x59, 0x94, 0x9f, 0xcd, 0x37, 0x8c, 0xa9, 0xa6, 0xd9, 0x39, - 0xaa, 0xd0, 0x7d, 0xa9, 0x1c, 0x03, 0x5e, 0x09, 0xff, 0x00, 0x0c, 0x76, - 0xcb, 0x62, 0x2d, 0xa5, 0xf2, 0x85, 0xbf, 0xe7, 0x87, 0xe6, 0xa3, 0x5e, - 0x4d, 0xa8, 0xc9, 0xe6, 0x8b, 0xd5, 0x69, 0x5c, 0xb0, 0x4a, 0xab, 0xc4, - 0xb5, 0x35, 0x0a, 0xaa, 0xea, 0x40, 0x03, 0xa0, 0xf6, 0xcb, 0x40, 0x4d, - 0x3e, 0xdb, 0xff, 0x00, 0x9c, 0x7f, 0xfc, 0xce, 0x4f, 0xcc, 0xbf, 0x26, - 0x25, 0xe5, 0xd3, 0x2f, 0xe9, 0xdd, 0x3d, 0xfe, 0xab, 0xa9, 0xaa, 0xd2, - 0xa6, 0x40, 0x2a, 0xb2, 0x71, 0x00, 0x01, 0xea, 0x0d, 0xe8, 0x3a, 0x64, - 0x25, 0x16, 0x1c, 0x8b, 0xd9, 0x51, 0x39, 0x28, 0x12, 0x51, 0x41, 0xfd, - 0xa3, 0xd2, 0xb9, 0x4f, 0x0d, 0x33, 0xb5, 0xf4, 0x87, 0x9d, 0x79, 0x0e, - 0xb4, 0xaf, 0x6a, 0xf8, 0xf1, 0xf0, 0xc9, 0xda, 0xbf, 0xff, 0xd6, 0xf2, - 0xc6, 0xb5, 0x68, 0x64, 0xd0, 0x6d, 0x35, 0x20, 0x39, 0xcd, 0x13, 0x0f, - 0x5e, 0x61, 0xfc, 0x8f, 0x40, 0x8b, 0x5e, 0xe0, 0x66, 0x1c, 0x4f, 0xaa, - 0x9d, 0xe6, 0xa6, 0x1e, 0x91, 0x2e, 0xa9, 0x87, 0x95, 0xee, 0x9c, 0xc5, - 0x55, 0x34, 0x60, 0x40, 0xae, 0x57, 0x30, 0xd9, 0xa7, 0x95, 0xbd, 0x6f, - 0xcb, 0x26, 0x39, 0x40, 0x0d, 0x4e, 0xc0, 0x9f, 0x9e, 0x50, 0x5d, 0xac, - 0x79, 0x33, 0x8b, 0xbb, 0x9b, 0x3b, 0x6b, 0x35, 0x48, 0x54, 0x09, 0x29, - 0x56, 0x7f, 0xe1, 0x86, 0x72, 0x00, 0x2c, 0x6e, 0xf7, 0x63, 0x3e, 0x63, - 0xbd, 0xbd, 0x5d, 0x20, 0x2a, 0xb3, 0xa4, 0x33, 0x48, 0xab, 0x21, 0x43, - 0xf1, 0x2c, 0x47, 0xed, 0x1d, 0xbc, 0x73, 0x18, 0x9b, 0x64, 0x28, 0x96, - 0x3a, 0xc7, 0x49, 0xb0, 0xf4, 0xcc, 0xe9, 0x73, 0x6c, 0xb4, 0xf8, 0x67, - 0x92, 0x32, 0x21, 0x70, 0x7b, 0x89, 0x05, 0x57, 0xef, 0x38, 0x28, 0x94, - 0x4a, 0x7d, 0x13, 0x7d, 0x6a, 0xd3, 0x4c, 0xb8, 0xf2, 0xc3, 0xc8, 0x2e, - 0x03, 0xf3, 0xe2, 0x7d, 0x33, 0xb7, 0xc5, 0xcc, 0x71, 0x03, 0xc6, 0xb9, - 0x64, 0x06, 0xe2, 0x9a, 0xf2, 0x4f, 0xd2, 0x6d, 0xe9, 0xfe, 0x41, 0x45, - 0x5b, 0x18, 0x66, 0xa5, 0x64, 0x09, 0xf4, 0xd5, 0xb7, 0xcd, 0x93, 0xc7, - 0xcf, 0x9b, 0xe5, 0x6f, 0xf9, 0xc8, 0x0d, 0x56, 0xeb, 0x59, 0xfc, 0xce, - 0xd5, 0x12, 0x61, 0xc4, 0x69, 0xe9, 0x0d, 0xa4, 0x4b, 0xfe, 0x48, 0x40, - 0xd5, 0x3e, 0xe4, 0xb6, 0x64, 0x8e, 0x4c, 0x02, 0x61, 0x65, 0xa0, 0x14, - 0xb4, 0xb6, 0xb0, 0xb1, 0xb6, 0xb2, 0x97, 0xcb, 0xf1, 0x5a, 0x2d, 0xc6, - 0xa5, 0xac, 0xb4, 0x70, 0x5d, 0xc7, 0x3d, 0xc1, 0x51, 0x24, 0x91, 0xc9, - 0x31, 0x75, 0x6b, 0x70, 0x9f, 0x14, 0x68, 0x01, 0x46, 0xe4, 0xb5, 0xa3, - 0x17, 0xcb, 0x40, 0x61, 0x6f, 0x47, 0xff, 0x00, 0x9c, 0x3a, 0x8f, 0x5b, - 0x4f, 0x3c, 0x6b, 0xb7, 0xfa, 0x30, 0x91, 0x3c, 0xa4, 0xb1, 0x95, 0xb9, - 0x82, 0x42, 0x0a, 0xbc, 0x8e, 0xe4, 0xdb, 0xa9, 0xef, 0xc9, 0x17, 0x91, - 0x24, 0x7c, 0xb2, 0x05, 0x64, 0xfb, 0x75, 0x64, 0x32, 0x39, 0x69, 0x5b, - 0x9c, 0xad, 0xb9, 0xdb, 0xa7, 0xb5, 0x3b, 0x53, 0x2a, 0x21, 0x41, 0x44, - 0xf3, 0x8b, 0x8f, 0x2e, 0x43, 0x9d, 0x2b, 0xd4, 0x57, 0x23, 0x41, 0x36, - 0xff, 0x00, 0xff, 0xd7, 0xf0, 0xc0, 0xd5, 0xb5, 0x11, 0x64, 0xb6, 0x3f, - 0x59, 0x90, 0xd9, 0xab, 0x06, 0xf4, 0x79, 0x7c, 0x3b, 0x74, 0xc8, 0x08, - 0x8b, 0xb6, 0xe3, 0x96, 0x55, 0x57, 0xb3, 0x3e, 0xf2, 0x35, 0xc7, 0xd6, - 0x0b, 0x45, 0x5d, 0xdc, 0x8a, 0x7d, 0xd9, 0x8d, 0x94, 0x3b, 0x3d, 0x1c, - 0x9e, 0xc3, 0xe5, 0xc3, 0x2c, 0x7c, 0xc5, 0x0f, 0xee, 0xdb, 0x8b, 0x0c, - 0xc4, 0x26, 0x9d, 0xa0, 0x9a, 0x7d, 0x2c, 0xe5, 0xe4, 0x55, 0x7f, 0xee, - 0xc1, 0x15, 0x04, 0xd0, 0x12, 0x3c, 0x72, 0x89, 0x1b, 0x2c, 0xcc, 0xa8, - 0x2a, 0x8b, 0x87, 0xbb, 0x63, 0x1a, 0x28, 0x65, 0xf0, 0xed, 0xf2, 0xc3, - 0xc2, 0x0a, 0x06, 0x4a, 0x46, 0xc7, 0xa5, 0xa3, 0x59, 0xc8, 0xb2, 0xc7, - 0x45, 0x22, 0x9c, 0x14, 0x54, 0x10, 0x46, 0xf5, 0x1d, 0x32, 0x5c, 0x14, - 0x14, 0xe4, 0x32, 0x2f, 0x3a, 0xf3, 0xb6, 0x90, 0x9a, 0x6d, 0xae, 0x9f, - 0x3d, 0xab, 0xb8, 0x8a, 0x3b, 0xf8, 0x39, 0x44, 0x58, 0xf0, 0x08, 0xd5, - 0x14, 0xa5, 0x7b, 0x65, 0x98, 0x8e, 0xfb, 0xb5, 0x67, 0x87, 0xa5, 0xef, - 0x5e, 0x44, 0x96, 0x35, 0xb5, 0xb6, 0x59, 0x36, 0xfd, 0xd8, 0xa0, 0xf1, - 0x20, 0x53, 0x33, 0xc0, 0x79, 0x59, 0x73, 0x7c, 0xd7, 0xf9, 0xfb, 0xa2, - 0xcd, 0x67, 0xf9, 0xa7, 0x7b, 0x72, 0xf1, 0x71, 0x83, 0x53, 0x86, 0x0b, - 0x98, 0x24, 0x22, 0x8a, 0xcc, 0x88, 0x23, 0x7f, 0xb8, 0xae, 0xf9, 0x7c, - 0x50, 0x1e, 0x5f, 0x7c, 0x48, 0x21, 0x44, 0x6b, 0xce, 0x9b, 0xb0, 0x1b, - 0x9e, 0xf5, 0xaf, 0x8e, 0x4d, 0x5f, 0x7a, 0x7f, 0xce, 0x34, 0xf9, 0x5d, - 0x3c, 0xa3, 0xf9, 0x69, 0x63, 0xa9, 0x3c, 0x27, 0xeb, 0xda, 0xe1, 0x37, - 0xd7, 0x2e, 0xaa, 0xdb, 0x06, 0xda, 0x30, 0x49, 0xfe, 0x54, 0x03, 0x03, - 0x49, 0xdc, 0xb3, 0xaf, 0x38, 0xfe, 0x6a, 0xf9, 0x47, 0xc9, 0x3a, 0x74, - 0x97, 0xfa, 0xf6, 0xaf, 0x15, 0x85, 0xb8, 0x75, 0x89, 0xb8, 0x87, 0x9a, - 0x72, 0xee, 0x2a, 0x14, 0x24, 0x60, 0xb1, 0xa8, 0xdf, 0x07, 0x0b, 0x2d, - 0xcb, 0xcf, 0x7f, 0xe8, 0x6a, 0xff, 0x00, 0x26, 0xbd, 0x6a, 0x7f, 0x89, - 0x2f, 0xf8, 0x52, 0x9e, 0xb7, 0xe8, 0xb9, 0xb8, 0x57, 0xc2, 0x95, 0xe9, - 0x8f, 0x08, 0x5a, 0x2f, 0xff, 0xd0, 0xf0, 0x4d, 0x40, 0xaa, 0xd7, 0x00, - 0x64, 0xcb, 0x3c, 0x97, 0xa8, 0xb5, 0x9e, 0xa3, 0x1a, 0xd6, 0x84, 0x95, - 0x3f, 0x45, 0x72, 0x9c, 0xa2, 0xc3, 0x99, 0xa5, 0x9d, 0x49, 0xf4, 0x17, - 0x97, 0xaf, 0x63, 0x17, 0x52, 0x6f, 0xf0, 0xc8, 0x43, 0x6f, 0x9a, 0xe9, - 0x07, 0x70, 0x0e, 0xec, 0x83, 0x51, 0x44, 0xb8, 0x61, 0x1a, 0x9e, 0x11, - 0xd3, 0x91, 0x60, 0x68, 0x6b, 0xd3, 0x31, 0x4f, 0x36, 0xd3, 0x4c, 0x52, - 0xef, 0x4c, 0xd5, 0x0c, 0xc4, 0x69, 0xda, 0x94, 0xc8, 0x3a, 0xf0, 0x66, - 0x07, 0x73, 0xe0, 0x40, 0xfd, 0x79, 0x93, 0x12, 0x1c, 0x9c, 0x32, 0xc7, - 0xfc, 0x41, 0x33, 0xd2, 0xb4, 0x6f, 0x38, 0x98, 0x65, 0x76, 0xbf, 0x69, - 0x42, 0xd0, 0xaa, 0xc9, 0xde, 0x95, 0xad, 0x28, 0x46, 0x4e, 0xac, 0x39, - 0x77, 0x80, 0x11, 0xbf, 0xd8, 0xc7, 0x7c, 0xe1, 0xa5, 0xf9, 0x92, 0x4d, - 0x32, 0x5b, 0x8b, 0x93, 0x27, 0xa7, 0x68, 0x56, 0xe2, 0x45, 0xda, 0x85, - 0x61, 0x6e, 0x67, 0xad, 0x6b, 0xb0, 0x38, 0xc2, 0x81, 0xe4, 0xc7, 0x52, - 0x31, 0x1c, 0x67, 0x86, 0x5b, 0xbd, 0x37, 0xca, 0x7a, 0x94, 0xb1, 0x69, - 0xb6, 0x2e, 0xb7, 0x15, 0x48, 0xc2, 0xb4, 0x52, 0x53, 0xac, 0x32, 0xaf, - 0xb1, 0xed, 0x9b, 0x10, 0x36, 0x78, 0x5c, 0x9f, 0x51, 0x64, 0x1f, 0x98, - 0x3e, 0x58, 0xb6, 0xfc, 0xc8, 0xf2, 0xe5, 0xbc, 0x68, 0x52, 0x2d, 0x5a, - 0xd1, 0x84, 0xb6, 0xf3, 0x95, 0x0e, 0xc0, 0x85, 0xe2, 0xcb, 0xd8, 0xd1, - 0xbb, 0xe4, 0xc1, 0xa6, 0x97, 0xce, 0x17, 0x5f, 0x95, 0xde, 0x6d, 0xb6, - 0xbe, 0xb7, 0x69, 0x34, 0xf3, 0x3c, 0x72, 0xcf, 0xe8, 0xa3, 0x45, 0x49, - 0x95, 0x4a, 0x90, 0x3e, 0x35, 0x5a, 0x95, 0x1d, 0xfe, 0x21, 0x93, 0x4d, - 0xbe, 0xd2, 0xd2, 0xf5, 0x8b, 0xbd, 0x32, 0x2d, 0x3f, 0x4c, 0x9a, 0xe4, - 0xca, 0x9e, 0x90, 0x85, 0x65, 0x55, 0x08, 0x85, 0x91, 0x01, 0x3b, 0x0a, - 0x05, 0xe9, 0xb0, 0xc0, 0x5a, 0xc3, 0xcd, 0x3f, 0x3b, 0x7f, 0x26, 0xec, - 0xff, 0x00, 0x35, 0x6d, 0x6d, 0xb5, 0x3d, 0x16, 0xfe, 0x0d, 0x3b, 0xcd, - 0x96, 0x01, 0x92, 0x46, 0x9e, 0xa2, 0x0b, 0xc8, 0xb7, 0x28, 0x92, 0x71, - 0xfb, 0x2e, 0xa7, 0xec, 0x3d, 0x0f, 0xc2, 0x68, 0x71, 0x05, 0x95, 0xd3, - 0xe7, 0x9f, 0xfa, 0x16, 0x2f, 0xcd, 0x7f, 0x43, 0xd6, 0xfa, 0xa5, 0x97, - 0xab, 0xeb, 0x7a, 0x5f, 0x55, 0xfa, 0xec, 0x5e, 0xaf, 0x0f, 0xf7, 0xed, - 0x2b, 0x4e, 0x15, 0xff, 0x00, 0x65, 0xdf, 0x8e, 0x14, 0xf1, 0xbf, 0xff, - 0xd1, 0xf0, 0x5a, 0xa7, 0x18, 0x5e, 0x56, 0x1f, 0x68, 0x71, 0x5f, 0xa7, - 0xbe, 0x2a, 0x98, 0xdb, 0xfa, 0x90, 0x24, 0x37, 0xb0, 0xfd, 0xb8, 0xa8, - 0x58, 0x78, 0xae, 0x43, 0xc9, 0xb4, 0x6d, 0xbb, 0xda, 0x3c, 0xa1, 0xad, - 0x43, 0xa8, 0xda, 0xc5, 0x2a, 0x3d, 0x26, 0x5a, 0x02, 0x2b, 0xbe, 0x60, - 0x64, 0x8d, 0x17, 0x6f, 0x8b, 0x20, 0x90, 0x7a, 0x3c, 0x32, 0x8b, 0xa8, - 0x02, 0xf3, 0xfd, 0xe0, 0x1b, 0x11, 0x98, 0x66, 0x3b, 0xb9, 0x62, 0x54, - 0x83, 0x36, 0xf2, 0xa4, 0xe4, 0x29, 0x34, 0xeb, 0xc8, 0x74, 0xae, 0x0d, - 0xc3, 0x65, 0x82, 0x13, 0x6b, 0x57, 0xba, 0x54, 0xe4, 0x8c, 0x41, 0x1b, - 0x75, 0xa7, 0xe0, 0x72, 0x5c, 0x4c, 0x84, 0x50, 0x5a, 0xb3, 0xdd, 0xdd, - 0xc3, 0x24, 0x33, 0xb1, 0x60, 0xe0, 0x86, 0x52, 0x45, 0x38, 0xd2, 0x87, - 0x24, 0x26, 0x6d, 0x8c, 0xe1, 0x41, 0x25, 0xfc, 0xa3, 0xd7, 0x2f, 0x6f, - 0x3c, 0xbf, 0x73, 0xa5, 0xb2, 0x2c, 0xd1, 0x69, 0x17, 0x2f, 0x6b, 0x14, - 0x8c, 0x0f, 0x21, 0x0d, 0x79, 0x46, 0x09, 0x15, 0xed, 0xb7, 0x4e, 0xd9, - 0xb9, 0x8b, 0xcb, 0xe4, 0xa2, 0x5e, 0xa3, 0xa6, 0xdf, 0x6a, 0x36, 0xe4, - 0xcd, 0x69, 0x1c, 0x4e, 0x84, 0x7c, 0x76, 0xab, 0x21, 0x67, 0xa8, 0xa7, - 0xd9, 0xf8, 0x4d, 0x2b, 0xf3, 0xc3, 0x4d, 0x49, 0x57, 0x98, 0x75, 0x6f, - 0x31, 0xda, 0xf9, 0xa3, 0x4b, 0xfd, 0x1f, 0x69, 0x1d, 0xae, 0xa1, 0xa9, - 0x7e, 0xee, 0xe6, 0xd2, 0x79, 0x18, 0xf3, 0xb5, 0x1f, 0xee, 0xd9, 0x0a, - 0x01, 0x4e, 0x3f, 0xb3, 0x4d, 0xf2, 0x9c, 0xb9, 0x04, 0x05, 0xb7, 0xe2, - 0x87, 0x1e, 0xdd, 0x19, 0x3e, 0xaf, 0x6b, 0xae, 0xcb, 0x6d, 0x13, 0x0d, - 0x45, 0xa2, 0x8e, 0x06, 0xe5, 0x13, 0x2a, 0x02, 0x01, 0x5e, 0x82, 0xb5, - 0x04, 0xe6, 0x11, 0xd4, 0xcd, 0xda, 0x43, 0x49, 0x8e, 0xb7, 0xdc, 0xb1, - 0x51, 0xe6, 0x4d, 0x76, 0xd2, 0x61, 0x15, 0xaa, 0x4b, 0xa8, 0xc9, 0x6e, - 0x49, 0x79, 0x20, 0xe6, 0x8c, 0x49, 0xad, 0x43, 0x16, 0xe4, 0xa7, 0xaf, - 0x43, 0xd3, 0x26, 0x35, 0x75, 0xcd, 0xa8, 0xe8, 0x87, 0x46, 0xbf, 0xc7, - 0x9a, 0xff, 0x00, 0xd6, 0xbf, 0x48, 0xfe, 0x88, 0xfd, 0xe7, 0x0f, 0xab, - 0xfa, 0x3f, 0x58, 0x7f, 0x5f, 0x8d, 0x3f, 0x9f, 0xa7, 0x5e, 0xd4, 0xc3, - 0xf9, 0xd1, 0x7c, 0xb6, 0x47, 0xe4, 0x3a, 0x5b, 0xff, 0xd2, 0xf0, 0xb7, - 0xa6, 0x1e, 0xdf, 0xd3, 0xf6, 0xa5, 0x71, 0x54, 0xdb, 0x4b, 0x80, 0x3c, - 0x42, 0x26, 0xee, 0x29, 0xbe, 0x51, 0x23, 0x4e, 0x44, 0x05, 0x84, 0x45, - 0xa5, 0xd5, 0xf7, 0x97, 0x2e, 0xfd, 0x6b, 0x6a, 0x98, 0x09, 0xab, 0xc7, - 0xfc, 0x46, 0x3b, 0x4c, 0x26, 0x32, 0x30, 0x3e, 0x4f, 0x49, 0xd0, 0xfc, - 0xfb, 0x05, 0xd4, 0x4a, 0x7d, 0x40, 0xac, 0x3a, 0x8e, 0x84, 0x1c, 0xc5, - 0x96, 0x2a, 0x73, 0xe1, 0x9c, 0x16, 0x6d, 0xa5, 0x79, 0x86, 0xd6, 0xec, - 0x80, 0x5a, 0xa0, 0xf5, 0xca, 0xcc, 0x5c, 0xa1, 0x2b, 0x1b, 0x26, 0x30, - 0x6a, 0x31, 0x46, 0xcf, 0x1c, 0x87, 0x94, 0x64, 0x9e, 0x3d, 0xb6, 0xf0, - 0xca, 0xa8, 0x39, 0x51, 0x99, 0x42, 0x6b, 0x1a, 0xc5, 0xa5, 0xa5, 0x94, - 0xf7, 0x92, 0xc8, 0xaa, 0xb1, 0x23, 0x30, 0x04, 0xf8, 0x0e, 0x9f, 0x4e, - 0x4a, 0x11, 0xb2, 0xd5, 0x9b, 0x25, 0x06, 0x1b, 0xff, 0x00, 0x38, 0xfd, - 0xad, 0xdf, 0xda, 0xf9, 0xa2, 0xfe, 0xc5, 0x42, 0xbe, 0x9b, 0x7f, 0x0b, - 0xdd, 0xdd, 0x07, 0xaf, 0x14, 0x68, 0xd8, 0x71, 0x6d, 0xbb, 0x90, 0xfc, - 0x73, 0x6e, 0xf2, 0xf2, 0xdd, 0xf4, 0xad, 0xa6, 0xab, 0x6d, 0x69, 0x14, - 0xfa, 0xee, 0xa0, 0xe2, 0x0b, 0x0d, 0x39, 0x19, 0xfe, 0x11, 0xc5, 0x1a, - 0x4a, 0x1d, 0x8f, 0x73, 0x4f, 0xf8, 0x96, 0x0b, 0x40, 0x8d, 0xec, 0xf3, - 0x6d, 0x3f, 0x52, 0xba, 0xd6, 0x35, 0x8b, 0xbf, 0x36, 0x6a, 0x5f, 0x0d, - 0xc5, 0xdc, 0xa8, 0xb6, 0xa8, 0x7a, 0xc5, 0x6c, 0x9b, 0x22, 0x0f, 0xa3, - 0x73, 0x9a, 0xbc, 0xb3, 0xe2, 0x36, 0xed, 0xb1, 0x43, 0x80, 0x53, 0xd0, - 0xa7, 0xd4, 0x44, 0xfa, 0x7a, 0xda, 0x83, 0xbd, 0x3e, 0x2f, 0xa7, 0x2b, - 0xad, 0x9b, 0xb8, 0x8d, 0xa8, 0xe8, 0x91, 0xdb, 0xfa, 0x2d, 0x6f, 0xc3, - 0x8a, 0x2d, 0x56, 0xa3, 0xad, 0x4f, 0x5c, 0xa4, 0x0d, 0xdc, 0xa3, 0xca, - 0xd0, 0xbf, 0xa1, 0xe3, 0xfa, 0xe7, 0x0f, 0xf2, 0xb9, 0x57, 0xbf, 0x1a, - 0xe4, 0xb8, 0x57, 0xc5, 0xdd, 0xff, 0xd3, 0xf0, 0xcc, 0x5d, 0x7b, 0x70, - 0xc5, 0x53, 0x6d, 0x2f, 0xd5, 0xe4, 0x69, 0xfd, 0xdf, 0xec, 0xd7, 0xad, - 0x7d, 0xb2, 0x8c, 0x8d, 0xd8, 0xed, 0x91, 0x9f, 0x43, 0xea, 0xe7, 0xeb, - 0x94, 0xad, 0x3e, 0x1e, 0x95, 0xfc, 0x72, 0x81, 0x7d, 0x1c, 0x9d, 0xba, - 0xb1, 0x7b, 0xdf, 0xa9, 0x7a, 0xdf, 0xee, 0x2f, 0xd4, 0xfa, 0xe7, 0xed, - 0x7a, 0x7f, 0xdd, 0xff, 0x00, 0xb2, 0xae, 0x64, 0x0b, 0xea, 0xe3, 0x9a, - 0xbf, 0x4a, 0x6f, 0xa4, 0xff, 0x00, 0x89, 0xbd, 0x45, 0xfa, 0xb5, 0x79, - 0xf7, 0xeb, 0xc7, 0xe9, 0xae, 0x57, 0x2e, 0x17, 0x23, 0x1f, 0x89, 0xd1, - 0x99, 0x8f, 0xf1, 0xa7, 0x11, 0xcf, 0xd3, 0xf5, 0x29, 0xb5, 0x6b, 0xd3, - 0xe8, 0xcc, 0x7f, 0x45, 0xb9, 0xa3, 0xc5, 0x62, 0xbe, 0x68, 0xff, 0x00, - 0x15, 0xfd, 0x4c, 0xfe, 0x90, 0xaf, 0xd4, 0xab, 0xf1, 0x7a, 0x7f, 0x62, - 0x9d, 0xab, 0xdf, 0x32, 0xb1, 0x70, 0x5e, 0xdc, 0xdc, 0x2d, 0x47, 0x8b, - 0x5e, 0xae, 0x4c, 0xbf, 0xf2, 0x37, 0x9f, 0x3d, 0x5b, 0xd2, 0xff, 0x00, - 0x8e, 0x87, 0xee, 0x29, 0x5a, 0xf2, 0xf4, 0xaa, 0xd4, 0xa5, 0x36, 0xa7, - 0x3a, 0x57, 0xfd, 0x8e, 0x64, 0x3a, 0xf2, 0xf6, 0xbf, 0xcc, 0x7f, 0x5b, - 0xfc, 0x23, 0xa7, 0xfe, 0x8e, 0xff, 0x00, 0x8e, 0x37, 0xd6, 0x63, 0xfa, - 0xe5, 0x2b, 0xcb, 0x87, 0xec, 0xd6, 0xbd, 0xb9, 0x7d, 0xac, 0xc7, 0xcd, - 0x7c, 0x2d, 0xf8, 0x2b, 0x89, 0x26, 0x8f, 0xd4, 0xfa, 0x94, 0x3e, 0x85, - 0x29, 0xc9, 0x69, 0xfc, 0x33, 0x58, 0x5d, 0x9c, 0x79, 0xb2, 0xbb, 0x0f, - 0xac, 0x7a, 0x2b, 0xea, 0x75, 0xef, 0x92, 0x0c, 0x53, 0x3d, 0x2f, 0xd4, - 0xfa, 0xbb, 0xfa, 0x74, 0xf5, 0x39, 0x9a, 0xd7, 0xe7, 0x80, 0x53, 0x79, - 0xba, 0x5b, 0xfe, 0x97, 0xfa, 0x4b, 0xfc, 0xba, 0x7f, 0xb1, 0xc7, 0xab, - 0x1e, 0x8f, 0xff, 0xd9}; - -#endif // RTC_BASE_TEST_BASE64_H_ diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 2491335c96..6599615233 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -88,8 +88,6 @@ class ScopedAutoReleasePool { namespace webrtc { -using ::webrtc::MutexLock; -using ::webrtc::TimeDelta; ThreadManager* ThreadManager::Instance() { static ThreadManager* const thread_manager = new ThreadManager(); @@ -499,7 +497,7 @@ void Thread::PostDelayedTaskImpl(absl::AnyInvocable task, // Add to the priority queue. Gets sorted soonest first. // Signal for the multiplexer to return. - int64_t delay_ms = delay.RoundUpTo(webrtc::TimeDelta::Millis(1)).ms(); + int64_t delay_ms = delay.RoundUpTo(TimeDelta::Millis(1)).ms(); int64_t run_time_ms = TimeAfter(delay_ms); { MutexLock lock(&mutex_); @@ -523,7 +521,7 @@ int Thread::GetDelay() { return 0; if (!delayed_messages_.empty()) { - int delay = webrtc::TimeUntil(delayed_messages_.top().run_time_ms); + int delay = TimeUntil(delayed_messages_.top().run_time_ms); if (delay < 0) delay = 0; return delay; @@ -535,10 +533,10 @@ int Thread::GetDelay() { void Thread::Dispatch(absl::AnyInvocable task) { TRACE_EVENT0("webrtc", "Thread::Dispatch"); RTC_DCHECK_RUN_ON(this); - int64_t start_time = webrtc::TimeMillis(); + int64_t start_time = TimeMillis(); std::move(task)(); - int64_t end_time = webrtc::TimeMillis(); - int64_t diff = webrtc::TimeDiff(end_time, start_time); + int64_t end_time = TimeMillis(); + int64_t diff = TimeDiff(end_time, start_time); if (diff >= dispatch_warning_ms_) { RTC_LOG(LS_INFO) << "Message to " << name() << " took " << diff << "ms to dispatch."; @@ -850,9 +848,9 @@ bool Thread::ProcessMessages(int cmsLoop) { // Using ProcessMessages with a custom clock for testing and a time greater // than 0 doesn't work, since it's not guaranteed to advance the custom // clock's time, and may get stuck in an infinite loop. - RTC_DCHECK(webrtc::GetClockForTesting() == nullptr || cmsLoop == 0 || + RTC_DCHECK(GetClockForTesting() == nullptr || cmsLoop == 0 || cmsLoop == kForever); - int64_t msEnd = (kForever == cmsLoop) ? 0 : webrtc::TimeAfter(cmsLoop); + int64_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); int cmsNext = cmsLoop; while (true) { @@ -865,7 +863,7 @@ bool Thread::ProcessMessages(int cmsLoop) { Dispatch(std::move(task)); if (cmsLoop != kForever) { - cmsNext = static_cast(webrtc::TimeUntil(msEnd)); + cmsNext = static_cast(TimeUntil(msEnd)); if (cmsNext < 0) return true; } diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc index 9c417fe75a..24e7106cf5 100644 --- a/rtc_base/thread_unittest.cc +++ b/rtc_base/thread_unittest.cc @@ -53,7 +53,6 @@ namespace webrtc { namespace { using ::testing::ElementsAre; -using ::webrtc::TimeDelta; // Generates a sequence of numbers (collaboratively). class TestGenerator { @@ -206,7 +205,7 @@ TEST(ThreadTest, CountBlockingCalls) { // (thread_unittest.cc:262): Blocking TestBody: total=2 (actual=1, could=1) RTC_LOG_THREAD_BLOCK_COUNT(); #if RTC_DCHECK_IS_ON - webrtc::Thread::ScopedCountBlockingCalls blocked_calls( + Thread::ScopedCountBlockingCalls blocked_calls( [&](uint32_t actual_block, uint32_t could_block) { EXPECT_EQ(1u, actual_block); EXPECT_EQ(1u, could_block); @@ -242,10 +241,10 @@ TEST(ThreadTest, CountBlockingCalls) { #if RTC_DCHECK_IS_ON TEST(ThreadTest, CountBlockingCallsOneCallback) { - webrtc::AutoThread current; + AutoThread current; bool was_called_back = false; { - webrtc::Thread::ScopedCountBlockingCalls blocked_calls( + Thread::ScopedCountBlockingCalls blocked_calls( [&](uint32_t actual_block, uint32_t could_block) { was_called_back = true; }); @@ -255,10 +254,10 @@ TEST(ThreadTest, CountBlockingCallsOneCallback) { } TEST(ThreadTest, CountBlockingCallsSkipCallback) { - webrtc::AutoThread current; + AutoThread current; bool was_called_back = false; { - webrtc::Thread::ScopedCountBlockingCalls blocked_calls( + Thread::ScopedCountBlockingCalls blocked_calls( [&](uint32_t actual_block, uint32_t could_block) { was_called_back = true; }); @@ -309,7 +308,7 @@ TEST(ThreadTest, Wrap) { #if (!defined(NDEBUG) || RTC_DCHECK_IS_ON) TEST(ThreadTest, InvokeToThreadAllowedReturnsTrueWithoutPolicies) { - webrtc::AutoThread main_thread; + AutoThread main_thread; // Create and start the thread. auto thread1 = Thread::CreateWithSocketServer(); auto thread2 = Thread::CreateWithSocketServer(); @@ -320,7 +319,7 @@ TEST(ThreadTest, InvokeToThreadAllowedReturnsTrueWithoutPolicies) { } TEST(ThreadTest, InvokeAllowedWhenThreadsAdded) { - webrtc::AutoThread main_thread; + AutoThread main_thread; // Create and start the thread. auto thread1 = Thread::CreateWithSocketServer(); auto thread2 = Thread::CreateWithSocketServer(); @@ -339,7 +338,7 @@ TEST(ThreadTest, InvokeAllowedWhenThreadsAdded) { } TEST(ThreadTest, InvokesDisallowedWhenDisallowAllInvokes) { - webrtc::AutoThread main_thread; + AutoThread main_thread; // Create and start the thread. auto thread1 = Thread::CreateWithSocketServer(); auto thread2 = Thread::CreateWithSocketServer(); @@ -469,9 +468,9 @@ TEST(ThreadTest, ThreeThreadsBlockingCall) { SetAndInvokeSet(&async_invoked, thread2, out); }); - EXPECT_THAT(webrtc::WaitUntil([&] { return async_invoked.Get(); }, - ::testing::IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return async_invoked.Get(); }, ::testing::IsTrue()), + IsRtcOk()); } }; @@ -486,9 +485,9 @@ TEST(ThreadTest, ThreeThreadsBlockingCall) { }); EXPECT_FALSE(thread_a_called.Get()); - EXPECT_THAT(webrtc::WaitUntil([&] { return thread_a_called.Get(); }, - ::testing::IsTrue()), - webrtc::IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return thread_a_called.Get(); }, ::testing::IsTrue()), + IsRtcOk()); } static void DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder( @@ -858,7 +857,6 @@ std::unique_ptr CreateDefaultThreadFactory( return std::make_unique(); } -using ::webrtc::TaskQueueTest; INSTANTIATE_TEST_SUITE_P(RtcThread, TaskQueueTest, diff --git a/rtc_base/unique_id_generator.cc b/rtc_base/unique_id_generator.cc index f817decb99..6bd47d32ed 100644 --- a/rtc_base/unique_id_generator.cc +++ b/rtc_base/unique_id_generator.cc @@ -60,7 +60,7 @@ bool UniqueStringGenerator::AddKnownId(absl::string_view value) { // TODO(webrtc:13579): remove string copy here once absl::string_view version // of StringToNumber is available. std::optional int_value = - webrtc::StringToNumber(std::string(value)); + StringToNumber(std::string(value)); // The underlying generator works for uint32_t values, so if the provided // value is not a uint32_t it will never be generated anyway. if (int_value.has_value()) { diff --git a/rtc_base/unique_id_generator_unittest.cc b/rtc_base/unique_id_generator_unittest.cc index 85ed5d4715..661ba58bdf 100644 --- a/rtc_base/unique_id_generator_unittest.cc +++ b/rtc_base/unique_id_generator_unittest.cc @@ -173,7 +173,7 @@ TYPED_TEST(UniqueIdGeneratorTest, // Tests that it's OK to construct the generator in one execution environment // (thread/task queue) but use it in another. TEST(UniqueNumberGenerator, UsedOnSecondaryThread) { - const auto* current_tq = webrtc::TaskQueueBase::Current(); + const auto* current_tq = TaskQueueBase::Current(); // Construct the generator before `fake_task_queue` to ensure that it is // constructed in a different execution environment than what // `fake_task_queue` will represent. @@ -181,7 +181,7 @@ TEST(UniqueNumberGenerator, UsedOnSecondaryThread) { FakeTaskQueue fake_task_queue; // Sanity check to make sure we're in a different runtime environment. - ASSERT_NE(current_tq, webrtc::TaskQueueBase::Current()); + ASSERT_NE(current_tq, TaskQueueBase::Current()); // Generating an id should be fine in this context. generator.Generate(); diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc index 9fad9dfe27..20ae7890c4 100644 --- a/rtc_base/virtual_socket_server.cc +++ b/rtc_base/virtual_socket_server.cc @@ -31,9 +31,6 @@ namespace webrtc { -using ::webrtc::MutexLock; -using ::webrtc::TaskQueueBase; -using ::webrtc::TimeDelta; #if defined(WEBRTC_WIN) const in_addr kInitialNextIPv4 = {{{0x01, 0, 0, 0}}}; @@ -550,7 +547,7 @@ int VirtualSocket::SendUdp(const void* pv, // If we have not been assigned a local port, then get one. if (local_addr_.IsNil()) { local_addr_ = server_->AssignBindAddress( - webrtc::EmptySocketAddressWithFamily(addr.ipaddr().family())); + EmptySocketAddressWithFamily(addr.ipaddr().family())); int result = server_->Bind(this, local_addr_); if (result != 0) { local_addr_.Clear(); @@ -681,8 +678,7 @@ VirtualSocketServer::~VirtualSocketServer() { IPAddress VirtualSocketServer::GetNextIP(int family) { if (family == AF_INET) { IPAddress next_ip(next_ipv4_); - next_ipv4_.s_addr = - webrtc::HostToNetwork32(webrtc::NetworkToHost32(next_ipv4_.s_addr) + 1); + next_ipv4_.s_addr = HostToNetwork32(NetworkToHost32(next_ipv4_.s_addr) + 1); return next_ip; } else if (family == AF_INET6) { IPAddress next_ip(next_ipv6_); @@ -791,7 +787,7 @@ int VirtualSocketServer::Bind(VirtualSocket* socket, const SocketAddress& addr) { RTC_DCHECK(nullptr != socket); // Address must be completely specified at this point - RTC_DCHECK(!webrtc::IPIsUnspec(addr.ipaddr())); + RTC_DCHECK(!IPIsUnspec(addr.ipaddr())); RTC_DCHECK(addr.port() != 0); // Normalize the address (turns v6-mapped addresses into v4-addresses). @@ -803,7 +799,7 @@ int VirtualSocketServer::Bind(VirtualSocket* socket, SocketAddress VirtualSocketServer::AssignBindAddress( const SocketAddress& app_addr) { - RTC_DCHECK(!webrtc::IPIsUnspec(app_addr.ipaddr())); + RTC_DCHECK(!IPIsUnspec(app_addr.ipaddr())); // Normalize the IP. SocketAddress addr; @@ -840,12 +836,12 @@ VirtualSocket* VirtualSocketServer::LookupBinding(const SocketAddress& addr) { } IPAddress default_ip = GetDefaultSourceAddress(addr.ipaddr().family()); - if (!webrtc::IPIsUnspec(default_ip) && addr.ipaddr() == default_ip) { + if (!IPIsUnspec(default_ip) && addr.ipaddr() == default_ip) { // If we can't find a binding for the packet which is sent to the interface // corresponding to the default route, it should match a binding with the // correct port to the any address. SocketAddress sock_addr = - webrtc::EmptySocketAddressWithFamily(addr.ipaddr().family()); + EmptySocketAddressWithFamily(addr.ipaddr().family()); sock_addr.SetPort(addr.port()); return LookupBinding(sock_addr); } @@ -1096,7 +1092,7 @@ void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender, // route. SocketAddress sender_addr = sender->GetLocalAddress(); IPAddress default_ip = GetDefaultSourceAddress(sender_addr.ipaddr().family()); - if (sender_addr.IsAnyIP() && !webrtc::IPIsUnspec(default_ip)) { + if (sender_addr.IsAnyIP() && !IPIsUnspec(default_ip)) { sender_addr.SetIP(default_ip); } @@ -1285,15 +1281,13 @@ bool VirtualSocketServer::CanInteractWith(VirtualSocket* local, // If ip1 is IPv4 and ip2 is :: and ip2 is not IPV6_V6ONLY. int remote_v6_only = 0; remote->GetOption(Socket::OPT_IPV6_V6ONLY, &remote_v6_only); - if (local_ip.family() == AF_INET && !remote_v6_only && - webrtc::IPIsAny(remote_ip)) { + if (local_ip.family() == AF_INET && !remote_v6_only && IPIsAny(remote_ip)) { return true; } // Same check, backwards. int local_v6_only = 0; local->GetOption(Socket::OPT_IPV6_V6ONLY, &local_v6_only); - if (remote_ip.family() == AF_INET && !local_v6_only && - webrtc::IPIsAny(local_ip)) { + if (remote_ip.family() == AF_INET && !local_v6_only && IPIsAny(local_ip)) { return true; } @@ -1319,7 +1313,7 @@ IPAddress VirtualSocketServer::GetDefaultSourceAddress(int family) { return IPAddress(); } void VirtualSocketServer::SetDefaultSourceAddress(const IPAddress& from_addr) { - RTC_DCHECK(!webrtc::IPIsAny(from_addr)); + RTC_DCHECK(!IPIsAny(from_addr)); if (from_addr.family() == AF_INET) { default_source_address_v4_ = from_addr; } else if (from_addr.family() == AF_INET6) { diff --git a/rtc_base/virtual_socket_unittest.cc b/rtc_base/virtual_socket_unittest.cc index c05f8d87c7..c6237303a9 100644 --- a/rtc_base/virtual_socket_unittest.cc +++ b/rtc_base/virtual_socket_unittest.cc @@ -42,24 +42,24 @@ namespace webrtc { namespace { -using ::webrtc::testing::SSE_CLOSE; -using ::webrtc::testing::SSE_ERROR; -using ::webrtc::testing::SSE_OPEN; -using ::webrtc::testing::SSE_READ; -using ::webrtc::testing::SSE_WRITE; -using ::webrtc::testing::StreamSink; +using testing::SSE_CLOSE; +using testing::SSE_ERROR; +using testing::SSE_OPEN; +using testing::SSE_READ; +using testing::SSE_WRITE; +using testing::StreamSink; // Sends at a constant rate but with random packet sizes. struct Sender { - Sender(webrtc::Thread* th, webrtc::Socket* s, uint32_t rt) + Sender(Thread* th, Socket* s, uint32_t rt) : thread(th), - socket(std::make_unique(s)), + socket(std::make_unique(s)), rate(rt), count(0) { - last_send = webrtc::TimeMillis(); + last_send = TimeMillis(); periodic = RepeatingTaskHandle::DelayedStart(thread, NextDelay(), [this] { - int64_t cur_time = webrtc::TimeMillis(); + int64_t cur_time = TimeMillis(); int64_t delay = cur_time - last_send; uint32_t size = std::clamp(rate * delay / 1000, sizeof(uint32_t), 4096); @@ -77,8 +77,8 @@ struct Sender { return TimeDelta::Seconds(1) * size / rate; } - webrtc::Thread* thread; - std::unique_ptr socket; + Thread* thread; + std::unique_ptr socket; AsyncSocketPacketOptions options; RepeatingTaskHandle periodic; uint32_t rate; // bytes per second @@ -88,9 +88,9 @@ struct Sender { }; struct Receiver : public sigslot::has_slots<> { - Receiver(webrtc::Thread* th, webrtc::Socket* s, uint32_t bw) + Receiver(Thread* th, Socket* s, uint32_t bw) : thread(th), - socket(std::make_unique(s)), + socket(std::make_unique(s)), bandwidth(bw), count(0), sec_count(0), @@ -115,8 +115,7 @@ struct Receiver : public sigslot::has_slots<> { ~Receiver() override { periodic.Stop(); } - void OnReadPacket(webrtc::AsyncPacketSocket* s, - const ReceivedIpPacket& packet) { + void OnReadPacket(AsyncPacketSocket* s, const ReceivedIpPacket& packet) { ASSERT_EQ(socket.get(), s); ASSERT_GE(packet.payload().size(), 4U); @@ -125,15 +124,15 @@ struct Receiver : public sigslot::has_slots<> { uint32_t send_time = *reinterpret_cast(packet.payload().data()); - uint32_t recv_time = webrtc::TimeMillis(); + uint32_t recv_time = TimeMillis(); uint32_t delay = recv_time - send_time; sum += delay; sum_sq += delay * delay; samples += 1; } - webrtc::Thread* thread; - std::unique_ptr socket; + Thread* thread; + std::unique_ptr socket; uint32_t bandwidth; RepeatingTaskHandle periodic; size_t count; @@ -149,14 +148,14 @@ class VirtualSocketServerTest : public ::testing::Test { VirtualSocketServerTest() : ss_(&fake_clock_), thread_(&ss_), - kIPv4AnyAddress(webrtc::IPAddress(INADDR_ANY), 0), - kIPv6AnyAddress(webrtc::IPAddress(in6addr_any), 0) {} + kIPv4AnyAddress(IPAddress(INADDR_ANY), 0), + kIPv6AnyAddress(IPAddress(in6addr_any), 0) {} - void CheckPortIncrementalization(const webrtc::SocketAddress& post, - const webrtc::SocketAddress& pre) { + void CheckPortIncrementalization(const SocketAddress& post, + const SocketAddress& pre) { EXPECT_EQ(post.port(), pre.port() + 1); - webrtc::IPAddress post_ip = post.ipaddr(); - webrtc::IPAddress pre_ip = pre.ipaddr(); + IPAddress post_ip = post.ipaddr(); + IPAddress pre_ip = pre.ipaddr(); EXPECT_EQ(pre_ip.family(), post_ip.family()); if (post_ip.family() == AF_INET) { in_addr pre_ipv4 = pre_ip.ipv4_address(); @@ -174,79 +173,72 @@ class VirtualSocketServerTest : public ::testing::Test { // Test a client can bind to the any address, and all sent packets will have // the default source address. Also, it can receive packets sent to the // default address. - void TestDefaultSourceAddress(const webrtc::IPAddress& default_address) { + void TestDefaultSourceAddress(const IPAddress& default_address) { ss_.SetDefaultSourceAddress(default_address); // Create client1 bound to the any address. - webrtc::Socket* socket = - ss_.CreateSocket(default_address.family(), SOCK_DGRAM); - socket->Bind( - webrtc::EmptySocketAddressWithFamily(default_address.family())); - webrtc::SocketAddress client1_any_addr = socket->GetLocalAddress(); + Socket* socket = ss_.CreateSocket(default_address.family(), SOCK_DGRAM); + socket->Bind(EmptySocketAddressWithFamily(default_address.family())); + SocketAddress client1_any_addr = socket->GetLocalAddress(); EXPECT_TRUE(client1_any_addr.IsAnyIP()); - auto client1 = std::make_unique( - std::make_unique(socket), &fake_clock_); + auto client1 = std::make_unique( + std::make_unique(socket), &fake_clock_); // Create client2 bound to the address route. - webrtc::Socket* socket2 = - ss_.CreateSocket(default_address.family(), SOCK_DGRAM); - socket2->Bind(webrtc::SocketAddress(default_address, 0)); - webrtc::SocketAddress client2_addr = socket2->GetLocalAddress(); + Socket* socket2 = ss_.CreateSocket(default_address.family(), SOCK_DGRAM); + socket2->Bind(SocketAddress(default_address, 0)); + SocketAddress client2_addr = socket2->GetLocalAddress(); EXPECT_FALSE(client2_addr.IsAnyIP()); - auto client2 = std::make_unique( - std::make_unique(socket2), &fake_clock_); + auto client2 = std::make_unique( + std::make_unique(socket2), &fake_clock_); // Client1 sends to client2, client2 should see the default address as // client1's address. - webrtc::SocketAddress client1_addr; + SocketAddress client1_addr; EXPECT_EQ(6, client1->SendTo("bizbaz", 6, client2_addr)); EXPECT_TRUE(client2->CheckNextPacket("bizbaz", 6, &client1_addr)); EXPECT_EQ(client1_addr, - webrtc::SocketAddress(default_address, client1_any_addr.port())); + SocketAddress(default_address, client1_any_addr.port())); // Client2 can send back to client1's default address. EXPECT_EQ(3, client2->SendTo("foo", 3, client1_addr)); EXPECT_TRUE(client1->CheckNextPacket("foo", 3, &client2_addr)); } - void BasicTest(const webrtc::SocketAddress& initial_addr) { - webrtc::Socket* socket = - ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); + void BasicTest(const SocketAddress& initial_addr) { + Socket* socket = ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); socket->Bind(initial_addr); - webrtc::SocketAddress server_addr = socket->GetLocalAddress(); + SocketAddress server_addr = socket->GetLocalAddress(); // Make sure VSS didn't switch families on us. EXPECT_EQ(server_addr.family(), initial_addr.family()); - auto client1 = std::make_unique( - std::make_unique(socket), &fake_clock_); - webrtc::Socket* socket2 = - ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); - auto client2 = std::make_unique( - std::make_unique(socket2), &fake_clock_); + auto client1 = std::make_unique( + std::make_unique(socket), &fake_clock_); + Socket* socket2 = ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); + auto client2 = std::make_unique( + std::make_unique(socket2), &fake_clock_); - webrtc::SocketAddress client2_addr; + SocketAddress client2_addr; EXPECT_EQ(3, client2->SendTo("foo", 3, server_addr)); EXPECT_TRUE(client1->CheckNextPacket("foo", 3, &client2_addr)); - webrtc::SocketAddress client1_addr; + SocketAddress client1_addr; EXPECT_EQ(6, client1->SendTo("bizbaz", 6, client2_addr)); EXPECT_TRUE(client2->CheckNextPacket("bizbaz", 6, &client1_addr)); EXPECT_EQ(client1_addr, server_addr); - webrtc::SocketAddress empty = - webrtc::EmptySocketAddressWithFamily(initial_addr.family()); + SocketAddress empty = EmptySocketAddressWithFamily(initial_addr.family()); for (int i = 0; i < 10; i++) { - client2 = std::make_unique( - absl::WrapUnique(webrtc::AsyncUDPSocket::Create(&ss_, empty)), - &fake_clock_); + client2 = std::make_unique( + absl::WrapUnique(AsyncUDPSocket::Create(&ss_, empty)), &fake_clock_); - webrtc::SocketAddress next_client2_addr; + SocketAddress next_client2_addr; EXPECT_EQ(3, client2->SendTo("foo", 3, server_addr)); EXPECT_TRUE(client1->CheckNextPacket("foo", 3, &next_client2_addr)); CheckPortIncrementalization(next_client2_addr, client2_addr); // EXPECT_EQ(next_client2_addr.port(), client2_addr.port() + 1); - webrtc::SocketAddress server_addr2; + SocketAddress server_addr2; EXPECT_EQ(6, client1->SendTo("bizbaz", 6, next_client2_addr)); EXPECT_TRUE(client2->CheckNextPacket("bizbaz", 6, &server_addr2)); EXPECT_EQ(server_addr2, server_addr); @@ -256,28 +248,28 @@ class VirtualSocketServerTest : public ::testing::Test { } // initial_addr should be made from either INADDR_ANY or in6addr_any. - void ConnectTest(const webrtc::SocketAddress& initial_addr) { + void ConnectTest(const SocketAddress& initial_addr) { StreamSink sink; - webrtc::SocketAddress accept_addr; - const webrtc::SocketAddress kEmptyAddr = - webrtc::EmptySocketAddressWithFamily(initial_addr.family()); + SocketAddress accept_addr; + const SocketAddress kEmptyAddr = + EmptySocketAddressWithFamily(initial_addr.family()); // Create client - std::unique_ptr client = + std::unique_ptr client = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(client.get()); - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(client->GetState(), Socket::CS_CLOSED); EXPECT_TRUE(client->GetLocalAddress().IsNil()); // Create server - std::unique_ptr server = + std::unique_ptr server = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(server.get()); EXPECT_NE(0, server->Listen(5)); // Bind required EXPECT_EQ(0, server->Bind(initial_addr)); EXPECT_EQ(server->GetLocalAddress().family(), initial_addr.family()); EXPECT_EQ(0, server->Listen(5)); - EXPECT_EQ(server->GetState(), webrtc::Socket::CS_CONNECTING); + EXPECT_EQ(server->GetState(), Socket::CS_CONNECTING); // No pending server connections EXPECT_FALSE(sink.Check(server.get(), SSE_READ)); @@ -291,53 +283,53 @@ class VirtualSocketServerTest : public ::testing::Test { EXPECT_NE(client->GetLocalAddress(), server->GetLocalAddress()); // Client is connecting - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CONNECTING); + EXPECT_EQ(client->GetState(), Socket::CS_CONNECTING); EXPECT_FALSE(sink.Check(client.get(), SSE_OPEN)); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); ss_.ProcessMessagesUntilIdle(); // Client still connecting - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CONNECTING); + EXPECT_EQ(client->GetState(), Socket::CS_CONNECTING); EXPECT_FALSE(sink.Check(client.get(), SSE_OPEN)); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); // Server has pending connection EXPECT_TRUE(sink.Check(server.get(), SSE_READ)); - std::unique_ptr accepted = + std::unique_ptr accepted = absl::WrapUnique(server->Accept(&accept_addr)); EXPECT_TRUE(nullptr != accepted); EXPECT_NE(accept_addr, kEmptyAddr); EXPECT_EQ(accepted->GetRemoteAddress(), accept_addr); - EXPECT_EQ(accepted->GetState(), webrtc::Socket::CS_CONNECTED); + EXPECT_EQ(accepted->GetState(), Socket::CS_CONNECTED); EXPECT_EQ(accepted->GetLocalAddress(), server->GetLocalAddress()); EXPECT_EQ(accepted->GetRemoteAddress(), client->GetLocalAddress()); ss_.ProcessMessagesUntilIdle(); // Client has connected - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CONNECTED); + EXPECT_EQ(client->GetState(), Socket::CS_CONNECTED); EXPECT_TRUE(sink.Check(client.get(), SSE_OPEN)); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); EXPECT_EQ(client->GetRemoteAddress(), server->GetLocalAddress()); EXPECT_EQ(client->GetRemoteAddress(), accepted->GetLocalAddress()); } - void ConnectToNonListenerTest(const webrtc::SocketAddress& initial_addr) { + void ConnectToNonListenerTest(const SocketAddress& initial_addr) { StreamSink sink; - webrtc::SocketAddress accept_addr; - const webrtc::SocketAddress nil_addr; - const webrtc::SocketAddress empty_addr = - webrtc::EmptySocketAddressWithFamily(initial_addr.family()); + SocketAddress accept_addr; + const SocketAddress nil_addr; + const SocketAddress empty_addr = + EmptySocketAddressWithFamily(initial_addr.family()); // Create client - std::unique_ptr client = + std::unique_ptr client = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(client.get()); // Create server - std::unique_ptr server = + std::unique_ptr server = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(server.get()); EXPECT_EQ(0, server->Bind(initial_addr)); @@ -353,23 +345,23 @@ class VirtualSocketServerTest : public ::testing::Test { EXPECT_EQ(accept_addr, nil_addr); // Connection failed - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(client->GetState(), Socket::CS_CLOSED); EXPECT_FALSE(sink.Check(client.get(), SSE_OPEN)); EXPECT_TRUE(sink.Check(client.get(), SSE_ERROR)); EXPECT_EQ(client->GetRemoteAddress(), nil_addr); } - void CloseDuringConnectTest(const webrtc::SocketAddress& initial_addr) { + void CloseDuringConnectTest(const SocketAddress& initial_addr) { StreamSink sink; - webrtc::SocketAddress accept_addr; - const webrtc::SocketAddress empty_addr = - webrtc::EmptySocketAddressWithFamily(initial_addr.family()); + SocketAddress accept_addr; + const SocketAddress empty_addr = + EmptySocketAddressWithFamily(initial_addr.family()); // Create client and server - std::unique_ptr client( + std::unique_ptr client( ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(client.get()); - std::unique_ptr server( + std::unique_ptr server( ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(server.get()); @@ -387,7 +379,7 @@ class VirtualSocketServerTest : public ::testing::Test { ss_.ProcessMessagesUntilIdle(); // Result: connection failed - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(client->GetState(), Socket::CS_CLOSED); EXPECT_TRUE(sink.Check(client.get(), SSE_ERROR)); server.reset(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); @@ -409,7 +401,7 @@ class VirtualSocketServerTest : public ::testing::Test { ss_.ProcessMessagesUntilIdle(); // Result: connection failed - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(client->GetState(), Socket::CS_CLOSED); EXPECT_TRUE(sink.Check(client.get(), SSE_ERROR)); // New server @@ -427,37 +419,37 @@ class VirtualSocketServerTest : public ::testing::Test { // Server accepts connection EXPECT_TRUE(sink.Check(server.get(), SSE_READ)); - std::unique_ptr accepted(server->Accept(&accept_addr)); + std::unique_ptr accepted(server->Accept(&accept_addr)); ASSERT_TRUE(nullptr != accepted.get()); sink.Monitor(accepted.get()); // Client closes before connection complets - EXPECT_EQ(accepted->GetState(), webrtc::Socket::CS_CONNECTED); + EXPECT_EQ(accepted->GetState(), Socket::CS_CONNECTED); // Connected message has not been processed yet. - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CONNECTING); + EXPECT_EQ(client->GetState(), Socket::CS_CONNECTING); client->Close(); ss_.ProcessMessagesUntilIdle(); // Result: accepted socket closes - EXPECT_EQ(accepted->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(accepted->GetState(), Socket::CS_CLOSED); EXPECT_TRUE(sink.Check(accepted.get(), SSE_CLOSE)); EXPECT_FALSE(sink.Check(client.get(), SSE_CLOSE)); } - void CloseTest(const webrtc::SocketAddress& initial_addr) { + void CloseTest(const SocketAddress& initial_addr) { StreamSink sink; - const webrtc::SocketAddress kEmptyAddr; + const SocketAddress kEmptyAddr; // Create clients - std::unique_ptr a = + std::unique_ptr a = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(a.get()); a->Bind(initial_addr); EXPECT_EQ(a->GetLocalAddress().family(), initial_addr.family()); - std::unique_ptr b = + std::unique_ptr b = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(b.get()); b->Bind(initial_addr); @@ -469,11 +461,11 @@ class VirtualSocketServerTest : public ::testing::Test { ss_.ProcessMessagesUntilIdle(); EXPECT_TRUE(sink.Check(a.get(), SSE_OPEN)); - EXPECT_EQ(a->GetState(), webrtc::Socket::CS_CONNECTED); + EXPECT_EQ(a->GetState(), Socket::CS_CONNECTED); EXPECT_EQ(a->GetRemoteAddress(), b->GetLocalAddress()); EXPECT_TRUE(sink.Check(b.get(), SSE_OPEN)); - EXPECT_EQ(b->GetState(), webrtc::Socket::CS_CONNECTED); + EXPECT_EQ(b->GetState(), Socket::CS_CONNECTED); EXPECT_EQ(b->GetRemoteAddress(), a->GetLocalAddress()); EXPECT_EQ(1, a->Send("a", 1)); @@ -487,27 +479,27 @@ class VirtualSocketServerTest : public ::testing::Test { EXPECT_EQ(-1, b->Recv(buffer, 10, nullptr)); EXPECT_TRUE(sink.Check(a.get(), SSE_CLOSE)); - EXPECT_EQ(a->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(a->GetState(), Socket::CS_CLOSED); EXPECT_EQ(a->GetRemoteAddress(), kEmptyAddr); // No signal for Closer EXPECT_FALSE(sink.Check(b.get(), SSE_CLOSE)); - EXPECT_EQ(b->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(b->GetState(), Socket::CS_CLOSED); EXPECT_EQ(b->GetRemoteAddress(), kEmptyAddr); } - void TcpSendTest(const webrtc::SocketAddress& initial_addr) { + void TcpSendTest(const SocketAddress& initial_addr) { StreamSink sink; - const webrtc::SocketAddress kEmptyAddr; + const SocketAddress kEmptyAddr; // Connect two sockets - std::unique_ptr a = + std::unique_ptr a = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(a.get()); a->Bind(initial_addr); EXPECT_EQ(a->GetLocalAddress().family(), initial_addr.family()); - std::unique_ptr b = + std::unique_ptr b = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); sink.Monitor(b.get()); b->Bind(initial_addr); @@ -619,13 +611,13 @@ class VirtualSocketServerTest : public ::testing::Test { EXPECT_EQ(0, memcmp(recv_buffer, send_buffer, kDataSize)); } - void TcpSendsPacketsInOrderTest(const webrtc::SocketAddress& initial_addr) { - const webrtc::SocketAddress kEmptyAddr; + void TcpSendsPacketsInOrderTest(const SocketAddress& initial_addr) { + const SocketAddress kEmptyAddr; // Connect two sockets - std::unique_ptr a = + std::unique_ptr a = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); - std::unique_ptr b = + std::unique_ptr b = absl::WrapUnique(ss_.CreateSocket(initial_addr.family(), SOCK_STREAM)); a->Bind(initial_addr); EXPECT_EQ(a->GetLocalAddress().family(), initial_addr.family()); @@ -676,11 +668,9 @@ class VirtualSocketServerTest : public ::testing::Test { // It is important that initial_addr's port has to be 0 such that the // incremental port behavior could ensure the 2 Binds result in different // address. - void BandwidthTest(const webrtc::SocketAddress& initial_addr) { - webrtc::Socket* send_socket = - ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); - webrtc::Socket* recv_socket = - ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); + void BandwidthTest(const SocketAddress& initial_addr) { + Socket* send_socket = ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); + Socket* recv_socket = ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); ASSERT_EQ(0, send_socket->Bind(initial_addr)); ASSERT_EQ(0, recv_socket->Bind(initial_addr)); EXPECT_EQ(send_socket->GetLocalAddress().family(), initial_addr.family()); @@ -690,7 +680,7 @@ class VirtualSocketServerTest : public ::testing::Test { uint32_t bandwidth = 64 * 1024; ss_.set_bandwidth(bandwidth); - webrtc::Thread* pthMain = webrtc::Thread::Current(); + Thread* pthMain = Thread::Current(); Sender sender(pthMain, send_socket, 80 * 1024); Receiver receiver(pthMain, recv_socket, bandwidth); @@ -710,7 +700,7 @@ class VirtualSocketServerTest : public ::testing::Test { // It is important that initial_addr's port has to be 0 such that the // incremental port behavior could ensure the 2 Binds result in different // address. - void DelayTest(const webrtc::SocketAddress& initial_addr) { + void DelayTest(const SocketAddress& initial_addr) { time_t seed = ::time(nullptr); RTC_LOG(LS_VERBOSE) << "seed = " << seed; srand(static_cast(seed)); @@ -722,17 +712,15 @@ class VirtualSocketServerTest : public ::testing::Test { ss_.set_delay_stddev(stddev); ss_.UpdateDelayDistribution(); - webrtc::Socket* send_socket = - ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); - webrtc::Socket* recv_socket = - ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); + Socket* send_socket = ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); + Socket* recv_socket = ss_.CreateSocket(initial_addr.family(), SOCK_DGRAM); ASSERT_EQ(0, send_socket->Bind(initial_addr)); ASSERT_EQ(0, recv_socket->Bind(initial_addr)); EXPECT_EQ(send_socket->GetLocalAddress().family(), initial_addr.family()); EXPECT_EQ(recv_socket->GetLocalAddress().family(), initial_addr.family()); ASSERT_EQ(0, send_socket->Connect(recv_socket->GetLocalAddress())); - webrtc::Thread* pthMain = webrtc::Thread::Current(); + Thread* pthMain = Thread::Current(); // Avg packet size is 2K, so at 200KB/s for 10s, we should see about // 1000 packets, which is necessary to get a good distribution. Sender sender(pthMain, send_socket, 100 * 2 * 1024); @@ -767,24 +755,24 @@ class VirtualSocketServerTest : public ::testing::Test { // Test cross-family communication between a client bound to client_addr and a // server bound to server_addr. shouldSucceed indicates if communication is // expected to work or not. - void CrossFamilyConnectionTest(const webrtc::SocketAddress& client_addr, - const webrtc::SocketAddress& server_addr, + void CrossFamilyConnectionTest(const SocketAddress& client_addr, + const SocketAddress& server_addr, bool shouldSucceed) { StreamSink sink; - webrtc::SocketAddress accept_address; - const webrtc::SocketAddress kEmptyAddr; + SocketAddress accept_address; + const SocketAddress kEmptyAddr; // Client gets a IPv4 address - std::unique_ptr client = + std::unique_ptr client = absl::WrapUnique(ss_.CreateSocket(client_addr.family(), SOCK_STREAM)); sink.Monitor(client.get()); - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(client->GetState(), Socket::CS_CLOSED); EXPECT_EQ(client->GetLocalAddress(), kEmptyAddr); client->Bind(client_addr); // Server gets a non-mapped non-any IPv6 address. // IPv4 sockets should not be able to connect to this. - std::unique_ptr server = + std::unique_ptr server = absl::WrapUnique(ss_.CreateSocket(server_addr.family(), SOCK_STREAM)); sink.Monitor(server.get()); server->Bind(server_addr); @@ -794,7 +782,7 @@ class VirtualSocketServerTest : public ::testing::Test { EXPECT_EQ(0, client->Connect(server->GetLocalAddress())); ss_.ProcessMessagesUntilIdle(); EXPECT_TRUE(sink.Check(server.get(), SSE_READ)); - std::unique_ptr accepted = + std::unique_ptr accepted = absl::WrapUnique(server->Accept(&accept_address)); EXPECT_TRUE(nullptr != accepted); EXPECT_NE(kEmptyAddr, accept_address); @@ -809,7 +797,7 @@ class VirtualSocketServerTest : public ::testing::Test { EXPECT_FALSE(sink.Check(server.get(), SSE_READ)); EXPECT_TRUE(nullptr == server->Accept(&accept_address)); EXPECT_EQ(accept_address, kEmptyAddr); - EXPECT_EQ(client->GetState(), webrtc::Socket::CS_CLOSED); + EXPECT_EQ(client->GetState(), Socket::CS_CLOSED); EXPECT_FALSE(sink.Check(client.get(), SSE_OPEN)); EXPECT_EQ(client->GetRemoteAddress(), kEmptyAddr); } @@ -818,25 +806,25 @@ class VirtualSocketServerTest : public ::testing::Test { // Test cross-family datagram sending between a client bound to client_addr // and a server bound to server_addr. shouldSucceed indicates if sending is // expected to succeed or not. - void CrossFamilyDatagramTest(const webrtc::SocketAddress& client_addr, - const webrtc::SocketAddress& server_addr, + void CrossFamilyDatagramTest(const SocketAddress& client_addr, + const SocketAddress& server_addr, bool shouldSucceed) { - webrtc::Socket* socket = ss_.CreateSocket(AF_INET, SOCK_DGRAM); + Socket* socket = ss_.CreateSocket(AF_INET, SOCK_DGRAM); socket->Bind(server_addr); - webrtc::SocketAddress bound_server_addr = socket->GetLocalAddress(); - auto client1 = std::make_unique( - std::make_unique(socket), &fake_clock_); + SocketAddress bound_server_addr = socket->GetLocalAddress(); + auto client1 = std::make_unique( + std::make_unique(socket), &fake_clock_); - webrtc::Socket* socket2 = ss_.CreateSocket(AF_INET, SOCK_DGRAM); + Socket* socket2 = ss_.CreateSocket(AF_INET, SOCK_DGRAM); socket2->Bind(client_addr); - auto client2 = std::make_unique( - std::make_unique(socket2), &fake_clock_); - webrtc::SocketAddress client2_addr; + auto client2 = std::make_unique( + std::make_unique(socket2), &fake_clock_); + SocketAddress client2_addr; if (shouldSucceed) { EXPECT_EQ(3, client2->SendTo("foo", 3, bound_server_addr)); EXPECT_TRUE(client1->CheckNextPacket("foo", 3, &client2_addr)); - webrtc::SocketAddress client1_addr; + SocketAddress client1_addr; EXPECT_EQ(6, client1->SendTo("bizbaz", 6, client2_addr)); EXPECT_TRUE(client2->CheckNextPacket("bizbaz", 6, &client1_addr)); EXPECT_EQ(client1_addr, bound_server_addr); @@ -847,32 +835,32 @@ class VirtualSocketServerTest : public ::testing::Test { } protected: - webrtc::ScopedFakeClock fake_clock_; - webrtc::VirtualSocketServer ss_; - webrtc::AutoSocketServerThread thread_; - const webrtc::SocketAddress kIPv4AnyAddress; - const webrtc::SocketAddress kIPv6AnyAddress; + ScopedFakeClock fake_clock_; + VirtualSocketServer ss_; + AutoSocketServerThread thread_; + const SocketAddress kIPv4AnyAddress; + const SocketAddress kIPv6AnyAddress; }; TEST_F(VirtualSocketServerTest, basic_v4) { - webrtc::SocketAddress ipv4_test_addr(webrtc::IPAddress(INADDR_ANY), 5000); + SocketAddress ipv4_test_addr(IPAddress(INADDR_ANY), 5000); BasicTest(ipv4_test_addr); } TEST_F(VirtualSocketServerTest, basic_v6) { - webrtc::SocketAddress ipv6_test_addr(webrtc::IPAddress(in6addr_any), 5000); + SocketAddress ipv6_test_addr(IPAddress(in6addr_any), 5000); BasicTest(ipv6_test_addr); } TEST_F(VirtualSocketServerTest, TestDefaultRoute_v4) { - webrtc::IPAddress ipv4_default_addr(0x01020304); + IPAddress ipv4_default_addr(0x01020304); TestDefaultSourceAddress(ipv4_default_addr); } TEST_F(VirtualSocketServerTest, TestDefaultRoute_v6) { - webrtc::IPAddress ipv6_default_addr; - EXPECT_TRUE(webrtc::IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c3", - &ipv6_default_addr)); + IPAddress ipv6_default_addr; + EXPECT_TRUE( + IPFromString("2401:fa00:4:1000:be30:5bff:fee5:c3", &ipv6_default_addr)); TestDefaultSourceAddress(ipv6_default_addr); } @@ -942,105 +930,100 @@ TEST_F(VirtualSocketServerTest, delay_v6) { // Works, receiving socket sees 127.0.0.2. TEST_F(VirtualSocketServerTest, CanConnectFromMappedIPv6ToIPv4Any) { - CrossFamilyConnectionTest(webrtc::SocketAddress("::ffff:127.0.0.2", 0), - webrtc::SocketAddress("0.0.0.0", 5000), true); + CrossFamilyConnectionTest(SocketAddress("::ffff:127.0.0.2", 0), + SocketAddress("0.0.0.0", 5000), true); } // Fails. TEST_F(VirtualSocketServerTest, CantConnectFromUnMappedIPv6ToIPv4Any) { - CrossFamilyConnectionTest(webrtc::SocketAddress("::2", 0), - webrtc::SocketAddress("0.0.0.0", 5000), false); + CrossFamilyConnectionTest(SocketAddress("::2", 0), + SocketAddress("0.0.0.0", 5000), false); } // Fails. TEST_F(VirtualSocketServerTest, CantConnectFromUnMappedIPv6ToMappedIPv6) { - CrossFamilyConnectionTest(webrtc::SocketAddress("::2", 0), - webrtc::SocketAddress("::ffff:127.0.0.1", 5000), - false); + CrossFamilyConnectionTest(SocketAddress("::2", 0), + SocketAddress("::ffff:127.0.0.1", 5000), false); } // Works. receiving socket sees ::ffff:127.0.0.2. TEST_F(VirtualSocketServerTest, CanConnectFromIPv4ToIPv6Any) { - CrossFamilyConnectionTest(webrtc::SocketAddress("127.0.0.2", 0), - webrtc::SocketAddress("::", 5000), true); + CrossFamilyConnectionTest(SocketAddress("127.0.0.2", 0), + SocketAddress("::", 5000), true); } // Fails. TEST_F(VirtualSocketServerTest, CantConnectFromIPv4ToUnMappedIPv6) { - CrossFamilyConnectionTest(webrtc::SocketAddress("127.0.0.2", 0), - webrtc::SocketAddress("::1", 5000), false); + CrossFamilyConnectionTest(SocketAddress("127.0.0.2", 0), + SocketAddress("::1", 5000), false); } // Works. Receiving socket sees ::ffff:127.0.0.1. TEST_F(VirtualSocketServerTest, CanConnectFromIPv4ToMappedIPv6) { - CrossFamilyConnectionTest(webrtc::SocketAddress("127.0.0.1", 0), - webrtc::SocketAddress("::ffff:127.0.0.2", 5000), - true); + CrossFamilyConnectionTest(SocketAddress("127.0.0.1", 0), + SocketAddress("::ffff:127.0.0.2", 5000), true); } // Works, receiving socket sees a result from GetNextIP. TEST_F(VirtualSocketServerTest, CanConnectFromUnboundIPv6ToIPv4Any) { - CrossFamilyConnectionTest(webrtc::SocketAddress("::", 0), - webrtc::SocketAddress("0.0.0.0", 5000), true); + CrossFamilyConnectionTest(SocketAddress("::", 0), + SocketAddress("0.0.0.0", 5000), true); } // Works, receiving socket sees whatever GetNextIP gave the client. TEST_F(VirtualSocketServerTest, CanConnectFromUnboundIPv4ToIPv6Any) { - CrossFamilyConnectionTest(webrtc::SocketAddress("0.0.0.0", 0), - webrtc::SocketAddress("::", 5000), true); + CrossFamilyConnectionTest(SocketAddress("0.0.0.0", 0), + SocketAddress("::", 5000), true); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromUnboundIPv4ToIPv6Any) { - CrossFamilyDatagramTest(webrtc::SocketAddress("0.0.0.0", 0), - webrtc::SocketAddress("::", 5000), true); + CrossFamilyDatagramTest(SocketAddress("0.0.0.0", 0), + SocketAddress("::", 5000), true); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromMappedIPv6ToIPv4Any) { - CrossFamilyDatagramTest(webrtc::SocketAddress("::ffff:127.0.0.1", 0), - webrtc::SocketAddress("0.0.0.0", 5000), true); + CrossFamilyDatagramTest(SocketAddress("::ffff:127.0.0.1", 0), + SocketAddress("0.0.0.0", 5000), true); } TEST_F(VirtualSocketServerTest, CantSendDatagramFromUnMappedIPv6ToIPv4Any) { - CrossFamilyDatagramTest(webrtc::SocketAddress("::2", 0), - webrtc::SocketAddress("0.0.0.0", 5000), false); + CrossFamilyDatagramTest(SocketAddress("::2", 0), + SocketAddress("0.0.0.0", 5000), false); } TEST_F(VirtualSocketServerTest, CantSendDatagramFromUnMappedIPv6ToMappedIPv6) { - CrossFamilyDatagramTest(webrtc::SocketAddress("::2", 0), - webrtc::SocketAddress("::ffff:127.0.0.1", 5000), - false); + CrossFamilyDatagramTest(SocketAddress("::2", 0), + SocketAddress("::ffff:127.0.0.1", 5000), false); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromIPv4ToIPv6Any) { - CrossFamilyDatagramTest(webrtc::SocketAddress("127.0.0.2", 0), - webrtc::SocketAddress("::", 5000), true); + CrossFamilyDatagramTest(SocketAddress("127.0.0.2", 0), + SocketAddress("::", 5000), true); } TEST_F(VirtualSocketServerTest, CantSendDatagramFromIPv4ToUnMappedIPv6) { - CrossFamilyDatagramTest(webrtc::SocketAddress("127.0.0.2", 0), - webrtc::SocketAddress("::1", 5000), false); + CrossFamilyDatagramTest(SocketAddress("127.0.0.2", 0), + SocketAddress("::1", 5000), false); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromIPv4ToMappedIPv6) { - CrossFamilyDatagramTest(webrtc::SocketAddress("127.0.0.1", 0), - webrtc::SocketAddress("::ffff:127.0.0.2", 5000), - true); + CrossFamilyDatagramTest(SocketAddress("127.0.0.1", 0), + SocketAddress("::ffff:127.0.0.2", 5000), true); } TEST_F(VirtualSocketServerTest, CanSendDatagramFromUnboundIPv6ToIPv4Any) { - CrossFamilyDatagramTest(webrtc::SocketAddress("::", 0), - webrtc::SocketAddress("0.0.0.0", 5000), true); + CrossFamilyDatagramTest(SocketAddress("::", 0), + SocketAddress("0.0.0.0", 5000), true); } TEST_F(VirtualSocketServerTest, SetSendingBlockedWithUdpSocket) { - webrtc::Socket* socket1 = - ss_.CreateSocket(kIPv4AnyAddress.family(), SOCK_DGRAM); - std::unique_ptr socket2 = + Socket* socket1 = ss_.CreateSocket(kIPv4AnyAddress.family(), SOCK_DGRAM); + std::unique_ptr socket2 = absl::WrapUnique(ss_.CreateSocket(kIPv4AnyAddress.family(), SOCK_DGRAM)); socket1->Bind(kIPv4AnyAddress); socket2->Bind(kIPv4AnyAddress); - auto client1 = std::make_unique( - std::make_unique(socket1), &fake_clock_); + auto client1 = std::make_unique( + std::make_unique(socket1), &fake_clock_); ss_.SetSendingBlocked(true); EXPECT_EQ(-1, client1->SendTo("foo", 3, socket2->GetLocalAddress())); @@ -1058,9 +1041,9 @@ TEST_F(VirtualSocketServerTest, SetSendingBlockedWithTcpSocket) { ss_.set_recv_buffer_capacity(kBufferSize); StreamSink sink; - std::unique_ptr socket1 = + std::unique_ptr socket1 = absl::WrapUnique(ss_.CreateSocket(kIPv4AnyAddress.family(), SOCK_STREAM)); - std::unique_ptr socket2 = + std::unique_ptr socket2 = absl::WrapUnique(ss_.CreateSocket(kIPv4AnyAddress.family(), SOCK_STREAM)); sink.Monitor(socket1.get()); sink.Monitor(socket2.get()); @@ -1107,9 +1090,9 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) { ASSERT_LT(0u, kTestSamples[sidx]); const uint32_t kStdDev = static_cast(kTestDev[didx] * kTestMean[midx]); - std::unique_ptr f = - webrtc::VirtualSocketServer::CreateDistribution( - kTestMean[midx], kStdDev, kTestSamples[sidx]); + std::unique_ptr f = + VirtualSocketServer::CreateDistribution(kTestMean[midx], kStdDev, + kTestSamples[sidx]); ASSERT_TRUE(nullptr != f.get()); ASSERT_EQ(kTestSamples[sidx], f->size()); double sum = 0; diff --git a/rtc_base/win/windows_version.cc b/rtc_base/win/windows_version.cc index 871be7fc37..6ea62aca36 100644 --- a/rtc_base/win/windows_version.cc +++ b/rtc_base/win/windows_version.cc @@ -221,10 +221,17 @@ Version MajorMinorBuildToVersion(int major, int minor, int build) { return VERSION_WIN10_21H2; } else if (build < 22000) { return VERSION_SERVER_2022; - } else { + } else if (build < 22621) { return VERSION_WIN11; + } else if (build < 22631) { + return VERSION_WIN11_22H2; + } else if (build < 26100) { + return VERSION_WIN11_23H2; + } else { + return VERSION_WIN11_24H2; } } else if (major == 11) { + RTC_DCHECK_NOTREACHED(); return VERSION_WIN11; } else if (major > 6) { RTC_DCHECK_NOTREACHED(); diff --git a/rtc_base/win/windows_version.h b/rtc_base/win/windows_version.h index cbe7cfd88b..cb75ae220c 100644 --- a/rtc_base/win/windows_version.h +++ b/rtc_base/win/windows_version.h @@ -50,6 +50,9 @@ enum Version { VERSION_WIN10_21H2 = 19, // 21H2: Build 19044. VERSION_SERVER_2022 = 20, // Server 2022: Build 20348. VERSION_WIN11 = 21, // Windows 11: Build 22000. + VERSION_WIN11_22H2 = 22, // Windows 11 22H2: Build 22621. + VERSION_WIN11_23H2 = 23, // Windows 11 23H2: Build 22631. + VERSION_WIN11_24H2 = 24, // Windows 11 24H2: Build 26100. VERSION_WIN_LAST, // Indicates error condition. }; diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn index bac6167a60..c853f3408b 100644 --- a/rtc_tools/BUILD.gn +++ b/rtc_tools/BUILD.gn @@ -183,12 +183,16 @@ if (!is_component_build) { "..//api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter", "..//api/video_codecs:video_encoder_factory_template_open_h264_adapter", "..//test/network:simulated_network", + "../api:array_view", "../api:create_frame_generator", + "../api:make_ref_counted", + "../api:rtp_headers", "../api:rtp_parameters", "../api:transport_api", "../api/environment", "../api/environment:environment_factory", "../api/video:builtin_video_bitrate_allocator_factory", + "../api/video:video_bitrate_allocator_factory", "../api/video_codecs:video_codecs_api", "../call", "../call:call_interfaces", @@ -199,9 +203,11 @@ if (!is_component_build) { "../call:video_send_stream_api", "../media:media_constants", "../media:rtc_audio_video", + "../rtc_base:logging", "../rtc_base:rtc_json", "../rtc_base:threading", "../rtc_base/system:file_wrapper", + "../system_wrappers", "../test:fileutils", "../test:frame_generator_capturer", "../test:rtp_test_utils", @@ -364,6 +370,7 @@ if (!build_with_chromium) { ":chart_proto", "../api:candidate", "../api:dtls_transport_interface", + "../api:field_trials", "../api:function_view", "../api:make_ref_counted", "../api:rtp_headers", @@ -377,7 +384,6 @@ if (!build_with_chromium) { "../api/rtc_event_log:rtc_event_log", "../api/transport:bandwidth_usage", "../api/transport:ecn_marking", - "../api/transport:field_trial_based_config", "../api/transport:goog_cc", "../api/transport:network_control", "../api/units:data_rate", @@ -415,8 +421,6 @@ if (!build_with_chromium) { "../rtc_base:stringutils", "../rtc_base/network:sent_packet", "../system_wrappers", - "../system_wrappers:field_trial", - "../test:explicit_key_value_config", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/functional:bind_front", @@ -434,6 +438,7 @@ if (!build_with_chromium) { deps = [ ":chart_proto", ":event_log_visualizer_utils", + "../api/environment:environment_factory", "//api/units:time_delta", "//logging:rtc_event_log_parser", "//rtc_base:protobuf_utils", @@ -512,6 +517,9 @@ if (rtc_include_tests) { deps = [ ":chart_proto", ":event_log_visualizer_utils", + "../api:field_trials", + "../api/environment", + "../api/environment:environment_factory", "../api/neteq:neteq_api", "../api/rtc_event_log", "../api/units:time_delta", @@ -521,7 +529,6 @@ if (rtc_include_tests) { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:protobuf_utils", - "../system_wrappers:field_trial", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/flags:config", "//third_party/abseil-cpp/absl/flags:flag", diff --git a/rtc_tools/data_channel_benchmark/grpc_signaling.cc b/rtc_tools/data_channel_benchmark/grpc_signaling.cc index 33fb60028c..9073b0078b 100644 --- a/rtc_tools/data_channel_benchmark/grpc_signaling.cc +++ b/rtc_tools/data_channel_benchmark/grpc_signaling.cc @@ -29,7 +29,7 @@ using GrpcSignaling::SessionDescription; using GrpcSignaling::SignalingMessage; template -class SessionData : public webrtc::SignalingInterface { +class SessionData : public SignalingInterface { public: SessionData() {} explicit SessionData(T* stream) : stream_(stream) {} @@ -102,8 +102,8 @@ void ProcessMessages(StreamReader* stream, SessionData* session) { while (stream->Read(&message)) { switch (message.Content_case()) { case SignalingMessage::ContentCase::kCandidate: { - webrtc::SdpParseError error; - auto jsep_candidate = std::make_unique( + SdpParseError error; + auto jsep_candidate = std::make_unique( message.candidate().mid(), message.candidate().mline_index()); if (!jsep_candidate->Initialize(message.candidate().description(), &error)) { @@ -121,10 +121,9 @@ void ProcessMessages(StreamReader* stream, SessionData* session) { auto& description = message.description(); auto content = description.content(); - auto sdp = webrtc::CreateSessionDescription( - description.type() == SessionDescription::OFFER - ? webrtc::SdpType::kOffer - : webrtc::SdpType::kAnswer, + auto sdp = CreateSessionDescription( + description.type() == SessionDescription::OFFER ? SdpType::kOffer + : SdpType::kAnswer, description.content()); session->remote_description_callback_(std::move(sdp)); break; @@ -138,10 +137,9 @@ void ProcessMessages(StreamReader* stream, SessionData* session) { class GrpcNegotiationServer : public GrpcSignalingServerInterface, public PeerConnectionSignaling::Service { public: - GrpcNegotiationServer( - std::function callback, - int port, - bool oneshot) + GrpcNegotiationServer(std::function callback, + int port, + bool oneshot) : connect_callback_(std::move(callback)), requested_port_(port), oneshot_(oneshot) {} @@ -196,7 +194,7 @@ class GrpcNegotiationServer : public GrpcSignalingServerInterface, } private: - std::function connect_callback_; + std::function connect_callback_; int requested_port_; int selected_port_; bool oneshot_; @@ -236,7 +234,7 @@ class GrpcNegotiationClient : public GrpcSignalingClientInterface { return true; } - webrtc::SignalingInterface* signaling_client() override { return &session_; } + SignalingInterface* signaling_client() override { return &session_; } private: std::shared_ptr channel_; @@ -252,7 +250,7 @@ class GrpcNegotiationClient : public GrpcSignalingClientInterface { std::unique_ptr GrpcSignalingServerInterface::Create( - std::function callback, + std::function callback, int port, bool oneshot) { return std::make_unique(std::move(callback), port, diff --git a/rtc_tools/data_channel_benchmark/peer_connection_client.cc b/rtc_tools/data_channel_benchmark/peer_connection_client.cc index 74175bd7da..74f1216e2b 100644 --- a/rtc_tools/data_channel_benchmark/peer_connection_client.cc +++ b/rtc_tools/data_channel_benchmark/peer_connection_client.cc @@ -128,15 +128,15 @@ class CreateSessionDescriptionObserverAdapter namespace webrtc { PeerConnectionClient::PeerConnectionClient( - webrtc::PeerConnectionFactoryInterface* factory, - webrtc::SignalingInterface* signaling) + PeerConnectionFactoryInterface* factory, + SignalingInterface* signaling) : signaling_(signaling) { signaling_->OnIceCandidate( - [&](std::unique_ptr candidate) { + [&](std::unique_ptr candidate) { AddIceCandidate(std::move(candidate)); }); signaling_->OnRemoteDescription( - [&](std::unique_ptr sdp) { + [&](std::unique_ptr sdp) { SetRemoteDescription(std::move(sdp)); }); InitializePeerConnection(factory); @@ -148,11 +148,11 @@ PeerConnectionClient::~PeerConnectionClient() { scoped_refptr PeerConnectionClient::CreateDefaultFactory(Thread* signaling_thread) { - auto factory = webrtc::CreatePeerConnectionFactory( + auto factory = CreatePeerConnectionFactory( /*network_thread=*/nullptr, /*worker_thread=*/nullptr, /*signaling_thread*/ signaling_thread, - /*default_adm=*/nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), - webrtc::CreateBuiltinAudioDecoderFactory(), + /*default_adm=*/nullptr, CreateBuiltinAudioEncoderFactory(), + CreateBuiltinAudioDecoderFactory(), std::make_unique>(), @@ -170,17 +170,17 @@ PeerConnectionClient::CreateDefaultFactory(Thread* signaling_thread) { } bool PeerConnectionClient::InitializePeerConnection( - webrtc::PeerConnectionFactoryInterface* factory) { + PeerConnectionFactoryInterface* factory) { RTC_CHECK(factory) << "Must call InitializeFactory before InitializePeerConnection"; - webrtc::PeerConnectionInterface::RTCConfiguration config; - webrtc::PeerConnectionInterface::IceServer server; + PeerConnectionInterface::RTCConfiguration config; + PeerConnectionInterface::IceServer server; server.urls.push_back(kStunServer); config.servers.push_back(server); - config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan; + config.sdp_semantics = SdpSemantics::kUnifiedPlan; - webrtc::PeerConnectionDependencies dependencies(this); + PeerConnectionDependencies dependencies(this); auto result = factory->CreatePeerConnectionOrError(config, std::move(dependencies)); @@ -199,8 +199,7 @@ bool PeerConnectionClient::StartPeerConnection() { RTC_LOG(LS_INFO) << "Creating offer"; peer_connection_->SetLocalDescription( - SetLocalDescriptionObserverAdapter::Create([this]( - webrtc::RTCError error) { + SetLocalDescriptionObserverAdapter::Create([this](RTCError error) { if (error.ok()) signaling_->SendDescription(peer_connection_->local_description()); })); @@ -210,7 +209,7 @@ bool PeerConnectionClient::StartPeerConnection() { bool PeerConnectionClient::IsConnected() { return peer_connection_->peer_connection_state() == - webrtc::PeerConnectionInterface::PeerConnectionState::kConnected; + PeerConnectionInterface::PeerConnectionState::kConnected; } // Disconnect from the call. @@ -234,11 +233,11 @@ void PeerConnectionClient::DeletePeerConnection() { } void PeerConnectionClient::OnIceConnectionChange( - webrtc::PeerConnectionInterface::IceConnectionState new_state) { - if (new_state == webrtc::PeerConnectionInterface::IceConnectionState:: - kIceConnectionCompleted) { + PeerConnectionInterface::IceConnectionState new_state) { + if (new_state == + PeerConnectionInterface::IceConnectionState::kIceConnectionCompleted) { RTC_LOG(LS_INFO) << "State is updating to connected"; - } else if (new_state == webrtc::PeerConnectionInterface::IceConnectionState:: + } else if (new_state == PeerConnectionInterface::IceConnectionState:: kIceConnectionDisconnected) { RTC_LOG(LS_INFO) << "Disconnecting from peer"; Disconnect(); @@ -246,19 +245,19 @@ void PeerConnectionClient::OnIceConnectionChange( } void PeerConnectionClient::OnIceGatheringChange( - webrtc::PeerConnectionInterface::IceGatheringState new_state) { - if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) { + PeerConnectionInterface::IceGatheringState new_state) { + if (new_state == PeerConnectionInterface::kIceGatheringComplete) { RTC_LOG(LS_INFO) << "Client is ready to receive remote SDP"; } } void PeerConnectionClient::OnIceCandidate( - const webrtc::IceCandidateInterface* candidate) { + const IceCandidateInterface* candidate) { signaling_->SendIceCandidate(candidate); } void PeerConnectionClient::OnDataChannel( - scoped_refptr channel) { + scoped_refptr channel) { RTC_LOG(LS_INFO) << __FUNCTION__ << " remote datachannel created"; if (on_data_channel_callback_) on_data_channel_callback_(channel); @@ -266,8 +265,7 @@ void PeerConnectionClient::OnDataChannel( } void PeerConnectionClient::SetOnDataChannel( - std::function)> - callback) { + std::function)> callback) { on_data_channel_callback_ = callback; } @@ -275,28 +273,27 @@ void PeerConnectionClient::OnNegotiationNeededEvent(uint32_t event_id) { RTC_LOG(LS_INFO) << "OnNegotiationNeededEvent"; peer_connection_->SetLocalDescription( - SetLocalDescriptionObserverAdapter::Create([this]( - webrtc::RTCError error) { + SetLocalDescriptionObserverAdapter::Create([this](RTCError error) { if (error.ok()) signaling_->SendDescription(peer_connection_->local_description()); })); } bool PeerConnectionClient::SetRemoteDescription( - std::unique_ptr desc) { + std::unique_ptr desc) { RTC_LOG(LS_INFO) << "SetRemoteDescription"; auto type = desc->GetType(); peer_connection_->SetRemoteDescription( std::move(desc), - SetRemoteDescriptionObserverAdapter::Create([&](webrtc::RTCError) { + SetRemoteDescriptionObserverAdapter::Create([&](RTCError) { RTC_LOG(LS_INFO) << "SetRemoteDescription done"; - if (type == webrtc::SdpType::kOffer) { + if (type == SdpType::kOffer) { // Got an offer from the remote, need to set an answer and send it. peer_connection_->SetLocalDescription( SetLocalDescriptionObserverAdapter::Create( - [this](webrtc::RTCError error) { + [this](RTCError error) { if (error.ok()) signaling_->SendDescription( peer_connection_->local_description()); @@ -308,7 +305,7 @@ bool PeerConnectionClient::SetRemoteDescription( } void PeerConnectionClient::AddIceCandidate( - std::unique_ptr candidate) { + std::unique_ptr candidate) { RTC_LOG(LS_INFO) << "AddIceCandidate"; peer_connection_->AddIceCandidate( diff --git a/rtc_tools/frame_analyzer/video_quality_analysis.cc b/rtc_tools/frame_analyzer/video_quality_analysis.cc index 1229d0a85f..36dc933506 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis.cc +++ b/rtc_tools/frame_analyzer/video_quality_analysis.cc @@ -55,8 +55,8 @@ double Ssim(const scoped_refptr& ref_buffer, } std::vector RunAnalysis( - const scoped_refptr& reference_video, - const scoped_refptr& test_video, + const scoped_refptr& reference_video, + const scoped_refptr& test_video, const std::vector& test_frame_indices) { std::vector results; for (size_t i = 0; i < test_video->number_of_frames(); ++i) { diff --git a/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc b/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc index d0227fb4b3..7ad8ec1a03 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc +++ b/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc @@ -136,10 +136,9 @@ TEST(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesDecodeErrorInTest) { ResultsContainer result; - std::string log_filename = - TempFilename(webrtc::test::OutputPath(), "log.log"); + std::string log_filename = TempFilename(test::OutputPath(), "log.log"); FILE* logfile = fopen(log_filename.c_str(), "w"); - ASSERT_TRUE(logfile != NULL); + ASSERT_TRUE(logfile != nullptr); result.max_repeated_frames = 1; result.max_skipped_frames = 0; diff --git a/rtc_tools/network_tester/packet_sender.cc b/rtc_tools/network_tester/packet_sender.cc index 0ab5b77ffc..abc2240408 100644 --- a/rtc_tools/network_tester/packet_sender.cc +++ b/rtc_tools/network_tester/packet_sender.cc @@ -28,7 +28,7 @@ namespace { absl::AnyInvocable SendPacketTask( PacketSender* packet_sender, - scoped_refptr task_safety_flag, + scoped_refptr task_safety_flag, int64_t target_time_ms = TimeMillis()) { return [target_time_ms, packet_sender, task_safety_flag = std::move(task_safety_flag)]() mutable { @@ -48,7 +48,7 @@ absl::AnyInvocable SendPacketTask( absl::AnyInvocable UpdateTestSettingTask( PacketSender* packet_sender, std::unique_ptr config_reader, - scoped_refptr task_safety_flag) { + scoped_refptr task_safety_flag) { return [packet_sender, config_reader = std::move(config_reader), task_safety_flag = std::move(task_safety_flag)]() mutable { if (!task_safety_flag->alive()) { @@ -72,8 +72,8 @@ absl::AnyInvocable UpdateTestSettingTask( PacketSender::PacketSender( TestController* test_controller, - webrtc::TaskQueueBase* worker_queue, - scoped_refptr task_safety_flag, + TaskQueueBase* worker_queue, + scoped_refptr task_safety_flag, const std::string& config_file_path) : packet_size_(0), send_interval_ms_(0), diff --git a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc index 7a34309d53..ed3629a787 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc @@ -44,7 +44,6 @@ #include "rtc_base/checks.h" #include "rtc_tools/rtc_event_log_visualizer/analyzer_common.h" #include "rtc_tools/rtc_event_log_visualizer/plot_base.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { @@ -242,8 +241,9 @@ class ReplacementAudioDecoderFactory : public AudioDecoderFactory { std::unique_ptr CreateNetEqTestAndRun( const ParsedRtcEventLog& parsed_log, uint32_t ssrc, - const std::string& replacement_file_name, - int file_sample_rate_hz) { + absl::string_view replacement_file_name, + int file_sample_rate_hz, + absl::string_view field_trials) { std::unique_ptr input = test::CreateNetEqEventLogInput(parsed_log, ssrc); if (!input) { @@ -278,7 +278,7 @@ std::unique_ptr CreateNetEqTestAndRun( NetEq::Config config; test::NetEqTest test(config, decoder_factory, codecs, /*text_log=*/nullptr, /*factory=*/nullptr, std::move(input), std::move(output), - callbacks, field_trial::GetFieldTrialString()); + callbacks, field_trials); test.Run(); return neteq_stats_getter; } @@ -286,12 +286,14 @@ std::unique_ptr CreateNetEqTestAndRun( NetEqStatsGetterMap SimulateNetEq(const ParsedRtcEventLog& parsed_log, const AnalyzerConfig& config, - const std::string& replacement_file_name, - int file_sample_rate_hz) { + absl::string_view replacement_file_name, + int file_sample_rate_hz, + absl::string_view field_trials) { NetEqStatsGetterMap neteq_stats; for (uint32_t ssrc : parsed_log.incoming_audio_ssrcs()) { - std::unique_ptr stats = CreateNetEqTestAndRun( - parsed_log, ssrc, replacement_file_name, file_sample_rate_hz); + std::unique_ptr stats = + CreateNetEqTestAndRun(parsed_log, ssrc, replacement_file_name, + file_sample_rate_hz, field_trials); if (stats) { neteq_stats[ssrc] = std::move(stats); } diff --git a/rtc_tools/rtc_event_log_visualizer/analyze_audio.h b/rtc_tools/rtc_event_log_visualizer/analyze_audio.h index c5132f25a8..094f9d91b6 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyze_audio.h +++ b/rtc_tools/rtc_event_log_visualizer/analyze_audio.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/function_view.h" #include "api/neteq/neteq.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" @@ -48,8 +49,9 @@ using NetEqStatsGetterMap = std::map>; NetEqStatsGetterMap SimulateNetEq(const ParsedRtcEventLog& parsed_log, const AnalyzerConfig& config, - const std::string& replacement_file_name, - int file_sample_rate_hz); + absl::string_view replacement_file_name, + int file_sample_rate_hz, + absl::string_view field_trials); void CreateAudioJitterBufferGraph(const ParsedRtcEventLog& parsed_log, const AnalyzerConfig& config, diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index 4aea669675..f1afcc4b90 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -30,10 +30,11 @@ #include "absl/strings/string_view.h" #include "api/candidate.h" #include "api/dtls_transport_interface.h" +#include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/function_view.h" #include "api/media_types.h" -#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_headers.h" #include "api/transport/bandwidth_usage.h" #include "api/transport/ecn_marking.h" @@ -77,7 +78,6 @@ #include "rtc_tools/rtc_event_log_visualizer/log_simulation.h" #include "rtc_tools/rtc_event_log_visualizer/plot_base.h" #include "system_wrappers/include/clock.h" -#include "test/explicit_key_value_config.h" namespace webrtc { @@ -282,44 +282,43 @@ absl::string_view GetIceCandidateTypeAsString(IceCandidateType type) { } } -std::string GetProtocolAsString(webrtc::IceCandidatePairProtocol protocol) { +std::string GetProtocolAsString(IceCandidatePairProtocol protocol) { switch (protocol) { - case webrtc::IceCandidatePairProtocol::kUdp: + case IceCandidatePairProtocol::kUdp: return kProtocolUdp; - case webrtc::IceCandidatePairProtocol::kTcp: + case IceCandidatePairProtocol::kTcp: return kProtocolTcp; - case webrtc::IceCandidatePairProtocol::kSsltcp: + case IceCandidatePairProtocol::kSsltcp: return kProtocolSsltcp; - case webrtc::IceCandidatePairProtocol::kTls: + case IceCandidatePairProtocol::kTls: return kProtocolTls; default: return kUnknownEnumValue; } } -std::string GetAddressFamilyAsString( - webrtc::IceCandidatePairAddressFamily family) { +std::string GetAddressFamilyAsString(IceCandidatePairAddressFamily family) { switch (family) { - case webrtc::IceCandidatePairAddressFamily::kIpv4: + case IceCandidatePairAddressFamily::kIpv4: return kAddressFamilyIpv4; - case webrtc::IceCandidatePairAddressFamily::kIpv6: + case IceCandidatePairAddressFamily::kIpv6: return kAddressFamilyIpv6; default: return kUnknownEnumValue; } } -std::string GetNetworkTypeAsString(webrtc::IceCandidateNetworkType type) { +std::string GetNetworkTypeAsString(IceCandidateNetworkType type) { switch (type) { - case webrtc::IceCandidateNetworkType::kEthernet: + case IceCandidateNetworkType::kEthernet: return kNetworkTypeEthernet; - case webrtc::IceCandidateNetworkType::kLoopback: + case IceCandidateNetworkType::kLoopback: return kNetworkTypeLoopback; - case webrtc::IceCandidateNetworkType::kWifi: + case IceCandidateNetworkType::kWifi: return kNetworkTypeWifi; - case webrtc::IceCandidateNetworkType::kVpn: + case IceCandidateNetworkType::kVpn: return kNetworkTypeVpn; - case webrtc::IceCandidateNetworkType::kCellular: + case IceCandidateNetworkType::kCellular: return kNetworkTypeCellular; default: return kUnknownEnumValue; @@ -435,19 +434,19 @@ struct PacketLossSummary { Timestamp base_time = Timestamp::MinusInfinity(); }; -float GetHighestSeqNumber(const webrtc::rtcp::ReportBlock& block) { +float GetHighestSeqNumber(const rtcp::ReportBlock& block) { return block.extended_high_seq_num(); } -float GetFractionLost(const webrtc::rtcp::ReportBlock& block) { +float GetFractionLost(const rtcp::ReportBlock& block) { return static_cast(block.fraction_lost()) / 256 * 100; } -float GetCumulativeLost(const webrtc::rtcp::ReportBlock& block) { +float GetCumulativeLost(const rtcp::ReportBlock& block) { return block.cumulative_lost(); } -float DelaySinceLastSr(const webrtc::rtcp::ReportBlock& block) { +float DelaySinceLastSr(const rtcp::ReportBlock& block) { return static_cast(block.delay_since_last_sr()) / 65536; } @@ -472,7 +471,7 @@ std::map BuildCandidateIdLogDescriptionMap( EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, bool normalize_time) - : parsed_log_(log) { + : env_(CreateEnvironment()), parsed_log_(log) { config_.window_duration_ = TimeDelta::Millis(250); config_.step_ = TimeDelta::Millis(10); if (!log.start_log_events().empty()) { @@ -494,9 +493,10 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, << " seconds long."; } -EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, +EventLogAnalyzer::EventLogAnalyzer(const Environment& env, + const ParsedRtcEventLog& log, const AnalyzerConfig& config) - : parsed_log_(log), config_(config) { + : env_(env), parsed_log_(log), config_(config) { RTC_LOG(LS_INFO) << "Log is " << (parsed_log_.last_timestamp().ms() - parsed_log_.first_timestamp().ms()) / @@ -534,35 +534,35 @@ void EventLogAnalyzer::InitializeMapOfNamedGraphs(bool show_detector_state, bool show_alr_state, bool show_link_capacity) { plots_.RegisterPlot("incoming_packet_sizes", [this](Plot* plot) { - this->CreatePacketGraph(webrtc::kIncomingPacket, plot); + this->CreatePacketGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_packet_sizes", [this](Plot* plot) { - this->CreatePacketGraph(webrtc::kOutgoingPacket, plot); + this->CreatePacketGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("incoming_rtcp_types", [this](Plot* plot) { - this->CreateRtcpTypeGraph(webrtc::kIncomingPacket, plot); + this->CreateRtcpTypeGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_rtcp_types", [this](Plot* plot) { - this->CreateRtcpTypeGraph(webrtc::kOutgoingPacket, plot); + this->CreateRtcpTypeGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("incoming_packet_count", [this](Plot* plot) { - this->CreateAccumulatedPacketsGraph(webrtc::kIncomingPacket, plot); + this->CreateAccumulatedPacketsGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_packet_count", [this](Plot* plot) { - this->CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket, plot); + this->CreateAccumulatedPacketsGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("incoming_packet_rate", [this](Plot* plot) { - this->CreatePacketRateGraph(webrtc::kIncomingPacket, plot); + this->CreatePacketRateGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_packet_rate", [this](Plot* plot) { - this->CreatePacketRateGraph(webrtc::kOutgoingPacket, plot); + this->CreatePacketRateGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("total_incoming_packet_rate", [this](Plot* plot) { - this->CreateTotalPacketRateGraph(webrtc::kIncomingPacket, plot); + this->CreateTotalPacketRateGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("total_outgoing_packet_rate", [this](Plot* plot) { - this->CreateTotalPacketRateGraph(webrtc::kOutgoingPacket, plot); + this->CreateTotalPacketRateGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("audio_playout", [this](Plot* plot) { this->CreatePlayoutGraph(plot); }); @@ -572,10 +572,10 @@ void EventLogAnalyzer::InitializeMapOfNamedGraphs(bool show_detector_state, }); plots_.RegisterPlot("incoming_audio_level", [this](Plot* plot) { - this->CreateAudioLevelGraph(webrtc::kIncomingPacket, plot); + this->CreateAudioLevelGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_audio_level", [this](Plot* plot) { - this->CreateAudioLevelGraph(webrtc::kOutgoingPacket, plot); + this->CreateAudioLevelGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("incoming_sequence_number_delta", [this](Plot* plot) { this->CreateSequenceNumberGraph(plot); @@ -596,16 +596,16 @@ void EventLogAnalyzer::InitializeMapOfNamedGraphs(bool show_detector_state, plot, show_detector_state, show_alr_state, show_link_capacity); }); plots_.RegisterPlot("incoming_stream_bitrate", [this](Plot* plot) { - this->CreateStreamBitrateGraph(webrtc::kIncomingPacket, plot); + this->CreateStreamBitrateGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_stream_bitrate", [this](Plot* plot) { - this->CreateStreamBitrateGraph(webrtc::kOutgoingPacket, plot); + this->CreateStreamBitrateGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("incoming_layer_bitrate_allocation", [this](Plot* plot) { - this->CreateBitrateAllocationGraph(webrtc::kIncomingPacket, plot); + this->CreateBitrateAllocationGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_layer_bitrate_allocation", [this](Plot* plot) { - this->CreateBitrateAllocationGraph(webrtc::kOutgoingPacket, plot); + this->CreateBitrateAllocationGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("simulated_receiveside_bwe", [this](Plot* plot) { this->CreateReceiveSideBweSimulationGraph(plot); @@ -632,54 +632,54 @@ void EventLogAnalyzer::InitializeMapOfNamedGraphs(bool show_detector_state, this->CreateFractionLossGraph(plot); }); plots_.RegisterPlot("incoming_timestamps", [this](Plot* plot) { - this->CreateTimestampGraph(webrtc::kIncomingPacket, plot); + this->CreateTimestampGraph(kIncomingPacket, plot); }); plots_.RegisterPlot("outgoing_timestamps", [this](Plot* plot) { - this->CreateTimestampGraph(webrtc::kOutgoingPacket, plot); + this->CreateTimestampGraph(kOutgoingPacket, plot); }); plots_.RegisterPlot("incoming_rtcp_fraction_lost", [this](Plot* plot) { - this->CreateSenderAndReceiverReportPlot( - webrtc::kIncomingPacket, GetFractionLost, - "Fraction lost (incoming RTCP)", "Loss rate (percent)", plot); + this->CreateSenderAndReceiverReportPlot(kIncomingPacket, GetFractionLost, + "Fraction lost (incoming RTCP)", + "Loss rate (percent)", plot); }); plots_.RegisterPlot("outgoing_rtcp_fraction_lost", [this](Plot* plot) { - this->CreateSenderAndReceiverReportPlot( - webrtc::kOutgoingPacket, GetFractionLost, - "Fraction lost (outgoing RTCP)", "Loss rate (percent)", plot); + this->CreateSenderAndReceiverReportPlot(kOutgoingPacket, GetFractionLost, + "Fraction lost (outgoing RTCP)", + "Loss rate (percent)", plot); }); plots_.RegisterPlot("incoming_rtcp_cumulative_lost", [this](Plot* plot) { this->CreateSenderAndReceiverReportPlot( - webrtc::kIncomingPacket, GetCumulativeLost, + kIncomingPacket, GetCumulativeLost, "Cumulative lost packets (incoming RTCP)", "Packets", plot); }); plots_.RegisterPlot("outgoing_rtcp_cumulative_lost", [this](Plot* plot) { this->CreateSenderAndReceiverReportPlot( - webrtc::kOutgoingPacket, GetCumulativeLost, + kOutgoingPacket, GetCumulativeLost, "Cumulative lost packets (outgoing RTCP)", "Packets", plot); }); plots_.RegisterPlot("incoming_rtcp_highest_seq_number", [this](Plot* plot) { this->CreateSenderAndReceiverReportPlot( - webrtc::kIncomingPacket, GetHighestSeqNumber, + kIncomingPacket, GetHighestSeqNumber, "Highest sequence number (incoming RTCP)", "Sequence number", plot); }); plots_.RegisterPlot("outgoing_rtcp_highest_seq_number", [this](Plot* plot) { this->CreateSenderAndReceiverReportPlot( - webrtc::kOutgoingPacket, GetHighestSeqNumber, + kOutgoingPacket, GetHighestSeqNumber, "Highest sequence number (outgoing RTCP)", "Sequence number", plot); }); plots_.RegisterPlot("incoming_rtcp_delay_since_last_sr", [this](Plot* plot) { this->CreateSenderAndReceiverReportPlot( - webrtc::kIncomingPacket, DelaySinceLastSr, + kIncomingPacket, DelaySinceLastSr, "Delay since last received sender report (incoming RTCP)", "Time (s)", plot); }); plots_.RegisterPlot("outgoing_rtcp_delay_since_last_sr", [this](Plot* plot) { this->CreateSenderAndReceiverReportPlot( - webrtc::kOutgoingPacket, DelaySinceLastSr, + kOutgoingPacket, DelaySinceLastSr, "Delay since last received sender report (outgoing RTCP)", "Time (s)", plot); }); @@ -1534,7 +1534,7 @@ void EventLogAnalyzer::CreateGoogCcSimulationGraph(Plot* plot) const { PointStyle::kHighlight); LogBasedNetworkControllerSimulation simulation( - std::make_unique(), + env_, std::make_unique(), [&](const NetworkControlUpdate& update, Timestamp at_time) { if (update.target_rate) { target_rates.points.emplace_back( @@ -1592,16 +1592,16 @@ void EventLogAnalyzer::CreateEcnFeedbackGraph(Plot* plot, for (const rtcp::CongestionControlFeedback::PacketInfo& info : feedback.congestion_feedback.packets()) { switch (info.ecn) { - case webrtc::EcnMarking::kNotEct: + case EcnMarking::kNotEct: ++not_ect_count; break; - case webrtc::EcnMarking::kEct1: + case EcnMarking::kEct1: ++ect_1_count; break; - case webrtc::EcnMarking::kEct0: + case EcnMarking::kEct0: RTC_LOG(LS_ERROR) << "unexpected ect(0)"; break; - case webrtc::EcnMarking::kCe: + case EcnMarking::kCe: ++ce_count; break; } @@ -1763,13 +1763,12 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) const { SimulatedClock clock(0); BitrateObserver observer; - RtcEventLogNull null_event_log; TransportFeedbackAdapter transport_feedback; auto factory = GoogCcNetworkControllerFactory(); TimeDelta process_interval = factory.GetProcessInterval(); // TODO(holmer): Log the call config and use that here instead. static const uint32_t kDefaultStartBitrateBps = 300000; - NetworkControllerConfig cc_config(CreateEnvironment(&null_event_log)); + NetworkControllerConfig cc_config(env_); cc_config.constraints.at_time = Timestamp::Micros(clock.TimeInMicroseconds()); cc_config.constraints.starting_rate = DataRate::BitsPerSec(kDefaultStartBitrateBps); @@ -1810,12 +1809,12 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) const { }; RateStatistics raw_acked_bitrate(750, 8000); - test::ExplicitKeyValueConfig throughput_config( + FieldTrials throughput_config( "WebRTC-Bwe-RobustThroughputEstimatorSettings/enabled:true/"); std::unique_ptr robust_throughput_estimator( AcknowledgedBitrateEstimatorInterface::Create(&throughput_config)); - test::ExplicitKeyValueConfig acked_bitrate_config( + FieldTrials acked_bitrate_config( "WebRTC-Bwe-RobustThroughputEstimatorSettings/enabled:false/"); std::unique_ptr acknowledged_bitrate_estimator( @@ -1969,9 +1968,11 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) const { } SimulatedClock clock(0); + EnvironmentFactory env_factory(env_); + env_factory.Set(&clock); RembInterceptor remb_interceptor; ReceiveSideCongestionController rscc( - CreateEnvironment(&clock), [](auto...) {}, + env_factory.Create(), [](auto...) {}, absl::bind_front(&RembInterceptor::SendRemb, &remb_interceptor)); // TODO(holmer): Log the call config and use that here instead. // static const uint32_t kDefaultStartBitrateBps = 300000; diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.h b/rtc_tools/rtc_event_log_visualizer/analyzer.h index 5bb0840728..134a45fa63 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.h +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.h @@ -14,10 +14,10 @@ #include #include #include -#include #include #include +#include "api/environment/environment.h" #include "api/function_view.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" @@ -62,7 +62,9 @@ class EventLogAnalyzer { // duration of its lifetime. The ParsedRtcEventLogNew must not be destroyed or // modified while the EventLogAnalyzer is being used. EventLogAnalyzer(const ParsedRtcEventLog& log, bool normalize_time); - EventLogAnalyzer(const ParsedRtcEventLog& log, const AnalyzerConfig& config); + EventLogAnalyzer(const Environment& env, + const ParsedRtcEventLog& log, + const AnalyzerConfig& config); void CreateGraphsByName(const std::vector& names, PlotCollection* collection) const; @@ -148,6 +150,7 @@ class EventLogAnalyzer { const std::string& label) const; void CreateEcnFeedbackGraph(Plot* plot, PacketDirection direction) const; + const Environment env_; const ParsedRtcEventLog& parsed_log_; // A list of SSRCs we are interested in analysing. diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc index 254a76387d..a50e0fbf53 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc @@ -18,6 +18,7 @@ #include #include "absl/strings/string_view.h" +#include "api/environment/environment_factory.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" #include "rtc_base/numerics/safe_conversions.h" @@ -82,7 +83,8 @@ void analyze_rtc_event_log(const char* log_contents, return; } - webrtc::EventLogAnalyzer analyzer(parsed_log, config); + webrtc::EventLogAnalyzer analyzer(webrtc::CreateEnvironment(), parsed_log, + config); analyzer.InitializeMapOfNamedGraphs(/*show_detector_state=*/false, /*show_alr_state=*/false, /*show_link_capacity=*/false); diff --git a/rtc_tools/rtc_event_log_visualizer/log_simulation.cc b/rtc_tools/rtc_event_log_visualizer/log_simulation.cc index 47bdb76bbb..82f340632e 100644 --- a/rtc_tools/rtc_event_log_visualizer/log_simulation.cc +++ b/rtc_tools/rtc_event_log_visualizer/log_simulation.cc @@ -16,7 +16,7 @@ #include #include -#include "api/environment/environment_factory.h" +#include "api/environment/environment.h" #include "api/transport/network_control.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -30,15 +30,19 @@ #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/ntp_time_util.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" +#include "rtc_base/checks.h" #include "rtc_base/network/sent_packet.h" #include "system_wrappers/include/clock.h" namespace webrtc { LogBasedNetworkControllerSimulation::LogBasedNetworkControllerSimulation( + const Environment& env, std::unique_ptr factory, std::function update_handler) - : update_handler_(update_handler), factory_(std::move(factory)) {} + : env_(env), + update_handler_(update_handler), + factory_(std::move(factory)) {} LogBasedNetworkControllerSimulation::~LogBasedNetworkControllerSimulation() {} @@ -49,7 +53,7 @@ void LogBasedNetworkControllerSimulation::HandleStateUpdate( void LogBasedNetworkControllerSimulation::ProcessUntil(Timestamp to_time) { if (last_process_.IsInfinite()) { - NetworkControllerConfig config(CreateEnvironment(&null_event_log_)); + NetworkControllerConfig config(env_); config.constraints.at_time = to_time; config.constraints.min_data_rate = DataRate::KilobitsPerSec(30); config.constraints.starting_rate = DataRate::KilobitsPerSec(300); diff --git a/rtc_tools/rtc_event_log_visualizer/log_simulation.h b/rtc_tools/rtc_event_log_visualizer/log_simulation.h index dbb0a1c798..0c0f8959b6 100644 --- a/rtc_tools/rtc_event_log_visualizer/log_simulation.h +++ b/rtc_tools/rtc_event_log_visualizer/log_simulation.h @@ -17,7 +17,7 @@ #include #include -#include "api/rtc_event_log/rtc_event_log.h" +#include "api/environment/environment.h" #include "api/transport/network_control.h" #include "api/transport/network_types.h" #include "api/units/timestamp.h" @@ -33,6 +33,7 @@ namespace webrtc { class LogBasedNetworkControllerSimulation { public: explicit LogBasedNetworkControllerSimulation( + const Environment& env, std::unique_ptr factory, std::function update_handler); @@ -53,8 +54,8 @@ class LogBasedNetworkControllerSimulation { void OnFeedback(const LoggedRtcpPacketTransportFeedback& feedback); void OnReceiverReport(const LoggedRtcpPacketReceiverReport& report); void OnIceConfig(const LoggedIceCandidatePairConfig& candidate); - RtcEventLogNull null_event_log_; + const Environment env_; const std::function update_handler_; std::unique_ptr factory_; diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc index 466203baf2..a410985040 100644 --- a/rtc_tools/rtc_event_log_visualizer/main.cc +++ b/rtc_tools/rtc_event_log_visualizer/main.cc @@ -28,6 +28,9 @@ #include "absl/flags/usage_config.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/neteq/neteq.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" @@ -40,7 +43,6 @@ #include "rtc_tools/rtc_event_log_visualizer/conversational_speech_en.h" #include "rtc_tools/rtc_event_log_visualizer/plot_base.h" #include "rtc_tools/rtc_event_log_visualizer/proto/chart.pb.h" -#include "system_wrappers/include/field_trial.h" ABSL_FLAG(std::string, plot, @@ -157,10 +159,9 @@ int main(int argc, char* argv[]) { } webrtc::LogMessage::SetLogToStderr(true); - // InitFieldTrialsFromString stores the char*, so the char array must outlive - // the application. const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials); - webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str()); + webrtc::Environment env = webrtc::CreateEnvironment( + std::make_unique(field_trials)); webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions = webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse; @@ -213,7 +214,7 @@ int main(int argc, char* argv[]) { has_generated_wav_file = true; } - webrtc::EventLogAnalyzer analyzer(parsed_log, config); + webrtc::EventLogAnalyzer analyzer(env, parsed_log, config); analyzer.InitializeMapOfNamedGraphs(absl::GetFlag(FLAGS_show_detector_state), absl::GetFlag(FLAGS_show_alr_state), absl::GetFlag(FLAGS_show_link_capacity)); @@ -329,7 +330,8 @@ int main(int argc, char* argv[]) { if (absl::c_find(plot_names, "simulated_neteq_expand_rate") != plot_names.end()) { if (!neteq_stats) { - neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000); + neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000, + field_trials); } webrtc::CreateNetEqNetworkStatsGraph( parsed_log, config, *neteq_stats, @@ -341,7 +343,8 @@ int main(int argc, char* argv[]) { if (absl::c_find(plot_names, "simulated_neteq_speech_expand_rate") != plot_names.end()) { if (!neteq_stats) { - neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000); + neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000, + field_trials); } webrtc::CreateNetEqNetworkStatsGraph( parsed_log, config, *neteq_stats, @@ -354,7 +357,8 @@ int main(int argc, char* argv[]) { if (absl::c_find(plot_names, "simulated_neteq_accelerate_rate") != plot_names.end()) { if (!neteq_stats) { - neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000); + neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000, + field_trials); } webrtc::CreateNetEqNetworkStatsGraph( parsed_log, config, *neteq_stats, @@ -367,7 +371,8 @@ int main(int argc, char* argv[]) { if (absl::c_find(plot_names, "simulated_neteq_preemptive_rate") != plot_names.end()) { if (!neteq_stats) { - neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000); + neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000, + field_trials); } webrtc::CreateNetEqNetworkStatsGraph( parsed_log, config, *neteq_stats, @@ -380,7 +385,8 @@ int main(int argc, char* argv[]) { if (absl::c_find(plot_names, "simulated_neteq_concealment_events") != plot_names.end()) { if (!neteq_stats) { - neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000); + neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000, + field_trials); } webrtc::CreateNetEqLifetimeStatsGraph( parsed_log, config, *neteq_stats, @@ -393,7 +399,8 @@ int main(int argc, char* argv[]) { if (absl::c_find(plot_names, "simulated_neteq_preferred_buffer_size") != plot_names.end()) { if (!neteq_stats) { - neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000); + neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000, + field_trials); } webrtc::CreateNetEqNetworkStatsGraph( parsed_log, config, *neteq_stats, @@ -412,7 +419,8 @@ int main(int argc, char* argv[]) { if (absl::c_find(plot_names, "simulated_neteq_jitter_buffer_delay") != plot_names.end()) { if (!neteq_stats) { - neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000); + neteq_stats = webrtc::SimulateNetEq(parsed_log, config, wav_path, 48000, + field_trials); } for (auto it = neteq_stats->cbegin(); it != neteq_stats->cend(); ++it) { webrtc::CreateAudioJitterBufferGraph( diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.cc b/rtc_tools/rtc_event_log_visualizer/plot_base.cc index ddfa5e056e..481c81cd40 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.cc +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.cc @@ -262,9 +262,9 @@ void Plot::PrintPythonCode(absl::string_view figure_output_path) const { } } -void Plot::ExportProtobuf(webrtc::analytics::Chart* chart) const { +void Plot::ExportProtobuf(analytics::Chart* chart) const { for (size_t i = 0; i < series_list_.size(); i++) { - webrtc::analytics::DataSet* data_set = chart->add_data_sets(); + analytics::DataSet* data_set = chart->add_data_sets(); for (const auto& point : series_list_[i].points) { data_set->add_x_values(point.x); } @@ -273,15 +273,15 @@ void Plot::ExportProtobuf(webrtc::analytics::Chart* chart) const { } if (series_list_[i].line_style == LineStyle::kBar) { - data_set->set_style(webrtc::analytics::ChartStyle::BAR_CHART); + data_set->set_style(analytics::ChartStyle::BAR_CHART); } else if (series_list_[i].line_style == LineStyle::kLine) { - data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART); + data_set->set_style(analytics::ChartStyle::LINE_CHART); } else if (series_list_[i].line_style == LineStyle::kStep) { - data_set->set_style(webrtc::analytics::ChartStyle::LINE_STEP_CHART); + data_set->set_style(analytics::ChartStyle::LINE_STEP_CHART); } else if (series_list_[i].line_style == LineStyle::kNone) { - data_set->set_style(webrtc::analytics::ChartStyle::SCATTER_CHART); + data_set->set_style(analytics::ChartStyle::SCATTER_CHART); } else { - data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED); + data_set->set_style(analytics::ChartStyle::UNDEFINED); } if (series_list_[i].point_style == PointStyle::kHighlight) @@ -300,7 +300,7 @@ void Plot::ExportProtobuf(webrtc::analytics::Chart* chart) const { chart->set_id(id_); for (const auto& kv : yaxis_tick_labels_) { - webrtc::analytics::TickLabel* tick = chart->add_yaxis_tick_labels(); + analytics::TickLabel* tick = chart->add_yaxis_tick_labels(); tick->set_value(kv.first); tick->set_label(kv.second); } @@ -334,10 +334,9 @@ void PlotCollection::PrintPythonCode( } void PlotCollection::ExportProtobuf( - webrtc::analytics::ChartCollection* collection) const { + analytics::ChartCollection* collection) const { for (const auto& plot : plots_) { - webrtc::analytics::Chart* protobuf_representation = - collection->add_charts(); + analytics::Chart* protobuf_representation = collection->add_charts(); plot->ExportProtobuf(protobuf_representation); } if (calltime_to_utc_ms_) { diff --git a/rtc_tools/rtp_generator/rtp_generator.cc b/rtc_tools/rtp_generator/rtp_generator.cc index cb4a14cba4..3152bc1834 100644 --- a/rtc_tools/rtp_generator/rtp_generator.cc +++ b/rtc_tools/rtp_generator/rtp_generator.cc @@ -11,27 +11,47 @@ #include "rtc_tools/rtp_generator/rtp_generator.h" #include +#include +#include +#include #include +#include +#include #include +#include +#include "api/array_view.h" +#include "api/call/transport.h" #include "api/environment/environment_factory.h" +#include "api/make_ref_counted.h" +#include "api/media_types.h" +#include "api/rtp_headers.h" +#include "api/rtp_parameters.h" #include "api/test/create_frame_generator.h" +#include "api/video/builtin_video_bitrate_allocator_factory.h" +#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_decoder_factory_template.h" #include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h" #include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h" #include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h" #include "api/video_codecs/video_encoder.h" -#include "api/video_codecs/video_encoder_factory.h" #include "api/video_codecs/video_encoder_factory_template.h" #include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h" #include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h" #include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h" +#include "call/call.h" +#include "call/call_config.h" +#include "call/video_send_stream.h" #include "media/base/media_constants.h" +#include "rtc_base/logging.h" #include "rtc_base/strings/json.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/thread.h" +#include "system_wrappers/include/clock.h" +#include "test/frame_generator_capturer.h" +#include "test/rtp_file_reader.h" +#include "test/rtp_file_writer.h" #include "test/testsupport/file_utils.h" -#include "video/config/encoder_stream_factory.h" #include "video/config/video_encoder_config.h" namespace webrtc { @@ -172,15 +192,15 @@ RtpGenerator::RtpGenerator(const RtpGeneratorOptions& options) : options_(options), env_(CreateEnvironment()), video_encoder_factory_( - std::make_unique>()), + std::make_unique< + VideoEncoderFactoryTemplate>()), video_decoder_factory_( - std::make_unique>()), + std::make_unique< + VideoDecoderFactoryTemplate>()), video_bitrate_allocator_factory_( CreateBuiltinVideoBitrateAllocatorFactory()), call_(Call::Create(CallConfig(env_))) { @@ -188,9 +208,9 @@ RtpGenerator::RtpGenerator(const RtpGeneratorOptions& options) constexpr int kMaxBitrateBps = 2500000; // 2.5 Mbps int stream_count = 0; - webrtc::VideoEncoder::EncoderInfo encoder_info; + VideoEncoder::EncoderInfo encoder_info; for (const auto& send_config : options.video_streams) { - webrtc::VideoSendStream::Config video_config(this); + VideoSendStream::Config video_config(this); video_config.encoder_settings.encoder_factory = video_encoder_factory_.get(); video_config.encoder_settings.bitrate_allocator_factory = @@ -248,9 +268,8 @@ RtpGenerator::RtpGenerator(const RtpGeneratorOptions& options) VideoSendStream* video_send_stream = call_->CreateVideoSendStream( std::move(video_config), std::move(encoder_config)); - video_send_stream->SetSource( - frame_generator.get(), - webrtc::DegradationPreference::MAINTAIN_FRAMERATE); + video_send_stream->SetSource(frame_generator.get(), + DegradationPreference::MAINTAIN_FRAMERATE); // Store these objects so we can destropy them at the end. frame_generators_.push_back(std::move(frame_generator)); video_send_streams_.push_back(video_send_stream); @@ -267,8 +286,7 @@ void RtpGenerator::GenerateRtpDump(const std::string& rtp_dump_path) { rtp_dump_writer_.reset(test::RtpFileWriter::Create( test::RtpFileWriter::kRtpDump, rtp_dump_path)); - call_->SignalChannelNetworkState(webrtc::MediaType::VIDEO, - webrtc::kNetworkUp); + call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); for (VideoSendStream* send_stream : video_send_streams_) { send_stream->Start(); } @@ -276,18 +294,18 @@ void RtpGenerator::GenerateRtpDump(const std::string& rtp_dump_path) { // Spinlock until all the durations end. WaitUntilAllVideoStreamsFinish(); - call_->SignalChannelNetworkState(webrtc::MediaType::VIDEO, - webrtc::kNetworkDown); + call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkDown); } bool RtpGenerator::SendRtp(ArrayView packet, - const webrtc::PacketOptions& options) { + const PacketOptions& /* options */) { test::RtpPacket rtp_packet = DataToRtpPacket(packet.data(), packet.size()); rtp_dump_writer_->WritePacket(&rtp_packet); return true; } -bool RtpGenerator::SendRtcp(ArrayView packet) { +bool RtpGenerator::SendRtcp(ArrayView packet, + const PacketOptions& /* options */) { test::RtpPacket rtcp_packet = DataToRtpPacket(packet.data(), packet.size()); rtp_dump_writer_->WritePacket(&rtcp_packet); return true; @@ -325,12 +343,12 @@ void RtpGenerator::WaitUntilAllVideoStreamsFinish() { test::RtpPacket RtpGenerator::DataToRtpPacket(const uint8_t* packet, size_t packet_len) { - webrtc::test::RtpPacket rtp_packet; + test::RtpPacket rtp_packet; memcpy(rtp_packet.data, packet, packet_len); rtp_packet.length = packet_len; rtp_packet.original_length = packet_len; rtp_packet.time_ms = - webrtc::Clock::GetRealTimeClock()->TimeInMilliseconds() - start_ms_; + Clock::GetRealTimeClock()->TimeInMilliseconds() - start_ms_; return rtp_packet; } diff --git a/rtc_tools/rtp_generator/rtp_generator.h b/rtc_tools/rtp_generator/rtp_generator.h index bb5f141f5a..cd7ad29848 100644 --- a/rtc_tools/rtp_generator/rtp_generator.h +++ b/rtc_tools/rtp_generator/rtp_generator.h @@ -11,14 +11,17 @@ #ifndef RTC_TOOLS_RTP_GENERATOR_RTP_GENERATOR_H_ #define RTC_TOOLS_RTP_GENERATOR_RTP_GENERATOR_H_ +#include +#include #include +#include #include #include +#include "api/array_view.h" #include "api/call/transport.h" #include "api/environment/environment.h" -#include "api/media_types.h" -#include "api/video/builtin_video_bitrate_allocator_factory.h" +#include "api/video/video_bitrate_allocator_factory.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" #include "call/call.h" @@ -28,7 +31,6 @@ #include "test/frame_generator_capturer.h" #include "test/rtp_file_reader.h" #include "test/rtp_file_writer.h" -#include "video/config/video_encoder_config.h" namespace webrtc { @@ -92,9 +94,10 @@ class RtpGenerator final : public webrtc::Transport { // Captured RTP packets are written to the RTPDump file instead of over the // network. bool SendRtp(ArrayView packet, - const webrtc::PacketOptions& options) override; + const PacketOptions& options) override; // RTCP packets are ignored for now. - bool SendRtcp(ArrayView packet) override; + bool SendRtcp(ArrayView packet, + const PacketOptions& options) override; // Returns the maximum duration int GetMaxDuration() const; // Waits until all video streams have finished. diff --git a/rtc_tools/video_encoder/video_encoder.cc b/rtc_tools/video_encoder/video_encoder.cc index 130308415d..b252162bcf 100644 --- a/rtc_tools/video_encoder/video_encoder.cc +++ b/rtc_tools/video_encoder/video_encoder.cc @@ -189,14 +189,14 @@ uint32_t GetDefaultTargetBitrate(const VideoCodecType codec, }; size_t codec_index = 0; switch (codec) { - case webrtc::kVideoCodecVP8: - case webrtc::kVideoCodecH264: + case kVideoCodecVP8: + case kVideoCodecH264: codec_index = 0; break; - case webrtc::kVideoCodecVP9: + case kVideoCodecVP9: codec_index = 1; break; - case webrtc::kVideoCodecAV1: + case kVideoCodecAV1: codec_index = 2; break; default: @@ -264,7 +264,7 @@ class BitstreamProcessor final : public EncodedImageCallback, } } - void ValidatePSNR(webrtc::VideoFrame& frame) { + void ValidatePSNR(VideoFrame& frame) { RTC_CHECK(validate_psnr_); video_decoder_->Decode(*encoded_image_, /*dont_care=*/0); double psnr = I420PSNR(*frame.video_frame_buffer()->ToI420(), @@ -494,10 +494,9 @@ class TestVideoEncoderFactoryWrapper final { RTC_CHECK(video_encoder); // Initialize video encoder. - const webrtc::VideoEncoder::Settings kSettings( - webrtc::VideoEncoder::Capabilities(false), - /*number_of_cores=*/1, - /*max_payload_size=*/0); + const VideoEncoder::Settings kSettings(VideoEncoder::Capabilities(false), + /*number_of_cores=*/1, + /*max_payload_size=*/0); int ret = video_encoder->InitEncode(&video_codec_setting, kSettings); RTC_CHECK_EQ(ret, WEBRTC_VIDEO_CODEC_OK); @@ -508,12 +507,12 @@ class TestVideoEncoderFactoryWrapper final { env, video_codec_setting); RTC_CHECK(bitrate_allocator); - webrtc::VideoBitrateAllocation allocation = + VideoBitrateAllocation allocation = bitrate_allocator->GetAllocation(bitrate_kbps * 1000, frame_rate_fps); RTC_LOG(LS_INFO) << allocation.ToString(); - video_encoder->SetRates(webrtc::VideoEncoder::RateControlParameters( - allocation, frame_rate_fps)); + video_encoder->SetRates( + VideoEncoder::RateControlParameters(allocation, frame_rate_fps)); return video_encoder; } diff --git a/rtc_tools/video_file_reader_unittest.cc b/rtc_tools/video_file_reader_unittest.cc index a357699d37..cd81dd1785 100644 --- a/rtc_tools/video_file_reader_unittest.cc +++ b/rtc_tools/video_file_reader_unittest.cc @@ -24,7 +24,7 @@ class Y4mFileReaderTest : public ::testing::Test { public: void SetUp() override { const std::string filename = - TempFilename(webrtc::test::OutputPath(), "test_video_file.y4m"); + TempFilename(test::OutputPath(), "test_video_file.y4m"); // Create simple test video of size 6x4. FILE* file = fopen(filename.c_str(), "wb"); @@ -45,11 +45,11 @@ class Y4mFileReaderTest : public ::testing::Test { fclose(file); // Open the newly created file. - video = webrtc::test::OpenY4mFile(filename); + video = test::OpenY4mFile(filename); ASSERT_TRUE(video); } - scoped_refptr video; + scoped_refptr video; }; TEST_F(Y4mFileReaderTest, TestParsingFileHeader) { @@ -77,7 +77,7 @@ class YuvFileReaderTest : public ::testing::Test { public: void SetUp() override { const std::string filename = - TempFilename(webrtc::test::OutputPath(), "test_video_file.yuv"); + TempFilename(test::OutputPath(), "test_video_file.yuv"); // Create simple test video of size 6x4. FILE* file = fopen(filename.c_str(), "wb"); @@ -95,11 +95,11 @@ class YuvFileReaderTest : public ::testing::Test { fclose(file); // Open the newly created file. - video = webrtc::test::OpenYuvFile(filename, 6, 4); + video = test::OpenYuvFile(filename, 6, 4); ASSERT_TRUE(video); } - scoped_refptr video; + scoped_refptr video; }; TEST_F(YuvFileReaderTest, TestParsingFileHeader) { diff --git a/rtc_tools/video_file_writer_unittest.cc b/rtc_tools/video_file_writer_unittest.cc index bcf10c0d54..7c8b65df8d 100644 --- a/rtc_tools/video_file_writer_unittest.cc +++ b/rtc_tools/video_file_writer_unittest.cc @@ -26,8 +26,7 @@ namespace test { class VideoFileWriterTest : public ::testing::Test { public: void SetUp() override { - video_filename_ = - TempFilename(webrtc::test::OutputPath(), "test_video_file.y4m"); + video_filename_ = TempFilename(test::OutputPath(), "test_video_file.y4m"); // Create simple test video of size 6x4. FILE* file = fopen(video_filename_.c_str(), "wb"); @@ -46,7 +45,7 @@ class VideoFileWriterTest : public ::testing::Test { fclose(file); // Open the newly created file. - video_ = webrtc::test::OpenY4mFile(video_filename_); + video_ = test::OpenY4mFile(video_filename_); ASSERT_TRUE(video_); ASSERT_EQ(video_->number_of_frames(), 2u); } @@ -68,9 +67,9 @@ class VideoFileWriterTest : public ::testing::Test { } // Create an unique filename, e.g. test_video_file2.y4mZapata. written_video_filename_ = - TempFilename(webrtc::test::OutputPath(), "test_video_file2.y4m"); - webrtc::test::WriteY4mVideoToFile(video_, written_video_filename_, fps); - written_video_ = webrtc::test::OpenY4mFile(written_video_filename_); + TempFilename(test::OutputPath(), "test_video_file2.y4m"); + test::WriteY4mVideoToFile(video_, written_video_filename_, fps); + written_video_ = test::OpenY4mFile(written_video_filename_); ASSERT_TRUE(written_video_); } @@ -82,18 +81,17 @@ class VideoFileWriterTest : public ::testing::Test { } // Create an unique filename, e.g. test_video_file2.yuvZapata. written_video_filename_ = - TempFilename(webrtc::test::OutputPath(), "test_video_file2.yuv"); - webrtc::test::WriteYuvVideoToFile(video_, written_video_filename_, fps); - written_video_ = - webrtc::test::OpenYuvFile(written_video_filename_, width, height); + TempFilename(test::OutputPath(), "test_video_file2.yuv"); + test::WriteYuvVideoToFile(video_, written_video_filename_, fps); + written_video_ = test::OpenYuvFile(written_video_filename_, width, height); ASSERT_TRUE(written_video_); } const int width = 6; const int height = 4; const int fps = 60; - scoped_refptr video_; - scoped_refptr written_video_; + scoped_refptr video_; + scoped_refptr written_video_; // Each video object must be backed by file! std::string video_filename_; std::string written_video_filename_; diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index 56a0e2187d..d281a8c316 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -60,7 +60,6 @@ #include "rtc_base/system/file_wrapper.h" #include "rtc_base/thread.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/sleep.h" #include "test/call_config_utils.h" #include "test/encoder_settings.h" #include "test/fake_decoder.h" @@ -703,7 +702,7 @@ class RtpReplayer final { if (time_sim_) { time_sim_->AdvanceTime(TimeDelta::Millis(duration_ms)); } else if (duration_ms > 0) { - SleepMs(duration_ms); + Thread::SleepMs(duration_ms); } } diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 97aa425022..61199255ae 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -9,6 +9,7 @@ import("//third_party/libaom/options.gni") import("../webrtc.gni") if (is_ios) { + import("//build/config/apple/mobile_config.gni") import("//build/config/ios/ios_sdk.gni") import("//build/config/ios/rules.gni") } @@ -167,11 +168,17 @@ if (is_ios || is_mac) { if (is_ios) { sources += [ - "objc/helpers/RTCCameraPreviewView.h", - "objc/helpers/RTCCameraPreviewView.m", "objc/helpers/UIDevice+RTCDevice.h", "objc/helpers/UIDevice+RTCDevice.mm", ] + + if (target_platform != "tvos") { + sources += [ + "objc/helpers/RTCCameraPreviewView.h", + "objc/helpers/RTCCameraPreviewView.m", + ] + } + frameworks += [ "UIKit.framework" ] } } @@ -224,6 +231,10 @@ if (is_ios || is_mac) { rtc_library("native_api_audio_device_module") { visibility = [ "*" ] + # TODO: bugs.webrtc.org/413413572 - Remove the poison when users of this + # api provide Environment explicitly. + allow_poison = [ "environment_construction" ] + sources = [ "objc/native/api/audio_device_module.h", "objc/native/api/audio_device_module.mm", @@ -233,7 +244,10 @@ if (is_ios || is_mac) { ":audio_device", ":audio_device_module_error_handler", "../api:make_ref_counted", + "../api:scoped_refptr", "../api/audio:audio_device", + "../api/environment", + "../api/environment:environment_factory", "../modules/audio_device:audio_device_generic", "../rtc_base:checks", "../rtc_base:logging", @@ -301,8 +315,8 @@ if (is_ios || is_mac) { "../api:scoped_refptr", "../api:sequence_checker", "../api/audio:audio_device", + "../api/environment", "../api/task_queue", - "../api/task_queue:default_task_queue_factory", "../api/task_queue:pending_task_safety_flag", "../modules/audio_device:audio_device_buffer", "../modules/audio_device:audio_device_config", @@ -314,7 +328,6 @@ if (is_ios || is_mac) { "../rtc_base:refcount", "../rtc_base:threading", "../rtc_base:timeutils", - "../system_wrappers:field_trial", "../system_wrappers:metrics", ] @@ -480,7 +493,6 @@ if (is_ios || is_mac) { rtc_library("audio_device_objc") { visibility = [ "*" ] - allow_poison = [ "environment_construction" ] sources = [ "objc/native/src/objc_audio_device.h", "objc/native/src/objc_audio_device.mm", @@ -496,8 +508,8 @@ if (is_ios || is_mac) { "../api:scoped_refptr", "../api:sequence_checker", "../api/audio:audio_device", + "../api/environment", "../api/task_queue", - "../api/task_queue:default_task_queue_factory", "../modules/audio_device:audio_device_buffer", "../rtc_base:buffer", "../rtc_base:checks", @@ -523,7 +535,6 @@ if (is_ios || is_mac) { rtc_library("objc_audio_device_module") { visibility = [ "*" ] - allow_poison = [ "environment_construction" ] sources = [ "objc/native/api/objc_audio_device_module.h", "objc/native/api/objc_audio_device_module.mm", @@ -533,7 +544,9 @@ if (is_ios || is_mac) { ":audio_device_api_objc", ":audio_device_objc", "../api:make_ref_counted", + "../api:scoped_refptr", "../api/audio:audio_device", + "../api/environment", "../rtc_base:logging", ] if (is_mac) { @@ -1098,6 +1111,7 @@ if (is_ios || is_mac) { "../api/audio_codecs:builtin_audio_encoder_factory", "../api/crypto:frame_decryptor_interface", "../api/crypto:frame_encryptor_interface", + "../api/environment:environment_factory", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue:default_task_queue_factory", "../api/transport:field_trial_based_config", @@ -1205,6 +1219,7 @@ if (is_ios || is_mac) { "../api/audio:audio_processing", "../api/audio_codecs:builtin_audio_decoder_factory", "../api/audio_codecs:builtin_audio_encoder_factory", + "../api/environment", "../api/environment:environment_factory", "../api/task_queue:default_task_queue_factory", "../api/video:video_frame", diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index 6d8992f8b4..9c9cd415db 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -117,6 +117,7 @@ if (is_android) { ":base_jni", ":builtin_audio_codecs_jni", ":default_video_codec_factory_jni", + ":environment_jni", ":java_audio_device_module_jni", ":peerconnection_jni", ":video_jni", @@ -182,6 +183,15 @@ if (is_android) { ] } + rtc_android_library("environment_java") { + visibility = [ "*" ] + sources = [ "api/org/webrtc/Environment.java" ] + deps = [ + ":generated_environment_jni_java", + "//third_party/androidx:androidx_annotation_annotation_java", + ] + } + rtc_android_library("audio_api_java") { visibility = [ "*" ] sources = [ @@ -330,6 +340,7 @@ if (is_android) { ":base_java", ":builtin_audio_codecs_java", ":default_video_codec_factory_java", + ":environment_java", ":generated_base_jni_java", ":generated_peerconnection_jni_java", @@ -609,13 +620,27 @@ if (current_os == "linux" || is_android) { "../../rtc_base:refcount", "../../rtc_base:stringutils", "../../rtc_base:threading", - "../../system_wrappers:field_trial", "../../system_wrappers:metrics", "//third_party/abseil-cpp/absl/strings:string_view", "//third_party/jni_zero", ] } + rtc_library("environment_jni") { + visibility = [ "*" ] + allow_poison = [ "environment_construction" ] + sources = [ "src/jni/environment.cc" ] + deps = [ + ":generated_environment_jni", + ":native_api_jni", + "../../api:field_trials", + "../../api:field_trials_view", + "../../api/environment", + "../../api/environment:environment_factory", + "//third_party/jni_zero", + ] + } + rtc_library("builtin_audio_codecs_jni") { visibility = [ "*" ] allow_poison = [ "audio_codecs" ] @@ -778,29 +803,39 @@ if (current_os == "linux" || is_android) { deps = [ ":base_jni", + ":environment_jni", ":generated_external_classes_jni", ":generated_external_classes_jni", ":generated_peerconnection_jni", ":generated_rtcerror_jni", + ":internal_jni", ":logging_jni", ":native_api_jni", ":native_api_stacktrace", "..:media_constraints", + "../../api:audio_options_api", "../../api:dtmf_sender_interface", "../../api:enable_media", + "../../api:fec_controller_api", "../../api:libjingle_peerconnection_api", "../../api:media_stream_interface", + "../../api:network_state_predictor_api", "../../api:rtc_event_log_output_file", "../../api:rtc_stats_api", "../../api:rtp_parameters", "../../api:rtp_sender_interface", + "../../api:scoped_refptr", "../../api:turn_customizer", "../../api/audio:audio_device", "../../api/audio:audio_processing", "../../api/audio:builtin_audio_processing_builder", + "../../api/audio_codecs:audio_codecs_api", "../../api/crypto:options", + "../../api/environment", + "../../api/neteq:neteq_api", "../../api/rtc_event_log:rtc_event_log_factory", "../../api/task_queue:default_task_queue_factory", + "../../api/transport:network_control", "../../api/video_codecs:video_codecs_api", "../../call:call_interfaces", "../../media:rtc_media_base", @@ -816,6 +851,7 @@ if (current_os == "linux" || is_android) { "../../rtc_base:refcount", "../../rtc_base:rtc_certificate_generator", "../../rtc_base:safe_conversions", + "../../rtc_base:socket_factory", "../../rtc_base:ssl", "../../rtc_base:stringutils", "../../rtc_base:threading", @@ -832,9 +868,12 @@ if (current_os == "linux" || is_android) { sources = [ "src/jni/audio_device/java_audio_device_module.cc" ] deps = [ - ":base_jni", + ":audio_device_module_base", ":generated_java_audio_jni", ":java_audio_device_module", + ":native_api_jni", + "../../api/audio:audio_device", + "../../api/environment", "//third_party/jni_zero", ] } @@ -1005,6 +1044,7 @@ if (current_os == "linux" || is_android) { ":opensles_audio_device_module", "../../api:scoped_refptr", "../../api/audio:audio_device", + "../../api/environment", "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:refcount", @@ -1192,10 +1232,11 @@ if (current_os == "linux" || is_android) { ":generated_audio_device_module_base_jni", ":native_api_jni", "../../api:make_ref_counted", + "../../api:scoped_refptr", "../../api:sequence_checker", "../../api/audio:audio_device", + "../../api/environment", "../../api/task_queue", - "../../api/task_queue:default_task_queue_factory", "../../modules/audio_device:audio_device_buffer", "../../rtc_base:checks", "../../rtc_base:logging", @@ -1216,15 +1257,17 @@ if (current_os == "linux" || is_android) { ":audio_device_module_base", ":base_jni", ":generated_java_audio_device_module_native_jni", + ":internal_jni", + ":native_api_jni", "../../api:sequence_checker", "../../api/audio:audio_device", + "../../api/environment", "../../modules/audio_device:audio_device_buffer", "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:platform_thread", "../../rtc_base:timeutils", - "../../system_wrappers:field_trial", "../../system_wrappers:metrics", "//third_party/jni_zero", ] @@ -1263,6 +1306,7 @@ if (current_os == "linux" || is_android) { rtc_library("opensles_audio_device_module") { visibility = [ "*" ] + sources = [ "src/jni/audio_device/opensles_common.cc", "src/jni/audio_device/opensles_common.h", @@ -1310,6 +1354,12 @@ if (current_os == "linux" || is_android) { jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } + generate_jni("generated_environment_jni") { + sources = [ "api/org/webrtc/Environment.java" ] + namespace = "webrtc::jni" + jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" + } + generate_jni("generated_metrics_jni") { sources = [ "api/org/webrtc/Metrics.java" ] namespace = "webrtc::jni" @@ -1671,6 +1721,7 @@ if (is_android) { ":video_jni", "../../api:enable_media_with_defaults", "../../api:field_trials_view", + "../../api:libjingle_peerconnection_api", "../../api:scoped_refptr", "../../api/audio:audio_device", "../../api/environment", @@ -1698,7 +1749,6 @@ if (is_android) { "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:inline", - "../../system_wrappers", "../../test:fileutils", "../../test:scoped_key_value_config", "../../test:test_support", diff --git a/sdk/android/api/org/webrtc/AudioProcessingFactory.java b/sdk/android/api/org/webrtc/AudioProcessingFactory.java index bd8fdb8989..e0aa25b87f 100644 --- a/sdk/android/api/org/webrtc/AudioProcessingFactory.java +++ b/sdk/android/api/org/webrtc/AudioProcessingFactory.java @@ -16,5 +16,14 @@ public interface AudioProcessingFactory { * Dynamically allocates a webrtc::AudioProcessing instance and returns a pointer to it. * The caller takes ownership of the object. */ - public long createNative(); + // TODO: bugs.webrtc.org/369904700 - Remove when implementations switch to + // another variant. + @Deprecated + public default long createNative() { + return 0; + } + + public default long createNative(long webrtcEnvRef) { + return createNative(); + } } diff --git a/sdk/android/api/org/webrtc/Environment.java b/sdk/android/api/org/webrtc/Environment.java new file mode 100644 index 0000000000..10749ec4e2 --- /dev/null +++ b/sdk/android/api/org/webrtc/Environment.java @@ -0,0 +1,54 @@ +/* + * 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. + */ + +package org.webrtc; + +import androidx.annotation.Nullable; + +/** Wrapper for the webrtc::Environment native class. */ +public final class Environment implements AutoCloseable { + private final long webrtcEnv; + + /** Builder for {@link Environment}. */ + public static class Builder { + public Builder setFieldTrials(String fieldTrials) { + this.fieldTrials = fieldTrials; + return this; + } + + public Environment build() { + return new Environment(this.fieldTrials); + } + + private @Nullable String fieldTrials; + } + + public static Builder builder() { + return new Builder(); + } + + /** Returns non-owning non-null native pointer to the webrtc::Environment */ + public long ref() { + return webrtcEnv; + } + + @Override + public void close() { + nativeFree(webrtcEnv); + } + + private Environment(@Nullable String fieldTrials) { + this.webrtcEnv = nativeCreate(fieldTrials); + } + + private static native long nativeCreate(@Nullable String fieldTrials); + + private static native void nativeFree(long webrtcEnv); +} diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java index 2b2ea155c1..7523dcadfb 100644 --- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java +++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java @@ -15,9 +15,6 @@ import androidx.annotation.Nullable; import java.util.List; import org.webrtc.Logging.Severity; -import org.webrtc.MediaStreamTrack; -import org.webrtc.PeerConnection; -import org.webrtc.RtpCapabilities; import org.webrtc.audio.AudioDeviceModule; import org.webrtc.audio.JavaAudioDeviceModule; @@ -166,6 +163,7 @@ boolean getDisableNetworkMonitor() { public static class Builder { @Nullable private Options options; + private Environment.Builder envBuilder = Environment.builder(); @Nullable private AudioDeviceModule audioDeviceModule; private AudioEncoderFactoryFactory audioEncoderFactoryFactory = new BuiltinAudioEncoderFactoryFactory(); @@ -186,6 +184,11 @@ public Builder setOptions(Options options) { return this; } + public Builder setFieldTrials(String fieldTrials) { + envBuilder.setFieldTrials(fieldTrials); + return this; + } + public Builder setAudioDeviceModule(AudioDeviceModule audioDeviceModule) { this.audioDeviceModule = audioDeviceModule; return this; @@ -261,24 +264,30 @@ public Builder setNetEqFactoryFactory(NetEqFactoryFactory neteqFactoryFactory) { public PeerConnectionFactory createPeerConnectionFactory() { checkInitializeHasBeenCalled(); - if (audioDeviceModule == null) { - audioDeviceModule = JavaAudioDeviceModule.builder(ContextUtils.getApplicationContext()) - .createAudioDeviceModule(); + try (Environment env = envBuilder.build()) { + if (audioDeviceModule == null) { + audioDeviceModule = JavaAudioDeviceModule.builder(ContextUtils.getApplicationContext()) + .createAudioDeviceModule(); + } + return nativeCreatePeerConnectionFactory( + ContextUtils.getApplicationContext(), + options, + env.ref(), + audioDeviceModule.getNative(env.ref()), + audioEncoderFactoryFactory.createNativeAudioEncoderFactory(), + audioDecoderFactoryFactory.createNativeAudioDecoderFactory(), + videoEncoderFactory, + videoDecoderFactory, + audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(env.ref()), + fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative(), + networkControllerFactoryFactory == null + ? 0 + : networkControllerFactoryFactory.createNativeNetworkControllerFactory(), + networkStatePredictorFactoryFactory == null + ? 0 + : networkStatePredictorFactoryFactory.createNativeNetworkStatePredictorFactory(), + neteqFactoryFactory == null ? 0 : neteqFactoryFactory.createNativeNetEqFactory()); } - return nativeCreatePeerConnectionFactory(ContextUtils.getApplicationContext(), options, - audioDeviceModule.getNativeAudioDeviceModulePointer(), - audioEncoderFactoryFactory.createNativeAudioEncoderFactory(), - audioDecoderFactoryFactory.createNativeAudioDecoderFactory(), videoEncoderFactory, - videoDecoderFactory, - audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(), - fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative(), - networkControllerFactoryFactory == null - ? 0 - : networkControllerFactoryFactory.createNativeNetworkControllerFactory(), - networkStatePredictorFactoryFactory == null - ? 0 - : networkStatePredictorFactoryFactory.createNativeNetworkStatePredictorFactory(), - neteqFactoryFactory == null ? 0 : neteqFactoryFactory.createNativeNetEqFactory()); } } @@ -338,16 +347,6 @@ public static void initializeFieldTrials(String fieldTrialsInitString) { nativeInitializeFieldTrials(fieldTrialsInitString); } - // Wrapper of webrtc::field_trial::FindFullName. Develop the feature with default behaviour off. - // Example usage: - // if (PeerConnectionFactory.fieldTrialsFindFullName("WebRTCExperiment").equals("Enabled")) { - // method1(); - // } else { - // method2(); - // } - public static String fieldTrialsFindFullName(String name) { - return NativeLibrary.isLoaded() ? nativeFindFieldTrialsFullName(name) : ""; - } // Start/stop internal capturing of internal tracing. public static boolean startInternalTracingCapture(String tracingFilename) { return nativeStartInternalTracingCapture(tracingFilename); @@ -595,7 +594,6 @@ private void onSignalingThreadReady() { // (for example, at application startup time). private static native void nativeInitializeAndroidGlobals(); private static native void nativeInitializeFieldTrials(String fieldTrialsInitString); - private static native String nativeFindFieldTrialsFullName(String name); private static native void nativeInitializeInternalTracer(); // Internal tracing shutdown, called to prevent resource leaks. Must be called after // PeerConnectionFactory is gone to prevent races with code performing tracing. @@ -604,7 +602,7 @@ private void onSignalingThreadReady() { private static native void nativeStopInternalTracingCapture(); private static native PeerConnectionFactory nativeCreatePeerConnectionFactory(Context context, - Options options, long nativeAudioDeviceModule, long audioEncoderFactory, + Options options, long webrtcEnvRef, long nativeAudioDeviceModule, long audioEncoderFactory, long audioDecoderFactory, VideoEncoderFactory encoderFactory, VideoDecoderFactory decoderFactory, long nativeAudioProcessor, long nativeFecControllerFactory, long nativeNetworkControllerFactory, diff --git a/sdk/android/api/org/webrtc/audio/AudioDeviceModule.java b/sdk/android/api/org/webrtc/audio/AudioDeviceModule.java index 5a0bf5c74d..ba5097d6c8 100644 --- a/sdk/android/api/org/webrtc/audio/AudioDeviceModule.java +++ b/sdk/android/api/org/webrtc/audio/AudioDeviceModule.java @@ -22,7 +22,14 @@ public interface AudioDeviceModule { * Returns a C++ pointer to a webrtc::AudioDeviceModule. Caller does _not_ take ownership and * lifetime is handled through the release() call. */ - long getNativeAudioDeviceModulePointer(); + @Deprecated + default long getNativeAudioDeviceModulePointer() { + return 0; + } + + public default long getNative(long webrtcEnvRef) { + return getNativeAudioDeviceModulePointer(); + } /** * Release resources for this AudioDeviceModule, including native resources. The object should not diff --git a/sdk/android/api/org/webrtc/audio/JavaAudioDeviceModule.java b/sdk/android/api/org/webrtc/audio/JavaAudioDeviceModule.java index 8e38c1f34f..bbf1c3a753 100644 --- a/sdk/android/api/org/webrtc/audio/JavaAudioDeviceModule.java +++ b/sdk/android/api/org/webrtc/audio/JavaAudioDeviceModule.java @@ -386,11 +386,12 @@ private JavaAudioDeviceModule(Context context, AudioManager audioManager, } @Override - public long getNativeAudioDeviceModulePointer() { + public long getNative(long webrtcEnvRef) { synchronized (nativeLock) { if (nativeAudioDeviceModule == 0) { nativeAudioDeviceModule = nativeCreateAudioDeviceModule(context, audioManager, audioInput, - audioOutput, inputSampleRate, outputSampleRate, useStereoInput, useStereoOutput); + audioOutput, webrtcEnvRef, inputSampleRate, outputSampleRate, useStereoInput, + useStereoOutput); } return nativeAudioDeviceModule; } @@ -438,5 +439,6 @@ public void setPreferredInputDevice(AudioDeviceInfo preferredInputDevice) { private static native long nativeCreateAudioDeviceModule(Context context, AudioManager audioManager, WebRtcAudioRecord audioInput, WebRtcAudioTrack audioOutput, - int inputSampleRate, int outputSampleRate, boolean useStereoInput, boolean useStereoOutput); + long webrtcEnvRef, int inputSampleRate, int outputSampleRate, boolean useStereoInput, + boolean useStereoOutput); } diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java index 5ec5aae2e3..33807af2f4 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java @@ -169,6 +169,11 @@ public synchronized void expectSignalingChange(SignalingState newState) { // TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression. @SuppressWarnings("NoSynchronizedMethodCheck") public synchronized void onSignalingChange(SignalingState newState) { + if (expectedSignalingChanges.isEmpty()) { + Logging.d(TAG, name + "Got an unexpected signaling state change " + newState); + return; + } + assertEquals(newState, expectedSignalingChanges.remove()); } @@ -261,6 +266,7 @@ public synchronized void onIceGatheringChange(IceGatheringState newState) { } if (expectedIceGatheringChanges.isEmpty()) { Logging.d(TAG, name + "Got an unexpected ICE gathering change " + newState); + return; } assertEquals(newState, expectedIceGatheringChanges.remove()); } @@ -1123,6 +1129,99 @@ public void testDataChannelOnlySession() throws Exception { System.gc(); } + @Test + @MediumTest + public void testSurfaceIceCandidatesBeforeIceGatheringStateComplete() throws Exception { + // Allow loopback interfaces too since our Android devices often don't + // have those. + PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); + options.networkIgnoreMask = 0; + PeerConnectionFactory factory = + PeerConnectionFactory.builder().setOptions(options).createPeerConnectionFactory(); + + List iceServers = new ArrayList<>(); + iceServers.add( + PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer()); + + PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers); + rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN; + + ObserverExpectations offeringExpectations = new ObserverExpectations("PCTest:offerer"); + PeerConnection offeringPC = factory.createPeerConnection(rtcConfig, offeringExpectations); + assertNotNull(offeringPC); + + offeringExpectations.expectRenegotiationNeeded(); + DataChannel offeringDC = offeringPC.createDataChannel("offeringDC", new DataChannel.Init()); + + offeringExpectations.expectIceCandidates(2); + + SdpObserverLatch sdpLatch = new SdpObserverLatch(); + offeringPC.createOffer(sdpLatch, new MediaConstraints()); + assertTrue(sdpLatch.await()); + SessionDescription offerSdp = sdpLatch.getSdp(); + + sdpLatch = new SdpObserverLatch(); + offeringPC.setLocalDescription(sdpLatch, offerSdp); + + assertTrue(offeringExpectations.waitForAllExpectationsToBeSatisfied(DEFAULT_TIMEOUT_SECONDS)); + assertEquals(IceGatheringState.GATHERING, offeringPC.iceGatheringState()); + + ObserverExpectations answeringExpectations = new ObserverExpectations("PCTest:answerer"); + PeerConnection answeringPC = factory.createPeerConnection(rtcConfig, answeringExpectations); + assertNotNull(answeringPC); + + sdpLatch = new SdpObserverLatch(); + answeringPC.setRemoteDescription(sdpLatch, offerSdp); + assertTrue(sdpLatch.await()); + + sdpLatch = new SdpObserverLatch(); + answeringPC.createAnswer(sdpLatch, new MediaConstraints()); + assertTrue(sdpLatch.await()); + SessionDescription answerSdp = sdpLatch.getSdp(); + + answeringExpectations.expectIceCandidates(2); + + sdpLatch = new SdpObserverLatch(); + answeringPC.setLocalDescription(sdpLatch, answerSdp); + assertTrue(sdpLatch.await()); + + assertTrue(answeringExpectations.waitForAllExpectationsToBeSatisfied(DEFAULT_TIMEOUT_SECONDS)); + assertEquals(IceGatheringState.GATHERING, answeringPC.iceGatheringState()); + + sdpLatch = new SdpObserverLatch(); + offeringPC.setRemoteDescription(sdpLatch, answerSdp); + assertTrue(sdpLatch.await()); + + assertTrue(offeringExpectations.waitForAllExpectationsToBeSatisfied(DEFAULT_TIMEOUT_SECONDS)); + assertEquals(IceGatheringState.GATHERING, offeringPC.iceGatheringState()); + + // SCTP DataChannels are announced via OPEN messages over the established + // connection (not via SDP), so answeringExpectations can only register + // expecting the channel during ICE. + answeringExpectations.expectDataChannel("offeringDC"); + answeringExpectations.expectStateChange(DataChannel.State.OPEN); + + offeringExpectations.expectIceGatheringChange(IceGatheringState.COMPLETE); + answeringExpectations.expectIceGatheringChange(IceGatheringState.COMPLETE); + + // Wait for at least one ice candidate from the offering PC and forward them to + // the answering PC. + for (IceCandidate candidate : offeringExpectations.getAtLeastOneIceCandidate()) { + answeringPC.addIceCandidate(candidate); + } + // Wait for at least one ice candidate from the answering PC and forward them to + // the offering PC. + for (IceCandidate candidate : answeringExpectations.getAtLeastOneIceCandidate()) { + offeringPC.addIceCandidate(candidate); + } + + assertTrue(offeringExpectations.waitForAllExpectationsToBeSatisfied(DEFAULT_TIMEOUT_SECONDS)); + assertTrue(answeringExpectations.waitForAllExpectationsToBeSatisfied(DEFAULT_TIMEOUT_SECONDS)); + + assertEquals(IceGatheringState.COMPLETE, offeringPC.iceGatheringState()); + assertEquals(IceGatheringState.COMPLETE, answeringPC.iceGatheringState()); + } + // Tests that ICE candidates that are not allowed by an ICE transport type, thus not being // signaled to the gathering PeerConnection, can be surfaced via configuration if allowed by the // new ICE transport type, when RTCConfiguration.surfaceIceCandidatesOnIceTransportTypeChanged is diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java index a28b9c25ff..1e36fef760 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java @@ -62,4 +62,31 @@ public void testInitializeWithTracerAndShutdown() { .createInitializationOptions()); PeerConnectionFactory.shutdownInternalTracer(); } + + // Tests that the JNI glue between Java and C++ does not crash when creating a + // PeerConnectionFactory. + @Test + @SmallTest + public void testCreation() throws Exception { + PeerConnectionFactory.initialize( + PeerConnectionFactory.InitializationOptions.builder( + InstrumentationRegistry.getTargetContext()) + .setNativeLibraryName(TestConstants.NATIVE_LIBRARY) + .createInitializationOptions()); + + PeerConnectionFactory factory = PeerConnectionFactory.builder().createPeerConnectionFactory(); + } + + @Test + @SmallTest + public void testCreationWithFieldTrials() throws Exception { + PeerConnectionFactory.initialize( + PeerConnectionFactory.InitializationOptions.builder( + InstrumentationRegistry.getTargetContext()) + .setNativeLibraryName(TestConstants.NATIVE_LIBRARY) + .createInitializationOptions()); + + PeerConnectionFactory factory = + PeerConnectionFactory.builder().setFieldTrials("").createPeerConnectionFactory(); + } } diff --git a/sdk/android/native_api/audio_device_module/audio_device_android.cc b/sdk/android/native_api/audio_device_module/audio_device_android.cc index 2ee8b74d41..06a66df61c 100644 --- a/sdk/android/native_api/audio_device_module/audio_device_android.cc +++ b/sdk/android/native_api/audio_device_module/audio_device_android.cc @@ -15,6 +15,7 @@ #include #include +#include "api/environment/environment.h" #include "api/scoped_refptr.h" #include "rtc_base/logging.h" #include "rtc_base/ref_count.h" @@ -56,8 +57,9 @@ void GetDefaultAudioParameters(JNIEnv* env, } // namespace #if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO) -webrtc::scoped_refptr CreateAAudioAudioDeviceModule( +scoped_refptr CreateAAudioAudioDeviceModule( JNIEnv* env, + const Environment& webrtc_env, jobject application_context) { RTC_DLOG(LS_INFO) << __FUNCTION__; // Get default audio input/output parameters. @@ -67,15 +69,17 @@ webrtc::scoped_refptr CreateAAudioAudioDeviceModule( &output_parameters); // Create ADM from AAudioRecorder and AAudioPlayer. return CreateAudioDeviceModuleFromInputAndOutput( - AudioDeviceModule::kAndroidAAudioAudio, false /* use_stereo_input */, - false /* use_stereo_output */, + webrtc_env, AudioDeviceModule::kAndroidAAudioAudio, + /*is_stereo_playout_supported=*/false, + /*is_stereo_record_supported=*/false, jni::kLowLatencyModeDelayEstimateInMilliseconds, std::make_unique(input_parameters), std::make_unique(output_parameters)); } -webrtc::scoped_refptr +scoped_refptr CreateJavaInputAndAAudioOutputAudioDeviceModule(JNIEnv* env, + const Environment& webrtc_env, jobject application_context) { RTC_DLOG(LS_INFO) << __FUNCTION__; // Get default audio input/output parameters. @@ -93,15 +97,17 @@ CreateJavaInputAndAAudioOutputAudioDeviceModule(JNIEnv* env, j_audio_manager)); return CreateAudioDeviceModuleFromInputAndOutput( - AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio, - false /* use_stereo_input */, false /* use_stereo_output */, + webrtc_env, AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio, + /*is_stereo_playout_supported=*/false, + /*is_stereo_record_supported=*/false, jni::kLowLatencyModeDelayEstimateInMilliseconds, std::move(audio_input), std::make_unique(output_parameters)); } #endif -webrtc::scoped_refptr CreateJavaAudioDeviceModule( +scoped_refptr CreateJavaAudioDeviceModule( JNIEnv* env, + const Environment& webrtc_env, jobject application_context) { RTC_DLOG(LS_INFO) << __FUNCTION__; // Get default audio input/output parameters. @@ -118,18 +124,20 @@ webrtc::scoped_refptr CreateJavaAudioDeviceModule( jni::AudioRecordJni::CreateJavaWebRtcAudioRecord(env, j_context, j_audio_manager)); auto audio_output = std::make_unique( - env, output_parameters, + env, webrtc_env, output_parameters, jni::AudioTrackJni::CreateJavaWebRtcAudioTrack(env, j_context, j_audio_manager)); return CreateAudioDeviceModuleFromInputAndOutput( - AudioDeviceModule::kAndroidJavaAudio, false /* use_stereo_input */, - false /* use_stereo_output */, + webrtc_env, AudioDeviceModule::kAndroidJavaAudio, + /*is_stereo_playout_supported=*/false, + /*is_stereo_record_supported=*/false, jni::kHighLatencyModeDelayEstimateInMilliseconds, std::move(audio_input), std::move(audio_output)); } -webrtc::scoped_refptr CreateOpenSLESAudioDeviceModule( +scoped_refptr CreateOpenSLESAudioDeviceModule( JNIEnv* env, + const Environment& webrtc_env, jobject application_context) { RTC_DLOG(LS_INFO) << __FUNCTION__; // Get default audio input/output parameters. @@ -138,21 +146,23 @@ webrtc::scoped_refptr CreateOpenSLESAudioDeviceModule( GetDefaultAudioParameters(env, application_context, &input_parameters, &output_parameters); // Create ADM from OpenSLESRecorder and OpenSLESPlayer. - webrtc::scoped_refptr engine_manager( + scoped_refptr engine_manager( new jni::OpenSLEngineManager()); auto audio_input = std::make_unique(input_parameters, engine_manager); auto audio_output = std::make_unique( output_parameters, std::move(engine_manager)); return CreateAudioDeviceModuleFromInputAndOutput( - AudioDeviceModule::kAndroidOpenSLESAudio, false /* use_stereo_input */, - false /* use_stereo_output */, + webrtc_env, AudioDeviceModule::kAndroidOpenSLESAudio, + /*is_stereo_playout_supported=*/false, + /*is_stereo_record_supported=*/false, jni::kLowLatencyModeDelayEstimateInMilliseconds, std::move(audio_input), std::move(audio_output)); } -webrtc::scoped_refptr +scoped_refptr CreateJavaInputAndOpenSLESOutputAudioDeviceModule(JNIEnv* env, + const Environment& webrtc_env, jobject application_context) { RTC_DLOG(LS_INFO) << __FUNCTION__; // Get default audio input/output parameters. @@ -169,21 +179,23 @@ CreateJavaInputAndOpenSLESOutputAudioDeviceModule(JNIEnv* env, jni::AudioRecordJni::CreateJavaWebRtcAudioRecord(env, j_context, j_audio_manager)); - webrtc::scoped_refptr engine_manager( + scoped_refptr engine_manager( new jni::OpenSLEngineManager()); auto audio_output = std::make_unique( output_parameters, std::move(engine_manager)); return CreateAudioDeviceModuleFromInputAndOutput( - AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio, - false /* use_stereo_input */, false /* use_stereo_output */, + webrtc_env, AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio, + /*is_stereo_playout_supported=*/false, + /*is_stereo_record_supported=*/false, jni::kLowLatencyModeDelayEstimateInMilliseconds, std::move(audio_input), std::move(audio_output)); } -webrtc::scoped_refptr CreateAndroidAudioDeviceModule( +scoped_refptr CreateAndroidAudioDeviceModule( + const Environment& webrtc_env, AudioDeviceModule::AudioLayer audio_layer) { auto env = AttachCurrentThreadIfNeeded(); - auto j_context = webrtc::GetAppContext(env); + auto j_context = GetAppContext(env); // Select best possible combination of audio layers. if (audio_layer == AudioDeviceModule::kPlatformDefaultAudio) { #if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO) @@ -209,23 +221,23 @@ webrtc::scoped_refptr CreateAndroidAudioDeviceModule( switch (audio_layer) { case AudioDeviceModule::kAndroidJavaAudio: // Java audio for both input and output audio. - return CreateJavaAudioDeviceModule(env, j_context.obj()); + return CreateJavaAudioDeviceModule(env, webrtc_env, j_context.obj()); case AudioDeviceModule::kAndroidOpenSLESAudio: // OpenSL ES based audio for both input and output audio. - return CreateOpenSLESAudioDeviceModule(env, j_context.obj()); + return CreateOpenSLESAudioDeviceModule(env, webrtc_env, j_context.obj()); case AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio: // Java audio for input and OpenSL ES for output audio (i.e. mixed APIs). // This combination provides low-latency output audio and at the same // time support for HW AEC using the AudioRecord Java API. - return CreateJavaInputAndOpenSLESOutputAudioDeviceModule(env, + return CreateJavaInputAndOpenSLESOutputAudioDeviceModule(env, webrtc_env, j_context.obj()); #if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO) case AudioDeviceModule::kAndroidAAudioAudio: // AAudio based audio for both input and output. - return CreateAAudioAudioDeviceModule(env, j_context.obj()); + return CreateAAudioAudioDeviceModule(env, webrtc_env, j_context.obj()); case AudioDeviceModule::kAndroidJavaInputAndAAudioOutputAudio: // Java audio for input and AAudio for output audio (i.e. mixed APIs). - return CreateJavaInputAndAAudioOutputAudioDeviceModule(env, + return CreateJavaInputAndAAudioOutputAudioDeviceModule(env, webrtc_env, j_context.obj()); #endif default: diff --git a/sdk/android/native_api/audio_device_module/audio_device_android.h b/sdk/android/native_api/audio_device_module/audio_device_android.h index 4bfd7e850c..5cf4e51014 100644 --- a/sdk/android/native_api/audio_device_module/audio_device_android.h +++ b/sdk/android/native_api/audio_device_module/audio_device_android.h @@ -14,32 +14,18 @@ #include #include "api/audio/audio_device.h" +#include "api/environment/environment.h" +#include "api/scoped_refptr.h" namespace webrtc { -#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO) -webrtc::scoped_refptr CreateAAudioAudioDeviceModule( +scoped_refptr CreateJavaAudioDeviceModule( JNIEnv* env, + const Environment& webrtc_env, jobject application_context); -#endif -webrtc::scoped_refptr CreateJavaAudioDeviceModule( - JNIEnv* env, - jobject application_context); - -webrtc::scoped_refptr CreateOpenSLESAudioDeviceModule( - JNIEnv* env, - jobject application_context); - -webrtc::scoped_refptr -CreateJavaInputAndOpenSLESOutputAudioDeviceModule(JNIEnv* env, - jobject application_context); - -webrtc::scoped_refptr -CreateJavaInputAndAAudioOutputAudioDeviceModule(JNIEnv* env, - jobject application_context); - -webrtc::scoped_refptr CreateAndroidAudioDeviceModule( +scoped_refptr CreateAndroidAudioDeviceModule( + const Environment& webrtc_env, AudioDeviceModule::AudioLayer audio_layer); } // namespace webrtc diff --git a/sdk/android/native_api/peerconnection/peer_connection_factory.cc b/sdk/android/native_api/peerconnection/peer_connection_factory.cc index ca87f809d2..c2208a06be 100644 --- a/sdk/android/native_api/peerconnection/peer_connection_factory.cc +++ b/sdk/android/native_api/peerconnection/peer_connection_factory.cc @@ -20,12 +20,12 @@ namespace webrtc { jobject NativeToJavaPeerConnectionFactory( JNIEnv* jni, - scoped_refptr pcf, + scoped_refptr pcf, std::unique_ptr socket_factory, std::unique_ptr network_thread, std::unique_ptr worker_thread, std::unique_ptr signaling_thread) { - return webrtc::jni::NativeToJavaPeerConnectionFactory( + return jni::NativeToJavaPeerConnectionFactory( jni, pcf, std::move(socket_factory), std::move(network_thread), std::move(worker_thread), std::move(signaling_thread)); } diff --git a/sdk/android/native_api/video/video_source.cc b/sdk/android/native_api/video/video_source.cc index ba2d486aef..2ca8ddcded 100644 --- a/sdk/android/native_api/video/video_source.cc +++ b/sdk/android/native_api/video/video_source.cc @@ -92,9 +92,9 @@ class JavaVideoTrackSourceImpl : public JavaVideoTrackSourceInterface { bool SupportsEncodedOutput() const override { return false; } void GenerateKeyFrame() override {} void AddEncodedSink( - VideoSinkInterface* sink) override {} + VideoSinkInterface* sink) override {} void RemoveEncodedSink( - VideoSinkInterface* sink) override {} + VideoSinkInterface* sink) override {} scoped_refptr android_video_track_source_; ScopedJavaGlobalRef native_capturer_observer_; diff --git a/sdk/android/native_unittests/audio_device/audio_device_unittest.cc b/sdk/android/native_unittests/audio_device/audio_device_unittest.cc index 878f8ae5d3..e8e5ad7c6b 100644 --- a/sdk/android/native_unittests/audio_device/audio_device_unittest.cc +++ b/sdk/android/native_unittests/audio_device/audio_device_unittest.cc @@ -14,6 +14,8 @@ #include #include +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/scoped_refptr.h" #include "modules/audio_device/include/mock_audio_transport.h" #include "rtc_base/arraysize.h" @@ -467,7 +469,8 @@ class AudioDeviceTest : public ::testing::Test { // Creates an audio device using a default audio layer. jni_ = AttachCurrentThreadIfNeeded(); context_ = GetAppContext(jni_); - audio_device_ = CreateJavaAudioDeviceModule(jni_, context_.obj()); + audio_device_ = + CreateJavaAudioDeviceModule(jni_, webrtc_env_, context_.obj()); EXPECT_NE(audio_device_.get(), nullptr); EXPECT_EQ(0, audio_device_->Init()); audio_manager_ = GetAudioManager(jni_, context_); @@ -491,7 +494,7 @@ class AudioDeviceTest : public ::testing::Test { } void SetActiveAudioLayer(AudioDeviceModule::AudioLayer audio_layer) { - audio_device_ = CreateAndroidAudioDeviceModule(audio_layer); + audio_device_ = CreateAndroidAudioDeviceModule(webrtc_env_, audio_layer); EXPECT_NE(audio_device_.get(), nullptr); EXPECT_EQ(0, audio_device_->Init()); UpdateParameters(); @@ -542,7 +545,7 @@ class AudioDeviceTest : public ::testing::Test { int TestDelayOnAudioLayer( const AudioDeviceModule::AudioLayer& layer_to_test) { webrtc::scoped_refptr audio_device; - audio_device = CreateAndroidAudioDeviceModule(layer_to_test); + audio_device = CreateAndroidAudioDeviceModule(webrtc_env_, layer_to_test); EXPECT_NE(audio_device.get(), nullptr); uint16_t playout_delay; EXPECT_EQ(0, audio_device->PlayoutDelay(&playout_delay)); @@ -552,7 +555,7 @@ class AudioDeviceTest : public ::testing::Test { AudioDeviceModule::AudioLayer TestActiveAudioLayer( const AudioDeviceModule::AudioLayer& layer_to_test) { webrtc::scoped_refptr audio_device; - audio_device = CreateAndroidAudioDeviceModule(layer_to_test); + audio_device = CreateAndroidAudioDeviceModule(webrtc_env_, layer_to_test); EXPECT_NE(audio_device.get(), nullptr); AudioDeviceModule::AudioLayer active; EXPECT_EQ(0, audio_device->ActiveAudioLayer(&active)); @@ -667,6 +670,7 @@ class AudioDeviceTest : public ::testing::Test { } JNIEnv* jni_; + const Environment webrtc_env_ = CreateEnvironment(); ScopedJavaLocalRef context_; webrtc::Event test_is_done_; webrtc::scoped_refptr audio_device_; @@ -1157,19 +1161,20 @@ TEST_F(AudioDeviceTest, DISABLED_MeasureLoopbackLatency) { // TODO(https://crbug.com/webrtc/15537): test randomly fails. TEST(JavaAudioDeviceTest, DISABLED_TestRunningTwoAdmsSimultaneously) { JNIEnv* jni = AttachCurrentThreadIfNeeded(); + const Environment webrtc_env = CreateEnvironment(); ScopedJavaLocalRef context = GetAppContext(jni); // Create and start the first ADM. - webrtc::scoped_refptr adm_1 = - CreateJavaAudioDeviceModule(jni, context.obj()); + scoped_refptr adm_1 = + CreateJavaAudioDeviceModule(jni, webrtc_env, context.obj()); EXPECT_EQ(0, adm_1->Init()); EXPECT_EQ(0, adm_1->InitRecording()); EXPECT_EQ(0, adm_1->StartRecording()); // Create and start a second ADM. Expect this to fail due to the microphone // already being in use. - webrtc::scoped_refptr adm_2 = - CreateJavaAudioDeviceModule(jni, context.obj()); + scoped_refptr adm_2 = + CreateJavaAudioDeviceModule(jni, webrtc_env, context.obj()); int32_t err = adm_2->Init(); err |= adm_2->InitRecording(); err |= adm_2->StartRecording(); diff --git a/sdk/android/native_unittests/peerconnection/peer_connection_factory_unittest.cc b/sdk/android/native_unittests/peerconnection/peer_connection_factory_unittest.cc index 110fbb1b17..f5d8470ddb 100644 --- a/sdk/android/native_unittests/peerconnection/peer_connection_factory_unittest.cc +++ b/sdk/android/native_unittests/peerconnection/peer_connection_factory_unittest.cc @@ -9,15 +9,20 @@ */ #include "sdk/android/native_api/peerconnection/peer_connection_factory.h" +#include + +#include #include +#include #include "api/enable_media_with_defaults.h" +#include "api/environment/environment_factory.h" +#include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/task_queue/default_task_queue_factory.h" -#include "media/base/media_engine.h" +#include "api/scoped_refptr.h" #include "media/engine/internal_decoder_factory.h" #include "media/engine/internal_encoder_factory.h" -#include "media/engine/webrtc_media_engine.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/physical_socket_server.h" #include "rtc_base/thread.h" @@ -25,7 +30,6 @@ #include "sdk/android/native_api/audio_device_module/audio_device_android.h" #include "sdk/android/native_api/jni/application_context_provider.h" #include "sdk/android/native_api/jni/jvm.h" -#include "sdk/android/src/jni/jni_helpers.h" #include "test/gtest.h" namespace webrtc { @@ -49,10 +53,11 @@ webrtc::scoped_refptr CreateTestPCF( pcf_deps.network_thread = network_thread; pcf_deps.worker_thread = worker_thread; pcf_deps.signaling_thread = signaling_thread; - pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); pcf_deps.event_log_factory = std::make_unique(); + pcf_deps.env = CreateEnvironment(); - pcf_deps.adm = CreateJavaAudioDeviceModule(jni, GetAppContext(jni).obj()); + pcf_deps.adm = + CreateJavaAudioDeviceModule(jni, *pcf_deps.env, GetAppContext(jni).obj()); pcf_deps.video_encoder_factory = std::make_unique(); pcf_deps.video_decoder_factory = diff --git a/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc b/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc index 0d81cd6918..1ecd2d6dff 100644 --- a/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc +++ b/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc @@ -24,7 +24,7 @@ #include "rtc_base/strings/string_builder.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/inline.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" #include "test/gtest.h" namespace webrtc { @@ -176,7 +176,7 @@ void TestStacktrace(std::unique_ptr deadlock_impl) { // Wait until the thread has entered the deadlock region, and take a very // brief nap to give it time to reach the actual deadlock. params.deadlock_start_event.Wait(); - SleepMs(1); + Thread::SleepMs(1); // Acquire the stack trace of the thread which should now be deadlocking. std::vector stack_trace = GetStackTrace(params.tid); diff --git a/sdk/android/src/jni/android_network_monitor.cc b/sdk/android/src/jni/android_network_monitor.cc index f2f14b3b18..f8dc19eaec 100644 --- a/sdk/android/src/jni/android_network_monitor.cc +++ b/sdk/android/src/jni/android_network_monitor.cc @@ -478,11 +478,11 @@ std::optional AndroidNetworkMonitor::FindNetworkHandleFromIfname( } if (bind_using_ifname_) { - for (auto const& iter : network_handle_by_if_name_) { + for (auto const& c_iter : network_handle_by_if_name_) { // Use substring match so that e.g if_name="v4-wlan0" is matched // agains iter="wlan0" - if (if_name.find(iter.first) != absl::string_view::npos) { - return std::make_optional(iter.second); + if (if_name.find(c_iter.first) != absl::string_view::npos) { + return std::make_optional(c_iter.second); } } } diff --git a/sdk/android/src/jni/audio_device/audio_device_module.cc b/sdk/android/src/jni/audio_device/audio_device_module.cc index 4d64e5ff35..4331db2112 100644 --- a/sdk/android/src/jni/audio_device/audio_device_module.cc +++ b/sdk/android/src/jni/audio_device/audio_device_module.cc @@ -13,10 +13,9 @@ #include #include +#include "api/environment/environment.h" #include "api/make_ref_counted.h" #include "api/sequence_checker.h" -#include "api/task_queue/default_task_queue_factory.h" -#include "api/task_queue/task_queue_factory.h" #include "modules/audio_device/audio_device_buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -54,17 +53,18 @@ class AndroidAudioDeviceModule : public AudioDeviceModule { NUM_STATUSES = 4 }; - AndroidAudioDeviceModule(AudioDeviceModule::AudioLayer audio_layer, + AndroidAudioDeviceModule(const Environment& env, + AudioDeviceModule::AudioLayer audio_layer, bool is_stereo_playout_supported, bool is_stereo_record_supported, uint16_t playout_delay_ms, std::unique_ptr audio_input, std::unique_ptr audio_output) - : audio_layer_(audio_layer), + : env_(env), + audio_layer_(audio_layer), is_stereo_playout_supported_(is_stereo_playout_supported), is_stereo_record_supported_(is_stereo_record_supported), playout_delay_ms_(playout_delay_ms), - task_queue_factory_(CreateDefaultTaskQueueFactory()), input_(std::move(audio_input)), output_(std::move(audio_output)), initialized_(false) { @@ -92,7 +92,7 @@ class AndroidAudioDeviceModule : public AudioDeviceModule { RTC_DLOG(LS_INFO) << __FUNCTION__; RTC_DCHECK(thread_checker_.IsCurrent()); audio_device_buffer_ = - std::make_unique(task_queue_factory_.get()); + std::make_unique(&env_.task_queue_factory()); AttachAudioBuffer(); if (initialized_) { return 0; @@ -589,11 +589,11 @@ class AndroidAudioDeviceModule : public AudioDeviceModule { private: SequenceChecker thread_checker_; + const Environment env_; const AudioDeviceModule::AudioLayer audio_layer_; const bool is_stereo_playout_supported_; const bool is_stereo_record_supported_; const uint16_t playout_delay_ms_; - const std::unique_ptr task_queue_factory_; const std::unique_ptr input_; const std::unique_ptr output_; std::unique_ptr audio_device_buffer_; @@ -648,6 +648,7 @@ bool IsLowLatencyOutputSupported(JNIEnv* env, } scoped_refptr CreateAudioDeviceModuleFromInputAndOutput( + const Environment& env, AudioDeviceModule::AudioLayer audio_layer, bool is_stereo_playout_supported, bool is_stereo_record_supported, @@ -656,7 +657,7 @@ scoped_refptr CreateAudioDeviceModuleFromInputAndOutput( std::unique_ptr audio_output) { RTC_DLOG(LS_INFO) << __FUNCTION__; return make_ref_counted( - audio_layer, is_stereo_playout_supported, is_stereo_record_supported, + env, audio_layer, is_stereo_playout_supported, is_stereo_record_supported, playout_delay_ms, std::move(audio_input), std::move(audio_output)); } diff --git a/sdk/android/src/jni/audio_device/audio_device_module.h b/sdk/android/src/jni/audio_device/audio_device_module.h index cbf71ed473..dc7c73d587 100644 --- a/sdk/android/src/jni/audio_device/audio_device_module.h +++ b/sdk/android/src/jni/audio_device/audio_device_module.h @@ -15,6 +15,8 @@ #include #include "api/audio/audio_device.h" +#include "api/environment/environment.h" +#include "api/scoped_refptr.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { @@ -96,6 +98,7 @@ bool IsLowLatencyOutputSupported(JNIEnv* env, // Glue together an audio input and audio output to get an AudioDeviceModule. scoped_refptr CreateAudioDeviceModuleFromInputAndOutput( + const Environment& env, AudioDeviceModule::AudioLayer audio_layer, bool is_stereo_playout_supported, bool is_stereo_record_supported, diff --git a/sdk/android/src/jni/audio_device/audio_track_jni.cc b/sdk/android/src/jni/audio_device/audio_track_jni.cc index 464805f912..59d6d75f36 100644 --- a/sdk/android/src/jni/audio_device/audio_track_jni.cc +++ b/sdk/android/src/jni/audio_device/audio_track_jni.cc @@ -10,15 +10,22 @@ #include "sdk/android/src/jni/audio_device/audio_track_jni.h" -#include +#include -#include "rtc_base/arraysize.h" +#include +#include +#include +#include + +#include "api/audio/audio_device_defines.h" +#include "api/environment/environment.h" +#include "modules/audio_device/audio_device_buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/platform_thread.h" #include "sdk/android/generated_java_audio_device_module_native_jni/WebRtcAudioTrack_jni.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" #include "sdk/android/src/jni/jni_helpers.h" -#include "system_wrappers/include/field_trial.h" +#include "sdk/android/src/jni/jvm.h" #include "system_wrappers/include/metrics.h" #include "third_party/jni_zero/jni_zero.h" @@ -35,9 +42,11 @@ ScopedJavaLocalRef AudioTrackJni::CreateJavaWebRtcAudioTrack( AudioTrackJni::AudioTrackJni( JNIEnv* env, + const Environment& webrtc_env, const AudioParameters& audio_parameters, const jni_zero::JavaRef& j_webrtc_audio_track) - : j_audio_track_(env, j_webrtc_audio_track), + : webrtc_env_(webrtc_env), + j_audio_track_(env, j_webrtc_audio_track), audio_parameters_(audio_parameters), direct_buffer_address_(nullptr), direct_buffer_capacity_in_bytes_(0), @@ -85,8 +94,8 @@ int32_t AudioTrackJni::InitPlayout() { } RTC_DCHECK(!playing_); double buffer_size_factor = - strtod(webrtc::field_trial::FindFullName( - "WebRTC-AudioDevicePlayoutBufferSizeFactor") + strtod(webrtc_env_.field_trials() + .Lookup("WebRTC-AudioDevicePlayoutBufferSizeFactor") .c_str(), nullptr); if (buffer_size_factor == 0) diff --git a/sdk/android/src/jni/audio_device/audio_track_jni.h b/sdk/android/src/jni/audio_device/audio_track_jni.h index fee50ef77f..8044182ef1 100644 --- a/sdk/android/src/jni/audio_device/audio_track_jni.h +++ b/sdk/android/src/jni/audio_device/audio_track_jni.h @@ -13,14 +13,16 @@ #include -#include +#include +#include #include #include "api/audio/audio_device_defines.h" +#include "api/environment/environment.h" #include "api/sequence_checker.h" #include "modules/audio_device/audio_device_buffer.h" -#include "sdk/android/src/jni/audio_device/audio_common.h" #include "sdk/android/src/jni/audio_device/audio_device_module.h" +#include "third_party/jni_zero/jni_zero.h" namespace webrtc { @@ -47,6 +49,7 @@ class AudioTrackJni : public AudioOutput { const jni_zero::JavaRef& j_audio_manager); AudioTrackJni(JNIEnv* env, + const Environment& webrtc_env, const AudioParameters& audio_parameters, const jni_zero::JavaRef& j_webrtc_audio_track); ~AudioTrackJni() override; @@ -85,6 +88,8 @@ class AudioTrackJni : public AudioOutput { void GetPlayoutData(JNIEnv* env, size_t length); private: + const Environment webrtc_env_; + // Stores thread ID in constructor. SequenceChecker thread_checker_; diff --git a/sdk/android/src/jni/audio_device/java_audio_device_module.cc b/sdk/android/src/jni/audio_device/java_audio_device_module.cc index ea0c659558..a8152a39c4 100644 --- a/sdk/android/src/jni/audio_device/java_audio_device_module.cc +++ b/sdk/android/src/jni/audio_device/java_audio_device_module.cc @@ -8,12 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include +#include +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "api/environment/environment.h" #include "sdk/android/generated_java_audio_jni/JavaAudioDeviceModule_jni.h" +#include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/src/jni/audio_device/audio_common.h" +#include "sdk/android/src/jni/audio_device/audio_device_module.h" #include "sdk/android/src/jni/audio_device/audio_record_jni.h" #include "sdk/android/src/jni/audio_device/audio_track_jni.h" -#include "sdk/android/src/jni/jni_helpers.h" #include "third_party/jni_zero/jni_zero.h" namespace webrtc { @@ -25,10 +33,12 @@ static jlong JNI_JavaAudioDeviceModule_CreateAudioDeviceModule( const jni_zero::JavaParamRef& j_audio_manager, const jni_zero::JavaParamRef& j_webrtc_audio_record, const jni_zero::JavaParamRef& j_webrtc_audio_track, + jlong webrtcEnvRef, int input_sample_rate, int output_sample_rate, jboolean j_use_stereo_input, jboolean j_use_stereo_output) { + const Environment& webrtc_env = *reinterpret_cast(webrtcEnvRef); AudioParameters input_parameters; AudioParameters output_parameters; GetAudioParameters(env, j_context, j_audio_manager, input_sample_rate, @@ -38,14 +48,14 @@ static jlong JNI_JavaAudioDeviceModule_CreateAudioDeviceModule( auto audio_input = std::make_unique( env, input_parameters, kHighLatencyModeDelayEstimateInMilliseconds, j_webrtc_audio_record); - auto audio_output = std::make_unique(env, output_parameters, - j_webrtc_audio_track); - return jlongFromPointer(CreateAudioDeviceModuleFromInputAndOutput( - AudioDeviceModule::kAndroidJavaAudio, - j_use_stereo_input, j_use_stereo_output, - kHighLatencyModeDelayEstimateInMilliseconds, - std::move(audio_input), std::move(audio_output)) - .release()); + auto audio_output = std::make_unique( + env, webrtc_env, output_parameters, j_webrtc_audio_track); + return NativeToJavaPointer( + CreateAudioDeviceModuleFromInputAndOutput( + webrtc_env, AudioDeviceModule::kAndroidJavaAudio, j_use_stereo_input, + j_use_stereo_output, kHighLatencyModeDelayEstimateInMilliseconds, + std::move(audio_input), std::move(audio_output)) + .release()); } } // namespace jni diff --git a/sdk/android/src/jni/dav1d_codec.cc b/sdk/android/src/jni/dav1d_codec.cc index 1246d88c0b..99ad2f50ae 100644 --- a/sdk/android/src/jni/dav1d_codec.cc +++ b/sdk/android/src/jni/dav1d_codec.cc @@ -18,7 +18,7 @@ namespace webrtc { namespace jni { static jlong JNI_Dav1dDecoder_CreateDecoder(JNIEnv* jni) { - return jlongFromPointer(webrtc::CreateDav1dDecoder().release()); + return jlongFromPointer(CreateDav1dDecoder().release()); } } // namespace jni diff --git a/sdk/android/src/jni/environment.cc b/sdk/android/src/jni/environment.cc new file mode 100644 index 0000000000..fab50ebd5d --- /dev/null +++ b/sdk/android/src/jni/environment.cc @@ -0,0 +1,42 @@ +/* + * 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/environment/environment.h" + +#include + +#include +#include + +#include "api/environment/environment_factory.h" +#include "api/field_trials.h" +#include "api/field_trials_view.h" +#include "sdk/android/generated_environment_jni/Environment_jni.h" +#include "sdk/android/native_api/jni/java_types.h" +#include "third_party/jni_zero/jni_zero.h" + +namespace webrtc::jni { + +void JNI_Environment_Free(JNIEnv* /*env*/, jlong webrtcEnv) { + delete reinterpret_cast(webrtcEnv); +} + +jlong JNI_Environment_Create( + JNIEnv* env, + const jni_zero::JavaParamRef& fieldTrials) { + std::unique_ptr field_trials; + if (!IsNull(env, fieldTrials)) { + field_trials = + std::make_unique(JavaToNativeString(env, fieldTrials)); + } + return NativeToJavaPointer( + new Environment(CreateEnvironment(std::move(field_trials)))); +} + +} // namespace webrtc::jni diff --git a/sdk/android/src/jni/jni_onload.cc b/sdk/android/src/jni/jni_onload.cc index 5c44784077..6945e7601f 100644 --- a/sdk/android/src/jni/jni_onload.cc +++ b/sdk/android/src/jni/jni_onload.cc @@ -28,7 +28,7 @@ extern "C" jint JNIEXPORT JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved) { return -1; RTC_CHECK(InitializeSSL()) << "Failed to InitializeSSL()"; - webrtc::InitClassLoader(GetEnv()); + InitClassLoader(GetEnv()); return ret; } diff --git a/sdk/android/src/jni/pc/add_ice_candidate_observer.cc b/sdk/android/src/jni/pc/add_ice_candidate_observer.cc index 7f3dddbb28..57a053aa9a 100644 --- a/sdk/android/src/jni/pc/add_ice_candidate_observer.cc +++ b/sdk/android/src/jni/pc/add_ice_candidate_observer.cc @@ -25,7 +25,7 @@ AddIceCandidateObserverJni::AddIceCandidateObserverJni( const JavaRef& j_observer) : j_observer_global_(env, j_observer) {} -void AddIceCandidateObserverJni::OnComplete(webrtc::RTCError error) { +void AddIceCandidateObserverJni::OnComplete(RTCError error) { JNIEnv* env = AttachCurrentThreadIfNeeded(); if (error.ok()) { Java_AddIceObserver_onAddSuccess(env, j_observer_global_); diff --git a/sdk/android/src/jni/pc/ice_candidate.cc b/sdk/android/src/jni/pc/ice_candidate.cc index 10c1a11243..4e6e5706c7 100644 --- a/sdk/android/src/jni/pc/ice_candidate.cc +++ b/sdk/android/src/jni/pc/ice_candidate.cc @@ -192,23 +192,23 @@ JavaToNativeContinualGatheringPolicy( return PeerConnectionInterface::GATHER_ONCE; } -webrtc::PortPrunePolicy JavaToNativePortPrunePolicy( +PortPrunePolicy JavaToNativePortPrunePolicy( JNIEnv* jni, const JavaRef& j_port_prune_policy) { std::string enum_name = GetJavaEnumName(jni, j_port_prune_policy); if (enum_name == "NO_PRUNE") { - return webrtc::NO_PRUNE; + return NO_PRUNE; } if (enum_name == "PRUNE_BASED_ON_PRIORITY") { - return webrtc::PRUNE_BASED_ON_PRIORITY; + return PRUNE_BASED_ON_PRIORITY; } if (enum_name == "KEEP_FIRST_READY") { - return webrtc::KEEP_FIRST_READY; + return KEEP_FIRST_READY; } RTC_CHECK(false) << " Unexpected PortPrunePolicy enum name " << enum_name; - return webrtc::NO_PRUNE; + return NO_PRUNE; } PeerConnectionInterface::TlsCertPolicy JavaToNativeTlsCertPolicy( diff --git a/sdk/android/src/jni/pc/media_stream_track.cc b/sdk/android/src/jni/pc/media_stream_track.cc index 20c02536c5..d3eb4e8d3b 100644 --- a/sdk/android/src/jni/pc/media_stream_track.cc +++ b/sdk/android/src/jni/pc/media_stream_track.cc @@ -18,16 +18,14 @@ namespace webrtc { namespace jni { -ScopedJavaLocalRef NativeToJavaMediaType( - JNIEnv* jni, - webrtc::MediaType media_type) { +ScopedJavaLocalRef NativeToJavaMediaType(JNIEnv* jni, + MediaType media_type) { return Java_MediaType_fromNativeIndex(jni, static_cast(media_type)); } -webrtc::MediaType JavaToNativeMediaType(JNIEnv* jni, - const JavaRef& j_media_type) { - return static_cast( - Java_MediaType_getNative(jni, j_media_type)); +MediaType JavaToNativeMediaType(JNIEnv* jni, + const JavaRef& j_media_type) { + return static_cast(Java_MediaType_getNative(jni, j_media_type)); } static ScopedJavaLocalRef JNI_MediaStreamTrack_GetId(JNIEnv* jni, diff --git a/sdk/android/src/jni/pc/peer_connection_factory.cc b/sdk/android/src/jni/pc/peer_connection_factory.cc index 7404a950f8..d34f8c0d4d 100644 --- a/sdk/android/src/jni/pc/peer_connection_factory.cc +++ b/sdk/android/src/jni/pc/peer_connection_factory.cc @@ -10,35 +10,61 @@ #include "sdk/android/src/jni/pc/peer_connection_factory.h" +#include +#include +#include + +#include +#include #include +#include +#include #include #include "absl/memory/memory.h" #include "api/audio/audio_device.h" #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_encoder_factory.h" +#include "api/audio_options.h" #include "api/enable_media.h" +#include "api/environment/environment.h" +#include "api/fec_controller.h" +#include "api/media_stream_interface.h" +#include "api/neteq/neteq_factory.h" +#include "api/network_state_predictor.h" +#include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/task_queue/default_task_queue_factory.h" -#include "api/video_codecs/video_decoder_factory.h" -#include "api/video_codecs/video_encoder_factory.h" +#include "api/scoped_refptr.h" +#include "api/transport/network_control.h" #include "modules/utility/include/jvm_android.h" +#include "rtc_base/checks.h" #include "rtc_base/event_tracer.h" +#include "rtc_base/logging.h" #include "rtc_base/physical_socket_server.h" +#include "rtc_base/rtc_certificate.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/socket_factory.h" +#include "rtc_base/ssl_identity.h" #include "rtc_base/thread.h" #include "sdk/android/generated_peerconnection_jni/PeerConnectionFactory_jni.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" #include "sdk/android/native_api/stacktrace/stacktrace.h" +#include "sdk/android/src/jni/android_network_monitor.h" #include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/src/jni/jvm.h" #include "sdk/android/src/jni/logging/log_sink.h" #include "sdk/android/src/jni/pc/android_network_monitor.h" -#include "sdk/android/src/jni/pc/ice_candidate.h" +#include "sdk/android/src/jni/pc/media_constraints.h" #include "sdk/android/src/jni/pc/media_stream_track.h" #include "sdk/android/src/jni/pc/owned_factory_and_threads.h" #include "sdk/android/src/jni/pc/peer_connection.h" #include "sdk/android/src/jni/pc/rtp_capabilities.h" #include "sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.h" #include "sdk/android/src/jni/pc/video.h" +#include "sdk/media_constraints.h" #include "system_wrappers/include/field_trial.h" #include "third_party/jni_zero/jni_zero.h" @@ -114,7 +140,7 @@ StaticObjectContainer& GetStaticObjects() { ScopedJavaLocalRef NativeToScopedJavaPeerConnectionFactory( JNIEnv* env, - scoped_refptr pcf, + scoped_refptr pcf, std::unique_ptr socket_factory, std::unique_ptr network_thread, std::unique_ptr worker_thread, @@ -154,7 +180,7 @@ static bool factory_static_initialized = false; jobject NativeToJavaPeerConnectionFactory( JNIEnv* jni, - scoped_refptr pcf, + scoped_refptr pcf, std::unique_ptr socket_factory, std::unique_ptr network_thread, std::unique_ptr worker_thread, @@ -193,14 +219,6 @@ static void JNI_PeerConnectionFactory_InitializeInternalTracer(JNIEnv* jni) { tracing::SetupInternalTracer(); } -static jni_zero::ScopedJavaLocalRef -JNI_PeerConnectionFactory_FindFieldTrialsFullName( - JNIEnv* jni, - const jni_zero::JavaParamRef& j_name) { - return NativeToJavaString( - jni, field_trial::FindFullName(JavaToStdString(jni, j_name))); -} - static jboolean JNI_PeerConnectionFactory_StartInternalTracingCapture( JNIEnv* jni, const jni_zero::JavaParamRef& j_event_tracing_filename) { @@ -231,6 +249,7 @@ ScopedJavaLocalRef CreatePeerConnectionFactoryForJava( JNIEnv* jni, const jni_zero::JavaParamRef& jcontext, const jni_zero::JavaParamRef& joptions, + const Environment& env, scoped_refptr audio_device_module, scoped_refptr audio_encoder_factory, scoped_refptr audio_decoder_factory, @@ -267,12 +286,11 @@ ScopedJavaLocalRef CreatePeerConnectionFactoryForJava( JavaToNativePeerConnectionFactoryOptions(jni, joptions); PeerConnectionFactoryDependencies dependencies; - // TODO(bugs.webrtc.org/13145): Also add socket_server.get() to the - // dependencies. + dependencies.env = env; + dependencies.socket_factory = socket_server.get(); dependencies.network_thread = network_thread.get(); dependencies.worker_thread = worker_thread.get(); dependencies.signaling_thread = signaling_thread.get(); - dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); dependencies.event_log_factory = std::make_unique(); dependencies.fec_controller_factory = std::move(fec_controller_factory); dependencies.network_controller_factory = @@ -294,7 +312,7 @@ ScopedJavaLocalRef CreatePeerConnectionFactoryForJava( #ifndef WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE } else { dependencies.audio_processing_builder = - std::make_unique(); + std::make_unique(); #endif } dependencies.video_encoder_factory = @@ -323,6 +341,7 @@ JNI_PeerConnectionFactory_CreatePeerConnectionFactory( JNIEnv* jni, const jni_zero::JavaParamRef& jcontext, const jni_zero::JavaParamRef& joptions, + jlong webrtc_env_ref, jlong native_audio_device_module, jlong native_audio_encoder_factory, jlong native_audio_decoder_factory, @@ -333,10 +352,12 @@ JNI_PeerConnectionFactory_CreatePeerConnectionFactory( jlong native_network_controller_factory, jlong native_network_state_predictor_factory, jlong native_neteq_factory) { + const Environment* env = reinterpret_cast(webrtc_env_ref); + RTC_CHECK(env != nullptr); scoped_refptr audio_processor( reinterpret_cast(native_audio_processor)); return CreatePeerConnectionFactoryForJava( - jni, jcontext, joptions, + jni, jcontext, joptions, *env, scoped_refptr( reinterpret_cast(native_audio_device_module)), TakeOwnershipOfRefPtr(native_audio_encoder_factory), diff --git a/sdk/android/src/jni/pc/rtp_parameters.cc b/sdk/android/src/jni/pc/rtp_parameters.cc index 4bd9ee0e1d..c83ea8599c 100644 --- a/sdk/android/src/jni/pc/rtp_parameters.cc +++ b/sdk/android/src/jni/pc/rtp_parameters.cc @@ -20,26 +20,26 @@ namespace jni { namespace { -webrtc::DegradationPreference JavaToNativeDegradationPreference( +DegradationPreference JavaToNativeDegradationPreference( JNIEnv* jni, const JavaRef& j_degradation_preference) { std::string enum_name = GetJavaEnumName(jni, j_degradation_preference); if (enum_name == "DISABLED") - return webrtc::DegradationPreference::DISABLED; + return DegradationPreference::DISABLED; if (enum_name == "MAINTAIN_FRAMERATE") - return webrtc::DegradationPreference::MAINTAIN_FRAMERATE; + return DegradationPreference::MAINTAIN_FRAMERATE; if (enum_name == "MAINTAIN_RESOLUTION") - return webrtc::DegradationPreference::MAINTAIN_RESOLUTION; + return DegradationPreference::MAINTAIN_RESOLUTION; if (enum_name == "BALANCED") - return webrtc::DegradationPreference::BALANCED; + return DegradationPreference::BALANCED; RTC_CHECK(false) << "Unexpected DegradationPreference enum_name " << enum_name; - return webrtc::DegradationPreference::DISABLED; + return DegradationPreference::DISABLED; } ScopedJavaLocalRef NativeToJavaRtpEncodingParameter( @@ -99,7 +99,7 @@ RtpEncodingParameters JavaToNativeRtpEncodingParameters( Java_Encoding_getMaxBitrateBps(jni, j_encoding_parameters); encoding.bitrate_priority = Java_Encoding_getBitratePriority(jni, j_encoding_parameters); - encoding.network_priority = static_cast( + encoding.network_priority = static_cast( Java_Encoding_getNetworkPriority(jni, j_encoding_parameters)); encoding.max_bitrate_bps = JavaToNativeOptionalInt(jni, j_max_bitrate); ScopedJavaLocalRef j_min_bitrate = diff --git a/sdk/android/src/jni/pc/rtp_receiver.cc b/sdk/android/src/jni/pc/rtp_receiver.cc index 56dc78de13..81dcd4abc2 100644 --- a/sdk/android/src/jni/pc/rtp_receiver.cc +++ b/sdk/android/src/jni/pc/rtp_receiver.cc @@ -33,7 +33,7 @@ class RtpReceiverObserverJni : public RtpReceiverObserverInterface { ~RtpReceiverObserverJni() override = default; - void OnFirstPacketReceived(webrtc::MediaType media_type) override { + void OnFirstPacketReceived(MediaType media_type) override { JNIEnv* const env = AttachCurrentThreadIfNeeded(); Java_Observer_onFirstPacketReceived(env, j_observer_global_, NativeToJavaMediaType(env, media_type)); diff --git a/sdk/android/src/jni/pc/rtp_sender.cc b/sdk/android/src/jni/pc/rtp_sender.cc index e63d0cc688..c3dd3a2a63 100644 --- a/sdk/android/src/jni/pc/rtp_sender.cc +++ b/sdk/android/src/jni/pc/rtp_sender.cc @@ -112,11 +112,10 @@ static void JNI_RtpSender_SetFrameEncryptor(JNIEnv* jni, static jni_zero::ScopedJavaLocalRef JNI_RtpSender_GetMediaType( JNIEnv* jni, jlong j_rtp_sender_pointer) { - webrtc::MediaType media_type = + MediaType media_type = reinterpret_cast(j_rtp_sender_pointer)->media_type(); - return media_type == webrtc::MediaType::AUDIO - ? NativeToJavaString(jni, "audio") - : NativeToJavaString(jni, "video"); + return media_type == MediaType::AUDIO ? NativeToJavaString(jni, "audio") + : NativeToJavaString(jni, "video"); } } // namespace jni diff --git a/sdk/android/src/jni/pc/rtp_transceiver.cc b/sdk/android/src/jni/pc/rtp_transceiver.cc index d7425b97b7..8818438b85 100644 --- a/sdk/android/src/jni/pc/rtp_transceiver.cc +++ b/sdk/android/src/jni/pc/rtp_transceiver.cc @@ -182,7 +182,7 @@ jboolean JNI_RtpTransceiver_SetDirection( RtpTransceiverDirection direction = static_cast( Java_RtpTransceiverDirection_getNativeIndex(jni, j_rtp_transceiver_direction)); - webrtc::RTCError error = + RTCError error = reinterpret_cast(j_rtp_transceiver_pointer) ->SetDirectionWithError(direction); if (!error.ok()) { diff --git a/sdk/android/src/jni/pc/sdp_observer.cc b/sdk/android/src/jni/pc/sdp_observer.cc index c8b4345af4..2b5d8e23b4 100644 --- a/sdk/android/src/jni/pc/sdp_observer.cc +++ b/sdk/android/src/jni/pc/sdp_observer.cc @@ -41,7 +41,7 @@ void CreateSdpObserverJni::OnSuccess(SessionDescriptionInterface* desc) { delete desc; } -void CreateSdpObserverJni::OnFailure(webrtc::RTCError error) { +void CreateSdpObserverJni::OnFailure(RTCError error) { JNIEnv* env = AttachCurrentThreadIfNeeded(); Java_SdpObserver_onCreateFailure(env, j_observer_global_, NativeToJavaString(env, error.message())); diff --git a/sdk/android/src/jni/pc/turn_customizer.cc b/sdk/android/src/jni/pc/turn_customizer.cc index 94ebf0140d..b79fe515fd 100644 --- a/sdk/android/src/jni/pc/turn_customizer.cc +++ b/sdk/android/src/jni/pc/turn_customizer.cc @@ -22,7 +22,7 @@ TurnCustomizer* GetNativeTurnCustomizer( const JavaRef& j_turn_customizer) { if (IsNull(env, j_turn_customizer)) return nullptr; - return reinterpret_cast( + return reinterpret_cast( Java_TurnCustomizer_getNativeTurnCustomizer(env, j_turn_customizer)); } diff --git a/sdk/android/src/jni/software_video_decoder_factory.cc b/sdk/android/src/jni/software_video_decoder_factory.cc index 08e94a964f..cc82e51481 100644 --- a/sdk/android/src/jni/software_video_decoder_factory.cc +++ b/sdk/android/src/jni/software_video_decoder_factory.cc @@ -24,8 +24,7 @@ namespace webrtc { namespace jni { static jlong JNI_SoftwareVideoDecoderFactory_CreateFactory(JNIEnv* env) { - return webrtc::NativeToJavaPointer( - CreateBuiltinVideoDecoderFactory().release()); + return NativeToJavaPointer(CreateBuiltinVideoDecoderFactory().release()); } jboolean JNI_SoftwareVideoDecoderFactory_IsSupported( @@ -53,10 +52,10 @@ static jni_zero::ScopedJavaLocalRef JNI_SoftwareVideoDecoderFactory_GetSupportedCodecs(JNIEnv* env, jlong j_factory) { auto* const native_factory = - reinterpret_cast(j_factory); + reinterpret_cast(j_factory); - return webrtc::NativeToJavaList(env, native_factory->GetSupportedFormats(), - &webrtc::jni::SdpVideoFormatToVideoCodecInfo); + return NativeToJavaList(env, native_factory->GetSupportedFormats(), + &jni::SdpVideoFormatToVideoCodecInfo); } } // namespace jni diff --git a/sdk/android/src/jni/software_video_encoder_factory.cc b/sdk/android/src/jni/software_video_encoder_factory.cc index a2d44d932d..344a459259 100644 --- a/sdk/android/src/jni/software_video_encoder_factory.cc +++ b/sdk/android/src/jni/software_video_encoder_factory.cc @@ -21,8 +21,7 @@ namespace webrtc { namespace jni { static jlong JNI_SoftwareVideoEncoderFactory_CreateFactory(JNIEnv* env) { - return webrtc::NativeToJavaPointer( - CreateBuiltinVideoEncoderFactory().release()); + return NativeToJavaPointer(CreateBuiltinVideoEncoderFactory().release()); } jboolean JNI_SoftwareVideoEncoderFactory_IsSupported( @@ -50,10 +49,10 @@ static jni_zero::ScopedJavaLocalRef JNI_SoftwareVideoEncoderFactory_GetSupportedCodecs(JNIEnv* env, jlong j_factory) { auto* const native_factory = - reinterpret_cast(j_factory); + reinterpret_cast(j_factory); - return webrtc::NativeToJavaList(env, native_factory->GetSupportedFormats(), - &webrtc::jni::SdpVideoFormatToVideoCodecInfo); + return NativeToJavaList(env, native_factory->GetSupportedFormats(), + &jni::SdpVideoFormatToVideoCodecInfo); } } // namespace jni diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h index 53cdbabf40..3dac96b55b 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN /* Initialize object with provided dependencies and with media support. */ - (instancetype)initWithMediaAndDependencies: - (webrtc::PeerConnectionFactoryDependencies)dependencies; + (webrtc::PeerConnectionFactoryDependencies &)dependencies; /* Initialize object with injectable native audio/video encoder/decoder * factories */ diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 3d69a40bd7..d63a023a9d 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -36,9 +36,9 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/enable_media.h" +#include "api/environment/environment_factory.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/task_queue/default_task_queue_factory.h" -#include "api/transport/field_trial_based_config.h" #import "components/video_codec/RTCVideoDecoderFactoryH264.h" #import "components/video_codec/RTCVideoEncoderFactoryH264.h" #include "media/base/media_constants.h" @@ -65,20 +65,11 @@ @implementation RTC_OBJC_TYPE (RTCPeerConnectionFactory) { @synthesize nativeFactory = _nativeFactory; -- (webrtc::scoped_refptr)audioDeviceModule { -#if defined(WEBRTC_IOS) - RTCLogInfo(@"Creating AudioDeviceModule without AudioSourceSink"); - return webrtc::CreateAudioDeviceModule(); -#else - return nullptr; -#endif -} - -- (webrtc::scoped_refptr)audioDeviceModuleWithAudioSink:(nullable RTC_OBJC_TYPE(RTCAudioSink) *)audioSink { +- (webrtc::scoped_refptr)audioDeviceModuleWithAudioSink:(nullable RTC_OBJC_TYPE(RTCAudioSink) *)audioSink environment:(const webrtc::Environment &)env { #if defined(WEBRTC_IOS) RTCLogInfo(@"Creating AudioDeviceModule with AudioSourceSink"); webrtc::AudioSourceSink *sink = new webrtc::AudioSourceSink(audioSink); - return webrtc::CreateAudioDeviceModule(false, sink); + return webrtc::CreateAudioDeviceModule(env, false, sink); #else return nullptr; #endif @@ -94,8 +85,11 @@ - (instancetype)init { [[RTC_OBJC_TYPE(RTCVideoEncoderFactoryH264) alloc] init]); dependencies.video_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory( [[RTC_OBJC_TYPE(RTCVideoDecoderFactoryH264) alloc] init]); - dependencies.adm = [self audioDeviceModule]; - return [self initWithMediaAndDependencies:std::move(dependencies)]; + dependencies.env = webrtc::CreateEnvironment(); +#ifdef WEBRTC_IOS + dependencies.adm = webrtc::CreateAudioDeviceModule(dependencies.env.value()); +#endif + return [self initWithMediaAndDependencies:dependencies]; } - (instancetype) @@ -122,6 +116,7 @@ - (instancetype)init { return [self initWithNoMedia]; #else webrtc::PeerConnectionFactoryDependencies dependencies; + dependencies.env = webrtc::CreateEnvironment(); dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); dependencies.audio_decoder_factory = @@ -135,16 +130,19 @@ - (instancetype)init { webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory); } if (audioDevice) { - dependencies.adm = webrtc::CreateAudioDeviceModule(audioDevice); + dependencies.adm = + webrtc::CreateAudioDeviceModule(*dependencies.env, audioDevice); +#ifdef WEBRTC_IOS } else { - dependencies.adm = [self audioDeviceModuleWithAudioSink:audioSink]; + dependencies.adm = [self audioDeviceModuleWithAudioSink:audioSink environment:dependencies.env.value()]; +#endif } - return [self initWithMediaAndDependencies:std::move(dependencies)]; + return [self initWithMediaAndDependencies:dependencies]; #endif } - (instancetype)initWithNativeDependencies: - (webrtc::PeerConnectionFactoryDependencies)dependencies { + (webrtc::PeerConnectionFactoryDependencies &)dependencies { self = [super init]; if (self) { _networkThread = webrtc::Thread::CreateWithSocketServer(); @@ -167,11 +165,12 @@ - (instancetype)initWithNativeDependencies: dependencies.network_thread = _networkThread.get(); dependencies.worker_thread = _workerThread.get(); dependencies.signaling_thread = _signalingThread.get(); - if (dependencies.trials == nullptr) { - dependencies.trials = std::make_unique(); + if (!dependencies.env.has_value()) { + dependencies.env = webrtc::CreateEnvironment(); } if (dependencies.network_monitor_factory == nullptr && - dependencies.trials->IsEnabled("WebRTC-Network-UseNWPathMonitor")) { + dependencies.env->field_trials().IsEnabled( + "WebRTC-Network-UseNWPathMonitor")) { dependencies.network_monitor_factory = webrtc::CreateNetworkMonitorFactory(); } @@ -184,8 +183,8 @@ - (instancetype)initWithNativeDependencies: } - (instancetype)initWithNoMedia { - return [self - initWithNativeDependencies:webrtc::PeerConnectionFactoryDependencies()]; + webrtc::PeerConnectionFactoryDependencies default_deps; + return [self initWithNativeDependencies:default_deps]; } - (instancetype) @@ -215,7 +214,7 @@ - (instancetype)initWithNoMedia { dependencies.audio_processing_builder = CustomAudioProcessing(std::move(audioProcessingModule)); } - return [self initWithMediaAndDependencies:std::move(dependencies)]; + return [self initWithMediaAndDependencies:dependencies]; } - (instancetype) @@ -249,17 +248,11 @@ - (instancetype)initWithNoMedia { CustomAudioProcessing(std::move(audioProcessingModule)); } dependencies.network_controller_factory = std::move(networkControllerFactory); - return [self initWithMediaAndDependencies:std::move(dependencies)]; + return [self initWithMediaAndDependencies:dependencies]; } - (instancetype)initWithMediaAndDependencies: - (webrtc::PeerConnectionFactoryDependencies)dependencies { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - // audio_processing_builder should be used instead in new code. - RTC_CHECK(dependencies.audio_processing == nullptr); -#pragma clang diagnostic pop - + (webrtc::PeerConnectionFactoryDependencies &)dependencies { #ifndef WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE if (dependencies.audio_processing_builder == nullptr) { dependencies.audio_processing_builder = @@ -271,7 +264,7 @@ - (instancetype)initWithMediaAndDependencies: std::make_unique(); } webrtc::EnableMedia(dependencies); - return [self initWithNativeDependencies:std::move(dependencies)]; + return [self initWithNativeDependencies:dependencies]; } - (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesForKind: diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm index e5eeba5992..3e18fd1c57 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm @@ -19,6 +19,7 @@ #include "sdk/objc/native/api/video_encoder_factory.h" #if defined(WEBRTC_IOS) +#include "api/environment/environment_factory.h" #import "sdk/objc/native/api/audio_device_module.h" #endif @@ -42,7 +43,8 @@ + (RTCPeerConnectionFactoryBuilder *)defaultBuilder { [builder setVideoDecoderFactory:std::move(videoDecoderFactory)]; #if defined(WEBRTC_IOS) - [builder setAudioDeviceModule:webrtc::CreateAudioDeviceModule()]; + [builder setAudioDeviceModule:webrtc::CreateAudioDeviceModule( + webrtc::CreateEnvironment())]; #endif return builder; } diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm index 8fe5565111..6e2f7c4ef2 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm @@ -15,6 +15,7 @@ #include "api/audio/audio_processing.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_encoder_factory.h" +#include "api/environment/environment_factory.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" @@ -28,11 +29,11 @@ + (RTCPeerConnectionFactoryBuilder *)builder { - (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)createPeerConnectionFactory { return [[RTC_OBJC_TYPE(RTCPeerConnectionFactory) alloc] - initWithMediaAndDependencies:std::move(_dependencies)]; + initWithMediaAndDependencies:_dependencies]; } - (void)setFieldTrials:(std::unique_ptr)fieldTrials { - _dependencies.trials = std::move(fieldTrials); + _dependencies.env = webrtc::CreateEnvironment(std::move(fieldTrials)); } - (void)setVideoEncoderFactory: diff --git a/sdk/objc/components/network/RTCNetworkMonitor.mm b/sdk/objc/components/network/RTCNetworkMonitor.mm index e3f312362f..df93636eca 100644 --- a/sdk/objc/components/network/RTCNetworkMonitor.mm +++ b/sdk/objc/components/network/RTCNetworkMonitor.mm @@ -95,9 +95,10 @@ - (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer { return true; }); @synchronized(strongSelf) { - webrtc::NetworkMonitorObserver *observer = strongSelf->_observer; - if (observer) { - observer->OnPathUpdate(std::move(owned_map)); + webrtc::NetworkMonitorObserver *strongObserver = + strongSelf->_observer; + if (strongObserver) { + strongObserver->OnPathUpdate(std::move(owned_map)); } } }); diff --git a/sdk/objc/helpers/RTCCameraPreviewView.m b/sdk/objc/helpers/RTCCameraPreviewView.m index 92c3cd2635..3314322b99 100644 --- a/sdk/objc/helpers/RTCCameraPreviewView.m +++ b/sdk/objc/helpers/RTCCameraPreviewView.m @@ -80,6 +80,56 @@ - (void)orientationChanged:(NSNotification *)notification { } - (void)setCorrectVideoOrientation { + if (@available(iOS 17, *)) { + [self modifyVideoAngle]; + } +#if !defined(__IPHONE_17_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_17_0 + else { + [self modifyVideoOrientation]; + } +#endif +} + +#pragma mark - Private + +- (void)addOrientationObserver { + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(orientationChanged:) + name:UIDeviceOrientationDidChangeNotification + object:nil]; +} + +- (void)removeOrientationObserver { + [[NSNotificationCenter defaultCenter] + removeObserver:self + name:UIDeviceOrientationDidChangeNotification + object:nil]; +} + +- (AVCaptureVideoPreviewLayer *)previewLayer { + return (AVCaptureVideoPreviewLayer *)self.layer; +} + +- (void)modifyVideoAngle API_AVAILABLE(ios(17.0)) { + AVCaptureDeviceInput* captureSessionInput = + _captureSession.inputs.firstObject; + AVCaptureDevice* camera = captureSessionInput.device; + AVCaptureVideoPreviewLayer* previewLayer = [self previewLayer]; + AVCaptureConnection* videoConnection = previewLayer.connection; + AVCaptureDeviceRotationCoordinator* rotationCoordiantor = + [[AVCaptureDeviceRotationCoordinator alloc] + initWithDevice:camera + previewLayer:previewLayer]; + CGFloat angle = + rotationCoordiantor.videoRotationAngleForHorizonLevelCapture; + if ([videoConnection isVideoRotationAngleSupported:angle]) { + [videoConnection setVideoRotationAngle:angle]; + } +} + +#if !defined(__IPHONE_17_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_17_0 +- (void)modifyVideoOrientation { // Get current device orientation. UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; @@ -104,26 +154,6 @@ - (void)setCorrectVideoOrientation { // orientation. } } +#endif -#pragma mark - Private - -- (void)addOrientationObserver { - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(orientationChanged:) - name:UIDeviceOrientationDidChangeNotification - object:nil]; -} - -- (void)removeOrientationObserver { - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:UIDeviceOrientationDidChangeNotification - object:nil]; -} - -- (AVCaptureVideoPreviewLayer *)previewLayer { - return (AVCaptureVideoPreviewLayer *)self.layer; -} - -@end +@end \ No newline at end of file diff --git a/sdk/objc/native/api/audio_device_module.h b/sdk/objc/native/api/audio_device_module.h index b99fc0de57..20ef9eee58 100644 --- a/sdk/objc/native/api/audio_device_module.h +++ b/sdk/objc/native/api/audio_device_module.h @@ -14,6 +14,8 @@ #include #include "api/audio/audio_device.h" +#include "api/environment/environment.h" +#include "api/scoped_refptr.h" #include "sdk/objc/native/api/audio_device_module_error_handler.h" namespace webrtc { @@ -25,14 +27,13 @@ class AudioSourceSink; // Warning: Setting `bypass_voice_processing` will have unpredictable // consequences for the audio path in the device. It is not advisable to use in // most scenarios. -webrtc::scoped_refptr CreateAudioDeviceModule( +scoped_refptr CreateAudioDeviceModule( + const Environment& env, bool bypass_voice_processing = false, AudioSourceSink* audioSink = nullptr); -// If `muted_speech_event_handler` is exist, audio unit will catch speech -// activity while muted. -webrtc::scoped_refptr CreateMutedDetectAudioDeviceModule( - AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, +[[deprecated("Pass `env` explicitly instead of relying on the default")]] +scoped_refptr CreateAudioDeviceModule( bool bypass_voice_processing = false, AudioSourceSink* audioSink = nullptr); @@ -40,7 +41,15 @@ webrtc::scoped_refptr CreateMutedDetectAudioDeviceModule( // activity while muted. // Provide `error_handler` to receive callbacks on errors such as microphone // init failed or playout start failied. -webrtc::scoped_refptr CreateMutedDetectAudioDeviceModule( +scoped_refptr CreateMutedDetectAudioDeviceModule( + const Environment& env, + AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, + ADMErrorHandler error_handler, + bool bypass_voice_processing = false, + AudioSourceSink* audioSink = nullptr); + +[[deprecated("Pass `env` explicitly instead of relying on the default")]] +scoped_refptr CreateMutedDetectAudioDeviceModule( AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, ADMErrorHandler error_handler, bool bypass_voice_processing = false, diff --git a/sdk/objc/native/api/audio_device_module.mm b/sdk/objc/native/api/audio_device_module.mm index b3bb51c472..0b99ef6fe4 100644 --- a/sdk/objc/native/api/audio_device_module.mm +++ b/sdk/objc/native/api/audio_device_module.mm @@ -10,54 +10,63 @@ #include "audio_device_module.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/make_ref_counted.h" #include "rtc_base/logging.h" - #include "sdk/objc/native/src/audio/audio_device_module_ios.h" #import "sdk/objc/native/src/audio/audio_source_sink.h" +#ifndef WEBRTC_IOS +#error This file shouldn't be compiled on platforms other than IOS. +#endif + namespace webrtc { -webrtc::scoped_refptr CreateAudioDeviceModule( - bool bypass_voice_processing, - webrtc::AudioSourceSink* audioSink) { +scoped_refptr CreateAudioDeviceModule( + const Environment& env, bool bypass_voice_processing, webrtc::AudioSourceSink* audioSink) { RTC_DLOG(LS_INFO) << __FUNCTION__; -#if defined(WEBRTC_IOS) - return webrtc::make_ref_counted( + return make_ref_counted( + env, bypass_voice_processing, /*muted_speech_event_handler=*/nullptr, /*error_handler=*/nullptr, audioSink); -#else - RTC_LOG(LS_ERROR) - << "current platform is not supported => this module will self destruct!"; - return nullptr; -#endif } -webrtc::scoped_refptr CreateMutedDetectAudioDeviceModule( - AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, +scoped_refptr CreateAudioDeviceModule( bool bypass_voice_processing, webrtc::AudioSourceSink* audioSink) { RTC_DLOG(LS_INFO) << __FUNCTION__; - return CreateMutedDetectAudioDeviceModule(muted_speech_event_handler, - /*error_handler=*/nullptr, - bypass_voice_processing, - audioSink); + return make_ref_counted( + CreateEnvironment(), + bypass_voice_processing, + /*muted_speech_event_handler=*/nullptr, + /*error_handler=*/nullptr, + audioSink); } -webrtc::scoped_refptr CreateMutedDetectAudioDeviceModule( +scoped_refptr CreateMutedDetectAudioDeviceModule( + const Environment& env, AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, ADMErrorHandler error_handler, bool bypass_voice_processing, webrtc::AudioSourceSink* audioSink) { RTC_DLOG(LS_INFO) << __FUNCTION__; -#if defined(WEBRTC_IOS) - return webrtc::make_ref_counted( - bypass_voice_processing, muted_speech_event_handler, error_handler, audioSink); -#else - RTC_LOG(LS_ERROR) - << "current platform is not supported => this module will self destruct!"; - return nullptr; -#endif + return make_ref_counted( + env, bypass_voice_processing, muted_speech_event_handler, error_handler, audioSink); +} + +scoped_refptr CreateMutedDetectAudioDeviceModule( + AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, + ADMErrorHandler error_handler, + bool bypass_voice_processing, + webrtc::AudioSourceSink* audioSink) { + RTC_DLOG(LS_INFO) << __FUNCTION__; + return make_ref_counted( + CreateEnvironment(), + bypass_voice_processing, + muted_speech_event_handler, + error_handler, + audioSink); } } // namespace webrtc diff --git a/sdk/objc/native/api/objc_audio_device_module.h b/sdk/objc/native/api/objc_audio_device_module.h index a4387df9ee..be1b344866 100644 --- a/sdk/objc/native/api/objc_audio_device_module.h +++ b/sdk/objc/native/api/objc_audio_device_module.h @@ -12,11 +12,14 @@ #define SDK_OBJC_NATIVE_API_OBJC_AUDIO_DEVICE_MODULE_H_ #include "api/audio/audio_device.h" +#include "api/environment/environment.h" +#include "api/scoped_refptr.h" #import "components/audio/RTCAudioDevice.h" namespace webrtc { -webrtc::scoped_refptr CreateAudioDeviceModule( +scoped_refptr CreateAudioDeviceModule( + const Environment& env, id audio_device); } // namespace webrtc diff --git a/sdk/objc/native/api/objc_audio_device_module.mm b/sdk/objc/native/api/objc_audio_device_module.mm index cedb38f661..3eb78ece9b 100644 --- a/sdk/objc/native/api/objc_audio_device_module.mm +++ b/sdk/objc/native/api/objc_audio_device_module.mm @@ -10,6 +10,7 @@ #include "objc_audio_device_module.h" +#include "api/environment/environment.h" #include "api/make_ref_counted.h" #include "rtc_base/logging.h" @@ -17,11 +18,10 @@ namespace webrtc { -webrtc::scoped_refptr CreateAudioDeviceModule( - id audio_device) { +scoped_refptr CreateAudioDeviceModule( + const Environment& env, id audio_device) { RTC_DLOG(LS_INFO) << __FUNCTION__; - return webrtc::make_ref_counted( - audio_device); + return make_ref_counted(env, audio_device); } } // namespace webrtc diff --git a/sdk/objc/native/src/audio/audio_device_ios.h b/sdk/objc/native/src/audio/audio_device_ios.h index 8c070324aa..06aaf072f5 100644 --- a/sdk/objc/native/src/audio/audio_device_ios.h +++ b/sdk/objc/native/src/audio/audio_device_ios.h @@ -14,6 +14,7 @@ #include #include +#include "api/environment/environment.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" @@ -57,6 +58,7 @@ class AudioDeviceIOS : public AudioDeviceGeneric, public VoiceProcessingAudioUnitObserver { public: explicit AudioDeviceIOS( + const Environment& env, bool bypass_voice_processing, AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, AudioDeviceIOSRenderErrorHandler render_error_handler); @@ -223,6 +225,8 @@ class AudioDeviceIOS : public AudioDeviceGeneric, // Resets thread-checkers before a call is restarted. void PrepareForNewStart(); + const Environment env_; + // Determines whether voice processing should be enabled or disabled. const bool bypass_voice_processing_; diff --git a/sdk/objc/native/src/audio/audio_device_ios.mm b/sdk/objc/native/src/audio/audio_device_ios.mm index 8e1f669c67..f2425589fc 100644 --- a/sdk/objc/native/src/audio/audio_device_ios.mm +++ b/sdk/objc/native/src/audio/audio_device_ios.mm @@ -17,6 +17,7 @@ #include #include "api/array_view.h" +#include "api/environment/environment.h" #include "api/task_queue/pending_task_safety_flag.h" #include "helpers.h" #include "modules/audio_device/fine_audio_buffer.h" @@ -25,7 +26,6 @@ #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #import "base/RTCLogging.h" @@ -98,10 +98,12 @@ static void LogDeviceInfo() { #endif // !defined(NDEBUG) AudioDeviceIOS::AudioDeviceIOS( + const Environment& env, bool bypass_voice_processing, AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, AudioDeviceIOSRenderErrorHandler render_error_handler) - : bypass_voice_processing_(bypass_voice_processing), + : env_(env), + bypass_voice_processing_(bypass_voice_processing), muted_speech_event_handler_(muted_speech_event_handler), render_error_handler_(render_error_handler), disregard_next_render_error_(false), @@ -584,7 +586,7 @@ static void LogDeviceInfo() { is_interrupted_); is_interrupted_ = false; if (!audio_unit_) return; - if (webrtc::field_trial::IsEnabled("WebRTC-Audio-iOS-Holding")) { + if (env_.field_trials().IsEnabled("WebRTC-Audio-iOS-Holding")) { // Work around an issue where audio does not restart properly after an // interruption by restarting the audio unit when the interruption ends. if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kStarted) { @@ -693,9 +695,9 @@ static void LogDeviceInfo() { if (restart_audio_unit) { OSStatus result = audio_unit_->Start(); if (result != noErr) { - RTC_OBJC_TYPE(RTCAudioSession)* session = + RTC_OBJC_TYPE(RTCAudioSession)* new_session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; - [session notifyAudioUnitStartFailedWithError:result]; + [new_session notifyAudioUnitStartFailedWithError:result]; RTCLogError(@"Failed to start audio unit with sample rate: %d, reason %d", playout_parameters_.sample_rate(), (int)result); diff --git a/sdk/objc/native/src/audio/audio_device_module_ios.h b/sdk/objc/native/src/audio/audio_device_module_ios.h index 1098fee76c..68b65fdccb 100644 --- a/sdk/objc/native/src/audio/audio_device_module_ios.h +++ b/sdk/objc/native/src/audio/audio_device_module_ios.h @@ -14,7 +14,6 @@ #include #include "api/audio/audio_device.h" -#include "api/task_queue/task_queue_factory.h" #include "audio_device_ios.h" #include "modules/audio_device/audio_device_buffer.h" #include "rtc_base/checks.h" @@ -32,6 +31,7 @@ class AudioDeviceModuleIOS : public AudioDeviceModule { int32_t AttachAudioBuffer(); explicit AudioDeviceModuleIOS( + const Environment& env, bool bypass_voice_processing, MutedSpeechEventHandler muted_speech_event_handler, ADMErrorHandler error_handler, @@ -139,11 +139,12 @@ class AudioDeviceModuleIOS : public AudioDeviceModule { #endif // WEBRTC_IOS private: void ReportError(ADMError error) const; + + const Environment env_; const bool bypass_voice_processing_; MutedSpeechEventHandler muted_speech_event_handler_; ADMErrorHandler error_handler_; bool initialized_ = false; - const std::unique_ptr task_queue_factory_; std::unique_ptr audio_device_; std::unique_ptr audio_device_buffer_; AudioSourceSink* audio_sink_; diff --git a/sdk/objc/native/src/audio/audio_device_module_ios.mm b/sdk/objc/native/src/audio/audio_device_module_ios.mm index a8eafd0825..00799d7b46 100644 --- a/sdk/objc/native/src/audio/audio_device_module_ios.mm +++ b/sdk/objc/native/src/audio/audio_device_module_ios.mm @@ -10,7 +10,9 @@ #include "audio_device_module_ios.h" -#include "api/task_queue/default_task_queue_factory.h" +#include + +#include "api/environment/environment.h" #include "modules/audio_device/audio_device_config.h" #include "modules/audio_device/audio_device_generic.h" #include "rtc_base/checks.h" @@ -43,14 +45,15 @@ namespace ios_adm { AudioDeviceModuleIOS::AudioDeviceModuleIOS( + const Environment& env, bool bypass_voice_processing, MutedSpeechEventHandler muted_speech_event_handler, ADMErrorHandler error_handler, AudioSourceSink* audioSink) - : bypass_voice_processing_(bypass_voice_processing), + : env_(env), + bypass_voice_processing_(bypass_voice_processing), muted_speech_event_handler_(muted_speech_event_handler), error_handler_(error_handler), - task_queue_factory_(CreateDefaultTaskQueueFactory()), audio_sink_(audioSink) { RTC_LOG(LS_INFO) << "current platform is IOS"; RTC_LOG(LS_INFO) << "iPhone Audio APIs will be utilized."; @@ -91,10 +94,13 @@ AudioDeviceIOSRenderErrorHandler error_handler = ^(OSStatus error) { ReportError(kRecordingDeviceFailed); }; - audio_device_buffer_.reset( - new webrtc::AudioDeviceBuffer(task_queue_factory_.get())); - audio_device_.reset(new ios_adm::AudioDeviceIOS( - bypass_voice_processing_, muted_speech_event_handler_, error_handler)); + audio_device_buffer_ = + std::make_unique(&env_.task_queue_factory()); + audio_device_ = + std::make_unique(env_, + bypass_voice_processing_, + muted_speech_event_handler_, + error_handler); RTC_CHECK(audio_device_); audio_device_->AddAudioSourceSink(audio_sink_); diff --git a/sdk/objc/native/src/objc_audio_device.h b/sdk/objc/native/src/objc_audio_device.h index 27eb0af88c..d8edde6f65 100644 --- a/sdk/objc/native/src/objc_audio_device.h +++ b/sdk/objc/native/src/objc_audio_device.h @@ -16,6 +16,7 @@ #import "components/audio/RTCAudioDevice.h" #include "api/audio/audio_device.h" +#include "api/environment/environment.h" #include "modules/audio_device/audio_device_buffer.h" #include "rtc_base/thread.h" @@ -30,7 +31,7 @@ namespace objc_adm { class ObjCAudioDeviceModule : public AudioDeviceModule { public: explicit ObjCAudioDeviceModule( - id audio_device); + const Environment& env, id audio_device); ~ObjCAudioDeviceModule() override; // Retrieve the currently utilized audio layer @@ -219,7 +220,7 @@ class ObjCAudioDeviceModule : public AudioDeviceModule { private: id audio_device_; - const std::unique_ptr task_queue_factory_; + const Environment env_; // AudioDeviceBuffer is a buffer to consume audio recorded by `RTCAudioDevice` // and provide audio to be played via `RTCAudioDevice`. diff --git a/sdk/objc/native/src/objc_audio_device.mm b/sdk/objc/native/src/objc_audio_device.mm index da595ba059..d17dd63811 100644 --- a/sdk/objc/native/src/objc_audio_device.mm +++ b/sdk/objc/native/src/objc_audio_device.mm @@ -9,12 +9,12 @@ */ #include "objc_audio_device.h" -#include "objc_audio_device_delegate.h" + +#include #import "components/audio/RTCAudioDevice.h" #include "modules/audio_device/fine_audio_buffer.h" - -#include "api/task_queue/default_task_queue_factory.h" +#include "objc_audio_device_delegate.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_minmax.h" #include "rtc_base/time_utils.h" @@ -49,9 +49,8 @@ namespace objc_adm { ObjCAudioDeviceModule::ObjCAudioDeviceModule( - id audio_device) - : audio_device_(audio_device), - task_queue_factory_(CreateDefaultTaskQueueFactory()) { + const Environment& env, id audio_device) + : audio_device_(audio_device), env_(env) { RTC_DLOG_F(LS_VERBOSE) << ""; RTC_DCHECK(audio_device_); thread_checker_.Detach(); @@ -82,8 +81,8 @@ io_record_thread_checker_.Detach(); thread_ = Thread::Current(); - audio_device_buffer_.reset( - new webrtc::AudioDeviceBuffer(task_queue_factory_.get())); + audio_device_buffer_ = + std::make_unique(&env_.task_queue_factory()); if (![audio_device_ isInitialized]) { if (audio_device_delegate_ == nil) { diff --git a/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm b/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm index e0ca410937..b87460c0ee 100644 --- a/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm +++ b/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm @@ -16,6 +16,7 @@ #import "sdk/objc/native/api/audio_device_module.h" #endif +#include "api/environment/environment_factory.h" #include "api/scoped_refptr.h" typedef int32_t (^NeedMorePlayDataBlock)(const size_t nSamples, @@ -156,7 +157,8 @@ - (void)setUp { _testEnabled = true; #endif - audioDeviceModule = webrtc::CreateAudioDeviceModule(); + audioDeviceModule = + webrtc::CreateAudioDeviceModule(webrtc::CreateEnvironment()); XCTAssertEqual(0, audioDeviceModule->Init()); XCTAssertEqual( 0, audioDeviceModule->GetPlayoutAudioParameters(&playoutParameters)); @@ -264,7 +266,7 @@ - (void)testStartPlayoutOnTwoInstances { // Create and initialize a second/extra ADM instance. The default ADM is // created by the test harness. webrtc::scoped_refptr secondAudioDeviceModule = - webrtc::CreateAudioDeviceModule(); + webrtc::CreateAudioDeviceModule(webrtc::CreateEnvironment()); XCTAssertNotEqual(secondAudioDeviceModule.get(), nullptr); XCTAssertEqual(0, secondAudioDeviceModule->Init()); diff --git a/sdk/objc/unittests/RTCAudioDevice_xctest.mm b/sdk/objc/unittests/RTCAudioDevice_xctest.mm index 5bdb90c3b8..f117832d22 100644 --- a/sdk/objc/unittests/RTCAudioDevice_xctest.mm +++ b/sdk/objc/unittests/RTCAudioDevice_xctest.mm @@ -12,6 +12,8 @@ #include +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/task_queue/default_task_queue_factory.h" #import "sdk/objc/components/audio/RTCAudioSession+Private.h" @@ -45,8 +47,10 @@ - (void)setUp { _testEnabled = true; #endif - _audioDeviceModule = webrtc::CreateAudioDeviceModule(); + webrtc::Environment env = webrtc::CreateEnvironment(); + _audioDeviceModule = webrtc::CreateAudioDeviceModule(env); _audio_device.reset(new webrtc::ios_adm::AudioDeviceIOS( + env, /*bypass_voice_processing=*/false, /*muted_speech_event_handler=*/nullptr, /*render_error_handler=*/nullptr)); @@ -149,6 +153,7 @@ - (void)testMuteSpeechHandlerCalledWithStartedWhenSpeechActivityHasStarted { }; _audio_device.reset(new webrtc::ios_adm::AudioDeviceIOS( + webrtc::CreateEnvironment(), /*bypass_voice_processing=*/false, /*muted_speech_event_handler=*/muted_speech_event_handler, /*render_error_handler=*/nullptr)); @@ -169,6 +174,7 @@ - (void)testMuteSpeechHandlerCalledWithEndedWhenSpeechActivityHasEnded { }; _audio_device.reset(new webrtc::ios_adm::AudioDeviceIOS( + webrtc::CreateEnvironment(), /*bypass_voice_processing=*/false, /*muted_speech_event_handler=*/muted_speech_event_handler, /*render_error_handler=*/nullptr)); diff --git a/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm b/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm index 95d8b058f9..929490b0ba 100644 --- a/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm +++ b/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm @@ -40,9 +40,9 @@ - (void)testBuilder { id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]); OCMExpect([factoryMock alloc]).andReturn(factoryMock); + webrtc::PeerConnectionFactoryDependencies default_deps; RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] - ignoringNonObjectArgs] initWithMediaAndDependencies: - webrtc::PeerConnectionFactoryDependencies()]); + ignoringNonObjectArgs] initWithMediaAndDependencies:default_deps]); RTCPeerConnectionFactoryBuilder* builder = [[RTCPeerConnectionFactoryBuilder alloc] init]; RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory = @@ -55,9 +55,9 @@ - (void)testDefaultComponentsBuilder { id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]); OCMExpect([factoryMock alloc]).andReturn(factoryMock); + webrtc::PeerConnectionFactoryDependencies default_deps; RTC_UNUSED([[[[factoryMock expect] andReturn:factoryMock] - ignoringNonObjectArgs] initWithMediaAndDependencies: - webrtc::PeerConnectionFactoryDependencies()]); + ignoringNonObjectArgs] initWithMediaAndDependencies:default_deps]); RTCPeerConnectionFactoryBuilder* builder = [RTCPeerConnectionFactoryBuilder defaultBuilder]; RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory = diff --git a/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m b/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m index c5e39a6a30..ec88d6d257 100644 --- a/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m +++ b/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m @@ -370,11 +370,11 @@ - (void)testRollback { __weak RTC_OBJC_TYPE(RTCPeerConnection) *weakPC1 = pc1; [pc1 setLocalDescription:offer - completionHandler:^(NSError *error) { - XCTAssertNil(error); + completionHandler:^(NSError *sldError) { + XCTAssertNil(sldError); [weakPC1 setLocalDescription:rollback - completionHandler:^(NSError *error) { - XCTAssertNil(error); + completionHandler:^(NSError *rollbackError) { + XCTAssertNil(rollbackError); }]; }]; NSTimeInterval negotiationTimeout = 15; @@ -522,8 +522,8 @@ - (void)testSetCodecPreferences { offerForConstraints:constraints completionHandler:^( RTC_OBJC_TYPE(RTCSessionDescription) *_Nullable sdp, - NSError *_Nullable error) { - XCTAssertNil(error); + NSError *_Nullable createOfferError) { + XCTAssertNil(createOfferError); XCTAssertNotNil(sdp); NSArray *rtpMaps = [self rtpMapsFromSDP:sdp.sdp]; @@ -611,8 +611,8 @@ __block RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *targetExtension = offerForConstraints:constraints completionHandler:^( RTC_OBJC_TYPE(RTCSessionDescription) *_Nullable sdp, - NSError *_Nullable error) { - XCTAssertNil(error); + NSError *_Nullable createOfferError) { + XCTAssertNil(createOfferError); XCTAssertNotNil(sdp); NSArray *extMaps = [self extMapsFromSDP:sdp.sdp]; @@ -712,34 +712,37 @@ - (bool)negotiatePeerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)pc1 [weakPC1 offerForConstraints:sdpConstraints completionHandler:^(RTC_OBJC_TYPE(RTCSessionDescription) * offer, - NSError * error) { - XCTAssertNil(error); + NSError * createOfferError) { + XCTAssertNil(createOfferError); XCTAssertNotNil(offer); [weakPC1 setLocalDescription:offer - completionHandler:^(NSError *error) { - XCTAssertNil(error); + completionHandler:^(NSError *sldError) { + XCTAssertNil(sldError); [weakPC2 setRemoteDescription:offer - completionHandler:^(NSError *error) { - XCTAssertNil(error); + completionHandler:^(NSError *srdError) { + XCTAssertNil(srdError); [weakPC2 answerForConstraints:sdpConstraints completionHandler:^( RTC_OBJC_TYPE(RTCSessionDescription) * answer, - NSError * error) { - XCTAssertNil(error); + NSError * createAnswerError) { + XCTAssertNil(createAnswerError); XCTAssertNotNil(answer); [weakPC2 setLocalDescription:answer - completionHandler:^(NSError *error) { - XCTAssertNil(error); + completionHandler:^( + NSError *sldAnswerError) { + XCTAssertNil(sldAnswerError); [weakPC1 setRemoteDescription:answer completionHandler:^( - NSError *error) { - XCTAssertNil(error); + NSError + *srdAnswerError) { + XCTAssertNil( + srdAnswerError); dispatch_semaphore_signal( negotiatedSem); }]; diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 786c469689..a1fab28ad8 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -17,15 +17,9 @@ rtc_library("system_wrappers") { sources = [ "include/clock.h", "include/cpu_features_wrapper.h", - "include/cpu_info.h", "include/ntp_time.h", - "include/rtp_to_ntp_estimator.h", - "include/sleep.h", "source/clock.cc", "source/cpu_features.cc", - "source/cpu_info.cc", - "source/rtp_to_ntp_estimator.cc", - "source/sleep.cc", ] defines = [] @@ -79,6 +73,7 @@ rtc_library("system_wrappers") { rtc_library("field_trial") { visibility = [ "*" ] + poisonous = [ "environment_construction" ] public = [ "include/field_trial.h" ] sources = [ "source/field_trial.cc" ] if (rtc_exclude_field_trial_default) { @@ -111,34 +106,18 @@ rtc_library("metrics") { ] } -rtc_library("denormal_disabler") { - visibility = [ "*" ] - public = [ "include/denormal_disabler.h" ] - sources = [ "source/denormal_disabler.cc" ] - deps = [ - "../rtc_base:checks", - "../rtc_base/system:arch", - ] - if (is_clang) { - cflags_cc = [ "-Wno-unused-private-field" ] - } -} - if (rtc_include_tests && !build_with_chromium) { rtc_test("system_wrappers_unittests") { testonly = true sources = [ "source/clock_unittest.cc", - "source/denormal_disabler_unittest.cc", "source/field_trial_unittest.cc", "source/metrics_default_unittest.cc", "source/metrics_unittest.cc", "source/ntp_time_unittest.cc", - "source/rtp_to_ntp_estimator_unittest.cc", ] deps = [ - ":denormal_disabler", ":field_trial", ":metrics", ":system_wrappers", diff --git a/system_wrappers/include/cpu_features_wrapper.h b/system_wrappers/include/cpu_features_wrapper.h index 254e2d8dda..d73b12abe8 100644 --- a/system_wrappers/include/cpu_features_wrapper.h +++ b/system_wrappers/include/cpu_features_wrapper.h @@ -11,7 +11,7 @@ #ifndef SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ #define SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_ -#include +#include namespace webrtc { @@ -29,9 +29,6 @@ enum { // Returns true if the CPU supports the feature. int GetCPUInfo(CPUFeature feature); -// No CPU feature is available => straight C path. -int GetCPUInfoNoASM(CPUFeature feature); - // Return the features in an ARM device. // It detects the features in the hardware platform, and returns supported // values in the above enum definition as a bitmask. diff --git a/system_wrappers/include/cpu_info.h b/system_wrappers/include/cpu_info.h deleted file mode 100644 index ab546c7214..0000000000 --- a/system_wrappers/include/cpu_info.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_ -#define SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_ - -#include - -namespace webrtc { - -class CpuInfo { - public: - static uint32_t DetectNumberOfCores(); - - private: - CpuInfo() {} -}; - -} // namespace webrtc - -#endif // SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_ diff --git a/system_wrappers/include/sleep.h b/system_wrappers/include/sleep.h deleted file mode 100644 index 3bf8df219f..0000000000 --- a/system_wrappers/include/sleep.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -// An OS-independent sleep function. - -#ifndef SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ -#define SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ - -namespace webrtc { - -// This function sleeps for the specified number of milliseconds. -// It may return early if the thread is woken by some other event, -// such as the delivery of a signal on Unix. -void SleepMs(int msecs); - -} // namespace webrtc - -#endif // SYSTEM_WRAPPERS_INCLUDE_SLEEP_H_ diff --git a/system_wrappers/source/cpu_features.cc b/system_wrappers/source/cpu_features.cc index 4a6170c520..3050ad8f09 100644 --- a/system_wrappers/source/cpu_features.cc +++ b/system_wrappers/source/cpu_features.cc @@ -19,12 +19,6 @@ namespace webrtc { -// No CPU feature is available => straight C path. -int GetCPUInfoNoASM(CPUFeature feature) { - (void)feature; - return 0; -} - #if defined(WEBRTC_ARCH_X86_FAMILY) #if defined(WEBRTC_ENABLE_AVX2) diff --git a/system_wrappers/source/field_trial.cc b/system_wrappers/source/field_trial.cc index a1309edbfe..5efa01c9ef 100644 --- a/system_wrappers/source/field_trial.cc +++ b/system_wrappers/source/field_trial.cc @@ -28,7 +28,7 @@ namespace webrtc { namespace field_trial { -static const char* trials_init_string = NULL; +static const char* trials_init_string = nullptr; namespace { @@ -127,7 +127,7 @@ std::string FindFullName(absl::string_view name) { << name << " is not registered, see g3doc/field-trials.md."; #endif - if (trials_init_string == NULL) + if (trials_init_string == nullptr) return std::string(); absl::string_view trials_string(trials_init_string); diff --git a/system_wrappers/source/sleep.cc b/system_wrappers/source/sleep.cc deleted file mode 100644 index e2fa486118..0000000000 --- a/system_wrappers/source/sleep.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -// An OS-independent sleep function. - -#include "system_wrappers/include/sleep.h" - -#ifdef _WIN32 -// For Sleep() -#include -#else -// For nanosleep() -#include -#endif - -namespace webrtc { - -void SleepMs(int msecs) { -#ifdef _WIN32 - Sleep(msecs); -#else - struct timespec short_wait; - struct timespec remainder; - short_wait.tv_sec = msecs / 1000; - short_wait.tv_nsec = (msecs % 1000) * 1000 * 1000; - nanosleep(&short_wait, &remainder); -#endif -} - -} // namespace webrtc diff --git a/test/BUILD.gn b/test/BUILD.gn index a17bbcdb13..85e65b3785 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -329,16 +329,9 @@ rtc_library("field_trial") { } rtc_library("explicit_key_value_config") { - sources = [ - "explicit_key_value_config.cc", - "explicit_key_value_config.h", - ] + sources = [ "explicit_key_value_config.h" ] - deps = [ - "../api:field_trials_registry", - "../rtc_base:checks", - "//third_party/abseil-cpp/absl/strings:string_view", - ] + deps = [ "../api:field_trials" ] } rtc_library("scoped_key_value_config") { @@ -594,12 +587,14 @@ if (rtc_include_tests) { deps = [ ":field_trial", + ":fileutils", ":perf_test", ":resources_dir_flag", ":test_flags", ":test_support", "../api/test/metrics:chrome_perf_dashboard_metrics_exporter", "../api/test/metrics:global_metrics_logger_and_exporter", + "../api/test/metrics:metric", "../api/test/metrics:metrics_exporter", "../api/test/metrics:metrics_set_proto_file_exporter", "../api/test/metrics:print_result_proxy_metrics_exporter", @@ -1018,6 +1013,7 @@ rtc_library("fake_video_codecs") { "../rtc_base:checks", "../rtc_base:criticalsection", "../rtc_base:macromagic", + "../rtc_base:threading", "../rtc_base:timeutils", "../rtc_base/synchronization:mutex", "../system_wrappers", @@ -1031,7 +1027,10 @@ rtc_library("null_transport") { "null_transport.cc", "null_transport.h", ] - deps = [ "../api:transport_api" ] + deps = [ + "../api:array_view", + "../api:transport_api", + ] } rtc_library("encoder_settings") { @@ -1086,6 +1085,7 @@ rtc_library("mock_transport") { ] deps = [ ":test_support", + "../api:array_view", "../api:transport_api", ] } @@ -1263,10 +1263,12 @@ if (!build_with_chromium) { "../api:frame_generator_api", "../api:rtp_headers", "../api:rtp_parameters", + "../api:scoped_refptr", "../api:simulated_network_api", "../api:transport_api", "../api/audio:audio_device", "../api/audio:builtin_audio_processing_builder", + "../api/audio_codecs:audio_codecs_api", "../api/audio_codecs:builtin_audio_decoder_factory", "../api/audio_codecs:builtin_audio_encoder_factory", "../api/environment", @@ -1274,16 +1276,19 @@ if (!build_with_chromium) { "../api/rtc_event_log", "../api/task_queue", "../api/test/video:function_video_factory", + "../api/transport:bitrate_settings", "../api/transport:field_trial_based_config", "../api/units:time_delta", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_bitrate_allocator_factory", "../api/video:video_frame", + "../api/video:video_rtp_headers", "../api/video_codecs:video_codecs_api", "../call", "../call:call_interfaces", "../call:fake_network", "../call:simulated_packet_receiver", + "../call:video_receive_stream_api", "../call:video_send_stream_api", "../modules/audio_device:test_audio_device_module", "../modules/audio_mixer:audio_mixer_impl", @@ -1431,10 +1436,10 @@ rtc_library("video_codec_tester") { "../rtc_base:rtc_event", "../rtc_base:stringutils", "../rtc_base:task_queue_for_test", + "../rtc_base:threading", "../rtc_base:timeutils", "../rtc_base/synchronization:mutex", "../rtc_base/system:file_wrapper", - "../system_wrappers", "../test:fileutils", "../video/config:encoder_config", "../video/config:streams_config", diff --git a/test/call_config_utils.cc b/test/call_config_utils.cc index d93c902bbe..ff586821f7 100644 --- a/test/call_config_utils.cc +++ b/test/call_config_utils.cc @@ -20,7 +20,7 @@ namespace test { // back into a valid object. This will not initialize the decoders or the // renderer. VideoReceiveStreamInterface::Config ParseVideoReceiveStreamJsonConfig( - webrtc::Transport* transport, + Transport* transport, const Json::Value& json) { auto receive_config = VideoReceiveStreamInterface::Config(transport); for (const auto& decoder_json : json["decoders"]) { diff --git a/test/call_test.cc b/test/call_test.cc index 37e2ef9f09..4d55cde9ef 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -10,26 +10,59 @@ #include "test/call_test.h" -#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include "api/audio/audio_device.h" #include "api/audio/builtin_audio_processing_builder.h" +#include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/call/transport.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/task_queue/task_queue_base.h" +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/rtp_headers.h" +#include "api/rtp_parameters.h" +#include "api/scoped_refptr.h" +#include "api/task_queue/task_queue_factory.h" #include "api/test/create_frame_generator.h" +#include "api/test/simulated_network.h" +#include "api/transport/bitrate_settings.h" +#include "api/units/time_delta.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_rotation.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" +#include "call/audio_state.h" +#include "call/call.h" +#include "call/call_config.h" #include "call/fake_network_pipe.h" +#include "call/flexfec_receive_stream.h" #include "call/packet_receiver.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/audio_device/include/test_audio_device.h" #include "modules/audio_mixer/audio_mixer_impl.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" -#include "rtc_base/event.h" #include "rtc_base/task_queue_for_test.h" +#include "test/encoder_settings.h" +#include "test/fake_decoder.h" #include "test/fake_encoder.h" +#include "test/fake_vp8_encoder.h" +#include "test/frame_generator_capturer.h" +#include "test/gtest.h" #include "test/network/simulated_network.h" #include "test/rtp_rtcp_observer.h" #include "test/testsupport/file_utils.h" @@ -531,10 +564,10 @@ void CallTest::CreateFrameGeneratorCapturer(int framerate, void CallTest::CreateFakeAudioDevices( std::unique_ptr capturer, std::unique_ptr renderer) { - fake_send_audio_device_ = TestAudioDeviceModule::Create( - &env_.task_queue_factory(), std::move(capturer), nullptr, 1.f); - fake_recv_audio_device_ = TestAudioDeviceModule::Create( - &env_.task_queue_factory(), nullptr, std::move(renderer), 1.f); + fake_send_audio_device_ = + TestAudioDeviceModule::Create(env_, std::move(capturer), nullptr, 1.f); + fake_recv_audio_device_ = + TestAudioDeviceModule::Create(env_, nullptr, std::move(renderer), 1.f); } void CallTest::CreateVideoStreams() { diff --git a/test/configurable_frame_size_encoder.cc b/test/configurable_frame_size_encoder.cc index e18a87cd7e..51274f49db 100644 --- a/test/configurable_frame_size_encoder.cc +++ b/test/configurable_frame_size_encoder.cc @@ -26,7 +26,7 @@ namespace test { ConfigurableFrameSizeEncoder::ConfigurableFrameSizeEncoder( size_t max_frame_size) - : callback_(NULL), + : callback_(nullptr), current_frame_size_(max_frame_size), codec_type_(kVideoCodecGeneric) {} diff --git a/test/direct_transport.cc b/test/direct_transport.cc index fe68dd7048..5b8e53aa2a 100644 --- a/test/direct_transport.cc +++ b/test/direct_transport.cc @@ -96,10 +96,10 @@ bool DirectTransport::SendRtp(ArrayView data, const RtpHeaderExtensionMap* extensions = nullptr; MediaType media_type = demuxer_.GetMediaType(data.data(), data.size()); switch (demuxer_.GetMediaType(data.data(), data.size())) { - case webrtc::MediaType::AUDIO: + case MediaType::AUDIO: extensions = &audio_extensions_; break; - case webrtc::MediaType::VIDEO: + case MediaType::VIDEO: extensions = &video_extensions_; break; default: @@ -120,7 +120,8 @@ bool DirectTransport::SendRtp(ArrayView data, return true; } -bool DirectTransport::SendRtcp(ArrayView data) { +bool DirectTransport::SendRtcp(ArrayView data, + const PacketOptions& /* options */) { fake_network_->DeliverRtcpPacket(CopyOnWriteBuffer(data)); MutexLock lock(&process_lock_); if (!next_process_task_.Running()) diff --git a/test/direct_transport.h b/test/direct_transport.h index 4cf3f262b6..3b79957a3b 100644 --- a/test/direct_transport.h +++ b/test/direct_transport.h @@ -10,14 +10,19 @@ #ifndef TEST_DIRECT_TRANSPORT_H_ #define TEST_DIRECT_TRANSPORT_H_ +#include +#include +#include #include +#include "api/array_view.h" #include "api/call/transport.h" -#include "api/sequence_checker.h" +#include "api/media_types.h" +#include "api/rtp_parameters.h" #include "api/task_queue/task_queue_base.h" -#include "api/test/simulated_network.h" #include "call/call.h" #include "call/simulated_packet_receiver.h" +#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/thread_annotations.h" @@ -63,7 +68,8 @@ class DirectTransport : public Transport { bool SendRtp(ArrayView data, const PacketOptions& options) override; - bool SendRtcp(ArrayView data) override; + bool SendRtcp(ArrayView data, + const PacketOptions& options) override; int GetAverageDelayMs(); diff --git a/test/encoder_settings.cc b/test/encoder_settings.cc index d5009ca9ef..d8c9348c43 100644 --- a/test/encoder_settings.cc +++ b/test/encoder_settings.cc @@ -29,7 +29,7 @@ const int DefaultVideoStreamFactory::kDefaultMinBitratePerStream[] = { std::vector CreateVideoStreams( int width, int height, - const webrtc::VideoEncoderConfig& encoder_config) { + const VideoEncoderConfig& encoder_config) { RTC_DCHECK(encoder_config.number_of_streams <= DefaultVideoStreamFactory::kMaxNumberOfStreams); @@ -109,7 +109,7 @@ std::vector DefaultVideoStreamFactory::CreateEncoderStreams( const FieldTrialsView& /*field_trials*/, int frame_width, int frame_height, - const webrtc::VideoEncoderConfig& encoder_config) { + const VideoEncoderConfig& encoder_config) { return CreateVideoStreams(frame_width, frame_height, encoder_config); } diff --git a/test/explicit_key_value_config.cc b/test/explicit_key_value_config.cc deleted file mode 100644 index 90690c0514..0000000000 --- a/test/explicit_key_value_config.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "test/explicit_key_value_config.h" - -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" - -namespace webrtc { -namespace test { - -ExplicitKeyValueConfig::ExplicitKeyValueConfig(absl::string_view s) { - std::string::size_type field_start = 0; - while (field_start < s.size()) { - std::string::size_type separator_pos = s.find('/', field_start); - RTC_CHECK_NE(separator_pos, std::string::npos) - << "Missing separator '/' after field trial key."; - RTC_CHECK_GT(separator_pos, field_start) - << "Field trial key cannot be empty."; - std::string key(s.substr(field_start, separator_pos - field_start)); - field_start = separator_pos + 1; - - RTC_CHECK_LT(field_start, s.size()) - << "Missing value after field trial key. String ended."; - separator_pos = s.find('/', field_start); - RTC_CHECK_NE(separator_pos, std::string::npos) - << "Missing terminating '/' in field trial string."; - RTC_CHECK_GT(separator_pos, field_start) - << "Field trial value cannot be empty."; - std::string value(s.substr(field_start, separator_pos - field_start)); - field_start = separator_pos + 1; - - key_value_map_[key] = value; - } - // This check is technically redundant due to earlier checks. - // We nevertheless keep the check to make it clear that the entire - // string has been processed, and without indexing past the end. - RTC_CHECK_EQ(field_start, s.size()); -} - -std::string ExplicitKeyValueConfig::GetValue(absl::string_view key) const { - auto it = key_value_map_.find(key); - if (it != key_value_map_.end()) - return it->second; - return ""; -} - -} // namespace test -} // namespace webrtc diff --git a/test/explicit_key_value_config.h b/test/explicit_key_value_config.h index f14a10432c..0766447853 100644 --- a/test/explicit_key_value_config.h +++ b/test/explicit_key_value_config.h @@ -11,27 +11,13 @@ #ifndef TEST_EXPLICIT_KEY_VALUE_CONFIG_H_ #define TEST_EXPLICIT_KEY_VALUE_CONFIG_H_ -#include -#include -#include - -#include "absl/strings/string_view.h" -#include "api/field_trials_registry.h" +#include "api/field_trials.h" namespace webrtc { namespace test { -class ExplicitKeyValueConfig : public FieldTrialsRegistry { - public: - explicit ExplicitKeyValueConfig(absl::string_view s); - - private: - std::string GetValue(absl::string_view key) const override; - - // Unlike std::less, std::less<> is transparent and allows - // heterogeneous lookup directly with absl::string_view. - std::map> key_value_map_; -}; +// TODO: bugs.webrtc.org/42220378 - Use `FieldTrials` directly. +using ExplicitKeyValueConfig = FieldTrials; } // namespace test } // namespace webrtc diff --git a/test/fake_decoder.cc b/test/fake_decoder.cc index 36c6dd5c9a..d077ae7b5a 100644 --- a/test/fake_decoder.cc +++ b/test/fake_decoder.cc @@ -50,7 +50,7 @@ int32_t FakeDecoder::Decode(const EncodedImage& input, int64_t render_time_ms) { I420Buffer::SetBlack(buffer.get()); VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(buffer) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_ms(render_time_ms) .build(); frame.set_rtp_timestamp(input.RtpTimestamp()); diff --git a/test/fake_encoder.cc b/test/fake_encoder.cc index 15e2702c79..e069b4b4a3 100644 --- a/test/fake_encoder.cc +++ b/test/fake_encoder.cc @@ -24,7 +24,7 @@ #include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/include/video_error_codes.h" #include "rtc_base/checks.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" namespace webrtc { namespace test { @@ -380,7 +380,7 @@ int32_t DelayedEncoder::Encode(const VideoFrame& input_image, const std::vector* frame_types) { RTC_DCHECK_RUN_ON(&sequence_checker_); - SleepMs(delay_ms_); + Thread::SleepMs(delay_ms_); return FakeEncoder::Encode(input_image, frame_types); } diff --git a/test/fake_vp8_decoder.cc b/test/fake_vp8_decoder.cc index 3a4793986b..9471d11280 100644 --- a/test/fake_vp8_decoder.cc +++ b/test/fake_vp8_decoder.cc @@ -55,7 +55,7 @@ int32_t FakeVp8Decoder::Decode(const EncodedImage& input, VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(width_, height_)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_ms(render_time_ms) .build(); frame.set_rtp_timestamp(input.RtpTimestamp()); diff --git a/test/field_trial.cc b/test/field_trial.cc index 3d6c6ac617..5267d7a457 100644 --- a/test/field_trial.cc +++ b/test/field_trial.cc @@ -21,18 +21,17 @@ namespace test { ScopedFieldTrials::ScopedFieldTrials(absl::string_view config) : current_field_trials_(config), - previous_field_trials_(webrtc::field_trial::GetFieldTrialString()) { - RTC_CHECK(webrtc::field_trial::FieldTrialsStringIsValid( - current_field_trials_.c_str())) + previous_field_trials_(field_trial::GetFieldTrialString()) { + RTC_CHECK( + field_trial::FieldTrialsStringIsValid(current_field_trials_.c_str())) << "Invalid field trials string: " << current_field_trials_; - webrtc::field_trial::InitFieldTrialsFromString(current_field_trials_.c_str()); + field_trial::InitFieldTrialsFromString(current_field_trials_.c_str()); } ScopedFieldTrials::~ScopedFieldTrials() { - RTC_CHECK( - webrtc::field_trial::FieldTrialsStringIsValid(previous_field_trials_)) + RTC_CHECK(field_trial::FieldTrialsStringIsValid(previous_field_trials_)) << "Invalid field trials string: " << previous_field_trials_; - webrtc::field_trial::InitFieldTrialsFromString(previous_field_trials_); + field_trial::InitFieldTrialsFromString(previous_field_trials_); } } // namespace test diff --git a/test/frame_generator.cc b/test/frame_generator.cc index 42f4617b26..aab3991c36 100644 --- a/test/frame_generator.cc +++ b/test/frame_generator.cc @@ -139,7 +139,7 @@ void SquareGenerator::Square::Draw( return; // Optionally draw on alpha plane if given. - const webrtc::I420ABufferInterface* yuva_buffer = frame_buffer->GetI420A(); + const I420ABufferInterface* yuva_buffer = frame_buffer->GetI420A(); for (int y = y_; y < y_ + length; ++y) { uint8_t* pos_y = (const_cast(yuva_buffer->DataA()) + x_ + y * yuva_buffer->StrideA()); diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc index 0e2f2ee952..48051cd4eb 100644 --- a/test/frame_generator_capturer.cc +++ b/test/frame_generator_capturer.cc @@ -107,8 +107,7 @@ void FrameGeneratorCapturer::InsertFrame() { // Skip frames that are identical to the previous one but still send at // least one frame every second. if (number_of_frames_skipped_ < target_capture_fps_ - 1 && - webrtc::test::FrameBufsEqual(last_frame_captured_, - frame_data.buffer)) { + test::FrameBufsEqual(last_frame_captured_, frame_data.buffer)) { ++number_of_frames_skipped_; return; } diff --git a/test/frame_utils.cc b/test/frame_utils.cc index 1e2019bb7f..1a45c04a2a 100644 --- a/test/frame_utils.cc +++ b/test/frame_utils.cc @@ -35,7 +35,7 @@ bool EqualPlane(const uint8_t* data1, return true; } -bool FramesEqual(const webrtc::VideoFrame& f1, const webrtc::VideoFrame& f2) { +bool FramesEqual(const VideoFrame& f1, const VideoFrame& f2) { if (f1.rtp_timestamp() != f2.rtp_timestamp() || f1.ntp_time_ms() != f2.ntp_time_ms() || f1.render_time_ms() != f2.render_time_ms()) { @@ -44,8 +44,8 @@ bool FramesEqual(const webrtc::VideoFrame& f1, const webrtc::VideoFrame& f2) { return FrameBufsEqual(f1.video_frame_buffer(), f2.video_frame_buffer()); } -bool FrameBufsEqual(const scoped_refptr& f1, - const scoped_refptr& f2) { +bool FrameBufsEqual(const scoped_refptr& f1, + const scoped_refptr& f2) { if (f1 == f2) { return true; } @@ -59,8 +59,8 @@ bool FrameBufsEqual(const scoped_refptr& f1, return false; } - scoped_refptr f1_i420 = f1->ToI420(); - scoped_refptr f2_i420 = f2->ToI420(); + scoped_refptr f1_i420 = f1->ToI420(); + scoped_refptr f2_i420 = f2->ToI420(); return EqualPlane(f1_i420->DataY(), f2_i420->DataY(), f1_i420->StrideY(), f2_i420->StrideY(), f1_i420->width(), f1_i420->height()) && EqualPlane(f1_i420->DataU(), f2_i420->DataU(), f1_i420->StrideU(), diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index 60a9d18b99..acf6db2a6a 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -105,17 +105,6 @@ webrtc_fuzzer_test("vp9_depacketizer_fuzzer") { ] } -webrtc_fuzzer_test("dtls_utils_fuzzer") { - sources = [ "dtls_utils_fuzzer.cc" ] - deps = [ - "../../api:array_view", - "../../p2p:dtls_utils", - ] - - # Seed from boringssl DTLS corpus. - seed_corpus = "//third_party/boringssl/src/fuzz/dtls_client_corpus" -} - webrtc_fuzzer_test("vp8_qp_parser_fuzzer") { sources = [ "vp8_qp_parser_fuzzer.cc" ] deps = [ @@ -564,6 +553,7 @@ webrtc_fuzzer_test("audio_processing_fuzzer") { deps = [ ":audio_processing_fuzzer_helper", "../../api:array_view", + "../../api:field_trials", "../../api:scoped_refptr", "../../api/audio:aec3_factory", "../../api/audio:audio_processing", @@ -573,19 +563,10 @@ webrtc_fuzzer_test("audio_processing_fuzzer") { "../../api/environment", "../../api/environment:environment_factory", "../../api/task_queue", - "../../api/task_queue:default_task_queue_factory", - "../../modules/audio_processing", - "../../modules/audio_processing:audio_buffer", - "../../modules/audio_processing:audioproc_test_utils", - "../../modules/audio_processing/aec3", "../../modules/audio_processing/aec_dump", - "../../modules/audio_processing/aec_dump:aec_dump_impl", "../../rtc_base:checks", - "../../rtc_base:macromagic", - "../../rtc_base:safe_minmax", - "../../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", ] seed_corpus = "corpora/audio_processing-corpus" } diff --git a/test/fuzzers/audio_processing_configs_fuzzer.cc b/test/fuzzers/audio_processing_configs_fuzzer.cc index 80a5f626dc..04a50e21ae 100644 --- a/test/fuzzers/audio_processing_configs_fuzzer.cc +++ b/test/fuzzers/audio_processing_configs_fuzzer.cc @@ -16,6 +16,7 @@ #include #include "absl/base/nullability.h" +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" @@ -24,20 +25,19 @@ #include "api/audio/echo_detector_creator.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_factory.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" -#include "rtc_base/arraysize.h" #include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" #include "test/fuzzers/audio_processing_fuzzer_helper.h" #include "test/fuzzers/fuzz_data_helper.h" namespace webrtc { namespace { -const std::string kFieldTrialNames[] = { +constexpr absl::string_view kFieldTrialNames[] = { "WebRTC-Aec3MinErleDuringOnsetsKillSwitch", "WebRTC-Aec3ShortHeadroomKillSwitch", }; @@ -49,7 +49,6 @@ const Environment& GetEnvironment() { webrtc::scoped_refptr CreateApm( test::FuzzDataHelper* fuzz_data, - std::string* field_trial_string, TaskQueueBase* absl_nonnull worker_queue) { // Parse boolean values for optionally enabling different // configurable public components of APM. @@ -69,19 +68,22 @@ webrtc::scoped_refptr CreateApm( const float gain_controller2_gain_db = fuzz_data->ReadOrDefaultValue(0) % 50; - constexpr size_t kNumFieldTrials = arraysize(kFieldTrialNames); + constexpr size_t kNumFieldTrials = std::size(kFieldTrialNames); // Verify that the read data type has enough bits to fuzz the field trials. using FieldTrialBitmaskType = uint64_t; static_assert(kNumFieldTrials <= sizeof(FieldTrialBitmaskType) * 8, "FieldTrialBitmaskType is not large enough."); std::bitset field_trial_bitmask( fuzz_data->ReadOrDefaultValue(0)); + auto field_trials = std::make_unique(""); for (size_t i = 0; i < kNumFieldTrials; ++i) { if (field_trial_bitmask[i]) { - *field_trial_string += kFieldTrialNames[i] + "/Enabled/"; + field_trials->Set(kFieldTrialNames[i], "Enabled"); } } - field_trial::InitFieldTrialsFromString(field_trial_string->c_str()); + EnvironmentFactory env_factory(GetEnvironment()); + env_factory.Set(std::move(field_trials)); + const Environment env = env_factory.Create(); // Ignore a few bytes. Bytes from this segment will be used for // future config flag changes. We assume 40 bytes is enough for @@ -123,7 +125,7 @@ webrtc::scoped_refptr CreateApm( .SetEchoControlFactory(std::move(echo_control_factory)) .SetEchoDetector(use_red ? CreateEchoDetector() : nullptr) .SetConfig(apm_config) - .Build(GetEnvironment()); + .Build(env); #ifdef WEBRTC_LINUX apm->AttachAecDump(AecDumpFactory::Create("/dev/null", -1, worker_queue)); @@ -139,14 +141,11 @@ void FuzzOneInput(const uint8_t* data, size_t size) { return; } test::FuzzDataHelper fuzz_data(webrtc::ArrayView(data, size)); - // This string must be in scope during execution, according to documentation - // for field_trial.h. Hence it's created here and not in CreateApm. - std::string field_trial_string = ""; std::unique_ptr worker_queue = GetEnvironment().task_queue_factory().CreateTaskQueue( "rtc-low-prio", TaskQueueFactory::Priority::LOW); - auto apm = CreateApm(&fuzz_data, &field_trial_string, worker_queue.get()); + auto apm = CreateApm(&fuzz_data, worker_queue.get()); if (apm) { FuzzAudioProcessing(&fuzz_data, std::move(apm)); diff --git a/test/fuzzers/rtp_packet_fuzzer.cc b/test/fuzzers/rtp_packet_fuzzer.cc index d2d4376bed..2b9c95a5b7 100644 --- a/test/fuzzers/rtp_packet_fuzzer.cc +++ b/test/fuzzers/rtp_packet_fuzzer.cc @@ -79,10 +79,11 @@ void FuzzOneInput(const uint8_t* data, size_t size) { case kRtpExtensionNone: case kRtpExtensionNumberOfExtensions: break; - case kRtpExtensionTransmissionTimeOffset: + case kRtpExtensionTransmissionTimeOffset: { int32_t offset; packet.GetExtension(&offset); break; + } case kRtpExtensionAudioLevel: { AudioLevel audio_level; packet.GetExtension(&audio_level); @@ -102,14 +103,16 @@ void FuzzOneInput(const uint8_t* data, size_t size) { packet.GetExtension(&extension); break; } - case kRtpExtensionVideoRotation: + case kRtpExtensionVideoRotation: { uint8_t rotation; packet.GetExtension(&rotation); break; - case kRtpExtensionTransportSequenceNumber: + } + case kRtpExtensionTransportSequenceNumber: { uint16_t seqnum; packet.GetExtension(&seqnum); break; + } case kRtpExtensionTransportSequenceNumber02: { uint16_t seqnum; std::optional feedback_request; @@ -122,10 +125,11 @@ void FuzzOneInput(const uint8_t* data, size_t size) { packet.GetExtension(&playout); break; } - case kRtpExtensionVideoContentType: + case kRtpExtensionVideoContentType: { VideoContentType content_type; packet.GetExtension(&content_type); break; + } case kRtpExtensionVideoTiming: { VideoSendTiming timing; packet.GetExtension(&timing); diff --git a/test/fuzzers/utils/rtp_replayer.cc b/test/fuzzers/utils/rtp_replayer.cc index 6af6d330de..081d31ba80 100644 --- a/test/fuzzers/utils/rtp_replayer.cc +++ b/test/fuzzers/utils/rtp_replayer.cc @@ -52,7 +52,7 @@ void RtpReplayer::Replay( // Work around: webrtc calls webrtc::Random(clock.TimeInMicroseconds()) // everywhere and Random expects non-zero seed. Let's set the clock non-zero // to make them happy. - fake_clock.SetTime(webrtc::Timestamp::Millis(1)); + fake_clock.SetTime(Timestamp::Millis(1)); // Attempt to create an RtpReader from the input file. auto rtp_reader = CreateRtpReader(rtp_dump_data, rtp_dump_size); @@ -170,7 +170,7 @@ void RtpReplayer::ReplayPackets( if (deliver_in_ms > 0) { // StatsCounter::ReportMetricToAggregatedCounter is O(elapsed time). // Set an upper limit to prevent waste time. - clock->AdvanceTime(webrtc::TimeDelta::Millis( + clock->AdvanceTime(TimeDelta::Millis( std::min(deliver_in_ms, static_cast(100)))); } diff --git a/test/gl/gl_renderer.cc b/test/gl/gl_renderer.cc index 10162ee056..4a16419b8a 100644 --- a/test/gl/gl_renderer.cc +++ b/test/gl/gl_renderer.cc @@ -19,7 +19,7 @@ namespace webrtc { namespace test { GlRenderer::GlRenderer() - : is_init_(false), buffer_(NULL), width_(0), height_(0) {} + : is_init_(false), buffer_(nullptr), width_(0), height_(0) {} void GlRenderer::Init() { RTC_DCHECK(!is_init_); @@ -36,7 +36,7 @@ void GlRenderer::Destroy() { is_init_ = false; delete[] buffer_; - buffer_ = NULL; + buffer_ = nullptr; glDeleteTextures(1, &texture_); } @@ -70,7 +70,7 @@ void GlRenderer::ResizeVideo(size_t width, size_t height) { GL_UNSIGNED_INT_8_8_8_8, static_cast(buffer_)); } -void GlRenderer::OnFrame(const webrtc::VideoFrame& frame) { +void GlRenderer::OnFrame(const VideoFrame& frame) { RTC_DCHECK(is_init_); if (static_cast(frame.width()) != width_ || @@ -78,7 +78,7 @@ void GlRenderer::OnFrame(const webrtc::VideoFrame& frame) { ResizeVideo(frame.width(), frame.height()); } - webrtc::ConvertFromI420(frame, VideoType::kBGRA, 0, buffer_); + ConvertFromI420(frame, VideoType::kBGRA, 0, buffer_); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture_); diff --git a/test/linux/glx_renderer.cc b/test/linux/glx_renderer.cc index 509a6c286e..8e66b9272c 100644 --- a/test/linux/glx_renderer.cc +++ b/test/linux/glx_renderer.cc @@ -18,7 +18,7 @@ namespace webrtc { namespace test { GlxRenderer::GlxRenderer(size_t width, size_t height) - : width_(width), height_(height), display_(NULL), context_(NULL) { + : width_(width), height_(height), display_(nullptr), context_(nullptr) { RTC_DCHECK_GT(width, 0); RTC_DCHECK_GT(height, 0); } @@ -28,7 +28,7 @@ GlxRenderer::~GlxRenderer() { } bool GlxRenderer::Init(const char* window_title) { - if ((display_ = XOpenDisplay(NULL)) == NULL) { + if ((display_ = XOpenDisplay(nullptr)) == nullptr) { Destroy(); return false; } @@ -41,13 +41,13 @@ bool GlxRenderer::Init(const char* window_title) { GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None, }; - if ((vi = glXChooseVisual(display_, screen, attr_list)) == NULL) { + if ((vi = glXChooseVisual(display_, screen, attr_list)) == nullptr) { Destroy(); return false; } - context_ = glXCreateContext(display_, vi, 0, true); - if (context_ == NULL) { + context_ = glXCreateContext(display_, vi, nullptr, true); + if (context_ == nullptr) { Destroy(); return false; } @@ -64,7 +64,7 @@ bool GlxRenderer::Init(const char* window_title) { XFree(vi); XSetStandardProperties(display_, window_, window_title, window_title, None, - NULL, 0, NULL); + nullptr, 0, nullptr); Atom wm_delete = XInternAtom(display_, "WM_DELETE_WINDOW", True); if (wm_delete != None) { @@ -78,7 +78,7 @@ bool GlxRenderer::Init(const char* window_title) { return false; } GlRenderer::Init(); - if (!glXMakeCurrent(display_, None, NULL)) { + if (!glXMakeCurrent(display_, None, nullptr)) { Destroy(); return false; } @@ -88,17 +88,17 @@ bool GlxRenderer::Init(const char* window_title) { } void GlxRenderer::Destroy() { - if (context_ != NULL) { + if (context_ != nullptr) { glXMakeCurrent(display_, window_, context_); GlRenderer::Destroy(); - glXMakeCurrent(display_, None, NULL); + glXMakeCurrent(display_, None, nullptr); glXDestroyContext(display_, context_); - context_ = NULL; + context_ = nullptr; } - if (display_ != NULL) { + if (display_ != nullptr) { XCloseDisplay(display_); - display_ = NULL; + display_ = nullptr; } } @@ -109,7 +109,7 @@ GlxRenderer* GlxRenderer::Create(const char* window_title, if (!glx_renderer->Init(window_title)) { // TODO(pbos): Add GLX-failed warning here? delete glx_renderer; - return NULL; + return nullptr; } return glx_renderer; } @@ -121,12 +121,12 @@ void GlxRenderer::Resize(size_t width, size_t height) { abort(); } GlRenderer::ResizeViewport(width_, height_); - if (!glXMakeCurrent(display_, None, NULL)) { + if (!glXMakeCurrent(display_, None, nullptr)) { abort(); } XSizeHints* size_hints = XAllocSizeHints(); - if (size_hints == NULL) { + if (size_hints == nullptr) { abort(); } size_hints->flags = PAspect; @@ -141,7 +141,7 @@ void GlxRenderer::Resize(size_t width, size_t height) { XConfigureWindow(display_, window_, CWWidth | CWHeight, &wc); } -void GlxRenderer::OnFrame(const webrtc::VideoFrame& frame) { +void GlxRenderer::OnFrame(const VideoFrame& frame) { if (static_cast(frame.width()) != width_ || static_cast(frame.height()) != height_) { Resize(static_cast(frame.width()), @@ -167,7 +167,7 @@ void GlxRenderer::OnFrame(const webrtc::VideoFrame& frame) { GlRenderer::OnFrame(frame); glXSwapBuffers(display_, window_); - if (!glXMakeCurrent(display_, None, NULL)) { + if (!glXMakeCurrent(display_, None, nullptr)) { abort(); } } diff --git a/test/linux/video_renderer_linux.cc b/test/linux/video_renderer_linux.cc index 74c95235df..3d07bd0326 100644 --- a/test/linux/video_renderer_linux.cc +++ b/test/linux/video_renderer_linux.cc @@ -19,10 +19,10 @@ VideoRenderer* VideoRenderer::CreatePlatformRenderer(const char* window_title, size_t width, size_t height) { GlxRenderer* glx_renderer = GlxRenderer::Create(window_title, width, height); - if (glx_renderer != NULL) { + if (glx_renderer != nullptr) { return glx_renderer; } - return NULL; + return nullptr; } } // namespace test } // namespace webrtc diff --git a/test/mock_transport.h b/test/mock_transport.h index 87b60b3068..9cd6113ce7 100644 --- a/test/mock_transport.h +++ b/test/mock_transport.h @@ -11,6 +11,9 @@ #ifndef TEST_MOCK_TRANSPORT_H_ #define TEST_MOCK_TRANSPORT_H_ +#include + +#include "api/array_view.h" #include "api/call/transport.h" #include "test/gmock.h" @@ -25,7 +28,10 @@ class MockTransport : public Transport { SendRtp, (webrtc::ArrayView, const PacketOptions&), (override)); - MOCK_METHOD(bool, SendRtcp, (webrtc::ArrayView), (override)); + MOCK_METHOD(bool, + SendRtcp, + (webrtc::ArrayView, const PacketOptions&), + (override)); }; } // namespace webrtc diff --git a/test/network/BUILD.gn b/test/network/BUILD.gn index 6f2b030081..870b56769e 100644 --- a/test/network/BUILD.gn +++ b/test/network/BUILD.gn @@ -112,6 +112,8 @@ if (rtc_include_tests && !build_with_chromium) { "../../api:rtc_error_matchers", "../../api:scoped_refptr", "../../api:simulated_network_api", + "../../api/environment", + "../../api/environment:environment_factory", "../../api/rtc_event_log:rtc_event_log_factory", "../../api/task_queue:default_task_queue_factory", "../../api/test/network_emulation", @@ -122,6 +124,7 @@ if (rtc_include_tests && !build_with_chromium) { "../../pc:peerconnection_wrapper", "../../rtc_base:network", "../../rtc_base:task_queue_for_test", + "../../rtc_base:threading", ] } } @@ -191,29 +194,44 @@ if (rtc_include_tests) { deps = [ ":emulated_network", ":simulated_network", + "../../api:create_network_emulation_manager", "../../api:network_emulation_manager_api", + "../../api:rtp_parameters", "../../api:simulated_network_api", + "../../api/environment:environment", + "../../api/environment:environment_factory", + "../../api/rtc_event_log:rtc_event_log", + "../../api/rtc_event_log:rtc_event_log_factory", "../../api/transport:network_control", "../../api/transport:test_feedback_generator_interface", "../../api/units:data_rate", "../../api/units:data_size", "../../api/units:time_delta", "../../api/units:timestamp", + "../../logging:rtc_event_rtp_rtcp", + "../../modules/rtp_rtcp:rtp_rtcp_format", "../../rtc_base:checks", "//third_party/abseil-cpp/absl/memory", ] } - rtc_library("feedback_generator_unittest") { - testonly = true - sources = [ "feedback_generator_unittest.cc" ] - deps = [ - "..:test_support", - "../../api:simulated_network_api", - "../../api/transport:test_feedback_generator", - "../../api/transport:test_feedback_generator_interface", - "../../api/units:time_delta", - ] + if (rtc_enable_protobuf) { + rtc_library("feedback_generator_unittest") { + testonly = true + sources = [ "feedback_generator_unittest.cc" ] + deps = [ + "..:test_support", + "../../api:create_network_emulation_manager", + "../../api:network_emulation_manager_api", + "../../api:simulated_network_api", + "../../api/rtc_event_log:rtc_event_log", + "../../api/transport:test_feedback_generator", + "../../api/transport:test_feedback_generator_interface", + "../../api/units:time_delta", + "../../logging:rtc_event_log_parser", + "../logging:log_writer", + ] + } } if (!build_with_chromium) { @@ -221,13 +239,15 @@ if (rtc_include_tests) { testonly = true deps = [ ":cross_traffic_unittest", - ":feedback_generator_unittest", ":network_emulation_pc_unittest", ":network_emulation_unittest", ":simulated_network_unittest", ] if (rtc_enable_protobuf) { - deps += [ ":schedulable_network_behavior_test" ] + deps += [ + ":feedback_generator_unittest", + ":schedulable_network_behavior_test", + ] } } } diff --git a/test/network/emulated_turn_server.cc b/test/network/emulated_turn_server.cc index 6e5cc089ae..fe001d6f8d 100644 --- a/test/network/emulated_turn_server.cc +++ b/test/network/emulated_turn_server.cc @@ -87,8 +87,8 @@ namespace test { // sending data back into the emulated network. class EmulatedTURNServer::AsyncPacketSocketWrapper : public AsyncPacketSocket { public: - AsyncPacketSocketWrapper(webrtc::test::EmulatedTURNServer* turn_server, - webrtc::EmulatedEndpoint* endpoint, + AsyncPacketSocketWrapper(test::EmulatedTURNServer* turn_server, + EmulatedEndpoint* endpoint, uint16_t port) : turn_server_(turn_server), endpoint_(endpoint), @@ -126,8 +126,8 @@ class EmulatedTURNServer::AsyncPacketSocketWrapper : public AsyncPacketSocket { void SetError(int error) override {} private: - webrtc::test::EmulatedTURNServer* const turn_server_; - webrtc::EmulatedEndpoint* const endpoint_; + test::EmulatedTURNServer* const turn_server_; + EmulatedEndpoint* const endpoint_; const SocketAddress local_address_; }; @@ -182,7 +182,7 @@ AsyncPacketSocket* EmulatedTURNServer::Wrap(EmulatedEndpoint* endpoint) { return socket; } -void EmulatedTURNServer::OnPacketReceived(webrtc::EmulatedIpPacket packet) { +void EmulatedTURNServer::OnPacketReceived(EmulatedIpPacket packet) { // Copy from EmulatedEndpoint to webrtc::AsyncPacketSocket. thread_->PostTask([this, packet(std::move(packet))]() { RTC_DCHECK_RUN_ON(thread_.get()); diff --git a/test/network/fake_network_socket_server.cc b/test/network/fake_network_socket_server.cc index c9a1fb50a5..26e8911d98 100644 --- a/test/network/fake_network_socket_server.cc +++ b/test/network/fake_network_socket_server.cc @@ -296,7 +296,7 @@ void FakeNetworkSocketServer::SetMessageQueue(Thread* thread) { } // Always returns true (if return false, it won't be invoked again...) -bool FakeNetworkSocketServer::Wait(webrtc::TimeDelta max_wait_duration, +bool FakeNetworkSocketServer::Wait(TimeDelta max_wait_duration, bool process_io) { RTC_DCHECK(thread_ == Thread::Current()); if (!max_wait_duration.IsZero()) diff --git a/test/network/feedback_generator.cc b/test/network/feedback_generator.cc index 7462c99e54..eedbb19a06 100644 --- a/test/network/feedback_generator.cc +++ b/test/network/feedback_generator.cc @@ -10,90 +10,126 @@ #include "test/network/feedback_generator.h" #include +#include #include #include #include "absl/memory/memory.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/rtc_event_log/rtc_event_log_factory.h" +#include "api/rtp_parameters.h" +#include "api/test/create_network_emulation_manager.h" #include "api/test/network_emulation_manager.h" #include "api/test/simulated_network.h" #include "api/transport/network_types.h" +#include "api/transport/test/feedback_generator_interface.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "logging/rtc_event_log/events/rtc_event_rtcp_packet_incoming.h" +#include "logging/rtc_event_log/events/rtc_event_rtp_packet_outgoing.h" +#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" +#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" +#include "modules/rtp_rtcp/source/rtp_header_extensions.h" +#include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "rtc_base/checks.h" -#include "test/network/network_emulation_manager.h" +#include "test/network/network_emulation.h" #include "test/network/simulated_network.h" - namespace webrtc { -FeedbackGeneratorImpl::FeedbackGeneratorImpl( - FeedbackGeneratorImpl::Config config) - : conf_(config), - net_({.time_mode = TimeMode::kSimulated}), - send_link_{new SimulatedNetwork(conf_.send_link)}, - ret_link_{new SimulatedNetwork(conf_.return_link)}, - route_(this, - net_.CreateRoute( - {net_.CreateEmulatedNode(absl::WrapUnique(send_link_))}), - net_.CreateRoute( - {net_.CreateEmulatedNode(absl::WrapUnique(ret_link_))})) {} -Timestamp FeedbackGeneratorImpl::Now() { - return net_.Now(); +namespace { +Environment GetEnvironment(NetworkEmulationManager& net) { + EnvironmentFactory factory; + factory.Set(net.time_controller()->GetClock()); + factory.Set(net.time_controller()->GetTaskQueueFactory()); + return factory.Create(); } -void FeedbackGeneratorImpl::Sleep(TimeDelta duration) { - net_.time_controller()->AdvanceTime(duration); +EmulatedRoute* CreateRoute(NetworkEmulationManager& net, + std::vector link) { + if (!link.empty()) { + return net.CreateRoute(link); + } else { + return net.CreateRoute({net.CreateUnconstrainedEmulatedNode()}); + } } -void FeedbackGeneratorImpl::SendPacket(size_t size) { +} // namespace + +FeedbackGeneratorWithoutNetworkImpl::FeedbackGeneratorWithoutNetworkImpl( + Config config, + NetworkEmulationManager& net) + : net_(net), + feedback_interval_(config.feedback_interval), + feedback_packet_size_(config.feedback_packet_size), + event_log_(RtcEventLogFactory().Create(GetEnvironment(net))), + route_(this, + CreateRoute(net, std::move(config.sent_via_nodes)), + CreateRoute(net, std::move(config.received_via_nodes))) { + RtpExtension transport_sequence_number_extension; + transport_sequence_number_extension.uri = + RtpExtension::kTransportSequenceNumberUri; + transport_sequence_number_extension.id = 1; + transport_sequence_number_extension.encrypt = false; + rtp_extensions_.RegisterByUri(transport_sequence_number_extension.id, + transport_sequence_number_extension.uri); +} + +void FeedbackGeneratorWithoutNetworkImpl::SendPacket(size_t total_size, + size_t overhead) { SentPacket sent; sent.send_time = Now(); - sent.size = DataSize::Bytes(size); + sent.size = DataSize::Bytes(total_size); sent.sequence_number = sequence_number_++; sent_packets_.push(sent); - route_.SendRequest(size, sent); + + RtpPacketToSend packet_to_send(&rtp_extensions_); + packet_to_send.set_transport_sequence_number(sent.sequence_number); + packet_to_send.SetExtension(sent.sequence_number); + RTC_DCHECK(total_size > packet_to_send.headers_size() + overhead); + if (total_size > packet_to_send.headers_size() + overhead) { + packet_to_send.SetPayloadSize(total_size - packet_to_send.headers_size() - + overhead); + RTC_DCHECK_EQ(packet_to_send.size(), total_size - overhead); + } + event_log_->Log(std::make_unique( + packet_to_send, /*probe_cluster_id*/ 0)); + + route_.SendRequest(total_size, sent); } -std::vector FeedbackGeneratorImpl::PopFeedback() { +std::vector +FeedbackGeneratorWithoutNetworkImpl::PopFeedback() { std::vector ret; ret.swap(feedback_); return ret; } -void FeedbackGeneratorImpl::SetSendConfig(BuiltInNetworkBehaviorConfig config) { - conf_.send_link = config; - send_link_->SetConfig(conf_.send_link); +Timestamp FeedbackGeneratorWithoutNetworkImpl::Now() { + return net_.time_controller()->GetClock()->CurrentTime(); } -void FeedbackGeneratorImpl::SetReturnConfig( - BuiltInNetworkBehaviorConfig config) { - conf_.return_link = config; - ret_link_->SetConfig(conf_.return_link); -} - -void FeedbackGeneratorImpl::SetSendLinkCapacity(DataRate capacity) { - conf_.send_link.link_capacity = capacity; - send_link_->SetConfig(conf_.send_link); -} - -void FeedbackGeneratorImpl::OnRequest(SentPacket packet, - Timestamp arrival_time) { +void FeedbackGeneratorWithoutNetworkImpl::OnRequest(SentPacket packet, + Timestamp arrival_time) { PacketResult result; result.sent_packet = packet; result.receive_time = arrival_time; received_packets_.push_back(result); Timestamp first_recv = received_packets_.front().receive_time; - if (Now() - first_recv > conf_.feedback_interval) { - route_.SendResponse(conf_.feedback_packet_size.bytes(), + if (Now() - first_recv > feedback_interval_) { + route_.SendResponse(feedback_packet_size_.bytes(), std::move(received_packets_)); received_packets_ = {}; } } -void FeedbackGeneratorImpl::OnResponse(std::vector packet_results, - Timestamp arrival_time) { +void FeedbackGeneratorWithoutNetworkImpl::OnResponse( + std::vector packet_results, + Timestamp arrival_time) { TransportPacketsFeedback feedback; feedback.feedback_time = arrival_time; std::vector::const_iterator received_packet_iterator = @@ -117,7 +153,64 @@ void FeedbackGeneratorImpl::OnResponse(std::vector packet_results, } sent_packets_.pop(); } + rtcp::TransportFeedback transport_feedback; + transport_feedback.SetBase( + feedback.ReceivedWithSendInfo()[0].sent_packet.sequence_number, + feedback.ReceivedWithSendInfo()[0].receive_time); + for (const auto& received_packet : feedback.ReceivedWithSendInfo()) { + transport_feedback.AddReceivedPacket( + received_packet.sent_packet.sequence_number, + received_packet.receive_time); + } + event_log_->Log( + std::make_unique(transport_feedback.Build())); feedback_.push_back(feedback); } +FeedbackGeneratorImpl::FeedbackGeneratorImpl( + FeedbackGeneratorImpl::Config config) + : conf_(config), + net_(CreateNetworkEmulationManager({.time_mode = TimeMode::kSimulated})), + send_link_{new SimulatedNetwork(conf_.send_link)}, + ret_link_{new SimulatedNetwork(conf_.return_link)}, + delegate_({.sent_via_nodes = {net_->CreateEmulatedNode( + absl::WrapUnique(send_link_))}, + .received_via_nodes = {net_->CreateEmulatedNode( + absl::WrapUnique(ret_link_))}, + .feedback_interval = config.feedback_interval, + .feedback_packet_size = config.feedback_packet_size}, + *net_) {} + +Timestamp FeedbackGeneratorImpl::Now() { + return delegate_.Now(); +} + +void FeedbackGeneratorImpl::Sleep(TimeDelta duration) { + net_->time_controller()->AdvanceTime(duration); +} + +void FeedbackGeneratorImpl::SendPacket(size_t size) { + delegate_.SendPacket(size, /*overhead=*/0); +} + +std::vector FeedbackGeneratorImpl::PopFeedback() { + return delegate_.PopFeedback(); +} + +void FeedbackGeneratorImpl::SetSendConfig(BuiltInNetworkBehaviorConfig config) { + conf_.send_link = config; + send_link_->SetConfig(conf_.send_link); +} + +void FeedbackGeneratorImpl::SetReturnConfig( + BuiltInNetworkBehaviorConfig config) { + conf_.return_link = config; + ret_link_->SetConfig(conf_.return_link); +} + +void FeedbackGeneratorImpl::SetSendLinkCapacity(DataRate capacity) { + conf_.send_link.link_capacity = capacity; + send_link_->SetConfig(conf_.send_link); +} + } // namespace webrtc diff --git a/test/network/feedback_generator.h b/test/network/feedback_generator.h index c7975f69fa..97dc1441c6 100644 --- a/test/network/feedback_generator.h +++ b/test/network/feedback_generator.h @@ -12,27 +12,63 @@ #include #include +#include #include #include +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/test/network_emulation_manager.h" #include "api/test/simulated_network.h" #include "api/transport/network_types.h" #include "api/transport/test/feedback_generator_interface.h" #include "api/units/data_rate.h" +#include "api/units/data_size.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "test/network/network_emulation.h" -#include "test/network/network_emulation_manager.h" #include "test/network/simulated_network.h" namespace webrtc { -class FeedbackGeneratorImpl - : public FeedbackGenerator, - public TwoWayFakeTrafficRoute>:: +class FeedbackGeneratorWithoutNetworkImpl + : public FeedbackGeneratorWithoutNetwork, + TwoWayFakeTrafficRoute>:: TrafficHandlerInterface { + public: + FeedbackGeneratorWithoutNetworkImpl(Config config, + NetworkEmulationManager& net); + ~FeedbackGeneratorWithoutNetworkImpl() override = default; + + void SendPacket(size_t total_size, size_t overhead) override; + std::vector PopFeedback() override; + + RtcEventLog& event_log() override { return *event_log_; } + void OnRequest(SentPacket packet, Timestamp arrival_time) override; + void OnResponse(std::vector packet_results, + Timestamp arrival_time) override; + + Timestamp Now(); + + private: + NetworkEmulationManager& net_; + const TimeDelta feedback_interval_; + const DataSize feedback_packet_size_; + + std::unique_ptr event_log_; + TwoWayFakeTrafficRoute> route_; + + std::queue sent_packets_; + std::vector received_packets_; + std::vector feedback_; + int64_t sequence_number_ = 1; + RtpHeaderExtensionMap rtp_extensions_; +}; + +class FeedbackGeneratorImpl : public FeedbackGenerator { public: explicit FeedbackGeneratorImpl(Config config); + Timestamp Now() override; void Sleep(TimeDelta duration) override; void SendPacket(size_t size) override; @@ -43,21 +79,15 @@ class FeedbackGeneratorImpl void SetSendLinkCapacity(DataRate capacity) override; - void OnRequest(SentPacket packet, Timestamp arrival_time) override; - void OnResponse(std::vector packet_results, - Timestamp arrival_time) override; + RtcEventLog& event_log() override { return delegate_.event_log(); } private: Config conf_; - ::webrtc::test::NetworkEmulationManagerImpl net_; + std::unique_ptr net_; SimulatedNetwork* const send_link_; SimulatedNetwork* const ret_link_; - TwoWayFakeTrafficRoute> route_; - - std::queue sent_packets_; - std::vector received_packets_; - std::vector feedback_; - int64_t sequence_number_ = 1; + FeedbackGeneratorWithoutNetworkImpl delegate_; }; + } // namespace webrtc #endif // TEST_NETWORK_FEEDBACK_GENERATOR_H_ diff --git a/test/network/feedback_generator_unittest.cc b/test/network/feedback_generator_unittest.cc index 6ad41e5696..ff2073da05 100644 --- a/test/network/feedback_generator_unittest.cc +++ b/test/network/feedback_generator_unittest.cc @@ -9,14 +9,28 @@ */ #include +#include +#include +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/test/create_network_emulation_manager.h" +#include "api/test/network_emulation_manager.h" #include "api/test/simulated_network.h" #include "api/transport/test/create_feedback_generator.h" #include "api/transport/test/feedback_generator_interface.h" #include "api/units/time_delta.h" +#include "logging/rtc_event_log/rtc_event_log_parser.h" +#include "test/gmock.h" #include "test/gtest.h" +#include "test/logging/log_writer.h" +#include "test/logging/memory_log_writer.h" namespace webrtc { + +using ::testing::Eq; +using ::testing::Field; +using ::testing::SizeIs; + TEST(FeedbackGeneratorTest, ReportsFeedbackForSentPackets) { size_t kPacketSize = 1000; auto gen = CreateFeedbackGenerator(FeedbackGenerator::Config()); @@ -49,4 +63,63 @@ TEST(FeedbackGeneratorTest, FeedbackIncludesLostPackets) { EXPECT_NEAR(feedback_list[0].LostWithSendInfo().size(), feedback_list[0].ReceivedWithSendInfo().size(), 2); } + +TEST(FeedbackGeneratorTest, WritesToEventLog) { + size_t kPacketSize = 1000; + auto gen = CreateFeedbackGenerator(FeedbackGenerator::Config()); + + MemoryLogStorage log_storage; + std::unique_ptr log_writer_factory = + log_storage.CreateFactory(); + + const std::string rtc_event_log_file_name = "eventlog"; + gen->event_log().StartLogging( + log_writer_factory->Create(rtc_event_log_file_name), + RtcEventLog::kImmediateOutput); + + for (int i = 0; i < 10; ++i) { + gen->SendPacket(kPacketSize); + gen->Sleep(TimeDelta::Millis(50)); + } + auto feedback_list = gen->PopFeedback(); + ASSERT_GT(feedback_list.size(), 0u); + + gen->event_log().StopLogging(); + ParsedRtcEventLog parsed_log; + auto it = log_storage.logs().find(rtc_event_log_file_name); + ASSERT_TRUE(it != log_storage.logs().end()); + ASSERT_TRUE(parsed_log.ParseString(it->second).ok()); + + EXPECT_THAT(parsed_log.GetOutgoingPacketInfos(), SizeIs(10)); + EXPECT_THAT(parsed_log.GetOutgoingPacketInfos(), + Each(Field(&LoggedPacketInfo::size, Eq(kPacketSize)))); + EXPECT_THAT(parsed_log.transport_feedbacks(PacketDirection::kIncomingPacket), + SizeIs(feedback_list.size())); +} + +TEST(FeedbackGeneratorWithoutNetworkTest, ReportsFeedbackForSentPackets) { + auto network_emulation_manager = + CreateNetworkEmulationManager({.time_mode = TimeMode::kSimulated}); + std::unique_ptr gen = + CreateFeedbackGeneratorWithoutNetwork( + FeedbackGeneratorWithoutNetwork::Config(), + *network_emulation_manager); + size_t kTotalPacketSize = 1000; + size_t kOverhead = 40; + + for (int i = 0; i < 10; ++i) { + gen->SendPacket(kTotalPacketSize, kOverhead); + network_emulation_manager->time_controller()->AdvanceTime( + TimeDelta::Millis(50)); + } + auto feedback_list = gen->PopFeedback(); + EXPECT_GT(feedback_list.size(), 0u); + for (const auto& feedback : feedback_list) { + EXPECT_GT(feedback.packet_feedbacks.size(), 0u); + for (const auto& packet : feedback.packet_feedbacks) { + EXPECT_EQ(packet.sent_packet.size.bytes(), kTotalPacketSize); + } + } +} + } // namespace webrtc diff --git a/test/network/network_emulation_pc_unittest.cc b/test/network/network_emulation_pc_unittest.cc index 2eca595ebe..376471bbfc 100644 --- a/test/network/network_emulation_pc_unittest.cc +++ b/test/network/network_emulation_pc_unittest.cc @@ -14,23 +14,23 @@ #include "api/audio_options.h" #include "api/enable_media_with_defaults.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/jsep.h" #include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/scoped_refptr.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/test/network_emulation_manager.h" #include "api/test/rtc_error_matchers.h" #include "api/test/simulated_network.h" -#include "api/transport/field_trial_based_config.h" #include "modules/audio_device/include/test_audio_device.h" #include "p2p/base/port_allocator.h" #include "pc/peer_connection_wrapper.h" #include "pc/test/mock_peer_connection_observers.h" -#include "rtc_base/network.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/network/network_emulation.h" @@ -63,17 +63,17 @@ bool AddIceCandidates(PeerConnectionWrapper* peer, scoped_refptr CreatePeerConnectionFactory( Thread* signaling_thread, EmulatedNetworkManagerInterface* network) { + const Environment env = CreateEnvironment(); PeerConnectionFactoryDependencies pcf_deps; - pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); + pcf_deps.env = env; pcf_deps.event_log_factory = std::make_unique(); pcf_deps.network_thread = network->network_thread(); pcf_deps.signaling_thread = signaling_thread; - pcf_deps.trials = std::make_unique(); pcf_deps.socket_factory = network->socket_factory(); pcf_deps.network_manager = network->ReleaseNetworkManager(); pcf_deps.adm = TestAudioDeviceModule::Create( - pcf_deps.task_queue_factory.get(), + env, TestAudioDeviceModule::CreatePulsedNoiseCapturer(kMaxAptitude, kSamplingFrequency), TestAudioDeviceModule::CreateDiscardRenderer(kSamplingFrequency), @@ -92,7 +92,7 @@ scoped_refptr CreatePeerConnection( // This test does not support TCP rtc_configuration.port_allocator_config.flags = PORTALLOCATOR_DISABLE_TCP; if (turn_server != nullptr) { - webrtc::PeerConnectionInterface::IceServer server; + PeerConnectionInterface::IceServer server; server.username = turn_server->GetIceServerConfig().username; server.password = turn_server->GetIceServerConfig().username; server.urls.push_back(turn_server->GetIceServerConfig().url); @@ -161,7 +161,7 @@ TEST(NetworkEmulationManagerPCTest, Run) { std::move(bob_observer)); SendTask(signaling_thread.get(), [&]() { - scoped_refptr source = + scoped_refptr source = alice_pcf->CreateAudioSource(AudioOptions()); scoped_refptr track = alice_pcf->CreateAudioTrack("audio", source.get()); @@ -272,7 +272,7 @@ TEST(NetworkEmulationManagerPCTest, RunTURN) { std::move(bob_observer)); SendTask(signaling_thread.get(), [&]() { - scoped_refptr source = + scoped_refptr source = alice_pcf->CreateAudioSource(AudioOptions()); scoped_refptr track = alice_pcf->CreateAudioTrack("audio", source.get()); diff --git a/test/network/network_emulation_unittest.cc b/test/network/network_emulation_unittest.cc index eb158c0753..7ebd0d9075 100644 --- a/test/network/network_emulation_unittest.cc +++ b/test/network/network_emulation_unittest.cc @@ -86,7 +86,7 @@ class SocketReader : public sigslot::has_slots<> { return received_count_; } - webrtc::EcnMarking LastEcnMarking() const { + EcnMarking LastEcnMarking() const { MutexLock lock(&lock_); return last_ecn_mark_; } @@ -95,7 +95,7 @@ class SocketReader : public sigslot::has_slots<> { Socket* const socket_; Thread* const network_thread_; Buffer payload_; - webrtc::EcnMarking last_ecn_mark_; + EcnMarking last_ecn_mark_; mutable Mutex lock_; int received_count_ RTC_GUARDED_BY(lock_) = 0; @@ -440,7 +440,7 @@ TEST(NetworkEmulationManagerTest, EcnMarkingIsPropagated) { network_manager.time_controller()->AdvanceTime(TimeDelta::Seconds(1)); EXPECT_EQ(r2.ReceivedCount(), 1); - EXPECT_EQ(r2.LastEcnMarking(), webrtc::EcnMarking::kEct1); + EXPECT_EQ(r2.LastEcnMarking(), EcnMarking::kEct1); std::atomic received_stats_count{0}; nt1->GetStats([&](EmulatedNetworkStats st) { diff --git a/test/network/schedulable_network_behavior.cc b/test/network/schedulable_network_behavior.cc index 114754dc64..f602eb39f6 100644 --- a/test/network/schedulable_network_behavior.cc +++ b/test/network/schedulable_network_behavior.cc @@ -30,7 +30,6 @@ namespace webrtc { namespace { -using ::webrtc::BuiltInNetworkBehaviorConfig; void UpdateConfigFromSchedule( const network_behaviour::NetworkConfigScheduleItem& schedule_item, @@ -77,8 +76,8 @@ BuiltInNetworkBehaviorConfig GetInitialConfig( SchedulableNetworkBehavior::SchedulableNetworkBehavior( network_behaviour::NetworkConfigSchedule schedule, uint64_t random_seed, - webrtc::Clock& clock, - absl::AnyInvocable start_callback) + Clock& clock, + absl::AnyInvocable start_callback) : SimulatedNetwork(GetInitialConfig(schedule), random_seed), schedule_(std::move(schedule)), start_condition_(std::move(start_callback)), @@ -90,19 +89,18 @@ SchedulableNetworkBehavior::SchedulableNetworkBehavior( sequence_checker_.Detach(); } -bool SchedulableNetworkBehavior::EnqueuePacket( - webrtc::PacketInFlightInfo packet_info) { +bool SchedulableNetworkBehavior::EnqueuePacket(PacketInFlightInfo packet_info) { RTC_DCHECK_RUN_ON(&sequence_checker_); if (first_send_time_.IsInfinite() && - start_condition_(webrtc::Timestamp::Micros(packet_info.send_time_us))) { - first_send_time_ = webrtc::Timestamp::Micros(packet_info.send_time_us); + start_condition_(Timestamp::Micros(packet_info.send_time_us))) { + first_send_time_ = Timestamp::Micros(packet_info.send_time_us); if (schedule_.item().size() > 1) { RTC_CHECK_LT(next_schedule_index_, schedule_.item().size()); - webrtc::TimeDelta delay = - webrtc::TimeDelta::Millis(schedule_.item()[next_schedule_index_] - .time_since_first_sent_packet_ms()); + TimeDelta delay = + TimeDelta::Millis(schedule_.item()[next_schedule_index_] + .time_since_first_sent_packet_ms()); schedule_task_ = RepeatingTaskHandle::DelayedStart( - webrtc::TaskQueueBase::Current(), delay, + TaskQueueBase::Current(), delay, [this] { return UpdateConfigAndReschedule(); }); } } @@ -118,9 +116,8 @@ TimeDelta SchedulableNetworkBehavior::UpdateConfigAndReschedule() { UpdateConfigFromSchedule(next_config, config_); SimulatedNetwork::SetConfig(config_, reschedule_time); next_schedule_index_ = ++next_schedule_index_ % schedule_.item().size(); - webrtc::TimeDelta delay = webrtc::TimeDelta::Zero(); - webrtc::TimeDelta time_since_first_sent_packet = - reschedule_time - first_send_time_; + TimeDelta delay = TimeDelta::Zero(); + TimeDelta time_since_first_sent_packet = reschedule_time - first_send_time_; if (next_schedule_index_ != 0) { delay = std::max(TimeDelta::Millis(schedule_.item()[next_schedule_index_] .time_since_first_sent_packet_ms()) - @@ -136,8 +133,7 @@ TimeDelta SchedulableNetworkBehavior::UpdateConfigAndReschedule() { TimeDelta::Millis(schedule_.repeat_schedule_after_last_ms()) + TimeDelta::Millis(schedule_.item()[schedule_.item().size() - 1] .time_since_first_sent_packet_ms()); - delay = - webrtc::TimeDelta::Millis(schedule_.repeat_schedule_after_last_ms()); + delay = TimeDelta::Millis(schedule_.repeat_schedule_after_last_ms()); RTC_DCHECK_GE(delay, TimeDelta::Zero()); } diff --git a/test/null_transport.cc b/test/null_transport.cc index 884f294f29..ae6e19ba9f 100644 --- a/test/null_transport.cc +++ b/test/null_transport.cc @@ -9,6 +9,11 @@ */ #include "test/null_transport.h" +#include + +#include "api/array_view.h" +#include "api/call/transport.h" + namespace webrtc { namespace test { @@ -17,7 +22,8 @@ bool NullTransport::SendRtp(ArrayView packet, return true; } -bool NullTransport::SendRtcp(ArrayView packet) { +bool NullTransport::SendRtcp(ArrayView packet, + const PacketOptions& options) { return true; } diff --git a/test/null_transport.h b/test/null_transport.h index 16496225af..a65c6d77d4 100644 --- a/test/null_transport.h +++ b/test/null_transport.h @@ -10,6 +10,9 @@ #ifndef TEST_NULL_TRANSPORT_H_ #define TEST_NULL_TRANSPORT_H_ +#include + +#include "api/array_view.h" #include "api/call/transport.h" namespace webrtc { @@ -21,7 +24,8 @@ class NullTransport : public Transport { public: bool SendRtp(ArrayView packet, const PacketOptions& options) override; - bool SendRtcp(ArrayView packet) override; + bool SendRtcp(ArrayView packet, + const PacketOptions& options) override; }; } // namespace test } // namespace webrtc diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index ac87522574..7899fc1465 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -102,17 +102,18 @@ if (!build_with_chromium) { ":echo_emulation", ":test_peer", "../..:copy_to_file_audio_capturer", - "../../../api:create_time_controller", + "../../../api:enable_media_with_defaults", "../../../api:libjingle_peerconnection_api", "../../../api:scoped_refptr", "../../../api:time_controller", "../../../api/audio:audio_device", + "../../../api/environment", + "../../../api/environment:environment_factory", "../../../api/rtc_event_log:rtc_event_log_factory", "../../../api/task_queue", "../../../api/test/pclf:media_configuration", "../../../api/test/pclf:media_quality_test_params", "../../../api/test/pclf:peer_configurer", - "../../../api/transport:field_trial_based_config", "../../../api/video_codecs:builtin_video_decoder_factory", "../../../api/video_codecs:builtin_video_encoder_factory", "../../../api/video_codecs:video_codecs_api", @@ -263,6 +264,7 @@ if (!build_with_chromium) { "../../../pc:pc_test_utils", "../../../pc:sdp_utils", "../../../rtc_base:checks", + "../../../rtc_base:cpu_info", "../../../rtc_base:gunit_helpers", "../../../rtc_base:logging", "../../../rtc_base:macromagic", diff --git a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc index 7c92cd228f..d282bee308 100644 --- a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc @@ -33,8 +33,8 @@ namespace webrtc { namespace webrtc_pc_e2e { -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::ImprovementDirection; +using test::Unit; DefaultAudioQualityAnalyzer::DefaultAudioQualityAnalyzer( test::MetricsLogger* const metrics_logger) diff --git a/test/pc/e2e/analyzer/video/BUILD.gn b/test/pc/e2e/analyzer/video/BUILD.gn index 72b2796976..8eb5c1acfb 100644 --- a/test/pc/e2e/analyzer/video/BUILD.gn +++ b/test/pc/e2e/analyzer/video/BUILD.gn @@ -514,8 +514,8 @@ if (rtc_include_tests) { "../../../../../api/video:video_frame", "../../../../../common_video", "../../../../../rtc_base:stringutils", + "../../../../../rtc_base:threading", "../../../../../rtc_tools:video_quality_analysis", - "../../../../../system_wrappers", "../../../../time_controller", ] } @@ -540,6 +540,7 @@ if (rtc_include_tests) { "../../../../../api/video:encoded_image", "../../../../../api/video:video_frame", "../../../../../common_video", + "../../../../../rtc_base:threading", "../../../../../rtc_tools:video_quality_analysis", "../../../../../system_wrappers", "//third_party/abseil-cpp/absl/flags:flag", diff --git a/test/pc/e2e/analyzer/video/analyzing_video_sink.cc b/test/pc/e2e/analyzer/video/analyzing_video_sink.cc index 9cba75cfd2..8b04799d29 100644 --- a/test/pc/e2e/analyzer/video/analyzing_video_sink.cc +++ b/test/pc/e2e/analyzer/video/analyzing_video_sink.cc @@ -120,7 +120,7 @@ void AnalyzingVideoSink::OnFrame(const VideoFrame& frame) { } } -void AnalyzingVideoSink::LogMetrics(webrtc::test::MetricsLogger& metrics_logger, +void AnalyzingVideoSink::LogMetrics(test::MetricsLogger& metrics_logger, absl::string_view test_case_name) const { if (report_infra_stats_) { MutexLock lock(&mutex_); diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc index 42f45abc7a..54984e5d0a 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc @@ -51,9 +51,9 @@ namespace webrtc { namespace { -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; -using ::webrtc::webrtc_pc_e2e::MetricMetadataKey; +using test::ImprovementDirection; +using test::Unit; +using webrtc_pc_e2e::MetricMetadataKey; constexpr int kBitsInByte = 8; constexpr absl::string_view kSkipRenderedFrameReasonProcessed = "processed"; @@ -140,7 +140,7 @@ SamplesStatsCounter::StatsSample StatsSample(double value, } // namespace DefaultVideoQualityAnalyzer::DefaultVideoQualityAnalyzer( - webrtc::Clock* clock, + Clock* clock, test::MetricsLogger* metrics_logger, DefaultVideoQualityAnalyzerOptions options) : options_(options), @@ -175,7 +175,7 @@ void DefaultVideoQualityAnalyzer::Start(std::string test_case_name, uint16_t DefaultVideoQualityAnalyzer::OnFrameCaptured( absl::string_view peer_name, const std::string& stream_label, - const webrtc::VideoFrame& frame) { + const VideoFrame& frame) { // `next_frame_id` is atomic, so we needn't lock here. Timestamp captured_time = Now(); Timestamp start_time = Timestamp::MinusInfinity(); @@ -288,9 +288,8 @@ uint16_t DefaultVideoQualityAnalyzer::OnFrameCaptured( return frame_id; } -void DefaultVideoQualityAnalyzer::OnFramePreEncode( - absl::string_view peer_name, - const webrtc::VideoFrame& frame) { +void DefaultVideoQualityAnalyzer::OnFramePreEncode(absl::string_view peer_name, + const VideoFrame& frame) { Timestamp processing_started = Now(); MutexLock lock(&mutex_); RTC_CHECK_EQ(state_, State::kActive) @@ -323,7 +322,7 @@ void DefaultVideoQualityAnalyzer::OnFramePreEncode( void DefaultVideoQualityAnalyzer::OnFrameEncoded( absl::string_view peer_name, uint16_t frame_id, - const webrtc::EncodedImage& encoded_image, + const EncodedImage& encoded_image, const EncoderStats& stats, bool discarded) { if (discarded) @@ -392,14 +391,14 @@ void DefaultVideoQualityAnalyzer::OnFrameEncoded( void DefaultVideoQualityAnalyzer::OnFrameDropped( absl::string_view peer_name, - webrtc::EncodedImageCallback::DropReason reason) { + EncodedImageCallback::DropReason reason) { // Here we do nothing, because we will see this drop on renderer side. } void DefaultVideoQualityAnalyzer::OnFramePreDecode( absl::string_view peer_name, uint16_t frame_id, - const webrtc::EncodedImage& input_image) { + const EncodedImage& input_image) { Timestamp processing_started = Now(); MutexLock lock(&mutex_); RTC_CHECK_EQ(state_, State::kActive) @@ -449,10 +448,9 @@ void DefaultVideoQualityAnalyzer::OnFramePreDecode( } } -void DefaultVideoQualityAnalyzer::OnFrameDecoded( - absl::string_view peer_name, - const webrtc::VideoFrame& frame, - const DecoderStats& stats) { +void DefaultVideoQualityAnalyzer::OnFrameDecoded(absl::string_view peer_name, + const VideoFrame& frame, + const DecoderStats& stats) { Timestamp processing_started = Now(); MutexLock lock(&mutex_); RTC_CHECK_EQ(state_, State::kActive) @@ -496,9 +494,8 @@ void DefaultVideoQualityAnalyzer::OnFrameDecoded( } } -void DefaultVideoQualityAnalyzer::OnFrameRendered( - absl::string_view peer_name, - const webrtc::VideoFrame& frame) { +void DefaultVideoQualityAnalyzer::OnFrameRendered(absl::string_view peer_name, + const VideoFrame& frame) { Timestamp processing_started = Now(); MutexLock lock(&mutex_); RTC_CHECK_EQ(state_, State::kActive) @@ -599,10 +596,9 @@ void DefaultVideoQualityAnalyzer::OnFrameRendered( } } -void DefaultVideoQualityAnalyzer::OnEncoderError( - absl::string_view peer_name, - const webrtc::VideoFrame& frame, - int32_t error_code) { +void DefaultVideoQualityAnalyzer::OnEncoderError(absl::string_view peer_name, + const VideoFrame& frame, + int32_t error_code) { RTC_LOG(LS_ERROR) << "Encoder error for frame.id=" << frame.id() << ", code=" << error_code; } diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frame_in_flight.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frame_in_flight.cc index fb96ee6ee5..6dbdfdc58e 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frame_in_flight.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frame_in_flight.cc @@ -78,7 +78,7 @@ bool FrameInFlight::HaveAllPeersReceived() const { } void FrameInFlight::OnFrameEncoded( - webrtc::Timestamp time, + Timestamp time, std::optional time_between_encoded_frames, VideoFrameType frame_type, DataSize encoded_image_size, @@ -113,8 +113,8 @@ void FrameInFlight::OnFrameEncoded( } void FrameInFlight::OnFramePreDecode(size_t peer, - webrtc::Timestamp received_time, - webrtc::Timestamp decode_start_time, + Timestamp received_time, + Timestamp decode_start_time, VideoFrameType frame_type, DataSize encoded_image_size) { receiver_stats_[peer].received_time = received_time; @@ -132,7 +132,7 @@ bool FrameInFlight::HasReceivedTime(size_t peer) const { } void FrameInFlight::OnFrameDecoded(size_t peer, - webrtc::Timestamp time, + Timestamp time, int width, int height, const StreamCodecInfo& used_decoder, @@ -158,7 +158,7 @@ bool FrameInFlight::HasDecodeEndTime(size_t peer) const { return it->second.decode_end_time.IsFinite(); } -void FrameInFlight::OnFrameRendered(size_t peer, webrtc::Timestamp time) { +void FrameInFlight::OnFrameRendered(size_t peer, Timestamp time) { receiver_stats_[peer].rendered_time = time; } diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc index 4a9906a401..de277e5983 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc @@ -33,7 +33,7 @@ namespace webrtc { namespace { -using ::webrtc::webrtc_pc_e2e::SampleMetadataKey; +using webrtc_pc_e2e::SampleMetadataKey; constexpr TimeDelta kFreezeThreshold = TimeDelta::Millis(150); constexpr int kMaxActiveComparisons = 10; diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc index 571c3c602f..9540840717 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc @@ -34,7 +34,7 @@ using ::testing::IsEmpty; using ::testing::Pair; using ::testing::SizeIs; -using StatsSample = ::webrtc::SamplesStatsCounter::StatsSample; +using StatsSample = SamplesStatsCounter::StatsSample; DefaultVideoQualityAnalyzerOptions AnalyzerOptionsForTest() { DefaultVideoQualityAnalyzerOptions options; diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_metric_names_test.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_metric_names_test.cc index f3f9caac0a..6dfe510b98 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_metric_names_test.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_metric_names_test.cc @@ -28,8 +28,8 @@ #include "api/video/encoded_image.h" #include "api/video/i420_buffer.h" #include "api/video/video_frame.h" +#include "rtc_base/thread.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/sleep.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/pc/e2e/analyzer/video/default_video_quality_analyzer.h" @@ -43,10 +43,10 @@ using ::testing::Contains; using ::testing::SizeIs; using ::testing::UnorderedElementsAre; -using ::webrtc::test::DefaultMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Metric; -using ::webrtc::test::Unit; +using test::DefaultMetricsLogger; +using test::ImprovementDirection; +using test::Metric; +using test::Unit; constexpr int kAnalyzerMaxThreadsCount = 1; constexpr int kFrameWidth = 320; @@ -123,7 +123,7 @@ void PassFramesThroughAnalyzer(DefaultVideoQualityAnalyzer& analyzer, analyzer.OnFrameRendered(receiver, received_frame); } if (i < frames_count - 1 && interframe_delay_ms > 0) { - SleepMs(interframe_delay_ms); + Thread::SleepMs(interframe_delay_ms); } } } diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc index 4aa80bf224..449247f3a7 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc @@ -27,8 +27,8 @@ #include "api/video/video_frame.h" #include "common_video/libyuv/include/webrtc_libyuv.h" #include "rtc_base/strings/string_builder.h" +#include "rtc_base/thread.h" #include "rtc_tools/frame_analyzer/video_geometry_aligner.h" -#include "system_wrappers/include/sleep.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h" @@ -44,7 +44,7 @@ using ::testing::Test; using ::testing::TestWithParam; using ::testing::ValuesIn; -using StatsSample = ::webrtc::SamplesStatsCounter::StatsSample; +using StatsSample = SamplesStatsCounter::StatsSample; constexpr int kAnalyzerMaxThreadsCount = 1; constexpr TimeDelta kMaxFramesInFlightStorageDuration = TimeDelta::Seconds(3); @@ -163,7 +163,7 @@ void PassFramesThroughAnalyzerSenderOnly( } if (i < frames_count - 1 && interframe_delay_ms > 0) { if (time_controller == nullptr) { - SleepMs(interframe_delay_ms); + Thread::SleepMs(interframe_delay_ms); } else { time_controller->AdvanceTime(TimeDelta::Millis(interframe_delay_ms)); } @@ -200,7 +200,7 @@ void PassFramesThroughAnalyzer(DefaultVideoQualityAnalyzer& analyzer, } if (i < frames_count - 1 && interframe_delay_ms > 0) { if (time_controller == nullptr) { - SleepMs(interframe_delay_ms); + Thread::SleepMs(interframe_delay_ms); } else { time_controller->AdvanceTime(TimeDelta::Millis(interframe_delay_ms)); } @@ -248,7 +248,7 @@ TEST(DefaultVideoQualityAnalyzerTest, NormalScenario) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -306,7 +306,7 @@ TEST(DefaultVideoQualityAnalyzerTest, OneFrameReceivedTwice) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -345,23 +345,23 @@ TEST(DefaultVideoQualityAnalyzerTest, NormalScenario2Receivers) { frames_order.push_back(frame.id()); captured_frames.insert({frame.id(), frame}); analyzer.OnFramePreEncode(kAlice, frame); - SleepMs(20); + Thread::SleepMs(20); analyzer.OnFrameEncoded(kAlice, frame.id(), FakeEncode(frame), VideoQualityAnalyzerInterface::EncoderStats(), false); } - SleepMs(50); + Thread::SleepMs(50); for (size_t i = 1; i < frames_order.size(); i += 2) { uint16_t frame_id = frames_order.at(i); VideoFrame received_frame = DeepCopy(captured_frames.at(frame_id)); analyzer.OnFramePreDecode(kBob, received_frame.id(), FakeEncode(received_frame)); - SleepMs(30); + Thread::SleepMs(30); analyzer.OnFrameDecoded(kBob, received_frame, VideoQualityAnalyzerInterface::DecoderStats()); - SleepMs(10); + Thread::SleepMs(10); analyzer.OnFrameRendered(kBob, received_frame); } @@ -370,17 +370,17 @@ TEST(DefaultVideoQualityAnalyzerTest, NormalScenario2Receivers) { VideoFrame received_frame = DeepCopy(captured_frames.at(frame_id)); analyzer.OnFramePreDecode(kCharlie, received_frame.id(), FakeEncode(received_frame)); - SleepMs(40); + Thread::SleepMs(40); analyzer.OnFrameDecoded(kCharlie, received_frame, VideoQualityAnalyzerInterface::DecoderStats()); - SleepMs(5); + Thread::SleepMs(5); analyzer.OnFrameRendered(kCharlie, received_frame); } // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats analyzer_stats = analyzer.GetAnalyzerStats(); @@ -494,7 +494,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -548,7 +548,7 @@ TEST(DefaultVideoQualityAnalyzerTest, HeavyQualityMetricsFromEqualFrames) { // Give analyzer some time to process frames on async thread. Heavy metrics // computation is turned on, so giving some extra time to be sure that // computatio have ended. - SleepMs(500); + Thread::SleepMs(500); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -613,7 +613,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. Heavy metrics // computation is turned on, so giving some extra time to be sure that // computatio have ended. - SleepMs(500); + Thread::SleepMs(500); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -678,13 +678,13 @@ TEST(DefaultVideoQualityAnalyzerTest, CpuUsage) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); double cpu_usage = analyzer.GetCpuUsagePercent(); ASSERT_GT(cpu_usage, 0); - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); EXPECT_EQ(analyzer.GetCpuUsagePercent(), cpu_usage); @@ -788,7 +788,7 @@ TEST(DefaultVideoQualityAnalyzerTest, RuntimeParticipantsAdding) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -891,7 +891,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -966,7 +966,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); analyzer_stats = analyzer.GetAnalyzerStats(); @@ -1063,7 +1063,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); analyzer_stats = analyzer.GetAnalyzerStats(); @@ -1147,7 +1147,7 @@ TEST(DefaultVideoQualityAnalyzerTest, CodecTrackedCorrectly) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); std::map stats = analyzer.GetStats(); @@ -1228,7 +1228,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats analyzer_stats = analyzer.GetAnalyzerStats(); @@ -1326,7 +1326,7 @@ TEST( // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats analyzer_stats = analyzer.GetAnalyzerStats(); @@ -1410,7 +1410,7 @@ TEST(DefaultVideoQualityAnalyzerTest, GetStreamFrames) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); EXPECT_EQ(analyzer.GetStreamFrames(), stream_to_frame_ids); @@ -1445,7 +1445,7 @@ TEST(DefaultVideoQualityAnalyzerTest, ReceiverReceivedFramesWhenSenderRemoved) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters stream_conters = @@ -1489,7 +1489,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters stream_conters = @@ -1533,7 +1533,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters stream_conters = @@ -1582,7 +1582,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters alice_alice_stream_conters = @@ -1625,7 +1625,7 @@ TEST(DefaultVideoQualityAnalyzerTest, ReceiverRemovedBeforeCapturing2ndFrame) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters global_stream_conters = analyzer.GetGlobalCounters(); @@ -1668,7 +1668,7 @@ TEST(DefaultVideoQualityAnalyzerTest, ReceiverRemovedBeforePreEncoded) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters global_stream_conters = analyzer.GetGlobalCounters(); @@ -1711,7 +1711,7 @@ TEST(DefaultVideoQualityAnalyzerTest, ReceiverRemovedBeforeEncoded) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters global_stream_conters = analyzer.GetGlobalCounters(); @@ -1759,7 +1759,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters global_stream_conters = analyzer.GetGlobalCounters(); @@ -1804,7 +1804,7 @@ TEST(DefaultVideoQualityAnalyzerTest, UnregisterOneAndRegisterAnother) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters global_stream_conters = analyzer.GetGlobalCounters(); @@ -1868,7 +1868,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); FrameCounters global_stream_conters = analyzer.GetGlobalCounters(); @@ -1914,7 +1914,7 @@ TEST(DefaultVideoQualityAnalyzerTest, uint16_t frame_id = analyzer.OnFrameCaptured("alice", "alice_video", frame); frame.set_id(frame_id); analyzer.OnFramePreEncode("alice", frame); - SleepMs(10); + Thread::SleepMs(10); analyzer.OnFrameEncoded("alice", frame.id(), FakeEncode(frame), VideoQualityAnalyzerInterface::EncoderStats(), false); @@ -1923,7 +1923,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); StreamStats stats = analyzer.GetStats().at(StatsKey("alice_video", "bob")); @@ -1950,7 +1950,7 @@ TEST(DefaultVideoQualityAnalyzerTest, InfraMetricsAreReportedWhenRequested) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -1982,7 +1982,7 @@ TEST(DefaultVideoQualityAnalyzerTest, InfraMetricsNotCollectedByDefault) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); AnalyzerStats stats = analyzer.GetAnalyzerStats(); @@ -2027,7 +2027,7 @@ TEST(DefaultVideoQualityAnalyzerTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); StreamStats stats = analyzer.GetStats().at(StatsKey("alice_video", "bob")); @@ -2060,7 +2060,7 @@ TEST_P(DefaultVideoQualityAnalyzerTimeBetweenFreezesTest, // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(50); + Thread::SleepMs(50); analyzer.Stop(); StreamStats stats = analyzer.GetStats().at(StatsKey("alice_video", "bob")); @@ -2401,7 +2401,7 @@ TEST(DefaultVideoQualityAnalyzerTest, CheckFrameSenderPeerName) { // Give analyzer some time to process frames on async thread. The computations // have to be fast (heavy metrics are disabled!), so if doesn't fit 100ms it // means we have an issue! - SleepMs(100); + Thread::SleepMs(100); analyzer.Stop(); EXPECT_EQ(sender_alice, kAlice); diff --git a/test/pc/e2e/analyzer/video/example_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/example_video_quality_analyzer.cc index f55e886c46..3946b9c0bd 100644 --- a/test/pc/e2e/analyzer/video/example_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/example_video_quality_analyzer.cc @@ -25,7 +25,7 @@ void ExampleVideoQualityAnalyzer::Start(std::string test_case_name, uint16_t ExampleVideoQualityAnalyzer::OnFrameCaptured( absl::string_view peer_name, const std::string& stream_label, - const webrtc::VideoFrame& frame) { + const VideoFrame& frame) { MutexLock lock(&lock_); uint16_t frame_id = next_frame_id_++; if (frame_id == VideoFrame::kNotSetId) { @@ -50,9 +50,8 @@ uint16_t ExampleVideoQualityAnalyzer::OnFrameCaptured( return frame_id; } -void ExampleVideoQualityAnalyzer::OnFramePreEncode( - absl::string_view peer_name, - const webrtc::VideoFrame& frame) { +void ExampleVideoQualityAnalyzer::OnFramePreEncode(absl::string_view peer_name, + const VideoFrame& frame) { MutexLock lock(&lock_); ++frames_pre_encoded_; } @@ -60,7 +59,7 @@ void ExampleVideoQualityAnalyzer::OnFramePreEncode( void ExampleVideoQualityAnalyzer::OnFrameEncoded( absl::string_view peer_name, uint16_t frame_id, - const webrtc::EncodedImage& encoded_image, + const EncodedImage& encoded_image, const EncoderStats& stats, bool discarded) { MutexLock lock(&lock_); @@ -69,7 +68,7 @@ void ExampleVideoQualityAnalyzer::OnFrameEncoded( void ExampleVideoQualityAnalyzer::OnFrameDropped( absl::string_view peer_name, - webrtc::EncodedImageCallback::DropReason reason) { + EncodedImageCallback::DropReason reason) { RTC_LOG(LS_INFO) << "Frame dropped by encoder"; MutexLock lock(&lock_); ++frames_dropped_; @@ -78,31 +77,28 @@ void ExampleVideoQualityAnalyzer::OnFrameDropped( void ExampleVideoQualityAnalyzer::OnFramePreDecode( absl::string_view peer_name, uint16_t frame_id, - const webrtc::EncodedImage& encoded_image) { + const EncodedImage& encoded_image) { MutexLock lock(&lock_); ++frames_received_; } -void ExampleVideoQualityAnalyzer::OnFrameDecoded( - absl::string_view peer_name, - const webrtc::VideoFrame& frame, - const DecoderStats& stats) { +void ExampleVideoQualityAnalyzer::OnFrameDecoded(absl::string_view peer_name, + const VideoFrame& frame, + const DecoderStats& stats) { MutexLock lock(&lock_); ++frames_decoded_; } -void ExampleVideoQualityAnalyzer::OnFrameRendered( - absl::string_view peer_name, - const webrtc::VideoFrame& frame) { +void ExampleVideoQualityAnalyzer::OnFrameRendered(absl::string_view peer_name, + const VideoFrame& frame) { MutexLock lock(&lock_); frames_in_flight_.erase(frame.id()); ++frames_rendered_; } -void ExampleVideoQualityAnalyzer::OnEncoderError( - absl::string_view peer_name, - const webrtc::VideoFrame& frame, - int32_t error_code) { +void ExampleVideoQualityAnalyzer::OnEncoderError(absl::string_view peer_name, + const VideoFrame& frame, + int32_t error_code) { RTC_LOG(LS_ERROR) << "Failed to encode frame " << frame.id() << ". Code: " << error_code; } diff --git a/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc b/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc index 1b51402c48..f990adf472 100644 --- a/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc +++ b/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc @@ -189,19 +189,18 @@ int32_t QualityAnalyzingVideoDecoder::DecoderCallback::IrrelevantSimulcastStreamDecoded( uint16_t frame_id, uint32_t timestamp_ms) { - webrtc::VideoFrame dummy_frame = - webrtc::VideoFrame::Builder() - .set_video_frame_buffer(GetDummyFrameBuffer()) - .set_rtp_timestamp(timestamp_ms) - .set_id(frame_id) - .build(); + VideoFrame dummy_frame = VideoFrame::Builder() + .set_video_frame_buffer(GetDummyFrameBuffer()) + .set_rtp_timestamp(timestamp_ms) + .set_id(frame_id) + .build(); MutexLock lock(&callback_mutex_); RTC_DCHECK(delegate_callback_); delegate_callback_->Decoded(dummy_frame, std::nullopt, std::nullopt); return WEBRTC_VIDEO_CODEC_OK; } -scoped_refptr +scoped_refptr QualityAnalyzingVideoDecoder::DecoderCallback::GetDummyFrameBuffer() { if (!dummy_frame_buffer_) { dummy_frame_buffer_ = CreateDummyFrameBuffer(); diff --git a/test/pc/e2e/analyzer/video/quality_analyzing_video_encoder.cc b/test/pc/e2e/analyzer/video/quality_analyzing_video_encoder.cc index 65e2f12594..c11a0e942c 100644 --- a/test/pc/e2e/analyzer/video/quality_analyzing_video_encoder.cc +++ b/test/pc/e2e/analyzer/video/quality_analyzing_video_encoder.cc @@ -27,7 +27,7 @@ namespace webrtc_pc_e2e { namespace { using EmulatedSFUConfigMap = - ::webrtc::webrtc_pc_e2e::QualityAnalyzingVideoEncoder::EmulatedSFUConfigMap; + webrtc_pc_e2e::QualityAnalyzingVideoEncoder::EmulatedSFUConfigMap; constexpr size_t kMaxFrameInPipelineCount = 1000; constexpr double kNoMultiplier = 1.0; diff --git a/test/pc/e2e/analyzer/video/simulcast_dummy_buffer_helper.cc b/test/pc/e2e/analyzer/video/simulcast_dummy_buffer_helper.cc index 955406ab83..e6925466e6 100644 --- a/test/pc/e2e/analyzer/video/simulcast_dummy_buffer_helper.cc +++ b/test/pc/e2e/analyzer/video/simulcast_dummy_buffer_helper.cc @@ -22,9 +22,9 @@ constexpr char kIrrelatedSimulcastStreamFrameData[] = "Dummy!"; } // namespace -scoped_refptr CreateDummyFrameBuffer() { +scoped_refptr CreateDummyFrameBuffer() { // Use i420 buffer here as default one and supported by all codecs. - scoped_refptr buffer = webrtc::I420Buffer::Create(2, 2); + scoped_refptr buffer = I420Buffer::Create(2, 2); memcpy(buffer->MutableDataY(), kIrrelatedSimulcastStreamFrameData, 2); memcpy(buffer->MutableDataY() + buffer->StrideY(), kIrrelatedSimulcastStreamFrameData + 2, 2); @@ -33,11 +33,11 @@ scoped_refptr CreateDummyFrameBuffer() { return buffer; } -bool IsDummyFrame(const webrtc::VideoFrame& video_frame) { +bool IsDummyFrame(const VideoFrame& video_frame) { if (video_frame.width() != 2 || video_frame.height() != 2) { return false; } - scoped_refptr buffer = + scoped_refptr buffer = video_frame.video_frame_buffer()->ToI420(); if (memcmp(buffer->DataY(), kIrrelatedSimulcastStreamFrameData, 2) != 0) { return false; diff --git a/test/pc/e2e/analyzer/video/video_dumping.cc b/test/pc/e2e/analyzer/video/video_dumping.cc index 4fec0a8f9e..6acacec106 100644 --- a/test/pc/e2e/analyzer/video/video_dumping.cc +++ b/test/pc/e2e/analyzer/video/video_dumping.cc @@ -70,7 +70,7 @@ class BroadcastingFrameWriter final : public test::VideoFrameWriter { : delegates_(std::move(delegates)) {} ~BroadcastingFrameWriter() override { Close(); } - bool WriteFrame(const webrtc::VideoFrame& frame) override { + bool WriteFrame(const VideoFrame& frame) override { for (auto& delegate : delegates_) { if (!delegate->WriteFrame(frame)) { return false; diff --git a/test/pc/e2e/analyzer/video/video_dumping_test.cc b/test/pc/e2e/analyzer/video/video_dumping_test.cc index 2b96fda024..3688fe5b8a 100644 --- a/test/pc/e2e/analyzer/video/video_dumping_test.cc +++ b/test/pc/e2e/analyzer/video/video_dumping_test.cc @@ -63,11 +63,11 @@ std::vector AsVector(const uint8_t* data, size_t size) { return out; } -void AssertFramesEqual(scoped_refptr actual, +void AssertFramesEqual(scoped_refptr actual, scoped_refptr expected) { ASSERT_THAT(actual->width(), Eq(expected->width())); ASSERT_THAT(actual->height(), Eq(expected->height())); - scoped_refptr expected_i420 = expected->ToI420(); + scoped_refptr expected_i420 = expected->ToI420(); int height = actual->height(); @@ -102,10 +102,10 @@ class VideoDumpingTest : public Test { ~VideoDumpingTest() override = default; void SetUp() override { - video_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "video_dumping_test"); - ids_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "video_dumping_test"); + video_filename_ = + test::TempFilename(test::OutputPath(), "video_dumping_test"); + ids_filename_ = + test::TempFilename(test::OutputPath(), "video_dumping_test"); } void TearDown() override { diff --git a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc index 643dc946fd..c175859bfa 100644 --- a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc +++ b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc @@ -37,9 +37,9 @@ namespace webrtc { namespace webrtc_pc_e2e { namespace { -using webrtc::webrtc_pc_e2e::VideoConfig; +using webrtc_pc_e2e::VideoConfig; using EmulatedSFUConfigMap = - ::webrtc::webrtc_pc_e2e::QualityAnalyzingVideoEncoder::EmulatedSFUConfigMap; + webrtc_pc_e2e::QualityAnalyzingVideoEncoder::EmulatedSFUConfigMap; class AnalyzingFramePreprocessor : public test::TestVideoCapturer::FramePreprocessor { diff --git a/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc b/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc index d717cbb8ce..11e586af9c 100644 --- a/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc +++ b/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc @@ -39,8 +39,8 @@ namespace webrtc { namespace webrtc_pc_e2e { namespace { -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::ImprovementDirection; +using test::Unit; SamplesStatsCounter BytesPerSecondToKbps(const SamplesStatsCounter& counter) { return counter * 0.008; diff --git a/test/pc/e2e/cross_media_metrics_reporter.cc b/test/pc/e2e/cross_media_metrics_reporter.cc index 3315ec6b84..9edc91a0a3 100644 --- a/test/pc/e2e/cross_media_metrics_reporter.cc +++ b/test/pc/e2e/cross_media_metrics_reporter.cc @@ -31,8 +31,8 @@ namespace webrtc { namespace webrtc_pc_e2e { -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::ImprovementDirection; +using test::Unit; CrossMediaMetricsReporter::CrossMediaMetricsReporter( test::MetricsLogger* metrics_logger) @@ -124,7 +124,7 @@ void CrossMediaMetricsReporter::StopAndReportResults() { "audio_ahead_ms", GetTestCaseName(pair.second.audio_stream_info.stream_label, sync_group), pair.second.audio_ahead_ms, Unit::kMilliseconds, - webrtc::test::ImprovementDirection::kSmallerIsBetter, + test::ImprovementDirection::kSmallerIsBetter, std::move(audio_metric_metadata)); std::map video_metric_metadata{ @@ -139,7 +139,7 @@ void CrossMediaMetricsReporter::StopAndReportResults() { "video_ahead_ms", GetTestCaseName(pair.second.video_stream_info.stream_label, sync_group), pair.second.video_ahead_ms, Unit::kMilliseconds, - webrtc::test::ImprovementDirection::kSmallerIsBetter, + test::ImprovementDirection::kSmallerIsBetter, std::move(video_metric_metadata)); } } diff --git a/test/pc/e2e/media/media_helper.cc b/test/pc/e2e/media/media_helper.cc index 0b4de88e9f..ad83e8d091 100644 --- a/test/pc/e2e/media/media_helper.cc +++ b/test/pc/e2e/media/media_helper.cc @@ -39,7 +39,7 @@ void MediaHelper::MaybeAddAudio(TestPeer* peer) { return; } const AudioConfig& audio_config = peer->params().audio_config.value(); - scoped_refptr source = + scoped_refptr source = peer->pc_factory()->CreateAudioSource(audio_config.audio_options); scoped_refptr track = peer->pc_factory()->CreateAudioTrack(*audio_config.stream_label, diff --git a/test/pc/e2e/network_quality_metrics_reporter.cc b/test/pc/e2e/network_quality_metrics_reporter.cc index bccc15ee57..3cb820eb62 100644 --- a/test/pc/e2e/network_quality_metrics_reporter.cc +++ b/test/pc/e2e/network_quality_metrics_reporter.cc @@ -22,8 +22,8 @@ namespace webrtc { namespace webrtc_pc_e2e { namespace { -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::ImprovementDirection; +using test::Unit; constexpr TimeDelta kStatsWaitTimeout = TimeDelta::Seconds(1); diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index ce177d4e4d..f6e7cf2b57 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -51,13 +51,13 @@ #include "media/base/media_constants.h" #include "pc/test/mock_peer_connection_observers.h" #include "rtc_base/checks.h" +#include "rtc_base/cpu_info.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/thread.h" -#include "system_wrappers/include/cpu_info.h" #include "system_wrappers/include/field_trial.h" #include "test/field_trial.h" #include "test/gtest.h" @@ -85,8 +85,8 @@ namespace webrtc { namespace webrtc_pc_e2e { namespace { -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::ImprovementDirection; +using test::Unit; constexpr TimeDelta kDefaultTimeout = TimeDelta::Seconds(10); constexpr char kSignalThreadName[] = "signaling_thread"; @@ -116,7 +116,7 @@ class FixturePeerConnectionObserver : public MockPeerConnectionObserver { // of reconnect this callback can be called again, so it should be tolerant // to such behavior. FixturePeerConnectionObserver( - std::function)> + std::function)> on_track_callback, std::function on_connected_callback) : on_track_callback_(std::move(on_track_callback)), @@ -136,7 +136,7 @@ class FixturePeerConnectionObserver : public MockPeerConnectionObserver { } private: - std::function)> + std::function)> on_track_callback_; std::function on_connected_callback_; }; @@ -235,7 +235,7 @@ PeerConnectionE2EQualityTest::PeerHandle* PeerConnectionE2EQualityTest::AddPeer( } void PeerConnectionE2EQualityTest::Run(RunParams run_params) { - webrtc::webrtc_pc_e2e::PeerParamsPreprocessor params_preprocessor; + webrtc_pc_e2e::PeerParamsPreprocessor params_preprocessor; for (auto& peer_configuration : peer_configurations_) { params_preprocessor.SetDefaultValuesForMissingParams(*peer_configuration); params_preprocessor.ValidateParams(*peer_configuration); @@ -280,9 +280,9 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { time_controller_.GetClock()); // Create a `task_queue_`. - task_queue_ = std::make_unique( + task_queue_ = std::make_unique( time_controller_.GetTaskQueueFactory()->CreateTaskQueue( - "pc_e2e_quality_test", webrtc::TaskQueueFactory::Priority::NORMAL)); + "pc_e2e_quality_test", TaskQueueFactory::Priority::NORMAL)); // Create call participants: Alice and Bob. // Audio streams are intercepted in AudioDeviceModule, so if it is required to @@ -329,8 +329,7 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { [this]() { StartVideo(bob_video_sources_); }), bob_remote_audio_config, run_params.echo_emulation_config); - int num_cores = CpuInfo::DetectNumberOfCores(); - RTC_DCHECK_GE(num_cores, 1); + int num_cores = cpu_info::DetectNumberOfCores(); int video_analyzer_threads = num_cores - kPeerConnectionUsedThreads - kFrameworkUsedThreads; @@ -358,16 +357,16 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { // Start RTCEventLog recording if requested. if (alice_->params().rtc_event_log_path) { - auto alice_rtc_event_log = std::make_unique( + auto alice_rtc_event_log = std::make_unique( alice_->params().rtc_event_log_path.value()); alice_->pc()->StartRtcEventLog(std::move(alice_rtc_event_log), - webrtc::RtcEventLog::kImmediateOutput); + RtcEventLog::kImmediateOutput); } if (bob_->params().rtc_event_log_path) { - auto bob_rtc_event_log = std::make_unique( + auto bob_rtc_event_log = std::make_unique( bob_->params().rtc_event_log_path.value()); bob_->pc()->StartRtcEventLog(std::move(bob_rtc_event_log), - webrtc::RtcEventLog::kImmediateOutput); + RtcEventLog::kImmediateOutput); } // Setup alive logging. It is done to prevent test infra to think that test is @@ -521,8 +520,7 @@ void PeerConnectionE2EQualityTest::SetupCallOnSignalingThread( // multiple audio streams, then we need transceiver for each Bob's audio // stream. RTCErrorOr> result = - alice_->AddTransceiver(webrtc::MediaType::AUDIO, - receive_only_transceiver_init); + alice_->AddTransceiver(MediaType::AUDIO, receive_only_transceiver_init); RTC_CHECK(result.ok()); alice_transceivers_counter++; } @@ -561,7 +559,7 @@ void PeerConnectionE2EQualityTest::SetupCallOnSignalingThread( alice_video_transceivers_non_simulcast_counter++; } RTCErrorOr> result = - alice_->AddTransceiver(webrtc::MediaType::VIDEO, transceiver_params); + alice_->AddTransceiver(MediaType::VIDEO, transceiver_params); RTC_CHECK(result.ok()); alice_transceivers_counter++; @@ -572,8 +570,7 @@ void PeerConnectionE2EQualityTest::SetupCallOnSignalingThread( for (size_t i = alice_video_transceivers_non_simulcast_counter; i < bob_->configurable_params().video_configs.size(); ++i) { RTCErrorOr> result = - alice_->AddTransceiver(webrtc::MediaType::VIDEO, - receive_only_transceiver_init); + alice_->AddTransceiver(MediaType::VIDEO, receive_only_transceiver_init); RTC_CHECK(result.ok()); alice_transceivers_counter++; } @@ -598,19 +595,19 @@ void PeerConnectionE2EQualityTest::SetPeerCodecPreferences(TestPeer* peer) { peer->params().video_codecs, true, peer->params().use_ulp_fec, peer->params().use_flex_fec, peer->pc_factory() - ->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpReceiverCapabilities(MediaType::VIDEO) .codecs); std::vector without_rtx_video_capabilities = FilterVideoCodecCapabilities( peer->params().video_codecs, false, peer->params().use_ulp_fec, peer->params().use_flex_fec, peer->pc_factory() - ->GetRtpReceiverCapabilities(webrtc::MediaType::VIDEO) + ->GetRtpReceiverCapabilities(MediaType::VIDEO) .codecs); // Set codecs for transceivers for (auto transceiver : peer->pc()->GetTransceivers()) { - if (transceiver->media_type() == webrtc::MediaType::VIDEO) { + if (transceiver->media_type() == MediaType::VIDEO) { if (transceiver->sender()->init_send_encodings().size() > 1) { // If transceiver's sender has more then 1 send encodings, it means it // has multiple simulcast streams, so we need disable RTX on it. diff --git a/test/pc/e2e/peer_connection_quality_test_metric_names_test.cc b/test/pc/e2e/peer_connection_quality_test_metric_names_test.cc index a3eea5d825..757ce74bc8 100644 --- a/test/pc/e2e/peer_connection_quality_test_metric_names_test.cc +++ b/test/pc/e2e/peer_connection_quality_test_metric_names_test.cc @@ -43,11 +43,11 @@ namespace { using ::testing::IsSupersetOf; using ::testing::UnorderedElementsAre; -using ::webrtc::test::DefaultMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Metric; -using ::webrtc::test::Unit; -using ::webrtc::webrtc_pc_e2e::PeerConfigurer; +using test::DefaultMetricsLogger; +using test::ImprovementDirection; +using test::Metric; +using test::Unit; +using webrtc_pc_e2e::PeerConfigurer; std::string GetExpectedTestCaseName(const std::string& stream_label) { if (!absl::GetFlag(FLAGS_isolated_script_test_perf_output).empty()) { diff --git a/test/pc/e2e/peer_connection_quality_test_test.cc b/test/pc/e2e/peer_connection_quality_test_test.cc index 35e299bf37..a945b0491f 100644 --- a/test/pc/e2e/peer_connection_quality_test_test.cc +++ b/test/pc/e2e/peer_connection_quality_test_test.cc @@ -36,7 +36,7 @@ namespace { using ::testing::Eq; using ::testing::Test; -using ::webrtc::webrtc_pc_e2e::PeerConfigurer; +using webrtc_pc_e2e::PeerConfigurer; // Remove files and directories in a directory non-recursively. void CleanDir(absl::string_view dir, size_t expected_output_files_count) { diff --git a/test/pc/e2e/sdp/sdp_changer.cc b/test/pc/e2e/sdp/sdp_changer.cc index 6c74740cac..6aa774bf69 100644 --- a/test/pc/e2e/sdp/sdp_changer.cc +++ b/test/pc/e2e/sdp/sdp_changer.cc @@ -133,7 +133,7 @@ void SignalingInterceptor::FillSimulcastContext( SessionDescriptionInterface* offer) { for (auto& content : offer->description()->contents()) { MediaContentDescription* media_desc = content.media_description(); - if (media_desc->type() != webrtc::MediaType::VIDEO) { + if (media_desc->type() != MediaType::VIDEO) { continue; } if (media_desc->HasSimulcast()) { @@ -189,7 +189,7 @@ LocalAndRemoteSdp SignalingInterceptor::PatchOffer( for (auto& content : offer->description()->contents()) { context_.mids_order.push_back(content.mid()); MediaContentDescription* media_desc = content.media_description(); - if (media_desc->type() != webrtc::MediaType::VIDEO) { + if (media_desc->type() != MediaType::VIDEO) { continue; } if (content.media_description()->streams().empty()) { @@ -249,7 +249,7 @@ LocalAndRemoteSdp SignalingInterceptor::PatchVp8Offer( // Swap mid and rid extensions, so remote peer will understand rid as mid. // Also remove rid extension. - std::vector extensions = + std::vector extensions = prototype_media_desc->rtp_header_extensions(); for (auto ext_it = extensions.begin(); ext_it != extensions.end();) { if (ext_it->uri == RtpExtension::kRidUri) { @@ -333,7 +333,7 @@ LocalAndRemoteSdp SignalingInterceptor::PatchVp9Offer( } for (auto& content : offer->description()->contents()) { - if (content.media_description()->type() != webrtc::MediaType::VIDEO) { + if (content.media_description()->type() != MediaType::VIDEO) { // We are interested in only video tracks continue; } @@ -381,7 +381,7 @@ LocalAndRemoteSdp SignalingInterceptor::PatchAnswer( const VideoCodecConfig& first_codec) { for (auto& content : answer->description()->contents()) { MediaContentDescription* media_desc = content.media_description(); - if (media_desc->type() != webrtc::MediaType::VIDEO) { + if (media_desc->type() != MediaType::VIDEO) { continue; } if (content.media_description()->direction() != @@ -433,8 +433,7 @@ LocalAndRemoteSdp SignalingInterceptor::PatchVp8Answer( // Patch `media_desc` to make it simulcast answer description. // Restore mid/rid rtp header extensions - std::vector extensions = - media_desc->rtp_header_extensions(); + std::vector extensions = media_desc->rtp_header_extensions(); // First remove existing rid/mid header extensions. extensions.erase(std::remove_if(extensions.begin(), extensions.end(), [](const webrtc::RtpExtension& e) { diff --git a/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc b/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc index 333d6818bf..32f6eb4d59 100644 --- a/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc +++ b/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc @@ -49,8 +49,8 @@ namespace webrtc { namespace webrtc_pc_e2e { namespace { -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Unit; +using test::ImprovementDirection; +using test::Unit; using NetworkLayerStats = StatsBasedNetworkQualityMetricsReporter::NetworkLayerStats; diff --git a/test/pc/e2e/stats_based_network_quality_metrics_reporter_test.cc b/test/pc/e2e/stats_based_network_quality_metrics_reporter_test.cc index fe2947aa79..b06324361e 100644 --- a/test/pc/e2e/stats_based_network_quality_metrics_reporter_test.cc +++ b/test/pc/e2e/stats_based_network_quality_metrics_reporter_test.cc @@ -39,11 +39,11 @@ namespace { using ::testing::UnorderedElementsAre; -using ::webrtc::test::DefaultMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Metric; -using ::webrtc::test::Unit; -using ::webrtc::webrtc_pc_e2e::PeerConfigurer; +using test::DefaultMetricsLogger; +using test::ImprovementDirection; +using test::Metric; +using test::Unit; +using webrtc_pc_e2e::PeerConfigurer; // Adds a peer with some audio and video (the client should not care about // details about audio and video configs). diff --git a/test/pc/e2e/stats_poller.cc b/test/pc/e2e/stats_poller.cc index 49daf20c1b..23db7acbd3 100644 --- a/test/pc/e2e/stats_poller.cc +++ b/test/pc/e2e/stats_poller.cc @@ -32,7 +32,7 @@ void InternalStatsObserver::OnStatsDelivered( StatsPoller::StatsPoller(std::vector observers, std::map peers) : observers_(std::move(observers)) { - webrtc::MutexLock lock(&mutex_); + MutexLock lock(&mutex_); for (auto& peer : peers) { pollers_.push_back(make_ref_counted( peer.first, peer.second, observers_)); @@ -42,7 +42,7 @@ StatsPoller::StatsPoller(std::vector observers, StatsPoller::StatsPoller(std::vector observers, std::map peers) : observers_(std::move(observers)) { - webrtc::MutexLock lock(&mutex_); + MutexLock lock(&mutex_); for (auto& peer : peers) { pollers_.push_back(make_ref_counted( peer.first, peer.second, observers_)); @@ -50,7 +50,7 @@ StatsPoller::StatsPoller(std::vector observers, } void StatsPoller::PollStatsAndNotifyObservers() { - webrtc::MutexLock lock(&mutex_); + MutexLock lock(&mutex_); for (auto& poller : pollers_) { poller->PollStats(); } @@ -58,13 +58,13 @@ void StatsPoller::PollStatsAndNotifyObservers() { void StatsPoller::RegisterParticipantInCall(absl::string_view peer_name, StatsProvider* peer) { - webrtc::MutexLock lock(&mutex_); + MutexLock lock(&mutex_); pollers_.push_back( make_ref_counted(peer_name, peer, observers_)); } bool StatsPoller::UnregisterParticipantInCall(absl::string_view peer_name) { - webrtc::MutexLock lock(&mutex_); + MutexLock lock(&mutex_); for (auto it = pollers_.begin(); it != pollers_.end(); ++it) { if ((*it)->pc_label() == peer_name) { pollers_.erase(it); diff --git a/test/pc/e2e/stats_poller_test.cc b/test/pc/e2e/stats_poller_test.cc index 754145f629..ce6ea2476c 100644 --- a/test/pc/e2e/stats_poller_test.cc +++ b/test/pc/e2e/stats_poller_test.cc @@ -41,7 +41,7 @@ class MockStatsObserver : public StatsObserverInterface { MOCK_METHOD(void, OnStatsReports, (absl::string_view pc_label, - const webrtc::scoped_refptr& report)); + const scoped_refptr& report)); }; TEST(StatsPollerTest, UnregisterParticipantAddedInCtor) { diff --git a/test/pc/e2e/test_peer.cc b/test/pc/e2e/test_peer.cc index a0c5dc48f3..9028f947dc 100644 --- a/test/pc/e2e/test_peer.cc +++ b/test/pc/e2e/test_peer.cc @@ -38,20 +38,20 @@ namespace webrtc_pc_e2e { namespace { class SetRemoteDescriptionCallback - : public webrtc::SetRemoteDescriptionObserverInterface { + : public SetRemoteDescriptionObserverInterface { public: - void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override { + void OnSetRemoteDescriptionComplete(RTCError error) override { is_called_ = true; error_ = error; } bool is_called() const { return is_called_; } - webrtc::RTCError error() const { return error_; } + RTCError error() const { return error_; } private: bool is_called_ = false; - webrtc::RTCError error_; + RTCError error_; }; } // namespace diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index 07b980a084..85d356a182 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -18,16 +18,16 @@ #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/audio/audio_device.h" +#include "api/enable_media_with_defaults.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/scoped_refptr.h" -#include "api/task_queue/task_queue_factory.h" -#include "api/test/create_time_controller.h" #include "api/test/pclf/media_configuration.h" #include "api/test/pclf/media_quality_test_params.h" #include "api/test/pclf/peer_configurer.h" #include "api/test/time_controller.h" -#include "api/transport/field_trial_based_config.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" #include "api/video_codecs/video_decoder_factory.h" @@ -48,7 +48,7 @@ namespace webrtc_pc_e2e { namespace { using EmulatedSFUConfigMap = - ::webrtc::webrtc_pc_e2e::QualityAnalyzingVideoEncoder::EmulatedSFUConfigMap; + webrtc_pc_e2e::QualityAnalyzingVideoEncoder::EmulatedSFUConfigMap; constexpr int16_t kGeneratedAudioMaxAmplitude = 32000; constexpr int kDefaultSamplingFrequencyInHz = 48000; @@ -66,10 +66,6 @@ void SetMandatoryEntities(InjectableComponents* components) { components->pcf_dependencies->event_log_factory = std::make_unique(); } - if (!components->pcf_dependencies->trials) { - components->pcf_dependencies->trials = - std::make_unique(); - } } // Returns mapping from stream label to optional spatial index. @@ -127,10 +123,10 @@ std::unique_ptr CreateAudioCapturer( } scoped_refptr CreateAudioDeviceModule( + const Environment& env, std::optional audio_config, std::optional remote_audio_config, - std::optional echo_emulation_config, - TaskQueueFactory* task_queue_factory) { + std::optional echo_emulation_config) { std::unique_ptr renderer = CreateAudioRenderer(remote_audio_config); std::unique_ptr capturer = @@ -153,7 +149,7 @@ scoped_refptr CreateAudioDeviceModule( std::move(capturer), audio_config->input_dump_file_name.value()); } - return TestAudioDeviceModule::Create(task_queue_factory, std::move(capturer), + return TestAudioDeviceModule::Create(env, std::move(capturer), std::move(renderer), /*speed=*/1.f); } @@ -193,8 +189,8 @@ void WrapVideoDecoderFactory( // Creates PeerConnectionFactoryDependencies objects, providing entities // from InjectableComponents::PeerConnectionFactoryComponents. PeerConnectionFactoryDependencies CreatePCFDependencies( + const Environment& env, std::unique_ptr pcf_dependencies, - TimeController& time_controller, scoped_refptr audio_device_module, Thread* signaling_thread, Thread* worker_thread, @@ -207,7 +203,7 @@ PeerConnectionFactoryDependencies CreatePCFDependencies( pcf_deps.network_manager = std::move(pcf_dependencies->network_manager); pcf_deps.event_log_factory = std::move(pcf_dependencies->event_log_factory); - pcf_deps.task_queue_factory = time_controller.CreateTaskQueueFactory(); + pcf_deps.env = env; if (pcf_dependencies->fec_controller_factory != nullptr) { pcf_deps.fec_controller_factory = @@ -220,9 +216,6 @@ PeerConnectionFactoryDependencies CreatePCFDependencies( if (pcf_dependencies->neteq_factory != nullptr) { pcf_deps.neteq_factory = std::move(pcf_dependencies->neteq_factory); } - if (pcf_dependencies->trials != nullptr) { - pcf_deps.trials = std::move(pcf_dependencies->trials); - } // Media dependencies pcf_deps.adm = std::move(audio_device_module); @@ -235,7 +228,7 @@ PeerConnectionFactoryDependencies CreatePCFDependencies( std::move(pcf_dependencies->video_decoder_factory); pcf_deps.audio_encoder_factory = pcf_dependencies->audio_encoder_factory; pcf_deps.audio_decoder_factory = pcf_dependencies->audio_decoder_factory; - EnableMediaWithDefaultsAndTimeController(time_controller, pcf_deps); + EnableMediaWithDefaults(pcf_deps); return pcf_deps; } @@ -296,11 +289,14 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( SetMandatoryEntities(components.get()); params->rtc_configuration.sdp_semantics = SdpSemantics::kUnifiedPlan; + const Environment env = CreateEnvironment( + std::move(components->pcf_dependencies->trials), + time_controller_.GetClock(), time_controller_.GetTaskQueueFactory()); + // Create peer connection factory. scoped_refptr audio_device_module = - CreateAudioDeviceModule(params->audio_config, remote_audio_config, - echo_emulation_config, - time_controller_.GetTaskQueueFactory()); + CreateAudioDeviceModule(env, params->audio_config, remote_audio_config, + echo_emulation_config); WrapVideoEncoderFactory( params->name.value(), params->video_encoder_bitrate_multiplier, CalculateRequiredSpatialIndexPerStream( @@ -319,7 +315,7 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( } PeerConnectionFactoryDependencies pcf_deps = CreatePCFDependencies( - std::move(components->pcf_dependencies), time_controller_, + env, std::move(components->pcf_dependencies), std::move(audio_device_module), signaling_thread_, components->worker_thread, components->network_thread); scoped_refptr peer_connection_factory = diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn index 41bcd65f0b..b56607f80a 100644 --- a/test/peer_scenario/BUILD.gn +++ b/test/peer_scenario/BUILD.gn @@ -31,7 +31,7 @@ if (rtc_include_tests) { "../../api:array_view", "../../api:audio_options_api", "../../api:candidate", - "../../api:create_time_controller", + "../../api:enable_media_with_defaults", "../../api:libjingle_peerconnection_api", "../../api:make_ref_counted", "../../api:media_stream_interface", @@ -41,11 +41,11 @@ if (rtc_include_tests) { "../../api:sequence_checker", "../../api:time_controller", "../../api/environment", + "../../api/environment:environment_factory", "../../api/rtc_event_log:rtc_event_log_factory", "../../api/test/network_emulation", "../../api/transport:datagram_transport_interface", "../../api/transport:enums", - "../../api/transport:field_trial_based_config", "../../api/video:video_frame", "../../api/video_codecs:scalability_mode", "../../api/video_codecs:video_codecs_api", @@ -89,6 +89,7 @@ if (rtc_include_tests) { "../../rtc_base:task_queue_for_test", "../../rtc_base:threading", "../../rtc_base/third_party/sigslot", + "../../system_wrappers", "../logging:log_writer", "../network:emulated_network", "../scenario", diff --git a/test/peer_scenario/peer_scenario_client.cc b/test/peer_scenario/peer_scenario_client.cc index 391967f14e..f5a207c4e9 100644 --- a/test/peer_scenario/peer_scenario_client.cc +++ b/test/peer_scenario/peer_scenario_client.cc @@ -23,7 +23,9 @@ #include "api/audio_options.h" #include "api/candidate.h" #include "api/data_channel_interface.h" +#include "api/enable_media_with_defaults.h" #include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/jsep.h" #include "api/make_ref_counted.h" #include "api/media_stream_interface.h" @@ -36,10 +38,8 @@ #include "api/sequence_checker.h" #include "api/set_local_description_observer_interface.h" #include "api/set_remote_description_observer_interface.h" -#include "api/test/create_time_controller.h" #include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/test/network_emulation_manager.h" -#include "api/transport/field_trial_based_config.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" @@ -210,11 +210,10 @@ class LambdaSetRemoteDescriptionObserver class FakeVideoEncoderFactory : public VideoEncoderFactory { public: std::vector GetSupportedFormats() const override { - const absl::InlinedVector - kSupportedScalabilityModes = {webrtc::ScalabilityMode::kL1T1, - webrtc::ScalabilityMode::kL1T2, - webrtc::ScalabilityMode::kL1T3}; + const absl::InlinedVector + kSupportedScalabilityModes = {ScalabilityMode::kL1T1, + ScalabilityMode::kL1T2, + ScalabilityMode::kL1T3}; return {SdpVideoFormat(kVp8CodecName, {}, kSupportedScalabilityModes)}; } std::unique_ptr Create(const Environment& env, @@ -241,8 +240,9 @@ PeerScenarioClient::PeerScenarioClient( Thread* signaling_thread, std::unique_ptr log_writer_factory, PeerScenarioClient::Config config) - : endpoints_(CreateEndpoints(net, config.endpoints)), - task_queue_factory_(net->time_controller()->GetTaskQueueFactory()), + : env_(CreateEnvironment(net->time_controller()->GetClock(), + net->time_controller()->GetTaskQueueFactory())), + endpoints_(CreateEndpoints(net, config.endpoints)), signaling_thread_(signaling_thread), log_writer_factory_(std::move(log_writer_factory)), worker_thread_(net->time_controller()->CreateThread("worker")), @@ -282,13 +282,11 @@ PeerScenarioClient::PeerScenarioClient( pcf_deps.worker_thread = worker_thread_.get(); pcf_deps.socket_factory = manager->socket_factory(); pcf_deps.network_manager = manager->ReleaseNetworkManager(); - pcf_deps.task_queue_factory = - net->time_controller()->CreateTaskQueueFactory(); pcf_deps.event_log_factory = std::make_unique(); - pcf_deps.trials = std::make_unique(); + pcf_deps.env = env_; pcf_deps.adm = TestAudioDeviceModule::Create( - task_queue_factory_, + env_, TestAudioDeviceModule::CreatePulsedNoiseCapturer( config.audio.pulsed_noise->amplitude * std::numeric_limits::max(), @@ -311,7 +309,7 @@ PeerScenarioClient::PeerScenarioClient( OpenH264DecoderTemplateAdapter, Dav1dDecoderTemplateAdapter>>(); } - EnableMediaWithDefaultsAndTimeController(*net->time_controller(), pcf_deps); + EnableMediaWithDefaults(pcf_deps); pcf_deps.fec_controller_factory = nullptr; pcf_deps.network_controller_factory = nullptr; @@ -356,8 +354,8 @@ PeerScenarioClient::VideoSendTrack PeerScenarioClient::CreateVideo( VideoSendTrackConfig config) { RTC_DCHECK_RUN_ON(signaling_thread_); VideoSendTrack res; - auto capturer = CreateFrameGeneratorCapturer(clock(), *task_queue_factory_, - config.generator); + auto capturer = CreateFrameGeneratorCapturer( + clock(), env_.task_queue_factory(), config.generator); res.capturer = capturer.get(); capturer->Init(); res.source = make_ref_counted( diff --git a/test/peer_scenario/peer_scenario_client.h b/test/peer_scenario/peer_scenario_client.h index dfe502ec95..6e2510fda1 100644 --- a/test/peer_scenario/peer_scenario_client.h +++ b/test/peer_scenario/peer_scenario_client.h @@ -14,15 +14,32 @@ #include #include #include +#include #include #include -#include "absl/memory/memory.h" +#include "api/audio_options.h" +#include "api/candidate.h" +#include "api/data_channel_interface.h" +#include "api/environment/environment.h" +#include "api/jsep.h" +#include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" +#include "api/rtp_receiver_interface.h" +#include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" +#include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/test/network_emulation_manager.h" -#include "api/test/time_controller.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" #include "pc/test/frame_generator_capturer_video_track_source.h" +#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" +#include "system_wrappers/include/clock.h" #include "test/create_frame_generator_capturer.h" +#include "test/frame_generator_capturer.h" #include "test/logging/log_writer.h" namespace webrtc { @@ -159,8 +176,8 @@ class PeerScenarioClient { void AddIceCandidate(std::unique_ptr candidate); private: + const Environment env_; const std::map endpoints_; - TaskQueueFactory* const task_queue_factory_; Thread* const signaling_thread_; const std::unique_ptr log_writer_factory_; const std::unique_ptr worker_thread_; diff --git a/test/peer_scenario/scenario_connection.cc b/test/peer_scenario/scenario_connection.cc index 9e35696ad1..bdbba3b9f0 100644 --- a/test/peer_scenario/scenario_connection.cc +++ b/test/peer_scenario/scenario_connection.cc @@ -113,7 +113,7 @@ class ScenarioIceConnectionImpl : public ScenarioIceConnection, std::unique_ptr ScenarioIceConnection::Create( const Environment& env, - webrtc::test::NetworkEmulationManagerImpl* net, + test::NetworkEmulationManagerImpl* net, IceConnectionObserver* observer) { return std::make_unique(env, net, observer); } @@ -155,7 +155,7 @@ ScenarioIceConnectionImpl::ScenarioIceConnectionImpl( port_allocator_->Initialize(); RTC_CHECK(port_allocator_->SetConfiguration(/*stun_servers*/ {}, /*turn_servers*/ {}, 0, - webrtc::NO_PRUNE)); + NO_PRUNE)); jsep_controller_->SetLocalCertificate(certificate_); }); } @@ -208,7 +208,7 @@ void ScenarioIceConnectionImpl::SendRtcpPacket( void ScenarioIceConnectionImpl::SetRemoteSdp(SdpType type, const std::string& remote_sdp) { RTC_DCHECK_RUN_ON(signaling_thread_); - remote_description_ = webrtc::CreateSessionDescription(type, remote_sdp); + remote_description_ = CreateSessionDescription(type, remote_sdp); jsep_controller_->SubscribeIceCandidateGathered( [this](const std::string& transport, const std::vector& candidate) { @@ -237,7 +237,7 @@ void ScenarioIceConnectionImpl::SetRemoteSdp(SdpType type, void ScenarioIceConnectionImpl::SetLocalSdp(SdpType type, const std::string& local_sdp) { RTC_DCHECK_RUN_ON(signaling_thread_); - local_description_ = webrtc::CreateSessionDescription(type, local_sdp); + local_description_ = CreateSessionDescription(type, local_sdp); auto res = jsep_controller_->SetLocalDescription( local_description_->GetType(), local_description_->description(), remote_description_ ? remote_description_->description() : nullptr); diff --git a/test/peer_scenario/tests/bwe_ramp_up_test.cc b/test/peer_scenario/tests/bwe_ramp_up_test.cc index ddd9d15bad..b8cee3e051 100644 --- a/test/peer_scenario/tests/bwe_ramp_up_test.cc +++ b/test/peer_scenario/tests/bwe_ramp_up_test.cc @@ -52,8 +52,7 @@ using ::testing::WithParamInterface; scoped_refptr GetStatsAndProcess( PeerScenario& s, PeerScenarioClient* client) { - auto stats_collector = - make_ref_counted(); + auto stats_collector = make_ref_counted(); client->pc()->GetStats(stats_collector.get()); s.ProcessMessages(TimeDelta::Millis(0)); RTC_CHECK(stats_collector->called()); @@ -214,13 +213,13 @@ INSTANTIATE_TEST_SUITE_P( .expected_bwe_min = DataRate::KilobitsPerSec(2500), }, { - .network_capacity = webrtc::DataRate::KilobitsPerSec(500), - .expected_bwe_min = webrtc::DataRate::KilobitsPerSec(400), + .network_capacity = DataRate::KilobitsPerSec(500), + .expected_bwe_min = DataRate::KilobitsPerSec(400), }})); class MockRtpSenderObserver : public RtpSenderObserverInterface { public: - MOCK_METHOD(void, OnFirstPacketSent, (webrtc::MediaType)); + MOCK_METHOD(void, OnFirstPacketSent, (MediaType)); }; // Test that caller and callee BWE rampup even if no media packets are sent. @@ -233,7 +232,7 @@ TEST_P(BweRampupWithInitialProbeTest, BweRampUpBothDirectionsWithoutMedia) { PeerScenarioClient* caller = s.CreateClient({}); PeerScenarioClient* callee = s.CreateClient({}); - auto transceiver = caller->pc()->AddTransceiver(webrtc::MediaType::VIDEO); + auto transceiver = caller->pc()->AddTransceiver(MediaType::VIDEO); ASSERT_TRUE(transceiver.error().ok()); MockRtpSenderObserver observer; @@ -326,7 +325,7 @@ TEST(BweRampupTest, CanReconfigureBweAfterStopingVideo) { // Send a TCP messages to the receiver using the same downlink node. // This is done just to force a lower BWE than the link capacity. - webrtc::TcpMessageRoute* tcp_route = s.net()->CreateTcpRoute( + TcpMessageRoute* tcp_route = s.net()->CreateTcpRoute( s.net()->CreateRoute({caller_node}), s.net()->CreateRoute({callee_node})); DataRate bwe_before_restart = DataRate::Zero(); diff --git a/test/peer_scenario/tests/l4s_test.cc b/test/peer_scenario/tests/l4s_test.cc index 3ac13e0005..b68fba2658 100644 --- a/test/peer_scenario/tests/l4s_test.cc +++ b/test/peer_scenario/tests/l4s_test.cc @@ -94,8 +94,7 @@ class RtcpFeedbackCounter { scoped_refptr GetStatsAndProcess( PeerScenario& s, PeerScenarioClient* client) { - auto stats_collector = - make_ref_counted(); + auto stats_collector = make_ref_counted(); client->pc()->GetStats(stats_collector.get()); s.ProcessMessages(TimeDelta::Millis(0)); RTC_CHECK(stats_collector->called()); diff --git a/test/rtp_file_reader_unittest.cc b/test/rtp_file_reader_unittest.cc index eea88c9d97..eb15d873f0 100644 --- a/test/rtp_file_reader_unittest.cc +++ b/test/rtp_file_reader_unittest.cc @@ -27,7 +27,7 @@ class TestRtpFileReader : public ::testing::Test { test::ResourcePath("video_coding/" + filename, "rtp"); rtp_packet_source_.reset( test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, filepath)); - ASSERT_TRUE(rtp_packet_source_.get() != NULL); + ASSERT_TRUE(rtp_packet_source_.get() != nullptr); headers_only_file_ = headers_only_file; } @@ -68,7 +68,7 @@ class TestPcapFileReader : public ::testing::Test { test::ResourcePath("video_coding/" + filename, "pcap"); rtp_packet_source_.reset( test::RtpFileReader::Create(test::RtpFileReader::kPcap, filepath)); - ASSERT_TRUE(rtp_packet_source_.get() != NULL); + ASSERT_TRUE(rtp_packet_source_.get() != nullptr); } int CountRtpPackets() { diff --git a/test/rtp_file_writer.cc b/test/rtp_file_writer.cc index f992756aab..118d8cdd29 100644 --- a/test/rtp_file_writer.cc +++ b/test/rtp_file_writer.cc @@ -29,13 +29,13 @@ static const char kFirstLine[] = "#!rtpplay1.0 0.0.0.0/0\n"; class RtpDumpWriter : public RtpFileWriter { public: explicit RtpDumpWriter(FILE* file) : file_(file) { - RTC_CHECK(file_ != NULL); + RTC_CHECK(file_ != nullptr); Init(); } ~RtpDumpWriter() override { - if (file_ != NULL) { + if (file_ != nullptr) { fclose(file_); - file_ = NULL; + file_ = nullptr; } } @@ -98,16 +98,16 @@ class RtpDumpWriter : public RtpFileWriter { RtpFileWriter* RtpFileWriter::Create(FileFormat format, const std::string& filename) { FILE* file = fopen(filename.c_str(), "wb"); - if (file == NULL) { + if (file == nullptr) { printf("ERROR: Can't open file: %s\n", filename.c_str()); - return NULL; + return nullptr; } switch (format) { case kRtpDump: return new RtpDumpWriter(file); } fclose(file); - return NULL; + return nullptr; } } // namespace test diff --git a/test/rtp_file_writer_unittest.cc b/test/rtp_file_writer_unittest.cc index 2396d7c346..5d51e46ef4 100644 --- a/test/rtp_file_writer_unittest.cc +++ b/test/rtp_file_writer_unittest.cc @@ -30,7 +30,7 @@ class RtpFileWriterTest : public ::testing::Test { } void WriteRtpPackets(int num_packets, int time_ms_offset = 0) { - ASSERT_TRUE(rtp_writer_.get() != NULL); + ASSERT_TRUE(rtp_writer_.get() != nullptr); test::RtpPacket packet; for (int i = 1; i <= num_packets; ++i) { packet.length = i; @@ -44,11 +44,11 @@ class RtpFileWriterTest : public ::testing::Test { void CloseOutputFile() { rtp_writer_.reset(); } void VerifyFileContents(int expected_packets) { - ASSERT_TRUE(rtp_writer_.get() == NULL) + ASSERT_TRUE(rtp_writer_.get() == nullptr) << "Must call CloseOutputFile before VerifyFileContents"; std::unique_ptr rtp_reader( test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, filename_)); - ASSERT_TRUE(rtp_reader.get() != NULL); + ASSERT_TRUE(rtp_reader.get() != nullptr); test::RtpPacket packet; int i = 0; while (rtp_reader->NextPacket(&packet)) { diff --git a/test/rtp_rtcp_observer.h b/test/rtp_rtcp_observer.h index d4b8ec4352..f392674bb8 100644 --- a/test/rtp_rtcp_observer.h +++ b/test/rtp_rtcp_observer.h @@ -10,20 +10,23 @@ #ifndef TEST_RTP_RTCP_OBSERVER_H_ #define TEST_RTP_RTCP_OBSERVER_H_ +#include #include #include #include -#include #include "absl/flags/flag.h" #include "api/array_view.h" -#include "api/test/simulated_network.h" +#include "api/call/transport.h" +#include "api/media_types.h" +#include "api/rtp_parameters.h" +#include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" +#include "call/call.h" #include "call/simulated_packet_receiver.h" -#include "call/video_send_stream.h" #include "modules/rtp_rtcp/source/rtp_util.h" +#include "rtc_base/checks.h" #include "rtc_base/event.h" -#include "system_wrappers/include/field_trial.h" #include "test/direct_transport.h" #include "test/gtest.h" #include "test/test_flags.h" @@ -116,10 +119,12 @@ class PacketTransport : public test::DirectTransport { case RtpRtcpObserver::SEND_PACKET: return test::DirectTransport::SendRtp(packet, options); } - return true; // Will never happen, makes compiler happy. + RTC_DCHECK_NOTREACHED(); + return true; } - bool SendRtcp(ArrayView packet) override { + bool SendRtcp(ArrayView packet, + const PacketOptions& options) override { EXPECT_TRUE(IsRtcpPacket(packet)); RtpRtcpObserver::Action action = RtpRtcpObserver::SEND_PACKET; if (observer_) { @@ -134,9 +139,10 @@ class PacketTransport : public test::DirectTransport { // Drop packet silently. return true; case RtpRtcpObserver::SEND_PACKET: - return test::DirectTransport::SendRtcp(packet); + return test::DirectTransport::SendRtcp(packet, options); } - return true; // Will never happen, makes compiler happy. + RTC_DCHECK_NOTREACHED(); + return true; } RtpRtcpObserver* const observer_; diff --git a/test/run_loop.cc b/test/run_loop.cc index d3495e00e8..7bcde87022 100644 --- a/test/run_loop.cc +++ b/test/run_loop.cc @@ -51,7 +51,7 @@ void RunLoop::FakeSocketServer::FailNextWait() { fail_next_wait_ = true; } -bool RunLoop::FakeSocketServer::Wait(webrtc::TimeDelta max_wait_duration, +bool RunLoop::FakeSocketServer::Wait(TimeDelta max_wait_duration, bool process_io) { if (fail_next_wait_) { fail_next_wait_ = false; diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn index 2cae7625cd..b7fd6a3506 100644 --- a/test/scenario/BUILD.gn +++ b/test/scenario/BUILD.gn @@ -103,6 +103,7 @@ if (rtc_include_tests && !build_with_chromium) { "../../api/task_queue", "../../api/test/network_emulation", "../../api/test/video:function_video_factory", + "../../api/transport:bitrate_settings", "../../api/transport:network_control", "../../api/units:data_rate", "../../api/units:data_size", @@ -140,6 +141,7 @@ if (rtc_include_tests && !build_with_chromium) { "../../modules/video_coding/svc:scalability_mode_util", "../../rtc_base:checks", "../../rtc_base:copy_on_write_buffer", + "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:net_helper", "../../rtc_base:net_helpers", diff --git a/test/scenario/call_client.cc b/test/scenario/call_client.cc index b598c2878c..1f6719d88d 100644 --- a/test/scenario/call_client.cc +++ b/test/scenario/call_client.cc @@ -9,24 +9,48 @@ */ #include "test/scenario/call_client.h" -#include +#include +#include +#include #include +#include #include +#include "api/array_view.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/media_types.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log_factory.h" +#include "api/rtc_event_log_output.h" +#include "api/rtp_parameters.h" +#include "api/scoped_refptr.h" +#include "api/task_queue/task_queue_factory.h" +#include "api/test/network_emulation/network_emulation_interfaces.h" +#include "api/test/time_controller.h" +#include "api/transport/bitrate_settings.h" +#include "api/transport/network_control.h" #include "api/transport/network_types.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "call/audio_state.h" #include "call/call.h" -#include "call/rtp_transport_controller_send_factory.h" +#include "call/call_config.h" #include "modules/audio_device/include/test_audio_device.h" #include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_util.h" +#include "rtc_base/checks.h" +#include "rtc_base/event.h" +#include "rtc_base/logging.h" +#include "rtc_base/strings/string_builder.h" +#include "test/logging/log_writer.h" +#include "test/scenario/column_printer.h" +#include "test/scenario/network_node.h" +#include "test/scenario/scenario_config.h" namespace webrtc { namespace test { @@ -48,7 +72,7 @@ CallClientFakeAudio InitAudio(const Environment& env) { auto capturer = TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000); auto renderer = TestAudioDeviceModule::CreateDiscardRenderer(48000); setup.fake_audio_device = TestAudioDeviceModule::Create( - &env.task_queue_factory(), std::move(capturer), std::move(renderer), 1.f); + env, std::move(capturer), std::move(renderer), 1.f); setup.apm = BuiltinAudioProcessingBuilder().Build(env); setup.fake_audio_device->Init(); AudioState::Config audio_state_config; diff --git a/test/scenario/column_printer.cc b/test/scenario/column_printer.cc index 046925ceaa..76746869c0 100644 --- a/test/scenario/column_printer.cc +++ b/test/scenario/column_printer.cc @@ -15,10 +15,9 @@ namespace test { ColumnPrinter::ColumnPrinter(const ColumnPrinter&) = default; ColumnPrinter::~ColumnPrinter() = default; -ColumnPrinter::ColumnPrinter( - const char* headers, - std::function printer, - size_t max_length) +ColumnPrinter::ColumnPrinter(const char* headers, + std::function printer, + size_t max_length) : headers_(headers), printer_(printer), max_length_(max_length) {} ColumnPrinter ColumnPrinter::Fixed(const char* headers, std::string fields) { @@ -29,7 +28,7 @@ ColumnPrinter ColumnPrinter::Fixed(const char* headers, std::string fields) { ColumnPrinter ColumnPrinter::Lambda( const char* headers, - std::function printer, + std::function printer, size_t max_length) { return ColumnPrinter(headers, printer, max_length); } diff --git a/test/scenario/network_node.cc b/test/scenario/network_node.cc index e64cf62cba..364f2e6da9 100644 --- a/test/scenario/network_node.cc +++ b/test/scenario/network_node.cc @@ -122,7 +122,8 @@ bool NetworkNodeTransport::SendRtp(ArrayView packet, return true; } -bool NetworkNodeTransport::SendRtcp(ArrayView packet) { +bool NetworkNodeTransport::SendRtcp(ArrayView packet, + const PacketOptions& options) { CopyOnWriteBuffer buffer(packet); MutexLock lock(&mutex_); if (!endpoint_) diff --git a/test/scenario/network_node.h b/test/scenario/network_node.h index e2f6f59c39..e0086fa6b4 100644 --- a/test/scenario/network_node.h +++ b/test/scenario/network_node.h @@ -62,7 +62,8 @@ class NetworkNodeTransport : public Transport { bool SendRtp(ArrayView packet, const PacketOptions& options) override; - bool SendRtcp(ArrayView packet) override; + bool SendRtcp(ArrayView packet, + const PacketOptions& options) override; void Connect(EmulatedEndpoint* endpoint, const SocketAddress& receiver_address, diff --git a/test/scenario/probing_test.cc b/test/scenario/probing_test.cc index 86653ced9b..f3cbe977c0 100644 --- a/test/scenario/probing_test.cc +++ b/test/scenario/probing_test.cc @@ -86,9 +86,8 @@ TEST(ProbingTest, ProbesRampsUpWhenVideoEncoderConfigChanges) { VideoStreamConfig video_config; video_config.encoder.codec = VideoStreamConfig::Encoder::Codec::kVideoCodecVP8; - video_config.encoder.simulcast_streams = {webrtc::ScalabilityMode::kL1T3, - webrtc::ScalabilityMode::kL1T3, - webrtc::ScalabilityMode::kL1T3}; + video_config.encoder.simulcast_streams = { + ScalabilityMode::kL1T3, ScalabilityMode::kL1T3, ScalabilityMode::kL1T3}; video_config.source.generator.width = 1280; video_config.source.generator.height = 720; diff --git a/test/scenario/video_stream.cc b/test/scenario/video_stream.cc index be211be9f0..0fe68161b2 100644 --- a/test/scenario/video_stream.cc +++ b/test/scenario/video_stream.cc @@ -195,7 +195,7 @@ CreateEncoderSpecificSettings(VideoStreamConfig config) { } VideoEncoderConfig CreateVideoEncoderConfig(VideoStreamConfig config) { - webrtc::VideoEncoder::EncoderInfo encoder_info; + VideoEncoder::EncoderInfo encoder_info; VideoEncoderConfig encoder_config; encoder_config.codec_type = config.encoder.codec; encoder_config.content_type = ConvertContentType(config.encoder.content_type); diff --git a/test/scenario/video_stream_unittest.cc b/test/scenario/video_stream_unittest.cc index b0d1f4d161..0ece8b0eff 100644 --- a/test/scenario/video_stream_unittest.cc +++ b/test/scenario/video_stream_unittest.cc @@ -104,9 +104,9 @@ TEST(VideoStreamTest, ReceivesVp8SimulcastFrames) { c->encoder.implementation = CodecImpl::kSoftware; c->encoder.codec = Codec::kVideoCodecVP8; // Enable simulcast. - c->encoder.simulcast_streams = {webrtc::ScalabilityMode::kL1T1, - webrtc::ScalabilityMode::kL1T1, - webrtc::ScalabilityMode::kL1T1}; + c->encoder.simulcast_streams = {ScalabilityMode::kL1T1, + ScalabilityMode::kL1T1, + ScalabilityMode::kL1T1}; }); s.RunFor(kRunTime); } @@ -218,7 +218,7 @@ TEST(VideoStreamTest, ResolutionAdaptsToAvailableBandwidth) { c->encoder.implementation = CodecImpl::kSoftware; c->encoder.codec = Codec::kVideoCodecVP9; // Enable SVC. - c->encoder.simulcast_streams = {webrtc::ScalabilityMode::kL2T1}; + c->encoder.simulcast_streams = {ScalabilityMode::kL2T1}; }); // Run for a few seconds, until streams have stabilized, diff --git a/test/scoped_key_value_config.cc b/test/scoped_key_value_config.cc index df84462637..6f1230da4b 100644 --- a/test/scoped_key_value_config.cc +++ b/test/scoped_key_value_config.cc @@ -115,7 +115,7 @@ std::string ScopedKeyValueConfig::LookupRecurse(absl::string_view key) const { // When at the root, check the global string so that test programs using // a mix between ScopedKeyValueConfig and the global string continue to work - return webrtc::field_trial::FindFullName(std::string(key)); + return field_trial::FindFullName(std::string(key)); } } // namespace test diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc index 8931adf776..5348d1c0be 100644 --- a/test/test_main_lib.cc +++ b/test/test_main_lib.cc @@ -10,10 +10,8 @@ #include "test/test_main_lib.h" -#include - #include -#include +#include #include #include #include @@ -25,11 +23,11 @@ #include "absl/strings/string_view.h" #include "api/test/metrics/chrome_perf_dashboard_metrics_exporter.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" +#include "api/test/metrics/metric.h" #include "api/test/metrics/metrics_exporter.h" #include "api/test/metrics/metrics_set_proto_file_exporter.h" #include "api/test/metrics/print_result_proxy_metrics_exporter.h" #include "api/test/metrics/stdout_metrics_exporter.h" -#include "rtc_base/checks.h" #include "rtc_base/event_tracer.h" #include "rtc_base/logging.h" #include "rtc_base/ssl_adapter.h" @@ -38,6 +36,7 @@ #include "system_wrappers/include/metrics.h" #include "test/gtest.h" #include "test/test_flags.h" +#include "test/testsupport/file_utils.h" #include "test/testsupport/perf_test.h" #include "test/testsupport/resources_dir_flag.h" @@ -204,10 +203,9 @@ class TestMainImpl : public TestMain { if (absl::GetFlag(FLAGS_export_perf_results_new_api)) { exporters.push_back(std::make_unique()); if (!absl::GetFlag(FLAGS_webrtc_test_metrics_output_path).empty()) { - exporters.push_back( - std::make_unique( - webrtc::test::MetricsSetProtoFileExporter::Options( - absl::GetFlag(FLAGS_webrtc_test_metrics_output_path)))); + exporters.push_back(std::make_unique( + test::MetricsSetProtoFileExporter::Options( + absl::GetFlag(FLAGS_webrtc_test_metrics_output_path)))); } if (!absl::GetFlag(FLAGS_isolated_script_test_perf_output).empty()) { exporters.push_back( @@ -218,18 +216,42 @@ class TestMainImpl : public TestMain { exporters.push_back( std::make_unique()); } + // Log number of tests that should be run, are disabled or skipped and total + // number. + int total_test_count = + ::testing::UnitTest::GetInstance()->total_test_count(); + int test_to_run_count = + ::testing::UnitTest::GetInstance()->test_to_run_count(); + int disabled_test_count = + ::testing::UnitTest::GetInstance()->disabled_test_count(); + int skipped_test_count = + ::testing::UnitTest::GetInstance()->skipped_test_count(); + absl::string_view test_suite_name = test::FileName(argv[0]); + test::GetGlobalMetricsLogger()->LogSingleValueMetric( + "TotalTestCount", test_suite_name, total_test_count, test::Unit::kCount, + test::ImprovementDirection::kBiggerIsBetter); + test::GetGlobalMetricsLogger()->LogSingleValueMetric( + "RunTestCount", test_suite_name, test_to_run_count, test::Unit::kCount, + test::ImprovementDirection::kBiggerIsBetter); + test::GetGlobalMetricsLogger()->LogSingleValueMetric( + "DisabledTestCount", test_suite_name, disabled_test_count, + test::Unit::kCount, test::ImprovementDirection::kSmallerIsBetter); + test::GetGlobalMetricsLogger()->LogSingleValueMetric( + "SkippedTestCount", test_suite_name, skipped_test_count, + test::Unit::kCount, test::ImprovementDirection::kSmallerIsBetter); + test::ExportPerfMetric(*test::GetGlobalMetricsLogger(), std::move(exporters)); if (!absl::GetFlag(FLAGS_export_perf_results_new_api)) { std::string perf_output_file = absl::GetFlag(FLAGS_isolated_script_test_perf_output); if (!perf_output_file.empty()) { - if (!webrtc::test::WritePerfResults(perf_output_file)) { + if (!test::WritePerfResults(perf_output_file)) { return 1; } } if (metrics_to_plot) { - webrtc::test::PrintPlottableResults(*metrics_to_plot); + test::PrintPlottableResults(*metrics_to_plot); } } diff --git a/test/testsupport/copy_to_file_audio_capturer_unittest.cc b/test/testsupport/copy_to_file_audio_capturer_unittest.cc index e97b69860a..023b61da2b 100644 --- a/test/testsupport/copy_to_file_audio_capturer_unittest.cc +++ b/test/testsupport/copy_to_file_audio_capturer_unittest.cc @@ -23,8 +23,8 @@ namespace test { class CopyToFileAudioCapturerTest : public ::testing::Test { protected: void SetUp() override { - temp_filename_ = webrtc::test::TempFilename( - webrtc::test::OutputPath(), "copy_to_file_audio_capturer_unittest"); + temp_filename_ = test::TempFilename(test::OutputPath(), + "copy_to_file_audio_capturer_unittest"); std::unique_ptr delegate = TestAudioDeviceModule::CreatePulsedNoiseCapturer(32000, 48000); capturer_ = std::make_unique(std::move(delegate), diff --git a/test/testsupport/file_utils.cc b/test/testsupport/file_utils.cc index 963514c88d..27bb59cbaa 100644 --- a/test/testsupport/file_utils.cc +++ b/test/testsupport/file_utils.cc @@ -10,6 +10,21 @@ #include "test/testsupport/file_utils.h" +#include +#include +#include +#include +#include +#include + +#include "absl/base/attributes.h" +#include "absl/strings/string_view.h" +#include "rtc_base/checks.h" +#include "rtc_base/crypto_random.h" +#include "rtc_base/string_utils.h" +#include "rtc_base/strings/string_builder.h" +#include "test/testsupport/file_utils_override.h" + #if defined(WEBRTC_POSIX) #include #endif @@ -38,29 +53,12 @@ #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) #endif -#include -#include - -#include -#include -#include -#include -#include -#include - #if defined(WEBRTC_IOS) #include "test/testsupport/ios_file_utils.h" #elif defined(WEBRTC_MAC) #include "test/testsupport/mac_file_utils.h" #endif -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" -#include "rtc_base/crypto_random.h" -#include "rtc_base/string_utils.h" -#include "rtc_base/strings/string_builder.h" -#include "test/testsupport/file_utils_override.h" - namespace webrtc { namespace test { @@ -82,6 +80,13 @@ std::string DirName(absl::string_view path) { return std::string(path.substr(0, path.find_last_of(kPathDelimiter))); } +absl::string_view FileName(absl::string_view path) { + if (path.find_last_of(kPathDelimiter) == absl::string_view::npos) { + return path; + } + return path.substr(path.find_last_of(kPathDelimiter) + 1); +} + bool FileExists(absl::string_view file_name) { struct stat file_info = {0}; return stat(std::string(file_name).c_str(), &file_info) == 0; @@ -94,18 +99,18 @@ bool DirExists(absl::string_view directory_name) { } std::string OutputPath() { - return webrtc::test::internal::OutputPath(); + return test::internal::OutputPath(); } std::string OutputPathWithRandomDirectory() { - std::string path = webrtc::test::internal::OutputPath(); + std::string path = test::internal::OutputPath(); std::string rand_dir = path + CreateRandomUuid(); RTC_CHECK(CreateDir(rand_dir)) << "Failed to create dir: " << rand_dir; return rand_dir + std::string(kPathDelimiter); } std::string WorkingDir() { - return webrtc::test::internal::WorkingDir(); + return test::internal::WorkingDir(); } // Generate a temporary filename in a safe way. @@ -254,7 +259,7 @@ bool RemoveFile(absl::string_view file_name) { } std::string ResourcePath(absl::string_view name, absl::string_view extension) { - return webrtc::test::internal::ResourcePath(name, extension); + return test::internal::ResourcePath(name, extension); } std::string JoinFilename(absl::string_view dir, absl::string_view name) { @@ -272,7 +277,7 @@ std::string JoinFilename(absl::string_view dir, absl::string_view name) { size_t GetFileSize(absl::string_view filename) { FILE* f = fopen(std::string(filename).c_str(), "rb"); size_t size = 0; - if (f != NULL) { + if (f != nullptr) { if (fseek(f, 0, SEEK_END) == 0) { size = ftell(f); } diff --git a/test/testsupport/file_utils.h b/test/testsupport/file_utils.h index b0652eafd6..4e5b268c35 100644 --- a/test/testsupport/file_utils.h +++ b/test/testsupport/file_utils.h @@ -8,11 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #ifndef TEST_TESTSUPPORT_FILE_UTILS_H_ #define TEST_TESTSUPPORT_FILE_UTILS_H_ +#include #include #include #include @@ -107,6 +106,9 @@ bool DirExists(absl::string_view directory_name); // Strips the rightmost path segment from a path. std::string DirName(absl::string_view path); +// Returns the rightmost path segment from a path. +absl::string_view FileName(absl::string_view path); + // File size of the supplied file in bytes. Will return 0 if the file is // empty or if the file does not exist/is readable. size_t GetFileSize(absl::string_view filename); diff --git a/test/testsupport/file_utils_unittest.cc b/test/testsupport/file_utils_unittest.cc index adb9a2a0ca..62745cb0fa 100644 --- a/test/testsupport/file_utils_unittest.cc +++ b/test/testsupport/file_utils_unittest.cc @@ -76,9 +76,7 @@ class FileUtilsTest : public ::testing::Test { FileUtilsTest() {} ~FileUtilsTest() override {} // Runs before the first test - static void SetUpTestSuite() { - original_working_dir_ = webrtc::test::WorkingDir(); - } + static void SetUpTestSuite() { original_working_dir_ = test::WorkingDir(); } void SetUp() override { ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); } void TearDown() override { ASSERT_EQ(chdir(original_working_dir_.c_str()), 0); @@ -104,7 +102,7 @@ std::string ExpectedRootDirByPlatform() { TEST_F(FileUtilsTest, OutputPathFromUnchangedWorkingDir) { std::string expected_end = ExpectedRootDirByPlatform(); - std::string result = webrtc::test::OutputPath(); + std::string result = test::OutputPath(); ASSERT_THAT(result, EndsWith(expected_end)); } @@ -115,7 +113,7 @@ TEST_F(FileUtilsTest, OutputPathFromRootWorkingDir) { ASSERT_EQ(0, chdir(kPathDelimiter.data())); std::string expected_end = ExpectedRootDirByPlatform(); - std::string result = webrtc::test::OutputPath(); + std::string result = test::OutputPath(); ASSERT_THAT(result, EndsWith(expected_end)); } @@ -125,7 +123,7 @@ TEST_F(FileUtilsTest, RandomOutputPathFromUnchangedWorkingDir) { std::string fixed_first_uuid = "def01482-f829-429a-bfd4-841706e92cdd"; std::string expected_end = ExpectedRootDirByPlatform() + fixed_first_uuid + std::string(kPathDelimiter); - std::string result = webrtc::test::OutputPathWithRandomDirectory(); + std::string result = test::OutputPathWithRandomDirectory(); ASSERT_THAT(result, EndsWith(expected_end)); } @@ -137,26 +135,26 @@ TEST_F(FileUtilsTest, RandomOutputPathFromRootWorkingDir) { std::string fixed_first_uuid = "def01482-f829-429a-bfd4-841706e92cdd"; std::string expected_end = ExpectedRootDirByPlatform() + fixed_first_uuid + std::string(kPathDelimiter); - std::string result = webrtc::test::OutputPathWithRandomDirectory(); + std::string result = test::OutputPathWithRandomDirectory(); ASSERT_THAT(result, EndsWith(expected_end)); } TEST_F(FileUtilsTest, TempFilename) { - std::string temp_filename = webrtc::test::TempFilename( - webrtc::test::OutputPath(), "TempFilenameTest"); - ASSERT_TRUE(webrtc::test::FileExists(temp_filename)) + std::string temp_filename = + test::TempFilename(test::OutputPath(), "TempFilenameTest"); + ASSERT_TRUE(test::FileExists(temp_filename)) << "Couldn't find file: " << temp_filename; remove(temp_filename.c_str()); } TEST_F(FileUtilsTest, GenerateTempFilename) { - std::string temp_filename = webrtc::test::GenerateTempFilename( - webrtc::test::OutputPath(), "TempFilenameTest"); - ASSERT_FALSE(webrtc::test::FileExists(temp_filename)) + std::string temp_filename = + test::GenerateTempFilename(test::OutputPath(), "TempFilenameTest"); + ASSERT_FALSE(test::FileExists(temp_filename)) << "File exists: " << temp_filename; FILE* file = fopen(temp_filename.c_str(), "wb"); - ASSERT_TRUE(file != NULL) << "Failed to open file: " << temp_filename; + ASSERT_TRUE(file != nullptr) << "Failed to open file: " << temp_filename; ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0) << "Failed to write to file: " << temp_filename; fclose(file); @@ -174,20 +172,20 @@ TEST_F(FileUtilsTest, MAYBE_CreateDir) { test::OutputPathWithRandomDirectory() + "fileutils-unittest-empty-dir"; // Make sure it's removed if a previous test has failed: remove(directory.c_str()); - ASSERT_TRUE(webrtc::test::CreateDir(directory)); + ASSERT_TRUE(test::CreateDir(directory)); remove(directory.c_str()); } TEST_F(FileUtilsTest, WorkingDirReturnsValue) { // This will obviously be different depending on where the webrtc checkout is, // so just check something is returned. - std::string working_dir = webrtc::test::WorkingDir(); + std::string working_dir = test::WorkingDir(); ASSERT_GT(working_dir.length(), 0u); } TEST_F(FileUtilsTest, ResourcePathReturnsCorrectPath) { - std::string result = webrtc::test::ResourcePath( - Path("video_coding/frame-ethernet-ii"), "pcap"); + std::string result = + test::ResourcePath(Path("video_coding/frame-ethernet-ii"), "pcap"); #if defined(WEBRTC_IOS) // iOS bundles resources straight into the bundle root. std::string expected_end = Path("/frame-ethernet-ii.pcap"); @@ -205,7 +203,7 @@ TEST_F(FileUtilsTest, ResourcePathReturnsCorrectPath) { TEST_F(FileUtilsTest, ResourcePathFromRootWorkingDir) { ASSERT_EQ(0, chdir(kPathDelimiter.data())); - std::string resource = webrtc::test::ResourcePath("whatever", "ext"); + std::string resource = test::ResourcePath("whatever", "ext"); #if !defined(WEBRTC_IOS) ASSERT_NE(resource.find("resources"), std::string::npos); #endif @@ -215,37 +213,36 @@ TEST_F(FileUtilsTest, ResourcePathFromRootWorkingDir) { TEST_F(FileUtilsTest, GetFileSizeExistingFile) { // Create a file with some dummy data in. - std::string temp_filename = webrtc::test::TempFilename( - webrtc::test::OutputPath(), "fileutils_unittest"); + std::string temp_filename = + test::TempFilename(test::OutputPath(), "fileutils_unittest"); FILE* file = fopen(temp_filename.c_str(), "wb"); - ASSERT_TRUE(file != NULL) << "Failed to open file: " << temp_filename; + ASSERT_TRUE(file != nullptr) << "Failed to open file: " << temp_filename; ASSERT_GT(fprintf(file, "%s", "Dummy data"), 0) << "Failed to write to file: " << temp_filename; fclose(file); - ASSERT_GT(webrtc::test::GetFileSize(temp_filename), 0u); + ASSERT_GT(test::GetFileSize(temp_filename), 0u); remove(temp_filename.c_str()); } TEST_F(FileUtilsTest, GetFileSizeNonExistingFile) { - ASSERT_EQ(0u, webrtc::test::GetFileSize("non-existing-file.tmp")); + ASSERT_EQ(0u, test::GetFileSize("non-existing-file.tmp")); } TEST_F(FileUtilsTest, DirExists) { // Check that an existing directory is recognized as such. - ASSERT_TRUE(webrtc::test::DirExists(webrtc::test::OutputPath())) + ASSERT_TRUE(test::DirExists(test::OutputPath())) << "Existing directory not found"; // Check that a non-existing directory is recognized as such. std::string directory = "direxists-unittest-non_existing-dir"; - ASSERT_FALSE(webrtc::test::DirExists(directory)) - << "Non-existing directory found"; + ASSERT_FALSE(test::DirExists(directory)) << "Non-existing directory found"; // Check that an existing file is not recognized as an existing directory. - std::string temp_filename = webrtc::test::TempFilename( - webrtc::test::OutputPath(), "TempFilenameTest"); - ASSERT_TRUE(webrtc::test::FileExists(temp_filename)) + std::string temp_filename = + test::TempFilename(test::OutputPath(), "TempFilenameTest"); + ASSERT_TRUE(test::FileExists(temp_filename)) << "Couldn't find file: " << temp_filename; - ASSERT_FALSE(webrtc::test::DirExists(temp_filename)) + ASSERT_FALSE(test::DirExists(temp_filename)) << "Existing file recognized as existing directory"; remove(temp_filename.c_str()); } diff --git a/test/testsupport/fixed_fps_video_frame_writer_adapter_test.cc b/test/testsupport/fixed_fps_video_frame_writer_adapter_test.cc index 5ee4701cc9..473e63dae3 100644 --- a/test/testsupport/fixed_fps_video_frame_writer_adapter_test.cc +++ b/test/testsupport/fixed_fps_video_frame_writer_adapter_test.cc @@ -36,7 +36,7 @@ class InMemoryVideoWriter : public VideoFrameWriter { public: ~InMemoryVideoWriter() override = default; - bool WriteFrame(const webrtc::VideoFrame& frame) override { + bool WriteFrame(const VideoFrame& frame) override { MutexLock lock(&mutex_); received_frames_.push_back(frame); return true; diff --git a/test/testsupport/ivf_video_frame_generator_unittest.cc b/test/testsupport/ivf_video_frame_generator_unittest.cc index ff0dd08d87..a2c3fea3c2 100644 --- a/test/testsupport/ivf_video_frame_generator_unittest.cc +++ b/test/testsupport/ivf_video_frame_generator_unittest.cc @@ -101,10 +101,9 @@ class IvfFileWriterEncodedCallback : public EncodedImageCallback { class IvfVideoFrameGeneratorTest : public ::testing::Test { protected: void SetUp() override { - file_name_ = - webrtc::test::TempFilename(webrtc::test::OutputPath(), "test_file.ivf"); + file_name_ = test::TempFilename(test::OutputPath(), "test_file.ivf"); } - void TearDown() override { webrtc::test::RemoveFile(file_name_); } + void TearDown() override { test::RemoveFile(file_name_); } VideoFrame BuildFrame(FrameGeneratorInterface::VideoFrameData frame_data) { return VideoFrame::Builder() @@ -121,7 +120,7 @@ class IvfVideoFrameGeneratorTest : public ::testing::Test { std::nullopt); VideoCodec codec_settings; - webrtc::test::CodecSettings(video_codec_type, &codec_settings); + test::CodecSettings(video_codec_type, &codec_settings); codec_settings.width = kWidth; codec_settings.height = kHeight; codec_settings.maxFramerate = kMaxFramerate; diff --git a/test/testsupport/perf_test.cc b/test/testsupport/perf_test.cc index c274ee1a7b..4c5e0f447e 100644 --- a/test/testsupport/perf_test.cc +++ b/test/testsupport/perf_test.cc @@ -31,15 +31,14 @@ namespace test { namespace { -std::string UnitWithDirection( - absl::string_view units, - webrtc::test::ImproveDirection improve_direction) { +std::string UnitWithDirection(absl::string_view units, + test::ImproveDirection improve_direction) { switch (improve_direction) { - case webrtc::test::ImproveDirection::kNone: + case test::ImproveDirection::kNone: return std::string(units); - case webrtc::test::ImproveDirection::kSmallerIsBetter: + case test::ImproveDirection::kSmallerIsBetter: return std::string(units) + "_smallerIsBetter"; - case webrtc::test::ImproveDirection::kBiggerIsBetter: + case test::ImproveDirection::kBiggerIsBetter: return std::string(units) + "_biggerIsBetter"; } } @@ -69,7 +68,7 @@ void OutputListToStream(std::ostream* ostream, const Container& values) { struct PlottableCounter { std::string graph_name; std::string trace_name; - webrtc::SamplesStatsCounter counter; + SamplesStatsCounter counter; std::string units; }; @@ -84,7 +83,7 @@ class PlottableCounterPrinter { void AddCounter(absl::string_view graph_name, absl::string_view trace_name, - const webrtc::SamplesStatsCounter& counter, + const SamplesStatsCounter& counter, absl::string_view units) { MutexLock lock(&mutex_); plottable_counters_.push_back({std::string(graph_name), @@ -181,7 +180,7 @@ class ResultsLinePrinter { const ArrayView values, absl::string_view units, const bool important, - webrtc::test::ImproveDirection improve_direction) { + test::ImproveDirection improve_direction) { std::ostringstream value_stream; value_stream.precision(8); OutputListToStream(&value_stream, values); @@ -244,7 +243,7 @@ bool WritePerfResults(const std::string& output_path) { std::string results = GetPerfResults(); CreateDir(DirName(output_path)); FILE* output = fopen(output_path.c_str(), "wb"); - if (output == NULL) { + if (output == nullptr) { printf("Failed to write to %s.\n", output_path.c_str()); return false; } diff --git a/test/testsupport/video_frame_writer.cc b/test/testsupport/video_frame_writer.cc index 09af7f12ea..96f1b0d810 100644 --- a/test/testsupport/video_frame_writer.cc +++ b/test/testsupport/video_frame_writer.cc @@ -71,7 +71,7 @@ Y4mVideoFrameWriterImpl::Y4mVideoFrameWriterImpl(std::string output_file_name, RTC_CHECK(frame_writer_->Init()); } -bool Y4mVideoFrameWriterImpl::WriteFrame(const webrtc::VideoFrame& frame) { +bool Y4mVideoFrameWriterImpl::WriteFrame(const VideoFrame& frame) { Buffer frame_buffer = ExtractI420BufferWithSize(frame, width_, height_); RTC_CHECK_EQ(frame_buffer.size(), frame_writer_->FrameLength()); return frame_writer_->WriteFrame(frame_buffer.data()); @@ -97,7 +97,7 @@ YuvVideoFrameWriterImpl::YuvVideoFrameWriterImpl(std::string output_file_name, RTC_CHECK(frame_writer_->Init()); } -bool YuvVideoFrameWriterImpl::WriteFrame(const webrtc::VideoFrame& frame) { +bool YuvVideoFrameWriterImpl::WriteFrame(const VideoFrame& frame) { Buffer frame_buffer = ExtractI420BufferWithSize(frame, width_, height_); RTC_CHECK_EQ(frame_buffer.size(), frame_writer_->FrameLength()); return frame_writer_->WriteFrame(frame_buffer.data()); diff --git a/test/testsupport/video_frame_writer_unittest.cc b/test/testsupport/video_frame_writer_unittest.cc index 30ebc526d7..de8c618216 100644 --- a/test/testsupport/video_frame_writer_unittest.cc +++ b/test/testsupport/video_frame_writer_unittest.cc @@ -56,8 +56,8 @@ scoped_refptr CreateI420Buffer(int width, int height) { return buffer; } -void AssertI420BuffersEq(scoped_refptr actual, - scoped_refptr expected) { +void AssertI420BuffersEq(scoped_refptr actual, + scoped_refptr expected) { ASSERT_TRUE(actual); ASSERT_EQ(actual->width(), expected->width()); @@ -93,8 +93,8 @@ class VideoFrameWriterTest : public ::testing::Test { ~VideoFrameWriterTest() override = default; void SetUp() override { - temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "video_frame_writer_unittest"); + temp_filename_ = + test::TempFilename(test::OutputPath(), "video_frame_writer_unittest"); frame_writer_ = CreateFrameWriter(); } diff --git a/test/testsupport/y4m_frame_generator.cc b/test/testsupport/y4m_frame_generator.cc index bd3c8f4127..f7b0eb0f88 100644 --- a/test/testsupport/y4m_frame_generator.cc +++ b/test/testsupport/y4m_frame_generator.cc @@ -36,7 +36,7 @@ Y4mFrameGenerator::Y4mFrameGenerator(absl::string_view filename, : filename_(filename), repeat_mode_(repeat_mode) { // Read resolution from the Y4M header. FILE* file = fopen(filename_.c_str(), "r"); - RTC_CHECK(file != NULL) << "Cannot open " << filename_; + RTC_CHECK(file != nullptr) << "Cannot open " << filename_; char header[kHeaderBytesToRead]; RTC_CHECK(fgets(header, sizeof(header), file) != nullptr) << "File " << filename_ << " is too small"; @@ -50,15 +50,14 @@ Y4mFrameGenerator::Y4mFrameGenerator(absl::string_view filename, RTC_CHECK_GT(height_, 0); // Delegate the actual reads (from NextFrame) to a Y4mReader. - frame_reader_ = webrtc::test::CreateY4mFrameReader( + frame_reader_ = test::CreateY4mFrameReader( filename_, ToYuvFrameReaderRepeatMode(repeat_mode_)); } Y4mFrameGenerator::VideoFrameData Y4mFrameGenerator::NextFrame() { - webrtc::VideoFrame::UpdateRect update_rect{0, 0, static_cast(width_), - static_cast(height_)}; - scoped_refptr next_frame_buffer = - frame_reader_->PullFrame(); + VideoFrame::UpdateRect update_rect{0, 0, static_cast(width_), + static_cast(height_)}; + scoped_refptr next_frame_buffer = frame_reader_->PullFrame(); if (!next_frame_buffer || (static_cast(next_frame_buffer->width()) == width_ && @@ -67,9 +66,8 @@ Y4mFrameGenerator::VideoFrameData Y4mFrameGenerator::NextFrame() { } // Allocate a new buffer and return scaled version. - scoped_refptr scaled_buffer( - I420Buffer::Create(width_, height_)); - webrtc::I420Buffer::SetBlack(scaled_buffer.get()); + scoped_refptr scaled_buffer(I420Buffer::Create(width_, height_)); + I420Buffer::SetBlack(scaled_buffer.get()); scaled_buffer->ScaleFrom(*next_frame_buffer->ToI420()); return VideoFrameData(scaled_buffer, update_rect); } diff --git a/test/testsupport/y4m_frame_reader.cc b/test/testsupport/y4m_frame_reader.cc index 4501ddba41..6d9649d707 100644 --- a/test/testsupport/y4m_frame_reader.cc +++ b/test/testsupport/y4m_frame_reader.cc @@ -32,11 +32,11 @@ void ParseY4mHeader(std::string filepath, Resolution* resolution, int* header_size) { FILE* file = fopen(filepath.c_str(), "r"); - RTC_CHECK(file != NULL) << "Cannot open " << filepath; + RTC_CHECK(file != nullptr) << "Cannot open " << filepath; // Length of Y4M header is technically unlimited due to the comment tag 'X'. char h[1024]; - RTC_CHECK(fgets(h, sizeof(h), file) != NULL) + RTC_CHECK(fgets(h, sizeof(h), file) != nullptr) << "File " << filepath << " is too small"; fclose(file); diff --git a/test/testsupport/y4m_frame_reader_unittest.cc b/test/testsupport/y4m_frame_reader_unittest.cc index 205cbdeb39..406c69eee3 100644 --- a/test/testsupport/y4m_frame_reader_unittest.cc +++ b/test/testsupport/y4m_frame_reader_unittest.cc @@ -41,8 +41,8 @@ class Y4mFrameReaderTest : public ::testing::Test { ~Y4mFrameReaderTest() override = default; void SetUp() override { - filepath_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "y4m_frame_reader_unittest"); + filepath_ = + test::TempFilename(test::OutputPath(), "y4m_frame_reader_unittest"); FILE* file = fopen(filepath_.c_str(), "wb"); fwrite(kFileHeader, 1, sizeof(kFileHeader) - 1, file); for (int n = 0; n < kNumFrames; ++n) { diff --git a/test/testsupport/y4m_frame_writer_unittest.cc b/test/testsupport/y4m_frame_writer_unittest.cc index f12a4b8e4f..ebb34f53ce 100644 --- a/test/testsupport/y4m_frame_writer_unittest.cc +++ b/test/testsupport/y4m_frame_writer_unittest.cc @@ -38,8 +38,8 @@ class Y4mFrameWriterTest : public ::testing::Test { ~Y4mFrameWriterTest() override = default; void SetUp() override { - temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "y4m_frame_writer_unittest"); + temp_filename_ = + test::TempFilename(test::OutputPath(), "y4m_frame_writer_unittest"); frame_writer_.reset(new Y4mFrameWriterImpl(temp_filename_, kFrameWidth, kFrameHeight, kFrameRate)); ASSERT_TRUE(frame_writer_->Init()); diff --git a/test/testsupport/yuv_frame_reader.cc b/test/testsupport/yuv_frame_reader.cc index ea1a586e9f..4a7273520d 100644 --- a/test/testsupport/yuv_frame_reader.cc +++ b/test/testsupport/yuv_frame_reader.cc @@ -94,7 +94,7 @@ void YuvFrameReaderImpl::Init() { CalcBufferSize(VideoType::kI420, resolution_.width, resolution_.height); file_ = fopen(filepath_.c_str(), "rb"); - RTC_CHECK(file_ != NULL) << "Cannot open " << filepath_; + RTC_CHECK(file_ != nullptr) << "Cannot open " << filepath_; size_t file_size_bytes = GetFileSize(filepath_); RTC_CHECK_GT(file_size_bytes, 0u) << "File " << filepath_ << " is empty"; diff --git a/test/testsupport/yuv_frame_reader_unittest.cc b/test/testsupport/yuv_frame_reader_unittest.cc index 82d242ff32..9d633d7006 100644 --- a/test/testsupport/yuv_frame_reader_unittest.cc +++ b/test/testsupport/yuv_frame_reader_unittest.cc @@ -38,8 +38,8 @@ class YuvFrameReaderTest : public ::testing::Test { ~YuvFrameReaderTest() override = default; void SetUp() override { - filepath_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "yuv_frame_reader_unittest"); + filepath_ = + test::TempFilename(test::OutputPath(), "yuv_frame_reader_unittest"); CreateYuvFileAndReader(/*num_frames=*/3, RepeatMode::kSingle); } diff --git a/test/testsupport/yuv_frame_writer_unittest.cc b/test/testsupport/yuv_frame_writer_unittest.cc index 13ed715b9e..22a048b7a2 100644 --- a/test/testsupport/yuv_frame_writer_unittest.cc +++ b/test/testsupport/yuv_frame_writer_unittest.cc @@ -34,8 +34,8 @@ class YuvFrameWriterTest : public ::testing::Test { ~YuvFrameWriterTest() override = default; void SetUp() override { - temp_filename_ = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "yuv_frame_writer_unittest"); + temp_filename_ = + test::TempFilename(test::OutputPath(), "yuv_frame_writer_unittest"); frame_writer_.reset( new YuvFrameWriterImpl(temp_filename_, kFrameWidth, kFrameHeight)); ASSERT_TRUE(frame_writer_->Init()); diff --git a/test/time_controller/time_controller_conformance_test.cc b/test/time_controller/time_controller_conformance_test.cc index 5e0dcf85cc..265404156e 100644 --- a/test/time_controller/time_controller_conformance_test.cc +++ b/test/time_controller/time_controller_conformance_test.cc @@ -45,11 +45,11 @@ std::unique_ptr CreateTimeController(TimeMode mode) { } } -std::string ParamsToString(const TestParamInfo& param) { +std::string ParamsToString(const TestParamInfo& param) { switch (param.param) { - case webrtc::TimeMode::kRealTime: + case TimeMode::kRealTime: return "RealTime"; - case webrtc::TimeMode::kSimulated: + case TimeMode::kSimulated: return "SimulatedTime"; default: RTC_DCHECK_NOTREACHED() << "Time mode not supported"; @@ -76,7 +76,7 @@ class ExecutionOrderKeeper { // Tests conformance between real time and simulated time time controller. class SimulatedRealTimeControllerConformanceTest - : public TestWithParam {}; + : public TestWithParam {}; TEST_P(SimulatedRealTimeControllerConformanceTest, ThreadPostOrderTest) { std::unique_ptr time_controller = @@ -153,7 +153,7 @@ TEST_P(SimulatedRealTimeControllerConformanceTest, std::unique_ptr time_controller = CreateTimeController(GetParam()); auto task_queue = time_controller->GetTaskQueueFactory()->CreateTaskQueue( - "task_queue", webrtc::TaskQueueFactory::Priority::NORMAL); + "task_queue", TaskQueueFactory::Priority::NORMAL); // Tasks on thread have to be executed in order in which they were // posted/invoked. diff --git a/test/vcm_capturer.cc b/test/vcm_capturer.cc index 0a9226ef6f..bc022c1a80 100644 --- a/test/vcm_capturer.cc +++ b/test/vcm_capturer.cc @@ -41,7 +41,7 @@ bool VcmCapturer::Init(size_t width, return false; } - vcm_ = webrtc::VideoCaptureFactory::Create(unique_name); + vcm_ = VideoCaptureFactory::Create(unique_name); if (!vcm_) { return false; } diff --git a/test/video_codec_tester.cc b/test/video_codec_tester.cc index 7c40fc2e5e..7c8d21019d 100644 --- a/test/video_codec_tester.cc +++ b/test/video_codec_tester.cc @@ -82,9 +82,9 @@ #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/sleep.h" #include "test/testsupport/file_utils.h" #include "test/testsupport/frame_reader.h" #include "test/testsupport/video_frame_writer.h" @@ -108,7 +108,7 @@ using PacingMode = PacingSettings::PacingMode; using VideoCodecStats = VideoCodecTester::VideoCodecStats; using DecodeCallback = absl::AnyInvocable; -using webrtc::test::ImprovementDirection; +using test::ImprovementDirection; constexpr Frequency k90kHz = Frequency::Hertz(90000); @@ -276,7 +276,7 @@ class LimitedTaskQueue { int64_t wait_ms = (scheduled - now).ms(); if (wait_ms > 0) { RTC_CHECK_LT(wait_ms, 10000) << "Too high wait_ms " << wait_ms; - SleepMs(wait_ms); + Thread::SleepMs(wait_ms); } std::move(task)(); --queue_size_; @@ -588,8 +588,8 @@ class VideoCodecAnalyzer : public VideoCodecTester::VideoCodecStats { } Frame superframe = subframes.back(); - for (const Frame& frame : webrtc::ArrayView(subframes).subview( - 0, subframes.size() - 1)) { + for (const Frame& frame : + ArrayView(subframes).subview(0, subframes.size() - 1)) { superframe.decoded |= frame.decoded; superframe.encoded |= frame.encoded; superframe.frame_size += frame.frame_size; diff --git a/test/video_codec_tester_unittest.cc b/test/video_codec_tester_unittest.cc index d78c7c6416..a24a1db072 100644 --- a/test/video_codec_tester_unittest.cc +++ b/test/video_codec_tester_unittest.cc @@ -103,8 +103,8 @@ scoped_refptr CreateYuvBuffer(uint8_t y = 0, // TODO(ssilkin): Wrap this into a class that removes file in dtor. std::string CreateYuvFile(int width, int height, int num_frames) { - std::string path = webrtc::test::TempFilename(webrtc::test::OutputPath(), - "video_codec_tester_unittest"); + std::string path = + test::TempFilename(test::OutputPath(), "video_codec_tester_unittest"); FILE* file = fopen(path.c_str(), "wb"); for (int frame_num = 0; frame_num < num_frames; ++frame_num) { // For purposes of testing quality estimation, we need Y, U, V values in diff --git a/tools_webrtc/android/build_aar.py b/tools_webrtc/android/build_aar.py index d3da72694c..e394f75883 100755 --- a/tools_webrtc/android/build_aar.py +++ b/tools_webrtc/android/build_aar.py @@ -118,8 +118,10 @@ def _RunGN(args): def _RunNinja(output_directory, args): cmd = [ - os.path.join(SRC_DIR, 'third_party', 'ninja', 'ninja'), '-C', - output_directory + os.path.join(SRC_DIR, 'third_party', 'siso', 'cipd', 'siso'), + 'ninja', + '-C', + output_directory, ] cmd.extend(args) logging.debug('Running: %r', cmd) @@ -175,9 +177,14 @@ def Build(build_dir, arch, use_remoteexec, extra_gn_args, extra_gn_switches, 'is_component_build': False, 'rtc_include_tests': False, 'target_cpu': _GetTargetCpu(arch), - 'use_remoteexec': use_remoteexec, 'android_static_analysis': "off", + 'use_siso': True, } + if use_remoteexec: + gn_args.update({ + 'use_remoteexec': True, + 'use_reclient': False, + }) arm_version = _GetArmVersion(arch) if arm_version: gn_args['arm_version'] = arm_version @@ -191,7 +198,7 @@ def Build(build_dir, arch, use_remoteexec, extra_gn_args, extra_gn_switches, ninja_args = TARGETS[:] if use_remoteexec: - ninja_args.extend(['-j', '200']) + ninja_args.extend(['-remote_jobs', '200']) ninja_args.extend(extra_ninja_switches) _RunNinja(output_directory, ninja_args) diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 0ffc7b6562..7165f8fdd6 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -88,15 +88,15 @@ def FindRootPath(): NOTIFY_EMAIL = 'webrtc-trooper@grotations.appspotmail.com' +GCS_OBJECTS_ERROR = ( + 'The number of objects in %s is different between ' + 'Chromium\'s DEPS and WebRTC\'s DEPS. They must be the same.') + sys.path.append(os.path.join(CHECKOUT_ROOT_DIR, 'build')) import find_depot_tools find_depot_tools.add_depot_tools_to_path() -CLANG_UPDATE_SCRIPT_URL_PATH = 'tools/clang/scripts/update.py' -CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join(CHECKOUT_ROOT_DIR, 'tools', - 'clang', 'scripts', 'update.py') - DepsEntry = collections.namedtuple('DepsEntry', 'path url revision') ChangedDep = collections.namedtuple('ChangedDep', 'path url current_rev new_rev') @@ -107,6 +107,8 @@ def FindRootPath(): 'ChangedCipdPackage', 'path package current_version new_version') ChangedVersionEntry = collections.namedtuple( 'ChangedVersionEntry', 'path current_version new_version') +ChangedGcsPackage = collections.namedtuple( + 'ChangedGcsPackage', 'path setdep_arg current_version new_version') ChromiumRevisionUpdate = collections.namedtuple('ChromiumRevisionUpdate', ('current_chromium_rev ' @@ -323,6 +325,24 @@ def AddVersionEntry(vars_subdict): return result +def _FindChangedGcsPackage(path, old_pkg, new_pkg): + assert len(old_pkg.objects) == len(new_pkg.objects), (GCS_OBJECTS_ERROR % + path) + current_version_str = ','.join(x['object_name'] for x in old_pkg.objects) + new_version_str = ','.join(x['object_name'] for x in new_pkg.objects) + if current_version_str != new_version_str: + objects = [ + ','.join([ + o['object_name'], o['sha256sum'], + str(o['size_bytes']), + str(o['generation']) + ]) for o in new_pkg.objects + ] + setdep_arg = '%s@%s' % (path, '?'.join(objects)) + yield ChangedGcsPackage(path, setdep_arg, current_version_str, + new_version_str) + + def _FindChangedCipdPackages(path, old_pkgs, new_pkgs): old_pkgs_names = {p['package'] for p in old_pkgs} new_pkgs_names = {p['package'] for p in new_pkgs} @@ -464,11 +484,8 @@ def CalculateChangedDeps(webrtc_deps, new_cr_deps): if isinstance(cr_deps_entry, GcsDepsEntry): result.extend( - _FindChangedVars( - path, ','.join(x['object_name'] - for x in webrtc_deps_entry.objects), - ','.join(x['object_name'] - for x in cr_deps_entry.objects))) + _FindChangedGcsPackage(path, webrtc_deps_entry, + cr_deps_entry)) continue if isinstance(cr_deps_entry, VersionEntry): @@ -502,26 +519,6 @@ def CalculateChangedDeps(webrtc_deps, new_cr_deps): return sorted(result) -def CalculateChangedClang(new_cr_rev): - - def GetClangRev(lines): - for line in lines: - match = CLANG_REVISION_RE.match(line) - if match: - return match.group(1) - raise RollError('Could not parse Clang revision!') - - with open(CLANG_UPDATE_SCRIPT_LOCAL_PATH, 'r') as f: - current_lines = f.readlines() - current_rev = GetClangRev(current_lines) - - new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH, - new_cr_rev).splitlines() - new_rev = GetClangRev(new_clang_update_py) - return ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, current_rev, - new_rev) - - def GenerateCommitMessage( rev_update, current_commit_pos, @@ -529,7 +526,6 @@ def GenerateCommitMessage( changed_deps_list, added_deps_paths=None, removed_deps_paths=None, - clang_change=None, ): current_cr_rev = rev_update.current_chromium_rev[0:10] new_cr_rev = rev_update.new_chromium_rev[0:10] @@ -554,6 +550,9 @@ def Section(adjective, deps): if isinstance(c, ChangedCipdPackage): commit_msg.append('* %s: %s..%s' % (c.path, c.current_version, c.new_version)) + elif isinstance(c, ChangedGcsPackage): + commit_msg.append('* %s: %s..%s' % + (c.path, c.current_version, c.new_version)) elif isinstance(c, ChangedVersionEntry): commit_msg.append('* %s_version: %s..%s' % (c.path, c.current_version, c.new_version)) @@ -576,15 +575,6 @@ def Section(adjective, deps): else: commit_msg.append('No dependencies changed.') - if clang_change and clang_change.current_rev != clang_change.new_rev: - commit_msg.append('Clang version changed %s:%s' % - (clang_change.current_rev, clang_change.new_rev)) - change_url = CHROMIUM_FILE_TEMPLATE % (rev_interval, - CLANG_UPDATE_SCRIPT_URL_PATH) - commit_msg.append('Details: %s\n' % change_url) - else: - commit_msg.append('No update to Clang.\n') - commit_msg.append('BUG=None') return '\n'.join(commit_msg) @@ -638,6 +628,8 @@ def UpdateDepsFile(deps_filename, rev_update, changed_deps, new_cr_content): if isinstance(dep, ChangedCipdPackage): package = dep.package.format() # Eliminate double curly brackets update = '%s:%s@%s' % (dep.path, package, dep.new_version) + elif isinstance(dep, ChangedGcsPackage): + update = dep.setdep_arg else: update = '%s@%s' % (dep.path, dep.new_rev) _RunCommand(['gclient', 'setdep', '--revision', update], @@ -831,15 +823,13 @@ def main(): 'Remove them or add them to either ' 'WEBRTC_ONLY_DEPS or DONT_AUTOROLL_THESE.' % other_deps) - clang_change = CalculateChangedClang(rev_update.new_chromium_rev) commit_msg = GenerateCommitMessage( rev_update, current_commit_pos, new_commit_pos, changed_deps, added_deps_paths=new_generated_android_deps, - removed_deps_paths=removed_generated_android_deps, - clang_change=clang_change) + removed_deps_paths=removed_generated_android_deps) logging.debug('Commit message:\n%s', commit_msg) _CreateRollBranch(opts.dry_run) diff --git a/tools_webrtc/clang_tidy.py b/tools_webrtc/clang_tidy.py deleted file mode 100755 index b3f738eab3..0000000000 --- a/tools_webrtc/clang_tidy.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env vpython3 - -# Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -"""Invoke clang-tidy tool. - -Usage: clang_tidy.py file.cc [clang-tidy-args...] - -Just a proof of concept! -We use an embedded clang-tidy whose version doesn't match clang++. -""" - -import argparse -import os -import shutil -import subprocess -import sys -import tempfile -from presubmit_checks_lib.build_helpers import (GetClangTidyPath, - GetCompilationCommand) - -# We enable all checkers by default for investigation purpose. -# This includes clang-analyzer-* checks. -# Individual checkers can be disabled via command line options. -# TODO(bugs.webrtc.com/10258): Select checkers relevant to webrtc guidelines. -CHECKER_OPTION = '-checks=*' - - -def Process(filepath, args): - # Build directory is needed to gather compilation flags. - # Create a temporary one (instead of reusing an existing one) - # to keep the CLI simple and unencumbered. - out_dir = tempfile.mkdtemp('clang_tidy') - - try: - gn_args = [] # Use default build. - command = GetCompilationCommand(filepath, gn_args, out_dir) - - # Remove warning flags. They aren't needed and they cause trouble - # when clang-tidy doesn't match most recent clang. - # Same battle for -f (e.g. -fcomplete-member-pointers). - command = [ - arg for arg in command - if not (arg.startswith('-W') or arg.startswith('-f')) - ] - - # Path from build dir. - rel_path = os.path.relpath(os.path.abspath(filepath), out_dir) - - # Replace clang++ by clang-tidy - command[0:1] = [GetClangTidyPath(), CHECKER_OPTION, rel_path - ] + args + ['--'] # Separator for clang flags. - print("Running: %s" % ' '.join(command)) - # Run from build dir so that relative paths are correct. - p = subprocess.Popen(command, - cwd=out_dir, - stdout=sys.stdout, - stderr=sys.stderr) - p.communicate() - return p.returncode - finally: - shutil.rmtree(out_dir, ignore_errors=True) - - -def ValidateCC(filepath): - """We can only analyze .cc files. Provide explicit message about that.""" - if filepath.endswith('.cc'): - return filepath - msg = ('%s not supported.\n' - 'For now, we can only analyze translation units (.cc files).' % - filepath) - raise argparse.ArgumentTypeError(msg) - - -def Main(): - description = ( - "Run clang-tidy on single cc file.\n" - "Use flags, defines and include paths as in default debug build.\n" - "WARNING, this is a POC version with rough edges.") - parser = argparse.ArgumentParser(description=description) - parser.add_argument('filepath', - help='Specifies the path of the .cc file to analyze.', - type=ValidateCC) - parser.add_argument('args', - nargs=argparse.REMAINDER, - help='Arguments passed to clang-tidy') - parsed_args = parser.parse_args() - return Process(parsed_args.filepath, parsed_args.args) - - -if __name__ == '__main__': - sys.exit(Main()) diff --git a/tools_webrtc/cpu/OWNERS b/tools_webrtc/cpu/OWNERS deleted file mode 100644 index 0fba125734..0000000000 --- a/tools_webrtc/cpu/OWNERS +++ /dev/null @@ -1 +0,0 @@ -tommi@webrtc.org diff --git a/tools_webrtc/cpu/README b/tools_webrtc/cpu/README deleted file mode 100644 index a0cee30a82..0000000000 --- a/tools_webrtc/cpu/README +++ /dev/null @@ -1,12 +0,0 @@ -This directory contains a little utility for doing CPU measurements. -It requires a Python package, psutil, to be installed. -See: https://pypi.python.org/pypi/psutil - -On mac you can install this package like so: -sudo ARCHFLAGS='-Wno-error=unused-command-line-argument-hard-error-in-future' easy_install psutil - -On Windows: -- TBD (see link above) - -On Linux: -- TBD (see link above) diff --git a/tools_webrtc/cpu/cpu_mon.py b/tools_webrtc/cpu/cpu_mon.py deleted file mode 100644 index 9c25fbd088..0000000000 --- a/tools_webrtc/cpu/cpu_mon.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env vpython3 -# -# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -import sys - -import psutil -import numpy -from matplotlib import pyplot - - -class CpuSnapshot: - def __init__(self, label): - self.label = label - self.samples = [] - - def Capture(self, sample_count): - print(('Capturing %d CPU samples for %s...' % - ((sample_count - len(self.samples)), self.label))) - while len(self.samples) < sample_count: - self.samples.append(psutil.cpu_percent(1.0, False)) - - def Text(self): - return ( - '%s: avg=%s, median=%s, min=%s, max=%s' % - (self.label, numpy.average(self.samples), numpy.median( - self.samples), numpy.min(self.samples), numpy.max(self.samples))) - - def Max(self): - return numpy.max(self.samples) - - -def GrabCpuSamples(sample_count): - print('Label for snapshot (enter to quit): ') - label = eval(input().strip()) - if len(label) == 0: - return None - - snapshot = CpuSnapshot(label) - snapshot.Capture(sample_count) - - return snapshot - - -def main(): - print('How many seconds to capture per snapshot (enter for 60)?') - sample_count = eval(input().strip()) - if len(sample_count) > 0 and int(sample_count) > 0: - sample_count = int(sample_count) - else: - print('Defaulting to 60 samples.') - sample_count = 60 - - snapshots = [] - while True: - snapshot = GrabCpuSamples(sample_count) - if snapshot is None: - break - snapshots.append(snapshot) - - if len(snapshots) == 0: - print('no samples captured') - return -1 - - pyplot.title('CPU usage') - - for s in snapshots: - pyplot.plot(s.samples, label=s.Text(), linewidth=2) - - pyplot.legend() - - pyplot.show() - return 0 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/tools_webrtc/gn_check_autofix.py b/tools_webrtc/gn_check_autofix.py index d750e46f54..1d594f151b 100755 --- a/tools_webrtc/gn_check_autofix.py +++ b/tools_webrtc/gn_check_autofix.py @@ -101,6 +101,21 @@ def fix_errors(filename, missing_deps, deleted_sources): Run(['gn', 'format', filename]) +def fix_source_set(filename, line_to_replace): + with open(filename) as file: + lines = file.readlines() + fixed_file = '' + for line in lines: + if line.strip() == line_to_replace.strip(): + fixed_file += line.replace('rtc_source_set', 'rtc_library') + else: + fixed_file += line + + with open(filename, 'w') as file: + file.write(fixed_file) + + Run(['gn', 'format', filename]) + def first_non_empty(iterable): """Return first item which evaluates to True, or fallback to None.""" return next((x for x in iterable if x), None) @@ -194,13 +209,15 @@ def main(): target_msg = 'The target:' if target_msg not in error: target_msg = 'It is not in any dependency of' + if target_msg not in error: + target_msg = 'rtc_source_set shall not contain cc files' if target_msg not in error: print('\n'.join(error)) continue index = error.index(target_msg) + 1 - path, target = error[index].strip().split(':') if error[index + 1] in ('is including a file from the target:', 'The include file is in the target(s):'): + path, target = error[index].strip().split(':') dep = error[index + 2].strip() dep_path, dep = dep.split(':') dep = rebase(path, dep_path, dep) @@ -214,6 +231,12 @@ def main(): deleted_file = '"' + os.path.basename( error[index + 2].strip()) + '",' deleted_sources.add(deleted_file) + elif target_msg == 'rtc_source_set shall not contain cc files': + path = error[index].strip().split(':', + maxsplit=1)[0].split(' ')[1][2:] + print('Turning', error[index + 1].strip().split(' ')[0], 'in', + path, 'into an rtc_library...') + fix_source_set(path, error[index + 1]) else: print('\n'.join(error)) continue diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py index 3304ec3353..24c5c27444 100755 --- a/tools_webrtc/ios/build_ios_libs.py +++ b/tools_webrtc/ios/build_ios_libs.py @@ -126,10 +126,11 @@ def _CleanArtifacts(output_dir): def _CleanTemporary(output_dir, architectures): if os.path.isdir(output_dir): logging.info('Removing temporary build files.') - for arch in architectures: - arch_lib_path = os.path.join(output_dir, arch) - if os.path.isdir(arch_lib_path): - shutil.rmtree(arch_lib_path) + for (env, archs) in architectures.items(): + for arch in archs: + arch_lib_path = '%s_%s_libs' % (env, arch) + if os.path.isdir(arch_lib_path): + shutil.rmtree(arch_lib_path) def _ParseArchitecture(architectures): @@ -189,8 +190,13 @@ def BuildWebRTC(output_dir, target_environment, target_arch, flavor, ('true' if libvpx_build_vp9 else 'false')) gn_args.append('use_lld=true') - gn_args.append('use_remoteexec=' + ('true' if use_remoteexec else 'false')) gn_args.append('rtc_enable_objc_symbol_export=true') + gn_args.append('use_siso=true') + if use_remoteexec: + gn_args.extend([ + 'use_remoteexec=true', + 'use_reclient=false', + ]) args_string = ' '.join(gn_args + extra_gn_args) logging.info('Building WebRTC with args: %s', args_string) @@ -206,13 +212,14 @@ def BuildWebRTC(output_dir, target_environment, target_arch, flavor, logging.info('Building target: %s', gn_target_name) cmd = [ - os.path.join(SRC_DIR, 'third_party', 'ninja', 'ninja'), + os.path.join(SRC_DIR, 'third_party', 'siso', 'cipd', 'siso'), + 'ninja', '-C', output_dir, gn_target_name, ] if use_remoteexec: - cmd.extend(['-j', '200']) + cmd.extend(['-remote_jobs', '200']) _RunCommand(cmd) @@ -232,7 +239,7 @@ def main(): gn_args = args.extra_gn_args if args.purify: - _CleanTemporary(args.output_dir, list(architectures.keys())) + _CleanTemporary(args.output_dir, architectures) return 0 gn_target_name = 'framework_objc' @@ -249,7 +256,7 @@ def main(): framework_paths.append(framework_path) lib_paths = [] for arch in archs: - lib_path = os.path.join(framework_path, arch + '_libs') + lib_path = '%s_%s_libs' % (framework_path, arch) lib_paths.append(lib_path) BuildWebRTC(lib_path, environment, arch, args.build_config, gn_target_name, ios_deployment_target, diff --git a/tools_webrtc/iwyu/apply-include-cleaner b/tools_webrtc/iwyu/apply-include-cleaner index 02de99a4ca..437f318248 100755 --- a/tools_webrtc/iwyu/apply-include-cleaner +++ b/tools_webrtc/iwyu/apply-include-cleaner @@ -1,150 +1,3 @@ #!/usr/bin/env bash -# -# Run the include-cleaner tool (iwyu replacement) on a file in the webrtc source -# directory. -# -# -# In order to handle include paths correctly, you need to provide -# a compile DB (aka compile_commands.json). -# You can create it in one of the following ways: -# "gn gen --export-compile-commands path/to/out" -# "tools/clang/scripts/generate_compdb.py -p path/to/out > compile_commands.json" -# If "out/Default" exists, the script will attempt to generate it for you. -# -# clang-include-cleaner is built as part of the "clangd" package in our -# LLVM build. -# Example .gclient file: -# solutions = [ -# { -# "name": "src", -# "url": "https://webrtc.googlesource.com/src.git", -# "deps_file": "DEPS", -# "managed": False, -# "custom_deps": {}, -# "custom_vars" : { -# "checkout_clangd": True, -# "download_remoteexec_cfg" : True, -# } -# }, -# ] - -CLEANER=third_party/llvm-build/Release+Asserts/bin/clang-include-cleaner -if [ ! -x $CLEANER ]; then - echo "clang-include-cleaner not found" - echo -n "Add '\"checkout_clangd\": True' to 'custom_vars' in your" - echo ".gclient file and run 'gclient sync'." - exit 1 -fi - -# Debug level, also controlled by the "-d" argument. -# Set this to 1 to get more debug information. -# Set this to 2 to also get a dump of the iwyu tool output. -DEBUG=0 - -set -e -if [ $DEBUG -gt 0 ]; then - set -x -fi - -error() { - echo "$*" >&2 - exit 1 -} - -WORKDIR=out/Default - -usage() { - echo "Usage: $0 [-r] file.cc [file2.cc ...]" - echo "Runs the include-cleaner tool on a list of files" - echo "Arguments:" - echo " -n : Just print changes, don't do them" - echo " -c : Just return non-zero exit code if there are changes, don't do them" - echo " -r : Remove non-required includes from .h file" - echo " -d : Set debug level to " - echo " -w : Specify the workdir (out/Default if not specified)" - echo " -h : Print this help message" -} - -COMMAND=" --edit" -INCLUDE_ARGS="" -GMOCK_INCLUDES="--extra-arg=-I../../third_party/googletest/src/googlemock/include/" -GTEST_INCLUDES="--extra-arg=-I../../third_party/googletest/src/googletest/include/" -CHECK_MODE=false - -while getopts 'd:rncw:h' opts; do - case "${opts}" in - n) COMMAND=" --print=changes" ;; - c) COMMAND=" --print=changes" ; CHECK_MODE=true ;; - r) INCLUDE_ARGS=" --remove" ;; - d) DEBUG=${OPTARG};if [ $DEBUG -gt 0 ]; then set -x; fi ;; - w) WORKDIR=${OPTARG} ;; - h) usage; exit 1 ;; - *) error "Unexpected option ${opts}" ;; - esac -done -shift $(expr $OPTIND - 1 ) - -if [[ -z "$COMPILE_COMMANDS" ]]; then - if [ -d "$WORKDIR" ]; then - if [ ! -f "$WORKDIR/compile_commands.json" ]; then - echo "Generating compile commands file" - tools/clang/scripts/generate_compdb.py -p $WORKDIR > $WORKDIR/compile_commands.json - fi - COMPILE_COMMANDS="$WORKDIR/compile_commands.json" - else - error "Could not generate $WORKDIR/compile_commands.json." - fi -fi - -# To get a list of files in a commit: git diff-tree --no-commit-id --name-only -r HEAD -for FILE in "$@" -do - if [ -z $FILE ] || [ ! -f $FILE ]; then - usage - error "File $FILE is not found" - fi -done - -HAS_OUTPUT=false -for FILE in "$@" -do - OUTPUT=$($CLEANER -p $WORKDIR $INCLUDE_ARGS $GMOCK_INCLUDES $GTEST_INCLUDES $COMMAND $FILE) - - # include-cleaner does not support custom mappings for certain deps - # this ensures that the gtest/gmock deps it inserts are replaced - # with the right paths for those includes. - # Since sed inplace argument acts differently between GNU/BSD based systems - # we handle this here. - case "$(uname -s)" in - Linux*) INPLACE_ARG=( -i );; - Darwin*) INPLACE_ARG=( -i '' );; - *) INPLACE_ARG=( -i ) - esac - IWYU_MAPPING=( "\"gmock\/gmock\.h\":\"test\/gmock\.h\"" - "\"gtest\/gtest\.h\":\"test\/gtest\.h\"" - "\:\"rtc_base\/net_helpers\.h\"" ) - - for mapping in "${IWYU_MAPPING[@]}" ; do - KEY="${mapping%%:*}" - VALUE="${mapping##*:}" - if grep -q "#include ${VALUE}" $FILE; then - OUTPUT=$(echo "$OUTPUT" | sed "/+ ${KEY}/d") - sed "${INPLACE_ARG[@]}" -e "/#include ${KEY}/d" $FILE - else - sed "${INPLACE_ARG[@]}" -e "s@^#include ${KEY}@#include ${VALUE}@g" $FILE - fi - done - - echo "${OUTPUT}" - HAS_OUTPUT=$HAS_OUTPUT || [[ ! -z $OUTPUT ]] -done - -echo "Finished. Check diff, compile, gn gen --check (tools_webrtc/gn_check_autofix.py can fix most of the issues)" -echo "and git cl format before uploading." - -# Return a non-zero exit code if running with "CHECK_MODE" -# and there are changes to apply. -if $CHECK_MODE && [[ ! -z $OUTPUT ]]; then - exit 1 -fi +tools_webrtc/iwyu/apply_include_cleaner.py "$@" diff --git a/tools_webrtc/iwyu/iwyu-verifier-filter_list.json b/tools_webrtc/iwyu/iwyu-verifier-filter_list.json index 9cd95be5d8..fd5d8b3751 100644 --- a/tools_webrtc/iwyu/iwyu-verifier-filter_list.json +++ b/tools_webrtc/iwyu/iwyu-verifier-filter_list.json @@ -8,7 +8,8 @@ "modules/desktop_capture/", "modules/desktop_capture/win/", "rtc_base/win", - "sdk/android/src/jni/", + "sdk/android/", + "sdk/objc/", "test/ios/", "test/mac/" ] diff --git a/tools_webrtc/libs/generate_licenses.py b/tools_webrtc/libs/generate_licenses.py index 73fd19ae86..0faddeabd4 100755 --- a/tools_webrtc/libs/generate_licenses.py +++ b/tools_webrtc/libs/generate_licenses.py @@ -196,7 +196,12 @@ def _run_gn(buildfile_dir, target): return output_json def _get_third_party_libraries(self, buildfile_dir, target): - output = json.loads(LicenseBuilder._run_gn(buildfile_dir, target)) + license_json = LicenseBuilder._run_gn(buildfile_dir, target) + try: + output = json.loads(license_json) + except: + logging.error("unable to parse license_json = '%s'", license_json) + raise libraries = set() for described_target in list(output.values()): third_party_libs = (self._parse_library(dep) diff --git a/tools_webrtc/matlab/maxUnwrap.m b/tools_webrtc/matlab/maxUnwrap.m deleted file mode 100644 index cda48278b8..0000000000 --- a/tools_webrtc/matlab/maxUnwrap.m +++ /dev/null @@ -1,26 +0,0 @@ -% // clang-format off -function sequence = maxUnwrap(sequence, max) -% -% sequence = maxUnwrap(sequence, max) -% Unwraps when a wrap around is detected. -% -% Arguments -% -% sequence: The vector to unwrap. -% max: The maximum value that the sequence can take, -% and after which it will wrap over to 0. -% -% Return value -% -% sequence: The unwrapped vector. -% - -% Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -% -% Use of this source code is governed by a BSD-style license -% that can be found in the LICENSE file in the root of the source -% tree. An additional intellectual property rights grant can be found -% in the file PATENTS. All contributing project authors may -% be found in the AUTHORS file in the root of the source tree. - -sequence = round((unwrap(2 * pi * sequence / max) * max) / (2 * pi)); diff --git a/tools_webrtc/matlab/parseLog.m b/tools_webrtc/matlab/parseLog.m deleted file mode 100644 index 62c9388621..0000000000 --- a/tools_webrtc/matlab/parseLog.m +++ /dev/null @@ -1,55 +0,0 @@ -% // clang-format off -function parsed = parseLog(filename) -% -% parsed = parseLog(filename) -% Parses a DataLog text file, with the filename specified in the string -% filename, into a struct with each column name as a field, and with the -% column data stored as a vector in that field. -% -% Arguments -% -% filename: A string with the name of the file to parse. -% -% Return value -% -% parsed: A struct containing each column parsed from the input file -% as a field and with the column data stored as a vector in that -% field. -% - -% Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -% -% Use of this source code is governed by a BSD-style license -% that can be found in the LICENSE file in the root of the source -% tree. An additional intellectual property rights grant can be found -% in the file PATENTS. All contributing project authors may -% be found in the AUTHORS file in the root of the source tree. - -table = importdata(filename, ',', 1); -if ~isstruct(table) - error('Malformed file, possibly empty or lacking data entries') -end - -colheaders = table.textdata; -if length(colheaders) == 1 - colheaders = regexp(table.textdata{1}, ',', 'split'); -end - -parsed = struct; -i = 1; -while i <= length(colheaders) - % Checking for a multi-value column. - m = regexp(colheaders{i}, '([\w\t]+)\[(\d+)\]', 'tokens'); - if ~isempty(m) - % Parse a multi-value column - n = str2double(m{1}{2}) - 1; - parsed.(strrep(m{1}{1}, ' ', '_')) = table.data(:, i:i+n); - i = i + n + 1; - elseif ~isempty(colheaders{i}) - % Parse a single-value column - parsed.(strrep(colheaders{i}, ' ', '_')) = table.data(:, i); - i = i + 1; - else - error('Empty column'); - end -end diff --git a/tools_webrtc/matlab/rtpAnalyze.m b/tools_webrtc/matlab/rtpAnalyze.m deleted file mode 100644 index c64756579e..0000000000 --- a/tools_webrtc/matlab/rtpAnalyze.m +++ /dev/null @@ -1,252 +0,0 @@ -% // clang-format off -function rtpAnalyze( input_file ) -%RTP_ANALYZE Analyze RTP stream(s) from a txt file -% The function takes the output from the command line tool rtp_analyze -% and analyzes the stream(s) therein. First, process your rtpdump file -% through rtp_analyze (from command line): -% $ out/Debug/rtp_analyze my_file.rtp my_file.txt -% Then load it with this function (in Matlab): -% >> rtpAnalyze('my_file.txt') - -% Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. -% -% Use of this source code is governed by a BSD-style license -% that can be found in the LICENSE file in the root of the source -% tree. An additional intellectual property rights grant can be found -% in the file PATENTS. All contributing project authors may -% be found in the AUTHORS file in the root of the source tree. - -[SeqNo,TimeStamp,ArrTime,Size,PT,M,SSRC] = importfile(input_file); - -%% Filter out RTCP packets. -% These appear as RTP packets having payload types 72 through 76. -ix = not(ismember(PT, 72:76)); -fprintf('Removing %i RTCP packets\n', length(SeqNo) - sum(ix)); -SeqNo = SeqNo(ix); -TimeStamp = TimeStamp(ix); -ArrTime = ArrTime(ix); -Size = Size(ix); -PT = PT(ix); -M = M(ix); -SSRC = SSRC(ix); - -%% Find streams. -[uSSRC, ~, uix] = unique(SSRC); - -% If there are multiple streams, select one and purge the other -% streams from the data vectors. If there is only one stream, the -% vectors are good to use as they are. -if length(uSSRC) > 1 - for i=1:length(uSSRC) - uPT = unique(PT(uix == i)); - fprintf('%i: %s (%d packets, pt: %i', i, uSSRC{i}, ... - length(find(uix==i)), uPT(1)); - if length(uPT) > 1 - fprintf(', %i', uPT(2:end)); - end - fprintf(')\n'); - end - sel = input('Select stream number: '); - if sel < 1 || sel > length(uSSRC) - error('Out of range'); - end - ix = find(uix == sel); - % This is where the data vectors are trimmed. - SeqNo = SeqNo(ix); - TimeStamp = TimeStamp(ix); - ArrTime = ArrTime(ix); - Size = Size(ix); - PT = PT(ix); - M = M(ix); - SSRC = SSRC(ix); -end - -%% Unwrap SeqNo and TimeStamp. -SeqNoUW = maxUnwrap(SeqNo, 65535); -TimeStampUW = maxUnwrap(TimeStamp, 4294967295); - -%% Generate some stats for the stream. -fprintf('Statistics:\n'); -fprintf('SSRC: %s\n', SSRC{1}); -uPT = unique(PT); -if length(uPT) > 1 - warning('This tool cannot yet handle changes in codec sample rate'); -end -fprintf('Payload type(s): %i', uPT(1)); -if length(uPT) > 1 - fprintf(', %i', uPT(2:end)); -end -fprintf('\n'); -fprintf('Packets: %i\n', length(SeqNo)); -SortSeqNo = sort(SeqNoUW); -fprintf('Missing sequence numbers: %i\n', ... - length(find(diff(SortSeqNo) > 1))); -fprintf('Duplicated packets: %i\n', length(find(diff(SortSeqNo) == 0))); -reorderIx = findReorderedPackets(SeqNoUW); -fprintf('Reordered packets: %i\n', length(reorderIx)); -tsdiff = diff(TimeStampUW); -tsdiff = tsdiff(diff(SeqNoUW) == 1); -[utsdiff, ~, ixtsdiff] = unique(tsdiff); -fprintf('Common packet sizes:\n'); -for i = 1:length(utsdiff) - fprintf(' %i samples (%i%%)\n', ... - utsdiff(i), ... - round(100 * length(find(ixtsdiff == i))/length(ixtsdiff))); -end - -%% Trying to figure out sample rate. -fs_est = (TimeStampUW(end) - TimeStampUW(1)) / (ArrTime(end) - ArrTime(1)); -fs_vec = [8, 16, 32, 48]; -fs = 0; -for f = fs_vec - if abs((fs_est-f)/f) < 0.05 % 5% margin - fs = f; - break; - end -end -if fs == 0 - fprintf('Cannot determine sample rate. I get it to %.2f kHz\n', ... - fs_est); - fs = input('Please, input a sample rate (in kHz): '); -else - fprintf('Sample rate estimated to %i kHz\n', fs); -end - -SendTimeMs = (TimeStampUW - TimeStampUW(1)) / fs; - -fprintf('Stream duration at sender: %.1f seconds\n', ... - (SendTimeMs(end) - SendTimeMs(1)) / 1000); - -fprintf('Stream duration at receiver: %.1f seconds\n', ... - (ArrTime(end) - ArrTime(1)) / 1000); - -fprintf('Clock drift: %.2f%%\n', ... - 100 * ((ArrTime(end) - ArrTime(1)) / ... - (SendTimeMs(end) - SendTimeMs(1)) - 1)); - -fprintf('Sent average bitrate: %i kbps\n', ... - round(sum(Size) * 8 / (SendTimeMs(end)-SendTimeMs(1)))); - -fprintf('Received average bitrate: %i kbps\n', ... - round(sum(Size) * 8 / (ArrTime(end)-ArrTime(1)))); - -%% Plots. -delay = ArrTime - SendTimeMs; -delay = delay - min(delay); -delayOrdered = delay; -delayOrdered(reorderIx) = nan; % Set reordered packets to NaN. -delayReordered = delay(reorderIx); % Pick the reordered packets. -sendTimeMsReordered = SendTimeMs(reorderIx); - -% Sort time arrays in packet send order. -[~, sortix] = sort(SeqNoUW); -SendTimeMs = SendTimeMs(sortix); -Size = Size(sortix); -delayOrdered = delayOrdered(sortix); - -figure -plot(SendTimeMs / 1000, delayOrdered, ... - sendTimeMsReordered / 1000, delayReordered, 'r.'); -xlabel('Send time [s]'); -ylabel('Relative transport delay [ms]'); -title(sprintf('SSRC: %s', SSRC{1})); - -SendBitrateKbps = 8 * Size(1:end-1) ./ diff(SendTimeMs); -figure -plot(SendTimeMs(1:end-1)/1000, SendBitrateKbps); -xlabel('Send time [s]'); -ylabel('Send bitrate [kbps]'); -end - -%% Subfunctions. - -% findReorderedPackets returns the index to all packets that are considered -% old compared with the largest seen sequence number. The input seqNo must -% be unwrapped for this to work. -function reorderIx = findReorderedPackets(seqNo) -largestSeqNo = seqNo(1); -reorderIx = []; -for i = 2:length(seqNo) - if seqNo(i) < largestSeqNo - reorderIx = [reorderIx; i]; %#ok - else - largestSeqNo = seqNo(i); - end -end -end - -%% Auto-generated subfunction. -function [SeqNo,TimeStamp,SendTime,Size,PT,M,SSRC] = ... - importfile(filename, startRow, endRow) -%IMPORTFILE Import numeric data from a text file as column vectors. -% [SEQNO,TIMESTAMP,SENDTIME,SIZE,PT,M,SSRC] = IMPORTFILE(FILENAME) Reads -% data from text file FILENAME for the default selection. -% -% [SEQNO,TIMESTAMP,SENDTIME,SIZE,PT,M,SSRC] = IMPORTFILE(FILENAME, -% STARTROW, ENDROW) Reads data from rows STARTROW through ENDROW of text -% file FILENAME. -% -% Example: -% [SeqNo,TimeStamp,SendTime,Size,PT,M,SSRC] = -% importfile('rtpdump_recv.txt',2, 123); -% -% See also TEXTSCAN. - -% Auto-generated by MATLAB on 2015/05/28 09:55:50 - -%% Initialize variables. -if nargin<=2 - startRow = 2; - endRow = inf; -end - -%% Format string for each line of text: -% column1: double (%f) -% column2: double (%f) -% column3: double (%f) -% column4: double (%f) -% column5: double (%f) -% column6: double (%f) -% column7: text (%s) -% For more information, see the TEXTSCAN documentation. -formatSpec = '%5f%11f%11f%6f%6f%3f%s%[^\n\r]'; - -%% Open the text file. -fileID = fopen(filename,'r'); - -%% Read columns of data according to format string. -% This call is based on the structure of the file used to generate this -% code. If an error occurs for a different file, try regenerating the code -% from the Import Tool. -dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, ... - 'Delimiter', '', 'WhiteSpace', '', 'HeaderLines', startRow(1)-1, ... - 'ReturnOnError', false); -for block=2:length(startRow) - frewind(fileID); - dataArrayBlock = textscan(fileID, formatSpec, ... - endRow(block)-startRow(block)+1, 'Delimiter', '', 'WhiteSpace', ... - '', 'HeaderLines', startRow(block)-1, 'ReturnOnError', false); - for col=1:length(dataArray) - dataArray{col} = [dataArray{col};dataArrayBlock{col}]; - end -end - -%% Close the text file. -fclose(fileID); - -%% Post processing for unimportable data. -% No unimportable data rules were applied during the import, so no post -% processing code is included. To generate code which works for -% unimportable data, select unimportable cells in a file and regenerate the -% script. - -%% Allocate imported array to column variable names -SeqNo = dataArray{:, 1}; -TimeStamp = dataArray{:, 2}; -SendTime = dataArray{:, 3}; -Size = dataArray{:, 4}; -PT = dataArray{:, 5}; -M = dataArray{:, 6}; -SSRC = dataArray{:, 7}; -end - diff --git a/tools_webrtc/mb/mb_config.pyl b/tools_webrtc/mb/mb_config.pyl index 3d1fd7ccb2..1fdaaf5c84 100644 --- a/tools_webrtc/mb/mb_config.pyl +++ b/tools_webrtc/mb/mb_config.pyl @@ -524,7 +524,7 @@ 'debug_bot': { 'mixins': [ 'debug', - 'reclient', + 'remoteexec', 'strict_field_trials', 'disallow_deprecated_namespaces' ], @@ -533,7 +533,7 @@ 'mixins': [ 'debug', 'minimal_symbols', - 'reclient', + 'remoteexec', 'strict_field_trials', 'disallow_deprecated_namespaces', ], @@ -620,10 +620,7 @@ # 100% release build without DCHECKs while 'release_bot' is a partial # release configs since `dcheck_always_on` is set to true. 'pure_release_bot': { - 'mixins': ['release', 'reclient', 'dcheck_off'], - }, - 'reclient': { - 'gn_args': 'use_remoteexec=true', + 'mixins': ['release', 'remoteexec', 'dcheck_off'], }, 'release': { 'gn_args': 'is_debug=false', @@ -636,6 +633,9 @@ 'disallow_deprecated_namespaces', ], }, + 'remoteexec': { + 'gn_args': 'use_remoteexec=true use_reclient=false use_siso=true', + }, 'rtc_objc_test_prefix': { 'gn_args': 'rtc_objc_prefix="RTC_TESTING"', }, diff --git a/tools_webrtc/network_emulator/config.py b/tools_webrtc/network_emulator/config.py deleted file mode 100644 index 9a18bdce45..0000000000 --- a/tools_webrtc/network_emulator/config.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env vpython3 - -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -"""Configuration class for network emulation.""" - - -class ConnectionConfig: - """Configuration containing the characteristics of a network connection.""" - - def __init__(self, num, name, receive_bw_kbps, send_bw_kbps, delay_ms, - packet_loss_percent, queue_slots): - self.num = num - self.name = name - self.receive_bw_kbps = receive_bw_kbps - self.send_bw_kbps = send_bw_kbps - self.delay_ms = delay_ms - self.packet_loss_percent = packet_loss_percent - self.queue_slots = queue_slots - - def __str__(self): - """String representing the configuration. - - Returns: - A string formatted and padded like this example: - 12 Name 375 kbps 375 kbps 10 145 ms 0.1 % - """ - left_aligned_name = self.name.ljust(24, ' ') - return '%2s %24s %5s kbps %5s kbps %4s %5s ms %3s %%' % ( - self.num, left_aligned_name, self.receive_bw_kbps, self.send_bw_kbps, - self.queue_slots, self.delay_ms, self.packet_loss_percent) diff --git a/tools_webrtc/network_emulator/emulate.py b/tools_webrtc/network_emulator/emulate.py deleted file mode 100755 index a35ccd36c8..0000000000 --- a/tools_webrtc/network_emulator/emulate.py +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env vpython3 - -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -"""Script for constraining traffic on the local machine.""" - -import logging -import optparse -import socket -import sys - -import config -import network_emulator - -_DEFAULT_LOG_LEVEL = logging.INFO - -# Default port range to apply network constraints on. -_DEFAULT_PORT_RANGE = (32768, 65535) - -# The numbers below are gathered from Google stats from the presets of the Apple -# developer tool called Network Link Conditioner. -_PRESETS = [ - config.ConnectionConfig(1, 'Generic, Bad', 95, 95, 250, 2, 100), - config.ConnectionConfig(2, 'Generic, Average', 375, 375, 145, 0.1, 100), - config.ConnectionConfig(3, 'Generic, Good', 1000, 1000, 35, 0, 100), - config.ConnectionConfig(4, '3G, Average Case', 780, 330, 100, 0, 100), - config.ConnectionConfig(5, '3G, Good', 850, 420, 90, 0, 100), - config.ConnectionConfig(6, '3G, Lossy Network', 780, 330, 100, 1, 100), - config.ConnectionConfig(7, 'Cable Modem', 6000, 1000, 2, 0, 10), - config.ConnectionConfig(8, 'DSL', 2000, 256, 5, 0, 10), - config.ConnectionConfig(9, 'Edge, Average Case', 240, 200, 400, 0, 100), - config.ConnectionConfig(10, 'Edge, Good', 250, 200, 350, 0, 100), - config.ConnectionConfig(11, 'Edge, Lossy Network', 240, 200, 400, 1, 100), - config.ConnectionConfig(12, 'Wifi, Average Case', 40000, 33000, 1, 0, 100), - config.ConnectionConfig(13, 'Wifi, Good', 45000, 40000, 1, 0, 100), - config.ConnectionConfig(14, 'Wifi, Lossy', 40000, 33000, 1, 0, 100), -] -_PRESETS_DICT = dict((p.num, p) for p in _PRESETS) - -_DEFAULT_PRESET_ID = 2 -_DEFAULT_PRESET = _PRESETS_DICT[_DEFAULT_PRESET_ID] - - -class NonStrippingEpilogOptionParser(optparse.OptionParser): - """Custom parser to let us show the epilog without weird line breaking.""" - - def format_epilog(self, formatter): - return self.epilog - - -def _GetExternalIp(): - """Finds out the machine's external IP by connecting to google.com.""" - external_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - external_socket.connect(('google.com', 80)) - return external_socket.getsockname()[0] - - -def _ParseArgs(): - """Define and parse the command-line arguments.""" - presets_string = '\n'.join(str(p) for p in _PRESETS) - parser = NonStrippingEpilogOptionParser(epilog=( - '\nAvailable presets:\n' - ' Bandwidth (kbps) Packet\n' - 'ID Name Receive Send Queue Delay loss \n' - '-- ---- --------- -------- ----- ------- ------\n' - '%s\n' % presets_string)) - parser.add_option('-p', - '--preset', - type='int', - default=_DEFAULT_PRESET_ID, - help=('ConnectionConfig configuration, specified by ID. ' - 'Default: %default')) - parser.add_option('-r', - '--receive-bw', - type='int', - default=_DEFAULT_PRESET.receive_bw_kbps, - help=('Receive bandwidth in kilobit/s. Default: %default')) - parser.add_option('-s', - '--send-bw', - type='int', - default=_DEFAULT_PRESET.send_bw_kbps, - help=('Send bandwidth in kilobit/s. Default: %default')) - parser.add_option('-d', - '--delay', - type='int', - default=_DEFAULT_PRESET.delay_ms, - help=('Delay in ms. Default: %default')) - parser.add_option('-l', - '--packet-loss', - type='float', - default=_DEFAULT_PRESET.packet_loss_percent, - help=('Packet loss in %. Default: %default')) - parser.add_option('-q', - '--queue', - type='int', - default=_DEFAULT_PRESET.queue_slots, - help=('Queue size as number of slots. Default: %default')) - parser.add_option('--port-range', - default='%s,%s' % _DEFAULT_PORT_RANGE, - help=('Range of ports for constrained network. Specify as ' - 'two comma separated integers. Default: %default')) - parser.add_option('--target-ip', - default=None, - help=('The interface IP address to apply the rules for. ' - 'Default: the external facing interface IP address.')) - parser.add_option('-v', - '--verbose', - action='store_true', - default=False, - help=('Turn on verbose output. Will print all \'ipfw\' ' - 'commands that are executed.')) - - options = parser.parse_args()[0] - - # Find preset by ID, if specified. - if options.preset and options.preset not in _PRESETS_DICT: - parser.error('Invalid preset: %s' % options.preset) - - # Simple validation of the IP address, if supplied. - if options.target_ip: - try: - socket.inet_aton(options.target_ip) - except socket.error: - parser.error('Invalid IP address specified: %s' % options.target_ip) - - # Convert port range into the desired tuple format. - try: - if isinstance(options.port_range, str): - options.port_range = tuple( - int(port) for port in options.port_range.split(',')) - if len(options.port_range) != 2: - parser.error('Invalid port range specified, please specify two ' - 'integers separated by a comma.') - except ValueError: - parser.error('Invalid port range specified.') - - _InitLogging(options.verbose) - return options - - -def _InitLogging(verbose): - """Setup logging.""" - log_level = _DEFAULT_LOG_LEVEL - if verbose: - log_level = logging.DEBUG - logging.basicConfig(level=log_level, format='%(message)s') - - -def main(): - options = _ParseArgs() - - # Build a configuration object. Override any preset configuration settings if - # a value of a setting was also given as a flag. - connection_config = _PRESETS_DICT[options.preset] - if options.receive_bw is not _DEFAULT_PRESET.receive_bw_kbps: - connection_config.receive_bw_kbps = options.receive_bw - if options.send_bw is not _DEFAULT_PRESET.send_bw_kbps: - connection_config.send_bw_kbps = options.send_bw - if options.delay is not _DEFAULT_PRESET.delay_ms: - connection_config.delay_ms = options.delay - if options.packet_loss is not _DEFAULT_PRESET.packet_loss_percent: - connection_config.packet_loss_percent = options.packet_loss - if options.queue is not _DEFAULT_PRESET.queue_slots: - connection_config.queue_slots = options.queue - emulator = network_emulator.NetworkEmulator(connection_config, - options.port_range) - try: - emulator.CheckPermissions() - except network_emulator.NetworkEmulatorError as e: - logging.error('Error: %s\n\nCause: %s', e.fail_msg, e.error) - return -1 - - if not options.target_ip: - external_ip = _GetExternalIp() - else: - external_ip = options.target_ip - - logging.info('Constraining traffic to/from IP: %s', external_ip) - try: - emulator.Emulate(external_ip) - logging.info( - 'Started network emulation with the following configuration:\n' - ' Receive bandwidth: %s kbps (%s kB/s)\n' - ' Send bandwidth : %s kbps (%s kB/s)\n' - ' Delay : %s ms\n' - ' Packet loss : %s %%\n' - ' Queue slots : %s', connection_config.receive_bw_kbps, - connection_config.receive_bw_kbps / 8, connection_config.send_bw_kbps, - connection_config.send_bw_kbps / 8, connection_config.delay_ms, - connection_config.packet_loss_percent, connection_config.queue_slots) - logging.info('Affected traffic: IP traffic on ports %s-%s', - options.port_range[0], options.port_range[1]) - input('Press Enter to abort Network Emulation...') - logging.info('Flushing all Dummynet rules...') - network_emulator.Cleanup() - logging.info('Completed Network Emulation.') - return 0 - except network_emulator.NetworkEmulatorError as e: - logging.error('Error: %s\n\nCause: %s', e.fail_msg, e.error) - return -2 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/tools_webrtc/network_emulator/network_emulator.py b/tools_webrtc/network_emulator/network_emulator.py deleted file mode 100644 index a7776a5f92..0000000000 --- a/tools_webrtc/network_emulator/network_emulator.py +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env vpython3 - -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -"""Script for constraining traffic on the local machine.""" - -import ctypes -import logging -import os -import subprocess -import sys - - -class NetworkEmulatorError(BaseException): - """Exception raised for errors in the network emulator. - - Attributes: - fail_msg: User defined error message. - cmd: Command for which the exception was raised. - returncode: Return code of running the command. - stdout: Output of running the command. - stderr: Error output of running the command. - """ - - def __init__(self, - fail_msg, - cmd=None, - returncode=None, - output=None, - error=None): - BaseException.__init__(self, fail_msg) - self.fail_msg = fail_msg - self.cmd = cmd - self.returncode = returncode - self.output = output - self.error = error - - -class NetworkEmulator: - """A network emulator that can constrain the network using Dummynet.""" - - def __init__(self, connection_config, port_range): - """Constructor. - - Args: - connection_config: A config.ConnectionConfig object containing the - characteristics for the connection to be emulation. - port_range: Tuple containing two integers defining the port range. - """ - self._pipe_counter = 0 - self._rule_counter = 0 - self._port_range = port_range - self._connection_config = connection_config - - def Emulate(self, target_ip): - """Starts a network emulation by setting up Dummynet rules. - - Args: - target_ip: The IP address of the interface that shall be that have the - network constraints applied to it. - """ - receive_pipe_id = self._CreateDummynetPipe( - self._connection_config.receive_bw_kbps, - self._connection_config.delay_ms, - self._connection_config.packet_loss_percent, - self._connection_config.queue_slots) - logging.debug('Created receive pipe: %s', receive_pipe_id) - send_pipe_id = self._CreateDummynetPipe( - self._connection_config.send_bw_kbps, self._connection_config.delay_ms, - self._connection_config.packet_loss_percent, - self._connection_config.queue_slots) - logging.debug('Created send pipe: %s', send_pipe_id) - - # Adding the rules will start the emulation. - incoming_rule_id = self._CreateDummynetRule(receive_pipe_id, 'any', - target_ip, self._port_range) - logging.debug('Created incoming rule: %s', incoming_rule_id) - outgoing_rule_id = self._CreateDummynetRule(send_pipe_id, target_ip, 'any', - self._port_range) - logging.debug('Created outgoing rule: %s', outgoing_rule_id) - - @staticmethod - def CheckPermissions(): - """Checks if permissions are available to run Dummynet commands. - - Raises: - NetworkEmulatorError: If permissions to run Dummynet commands are not - available. - """ - try: - if os.getuid() != 0: - raise NetworkEmulatorError('You must run this script with sudo.') - except AttributeError as permission_error: - - # AttributeError will be raised on Windows. - if ctypes.windll.shell32.IsUserAnAdmin() == 0: - raise NetworkEmulatorError('You must run this script with administrator' - ' privileges.') from permission_error - - def _CreateDummynetRule(self, pipe_id, from_address, to_address, port_range): - """Creates a network emulation rule and returns its ID. - - Args: - pipe_id: integer ID of the pipe. - from_address: The IP address to match source address. May be an IP or - 'any'. - to_address: The IP address to match destination address. May be an IP or - 'any'. - port_range: The range of ports the rule shall be applied on. Must be - specified as a tuple of with two integers. - Returns: - The ID of the rule, starting at 100. The rule ID increments with 100 for - each rule being added. - """ - self._rule_counter += 100 - add_part = [ - 'add', self._rule_counter, 'pipe', pipe_id, 'ip', 'from', from_address, - 'to', to_address - ] - _RunIpfwCommand(add_part + ['src-port', '%s-%s' % port_range], - 'Failed to add Dummynet src-port rule.') - _RunIpfwCommand(add_part + ['dst-port', '%s-%s' % port_range], - 'Failed to add Dummynet dst-port rule.') - return self._rule_counter - - def _CreateDummynetPipe(self, bandwidth_kbps, delay_ms, packet_loss_percent, - queue_slots): - """Creates a Dummynet pipe and return its ID. - - Args: - bandwidth_kbps: Bandwidth. - delay_ms: Delay for a one-way trip of a packet. - packet_loss_percent: Float value of packet loss, in percent. - queue_slots: Size of the queue. - Returns: - The ID of the pipe, starting at 1. - """ - self._pipe_counter += 1 - cmd = [ - 'pipe', self._pipe_counter, 'config', 'bw', - str(bandwidth_kbps / 8) + 'KByte/s', 'delay', - '%sms' % delay_ms, 'plr', (packet_loss_percent / 100.0), 'queue', - queue_slots - ] - error_message = 'Failed to create Dummynet pipe. ' - if sys.platform.startswith('linux'): - error_message += ('Make sure you have loaded the ipfw_mod.ko module to ' - 'your kernel (sudo insmod /path/to/ipfw_mod.ko).') - _RunIpfwCommand(cmd, error_message) - return self._pipe_counter - - -def Cleanup(): - """Stops the network emulation by flushing all Dummynet rules. - - Notice that this will flush any rules that may have been created previously - before starting the emulation. - """ - _RunIpfwCommand(['-f', 'flush'], 'Failed to flush Dummynet rules!') - _RunIpfwCommand(['-f', 'pipe', 'flush'], 'Failed to flush Dummynet pipes!') - - -def _RunIpfwCommand(command, fail_msg=None): - """Executes a command and prefixes the appropriate command for - Windows or Linux/UNIX. - - Args: - command: Command list to execute. - fail_msg: Message describing the error in case the command fails. - - Raises: - NetworkEmulatorError: If command fails a message is set by the fail_msg - parameter. - """ - if sys.platform == 'win32': - ipfw_command = ['ipfw.exe'] - else: - ipfw_command = ['sudo', '-n', 'ipfw'] - - cmd_list = ipfw_command[:] + [str(x) for x in command] - cmd_string = ' '.join(cmd_list) - logging.debug('Running command: %s', cmd_string) - process = subprocess.Popen(cmd_list, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - output, error = process.communicate() - if process.returncode != 0: - raise NetworkEmulatorError(fail_msg, cmd_string, process.returncode, output, - error) - return output.strip() diff --git a/video/BUILD.gn b/video/BUILD.gn index 3e7af5a1e9..bf77b139ca 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -26,6 +26,7 @@ rtc_library("video_stream_encoder_interface") { "../api/video:video_bitrate_allocator", "../api/video:video_codec_constants", "../api/video:video_frame", + "../api/video:video_frame_type", "../api/video:video_layers_allocation", "../api/video_codecs:video_codecs_api", "../video/config:encoder_config", @@ -143,6 +144,7 @@ rtc_library("video") { "../modules/rtp_rtcp:rtp_rtcp_format", "../modules/rtp_rtcp:rtp_video_header", "../modules/video_coding", + "../modules/video_coding:codec_globals_headers", "../modules/video_coding:h264_sprop_parameter_sets", "../modules/video_coding:h26x_packet_buffer", "../modules/video_coding:nack_requester", @@ -164,6 +166,7 @@ rtc_library("video") { "../rtc_base:rate_tracker", "../rtc_base:rtc_event", "../rtc_base:rtc_numerics", + "../rtc_base:rtp_to_ntp_estimator", "../rtc_base:safe_conversions", "../rtc_base:sample_counter", "../rtc_base:stringutils", @@ -180,7 +183,6 @@ rtc_library("video") { "../rtc_base/system:no_unique_address", "../rtc_base/task_utils:repeating_task", "../system_wrappers", - "../system_wrappers:field_trial", "../system_wrappers:metrics", "../video/config:encoder_config", "../video/corruption_detection:frame_instrumentation_evaluation", @@ -207,6 +209,7 @@ rtc_library("frame_dumping_decoder") { deps = [ "../api/video:encoded_frame", "../api/video:encoded_image", + "../api/video:video_frame", "../api/video_codecs:video_codecs_api", "../modules/video_coding", "../modules/video_coding:video_codec_interface", @@ -224,17 +227,21 @@ rtc_library("frame_dumping_encoder") { ] deps = [ + "../api:fec_controller_api", "../api:field_trials_view", "../api:sequence_checker", "../api/video:encoded_frame", "../api/video:encoded_image", "../api/video:video_frame", + "../api/video:video_frame_type", "../api/video_codecs:video_codecs_api", "../modules/video_coding", "../modules/video_coding:video_codec_interface", "../modules/video_coding:video_coding_utility", + "../rtc_base:macromagic", "../rtc_base:stringutils", "../rtc_base:timeutils", + "../rtc_base/synchronization:mutex", "../rtc_base/system:file_wrapper", "//third_party/abseil-cpp/absl/algorithm:container", ] @@ -249,7 +256,9 @@ rtc_library("frame_cadence_adapter") { deps = [ "../api:field_trials_view", + "../api:scoped_refptr", "../api:sequence_checker", + "../api:video_track_source_constraints", "../api/metronome", "../api/task_queue", "../api/task_queue:pending_task_safety_flag", @@ -268,7 +277,6 @@ rtc_library("frame_cadence_adapter") { "../rtc_base/system:unused", "../rtc_base/task_utils:repeating_task", "../system_wrappers", - "../system_wrappers:field_trial", "../system_wrappers:metrics", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:core_headers", @@ -291,6 +299,7 @@ rtc_library("video_stream_buffer_controller") { "../api:sequence_checker", "../api/metronome", "../api/task_queue", + "../api/task_queue:pending_task_safety_flag", "../api/units:data_size", "../api/units:time_delta", "../api/units:timestamp", @@ -306,9 +315,11 @@ rtc_library("video_stream_buffer_controller") { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:macromagic", + "../rtc_base/experiments:field_trial_parser", + "../rtc_base/system:no_unique_address", "../system_wrappers", - "../system_wrappers:field_trial", "//third_party/abseil-cpp/absl/base:core_headers", + "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/functional:bind_front", ] } @@ -333,6 +344,7 @@ rtc_library("task_queue_frame_decode_scheduler") { "../api:sequence_checker", "../api/task_queue", "../api/task_queue:pending_task_safety_flag", + "../api/units:time_delta", "../api/units:timestamp", "../rtc_base:checks", "../system_wrappers", @@ -348,7 +360,9 @@ rtc_library("frame_decode_timing") { "../api/task_queue", "../api/task_queue:pending_task_safety_flag", "../api/units:time_delta", + "../api/units:timestamp", "../modules/video_coding/timing:timing_module", + "../rtc_base:checks", "../rtc_base:logging", "../system_wrappers", ] @@ -360,10 +374,13 @@ rtc_library("video_receive_stream_timeout_tracker") { "video_receive_stream_timeout_tracker.h", ] deps = [ + "../api:sequence_checker", "../api/task_queue", "../api/units:time_delta", "../api/units:timestamp", + "../rtc_base:checks", "../rtc_base:logging", + "../rtc_base:macromagic", "../rtc_base/task_utils:repeating_task", "../system_wrappers", ] @@ -380,12 +397,14 @@ rtc_library("decode_synchronizer") { "../api:sequence_checker", "../api/metronome", "../api/task_queue", + "../api/task_queue:pending_task_safety_flag", "../api/units:time_delta", "../api/units:timestamp", "../rtc_base:checks", "../rtc_base:event_tracer", "../rtc_base:logging", "../rtc_base:macromagic", + "../system_wrappers", ] } @@ -422,6 +441,7 @@ rtc_library("video_stream_encoder_impl") { "../api:field_trials_view", "../api:make_ref_counted", "../api:rtc_error", + "../api:rtp_packet_info", "../api:rtp_parameters", "../api:rtp_sender_interface", "../api:scoped_refptr", @@ -460,7 +480,9 @@ rtc_library("video_stream_encoder_impl") { "../modules/video_coding:webrtc_vp9_helpers", "../modules/video_coding/svc:scalability_mode_util", "../modules/video_coding/svc:scalability_structures", + "../modules/video_coding/svc:scalable_video_controller", "../modules/video_coding/svc:svc_rate_allocator", + "../rtc_base:buffer", "../rtc_base:checks", "../rtc_base:criticalsection", "../rtc_base:event_tracer", @@ -508,8 +530,18 @@ if (rtc_include_tests) { sources = [ "test/mock_video_stream_encoder.h" ] deps = [ ":video_stream_encoder_interface", + "../api:fec_controller_api", + "../api:rtp_parameters", + "../api:rtp_sender_interface", + "../api:scoped_refptr", + "../api/adaptation:resource_adaptation_api", + "../api/units:data_rate", + "../api/video:video_frame", + "../api/video:video_frame_type", "../api/video:video_stream_encoder", + "../api/video_codecs:video_codecs_api", "../test:test_support", + "config:encoder_config", ] } if (!build_with_chromium) { @@ -529,32 +561,32 @@ if (rtc_include_tests) { ] deps = [ ":frame_dumping_decoder", - "..//test/network:simulated_network", "../api:array_view", "../api:create_frame_generator", "../api:fec_controller_api", "../api:field_trials_view", "../api:frame_generator_api", - "../api:libjingle_peerconnection_api", "../api:make_ref_counted", "../api:rtc_event_log_output_file", "../api:rtp_parameters", "../api:scoped_refptr", "../api:simulated_network_api", - "../api:test_dependency_factory", "../api:transport_api", "../api:video_quality_test_fixture_api", "../api/audio:audio_device", "../api/audio:builtin_audio_processing_builder", + "../api/audio:create_audio_device_module", "../api/environment", + "../api/environment:environment_factory", "../api/numerics", "../api/rtc_event_log", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue", - "../api/task_queue:default_task_queue_factory", "../api/test/metrics:global_metrics_logger_and_exporter", "../api/test/metrics:metric", + "../api/test/video:function_video_factory", "../api/units:time_delta", + "../api/units:timestamp", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:encoded_image", "../api/video:video_bitrate_allocation", @@ -562,7 +594,6 @@ if (rtc_include_tests) { "../api/video:video_codec_constants", "../api/video:video_frame", "../api/video:video_frame_type", - "../api/video:video_rtp_headers", "../api/video_codecs:video_codecs_api", "../call:call_interfaces", "../call:fake_network", @@ -573,20 +604,15 @@ if (rtc_include_tests) { "../media:rtc_audio_video", "../media:rtc_internal_video_codecs", "../media:rtc_simulcast_encoder_adapter", - "../modules/audio_device:audio_device_module_from_input_and_output", "../modules/audio_device:test_audio_device_module", - "../modules/audio_device:windows_core_audio_utility", "../modules/audio_mixer:audio_mixer_impl", "../modules/rtp_rtcp", "../modules/rtp_rtcp:rtp_rtcp_format", - "../modules/video_coding", "../modules/video_coding:codec_globals_headers", "../modules/video_coding:video_coding_utility", - "../modules/video_coding:webrtc_h264", - "../modules/video_coding:webrtc_vp8", - "../modules/video_coding:webrtc_vp9", "../rtc_base:checks", "../rtc_base:copy_on_write_buffer", + "../rtc_base:cpu_info", "../rtc_base:logging", "../rtc_base:macromagic", "../rtc_base:platform_thread", @@ -602,7 +628,6 @@ if (rtc_include_tests) { "../rtc_base/task_utils:repeating_task", "../system_wrappers", "../test:direct_transport", - "../test:fake_video_codecs", "../test:fileutils", "../test:frame_generator_capturer", "../test:platform_video_capturer", @@ -613,13 +638,12 @@ if (rtc_include_tests) { "../test:test_support", "../test:test_support_test_artifacts", "../test:video_frame_writer", - "../test:video_test_common", "../test:video_test_constants", + "../test/network:simulated_network", "config:encoder_config", "config:streams_config", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/flags:flag", - "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -627,7 +651,11 @@ if (rtc_include_tests) { deps += [ "../test:video_test_mac" ] } if (is_win) { - deps += [ "../rtc_base/win:scoped_com_initializer" ] + deps += [ + "../modules/audio_device:audio_device_module_from_input_and_output", + "../modules/audio_device:windows_core_audio_utility", + "../rtc_base/win:scoped_com_initializer", + ] } } @@ -637,6 +665,7 @@ if (rtc_include_tests) { sources = [ "full_stack_tests.cc" ] deps = [ ":video_quality_test", + "../api:rtp_parameters", "../api:simulated_network_api", "../api:test_dependency_factory", "../api:video_quality_test_fixture_api", @@ -667,6 +696,7 @@ if (rtc_include_tests) { "../api:create_peer_connection_quality_test_frame_generator", "../api:create_peerconnection_quality_test_fixture", "../api:frame_generator_api", + "../api:function_view", "../api:media_stream_interface", "../api:network_emulation_manager_api", "../api:peer_connection_quality_test_fixture_api", @@ -676,6 +706,9 @@ if (rtc_include_tests) { "../api/test/pclf:media_configuration", "../api/test/pclf:media_quality_test_params", "../api/test/pclf:peer_configurer", + "../api/transport:bitrate_settings", + "../api/units:data_rate", + "../api/units:time_delta", "../api/video_codecs:video_codecs_api", "../media:media_constants", "../modules/video_coding:webrtc_vp9", @@ -887,11 +920,14 @@ if (rtc_include_tests) { "../api:sequence_checker", "../api:simulated_network_api", "../api:time_controller", + "../api:transport_api", "../api:video_track_source_constraints", "../api/adaptation:resource_adaptation_api", + "../api/crypto:frame_decryptor_interface", "../api/crypto:options", "../api/environment", "../api/environment:environment_factory", + "../api/metronome", "../api/metronome/test:fake_metronome", "../api/rtc_event_log", "../api/task_queue", @@ -943,6 +979,7 @@ if (rtc_include_tests) { "../call/adaptation:resource_adaptation", "../call/adaptation:resource_adaptation_test_utilities", "../common_video", + "../common_video:frame_counts", "../common_video:frame_instrumentation_data", "../common_video/test:utilities", "../media:codec", @@ -974,19 +1011,23 @@ if (rtc_include_tests) { "../modules/video_coding/svc:scalability_structures", "../modules/video_coding/svc:scalable_video_controller", "../modules/video_coding/timing:timing_module", + "../rtc_base:buffer", "../rtc_base:byte_buffer", "../rtc_base:checks", "../rtc_base:copy_on_write_buffer", "../rtc_base:gunit_helpers", "../rtc_base:logging", "../rtc_base:macromagic", + "../rtc_base:mod_ops", "../rtc_base:network_route", + "../rtc_base:random", "../rtc_base:rate_limiter", "../rtc_base:rate_statistics", "../rtc_base:refcount", "../rtc_base:rtc_base_tests_utils", "../rtc_base:rtc_event", "../rtc_base:rtc_numerics", + "../rtc_base:rtp_to_ntp_estimator", "../rtc_base:safe_conversions", "../rtc_base:stringutils", "../rtc_base:task_queue_for_test", @@ -999,6 +1040,7 @@ if (rtc_include_tests) { "../rtc_base/experiments:rate_control_settings", "../rtc_base/synchronization:mutex", "../system_wrappers", + "../system_wrappers:field_trial", "../system_wrappers:metrics", "../test:direct_transport", "../test:encoder_settings", diff --git a/video/adaptation/BUILD.gn b/video/adaptation/BUILD.gn index 829d1f1305..1337140c8f 100644 --- a/video/adaptation/BUILD.gn +++ b/video/adaptation/BUILD.gn @@ -32,6 +32,7 @@ rtc_library("video_adaptation") { deps = [ "../../api:field_trials_view", + "../../api:make_ref_counted", "../../api:rtp_parameters", "../../api:scoped_refptr", "../../api:sequence_checker", @@ -39,7 +40,9 @@ rtc_library("video_adaptation") { "../../api/environment", "../../api/task_queue:task_queue", "../../api/units:data_rate", + "../../api/units:data_size", "../../api/units:time_delta", + "../../api/video:encoded_image", "../../api/video:video_adaptation", "../../api/video:video_frame", "../../api/video:video_stream_encoder", @@ -60,6 +63,7 @@ rtc_library("video_adaptation") { "../../rtc_base/experiments:balanced_degradation_settings", "../../rtc_base/experiments:field_trial_parser", "../../rtc_base/experiments:quality_scaler_settings", + "../../rtc_base/experiments:quality_scaling_experiment", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:no_unique_address", "../../rtc_base/task_utils:repeating_task", @@ -84,8 +88,12 @@ if (rtc_include_tests) { ] deps = [ ":video_adaptation", + "..:video_stream_encoder_interface", + "../../api:array_view", "../../api:field_trials_view", + "../../api:rtp_parameters", "../../api:scoped_refptr", + "../../api/adaptation:resource_adaptation_api", "../../api/environment", "../../api/environment:environment_factory", "../../api/task_queue:task_queue", @@ -94,6 +102,7 @@ if (rtc_include_tests) { "../../api/video:encoded_image", "../../api/video:video_adaptation", "../../api/video:video_frame", + "../../api/video:video_rtp_headers", "../../api/video_codecs:scalability_mode", "../../api/video_codecs:video_codecs_api", "../../call/adaptation:resource_adaptation", @@ -107,9 +116,11 @@ if (rtc_include_tests) { "../../rtc_base:rtc_numerics", "../../rtc_base:task_queue_for_test", "../../rtc_base:threading", + "../../rtc_base:timeutils", "../../test:rtc_expect_death", "../../test:test_support", "../../test/time_controller:time_controller", + "../config:encoder_config", "//third_party/abseil-cpp/absl/functional:any_invocable", ] } diff --git a/video/adaptation/balanced_constraint.cc b/video/adaptation/balanced_constraint.cc index 0e8975ca97..27f3eca1a4 100644 --- a/video/adaptation/balanced_constraint.cc +++ b/video/adaptation/balanced_constraint.cc @@ -10,10 +10,17 @@ #include "video/adaptation/balanced_constraint.h" -#include +#include +#include #include +#include "api/field_trials_view.h" +#include "api/rtp_parameters.h" #include "api/sequence_checker.h" +#include "call/adaptation/degradation_preference_provider.h" +#include "call/adaptation/video_source_restrictions.h" +#include "call/adaptation/video_stream_input_state.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/video/adaptation/balanced_constraint.h b/video/adaptation/balanced_constraint.h index 294fe6f70c..12375635f6 100644 --- a/video/adaptation/balanced_constraint.h +++ b/video/adaptation/balanced_constraint.h @@ -11,6 +11,7 @@ #ifndef VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_ #define VIDEO_ADAPTATION_BALANCED_CONSTRAINT_H_ +#include #include #include @@ -18,8 +19,11 @@ #include "api/sequence_checker.h" #include "call/adaptation/adaptation_constraint.h" #include "call/adaptation/degradation_preference_provider.h" +#include "call/adaptation/video_source_restrictions.h" +#include "call/adaptation/video_stream_input_state.h" #include "rtc_base/experiments/balanced_degradation_settings.h" #include "rtc_base/system/no_unique_address.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/video/adaptation/bandwidth_quality_scaler_resource.cc b/video/adaptation/bandwidth_quality_scaler_resource.cc index 815e07ed76..3b104e4b26 100644 --- a/video/adaptation/bandwidth_quality_scaler_resource.cc +++ b/video/adaptation/bandwidth_quality_scaler_resource.cc @@ -10,12 +10,20 @@ #include "video/adaptation/bandwidth_quality_scaler_resource.h" -#include - +#include +#include +#include + +#include "api/adaptation/resource.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" +#include "api/video/encoded_image.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/video_encoder.h" +#include "modules/video_coding/utility/bandwidth_quality_scaler.h" #include "rtc_base/checks.h" -#include "rtc_base/experiments/balanced_degradation_settings.h" -#include "rtc_base/logging.h" -#include "rtc_base/time_utils.h" +#include "video/adaptation/video_stream_encoder_resource.h" namespace webrtc { diff --git a/video/adaptation/bandwidth_quality_scaler_resource.h b/video/adaptation/bandwidth_quality_scaler_resource.h index 9661e75e6f..14540d668f 100644 --- a/video/adaptation/bandwidth_quality_scaler_resource.h +++ b/video/adaptation/bandwidth_quality_scaler_resource.h @@ -11,18 +11,16 @@ #ifndef VIDEO_ADAPTATION_BANDWIDTH_QUALITY_SCALER_RESOURCE_H_ #define VIDEO_ADAPTATION_BANDWIDTH_QUALITY_SCALER_RESOURCE_H_ +#include #include -#include -#include -#include #include #include "api/scoped_refptr.h" -#include "api/video/video_adaptation_reason.h" +#include "api/video/encoded_image.h" +#include "api/video/video_codec_type.h" #include "api/video_codecs/video_encoder.h" -#include "call/adaptation/degradation_preference_provider.h" -#include "call/adaptation/resource_adaptation_processor_interface.h" #include "modules/video_coding/utility/bandwidth_quality_scaler.h" +#include "rtc_base/thread_annotations.h" #include "video/adaptation/video_stream_encoder_resource.h" namespace webrtc { diff --git a/video/adaptation/bitrate_constraint.cc b/video/adaptation/bitrate_constraint.cc index 6eb480bf7f..cd3f5348ce 100644 --- a/video/adaptation/bitrate_constraint.cc +++ b/video/adaptation/bitrate_constraint.cc @@ -10,11 +10,17 @@ #include "video/adaptation/bitrate_constraint.h" +#include +#include #include -#include #include "api/sequence_checker.h" +#include "api/video_codecs/video_encoder.h" +#include "call/adaptation/encoder_settings.h" +#include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_adapter.h" +#include "call/adaptation/video_stream_input_state.h" +#include "rtc_base/checks.h" #include "video/adaptation/video_stream_encoder_resource_manager.h" namespace webrtc { diff --git a/video/adaptation/bitrate_constraint.h b/video/adaptation/bitrate_constraint.h index 8906a16d13..d57500fbcf 100644 --- a/video/adaptation/bitrate_constraint.h +++ b/video/adaptation/bitrate_constraint.h @@ -11,6 +11,7 @@ #ifndef VIDEO_ADAPTATION_BITRATE_CONSTRAINT_H_ #define VIDEO_ADAPTATION_BITRATE_CONSTRAINT_H_ +#include #include #include @@ -20,6 +21,7 @@ #include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_input_state.h" #include "rtc_base/system/no_unique_address.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/video/adaptation/bitrate_constraint_unittest.cc b/video/adaptation/bitrate_constraint_unittest.cc index 29ebb6a912..3d4e9fe227 100644 --- a/video/adaptation/bitrate_constraint_unittest.cc +++ b/video/adaptation/bitrate_constraint_unittest.cc @@ -10,16 +10,21 @@ #include "video/adaptation/bitrate_constraint.h" +#include +#include #include #include +#include "api/video/video_codec_type.h" #include "api/video_codecs/scalability_mode.h" +#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "call/adaptation/encoder_settings.h" #include "call/adaptation/test/fake_frame_rate_provider.h" #include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_input_state_provider.h" #include "test/gtest.h" +#include "video/config/video_encoder_config.h" namespace webrtc { diff --git a/video/adaptation/encode_usage_resource.cc b/video/adaptation/encode_usage_resource.cc index 3ca08cbcf2..0496a6c196 100644 --- a/video/adaptation/encode_usage_resource.cc +++ b/video/adaptation/encode_usage_resource.cc @@ -10,10 +10,21 @@ #include "video/adaptation/encode_usage_resource.h" +#include #include +#include +#include #include +#include "api/adaptation/resource.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" +#include "api/video/video_frame.h" #include "rtc_base/checks.h" +#include "video/adaptation/overuse_frame_detector.h" +#include "video/adaptation/video_stream_encoder_resource.h" namespace webrtc { diff --git a/video/adaptation/encode_usage_resource.h b/video/adaptation/encode_usage_resource.h index 7820859d9d..5b4dc02f33 100644 --- a/video/adaptation/encode_usage_resource.h +++ b/video/adaptation/encode_usage_resource.h @@ -11,12 +11,12 @@ #ifndef VIDEO_ADAPTATION_ENCODE_USAGE_RESOURCE_H_ #define VIDEO_ADAPTATION_ENCODE_USAGE_RESOURCE_H_ +#include #include #include -#include #include "api/scoped_refptr.h" -#include "api/video/video_adaptation_reason.h" +#include "rtc_base/thread_annotations.h" #include "video/adaptation/overuse_frame_detector.h" #include "video/adaptation/video_stream_encoder_resource.h" diff --git a/video/adaptation/overuse_frame_detector.cc b/video/adaptation/overuse_frame_detector.cc index d095d81d85..000f4bfb98 100644 --- a/video/adaptation/overuse_frame_detector.cc +++ b/video/adaptation/overuse_frame_detector.cc @@ -14,20 +14,29 @@ #include #include +#include #include #include #include +#include #include +#include #include #include "api/environment/environment.h" #include "api/field_trials_view.h" +#include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "api/video/video_frame.h" #include "rtc_base/checks.h" +#include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/exp_filter.h" +#include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" +#include "video/video_stream_encoder_observer.h" #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) #include diff --git a/video/adaptation/overuse_frame_detector.h b/video/adaptation/overuse_frame_detector.h index bfdc8ebd1d..719f1fa28b 100644 --- a/video/adaptation/overuse_frame_detector.h +++ b/video/adaptation/overuse_frame_detector.h @@ -11,7 +11,7 @@ #ifndef VIDEO_ADAPTATION_OVERUSE_FRAME_DETECTOR_H_ #define VIDEO_ADAPTATION_OVERUSE_FRAME_DETECTOR_H_ -#include +#include #include #include @@ -19,8 +19,8 @@ #include "api/field_trials_view.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "rtc_base/experiments/field_trial_parser.h" -#include "rtc_base/numerics/exp_filter.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/thread_annotations.h" diff --git a/video/adaptation/overuse_frame_detector_unittest.cc b/video/adaptation/overuse_frame_detector_unittest.cc index fa8530f00d..f1b522f105 100644 --- a/video/adaptation/overuse_frame_detector_unittest.cc +++ b/video/adaptation/overuse_frame_detector_unittest.cc @@ -10,20 +10,25 @@ #include "video/adaptation/overuse_frame_detector.h" +#include +#include #include +#include +#include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/video/encoded_image.h" +#include "api/units/time_delta.h" #include "api/video/i420_buffer.h" -#include "api/video/video_adaptation_reason.h" -#include "modules/video_coding/utility/quality_scaler.h" +#include "api/video/video_rotation.h" #include "rtc_base/event.h" #include "rtc_base/fake_clock.h" #include "rtc_base/random.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/time_utils.h" #include "test/gmock.h" #include "test/gtest.h" +#include "video/video_stream_encoder_observer.h" namespace webrtc { @@ -103,7 +108,7 @@ class OveruseFrameDetectorTest : public ::testing::Test, VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(width, height)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); uint32_t timestamp = 0; @@ -129,7 +134,7 @@ class OveruseFrameDetectorTest : public ::testing::Test, VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(width, height)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); uint32_t timestamp = 0; @@ -159,12 +164,12 @@ class OveruseFrameDetectorTest : public ::testing::Test, int width, int height, int delay_us) { - webrtc::Random random(17); + Random random(17); VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(width, height)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); uint32_t timestamp = 0; @@ -377,7 +382,7 @@ TEST_F(OveruseFrameDetectorTest, MeasuresMultipleConcurrentSamples) { VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(kWidth, kHeight)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); for (size_t i = 0; i < 1000; ++i) { @@ -404,7 +409,7 @@ TEST_F(OveruseFrameDetectorTest, UpdatesExistingSamples) { VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(kWidth, kHeight)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); uint32_t timestamp = 0; @@ -670,7 +675,7 @@ class OveruseFrameDetectorTest2 : public OveruseFrameDetectorTest { VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(width, height)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); while (num_frames-- > 0) { @@ -689,12 +694,12 @@ class OveruseFrameDetectorTest2 : public OveruseFrameDetectorTest { int width, int height, int delay_us) override { - webrtc::Random random(17); + Random random(17); VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(width, height)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); for (int i = 0; i < num_frames; i++) { @@ -858,7 +863,7 @@ TEST_F(OveruseFrameDetectorTest2, MeasuresMultipleConcurrentSamples) { VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(kWidth, kHeight)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); for (size_t i = 0; i < 1000; ++i) { @@ -885,7 +890,7 @@ TEST_F(OveruseFrameDetectorTest2, UpdatesExistingSamples) { VideoFrame frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(kWidth, kHeight)) - .set_rotation(webrtc::kVideoRotation_0) + .set_rotation(kVideoRotation_0) .set_timestamp_us(0) .build(); uint32_t timestamp = 0; diff --git a/video/adaptation/pixel_limit_resource.cc b/video/adaptation/pixel_limit_resource.cc index 446824fa78..04730b6147 100644 --- a/video/adaptation/pixel_limit_resource.cc +++ b/video/adaptation/pixel_limit_resource.cc @@ -10,10 +10,18 @@ #include "video/adaptation/pixel_limit_resource.h" +#include + +#include "api/adaptation/resource.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" #include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "call/adaptation/video_stream_adapter.h" +#include "call/adaptation/video_stream_input_state_provider.h" #include "rtc_base/checks.h" +#include "rtc_base/task_utils/repeating_task.h" namespace webrtc { diff --git a/video/adaptation/pixel_limit_resource.h b/video/adaptation/pixel_limit_resource.h index 591de753f0..38d20f7bfe 100644 --- a/video/adaptation/pixel_limit_resource.h +++ b/video/adaptation/pixel_limit_resource.h @@ -16,6 +16,7 @@ #include "api/adaptation/resource.h" #include "api/scoped_refptr.h" +#include "api/task_queue/task_queue_base.h" #include "call/adaptation/video_stream_input_state_provider.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/thread_annotations.h" diff --git a/video/adaptation/pixel_limit_resource_unittest.cc b/video/adaptation/pixel_limit_resource_unittest.cc index 4ed3daa494..ec6d2a8741 100644 --- a/video/adaptation/pixel_limit_resource_unittest.cc +++ b/video/adaptation/pixel_limit_resource_unittest.cc @@ -14,11 +14,15 @@ #include #include "absl/functional/any_invocable.h" +#include "api/adaptation/resource.h" +#include "api/scoped_refptr.h" +#include "api/task_queue/task_queue_base.h" +#include "api/task_queue/task_queue_factory.h" +#include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "call/adaptation/test/fake_video_stream_input_state_provider.h" #include "call/adaptation/test/mock_resource_listener.h" #include "call/adaptation/video_stream_adapter.h" -#include "rtc_base/task_queue_for_test.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" diff --git a/video/adaptation/quality_scaler_resource.cc b/video/adaptation/quality_scaler_resource.cc index 19ffbf8937..6f6e93caed 100644 --- a/video/adaptation/quality_scaler_resource.cc +++ b/video/adaptation/quality_scaler_resource.cc @@ -10,12 +10,20 @@ #include "video/adaptation/quality_scaler_resource.h" +#include +#include #include +#include "api/adaptation/resource.h" #include "api/field_trials_view.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" +#include "api/video/encoded_image.h" +#include "api/video_codecs/video_encoder.h" +#include "modules/video_coding/utility/quality_scaler.h" #include "rtc_base/checks.h" -#include "rtc_base/experiments/balanced_degradation_settings.h" -#include "rtc_base/time_utils.h" +#include "video/adaptation/video_stream_encoder_resource.h" namespace webrtc { diff --git a/video/adaptation/quality_scaler_resource.h b/video/adaptation/quality_scaler_resource.h index 88aa40c936..2e916bb586 100644 --- a/video/adaptation/quality_scaler_resource.h +++ b/video/adaptation/quality_scaler_resource.h @@ -11,18 +11,15 @@ #ifndef VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_ #define VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_ +#include #include -#include -#include -#include #include "api/field_trials_view.h" #include "api/scoped_refptr.h" -#include "api/video/video_adaptation_reason.h" +#include "api/video/encoded_image.h" #include "api/video_codecs/video_encoder.h" -#include "call/adaptation/degradation_preference_provider.h" -#include "call/adaptation/resource_adaptation_processor_interface.h" #include "modules/video_coding/utility/quality_scaler.h" +#include "rtc_base/thread_annotations.h" #include "video/adaptation/video_stream_encoder_resource.h" namespace webrtc { diff --git a/video/adaptation/quality_scaler_resource_unittest.cc b/video/adaptation/quality_scaler_resource_unittest.cc index b83db37545..32dfa3bab3 100644 --- a/video/adaptation/quality_scaler_resource_unittest.cc +++ b/video/adaptation/quality_scaler_resource_unittest.cc @@ -10,11 +10,11 @@ #include "video/adaptation/quality_scaler_resource.h" -#include -#include - +#include "api/adaptation/resource.h" +#include "api/rtp_parameters.h" +#include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" -#include "api/video_codecs/video_encoder.h" +#include "call/adaptation/degradation_preference_provider.h" #include "call/adaptation/test/mock_resource_listener.h" #include "rtc_base/thread.h" #include "test/gmock.h" diff --git a/video/adaptation/video_stream_encoder_resource.cc b/video/adaptation/video_stream_encoder_resource.cc index 7793315f93..84b8f04529 100644 --- a/video/adaptation/video_stream_encoder_resource.cc +++ b/video/adaptation/video_stream_encoder_resource.cc @@ -10,9 +10,15 @@ #include "video/adaptation/video_stream_encoder_resource.h" -#include +#include #include +#include "api/adaptation/resource.h" +#include "api/scoped_refptr.h" +#include "api/task_queue/task_queue_base.h" +#include "rtc_base/checks.h" +#include "rtc_base/synchronization/mutex.h" + namespace webrtc { VideoStreamEncoderResource::VideoStreamEncoderResource(std::string name) diff --git a/video/adaptation/video_stream_encoder_resource.h b/video/adaptation/video_stream_encoder_resource.h index 5e93b31ec3..620043dc8b 100644 --- a/video/adaptation/video_stream_encoder_resource.h +++ b/video/adaptation/video_stream_encoder_resource.h @@ -11,15 +11,12 @@ #ifndef VIDEO_ADAPTATION_VIDEO_STREAM_ENCODER_RESOURCE_H_ #define VIDEO_ADAPTATION_VIDEO_STREAM_ENCODER_RESOURCE_H_ -#include #include -#include #include "api/adaptation/resource.h" -#include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" -#include "call/adaptation/adaptation_constraint.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/video/adaptation/video_stream_encoder_resource_manager.cc b/video/adaptation/video_stream_encoder_resource_manager.cc index ae575de690..437f50f69e 100644 --- a/video/adaptation/video_stream_encoder_resource_manager.cc +++ b/video/adaptation/video_stream_encoder_resource_manager.cc @@ -13,28 +13,55 @@ #include #include -#include -#include +#include +#include #include +#include +#include +#include #include +#include -#include "absl/algorithm/container.h" -#include "absl/base/macros.h" #include "api/adaptation/resource.h" #include "api/field_trials_view.h" +#include "api/rtp_parameters.h" +#include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/video/encoded_image.h" +#include "api/video/video_adaptation_counters.h" #include "api/video/video_adaptation_reason.h" -#include "api/video/video_source_interface.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" +#include "call/adaptation/adaptation_constraint.h" +#include "call/adaptation/degradation_preference_provider.h" +#include "call/adaptation/encoder_settings.h" +#include "call/adaptation/resource_adaptation_processor_interface.h" #include "call/adaptation/video_source_restrictions.h" +#include "call/adaptation/video_stream_adapter.h" +#include "call/adaptation/video_stream_input_state_provider.h" #include "modules/video_coding/svc/scalability_mode_util.h" #include "rtc_base/checks.h" +#include "rtc_base/experiments/quality_scaler_settings.h" +#include "rtc_base/experiments/quality_scaling_experiment.h" #include "rtc_base/logging.h" -#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" +#include "system_wrappers/include/clock.h" +#include "video/adaptation/balanced_constraint.h" +#include "video/adaptation/bandwidth_quality_scaler_resource.h" +#include "video/adaptation/bitrate_constraint.h" +#include "video/adaptation/encode_usage_resource.h" +#include "video/adaptation/overuse_frame_detector.h" +#include "video/adaptation/pixel_limit_resource.h" #include "video/adaptation/quality_scaler_resource.h" +#include "video/config/video_encoder_config.h" +#include "video/video_stream_encoder_observer.h" namespace webrtc { @@ -552,7 +579,7 @@ void VideoStreamEncoderResourceManager::UpdateBandwidthQualityScalerSettings( // Before executing "StartCheckForOveruse",we must execute "AddResource" // firstly,because it can make the listener valid. AddResource(bandwidth_quality_scaler_resource_, - webrtc::VideoAdaptationReason::kQuality); + VideoAdaptationReason::kQuality); bandwidth_quality_scaler_resource_->StartCheckForOveruse( resolution_bitrate_limits, codec_type); } diff --git a/video/adaptation/video_stream_encoder_resource_manager.h b/video/adaptation/video_stream_encoder_resource_manager.h index 1520bd5aef..34c31af2ab 100644 --- a/video/adaptation/video_stream_encoder_resource_manager.h +++ b/video/adaptation/video_stream_encoder_resource_manager.h @@ -11,13 +11,11 @@ #ifndef VIDEO_ADAPTATION_VIDEO_STREAM_ENCODER_RESOURCE_MANAGER_H_ #define VIDEO_ADAPTATION_VIDEO_STREAM_ENCODER_RESOURCE_MANAGER_H_ -#include +#include #include #include #include #include -#include -#include #include #include "api/adaptation/resource.h" @@ -25,19 +23,22 @@ #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/data_rate.h" +#include "api/units/data_size.h" #include "api/video/video_adaptation_counters.h" #include "api/video/video_adaptation_reason.h" +#include "api/video/video_codec_type.h" #include "api/video/video_frame.h" -#include "api/video/video_source_interface.h" #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" +#include "call/adaptation/adaptation_constraint.h" +#include "call/adaptation/degradation_preference_provider.h" +#include "call/adaptation/encoder_settings.h" #include "call/adaptation/resource_adaptation_processor_interface.h" +#include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_adapter.h" #include "call/adaptation/video_stream_input_state_provider.h" -#include "rtc_base/experiments/quality_scaler_settings.h" -#include "rtc_base/ref_count.h" -#include "rtc_base/strings/string_builder.h" -#include "rtc_base/synchronization/mutex.h" +#include "rtc_base/experiments/balanced_degradation_settings.h" #include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" #include "video/adaptation/balanced_constraint.h" @@ -47,7 +48,6 @@ #include "video/adaptation/overuse_frame_detector.h" #include "video/adaptation/pixel_limit_resource.h" #include "video/adaptation/quality_scaler_resource.h" -#include "video/adaptation/video_stream_encoder_resource.h" #include "video/config/video_encoder_config.h" #include "video/video_stream_encoder_observer.h" diff --git a/video/alignment_adjuster.cc b/video/alignment_adjuster.cc index de32992837..c51d530422 100644 --- a/video/alignment_adjuster.cc +++ b/video/alignment_adjuster.cc @@ -11,10 +11,15 @@ #include "video/alignment_adjuster.h" #include +#include +#include #include +#include #include "absl/algorithm/container.h" +#include "api/video_codecs/video_encoder.h" #include "rtc_base/logging.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { diff --git a/video/alignment_adjuster.h b/video/alignment_adjuster.h index 086f633f96..fb2bc729c0 100644 --- a/video/alignment_adjuster.h +++ b/video/alignment_adjuster.h @@ -11,6 +11,9 @@ #ifndef VIDEO_ALIGNMENT_ADJUSTER_H_ #define VIDEO_ALIGNMENT_ADJUSTER_H_ +#include +#include + #include "api/video_codecs/video_encoder.h" #include "video/config/video_encoder_config.h" diff --git a/video/alignment_adjuster_unittest.cc b/video/alignment_adjuster_unittest.cc index 95a5e1346e..60e475c9ba 100644 --- a/video/alignment_adjuster_unittest.cc +++ b/video/alignment_adjuster_unittest.cc @@ -10,13 +10,16 @@ #include "video/alignment_adjuster.h" -#include +#include +#include #include #include -#include "rtc_base/numerics/safe_conversions.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/video_encoder.h" #include "test/encoder_settings.h" #include "test/gtest.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace test { diff --git a/video/buffered_frame_decryptor.cc b/video/buffered_frame_decryptor.cc index 29ec8aec22..03fc2eb567 100644 --- a/video/buffered_frame_decryptor.cc +++ b/video/buffered_frame_decryptor.cc @@ -73,7 +73,7 @@ BufferedFrameDecryptor::FrameDecision BufferedFrameDecryptor::DecryptFrame( } // Retrieve the maximum possible size of the decrypted payload. const size_t max_plaintext_byte_size = - frame_decryptor_->GetMaxPlaintextByteSize(webrtc::MediaType::VIDEO, + frame_decryptor_->GetMaxPlaintextByteSize(MediaType::VIDEO, frame->size()); RTC_CHECK_LE(max_plaintext_byte_size, frame->size()); // Place the decrypted frame inline into the existing frame. @@ -88,9 +88,8 @@ BufferedFrameDecryptor::FrameDecision BufferedFrameDecryptor::DecryptFrame( // Attempt to decrypt the video frame. const FrameDecryptorInterface::Result decrypt_result = - frame_decryptor_->Decrypt(webrtc::MediaType::VIDEO, /*csrcs=*/{}, - additional_data, *frame, - inline_decrypted_bitstream); + frame_decryptor_->Decrypt(MediaType::VIDEO, /*csrcs=*/{}, additional_data, + *frame, inline_decrypted_bitstream); // Optionally call the callback if there was a change in status if (decrypt_result.status != last_status_) { last_status_ = decrypt_result.status; diff --git a/video/buffered_frame_decryptor.h b/video/buffered_frame_decryptor.h index 2c857f8c98..2e28c37a12 100644 --- a/video/buffered_frame_decryptor.h +++ b/video/buffered_frame_decryptor.h @@ -11,12 +11,13 @@ #ifndef VIDEO_BUFFERED_FRAME_DECRYPTOR_H_ #define VIDEO_BUFFERED_FRAME_DECRYPTOR_H_ +#include #include #include -#include "api/crypto/crypto_options.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/field_trials_view.h" +#include "api/scoped_refptr.h" #include "modules/rtp_rtcp/source/frame_object.h" namespace webrtc { diff --git a/video/buffered_frame_decryptor_unittest.cc b/video/buffered_frame_decryptor_unittest.cc index 28e93fe022..781de7512c 100644 --- a/video/buffered_frame_decryptor_unittest.cc +++ b/video/buffered_frame_decryptor_unittest.cc @@ -10,14 +10,24 @@ #include "video/buffered_frame_decryptor.h" -#include +#include +#include #include #include #include +#include "api/crypto/frame_decryptor_interface.h" +#include "api/make_ref_counted.h" +#include "api/rtp_packet_infos.h" +#include "api/scoped_refptr.h" #include "api/test/mock_frame_decryptor.h" -#include "modules/video_coding/packet_buffer.h" -#include "system_wrappers/include/clock.h" +#include "api/video/encoded_image.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_content_type.h" +#include "api/video/video_rotation.h" +#include "api/video/video_timing.h" +#include "modules/rtp_rtcp/source/frame_object.h" +#include "modules/rtp_rtcp/source/rtp_video_header.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" diff --git a/video/call_stats2.cc b/video/call_stats2.cc index ef575d2667..8dd9ce98dd 100644 --- a/video/call_stats2.cc +++ b/video/call_stats2.cc @@ -11,11 +11,19 @@ #include "video/call_stats2.h" #include -#include +#include +#include #include #include "absl/algorithm/container.h" +#include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" +#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "modules/include/module_common_types.h" #include "rtc_base/checks.h" +#include "rtc_base/task_utils/repeating_task.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" namespace webrtc { diff --git a/video/call_stats2.h b/video/call_stats2.h index 7e941d1e75..110f60067f 100644 --- a/video/call_stats2.h +++ b/video/call_stats2.h @@ -11,15 +11,17 @@ #ifndef VIDEO_CALL_STATS2_H_ #define VIDEO_CALL_STATS2_H_ +#include #include -#include #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" -#include "api/units/timestamp.h" +#include "api/units/time_delta.h" #include "modules/include/module_common_types.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "rtc_base/checks.h" #include "rtc_base/task_utils/repeating_task.h" +#include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/video/call_stats2_unittest.cc b/video/call_stats2_unittest.cc index af19f3b883..dd49adf68d 100644 --- a/video/call_stats2_unittest.cc +++ b/video/call_stats2_unittest.cc @@ -10,12 +10,15 @@ #include "video/call_stats2.h" +#include #include #include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/task_queue_base.h" +#include "api/task_queue/task_queue_factory.h" +#include "modules/include/module_common_types.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "rtc_base/thread.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/video/config/BUILD.gn b/video/config/BUILD.gn index 5dcc6316f4..d48bb4931c 100644 --- a/video/config/BUILD.gn +++ b/video/config/BUILD.gn @@ -32,6 +32,7 @@ rtc_library("streams_config") { "../../modules/video_coding:webrtc_vp9_helpers", "../../rtc_base:checks", "../../rtc_base:logging", + "../../rtc_base:safe_conversions", "../../rtc_base/experiments:field_trial_parser", "../../rtc_base/experiments:min_video_bitrate_experiment", "../../rtc_base/experiments:normalize_simulcast_size_experiment", @@ -49,8 +50,10 @@ rtc_library("encoder_config") { deps = [ "../../api:field_trials_view", + "../../api:ref_count", "../../api:scoped_refptr", "../../api/video:resolution", + "../../api/video:video_frame", "../../api/video_codecs:scalability_mode", "../../api/video_codecs:video_codecs_api", "../../rtc_base:checks", diff --git a/video/config/encoder_stream_factory.cc b/video/config/encoder_stream_factory.cc index 558427478a..8820c98944 100644 --- a/video/config/encoder_stream_factory.cc +++ b/video/config/encoder_stream_factory.cc @@ -10,28 +10,38 @@ #include "video/config/encoder_stream_factory.h" #include +#include +#include #include -#include -#include -#include +#include +#include +#include #include "absl/algorithm/container.h" -#include "absl/strings/match.h" #include "api/field_trials_view.h" -#include "api/video/video_codec_constants.h" +#include "api/units/data_rate.h" +#include "api/video/resolution.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_source_interface.h" +#include "api/video_codecs/spatial_layer.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" +#include "call/adaptation/video_source_restrictions.h" #include "media/base/media_constants.h" #include "media/base/video_adapter.h" #include "modules/video_coding/codecs/vp9/svc_config.h" #include "modules/video_coding/utility/simulcast_utility.h" +#include "rtc_base/checks.h" #include "rtc_base/experiments/min_video_bitrate_experiment.h" #include "rtc_base/experiments/normalize_simulcast_size_experiment.h" #include "rtc_base/logging.h" +#include "rtc_base/numerics/safe_conversions.h" #include "video/config/simulcast.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { -using ::webrtc::FieldTrialsView; const int kMinLayerSize = 16; @@ -62,10 +72,10 @@ bool IsScaleFactorsPowerOfTwo(const VideoEncoderConfig& config) { } bool IsTemporalLayersSupported(VideoCodecType codec_type) { - return codec_type == webrtc::VideoCodecType::kVideoCodecVP8 || - codec_type == webrtc::VideoCodecType::kVideoCodecVP9 || - codec_type == webrtc::VideoCodecType::kVideoCodecAV1 || - codec_type == webrtc::VideoCodecType::kVideoCodecH265; + return codec_type == VideoCodecType::kVideoCodecVP8 || + codec_type == VideoCodecType::kVideoCodecVP9 || + codec_type == VideoCodecType::kVideoCodecAV1 || + codec_type == VideoCodecType::kVideoCodecH265; } size_t FindRequiredActiveLayers(const VideoEncoderConfig& encoder_config) { @@ -100,14 +110,14 @@ static int GetMaxDefaultVideoBitrateKbps(int width, int GetDefaultMaxQp(VideoCodecType codec_type) { switch (codec_type) { - case webrtc::kVideoCodecH264: - case webrtc::kVideoCodecH265: + case kVideoCodecH264: + case kVideoCodecH265: return kDefaultVideoMaxQpH26x; - case webrtc::kVideoCodecVP8: - case webrtc::kVideoCodecVP9: - case webrtc::kVideoCodecGeneric: + case kVideoCodecVP8: + case kVideoCodecVP9: + case kVideoCodecGeneric: return kDefaultVideoMaxQpVpx; - case webrtc::kVideoCodecAV1: + case kVideoCodecAV1: return kDefaultVideoMaxQpAv1; } } @@ -120,7 +130,7 @@ int NormalizeSimulcastSize(const FieldTrialsView& field_trials, size_t simulcast_layers) { int base2_exponent = static_cast(simulcast_layers) - 1; const std::optional experimental_base2_exponent = - webrtc::NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials); + NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials); if (experimental_base2_exponent && (size > (1 << *experimental_base2_exponent))) { base2_exponent = *experimental_base2_exponent; @@ -138,10 +148,10 @@ void OverrideStreamSettings( // Allow an experiment to override the minimum bitrate for the lowest // spatial layer. The experiment's configuration has the lowest priority. - layers[0].min_bitrate_bps = experimental_min_bitrate - .value_or(webrtc::DataRate::BitsPerSec( - webrtc::kDefaultMinVideoBitrateBps)) - .bps(); + layers[0].min_bitrate_bps = + experimental_min_bitrate + .value_or(DataRate::BitsPerSec(kDefaultMinVideoBitrateBps)) + .bps(); const bool temporal_layers_supported = IsTemporalLayersSupported(encoder_config.codec_type); @@ -209,14 +219,14 @@ void OverrideStreamSettings( bool is_highest_layer_max_bitrate_configured = encoder_config.simulcast_layers[layers.size() - 1].max_bitrate_bps > 0; - bool is_screencast = encoder_config.content_type == - webrtc::VideoEncoderConfig::ContentType::kScreen; + bool is_screencast = + encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen; if (!is_screencast && !is_highest_layer_max_bitrate_configured && encoder_config.max_bitrate_bps > 0) { // No application-configured maximum for the largest layer. // If there is bitrate leftover, give it to the largest layer. - webrtc::BoostMaxSimulcastLayer( - webrtc::DataRate::BitsPerSec(encoder_config.max_bitrate_bps), &layers); + BoostMaxSimulcastLayer(DataRate::BitsPerSec(encoder_config.max_bitrate_bps), + &layers); } // Sort the layers by max_bitrate_bps, they might not always be from @@ -248,7 +258,7 @@ void OverrideStreamSettings( } // namespace EncoderStreamFactory::EncoderStreamFactory( - const webrtc::VideoEncoder::EncoderInfo& encoder_info, + const VideoEncoder::EncoderInfo& encoder_info, std::optional restrictions) : encoder_info_requested_resolution_alignment_( encoder_info.requested_resolution_alignment), @@ -285,7 +295,7 @@ std::vector EncoderStreamFactory::CreateEncoderStreams( std::vector streams; if (is_simulcast || - webrtc::SimulcastUtility::IsConferenceModeScreenshare(encoder_config)) { + SimulcastUtility::IsConferenceModeScreenshare(encoder_config)) { streams = CreateSimulcastOrConferenceModeScreenshareStreams( trials, frame_width, frame_height, encoder_config, experimental_min_bitrate); @@ -307,8 +317,8 @@ std::vector EncoderStreamFactory::CreateDefaultVideoStreams( int height, const VideoEncoderConfig& encoder_config, const std::optional& experimental_min_bitrate) const { - bool is_screencast = encoder_config.content_type == - webrtc::VideoEncoderConfig::ContentType::kScreen; + bool is_screencast = + encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen; // The max bitrate specified by the API. // - `encoder_config.simulcast_layers[0].max_bitrate_bps` comes from the first @@ -335,8 +345,8 @@ std::vector EncoderStreamFactory::CreateDefaultVideoStreams( int min_bitrate_bps = experimental_min_bitrate - ? webrtc::saturated_cast(experimental_min_bitrate->bps()) - : webrtc::kDefaultMinVideoBitrateBps; + ? saturated_cast(experimental_min_bitrate->bps()) + : kDefaultMinVideoBitrateBps; if (encoder_config.simulcast_layers[0].min_bitrate_bps > 0) { // Use set min bitrate. min_bitrate_bps = encoder_config.simulcast_layers[0].min_bitrate_bps; @@ -377,7 +387,7 @@ std::vector EncoderStreamFactory::CreateDefaultVideoStreams( kMinLayerSize); } - if (encoder_config.codec_type == webrtc::VideoCodecType::kVideoCodecVP9) { + if (encoder_config.codec_type == VideoCodecType::kVideoCodecVP9) { RTC_DCHECK(encoder_config.encoder_specific_settings); // Use VP9 SVC layering from codec settings which might be initialized // though field trial in ConfigureVideoEncoderSettings. @@ -396,12 +406,12 @@ std::vector EncoderStreamFactory::CreateDefaultVideoStreams( (layer.num_temporal_layers > 1u || num_spatial_layers > 1)) { // In SVC mode, the VP9 max bitrate is determined by SvcConfig, instead of // GetMaxDefaultVideoBitrateKbps(). - std::vector svc_layers = - webrtc::GetSvcConfig(width, height, max_framerate, - /*first_active_layer=*/0, num_spatial_layers, - *layer.num_temporal_layers, is_screencast); + std::vector svc_layers = + GetSvcConfig(width, height, max_framerate, + /*first_active_layer=*/0, num_spatial_layers, + *layer.num_temporal_layers, is_screencast); int sum_max_bitrates_kbps = 0; - for (const webrtc::SpatialLayer& spatial_layer : svc_layers) { + for (const SpatialLayer& spatial_layer : svc_layers) { sum_max_bitrates_kbps += spatial_layer.maxBitrate; } RTC_DCHECK_GE(sum_max_bitrates_kbps, 0); @@ -457,9 +467,9 @@ EncoderStreamFactory::CreateSimulcastOrConferenceModeScreenshareStreams( // Use legacy simulcast screenshare if conference mode is explicitly enabled // or use the regular simulcast configuration path which is generic. - std::vector layers = webrtc::GetSimulcastConfig( + std::vector layers = GetSimulcastConfig( resolutions, - webrtc::SimulcastUtility::IsConferenceModeScreenshare(encoder_config), + SimulcastUtility::IsConferenceModeScreenshare(encoder_config), IsTemporalLayersSupported(encoder_config.codec_type), trials, encoder_config.codec_type); @@ -498,8 +508,8 @@ Resolution EncoderStreamFactory::GetLayerResolutionFromScaleResolutionDownTo( VideoSinkWants wants; wants.is_active = true; wants.target_pixel_count = restrictions_->target_pixels_per_frame(); - wants.max_pixel_count = webrtc::dchecked_cast( - restrictions_->max_pixels_per_frame().value_or( + wants.max_pixel_count = + dchecked_cast(restrictions_->max_pixels_per_frame().value_or( std::numeric_limits::max())); wants.aggregates.emplace(VideoSinkWants::Aggregates()); wants.resolution_alignment = encoder_info_requested_resolution_alignment_; @@ -521,7 +531,7 @@ std::vector EncoderStreamFactory::GetStreamResolutions( int height, const VideoEncoderConfig& encoder_config) const { std::vector resolutions; - if (webrtc::SimulcastUtility::IsConferenceModeScreenshare(encoder_config)) { + if (SimulcastUtility::IsConferenceModeScreenshare(encoder_config)) { for (size_t i = 0; i < encoder_config.number_of_streams; ++i) { resolutions.push_back({.width = width, .height = height}); } @@ -529,7 +539,7 @@ std::vector EncoderStreamFactory::GetStreamResolutions( size_t min_num_layers = FindRequiredActiveLayers(encoder_config); size_t max_num_layers = !encoder_config.HasScaleResolutionDownTo() - ? webrtc::LimitSimulcastLayerCount( + ? LimitSimulcastLayerCount( min_num_layers, encoder_config.number_of_streams, width, height, trials, encoder_config.codec_type) : encoder_config.number_of_streams; @@ -545,8 +555,8 @@ std::vector EncoderStreamFactory::GetStreamResolutions( if (encoder_config.HasScaleResolutionDownTo() && restrictions_.has_value() && restrictions_->max_pixels_per_frame().has_value()) { - int max_pixels = webrtc::dchecked_cast( - restrictions_->max_pixels_per_frame().value()); + int max_pixels = + dchecked_cast(restrictions_->max_pixels_per_frame().value()); int prev_pixel_count = encoder_config.simulcast_layers[0] .scale_resolution_down_to.value_or(Resolution()) @@ -581,8 +591,7 @@ std::vector EncoderStreamFactory::GetStreamResolutions( } const bool norm_size_configured = - webrtc::NormalizeSimulcastSizeExperiment::GetBase2Exponent(trials) - .has_value(); + NormalizeSimulcastSizeExperiment::GetBase2Exponent(trials).has_value(); const int normalized_width = (default_scale_factors_used || norm_size_configured) && (width >= kMinLayerSize) diff --git a/video/config/encoder_stream_factory.h b/video/config/encoder_stream_factory.h index 192aac6113..abf196bdae 100644 --- a/video/config/encoder_stream_factory.h +++ b/video/config/encoder_stream_factory.h @@ -10,11 +10,12 @@ #ifndef VIDEO_CONFIG_ENCODER_STREAM_FACTORY_H_ #define VIDEO_CONFIG_ENCODER_STREAM_FACTORY_H_ -#include +#include #include #include "api/field_trials_view.h" #include "api/units/data_rate.h" +#include "api/video/resolution.h" #include "api/video_codecs/video_encoder.h" #include "call/adaptation/video_source_restrictions.h" #include "video/config/video_encoder_config.h" diff --git a/video/config/encoder_stream_factory_unittest.cc b/video/config/encoder_stream_factory_unittest.cc index a36efaab01..5c93527282 100644 --- a/video/config/encoder_stream_factory_unittest.cc +++ b/video/config/encoder_stream_factory_unittest.cc @@ -42,7 +42,6 @@ using ::testing::Not; using ::testing::SizeIs; using ::testing::TestWithParam; using ::testing::Values; -using ::webrtc::EncoderStreamFactory; struct CreateVideoStreamParams { int width = 0; @@ -482,7 +481,7 @@ INSTANTIATE_TEST_SUITE_P( .scalability_mode = ScalabilityMode::kL1T2})}}), Values( #ifdef RTC_ENABLE_H265 - webrtc::kVideoCodecH265, + kVideoCodecH265, #endif VideoCodecType::kVideoCodecAV1, VideoCodecType::kVideoCodecVP9))); diff --git a/video/config/simulcast.cc b/video/config/simulcast.cc index 66e9005282..acc2e15d51 100644 --- a/video/config/simulcast.cc +++ b/video/config/simulcast.cc @@ -37,7 +37,6 @@ namespace webrtc { namespace { -using ::webrtc::FieldTrialsView; constexpr char kUseLegacySimulcastLayerLimitFieldTrial[] = "WebRTC-LegacySimulcastLayerLimit"; @@ -47,16 +46,16 @@ constexpr double kDefaultMaxRoundupRate = 0.1; // Limits for legacy conference screensharing mode. Currently used for the // lower of the two simulcast streams. constexpr DataRate kScreenshareDefaultTl0Bitrate = - webrtc::DataRate::KilobitsPerSec(200); + DataRate::KilobitsPerSec(200); constexpr DataRate kScreenshareDefaultTl1Bitrate = - webrtc::DataRate::KilobitsPerSec(1000); + DataRate::KilobitsPerSec(1000); // Min/max bitrate for the higher one of the two simulcast stream used for // screen content. constexpr DataRate kScreenshareHighStreamMinBitrate = - webrtc::DataRate::KilobitsPerSec(600); + DataRate::KilobitsPerSec(600); constexpr DataRate kScreenshareHighStreamMaxBitrate = - webrtc::DataRate::KilobitsPerSec(1250); + DataRate::KilobitsPerSec(1250); constexpr int kDefaultNumTemporalLayers = 3; constexpr int kScreenshareMaxSimulcastLayers = 2; @@ -83,62 +82,47 @@ struct SimulcastFormat { // simulcast layers at what bitrates (maximum, target, and minimum). // Important!! Keep this table from high resolution to low resolution. constexpr const SimulcastFormat kSimulcastFormatsVP8[] = { - {1920, 1080, 3, webrtc::DataRate::KilobitsPerSec(5000), - webrtc::DataRate::KilobitsPerSec(4000), - webrtc::DataRate::KilobitsPerSec(800)}, - {1280, 720, 3, webrtc::DataRate::KilobitsPerSec(2500), - webrtc::DataRate::KilobitsPerSec(2500), - webrtc::DataRate::KilobitsPerSec(600)}, - {960, 540, 3, webrtc::DataRate::KilobitsPerSec(1200), - webrtc::DataRate::KilobitsPerSec(1200), - webrtc::DataRate::KilobitsPerSec(350)}, - {640, 360, 2, webrtc::DataRate::KilobitsPerSec(700), - webrtc::DataRate::KilobitsPerSec(500), - webrtc::DataRate::KilobitsPerSec(150)}, - {480, 270, 2, webrtc::DataRate::KilobitsPerSec(450), - webrtc::DataRate::KilobitsPerSec(350), - webrtc::DataRate::KilobitsPerSec(150)}, - {320, 180, 1, webrtc::DataRate::KilobitsPerSec(200), - webrtc::DataRate::KilobitsPerSec(150), - webrtc::DataRate::KilobitsPerSec(30)}, + {1920, 1080, 3, DataRate::KilobitsPerSec(5000), + DataRate::KilobitsPerSec(4000), DataRate::KilobitsPerSec(800)}, + {1280, 720, 3, DataRate::KilobitsPerSec(2500), + DataRate::KilobitsPerSec(2500), DataRate::KilobitsPerSec(600)}, + {960, 540, 3, DataRate::KilobitsPerSec(1200), + DataRate::KilobitsPerSec(1200), DataRate::KilobitsPerSec(350)}, + {640, 360, 2, DataRate::KilobitsPerSec(700), DataRate::KilobitsPerSec(500), + DataRate::KilobitsPerSec(150)}, + {480, 270, 2, DataRate::KilobitsPerSec(450), DataRate::KilobitsPerSec(350), + DataRate::KilobitsPerSec(150)}, + {320, 180, 1, DataRate::KilobitsPerSec(200), DataRate::KilobitsPerSec(150), + DataRate::KilobitsPerSec(30)}, // As the resolution goes down, interpolate the target and max bitrates down // towards zero. The min bitrate is still limited at 30 kbps and the target // and the max will be capped from below accordingly. - {0, 0, 1, webrtc::DataRate::KilobitsPerSec(0), - webrtc::DataRate::KilobitsPerSec(0), - webrtc::DataRate::KilobitsPerSec(30)}}; + {0, 0, 1, DataRate::KilobitsPerSec(0), DataRate::KilobitsPerSec(0), + DataRate::KilobitsPerSec(30)}}; // These tables describe from which resolution we can use how many // simulcast layers at what bitrates (maximum, target, and minimum). // Important!! Keep this table from high resolution to low resolution. constexpr const SimulcastFormat kSimulcastFormatsVP9[] = { - {1920, 1080, 3, webrtc::DataRate::KilobitsPerSec(3367), - webrtc::DataRate::KilobitsPerSec(3367), - webrtc::DataRate::KilobitsPerSec(769)}, - {1280, 720, 3, webrtc::DataRate::KilobitsPerSec(1524), - webrtc::DataRate::KilobitsPerSec(1524), - webrtc::DataRate::KilobitsPerSec(481)}, - {960, 540, 3, webrtc::DataRate::KilobitsPerSec(879), - webrtc::DataRate::KilobitsPerSec(879), - webrtc::DataRate::KilobitsPerSec(337)}, - {640, 360, 2, webrtc::DataRate::KilobitsPerSec(420), - webrtc::DataRate::KilobitsPerSec(420), - webrtc::DataRate::KilobitsPerSec(193)}, - {480, 270, 2, webrtc::DataRate::KilobitsPerSec(257), - webrtc::DataRate::KilobitsPerSec(257), - webrtc::DataRate::KilobitsPerSec(121)}, - {320, 180, 1, webrtc::DataRate::KilobitsPerSec(142), - webrtc::DataRate::KilobitsPerSec(142), - webrtc::DataRate::KilobitsPerSec(30)}, - {240, 135, 1, webrtc::DataRate::KilobitsPerSec(101), - webrtc::DataRate::KilobitsPerSec(101), - webrtc::DataRate::KilobitsPerSec(30)}, + {1920, 1080, 3, DataRate::KilobitsPerSec(3367), + DataRate::KilobitsPerSec(3367), DataRate::KilobitsPerSec(769)}, + {1280, 720, 3, DataRate::KilobitsPerSec(1524), + DataRate::KilobitsPerSec(1524), DataRate::KilobitsPerSec(481)}, + {960, 540, 3, DataRate::KilobitsPerSec(879), DataRate::KilobitsPerSec(879), + DataRate::KilobitsPerSec(337)}, + {640, 360, 2, DataRate::KilobitsPerSec(420), DataRate::KilobitsPerSec(420), + DataRate::KilobitsPerSec(193)}, + {480, 270, 2, DataRate::KilobitsPerSec(257), DataRate::KilobitsPerSec(257), + DataRate::KilobitsPerSec(121)}, + {320, 180, 1, DataRate::KilobitsPerSec(142), DataRate::KilobitsPerSec(142), + DataRate::KilobitsPerSec(30)}, + {240, 135, 1, DataRate::KilobitsPerSec(101), DataRate::KilobitsPerSec(101), + DataRate::KilobitsPerSec(30)}, // As the resolution goes down, interpolate the target and max bitrates down // towards zero. The min bitrate is still limited at 30 kbps and the target // and the max will be capped from below accordingly. - {0, 0, 1, webrtc::DataRate::KilobitsPerSec(0), - webrtc::DataRate::KilobitsPerSec(0), - webrtc::DataRate::KilobitsPerSec(30)}}; + {0, 0, 1, DataRate::KilobitsPerSec(0), DataRate::KilobitsPerSec(0), + DataRate::KilobitsPerSec(30)}}; constexpr DataRate Interpolate(const DataRate& a, const DataRate& b, @@ -154,16 +138,16 @@ bool EnableLowresBitrateInterpolation(const FieldTrialsView& trials) { int GetDefaultSimulcastTemporalLayers(VideoCodecType codec) { switch (codec) { - case webrtc::kVideoCodecVP8: - case webrtc::kVideoCodecVP9: - case webrtc::kVideoCodecAV1: - case webrtc::kVideoCodecH264: - case webrtc::kVideoCodecGeneric: + case kVideoCodecVP8: + case kVideoCodecVP9: + case kVideoCodecAV1: + case kVideoCodecH264: + case kVideoCodecGeneric: return kDefaultNumTemporalLayers; // For codec type that has no software fallback, defaults to L1T1 for // initial simulcast setup, as this is the only scalability mode secure to // be supported. - case webrtc::kVideoCodecH265: + case kVideoCodecH265: return 1; } RTC_DCHECK_NOTREACHED() << "Unsupported codec."; @@ -175,15 +159,15 @@ std::vector GetSimulcastFormats( VideoCodecType codec) { std::vector formats; switch (codec) { - case webrtc::kVideoCodecGeneric: - case webrtc::kVideoCodecVP8: - case webrtc::kVideoCodecH264: + case kVideoCodecGeneric: + case kVideoCodecVP8: + case kVideoCodecH264: formats.insert(formats.begin(), std::begin(kSimulcastFormatsVP8), std::end(kSimulcastFormatsVP8)); break; - case webrtc::kVideoCodecVP9: - case webrtc::kVideoCodecAV1: - case webrtc::kVideoCodecH265: + case kVideoCodecVP9: + case kVideoCodecAV1: + case kVideoCodecH265: formats.insert(formats.begin(), std::begin(kSimulcastFormatsVP9), std::end(kSimulcastFormatsVP9)); break; @@ -323,7 +307,7 @@ std::vector GetScreenshareLayers(size_t max_layers, layers[0].width = width; layers[0].height = height; layers[0].max_framerate = 5; - layers[0].min_bitrate_bps = webrtc::kDefaultMinVideoBitrateBps; + layers[0].min_bitrate_bps = kDefaultMinVideoBitrateBps; layers[0].target_bitrate_bps = kScreenshareDefaultTl0Bitrate.bps(); layers[0].max_bitrate_bps = kScreenshareDefaultTl1Bitrate.bps(); layers[0].num_temporal_layers = temporal_layers_supported ? 2 : 1; @@ -340,7 +324,7 @@ std::vector GetScreenshareLayers(size_t max_layers, // layers were enabled. max_bitrate_bps = static_cast( kScreenshareHighStreamMaxBitrate.bps() * - webrtc::SimulcastRateAllocator::GetTemporalRateAllocation( + SimulcastRateAllocator::GetTemporalRateAllocation( kScreenshareTemporalLayers, 0, base_heavy_tl3_rate_alloc)); } else { // Experimental temporal layer mode used, use increased max bitrate. @@ -378,8 +362,8 @@ size_t LimitSimulcastLayerCount(size_t min_num_layers, // than configured `max_ratio`. pixels_down is the selected index in // kSimulcastFormats based on pixels. FieldTrialOptional max_ratio("max_ratio"); - webrtc::ParseFieldTrial({&max_ratio}, - trials.Lookup("WebRTC-SimulcastLayerLimitRoundUp")); + ParseFieldTrial({&max_ratio}, + trials.Lookup("WebRTC-SimulcastLayerLimitRoundUp")); size_t reduced_num_layers = std::max(min_num_layers, @@ -413,14 +397,14 @@ void BoostMaxSimulcastLayer(DataRate max_bitrate, DataRate GetTotalMaxBitrate(const std::vector& layers) { if (layers.empty()) - return webrtc::DataRate::Zero(); + return DataRate::Zero(); int total_max_bitrate_bps = 0; for (size_t s = 0; s < layers.size() - 1; ++s) { total_max_bitrate_bps += layers[s].target_bitrate_bps; } total_max_bitrate_bps += layers.back().max_bitrate_bps; - return webrtc::DataRate::BitsPerSec(total_max_bitrate_bps); + return DataRate::BitsPerSec(total_max_bitrate_bps); } std::vector GetSimulcastConfig( diff --git a/video/config/simulcast.h b/video/config/simulcast.h index 1a7f87c768..a8b9143ae7 100644 --- a/video/config/simulcast.h +++ b/video/config/simulcast.h @@ -19,6 +19,7 @@ #include "api/field_trials_view.h" #include "api/units/data_rate.h" #include "api/video/resolution.h" +#include "api/video/video_codec_type.h" #include "video/config/video_encoder_config.h" namespace webrtc { diff --git a/video/config/simulcast_unittest.cc b/video/config/simulcast_unittest.cc index 94b48fea56..628e4ea131 100644 --- a/video/config/simulcast_unittest.cc +++ b/video/config/simulcast_unittest.cc @@ -73,7 +73,7 @@ const std::vector GetH265SimulcastBitrates720p() { std::vector CreateResolutions(int max_width, int max_height, int num_streams) { - std::vector resolutions(num_streams); + std::vector resolutions(num_streams); for (int i = 0; i < num_streams; ++i) { resolutions[i].width = max_width >> (num_streams - i - 1); resolutions[i].height = max_height >> (num_streams - i - 1); @@ -107,10 +107,10 @@ TEST(SimulcastTest, BandwidthAboveTotalMaxBitrateGivenToHighestStream) { streams[1].target_bitrate_bps = 200000; streams[2].max_bitrate_bps = 400000; - const webrtc::DataRate one_bps = webrtc::DataRate::BitsPerSec(1); + const DataRate one_bps = DataRate::BitsPerSec(1); // No bitrate above the total max to give to the highest stream. - const webrtc::DataRate max_total_bitrate = GetTotalMaxBitrate(streams); + const DataRate max_total_bitrate = GetTotalMaxBitrate(streams); BoostMaxSimulcastLayer(max_total_bitrate, &streams); EXPECT_EQ(400000, streams[2].max_bitrate_bps); EXPECT_EQ(max_total_bitrate, GetTotalMaxBitrate(streams)); @@ -129,7 +129,7 @@ TEST(SimulcastTest, GetConfig) { const size_t kMaxLayers = 3; std::vector streams = GetSimulcastConfig(CreateResolutions(1280, 720, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(kMaxLayers)); EXPECT_EQ(320u, streams[0].width); @@ -157,7 +157,7 @@ TEST(SimulcastTest, GetConfigH265) { const size_t kMaxLayers = 3; std::vector streams = GetSimulcastConfig(CreateResolutions(1280, 720, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecH265); + !kScreenshare, true, trials, kVideoCodecH265); ASSERT_THAT(streams, SizeIs(kMaxLayers)); EXPECT_EQ(320u, streams[0].width); @@ -188,7 +188,7 @@ TEST(SimulcastTest, GetConfigWithBaseHeavyVP8TL3RateAllocation) { const size_t kMaxLayers = 3; std::vector streams = GetSimulcastConfig(CreateResolutions(1280, 720, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(kMaxLayers)); EXPECT_EQ(kExpected[0].min_bitrate_bps, streams[0].min_bitrate_bps); @@ -209,7 +209,7 @@ TEST(SimulcastTest, GetConfigWithLimitedMaxLayers) { const size_t kMaxLayers = 2; std::vector streams = GetSimulcastConfig(CreateResolutions(1280, 720, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(kMaxLayers)); EXPECT_EQ(640u, streams[0].width); @@ -224,7 +224,7 @@ TEST(SimulcastTest, GetConfigForScreenshareSimulcast) { std::vector{{.width = 1400, .height = 800}, {.width = 1400, .height = 800}, {.width = 1400, .height = 800}}, - kScreenshare, true, trials, webrtc::kVideoCodecVP8); + kScreenshare, true, trials, kVideoCodecVP8); EXPECT_THAT(streams, SizeIs(2)); for (size_t i = 0; i < streams.size(); ++i) { @@ -244,7 +244,7 @@ TEST(SimulcastTest, GetConfigForScreenshareSimulcastWithLimitedMaxLayers) { ExplicitKeyValueConfig trials(""); std::vector streams = GetSimulcastConfig( std::vector{{.width = 1400, .height = 800}}, kScreenshare, - true, trials, webrtc::kVideoCodecVP8); + true, trials, kVideoCodecVP8); EXPECT_THAT(streams, SizeIs(1)); } @@ -252,7 +252,7 @@ TEST(SimulcastTest, AveragesBitratesForNonStandardResolution) { ExplicitKeyValueConfig trials(""); std::vector streams = GetSimulcastConfig(std::vector{{.width = 900, .height = 800}}, - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(1)); EXPECT_EQ(900u, streams[0].width); @@ -273,7 +273,7 @@ TEST(SimulcastTest, BitratesForCloseToStandardResolution) { std::vector streams = GetSimulcastConfig(CreateResolutions(kWidth, kHeight, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(kMaxLayers)); EXPECT_EQ(kWidth, streams[2].width); @@ -296,18 +296,18 @@ TEST(SimulcastTest, MaxLayersWithRoundUpDisabled) { const int kMaxLayers = 3; size_t num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 960, 540, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 3u); // <960x540: 2 layers num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 960, 539, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 2u); num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 270, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 2u); // <480x270: 1 layer num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 269, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 1u); } @@ -318,24 +318,24 @@ TEST(SimulcastTest, MaxLayersWithDefaultRoundUpRatio) { const int kMaxLayers = 3; size_t num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 960, 540, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 3u); // Lowest cropped height where max layers from higher resolution is used. num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 960, 512, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 3u); num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 960, 508, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 2u); num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 270, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 2u); // Lowest cropped height where max layers from higher resolution is used. num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 256, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 2u); num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 254, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 1u); } @@ -347,14 +347,14 @@ TEST(SimulcastTest, MaxLayersWithRoundUpRatio) { const int kMaxLayers = 3; size_t num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 270, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 2u); // Lowest cropped height where max layers from higher resolution is used. num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 252, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 2u); num_layers = LimitSimulcastLayerCount(kMinLayers, kMaxLayers, 480, 250, - trials, webrtc::kVideoCodecVP8); + trials, kVideoCodecVP8); EXPECT_EQ(num_layers, 1u); } @@ -366,7 +366,7 @@ TEST(SimulcastTest, BitratesInterpolatedForResBelow180p) { const size_t kMaxLayers = 3; std::vector streams = GetSimulcastConfig( CreateResolutions(/*max_width=*/960, /*max_height=*/540, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(kMaxLayers)); EXPECT_EQ(240u, streams[0].width); @@ -383,7 +383,7 @@ TEST(SimulcastTest, BitratesConsistentForVerySmallRes) { std::vector streams = GetSimulcastConfig(std::vector{{.width = 1, .height = 1}}, - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(1)); EXPECT_EQ(1u, streams[0].width); @@ -401,7 +401,7 @@ TEST(SimulcastTest, const size_t kMaxLayers = 3; std::vector streams = GetSimulcastConfig( CreateResolutions(/*max_width=*/960, /*max_height=*/540, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecVP8); + !kScreenshare, true, trials, kVideoCodecVP8); ASSERT_THAT(streams, SizeIs(kMaxLayers)); EXPECT_EQ(240u, streams[0].width); @@ -419,10 +419,10 @@ struct BitrateLimitsTestParams { }; using BitrateLimitsTest = - TestWithParam>; + TestWithParam>; TEST_P(BitrateLimitsTest, VerifyBitrateLimits) { - const auto codec_type = std::get(GetParam()); + const auto codec_type = std::get(GetParam()); const auto test_params = std::get(GetParam()); ExplicitKeyValueConfig trials(""); std::vector streams = GetSimulcastConfig( @@ -442,7 +442,7 @@ TEST_P(BitrateLimitsTest, VerifyBitrateLimits) { INSTANTIATE_TEST_SUITE_P( Vp8H264, BitrateLimitsTest, - Combine(Values(webrtc::kVideoCodecVP8, webrtc::kVideoCodecH264), + Combine(Values(kVideoCodecVP8, kVideoCodecH264), Values(BitrateLimitsTestParams{.width = 1920, .height = 1080, .expected_min_bitrate_kbps{150, 350, @@ -460,8 +460,7 @@ INSTANTIATE_TEST_SUITE_P( .expected_min_bitrate_kbps{30, 150, 350}, .expected_max_bitrate_kbps{200, 450, 1200}})), [](const TestParamInfo& info) { - return CodecTypeToPayloadString( - std::get(info.param)) + + return CodecTypeToPayloadString(std::get(info.param)) + std::to_string( std::get(info.param).height); }); @@ -472,10 +471,10 @@ INSTANTIATE_TEST_SUITE_P( Combine( Values( #ifdef RTC_ENABLE_H265 - webrtc::kVideoCodecH265, + kVideoCodecH265, #endif - webrtc::kVideoCodecAV1, - webrtc::kVideoCodecVP9), + kVideoCodecAV1, + kVideoCodecVP9), Values( BitrateLimitsTestParams{.width = 1920, .height = 1080, @@ -491,8 +490,7 @@ INSTANTIATE_TEST_SUITE_P( .expected_min_bitrate_kbps{30, 121, 337}, .expected_max_bitrate_kbps{101, 257, 879}})), [](const TestParamInfo& info) { - return CodecTypeToPayloadString( - std::get(info.param)) + + return CodecTypeToPayloadString(std::get(info.param)) + std::to_string( std::get(info.param).height); }); @@ -506,7 +504,7 @@ TEST(SimulcastTest, GetConfigForH265) { const size_t kMaxLayers = 3; std::vector streams = GetSimulcastConfig(CreateResolutions(1280, 720, kMaxLayers), - !kScreenshare, true, trials, webrtc::kVideoCodecH265); + !kScreenshare, true, trials, kVideoCodecH265); ASSERT_THAT(streams, SizeIs(kMaxLayers)); for (size_t i = 0; i < streams.size(); ++i) { diff --git a/video/config/video_encoder_config.cc b/video/config/video_encoder_config.cc index ca3b20e436..c354014d17 100644 --- a/video/config/video_encoder_config.cc +++ b/video/config/video_encoder_config.cc @@ -9,8 +9,12 @@ */ #include "video/config/video_encoder_config.h" +#include +#include #include +#include "api/video/video_codec_type.h" +#include "api/video_codecs/video_codec.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" diff --git a/video/config/video_encoder_config.h b/video/config/video_encoder_config.h index adb78c7706..7fda03ffa8 100644 --- a/video/config/video_encoder_config.h +++ b/video/config/video_encoder_config.h @@ -18,12 +18,14 @@ #include #include "api/field_trials_view.h" +#include "api/ref_count.h" #include "api/scoped_refptr.h" #include "api/video/resolution.h" +#include "api/video/video_codec_type.h" #include "api/video_codecs/scalability_mode.h" #include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/spatial_layer.h" #include "api/video_codecs/video_codec.h" -#include "rtc_base/ref_count.h" namespace webrtc { diff --git a/video/corruption_detection/BUILD.gn b/video/corruption_detection/BUILD.gn index f2beeadf21..eb24a228c7 100644 --- a/video/corruption_detection/BUILD.gn +++ b/video/corruption_detection/BUILD.gn @@ -74,6 +74,7 @@ rtc_library("frame_pair_corruption_score") { ":halton_frame_sampler", ":utils", "../../api:scoped_refptr", + "../../api/video:corruption_detection_filter_settings", "../../api/video:video_frame", "../../rtc_base:checks", "//third_party/abseil-cpp/absl/strings:string_view", @@ -124,6 +125,7 @@ rtc_library("utils") { deps = [ "../../api:scoped_refptr", "../../api/video:video_frame", + "../../rtc_base:checks", "//third_party/abseil-cpp/absl/strings:string_view", "//third_party/abseil-cpp/absl/strings:strings", ] diff --git a/video/corruption_detection/evaluation/BUILD.gn b/video/corruption_detection/evaluation/BUILD.gn index 7b95a3b207..20ad2dcad4 100644 --- a/video/corruption_detection/evaluation/BUILD.gn +++ b/video/corruption_detection/evaluation/BUILD.gn @@ -8,6 +8,17 @@ import("../../../webrtc.gni") +rtc_library("picture_pair_provider") { + testonly = true + sources = [ "picture_pair_provider.h" ] + deps = [ + ":test_clip", + "../../../api/units:data_rate", + "../../../api/video:video_frame", + "../../../test:fileutils", + ] +} + rtc_library("test_clip") { testonly = true sources = [ diff --git a/video/corruption_detection/evaluation/picture_pair_provider.h b/video/corruption_detection/evaluation/picture_pair_provider.h new file mode 100644 index 0000000000..df04295f78 --- /dev/null +++ b/video/corruption_detection/evaluation/picture_pair_provider.h @@ -0,0 +1,58 @@ +/* + * 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. + */ + +#ifndef VIDEO_CORRUPTION_DETECTION_EVALUATION_PICTURE_PAIR_PROVIDER_H_ +#define VIDEO_CORRUPTION_DETECTION_EVALUATION_PICTURE_PAIR_PROVIDER_H_ + +#include + +#include "api/units/data_rate.h" +#include "api/video/video_frame.h" +#include "test/testsupport/file_utils.h" +#include "video/corruption_detection/evaluation/test_clip.h" + +namespace webrtc { + +struct OriginalCompressedPicturePair { + const VideoFrame original_image; + // The corresponding compressed image, obtained through encoding and decoding + // with the QP value = `frame_average_qp`. + const VideoFrame compressed_image; + const int frame_average_qp = 0; +}; + +// Opens and reads one frame at a time from a raw video. Encodes and decodes +// this frame (to obtain a compressed frame) based on the provided bitrate. +// The original and compressed frame is returned with the `GetNextPicturePair()` +// method together with the corresponding average QP value for that frame. +class PicturePairProvider { + public: + PicturePairProvider() = default; + virtual ~PicturePairProvider() = default; + + // Configures the provider such that `GetNextPicturePair()` can provide an + // original and compressed frame. + // Inputs: + // `clip` indicates the test clip's path, codec_mode, resolution and + // framerate. + // `bitrate` the maximum bitrate allowed for encoding a raw video. + virtual bool Configure(const TestClip& clip, DataRate bitrate) = 0; + + // Encodes and decodes the next frame based on the parameters given in the + // `Configure()`. + // Returns: + // `OriginalCompressedPicturePair` structure, with the original and + // compressed frames and the mean QP of the frame in focus. + virtual std::optional GetNextPicturePair() = 0; +}; + +} // namespace webrtc + +#endif // VIDEO_CORRUPTION_DETECTION_EVALUATION_PICTURE_PAIR_PROVIDER_H_ diff --git a/video/corruption_detection/frame_instrumentation_generator_unittest.cc b/video/corruption_detection/frame_instrumentation_generator_unittest.cc index d4362c012d..fff4cb497c 100644 --- a/video/corruption_detection/frame_instrumentation_generator_unittest.cc +++ b/video/corruption_detection/frame_instrumentation_generator_unittest.cc @@ -685,7 +685,7 @@ TEST(FrameInstrumentationGeneratorTest, QueuesAtMostThreeInputFrames) { VideoCodecType::kVideoCodecVP8); bool frames_destroyed[4] = {}; - class TestBuffer : public webrtc::I420Buffer { + class TestBuffer : public I420Buffer { public: TestBuffer(int width, int height, bool* frame_destroyed_indicator) : I420Buffer(width, height), diff --git a/video/corruption_detection/frame_pair_corruption_score.cc b/video/corruption_detection/frame_pair_corruption_score.cc index 91b789cb5e..a6d21c23e9 100644 --- a/video/corruption_detection/frame_pair_corruption_score.cc +++ b/video/corruption_detection/frame_pair_corruption_score.cc @@ -15,6 +15,7 @@ #include "absl/strings/string_view.h" #include "api/scoped_refptr.h" +#include "api/video/corruption_detection_filter_settings.h" #include "api/video/i420_buffer.h" #include "api/video/video_frame_buffer.h" #include "rtc_base/checks.h" diff --git a/video/corruption_detection/frame_pair_corruption_score_unittest.cc b/video/corruption_detection/frame_pair_corruption_score_unittest.cc index cf6de29bda..55ac374d09 100644 --- a/video/corruption_detection/frame_pair_corruption_score_unittest.cc +++ b/video/corruption_detection/frame_pair_corruption_score_unittest.cc @@ -18,7 +18,6 @@ #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" #include "api/video/video_frame_buffer.h" -#include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" #include "test/testsupport/frame_reader.h" diff --git a/video/corruption_detection/generic_mapping_functions.cc b/video/corruption_detection/generic_mapping_functions.cc index 9c75a50281..7dcbfedfef 100644 --- a/video/corruption_detection/generic_mapping_functions.cc +++ b/video/corruption_detection/generic_mapping_functions.cc @@ -12,6 +12,7 @@ #include +#include "api/video/corruption_detection_filter_settings.h" #include "api/video/video_codec_type.h" #include "api/video_codecs/video_codec.h" #include "rtc_base/checks.h" diff --git a/video/corruption_detection/utils.cc b/video/corruption_detection/utils.cc index b213dfb509..b213349c39 100644 --- a/video/corruption_detection/utils.cc +++ b/video/corruption_detection/utils.cc @@ -12,9 +12,11 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" +#include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" #include "api/video/video_codec_type.h" #include "api/video/video_frame_buffer.h" +#include "rtc_base/checks.h" namespace webrtc { namespace { diff --git a/video/decode_synchronizer.cc b/video/decode_synchronizer.cc index 94c4902c78..db012822fc 100644 --- a/video/decode_synchronizer.cc +++ b/video/decode_synchronizer.cc @@ -10,17 +10,21 @@ #include "video/decode_synchronizer.h" -#include +#include #include +#include #include -#include +#include "api/metronome/metronome.h" #include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" +#include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/trace_event.h" +#include "system_wrappers/include/clock.h" #include "video/frame_decode_scheduler.h" #include "video/frame_decode_timing.h" diff --git a/video/decode_synchronizer.h b/video/decode_synchronizer.h index d441fa0543..821ebfc2b6 100644 --- a/video/decode_synchronizer.h +++ b/video/decode_synchronizer.h @@ -13,18 +13,16 @@ #include -#include #include #include #include -#include #include "api/metronome/metronome.h" -#include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "api/units/timestamp.h" -#include "rtc_base/checks.h" #include "rtc_base/thread_annotations.h" +#include "system_wrappers/include/clock.h" #include "video/frame_decode_scheduler.h" #include "video/frame_decode_timing.h" diff --git a/video/decode_synchronizer_unittest.cc b/video/decode_synchronizer_unittest.cc index 78adc77c7f..a725f51aa9 100644 --- a/video/decode_synchronizer_unittest.cc +++ b/video/decode_synchronizer_unittest.cc @@ -12,12 +12,16 @@ #include +#include #include #include #include "absl/functional/any_invocable.h" +#include "api/metronome/metronome.h" #include "api/metronome/test/fake_metronome.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" diff --git a/video/encoder_bitrate_adjuster.cc b/video/encoder_bitrate_adjuster.cc index 8176e65822..babef538e1 100644 --- a/video/encoder_bitrate_adjuster.cc +++ b/video/encoder_bitrate_adjuster.cc @@ -11,14 +11,30 @@ #include "video/encoder_bitrate_adjuster.h" #include +#include +#include #include +#include #include #include "api/field_trials_view.h" +#include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "api/video/video_bitrate_allocation.h" +#include "api/video/video_codec_constants.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" #include "modules/video_coding/svc/scalability_mode_util.h" +#include "rtc_base/checks.h" #include "rtc_base/experiments/rate_control_settings.h" #include "rtc_base/logging.h" #include "rtc_base/time_utils.h" +#include "system_wrappers/include/clock.h" +#include "video/encoder_overshoot_detector.h" +#include "video/rate_utilization_tracker.h" namespace webrtc { namespace { diff --git a/video/encoder_bitrate_adjuster.h b/video/encoder_bitrate_adjuster.h index 9248b0d5eb..3f43047f9c 100644 --- a/video/encoder_bitrate_adjuster.h +++ b/video/encoder_bitrate_adjuster.h @@ -11,12 +11,18 @@ #ifndef VIDEO_ENCODER_BITRATE_ADJUSTER_H_ #define VIDEO_ENCODER_BITRATE_ADJUSTER_H_ +#include +#include #include +#include "absl/container/inlined_vector.h" #include "api/field_trials_view.h" +#include "api/units/data_size.h" #include "api/units/time_delta.h" -#include "api/video/encoded_image.h" #include "api/video/video_bitrate_allocation.h" +#include "api/video/video_codec_constants.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "system_wrappers/include/clock.h" #include "video/encoder_overshoot_detector.h" diff --git a/video/encoder_bitrate_adjuster_unittest.cc b/video/encoder_bitrate_adjuster_unittest.cc index 8d3195b892..642664a253 100644 --- a/video/encoder_bitrate_adjuster_unittest.cc +++ b/video/encoder_bitrate_adjuster_unittest.cc @@ -10,14 +10,25 @@ #include "video/encoder_bitrate_adjuster.h" +#include +#include +#include #include #include #include -#include "api/field_trials_view.h" #include "api/units/data_rate.h" -#include "rtc_base/logging.h" -#include "rtc_base/numerics/safe_conversions.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "api/video/video_bitrate_allocation.h" +#include "api/video/video_codec_constants.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/scalability_mode.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" +#include "rtc_base/checks.h" +#include "rtc_base/time_utils.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" diff --git a/video/encoder_overshoot_detector.cc b/video/encoder_overshoot_detector.cc index b9697f57de..b31b6be9ee 100644 --- a/video/encoder_overshoot_detector.cc +++ b/video/encoder_overshoot_detector.cc @@ -11,8 +11,14 @@ #include "video/encoder_overshoot_detector.h" #include +#include +#include +#include +#include #include +#include "api/units/data_rate.h" +#include "api/video/video_codec_type.h" #include "system_wrappers/include/metrics.h" namespace webrtc { diff --git a/video/encoder_overshoot_detector.h b/video/encoder_overshoot_detector.h index e78b601d1d..a36a45c144 100644 --- a/video/encoder_overshoot_detector.h +++ b/video/encoder_overshoot_detector.h @@ -11,11 +11,13 @@ #ifndef VIDEO_ENCODER_OVERSHOOT_DETECTOR_H_ #define VIDEO_ENCODER_OVERSHOOT_DETECTOR_H_ +#include +#include #include #include #include "api/units/data_rate.h" -#include "api/video_codecs/video_codec.h" +#include "api/video/video_codec_type.h" namespace webrtc { diff --git a/video/encoder_overshoot_detector_unittest.cc b/video/encoder_overshoot_detector_unittest.cc index 0712194a25..2dc8e4f24e 100644 --- a/video/encoder_overshoot_detector_unittest.cc +++ b/video/encoder_overshoot_detector_unittest.cc @@ -10,9 +10,15 @@ #include "video/encoder_overshoot_detector.h" +#include +#include #include #include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" +#include "api/video/video_codec_type.h" #include "rtc_base/fake_clock.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/metrics.h" diff --git a/video/encoder_rtcp_feedback.cc b/video/encoder_rtcp_feedback.cc index 42827e2df9..be8ee7a975 100644 --- a/video/encoder_rtcp_feedback.cc +++ b/video/encoder_rtcp_feedback.cc @@ -11,13 +11,24 @@ #include "video/encoder_rtcp_feedback.h" #include +#include +#include +#include +#include #include #include +#include #include "api/environment/environment.h" +#include "api/sequence_checker.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "api/video/video_frame_type.h" #include "api/video_codecs/video_encoder.h" +#include "modules/rtp_rtcp/source/rtp_sequence_number_map.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/keyframe_interval_settings.h" +#include "rtc_base/logging.h" #include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/video/encoder_rtcp_feedback.h b/video/encoder_rtcp_feedback.h index 29832dbd6d..6bea76f78c 100644 --- a/video/encoder_rtcp_feedback.h +++ b/video/encoder_rtcp_feedback.h @@ -10,6 +10,7 @@ #ifndef VIDEO_ENCODER_RTCP_FEEDBACK_H_ #define VIDEO_ENCODER_RTCP_FEEDBACK_H_ +#include #include #include @@ -17,9 +18,10 @@ #include "api/sequence_checker.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" -#include "call/rtp_video_sender_interface.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/rtp_rtcp/source/rtp_sequence_number_map.h" #include "rtc_base/system/no_unique_address.h" +#include "rtc_base/thread_annotations.h" #include "video/video_stream_encoder_interface.h" namespace webrtc { diff --git a/video/encoder_rtcp_feedback_unittest.cc b/video/encoder_rtcp_feedback_unittest.cc index 62140e81a8..c2ff40265b 100644 --- a/video/encoder_rtcp_feedback_unittest.cc +++ b/video/encoder_rtcp_feedback_unittest.cc @@ -10,9 +10,12 @@ #include "video/encoder_rtcp_feedback.h" -#include +#include +#include #include "api/environment/environment_factory.h" +#include "api/video/video_frame_type.h" +#include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" #include "video/test/mock_video_stream_encoder.h" diff --git a/video/end_to_end_tests/bandwidth_tests.cc b/video/end_to_end_tests/bandwidth_tests.cc index 82643ef59d..b073e6745d 100644 --- a/video/end_to_end_tests/bandwidth_tests.cc +++ b/video/end_to_end_tests/bandwidth_tests.cc @@ -8,30 +8,45 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include +#include +#include +#include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/rtp_headers.h" +#include "api/rtp_parameters.h" #include "api/task_queue/task_queue_base.h" #include "api/test/simulated_network.h" +#include "api/transport/bitrate_settings.h" #include "api/units/time_delta.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" #include "api/video/video_bitrate_allocation.h" -#include "call/fake_network_pipe.h" +#include "api/video/video_bitrate_allocator_factory.h" +#include "call/call.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" +#include "rtc_base/checks.h" #include "rtc_base/rate_limiter.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" +#include "system_wrappers/include/field_trial.h" #include "test/call_test.h" #include "test/fake_encoder.h" #include "test/field_trial.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" #include "test/rtp_rtcp_observer.h" #include "test/video_encoder_proxy_factory.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { @@ -312,7 +327,7 @@ TEST_F(BandwidthEndToEndTest, RembWithSendSideBwe) { TEST_F(BandwidthEndToEndTest, ReportsSetEncoderRates) { // If these fields trial are on, we get lower bitrates than expected by this // test, due to the packetization overhead and encoder pushback. - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( std::string(field_trial::GetFieldTrialString()) + "WebRTC-VideoRateControl/bitrate_adjuster:false/"); class EncoderRateStatsTest : public test::EndToEndTest, @@ -377,7 +392,7 @@ TEST_F(BandwidthEndToEndTest, ReportsSetEncoderRates) { return; } } - SleepMs(1); + Thread::SleepMs(1); } FAIL() << "Timed out waiting for stats reporting the currently set bitrate."; @@ -388,7 +403,7 @@ TEST_F(BandwidthEndToEndTest, ReportsSetEncoderRates) { if (send_stream_->GetStats().target_media_bitrate_bps == 0) { return; } - SleepMs(1); + Thread::SleepMs(1); } FAIL() << "Timed out waiting for stats reporting zero bitrate."; } diff --git a/video/end_to_end_tests/call_operation_tests.cc b/video/end_to_end_tests/call_operation_tests.cc index 5b6662bb82..272f66196f 100644 --- a/video/end_to_end_tests/call_operation_tests.cc +++ b/video/end_to_end_tests/call_operation_tests.cc @@ -9,18 +9,21 @@ */ #include +#include +#include "api/rtp_parameters.h" #include "api/test/create_frame_generator.h" #include "api/test/frame_generator_interface.h" #include "api/test/simulated_network.h" -#include "call/fake_network_pipe.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "rtc_base/event.h" #include "rtc_base/task_queue_for_test.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" #include "test/call_test.h" -#include "test/field_trial.h" +#include "test/direct_transport.h" #include "test/frame_forwarder.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/null_transport.h" #include "test/video_test_constants.h" @@ -85,7 +88,7 @@ TEST_F(CallOperationEndToEndTest, RendersSingleDelayedFrame) { class Renderer : public VideoSinkInterface { public: void OnFrame(const VideoFrame& video_frame) override { - SleepMs(kRenderDelayMs); + Thread::SleepMs(kRenderDelayMs); event_.Set(); } diff --git a/video/end_to_end_tests/codec_tests.cc b/video/end_to_end_tests/codec_tests.cc index 446b2c784e..e1d440e06c 100644 --- a/video/end_to_end_tests/codec_tests.cc +++ b/video/end_to_end_tests/codec_tests.cc @@ -8,26 +8,35 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include +#include +#include #include "api/environment/environment.h" +#include "api/rtp_parameters.h" +#include "api/test/video/function_video_decoder_factory.h" #include "api/test/video/function_video_encoder_factory.h" #include "api/video/color_space.h" +#include "api/video/video_frame.h" #include "api/video/video_rotation.h" +#include "api/video/video_sink_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder_factory.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "common_video/test/utilities.h" -#include "media/base/codec.h" #include "media/base/media_constants.h" -#include "media/engine/internal_decoder_factory.h" -#include "media/engine/internal_encoder_factory.h" #include "modules/video_coding/codecs/h264/include/h264.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "modules/video_coding/codecs/vp9/include/vp9.h" #include "test/call_test.h" -#include "test/encoder_settings.h" #include "test/field_trial.h" +#include "test/frame_generator_capturer.h" #include "test/gtest.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { diff --git a/video/end_to_end_tests/corruption_detection_tests.cc b/video/end_to_end_tests/corruption_detection_tests.cc index 098d230622..3398929f16 100644 --- a/video/end_to_end_tests/corruption_detection_tests.cc +++ b/video/end_to_end_tests/corruption_detection_tests.cc @@ -23,7 +23,7 @@ #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "rtc_base/checks.h" #include "rtc_base/task_queue_for_test.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" #include "test/call_test.h" #include "test/gtest.h" #include "test/video_test_constants.h" @@ -91,7 +91,7 @@ TEST_F( constexpr int kMaxIterations = 200; bool corruption_score_reported = false; for (int i = 0; i < kMaxIterations; ++i) { - SleepMs(10); + Thread::SleepMs(10); VideoReceiveStreamInterface::Stats stats; SendTask(task_queue_, [&]() { ASSERT_EQ(receive_streams_.size(), 1u); diff --git a/video/end_to_end_tests/extended_reports_tests.cc b/video/end_to_end_tests/extended_reports_tests.cc index c595074fc6..2a37082f14 100644 --- a/video/end_to_end_tests/extended_reports_tests.cc +++ b/video/end_to_end_tests/extended_reports_tests.cc @@ -11,36 +11,30 @@ #include #include -#include #include #include -#include #include +#include "api/array_view.h" #include "api/rtp_headers.h" -#include "api/task_queue/task_queue_base.h" +#include "api/rtp_parameters.h" #include "api/test/simulated_network.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" +#include "api/video/video_codec_type.h" #include "api/video_codecs/sdp_video_format.h" -#include "call/call.h" -#include "call/fake_network_pipe.h" #include "call/rtp_config.h" -#include "call/simulated_packet_receiver.h" #include "call/video_receive_stream.h" #include "call/video_send_stream.h" -#include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h" #include "modules/rtp_rtcp/source/rtcp_packet/target_bitrate.h" #include "rtc_base/event.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" -#include "system_wrappers/include/clock.h" #include "test/call_test.h" -#include "test/field_trial.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" #include "test/rtp_rtcp_observer.h" +#include "test/scoped_key_value_config.h" #include "test/video_test_constants.h" #include "video/config/video_encoder_config.h" diff --git a/video/end_to_end_tests/fec_tests.cc b/video/end_to_end_tests/fec_tests.cc index 98a9d2a85a..ebad6fe165 100644 --- a/video/end_to_end_tests/fec_tests.cc +++ b/video/end_to_end_tests/fec_tests.cc @@ -8,25 +8,45 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include #include +#include +#include -#include "api/task_queue/task_queue_base.h" +#include "api/array_view.h" +#include "api/environment/environment.h" +#include "api/rtp_parameters.h" #include "api/test/simulated_network.h" #include "api/test/video/function_video_encoder_factory.h" -#include "call/fake_network_pipe.h" +#include "api/transport/bitrate_settings.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_rotation.h" +#include "api/video/video_sink_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_encoder.h" +#include "call/flexfec_receive_stream.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "media/engine/internal_decoder_factory.h" #include "modules/include/module_common_types_public.h" #include "modules/rtp_rtcp/source/byte_io.h" +#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" +#include "rtc_base/random.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" #include "test/call_test.h" -#include "test/field_trial.h" +#include "test/encoder_settings.h" +#include "test/frame_generator_capturer.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" using ::testing::Contains; using ::testing::Not; diff --git a/video/end_to_end_tests/frame_encryption_tests.cc b/video/end_to_end_tests/frame_encryption_tests.cc index 698d8c14c0..efdb1d8b3d 100644 --- a/video/end_to_end_tests/frame_encryption_tests.cc +++ b/video/end_to_end_tests/frame_encryption_tests.cc @@ -8,14 +8,29 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include + +#include "api/environment/environment.h" +#include "api/make_ref_counted.h" +#include "api/rtp_parameters.h" #include "api/test/fake_frame_decryptor.h" #include "api/test/fake_frame_encryptor.h" +#include "api/test/video/function_video_encoder_factory.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_encoder.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "media/engine/internal_decoder_factory.h" -#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "test/call_test.h" +#include "test/encoder_settings.h" #include "test/gtest.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { diff --git a/video/end_to_end_tests/histogram_tests.cc b/video/end_to_end_tests/histogram_tests.cc index 5f281e267f..65775f1a12 100644 --- a/video/end_to_end_tests/histogram_tests.cc +++ b/video/end_to_end_tests/histogram_tests.cc @@ -8,15 +8,31 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include +#include +#include +#include "api/array_view.h" +#include "api/environment/environment.h" +#include "api/rtp_parameters.h" #include "api/test/video/function_video_encoder_factory.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "test/call_test.h" #include "test/gtest.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { diff --git a/video/end_to_end_tests/multi_codec_receive_tests.cc b/video/end_to_end_tests/multi_codec_receive_tests.cc index c4e4479d3a..d958c7749d 100644 --- a/video/end_to_end_tests/multi_codec_receive_tests.cc +++ b/video/end_to_end_tests/multi_codec_receive_tests.cc @@ -8,22 +8,42 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include #include +#include +#include +#include +#include +#include "api/array_view.h" +#include "api/environment/environment.h" #include "api/test/simulated_network.h" +#include "api/test/video/function_video_decoder_factory.h" #include "api/test/video/function_video_encoder_factory.h" -#include "call/fake_network_pipe.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_decoder.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder.h" +#include "api/video_codecs/video_encoder_factory.h" +#include "call/video_receive_stream.h" #include "modules/include/module_common_types_public.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/video_coding/codecs/h264/include/h264.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "modules/video_coding/codecs/vp9/include/vp9.h" +#include "rtc_base/checks.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread_annotations.h" #include "test/call_test.h" +#include "test/encoder_settings.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" using ::testing::Contains; diff --git a/video/end_to_end_tests/multi_stream_tester.cc b/video/end_to_end_tests/multi_stream_tester.cc index 7d82085617..a9c423a3db 100644 --- a/video/end_to_end_tests/multi_stream_tester.cc +++ b/video/end_to_end_tests/multi_stream_tester.cc @@ -10,25 +10,39 @@ #include "video/end_to_end_tests/multi_stream_tester.h" +#include +#include #include +#include #include #include #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/rtp_parameters.h" #include "api/task_queue/task_queue_base.h" +#include "api/task_queue/task_queue_factory.h" #include "api/test/create_frame_generator.h" #include "api/test/simulated_network.h" #include "api/test/video/function_video_encoder_factory.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" +#include "api/video/video_bitrate_allocator_factory.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/sdp_video_format.h" +#include "call/call.h" +#include "call/call_config.h" #include "call/fake_network_pipe.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "media/engine/internal_decoder_factory.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "rtc_base/task_queue_for_test.h" -#include "test/call_test.h" +#include "test/direct_transport.h" #include "test/encoder_settings.h" +#include "test/frame_generator_capturer.h" #include "test/network/simulated_network.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { diff --git a/video/end_to_end_tests/multi_stream_tester.h b/video/end_to_end_tests/multi_stream_tester.h index 87200930f4..1a58247f78 100644 --- a/video/end_to_end_tests/multi_stream_tester.h +++ b/video/end_to_end_tests/multi_stream_tester.h @@ -11,13 +11,19 @@ #ifndef VIDEO_END_TO_END_TESTS_MULTI_STREAM_TESTER_H_ #define VIDEO_END_TO_END_TESTS_MULTI_STREAM_TESTER_H_ +#include +#include #include #include +#include "api/media_types.h" #include "api/task_queue/task_queue_base.h" #include "call/call.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "test/direct_transport.h" #include "test/frame_generator_capturer.h" +#include "video/config/video_encoder_config.h" namespace webrtc { // Test sets up a Call multiple senders with different resolutions and SSRCs. diff --git a/video/end_to_end_tests/multi_stream_tests.cc b/video/end_to_end_tests/multi_stream_tests.cc index 35f017758b..0a20b34b6f 100644 --- a/video/end_to_end_tests/multi_stream_tests.cc +++ b/video/end_to_end_tests/multi_stream_tests.cc @@ -14,6 +14,7 @@ #include #include +#include "api/units/time_delta.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "call/rtp_config.h" diff --git a/video/end_to_end_tests/network_state_tests.cc b/video/end_to_end_tests/network_state_tests.cc index 4def7097af..35b802b7e2 100644 --- a/video/end_to_end_tests/network_state_tests.cc +++ b/video/end_to_end_tests/network_state_tests.cc @@ -8,24 +8,40 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include +#include +#include "api/array_view.h" +#include "api/call/transport.h" +#include "api/environment/environment.h" #include "api/media_types.h" -#include "api/task_queue/default_task_queue_factory.h" +#include "api/rtp_headers.h" #include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_factory.h" #include "api/test/simulated_network.h" +#include "api/units/time_delta.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" +#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" +#include "call/call.h" #include "call/fake_network_pipe.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/rtp_rtcp/source/rtp_packet.h" +#include "rtc_base/event.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" -#include "system_wrappers/include/sleep.h" +#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "test/call_test.h" #include "test/fake_encoder.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_encoder_proxy_factory.h" +#include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { @@ -42,7 +58,8 @@ class NetworkStateEndToEndTest : public test::CallTest { return false; } - bool SendRtcp(ArrayView packet) override { + bool SendRtcp(ArrayView packet, + const PacketOptions& /* options */) override { ADD_FAILURE() << "Unexpected RTCP sent."; return false; } @@ -68,7 +85,8 @@ class NetworkStateEndToEndTest : public test::CallTest { return true; } - bool SendRtcp(ArrayView packet) override { + bool SendRtcp(ArrayView packet, + const PacketOptions& /* options */) override { MutexLock lock(&mutex_); need_rtcp_ = false; return true; @@ -107,7 +125,7 @@ void NetworkStateEndToEndTest::VerifyNewVideoSendStreamsRespectNetworkState( Start(); }); - SleepMs(kSilenceTimeoutMs); + Thread::SleepMs(kSilenceTimeoutMs); SendTask(task_queue(), [this]() { Stop(); @@ -134,7 +152,7 @@ void NetworkStateEndToEndTest::VerifyNewVideoReceiveStreamsRespectNetworkState( Start(); }); - SleepMs(kSilenceTimeoutMs); + Thread::SleepMs(kSilenceTimeoutMs); SendTask(task_queue(), [this]() { Stop(); diff --git a/video/end_to_end_tests/resolution_bitrate_limits_tests.cc b/video/end_to_end_tests/resolution_bitrate_limits_tests.cc index 128406249d..786535a4aa 100644 --- a/video/end_to_end_tests/resolution_bitrate_limits_tests.cc +++ b/video/end_to_end_tests/resolution_bitrate_limits_tests.cc @@ -8,18 +8,34 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - -#include "media/engine/webrtc_video_engine.h" +#include +#include +#include +#include +#include + +#include "api/environment/environment.h" +#include "api/make_ref_counted.h" +#include "api/units/data_rate.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video/video_source_interface.h" +#include "api/video_codecs/scalability_mode.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/video_coding/svc/scalability_mode_util.h" #include "rtc_base/experiments/encoder_info_settings.h" #include "test/call_test.h" #include "test/fake_encoder.h" #include "test/field_trial.h" +#include "test/frame_generator_capturer.h" #include "test/gtest.h" #include "test/video_encoder_proxy_factory.h" #include "test/video_test_constants.h" -#include "video/config/encoder_stream_factory.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace test { @@ -212,7 +228,7 @@ class InitEncodeTest : public test::EndToEndTest, }; TEST_P(ResolutionBitrateLimitsTest, LimitsApplied) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:921600," "min_start_bitrate_bps:0," @@ -256,7 +272,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, } TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, OneStreamLimitsAppliedForOneSpatialLayer) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:921600," "min_start_bitrate_bps:0," @@ -275,7 +291,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, OneStreamLimitsNotAppliedForMultipleSpatialLayers) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -308,7 +324,7 @@ TEST_P(ResolutionBitrateLimitsTest, EncodingsApplied) { } TEST_P(ResolutionBitrateLimitsTest, IntersectionApplied) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:921600," "min_start_bitrate_bps:0," @@ -327,7 +343,7 @@ TEST_P(ResolutionBitrateLimitsTest, IntersectionApplied) { } TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedMiddleActive) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -344,7 +360,7 @@ TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedMiddleActive) { } TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedMiddleActive) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -367,7 +383,7 @@ TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedMiddleActive) { } TEST_P(ResolutionBitrateLimitsTest, MinBitrateNotAboveEncodingMax) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -388,7 +404,7 @@ TEST_P(ResolutionBitrateLimitsTest, MinBitrateNotAboveEncodingMax) { } TEST_P(ResolutionBitrateLimitsTest, MaxBitrateNotBelowEncodingMin) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -448,7 +464,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, } TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedHighestActive) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -465,7 +481,7 @@ TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedHighestActive) { } TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedHighestActive) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -490,7 +506,7 @@ TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedHighestActive) { } TEST_P(ResolutionBitrateLimitsTest, LimitsNotAppliedLowestActive) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -511,7 +527,7 @@ TEST_P(ResolutionBitrateLimitsTest, LimitsNotAppliedLowestActive) { TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsAppliedForVp9OneSpatialLayer) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -531,7 +547,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsNotAppliedForVp9MultipleSpatialLayers) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -554,7 +570,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, OneStreamLimitsAppliedForAv1OneSpatialLayer) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:921600," "min_start_bitrate_bps:0," @@ -573,7 +589,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsAppliedForAv1SingleSpatialLayer) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -593,7 +609,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, EncodingMinMaxBitrateAppliedForAv1SingleSpatialLayer) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:921600," "min_start_bitrate_bps:0," @@ -615,7 +631,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsNotAppliedForAv1MultipleSpatialLayers) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," @@ -637,7 +653,7 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, } TEST_P(ResolutionBitrateLimitsTest, LimitsNotAppliedSimulcast) { - webrtc::test::ScopedFieldTrials field_trials( + test::ScopedFieldTrials field_trials( "WebRTC-GetEncoderInfoOverride/" "frame_size_pixels:230400|921600," "min_start_bitrate_bps:0|0," diff --git a/video/end_to_end_tests/retransmission_tests.cc b/video/end_to_end_tests/retransmission_tests.cc index 7c50a7c034..836a4a4598 100644 --- a/video/end_to_end_tests/retransmission_tests.cc +++ b/video/end_to_end_tests/retransmission_tests.cc @@ -8,25 +8,45 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - -#include "absl/algorithm/container.h" +#include +#include +#include +#include +#include +#include + +#include "api/array_view.h" +#include "api/call/transport.h" +#include "api/environment/environment.h" +#include "api/rtp_parameters.h" #include "api/task_queue/task_queue_base.h" -#include "api/test/simulated_network.h" #include "api/test/video/function_video_encoder_factory.h" #include "api/units/time_delta.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_rotation.h" +#include "api/video/video_sink_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" #include "call/fake_network_pipe.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" +#include "modules/rtp_rtcp/source/rtcp_packet/nack.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/event.h" #include "rtc_base/synchronization/mutex.h" -#include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread_annotations.h" #include "test/call_test.h" -#include "test/field_trial.h" +#include "test/frame_generator_capturer.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { @@ -166,7 +186,8 @@ TEST_F(RetransmissionEndToEndTest, ReceivesNackAndRetransmitsAudio) { nack.SetPacketIds(nack_list, 1); Buffer buffer = nack.Build(); - EXPECT_TRUE(receive_transport_->SendRtcp(buffer)); + EXPECT_TRUE( + receive_transport_->SendRtcp(buffer, /*packet_options=*/{})); } return SEND_PACKET; diff --git a/video/end_to_end_tests/rtp_rtcp_tests.cc b/video/end_to_end_tests/rtp_rtcp_tests.cc index e372a9408c..1e0f1d78bc 100644 --- a/video/end_to_end_tests/rtp_rtcp_tests.cc +++ b/video/end_to_end_tests/rtp_rtcp_tests.cc @@ -8,21 +8,47 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include +#include +#include #include - +#include +#include + +#include "api/array_view.h" +#include "api/call/transport.h" +#include "api/environment/environment.h" +#include "api/field_trials_view.h" +#include "api/make_ref_counted.h" +#include "api/rtp_headers.h" #include "api/test/simulated_network.h" +#include "api/test/video/function_video_encoder_factory.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/sdp_video_format.h" #include "call/fake_network_pipe.h" +#include "call/flexfec_receive_stream.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/include/module_common_types_public.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread_annotations.h" #include "test/call_test.h" +#include "test/encoder_settings.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { @@ -336,8 +362,8 @@ void RtpRtcpEndToEndTest::TestRtpStatePreservation( // to wait for a second for periodic Sender Report. rtcp::RapidResyncRequest force_send_sr_back_request; Buffer packet = force_send_sr_back_request.Build(); - static_cast(receive_transport_.get()) - ->SendRtcp(packet); + static_cast(receive_transport_.get()) + ->SendRtcp(packet, /*packet_options=*/{}); } CreateFrameGeneratorCapturer(30, 1280, 720); StartVideoSources(); diff --git a/video/end_to_end_tests/ssrc_tests.cc b/video/end_to_end_tests/ssrc_tests.cc index f7542ef002..469ea7e068 100644 --- a/video/end_to_end_tests/ssrc_tests.cc +++ b/video/end_to_end_tests/ssrc_tests.cc @@ -8,20 +8,34 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include #include +#include +#include +#include "api/array_view.h" +#include "api/rtp_parameters.h" +#include "api/task_queue/task_queue_base.h" #include "api/test/simulated_network.h" #include "call/fake_network_pipe.h" #include "call/packet_receiver.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "modules/rtp_rtcp/source/rtp_util.h" +#include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/event.h" #include "rtc_base/task_queue_for_test.h" #include "test/call_test.h" +#include "test/direct_transport.h" #include "test/gtest.h" #include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { class SsrcEndToEndTest : public test::CallTest { diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc index d06a98be71..13008f9878 100644 --- a/video/end_to_end_tests/stats_tests.cc +++ b/video/end_to_end_tests/stats_tests.cc @@ -8,27 +8,54 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include #include #include +#include +#include +#include +#include #include "absl/algorithm/container.h" +#include "api/array_view.h" +#include "api/environment/environment.h" +#include "api/rtp_headers.h" +#include "api/rtp_parameters.h" +#include "api/scoped_refptr.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "api/test/simulated_network.h" #include "api/test/video/function_video_encoder_factory.h" +#include "api/transport/bitrate_settings.h" +#include "api/units/time_delta.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "call/call.h" +#include "call/call_config.h" #include "call/fake_network_pipe.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/video_coding/include/video_coding_defines.h" +#include "rtc_base/checks.h" +#include "rtc_base/event.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "system_wrappers/include/metrics.h" -#include "system_wrappers/include/sleep.h" #include "test/call_test.h" +#include "test/fake_decoder.h" #include "test/fake_encoder.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { @@ -397,7 +424,7 @@ TEST_F(StatsEndToEndTest, TimingFramesAreReported) { } }); // Wait for at least one timing frame to be sent with 100ms grace period. - SleepMs(kDefaultTimingFramesDelayMs + 100); + Thread::SleepMs(kDefaultTimingFramesDelayMs + 100); // Check that timing frames are reported for each stream. SendTask(task_queue_, [&]() { for (const auto& receive_stream : receive_streams_) { @@ -748,7 +775,7 @@ TEST_F(StatsEndToEndTest, CallReportsRttForSender) { EXPECT_GE(stats.rtt_ms, kSendDelayMs + kReceiveDelayMs - kAllowedErrorMs); break; } - SleepMs(10); + Thread::SleepMs(10); } SendTask(task_queue(), [this]() { diff --git a/video/end_to_end_tests/transport_feedback_tests.cc b/video/end_to_end_tests/transport_feedback_tests.cc index 4f285f2b29..84f2d56d23 100644 --- a/video/end_to_end_tests/transport_feedback_tests.cc +++ b/video/end_to_end_tests/transport_feedback_tests.cc @@ -8,25 +8,46 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include #include +#include #include +#include "api/array_view.h" +#include "api/call/transport.h" #include "api/rtp_parameters.h" #include "api/task_queue/task_queue_base.h" +#include "api/test/simulated_network.h" +#include "api/transport/bitrate_settings.h" #include "api/units/time_delta.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" #include "call/call.h" #include "call/fake_network_pipe.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" +#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet.h" +#include "rtc_base/checks.h" +#include "rtc_base/event.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" #include "test/call_test.h" +#include "test/direct_transport.h" +#include "test/fake_videorenderer.h" #include "test/field_trial.h" +#include "test/frame_generator_capturer.h" #include "test/gtest.h" #include "test/network/simulated_network.h" #include "test/rtcp_packet_parser.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" #include "video/end_to_end_tests/multi_stream_tester.h" namespace webrtc { diff --git a/video/frame_cadence_adapter.cc b/video/frame_cadence_adapter.cc index 2ee785fd53..7e151f6d22 100644 --- a/video/frame_cadence_adapter.cc +++ b/video/frame_cadence_adapter.cc @@ -12,35 +12,37 @@ #include #include +#include #include #include #include +#include #include #include #include "absl/algorithm/container.h" -#include "absl/base/attributes.h" #include "absl/cleanup/cleanup.h" +#include "api/field_trials_view.h" +#include "api/metronome/metronome.h" +#include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "api/video/video_frame.h" +#include "api/video_track_source_constraints.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/race_checker.h" #include "rtc_base/rate_statistics.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/no_unique_address.h" -#include "rtc_base/system/unused.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/thread_annotations.h" -#include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" -#include "system_wrappers/include/ntp_time.h" namespace webrtc { namespace { diff --git a/video/frame_cadence_adapter.h b/video/frame_cadence_adapter.h index 2f97b5b49f..2d457a5f93 100644 --- a/video/frame_cadence_adapter.h +++ b/video/frame_cadence_adapter.h @@ -11,17 +11,18 @@ #ifndef VIDEO_FRAME_CADENCE_ADAPTER_H_ #define VIDEO_FRAME_CADENCE_ADAPTER_H_ +#include +#include #include +#include -#include "absl/base/attributes.h" #include "api/field_trials_view.h" #include "api/metronome/metronome.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" -#include "rtc_base/synchronization/mutex.h" -#include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/video/frame_cadence_adapter_unittest.cc b/video/frame_cadence_adapter_unittest.cc index fb1eefeb37..37f73eedfb 100644 --- a/video/frame_cadence_adapter_unittest.cc +++ b/video/frame_cadence_adapter_unittest.cc @@ -10,12 +10,16 @@ #include "video/frame_cadence_adapter.h" +#include #include +#include #include +#include #include -#include #include "absl/functional/any_invocable.h" +#include "api/field_trials_view.h" +#include "api/make_ref_counted.h" #include "api/metronome/test/fake_metronome.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/task_queue_base.h" @@ -24,14 +28,16 @@ #include "api/units/timestamp.h" #include "api/video/nv12_buffer.h" #include "api/video/video_frame.h" +#include "api/video_track_source_constraints.h" #include "rtc_base/event.h" #include "rtc_base/logging.h" #include "rtc_base/rate_statistics.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "system_wrappers/include/ntp_time.h" -#include "system_wrappers/include/sleep.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" @@ -1076,7 +1082,7 @@ TEST(FrameCadenceAdapterRealTimeTest, TimestampsDoNotDrift) { ++frame_counter; // Avoid the first OnFrame and sleep on the second. if (frame_counter == 2) { - SleepMs(kSleepMs); + Thread::SleepMs(kSleepMs); } else if (frame_counter == 3) { EXPECT_GE(incoming_frame.ntp_time_ms(), original_ntp_time_ms + kSleepMs); @@ -1128,7 +1134,7 @@ TEST(FrameCadenceAdapterRealTimeTest, ScheduledRepeatAllowsForSlowEncode) { // Avoid the first OnFrame and sleep on the second. if (frame_counter == 2) { start_time = clock->CurrentTime(); - SleepMs(kSleepMs); + Thread::SleepMs(kSleepMs); } else if (frame_counter == 3) { TimeDelta diff = clock->CurrentTime() - (*start_time + TimeDelta::Millis(500)); @@ -1289,7 +1295,7 @@ TEST_F(ZeroHertzQueueOverloadTest, TEST_F(ZeroHertzQueueOverloadTest, QueueOverloadIsDisabledForZeroHerzWhenKillSwitchIsEnabled) { - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-ZeroHertzQueueOverload/Disabled/"); adapter_.reset(); adapter_ = CreateAdapter(field_trials, time_controller_.GetClock()); diff --git a/video/frame_decode_timing.cc b/video/frame_decode_timing.cc index e7401a0ca4..9871ba9784 100644 --- a/video/frame_decode_timing.cc +++ b/video/frame_decode_timing.cc @@ -10,16 +10,19 @@ #include "video/frame_decode_timing.h" -#include +#include #include #include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "modules/video_coding/timing/timing.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "system_wrappers/include/clock.h" namespace webrtc { -FrameDecodeTiming::FrameDecodeTiming(Clock* clock, - webrtc::VCMTiming const* timing) +FrameDecodeTiming::FrameDecodeTiming(Clock* clock, VCMTiming const* timing) : clock_(clock), timing_(timing) { RTC_DCHECK(clock_); RTC_DCHECK(timing_); diff --git a/video/frame_decode_timing.h b/video/frame_decode_timing.h index c5b024f7f2..1679bf524f 100644 --- a/video/frame_decode_timing.h +++ b/video/frame_decode_timing.h @@ -13,10 +13,10 @@ #include -#include +#include -#include "api/task_queue/pending_task_safety_flag.h" -#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/video_coding/timing/timing.h" #include "system_wrappers/include/clock.h" diff --git a/video/frame_decode_timing_unittest.cc b/video/frame_decode_timing_unittest.cc index cb45d709f1..da7a098ad0 100644 --- a/video/frame_decode_timing_unittest.cc +++ b/video/frame_decode_timing_unittest.cc @@ -14,9 +14,13 @@ #include +#include "api/field_trials_view.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/video_coding/timing/timing.h" +#include "rtc_base/checks.h" #include "rtc_base/containers/flat_map.h" +#include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" @@ -31,10 +35,10 @@ using ::testing::Optional; namespace { -class FakeVCMTiming : public webrtc::VCMTiming { +class FakeVCMTiming : public VCMTiming { public: explicit FakeVCMTiming(Clock* clock, const FieldTrialsView& field_trials) - : webrtc::VCMTiming(clock, field_trials) {} + : VCMTiming(clock, field_trials) {} Timestamp RenderTime(uint32_t frame_timestamp, Timestamp now) const override { RTC_DCHECK(render_time_map_.contains(frame_timestamp)); diff --git a/video/frame_dumping_decoder.cc b/video/frame_dumping_decoder.cc index cfb20988d9..a1a4e88426 100644 --- a/video/frame_dumping_decoder.cc +++ b/video/frame_dumping_decoder.cc @@ -10,11 +10,15 @@ #include "video/frame_dumping_decoder.h" +#include #include #include -#include "modules/video_coding/include/video_codec_interface.h" +#include "api/video/encoded_image.h" +#include "api/video/video_codec_type.h" +#include "api/video_codecs/video_decoder.h" #include "modules/video_coding/utility/ivf_file_writer.h" +#include "rtc_base/system/file_wrapper.h" namespace webrtc { namespace { diff --git a/video/frame_dumping_encoder.cc b/video/frame_dumping_encoder.cc index 3785293ee4..dcd5ed6b69 100644 --- a/video/frame_dumping_encoder.cc +++ b/video/frame_dumping_encoder.cc @@ -10,17 +10,26 @@ #include "video/frame_dumping_encoder.h" +#include #include +#include #include #include #include #include "absl/algorithm/container.h" -#include "api/sequence_checker.h" -#include "api/video/video_codec_type.h" +#include "api/fec_controller_override.h" +#include "api/field_trials_view.h" +#include "api/video/encoded_image.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" #include "modules/video_coding/utility/ivf_file_writer.h" #include "rtc_base/strings/string_builder.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/file_wrapper.h" +#include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" namespace webrtc { diff --git a/video/frame_encode_metadata_writer.cc b/video/frame_encode_metadata_writer.cc index 482ba201de..dbc303ce0b 100644 --- a/video/frame_encode_metadata_writer.cc +++ b/video/frame_encode_metadata_writer.cc @@ -11,14 +11,32 @@ #include "video/frame_encode_metadata_writer.h" #include +#include +#include #include +#include #include +#include "api/make_ref_counted.h" +#include "api/video/encoded_image.h" +#include "api/video/video_bitrate_allocation.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" +#include "api/video/video_timing.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" #include "common_video/h264/sps_vui_rewriter.h" #include "modules/include/module_common_types_public.h" +#include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/include/video_coding_defines.h" #include "modules/video_coding/svc/create_scalability_structure.h" +#include "modules/video_coding/svc/scalable_video_controller.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/time_utils.h" namespace webrtc { diff --git a/video/frame_encode_metadata_writer.h b/video/frame_encode_metadata_writer.h index 637d03a40e..1f91568593 100644 --- a/video/frame_encode_metadata_writer.h +++ b/video/frame_encode_metadata_writer.h @@ -11,15 +11,23 @@ #ifndef VIDEO_FRAME_ENCODE_METADATA_WRITER_H_ #define VIDEO_FRAME_ENCODE_METADATA_WRITER_H_ +#include +#include #include #include #include +#include "api/rtp_packet_infos.h" +#include "api/video/color_space.h" #include "api/video/encoded_image.h" +#include "api/video/video_bitrate_allocation.h" +#include "api/video/video_frame.h" +#include "api/video/video_rotation.h" #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/video/frame_encode_metadata_writer_unittest.cc b/video/frame_encode_metadata_writer_unittest.cc index 753c3092e0..4580caab93 100644 --- a/video/frame_encode_metadata_writer_unittest.cc +++ b/video/frame_encode_metadata_writer_unittest.cc @@ -11,15 +11,27 @@ #include "video/frame_encode_metadata_writer.h" #include +#include #include +#include "api/rtp_packet_infos.h" +#include "api/scoped_refptr.h" +#include "api/video/color_space.h" +#include "api/video/encoded_image.h" #include "api/video/i420_buffer.h" +#include "api/video/video_bitrate_allocation.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" +#include "api/video/video_rotation.h" #include "api/video/video_timing.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" #include "common_video/h264/h264_common.h" #include "common_video/test/utilities.h" +#include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/include/video_coding_defines.h" -#include "rtc_base/time_utils.h" #include "test/gmock.h" #include "test/gtest.h" @@ -374,8 +386,7 @@ TEST(FrameEncodeMetadataWriterTest, CopiesColorSpace) { bitrate_allocation.SetBitrate(0, 0, 500000); encode_timer.OnSetRates(bitrate_allocation, 30); - webrtc::ColorSpace color_space = - CreateTestColorSpace(/*with_hdr_metadata=*/true); + ColorSpace color_space = CreateTestColorSpace(/*with_hdr_metadata=*/true); image.SetRtpTimestamp(static_cast(kTimestampMs * 90)); VideoFrame frame = VideoFrame::Builder() .set_timestamp_ms(kTimestampMs) diff --git a/video/full_stack_tests.cc b/video/full_stack_tests.cc index 123ca10f0e..f8c809c970 100644 --- a/video/full_stack_tests.cc +++ b/video/full_stack_tests.cc @@ -14,12 +14,13 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" +#include "api/rtp_parameters.h" #include "api/test/simulated_network.h" #include "api/test/test_dependency_factory.h" #include "api/test/video_quality_test_fixture.h" #include "api/units/data_rate.h" #include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/spatial_layer.h" #include "api/video_codecs/video_codec.h" #include "api/video_codecs/vp9_profile.h" #include "modules/video_coding/codecs/vp9/include/vp9.h" @@ -977,7 +978,7 @@ TEST(FullStackTest, Screenshare_Slides_Vp9_3sl_High_Fps) { #if !defined(WEBRTC_MAC) TEST(FullStackTest, Vp9ksvc_3sl_High) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/")); auto fixture = CreateVideoQualityTestFixture(); ParamsWithLogging simulcast; @@ -992,7 +993,7 @@ TEST(FullStackTest, Vp9ksvc_3sl_High) { } TEST(FullStackTest, Vp9ksvc_3sl_Low) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/")); auto fixture = CreateVideoQualityTestFixture(); ParamsWithLogging simulcast; @@ -1007,7 +1008,7 @@ TEST(FullStackTest, Vp9ksvc_3sl_Low) { } TEST(FullStackTest, Vp9ksvc_3sl_Low_Bw_Limited) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/")); auto fixture = CreateVideoQualityTestFixture(); ParamsWithLogging simulcast; @@ -1023,7 +1024,7 @@ TEST(FullStackTest, Vp9ksvc_3sl_Low_Bw_Limited) { } TEST(FullStackTest, Vp9ksvc_3sl_Medium_Network_Restricted) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/")); auto fixture = CreateVideoQualityTestFixture(); ParamsWithLogging simulcast; @@ -1041,7 +1042,7 @@ TEST(FullStackTest, Vp9ksvc_3sl_Medium_Network_Restricted) { // TODO(webrtc:9722): Remove when experiment is cleaned up. TEST(FullStackTest, Vp9ksvc_3sl_Medium_Network_Restricted_Trusted_Rate) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9IssueKeyFrameOnLayerDeactivation/Enabled/")); auto fixture = CreateVideoQualityTestFixture(); ParamsWithLogging simulcast; @@ -1086,7 +1087,7 @@ TEST(FullStackTest, MAYBE_Simulcast_HD_High) { simulcast.ss[0] = { streams, 2, 1, 0, InterLayerPredMode::kOn, std::vector(), true}; - webrtc::test::ScopedFieldTrials override_trials(AppendFieldTrials( + test::ScopedFieldTrials override_trials(AppendFieldTrials( "WebRTC-ForceSimulatedOveruseIntervalMs/1000-50000-300/")); fixture->RunWithAnalyzer(simulcast); } diff --git a/video/g3doc/adaptation.md b/video/g3doc/adaptation.md index d34394fdc8..859fc9a50b 100644 --- a/video/g3doc/adaptation.md +++ b/video/g3doc/adaptation.md @@ -1,5 +1,5 @@ - + # Video Adaptation @@ -60,8 +60,8 @@ A custom resource can be injected into the call using the ## Adaptation -When a a *resource* signals the it is over or underused, this signal reaches the -`ResourceAdaptationProcessor` who requests an `Adaptation` proposal from the +When a *resource* signals that it is over or underused, this signal reaches the +`ResourceAdaptationProcessor` which requests an `Adaptation` proposal from the [VideoStreamAdapter][VideoStreamAdapter]. This proposal is based on the degradation preference of the video stream. `ResourceAdaptationProcessor` will determine if the `Adaptation` should be applied based on the current adaptation diff --git a/video/pc_full_stack_tests.cc b/video/pc_full_stack_tests.cc index bde1a751f8..f0c4c0ebf7 100644 --- a/video/pc_full_stack_tests.cc +++ b/video/pc_full_stack_tests.cc @@ -12,6 +12,7 @@ #include #include +#include "api/function_view.h" #include "api/media_stream_interface.h" #include "api/test/create_network_emulation_manager.h" #include "api/test/create_peer_connection_quality_test_frame_generator.h" @@ -25,26 +26,27 @@ #include "api/test/peerconnection_quality_test_fixture.h" #include "api/test/simulated_network.h" #include "api/test/time_controller.h" +#include "api/transport/bitrate_settings.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" #include "api/video_codecs/vp9_profile.h" #include "media/base/media_constants.h" -#include "modules/video_coding/codecs/vp9/include/vp9.h" #include "system_wrappers/include/field_trial.h" #include "test/field_trial.h" #include "test/gtest.h" -#include "test/network/simulated_network.h" #include "test/pc/e2e/network_quality_metrics_reporter.h" #include "test/testsupport/file_utils.h" namespace webrtc { -using ::webrtc::webrtc_pc_e2e::AudioConfig; -using ::webrtc::webrtc_pc_e2e::EmulatedSFUConfig; -using ::webrtc::webrtc_pc_e2e::PeerConfigurer; -using ::webrtc::webrtc_pc_e2e::RunParams; -using ::webrtc::webrtc_pc_e2e::ScreenShareConfig; -using ::webrtc::webrtc_pc_e2e::VideoCodecConfig; -using ::webrtc::webrtc_pc_e2e::VideoConfig; -using ::webrtc::webrtc_pc_e2e::VideoSimulcastConfig; +using webrtc_pc_e2e::AudioConfig; +using webrtc_pc_e2e::EmulatedSFUConfig; +using webrtc_pc_e2e::PeerConfigurer; +using webrtc_pc_e2e::RunParams; +using webrtc_pc_e2e::ScreenShareConfig; +using webrtc_pc_e2e::VideoCodecConfig; +using webrtc_pc_e2e::VideoConfig; +using webrtc_pc_e2e::VideoSimulcastConfig; namespace { @@ -1233,7 +1235,7 @@ ParamsWithLogging::Video SimulcastVp8VideoLow() { #if defined(RTC_ENABLE_VP9) TEST(PCFullStackTest, Pc_Screenshare_Slides_Vp9_3sl_High_Fps) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9InterLayerPred/" "Enabled,inter_layer_pred_mode:on/")); std::unique_ptr network_emulation_manager = @@ -1267,7 +1269,7 @@ TEST(PCFullStackTest, Pc_Screenshare_Slides_Vp9_3sl_High_Fps) { } TEST(PCFullStackTest, Pc_Vp9svc_3sl_High) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9InterLayerPred/" "Enabled,inter_layer_pred_mode:on/")); std::unique_ptr network_emulation_manager = @@ -1300,7 +1302,7 @@ TEST(PCFullStackTest, Pc_Vp9svc_3sl_High) { } TEST(PCFullStackTest, Pc_Vp9svc_3sl_Low) { - webrtc::test::ScopedFieldTrials override_trials( + test::ScopedFieldTrials override_trials( AppendFieldTrials("WebRTC-Vp9InterLayerPred/" "Enabled,inter_layer_pred_mode:on/")); std::unique_ptr network_emulation_manager = @@ -1432,7 +1434,7 @@ TEST(PCFullStackTest, VP9KSVC_3SL_Medium_Network_Restricted_Trusted_Rate) { #define MAYBE_Pc_Simulcast_HD_High Pc_Simulcast_HD_High #endif TEST(PCFullStackTest, MAYBE_Pc_Simulcast_HD_High) { - webrtc::test::ScopedFieldTrials override_trials(AppendFieldTrials( + test::ScopedFieldTrials override_trials(AppendFieldTrials( "WebRTC-ForceSimulatedOveruseIntervalMs/1000-50000-300/")); std::unique_ptr network_emulation_manager = CreateNetworkEmulationManager(); diff --git a/video/picture_id_tests.cc b/video/picture_id_tests.cc index 46d6499fcf..4e76e5d676 100644 --- a/video/picture_id_tests.cc +++ b/video/picture_id_tests.cc @@ -8,24 +8,46 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include #include - +#include +#include +#include +#include +#include + +#include "api/array_view.h" +#include "api/environment/environment.h" #include "api/test/simulated_network.h" #include "api/test/video/function_video_encoder_factory.h" -#include "call/fake_network_pipe.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame_type.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder_factory.h" #include "media/engine/internal_encoder_factory.h" #include "media/engine/simulcast_encoder_adapter.h" #include "modules/rtp_rtcp/source/create_video_rtp_depacketizer.h" #include "modules/rtp_rtcp/source/rtp_packet.h" +#include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" +#include "modules/video_coding/codecs/interface/common_constants.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" +#include "modules/video_coding/codecs/vp8/include/vp8_globals.h" #include "modules/video_coding/codecs/vp9/include/vp9.h" -#include "rtc_base/numerics/safe_conversions.h" +#include "modules/video_coding/codecs/vp9/include/vp9_globals.h" +#include "rtc_base/checks.h" +#include "rtc_base/numerics/mod_ops.h" #include "rtc_base/numerics/sequence_number_util.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" +#include "rtc_base/thread_annotations.h" #include "test/call_test.h" -#include "test/network/simulated_network.h" +#include "test/gtest.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { diff --git a/video/quality_convergence_controller.cc b/video/quality_convergence_controller.cc index c063f62b34..a3c9afa185 100644 --- a/video/quality_convergence_controller.cc +++ b/video/quality_convergence_controller.cc @@ -11,10 +11,15 @@ #include "video/quality_convergence_controller.h" #include +#include +#include +#include "api/field_trials_view.h" +#include "api/video/video_codec_type.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/struct_parameters_parser.h" #include "rtc_base/logging.h" +#include "video/quality_convergence_monitor.h" namespace webrtc { namespace { diff --git a/video/quality_convergence_controller_unittest.cc b/video/quality_convergence_controller_unittest.cc index 46965d4bff..4f7cf63b57 100644 --- a/video/quality_convergence_controller_unittest.cc +++ b/video/quality_convergence_controller_unittest.cc @@ -12,6 +12,7 @@ #include +#include "api/video/video_codec_type.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" diff --git a/video/quality_convergence_monitor.cc b/video/quality_convergence_monitor.cc index 25b7bed7a5..2f5d3f242c 100644 --- a/video/quality_convergence_monitor.cc +++ b/video/quality_convergence_monitor.cc @@ -10,9 +10,12 @@ #include "video/quality_convergence_monitor.h" -#include +#include +#include #include +#include "api/field_trials_view.h" +#include "api/video/video_codec_type.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/struct_parameters_parser.h" diff --git a/video/quality_convergence_monitor.h b/video/quality_convergence_monitor.h index 326372db43..ecc59dd18e 100644 --- a/video/quality_convergence_monitor.h +++ b/video/quality_convergence_monitor.h @@ -11,6 +11,7 @@ #ifndef VIDEO_QUALITY_CONVERGENCE_MONITOR_H_ #define VIDEO_QUALITY_CONVERGENCE_MONITOR_H_ +#include #include #include diff --git a/video/quality_convergence_monitor_unittest.cc b/video/quality_convergence_monitor_unittest.cc index e236f1dab9..c8da0a7d38 100644 --- a/video/quality_convergence_monitor_unittest.cc +++ b/video/quality_convergence_monitor_unittest.cc @@ -10,8 +10,10 @@ */ #include "video/quality_convergence_monitor.h" -#include +#include +#include +#include "api/video/video_codec_type.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" diff --git a/video/quality_limitation_reason_tracker.cc b/video/quality_limitation_reason_tracker.cc index c2b2cc4043..425070f40b 100644 --- a/video/quality_limitation_reason_tracker.cc +++ b/video/quality_limitation_reason_tracker.cc @@ -10,9 +10,13 @@ #include "video/quality_limitation_reason_tracker.h" +#include +#include #include +#include "common_video/include/quality_limitation_reason.h" #include "rtc_base/checks.h" +#include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/video/quality_limitation_reason_tracker.h b/video/quality_limitation_reason_tracker.h index 15bc90773a..738c3139de 100644 --- a/video/quality_limitation_reason_tracker.h +++ b/video/quality_limitation_reason_tracker.h @@ -11,6 +11,7 @@ #ifndef VIDEO_QUALITY_LIMITATION_REASON_TRACKER_H_ #define VIDEO_QUALITY_LIMITATION_REASON_TRACKER_H_ +#include #include #include "common_video/include/quality_limitation_reason.h" diff --git a/video/quality_limitation_reason_tracker_unittest.cc b/video/quality_limitation_reason_tracker_unittest.cc index f550c0d8e4..f39918fa89 100644 --- a/video/quality_limitation_reason_tracker_unittest.cc +++ b/video/quality_limitation_reason_tracker_unittest.cc @@ -10,6 +10,8 @@ #include "video/quality_limitation_reason_tracker.h" +#include + #include "common_video/include/quality_limitation_reason.h" #include "system_wrappers/include/clock.h" #include "test/gtest.h" diff --git a/video/quality_scaling_tests.cc b/video/quality_scaling_tests.cc index 81aeebb2da..bc9b72b549 100644 --- a/video/quality_scaling_tests.cc +++ b/video/quality_scaling_tests.cc @@ -8,19 +8,44 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include +#include +#include +#include #include +#include +#include "api/array_view.h" +#include "api/environment/environment.h" +#include "api/make_ref_counted.h" +#include "api/rtp_parameters.h" #include "api/test/video/function_video_encoder_factory.h" -#include "media/engine/internal_encoder_factory.h" +#include "api/transport/bitrate_settings.h" +#include "api/units/time_delta.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video/video_source_interface.h" +#include "api/video_codecs/scalability_mode.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/video_coding/codecs/h264/include/h264.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "modules/video_coding/codecs/vp9/include/vp9.h" +#include "rtc_base/checks.h" #include "rtc_base/experiments/encoder_info_settings.h" #include "test/call_test.h" -#include "test/field_trial.h" #include "test/frame_generator_capturer.h" +#include "test/gtest.h" +#include "test/rtp_rtcp_observer.h" +#include "test/scoped_key_value_config.h" #include "test/video_test_constants.h" -#include "video/config/encoder_stream_factory.h" +#include "video/config/video_encoder_config.h" namespace webrtc { namespace { diff --git a/video/rate_utilization_tracker.cc b/video/rate_utilization_tracker.cc index ad7125a5a1..75c73b06ba 100644 --- a/video/rate_utilization_tracker.cc +++ b/video/rate_utilization_tracker.cc @@ -11,6 +11,14 @@ #include "video/rate_utilization_tracker.h" #include +#include +#include + +#include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/video/rate_utilization_tracker.h b/video/rate_utilization_tracker.h index 619d542c4a..3d93eb7d38 100644 --- a/video/rate_utilization_tracker.h +++ b/video/rate_utilization_tracker.h @@ -11,6 +11,7 @@ #ifndef VIDEO_RATE_UTILIZATION_TRACKER_H_ #define VIDEO_RATE_UTILIZATION_TRACKER_H_ +#include #include #include diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index aae6b60f2d..b89ae42538 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -12,10 +12,28 @@ #include #include +#include +#include +#include #include #include -#include "modules/video_coding/include/video_codec_interface.h" +#include "absl/strings/string_view.h" +#include "api/rtp_packet_info.h" +#include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" +#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" +#include "api/video/video_timing.h" +#include "api/video_codecs/video_decoder.h" +#include "call/video_receive_stream.h" +#include "modules/rtp_rtcp/include/rtcp_statistics.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" @@ -23,6 +41,8 @@ #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" +#include "video/stats_counter.h" +#include "video/video_quality_observer2.h" #include "video/video_receive_stream2.h" namespace webrtc { @@ -594,7 +614,7 @@ void ReceiveStatisticsProxy::OnDecodedFrame(const VideoFrame& frame, VideoContentType content_type, VideoFrameType frame_type) { TimeDelta processing_delay = TimeDelta::Zero(); - webrtc::Timestamp current_time = clock_->CurrentTime(); + Timestamp current_time = clock_->CurrentTime(); // TODO(bugs.webrtc.org/13984): some tests do not fill packet_infos(). TimeDelta assembly_time = TimeDelta::Zero(); if (frame.packet_infos().size() > 0) { diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc index 565d076fdb..5e06231a38 100644 --- a/video/receive_statistics_proxy_unittest.cc +++ b/video/receive_statistics_proxy_unittest.cc @@ -10,26 +10,39 @@ #include "video/receive_statistics_proxy.h" +#include +#include +#include #include #include #include #include #include -#include +#include +#include "api/rtp_packet_info.h" +#include "api/rtp_packet_infos.h" #include "api/scoped_refptr.h" #include "api/units/frequency.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "api/video/i420_buffer.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" -#include "api/video/video_frame_buffer.h" +#include "api/video/video_frame_type.h" #include "api/video/video_rotation.h" -#include "rtc_base/thread.h" +#include "api/video/video_timing.h" +#include "api/video_codecs/video_decoder.h" +#include "call/video_receive_stream.h" +#include "modules/rtp_rtcp/include/rtcp_statistics.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "system_wrappers/include/metrics.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" +#include "video/video_quality_observer2.h" #include "video/video_receive_stream2.h" namespace webrtc { @@ -115,7 +128,7 @@ class ReceiveStatisticsProxyTest : public ::testing::Test { TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) { EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (uint32_t i = 1; i <= 3; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, @@ -128,7 +141,7 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReported) { const Frequency kFps = Frequency::Hertz(20); const int kRequiredSamples = TimeDelta::Seconds(metrics::kMinRunTimeInSeconds) * kFps; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kRequiredSamples; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, @@ -146,7 +159,7 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsNotReportedForTooFewSamples) { const Frequency kFps = Frequency::Hertz(20); const int kRequiredSamples = TimeDelta::Seconds(metrics::kMinRunTimeInSeconds) * kFps; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kRequiredSamples - 1; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, @@ -161,7 +174,7 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsNotReportedForTooFewSamples) { TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpDoesNotResetFramesDecodedOrTotalDecodeTime) { EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); TimeDelta expected_total_decode_time = TimeDelta::Zero(); unsigned int expected_frames_decoded = 0; for (uint32_t i = 1; i <= 3; ++i) { @@ -191,7 +204,7 @@ TEST_F(ReceiveStatisticsProxyTest, TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesProcessingDelay) { const TimeDelta kProcessingDelay = TimeDelta::Millis(10); EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); TimeDelta expected_total_processing_delay = TimeDelta::Zero(); unsigned int expected_frames_decoded = 0; // We set receive time fixed and increase the clock by 10ms @@ -229,7 +242,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesProcessingDelay) { TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesAssemblyTime) { const TimeDelta kAssemblyTime = TimeDelta::Millis(7); EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); TimeDelta expected_total_assembly_time = TimeDelta::Zero(); unsigned int expected_frames_decoded = 0; unsigned int expected_frames_assembled_from_multiple_packets = 0; @@ -303,7 +316,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesAssemblyTime) { TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) { EXPECT_EQ(std::nullopt, statistics_proxy_->GetStats().qp_sum); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, VideoFrameType::kVideoFrameKey); @@ -316,7 +329,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) { TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesTotalDecodeTime) { EXPECT_EQ(std::nullopt, statistics_proxy_->GetStats().qp_sum); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Millis(4), VideoContentType::UNSPECIFIED, VideoFrameType::kVideoFrameKey); @@ -330,7 +343,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesTotalDecodeTime) { TEST_F(ReceiveStatisticsProxyTest, ReportsContentType) { const std::string kRealtimeString("realtime"); const std::string kScreenshareString("screen"); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString( statistics_proxy_->GetStats().content_type)); statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Zero(), @@ -346,7 +359,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsContentType) { } TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); const TimeDelta kInterframeDelay1 = TimeDelta::Millis(100); const TimeDelta kInterframeDelay2 = TimeDelta::Millis(200); const TimeDelta kInterframeDelay3 = TimeDelta::Millis(100); @@ -377,7 +390,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) { } TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); const TimeDelta kInterframeDelay1 = TimeDelta::Millis(900); const TimeDelta kInterframeDelay2 = TimeDelta::Millis(750); const TimeDelta kInterframeDelay3 = TimeDelta::Millis(700); @@ -415,7 +428,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsFreezeMetrics) { EXPECT_EQ(0u, stats.freeze_count); EXPECT_FALSE(stats.total_freezes_duration_ms); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (size_t i = 0; i < VideoQualityObserver::kMinFrameSamplesToDetectFreeze; ++i) { time_controller_.AdvanceTime(TimeDelta::Millis(30)); @@ -436,7 +449,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsPauseMetrics) { ASSERT_EQ(0u, stats.pause_count); ASSERT_EQ(0u, stats.total_pauses_duration_ms); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnRenderedFrame(MetaData(frame)); // Pause. @@ -454,7 +467,7 @@ TEST_F(ReceiveStatisticsProxyTest, PauseBeforeFirstAndAfterLastFrameIgnored) { ASSERT_EQ(0u, stats.pause_count); ASSERT_EQ(0u, stats.total_pauses_duration_ms); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); // Pause -> Frame -> Pause time_controller_.AdvanceTime(TimeDelta::Seconds(5)); @@ -476,7 +489,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsTotalInterFrameDelay) { VideoReceiveStreamInterface::Stats stats = statistics_proxy_->GetStats(); ASSERT_EQ(0.0, stats.total_inter_frame_delay); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); // Emulate delay before first frame is rendered. This is needed to ensure // that frame duration only covers time since first frame is rendered and @@ -495,7 +508,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsTotalSquaredInterFrameDelay) { VideoReceiveStreamInterface::Stats stats = statistics_proxy_->GetStats(); ASSERT_EQ(0.0, stats.total_squared_inter_frame_delay); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i <= 10; ++i) { time_controller_.AdvanceTime(TimeDelta::Millis(30)); statistics_proxy_->OnRenderedFrame(MetaData(frame)); @@ -509,7 +522,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsTotalSquaredInterFrameDelay) { } TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); EXPECT_EQ(std::nullopt, statistics_proxy_->GetStats().qp_sum); statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, @@ -518,7 +531,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) { } TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); EXPECT_EQ(std::nullopt, statistics_proxy_->GetStats().qp_sum); statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, @@ -532,7 +545,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) { TEST_F(ReceiveStatisticsProxyTest, OnRenderedFrameIncreasesFramesRendered) { EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_rendered); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (uint32_t i = 1; i <= 3; ++i) { statistics_proxy_->OnRenderedFrame(MetaData(frame)); EXPECT_EQ(i, statistics_proxy_->GetStats().frames_rendered); @@ -682,7 +695,7 @@ TEST_F(ReceiveStatisticsProxyTest, TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsFrameCounts) { const int kKeyFrames = 3; const int kDeltaFrames = 22; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kKeyFrames; i++) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, @@ -761,7 +774,7 @@ TEST_F(ReceiveStatisticsProxyTest, LifetimeHistogramIsUpdated) { time_controller_.AdvanceTime(kLifetime); // Need at least one decoded frame to report stream lifetime. - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnCompleteFrame(true, 1000, VideoContentType::UNSPECIFIED); statistics_proxy_->OnDecodedFrame( frame, std::nullopt, TimeDelta::Millis(1000), @@ -907,7 +920,7 @@ TEST_F(ReceiveStatisticsProxyTest, KeyFrameHistogramNotUpdatedForTooFewSamples) { const bool kIsKeyFrame = false; const int kFrameSizeBytes = 1000; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples - 1; ++i) { statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes, @@ -932,7 +945,7 @@ TEST_F(ReceiveStatisticsProxyTest, KeyFrameHistogramUpdatedForMinRequiredSamples) { const bool kIsKeyFrame = false; const int kFrameSizeBytes = 1000; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples; ++i) { statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes, @@ -957,7 +970,7 @@ TEST_F(ReceiveStatisticsProxyTest, TEST_F(ReceiveStatisticsProxyTest, KeyFrameHistogramIsUpdated) { const int kFrameSizeBytes = 1000; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples; ++i) { statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes, @@ -1045,7 +1058,7 @@ TEST_F(ReceiveStatisticsProxyTest, TimingHistogramsAreUpdated) { TEST_F(ReceiveStatisticsProxyTest, DoesNotReportStaleFramerates) { const Frequency kDefaultFps = Frequency::Hertz(30); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kDefaultFps.hertz(); ++i) { // Since OnRenderedFrame is never called the fps in each sample will be 0, @@ -1124,7 +1137,7 @@ TEST_F(ReceiveStatisticsProxyTest, ReceivedFrameHistogramsAreUpdated) { } TEST_F(ReceiveStatisticsProxyTest, ZeroDelayReportedIfFrameNotDelayed) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, VideoFrameType::kVideoFrameKey); @@ -1147,7 +1160,7 @@ TEST_F(ReceiveStatisticsProxyTest, ZeroDelayReportedIfFrameNotDelayed) { TEST_F(ReceiveStatisticsProxyTest, DelayedFrameHistogramsAreNotUpdatedIfMinRuntimeHasNotPassed) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, VideoFrameType::kVideoFrameKey); @@ -1169,7 +1182,7 @@ TEST_F(ReceiveStatisticsProxyTest, TEST_F(ReceiveStatisticsProxyTest, DelayedFramesHistogramsAreNotUpdatedIfNoRenderedFrames) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, VideoFrameType::kVideoFrameKey); @@ -1186,7 +1199,7 @@ TEST_F(ReceiveStatisticsProxyTest, } TEST_F(ReceiveStatisticsProxyTest, DelayReportedIfFrameIsDelayed) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, VideoFrameType::kVideoFrameKey); @@ -1211,7 +1224,7 @@ TEST_F(ReceiveStatisticsProxyTest, DelayReportedIfFrameIsDelayed) { } TEST_F(ReceiveStatisticsProxyTest, AverageDelayOfDelayedFramesIsReported) { - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), VideoContentType::UNSPECIFIED, VideoFrameType::kVideoFrameKey); @@ -1329,7 +1342,7 @@ INSTANTIATE_TEST_SUITE_P(_, TEST_P(ReceiveStatisticsProxyTestWithFreezeDuration, FreezeDetection) { VideoReceiveStreamInterface::Stats stats = statistics_proxy_->GetStats(); EXPECT_EQ(0u, stats.freeze_count); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); // Add a very long frame. This is need to verify that average frame // duration, which is supposed to be calculated as mean of durations of @@ -1351,9 +1364,9 @@ TEST_P(ReceiveStatisticsProxyTestWithFreezeDuration, FreezeDetection) { class ReceiveStatisticsProxyTestWithContent : public ReceiveStatisticsProxyTest, - public ::testing::WithParamInterface { + public ::testing::WithParamInterface { protected: - const webrtc::VideoContentType content_type_{GetParam()}; + const VideoContentType content_type_{GetParam()}; }; INSTANTIATE_TEST_SUITE_P(ContentTypes, @@ -1363,7 +1376,7 @@ INSTANTIATE_TEST_SUITE_P(ContentTypes, TEST_P(ReceiveStatisticsProxyTestWithContent, InterFrameDelaysAreReported) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(33); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), @@ -1400,7 +1413,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, InterFrameDelaysPercentilesAreReported) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(33); const int kLastFivePercentsSamples = kMinRequiredSamples * 5 / 100; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i <= kMinRequiredSamples - kLastFivePercentsSamples; ++i) { time_controller_.AdvanceTime(kInterFrameDelay); @@ -1438,7 +1451,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, TEST_P(ReceiveStatisticsProxyTestWithContent, MaxInterFrameDelayOnlyWithValidAverage) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(33); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), @@ -1462,7 +1475,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, TEST_P(ReceiveStatisticsProxyTestWithContent, MaxInterFrameDelayOnlyWithPause) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(33); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i <= kMinRequiredSamples; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), @@ -1550,7 +1563,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, FreezesAreReported) { const TimeDelta kFreezeDelay = TimeDelta::Millis(200); const TimeDelta kCallDuration = kMinRequiredSamples * kInterFrameDelay + kFreezeDelay; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples; ++i) { VideoFrameMetaData meta = MetaData(frame); @@ -1599,7 +1612,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, HarmonicFrameRateIsReported) { const TimeDelta kPauseDuration = TimeDelta::Seconds(10); const TimeDelta kCallDuration = kMinRequiredSamples * kFrameDuration + kFreezeDuration + kPauseDuration; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples; ++i) { time_controller_.AdvanceTime(kFrameDuration); @@ -1648,7 +1661,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, HarmonicFrameRateIsReported) { TEST_P(ReceiveStatisticsProxyTestWithContent, PausesAreIgnored) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(33); const TimeDelta kPauseDuration = TimeDelta::Seconds(10); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i <= kMinRequiredSamples; ++i) { VideoFrameMetaData meta = MetaData(frame); @@ -1693,7 +1706,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, PausesAreIgnored) { TEST_P(ReceiveStatisticsProxyTestWithContent, ManyPausesAtTheBeginning) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(33); const TimeDelta kPauseDuration = TimeDelta::Seconds(10); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i <= kMinRequiredSamples; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), @@ -1723,8 +1736,8 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, ManyPausesAtTheBeginning) { TEST_P(ReceiveStatisticsProxyTestWithContent, TimeInHdReported) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(20); - webrtc::VideoFrame frame_hd = CreateFrame(1280, 720); - webrtc::VideoFrame frame_sd = CreateFrame(640, 360); + VideoFrame frame_hd = CreateFrame(1280, 720); + VideoFrame frame_sd = CreateFrame(640, 360); // HD frames. for (int i = 0; i < kMinRequiredSamples; ++i) { @@ -1764,7 +1777,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, TimeInBlockyVideoReported) { const TimeDelta kInterFrameDelay = TimeDelta::Millis(20); const int kHighQp = 80; const int kLowQp = 30; - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); // High quality frames. for (int i = 0; i < kMinRequiredSamples; ++i) { @@ -1808,9 +1821,9 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, DownscalesReported) { // To ensure long enough call duration. const TimeDelta kInterFrameDelay = TimeDelta::Seconds(2); - webrtc::VideoFrame frame_hd = CreateFrame(1280, 720); - webrtc::VideoFrame frame_sd = CreateFrame(640, 360); - webrtc::VideoFrame frame_ld = CreateFrame(320, 180); + VideoFrame frame_hd = CreateFrame(1280, 720); + VideoFrame frame_sd = CreateFrame(640, 360); + VideoFrame frame_ld = CreateFrame(320, 180); // Call once to pass content type. statistics_proxy_->OnDecodedFrame(frame_hd, std::nullopt, TimeDelta::Zero(), @@ -1841,7 +1854,7 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, DecodeTimeReported) { const int kLowQp = 30; const TimeDelta kDecodeTime = TimeDelta::Millis(7); - webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight); + VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kMinRequiredSamples; ++i) { statistics_proxy_->OnDecodedFrame(frame, kLowQp, kDecodeTime, content_type_, diff --git a/video/render/incoming_video_stream.cc b/video/render/incoming_video_stream.cc index 8d4e1ea5f2..970f303a33 100644 --- a/video/render/incoming_video_stream.cc +++ b/video/render/incoming_video_stream.cc @@ -10,12 +10,18 @@ #include "video/render/incoming_video_stream.h" +#include #include #include #include +#include "api/sequence_checker.h" +#include "api/task_queue/task_queue_factory.h" #include "api/units/time_delta.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" #include "rtc_base/checks.h" +#include "rtc_base/race_checker.h" #include "rtc_base/trace_event.h" #include "video/render/video_render_frames.h" diff --git a/video/render/video_render_frames.cc b/video/render/video_render_frames.cc index d26a050150..ca5385bded 100644 --- a/video/render/video_render_frames.cc +++ b/video/render/video_render_frames.cc @@ -10,10 +10,12 @@ #include "video/render/video_render_frames.h" -#include +#include +#include +#include #include -#include "rtc_base/checks.h" +#include "api/video/video_frame.h" #include "rtc_base/logging.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/metrics.h" diff --git a/video/report_block_stats.cc b/video/report_block_stats.cc index bf60364682..966e179d79 100644 --- a/video/report_block_stats.cc +++ b/video/report_block_stats.cc @@ -10,7 +10,7 @@ #include "video/report_block_stats.h" -#include +#include namespace webrtc { diff --git a/video/report_block_stats_unittest.cc b/video/report_block_stats_unittest.cc index bd66e571a0..05095f7f13 100644 --- a/video/report_block_stats_unittest.cc +++ b/video/report_block_stats_unittest.cc @@ -10,6 +10,8 @@ #include "video/report_block_stats.h" +#include + #include "test/gtest.h" namespace webrtc { diff --git a/video/rtp_streams_synchronizer2.cc b/video/rtp_streams_synchronizer2.cc index 5fc75e9f54..f3c3875dc9 100644 --- a/video/rtp_streams_synchronizer2.cc +++ b/video/rtp_streams_synchronizer2.cc @@ -10,14 +10,21 @@ #include "video/rtp_streams_synchronizer2.h" +#include #include +#include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "call/syncable.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/rtp_to_ntp_estimator.h" +#include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/rtp_to_ntp_estimator.h" +#include "system_wrappers/include/ntp_time.h" +#include "video/stream_synchronization.h" namespace webrtc { namespace internal { diff --git a/video/rtp_streams_synchronizer2.h b/video/rtp_streams_synchronizer2.h index 0503abe726..ec04a7c341 100644 --- a/video/rtp_streams_synchronizer2.h +++ b/video/rtp_streams_synchronizer2.h @@ -11,12 +11,14 @@ #ifndef VIDEO_RTP_STREAMS_SYNCHRONIZER2_H_ #define VIDEO_RTP_STREAMS_SYNCHRONIZER2_H_ +#include #include #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/task_utils/repeating_task.h" +#include "rtc_base/thread_annotations.h" #include "video/stream_synchronization.h" namespace webrtc { diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index bdd2cc22c6..2fccb605cb 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -393,7 +393,7 @@ RtpVideoStreamReceiver2::~RtpVideoStreamReceiver2() { void RtpVideoStreamReceiver2::AddReceiveCodec( uint8_t payload_type, VideoCodecType video_codec, - const webrtc::CodecParameterMap& codec_params, + const CodecParameterMap& codec_params, bool raw_payload) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); if (codec_params.count(kH264FmtpSpsPpsIdrInKeyframe) > 0 || @@ -634,9 +634,9 @@ bool RtpVideoStreamReceiver2::OnReceivedPayloadData( Timestamp now = env_.clock().CurrentTime(); if (now - last_logged_failed_to_parse_dd_ > TimeDelta::Seconds(1)) { last_logged_failed_to_parse_dd_ = now; - RTC_LOG(LS_WARNING) << "ssrc: " << rtp_packet.Ssrc() - << ", timestamp: " << rtp_packet.Timestamp() - << " Failed to parse dependency descriptor."; + RTC_LOG(LS_WARNING) << "Failed to parse dependency descriptor for " + << "ssrc: " << rtp_packet.Ssrc() + << ", timestamp: " << rtp_packet.Timestamp(); } if (video_structure_ == nullptr && next_keyframe_request_for_missing_video_structure_ < now) { @@ -1231,7 +1231,9 @@ void RtpVideoStreamReceiver2::ReceivePacket(const RtpPacketReceived& packet) { std::optional parsed_payload = type_it->second->Parse(packet.PayloadBuffer()); if (parsed_payload == std::nullopt) { - RTC_LOG(LS_WARNING) << "Failed parsing payload."; + RTC_LOG(LS_WARNING) << " Failed to parse payload for " + << "ssrc: " << packet.Ssrc() + << ", timestamp: " << packet.Timestamp(); return false; } diff --git a/video/rtp_video_stream_receiver2_unittest.cc b/video/rtp_video_stream_receiver2_unittest.cc index 068f476196..344060156a 100644 --- a/video/rtp_video_stream_receiver2_unittest.cc +++ b/video/rtp_video_stream_receiver2_unittest.cc @@ -207,7 +207,9 @@ class RtpVideoStreamReceiver2Test : public ::testing::Test, /*raw_payload=*/false); ON_CALL(mock_transport_, SendRtcp) .WillByDefault( - Invoke(&rtcp_packet_parser_, &test::RtcpPacketParser::Parse)); + Invoke([this](ArrayView packet, ::testing::Unused) { + return rtcp_packet_parser_.Parse(packet); + })); } RTPVideoHeader GetDefaultH264VideoHeader() { @@ -346,7 +348,7 @@ TEST_F(RtpVideoStreamReceiver2Test, CacheColorSpaceFromLastPacketOfKeyframe) { received_packet_generator.SetColorSpace(kColorSpace); // Prepare the receiver for VP9. - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; rtp_video_stream_receiver_->AddReceiveCodec(kVp9PayloadType, kVideoCodecVP9, codec_params, /*raw_payload=*/false); @@ -474,7 +476,7 @@ TEST_F(RtpVideoStreamReceiver2Test, const std::vector kDeltaFramePayload = {5, 6, 7, 8, 9}; // Prepare the receiver for VP9. - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; rtp_video_stream_receiver_->AddReceiveCodec(kVp9PayloadType, kVideoCodecVP9, codec_params, /*raw_payload=*/false); @@ -551,7 +553,7 @@ TEST_F(RtpVideoStreamReceiver2Test, const std::vector kDeltaFramePayload = {5, 6, 7, 8, 9}; // Prepare the receiver for VP9. - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; rtp_video_stream_receiver_->AddReceiveCodec(kVp9PayloadType, kVideoCodecVP9, codec_params, /*raw_payload=*/false); @@ -797,7 +799,7 @@ INSTANTIATE_TEST_SUITE_P(SpsPpsIdrIsKeyframeAndH26xPacketBuffer, TEST_P(RtpVideoStreamReceiver2TestH264, InBandSpsPps) { constexpr int kH264PayloadType = 98; - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; rtp_video_stream_receiver_->AddReceiveCodec(kH264PayloadType, kVideoCodecH264, codec_params, /*raw_payload=*/false); @@ -854,7 +856,7 @@ TEST_P(RtpVideoStreamReceiver2TestH264, InBandSpsPps) { TEST_P(RtpVideoStreamReceiver2TestH264, OutOfBandFmtpSpsPps) { constexpr int kH264PayloadType = 99; - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; // Example parameter sets from https://tools.ietf.org/html/rfc3984#section-8.2 // . codec_params.insert({kH264FmtpSpropParameterSets, "Z0IACpZTBYmI,aMljiA=="}); @@ -901,7 +903,7 @@ TEST_P(RtpVideoStreamReceiver2TestH264, OutOfBandFmtpSpsPps) { } TEST_P(RtpVideoStreamReceiver2TestH264, ForceSpsPpsIdrIsKeyframe) { - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; // Forcing can be done either with field trial or codec_params. if (!env_.field_trials().IsEnabled("WebRTC-SpsPpsIdrIsH264Keyframe")) { codec_params.insert({kH264FmtpSpsPpsIdrInKeyframe, ""}); @@ -1061,7 +1063,7 @@ TEST_P(RtpVideoStreamReceiver2TestPadding, EmptyPaddingInMediaStream) { rtp_packet_slice.Parse(raw_rtp_slice.data(), raw_rtp_slice.size()); // Prepare the receiver for H264. - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; rtp_video_stream_receiver_->AddReceiveCodec(kH264PayloadType, kVideoCodecH264, codec_params, false); rtp_video_stream_receiver_->StartReceive(); @@ -1768,7 +1770,7 @@ class RtpVideoStreamReceiver2TestH265 : public RtpVideoStreamReceiver2Test { TEST_F(RtpVideoStreamReceiver2TestH265, H265Bitstream) { constexpr int kH265PayloadType = 98; - webrtc::CodecParameterMap codec_params; + CodecParameterMap codec_params; rtp_video_stream_receiver_->AddReceiveCodec(kH265PayloadType, kVideoCodecH265, codec_params, /*raw_payload=*/false); diff --git a/video/screenshare_loopback.cc b/video/screenshare_loopback.cc index da2b2a3276..a0bf6e9cf5 100644 --- a/video/screenshare_loopback.cc +++ b/video/screenshare_loopback.cc @@ -21,12 +21,12 @@ #include "api/test/video_quality_test_fixture.h" #include "api/transport/bitrate_settings.h" #include "api/units/data_rate.h" +#include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_codec.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/string_encode.h" #include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/run_test.h" #include "test/test_flags.h" diff --git a/video/send_delay_stats.cc b/video/send_delay_stats.cc index 0deeb89c86..c81d457dc0 100644 --- a/video/send_delay_stats.cc +++ b/video/send_delay_stats.cc @@ -10,10 +10,18 @@ #include "video/send_delay_stats.h" +#include +#include #include +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "call/video_send_stream.h" #include "rtc_base/logging.h" +#include "rtc_base/synchronization/mutex.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" +#include "video/stats_counter.h" namespace webrtc { namespace { diff --git a/video/send_delay_stats_unittest.cc b/video/send_delay_stats_unittest.cc index e23467e71c..c564562e54 100644 --- a/video/send_delay_stats_unittest.cc +++ b/video/send_delay_stats_unittest.cc @@ -14,7 +14,11 @@ #include #include +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "call/rtp_config.h" +#include "call/video_send_stream.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "test/gtest.h" diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 57016db103..e6858dfef9 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -13,19 +13,50 @@ #include #include #include +#include +#include +#include #include +#include +#include +#include #include +#include #include "absl/strings/match.h" +#include "api/field_trials_view.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "api/video/encoded_image.h" +#include "api/video/video_adaptation_counters.h" +#include "api/video/video_adaptation_reason.h" +#include "api/video/video_bitrate_allocation.h" #include "api/video/video_codec_constants.h" #include "api/video/video_codec_type.h" +#include "api/video/video_content_type.h" +#include "api/video/video_frame_type.h" +#include "api/video/video_timing.h" #include "api/video_codecs/video_codec.h" +#include "call/rtp_config.h" +#include "call/video_send_stream.h" +#include "common_video/frame_counts.h" +#include "common_video/include/quality_limitation_reason.h" +#include "modules/rtp_rtcp/include/report_block_data.h" +#include "modules/rtp_rtcp/include/rtcp_statistics.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/video_coding/codecs/interface/common_constants.h" #include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/mod_ops.h" #include "rtc_base/strings/string_builder.h" +#include "rtc_base/synchronization/mutex.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" +#include "video/config/video_encoder_config.h" +#include "video/stats_counter.h" +#include "video/video_stream_encoder_observer.h" namespace webrtc { namespace { @@ -116,7 +147,7 @@ std::optional GetFallbackMaxPixels(const std::string& group) { } std::optional GetFallbackMaxPixelsIfFieldTrialEnabled( - const webrtc::FieldTrialsView& field_trials) { + const FieldTrialsView& field_trials) { std::string group = field_trials.Lookup(kVp8ForcedFallbackEncoderFieldTrial); return (absl::StartsWith(group, "Enabled")) ? GetFallbackMaxPixels(group.substr(7)) @@ -124,7 +155,7 @@ std::optional GetFallbackMaxPixelsIfFieldTrialEnabled( } std::optional GetFallbackMaxPixelsIfFieldTrialDisabled( - const webrtc::FieldTrialsView& field_trials) { + const FieldTrialsView& field_trials) { std::string group = field_trials.Lookup(kVp8ForcedFallbackEncoderFieldTrial); return (absl::StartsWith(group, "Disabled")) ? GetFallbackMaxPixels(group.substr(8)) diff --git a/video/send_statistics_proxy_unittest.cc b/video/send_statistics_proxy_unittest.cc index 39ff0a6ab8..c41a9cdec4 100644 --- a/video/send_statistics_proxy_unittest.cc +++ b/video/send_statistics_proxy_unittest.cc @@ -11,19 +11,35 @@ #include "video/send_statistics_proxy.h" #include +#include +#include #include #include +#include #include #include #include "absl/algorithm/container.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "api/video/video_adaptation_counters.h" #include "api/video/video_adaptation_reason.h" #include "api/video/video_bitrate_allocation.h" #include "api/video/video_codec_type.h" #include "api/video_codecs/scalability_mode.h" #include "api/video_codecs/video_codec.h" +#include "call/video_send_stream.h" +#include "common_video/frame_counts.h" +#include "common_video/include/quality_limitation_reason.h" +#include "modules/rtp_rtcp/include/report_block_data.h" +#include "modules/rtp_rtcp/include/rtcp_statistics.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" +#include "modules/video_coding/codecs/interface/common_constants.h" +#include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/fake_clock.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/video/stats_counter.cc b/video/stats_counter.cc index 09c2d4dd49..73181a4bb9 100644 --- a/video/stats_counter.cc +++ b/video/stats_counter.cc @@ -11,8 +11,10 @@ #include "video/stats_counter.h" #include +#include #include #include +#include #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" diff --git a/video/stats_counter_unittest.cc b/video/stats_counter_unittest.cc index 32f8c8e5e1..9f67afc116 100644 --- a/video/stats_counter_unittest.cc +++ b/video/stats_counter_unittest.cc @@ -10,6 +10,8 @@ #include "video/stats_counter.h" +#include + #include "system_wrappers/include/clock.h" #include "test/gtest.h" diff --git a/video/stream_synchronization.cc b/video/stream_synchronization.cc index d86cc79203..eae9643884 100644 --- a/video/stream_synchronization.cc +++ b/video/stream_synchronization.cc @@ -13,8 +13,10 @@ #include #include +#include #include "rtc_base/logging.h" +#include "system_wrappers/include/ntp_time.h" namespace webrtc { diff --git a/video/stream_synchronization.h b/video/stream_synchronization.h index 61073cb4b2..e34036f0b3 100644 --- a/video/stream_synchronization.h +++ b/video/stream_synchronization.h @@ -13,7 +13,7 @@ #include -#include "system_wrappers/include/rtp_to_ntp_estimator.h" +#include "rtc_base/rtp_to_ntp_estimator.h" namespace webrtc { diff --git a/video/stream_synchronization_unittest.cc b/video/stream_synchronization_unittest.cc index b733a1d2cf..e99e7f99e1 100644 --- a/video/stream_synchronization_unittest.cc +++ b/video/stream_synchronization_unittest.cc @@ -11,7 +11,9 @@ #include "video/stream_synchronization.h" #include +#include +#include "rtc_base/rtp_to_ntp_estimator.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/ntp_time.h" #include "test/gtest.h" diff --git a/video/sv_loopback.cc b/video/sv_loopback.cc index ee8075a7f1..4e9e3c0a91 100644 --- a/video/sv_loopback.cc +++ b/video/sv_loopback.cc @@ -26,7 +26,6 @@ #include "rtc_base/logging.h" #include "rtc_base/string_encode.h" #include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/run_test.h" #include "test/test_flags.h" diff --git a/video/task_queue_frame_decode_scheduler.cc b/video/task_queue_frame_decode_scheduler.cc index 624f8abf4a..569e1c62fc 100644 --- a/video/task_queue_frame_decode_scheduler.cc +++ b/video/task_queue_frame_decode_scheduler.cc @@ -11,11 +11,17 @@ #include "video/task_queue_frame_decode_scheduler.h" #include +#include +#include #include #include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "rtc_base/checks.h" +#include "system_wrappers/include/clock.h" +#include "video/frame_decode_timing.h" namespace webrtc { diff --git a/video/task_queue_frame_decode_scheduler.h b/video/task_queue_frame_decode_scheduler.h index 1d95c3e344..690a6b1b9e 100644 --- a/video/task_queue_frame_decode_scheduler.h +++ b/video/task_queue_frame_decode_scheduler.h @@ -11,7 +11,14 @@ #ifndef VIDEO_TASK_QUEUE_FRAME_DECODE_SCHEDULER_H_ #define VIDEO_TASK_QUEUE_FRAME_DECODE_SCHEDULER_H_ +#include +#include + +#include "api/task_queue/pending_task_safety_flag.h" +#include "api/task_queue/task_queue_base.h" +#include "system_wrappers/include/clock.h" #include "video/frame_decode_scheduler.h" +#include "video/frame_decode_timing.h" namespace webrtc { diff --git a/video/task_queue_frame_decode_scheduler_unittest.cc b/video/task_queue_frame_decode_scheduler_unittest.cc index 38b43e6e41..a4a36629f4 100644 --- a/video/task_queue_frame_decode_scheduler_unittest.cc +++ b/video/task_queue_frame_decode_scheduler_unittest.cc @@ -12,15 +12,15 @@ #include -#include +#include #include -#include #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" +#include "video/frame_decode_timing.h" namespace webrtc { diff --git a/video/test/mock_video_stream_encoder.h b/video/test/mock_video_stream_encoder.h index f1cfc7f4a8..13a6b8fa80 100644 --- a/video/test/mock_video_stream_encoder.h +++ b/video/test/mock_video_stream_encoder.h @@ -10,9 +10,22 @@ #ifndef VIDEO_TEST_MOCK_VIDEO_STREAM_ENCODER_H_ #define VIDEO_TEST_MOCK_VIDEO_STREAM_ENCODER_H_ +#include +#include #include +#include "api/adaptation/resource.h" +#include "api/fec_controller_override.h" +#include "api/rtp_parameters.h" +#include "api/rtp_sender_interface.h" +#include "api/scoped_refptr.h" +#include "api/units/data_rate.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" +#include "api/video/video_source_interface.h" +#include "api/video_codecs/video_encoder.h" #include "test/gmock.h" +#include "video/config/video_encoder_config.h" #include "video/video_stream_encoder_interface.h" namespace webrtc { diff --git a/video/transport_adapter.cc b/video/transport_adapter.cc index b3116ea528..95e430f00e 100644 --- a/video/transport_adapter.cc +++ b/video/transport_adapter.cc @@ -10,6 +10,10 @@ #include "video/transport_adapter.h" +#include + +#include "api/array_view.h" +#include "api/call/transport.h" #include "rtc_base/checks.h" namespace webrtc { @@ -30,11 +34,12 @@ bool TransportAdapter::SendRtp(ArrayView packet, return transport_->SendRtp(packet, options); } -bool TransportAdapter::SendRtcp(ArrayView packet) { +bool TransportAdapter::SendRtcp(ArrayView packet, + const PacketOptions& options) { if (!enabled_.load()) return false; - return transport_->SendRtcp(packet); + return transport_->SendRtcp(packet, options); } void TransportAdapter::Enable() { diff --git a/video/transport_adapter.h b/video/transport_adapter.h index 28c113e6ee..1752851500 100644 --- a/video/transport_adapter.h +++ b/video/transport_adapter.h @@ -15,6 +15,7 @@ #include +#include "api/array_view.h" #include "api/call/transport.h" namespace webrtc { @@ -27,7 +28,8 @@ class TransportAdapter : public Transport { bool SendRtp(ArrayView packet, const PacketOptions& options) override; - bool SendRtcp(ArrayView packet) override; + bool SendRtcp(ArrayView packet, + const PacketOptions& options) override; void Enable(); void Disable(); diff --git a/video/unique_timestamp_counter_unittest.cc b/video/unique_timestamp_counter_unittest.cc index b703e84576..d2bca7fd10 100644 --- a/video/unique_timestamp_counter_unittest.cc +++ b/video/unique_timestamp_counter_unittest.cc @@ -9,6 +9,8 @@ */ #include "video/unique_timestamp_counter.h" +#include + #include "test/gtest.h" namespace webrtc { diff --git a/video/video_analyzer.cc b/video/video_analyzer.cc index 0cd9babf18..f25fc3be72 100644 --- a/video/video_analyzer.cc +++ b/video/video_analyzer.cc @@ -49,6 +49,7 @@ #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/cpu_info.h" #include "rtc_base/cpu_time.h" #include "rtc_base/logging.h" #include "rtc_base/memory_usage.h" @@ -59,7 +60,6 @@ #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/cpu_info.h" #include "test/gtest.h" #include "test/layer_filtering_transport.h" #include "test/rtp_file_reader.h" @@ -78,10 +78,10 @@ ABSL_FLAG(bool, namespace webrtc { namespace { -using ::webrtc::test::GetGlobalMetricsLogger; -using ::webrtc::test::ImprovementDirection; -using ::webrtc::test::Metric; -using ::webrtc::test::Unit; +using test::GetGlobalMetricsLogger; +using test::ImprovementDirection; +using test::Metric; +using test::Unit; constexpr TimeDelta kSendStatsPollingInterval = TimeDelta::Seconds(1); constexpr size_t kMaxComparisons = 10; @@ -169,8 +169,7 @@ VideoAnalyzer::VideoAnalyzer(test::LayerFilteringTransport* transport, // Also, don't allocate more than kMaxComparisonThreads, even if there are // spare cores. - uint32_t num_cores = CpuInfo::DetectNumberOfCores(); - RTC_DCHECK_GE(num_cores, 1); + uint32_t num_cores = cpu_info::DetectNumberOfCores(); static const uint32_t kMinCoresLeft = 4; static const uint32_t kMaxComparisonThreads = 8; @@ -337,8 +336,9 @@ bool VideoAnalyzer::SendRtp(ArrayView packet, return result; } -bool VideoAnalyzer::SendRtcp(ArrayView packet) { - return transport_->SendRtcp(packet); +bool VideoAnalyzer::SendRtcp(ArrayView packet, + const PacketOptions& options) { + return transport_->SendRtcp(packet, options); } void VideoAnalyzer::OnFrame(const VideoFrame& video_frame) { diff --git a/video/video_analyzer.h b/video/video_analyzer.h index 6d68a5daf8..8ccd353fc0 100644 --- a/video/video_analyzer.h +++ b/video/video_analyzer.h @@ -10,24 +10,43 @@ #ifndef VIDEO_VIDEO_ANALYZER_H_ #define VIDEO_VIDEO_ANALYZER_H_ +#include +#include +#include #include #include #include +#include #include #include #include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/call/transport.h" +#include "api/media_types.h" #include "api/numerics/samples_stats_counter.h" #include "api/task_queue/task_queue_base.h" #include "api/test/metrics/metric.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" +#include "call/audio_receive_stream.h" +#include "call/call.h" +#include "call/packet_receiver.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "modules/rtp_rtcp/source/rtp_packet.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" +#include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/event.h" -#include "rtc_base/numerics/running_statistics.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/platform_thread.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" +#include "system_wrappers/include/clock.h" #include "test/layer_filtering_transport.h" #include "test/rtp_file_writer.h" @@ -79,7 +98,8 @@ class VideoAnalyzer : public PacketReceiver, bool SendRtp(ArrayView packet, const PacketOptions& options) override; - bool SendRtcp(ArrayView packet) override; + bool SendRtcp(ArrayView packet, + const PacketOptions& options) override; void OnFrame(const VideoFrame& video_frame) override; void Wait(); diff --git a/video/video_loopback.cc b/video/video_loopback.cc index 09254d7e73..f2ab82509a 100644 --- a/video/video_loopback.cc +++ b/video/video_loopback.cc @@ -26,7 +26,6 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/run_test.h" #include "test/test_flags.h" @@ -443,9 +442,9 @@ int RunLoopbackTest(int argc, char* argv[]) { // InitFieldTrialsFromString stores the char*, so the char array must outlive // the application. const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials); - webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str()); + field_trial::InitFieldTrialsFromString(field_trials.c_str()); - webrtc::test::RunTest(webrtc::Loopback); + test::RunTest(Loopback); return 0; } } // namespace webrtc diff --git a/video/video_quality_observer2.cc b/video/video_quality_observer2.cc index 3c48fd2747..90354d44c0 100644 --- a/video/video_quality_observer2.cc +++ b/video/video_quality_observer2.cc @@ -13,8 +13,12 @@ #include #include #include +#include +#include #include +#include "api/video/video_codec_type.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" #include "system_wrappers/include/metrics.h" diff --git a/video/video_quality_observer2.h b/video/video_quality_observer2.h index e9b66c5dfd..d46d9f669f 100644 --- a/video/video_quality_observer2.h +++ b/video/video_quality_observer2.h @@ -18,7 +18,6 @@ #include #include "api/video/video_codec_type.h" -#include "api/video/video_content_type.h" #include "rtc_base/numerics/moving_average.h" #include "rtc_base/numerics/sample_counter.h" diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 39494cbe85..d4e1754f04 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -17,8 +17,10 @@ #include #include "absl/flags/flag.h" +#include "api/audio/create_audio_device_module.h" #include "api/call/transport.h" #include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/field_trials_view.h" #include "api/make_ref_counted.h" #include "api/rtc_event_log/rtc_event_log.h" @@ -70,7 +72,6 @@ #include "api/audio/builtin_audio_processing_builder.h" #include "api/fec_controller_override.h" #include "api/rtc_event_log_output_file.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/task_queue_base.h" #include "api/test/create_frame_generator.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" @@ -339,7 +340,7 @@ std::unique_ptr VideoQualityTest::CreateVideoDecoder( const SdpVideoFormat& format) { std::unique_ptr decoder; if (format.name == "FakeCodec") { - decoder = webrtc::FakeVideoDecoderFactory::CreateVideoDecoder(); + decoder = FakeVideoDecoderFactory::CreateVideoDecoder(); } else { decoder = decoder_factory_->Create(env, format); } @@ -408,8 +409,7 @@ std::unique_ptr VideoQualityTest::CreateVideoEncoder( VideoQualityTest::VideoQualityTest( std::unique_ptr injection_components) - : clock_(Clock::GetRealTimeClock()), - task_queue_factory_(CreateDefaultTaskQueueFactory()), + : env_(CreateEnvironment()), video_decoder_factory_( [this](const Environment& env, const SdpVideoFormat& format) { return this->CreateVideoDecoder(env, format); @@ -644,14 +644,14 @@ void VideoQualityTest::FillScalabilitySettings( const std::vector& sl_descriptors) { if (params->ss[video_idx].streams.empty() && params->ss[video_idx].infer_streams) { - webrtc::VideoEncoder::EncoderInfo encoder_info; - webrtc::VideoEncoderConfig encoder_config; + VideoEncoder::EncoderInfo encoder_info; + VideoEncoderConfig encoder_config; encoder_config.codec_type = PayloadStringToCodecType(params->video[video_idx].codec); encoder_config.content_type = params->screenshare[video_idx].enabled - ? webrtc::VideoEncoderConfig::ContentType::kScreen - : webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; + ? VideoEncoderConfig::ContentType::kScreen + : VideoEncoderConfig::ContentType::kRealtimeVideo; encoder_config.max_bitrate_bps = params->video[video_idx].max_bitrate_bps; encoder_config.min_transmit_bitrate_bps = params->video[video_idx].min_transmit_bps; @@ -737,7 +737,7 @@ void VideoQualityTest::SetupVideo(Transport* send_transport, RTC_CHECK(num_video_streams_ > 0); video_encoder_configs_.resize(num_video_streams_); std::string generic_codec_name; - webrtc::VideoEncoder::EncoderInfo encoder_info; + VideoEncoder::EncoderInfo encoder_info; for (size_t video_idx = 0; video_idx < num_video_streams_; ++video_idx) { VideoSendStream::Config config(send_transport); config.rtp.extmap_allow_mixed = true; @@ -1058,11 +1058,11 @@ void VideoQualityTest::SetupThumbnailCapturers(size_t num_thumbnail_streams) { for (size_t i = 0; i < num_thumbnail_streams; ++i) { auto frame_generator_capturer = std::make_unique( - clock_, + &env_.clock(), test::CreateSquareFrameGenerator(static_cast(thumbnail.width), static_cast(thumbnail.height), std::nullopt, std::nullopt), - thumbnail.max_framerate, *task_queue_factory_); + thumbnail.max_framerate, env_.task_queue_factory()); EXPECT_TRUE(frame_generator_capturer->Init()); thumbnail_capturers_.push_back(std::move(frame_generator_capturer)); } @@ -1109,8 +1109,8 @@ VideoQualityTest::CreateFrameGenerator(size_t video_idx) { params_.screenshare[video_idx].slide_change_interval); frame_generator = test::CreateScrollingInputFromYuvFilesFrameGenerator( - clock_, slides, kWidth, kHeight, params_.video[video_idx].width, - params_.video[video_idx].height, + &env_.clock(), slides, kWidth, kHeight, + params_.video[video_idx].width, params_.video[video_idx].height, params_.screenshare[video_idx].scroll_duration * 1000, kPauseDurationMs); } @@ -1170,8 +1170,8 @@ void VideoQualityTest::CreateCapturers() { ASSERT_TRUE(frame_generator); auto frame_generator_capturer = std::make_unique( - clock_, std::move(frame_generator), params_.video[video_idx].fps, - *task_queue_factory_); + &env_.clock(), std::move(frame_generator), + params_.video[video_idx].fps, env_.task_queue_factory()); EXPECT_TRUE(frame_generator_capturer->Init()); video_sources_[video_idx] = std::move(frame_generator_capturer); } @@ -1207,7 +1207,8 @@ VideoQualityTest::CreateSendTransport() { } return std::make_unique( task_queue(), - std::make_unique(clock_, std::move(network_behavior)), + std::make_unique(&env_.clock(), + std::move(network_behavior)), sender_call_.get(), test::VideoTestConstants::kPayloadTypeVP8, test::VideoTestConstants::kPayloadTypeVP9, params_.video[0].selected_tl, params_.ss[0].selected_sl, payload_type_map_, @@ -1227,7 +1228,8 @@ VideoQualityTest::CreateReceiveTransport() { } return std::make_unique( task_queue(), - std::make_unique(clock_, std::move(network_behavior)), + std::make_unique(&env_.clock(), + std::move(network_behavior)), receiver_call_.get(), payload_type_map_, GetRegisteredExtensions(), GetRegisteredExtensions()); } @@ -1306,7 +1308,7 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { test::VideoTestConstants::kSendRtxSsrcs[params_.ss[0].selected_stream], static_cast(params_.ss[0].selected_stream), params.ss[0].selected_sl, params_.video[0].selected_tl, - is_quick_test_enabled, clock_, params_.logging.rtp_dump_name, + is_quick_test_enabled, &env_.clock(), params_.logging.rtp_dump_name, task_queue()); SendTask(task_queue(), [&]() { @@ -1386,11 +1388,11 @@ scoped_refptr VideoQualityTest::CreateAudioDevice() { RTC_CHECK(com_initializer_->Succeeded()); RTC_CHECK(webrtc_win::core_audio_utility::IsSupported()); RTC_CHECK(webrtc_win::core_audio_utility::IsMMCSSSupported()); - return CreateWindowsCoreAudioAudioDeviceModule(task_queue_factory_.get()); + return CreateWindowsCoreAudioAudioDeviceModule(&env_.task_queue_factory()); #else // Use legacy factory method on all platforms except Windows. - return AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio, - task_queue_factory_.get()); + return CreateAudioDeviceModule(env_, + AudioDeviceModule::kPlatformDefaultAudio); #endif } @@ -1405,8 +1407,7 @@ void VideoQualityTest::InitializeAudioDevice(CallConfig* send_call_config, } else { // By default, create a test ADM which fakes audio. audio_device = TestAudioDeviceModule::Create( - task_queue_factory_.get(), - TestAudioDeviceModule::CreatePulsedNoiseCapturer(32000, 48000), + env_, TestAudioDeviceModule::CreatePulsedNoiseCapturer(32000, 48000), TestAudioDeviceModule::CreateDiscardRenderer(48000), 1.f); } RTC_CHECK(audio_device); @@ -1422,7 +1423,7 @@ void VideoQualityTest::InitializeAudioDevice(CallConfig* send_call_config, // The real ADM requires extra initialization: setting default devices, // setting up number of channels etc. Helper class also calls // AudioDeviceModule::Init(). - webrtc::adm_helpers::Init(audio_device.get()); + adm_helpers::Init(audio_device.get()); } else { audio_device->Init(); } @@ -1447,8 +1448,8 @@ void VideoQualityTest::SetupAudio(Transport* transport) { if (params_.call.send_side_bwe) { audio_send_config.rtp.extensions.push_back( - webrtc::RtpExtension(webrtc::RtpExtension::kTransportSequenceNumberUri, - kTransportSequenceNumberExtensionId)); + RtpExtension(RtpExtension::kTransportSequenceNumberUri, + kTransportSequenceNumberExtensionId)); audio_send_config.min_bitrate_bps = kOpusMinBitrateBps; audio_send_config.max_bitrate_bps = kOpusBitrateFbBps; // Only allow ANA when send-side BWE is enabled. diff --git a/video/video_quality_test.h b/video/video_quality_test.h index 4afe3977dc..ce9260cd0b 100644 --- a/video/video_quality_test.h +++ b/video/video_quality_test.h @@ -10,25 +10,41 @@ #ifndef VIDEO_VIDEO_QUALITY_TEST_H_ #define VIDEO_VIDEO_QUALITY_TEST_H_ +#include +#include #include #include #include #include +#include "api/audio/audio_device.h" +#include "api/call/transport.h" #include "api/environment/environment.h" -#include "api/fec_controller.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/task_queue/task_queue_base.h" -#include "api/task_queue/task_queue_factory.h" +#include "api/scoped_refptr.h" #include "api/test/frame_generator_interface.h" +#include "api/test/video/function_video_decoder_factory.h" +#include "api/test/video/function_video_encoder_factory.h" #include "api/test/video_quality_test_fixture.h" #include "api/video/video_bitrate_allocator_factory.h" +#include "api/video/video_frame.h" +#include "api/video/video_source_interface.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_decoder.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder.h" +#include "api/video_codecs/video_encoder_factory.h" +#include "call/call_config.h" #include "call/fake_network_pipe.h" -#include "media/engine/internal_decoder_factory.h" -#include "media/engine/internal_encoder_factory.h" +#include "call/video_receive_stream.h" +#include "call/video_send_stream.h" #include "test/call_test.h" +#include "test/direct_transport.h" #include "test/layer_filtering_transport.h" +#include "video/config/video_encoder_config.h" #include "video/video_analyzer.h" + #ifdef WEBRTC_WIN #include "modules/audio_device/win/core_audio_utility_win.h" #include "rtc_base/win/scoped_com_initializer.h" @@ -103,10 +119,9 @@ class VideoQualityTest : public test::CallTest, virtual std::unique_ptr CreateSendTransport(); virtual std::unique_ptr CreateReceiveTransport(); + const Environment env_; std::vector>> thumbnail_capturers_; - Clock* const clock_; - const std::unique_ptr task_queue_factory_; RtcEventLogFactory rtc_event_log_factory_; test::FunctionVideoDecoderFactory video_decoder_factory_; diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index 3aced70817..c7c1c30175 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -132,11 +132,11 @@ class WebRtcRecordableEncodedFrame : public RecordableEncodedFrame { return buffer_; } - std::optional color_space() const override { + std::optional color_space() const override { return color_space_; } - std::optional video_rotation() const override { + std::optional video_rotation() const override { return video_rotation_; } @@ -156,8 +156,8 @@ class WebRtcRecordableEncodedFrame : public RecordableEncodedFrame { VideoCodecType codec_; bool is_key_frame_; EncodedResolution resolution_; - std::optional color_space_; - std::optional video_rotation_; + std::optional color_space_; + std::optional video_rotation_; }; RenderResolution InitialDecoderResolution(const FieldTrialsView& field_trials) { @@ -174,21 +174,21 @@ RenderResolution InitialDecoderResolution(const FieldTrialsView& field_trials) { // Video decoder class to be used for unknown codecs. Doesn't support decoding // but logs messages to LS_ERROR. -class NullVideoDecoder : public webrtc::VideoDecoder { +class NullVideoDecoder : public VideoDecoder { public: bool Configure(const Settings& settings) override { RTC_LOG(LS_ERROR) << "Can't initialize NullVideoDecoder."; return true; } - int32_t Decode(const webrtc::EncodedImage& input_image, + int32_t Decode(const EncodedImage& input_image, int64_t render_time_ms) override { RTC_LOG(LS_ERROR) << "The NullVideoDecoder doesn't support decoding."; return WEBRTC_VIDEO_CODEC_OK; } int32_t RegisterDecodeCompleteCallback( - webrtc::DecodedImageCallback* callback) override { + DecodedImageCallback* callback) override { RTC_LOG(LS_ERROR) << "Can't register decode complete callback on NullVideoDecoder."; return WEBRTC_VIDEO_CODEC_OK; @@ -710,7 +710,7 @@ void VideoReceiveStream2::OnFrame(const VideoFrame& video_frame) { frame_meta.decode_timestamp); })); - webrtc::MutexLock lock(&pending_resolution_mutex_); + MutexLock lock(&pending_resolution_mutex_); if (pending_resolution_.has_value()) { if (!pending_resolution_->empty() && (video_frame.width() != static_cast(pending_resolution_->width) || @@ -729,7 +729,7 @@ void VideoReceiveStream2::OnFrame(const VideoFrame& video_frame) { } void VideoReceiveStream2::SetFrameDecryptor( - scoped_refptr frame_decryptor) { + scoped_refptr frame_decryptor) { rtp_video_stream_receiver_.SetFrameDecryptor(std::move(frame_decryptor)); } @@ -973,7 +973,7 @@ int VideoReceiveStream2::DecodeAndMaybeDispatchEncodedFrame( RTC_LOG(LS_ERROR) << "About to halt recordable encoded frame output due " "to too many buffered frames."; - webrtc::MutexLock lock(&pending_resolution_mutex_); + MutexLock lock(&pending_resolution_mutex_); if (IsKeyFrameAndUnspecifiedResolution(*frame_ptr) && !pending_resolution_.has_value()) pending_resolution_.emplace(); @@ -1001,7 +1001,7 @@ int VideoReceiveStream2::DecodeAndMaybeDispatchEncodedFrame( { // Fish out `pending_resolution_` to avoid taking the mutex on every lap // or dispatching under the mutex in the flush loop. - webrtc::MutexLock lock(&pending_resolution_mutex_); + MutexLock lock(&pending_resolution_mutex_); if (pending_resolution_.has_value()) pending_resolution = *pending_resolution_; } @@ -1134,7 +1134,7 @@ void VideoReceiveStream2::UpdatePlayoutDelays() const { } } -std::vector VideoReceiveStream2::GetSources() const { +std::vector VideoReceiveStream2::GetSources() const { RTC_DCHECK_RUN_ON(&worker_sequence_checker_); return source_tracker_.GetSources(); } diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index 2feb51bb20..b19e0017e3 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -22,6 +22,7 @@ #include #include "absl/memory/memory.h" +#include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/metronome/test/fake_metronome.h" @@ -214,7 +215,9 @@ class VideoReceiveStream2Test : public ::testing::TestWithParam { .WillByDefault(Invoke(&fake_decoder_, &test::FakeDecoder::Release)); ON_CALL(mock_transport_, SendRtcp) .WillByDefault( - Invoke(&rtcp_packet_parser_, &test::RtcpPacketParser::Parse)); + Invoke([this](ArrayView packet, ::testing::Unused) { + return rtcp_packet_parser_.Parse(packet); + })); } ~VideoReceiveStream2Test() override { @@ -254,12 +257,10 @@ class VideoReceiveStream2Test : public ::testing::TestWithParam { video_receive_stream_ = nullptr; } timing_ = new VCMTiming(&env_.clock(), env_.field_trials()); - video_receive_stream_ = - std::make_unique( - env_, &fake_call_, kDefaultNumCpuCores, &packet_router_, - config_.Copy(), &call_stats_, absl::WrapUnique(timing_), - &nack_periodic_processor_, - UseMetronome() ? &decode_sync_ : nullptr); + video_receive_stream_ = std::make_unique( + env_, &fake_call_, kDefaultNumCpuCores, &packet_router_, config_.Copy(), + &call_stats_, absl::WrapUnique(timing_), &nack_periodic_processor_, + UseMetronome() ? &decode_sync_ : nullptr); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); if (state) @@ -280,7 +281,7 @@ class VideoReceiveStream2Test : public ::testing::TestWithParam { test::RtcpPacketParser rtcp_packet_parser_; PacketRouter packet_router_; RtpStreamReceiverController rtp_stream_receiver_controller_; - std::unique_ptr video_receive_stream_; + std::unique_ptr video_receive_stream_; VCMTiming* timing_; test::FakeMetronome fake_metronome_; DecodeSynchronizer decode_sync_; @@ -592,7 +593,7 @@ TEST_P(VideoReceiveStream2Test, PassesNtpTime) { } TEST_P(VideoReceiveStream2Test, PassesRotation) { - const webrtc::VideoRotation kRotation = webrtc::kVideoRotation_180; + const VideoRotation kRotation = kVideoRotation_180; std::unique_ptr test_frame = test::FakeFrameBuilder() .Id(0) diff --git a/video/video_receive_stream_timeout_tracker.cc b/video/video_receive_stream_timeout_tracker.cc index 0409f26560..e966f2c8b7 100644 --- a/video/video_receive_stream_timeout_tracker.cc +++ b/video/video_receive_stream_timeout_tracker.cc @@ -13,7 +13,14 @@ #include #include +#include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/task_utils/repeating_task.h" +#include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/video/video_receive_stream_timeout_tracker.h b/video/video_receive_stream_timeout_tracker.h index c15aa70e92..7672d1760d 100644 --- a/video/video_receive_stream_timeout_tracker.h +++ b/video/video_receive_stream_timeout_tracker.h @@ -13,10 +13,12 @@ #include +#include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "rtc_base/task_utils/repeating_task.h" +#include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/video/video_receive_stream_timeout_tracker_unittest.cc b/video/video_receive_stream_timeout_tracker_unittest.cc index ea3bf896b8..72a51df162 100644 --- a/video/video_receive_stream_timeout_tracker_unittest.cc +++ b/video/video_receive_stream_timeout_tracker_unittest.cc @@ -10,10 +10,10 @@ #include "video/video_receive_stream_timeout_tracker.h" -#include #include -#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" diff --git a/video/video_send_stream_impl.cc b/video/video_send_stream_impl.cc index dfcb9a30e9..c0c8dff453 100644 --- a/video/video_send_stream_impl.cc +++ b/video/video_send_stream_impl.cc @@ -53,7 +53,6 @@ #include "call/rtp_config.h" #include "call/rtp_transport_controller_send_interface.h" #include "call/video_send_stream.h" -#include "media/base/media_constants.h" #include "media/base/sdp_video_format_utils.h" #include "modules/pacing/pacing_controller.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" @@ -68,7 +67,6 @@ #include "rtc_base/experiments/rate_control_settings.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" -#include "rtc_base/strings/string_builder.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/clock.h" @@ -230,10 +228,9 @@ int GetEncoderPriorityBitrate(std::string codec_name, const FieldTrialsView& field_trials) { int priority_bitrate = 0; if (PayloadStringToCodecType(codec_name) == VideoCodecType::kVideoCodecAV1) { - webrtc::FieldTrialParameter av1_priority_bitrate("bitrate", 0); - webrtc::ParseFieldTrial( - {&av1_priority_bitrate}, - field_trials.Lookup("WebRTC-AV1-OverridePriorityBitrate")); + FieldTrialParameter av1_priority_bitrate("bitrate", 0); + ParseFieldTrial({&av1_priority_bitrate}, + field_trials.Lookup("WebRTC-AV1-OverridePriorityBitrate")); priority_bitrate = av1_priority_bitrate; } return priority_bitrate; @@ -250,8 +247,12 @@ uint32_t GetInitialEncoderMaxBitrate(int initial_encoder_max_bitrate) { // reasonable use cases as it allows adding the max of multiple streams // without wrappping around. const int kFallbackMaxBitrateBps = 10000000; - RTC_DLOG(LS_ERROR) << "ERROR: Initial encoder max bitrate = " - << initial_encoder_max_bitrate << " which is <= 0!"; + // Don't log an error for -1 since this is the default value that is used to + // signal that the max bitrate is unset. + if (initial_encoder_max_bitrate != -1) { + RTC_DLOG(LS_ERROR) << "ERROR: Initial encoder max bitrate = " + << initial_encoder_max_bitrate << " which is <= 0!"; + } RTC_DLOG(LS_INFO) << "Using default encoder max bitrate = 10 Mbps"; return kFallbackMaxBitrateBps; } @@ -297,9 +298,8 @@ size_t CalculateMaxHeaderSize(const RtpConfig& config) { VideoStreamEncoder::BitrateAllocationCallbackType GetBitrateAllocationCallbackType(const VideoSendStream::Config& config, const FieldTrialsView& field_trials) { - if (webrtc::RtpExtension::FindHeaderExtensionByUri( - config.rtp.extensions, - webrtc::RtpExtension::kVideoLayersAllocationUri, + if (RtpExtension::FindHeaderExtensionByUri( + config.rtp.extensions, RtpExtension::kVideoLayersAllocationUri, config.crypto_options.srtp.enable_encrypted_rtp_header_extensions ? RtpExtension::Filter::kPreferEncryptedExtension : RtpExtension::Filter::kDiscardEncryptedExtension)) { @@ -347,7 +347,7 @@ std::unique_ptr CreateVideoStreamEncoder( VideoStreamEncoder::BitrateAllocationCallbackType bitrate_allocation_callback_type, Metronome* metronome, - webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector) { + VideoEncoderFactory::EncoderSelectorInterface* encoder_selector) { std::unique_ptr encoder_queue = env.task_queue_factory().CreateTaskQueue( "EncoderQueue", TaskQueueFactory::Priority::NORMAL); @@ -540,7 +540,7 @@ VideoSendStreamImpl::GetAdaptationResources() { } void VideoSendStreamImpl::SetSource( - VideoSourceInterface* source, + VideoSourceInterface* source, const DegradationPreference& degradation_preference) { RTC_DCHECK_RUN_ON(&thread_checker_); video_stream_encoder_->SetSource(source, degradation_preference); diff --git a/video/video_send_stream_impl.h b/video/video_send_stream_impl.h index fec8962c01..646d4e4c53 100644 --- a/video/video_send_stream_impl.h +++ b/video/video_send_stream_impl.h @@ -20,13 +20,26 @@ #include #include +#include "api/adaptation/resource.h" +#include "api/call/bitrate_allocation.h" #include "api/environment/environment.h" +#include "api/fec_controller.h" #include "api/field_trials_view.h" #include "api/metronome/metronome.h" +#include "api/rtp_parameters.h" +#include "api/rtp_sender_interface.h" +#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "api/video/encoded_image.h" #include "api/video/video_bitrate_allocation.h" +#include "api/video/video_frame.h" +#include "api/video/video_layers_allocation.h" +#include "api/video/video_source_interface.h" #include "api/video_codecs/video_encoder.h" #include "call/bitrate_allocator.h" #include "call/rtp_config.h" diff --git a/video/video_send_stream_impl_unittest.cc b/video/video_send_stream_impl_unittest.cc index a298a017ba..f0023f12b9 100644 --- a/video/video_send_stream_impl_unittest.cc +++ b/video/video_send_stream_impl_unittest.cc @@ -22,7 +22,6 @@ #include "api/array_view.h" #include "api/call/bitrate_allocation.h" -#include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_parameters.h" @@ -56,7 +55,6 @@ #include "video/send_delay_stats.h" #include "video/send_statistics_proxy.h" #include "video/test/mock_video_stream_encoder.h" -#include "video/video_stream_encoder.h" #include "video/video_stream_encoder_interface.h" namespace webrtc { @@ -128,8 +126,7 @@ class MockRtpVideoSender : public RtpVideoSenderInterface { MOCK_METHOD(void, SetEncodingData, (size_t, size_t, size_t), (override)); MOCK_METHOD(std::vector, GetSentRtpPacketInfos, - (uint32_t ssrc, - webrtc::ArrayView sequence_numbers), + (uint32_t ssrc, ArrayView sequence_numbers), (const, override)); MOCK_METHOD(void, SetFecAllowed, (bool fec_allowed), (override)); @@ -219,7 +216,7 @@ class VideoSendStreamImplTest : public ::testing::Test { protected: GlobalSimulatedTimeController time_controller_; - webrtc::test::ScopedKeyValueConfig field_trials_; + test::ScopedKeyValueConfig field_trials_; NiceMock transport_; NiceMock transport_controller_; NiceMock bitrate_allocator_; diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 69e0c8edf3..9b0b57763d 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -101,7 +101,6 @@ #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" #include "rtc_base/unique_id_generator.h" -#include "system_wrappers/include/sleep.h" #include "test/call_test.h" #include "test/configurable_frame_size_encoder.h" #include "test/encoder_settings.h" @@ -126,7 +125,7 @@ namespace webrtc { namespace test { class VideoSendStreamPeer { public: - explicit VideoSendStreamPeer(webrtc::VideoSendStream* base_class_stream) + explicit VideoSendStreamPeer(VideoSendStream* base_class_stream) : internal_stream_( static_cast(base_class_stream)) {} std::optional GetPacingFactorOverride() const { @@ -1534,11 +1533,12 @@ TEST_F(VideoSendStreamTest, PaddingIsPrimarilyRetransmissions) { // TODO(isheriff): Some platforms do not ramp up as expected to full // capacity due to packet scheduling delays. Fix that before getting // rid of this. - SleepMs(5000); + Thread::SleepMs(5000); { MutexLock lock(&mutex_); - // Expect padding to be a small percentage of total bytes sent. - EXPECT_LT(padding_length_, .1 * total_length_); + // Expect padding to be some percentage of total bytes sent. + // BWE uses padding to ramp up after network has recovered from loss. + EXPECT_LT(padding_length_, .6 * total_length_); } } @@ -1754,8 +1754,8 @@ TEST_F(VideoSendStreamTest, ChangingNetworkRoute) { } private: - webrtc::SequenceChecker module_process_thread_; - webrtc::SequenceChecker task_queue_thread_; + SequenceChecker module_process_thread_; + SequenceChecker task_queue_thread_; TaskQueueBase* const task_queue_; RtpHeaderExtensionMap extensions_; Call* call_ RTC_GUARDED_BY(task_queue_thread_); @@ -1771,7 +1771,7 @@ TEST_F(VideoSendStreamTest, DISABLED_RelayToDirectRoute) { static const int kStartBitrateBps = 300000; static const int kRelayBandwidthCapBps = 800000; static const int kMinPacketsToSend = 100; - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-Bwe-NetworkRouteConstraints/relay_cap:" + std::to_string(kRelayBandwidthCapBps) + "bps/"); @@ -1858,8 +1858,8 @@ TEST_F(VideoSendStreamTest, DISABLED_RelayToDirectRoute) { } private: - webrtc::SequenceChecker module_process_thread_; - webrtc::SequenceChecker task_queue_thread_; + SequenceChecker module_process_thread_; + SequenceChecker task_queue_thread_; TaskQueueBase* const task_queue_; Call* call_ RTC_GUARDED_BY(task_queue_thread_); int packets_sent_ RTC_GUARDED_BY(task_queue_thread_); @@ -2049,11 +2049,11 @@ class MaxPaddingSetTest : public test::SendTest { } private: - webrtc::SequenceChecker task_queue_thread_; + SequenceChecker task_queue_thread_; Call* call_ RTC_GUARDED_BY(task_queue_thread_) = nullptr; VideoSendStream::Config send_stream_config_{nullptr}; VideoEncoderConfig encoder_config_; - webrtc::SequenceChecker module_process_thread_; + SequenceChecker module_process_thread_; uint32_t packets_sent_ RTC_GUARDED_BY(task_queue_thread_) = 0; bool running_without_padding_ RTC_GUARDED_BY(task_queue_thread_); T* const stream_resetter_; @@ -2729,7 +2729,7 @@ TEST_F(VideoSendStreamTest, ReconfigureBitratesSetsEncoderBitratesCorrectly) { // TODO(bugs.webrtc.org/12058): If these fields trial are on, we get lower // bitrates than expected by this test, due to encoder pushback and subtracted // overhead. - webrtc::test::ScopedKeyValueConfig field_trials( + test::ScopedKeyValueConfig field_trials( field_trials_, "WebRTC-VideoRateControl/bitrate_adjuster:false/"); class EncoderBitrateThresholdObserver : public test::SendTest, @@ -2919,11 +2919,11 @@ TEST_F(VideoSendStreamTest, ReconfigureBitratesSetsEncoderBitratesCorrectly) { int num_rate_allocator_creations_; int num_encoder_initializations_; - webrtc::Call* call_; - webrtc::VideoSendStream* send_stream_; + Call* call_; + VideoSendStream* send_stream_; test::VideoEncoderProxyFactory encoder_factory_; std::unique_ptr bitrate_allocator_factory_; - webrtc::VideoEncoderConfig encoder_config_; + VideoEncoderConfig encoder_config_; } test(env(), task_queue()); RunBaseTest(&test); @@ -3380,7 +3380,7 @@ class Vp9HeaderObserver : public test::SendTest { test::FunctionVideoEncoderFactory encoder_factory_; const Vp9TestParams params_; VideoCodecVP9 vp9_settings_; - webrtc::VideoEncoderConfig encoder_config_; + VideoEncoderConfig encoder_config_; bool last_packet_marker_ = false; std::optional last_packet_sequence_number_; std::optional last_packet_timestamp_; @@ -3979,7 +3979,7 @@ class ContentSwitchTest : public test::SendTest { internal_send_peer.GetPacingFactorOverride().value_or(0.0f); float expected_pacing_factor = 1.1; // Strict pacing factor. VideoSendStream::Stats stats = send_stream_->GetStats(); - if (stats.content_type == webrtc::VideoContentType::SCREENSHARE) { + if (stats.content_type == VideoContentType::SCREENSHARE) { expected_pacing_factor = 1.0f; // Currently used pacing factor in ALR. } @@ -4123,7 +4123,7 @@ void VideoSendStreamTest::TestTemporalLayers( VideoSendStream::Config* send_config, std::vector* receive_configs, VideoEncoderConfig* encoder_config) override { - webrtc::VideoEncoder::EncoderInfo encoder_info; + VideoEncoder::EncoderInfo encoder_info; send_config->encoder_settings.encoder_factory = encoder_factory_; send_config->rtp.payload_name = payload_name_; send_config->rtp.payload_type = diff --git a/video/video_source_sink_controller.cc b/video/video_source_sink_controller.cc index 51316f8b0c..92c65d8988 100644 --- a/video/video_source_sink_controller.cc +++ b/video/video_source_sink_controller.cc @@ -11,12 +11,19 @@ #include "video/video_source_sink_controller.h" #include +#include #include +#include #include - -#include "rtc_base/logging.h" +#include + +#include "api/sequence_checker.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video/video_source_interface.h" +#include "call/adaptation/video_source_restrictions.h" +#include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" -#include "rtc_base/strings/string_builder.h" namespace webrtc { diff --git a/video/video_source_sink_controller.h b/video/video_source_sink_controller.h index 451c59479e..53d2638c47 100644 --- a/video/video_source_sink_controller.h +++ b/video/video_source_sink_controller.h @@ -11,8 +11,8 @@ #ifndef VIDEO_VIDEO_SOURCE_SINK_CONTROLLER_H_ #define VIDEO_VIDEO_SOURCE_SINK_CONTROLLER_H_ +#include #include -#include #include #include "api/sequence_checker.h" @@ -21,6 +21,7 @@ #include "api/video/video_source_interface.h" #include "call/adaptation/video_source_restrictions.h" #include "rtc_base/system/no_unique_address.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/video/video_source_sink_controller_unittest.cc b/video/video_source_sink_controller_unittest.cc index a1df43a71e..603c726a8c 100644 --- a/video/video_source_sink_controller_unittest.cc +++ b/video/video_source_sink_controller_unittest.cc @@ -11,8 +11,10 @@ #include "video/video_source_sink_controller.h" #include +#include #include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" #include "call/adaptation/video_source_restrictions.h" #include "test/gmock.h" @@ -41,13 +43,9 @@ class MockVideoSourceWithVideoFrame : public VideoSourceInterface { MOCK_METHOD(void, AddOrUpdateSink, - (webrtc::VideoSinkInterface*, - const webrtc::VideoSinkWants&), - (override)); - MOCK_METHOD(void, - RemoveSink, - (webrtc::VideoSinkInterface*), + (VideoSinkInterface*, const VideoSinkWants&), (override)); + MOCK_METHOD(void, RemoveSink, (VideoSinkInterface*), (override)); MOCK_METHOD(void, RequestRefreshFrame, (), (override)); }; diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc index 83de75ac3f..93bb147802 100644 --- a/video/video_stream_buffer_controller.cc +++ b/video/video_stream_buffer_controller.cc @@ -11,12 +11,15 @@ #include "video/video_stream_buffer_controller.h" #include +#include +#include #include #include #include -#include "absl/base/attributes.h" +#include "absl/container/inlined_vector.h" #include "absl/functional/bind_front.h" +#include "api/field_trials_view.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" #include "api/units/data_size.h" @@ -25,15 +28,17 @@ #include "api/video/encoded_frame.h" #include "api/video/frame_buffer.h" #include "api/video/video_content_type.h" +#include "api/video/video_timing.h" #include "modules/video_coding/frame_helpers.h" +#include "modules/video_coding/include/video_coding_defines.h" #include "modules/video_coding/timing/inter_frame_delay_variation_calculator.h" #include "modules/video_coding/timing/jitter_estimator.h" +#include "modules/video_coding/timing/timing.h" #include "rtc_base/checks.h" +#include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/logging.h" -#include "rtc_base/thread_annotations.h" #include "video/frame_decode_scheduler.h" #include "video/frame_decode_timing.h" -#include "video/task_queue_frame_decode_scheduler.h" #include "video/video_receive_stream_timeout_tracker.h" namespace webrtc { diff --git a/video/video_stream_buffer_controller.h b/video/video_stream_buffer_controller.h index 43d4544f71..17227871cc 100644 --- a/video/video_stream_buffer_controller.h +++ b/video/video_stream_buffer_controller.h @@ -11,18 +11,32 @@ #ifndef VIDEO_VIDEO_STREAM_BUFFER_CONTROLLER_H_ #define VIDEO_VIDEO_STREAM_BUFFER_CONTROLLER_H_ +#include +#include #include +#include +#include "absl/container/inlined_vector.h" #include "api/field_trials_view.h" +#include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "api/video/encoded_frame.h" #include "api/video/frame_buffer.h" +#include "api/video/video_content_type.h" +#include "api/video/video_timing.h" #include "modules/video_coding/include/video_coding_defines.h" #include "modules/video_coding/timing/inter_frame_delay_variation_calculator.h" #include "modules/video_coding/timing/jitter_estimator.h" #include "modules/video_coding/timing/timing.h" +#include "rtc_base/experiments/field_trial_parser.h" +#include "rtc_base/system/no_unique_address.h" +#include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" -#include "video/decode_synchronizer.h" +#include "video/frame_decode_scheduler.h" +#include "video/frame_decode_timing.h" #include "video/video_receive_stream_timeout_tracker.h" namespace webrtc { diff --git a/video/video_stream_buffer_controller_unittest.cc b/video/video_stream_buffer_controller_unittest.cc index 6987e4a503..08a15338c1 100644 --- a/video/video_stream_buffer_controller_unittest.cc +++ b/video/video_stream_buffer_controller_unittest.cc @@ -12,6 +12,7 @@ #include +#include #include #include #include @@ -25,9 +26,12 @@ #include "api/units/frequency.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "api/video/encoded_frame.h" #include "api/video/video_content_type.h" #include "api/video/video_timing.h" +#include "modules/video_coding/timing/timing.h" #include "rtc_base/checks.h" +#include "system_wrappers/include/clock.h" #include "test/fake_encoded_frame.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/video/video_stream_decoder2.cc b/video/video_stream_decoder2.cc index 51175b7717..02b3db821e 100644 --- a/video/video_stream_decoder2.cc +++ b/video/video_stream_decoder2.cc @@ -15,6 +15,7 @@ #include "api/units/time_delta.h" #include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" #include "api/video_codecs/video_decoder.h" #include "modules/video_coding/video_receiver2.h" #include "rtc_base/checks.h" diff --git a/video/video_stream_decoder2.h b/video/video_stream_decoder2.h index 616ec12ed1..dad603605a 100644 --- a/video/video_stream_decoder2.h +++ b/video/video_stream_decoder2.h @@ -12,18 +12,11 @@ #define VIDEO_VIDEO_STREAM_DECODER2_H_ #include -#include -#include -#include -#include -#include "api/scoped_refptr.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "api/video_codecs/video_decoder.h" -#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" #include "modules/video_coding/include/video_coding_defines.h" -#include "rtc_base/platform_thread.h" namespace webrtc { diff --git a/video/video_stream_decoder_impl_unittest.cc b/video/video_stream_decoder_impl_unittest.cc deleted file mode 100644 index 6942e06679..0000000000 --- a/video/video_stream_decoder_impl_unittest.cc +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "video/video_stream_decoder_impl.h" - -#include - -#include "api/video/i420_buffer.h" -#include "api/video_codecs/video_decoder.h" -#include "test/fake_encoded_frame.h" -#include "test/gmock.h" -#include "test/gtest.h" -#include "test/scoped_key_value_config.h" -#include "test/time_controller/simulated_time_controller.h" - -namespace webrtc { -namespace { -using ::testing::_; -using ::testing::NiceMock; -using ::testing::Return; - -class MockVideoStreamDecoderCallbacks - : public VideoStreamDecoderInterface::Callbacks { - public: - MOCK_METHOD(void, OnNonDecodableState, (), (override)); - MOCK_METHOD(void, OnContinuousUntil, (int64_t frame_id), (override)); - MOCK_METHOD( - void, - OnDecodedFrame, - (VideoFrame frame, - const VideoStreamDecoderInterface::Callbacks::FrameInfo& frame_info), - (override)); -}; - -class StubVideoDecoder : public VideoDecoder { - public: - StubVideoDecoder() { ON_CALL(*this, Configure).WillByDefault(Return(true)); } - - MOCK_METHOD(bool, Configure, (const Settings&), (override)); - - int32_t Decode(const EncodedImage& input_image, - bool missing_frames, - int64_t render_time_ms) override { - int32_t ret_code = DecodeCall(input_image, missing_frames, render_time_ms); - if (ret_code == WEBRTC_VIDEO_CODEC_OK || - ret_code == WEBRTC_VIDEO_CODEC_OK_REQUEST_KEYFRAME) { - VideoFrame frame = VideoFrame::Builder() - .set_video_frame_buffer(I420Buffer::Create(1, 1)) - .build(); - callback_->Decoded(frame); - } - return ret_code; - } - - MOCK_METHOD(int32_t, - DecodeCall, - (const EncodedImage& input_image, - bool missing_frames, - int64_t render_time_ms), - ()); - - int32_t Release() override { return 0; } - - int32_t RegisterDecodeCompleteCallback( - DecodedImageCallback* callback) override { - callback_ = callback; - return 0; - } - - private: - DecodedImageCallback* callback_; -}; - -class WrappedVideoDecoder : public VideoDecoder { - public: - explicit WrappedVideoDecoder(StubVideoDecoder* decoder) : decoder_(decoder) {} - - bool Configure(const Settings& settings) override { - return decoder_->Configure(settings); - } - int32_t Decode(const EncodedImage& input_image, - bool missing_frames, - int64_t render_time_ms) override { - return decoder_->Decode(input_image, missing_frames, render_time_ms); - } - int32_t Release() override { return decoder_->Release(); } - - int32_t RegisterDecodeCompleteCallback( - DecodedImageCallback* callback) override { - return decoder_->RegisterDecodeCompleteCallback(callback); - } - - private: - StubVideoDecoder* decoder_; -}; - -class FakeVideoDecoderFactory : public VideoDecoderFactory { - public: - std::vector GetSupportedFormats() const override { - return {}; - } - std::unique_ptr CreateVideoDecoder( - const SdpVideoFormat& format) override { - if (format.name == "VP8") { - return std::make_unique(&vp8_decoder_); - } - - if (format.name == "AV1") { - return std::make_unique(&av1_decoder_); - } - - return {}; - } - - StubVideoDecoder& Vp8Decoder() { return vp8_decoder_; } - StubVideoDecoder& Av1Decoder() { return av1_decoder_; } - - private: - NiceMock vp8_decoder_; - NiceMock av1_decoder_; -}; - -class VideoStreamDecoderImplTest : public ::testing::Test { - public: - VideoStreamDecoderImplTest() - : time_controller_(Timestamp::Seconds(0)), - video_stream_decoder_( - &callbacks_, - &decoder_factory_, - time_controller_.GetTaskQueueFactory(), - {{1, std::make_pair(SdpVideoFormat::VP8(), 1)}, - {2, std::make_pair(SdpVideoFormat::AV1Profile0(), 1)}}, - &field_trials_) { - // Set the min playout delay to a value greater than zero to not activate - // the low-latency renderer. - video_stream_decoder_.SetMinPlayoutDelay(TimeDelta::Millis(10)); - } - - test::ScopedKeyValueConfig field_trials_; - NiceMock callbacks_; - FakeVideoDecoderFactory decoder_factory_; - GlobalSimulatedTimeController time_controller_; - VideoStreamDecoderImpl video_stream_decoder_; -}; - -TEST_F(VideoStreamDecoderImplTest, InsertAndDecodeFrame) { - video_stream_decoder_.OnFrame( - test::FakeFrameBuilder().PayloadType(1).AsLast().Build()); - EXPECT_CALL(callbacks_, OnDecodedFrame); - time_controller_.AdvanceTime(TimeDelta::Millis(1)); -} - -TEST_F(VideoStreamDecoderImplTest, NonDecodableStateWaitingForKeyframe) { - EXPECT_CALL(callbacks_, OnNonDecodableState); - time_controller_.AdvanceTime(TimeDelta::Millis(200)); -} - -TEST_F(VideoStreamDecoderImplTest, NonDecodableStateWaitingForDeltaFrame) { - video_stream_decoder_.OnFrame( - test::FakeFrameBuilder().PayloadType(1).AsLast().Build()); - EXPECT_CALL(callbacks_, OnDecodedFrame); - time_controller_.AdvanceTime(TimeDelta::Millis(1)); - EXPECT_CALL(callbacks_, OnNonDecodableState); - time_controller_.AdvanceTime(TimeDelta::Millis(3000)); -} - -TEST_F(VideoStreamDecoderImplTest, InsertAndDecodeFrameWithKeyframeRequest) { - video_stream_decoder_.OnFrame( - test::FakeFrameBuilder().PayloadType(1).AsLast().Build()); - EXPECT_CALL(decoder_factory_.Vp8Decoder(), DecodeCall) - .WillOnce(Return(WEBRTC_VIDEO_CODEC_OK_REQUEST_KEYFRAME)); - EXPECT_CALL(callbacks_, OnDecodedFrame); - EXPECT_CALL(callbacks_, OnNonDecodableState); - time_controller_.AdvanceTime(TimeDelta::Millis(1)); -} - -TEST_F(VideoStreamDecoderImplTest, FailToInitDecoder) { - video_stream_decoder_.OnFrame( - test::FakeFrameBuilder() - .ReceivedTime(time_controller_.GetClock()->CurrentTime()) - .PayloadType(1) - .AsLast() - .Build()); - ON_CALL(decoder_factory_.Vp8Decoder(), Configure) - .WillByDefault(Return(false)); - EXPECT_CALL(callbacks_, OnNonDecodableState); - time_controller_.AdvanceTime(TimeDelta::Millis(1)); -} - -TEST_F(VideoStreamDecoderImplTest, FailToDecodeFrame) { - video_stream_decoder_.OnFrame( - test::FakeFrameBuilder().PayloadType(1).AsLast().Build()); - ON_CALL(decoder_factory_.Vp8Decoder(), DecodeCall) - .WillByDefault(Return(WEBRTC_VIDEO_CODEC_ERROR)); - EXPECT_CALL(callbacks_, OnNonDecodableState); - time_controller_.AdvanceTime(TimeDelta::Millis(1)); -} - -TEST_F(VideoStreamDecoderImplTest, ChangeFramePayloadType) { - constexpr TimeDelta kFrameInterval = TimeDelta::Millis(1000 / 60); - video_stream_decoder_.OnFrame( - test::FakeFrameBuilder().PayloadType(1).Id(0).AsLast().Build()); - EXPECT_CALL(decoder_factory_.Vp8Decoder(), DecodeCall); - EXPECT_CALL(callbacks_, OnDecodedFrame); - time_controller_.AdvanceTime(kFrameInterval); - - video_stream_decoder_.OnFrame( - test::FakeFrameBuilder().PayloadType(2).Id(1).AsLast().Build()); - EXPECT_CALL(decoder_factory_.Av1Decoder(), DecodeCall); - EXPECT_CALL(callbacks_, OnDecodedFrame); - time_controller_.AdvanceTime(kFrameInterval); -} - -} // namespace -} // namespace webrtc diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 86239444f7..53125ff373 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -346,9 +346,9 @@ VideoLayersAllocation CreateVideoLayersAllocation( encoder_config.VP9().interLayerPred == InterLayerPredMode::kOn; layers_allocation.resolution_and_frame_rate_is_valid = true; - std::vector aggregated_spatial_bitrate( - webrtc::kMaxTemporalStreams, DataRate::Zero()); - for (int si = 0; si < webrtc::kMaxSpatialLayers; ++si) { + std::vector aggregated_spatial_bitrate(kMaxTemporalStreams, + DataRate::Zero()); + for (int si = 0; si < kMaxSpatialLayers; ++si) { layers_allocation.resolution_and_frame_rate_is_valid = true; if (!target_bitrate.IsSpatialLayerUsed(si) || target_bitrate.GetSpatialLayerSum(si) == 0) { @@ -692,10 +692,9 @@ VideoStreamEncoder::VideoStreamEncoder( const VideoStreamEncoderSettings& settings, std::unique_ptr overuse_detector, std::unique_ptr frame_cadence_adapter, - std::unique_ptr - encoder_queue, + std::unique_ptr encoder_queue, BitrateAllocationCallbackType allocation_cb_type, - webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector) + VideoEncoderFactory::EncoderSelectorInterface* encoder_selector) : env_(env), worker_queue_(TaskQueueBase::Current()), number_of_cores_(number_of_cores), @@ -1012,7 +1011,7 @@ void VideoStreamEncoder::ConfigureEncoder(VideoEncoderConfig config, ReconfigureEncoder(); } else { - webrtc::InvokeSetParametersCallback(callback, webrtc::RTCError::OK()); + InvokeSetParametersCallback(callback, RTCError::OK()); } }); } @@ -1485,7 +1484,7 @@ void VideoStreamEncoder::ReconfigureEncoder() { stream_resource_manager_.ConfigureQualityScaler(info); stream_resource_manager_.ConfigureBandwidthQualityScaler(info); - webrtc::RTCError encoder_configuration_result = webrtc::RTCError::OK(); + RTCError encoder_configuration_result = RTCError::OK(); if (!encoder_initialized_) { RTC_LOG(LS_WARNING) << "Failed to initialize " @@ -1497,14 +1496,13 @@ void VideoStreamEncoder::ReconfigureEncoder() { RequestEncoderSwitch(); } else { encoder_configuration_result = - webrtc::RTCError(RTCErrorType::UNSUPPORTED_OPERATION); + RTCError(RTCErrorType::UNSUPPORTED_OPERATION); } } if (!encoder_configuration_callbacks_.empty()) { for (auto& callback : encoder_configuration_callbacks_) { - webrtc::InvokeSetParametersCallback(callback, - encoder_configuration_result); + InvokeSetParametersCallback(callback, encoder_configuration_result); } encoder_configuration_callbacks_.clear(); } @@ -1532,7 +1530,7 @@ void VideoStreamEncoder::RequestEncoderSwitch() { } if (!preferred_fallback_encoder) { - if (!env_.field_trials().IsDisabled( + if (env_.field_trials().IsEnabled( kSwitchEncoderFollowCodecPreferenceOrderFieldTrial)) { encoder_fallback_requested_ = true; settings_.encoder_switch_request_callback->RequestEncoderFallback(); diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index 917d928149..8c0f2ca04d 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -12,38 +12,49 @@ #define VIDEO_VIDEO_STREAM_ENCODER_H_ #include -#include +#include +#include #include -#include +#include #include #include "absl/container/inlined_vector.h" #include "api/adaptation/resource.h" #include "api/environment/environment.h" +#include "api/fec_controller_override.h" +#include "api/rtp_parameters.h" #include "api/rtp_sender_interface.h" +#include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" +#include "api/task_queue/task_queue_base.h" #include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/timestamp.h" #include "api/video/encoded_image.h" +#include "api/video/video_adaptation_counters.h" +#include "api/video/video_adaptation_reason.h" +#include "api/video/video_bitrate_allocation.h" #include "api/video/video_bitrate_allocator.h" -#include "api/video/video_rotation.h" -#include "api/video/video_sink_interface.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" +#include "api/video/video_source_interface.h" #include "api/video/video_stream_encoder_settings.h" #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" +#include "api/video_codecs/video_encoder_factory.h" #include "call/adaptation/adaptation_constraint.h" -#include "call/adaptation/resource_adaptation_processor.h" #include "call/adaptation/resource_adaptation_processor_interface.h" #include "call/adaptation/video_source_restrictions.h" +#include "call/adaptation/video_stream_adapter.h" #include "call/adaptation/video_stream_input_state_provider.h" #include "modules/video_coding/utility/frame_dropper.h" #include "modules/video_coding/utility/qp_parser.h" #include "rtc_base/experiments/rate_control_settings.h" -#include "rtc_base/numerics/exp_filter.h" -#include "rtc_base/race_checker.h" -#include "rtc_base/rate_statistics.h" #include "rtc_base/thread_annotations.h" +#include "video/adaptation/overuse_frame_detector.h" #include "video/adaptation/video_stream_encoder_resource_manager.h" +#include "video/config/video_encoder_config.h" #include "video/corruption_detection/frame_instrumentation_generator.h" #include "video/encoder_bitrate_adjuster.h" #include "video/frame_cadence_adapter.h" diff --git a/video/video_stream_encoder_interface.h b/video/video_stream_encoder_interface.h index 05da612f26..234ef33d88 100644 --- a/video/video_stream_encoder_interface.h +++ b/video/video_stream_encoder_interface.h @@ -11,18 +11,20 @@ #ifndef VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_ #define VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_ +#include +#include #include #include "api/adaptation/resource.h" #include "api/fec_controller_override.h" -#include "api/rtc_error.h" #include "api/rtp_parameters.h" // For DegradationPreference. #include "api/rtp_sender_interface.h" #include "api/scoped_refptr.h" #include "api/units/data_rate.h" -#include "api/video/video_bitrate_allocator.h" +#include "api/video/video_bitrate_allocation.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "api/video/video_layers_allocation.h" -#include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" #include "api/video_codecs/video_encoder.h" #include "video/config/video_encoder_config.h" diff --git a/video/video_stream_encoder_observer.h b/video/video_stream_encoder_observer.h index 95ca5fa887..ec357043c4 100644 --- a/video/video_stream_encoder_observer.h +++ b/video/video_stream_encoder_observer.h @@ -17,6 +17,7 @@ #include "api/video/video_adaptation_counters.h" #include "api/video/video_adaptation_reason.h" #include "api/video/video_bitrate_allocation.h" +#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "video/config/video_encoder_config.h" diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index 17f4ea1a2c..bbae05d0df 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -94,13 +94,13 @@ #include "rtc_base/event.h" #include "rtc_base/experiments/encoder_info_settings.h" #include "rtc_base/experiments/rate_control_settings.h" -#include "rtc_base/gunit.h" #include "rtc_base/logging.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" +#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "test/encoder_settings.h" #include "test/fake_encoder.h" @@ -8314,7 +8314,9 @@ TEST_F(VideoStreamEncoderTest, .WillByDefault(Return(WEBRTC_VIDEO_CODEC_ENCODER_FAILURE)); Event encode_attempted; - EXPECT_CALL(switch_callback, RequestEncoderFallback()) + EXPECT_CALL(switch_callback, + RequestEncoderSwitch(Field(&SdpVideoFormat::name, "VP8"), + /*allow_default_fallback=*/true)) .WillOnce([&encode_attempted]() { encode_attempted.Set(); }); video_source_.IncomingCapturedFrame(CreateFrame(1, nullptr)); @@ -8387,6 +8389,9 @@ TEST_F(VideoStreamEncoderTest, NoPreferenceDefaultFallbackToVP8Disabled) { constexpr int kDontCare = 100; constexpr int kNumFrames = 8; + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-SwitchEncoderFollowCodecPreferenceOrder/Enabled/"); + NiceMock video_encoder; StrictMock switch_callback; video_send_config_.encoder_settings.encoder_switch_request_callback = @@ -8444,10 +8449,6 @@ TEST_F(VideoStreamEncoderTest, NoPreferenceDefaultFallbackToVP8Enabled) { constexpr int kSufficientBitrateToNotDrop = 1000; constexpr int kDontCare = 100; - webrtc::test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-SwitchEncoderFollowCodecPreferenceOrder/Disabled/"); - NiceMock video_encoder; StrictMock switch_callback; video_send_config_.encoder_settings.encoder_switch_request_callback = diff --git a/webrtc.gni b/webrtc.gni index 2a407632d6..103983dec4 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -334,6 +334,9 @@ declare_args() { # Set this to true to disable webrtc metrics. rtc_disable_metrics = false + + # Enables an experimental rust version of base64 for building and testing. + rtc_rusty_base64 = true } declare_args() { @@ -381,6 +384,7 @@ if (is_mac || is_ios) { if (build_with_chromium) { rtc_use_perfetto = true + rtc_allow_deprecated_namespaces = false } # Global public configuration that should be applied to all WebRTC targets. You @@ -597,6 +601,12 @@ template("rtc_source_set") { visibility = webrtc_default_visibility } + if (defined(invoker.sources)) { + nonheader_sources = filter_include(invoker.sources, [ "*.cc" ]) + assert(nonheader_sources == [], + "rtc_source_set shall not contain cc files") + } + # What's your poison? if (defined(testonly) && testonly) { assert(!defined(poisonous)) diff --git a/webrtc_lib_link_test.cc b/webrtc_lib_link_test.cc index 4eeb59a57a..b5ba086f55 100644 --- a/webrtc_lib_link_test.cc +++ b/webrtc_lib_link_test.cc @@ -8,19 +8,22 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include + #include "api/audio/audio_device.h" -#include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" +#include "api/audio/create_audio_device_module.h" #include "api/audio_codecs/audio_decoder_factory_template.h" #include "api/audio_codecs/audio_encoder_factory_template.h" #include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/create_peerconnection_factory.h" #include "api/enable_media.h" +#include "api/environment/environment_factory.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/stats/rtcstats_objects.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/video_codecs/video_decoder_factory_template.h" #include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h" #include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h" @@ -31,12 +34,13 @@ #include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h" #include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h" #include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h" +#include "rtc_base/thread.h" namespace webrtc { void CreateSomeMediaDeps(PeerConnectionFactoryDependencies& media_deps) { - media_deps.adm = AudioDeviceModule::CreateForTest( - AudioDeviceModule::kDummyAudio, media_deps.task_queue_factory.get()); + media_deps.adm = + CreateAudioDeviceModule(*media_deps.env, AudioDeviceModule::kDummyAudio); media_deps.audio_encoder_factory = webrtc::CreateAudioEncoderFactory(); media_deps.audio_decoder_factory = @@ -55,7 +59,7 @@ void CreateSomeMediaDeps(PeerConnectionFactoryDependencies& media_deps) { webrtc::PeerConnectionFactoryDependencies CreateSomePcfDeps() { webrtc::PeerConnectionFactoryDependencies pcf_deps; - pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); + pcf_deps.env = CreateEnvironment(); pcf_deps.signaling_thread = webrtc::Thread::Current(); pcf_deps.network_thread = webrtc::Thread::Current(); pcf_deps.worker_thread = webrtc::Thread::Current(); @@ -82,7 +86,7 @@ void TestCase1ModularFactory() { void TestCase2RegularFactory() { PeerConnectionFactoryDependencies media_deps; - media_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); + media_deps.env = CreateEnvironment(); CreateSomeMediaDeps(media_deps); auto peer_connection_factory = webrtc::CreatePeerConnectionFactory(