diff --git a/.gn b/.gn index fbd2c38721..1b112b34c0 100644 --- a/.gn +++ b/.gn @@ -91,4 +91,7 @@ default_args = { # See context on https://issues.chromium.org/issues/415076048. enable_js_protobuf = false + + # Use Siso instead of Ninja. + use_siso = true } diff --git a/BUILD.gn b/BUILD.gn index 4ad7f3e00c..3357c2dcdf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -70,7 +70,6 @@ if (!build_with_chromium) { "pc:rtc_pc_unittests", "pc:slow_peer_connection_unittests", "pc:svc_tests", - "rtc_tools:rtp_generator", "rtc_tools:video_encoder", "rtc_tools:video_replay", "stats:rtc_stats_unittests", @@ -83,7 +82,9 @@ if (!build_with_chromium) { if (use_libfuzzer) { deps += [ "test/fuzzers" ] } - if (!is_asan) { + + # TODO(bugs.webrtc.org/430260876): Remove once rust links with libwebrtc. + if (!is_asan && !rtc_rusty_base64) { # Do not build :webrtc_lib_link_test because lld complains on some OS # (e.g. when target_os = "mac") when is_asan=true. For more details, # see bugs.webrtc.org/11027#c5. @@ -251,10 +252,6 @@ config("common_inherited_config") { if (is_ubsan) { cflags += [ "-fsanitize=float-cast-overflow" ] } - - if (rtc_allow_deprecated_namespaces) { - defines += [ "WEBRTC_ALLOW_DEPRECATED_NAMESPACES" ] - } } # TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning @@ -526,23 +523,23 @@ if (!build_with_chromium) { ] sources = [] + complete_static_lib = true suppressed_configs += [ "//build/config/compiler:thin_archive" ] defines = [] deps = [ + "api:create_modular_peer_connection_factory", "api:create_peerconnection_factory", "api:enable_media", "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", "api/task_queue", "api/task_queue:default_task_queue_factory", - "api/test/metrics", "api/video_codecs:video_decoder_factory_template", "api/video_codecs:video_decoder_factory_template_dav1d_adapter", "api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter", @@ -584,9 +581,15 @@ if (!build_with_chromium) { if (rtc_enable_protobuf) { deps += [ "logging:rtc_event_log_proto" ] } + + if (rtc_include_internal_audio_device) { + deps += [ "api/audio:create_audio_device_module" ] + } } - if (rtc_include_tests && !is_asan) { + # TODO(bugs.webrtc.org/430260876): Compile webrtc lib with rust once toolchain + # is working. + if (rtc_include_tests && !is_asan && !rtc_rusty_base64) { rtc_executable("webrtc_lib_link_test") { testonly = true @@ -637,6 +640,7 @@ if (rtc_include_tests && !build_with_chromium) { "api/numerics:numerics_unittests", "api/task_queue:pending_task_safety_flag_unittests", "api/test/metrics:metrics_unittests", + "api/test/network_emulation:network_queue_unittests", "api/transport:stun_unittest", "api/transport/rtp:corruption_detection_message_unittest", "api/video/test:rtc_api_video_unittests", @@ -647,6 +651,7 @@ if (rtc_include_tests && !build_with_chromium) { "call:fake_network_pipe_unittests", "rtc_base:async_dns_resolver_unittests", "rtc_base:async_packet_socket_unittest", + "rtc_base:async_tcp_socket_unittest", "rtc_base:async_udp_socket_unittest", "rtc_base:callback_list_unittests", "rtc_base:rtc_base_approved_unittests", diff --git a/DEPS b/DEPS index 2117a1507e..a9acbddb20 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': '24cc1d0706d34abea623ee00e855b7f22fbc309f', + 'chromium_revision': '2fda948e24735acc22b12d891af252ac7299d010', # Fetch the prebuilt binaries for llvm-cov and llvm-profdata. Needed to # process the raw profiles produced by instrumented targets (built with @@ -33,7 +33,7 @@ vars = { # By default, download the fuchsia sdk from the public sdk directory. 'fuchsia_sdk_cipd_prefix': 'fuchsia/sdk/core/', - 'fuchsia_version': 'version:28.20250609.4.1', + 'fuchsia_version': 'version:29.20250730.5.1', # By default, download the fuchsia images from the fuchsia GCS bucket. 'fuchsia_images_bucket': 'fuchsia', 'checkout_fuchsia': False, @@ -50,7 +50,7 @@ vars = { # reclient CIPD package version 'reclient_version': 're_client_version:0.179.0.28341fc7-gomaip', # siso CIPD package version. - 'siso_version': 'git_revision:7e7d85fc69f9084d2168385fb504b31e830dbfff', + 'siso_version': 'git_revision:e5fa67c5a456c1ab932f440ddfb195a8a33c235b', # ninja CIPD package. 'ninja_package': 'infra/3pp/tools/ninja/', @@ -69,28 +69,28 @@ vars = { deps = { 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@6311c38ef211e0d9d11ae6b0316fd38246df5e84', + 'https://chromium.googlesource.com/chromium/src/build@66d076c7ab192991f67891b062b35404f3cb0739', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@b2eba427b82f292067b546b1075363b44b27b9c4', + 'https://chromium.googlesource.com/chromium/src/buildtools@0c4bbb0f8a874de0a2a15d196031c7303d04fbb3', # 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@0818da033e3fa948de459e52ce16cab743dbb4b5', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@e11547b2c24f408b1179c7540fd1410c8e560f4e', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@766840625d37bc9e41a74c61ffa632691576bdf5', + 'https://chromium.googlesource.com/chromium/src/testing@305de9533d3ee2840af0b3f2c8ed0b32802b0a5d', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@fbcbb2a67783f602bea3483091e3aad5b3ae1ebd', + 'https://chromium.googlesource.com/chromium/src/third_party@e30091e8987ee0bb0cd30bc467250a96a7614762', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-${{arch}}', - 'version': 'git_revision:81dab9f25cb2381400c237fdea7030d5068f9a73', + 'version': 'git_revision:3a4f5cea73eca32e9586e8145f97b04cbd4a1aee', } ], 'dep_type': 'cipd', @@ -100,7 +100,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:81dab9f25cb2381400c237fdea7030d5068f9a73', + 'version': 'git_revision:3a4f5cea73eca32e9586e8145f97b04cbd4a1aee', } ], 'dep_type': 'cipd', @@ -110,7 +110,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:81dab9f25cb2381400c237fdea7030d5068f9a73', + 'version': 'git_revision:3a4f5cea73eca32e9586e8145f97b04cbd4a1aee', } ], 'dep_type': 'cipd', @@ -136,143 +136,157 @@ 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-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '5f69279b3697166facfc354634157e0a8a32fa6e36864200ad8a8f85add3f3f6', - 'size_bytes': 55654416, - 'generation': 1747138963230938, + 'object_name': 'Linux_x64/clang-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '73e573aa1824bf1cd8ac8815304e41c174938ab05362e316d9c3d8d3ae8f4d0b', + 'size_bytes': 54836700, + 'generation': 1753711033480152, 'condition': '(host_os == "linux" or checkout_android) and non_git_source', }, { - 'object_name': 'Linux_x64/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '9c9cd089b46f36232d7553d03a0b30cf509f5e42b2113fe8172ba14f905b91df', - 'size_bytes': 13597708, - 'generation': 1747138963497696, + 'object_name': 'Linux_x64/clang-tidy-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '7cd6261a5ffe1989bcaed190b6911d8bb1f296b1dfbbc92b5eda2262d2d2d604', + 'size_bytes': 13658364, + 'generation': 1753711033512134, 'condition': 'host_os == "linux" and checkout_clang_tidy and non_git_source', }, { - 'object_name': 'Linux_x64/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': 'cf580450a46e262d899c2d48fff2b6ea8f6691a6bcfc0c280f87d8b6da088e5f', - 'size_bytes': 13854788, - 'generation': 1747138963598582, + 'object_name': 'Linux_x64/clangd-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '19c844ed67e3cc7054fd2af4793f5828fa8bd4a712fb797e90cb814fc81d406e', + 'size_bytes': 13870348, + 'generation': 1753711033515636, 'condition': 'host_os == "linux" and checkout_clangd and non_git_source', }, { - 'object_name': 'Linux_x64/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '1a3488e55d62bda48d09b69fb4e5267ac64247258dc51fd9dabdb7fe5d66da4c', - 'size_bytes': 2297996, - 'generation': 1747138964068040, + 'object_name': 'Linux_x64/llvm-code-coverage-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '78dbed2a5e4e9747c18f5e4876070c22e126bf6990acc66effcb5c981a30c346', + 'size_bytes': 2313988, + 'generation': 1753711033567913, 'condition': 'host_os == "linux" and checkout_clang_coverage_tools and non_git_source', }, { - 'object_name': 'Linux_x64/llvmobjdump-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': 'efb127c69ac198284ff3622cd173e9dc4839d0bed33dbcaa96501db169607a2e', - 'size_bytes': 5701128, - 'generation': 1747138963789285, + 'object_name': 'Linux_x64/llvmobjdump-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '4e34eac7c8fc81440df3524f28b7140276710996241acdf8515592ff73586f87', + 'size_bytes': 5675412, + 'generation': 1753711033518775, 'condition': '((checkout_linux or checkout_mac or checkout_android) and host_os == "linux") and non_git_source', }, { - 'object_name': 'Mac/clang-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '3d83bd33ae0a0331ba8e23340023ae05174128503d94116cd8a855913fca88c7', - 'size_bytes': 52212572, - 'generation': 1747138966013176, + 'object_name': 'Mac/clang-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': 'f585d02104e485eb443a26555a779a0444bf30ccc3600d34ab1f35d09a500598', + 'size_bytes': 52411164, + 'generation': 1753711035252100, 'condition': 'host_os == "mac" and host_cpu == "x64"', }, { - 'object_name': 'Mac/clang-mac-runtime-library-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '809b6f72718d9bcbf25ad6ab80517f215ed2526435a095ee9bceb5ed40f989a2', - 'size_bytes': 993800, - 'generation': 1747138984414942, + 'object_name': 'Mac/clang-mac-runtime-library-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '9816d228b6d30ba0fe469be5df19199fcf1851b39872add9ba3be5a8e350830a', + 'size_bytes': 996000, + 'generation': 1753711043142947, 'condition': 'checkout_mac and not host_os == "mac"', }, { - 'object_name': 'Mac/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': 'c1fd7930eadede03470cbc8d38697669c6254069da2f6bd58328a8654d68f70d', - 'size_bytes': 13699584, - 'generation': 1747138966324770, + 'object_name': 'Mac/clang-tidy-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': 'e78bba5afc0c824d17c096b0e4b4c52145433bbb43a7f3b8c3264251b9f866d1', + 'size_bytes': 13746260, + 'generation': 1753711035308001, 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_tidy', }, { - 'object_name': 'Mac/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '3aa82177f6e03da693d93aa9f8052fa669af1bd897359a20eaf01379db0924b8', - 'size_bytes': 15136432, - 'generation': 1747138966446697, + 'object_name': 'Mac/clangd-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '26dba5d090c218342c9ae92dc771ae5ac46953f427752c40995c1c5174802da7', + 'size_bytes': 15150168, + 'generation': 1753711035309045, 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clangd', }, { - 'object_name': 'Mac/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '1f8d0d65f9d027707890c28433b0bfe29e32551008e9f3c1b9803318ede2bfc6', - 'size_bytes': 2272500, - 'generation': 1747138966854415, + 'object_name': 'Mac/llvm-code-coverage-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '217fccb5c021908d3972f32f40a9631fbd5cac9d2bee3fd973aef88b2f6a251e', + 'size_bytes': 2282228, + 'generation': 1753711035430925, 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_coverage_tools', }, { - 'object_name': 'Mac_arm64/clang-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '2d5660c50637a7ee6e5501525e7588bb255cdfd48e792b12b86ae7113c31b8ae', - 'size_bytes': 44214476, - 'generation': 1747138986010150, + 'object_name': 'Mac/llvmobjdump-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '4eae5f9ad4fba33dea45815fd965258f4649cf8e0794b6c431ce166a966cb29d', + 'size_bytes': 5483720, + 'generation': 1753711035319601, + 'condition': 'host_os == "mac" and host_cpu == "x64"', + }, + { + 'object_name': 'Mac_arm64/clang-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '17275ca988de014adc269f8fa694f501cecd6c25c0494fc45582fc4e3d258bed', + 'size_bytes': 44345732, + 'generation': 1753711044909340, 'condition': 'host_os == "mac" and host_cpu == "arm64"', }, { - 'object_name': 'Mac_arm64/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': 'c17b6d7d112ff54699477d5fc7f5009e7b650d263d127cad4f8406f8df914996', - 'size_bytes': 11838956, - 'generation': 1747138986259606, + 'object_name': 'Mac_arm64/clang-tidy-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '387eb3412e41a17c4e40e8fe3eeda65806a78bba6bb5799ff3ccce6ee499bb2d', + 'size_bytes': 11877428, + 'generation': 1753711044929125, 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_tidy', }, { - 'object_name': 'Mac_arm64/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': 'd6c134df8273fe9c4c2b5ff5786f2ceeb9ed5f251e223e55edbc0cd7aa772e83', - 'size_bytes': 12115024, - 'generation': 1747138986359326, + 'object_name': 'Mac_arm64/clangd-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '21893beaab322a2f04a3f07fdab1fe6219ca04d6151d621cbcf445214f213c23', + 'size_bytes': 12132752, + 'generation': 1753711044937334, 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clangd', }, { - 'object_name': 'Mac_arm64/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '82ca9187d1fd5ed14266612339b921d560b1008f92e1719255b755ff882d23e3', - 'size_bytes': 1982036, - 'generation': 1747138986831545, + 'object_name': 'Mac_arm64/llvm-code-coverage-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '33603b2ac2577042d0cb8ed050dc5c7c5894984cf85933003e87fd3eb854bb7b', + 'size_bytes': 1988508, + 'generation': 1753711045041769, 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_coverage_tools', }, { - 'object_name': 'Win/clang-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '39e17b8282b9f1e3cbc6b22d3144696728c867f3ae66694b0125c3ed60755401', - 'size_bytes': 47250032, - 'generation': 1747139012194774, + 'object_name': 'Mac_arm64/llvmobjdump-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '26c961fa85d76f5f2fcdfd80980b4a0ca4c394307cf78e65888d061e29ae9b0b', + 'size_bytes': 5315616, + 'generation': 1753711044929262, + 'condition': 'host_os == "mac" and host_cpu == "arm64"', + }, + { + 'object_name': 'Win/clang-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': 'ce28d6045da4a2d3e909a3b272e973ecab3360452780e501b2110b6fd51be899', + 'size_bytes': 47389532, + 'generation': 1753711055091539, 'condition': 'host_os == "win"', }, { - 'object_name': 'Win/clang-tidy-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '9dec82a917bd55947e39891137ba5c13663ca94d2c102d56eb52b9b176365910', - 'size_bytes': 13492960, - 'generation': 1747139012510054, + 'object_name': 'Win/clang-tidy-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '1380577341962e45d86ace7791bb327a8fb0f7854b31cb22271a79742df19921', + 'size_bytes': 13484452, + 'generation': 1753711055103864, 'condition': 'host_os == "win" and checkout_clang_tidy', }, { - 'object_name': 'Win/clang-win-runtime-library-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '220abd9ce9a85446a2e7879aab3c1f2f5393665f6b13b067f8cec565ae7d36eb', - 'size_bytes': 2486856, - 'generation': 1747139033547001, + 'object_name': 'Win/clang-win-runtime-library-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': 'ea7a3e86fbfa94eef0fa2560206cf596876cf96145be2d03bdf2af7f1a23198e', + 'size_bytes': 2506736, + 'generation': 1753711063058491, 'condition': 'checkout_win and not host_os == "win"', }, { - 'object_name': 'Win/clangd-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '81fa230b6311e3e50147cae3acd6d2c83c1bef13ff46df3df3d580ca911e9d15', - 'size_bytes': 13918432, - 'generation': 1747139013351355, + 'object_name': 'Win/clangd-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': 'fa919c060a1369d069a4f7b656a89f89393c7e08cfa96fd5bc85cb3208258ddf', + 'size_bytes': 13911060, + 'generation': 1753711055091772, 'condition': 'host_os == "win" and checkout_clangd', }, { - 'object_name': 'Win/llvm-code-coverage-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '611b9689c3d3e80ab7485e698f6b67e0df328b5407f30f177c29fe394b81a13e', - 'size_bytes': 2378584, - 'generation': 1747139013764369, + 'object_name': 'Win/llvm-code-coverage-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': '393704c1adb6b3b1202b46144ad7d081eb79f330700a4d109269722d680d52de', + 'size_bytes': 2383152, + 'generation': 1753711055387102, 'condition': 'host_os == "win" and checkout_clang_coverage_tools', }, { - 'object_name': 'Win/llvmobjdump-llvmorg-21-init-11777-gfd3fecfc-1.tar.xz', - 'sha256sum': '67a05210ee38b2f575df3cc1feb04ed36b4186748c2d769e2201572b413305fe', - 'size_bytes': 5698204, - 'generation': 1747139013159526, + 'object_name': 'Win/llvmobjdump-llvmorg-21-init-16348-gbd809ffb-14.tar.xz', + 'sha256sum': 'd1a654f0342bad3658ed9fab7a91a7726c6aa0af44a6e6c33da96ddf3602ece4', + 'size_bytes': 5649720, + 'generation': 1753711055166454, 'condition': '(checkout_linux or checkout_mac or checkout_android) and host_os == "win"', }, ] @@ -284,31 +298,31 @@ deps = { 'bucket': 'chromium-browser-clang', 'objects': [ { - 'object_name': 'Linux_x64/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz', - 'sha256sum': 'df1573701599cb7d00c1050b71636a436320b8ad47bb09cb46d6e96b3f8ac585', - 'size_bytes': 118529212, - 'generation': 1747160498430964, + 'object_name': 'Linux_x64/rust-toolchain-22be76b7e259f27bf3e55eb931f354cd8b69d55f-3-llvmorg-21-init-16348-gbd809ffb.tar.xz', + 'sha256sum': '5f8e9ad847e5bf586e0de1bb563c9a49e05ad36edfad5037900d7510004fc577', + 'size_bytes': 138573136, + 'generation': 1750840933611077, 'condition': 'host_os == "linux" and non_git_source', }, { - 'object_name': 'Mac/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz', - 'sha256sum': '83836493c8a81b212c20e16666c6b918bff28748f4d6685c5107eb7e9d16f6fe', - 'size_bytes': 111691772, - 'generation': 1747160500088595, + 'object_name': 'Mac/rust-toolchain-22be76b7e259f27bf3e55eb931f354cd8b69d55f-3-llvmorg-21-init-16348-gbd809ffb.tar.xz', + 'sha256sum': '357db812ca0a518ef0fc4394ddc859d68f23384931294412b7424bb3aabb3c09', + 'size_bytes': 132392604, + 'generation': 1750840935469331, 'condition': 'host_os == "mac" and host_cpu == "x64"', }, { - 'object_name': 'Mac_arm64/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz', - 'sha256sum': 'd975e322a2e5c680b54f27a6545c63c0de2c5367ca6ffefda04de491d6b76553', - 'size_bytes': 102206348, - 'generation': 1747160501743827, + 'object_name': 'Mac_arm64/rust-toolchain-22be76b7e259f27bf3e55eb931f354cd8b69d55f-3-llvmorg-21-init-16348-gbd809ffb.tar.xz', + 'sha256sum': 'd3cb60c6388e86d3d1a0c46c539f1ea0ed1ff48cf907dc21b2cb5ff441b23c03', + 'size_bytes': 120354192, + 'generation': 1750840937280735, 'condition': 'host_os == "mac" and host_cpu == "arm64"', }, { - 'object_name': 'Win/rust-toolchain-4a0969e06dbeaaa43914d2d00b2e843d49aa3886-1-llvmorg-21-init-11777-gfd3fecfc.tar.xz', - 'sha256sum': '25c51b4c2e0e8b4e974973f0357b12ecb645a0a7a136f9e0a6604e87c21acc7a', - 'size_bytes': 193582440, - 'generation': 1747160503376785, + 'object_name': 'Win/rust-toolchain-22be76b7e259f27bf3e55eb931f354cd8b69d55f-3-llvmorg-21-init-16348-gbd809ffb.tar.xz', + 'sha256sum': '7e804f3a8bef4c8ca32d3368ca7564e5c12b684899453d9a522bdd05b1f1df7b', + 'size_bytes': 195000356, + 'generation': 1750840939064273, 'condition': 'host_os == "win"', }, ], @@ -317,15 +331,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@249b29a0e0b0f4b9dac1b099a44e3536903d6896', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/compiler-rt.git@dc425afb37a69b60c8c02fef815af29e91b61773', 'src/third_party/libc++/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@2c359c239b138a20a03f798e47889448ef131c22', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@adbb4a5210ae2a8a4e27fa6199221156c02a9b1a', 'src/third_party/libc++abi/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@e44c3c4560f1742744ef3f9fb4217a5f26ebca1b', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@a6c815c69d55ec59d020abde636754d120b402ad', 'src/third_party/llvm-libc/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libc.git@3d71fc6b43d55209a3c351031421b794f726b405', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libc.git@8ec6b26421b5fa7aa876fdab486fa1decc558326', 'src/third_party/libunwind/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@5bbf35ae6801f579c523893176789774c0726e22', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@84c5262b57147e9934c0a8f2302d989b44ec7093', 'src/third_party/test_fonts/test_fonts': { 'dep_type': 'gcs', @@ -388,7 +402,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/aapt2', - 'version': '_lNsOL_GGlXLOIMGtrbMOqNd7TQHabaP1q8SlvUpFbMC', + 'version': '2Tff49a5dYTM5YvxxqyOsTQ9k8nOqM4ayydbCuKoxIwC', }, ], 'condition': 'checkout_android', @@ -421,7 +435,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/error_prone', - 'version': 'RiplT9oTSE0lQHviAF6FMk5P9863t0-WHcl2te12hi0C', + 'version': '56Xo0VEDkKxzOr5L7pafI6SaIY2S7wnOOcgy4CNSANEC', }, ], 'condition': 'checkout_android', @@ -443,7 +457,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/lint', - 'version': '3bWjs4NjBtTIXoWH03nPx8c--ehZzlDkL8PUE_GaPKUC', + 'version': 'AGywP4kNoPZjZa3fVdf1g2cKgEPkXnVFRxhlFjroXJcC', }, ], 'condition': 'checkout_android and non_git_source', @@ -462,11 +476,11 @@ deps = { }, 'src/third_party/boringssl/src': - 'https://boringssl.googlesource.com/boringssl.git@860c27038fcd9c2c27242e9874c18408dec1f84c', + 'https://boringssl.googlesource.com/boringssl.git@ddb2ca4b48fca9a1c468d83dc513b837331843ac', 'src/third_party/breakpad/breakpad': - 'https://chromium.googlesource.com/breakpad/breakpad.git@9d1f417714a6883f8d4e345c07802eb79edd2e90', + 'https://chromium.googlesource.com/breakpad/breakpad.git@ff252ff6faf5e3a52dc4955aab0d84831697dc94', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@5b85fe2b7c3e03e36f8206dacd7d1d58268b3a94', + 'https://chromium.googlesource.com/catapult.git@0fd1415f0cf3219ba097d37336141897fab7c5e9', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -479,21 +493,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@377f55f382fe2b3b4734a94ac3e1b60339695ef8', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@d85491b0a1dcb82dd8e124a876ecd7e3d50dc5e8', 'src/third_party/ffmpeg': - 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@dcdd0fa51b65a0b1688ff6b8f0cc81908f09ded2', + 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@d2d06b12c22d27af58114e779270521074ff1f85', '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@ec70317566ae70bd8804b65360a21b75233bff99', + 'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@806e186735cc3bf4375f43d2d6a9483c607e4278', }, # Used for embedded builds. CrOS & Linux use the system version. 'src/third_party/fontconfig/src': { - 'url': 'https://chromium.googlesource.com/external/fontconfig.git@f71f39e7da6bccfb5a803a4adcdfe88d382a6eab', + 'url': 'https://chromium.googlesource.com/external/fontconfig.git@86b48ec01ece451d5270d0c5181a43151e45a042', 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@738905b34bd1f5a8ff51bd2bc8e38a2d8be9bfd6', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@08805be530d6820d2bf8a1b7685826de40f06812', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@9f83bbbe64654b45ba5bb06927ff36c2e7588495', 'src/third_party/google_benchmark/src': { @@ -501,15 +515,15 @@ deps = { }, # WebRTC-only dependency (not present in Chromium). 'src/third_party/gtest-parallel': - 'https://chromium.googlesource.com/external/github.com/google/gtest-parallel@96f4f904922f9bf66689e749c40f314845baaac8', + 'https://chromium.googlesource.com/external/github.com/google/gtest-parallel@cd488bdedc1d2cffb98201a17afc1b298b0b90f1', 'src/third_party/google-truth/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/truth.git@33387149b465f82712a817e6744847fe136949b3', 'condition': 'checkout_android', }, 'src/third_party/googletest/src': - 'https://chromium.googlesource.com/external/github.com/google/googletest.git@35b75a2cba6ef72b7ce2b6b94b05c54ca07df866', + 'https://chromium.googlesource.com/external/github.com/google/googletest.git@373af2e3df71599b87a40ce0e37164523849166b', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@b929596baebf0ab4ac7ec07f38365db4c50a559d', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@1b2e3e8a421efae36141a7b932b41e315b089af8', }, 'src/third_party/jdk/current': { 'packages': [ @@ -545,7 +559,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/kotlin_stdlib', - 'version': 'E405j4iATVcDLLGq9LbG61CRuyD0rs08XuMkg_GCJAwC', + 'version': 'jHhaILmhjHo4cYTvCdIRMwWPOAGSwjhEtrMxwREj52gC', }, ], 'condition': 'checkout_android', @@ -556,36 +570,36 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/kotlinc', - 'version': 'mGeAAvYPiWnWdB1IzKIoMQGoAMYI3GYfT7zWdPTypJEC', + 'version': 'clr2_okgxf1Zih4H2dIOKUWGJhrBo7fj3ZZ6nKV0dJIC', }, ], 'condition': 'checkout_android', 'dep_type': 'cipd', }, 'src/third_party/libFuzzer/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/compiler-rt/lib/fuzzer.git@e31b99917861f891308269c36a32363b120126bb', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/compiler-rt/lib/fuzzer.git@bea408a6e01f0f7e6c82a43121fe3af4506c932e', 'src/third_party/fuzztest/src': - 'https://chromium.googlesource.com/external/github.com/google/fuzztest.git@6c64b55603eab828e5acb92d40cf92c663194fb2', + 'https://chromium.googlesource.com/external/github.com/google/fuzztest.git@7bab06ff5fbbf8b8cce05a8661369dc2e11cde66', 'src/third_party/libjpeg_turbo': 'https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@e14cbfaa85529d47f9f55b0f104a579c1061f9ad', 'src/third_party/libsrtp': 'https://chromium.googlesource.com/chromium/deps/libsrtp.git@a52756acb1c5e133089c798736dd171567df11f5', 'src/third_party/dav1d/libdav1d': - 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@63bf075aada99afa112f84c61ddc9cead8ce04d3', + 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@716164239ad6e6b11c5dcdaa3fb540309d499833', 'src/third_party/libaom/source/libaom': - 'https://aomedia.googlesource.com/aom.git@6c4010bde34318fd6c1f0d10196f27ac9908eeb8', + 'https://aomedia.googlesource.com/aom.git@e91b7aa26d6d0979bba2bee5e1c27a7a695e0226', 'src/third_party/libunwindstack': { - 'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@0d758dd57f42564acecdd7a1e7ac5c8521c1b01a', + 'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@68973d9d4690b905cab27a553a0892868b697e4a', 'condition': 'checkout_android', }, 'src/third_party/perfetto': - Var('chromium_git') + '/external/github.com/google/perfetto.git' + '@' + '8824a8a3db2061f80f1ae662300c7d7f2c5fcad7', + Var('chromium_git') + '/external/github.com/google/perfetto.git' + '@' + '0c893ed6bf6b42e3fee58daf3380d301c72550ed', 'src/third_party/protobuf-javascript/src': Var('chromium_git') + '/external/github.com/protocolbuffers/protobuf-javascript' + '@' + '28bf5df73ef2f345a936d9cc95d64ba8ed426a53', 'src/third_party/libvpx/source/libvpx': - 'https://chromium.googlesource.com/webm/libvpx.git@686bf6f1cde888898498f89ba9aefa66b683566a', + 'https://chromium.googlesource.com/webm/libvpx.git@a985e5e847a2fe69bef3e547cf25088132194e39', 'src/third_party/libyuv': - 'https://chromium.googlesource.com/libyuv/libyuv.git@61bdaee13a701d2b52c6dc943ccc5c888077a591', + 'https://chromium.googlesource.com/libyuv/libyuv.git@cdd3bae84818e78466fec1ce954eead8f403d10c', 'src/third_party/lss': { 'url': 'https://chromium.googlesource.com/linux-syscall-support.git@ed31caa60f20a4f6569883b2d752ef7522de51e0', 'condition': 'checkout_android or checkout_linux', @@ -608,13 +622,13 @@ deps = { 'https://chromium.googlesource.com/external/github.com/cisco/openh264@652bdb7719f30b52b08e506645a7322ff1b2cc6f', 'src/third_party/re2/src': - 'https://chromium.googlesource.com/external/github.com/google/re2.git@c84a140c93352cdabbfb547c531be34515b12228', + 'https://chromium.googlesource.com/external/github.com/google/re2.git@8451125897dd7816a5c118925e8e42309d598ecc', 'src/third_party/r8/cipd': { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'vyND5ed7BNCedbc49JaNOodeA7NrhM08caDYzWEh4PoC', + 'version': 'qD5apdNjxRv3dBblf27nEZYf7r_pbLEgfN7hWyXvP_UC', }, ], 'condition': 'checkout_android', @@ -627,7 +641,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'F0pTWc6uG70kZPngypnQxCgD3CgY5D8O-pDqj_qeoQMC', + 'version': 'qD5apdNjxRv3dBblf27nEZYf7r_pbLEgfN7hWyXvP_UC', }, ], 'condition': 'checkout_android', @@ -638,7 +652,7 @@ deps = { 'condition': 'checkout_android', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@0f1d03e3d2e946991644070d6a702c6d7b4a9898', + 'https://chromium.googlesource.com/chromium/src/tools@ec8f1c6113753a31c55b6d6bddfbe198046029a8', 'src/third_party/espresso': { 'packages': [ @@ -677,7 +691,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'PNhEgzpn3fLIoqcPAPoa_8pYF-b7mk1e1bmeV8r3ti0C', + 'version': 'IG08WxVoI4_gwNrbpXqXXmytPWFopEI1x0EaFC1KosAC', }, ], 'condition': 'checkout_android and non_git_source', @@ -688,7 +702,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/manifest_merger', - 'version': 'AFWUMAcwcd0L1DG2-ib4ghtQYFsCvZjWuQkhuTJl4ToC', + 'version': 'K-0K2jznbc6LGEnKhT8NliSShwC43TBuVFZ6gRjOuxgC', }, ], 'condition': 'checkout_android', @@ -707,7 +721,7 @@ deps = { }, { 'package': 'chromium/third_party/android_sdk/public/platform-tools', - 'version': 'mjFmRj7k_XR9yj60pYbr9mG38FyEbU5oWdU56bZQ5cwC' + 'version': 'qTD9QdBlBf3dyHsN1lJ0RH6AhHxR42Hmg2Ih-Vj4zIEC' }, { 'package': 'chromium/third_party/android_sdk/public/platforms/android-36', @@ -759,7 +773,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/turbine', - 'version': 'npJIrAZr4-2wb6qWV0r2oeWQd-Q1wiMGAAi8Up15SkQC', + 'version': 'TkTaFqF4Bs-JmFtxFV_Nfh4u5jh_401ZQsLhC7vIEqQC', }, ], 'condition': 'checkout_android', @@ -775,15 +789,15 @@ deps = { 'packages': [ { 'package': 'infra/tools/luci/cas/${{platform}}', - 'version': 'git_revision:0250323d999386415553b5e2297eafe827ca41f3', + 'version': 'git_revision:69966f1a4984c4ade24b8e2e1af0bbc51b64d3c0', }, { 'package': 'infra/tools/luci/isolate/${{platform}}', - 'version': 'git_revision:0250323d999386415553b5e2297eafe827ca41f3', + 'version': 'git_revision:69966f1a4984c4ade24b8e2e1af0bbc51b64d3c0', }, { 'package': 'infra/tools/luci/swarming/${{platform}}', - 'version': 'git_revision:0250323d999386415553b5e2297eafe827ca41f3', + 'version': 'git_revision:69966f1a4984c4ade24b8e2e1af0bbc51b64d3c0', } ], 'dep_type': 'cipd', @@ -809,7 +823,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/autorolled', - 'version': 'DUJmkzdVnkEDGATSbsAPZ0prXoXODlDZn8HA9NOMD9UC', + 'version': 'RcN7kx5OuQtBLrhCRBTO9NABzT2sjw-ogJBZmT3nOdAC', }, ], 'condition': 'checkout_android and non_git_source', @@ -874,975 +888,172 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_android_datatransport_transport_api': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_datatransport_transport_api', - 'version': 'version:2@4.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_datatransport_transport_backend_cct': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_datatransport_transport_backend_cct', - 'version': 'version:2@4.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_datatransport_transport_runtime': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_datatransport_transport_runtime', - 'version': 'version:2@4.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_auth': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_auth', - 'version': 'version:2@21.3.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_auth_api_phone': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_auth_api_phone', - 'version': 'version:2@18.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_auth_base': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_auth_base', - 'version': 'version:2@18.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_auth_blockstore': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_auth_blockstore', - 'version': 'version:2@16.4.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_base': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_base', - 'version': 'version:2@18.5.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_basement': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_basement', - 'version': 'version:2@18.5.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_cast': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_cast', - 'version': 'version:2@22.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_cast_framework': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_cast_framework', - 'version': 'version:2@22.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_clearcut': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_clearcut', - 'version': 'version:2@17.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_cloud_messaging': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_cloud_messaging', - 'version': 'version:2@17.2.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_fido': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_fido', - 'version': 'version:2@21.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_flags': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_flags', - 'version': 'version:2@18.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_gcm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_gcm', - 'version': 'version:2@17.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_identity_credentials': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_identity_credentials', - 'version': 'version:2@16.0.0-alpha05.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_iid': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_iid', - 'version': 'version:2@17.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_instantapps': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_instantapps', - 'version': 'version:2@18.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_location': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_location', - 'version': 'version:2@21.3.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_phenotype': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_phenotype', - 'version': 'version:2@17.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_stats': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_stats', - 'version': 'version:2@17.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_tasks': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_tasks', - 'version': 'version:2@18.2.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_vision': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_vision', - 'version': 'version:2@20.1.3.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_gms_play_services_vision_common': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_vision_common', - 'version': 'version:2@19.1.3.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_android_libraries_identity_googleid_googleid': { + 'src/third_party/android_deps/cipd/libs/com_google_ar_impress': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_libraries_identity_googleid_googleid', - 'version': 'version:2@1.1.1.cr1', + 'package': 'chromium/third_party/android_deps/libs/com_google_ar_impress', + 'version': 'version:2@0.0.3.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_android_material_material': { + 'src/third_party/android_deps/cipd/libs/com_googlecode_java_diff_utils_diffutils': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_material_material', - 'version': 'version:2@1.13.0-alpha05.cr1', + 'package': 'chromium/third_party/android_deps/libs/com_googlecode_java_diff_utils_diffutils', + 'version': 'version:2@1.3.0.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_android_play_core_common': { + 'src/third_party/android_deps/cipd/libs/com_squareup_javapoet': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_play_core_common', - 'version': 'version:2@2.0.3.cr1', + 'package': 'chromium/third_party/android_deps/libs/com_squareup_javapoet', + 'version': 'version:2@1.13.0.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_android_play_feature_delivery': { + 'src/third_party/android_deps/cipd/libs/net_bytebuddy_byte_buddy': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_android_play_feature_delivery', - 'version': 'version:2@2.1.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/net_bytebuddy_byte_buddy', + 'version': 'version:2@1.14.12.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_ar_impress': { + 'src/third_party/android_deps/cipd/libs/net_bytebuddy_byte_buddy_agent': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_ar_impress', - 'version': 'version:2@0.0.2.cr1', + 'package': 'chromium/third_party/android_deps/libs/net_bytebuddy_byte_buddy_agent', + 'version': 'version:2@1.14.12.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_auto_service_auto_service_annotations': { + 'src/third_party/android_deps/cipd/libs/org_ccil_cowan_tagsoup_tagsoup': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_auto_service_auto_service_annotations', - 'version': 'version:2@1.0-rc6.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_ccil_cowan_tagsoup_tagsoup', + 'version': 'version:2@1.2.1.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_auto_value_auto_value_annotations': { + 'src/third_party/android_deps/cipd/libs/org_checkerframework_checker_compat_qual': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_auto_value_auto_value_annotations', - 'version': 'version:2@1.11.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_checker_compat_qual', + 'version': 'version:2@2.5.5.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_code_findbugs_jsr305': { + 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlin_kotlin_android_extensions_runtime': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_code_findbugs_jsr305', - 'version': 'version:2@3.0.2.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_android_extensions_runtime', + 'version': 'version:2@1.9.22.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_code_gson_gson': { + 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlin_kotlin_parcelize_runtime': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_code_gson_gson', - 'version': 'version:2@2.8.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_parcelize_runtime', + 'version': 'version:2@1.9.22.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_dagger_dagger': { + 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_atomicfu_jvm': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_dagger_dagger', - 'version': 'version:2@2.52.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_atomicfu_jvm', + 'version': 'version:2@0.23.2.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_errorprone_error_prone_annotations': { + 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_kotlinx_coroutines_guava': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_annotations', - 'version': 'version:2@2.30.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_guava', + 'version': 'version:2@1.8.1.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_annotations': { + 'src/third_party/android_deps/cipd/libs/org_jsoup_jsoup': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_annotations', - 'version': 'version:2@16.2.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_jsoup_jsoup', + 'version': 'version:2@1.15.1.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_common': { + 'src/third_party/android_deps/cipd/libs/org_mockito_mockito_android': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_common', - 'version': 'version:2@21.0.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_mockito_mockito_android', + 'version': 'version:2@5.11.0.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_common_ktx': { + 'src/third_party/android_deps/cipd/libs/org_mockito_mockito_core': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_common_ktx', - 'version': 'version:2@21.0.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_mockito_mockito_core', + 'version': 'version:2@5.11.0.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_components': { + 'src/third_party/android_deps/cipd/libs/org_mockito_mockito_subclass': { 'packages': [ { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_components', - 'version': 'version:2@18.0.0.cr1', + 'package': 'chromium/third_party/android_deps/libs/org_mockito_mockito_subclass', + 'version': 'version:2@5.11.0.cr1', }, ], 'condition': 'checkout_android and non_git_source', 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_datatransport': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_datatransport', - 'version': 'version:2@19.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_encoders': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_encoders', - 'version': 'version:2@17.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_encoders_json': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_encoders_json', - 'version': 'version:2@18.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_encoders_proto': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_encoders_proto', - 'version': 'version:2@16.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_iid': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_iid', - 'version': 'version:2@21.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_iid_interop': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_iid_interop', - 'version': 'version:2@17.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_installations': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_installations', - 'version': 'version:2@17.2.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_installations_interop': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_installations_interop', - 'version': 'version:2@17.1.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_measurement_connector': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_measurement_connector', - 'version': 'version:2@20.0.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_firebase_firebase_messaging': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_messaging', - 'version': 'version:2@24.1.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_guava_failureaccess': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_guava_failureaccess', - 'version': 'version:2@1.0.2.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_guava_guava': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_guava_guava', - 'version': 'version:2@33.3.1-jre.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_guava_guava_android': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_guava_guava_android', - 'version': 'version:2@33.3.1-android.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_j2objc_j2objc_annotations': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_j2objc_j2objc_annotations', - 'version': 'version:2@3.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_protobuf_protobuf_javalite': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_protobuf_protobuf_javalite', - 'version': 'version:2@4.28.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_google_testparameterinjector_test_parameter_injector': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_testparameterinjector_test_parameter_injector', - 'version': 'version:2@1.18.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_googlecode_java_diff_utils_diffutils': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_googlecode_java_diff_utils_diffutils', - 'version': 'version:2@1.3.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_squareup_javapoet': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_squareup_javapoet', - 'version': 'version:2@1.13.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_squareup_moshi_moshi': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_squareup_moshi_moshi', - 'version': 'version:2@1.15.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_squareup_moshi_moshi_adapters': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_squareup_moshi_moshi_adapters', - 'version': 'version:2@1.15.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_squareup_okio_okio_jvm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_squareup_okio_okio_jvm', - 'version': 'version:2@3.9.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/com_squareup_wire_wire_runtime_jvm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_squareup_wire_wire_runtime_jvm', - 'version': 'version:2@5.2.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/jakarta_inject_jakarta_inject_api': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/jakarta_inject_jakarta_inject_api', - 'version': 'version:2@2.0.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/javax_annotation_javax_annotation_api': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/javax_annotation_javax_annotation_api', - 'version': 'version:2@1.3.2.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/javax_inject_javax_inject': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/javax_inject_javax_inject', - 'version': 'version:2@1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/net_bytebuddy_byte_buddy': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/net_bytebuddy_byte_buddy', - 'version': 'version:2@1.14.12.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/net_bytebuddy_byte_buddy_agent': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/net_bytebuddy_byte_buddy_agent', - 'version': 'version:2@1.14.12.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_bouncycastle_bcprov_jdk18on': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_bouncycastle_bcprov_jdk18on', - 'version': 'version:2@1.78.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_ccil_cowan_tagsoup_tagsoup': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_ccil_cowan_tagsoup_tagsoup', - 'version': 'version:2@1.2.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_checkerframework_checker_compat_qual': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_checker_compat_qual', - 'version': 'version:2@2.5.5.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_checkerframework_checker_qual': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_checker_qual', - 'version': 'version:2@3.43.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_checkerframework_checker_util': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_checker_util', - 'version': 'version:2@3.25.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_codehaus_mojo_animal_sniffer_annotations': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_codehaus_mojo_animal_sniffer_annotations', - 'version': 'version:2@1.17.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_conscrypt_conscrypt_openjdk_uber': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_conscrypt_conscrypt_openjdk_uber', - 'version': 'version:2@2.5.2.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlin_kotlin_android_extensions_runtime': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_android_extensions_runtime', - 'version': 'version:2@1.9.22.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlin_kotlin_parcelize_runtime': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_parcelize_runtime', - 'version': 'version:2@1.9.22.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_atomicfu_jvm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_atomicfu_jvm', - 'version': 'version:2@0.23.2.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_kotlinx_coroutines_android': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_android', - 'version': 'version:2@1.8.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm', - 'version': 'version:2@1.10.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_kotlinx_coroutines_guava': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_guava', - 'version': 'version:2@1.8.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_kotlinx_coroutines_play_services': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_play_services', - 'version': 'version:2@1.10.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_kotlinx_coroutines_test_jvm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_test_jvm', - 'version': 'version:2@1.7.3.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jetbrains_kotlinx_kotlinx_serialization_core_jvm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_serialization_core_jvm', - 'version': 'version:2@1.7.2.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jsoup_jsoup': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jsoup_jsoup', - 'version': 'version:2@1.15.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_jspecify_jspecify': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_jspecify_jspecify', - 'version': 'version:2@1.0.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_mockito_mockito_android': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_mockito_mockito_android', - 'version': 'version:2@5.11.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_mockito_mockito_core': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_mockito_mockito_core', - 'version': 'version:2@5.11.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_mockito_mockito_subclass': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_mockito_mockito_subclass', - 'version': 'version:2@5.11.0.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_objenesis_objenesis': { + 'src/third_party/android_deps/cipd/libs/org_objenesis_objenesis': { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_objenesis_objenesis', @@ -1853,215 +1064,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/android_deps/cipd/libs/org_ow2_asm_asm': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm', - 'version': 'version:2@9.7.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_ow2_asm_asm_analysis': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_analysis', - 'version': 'version:2@9.7.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_ow2_asm_asm_commons': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_commons', - 'version': 'version:2@9.7.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_ow2_asm_asm_tree': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_tree', - 'version': 'version:2@9.7.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_ow2_asm_asm_util': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_util', - 'version': 'version:2@9.7.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_annotations': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_annotations', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_junit': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_junit', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_nativeruntime': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_nativeruntime', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_nativeruntime_dist_compat': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_nativeruntime_dist_compat', - 'version': 'version:2@1.0.16.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_pluginapi': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_pluginapi', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_plugins_maven_dependency_resolver': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_plugins_maven_dependency_resolver', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_resources': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_resources', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_robolectric': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_robolectric', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_sandbox': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_sandbox', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_shadowapi': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadowapi', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_shadows_framework': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_framework', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_utils': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_robolectric_utils_reflector': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils_reflector', - 'version': 'version:2@4.14.1.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/cipd/libs/org_yaml_snakeyaml': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_yaml_snakeyaml', - 'version': 'version:2@2.3.cr1', - }, - ], - 'condition': 'checkout_android and non_git_source', - 'dep_type': 'cipd', - }, - # === ANDROID_DEPS Generated Code End === } diff --git a/PRESUBMIT.py b/PRESUBMIT.py index debc65fb24..153d77302b 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -33,8 +33,6 @@ 'modules/include/module_common_types.h', 'modules/utility', 'modules/video_capture', - 'p2p/base/pseudo_tcp.cc', - 'p2p/base/pseudo_tcp.h', 'PRESUBMIT.py', 'presubmit_test_mocks.py', 'presubmit_test.py', diff --git a/api/BUILD.gn b/api/BUILD.gn index 706c48dcc6..036a23ca9b 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -70,6 +70,19 @@ rtc_library("enable_media_with_defaults") { ] } +rtc_source_set("create_modular_peer_connection_factory") { + visibility = [ "*" ] + allow_poison = [ "environment_construction" ] + sources = [ "create_modular_peer_connection_factory.h" ] + deps = [ + ":libjingle_peerconnection_api", + ":scoped_refptr", + "../pc:peer_connection_factory", + "../rtc_base/system:rtc_export", + "../stats:rtc_stats", + ] +} + if (!build_with_chromium) { rtc_library("create_peerconnection_factory") { visibility = [ "*" ] @@ -79,14 +92,13 @@ if (!build_with_chromium) { "create_peerconnection_factory.h", ] deps = [ + ":create_modular_peer_connection_factory", ":enable_media", ":field_trials_view", ":libjingle_peerconnection_api", ":scoped_refptr", - "../pc:peer_connection_factory", "../rtc_base:threading", "../rtc_base/system:rtc_export", - "../stats:rtc_stats", "audio:audio_device", "audio:audio_mixer_api", "audio:audio_processing", @@ -221,7 +233,7 @@ rtc_source_set("ice_transport_interface") { ":ref_count", ":rtc_error", ":scoped_refptr", - "rtc_event_log:rtc_event_log", + "rtc_event_log", ] } @@ -277,6 +289,17 @@ rtc_library("rtp_sender_interface") { ] } +# TODO: bugs.webrtc.org/42220069 - Remove when downstream has been updated +# to depend on `create_modular_peer_connection_factory` instead. +rtc_source_set("create_modular_peer_connection_factory_internal") { + visibility = [ ":libjingle_peerconnection_api" ] + sources = [ "create_modular_peer_connection_factory_internal.h" ] + deps = [ + ":scoped_refptr", + "../rtc_base/system:rtc_export", + ] +} + rtc_library("libjingle_peerconnection_api") { visibility = [ "*" ] cflags = [] @@ -317,6 +340,7 @@ rtc_library("libjingle_peerconnection_api") { ":async_dns_resolver", ":audio_options_api", ":candidate", + ":create_modular_peer_connection_factory_internal", ":data_channel_event_observer_interface", ":dtls_transport_interface", ":fec_controller_api", @@ -416,6 +440,7 @@ rtc_library("frame_transformer_interface") { ":make_ref_counted", ":ref_count", ":scoped_refptr", + "../rtc_base:checks", "../rtc_base:refcount", "../rtc_base/system:rtc_export", "units:time_delta", @@ -888,6 +913,8 @@ rtc_source_set("simulated_network_api") { "../rtc_base:random", "transport:ecn_marking", "units:data_rate", + "units:data_size", + "units:timestamp", "//third_party/abseil-cpp/absl/functional:any_invocable", ] } @@ -913,6 +940,7 @@ rtc_library("network_emulation_manager_api") { "../rtc_base:socket_address", "../test/network:simulated_network", "test/network_emulation", + "test/network_emulation:network_queue", "units:data_rate", "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", @@ -997,7 +1025,7 @@ rtc_library("ice_transport_factory") { "../rtc_base:macromagic", "../rtc_base:threading", "../rtc_base/system:rtc_export", - "rtc_event_log:rtc_event_log", + "rtc_event_log", ] } @@ -1023,7 +1051,7 @@ rtc_source_set("sequence_checker") { "../rtc_base:checks", "../rtc_base:macromagic", "../rtc_base/synchronization:sequence_checker_internal", - "task_queue:task_queue", + "task_queue", ] } @@ -1365,6 +1393,7 @@ if (rtc_include_tests) { ":candidate", ":libjingle_peerconnection_api", "../test:test_support", + "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -1393,13 +1422,17 @@ if (rtc_include_tests) { ] } - rtc_source_set("mock_local_network_access_permission") { + rtc_library("mock_local_network_access_permission") { visibility = [ "*" ] testonly = true - sources = [ "test/mock_local_network_access_permission.h" ] + sources = [ + "test/mock_local_network_access_permission.cc", + "test/mock_local_network_access_permission.h", + ] deps = [ ":local_network_access_permission", "../rtc_base:socket_address", + "../rtc_base:threading", "../test:test_support", "//third_party/abseil-cpp/absl/functional:any_invocable", ] @@ -1696,6 +1729,11 @@ rtc_source_set("field_trials_view") { rtc_library("field_trials") { visibility = [ "*" ] + + # Internally webrtc shouldn't create or modify field trials, and should use + # FieldTrials through the FieldTrialsView interface that is usually propagated + # with Environment. + poisonous = [ "environment_construction" ] sources = [ "field_trials.cc", "field_trials.h", @@ -1720,7 +1758,7 @@ rtc_library("frame_transformer_factory") { ":frame_transformer_interface", ":ref_count", ":scoped_refptr", - "../audio:audio", + "../audio", "../modules/rtp_rtcp", "../rtc_base:checks", "../rtc_base/system:rtc_export", diff --git a/api/array_view.h b/api/array_view.h index 8b68b9d22d..4e7bfea4eb 100644 --- a/api/array_view.h +++ b/api/array_view.h @@ -332,16 +332,5 @@ inline ArrayView reinterpret_array_view(ArrayView view) { } // 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 { -template -using ArrayView = ::webrtc::ArrayView; -using ::webrtc::MakeArrayView; -using ::webrtc::reinterpret_array_view; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_ARRAY_VIEW_H_ diff --git a/api/array_view_unittest.cc b/api/array_view_unittest.cc index 445f4189b1..f424cd2ff6 100644 --- a/api/array_view_unittest.cc +++ b/api/array_view_unittest.cc @@ -10,10 +10,9 @@ #include "api/array_view.h" -#include - #include #include +#include #include #include #include diff --git a/api/audio/audio_frame.cc b/api/audio/audio_frame.cc index c6a89361cd..78b84efce9 100644 --- a/api/audio/audio_frame.cc +++ b/api/audio/audio_frame.cc @@ -10,9 +10,8 @@ #include "api/audio/audio_frame.h" -#include - #include +#include #include #include "api/array_view.h" diff --git a/api/audio/channel_layout.cc b/api/audio/channel_layout.cc index 596db90cfd..9e6dcc3eab 100644 --- a/api/audio/channel_layout.cc +++ b/api/audio/channel_layout.cc @@ -10,8 +10,7 @@ #include "api/audio/channel_layout.h" -#include - +#include #include #include "rtc_base/checks.h" diff --git a/api/audio/test/audio_frame_unittest.cc b/api/audio/test/audio_frame_unittest.cc index 4397716a45..9ee422eea1 100644 --- a/api/audio/test/audio_frame_unittest.cc +++ b/api/audio/test/audio_frame_unittest.cc @@ -10,8 +10,8 @@ #include "api/audio/audio_frame.h" -#include -#include // memcmp +#include +#include #include "api/audio/audio_view.h" #include "api/audio/channel_layout.h" diff --git a/api/audio_codecs/L16/audio_encoder_L16.cc b/api/audio_codecs/L16/audio_encoder_L16.cc index 458f680ec4..71372bd450 100644 --- a/api/audio_codecs/L16/audio_encoder_L16.cc +++ b/api/audio_codecs/L16/audio_encoder_L16.cc @@ -10,8 +10,7 @@ #include "api/audio_codecs/L16/audio_encoder_L16.h" -#include - +#include #include #include #include diff --git a/api/audio_codecs/g711/audio_encoder_g711.cc b/api/audio_codecs/g711/audio_encoder_g711.cc index f430bbc862..af8f1eaf80 100644 --- a/api/audio_codecs/g711/audio_encoder_g711.cc +++ b/api/audio_codecs/g711/audio_encoder_g711.cc @@ -10,8 +10,7 @@ #include "api/audio_codecs/g711/audio_encoder_g711.h" -#include - +#include #include #include #include diff --git a/api/audio_codecs/g722/audio_encoder_g722.cc b/api/audio_codecs/g722/audio_encoder_g722.cc index ed86d164da..d1bbb2e21b 100644 --- a/api/audio_codecs/g722/audio_encoder_g722.cc +++ b/api/audio_codecs/g722/audio_encoder_g722.cc @@ -10,8 +10,7 @@ #include "api/audio_codecs/g722/audio_encoder_g722.h" -#include - +#include #include #include #include diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn index ad59ce700e..6df8361dbb 100644 --- a/api/audio_codecs/opus/BUILD.gn +++ b/api/audio_codecs/opus/BUILD.gn @@ -41,8 +41,10 @@ rtc_source_set("audio_decoder_opus_config") { rtc_library("audio_encoder_opus") { visibility = [ "*" ] poisonous = [ "audio_codecs" ] - public = [ "audio_encoder_opus.h" ] - sources = [ "audio_encoder_opus.cc" ] + sources = [ + "audio_encoder_opus.cc", + "audio_encoder_opus.h", + ] deps = [ ":audio_encoder_opus_config", "..:audio_codecs_api", @@ -74,8 +76,10 @@ rtc_library("audio_decoder_opus") { rtc_library("audio_encoder_multiopus") { visibility = [ "*" ] poisonous = [ "audio_codecs" ] - public = [ "audio_encoder_multi_channel_opus.h" ] - sources = [ "audio_encoder_multi_channel_opus.cc" ] + sources = [ + "audio_encoder_multi_channel_opus.cc", + "audio_encoder_multi_channel_opus.h", + ] deps = [ "..:audio_codecs_api", "../../../api:field_trials_view", diff --git a/api/audio_codecs/opus/audio_decoder_opus_unittest.cc b/api/audio_codecs/opus/audio_decoder_opus_unittest.cc index f8fe4fafa7..8fdd6312e7 100644 --- a/api/audio_codecs/opus/audio_decoder_opus_unittest.cc +++ b/api/audio_codecs/opus/audio_decoder_opus_unittest.cc @@ -17,7 +17,6 @@ #include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" @@ -88,9 +87,8 @@ TEST(AudioDecoderOpusTest, MakeAudioDecoderCannotForceDefaultNumChannels) { } TEST(AudioDecoderOpusTest, MakeAudioDecoderForcesStereo) { - const Environment env = - CreateEnvironment(std::make_unique(CreateTestFieldTrials( - "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/"))); + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/")); auto decoder = AudioDecoderOpus::MakeAudioDecoder( env, /*config=*/{.num_channels = std::nullopt}); @@ -99,9 +97,8 @@ TEST(AudioDecoderOpusTest, MakeAudioDecoderForcesStereo) { } TEST(AudioDecoderOpusTest, MakeAudioDecoderCannotForceStereo) { - const Environment env = - CreateEnvironment(std::make_unique(CreateTestFieldTrials( - "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/"))); + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/")); auto decoder = AudioDecoderOpus::MakeAudioDecoder(env, /*config=*/{.num_channels = 1}); diff --git a/api/audio_options.h b/api/audio_options.h index 723ee0ff3e..6d4ad0b42a 100644 --- a/api/audio_options.h +++ b/api/audio_options.h @@ -70,12 +70,5 @@ struct RTC_EXPORT AudioOptions { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::AudioOptions; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_AUDIO_OPTIONS_H_ diff --git a/api/candidate.h b/api/candidate.h index 69e66ef526..6e97a1f43c 100644 --- a/api/candidate.h +++ b/api/candidate.h @@ -289,17 +289,5 @@ class RTC_EXPORT Candidate { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::Candidate; -using ::webrtc::kMaxTurnServers; -using ::webrtc::LOCAL_PORT_TYPE; -using ::webrtc::PRFLX_PORT_TYPE; -using ::webrtc::RELAY_PORT_TYPE; -using ::webrtc::STUN_PORT_TYPE; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_CANDIDATE_H_ diff --git a/api/create_modular_peer_connection_factory.h b/api/create_modular_peer_connection_factory.h new file mode 100644 index 0000000000..9dcd3cb531 --- /dev/null +++ b/api/create_modular_peer_connection_factory.h @@ -0,0 +1,34 @@ +/* + * 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 API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_H_ +#define API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_H_ + +#include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" +#include "rtc_base/system/rtc_export.h" + +namespace webrtc { +// Creates a new instance of PeerConnectionFactoryInterface with optional +// dependencies. +// +// If an application knows it will only require certain modules, it can reduce +// webrtc's impact on its binary size by depending only on this target and the +// modules the application requires, using CreateModularPeerConnectionFactory. +// For example, if an application only uses WebRTC for audio, it can pass in +// null pointers for the video-specific interfaces, and omit the corresponding +// modules from its build. +RTC_EXPORT scoped_refptr +CreateModularPeerConnectionFactory( + PeerConnectionFactoryDependencies dependencies); + +} // namespace webrtc + +#endif // API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_H_ diff --git a/api/create_modular_peer_connection_factory_internal.h b/api/create_modular_peer_connection_factory_internal.h new file mode 100644 index 0000000000..370c148deb --- /dev/null +++ b/api/create_modular_peer_connection_factory_internal.h @@ -0,0 +1,39 @@ +/* + * 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. + */ + +// This temporary header is here to steer users of the +// CreateModularPeerConnectionFactory to include +// `create_modular_peer_connection_factory.h` and thus depend on +// `create_modular_peer_connection_factory` build target. Once users are +// migrated this file can be deleted. + +// IWYU pragma: private, include "api/create_modular_peer_connection_factory.h" + +#ifndef API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_ +#define API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_ + +#include "api/scoped_refptr.h" +#include "rtc_base/system/rtc_export.h" + +namespace webrtc { + +// Forward declare to avoid circular dependencies with +// `api/peer_connection_interface.h`. This file exists to be included from that +// header, and same time requires classes defined in that header. +class PeerConnectionFactoryInterface; +struct PeerConnectionFactoryDependencies; + +RTC_EXPORT scoped_refptr +CreateModularPeerConnectionFactory( + PeerConnectionFactoryDependencies dependencies); + +} // namespace webrtc + +#endif // API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_ diff --git a/api/create_peerconnection_factory.cc b/api/create_peerconnection_factory.cc index 12434eef58..c64828e42c 100644 --- a/api/create_peerconnection_factory.cc +++ b/api/create_peerconnection_factory.cc @@ -19,6 +19,7 @@ #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/create_modular_peer_connection_factory.h" #include "api/enable_media.h" #include "api/environment/environment_factory.h" #include "api/field_trials_view.h" diff --git a/api/crypto/BUILD.gn b/api/crypto/BUILD.gn index 7bfae89caf..be26152266 100644 --- a/api/crypto/BUILD.gn +++ b/api/crypto/BUILD.gn @@ -59,8 +59,9 @@ if (rtc_include_tests) { sources = [ "crypto_options_unittest.cc" ] deps = [ ":options", + "..:field_trials", "../../rtc_base:ssl_adapter", - "../../test:scoped_key_value_config", + "../../test:create_test_field_trials", "../../test:test_support", "//testing/gtest", ] diff --git a/api/crypto/crypto_options.cc b/api/crypto/crypto_options.cc index e939f390e5..c83e1105cc 100644 --- a/api/crypto/crypto_options.cc +++ b/api/crypto/crypto_options.cc @@ -12,7 +12,9 @@ #include #include +#include #include +#include #include #include @@ -105,6 +107,11 @@ CryptoOptions::EphemeralKeyExchangeCipherGroups::GetSupported() { return SSLStreamAdapter::GetSupportedEphemeralKeyExchangeCipherGroups(); } +std::optional +CryptoOptions::EphemeralKeyExchangeCipherGroups::GetName(uint16_t group_id) { + return SSLStreamAdapter::GetEphemeralKeyExchangeCipherGroupName(group_id); +} + void CryptoOptions::EphemeralKeyExchangeCipherGroups::AddFirst(uint16_t group) { std::erase(enabled_, group); enabled_.insert(enabled_.begin(), group); diff --git a/api/crypto/crypto_options.h b/api/crypto/crypto_options.h index 5504f6f900..56238fb764 100644 --- a/api/crypto/crypto_options.h +++ b/api/crypto/crypto_options.h @@ -86,7 +86,7 @@ struct RTC_EXPORT CryptoOptions { static constexpr uint16_t kX25519_MLKEM768 = 0x11ec; static std::set GetSupported(); - static std::optional GetName(uint16_t); + static std::optional GetName(uint16_t group_id); EphemeralKeyExchangeCipherGroups(); diff --git a/api/crypto/crypto_options_unittest.cc b/api/crypto/crypto_options_unittest.cc index 6abc806c3a..3c0ee2914c 100644 --- a/api/crypto/crypto_options_unittest.cc +++ b/api/crypto/crypto_options_unittest.cc @@ -14,9 +14,13 @@ #include #include -#include "rtc_base/openssl_stream_adapter.h" +#include "api/field_trials.h" +#include "rtc_base/openssl_stream_adapter.h" // IWYU pragma: keep +#include "test/create_test_field_trials.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" + +namespace webrtc { +namespace { TEST(EphemeralKeyExchangeCipherGroupsTest, GetSupported) { std::set expected = { @@ -123,8 +127,8 @@ TEST(EphemeralKeyExchangeCipherGroupsTest, Update) { }; webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups groups; - webrtc::test::ScopedKeyValueConfig field_trials( - "WebRTC-EnableDtlsPqc/Enabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-EnableDtlsPqc/Enabled/"); groups.Update(&field_trials, &disable); EXPECT_EQ(groups.GetEnabled(), expected); } @@ -139,3 +143,6 @@ TEST(EphemeralKeyExchangeCipherGroupsTest, CopyCryptoOptions) { EXPECT_EQ(options, copy1); EXPECT_EQ(options, copy2); } + +} // namespace +} // namespace webrtc diff --git a/api/environment/BUILD.gn b/api/environment/BUILD.gn index 1a21672e5c..c0aeda973e 100644 --- a/api/environment/BUILD.gn +++ b/api/environment/BUILD.gn @@ -40,8 +40,8 @@ rtc_library("environment_factory") { "../../rtc_base/system:rtc_export", "../../system_wrappers", "../rtc_event_log", + "../task_queue", "../task_queue:default_task_queue_factory", - "../task_queue:task_queue", "../transport:field_trial_based_config", "//third_party/abseil-cpp/absl/base:nullability", ] diff --git a/api/environment/environment_factory.cc b/api/environment/environment_factory.cc index 8ee52c3d8d..0dd380a70b 100644 --- a/api/environment/environment_factory.cc +++ b/api/environment/environment_factory.cc @@ -100,7 +100,10 @@ void EnvironmentFactory::Set( Environment EnvironmentFactory::CreateWithDefaults() && { if (field_trials_ == nullptr) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" Set(std::make_unique()); +#pragma clang diagnostic pop } if (clock_ == nullptr) { Set(Clock::GetRealTimeClock()); diff --git a/api/field_trials.h b/api/field_trials.h index 4937b506be..09aa1dc8b6 100644 --- a/api/field_trials.h +++ b/api/field_trials.h @@ -70,8 +70,8 @@ class FieldTrials : public FieldTrialsRegistry { // 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. + // TODO: bugs.webrtc.org/42220378 - Delete after August 1, 2025. + [[deprecated]] static std::unique_ptr CreateNoGlobal(absl::string_view s) { return std::make_unique(s); } diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h index db3a8cdac3..904a2ef3b0 100644 --- a/api/frame_transformer_interface.h +++ b/api/frame_transformer_interface.h @@ -22,6 +22,7 @@ #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "api/video/video_frame_metadata.h" +#include "rtc_base/checks.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { diff --git a/api/function_view.h b/api/function_view.h index f19a1d389d..adbb5cdcb3 100644 --- a/api/function_view.h +++ b/api/function_view.h @@ -128,12 +128,5 @@ class FunctionView final { } // 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::FunctionView; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_FUNCTION_VIEW_H_ diff --git a/api/g3doc/threading_design.md b/api/g3doc/threading_design.md index 8023b5eda0..38ace685a5 100644 --- a/api/g3doc/threading_design.md +++ b/api/g3doc/threading_design.md @@ -47,6 +47,13 @@ void ObserverClass::Handler(event) { // Process event, we're now on the right thread } ``` +It is generally NOT safe to call WebRTC library functions from the callback; +if this is wanted, one should instead dispatch a task on an appropriate +thread to do so. + +In the future, the implementation may evolve to crash or return an error +if this happens. + In the future, the implementation may change to always call the callbacks and event handlers on the client thread. diff --git a/api/jsep.cc b/api/jsep.cc index cf7c97bade..26b89588c8 100644 --- a/api/jsep.cc +++ b/api/jsep.cc @@ -13,17 +13,9 @@ #include #include #include -#include - -#include "api/candidate.h" namespace webrtc { -size_t SessionDescriptionInterface::RemoveCandidates( - const std::vector& /* candidates */) { - return 0; -} - const char SessionDescriptionInterface::kOffer[] = "offer"; const char SessionDescriptionInterface::kPrAnswer[] = "pranswer"; const char SessionDescriptionInterface::kAnswer[] = "answer"; diff --git a/api/jsep.h b/api/jsep.h index 5808e990a6..bd3214499f 100644 --- a/api/jsep.h +++ b/api/jsep.h @@ -154,11 +154,6 @@ class IceCandidateCollection final { [[deprecated("Use unique_ptr version")]] void add(IceCandidate* candidate); - // Removes the candidate that has a matching address and protocol. - // - // Returns the number of candidates that were removed. - size_t remove(const Candidate& candidate); - // Removes the candidate that has a matching address and protocol. // // Returns the number of candidates that were removed. @@ -198,6 +193,11 @@ enum class SdpType { // SessionDescriptionInterface. RTC_EXPORT const char* SdpTypeToString(SdpType type); +template +void AbslStringify(Sink& sink, SdpType sdp_type) { + sink.Append(SdpTypeToString(sdp_type)); +} + // Returns the SdpType from its string form. The string form can be one of the // constants defined in SessionDescriptionInterface. Passing in any other string // results in nullopt. @@ -263,13 +263,6 @@ class RTC_EXPORT SessionDescriptionInterface { // Returns false if no matching candidate was found (and removed). virtual bool RemoveCandidate(const IceCandidate* candidate) = 0; - // Removes the candidates from the description, if found. - // - // Returns the number of candidates removed. - // TODO: webrtc:42233526 - Deprecate and eventually remove this method in - // favor of the IceCandidate version. - virtual size_t RemoveCandidates(const std::vector& candidates); - // Returns the number of m= sections in the session description. virtual size_t number_of_mediasections() const = 0; @@ -283,7 +276,7 @@ class RTC_EXPORT SessionDescriptionInterface { template friend void AbslStringify(Sink& sink, const SessionDescriptionInterface& p) { sink.Append("\n--- BEGIN SDP "); - sink.Append(SdpTypeToString(p.GetType())); + absl::Format(&sink, "%v", p.GetType()); sink.Append(" ---\n"); std::string temp; if (p.ToString(&temp)) { diff --git a/api/jsep_ice_candidate.cc b/api/jsep_ice_candidate.cc index 0e7db64c8c..49c7fb7ab1 100644 --- a/api/jsep_ice_candidate.cc +++ b/api/jsep_ice_candidate.cc @@ -73,18 +73,6 @@ bool IceCandidateCollection::HasCandidate(const IceCandidate* candidate) const { }); } -size_t JsepCandidateCollection::remove(const Candidate& candidate) { - auto iter = - absl::c_find_if(candidates_, [&](const std::unique_ptr& c) { - return candidate.MatchesForRemoval(c->candidate()); - }); - if (iter != candidates_.end()) { - candidates_.erase(iter); - return 1; - } - return 0; -} - size_t JsepCandidateCollection::remove(const IceCandidate* candidate) { RTC_DCHECK(candidate); auto iter = diff --git a/api/jsep_ice_candidate.h b/api/jsep_ice_candidate.h index f0a41bef91..6bc5d82cd0 100644 --- a/api/jsep_ice_candidate.h +++ b/api/jsep_ice_candidate.h @@ -12,6 +12,6 @@ #define API_JSEP_ICE_CANDIDATE_H_ // TODO: webrtc:406795492 - Delete file once no longer #included. -#include "api/jsep.h" +#include "api/jsep.h" // IWYU pragma: keep #endif // API_JSEP_ICE_CANDIDATE_H_ diff --git a/api/jsep_session_description.h b/api/jsep_session_description.h index d2683a01db..357ed78ba7 100644 --- a/api/jsep_session_description.h +++ b/api/jsep_session_description.h @@ -20,7 +20,6 @@ #include #include "absl/strings/string_view.h" -#include "api/candidate.h" #include "api/jsep.h" namespace webrtc { @@ -60,9 +59,7 @@ class JsepSessionDescription : public SessionDescriptionInterface { // Allows changing the type. Used for testing. virtual bool AddCandidate(const IceCandidate* candidate); virtual bool RemoveCandidate(const IceCandidate* candidate); - // TODO: https://issues.webrtc.org/42233526 - Remove this method in favor of - // the IceCandidate version. - virtual size_t RemoveCandidates(const std::vector& candidates); + virtual size_t number_of_mediasections() const; virtual const IceCandidateCollection* candidates( size_t mediasection_index) const; @@ -75,8 +72,9 @@ class JsepSessionDescription : public SessionDescriptionInterface { SdpType type_; std::vector candidate_collection_; - bool GetMediasectionIndex(const IceCandidate* candidate, size_t* index); - int GetMediasectionIndex(const Candidate& candidate); + bool IsValidMLineIndex(int index) const; + bool GetMediasectionIndex(const IceCandidate* candidate, size_t* index) const; + int GetMediasectionIndex(absl::string_view mid) const; }; } // namespace webrtc diff --git a/api/legacy_stats_types.cc b/api/legacy_stats_types.cc index 64e8d42409..c7dae1c63d 100644 --- a/api/legacy_stats_types.cc +++ b/api/legacy_stats_types.cc @@ -10,9 +10,8 @@ #include "api/legacy_stats_types.h" -#include - #include +#include #include #include diff --git a/api/make_ref_counted.h b/api/make_ref_counted.h index 48a05359a4..359271a190 100644 --- a/api/make_ref_counted.h +++ b/api/make_ref_counted.h @@ -121,12 +121,5 @@ absl_nonnull scoped_refptr> make_ref_counted( } // namespace webrtc -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { -// Backwards compatibe alias. -// TODO: bugs.webrtc.org/42225969 - deprecate and remove. -using ::webrtc::make_ref_counted; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_MAKE_REF_COUNTED_H_ diff --git a/api/media_types.h b/api/media_types.h index e58abfdb3b..0dd232ba45 100644 --- a/api/media_types.h +++ b/api/media_types.h @@ -13,7 +13,6 @@ #include -#include "absl/base/macros.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -49,24 +48,5 @@ extern const char kMediaTypeData[]; // They used to be incompatible, but now cricket is defined in terms of the // webrtc definition. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { - -using MediaType ABSL_DEPRECATE_AND_INLINE() = webrtc::MediaType; -using webrtc::kMediaTypeAudio; -using webrtc::kMediaTypeData; -using webrtc::kMediaTypeVideo; -using webrtc::MediaTypeToString; - -// Backwards compatibility values for cricket::MediaType users -// TODO: https://issues.webrtc.org/42222911 - remove -[[deprecated]] constexpr MediaType MEDIA_TYPE_AUDIO = webrtc::MediaType::AUDIO; -[[deprecated]] constexpr MediaType MEDIA_TYPE_VIDEO = webrtc::MediaType::VIDEO; -[[deprecated]] constexpr MediaType MEDIA_TYPE_DATA = webrtc::MediaType::DATA; -[[deprecated]] constexpr MediaType MEDIA_TYPE_UNSUPPORTED = - webrtc::MediaType::UNSUPPORTED; - -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_MEDIA_TYPES_H_ diff --git a/api/neteq/BUILD.gn b/api/neteq/BUILD.gn index 3fd020b6fe..826e426e86 100644 --- a/api/neteq/BUILD.gn +++ b/api/neteq/BUILD.gn @@ -89,6 +89,34 @@ rtc_library("default_neteq_controller_factory") { ] } +rtc_library("custom_neteq_controller_factory") { + visibility = [ "*" ] + sources = [ + "custom_neteq_controller_factory.cc", + "custom_neteq_controller_factory.h", + ] + deps = [ + ":delay_manager_api", + ":neteq_controller_api", + "../../modules/audio_coding:neteq", + "../../rtc_base:checks", + "../environment", + ] +} + +rtc_library("delay_manager_api") { + visibility = [ "*" ] + sources = [ + "delay_manager_factory.h", + "delay_manager_interface.h", + ] + deps = [ + ":neteq_controller_api", + ":tick_timer", + "..:field_trials_view", + ] +} + rtc_library("tick_timer") { visibility = [ "*" ] sources = [ diff --git a/api/neteq/custom_neteq_controller_factory.cc b/api/neteq/custom_neteq_controller_factory.cc new file mode 100644 index 0000000000..3c3520377d --- /dev/null +++ b/api/neteq/custom_neteq_controller_factory.cc @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "api/neteq/custom_neteq_controller_factory.h" + +#include +#include + +#include "api/environment/environment.h" +#include "api/neteq/delay_manager_factory.h" +#include "api/neteq/neteq_controller.h" +#include "modules/audio_coding/neteq/decision_logic.h" +#include "rtc_base/checks.h" + +namespace webrtc { + +CustomNetEqControllerFactory::CustomNetEqControllerFactory( + std::unique_ptr delay_manager_factory) + : delay_manager_factory_(std::move(delay_manager_factory)) {} +CustomNetEqControllerFactory::~CustomNetEqControllerFactory() = default; + +std::unique_ptr CustomNetEqControllerFactory::Create( + const Environment& env, + const NetEqController::Config& config) const { + RTC_DCHECK(delay_manager_factory_); + return std::make_unique( + env, config, + delay_manager_factory_->Create(env.field_trials(), config.tick_timer)); +} + +} // namespace webrtc diff --git a/api/neteq/custom_neteq_controller_factory.h b/api/neteq/custom_neteq_controller_factory.h new file mode 100644 index 0000000000..742981ea09 --- /dev/null +++ b/api/neteq/custom_neteq_controller_factory.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_NETEQ_CUSTOM_NETEQ_CONTROLLER_FACTORY_H_ +#define API_NETEQ_CUSTOM_NETEQ_CONTROLLER_FACTORY_H_ + +#include + +#include "api/environment/environment.h" +#include "api/neteq/delay_manager_factory.h" +#include "api/neteq/neteq_controller.h" +#include "api/neteq/neteq_controller_factory.h" +namespace webrtc { + +// This factory can be used to generate NetEqController instances that make +// use of a custom DelayManagerFactory. +class CustomNetEqControllerFactory : public NetEqControllerFactory { + public: + explicit CustomNetEqControllerFactory( + std::unique_ptr delay_manager_factory); + ~CustomNetEqControllerFactory() override; + CustomNetEqControllerFactory(const CustomNetEqControllerFactory&) = delete; + CustomNetEqControllerFactory& operator=(const CustomNetEqControllerFactory&) = + delete; + + std::unique_ptr Create( + const Environment& env, + const NetEqController::Config& config) const override; + + private: + std::unique_ptr delay_manager_factory_; +}; + +} // namespace webrtc + +#endif // API_NETEQ_CUSTOM_NETEQ_CONTROLLER_FACTORY_H_ diff --git a/api/neteq/default_neteq_controller_factory.cc b/api/neteq/default_neteq_controller_factory.cc index 81461c0817..f432988203 100644 --- a/api/neteq/default_neteq_controller_factory.cc +++ b/api/neteq/default_neteq_controller_factory.cc @@ -11,10 +11,12 @@ #include "api/neteq/default_neteq_controller_factory.h" #include +#include #include "api/environment/environment.h" #include "api/neteq/neteq_controller.h" #include "modules/audio_coding/neteq/decision_logic.h" +#include "modules/audio_coding/neteq/delay_manager.h" namespace webrtc { @@ -24,7 +26,9 @@ DefaultNetEqControllerFactory::~DefaultNetEqControllerFactory() = default; std::unique_ptr DefaultNetEqControllerFactory::Create( const Environment& env, const NetEqController::Config& config) const { - return std::make_unique(env, config); + auto delay_manager = std::make_unique( + DelayManager::Config(env.field_trials()), config.tick_timer); + return std::make_unique(env, config, std::move(delay_manager)); } } // namespace webrtc diff --git a/api/neteq/delay_manager_factory.h b/api/neteq/delay_manager_factory.h new file mode 100644 index 0000000000..4ebed04ac9 --- /dev/null +++ b/api/neteq/delay_manager_factory.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_NETEQ_DELAY_MANAGER_FACTORY_H_ +#define API_NETEQ_DELAY_MANAGER_FACTORY_H_ + +#include + +#include "api/field_trials_view.h" +#include "api/neteq/delay_manager_interface.h" +#include "api/neteq/tick_timer.h" +namespace webrtc { + +// Creates DelayManagerInterface instances. +class DelayManagerFactory { + public: + virtual ~DelayManagerFactory() = default; + + // Creates a new DelayManager object. + virtual std::unique_ptr Create( + const FieldTrialsView& field_trials, + const TickTimer* tick_timer) const = 0; +}; + +} // namespace webrtc + +#endif // API_NETEQ_DELAY_MANAGER_FACTORY_H_ diff --git a/api/neteq/delay_manager_interface.h b/api/neteq/delay_manager_interface.h new file mode 100644 index 0000000000..b68b2ecae3 --- /dev/null +++ b/api/neteq/delay_manager_interface.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_NETEQ_DELAY_MANAGER_INTERFACE_H_ +#define API_NETEQ_DELAY_MANAGER_INTERFACE_H_ + +#include "api/neteq/neteq_controller.h" + +namespace webrtc { + +// Interface for the delay manager. +class DelayManagerInterface { + public: + virtual ~DelayManagerInterface() = default; + + // Updates the delay manager that a new packet arrived with delay + // `arrival_delay_ms`. This updates the statistics and a new target buffer + // level is calculated. The `reordered` flag indicates if the packet was + // reordered. The `info` argument contains information about the packet. + virtual void Update(int arrival_delay_ms, + bool reordered, + NetEqController::PacketArrivedInfo info) = 0; + + // Resets all state. + virtual void Reset() = 0; + + // Gets the target buffer level in milliseconds. + virtual int TargetDelayMs() const = 0; +}; + +} // namespace webrtc + +#endif // API_NETEQ_DELAY_MANAGER_INTERFACE_H_ diff --git a/api/neteq/neteq.h b/api/neteq/neteq.h index 67a1a83433..c5968ebe3d 100644 --- a/api/neteq/neteq.h +++ b/api/neteq/neteq.h @@ -238,10 +238,15 @@ class NetEq { virtual void SetCodecs(const std::map& codecs) = 0; // Associates `rtp_payload_type` with the given codec, which NetEq will - // instantiate when it needs it. Returns true iff successful. + // instantiate when it needs it. Returns true if successful. virtual bool RegisterPayloadType(int rtp_payload_type, const SdpAudioFormat& audio_format) = 0; + // Creates a decoder for `rtp_payload_type`. Can be used to instantiate a + // decoder ahead of time to avoid blocking when needed. Returns true if + // successful. + virtual bool CreateDecoder(int rtp_payload_type) { return false; } + // Removes `rtp_payload_type` from the codec database. Returns 0 on success, // -1 on failure. Removing a payload type that is not registered is ok and // will not result in an error. diff --git a/api/numerics/samples_stats_counter_unittest.cc b/api/numerics/samples_stats_counter_unittest.cc index d1614f2e2d..a713bb1048 100644 --- a/api/numerics/samples_stats_counter_unittest.cc +++ b/api/numerics/samples_stats_counter_unittest.cc @@ -10,8 +10,7 @@ #include "api/numerics/samples_stats_counter.h" -#include - +#include #include #include diff --git a/api/packet_socket_factory.h b/api/packet_socket_factory.h index 602eeaa9ed..3c98b24b73 100644 --- a/api/packet_socket_factory.h +++ b/api/packet_socket_factory.h @@ -78,13 +78,5 @@ class RTC_EXPORT PacketSocketFactory { } // 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::PacketSocketFactory; -using ::webrtc::PacketSocketTcpOptions; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_PACKET_SOCKET_FACTORY_H_ diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h index 25ac226bad..1b0beb3ae3 100644 --- a/api/peer_connection_interface.h +++ b/api/peer_connection_interface.h @@ -148,6 +148,10 @@ #include "rtc_base/system/rtc_export.h" #include "rtc_base/thread.h" +// TODO: bugs.webrtc.org/42220069 - Remove this include when users of this +// function include "create_modular_peer_connection_factory.h" instead. +#include "api/create_modular_peer_connection_factory_internal.h" // IWYU pragma: keep + namespace webrtc { // IWYU pragma: begin_keep // MediaFactory class definition is not part of the api. @@ -228,6 +232,10 @@ class RTC_EXPORT PeerConnectionInterface : public RefCountInterface { kIceConnectionMax, }; static constexpr absl::string_view AsString(IceConnectionState state); + template + void AbslStringify(Sink& sink, IceConnectionState state) { + sink.Append(AsString(state)); + } // TLS certificate policy. enum TlsCertPolicy { @@ -651,10 +659,18 @@ class RTC_EXPORT PeerConnectionInterface : public RefCountInterface { bool active_reset_srtp_params = false; // Defines advanced optional cryptographic settings related to SRTP and - // frame encryption for native WebRTC. Setting this will overwrite any - // settings set in PeerConnectionFactory (which is deprecated). + // frame encryption for native WebRTC. std::optional crypto_options; + // TODO: bugs.webrtc.org/42235111 - remove after converting callers that + // expect an optional. + CryptoOptions& GetWritableCryptoOptions() { + if (!crypto_options) { + crypto_options = CryptoOptions(); + } + return *crypto_options; + } + // Configure if we should include the SDP attribute extmap-allow-mixed in // our offer on session level. bool offer_extmap_allow_mixed = true; @@ -1120,8 +1136,9 @@ class RTC_EXPORT PeerConnectionInterface : public RefCountInterface { virtual bool AddIceCandidate(const IceCandidate* candidate) = 0; // TODO(hbos): Remove default implementation once implemented by downstream // projects. - virtual void AddIceCandidate(std::unique_ptr /* candidate */, - std::function /* callback */) {} + virtual void AddIceCandidate(std::unique_ptr candidate, + std::function callback) {} + virtual bool RemoveIceCandidate(const IceCandidate* candidate) = 0; // Removes a group of remote candidates from the ICE agent. Needed mainly for // continual gathering, to avoid an ever-growing list of candidates as @@ -1129,6 +1146,7 @@ class RTC_EXPORT PeerConnectionInterface : public RefCountInterface { // to the MID of the m= section that generated the candidate. // TODO(bugs.webrtc.org/8395): Use IceCandidate instead of // Candidate, which would avoid the transport_name oddity. + [[deprecated("Use IceCandidate version")]] virtual bool RemoveIceCandidates( const std::vector& candidates) = 0; @@ -1520,9 +1538,6 @@ class RTC_EXPORT PeerConnectionFactoryInterface : public RefCountInterface { // supported by both ends will be used for the connection, i.e. if one // party supports DTLS 1.0 and the other DTLS 1.2, DTLS 1.0 will be used. SSLProtocolVersion ssl_max_version = SSL_PROTOCOL_DTLS_12; - - // Sets crypto related options, e.g. enabled cipher suites. - CryptoOptions crypto_options = {}; }; // Set the options to be used for subsequently created PeerConnections. @@ -1558,13 +1573,6 @@ class RTC_EXPORT PeerConnectionFactoryInterface : public RefCountInterface { virtual scoped_refptr CreateVideoTrack( scoped_refptr source, absl::string_view label) = 0; - ABSL_DEPRECATED("Use version with scoped_refptr") - virtual scoped_refptr CreateVideoTrack( - const std::string& label, - VideoTrackSourceInterface* source) { - return CreateVideoTrack(scoped_refptr(source), - label); - } // Creates an new AudioTrack. At the moment `source` can be null. virtual scoped_refptr CreateAudioTrack( @@ -1594,26 +1602,6 @@ class RTC_EXPORT PeerConnectionFactoryInterface : public RefCountInterface { ~PeerConnectionFactoryInterface() override = default; }; -// CreateModularPeerConnectionFactory is implemented in the "peerconnection" -// build target, which doesn't pull in the implementations of every module -// webrtc may use. -// -// If an application knows it will only require certain modules, it can reduce -// webrtc's impact on its binary size by depending only on the "peerconnection" -// target and the modules the application requires, using -// CreateModularPeerConnectionFactory. For example, if an application -// only uses WebRTC for audio, it can pass in null pointers for the -// video-specific interfaces, and omit the corresponding modules from its -// build. -// -// If `network_thread` or `worker_thread` are null, the PeerConnectionFactory -// will create the necessary thread internally. If `signaling_thread` is null, -// the PeerConnectionFactory will use the thread on which this method is called -// as the signaling thread, wrapping it in an Thread object if needed. -RTC_EXPORT scoped_refptr -CreateModularPeerConnectionFactory( - PeerConnectionFactoryDependencies dependencies); - // https://w3c.github.io/webrtc-pc/#dom-rtcsignalingstate inline constexpr absl::string_view PeerConnectionInterface::AsString( SignalingState state) { diff --git a/api/ref_counted_base.h b/api/ref_counted_base.h index a411257069..b718ce1e1b 100644 --- a/api/ref_counted_base.h +++ b/api/ref_counted_base.h @@ -96,14 +96,5 @@ class RefCountedNonVirtual { } // namespace webrtc -// Backwards compatibe aliases. -// TODO: https://issues.webrtc.org/42225969 - deprecate and remove. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { -using RefCountedBase = webrtc::RefCountedBase; -template -using RefCountedNonVirtual = webrtc::RefCountedNonVirtual; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_REF_COUNTED_BASE_H_ diff --git a/api/rtc_event_log_output_file_unittest.cc b/api/rtc_event_log_output_file_unittest.cc index b1441c7cf7..38b8b4736c 100644 --- a/api/rtc_event_log_output_file_unittest.cc +++ b/api/rtc_event_log_output_file_unittest.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/api/rtp_packet_info.cc b/api/rtp_packet_info.cc index 90cd27515c..557247b523 100644 --- a/api/rtp_packet_info.cc +++ b/api/rtp_packet_info.cc @@ -10,9 +10,8 @@ #include "api/rtp_packet_info.h" -#include - #include +#include #include #include #include diff --git a/api/rtp_packet_infos_unittest.cc b/api/rtp_packet_infos_unittest.cc index 544bb93b38..e05ed66298 100644 --- a/api/rtp_packet_infos_unittest.cc +++ b/api/rtp_packet_infos_unittest.cc @@ -10,7 +10,7 @@ #include "api/rtp_packet_infos.h" -#include +#include #include "api/rtp_headers.h" #include "api/rtp_packet_info.h" diff --git a/api/scoped_refptr.h b/api/scoped_refptr.h index f533670444..03d611731d 100644 --- a/api/scoped_refptr.h +++ b/api/scoped_refptr.h @@ -219,12 +219,5 @@ bool operator<(const scoped_refptr& a, const scoped_refptr& b) { } // namespace webrtc -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { -// Backwards compatible alias. -// TODO: bugs.webrtc.org/42225969 - Deprecate and remove. -using ::webrtc::scoped_refptr; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_SCOPED_REFPTR_H_ diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn index 9f10f0afc6..71778f52ec 100644 --- a/api/task_queue/BUILD.gn +++ b/api/task_queue/BUILD.gn @@ -10,11 +10,11 @@ import("../../webrtc.gni") rtc_library("task_queue") { visibility = [ "*" ] - public = [ + sources = [ + "task_queue_base.cc", "task_queue_base.h", "task_queue_factory.h", ] - sources = [ "task_queue_base.cc" ] deps = [ "..:location", @@ -77,12 +77,11 @@ rtc_library("task_queue_test") { rtc_library("default_task_queue_factory") { visibility = [ "*" ] - if (!is_ios && !is_android) { - # Internally webrtc shouldn't rely on any specific TaskQueue implementation - # and should create TaskQueue using TaskQueueFactory interface. - # TaskQueueFactory interface can be propagated with Environment. - poisonous = [ "environment_construction" ] - } + + # Internally webrtc shouldn't rely on any specific TaskQueue implementation + # and should create TaskQueue using TaskQueueFactory interface. + # TaskQueueFactory interface can be propagated with Environment. + poisonous = [ "environment_construction" ] sources = [ "default_task_queue_factory.h" ] deps = [ ":task_queue", diff --git a/api/task_queue/test/BUILD.gn b/api/task_queue/test/BUILD.gn index 65a590f67e..f1438c7d8c 100644 --- a/api/task_queue/test/BUILD.gn +++ b/api/task_queue/test/BUILD.gn @@ -13,7 +13,7 @@ rtc_library("mock_task_queue_base") { sources = [ "mock_task_queue_base.h" ] deps = [ "../..:location", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", "../../../api/units:time_delta", "../../../test:test_support", "//third_party/abseil-cpp/absl/functional:any_invocable", diff --git a/api/test/metrics/BUILD.gn b/api/test/metrics/BUILD.gn index 3f93d22fa8..abb6453bbe 100644 --- a/api/test/metrics/BUILD.gn +++ b/api/test/metrics/BUILD.gn @@ -12,14 +12,17 @@ if (rtc_enable_protobuf) { } group("metrics") { + testonly = true deps = [ ":global_metrics_logger_and_exporter", ":metric", ":metrics_accumulator", ":metrics_exporter", ":metrics_logger", - ":stdout_metrics_exporter", ] + if (!build_with_chromium) { + deps += [ ":stdout_metrics_exporter" ] + } } if (rtc_include_tests) { @@ -98,18 +101,26 @@ rtc_library("metrics_exporter") { ] } -rtc_library("stdout_metrics_exporter") { - visibility = [ "*" ] - sources = [ - "stdout_metrics_exporter.cc", - "stdout_metrics_exporter.h", - ] - deps = [ - ":metric", - ":metrics_exporter", - "../..:array_view", - "../../../rtc_base:stringutils", - ] +if (!build_with_chromium) { + # Hidden from the Chromium build because it depends on absl flags which + # cannot be compiled in Chromium. + rtc_library("stdout_metrics_exporter") { + visibility = [ "*" ] + testonly = true + sources = [ + "stdout_metrics_exporter.cc", + "stdout_metrics_exporter.h", + ] + deps = [ + ":metric", + ":metrics_exporter", + "../..:array_view", + "../../../rtc_base:stringutils", + "../../../test:test_flags", + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/strings", + ] + } } rtc_library("chrome_perf_dashboard_metrics_exporter") { @@ -222,8 +233,10 @@ if (rtc_include_tests) { deps = [ ":metric", ":stdout_metrics_exporter", + "../../../test:test_flags", "../../../test:test_support", "../../units:timestamp", + "//third_party/abseil-cpp/absl/flags:flag", ] } diff --git a/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc b/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc index 5fe0b14c2b..79d50d6c64 100644 --- a/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc +++ b/api/test/metrics/chrome_perf_dashboard_metrics_exporter.cc @@ -9,8 +9,7 @@ */ #include "api/test/metrics/chrome_perf_dashboard_metrics_exporter.h" -#include - +#include #include #include #include diff --git a/api/test/metrics/metrics_set_proto_file_exporter.cc b/api/test/metrics/metrics_set_proto_file_exporter.cc index 044828c120..c3a7554585 100644 --- a/api/test/metrics/metrics_set_proto_file_exporter.cc +++ b/api/test/metrics/metrics_set_proto_file_exporter.cc @@ -9,8 +9,7 @@ */ #include "api/test/metrics/metrics_set_proto_file_exporter.h" -#include - +#include #include #include #include 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 cc9ecde8d2..58af31bc4b 100644 --- a/api/test/metrics/metrics_set_proto_file_exporter_test.cc +++ b/api/test/metrics/metrics_set_proto_file_exporter_test.cc @@ -19,7 +19,6 @@ #include "api/test/metrics/metric.h" #include "api/test/metrics/proto/metric.pb.h" #include "api/units/timestamp.h" -#include "rtc_base/protobuf_utils.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" diff --git a/api/test/metrics/stdout_metrics_exporter.cc b/api/test/metrics/stdout_metrics_exporter.cc index 62b8ad8a74..336817f8da 100644 --- a/api/test/metrics/stdout_metrics_exporter.cc +++ b/api/test/metrics/stdout_metrics_exporter.cc @@ -9,16 +9,18 @@ */ #include "api/test/metrics/stdout_metrics_exporter.h" -#include - #include #include +#include #include #include +#include "absl/flags/flag.h" +#include "absl/strings/str_cat.h" #include "api/array_view.h" #include "api/test/metrics/metric.h" #include "rtc_base/strings/string_builder.h" +#include "test/test_flags.h" namespace webrtc { namespace test { @@ -67,6 +69,22 @@ void AppendWithPrecision(double value, } } +std::string TestCaseAndMetadata(const Metric& metric) { + if (absl::GetFlag(FLAGS_isolated_script_test_perf_output).empty()) { + if (metric.metric_metadata.contains("video_stream")) { + return absl::StrCat(metric.test_case, "/", + metric.metric_metadata.at("video_stream"), "_", + metric.metric_metadata.at("sender"), "_", + metric.metric_metadata.at("receiver")); + } + if (metric.metric_metadata.contains("peer")) { + return absl::StrCat(metric.test_case, "/", + metric.metric_metadata.at("peer")); + } + } + return metric.test_case; +} + } // namespace StdoutMetricsExporter::StdoutMetricsExporter() : output_(stdout) {} @@ -80,7 +98,8 @@ bool StdoutMetricsExporter::Export(ArrayView metrics) { void StdoutMetricsExporter::PrintMetric(const Metric& metric) { StringBuilder value_stream; - value_stream << metric.test_case << " / " << metric.name << "= {mean="; + value_stream << TestCaseAndMetadata(metric) << " / " << metric.name + << "= {mean="; if (metric.stats.mean.has_value()) { AppendWithPrecision(*metric.stats.mean, 8, value_stream); } else { diff --git a/api/test/metrics/stdout_metrics_exporter_test.cc b/api/test/metrics/stdout_metrics_exporter_test.cc index 27c1d84927..93d25fb844 100644 --- a/api/test/metrics/stdout_metrics_exporter_test.cc +++ b/api/test/metrics/stdout_metrics_exporter_test.cc @@ -13,9 +13,11 @@ #include #include +#include "absl/flags/flag.h" #include "api/test/metrics/metric.h" #include "api/units/timestamp.h" #include "test/gtest.h" +#include "test/test_flags.h" namespace webrtc { namespace test { @@ -42,27 +44,51 @@ Metric PsnrForTestFoo(double mean, double stddev) { .stats = Metric::Stats{.mean = mean, .stddev = stddev}}; } -TEST(StdoutMetricsExporterTest, ExportMetricFormatCorrect) { - Metric metric1{ - .name = "test_metric1", - .unit = Unit::kMilliseconds, - .improvement_direction = ImprovementDirection::kBiggerIsBetter, - .test_case = "test_case_name1", - .metric_metadata = DefaultMetadata(), - .time_series = - Metric::TimeSeries{.samples = std::vector{Sample(10), Sample(20)}}, - .stats = - Metric::Stats{.mean = 15.0, .stddev = 5.0, .min = 10.0, .max = 20.0}}; - Metric metric2{ - .name = "test_metric2", - .unit = Unit::kKilobitsPerSecond, - .improvement_direction = ImprovementDirection::kSmallerIsBetter, - .test_case = "test_case_name2", - .metric_metadata = DefaultMetadata(), - .time_series = - Metric::TimeSeries{.samples = std::vector{Sample(20), Sample(40)}}, - .stats = Metric::Stats{ - .mean = 30.0, .stddev = 10.0, .min = 20.0, .max = 40.0}}; +class StdoutMetricsExporterTest : public ::testing::Test { + public: + StdoutMetricsExporterTest() { + original_isolated_script_test_perf_output_ = + absl::GetFlag(FLAGS_isolated_script_test_perf_output); + + metric1_ = { + .name = "test_metric1", + .unit = Unit::kMilliseconds, + .improvement_direction = ImprovementDirection::kBiggerIsBetter, + .test_case = "test_case_name1", + .metric_metadata = + std::map{{"video_stream", "alice_stream"}, + {"sender", "alice"}, + {"receiver", "bob"}}, + .time_series = + Metric::TimeSeries{.samples = std::vector{Sample(10), Sample(20)}}, + .stats = Metric::Stats{ + .mean = 15.0, .stddev = 5.0, .min = 10.0, .max = 20.0}}; + metric2_ = { + .name = "test_metric2", + .unit = Unit::kKilobitsPerSecond, + .improvement_direction = ImprovementDirection::kSmallerIsBetter, + .test_case = "test_case_name2", + .metric_metadata = + std::map{{"peer", "alice"}}, + .time_series = + Metric::TimeSeries{.samples = std::vector{Sample(20), Sample(40)}}, + .stats = Metric::Stats{ + .mean = 30.0, .stddev = 10.0, .min = 20.0, .max = 40.0}}; + } + ~StdoutMetricsExporterTest() { + absl::SetFlag(&FLAGS_isolated_script_test_perf_output, + original_isolated_script_test_perf_output_); + } + + protected: + std::string original_isolated_script_test_perf_output_; + Metric metric1_; + Metric metric2_; +}; + +TEST_F(StdoutMetricsExporterTest, + ExportMetricFormatCorrectWhenIsolatedScriptTestPerfOutputIsSet) { + absl::SetFlag(&FLAGS_isolated_script_test_perf_output, "/tmp/foo"); testing::internal::CaptureStdout(); StdoutMetricsExporter exporter; @@ -73,7 +99,24 @@ TEST(StdoutMetricsExporterTest, ExportMetricFormatCorrect) { "RESULT: test_case_name2 / test_metric2= " "{mean=30, stddev=10} KilobitsPerSecond (SmallerIsBetter)\n"; - EXPECT_TRUE(exporter.Export(std::vector{metric1, metric2})); + EXPECT_TRUE(exporter.Export(std::vector{metric1_, metric2_})); + EXPECT_EQ(expected, testing::internal::GetCapturedStdout()); +} + +TEST_F(StdoutMetricsExporterTest, + ExportMetricFormatCorrectWhenIsolatedScriptTestPerfOutputIsNotSet) { + absl::SetFlag(&FLAGS_isolated_script_test_perf_output, ""); + + testing::internal::CaptureStdout(); + StdoutMetricsExporter exporter; + + std::string expected = + "RESULT: test_case_name1/alice_stream_alice_bob / test_metric1= " + "{mean=15, stddev=5} Milliseconds (BiggerIsBetter)\n" + "RESULT: test_case_name2/alice / test_metric2= " + "{mean=30, stddev=10} KilobitsPerSecond (SmallerIsBetter)\n"; + + EXPECT_TRUE(exporter.Export(std::vector{metric1_, metric2_})); EXPECT_EQ(expected, testing::internal::GetCapturedStdout()); } diff --git a/api/test/mock_local_network_access_permission.cc b/api/test/mock_local_network_access_permission.cc new file mode 100644 index 0000000000..523a7a9812 --- /dev/null +++ b/api/test/mock_local_network_access_permission.cc @@ -0,0 +1,53 @@ +/* + * 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/test/mock_local_network_access_permission.h" + +#include +#include + +#include "absl/functional/any_invocable.h" +#include "api/local_network_access_permission.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/thread.h" +#include "test/gmock.h" +#include "test/gtest.h" + +using ::testing::_; + +namespace webrtc { + +FakeLocalNetworkAccessPermissionFactory:: + FakeLocalNetworkAccessPermissionFactory( + LocalNetworkAccessPermissionStatus status) { + EXPECT_CALL(*this, Create()).WillRepeatedly([status]() { + auto mock_lna_permission = + std::make_unique(); + + EXPECT_CALL(*mock_lna_permission, RequestPermission(_, _)) + .WillRepeatedly( + [status]( + const SocketAddress& /* addr */, + absl::AnyInvocable callback) { + Thread::Current()->PostTask( + [callback = std::move(callback), status]() mutable { + callback(status); + }); + }); + + return mock_lna_permission; + }); +} + +FakeLocalNetworkAccessPermissionFactory:: + ~FakeLocalNetworkAccessPermissionFactory() = default; + +} // namespace webrtc diff --git a/api/test/mock_local_network_access_permission.h b/api/test/mock_local_network_access_permission.h index 47fac75898..66c142232f 100644 --- a/api/test/mock_local_network_access_permission.h +++ b/api/test/mock_local_network_access_permission.h @@ -40,6 +40,16 @@ class MockLocalNetworkAccessPermissionFactory (override)); }; +// Class that returns LocalNetworkAccessPermission's that run their callback +// with the provided status. +class FakeLocalNetworkAccessPermissionFactory + : public MockLocalNetworkAccessPermissionFactory { + public: + explicit FakeLocalNetworkAccessPermissionFactory( + LocalNetworkAccessPermissionStatus status); + ~FakeLocalNetworkAccessPermissionFactory() override; +}; + } // namespace webrtc #endif // API_TEST_MOCK_LOCAL_NETWORK_ACCESS_PERMISSION_H_ diff --git a/api/test/mock_packet_socket_factory.h b/api/test/mock_packet_socket_factory.h index d32836b39f..f307549e08 100644 --- a/api/test/mock_packet_socket_factory.h +++ b/api/test/mock_packet_socket_factory.h @@ -48,12 +48,5 @@ static_assert(!std::is_abstract_v, ""); } // 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::MockPacketSocketFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_TEST_MOCK_PACKET_SOCKET_FACTORY_H_ diff --git a/api/test/mock_peer_connection_factory_interface.h b/api/test/mock_peer_connection_factory_interface.h index 4e75a10266..53dd721cde 100644 --- a/api/test/mock_peer_connection_factory_interface.h +++ b/api/test/mock_peer_connection_factory_interface.h @@ -58,10 +58,6 @@ class MockPeerConnectionFactoryInterface CreateAudioSource, (const AudioOptions&), (override)); - MOCK_METHOD(scoped_refptr, - CreateVideoTrack, - (const std::string&, VideoTrackSourceInterface*), - (override)); MOCK_METHOD(scoped_refptr, CreateVideoTrack, (scoped_refptr, absl::string_view), diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h index 575f4bc910..b383197e9c 100644 --- a/api/test/mock_peerconnectioninterface.h +++ b/api/test/mock_peerconnectioninterface.h @@ -199,6 +199,10 @@ class MockPeerConnectionInterface : public PeerConnectionInterface { RemoveIceCandidates, (const std::vector&), (override)); + MOCK_METHOD(bool, + RemoveIceCandidate, + (const IceCandidate* candidate), + (override)); MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override)); MOCK_METHOD(void, ReconfigureBandwidthEstimation, diff --git a/api/test/mock_session_description_interface.h b/api/test/mock_session_description_interface.h index 655055af8a..e2ff56cff7 100644 --- a/api/test/mock_session_description_interface.h +++ b/api/test/mock_session_description_interface.h @@ -15,9 +15,7 @@ #include #include #include -#include -#include "api/candidate.h" #include "api/jsep.h" #include "test/gmock.h" @@ -37,10 +35,6 @@ class MockSessionDescriptionInterface : public SessionDescriptionInterface { MOCK_METHOD(std::string, type, (), (const, override)); MOCK_METHOD(bool, AddCandidate, (const IceCandidate*), (override)); MOCK_METHOD(bool, RemoveCandidate, (const IceCandidate*), (override)); - MOCK_METHOD(size_t, - RemoveCandidates, - (const std::vector&), - (override)); MOCK_METHOD(size_t, number_of_mediasections, (), (const, override)); MOCK_METHOD(const IceCandidateCollection*, candidates, diff --git a/api/test/network_emulation/BUILD.gn b/api/test/network_emulation/BUILD.gn index d22cc09d00..681b289c6a 100644 --- a/api/test/network_emulation/BUILD.gn +++ b/api/test/network_emulation/BUILD.gn @@ -76,3 +76,48 @@ rtc_library("create_cross_traffic") { "../../../test/network:emulated_network", ] } + +rtc_library("network_queue") { + visibility = [ "*" ] + + sources = [ + "dual_pi2_network_queue.cc", + "dual_pi2_network_queue.h", + "leaky_bucket_network_queue.cc", + "leaky_bucket_network_queue.h", + "network_queue.h", + ] + + deps = [ + "../..:sequence_checker", + "../..:simulated_network_api", + "../../../rtc_base:checks", + "../../../rtc_base:logging", + "../../../rtc_base:macromagic", + "../../../rtc_base:random", + "../../transport:ecn_marking", + "../../units:data_rate", + "../../units:data_size", + "../../units:time_delta", + "../../units:timestamp", + ] +} + +rtc_library("network_queue_unittests") { + sources = [ + "dual_pi2_network_queue_unittest.cc", + "leaky_bucket_network_queue_unittest.cc", + ] + + testonly = true + deps = [ + ":network_queue", + "../..:simulated_network_api", + "../../../test:test_support", + "../../transport:ecn_marking", + "../../units:data_rate", + "../../units:data_size", + "../../units:time_delta", + "../../units:timestamp", + ] +} diff --git a/api/test/network_emulation/dual_pi2_network_queue.cc b/api/test/network_emulation/dual_pi2_network_queue.cc new file mode 100644 index 0000000000..5e83f2227b --- /dev/null +++ b/api/test/network_emulation/dual_pi2_network_queue.cc @@ -0,0 +1,157 @@ +/* + * 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/test/network_emulation/dual_pi2_network_queue.h" + +#include +#include +#include +#include + +#include "api/sequence_checker.h" +#include "api/test/simulated_network.h" +#include "api/transport/ecn_marking.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" + +namespace webrtc { + +DualPi2NetworkQueue::DualPi2NetworkQueue(const Config& config) + : config_(config), + step_threshold_(config.link_rate.IsInfinite() + ? DataSize::Infinity() + : config_.target_delay * config_.link_rate * 2), + random_(config.seed), + distribution_(0.0, 1.0) { + sequence_checker_.Detach(); +} + +void DualPi2NetworkQueue::SetMaxPacketCapacity(size_t max_packet_capacity) { + RTC_DCHECK_RUN_ON(&sequence_checker_); + max_packet_capacity_ = max_packet_capacity; + // Hack to allow SetMaxpPacketCapactiy to be called before the queue is being + // used on another sequence. + sequence_checker_.Detach(); +} + +bool DualPi2NetworkQueue::EnqueuePacket(const PacketInFlightInfo& packet_info) { + RTC_DCHECK_RUN_ON(&sequence_checker_); + UpdateBaseMarkingProbability(packet_info.send_time()); + if (max_packet_capacity_.has_value() && + l4s_queue_.size() + classic_queue_.size() >= *max_packet_capacity_) { + RTC_LOG(LS_WARNING) + << "DualPi2NetworkQueue::EnqueuePacket: Dropping packet " + "because max packet capacity is reached."; + return false; + } + + if (packet_info.ecn == EcnMarking::kNotEct || + packet_info.ecn == EcnMarking::kEct0) { + bool take_action = ShouldTakeAction(classic_drop_probability()); + if (!take_action) { + total_queued_size_ += packet_info.packet_size(); + classic_queue_.push(packet_info); + return true; + } + RTC_DLOG(LS_WARNING) + << "DualPi2NetworkQueue::EnqueuePacket: Dropping classic packet " + << packet_info.packet_id << ". Classic drop probability is " + << classic_drop_probability() + << " L4S queue size: " << l4s_queue_.size() + << " classic queue size: " << classic_queue_.size(); + + return false; + } + RTC_DCHECK(packet_info.ecn == EcnMarking::kEct1 || + packet_info.ecn == EcnMarking::kCe); + total_queued_size_ += packet_info.packet_size(); + bool take_action = ShouldTakeAction(l4s_marking_probability()); + if (take_action) { + PacketInFlightInfo ce_packet_info(packet_info); + ce_packet_info.ecn = EcnMarking::kCe; + l4s_queue_.push(ce_packet_info); + } else { + l4s_queue_.push(packet_info); + } + return true; +} + +std::optional DualPi2NetworkQueue::PeekNextPacket() const { + RTC_DCHECK_RUN_ON(&sequence_checker_); + if (!l4s_queue_.empty()) { + return l4s_queue_.front(); + } + if (!classic_queue_.empty()) { + return classic_queue_.front(); + } + return std::nullopt; +} + +std::optional DualPi2NetworkQueue::DequeuePacket( + Timestamp time_now) { + RTC_DCHECK_RUN_ON(&sequence_checker_); + UpdateBaseMarkingProbability(time_now); + std::queue& queue = + l4s_queue_.empty() ? classic_queue_ : l4s_queue_; + if (queue.empty()) { + return std::nullopt; + } + + PacketInFlightInfo packet_info = queue.front(); + queue.pop(); + total_queued_size_ -= packet_info.packet_size(); + if (packet_info.ecn == EcnMarking::kEct1 && + ShouldTakeAction(l4s_marking_probability())) { + packet_info.ecn = EcnMarking::kCe; + } + return packet_info; +} + +bool DualPi2NetworkQueue::empty() const { + RTC_DCHECK_RUN_ON(&sequence_checker_); + return classic_queue_.empty() && l4s_queue_.empty(); +} + +void DualPi2NetworkQueue::UpdateBaseMarkingProbability(Timestamp time_now) { + if (time_now - config_.probability_update_interval < + last_probability_update_time_) { + return; + } + last_probability_update_time_ = time_now; + TimeDelta sojourn_time = + std::max(l4s_queue_delay(time_now), classic_queue_delay(time_now)); + TimeDelta proportional_update = + config_.alpha * (sojourn_time - config_.target_delay); + TimeDelta integral_update = + config_.beta * (sojourn_time - previous_sojourn_time_); + previous_sojourn_time_ = sojourn_time; + base_marking_probability_ += + proportional_update.seconds() + integral_update.seconds(); + + if (base_marking_probability_ < 0) { + base_marking_probability_ = 0; + } + if (base_marking_probability_ > 1.0) { + base_marking_probability_ = 1.0; + } + RTC_DLOG(LS_VERBOSE) << "base_marking_probability_: " + << base_marking_probability_; +} + +bool DualPi2NetworkQueue::ShouldTakeAction(double marking_probability) { + if (total_queued_size_ > step_threshold_) { + return true; + } + return distribution_(random_) < marking_probability; +} + +} // namespace webrtc diff --git a/api/test/network_emulation/dual_pi2_network_queue.h b/api/test/network_emulation/dual_pi2_network_queue.h new file mode 100644 index 0000000000..bd2e381588 --- /dev/null +++ b/api/test/network_emulation/dual_pi2_network_queue.h @@ -0,0 +1,138 @@ +/* + * 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 API_TEST_NETWORK_EMULATION_DUAL_PI2_NETWORK_QUEUE_H_ +#define API_TEST_NETWORK_EMULATION_DUAL_PI2_NETWORK_QUEUE_H_ + +#include +#include +#include +#include +#include +#include + +#include "api/sequence_checker.h" +#include "api/test/network_emulation/network_queue.h" +#include "api/test/simulated_network.h" +#include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" + +namespace webrtc { + +// DualPi2NetworkQueue is a simplified version of the DualPi2 AQM controller in +// https://github.com/L4STeam/linux/. Concepts are described in +// https://datatracker.ietf.org/doc/html/rfc9332. +// Developed for testing purposes. +// Note that this implementation does not support the credit-based system +// (c_protection) from the real implementation and thus a L4S stream can +// completely starve a classic stream. +// +// TODO: bugs.webrtc.org/42225697 - Implement c_protection to better +// support testing of cross traffic with classic TCP. +class DualPi2NetworkQueue : public NetworkQueue { + public: + struct Config { + // Target delay for the queue. The queue will try to keep the delay of the + // L4S queue below this value. + TimeDelta target_delay = TimeDelta::Micros(500); + // Link rate puts a cap on how many bytes in total that can be stored in the + // queue and still approximately meet the target delay. The cap is + // calculated as: 2*target_delay * link_rate and applies to both queues + // combined. If more packets than this are enqueued, they will be CE marked + // (L4S) or dropped (classic). + DataRate link_rate = DataRate::PlusInfinity(); + + // These constants are used to calculate the proportional and integral + // factors when updating the marking probability. + // Values are from the original implementation. + double alpha = 0.16; + double beta = 3.2; + // Coupling factor. + int k = 2; + + // How often the base marking probability is updated. + TimeDelta probability_update_interval = TimeDelta::Millis(16); + int seed = 1; + }; + + DualPi2NetworkQueue() : DualPi2NetworkQueue(Config()) {} + explicit DualPi2NetworkQueue(const Config& config); + + void SetMaxPacketCapacity(size_t max_packet_capacity) override; + bool EnqueuePacket(const PacketInFlightInfo& packet_info) override; + + std::optional PeekNextPacket() const override; + std::optional DequeuePacket(Timestamp time_now) override; + std::vector DequeueDroppedPackets() override { + // DualPi2 always tail drop packets. + return {}; + } + bool empty() const override; + + // Returns the marking probability of the L4S the l4s queue. Public for + // testing. + double l4s_marking_probability() const { + return base_marking_probability_ * config_.k; + } + // Returns the drop probability of the classic queue. Public for + // testing. + double classic_drop_probability() const { + return (base_marking_probability_ * base_marking_probability_); + } + + private: + void UpdateBaseMarkingProbability(Timestamp time_now); + bool ShouldTakeAction(double marking_probability); + TimeDelta l4s_queue_delay(Timestamp time_now) const { + return l4s_queue_.empty() ? TimeDelta::Zero() + : time_now - l4s_queue_.front().send_time(); + } + + TimeDelta classic_queue_delay(Timestamp time_now) const { + return classic_queue_.empty() + ? TimeDelta::Zero() + : time_now - classic_queue_.front().send_time(); + } + + SequenceChecker sequence_checker_; + + const Config config_; + const DataSize step_threshold_; + + std::queue l4s_queue_; + std::queue classic_queue_; + + std::mt19937 random_; + std::uniform_real_distribution distribution_; + + std::optional max_packet_capacity_; + DataSize total_queued_size_; + double base_marking_probability_ = 0; + Timestamp last_probability_update_time_ = Timestamp::MinusInfinity(); + // The delay of the queue after the last probability update. + TimeDelta previous_sojourn_time_ = TimeDelta::Zero(); +}; + +class DualPi2NetworkQueueFactory : public NetworkQueueFactory { + public: + explicit DualPi2NetworkQueueFactory(const DualPi2NetworkQueue::Config& config) + : config_(config) {} + + std::unique_ptr CreateQueue() override { + return std::make_unique(config_); + } + + private: + const DualPi2NetworkQueue::Config config_; +}; +} // namespace webrtc + +#endif // API_TEST_NETWORK_EMULATION_DUAL_PI2_NETWORK_QUEUE_H_ diff --git a/api/test/network_emulation/dual_pi2_network_queue_unittest.cc b/api/test/network_emulation/dual_pi2_network_queue_unittest.cc new file mode 100644 index 0000000000..d7a429d203 --- /dev/null +++ b/api/test/network_emulation/dual_pi2_network_queue_unittest.cc @@ -0,0 +1,281 @@ +/* + * 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/test/network_emulation/dual_pi2_network_queue.h" + +#include +#include +#include + +#include "api/test/simulated_network.h" +#include "api/transport/ecn_marking.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 "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { + +namespace { + +using ::testing::AnyOf; +using ::testing::Field; +using ::testing::Optional; +using ::testing::Property; + +constexpr DataSize kPacketSize = DataSize::Bytes(1000); + +TEST(DualPi2NetworkQueueTest, EnqueuePacket) { + DualPi2NetworkQueue queue; + Timestamp send_time = Timestamp::Seconds(123); + PacketInFlightInfo packet_info(kPacketSize, send_time, /*packet_id=*/1, + EcnMarking::kNotEct); + EXPECT_TRUE(queue.EnqueuePacket(packet_info)); +} + +TEST(DualPi2NetworkQueueTest, PeekNextPacketReturnsNulloptWhenEmpty) { + DualPi2NetworkQueue queue; + EXPECT_EQ(queue.PeekNextPacket(), std::nullopt); +} + +TEST(DualPi2NetworkQueueTest, PeekNextPacketPrioritizeL4SQueue) { + DualPi2NetworkQueue queue; + Timestamp send_time = Timestamp::Seconds(123); + PacketInFlightInfo packet_info_classic(kPacketSize, send_time, + /*packet_id=*/1, EcnMarking::kNotEct); + queue.EnqueuePacket(packet_info_classic); + PacketInFlightInfo packet_info_l4s_1(kPacketSize, send_time, + /*packet_id=*/2, EcnMarking::kEct1); + queue.EnqueuePacket(packet_info_l4s_1); + PacketInFlightInfo packet_info_l4s_2(kPacketSize, send_time, + /*packet_id=*/3, EcnMarking::kEct1); + queue.EnqueuePacket(packet_info_l4s_2); + std::optional peeked_packet = queue.PeekNextPacket(); + ASSERT_TRUE(peeked_packet.has_value()); + EXPECT_EQ(peeked_packet.value().packet_id, 2u); +} + +TEST(DualPi2NetworkQueueTest, DequeuePacketReturnsNulloptWhenEmpty) { + DualPi2NetworkQueue queue; + EXPECT_EQ(queue.DequeuePacket(Timestamp::Seconds(123)), std::nullopt); +} + +TEST(DualPi2NetworkQueueTest, DequeuePacketPrioritizeL4SQueue) { + DualPi2NetworkQueue queue; + Timestamp send_time = Timestamp::Seconds(123); + PacketInFlightInfo packet_info_classic(kPacketSize, send_time, + /*packet_id=*/1, EcnMarking::kNotEct); + queue.EnqueuePacket(packet_info_classic); + PacketInFlightInfo packet_info_l4s_1(kPacketSize, send_time, + /*packet_id=*/2, EcnMarking::kEct1); + queue.EnqueuePacket(packet_info_l4s_1); + PacketInFlightInfo packet_info_l4s_2(kPacketSize, send_time, + /*packet_id=*/3, EcnMarking::kEct1); + queue.EnqueuePacket(packet_info_l4s_2); + Timestamp dequeue_time = Timestamp::Seconds(123); + EXPECT_THAT( + queue.DequeuePacket(dequeue_time), + Optional(AllOf(Field(&PacketInFlightInfo::packet_id, 2), + Field(&PacketInFlightInfo::ecn, EcnMarking::kEct1), + Property(&PacketInFlightInfo::send_time, send_time)))); + EXPECT_THAT( + queue.DequeuePacket(dequeue_time), + Optional(AllOf(Field(&PacketInFlightInfo::packet_id, 3), + Field(&PacketInFlightInfo::ecn, EcnMarking::kEct1), + Property(&PacketInFlightInfo::send_time, send_time)))); + EXPECT_THAT( + queue.DequeuePacket(dequeue_time), + Optional(AllOf(Field(&PacketInFlightInfo::packet_id, 1), + Field(&PacketInFlightInfo::ecn, EcnMarking::kNotEct), + Property(&PacketInFlightInfo::send_time, send_time)))); +} + +TEST(DualPi2NetworkQueueTest, + CeMarkingProbabilityIncreaseIfSojournTimeTooHigh) { + DualPi2NetworkQueue queue; + + double marking_probability = 0; + Timestamp now = Timestamp::Seconds(123); + + for (int i = 0; i < 4; ++i) { + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i, EcnMarking::kEct1)); + // Dequeue 1 packet after 17ms, 1ms more than the probability update + // interval and more than the target delay. + now += TimeDelta::Millis(17); + ASSERT_THAT(queue.DequeuePacket(now), + Optional(Field(&PacketInFlightInfo::packet_id, i))); + EXPECT_GT(queue.l4s_marking_probability(), marking_probability); + marking_probability = queue.l4s_marking_probability(); + EXPECT_GT(marking_probability, 0); + EXPECT_LE(marking_probability, std::numeric_limits::max()); + } +} + +TEST(DualPi2NetworkQueueTest, + CeMarkingProbabilityIncreaseIfSojournTimeTooHighForClassicTraffic) { + DualPi2NetworkQueue queue; + + double marking_probability = 0; + Timestamp now = Timestamp::Seconds(123); + + for (int i = 0; i < 4; ++i) { + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i, EcnMarking::kEct0)); + // Dequeue 1 packet after 17ms, 1ms more than the probability update + // interval and more than the target delay. + now += TimeDelta::Millis(17); + ASSERT_THAT(queue.DequeuePacket(now), + Optional(Field(&PacketInFlightInfo::packet_id, i))); + EXPECT_GT(queue.l4s_marking_probability(), marking_probability); + marking_probability = queue.l4s_marking_probability(); + EXPECT_GT(marking_probability, 0); + EXPECT_LE(marking_probability, std::numeric_limits::max()); + } +} + +TEST(DualPi2NetworkQueueTest, + CeMarkingProbabilityDontIncreaseIfSojournTimeEqualToTarget) { + DualPi2NetworkQueue queue; + Timestamp now = Timestamp::Seconds(123); + int i = 0; + double marking_probability_at_equilibrium = -1; + while (now < Timestamp::Seconds(123 + 1)) { + i = i + 2; + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i, EcnMarking::kEct1)); + now += TimeDelta::Micros(500); + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i + 1, + EcnMarking::kEct1)); + + ASSERT_THAT(queue.DequeuePacket(now), + Optional(Field(&PacketInFlightInfo::packet_id, i))); + now += TimeDelta::Micros(500); + ASSERT_THAT(queue.DequeuePacket(now), + Optional(Field(&PacketInFlightInfo::packet_id, i + 1))); + if (queue.l4s_marking_probability() != 0 && + marking_probability_at_equilibrium == -1) { + // Both proportional and integral updates are zero after the second update + // since the sojourn time is equal to the target delay. + marking_probability_at_equilibrium = queue.l4s_marking_probability(); + } + } + EXPECT_EQ(queue.l4s_marking_probability(), + marking_probability_at_equilibrium); +} + +TEST(DualPi2NetworkQueueTest, L4SQueueCeMarkIfDelayIsTooHigh) { + DualPi2NetworkQueue queue; + bool has_seen_ce_marked_packet = false; + Timestamp now = Timestamp::Seconds(123); + int i = 0; + while (now < Timestamp::Seconds(123 + 1)) { + now += TimeDelta::Millis(20); + // Enqueue 2 L4S packets but only dequeue one. Delay will grow.... + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct1)); + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct1)); + + std::optional dequeued_packet = + queue.DequeuePacket(now); + ASSERT_TRUE(dequeued_packet.has_value()); + if (dequeued_packet->ecn == EcnMarking::kCe) { + EXPECT_GT(queue.l4s_marking_probability(), 0); + has_seen_ce_marked_packet = true; + break; + } + } + EXPECT_TRUE(has_seen_ce_marked_packet); +} + +TEST(DualPi2NetworkQueueTest, ClassicQueueDropPacketIfL4SDelayIsTooHigh) { + DualPi2NetworkQueue queue; + bool has_dropped_classic_packet = false; + Timestamp now = Timestamp::Seconds(123); + int i = 0; + while (now < Timestamp::Seconds(123 + 1)) { + now += TimeDelta::Millis(20); + // Enqueue 2 L4S packets but only dequeue one. L4S delay will grow.... + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct1)); + queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct1)); + // Enqueue a classic packet. + has_dropped_classic_packet |= queue.EnqueuePacket( + PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, EcnMarking::kEct0)); + + std::optional dequeued_packet = + queue.DequeuePacket(now); + ASSERT_TRUE(dequeued_packet.has_value()); + // Dequeued packets are always L4S. + EXPECT_THAT(dequeued_packet->ecn, + AnyOf(EcnMarking::kEct1, EcnMarking::kCe)); + } + EXPECT_TRUE(has_dropped_classic_packet); +} + +TEST(DualPi2NetworkQueueTest, CeMarksIfStepThresholdIsReached) { + DualPi2NetworkQueue::Config config; + config.link_rate = DataRate::KilobitsPerSec(100); + const DataSize kStepThreshold = config.target_delay * config.link_rate * 2; + DualPi2NetworkQueue queue(config); + DataSize total_queued_size = DataSize::Zero(); + Timestamp now = Timestamp::Seconds(123); + + int i = 0; + while (total_queued_size < kStepThreshold) { + ASSERT_TRUE(queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct1))); + total_queued_size += kPacketSize; + } + std::optional dequeued_packet = queue.DequeuePacket(now); + ASSERT_TRUE(dequeued_packet.has_value()); + EXPECT_EQ(dequeued_packet->ecn, EcnMarking::kCe); +} + +TEST(DualPi2NetworkQueueTest, DropsClassicPacketIfStepThresholdIsReached) { + DualPi2NetworkQueue::Config config; + config.link_rate = DataRate::KilobitsPerSec(100); + const DataSize kStepThreshold = config.target_delay * config.link_rate * 2; + DualPi2NetworkQueue queue(config); + DataSize total_queued_size = DataSize::Zero(); + Timestamp now = Timestamp::Seconds(123); + int i = 0; + + while (total_queued_size < kStepThreshold) { + ASSERT_TRUE(queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct1))); + total_queued_size += kPacketSize; + } + + EXPECT_FALSE(queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct0))); + + while (total_queued_size < kStepThreshold) { + ASSERT_TRUE(queue.EnqueuePacket(PacketInFlightInfo(kPacketSize, now, + /*packet_id=*/i++, + EcnMarking::kEct1))); + total_queued_size += kPacketSize; + } +} + +} // namespace +} // namespace webrtc diff --git a/api/test/network_emulation/leaky_bucket_network_queue.cc b/api/test/network_emulation/leaky_bucket_network_queue.cc new file mode 100644 index 0000000000..b3fbb3b854 --- /dev/null +++ b/api/test/network_emulation/leaky_bucket_network_queue.cc @@ -0,0 +1,71 @@ +/* + * 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/test/network_emulation/leaky_bucket_network_queue.h" + +#include +#include +#include + +#include "api/test/simulated_network.h" +#include "api/units/timestamp.h" +#include "rtc_base/checks.h" + +namespace webrtc { + +bool LeakyBucketNetworkQueue::EnqueuePacket( + const PacketInFlightInfo& packet_info) { + if (max_packet_capacity_ <= queue_.size()) { + return false; + } + queue_.push(packet_info); + return true; +} + +std::optional LeakyBucketNetworkQueue::PeekNextPacket() + const { + if (queue_.empty()) { + return std::nullopt; + } + return queue_.front(); +} + +std::optional LeakyBucketNetworkQueue::DequeuePacket( + Timestamp time_now) { + if (queue_.empty()) { + return std::nullopt; + } + RTC_DCHECK_LE(queue_.front().send_time(), time_now); + PacketInFlightInfo packet_info = queue_.front(); + queue_.pop(); + return packet_info; +} + +void LeakyBucketNetworkQueue::SetMaxPacketCapacity(size_t max_capactiy) { + max_packet_capacity_ = max_capactiy; +} + +bool LeakyBucketNetworkQueue::empty() const { + return queue_.empty(); +} + +void LeakyBucketNetworkQueue::DropOldestPacket() { + dropped_packets_.push_back(queue_.front()); + queue_.pop(); +} + +std::vector +LeakyBucketNetworkQueue::DequeueDroppedPackets() { + std::vector dropped_packets; + dropped_packets.swap(dropped_packets_); + return dropped_packets; +} + +} // namespace webrtc diff --git a/api/test/network_emulation/leaky_bucket_network_queue.h b/api/test/network_emulation/leaky_bucket_network_queue.h new file mode 100644 index 0000000000..60116c8c59 --- /dev/null +++ b/api/test/network_emulation/leaky_bucket_network_queue.h @@ -0,0 +1,59 @@ +/* + * 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 API_TEST_NETWORK_EMULATION_LEAKY_BUCKET_NETWORK_QUEUE_H_ +#define API_TEST_NETWORK_EMULATION_LEAKY_BUCKET_NETWORK_QUEUE_H_ + +#include +#include +#include +#include +#include + +#include "api/test/network_emulation/network_queue.h" +#include "api/test/simulated_network.h" +#include "api/units/timestamp.h" + +namespace webrtc { + +// A network queue that uses a leaky bucket to limit the number of packets that +// can be queued. +class LeakyBucketNetworkQueue : public NetworkQueue { + public: + LeakyBucketNetworkQueue() = default; + // If `max_capacity` is larger than current queue length, existing packets are + // not dropped. But the queue will not accept new packets until queue length + // is below `max_capacity`, + void SetMaxPacketCapacity(size_t max_capactiy) override; + + bool EnqueuePacket(const PacketInFlightInfo& packet_info) override; + std::optional PeekNextPacket() const override; + std::optional DequeuePacket(Timestamp time_now) override; + std::vector DequeueDroppedPackets() override; + bool empty() const override; + + void DropOldestPacket(); + + private: + size_t max_packet_capacity_ = kMaxPacketCapacity; + + std::queue queue_; + std::vector dropped_packets_; +}; + +class LeakyBucketNetworkQueueFactory : public NetworkQueueFactory { + public: + std::unique_ptr CreateQueue() override { + return std::make_unique(); + } +}; +} // namespace webrtc + +#endif // API_TEST_NETWORK_EMULATION_LEAKY_BUCKET_NETWORK_QUEUE_H_ diff --git a/api/test/network_emulation/leaky_bucket_network_queue_unittest.cc b/api/test/network_emulation/leaky_bucket_network_queue_unittest.cc new file mode 100644 index 0000000000..212f7fedef --- /dev/null +++ b/api/test/network_emulation/leaky_bucket_network_queue_unittest.cc @@ -0,0 +1,74 @@ +/* + * 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/test/network_emulation/leaky_bucket_network_queue.h" + +#include + +#include "api/test/simulated_network.h" +#include "api/units/data_size.h" +#include "api/units/timestamp.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { +namespace { + +using ::testing::Field; +using ::testing::Optional; +using ::testing::Property; + +TEST(LeakyBucketNetworkQueueTest, EnqueuePacketReturnsFalseIfQueueIsFull) { + LeakyBucketNetworkQueue queue; + queue.SetMaxPacketCapacity(1); + PacketInFlightInfo packet_info(DataSize::Bytes(123), Timestamp::Zero(), + /*packet_id=*/1); + EXPECT_TRUE(queue.EnqueuePacket(packet_info)); + EXPECT_FALSE(queue.EnqueuePacket(packet_info)); +} + +TEST(LeakyBucketNetworkQueueTest, + EnqueuePacketReturnsFalseIfQueueIsFullAfterCapacityChange) { + LeakyBucketNetworkQueue queue; + PacketInFlightInfo packet_info(DataSize::Bytes(123), Timestamp::Zero(), + /*packet_id=*/1); + ASSERT_TRUE(queue.EnqueuePacket(packet_info)); + ASSERT_TRUE(queue.EnqueuePacket(packet_info)); + + queue.SetMaxPacketCapacity(2); + EXPECT_FALSE(queue.EnqueuePacket(packet_info)); + EXPECT_NE(queue.DequeuePacket(Timestamp::Seconds(125)), std::nullopt); + EXPECT_TRUE(queue.EnqueuePacket(packet_info)); +} + +TEST(LeakyBucketNetworkQueueTest, ReturnsNullOptWhenEmtpy) { + LeakyBucketNetworkQueue queue; + EXPECT_TRUE(queue.empty()); + EXPECT_EQ(queue.DequeuePacket(Timestamp::Zero()), std::nullopt); + EXPECT_EQ(queue.PeekNextPacket(), std::nullopt); +} + +TEST(LeakyBucketNetworkQueueTest, DequeueDoesNotChangePacketInfo) { + LeakyBucketNetworkQueue queue; + EXPECT_TRUE(queue.empty()); + PacketInFlightInfo packet_info(DataSize::Bytes(123), Timestamp::Seconds(123), + /*packet_id=*/1); + queue.EnqueuePacket(packet_info); + + EXPECT_THAT( + queue.DequeuePacket(Timestamp::Seconds(125)), + Optional(AllOf( + Field(&PacketInFlightInfo::packet_id, packet_info.packet_id), + Property(&PacketInFlightInfo::packet_size, packet_info.packet_size()), + Property(&PacketInFlightInfo::send_time, packet_info.send_time())))); +} + +} // namespace +} // namespace webrtc diff --git a/api/test/network_emulation/network_queue.h b/api/test/network_emulation/network_queue.h new file mode 100644 index 0000000000..e9b51d5629 --- /dev/null +++ b/api/test/network_emulation/network_queue.h @@ -0,0 +1,61 @@ +/* + * 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 API_TEST_NETWORK_EMULATION_NETWORK_QUEUE_H_ +#define API_TEST_NETWORK_EMULATION_NETWORK_QUEUE_H_ + +#include +#include +#include +#include + +#include "api/test/simulated_network.h" +#include "api/units/timestamp.h" + +namespace webrtc { + +// NetworkQueue defines the interface for a queue used in network simulation. +// The purpose is to allow for different AQM implementations. +// A queue should not modify PacketInFlightInfo except for the explicit +// congestion notification field (ecn). +class NetworkQueue { + public: + // Max capacity a queue is expected to handle. + constexpr static size_t kMaxPacketCapacity = 10000; + + virtual ~NetworkQueue() = default; + // Sets the max capacity of the queue. If there are already more than + // `max_capacitiy` packets in the queue, the behaviour depends on the + // implementation. + virtual void SetMaxPacketCapacity(size_t max_capactiy) = 0; + // Enqueues a packet. + // Must return true if the packet is enqueued successfully, false otherwise. + virtual bool EnqueuePacket(const PacketInFlightInfo& packet_info) = 0; + // Next packet that can be dequeued. + virtual std::optional PeekNextPacket() const = 0; + // Dequeues a packet. + // or std::nullopt if there are no enqueued packets. + virtual std::optional DequeuePacket( + Timestamp time_now) = 0; + + // Dequeues all packets that are dropped by the queue itself after being + // enqueued. + virtual std::vector DequeueDroppedPackets() = 0; + virtual bool empty() const = 0; +}; + +class NetworkQueueFactory { + public: + virtual ~NetworkQueueFactory() = default; + virtual std::unique_ptr CreateQueue() = 0; +}; + +} // namespace webrtc +#endif // API_TEST_NETWORK_EMULATION_NETWORK_QUEUE_H_ diff --git a/api/test/network_emulation_manager.cc b/api/test/network_emulation_manager.cc index 03dcd84573..470c06bfd4 100644 --- a/api/test/network_emulation_manager.cc +++ b/api/test/network_emulation_manager.cc @@ -9,12 +9,15 @@ */ #include "api/test/network_emulation_manager.h" +#include #include #include #include #include #include "absl/strings/string_view.h" +#include "api/test/network_emulation/leaky_bucket_network_queue.h" +#include "api/test/network_emulation/network_queue.h" #include "api/test/simulated_network.h" #include "api/units/data_rate.h" #include "rtc_base/checks.h" @@ -54,6 +57,13 @@ NetworkEmulationManager::SimulatedNetworkNode::Builder::config( return *this; } +NetworkEmulationManager::SimulatedNetworkNode::Builder& +NetworkEmulationManager::SimulatedNetworkNode::Builder::queue_factory( + NetworkQueueFactory& queue_factory) { + queue_factory_ = &queue_factory; + return *this; +} + NetworkEmulationManager::SimulatedNetworkNode::Builder& NetworkEmulationManager::SimulatedNetworkNode::Builder::delay_ms( int queue_delay_ms) { @@ -143,8 +153,15 @@ NetworkEmulationManager::SimulatedNetworkNode::Builder::Build( uint64_t random_seed) const { RTC_CHECK(net); RTC_CHECK(net_ == nullptr || net_ == net); + std::unique_ptr network_queue; + if (queue_factory_ != nullptr) { + network_queue = queue_factory_->CreateQueue(); + } else { + network_queue = std::make_unique(); + } SimulatedNetworkNode res; - auto behavior = std::make_unique(config_, random_seed); + auto behavior = std::make_unique(config_, random_seed, + std::move(network_queue)); res.simulation = behavior.get(); res.node = net->CreateEmulatedNode(std::move(behavior)); return res; diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h index 199a60e2ab..c2758815a7 100644 --- a/api/test/network_emulation_manager.h +++ b/api/test/network_emulation_manager.h @@ -25,6 +25,7 @@ #include "api/field_trials_view.h" #include "api/test/network_emulation/cross_traffic.h" #include "api/test/network_emulation/network_emulation_interfaces.h" +#include "api/test/network_emulation/network_queue.h" #include "api/test/peer_network_dependencies.h" #include "api/test/simulated_network.h" #include "api/test/time_controller.h" @@ -190,6 +191,8 @@ class NetworkEmulationManager { // Sets the config state, note that this will replace any previously set // values. Builder& config(BuiltInNetworkBehaviorConfig config); + // If set, `queue_factory` must outlive the Builder. + Builder& queue_factory(NetworkQueueFactory& queue_factory); Builder& delay_ms(int queue_delay_ms); Builder& capacity(DataRate link_capacity); Builder& capacity_kbps(int link_capacity_kbps); @@ -207,6 +210,7 @@ class NetworkEmulationManager { private: NetworkEmulationManager* const net_; BuiltInNetworkBehaviorConfig config_; + NetworkQueueFactory* queue_factory_ = nullptr; }; }; virtual ~NetworkEmulationManager() = default; diff --git a/api/test/pclf/peer_configurer.cc b/api/test/pclf/peer_configurer.cc index 668f29af73..525f5c5e93 100644 --- a/api/test/pclf/peer_configurer.cc +++ b/api/test/pclf/peer_configurer.cc @@ -55,8 +55,7 @@ PeerConfigurer::PeerConfigurer(PeerNetworkDependencies& network) network.socket_factory())), params_(std::make_unique()), configurable_params_(std::make_unique()) { - components_->pcf_dependencies->field_trials = - std::make_unique(CreateTestFieldTrials()); + components_->pcf_dependencies->field_trials = CreateTestFieldTrialsPtr(); } PeerConfigurer* PeerConfigurer::SetName(absl::string_view name) { diff --git a/api/test/simulated_network.h b/api/test/simulated_network.h index 174fc0bb2b..d1a823a7d3 100644 --- a/api/test/simulated_network.h +++ b/api/test/simulated_network.h @@ -21,6 +21,8 @@ #include "absl/functional/any_invocable.h" #include "api/transport/ecn_marking.h" #include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/timestamp.h" namespace webrtc { @@ -33,11 +35,24 @@ struct PacketInFlightInfo { send_time_us(send_time_us), packet_id(packet_id), ecn(ecn) {} + PacketInFlightInfo(DataSize size, + Timestamp send_time, + uint64_t packet_id, + EcnMarking ecn) + : PacketInFlightInfo(size.bytes(), send_time.us(), packet_id, ecn) {} + PacketInFlightInfo(DataSize size, Timestamp send_time, uint64_t packet_id) + : PacketInFlightInfo(size.bytes(), + send_time.us(), + packet_id, + EcnMarking::kNotEct) {} PacketInFlightInfo(size_t size, int64_t send_time_us, uint64_t packet_id) : PacketInFlightInfo(size, send_time_us, packet_id, EcnMarking::kNotEct) { } + DataSize packet_size() const { return DataSize::Bytes(size); } + Timestamp send_time() const { return Timestamp::Micros(send_time_us); } + size_t size; int64_t send_time_us; // Unique identifier for the packet in relation to other packets in flight. diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn index 11b03496be..b99d40378d 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -140,7 +140,7 @@ if (rtc_include_tests) { ":network_control", "..:simulated_network_api", "../../api:network_emulation_manager_api", - "../../api/rtc_event_log:rtc_event_log", + "../../api/rtc_event_log", "../units:data_rate", "../units:data_size", "../units:time_delta", @@ -158,7 +158,7 @@ if (rtc_include_tests) { ":network_control", ":test_feedback_generator_interface", "../../api:network_emulation_manager_api", - "../../api/rtc_event_log:rtc_event_log", + "../../api/rtc_event_log", "../../test/network:feedback_generator", ] } diff --git a/api/transport/field_trial_based_config.cc b/api/transport/field_trial_based_config.cc index 81abd07411..bd9313a59f 100644 --- a/api/transport/field_trial_based_config.cc +++ b/api/transport/field_trial_based_config.cc @@ -16,6 +16,9 @@ namespace webrtc { std::string FieldTrialBasedConfig::GetValue(absl::string_view key) const { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return field_trial::FindFullName(std::string(key)); +#pragma clang diagnostic pop } } // namespace webrtc diff --git a/api/transport/field_trial_based_config.h b/api/transport/field_trial_based_config.h index 441f89e51d..08a37e50a3 100644 --- a/api/transport/field_trial_based_config.h +++ b/api/transport/field_trial_based_config.h @@ -18,7 +18,9 @@ namespace webrtc { // Implementation using the field trial API fo the key value lookup. -class RTC_EXPORT FieldTrialBasedConfig : public FieldTrialsRegistry { +// TODO: bugs.webrtc.org/42220378 - Remove from public api after August 1, 2025. +class [[deprecated]] RTC_EXPORT FieldTrialBasedConfig + : public FieldTrialsRegistry { private: std::string GetValue(absl::string_view key) const override; }; diff --git a/api/transport/network_types.h b/api/transport/network_types.h index 79bcc12d44..814a9062d8 100644 --- a/api/transport/network_types.h +++ b/api/transport/network_types.h @@ -240,7 +240,9 @@ struct RTC_EXPORT TargetTransferRate { // The estimate on which the target rate is based on. NetworkEstimate network_estimate; DataRate target_rate = DataRate::Zero(); - DataRate stable_target_rate = DataRate::Zero(); + // TODO(bugs.webrtc.org/423841921): stable_rate is not used by WebRTC and + // should be removed as soon as downstream projects are not referencing it. + DataRate stable_target_rate; // Deprecated double cwnd_reduce_ratio = 0; }; diff --git a/api/transport/stun.cc b/api/transport/stun.cc index d688f0c4ff..100b6c7e9b 100644 --- a/api/transport/stun.cc +++ b/api/transport/stun.cc @@ -10,14 +10,13 @@ #include "api/transport/stun.h" -#include - #include // IWYU pragma: keep #include #include #include #include #include +#include #include #include #include @@ -1111,6 +1110,17 @@ StunByteStringAttribute::StunByteStringAttribute(uint16_t type, CopyBytes(bytes, length); } +StunByteStringAttribute::StunByteStringAttribute( + uint16_t type, + const std::vector& values) + : StunAttribute(type, 0), bytes_(nullptr) { + ByteBufferWriter writer; + for (const auto& value : values) { + writer.WriteUInt32(value); + } + CopyBytes(writer.Data(), writer.Length()); +} + StunByteStringAttribute::StunByteStringAttribute(uint16_t type, uint16_t length) : StunAttribute(type, length), bytes_(nullptr) {} @@ -1122,6 +1132,20 @@ StunAttributeValueType StunByteStringAttribute::value_type() const { return STUN_VALUE_BYTE_STRING; } +std::optional> StunByteStringAttribute::GetUInt32Vector() + const { + if (length() % 4 != 0) { + return std::nullopt; + } + std::vector values; + ByteBufferReader reader(array_view()); + uint32_t value; + while (reader.ReadUInt32(&value)) { + values.push_back(value); + } + return values; +} + void StunByteStringAttribute::CopyBytes(absl::string_view bytes) { uint8_t* new_bytes = new uint8_t[bytes.size()]; memcpy(new_bytes, bytes.data(), bytes.size()); diff --git a/api/transport/stun.h b/api/transport/stun.h index 80cce7355b..9066a5c654 100644 --- a/api/transport/stun.h +++ b/api/transport/stun.h @@ -14,11 +14,11 @@ // This file contains classes for dealing with the STUN protocol, as specified // in RFC 5389, and its descendants. -#include -#include - +#include +#include #include #include +#include #include #include @@ -507,6 +507,7 @@ class StunByteStringAttribute : public StunAttribute { explicit StunByteStringAttribute(uint16_t type); StunByteStringAttribute(uint16_t type, absl::string_view str); StunByteStringAttribute(uint16_t type, const void* bytes, size_t length); + StunByteStringAttribute(uint16_t type, const std::vector& values); StunByteStringAttribute(uint16_t type, uint16_t length); ~StunByteStringAttribute() override; @@ -530,6 +531,8 @@ class StunByteStringAttribute : public StunAttribute { return std::string(reinterpret_cast(bytes_), length()); } + std::optional> GetUInt32Vector() const; + void CopyBytes(const void* bytes, size_t length); void CopyBytes(absl::string_view bytes); @@ -759,149 +762,5 @@ class IceMessage : public StunMessage { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ComputeStunCredentialHash; -using ::webrtc::CopyStunAttribute; -using ::webrtc::GetStunErrorResponseType; -using ::webrtc::GetStunSuccessResponseType; -using ::webrtc::GOOG_PING_ERROR_RESPONSE; -using ::webrtc::GOOG_PING_REQUEST; -using ::webrtc::GOOG_PING_RESPONSE; -using ::webrtc::IceAttributeType; -using ::webrtc::IceErrorCode; -using ::webrtc::IceGoogMiscInfoBindingRequestAttributeIndex; -using ::webrtc::IceGoogMiscInfoBindingResponseAttributeIndex; -using ::webrtc::IceMessage; -using ::webrtc::IsStunErrorResponseType; -using ::webrtc::IsStunIndicationType; -using ::webrtc::IsStunRequestType; -using ::webrtc::IsStunSuccessResponseType; -using ::webrtc::kStunAttributeHeaderSize; -using ::webrtc::kStunHeaderSize; -using ::webrtc::kStunLegacyTransactionIdLength; -using ::webrtc::kStunMagicCookie; -using ::webrtc::kStunMagicCookieLength; -using ::webrtc::kStunMessageIntegrity32Size; -using ::webrtc::kStunMessageIntegritySize; -using ::webrtc::kStunTransactionIdLength; -using ::webrtc::kStunTransactionIdOffset; -using ::webrtc::kStunTypeMask; -using ::webrtc::SERVER_NOT_REACHABLE_ERROR; -using ::webrtc::STUN_ADDRESS_IPV4; -using ::webrtc::STUN_ADDRESS_IPV6; -using ::webrtc::STUN_ADDRESS_UNDEF; -using ::webrtc::STUN_ALLOCATE_ERROR_RESPONSE; -using ::webrtc::STUN_ALLOCATE_REQUEST; -using ::webrtc::STUN_ALLOCATE_RESPONSE; -using ::webrtc::STUN_ATTR_ALTERNATE_SERVER; -using ::webrtc::STUN_ATTR_CHANNEL_NUMBER; -using ::webrtc::STUN_ATTR_DATA; -using ::webrtc::STUN_ATTR_DONT_FRAGMENT; -using ::webrtc::STUN_ATTR_ERROR_CODE; -using ::webrtc::STUN_ATTR_EVEN_PORT; -using ::webrtc::STUN_ATTR_FINGERPRINT; -using ::webrtc::STUN_ATTR_GOOG_CONNECTION_ID; -using ::webrtc::STUN_ATTR_GOOG_DELTA; -using ::webrtc::STUN_ATTR_GOOG_DELTA_ACK; -using ::webrtc::STUN_ATTR_GOOG_DELTA_SYNC_REQ; -using ::webrtc::STUN_ATTR_GOOG_LAST_ICE_CHECK_RECEIVED; -using ::webrtc::STUN_ATTR_GOOG_MESSAGE_INTEGRITY_32; -using ::webrtc::STUN_ATTR_GOOG_MISC_INFO; -using ::webrtc::STUN_ATTR_GOOG_NETWORK_INFO; -using ::webrtc::STUN_ATTR_GOOG_OBSOLETE_1; -using ::webrtc::STUN_ATTR_ICE_CONTROLLED; -using ::webrtc::STUN_ATTR_ICE_CONTROLLING; -using ::webrtc::STUN_ATTR_LIFETIME; -using ::webrtc::STUN_ATTR_MAPPED_ADDRESS; -using ::webrtc::STUN_ATTR_MESSAGE_INTEGRITY; -using ::webrtc::STUN_ATTR_META_DTLS_IN_STUN; -using ::webrtc::STUN_ATTR_META_DTLS_IN_STUN_ACK; -using ::webrtc::STUN_ATTR_NOMINATION; -using ::webrtc::STUN_ATTR_NONCE; -using ::webrtc::STUN_ATTR_PRIORITY; -using ::webrtc::STUN_ATTR_REALM; -using ::webrtc::STUN_ATTR_REQUESTED_TRANSPORT; -using ::webrtc::STUN_ATTR_RESERVATION_TOKEN; -using ::webrtc::STUN_ATTR_RETRANSMIT_COUNT; -using ::webrtc::STUN_ATTR_SOFTWARE; -using ::webrtc::STUN_ATTR_UNKNOWN_ATTRIBUTES; -using ::webrtc::STUN_ATTR_USE_CANDIDATE; -using ::webrtc::STUN_ATTR_USERNAME; -using ::webrtc::STUN_ATTR_XOR_MAPPED_ADDRESS; -using ::webrtc::STUN_ATTR_XOR_PEER_ADDRESS; -using ::webrtc::STUN_ATTR_XOR_RELAYED_ADDRESS; -using ::webrtc::STUN_BINDING_ERROR_RESPONSE; -using ::webrtc::STUN_BINDING_INDICATION; -using ::webrtc::STUN_BINDING_REQUEST; -using ::webrtc::STUN_BINDING_RESPONSE; -using ::webrtc::STUN_ERROR_ALLOCATION_MISMATCH; -using ::webrtc::STUN_ERROR_BAD_REQUEST; -using ::webrtc::STUN_ERROR_FORBIDDEN; -using ::webrtc::STUN_ERROR_GLOBAL_FAILURE; -using ::webrtc::STUN_ERROR_NOT_AN_ERROR; -using ::webrtc::STUN_ERROR_REASON_ALLOCATION_MISMATCH; -using ::webrtc::STUN_ERROR_REASON_BAD_REQUEST; -using ::webrtc::STUN_ERROR_REASON_FORBIDDEN; -using ::webrtc::STUN_ERROR_REASON_ROLE_CONFLICT; -using ::webrtc::STUN_ERROR_REASON_SERVER_ERROR; -using ::webrtc::STUN_ERROR_REASON_STALE_NONCE; -using ::webrtc::STUN_ERROR_REASON_TRY_ALTERNATE_SERVER; -using ::webrtc::STUN_ERROR_REASON_UNAUTHORIZED; -using ::webrtc::STUN_ERROR_REASON_UNKNOWN_ATTRIBUTE; -using ::webrtc::STUN_ERROR_REASON_UNSUPPORTED_PROTOCOL; -using ::webrtc::STUN_ERROR_REASON_WRONG_CREDENTIALS; -using ::webrtc::STUN_ERROR_ROLE_CONFLICT; -using ::webrtc::STUN_ERROR_SERVER_ERROR; -using ::webrtc::STUN_ERROR_SERVER_NOT_REACHABLE; -using ::webrtc::STUN_ERROR_STALE_NONCE; -using ::webrtc::STUN_ERROR_TRY_ALTERNATE; -using ::webrtc::STUN_ERROR_UNAUTHORIZED; -using ::webrtc::STUN_ERROR_UNKNOWN_ATTRIBUTE; -using ::webrtc::STUN_ERROR_UNSUPPORTED_PROTOCOL; -using ::webrtc::STUN_ERROR_WRONG_CREDENTIALS; -using ::webrtc::STUN_INVALID_MESSAGE_TYPE; -using ::webrtc::STUN_VALUE_ADDRESS; -using ::webrtc::STUN_VALUE_BYTE_STRING; -using ::webrtc::STUN_VALUE_ERROR_CODE; -using ::webrtc::STUN_VALUE_UINT16_LIST; -using ::webrtc::STUN_VALUE_UINT32; -using ::webrtc::STUN_VALUE_UINT64; -using ::webrtc::STUN_VALUE_UNKNOWN; -using ::webrtc::STUN_VALUE_XOR_ADDRESS; -using ::webrtc::StunAddressAttribute; -using ::webrtc::StunAddressFamily; -using ::webrtc::StunAttribute; -using ::webrtc::StunAttributeType; -using ::webrtc::StunAttributeValueType; -using ::webrtc::StunByteStringAttribute; -using ::webrtc::StunErrorCode; -using ::webrtc::StunErrorCodeAttribute; -using ::webrtc::StunMessage; -using ::webrtc::StunMessageType; -using ::webrtc::StunMethodToString; -using ::webrtc::StunUInt16ListAttribute; -using ::webrtc::StunUInt32Attribute; -using ::webrtc::StunUInt64Attribute; -using ::webrtc::StunXorAddressAttribute; -using ::webrtc::TURN_CHANNEL_BIND_ERROR_RESPONSE; -using ::webrtc::TURN_CHANNEL_BIND_REQUEST; -using ::webrtc::TURN_CHANNEL_BIND_RESPONSE; -using ::webrtc::TURN_CREATE_PERMISSION_ERROR_RESPONSE; -using ::webrtc::TURN_CREATE_PERMISSION_REQUEST; -using ::webrtc::TURN_CREATE_PERMISSION_RESPONSE; -using ::webrtc::TURN_DATA_INDICATION; -using ::webrtc::TURN_REFRESH_ERROR_RESPONSE; -using ::webrtc::TURN_REFRESH_REQUEST; -using ::webrtc::TURN_REFRESH_RESPONSE; -using ::webrtc::TURN_SEND_INDICATION; -using ::webrtc::TurnAttributeType; -using ::webrtc::TurnErrorType; -using ::webrtc::TurnMessage; -using ::webrtc::TurnMessageType; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_TRANSPORT_STUN_H_ diff --git a/api/transport/stun_unittest.cc b/api/transport/stun_unittest.cc index 0aeff066d4..542a5bfd24 100644 --- a/api/transport/stun_unittest.cc +++ b/api/transport/stun_unittest.cc @@ -10,12 +10,13 @@ #include "api/transport/stun.h" -#include - #include +#include #include +#include #include #include +#include #include "api/array_view.h" #include "rtc_base/byte_buffer.h" @@ -23,62 +24,12 @@ #include "rtc_base/ip_address.h" #include "rtc_base/socket_address.h" #include "system_wrappers/include/metrics.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { -class StunTest : public ::testing::Test { - protected: - void CheckStunHeader(const StunMessage& msg, - StunMessageType expected_type, - size_t expected_length) { - ASSERT_EQ(expected_type, msg.type()); - ASSERT_EQ(expected_length, msg.length()); - } - - void CheckStunTransactionID(const StunMessage& msg, - const uint8_t* expectedID, - size_t length) { - ASSERT_EQ(length, msg.transaction_id().size()); - ASSERT_EQ(length == kStunTransactionIdLength + 4, msg.IsLegacy()); - ASSERT_EQ(length == kStunTransactionIdLength, !msg.IsLegacy()); - ASSERT_EQ(0, memcmp(msg.transaction_id().c_str(), expectedID, length)); - } - - void CheckStunAddressAttribute(const StunAddressAttribute* addr, - StunAddressFamily expected_family, - int expected_port, - const IPAddress& expected_address) { - ASSERT_EQ(expected_family, addr->family()); - ASSERT_EQ(expected_port, addr->port()); - - if (addr->family() == STUN_ADDRESS_IPV4) { - in_addr v4_address = expected_address.ipv4_address(); - in_addr stun_address = addr->ipaddr().ipv4_address(); - ASSERT_EQ(0, memcmp(&v4_address, &stun_address, sizeof(stun_address))); - } else if (addr->family() == STUN_ADDRESS_IPV6) { - in6_addr v6_address = expected_address.ipv6_address(); - in6_addr stun_address = addr->ipaddr().ipv6_address(); - ASSERT_EQ(0, memcmp(&v6_address, &stun_address, sizeof(stun_address))); - } else { - ASSERT_TRUE(addr->family() == STUN_ADDRESS_IPV6 || - addr->family() == STUN_ADDRESS_IPV4); - } - } - - size_t ReadStunMessageTestCase(StunMessage* msg, - const uint8_t* testcase, - size_t size) { - ByteBufferReader buf(MakeArrayView(testcase, size)); - if (msg->Read(&buf)) { - // Returns the size the stun message should report itself as being - return (size - 20); - } else { - return 0; - } - } -}; - +namespace { // Sample STUN packets with various attributes // Gathered by wiresharking pjproject's pjnath test programs // pjproject available at www.pjsip.org @@ -86,7 +37,7 @@ class StunTest : public ::testing::Test { // clang-format off // clang formatting doesn't respect inline comments. -static const uint8_t kStunMessageWithIPv6MappedAddress[] = { +constexpr uint8_t kStunMessageWithIPv6MappedAddress[] = { 0x00, 0x01, 0x00, 0x18, // message header 0x21, 0x12, 0xa4, 0x42, // transaction id 0x29, 0x1f, 0xcd, 0x7c, @@ -100,7 +51,7 @@ static const uint8_t kStunMessageWithIPv6MappedAddress[] = { 0xfe, 0xe5, 0x00, 0xc3 }; -static const uint8_t kStunMessageWithIPv4MappedAddress[] = { +constexpr uint8_t kStunMessageWithIPv4MappedAddress[] = { 0x01, 0x01, 0x00, 0x0c, // binding response, length 12 0x21, 0x12, 0xa4, 0x42, // magic cookie 0x29, 0x1f, 0xcd, 0x7c, // transaction ID @@ -112,7 +63,7 @@ static const uint8_t kStunMessageWithIPv4MappedAddress[] = { }; // Test XOR-mapped IP addresses: -static const uint8_t kStunMessageWithIPv6XorMappedAddress[] = { +constexpr uint8_t kStunMessageWithIPv6XorMappedAddress[] = { 0x01, 0x01, 0x00, 0x18, // message header (binding response) 0x21, 0x12, 0xa4, 0x42, // magic cookie (rfc5389) 0xe3, 0xa9, 0x46, 0xe1, // transaction ID @@ -126,7 +77,7 @@ static const uint8_t kStunMessageWithIPv6XorMappedAddress[] = { 0xaa, 0xed, 0x01, 0xc3 }; -static const uint8_t kStunMessageWithIPv4XorMappedAddress[] = { +constexpr uint8_t kStunMessageWithIPv4XorMappedAddress[] = { 0x01, 0x01, 0x00, 0x0c, // message header (binding response) 0x21, 0x12, 0xa4, 0x42, // magic cookie 0x29, 0x1f, 0xcd, 0x7c, // transaction ID @@ -138,7 +89,7 @@ static const uint8_t kStunMessageWithIPv4XorMappedAddress[] = { }; // ByteString Attribute (username) -static const uint8_t kStunMessageWithByteStringAttribute[] = { +constexpr uint8_t kStunMessageWithByteStringAttribute[] = { 0x00, 0x01, 0x00, 0x0c, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -151,7 +102,7 @@ static const uint8_t kStunMessageWithByteStringAttribute[] = { // Message with an unknown but comprehensible optional attribute. // Parsing should succeed despite this unknown attribute. -static const uint8_t kStunMessageWithUnknownAttribute[] = { +constexpr uint8_t kStunMessageWithUnknownAttribute[] = { 0x00, 0x01, 0x00, 0x14, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -165,7 +116,7 @@ static const uint8_t kStunMessageWithUnknownAttribute[] = { }; // ByteString Attribute (username) with padding byte -static const uint8_t kStunMessageWithPaddedByteStringAttribute[] = { +constexpr uint8_t kStunMessageWithPaddedByteStringAttribute[] = { 0x00, 0x01, 0x00, 0x08, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -176,7 +127,7 @@ static const uint8_t kStunMessageWithPaddedByteStringAttribute[] = { }; // Message with an Unknown Attributes (uint16_t list) attribute. -static const uint8_t kStunMessageWithUInt16ListAttribute[] = { +constexpr uint8_t kStunMessageWithUInt16ListAttribute[] = { 0x00, 0x01, 0x00, 0x0c, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -188,7 +139,7 @@ static const uint8_t kStunMessageWithUInt16ListAttribute[] = { }; // Error response message (unauthorized) -static const uint8_t kStunMessageWithErrorAttribute[] = { +constexpr uint8_t kStunMessageWithErrorAttribute[] = { 0x01, 0x11, 0x00, 0x14, 0x21, 0x12, 0xa4, 0x42, 0x29, 0x1f, 0xcd, 0x7c, @@ -204,9 +155,9 @@ static const uint8_t kStunMessageWithErrorAttribute[] = { // Sample messages with an invalid length Field // The actual length in bytes of the invalid messages (including STUN header) -static const int kRealLengthOfInvalidLengthTestCases = 32; +constexpr int kRealLengthOfInvalidLengthTestCases = 32; -static const uint8_t kStunMessageWithZeroLength[] = { +constexpr uint8_t kStunMessageWithZeroLength[] = { 0x00, 0x01, 0x00, 0x00, // length of 0 (last 2 bytes) 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -217,7 +168,7 @@ static const uint8_t kStunMessageWithZeroLength[] = { 0x21, 0x12, 0xA4, 0x53, }; -static const uint8_t kStunMessageWithExcessLength[] = { +constexpr uint8_t kStunMessageWithExcessLength[] = { 0x00, 0x01, 0x00, 0x55, // length of 85 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -228,7 +179,7 @@ static const uint8_t kStunMessageWithExcessLength[] = { 0x21, 0x12, 0xA4, 0x53, }; -static const uint8_t kStunMessageWithSmallLength[] = { +constexpr uint8_t kStunMessageWithSmallLength[] = { 0x00, 0x01, 0x00, 0x03, // length of 3 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -239,7 +190,7 @@ static const uint8_t kStunMessageWithSmallLength[] = { 0x21, 0x12, 0xA4, 0x53, }; -static const uint8_t kStunMessageWithBadHmacAtEnd[] = { +constexpr uint8_t kStunMessageWithBadHmacAtEnd[] = { 0x00, 0x01, 0x00, 0x14, // message length exactly 20 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction ID @@ -254,7 +205,7 @@ static const uint8_t kStunMessageWithBadHmacAtEnd[] = { // RTCP packet, for testing we correctly ignore non stun packet types. // V=2, P=false, RC=0, Type=200, Len=6, Sender-SSRC=85, etc -static const uint8_t kRtcpPacket[] = { +constexpr uint8_t kRtcpPacket[] = { 0x80, 0xc8, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0xce, 0xa5, 0x18, 0x3a, 0x39, 0xcc, 0x7d, 0x09, 0x23, 0xed, 0x19, 0x07, 0x00, 0x00, 0x01, 0x56, @@ -267,30 +218,30 @@ static const uint8_t kRtcpPacket[] = { // Software name (response): "test vector" (without quotes) // Username: "evtj:h6vY" (without quotes) // Password: "VOkJxbRl1RmTxUk/WvJxBt" (without quotes) -static const uint8_t kRfc5769SampleMsgTransactionId[] = { +constexpr uint8_t kRfc5769SampleMsgTransactionId[] = { 0xb7, 0xe7, 0xa7, 0x01, 0xbc, 0x34, 0xd6, 0x86, 0xfa, 0x87, 0xdf, 0xae }; -static const char kRfc5769SampleMsgClientSoftware[] = "STUN test client"; -static const char kRfc5769SampleMsgServerSoftware[] = "test vector"; -static const char kRfc5769SampleMsgUsername[] = "evtj:h6vY"; -static const char kRfc5769SampleMsgPassword[] = "VOkJxbRl1RmTxUk/WvJxBt"; -static const SocketAddress kRfc5769SampleMsgMappedAddress( +constexpr char kRfc5769SampleMsgClientSoftware[] = "STUN test client"; +constexpr char kRfc5769SampleMsgServerSoftware[] = "test vector"; +constexpr char kRfc5769SampleMsgUsername[] = "evtj:h6vY"; +constexpr char kRfc5769SampleMsgPassword[] = "VOkJxbRl1RmTxUk/WvJxBt"; +const SocketAddress kRfc5769SampleMsgMappedAddress( "192.0.2.1", 32853); -static const SocketAddress kRfc5769SampleMsgIPv6MappedAddress( +const SocketAddress kRfc5769SampleMsgIPv6MappedAddress( "2001:db8:1234:5678:11:2233:4455:6677", 32853); -static const uint8_t kRfc5769SampleMsgWithAuthTransactionId[] = { +constexpr uint8_t kRfc5769SampleMsgWithAuthTransactionId[] = { 0x78, 0xad, 0x34, 0x33, 0xc6, 0xad, 0x72, 0xc0, 0x29, 0xda, 0x41, 0x2e }; -static const char kRfc5769SampleMsgWithAuthUsername[] = +constexpr char kRfc5769SampleMsgWithAuthUsername[] = "\xe3\x83\x9e\xe3\x83\x88\xe3\x83\xaa\xe3\x83\x83\xe3\x82\xaf\xe3\x82\xb9"; -static const char kRfc5769SampleMsgWithAuthPassword[] = "TheMatrIX"; -static const char kRfc5769SampleMsgWithAuthNonce[] = +constexpr char kRfc5769SampleMsgWithAuthPassword[] = "TheMatrIX"; +constexpr char kRfc5769SampleMsgWithAuthNonce[] = "f//499k954d6OL34oL9FSTvy64sA"; -static const char kRfc5769SampleMsgWithAuthRealm[] = "example.org"; +constexpr char kRfc5769SampleMsgWithAuthRealm[] = "example.org"; // 2.1. Sample Request -static const uint8_t kRfc5769SampleRequest[] = { +constexpr uint8_t kRfc5769SampleRequest[] = { 0x00, 0x01, 0x00, 0x58, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -321,7 +272,7 @@ static const uint8_t kRfc5769SampleRequest[] = { }; // 2.1. Sample Request -static const uint8_t kSampleRequestMI32[] = { +constexpr uint8_t kSampleRequestMI32[] = { 0x00, 0x01, 0x00, 0x48, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -348,7 +299,7 @@ static const uint8_t kSampleRequestMI32[] = { }; // 2.2. Sample IPv4 Response -static const uint8_t kRfc5769SampleResponse[] = { +constexpr uint8_t kRfc5769SampleResponse[] = { 0x01, 0x01, 0x00, 0x3c, // Response type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -372,7 +323,7 @@ static const uint8_t kRfc5769SampleResponse[] = { }; // 2.3. Sample IPv6 Response -static const uint8_t kRfc5769SampleResponseIPv6[] = { +constexpr uint8_t kRfc5769SampleResponseIPv6[] = { 0x01, 0x01, 0x00, 0x48, // Response type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -399,7 +350,7 @@ static const uint8_t kRfc5769SampleResponseIPv6[] = { }; // 2.4. Sample Request with Long-Term Authentication -static const uint8_t kRfc5769SampleRequestLongTermAuth[] = { +constexpr uint8_t kRfc5769SampleRequestLongTermAuth[] = { 0x00, 0x01, 0x00, 0x60, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0x78, 0xad, 0x34, 0x33, // } @@ -434,7 +385,7 @@ static const uint8_t kRfc5769SampleRequestLongTermAuth[] = { // Length parameter is changed to 0x38 from 0x58. // AddMessageIntegrity will add MI information and update the length param // accordingly. -static const uint8_t kRfc5769SampleRequestWithoutMI[] = { +constexpr uint8_t kRfc5769SampleRequestWithoutMI[] = { 0x00, 0x01, 0x00, 0x38, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -458,7 +409,7 @@ static const uint8_t kRfc5769SampleRequestWithoutMI[] = { // This HMAC differs from the RFC 5769 SampleRequest message. This differs // because spec uses 0x20 for the padding where as our implementation uses 0. -static const uint8_t kCalculatedHmac1[] = { +constexpr uint8_t kCalculatedHmac1[] = { 0x79, 0x07, 0xc2, 0xd2, // } 0xed, 0xbf, 0xea, 0x48, // } 0x0e, 0x4c, 0x76, 0xd8, // } HMAC-SHA1 fingerprint @@ -470,14 +421,14 @@ static const uint8_t kCalculatedHmac1[] = { // above since the sum is computed including header // and the header is different since the message is shorter // than when MESSAGE-INTEGRITY is used. -static const uint8_t kCalculatedHmac1_32[] = { +constexpr uint8_t kCalculatedHmac1_32[] = { 0xda, 0x39, 0xde, 0x5d, // } }; // Length parameter is changed to 0x1c from 0x3c. // AddMessageIntegrity will add MI information and update the length param // accordingly. -static const uint8_t kRfc5769SampleResponseWithoutMI[] = { +constexpr uint8_t kRfc5769SampleResponseWithoutMI[] = { 0x01, 0x01, 0x00, 0x1c, // Response type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -494,7 +445,7 @@ static const uint8_t kRfc5769SampleResponseWithoutMI[] = { // This HMAC differs from the RFC 5769 SampleResponse message. This differs // because spec uses 0x20 for the padding where as our implementation uses 0. -static const uint8_t kCalculatedHmac2[] = { +constexpr uint8_t kCalculatedHmac2[] = { 0x5d, 0x6b, 0x58, 0xbe, // } 0xad, 0x94, 0xe0, 0x7e, // } 0xef, 0x0d, 0xfc, 0x12, // } HMAC-SHA1 fingerprint @@ -506,7 +457,7 @@ static const uint8_t kCalculatedHmac2[] = { // above since the sum is computed including header // and the header is different since the message is shorter // than when MESSAGE-INTEGRITY is used. -static const uint8_t kCalculatedHmac2_32[] = { +constexpr uint8_t kCalculatedHmac2_32[] = { 0xe7, 0x5c, 0xd3, 0x16, // } }; @@ -514,14 +465,14 @@ static const uint8_t kCalculatedHmac2_32[] = { // A transaction ID without the 'magic cookie' portion // pjnat's test programs use this transaction ID a lot. -const uint8_t kTestTransactionId1[] = {0x029, 0x01f, 0x0cd, 0x07c, - 0x0ba, 0x058, 0x0ab, 0x0d7, - 0x0f2, 0x041, 0x001, 0x000}; +constexpr uint8_t kTestTransactionId1[] = {0x029, 0x01f, 0x0cd, 0x07c, + 0x0ba, 0x058, 0x0ab, 0x0d7, + 0x0f2, 0x041, 0x001, 0x000}; // They use this one sometimes too. -const uint8_t kTestTransactionId2[] = {0x0e3, 0x0a9, 0x046, 0x0e1, - 0x07c, 0x000, 0x0c2, 0x062, - 0x054, 0x008, 0x001, 0x000}; +constexpr uint8_t kTestTransactionId2[] = {0x0e3, 0x0a9, 0x046, 0x0e1, + 0x07c, 0x000, 0x0c2, 0x062, + 0x054, 0x008, 0x001, 0x000}; const in6_addr kIPv6TestAddress1 = { {{0x24, 0x01, 0xfa, 0x00, 0x00, 0x04, 0x10, 0x00, 0xbe, 0x30, 0x5b, 0xff, @@ -536,17 +487,70 @@ const in_addr kIPv4TestAddress1 = {0xe64417ac}; // Windows in_addr has a union with a uchar[] array first. const in_addr kIPv4TestAddress1 = {{{0x0ac, 0x017, 0x044, 0x0e6}}}; #endif -const char kTestUserName1[] = "abcdefgh"; -const char kTestUserName2[] = "abc"; -const char kTestErrorReason[] = "Unauthorized"; -const int kTestErrorClass = 4; -const int kTestErrorNumber = 1; -const int kTestErrorCode = 401; - -const int kTestMessagePort1 = 59977; -const int kTestMessagePort2 = 47233; -const int kTestMessagePort3 = 56743; -const int kTestMessagePort4 = 40444; +constexpr char kTestUserName1[] = "abcdefgh"; +constexpr char kTestUserName2[] = "abc"; +constexpr char kTestErrorReason[] = "Unauthorized"; +constexpr int kTestErrorClass = 4; +constexpr int kTestErrorNumber = 1; +constexpr int kTestErrorCode = 401; + +constexpr int kTestMessagePort1 = 59977; +constexpr int kTestMessagePort2 = 47233; +constexpr int kTestMessagePort3 = 56743; +constexpr int kTestMessagePort4 = 40444; +} // namespace + +class StunTest : public ::testing::Test { + protected: + void CheckStunHeader(const StunMessage& msg, + StunMessageType expected_type, + size_t expected_length) { + ASSERT_EQ(expected_type, msg.type()); + ASSERT_EQ(expected_length, msg.length()); + } + + void CheckStunTransactionID(const StunMessage& msg, + const uint8_t* expectedID, + size_t length) { + ASSERT_EQ(length, msg.transaction_id().size()); + ASSERT_EQ(length == kStunTransactionIdLength + 4, msg.IsLegacy()); + ASSERT_EQ(length == kStunTransactionIdLength, !msg.IsLegacy()); + ASSERT_EQ(0, memcmp(msg.transaction_id().c_str(), expectedID, length)); + } + + void CheckStunAddressAttribute(const StunAddressAttribute* addr, + StunAddressFamily expected_family, + int expected_port, + const IPAddress& expected_address) { + ASSERT_EQ(expected_family, addr->family()); + ASSERT_EQ(expected_port, addr->port()); + + if (addr->family() == STUN_ADDRESS_IPV4) { + in_addr v4_address = expected_address.ipv4_address(); + in_addr stun_address = addr->ipaddr().ipv4_address(); + ASSERT_EQ(0, memcmp(&v4_address, &stun_address, sizeof(stun_address))); + } else if (addr->family() == STUN_ADDRESS_IPV6) { + in6_addr v6_address = expected_address.ipv6_address(); + in6_addr stun_address = addr->ipaddr().ipv6_address(); + ASSERT_EQ(0, memcmp(&v6_address, &stun_address, sizeof(stun_address))); + } else { + ASSERT_TRUE(addr->family() == STUN_ADDRESS_IPV6 || + addr->family() == STUN_ADDRESS_IPV4); + } + } + + size_t ReadStunMessageTestCase(StunMessage* msg, + const uint8_t* testcase, + size_t size) { + ByteBufferReader buf(MakeArrayView(testcase, size)); + if (msg->Read(&buf)) { + // Returns the size the stun message should report itself as being + return (size - 20); + } else { + return 0; + } + } +}; #define ReadStunMessage(X, Y) ReadStunMessageTestCase(X, Y, sizeof(Y)); @@ -1507,7 +1511,7 @@ TEST_F(StunTest, CopyAttribute) { auto attr = StunAttribute::CreateByteString(STUN_ATTR_USERNAME); attr->CopyBytes("kes", sizeof("kes")); - auto copy = CopyStunAttribute(*attr.get(), buffer_ptr); + auto copy = CopyStunAttribute(*attr, buffer_ptr); ASSERT_EQ(copy->value_type(), STUN_VALUE_BYTE_STRING); EXPECT_STREQ("kes", static_cast(copy.get()) ->string_view() @@ -1522,7 +1526,7 @@ TEST_F(StunTest, CopyAttribute) { CheckStunAddressAttribute(addr.get(), STUN_ADDRESS_IPV6, kTestMessagePort2, test_ip); - auto copy = CopyStunAttribute(*addr.get(), buffer_ptr); + auto copy = CopyStunAttribute(*addr, buffer_ptr); ASSERT_EQ(copy->value_type(), STUN_VALUE_ADDRESS); CheckStunAddressAttribute(static_cast(copy.get()), STUN_ADDRESS_IPV6, kTestMessagePort2, test_ip); @@ -1536,7 +1540,7 @@ TEST_F(StunTest, CopyAttribute) { CheckStunAddressAttribute(addr.get(), STUN_ADDRESS_IPV6, kTestMessagePort2, test_ip); - auto copy = CopyStunAttribute(*addr.get(), buffer_ptr); + auto copy = CopyStunAttribute(*addr, buffer_ptr); ASSERT_EQ(copy->value_type(), STUN_VALUE_ADDRESS); CheckStunAddressAttribute(static_cast(copy.get()), STUN_ADDRESS_IPV6, kTestMessagePort2, test_ip); @@ -1725,4 +1729,31 @@ TEST_F(StunTest, ValidateMessageIntegrityWithParser) { EXPECT_EQ(metrics::NumSamples("WebRTC.Stun.Integrity.Request"), 2); } +TEST_F(StunTest, ByteStringAsVectorOfUint32) { + StunMessage message; + ByteBufferReader reader(kRfc5769SampleRequest); + EXPECT_TRUE(message.Read(&reader)); + + // The username attribute has a length which is not a multiple of 4 + // so getting a uint32_t vector from it should fail. + const StunByteStringAttribute* username = + message.GetByteString(STUN_ATTR_USERNAME); + ASSERT_TRUE(username); + EXPECT_FALSE(username->GetUInt32Vector()); + + // message-integrity is 20 bytes which makes it usable as a test case. + const StunByteStringAttribute* integrity = + message.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); + ASSERT_TRUE(integrity); + std::optional> integrity_vector = + integrity->GetUInt32Vector(); + ASSERT_TRUE(integrity_vector); + EXPECT_EQ(5U, integrity_vector->size()); + // Taken from the RFC 5769 sample request. + std::vector expected_integrity_vector = { + 0x9aeaa70c, 0xbfd8cb56, 0x781ef2b5, 0xb2d3f249, 0xc1b571a2}; + EXPECT_THAT(*integrity_vector, + ::testing::ElementsAreArray(expected_integrity_vector)); +} + } // namespace webrtc diff --git a/api/uma_metrics.h b/api/uma_metrics.h index 93c8c8d0ca..3a3dac3234 100644 --- a/api/uma_metrics.h +++ b/api/uma_metrics.h @@ -196,6 +196,8 @@ enum SdpMungingType { kSsrcs = 27, kIceOptionsRenomination = 28, kDirection = 29, + kRtcpMux = 30, + kIceOptionsTrickle = 31, // RTP header extension munging. kRtpHeaderExtensionRemoved = 40, kRtpHeaderExtensionAdded = 41, @@ -214,6 +216,7 @@ enum SdpMungingType { kAudioCodecsFmtp = 70, kAudioCodecsRtcpFb = 71, kAudioCodecsRtcpFbRrtr = 72, + kAudioCodecsRtcpReducedSize = 73, // Video-related munging. kVideoCodecsRemoved = 80, kVideoCodecsAdded = 81, @@ -224,6 +227,7 @@ enum SdpMungingType { kVideoCodecsRtcpFb = 86, kVideoCodecsAddedWithRawPacketization = 87, kVideoCodecsModifiedWithRawPacketization = 88, + kVideoCodecsRtcpReducedSize = 89, kMaxValue, }; diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index d0af76a6a0..e621f9c088 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -135,18 +135,18 @@ rtc_source_set("video_frame_type") { rtc_source_set("render_resolution") { visibility = [ "*" ] - public = [ "render_resolution.h" ] + sources = [ "render_resolution.h" ] } rtc_source_set("resolution") { visibility = [ "*" ] - public = [ "resolution.h" ] + sources = [ "resolution.h" ] deps = [ "../../rtc_base/system:rtc_export" ] } rtc_source_set("corruption_detection_filter_settings") { visibility = [ "*" ] - public = [ "corruption_detection_filter_settings.h" ] + sources = [ "corruption_detection_filter_settings.h" ] } rtc_library("encoded_image") { @@ -207,11 +207,11 @@ rtc_library("rtp_video_frame_assembler") { "..:array_view", "..:rtp_packet_info", "..:scoped_refptr", - "../../modules/rtp_rtcp:rtp_rtcp", + "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../modules/rtp_rtcp:rtp_video_header", + "../../modules/video_coding", "../../modules/video_coding:packet_buffer", - "../../modules/video_coding:video_coding", "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:rtc_numerics", @@ -230,8 +230,8 @@ rtc_library("rtp_video_frame_assembler_unittests") { ":video_frame", ":video_frame_type", "..:array_view", + "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_packetizer_av1_test_helper", - "../../modules/rtp_rtcp:rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../modules/rtp_rtcp:rtp_video_header", "../../modules/video_coding:codec_globals_headers", @@ -252,7 +252,7 @@ if (rtc_use_h265) { ":video_frame", ":video_frame_type", "..:array_view", - "../../modules/rtp_rtcp:rtp_rtcp", + "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../modules/rtp_rtcp:rtp_video_header", "../../modules/video_coding:codec_globals_headers", @@ -415,10 +415,10 @@ rtc_library("frame_buffer_unittest") { deps = [ ":frame_buffer", + "..:field_trials", "../../api/video:encoded_frame", + "../../test:create_test_field_trials", "../../test:fake_encoded_frame", - "../../test:field_trial", - "../../test:scoped_key_value_config", "../../test:test_support", ] } @@ -432,6 +432,6 @@ rtc_library("video_frame_metadata_unittest") { "../../api/video:video_frame", "../../modules/video_coding:codec_globals_headers", "../../test:test_support", - "../../video:video", + "../../video", ] } diff --git a/api/video/encoded_image.cc b/api/video/encoded_image.cc index 163250a87e..f09bb235bb 100644 --- a/api/video/encoded_image.cc +++ b/api/video/encoded_image.cc @@ -10,9 +10,8 @@ #include "api/video/encoded_image.h" -#include - #include +#include #include #include diff --git a/api/video/frame_buffer_unittest.cc b/api/video/frame_buffer_unittest.cc index d97c7ec914..e3cf0a04d3 100644 --- a/api/video/frame_buffer_unittest.cc +++ b/api/video/frame_buffer_unittest.cc @@ -12,10 +12,11 @@ #include #include +#include "api/field_trials.h" +#include "test/create_test_field_trials.h" #include "test/fake_encoded_frame.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" namespace webrtc { namespace { @@ -30,7 +31,7 @@ MATCHER_P(FrameWithId, id, "") { } TEST(FrameBuffer3Test, RejectInvalidRefs) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); // Ref must be less than the id of this frame. @@ -47,7 +48,7 @@ TEST(FrameBuffer3Test, RejectInvalidRefs) { } TEST(FrameBuffer3Test, LastContinuousUpdatesOnInsertedFrames) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); EXPECT_THAT(buffer.LastContinuousFrameId(), Eq(std::nullopt)); @@ -65,7 +66,7 @@ TEST(FrameBuffer3Test, LastContinuousUpdatesOnInsertedFrames) { } TEST(FrameBuffer3Test, LastContinuousFrameReordering) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -81,7 +82,7 @@ TEST(FrameBuffer3Test, LastContinuousFrameReordering) { } TEST(FrameBuffer3Test, LastContinuousTemporalUnit) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -94,7 +95,7 @@ TEST(FrameBuffer3Test, LastContinuousTemporalUnit) { } TEST(FrameBuffer3Test, LastContinuousTemporalUnitReordering) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -112,7 +113,7 @@ TEST(FrameBuffer3Test, LastContinuousTemporalUnitReordering) { } TEST(FrameBuffer3Test, NextDecodable) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -123,7 +124,7 @@ TEST(FrameBuffer3Test, NextDecodable) { } TEST(FrameBuffer3Test, AdvanceNextDecodableOnExtraction) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -146,7 +147,7 @@ TEST(FrameBuffer3Test, AdvanceNextDecodableOnExtraction) { } TEST(FrameBuffer3Test, AdvanceLastDecodableOnExtraction) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -164,7 +165,7 @@ TEST(FrameBuffer3Test, AdvanceLastDecodableOnExtraction) { } TEST(FrameBuffer3Test, FrameUpdatesNextDecodable) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -178,7 +179,7 @@ TEST(FrameBuffer3Test, FrameUpdatesNextDecodable) { } TEST(FrameBuffer3Test, KeyframeClearsFullBuffer) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/5, /*max_decode_history=*/10, field_trials); EXPECT_TRUE(buffer.InsertFrame( @@ -204,7 +205,7 @@ TEST(FrameBuffer3Test, KeyframeClearsFullBuffer) { } TEST(FrameBuffer3Test, DropNextDecodableTemporalUnit) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); EXPECT_TRUE(buffer.InsertFrame( @@ -221,7 +222,7 @@ TEST(FrameBuffer3Test, DropNextDecodableTemporalUnit) { } TEST(FrameBuffer3Test, OldFramesAreIgnored) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); EXPECT_TRUE(buffer.InsertFrame( @@ -243,7 +244,7 @@ TEST(FrameBuffer3Test, OldFramesAreIgnored) { } TEST(FrameBuffer3Test, ReturnFullTemporalUnitKSVC) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); EXPECT_TRUE( @@ -262,7 +263,7 @@ TEST(FrameBuffer3Test, ReturnFullTemporalUnitKSVC) { } TEST(FrameBuffer3Test, InterleavedStream) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); EXPECT_TRUE(buffer.InsertFrame( @@ -302,8 +303,8 @@ TEST(FrameBuffer3Test, InterleavedStream) { TEST(FrameBuffer3Test, LegacyFrameIdJumpBehavior) { { - test::ScopedKeyValueConfig field_trials( - "WebRTC-LegacyFrameIdJumpBehavior/Disabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-LegacyFrameIdJumpBehavior/Disabled/"); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -318,7 +319,7 @@ TEST(FrameBuffer3Test, LegacyFrameIdJumpBehavior) { { // WebRTC-LegacyFrameIdJumpBehavior is disabled by default. - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); @@ -337,7 +338,7 @@ TEST(FrameBuffer3Test, LegacyFrameIdJumpBehavior) { } TEST(FrameBuffer3Test, TotalNumberOfContinuousTemporalUnits) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); EXPECT_THAT(buffer.GetTotalNumberOfContinuousTemporalUnits(), Eq(0)); @@ -363,7 +364,7 @@ TEST(FrameBuffer3Test, TotalNumberOfContinuousTemporalUnits) { } TEST(FrameBuffer3Test, TotalNumberOfDroppedFrames) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); EXPECT_THAT(buffer.GetTotalNumberOfDroppedFrames(), Eq(0)); diff --git a/api/video/i410_buffer.cc b/api/video/i410_buffer.cc index 37564b9f3a..a09a5a54ba 100644 --- a/api/video/i410_buffer.cc +++ b/api/video/i410_buffer.cc @@ -9,10 +9,9 @@ */ #include "api/video/i410_buffer.h" -#include - #include #include +#include #include #include "api/make_ref_counted.h" diff --git a/api/video/i420_buffer.cc b/api/video/i420_buffer.cc index 33b2ea666e..e9320ced2a 100644 --- a/api/video/i420_buffer.cc +++ b/api/video/i420_buffer.cc @@ -9,10 +9,9 @@ */ #include "api/video/i420_buffer.h" -#include - #include #include +#include #include #include "api/make_ref_counted.h" diff --git a/api/video/i422_buffer.cc b/api/video/i422_buffer.cc index 25814a88d9..fb6dd34246 100644 --- a/api/video/i422_buffer.cc +++ b/api/video/i422_buffer.cc @@ -9,10 +9,9 @@ */ #include "api/video/i422_buffer.h" -#include - #include #include +#include #include #include "api/make_ref_counted.h" diff --git a/api/video/i444_buffer.cc b/api/video/i444_buffer.cc index ace6af1ea1..452777edf9 100644 --- a/api/video/i444_buffer.cc +++ b/api/video/i444_buffer.cc @@ -9,10 +9,9 @@ */ #include "api/video/i444_buffer.h" -#include - #include #include +#include #include #include "api/make_ref_counted.h" diff --git a/api/video/test/color_space_unittest.cc b/api/video/test/color_space_unittest.cc index ae66b018f5..55714f2871 100644 --- a/api/video/test/color_space_unittest.cc +++ b/api/video/test/color_space_unittest.cc @@ -10,7 +10,7 @@ #include "api/video/color_space.h" -#include +#include #include "test/gtest.h" diff --git a/api/video/video_sink_interface.h b/api/video/video_sink_interface.h index b5ddb03a91..f9b7d729c2 100644 --- a/api/video/video_sink_interface.h +++ b/api/video/video_sink_interface.h @@ -34,12 +34,5 @@ class VideoSinkInterface { } // 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::VideoSinkInterface; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_VIDEO_VIDEO_SINK_INTERFACE_H_ diff --git a/api/video/video_source_interface.h b/api/video/video_source_interface.h index e6f94c67e5..0271fd0547 100644 --- a/api/video/video_source_interface.h +++ b/api/video/video_source_interface.h @@ -134,12 +134,4 @@ class VideoSourceInterface { } // 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::VideoSinkWants; -using ::webrtc::VideoSourceInterface; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // API_VIDEO_VIDEO_SOURCE_INTERFACE_H_ diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn index 802f8cc436..eddc2b7782 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn @@ -151,7 +151,7 @@ rtc_library("builtin_video_encoder_factory") { rtc_source_set("video_encoder_factory_template") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_encoder_factory_template.h" ] + sources = [ "video_encoder_factory_template.h" ] deps = [ ":scalability_mode", @@ -166,7 +166,7 @@ rtc_source_set("video_encoder_factory_template") { rtc_source_set("video_encoder_factory_template_libvpx_vp8_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_encoder_factory_template_libvpx_vp8_adapter.h" ] + sources = [ "video_encoder_factory_template_libvpx_vp8_adapter.h" ] deps = [ ":scalability_mode", @@ -181,7 +181,7 @@ rtc_source_set("video_encoder_factory_template_libvpx_vp8_adapter") { rtc_source_set("video_encoder_factory_template_libvpx_vp9_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_encoder_factory_template_libvpx_vp9_adapter.h" ] + sources = [ "video_encoder_factory_template_libvpx_vp9_adapter.h" ] deps = [ ":scalability_mode", @@ -194,7 +194,7 @@ rtc_source_set("video_encoder_factory_template_libvpx_vp9_adapter") { rtc_source_set("video_encoder_factory_template_open_h264_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_encoder_factory_template_open_h264_adapter.h" ] + sources = [ "video_encoder_factory_template_open_h264_adapter.h" ] deps = [ ":scalability_mode", @@ -207,7 +207,7 @@ rtc_source_set("video_encoder_factory_template_open_h264_adapter") { rtc_source_set("video_encoder_factory_template_libaom_av1_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_encoder_factory_template_libaom_av1_adapter.h" ] + sources = [ "video_encoder_factory_template_libaom_av1_adapter.h" ] deps = [ ":scalability_mode", @@ -223,7 +223,7 @@ rtc_source_set("video_encoder_factory_template_libaom_av1_adapter") { rtc_source_set("video_decoder_factory_template") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_decoder_factory_template.h" ] + sources = [ "video_decoder_factory_template.h" ] deps = [ ":video_codecs_api", @@ -236,7 +236,7 @@ rtc_source_set("video_decoder_factory_template") { rtc_source_set("video_decoder_factory_template_libvpx_vp8_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_decoder_factory_template_libvpx_vp8_adapter.h" ] + sources = [ "video_decoder_factory_template_libvpx_vp8_adapter.h" ] deps = [ ":video_codecs_api", @@ -248,7 +248,7 @@ rtc_source_set("video_decoder_factory_template_libvpx_vp8_adapter") { rtc_source_set("video_decoder_factory_template_libvpx_vp9_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_decoder_factory_template_libvpx_vp9_adapter.h" ] + sources = [ "video_decoder_factory_template_libvpx_vp9_adapter.h" ] deps = [ ":video_codecs_api", @@ -259,7 +259,7 @@ rtc_source_set("video_decoder_factory_template_libvpx_vp9_adapter") { rtc_source_set("video_decoder_factory_template_open_h264_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_decoder_factory_template_open_h264_adapter.h" ] + sources = [ "video_decoder_factory_template_open_h264_adapter.h" ] deps = [ ":video_codecs_api", @@ -270,7 +270,7 @@ rtc_source_set("video_decoder_factory_template_open_h264_adapter") { rtc_source_set("video_decoder_factory_template_dav1d_adapter") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] - public = [ "video_decoder_factory_template_dav1d_adapter.h" ] + sources = [ "video_decoder_factory_template_dav1d_adapter.h" ] deps = [ ":video_codecs_api", @@ -280,11 +280,11 @@ rtc_source_set("video_decoder_factory_template_dav1d_adapter") { } rtc_source_set("video_encoding_general") { - public = [ "video_encoding_general.h" ] + sources = [ "video_encoding_general.h" ] } rtc_source_set("video_encoder_interface") { - public = [ "video_encoder_interface.h" ] + sources = [ "video_encoder_interface.h" ] deps = [ ":video_encoding_general", @@ -304,7 +304,7 @@ rtc_source_set("video_encoder_interface") { } rtc_source_set("video_encoder_factory_interface") { - public = [ "video_encoder_factory_interface.h" ] + sources = [ "video_encoder_factory_interface.h" ] deps = [ ":video_encoder_interface", @@ -330,7 +330,7 @@ rtc_library("simple_encoder_wrapper") { "../../api/units:data_rate", "../../api/video_codecs:scalability_mode", "../../api/video_codecs:scalability_mode_helper", - "../../common_video/generic_frame_descriptor:generic_frame_descriptor", + "../../common_video/generic_frame_descriptor", "../../modules/video_coding/svc:scalability_structures", "../../modules/video_coding/svc:scalable_video_controller", "../../rtc_base:checks", @@ -407,7 +407,7 @@ rtc_library("libaom_av1_encoder_factory_test") { "..:scoped_refptr", "../../api/video:video_frame", "../../api/video_codecs:video_codecs_api", - "../../common_video:common_video", + "../../common_video", "../../modules/video_coding/codecs/av1:dav1d_decoder", "../../rtc_base:checks", "../../rtc_base:logging", diff --git a/api/video_codecs/libaom_av1_encoder_factory.cc b/api/video_codecs/libaom_av1_encoder_factory.cc index f82538f5c8..d79719afbf 100644 --- a/api/video_codecs/libaom_av1_encoder_factory.cc +++ b/api/video_codecs/libaom_av1_encoder_factory.cc @@ -781,7 +781,7 @@ void LibaomAv1Encoder::Encode(scoped_refptr frame_buffer, aom_codec_get_cx_data(&ctx_, &iter)) { if (pkt->kind == AOM_CODEC_CX_FRAME_PKT && pkt->data.frame.sz > 0) { SET_OR_RETURN(AOME_GET_LAST_QUANTIZER_64, &result.encoded_qp); - result.frame_type = pkt->data.frame.flags & AOM_EFLAG_FORCE_KF + result.frame_type = pkt->data.frame.flags & AOM_FRAME_IS_KEY ? FrameType::kKeyframe : FrameType::kDeltaFrame; ArrayView output_buffer = diff --git a/api/video_codecs/test/BUILD.gn b/api/video_codecs/test/BUILD.gn index 6b8fe75a7a..c6921157dd 100644 --- a/api/video_codecs/test/BUILD.gn +++ b/api/video_codecs/test/BUILD.gn @@ -30,6 +30,7 @@ if (rtc_include_tests) { "..:rtc_software_fallback_wrappers", "..:video_codecs_api", "../..:fec_controller_api", + "../..:field_trials", "../..:mock_video_encoder", "../..:rtp_parameters", "../../../api:scoped_refptr", @@ -39,9 +40,8 @@ if (rtc_include_tests) { "../../../modules/video_coding:webrtc_vp8", "../../../rtc_base:checks", "../../../rtc_base:rtc_base_tests_utils", - "../../../test:explicit_key_value_config", + "../../../test:create_test_field_trials", "../../../test:fake_video_codecs", - "../../../test:field_trial", "../../../test:test_support", "../../../test:video_test_common", "../../environment", 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 5ff941f273..493dc1fc92 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 @@ -10,14 +10,14 @@ #include "api/video_codecs/video_decoder_software_fallback_wrapper.h" -#include - +#include #include #include #include #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/video/encoded_image.h" #include "api/video/video_frame.h" #include "api/video/video_frame_type.h" @@ -25,7 +25,7 @@ #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "modules/video_coding/include/video_error_codes.h" #include "rtc_base/checks.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" namespace webrtc { @@ -36,7 +36,7 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test { : VideoDecoderSoftwareFallbackWrapperTest("") {} explicit VideoDecoderSoftwareFallbackWrapperTest( const std::string& field_trials) - : field_trials_(field_trials), + : field_trials_(CreateTestFieldTrials(field_trials)), env_(CreateEnvironment(&field_trials_)), fake_decoder_(new CountingFakeDecoder()), fallback_wrapper_(CreateVideoDecoderSoftwareFallbackWrapper( @@ -78,7 +78,7 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test { int release_count_ = 0; int reset_count_ = 0; }; - test::ExplicitKeyValueConfig field_trials_; + FieldTrials field_trials_; const Environment env_; // `fake_decoder_` is owned and released by `fallback_wrapper_`. CountingFakeDecoder* fake_decoder_; 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 903e7fe1d4..bdb388e6ec 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 @@ -10,9 +10,8 @@ #include "api/video_codecs/video_encoder_software_fallback_wrapper.h" -#include -#include - +#include +#include #include #include #include @@ -40,7 +39,7 @@ #include "modules/video_coding/include/video_error_codes.h" #include "modules/video_coding/utility/simulcast_rate_allocator.h" #include "rtc_base/fake_clock.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/fake_encoder.h" #include "test/fake_texture_frame.h" #include "test/gmock.h" @@ -49,18 +48,20 @@ namespace webrtc { namespace { -using test::ExplicitKeyValueConfig; using ::testing::_; using ::testing::Return; using ::testing::ValuesIn; -const int kWidth = 320; -const int kHeight = 240; -const int kNumCores = 2; -const uint32_t kFramerate = 30; -const size_t kMaxPayloadSize = 800; -const int kLowThreshold = 10; -const int kHighThreshold = 20; +constexpr int kWidth = 320; +constexpr int kHeight = 240; +constexpr int kNumCores = 2; +constexpr uint32_t kFramerate = 30; +constexpr size_t kMaxPayloadSize = 800; +constexpr int kLowThreshold = 10; +constexpr int kHighThreshold = 20; +constexpr int kBitrateKbps = 200; +constexpr int kMinPixelsPerFrame = 1; +constexpr char kFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2"; const VideoEncoder::Capabilities kCapabilities(false); const VideoEncoder::Settings kSettings(kCapabilities, @@ -91,6 +92,7 @@ class FakeEncodedImageCallback : public EncodedImageCallback { } int callback_count_ = 0; }; + } // namespace class VideoEncoderSoftwareFallbackWrapperTestBase : public ::testing::Test { @@ -487,12 +489,6 @@ TEST_F(VideoEncoderSoftwareFallbackWrapperTest, fake_sw_encoder_->last_video_frame_->height()); } -namespace { -const int kBitrateKbps = 200; -const int kMinPixelsPerFrame = 1; -const char kFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2"; -} // namespace - class ForcedFallbackTest : public VideoEncoderSoftwareFallbackWrapperTestBase { public: explicit ForcedFallbackTest(const Environment& env) @@ -560,19 +556,17 @@ class ForcedFallbackTest : public VideoEncoderSoftwareFallbackWrapperTestBase { class ForcedFallbackTestEnabled : public ForcedFallbackTest { public: ForcedFallbackTestEnabled() - : ForcedFallbackTest( - CreateEnvironment(std::make_unique( - std::string(kFieldTrial) + "/Enabled-" + - std::to_string(kMinPixelsPerFrame) + "," + - std::to_string(kWidth * kHeight) + ",30000/"))) {} + : ForcedFallbackTest(CreateEnvironment(CreateTestFieldTrialsPtr( + std::string(kFieldTrial) + "/Enabled-" + + std::to_string(kMinPixelsPerFrame) + "," + + std::to_string(kWidth * kHeight) + ",30000/"))) {} }; class ForcedFallbackTestDisabled : public ForcedFallbackTest { public: ForcedFallbackTestDisabled() - : ForcedFallbackTest( - CreateEnvironment(std::make_unique( - std::string(kFieldTrial) + "/Disabled/"))) {} + : ForcedFallbackTest(CreateEnvironment(CreateTestFieldTrialsPtr( + std::string(kFieldTrial) + "/Disabled/"))) {} }; TEST_F(ForcedFallbackTestDisabled, NoFallbackWithoutFieldTrial) { @@ -1144,8 +1138,8 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(ResolutionBasedFallbackTest, VerifyForcedEncoderFallback) { const ResolutionBasedFallbackTestParams& params = GetParam(); - const Environment env = CreateEnvironment( - std::make_unique(params.field_trials)); + const Environment env = + CreateEnvironment(CreateTestFieldTrialsPtr(params.field_trials)); auto primary = std::make_unique(env); primary->SetImplementationName("primary"); auto fallback = std::make_unique(env); diff --git a/api/video_codecs/video_codec.cc b/api/video_codecs/video_codec.cc index 7ebe0294f4..e03243918a 100644 --- a/api/video_codecs/video_codec.cc +++ b/api/video_codecs/video_codec.cc @@ -10,8 +10,7 @@ #include "api/video_codecs/video_codec.h" -#include - +#include #include #include "absl/strings/match.h" diff --git a/api/video_codecs/video_decoder_software_fallback_wrapper.cc b/api/video_codecs/video_decoder_software_fallback_wrapper.cc index 5d5eeaa182..ffb151e2ed 100644 --- a/api/video_codecs/video_decoder_software_fallback_wrapper.cc +++ b/api/video_codecs/video_decoder_software_fallback_wrapper.cc @@ -10,9 +10,8 @@ #include "api/video_codecs/video_decoder_software_fallback_wrapper.h" -#include - #include +#include #include #include #include diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc index fcbb250584..d549e87d75 100644 --- a/api/video_codecs/video_encoder.cc +++ b/api/video_codecs/video_encoder.cc @@ -10,10 +10,9 @@ #include "api/video_codecs/video_encoder.h" -#include - #include #include +#include #include #include #include diff --git a/api/video_codecs/video_encoder_software_fallback_wrapper.cc b/api/video_codecs/video_encoder_software_fallback_wrapper.cc index e1b7910b16..f2ed055ddd 100644 --- a/api/video_codecs/video_encoder_software_fallback_wrapper.cc +++ b/api/video_codecs/video_encoder_software_fallback_wrapper.cc @@ -10,8 +10,7 @@ #include "api/video_codecs/video_encoder_software_fallback_wrapper.h" -#include - +#include #include #include #include diff --git a/api/voip/BUILD.gn b/api/voip/BUILD.gn index 36d2e7127e..b0ae871f41 100644 --- a/api/voip/BUILD.gn +++ b/api/voip/BUILD.gn @@ -72,6 +72,7 @@ if (rtc_include_tests) { "../../modules/audio_device:mock_audio_device", "../../modules/audio_processing:mocks", "../../test:audio_codec_mocks", + "../../test:create_test_field_trials", "../../test:test_support", "../environment:environment_factory", ] diff --git a/api/voip/test/voip_engine_factory_unittest.cc b/api/voip/test/voip_engine_factory_unittest.cc index 557dfd9d0f..07ae9db79f 100644 --- a/api/voip/test/voip_engine_factory_unittest.cc +++ b/api/voip/test/voip_engine_factory_unittest.cc @@ -14,10 +14,10 @@ #include #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "api/make_ref_counted.h" #include "modules/audio_device/include/mock_audio_device.h" #include "modules/audio_processing/include/mock_audio_processing.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_decoder_factory.h" @@ -33,7 +33,7 @@ TEST(VoipEngineFactoryTest, CreateEngineWithMockModules) { VoipEngineConfig config; config.encoder_factory = make_ref_counted(); config.decoder_factory = make_ref_counted(); - config.env = CreateEnvironment(FieldTrials::CreateNoGlobal("")); + config.env = CreateEnvironment(CreateTestFieldTrialsPtr()); config.audio_processing_builder = std::make_unique>(); config.audio_device_module = test::MockAudioDeviceModule::CreateNice(); diff --git a/audio/BUILD.gn b/audio/BUILD.gn index aa82f7a149..eda3161da8 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -139,7 +139,9 @@ if (rtc_include_tests) { ":audio", "../api:simulated_network_api", "../api/audio:audio_device", + "../api/audio_codecs:audio_codecs_api", "../api/task_queue", + "../call:call_interfaces", "../call:fake_network", "../modules/audio_device:test_audio_device_module", "../system_wrappers", @@ -177,6 +179,7 @@ if (rtc_include_tests) { "../api:frame_transformer_factory", "../api:frame_transformer_interface", "../api:function_view", + "../api:location", "../api:make_ref_counted", "../api:mock_audio_mixer", "../api:mock_frame_decryptor", @@ -190,6 +193,7 @@ if (rtc_include_tests) { "../api:simulated_network_api", "../api:transport_api", "../api/audio:audio_frame_api", + "../api/audio:audio_frame_processor", "../api/audio:audio_mixer_api", "../api/audio:audio_processing_statistics", "../api/audio_codecs:audio_codecs_api", @@ -217,6 +221,7 @@ if (rtc_include_tests) { "../call:rtp_receiver", "../call:rtp_sender", "../common_audio", + "../modules/async_audio_processing", "../modules/audio_coding:audio_coding_module_typedefs", "../modules/audio_device:mock_audio_device", "../modules/audio_mixer:audio_mixer_impl", @@ -226,6 +231,7 @@ if (rtc_include_tests) { "../modules/rtp_rtcp", "../modules/rtp_rtcp:mock_rtp_rtcp", "../modules/rtp_rtcp:rtp_rtcp_format", + "../rtc_base:logging", "../rtc_base:safe_compare", "../rtc_base:task_queue_for_test", "../rtc_base:threading", @@ -233,7 +239,6 @@ if (rtc_include_tests) { "../system_wrappers", "../test:audio_codec_mocks", "../test:create_test_field_trials", - "../test:field_trial", "../test:mock_transport", "../test:rtp_test_utils", "../test:run_loop", @@ -243,6 +248,7 @@ if (rtc_include_tests) { "../test:wait_until", "../test/time_controller", "utility:utility_tests", + "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", ] diff --git a/audio/audio_level.cc b/audio/audio_level.cc index 7874b73f1c..5e2426c7ee 100644 --- a/audio/audio_level.cc +++ b/audio/audio_level.cc @@ -10,8 +10,11 @@ #include "audio/audio_level.h" +#include + #include "api/audio/audio_frame.h" #include "common_audio/signal_processing/include/signal_processing_library.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { namespace voe { diff --git a/audio/audio_level.h b/audio/audio_level.h index acd1231fe2..cfdca75c61 100644 --- a/audio/audio_level.h +++ b/audio/audio_level.h @@ -11,6 +11,8 @@ #ifndef AUDIO_AUDIO_LEVEL_H_ #define AUDIO_AUDIO_LEVEL_H_ +#include + #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 1c4d634729..ab2383ffe0 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -25,6 +25,7 @@ #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_format.h" #include "api/call/audio_sink.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" @@ -428,9 +429,9 @@ bool AudioReceiveStreamImpl::SetMinimumPlayoutDelay(int delay_ms) { return channel_receive_->SetMinimumPlayoutDelay(delay_ms); } -void AudioReceiveStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) { +void AudioReceiveStreamImpl::DeliverRtcp(ArrayView packet) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); - channel_receive_->ReceivedRTCPPacket(packet, length); + channel_receive_->ReceivedRTCPPacket(packet.data(), packet.size()); } void AudioReceiveStreamImpl::SetSyncGroup(absl::string_view sync_group) { diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index bc248120ef..0d78482e0e 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -20,6 +20,7 @@ #include #include "absl/strings/string_view.h" +#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_format.h" @@ -123,7 +124,7 @@ class AudioReceiveStreamImpl final : public webrtc::AudioReceiveStreamInterface, int64_t time_ms) override; bool SetMinimumPlayoutDelay(int delay_ms) override; - void DeliverRtcp(const uint8_t* packet, size_t length); + void DeliverRtcp(ArrayView packet); void SetSyncGroup(absl::string_view sync_group); diff --git a/audio/audio_receive_stream_unittest.cc b/audio/audio_receive_stream_unittest.cc index 35d846b241..c3459b73b0 100644 --- a/audio/audio_receive_stream_unittest.cc +++ b/audio/audio_receive_stream_unittest.cc @@ -65,14 +65,14 @@ AudioDecodingCallStats MakeAudioDecodeStatsForTest() { return audio_decode_stats; } -const uint32_t kRemoteSsrc = 1234; -const uint32_t kLocalSsrc = 5678; -const int kJitterBufferDelay = -7; -const int kPlayoutBufferDelay = 302; -const unsigned int kSpeechOutputLevel = 99; -const double kTotalOutputEnergy = 0.25; -const double kTotalOutputDuration = 0.5; -const int64_t kPlayoutNtpTimestampMs = 5678; +constexpr uint32_t kRemoteSsrc = 1234; +constexpr uint32_t kLocalSsrc = 5678; +constexpr int kJitterBufferDelay = -7; +constexpr int kPlayoutBufferDelay = 302; +constexpr unsigned int kSpeechOutputLevel = 99; +constexpr double kTotalOutputEnergy = 0.25; +constexpr double kTotalOutputDuration = 0.5; +constexpr int64_t kPlayoutNtpTimestampMs = 5678; const CallReceiveStatistics kCallStats = {678, 234, -12, 567, 78, 890, 123}; const std::pair kReceiveCodec = { @@ -242,7 +242,7 @@ TEST(AudioReceiveStreamTest, ReceiveRtcpPacket) { EXPECT_CALL(*helper.channel_receive(), ReceivedRTCPPacket(&rtcp_packet[0], rtcp_packet.size())) .WillOnce(Return()); - recv_stream->DeliverRtcp(&rtcp_packet[0], rtcp_packet.size()); + recv_stream->DeliverRtcp(rtcp_packet); recv_stream->UnregisterFromTransport(); } } diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 692527d000..5c7fa93ba5 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -20,6 +20,7 @@ #include "absl/strings/str_cat.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_codecs/audio_encoder.h" @@ -489,9 +490,9 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats( return stats; } -void AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { +void AudioSendStream::DeliverRtcp(ArrayView packet) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); - channel_send_->ReceivedRTCPPacket(packet, length); + channel_send_->ReceivedRTCPPacket(packet.data(), packet.size()); // Poll if overhead has changed, which it can do if ack triggers us to stop // sending mid/rid. UpdateOverheadPerPacket(); diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index c38456d5df..9bac56005a 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -11,24 +11,34 @@ #ifndef AUDIO_AUDIO_SEND_STREAM_H_ #define AUDIO_AUDIO_SEND_STREAM_H_ +#include +#include #include +#include #include #include -#include "absl/functional/any_invocable.h" +#include "api/array_view.h" +#include "api/call/bitrate_allocation.h" #include "api/environment/environment.h" #include "api/field_trials_view.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/task_queue_base.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" #include "audio/audio_level.h" #include "audio/channel_send.h" #include "call/audio_send_stream.h" #include "call/audio_state.h" #include "call/bitrate_allocator.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/experiments/struct_parameters_parser.h" #include "rtc_base/race_checker.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { class RtcpRttStats; @@ -93,7 +103,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, webrtc::AudioSendStream::Stats GetStats( bool has_remote_tracks) const override; - void DeliverRtcp(const uint8_t* packet, size_t length); + void DeliverRtcp(ArrayView packet); // Implements BitrateAllocatorObserver. uint32_t OnBitrateUpdated(BitrateAllocationUpdate update) override; diff --git a/audio/audio_send_stream_tests.cc b/audio/audio_send_stream_tests.cc index 966cf9b84d..6c754a1878 100644 --- a/audio/audio_send_stream_tests.cc +++ b/audio/audio_send_stream_tests.cc @@ -8,17 +8,24 @@ * 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/rtp_headers.h" +#include "api/rtp_parameters.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" #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.h" +#include "rtc_base/logging.h" #include "test/call_test.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/rtcp_packet_parser.h" +#include "test/rtp_rtcp_observer.h" #include "test/video_test_constants.h" namespace webrtc { diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 0cc99124e8..4383b17c75 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -76,28 +76,28 @@ using ::testing::Return; using ::testing::StrEq; using ::testing::WithArg; -const float kTolerance = 0.0001f; - -const uint32_t kSsrc = 1234; -const char* kCName = "foo_name"; -const std::array kCsrcs = {5678, 9012}; -const int kAudioLevelId = 2; -const int kTransportSequenceNumberId = 4; -const int32_t kEchoDelayMedian = 254; -const int32_t kEchoDelayStdDev = -3; -const double kDivergentFilterFraction = 0.2f; -const double kEchoReturnLoss = -65; -const double kEchoReturnLossEnhancement = 101; -const double kResidualEchoLikelihood = -1.0f; -const double kResidualEchoLikelihoodMax = 23.0f; -const CallSendStatistics kCallStats = {112, 12, 13456, 17890}; +constexpr float kTolerance = 0.0001f; + +constexpr uint32_t kSsrc = 1234; +constexpr char kCName[] = "foo_name"; +constexpr std::array kCsrcs = {5678, 9012}; +constexpr int kAudioLevelId = 2; +constexpr int kTransportSequenceNumberId = 4; +constexpr int32_t kEchoDelayMedian = 254; +constexpr int32_t kEchoDelayStdDev = -3; +constexpr double kDivergentFilterFraction = 0.2f; +constexpr double kEchoReturnLoss = -65; +constexpr double kEchoReturnLossEnhancement = 101; +constexpr double kResidualEchoLikelihood = -1.0f; +constexpr double kResidualEchoLikelihoodMax = 23.0f; +constexpr CallSendStatistics kCallStats = {112, 12, 13456, 17890}; constexpr int kFractionLost = 123; constexpr int kCumulativeLost = 567; constexpr uint32_t kInterarrivalJitter = 132; -const int kTelephoneEventPayloadType = 123; -const int kTelephoneEventPayloadFrequency = 65432; -const int kTelephoneEventCode = 45; -const int kTelephoneEventDuration = 6789; +constexpr int kTelephoneEventPayloadType = 123; +constexpr int kTelephoneEventPayloadFrequency = 65432; +constexpr int kTelephoneEventCode = 45; +constexpr int kTelephoneEventDuration = 6789; constexpr int kIsacPayloadType = 103; const SdpAudioFormat kIsacFormat = {"isac", 16000, 1}; const SdpAudioFormat kOpusFormat = {"opus", 48000, 2}; @@ -110,11 +110,11 @@ const AudioCodecSpec kCodecSpecs[] = { // TODO(dklee): This mirrors calculation in audio_send_stream.cc, which // should be made more precise in the future. This can be changed when that // logic is more accurate. -const DataSize kOverheadPerPacket = DataSize::Bytes(20 + 8 + 10 + 12); -const TimeDelta kMinFrameLength = TimeDelta::Millis(20); -const TimeDelta kMaxFrameLength = TimeDelta::Millis(120); -const DataRate kMinOverheadRate = kOverheadPerPacket / kMaxFrameLength; -const DataRate kMaxOverheadRate = kOverheadPerPacket / kMinFrameLength; +constexpr DataSize kOverheadPerPacket = DataSize::Bytes(20 + 8 + 10 + 12); +constexpr TimeDelta kMinFrameLength = TimeDelta::Millis(20); +constexpr TimeDelta kMaxFrameLength = TimeDelta::Millis(120); +constexpr DataRate kMinOverheadRate = kOverheadPerPacket / kMaxFrameLength; +constexpr DataRate kMaxOverheadRate = kOverheadPerPacket / kMinFrameLength; class MockLimitObserver : public BitrateAllocator::LimitObserver { public: diff --git a/audio/audio_state.cc b/audio/audio_state.cc index 57ae1a91b2..a489132e0e 100644 --- a/audio/audio_state.cc +++ b/audio/audio_state.cc @@ -11,18 +11,26 @@ #include "audio/audio_state.h" #include -#include +#include +#include #include #include #include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "api/audio/audio_processing.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 "audio/audio_receive_stream.h" #include "audio/audio_send_stream.h" +#include "call/audio_receive_stream.h" +#include "call/audio_sender.h" +#include "call/audio_state.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/task_utils/repeating_task.h" namespace webrtc { namespace internal { diff --git a/audio/audio_state.h b/audio/audio_state.h index 88aaaa3697..6a2d236d5a 100644 --- a/audio/audio_state.h +++ b/audio/audio_state.h @@ -11,14 +11,16 @@ #ifndef AUDIO_AUDIO_STATE_H_ #define AUDIO_AUDIO_STATE_H_ +#include #include -#include +#include "api/audio/audio_device.h" +#include "api/audio/audio_processing.h" #include "api/sequence_checker.h" #include "audio/audio_transport_impl.h" #include "call/audio_state.h" +#include "rtc_base/checks.h" #include "rtc_base/containers/flat_set.h" -#include "rtc_base/ref_count.h" #include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/thread_annotations.h" diff --git a/audio/audio_state_unittest.cc b/audio/audio_state_unittest.cc index 959eb38b62..534cb1158e 100644 --- a/audio/audio_state_unittest.cc +++ b/audio/audio_state_unittest.cc @@ -10,18 +10,35 @@ #include "audio/audio_state.h" +#include +#include +#include +#include #include #include #include #include +#include "absl/functional/any_invocable.h" +#include "absl/strings/string_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio/audio_frame_processor.h" +#include "api/audio/audio_mixer.h" +#include "api/location.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/task_queue/task_queue_base.h" +#include "api/task_queue/task_queue_factory.h" #include "api/task_queue/test/mock_task_queue_base.h" +#include "call/audio_state.h" #include "call/test/mock_audio_receive_stream.h" #include "call/test/mock_audio_send_stream.h" +#include "modules/async_audio_processing/async_audio_processing.h" #include "modules/audio_device/include/mock_audio_device.h" #include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/audio_processing/include/mock_audio_processing.h" #include "rtc_base/thread.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { diff --git a/audio/audio_transport_impl.h b/audio/audio_transport_impl.h index a240eb0fe5..53f19351d5 100644 --- a/audio/audio_transport_impl.h +++ b/audio/audio_transport_impl.h @@ -11,10 +11,13 @@ #ifndef AUDIO_AUDIO_TRANSPORT_IMPL_H_ #define AUDIO_AUDIO_TRANSPORT_IMPL_H_ +#include +#include #include +#include #include -#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" #include "api/scoped_refptr.h" diff --git a/audio/channel_receive_frame_transformer_delegate.cc b/audio/channel_receive_frame_transformer_delegate.cc index f409c1a9df..887edaa2ee 100644 --- a/audio/channel_receive_frame_transformer_delegate.cc +++ b/audio/channel_receive_frame_transformer_delegate.cc @@ -26,7 +26,7 @@ #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "rtc_base/buffer.h" -#include "rtc_base/string_encode.h" +#include "rtc_base/checks.h" #include "system_wrappers/include/ntp_time.h" namespace webrtc { diff --git a/audio/channel_receive_frame_transformer_delegate.h b/audio/channel_receive_frame_transformer_delegate.h index b856337442..1b5f04eeee 100644 --- a/audio/channel_receive_frame_transformer_delegate.h +++ b/audio/channel_receive_frame_transformer_delegate.h @@ -11,16 +11,20 @@ #ifndef AUDIO_CHANNEL_RECEIVE_FRAME_TRANSFORMER_DELEGATE_H_ #define AUDIO_CHANNEL_RECEIVE_FRAME_TRANSFORMER_DELEGATE_H_ +#include +#include #include #include +#include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/rtp_headers.h" +#include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" #include "api/units/timestamp.h" #include "rtc_base/system/no_unique_address.h" -#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/audio/channel_receive_frame_transformer_delegate_unittest.cc b/audio/channel_receive_frame_transformer_delegate_unittest.cc index 5e8d35fc5d..ae9a01cd69 100644 --- a/audio/channel_receive_frame_transformer_delegate_unittest.cc +++ b/audio/channel_receive_frame_transformer_delegate_unittest.cc @@ -22,6 +22,7 @@ #include "api/scoped_refptr.h" #include "api/test/mock_frame_transformer.h" #include "api/test/mock_transformable_audio_frame.h" +#include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "rtc_base/thread.h" #include "system_wrappers/include/ntp_time.h" diff --git a/audio/conversion.h b/audio/conversion.h index dd71942f6a..453e984fc5 100644 --- a/audio/conversion.h +++ b/audio/conversion.h @@ -11,8 +11,8 @@ #ifndef AUDIO_CONVERSION_H_ #define AUDIO_CONVERSION_H_ -#include -#include +#include +#include namespace webrtc { diff --git a/audio/remix_resample.h b/audio/remix_resample.h index d2f34686dd..ae1017f397 100644 --- a/audio/remix_resample.h +++ b/audio/remix_resample.h @@ -11,6 +11,8 @@ #ifndef AUDIO_REMIX_RESAMPLE_H_ #define AUDIO_REMIX_RESAMPLE_H_ +#include + #include "api/audio/audio_frame.h" #include "api/audio/audio_view.h" #include "common_audio/resampler/include/push_resampler.h" diff --git a/audio/test/audio_end_to_end_test.cc b/audio/test/audio_end_to_end_test.cc index 95bc86dcca..b5f6400959 100644 --- a/audio/test/audio_end_to_end_test.cc +++ b/audio/test/audio_end_to_end_test.cc @@ -10,12 +10,16 @@ #include "audio/test/audio_end_to_end_test.h" -#include +#include #include +#include -#include "api/task_queue/task_queue_base.h" -#include "call/fake_network_pipe.h" +#include "api/audio/audio_device.h" +#include "api/audio_codecs/audio_format.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" #include "modules/audio_device/include/test_audio_device.h" +#include "test/call_test.h" #include "test/gtest.h" #include "test/video_test_constants.h" diff --git a/audio/test/audio_end_to_end_test.h b/audio/test/audio_end_to_end_test.h index a5a6397c18..5580133d42 100644 --- a/audio/test/audio_end_to_end_test.h +++ b/audio/test/audio_end_to_end_test.h @@ -10,13 +10,13 @@ #ifndef AUDIO_TEST_AUDIO_END_TO_END_TEST_H_ #define AUDIO_TEST_AUDIO_END_TO_END_TEST_H_ +#include #include -#include #include #include "api/audio/audio_device.h" -#include "api/task_queue/task_queue_base.h" -#include "api/test/simulated_network.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" #include "modules/audio_device/include/test_audio_device.h" #include "test/call_test.h" diff --git a/audio/test/audio_stats_test.cc b/audio/test/audio_stats_test.cc index d8f1d406a5..e494e92310 100644 --- a/audio/test/audio_stats_test.cc +++ b/audio/test/audio_stats_test.cc @@ -8,9 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include + +#include "api/test/simulated_network.h" #include "audio/test/audio_end_to_end_test.h" -#include "rtc_base/numerics/safe_compare.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" #include "rtc_base/thread.h" +#include "test/call_test.h" #include "test/gtest.h" namespace webrtc { diff --git a/audio/test/nack_test.cc b/audio/test/nack_test.cc index 05cd11b2ce..cc257f1e4b 100644 --- a/audio/test/nack_test.cc +++ b/audio/test/nack_test.cc @@ -8,8 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include + +#include "api/test/simulated_network.h" #include "audio/test/audio_end_to_end_test.h" +#include "call/audio_receive_stream.h" +#include "call/audio_send_stream.h" #include "rtc_base/thread.h" +#include "test/call_test.h" #include "test/gtest.h" namespace webrtc { diff --git a/audio/utility/audio_frame_operations.cc b/audio/utility/audio_frame_operations.cc index d602182041..4d9c414151 100644 --- a/audio/utility/audio_frame_operations.cc +++ b/audio/utility/audio_frame_operations.cc @@ -10,12 +10,13 @@ #include "audio/utility/audio_frame_operations.h" -#include - #include #include +#include #include +#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" #include "common_audio/include/audio_util.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/audio/utility/audio_frame_operations.h b/audio/utility/audio_frame_operations.h index 41ea05edf3..377f7861ca 100644 --- a/audio/utility/audio_frame_operations.h +++ b/audio/utility/audio_frame_operations.h @@ -11,12 +11,11 @@ #ifndef AUDIO_UTILITY_AUDIO_FRAME_OPERATIONS_H_ #define AUDIO_UTILITY_AUDIO_FRAME_OPERATIONS_H_ -#include -#include +#include +#include -#include "absl/base/attributes.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" namespace webrtc { diff --git a/audio/utility/audio_frame_operations_unittest.cc b/audio/utility/audio_frame_operations_unittest.cc index feb86e8de7..2083eb99dd 100644 --- a/audio/utility/audio_frame_operations_unittest.cc +++ b/audio/utility/audio_frame_operations_unittest.cc @@ -10,6 +10,11 @@ #include "audio/utility/audio_frame_operations.h" +#include +#include + +#include "api/audio/audio_frame.h" +#include "api/audio/audio_view.h" #include "rtc_base/checks.h" #include "test/gtest.h" diff --git a/audio/utility/channel_mixer.cc b/audio/utility/channel_mixer.cc index 7049e85503..b46b7ad0a1 100644 --- a/audio/utility/channel_mixer.cc +++ b/audio/utility/channel_mixer.cc @@ -10,9 +10,14 @@ #include "audio/utility/channel_mixer.h" +#include +#include +#include + +#include "api/audio/audio_frame.h" +#include "api/audio/channel_layout.h" #include "audio/utility/channel_mixing_matrix.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" namespace webrtc { diff --git a/audio/utility/channel_mixer.h b/audio/utility/channel_mixer.h index d8a0d3a254..586db5556c 100644 --- a/audio/utility/channel_mixer.h +++ b/audio/utility/channel_mixer.h @@ -11,9 +11,8 @@ #ifndef AUDIO_UTILITY_CHANNEL_MIXER_H_ #define AUDIO_UTILITY_CHANNEL_MIXER_H_ -#include -#include - +#include +#include #include #include diff --git a/audio/utility/channel_mixing_matrix.cc b/audio/utility/channel_mixing_matrix.cc index 83fee65958..8aad9131ec 100644 --- a/audio/utility/channel_mixing_matrix.cc +++ b/audio/utility/channel_mixing_matrix.cc @@ -10,13 +10,13 @@ #include "audio/utility/channel_mixing_matrix.h" -#include - #include +#include +#include +#include "api/audio/channel_layout.h" #include "audio/utility/channel_mixer.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" namespace webrtc { diff --git a/audio/utility/channel_mixing_matrix_unittest.cc b/audio/utility/channel_mixing_matrix_unittest.cc index b6a2a7d656..0f5baf20b3 100644 --- a/audio/utility/channel_mixing_matrix_unittest.cc +++ b/audio/utility/channel_mixing_matrix_unittest.cc @@ -10,8 +10,7 @@ #include "audio/utility/channel_mixing_matrix.h" -#include - +#include #include #include "api/audio/channel_layout.h" diff --git a/audio/voip/BUILD.gn b/audio/voip/BUILD.gn index fab9291f6b..0ec84fb94a 100644 --- a/audio/voip/BUILD.gn +++ b/audio/voip/BUILD.gn @@ -16,16 +16,24 @@ rtc_library("voip_core") { deps = [ ":audio_channel", "..:audio", + "../../api:array_view", + "../../api:make_ref_counted", "../../api:scoped_refptr", + "../../api:transport_api", "../../api/audio:audio_device", + "../../api/audio:audio_mixer_api", "../../api/audio:audio_processing", "../../api/audio_codecs:audio_codecs_api", "../../api/environment", "../../api/task_queue", "../../api/voip:voip_api", + "../../call:audio_sender_interface", "../../modules/audio_mixer:audio_mixer_impl", "../../rtc_base:criticalsection", "../../rtc_base:logging", + "../../rtc_base:macromagic", + "../../rtc_base:random", + "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", ] } @@ -38,12 +46,21 @@ rtc_library("audio_channel") { deps = [ ":audio_egress", ":audio_ingress", + "../../api:array_view", + "../../api:ref_count", + "../../api:rtp_headers", + "../../api:scoped_refptr", "../../api:transport_api", + "../../api/audio:audio_mixer_api", "../../api/audio_codecs:audio_codecs_api", + "../../api/environment", "../../api/task_queue", "../../api/voip:voip_api", + "../../call:audio_sender_interface", + "../../modules/audio_coding:audio_coding_module_typedefs", "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", + "../../rtc_base:checks", "../../rtc_base:criticalsection", "../../rtc_base:logging", "../../rtc_base:refcount", @@ -75,7 +92,9 @@ rtc_library("audio_ingress") { "../../rtc_base:checks", "../../rtc_base:criticalsection", "../../rtc_base:logging", + "../../rtc_base:macromagic", "../../rtc_base:rtc_numerics", + "../../rtc_base:safe_conversions", "../../rtc_base:safe_minmax", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", @@ -90,15 +109,21 @@ rtc_library("audio_egress") { ] deps = [ "..:audio", + "../../api:array_view", "../../api:sequence_checker", + "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", "../../api/environment", "../../api/task_queue", "../../call:audio_sender_interface", "../../modules/audio_coding", + "../../modules/audio_coding:audio_coding_module_typedefs", "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", + "../../rtc_base:checks", "../../rtc_base:logging", + "../../rtc_base:macromagic", + "../../rtc_base:safe_conversions", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:no_unique_address", diff --git a/audio/voip/audio_channel.cc b/audio/voip/audio_channel.cc index 81a01b670c..e564f9f59f 100644 --- a/audio/voip/audio_channel.cc +++ b/audio/voip/audio_channel.cc @@ -10,14 +10,25 @@ #include "audio/voip/audio_channel.h" +#include +#include #include -#include -#include "api/audio_codecs/audio_format.h" -#include "api/task_queue/task_queue_factory.h" +#include "api/audio/audio_mixer.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/call/transport.h" +#include "api/environment/environment.h" +#include "api/rtp_headers.h" +#include "api/scoped_refptr.h" +#include "api/voip/voip_statistics.h" +#include "audio/voip/audio_egress.h" +#include "audio/voip/audio_ingress.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/rtp_rtcp/include/receive_statistics.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" -#include "rtc_base/logging.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/audio/voip/audio_channel.h b/audio/voip/audio_channel.h index b43c9cd814..b670b310f3 100644 --- a/audio/voip/audio_channel.h +++ b/audio/voip/audio_channel.h @@ -11,18 +11,29 @@ #ifndef AUDIO_VOIP_AUDIO_CHANNEL_H_ #define AUDIO_VOIP_AUDIO_CHANNEL_H_ +#include #include #include -#include +#include #include -#include "api/task_queue/task_queue_factory.h" +#include "api/array_view.h" +#include "api/audio/audio_mixer.h" +#include "api/audio_codecs/audio_decoder_factory.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" +#include "api/environment/environment.h" +#include "api/ref_count.h" +#include "api/scoped_refptr.h" #include "api/voip/voip_base.h" #include "api/voip/voip_statistics.h" #include "audio/voip/audio_egress.h" #include "audio/voip/audio_ingress.h" +#include "call/audio_sender.h" +#include "modules/rtp_rtcp/include/receive_statistics.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" -#include "rtc_base/ref_count.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/audio/voip/audio_egress.cc b/audio/voip/audio_egress.cc index e0fef278b8..81d5f60f04 100644 --- a/audio/voip/audio_egress.cc +++ b/audio/voip/audio_egress.cc @@ -10,11 +10,25 @@ #include "audio/voip/audio_egress.h" +#include +#include +#include #include -#include +#include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_format.h" +#include "api/environment/environment.h" #include "api/sequence_checker.h" +#include "api/task_queue/task_queue_factory.h" +#include "audio/utility/audio_frame_operations.h" +#include "modules/audio_coding/include/audio_coding_module.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/numerics/safe_conversions.h" namespace webrtc { diff --git a/audio/voip/audio_egress.h b/audio/voip/audio_egress.h index 7955fed4b3..c1150ed9df 100644 --- a/audio/voip/audio_egress.h +++ b/audio/voip/audio_egress.h @@ -11,24 +11,24 @@ #ifndef AUDIO_VOIP_AUDIO_EGRESS_H_ #define AUDIO_VOIP_AUDIO_EGRESS_H_ +#include +#include #include -#include +#include #include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" -#include "api/task_queue/task_queue_factory.h" #include "audio/audio_level.h" -#include "audio/utility/audio_frame_operations.h" #include "call/audio_sender.h" #include "modules/audio_coding/include/audio_coding_module.h" -#include "modules/rtp_rtcp/include/report_block_data.h" +#include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "modules/rtp_rtcp/source/rtp_sender_audio.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/no_unique_address.h" -#include "rtc_base/time_utils.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/audio/voip/audio_ingress.h b/audio/voip/audio_ingress.h index 97ee2acb62..642b81783e 100644 --- a/audio/voip/audio_ingress.h +++ b/audio/voip/audio_ingress.h @@ -13,28 +13,30 @@ #include #include +#include #include #include #include -#include #include "api/array_view.h" #include "api/audio/audio_mixer.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/rtp_headers.h" #include "api/scoped_refptr.h" #include "api/voip/voip_statistics.h" #include "audio/audio_level.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/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" -#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" +#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/audio/voip/test/BUILD.gn b/audio/voip/test/BUILD.gn index 2b80dc66c6..05a3dac4d5 100644 --- a/audio/voip/test/BUILD.gn +++ b/audio/voip/test/BUILD.gn @@ -14,9 +14,10 @@ if (rtc_include_tests) { visibility = [ "*" ] sources = [ "mock_task_queue.h" ] deps = [ - "../../../api/task_queue:task_queue", + "../../../api/task_queue", "../../../api/task_queue/test:mock_task_queue_base", "../../../test:test_support", + "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -26,10 +27,15 @@ if (rtc_include_tests) { sources = [ "voip_core_unittest.cc" ] deps = [ "..:voip_core", + "../../../api:make_ref_counted", + "../../../api:scoped_refptr", + "../../../api/audio:audio_processing", + "../../../api/audio_codecs:audio_codecs_api", "../../../api/audio_codecs:builtin_audio_decoder_factory", "../../../api/audio_codecs:builtin_audio_encoder_factory", "../../../api/environment:environment_factory", "../../../api/task_queue:default_task_queue_factory", + "../../../api/voip:voip_api", "../../../modules/audio_device:mock_audio_device", "../../../modules/audio_processing:mocks", "../../../test:audio_codec_mocks", @@ -57,11 +63,11 @@ if (rtc_include_tests) { "../../../api/audio_codecs:builtin_audio_encoder_factory", "../../../api/environment", "../../../api/environment:environment_factory", - "../../../api/task_queue:task_queue", + "../../../api/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", "../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../rtc_base:logging", "../../../system_wrappers", @@ -77,7 +83,13 @@ if (rtc_include_tests) { deps = [ "..:audio_egress", "..:audio_ingress", + "../../../api:array_view", + "../../../api:rtp_headers", + "../../../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", @@ -86,13 +98,13 @@ if (rtc_include_tests) { "../../../api/units:time_delta", "../../../api/units:timestamp", "../../../modules/audio_mixer:audio_mixer_test_utils", - "../../../modules/rtp_rtcp:rtp_rtcp", + "../../../modules/rtp_rtcp", "../../../rtc_base:logging", "../../../rtc_base:rtc_event", "../../../test:mock_transport", "../../../test:run_loop", "../../../test:test_support", - "../../../test/time_controller:time_controller", + "../../../test/time_controller", ] } @@ -101,7 +113,12 @@ if (rtc_include_tests) { sources = [ "audio_egress_unittest.cc" ] deps = [ "..:audio_egress", + "../../../api:array_view", + "../../../api:rtp_headers", + "../../../api:scoped_refptr", "../../../api:transport_api", + "../../../api/audio:audio_frame_api", + "../../../api/audio_codecs:audio_codecs_api", "../../../api/audio_codecs:builtin_audio_encoder_factory", "../../../api/environment", "../../../api/environment:environment_factory", @@ -109,14 +126,14 @@ if (rtc_include_tests) { "../../../api/units:time_delta", "../../../api/units:timestamp", "../../../modules/audio_mixer:audio_mixer_test_utils", - "../../../modules/rtp_rtcp:rtp_rtcp", + "../../../modules/rtp_rtcp", "../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../rtc_base:logging", "../../../rtc_base:rtc_event", "../../../test:mock_transport", "../../../test:run_loop", "../../../test:test_support", - "../../../test/time_controller:time_controller", + "../../../test/time_controller", ] } } diff --git a/audio/voip/test/audio_egress_unittest.cc b/audio/voip/test/audio_egress_unittest.cc index 50b0b99636..e60a1a0baf 100644 --- a/audio/voip/test/audio_egress_unittest.cc +++ b/audio/voip/test/audio_egress_unittest.cc @@ -10,21 +10,31 @@ #include "audio/voip/audio_egress.h" +#include +#include +#include +#include + +#include "api/array_view.h" +#include "api/audio/audio_frame.h" +#include "api/audio_codecs/audio_encoder_factory.h" +#include "api/audio_codecs/audio_format.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/rtp_headers.h" +#include "api/scoped_refptr.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/audio_mixer/sine_wave_generator.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/event.h" -#include "rtc_base/logging.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" -#include "test/run_loop.h" #include "test/time_controller/simulated_time_controller.h" namespace webrtc { diff --git a/audio/voip/test/audio_ingress_unittest.cc b/audio/voip/test/audio_ingress_unittest.cc index 282501c38f..d67f7dfb78 100644 --- a/audio/voip/test/audio_ingress_unittest.cc +++ b/audio/voip/test/audio_ingress_unittest.cc @@ -10,22 +10,33 @@ #include "audio/voip/audio_ingress.h" +#include +#include +#include + +#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/default_task_queue_factory.h" +#include "api/rtp_headers.h" +#include "api/scoped_refptr.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "audio/voip/audio_egress.h" #include "modules/audio_mixer/sine_wave_generator.h" +#include "modules/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" +#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/event.h" -#include "rtc_base/logging.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" -#include "test/run_loop.h" #include "test/time_controller/simulated_time_controller.h" namespace webrtc { diff --git a/audio/voip/test/mock_task_queue.h b/audio/voip/test/mock_task_queue.h index 6a769bfefb..d3f004acb9 100644 --- a/audio/voip/test/mock_task_queue.h +++ b/audio/voip/test/mock_task_queue.h @@ -13,9 +13,10 @@ #include +#include "absl/strings/string_view.h" +#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_factory.h" #include "api/task_queue/test/mock_task_queue_base.h" -#include "test/gmock.h" namespace webrtc { diff --git a/audio/voip/test/voip_core_unittest.cc b/audio/voip/test/voip_core_unittest.cc index 5b13cc3eb1..c651778359 100644 --- a/audio/voip/test/voip_core_unittest.cc +++ b/audio/voip/test/voip_core_unittest.cc @@ -10,11 +10,21 @@ #include "audio/voip/voip_core.h" +#include +#include + +#include "api/audio/audio_processing.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/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/voip/voip_base.h" +#include "api/voip/voip_dtmf.h" #include "modules/audio_device/include/mock_audio_device.h" #include "modules/audio_processing/include/mock_audio_processing.h" +#include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" #include "test/run_loop.h" diff --git a/audio/voip/voip_core.cc b/audio/voip/voip_core.cc index a557c3567a..7676811698 100644 --- a/audio/voip/voip_core.cc +++ b/audio/voip/voip_core.cc @@ -11,11 +11,36 @@ #include "audio/voip/voip_core.h" #include +#include +#include +#include #include +#include #include +#include +#include "api/array_view.h" +#include "api/audio/audio_device.h" +#include "api/audio/audio_processing.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/call/transport.h" +#include "api/environment/environment.h" +#include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" +#include "api/voip/voip_base.h" +#include "api/voip/voip_dtmf.h" +#include "api/voip/voip_statistics.h" +#include "api/voip/voip_volume_control.h" +#include "audio/audio_transport_impl.h" +#include "audio/voip/audio_channel.h" +#include "call/audio_sender.h" +#include "modules/audio_mixer/audio_mixer_impl.h" #include "rtc_base/logging.h" +#include "rtc_base/random.h" +#include "rtc_base/synchronization/mutex.h" +#include "rtc_base/time_utils.h" namespace webrtc { diff --git a/audio/voip/voip_core.h b/audio/voip/voip_core.h index 01933623c2..dbd9150be9 100644 --- a/audio/voip/voip_core.h +++ b/audio/voip/voip_core.h @@ -11,16 +11,19 @@ #ifndef AUDIO_VOIP_VOIP_CORE_H_ #define AUDIO_VOIP_VOIP_CORE_H_ +#include #include #include -#include +#include #include -#include +#include "api/array_view.h" #include "api/audio/audio_device.h" +#include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.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/scoped_refptr.h" #include "api/voip/voip_base.h" @@ -32,8 +35,8 @@ #include "api/voip/voip_volume_control.h" #include "audio/audio_transport_impl.h" #include "audio/voip/audio_channel.h" -#include "modules/audio_mixer/audio_mixer_impl.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/call/BUILD.gn b/call/BUILD.gn index 7334d82cf1..2b796266c2 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -650,7 +650,6 @@ if (rtc_include_tests) { "../system_wrappers:metrics", "../test:encoder_settings", "../test:fake_video_codecs", - "../test:field_trial", "../test:fileutils", "../test:frame_generator_capturer", "../test:test_common", @@ -661,6 +660,7 @@ if (rtc_include_tests) { "../test/network:simulated_network", "../video/config:encoder_config", "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", ] } diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc index d698d03047..9d5a68b714 100644 --- a/call/adaptation/resource_adaptation_processor_unittest.cc +++ b/call/adaptation/resource_adaptation_processor_unittest.cc @@ -40,8 +40,8 @@ namespace { using ::testing::Eq; -const int kDefaultFrameRate = 30; -const int kDefaultFrameSize = 1280 * 720; +constexpr int kDefaultFrameRate = 30; +constexpr int kDefaultFrameSize = 1280 * 720; constexpr TimeDelta kDefaultTimeout = TimeDelta::Seconds(5); class VideoSourceRestrictionsListenerForTesting diff --git a/call/adaptation/video_source_restrictions_unittest.cc b/call/adaptation/video_source_restrictions_unittest.cc index aac76547f1..4f83abbb2f 100644 --- a/call/adaptation/video_source_restrictions_unittest.cc +++ b/call/adaptation/video_source_restrictions_unittest.cc @@ -18,7 +18,7 @@ namespace webrtc { namespace { -const size_t kHdPixels = 1280 * 720; +constexpr size_t kHdPixels = 1280 * 720; const VideoSourceRestrictions kUnlimited; const VideoSourceRestrictions k15fps(std::nullopt, std::nullopt, 15.0); diff --git a/call/adaptation/video_stream_adapter_unittest.cc b/call/adaptation/video_stream_adapter_unittest.cc index 16d070b3ad..763ad2fc80 100644 --- a/call/adaptation/video_stream_adapter_unittest.cc +++ b/call/adaptation/video_stream_adapter_unittest.cc @@ -38,14 +38,14 @@ using ::testing::Return; namespace { -const int kBalancedHighResolutionPixels = 1280 * 720; -const int kBalancedHighFrameRateFps = 30; +constexpr int kBalancedHighResolutionPixels = 1280 * 720; +constexpr int kBalancedHighFrameRateFps = 30; -const int kBalancedMediumResolutionPixels = 640 * 480; -const int kBalancedMediumFrameRateFps = 20; +constexpr int kBalancedMediumResolutionPixels = 640 * 480; +constexpr int kBalancedMediumFrameRateFps = 20; -const int kBalancedLowResolutionPixels = 320 * 240; -const int kBalancedLowFrameRateFps = 10; +constexpr int kBalancedLowResolutionPixels = 320 * 240; +constexpr int kBalancedLowFrameRateFps = 10; std::string BalancedFieldTrialConfig() { return "WebRTC-Video-BalancedDegradationSettings/pixels:" + diff --git a/call/audio_send_stream.cc b/call/audio_send_stream.cc index e2f3862f54..dc41a6aef6 100644 --- a/call/audio_send_stream.cc +++ b/call/audio_send_stream.cc @@ -10,8 +10,7 @@ #include "call/audio_send_stream.h" -#include - +#include #include #include "absl/strings/str_cat.h" diff --git a/call/bitrate_allocator_unittest.cc b/call/bitrate_allocator_unittest.cc index 13f00abeb7..b4bb3323e0 100644 --- a/call/bitrate_allocator_unittest.cc +++ b/call/bitrate_allocator_unittest.cc @@ -100,7 +100,7 @@ class TestContributingBitrateObserver : public TestBitrateObserver { }; constexpr int64_t kDefaultProbingIntervalMs = 3000; -const double kDefaultBitratePriority = 1.0; +constexpr double kDefaultBitratePriority = 1.0; TargetTransferRate CreateTargetRateMessage(uint32_t target_bitrate_bps, uint8_t fraction_loss, diff --git a/call/call.cc b/call/call.cc index d6d0e4b2d3..dc1e44995c 100644 --- a/call/call.cc +++ b/call/call.cc @@ -10,11 +10,10 @@ #include "call/call.h" -#include - #include #include #include +#include #include #include #include @@ -26,6 +25,7 @@ #include "absl/functional/bind_front.h" #include "absl/strings/string_view.h" #include "api/adaptation/resource.h" +#include "api/array_view.h" #include "api/environment/environment.h" #include "api/fec_controller.h" #include "api/field_trials_view.h" @@ -655,7 +655,7 @@ Call::SendStats::~SendStats() { return; TimeDelta elapsed = clock_->CurrentTime() - *first_sent_packet_time_; - if (elapsed.seconds() < metrics::kMinRunTimeInSeconds) + if (elapsed < metrics::kMinRunTime) return; const int kMinRequiredPeriodicSamples = 5; @@ -1406,23 +1406,24 @@ void Call::DeliverRtcpPacket(CopyOnWriteBuffer packet) { receive_stats_.AddReceivedRtcpBytes(static_cast(packet.size())); bool rtcp_delivered = false; + ArrayView packet_view(packet.cdata(), packet.size()); for (VideoReceiveStream2* stream : video_receive_streams_) { - if (stream->DeliverRtcp(packet.cdata(), packet.size())) + if (stream->DeliverRtcp(packet_view)) rtcp_delivered = true; } for (AudioReceiveStreamImpl* stream : audio_receive_streams_) { - stream->DeliverRtcp(packet.cdata(), packet.size()); + stream->DeliverRtcp(packet_view); rtcp_delivered = true; } for (VideoSendStreamImpl* stream : video_send_streams_) { - stream->DeliverRtcp(packet.cdata(), packet.size()); + stream->DeliverRtcp(packet); rtcp_delivered = true; } for (auto& kv : audio_send_ssrcs_) { - kv.second->DeliverRtcp(packet.cdata(), packet.size()); + kv.second->DeliverRtcp(packet_view); rtcp_delivered = true; } diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index c7d2e17d8b..45ce575ddf 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -74,13 +74,11 @@ #include "test/drifting_clock.h" #include "test/encoder_settings.h" #include "test/fake_encoder.h" -#include "test/field_trial.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/test_flags.h" -#include "test/testsupport/file_utils.h" #include "test/video_encoder_proxy_factory.h" #include "test/video_test_constants.h" #include "video/config/video_encoder_config.h" @@ -431,8 +429,7 @@ TEST_F(CallPerfTest, TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { // Minimal normal usage at the start, then 30s overuse to allow filter to // settle, and then 80s underuse to allow plenty of time for rampup again. - test::ScopedFieldTrials fake_overuse_settings( - "WebRTC-ForceSimulatedOveruseIntervalMs/1-30000-80000/"); + field_trials().Set("WebRTC-ForceSimulatedOveruseIntervalMs", "1-30000-80000"); class LoadObserver : public test::SendTest, public test::FrameGeneratorCapturer::SinkWantsObserver { diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index f63bf11ef1..4504b6c704 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -10,10 +10,9 @@ #include "call/fake_network_pipe.h" -#include - #include #include +#include #include #include #include diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc index 2158e5775b..ad7b3bbc8d 100644 --- a/call/flexfec_receive_stream_impl.cc +++ b/call/flexfec_receive_stream_impl.cc @@ -10,8 +10,7 @@ #include "call/flexfec_receive_stream_impl.h" -#include - +#include #include #include #include diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index 243a374795..e7bd6d4ba1 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -18,6 +18,7 @@ #include #include "absl/flags/flag.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "api/field_trials_view.h" #include "api/make_ref_counted.h" @@ -43,7 +44,6 @@ #include "call/video_receive_stream.h" #include "call/video_send_stream.h" #include "rtc_base/checks.h" -#include "rtc_base/string_encode.h" #include "rtc_base/task_queue_for_test.h" #include "rtc_base/task_utils/repeating_task.h" #include "test/call_test.h" diff --git a/call/receive_time_calculator_unittest.cc b/call/receive_time_calculator_unittest.cc index f7a382c228..bd4534d0ad 100644 --- a/call/receive_time_calculator_unittest.cc +++ b/call/receive_time_calculator_unittest.cc @@ -10,11 +10,10 @@ #include "call/receive_time_calculator.h" -#include - #include #include #include +#include #include #include diff --git a/call/rtp_payload_params.cc b/call/rtp_payload_params.cc index a3151814c3..4840f6d899 100644 --- a/call/rtp_payload_params.cc +++ b/call/rtp_payload_params.cc @@ -10,15 +10,13 @@ #include "call/rtp_payload_params.h" -#include - #include +#include #include #include #include #include "absl/container/inlined_vector.h" -#include "absl/strings/match.h" #include "api/field_trials_view.h" #include "api/transport/rtp/dependency_descriptor.h" #include "api/video/encoded_image.h" @@ -186,11 +184,9 @@ RtpPayloadParams::RtpPayloadParams(const uint32_t ssrc, const FieldTrialsView& trials) : ssrc_(ssrc), generic_picture_id_experiment_( - absl::StartsWith(trials.Lookup("WebRTC-GenericPictureId"), - "Enabled")), - simulate_generic_structure_(absl::StartsWith( - trials.Lookup("WebRTC-GenericCodecDependencyDescriptor"), - "Enabled")) { + trials.IsEnabled("WebRTC-GenericPictureId")), + simulate_generic_structure_( + trials.IsEnabled("WebRTC-GenericCodecDependencyDescriptor")) { for (auto& spatial_layer : last_frame_id_) spatial_layer.fill(-1); diff --git a/call/rtp_payload_params_unittest.cc b/call/rtp_payload_params_unittest.cc index e38235f95a..377a0e2257 100644 --- a/call/rtp_payload_params_unittest.cc +++ b/call/rtp_payload_params_unittest.cc @@ -54,14 +54,14 @@ using ::testing::SizeIs; using GenericDescriptorInfo = RTPVideoHeader::GenericDescriptorInfo; -const uint32_t kSsrc1 = 12345; -const uint32_t kSsrc2 = 23456; -const int16_t kPictureId = 123; -const int16_t kTl0PicIdx = 20; -const uint8_t kTemporalIdx = 1; -const int16_t kInitialPictureId1 = 222; -const int16_t kInitialTl0PicIdx1 = 99; -const int64_t kDontCare = 0; +constexpr uint32_t kSsrc1 = 12345; +constexpr uint32_t kSsrc2 = 23456; +constexpr int16_t kPictureId = 123; +constexpr int16_t kTl0PicIdx = 20; +constexpr uint8_t kTemporalIdx = 1; +constexpr int16_t kInitialPictureId1 = 222; +constexpr int16_t kInitialTl0PicIdx1 = 99; +constexpr int64_t kDontCare = 0; TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp8) { RtpPayloadState state2; diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index 06ce7b36ec..25cc81396c 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -23,7 +23,6 @@ #include "absl/algorithm/container.h" #include "absl/base/nullability.h" -#include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/call/bitrate_allocation.h" @@ -103,7 +102,7 @@ bool PayloadTypeSupportsSkippingFecPackets(absl::string_view payload_name, return true; } if (codecType == kVideoCodecGeneric && - absl::StartsWith(trials.Lookup("WebRTC-GenericPictureId"), "Enabled")) { + trials.IsEnabled("WebRTC-GenericPictureId")) { return true; } return false; @@ -123,8 +122,7 @@ bool ShouldDisableRedAndUlpfec(bool flexfec_enabled, bool should_disable_red_and_ulpfec = false; - if (absl::StartsWith(trials.Lookup("WebRTC-DisableUlpFecExperiment"), - "Enabled")) { + if (trials.IsEnabled("WebRTC-DisableUlpFecExperiment")) { RTC_LOG(LS_INFO) << "Experiment to disable sending ULPFEC is enabled."; should_disable_red_and_ulpfec = true; } @@ -406,9 +404,8 @@ RtpVideoSender::RtpVideoSender( const CryptoOptions& crypto_options, scoped_refptr frame_transformer) : env_(env), - use_frame_rate_for_overhead_(absl::StartsWith( - env.field_trials().Lookup("WebRTC-Video-UseFrameRateForOverhead"), - "Enabled")), + use_frame_rate_for_overhead_( + env.field_trials().IsEnabled("WebRTC-Video-UseFrameRateForOverhead")), has_packet_feedback_(TransportSeqNumExtensionConfigured(rtp_config)), transport_queue_(*transport_queue), active_(false), @@ -723,10 +720,10 @@ DataRate RtpVideoSender::GetPostEncodeOverhead() const { return post_encode_overhead; } -void RtpVideoSender::DeliverRtcp(const uint8_t* packet, size_t length) { +void RtpVideoSender::DeliverRtcp(ArrayView packet) { // Runs on a network thread. for (const RtpStreamSender& stream : rtp_streams_) - stream.rtp_rtcp->IncomingRtcpPacket(MakeArrayView(packet, length)); + stream.rtp_rtcp->IncomingRtcpPacket(packet); } void RtpVideoSender::ConfigureSsrcs( diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h index 86a5338f91..77f60ef7a6 100644 --- a/call/rtp_video_sender.h +++ b/call/rtp_video_sender.h @@ -113,9 +113,8 @@ class RtpVideoSender : public RtpVideoSenderInterface, std::map GetRtpPayloadStates() const RTC_LOCKS_EXCLUDED(mutex_) override; - void DeliverRtcp(const uint8_t* packet, size_t length) + void DeliverRtcp(ArrayView packet) RTC_LOCKS_EXCLUDED(mutex_) override; - // Implements webrtc::VCMProtectionCallback. int ProtectionRequest(const FecProtectionParams* delta_params, const FecProtectionParams* key_params, diff --git a/call/rtp_video_sender_interface.h b/call/rtp_video_sender_interface.h index 70c0800f3a..754fe03cd4 100644 --- a/call/rtp_video_sender_interface.h +++ b/call/rtp_video_sender_interface.h @@ -40,7 +40,7 @@ class RtpVideoSenderInterface : public EncodedImageCallback, virtual std::map GetRtpStates() const = 0; virtual std::map GetRtpPayloadStates() const = 0; - virtual void DeliverRtcp(const uint8_t* packet, size_t length) = 0; + virtual void DeliverRtcp(ArrayView packet) = 0; virtual void OnBitrateAllocationUpdated( const VideoBitrateAllocation& bitrate) = 0; diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc index c7c83ebc59..150f775fc6 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc @@ -85,19 +85,19 @@ using ::testing::NotNull; using ::testing::SaveArg; using ::testing::SizeIs; -const int8_t kPayloadType = 96; -const int8_t kPayloadType2 = 98; -const uint32_t kSsrc1 = 12345; -const uint32_t kSsrc2 = 23456; -const uint32_t kRtxSsrc1 = 34567; -const uint32_t kRtxSsrc2 = 45678; -const int16_t kInitialPictureId1 = 222; -const int16_t kInitialPictureId2 = 44; -const int16_t kInitialTl0PicIdx1 = 99; -const int16_t kInitialTl0PicIdx2 = 199; -const int64_t kRetransmitWindowSizeMs = 500; -const int kTransportsSequenceExtensionId = 7; -const int kDependencyDescriptorExtensionId = 8; +constexpr int8_t kPayloadType = 96; +constexpr int8_t kPayloadType2 = 98; +constexpr uint32_t kSsrc1 = 12345; +constexpr uint32_t kSsrc2 = 23456; +constexpr uint32_t kRtxSsrc1 = 34567; +constexpr uint32_t kRtxSsrc2 = 45678; +constexpr int16_t kInitialPictureId1 = 222; +constexpr int16_t kInitialPictureId2 = 44; +constexpr int16_t kInitialTl0PicIdx1 = 99; +constexpr int16_t kInitialTl0PicIdx2 = 199; +constexpr int64_t kRetransmitWindowSizeMs = 500; +constexpr int kTransportsSequenceExtensionId = 7; +constexpr int kDependencyDescriptorExtensionId = 8; class MockRtcpIntraFrameObserver : public RtcpIntraFrameObserver { public: @@ -548,7 +548,7 @@ TEST(RtpVideoSenderTest, DoesNotRetrasmitAckedPackets) { ByteReader::ReadBigEndian(payload.data())); return true; }); - test.router()->DeliverRtcp(nack_buffer.data(), nack_buffer.size()); + test.router()->DeliverRtcp(nack_buffer); test.AdvanceTime(TimeDelta::Millis(33)); // Verify that both packets were retransmitted. @@ -589,7 +589,7 @@ TEST(RtpVideoSenderTest, DoesNotRetrasmitAckedPackets) { ByteReader::ReadBigEndian(payload.data())); return true; }); - test.router()->DeliverRtcp(nack_buffer.data(), nack_buffer.size()); + test.router()->DeliverRtcp(nack_buffer); test.AdvanceTime(TimeDelta::Millis(33)); } @@ -988,8 +988,8 @@ TEST(RtpVideoSenderTest, MixedCodecSimulcastPayloadType) { EXPECT_TRUE(rtp_packet.Parse(packet)); return true; }); - test.router()->DeliverRtcp(nack_buffer1.data(), nack_buffer1.size()); - test.router()->DeliverRtcp(nack_buffer2.data(), nack_buffer2.size()); + test.router()->DeliverRtcp(nack_buffer1); + test.router()->DeliverRtcp(nack_buffer2); test.AdvanceTime(TimeDelta::Millis(33)); @@ -1598,7 +1598,7 @@ TEST(RtpVideoSenderTest, RetransmitsBaseLayerOnly) { ByteReader::ReadBigEndian(payload.data())); return true; }); - test.router()->DeliverRtcp(nack_buffer.data(), nack_buffer.size()); + test.router()->DeliverRtcp(nack_buffer); test.AdvanceTime(TimeDelta::Millis(33)); // Verify that only base layer packet was retransmitted. diff --git a/call/rtx_receive_stream.cc b/call/rtx_receive_stream.cc index 1607ebbade..eae0e7b064 100644 --- a/call/rtx_receive_stream.cc +++ b/call/rtx_receive_stream.cc @@ -10,7 +10,6 @@ #include "call/rtx_receive_stream.h" -#include #include #include @@ -22,7 +21,6 @@ #include "modules/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "rtc_base/checks.h" #include "rtc_base/logging.h" namespace webrtc { @@ -79,12 +77,7 @@ void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) { media_packet.set_arrival_time(rtx_packet.arrival_time()); // Skip the RTX header. - ArrayView rtx_payload = payload.subview(kRtxHeaderSize); - - uint8_t* media_payload = media_packet.AllocatePayload(rtx_payload.size()); - RTC_DCHECK(media_payload != nullptr); - - memcpy(media_payload, rtx_payload.data(), rtx_payload.size()); + media_packet.SetPayload(payload.subview(kRtxHeaderSize)); media_sink_->OnRtpPacket(media_packet); } diff --git a/call/version.cc b/call/version.cc index 97caf539b4..b1f14954ca 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-06-18T04:04:29"; +const char* const kSourceTimestamp = "WebRTC source stamp 2025-08-03T04:02:00"; 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 c5459b21bb..6ddf551658 100644 --- a/common_audio/BUILD.gn +++ b/common_audio/BUILD.gn @@ -58,6 +58,7 @@ rtc_library("common_audio") { "../rtc_base/system:arch", "../rtc_base/system:file_wrapper", "third_party/ooura:fft_size_256", + "//third_party/abseil-cpp/absl/strings:string_view", ] defines = [] @@ -373,6 +374,7 @@ if (rtc_include_tests && !build_with_chromium) { ":fir_filter_factory", ":sinc_resampler", "../api/audio:audio_frame_api", + "../api/units:time_delta", "../rtc_base:checks", "../rtc_base:cpu_info", "../rtc_base:logging", diff --git a/common_audio/allocation_counter.cc b/common_audio/allocation_counter.cc index 2a60d2b13a..bf1a112925 100644 --- a/common_audio/allocation_counter.cc +++ b/common_audio/allocation_counter.cc @@ -12,9 +12,8 @@ #if defined(WEBRTC_ALLOCATION_COUNTER_AVAILABLE) -#include - #include +#include #include #include "absl/base/attributes.h" diff --git a/common_audio/audio_converter.cc b/common_audio/audio_converter.cc index 485ec80c56..c5d2b5e0bf 100644 --- a/common_audio/audio_converter.cc +++ b/common_audio/audio_converter.cc @@ -18,7 +18,6 @@ #include "common_audio/channel_buffer.h" #include "common_audio/resampler/push_sinc_resampler.h" #include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" namespace webrtc { diff --git a/common_audio/audio_util.cc b/common_audio/audio_util.cc index b1e4d9ac3c..417ef97efb 100644 --- a/common_audio/audio_util.cc +++ b/common_audio/audio_util.cc @@ -10,6 +10,9 @@ #include "common_audio/include/audio_util.h" +#include +#include + namespace webrtc { void FloatToS16(const float* src, size_t size, int16_t* dest) { diff --git a/common_audio/channel_buffer.cc b/common_audio/channel_buffer.cc index b9b8c25e37..83e807a9fd 100644 --- a/common_audio/channel_buffer.cc +++ b/common_audio/channel_buffer.cc @@ -10,6 +10,7 @@ #include "common_audio/channel_buffer.h" +#include #include #include "common_audio/include/audio_util.h" diff --git a/common_audio/channel_buffer.h b/common_audio/channel_buffer.h index efe761cf60..7d040e5d5f 100644 --- a/common_audio/channel_buffer.h +++ b/common_audio/channel_buffer.h @@ -11,15 +11,14 @@ #ifndef COMMON_AUDIO_CHANNEL_BUFFER_H_ #define COMMON_AUDIO_CHANNEL_BUFFER_H_ -#include - +#include +#include #include #include #include "api/array_view.h" -#include "common_audio/include/audio_util.h" +#include "api/audio/audio_view.h" #include "rtc_base/checks.h" -#include "rtc_base/gtest_prod_util.h" namespace webrtc { diff --git a/common_audio/channel_buffer_unittest.cc b/common_audio/channel_buffer_unittest.cc index a8b64891d6..9c4b52f9f2 100644 --- a/common_audio/channel_buffer_unittest.cc +++ b/common_audio/channel_buffer_unittest.cc @@ -10,6 +10,9 @@ #include "common_audio/channel_buffer.h" +#include + +#include "rtc_base/checks.h" #include "test/gtest.h" #include "test/testsupport/rtc_expect_death.h" @@ -17,9 +20,9 @@ namespace webrtc { namespace { -const size_t kNumFrames = 480u; -const size_t kStereo = 2u; -const size_t kMono = 1u; +constexpr size_t kNumFrames = 480u; +constexpr size_t kStereo = 2u; +constexpr size_t kMono = 1u; void ExpectNumChannels(const IFChannelBuffer& ifchb, size_t num_channels) { EXPECT_EQ(ifchb.ibuf_const()->num_channels(), num_channels); diff --git a/common_audio/fir_filter_avx2.cc b/common_audio/fir_filter_avx2.cc index 9cb0f770ca..88890be798 100644 --- a/common_audio/fir_filter_avx2.cc +++ b/common_audio/fir_filter_avx2.cc @@ -11,10 +11,11 @@ #include "common_audio/fir_filter_avx2.h" #include -#include -#include #include +#include +#include + #include "rtc_base/checks.h" #include "rtc_base/memory/aligned_malloc.h" diff --git a/common_audio/fir_filter_c.cc b/common_audio/fir_filter_c.cc index dc1c8e0d28..d5e687f437 100644 --- a/common_audio/fir_filter_c.cc +++ b/common_audio/fir_filter_c.cc @@ -10,8 +10,7 @@ #include "common_audio/fir_filter_c.h" -#include - +#include #include #include "rtc_base/checks.h" diff --git a/common_audio/fir_filter_factory.cc b/common_audio/fir_filter_factory.cc index fdf758ee79..a41b3cff8d 100644 --- a/common_audio/fir_filter_factory.cc +++ b/common_audio/fir_filter_factory.cc @@ -10,6 +10,8 @@ #include "common_audio/fir_filter_factory.h" +#include + #include "common_audio/fir_filter_c.h" #include "rtc_base/checks.h" #include "rtc_base/cpu_info.h" diff --git a/common_audio/fir_filter_sse.cc b/common_audio/fir_filter_sse.cc index 0e45994a1d..ab9b24ab36 100644 --- a/common_audio/fir_filter_sse.cc +++ b/common_audio/fir_filter_sse.cc @@ -10,10 +10,11 @@ #include "common_audio/fir_filter_sse.h" -#include -#include #include +#include +#include + #include "rtc_base/checks.h" #include "rtc_base/memory/aligned_malloc.h" diff --git a/common_audio/fir_filter_unittest.cc b/common_audio/fir_filter_unittest.cc index 9b2783b9f1..913ac78560 100644 --- a/common_audio/fir_filter_unittest.cc +++ b/common_audio/fir_filter_unittest.cc @@ -10,9 +10,8 @@ #include "common_audio/fir_filter.h" -#include - #include +#include #include #include "common_audio/fir_filter_factory.h" diff --git a/common_audio/mocks/mock_smoothing_filter.h b/common_audio/mocks/mock_smoothing_filter.h index 02966592da..3ac9367ac2 100644 --- a/common_audio/mocks/mock_smoothing_filter.h +++ b/common_audio/mocks/mock_smoothing_filter.h @@ -11,6 +11,8 @@ #ifndef COMMON_AUDIO_MOCKS_MOCK_SMOOTHING_FILTER_H_ #define COMMON_AUDIO_MOCKS_MOCK_SMOOTHING_FILTER_H_ +#include + #include "common_audio/smoothing_filter.h" #include "test/gmock.h" diff --git a/common_audio/real_fourier.cc b/common_audio/real_fourier.cc index 7365844e8d..850d9f2747 100644 --- a/common_audio/real_fourier.cc +++ b/common_audio/real_fourier.cc @@ -10,9 +10,16 @@ #include "common_audio/real_fourier.h" +#include +#include +#include +#include + #include "common_audio/real_fourier_ooura.h" -#include "common_audio/signal_processing/include/signal_processing_library.h" +#include "common_audio/signal_processing/include/signal_processing_library.h" // IWYU pragma: keep +#include "common_audio/signal_processing/include/spl_inl.h" #include "rtc_base/checks.h" +#include "rtc_base/memory/aligned_malloc.h" namespace webrtc { diff --git a/common_audio/real_fourier_ooura.cc b/common_audio/real_fourier_ooura.cc index 9acda5494c..21c0242437 100644 --- a/common_audio/real_fourier_ooura.cc +++ b/common_audio/real_fourier_ooura.cc @@ -12,6 +12,8 @@ #include #include +#include +#include #include "common_audio/third_party/ooura/fft_size_256/fft4g.h" #include "rtc_base/checks.h" diff --git a/common_audio/real_fourier_unittest.cc b/common_audio/real_fourier_unittest.cc index 3f3a2eb5e9..0bf80e3ba1 100644 --- a/common_audio/real_fourier_unittest.cc +++ b/common_audio/real_fourier_unittest.cc @@ -10,7 +10,9 @@ #include "common_audio/real_fourier.h" -#include +#include +#include +#include #include "common_audio/real_fourier_ooura.h" #include "test/gtest.h" diff --git a/common_audio/resampler/push_resampler.cc b/common_audio/resampler/push_resampler.cc index d35b9af605..14ec109945 100644 --- a/common_audio/resampler/push_resampler.cc +++ b/common_audio/resampler/push_resampler.cc @@ -10,9 +10,8 @@ #include "common_audio/resampler/include/push_resampler.h" -#include -#include - +#include +#include #include #include "api/audio/audio_view.h" diff --git a/common_audio/resampler/push_resampler_unittest.cc b/common_audio/resampler/push_resampler_unittest.cc index 4fba2f412e..f0d0d6cdd1 100644 --- a/common_audio/resampler/push_resampler_unittest.cc +++ b/common_audio/resampler/push_resampler_unittest.cc @@ -10,6 +10,8 @@ #include "common_audio/resampler/include/push_resampler.h" +#include + #include "rtc_base/checks.h" // RTC_DCHECK_IS_ON #include "test/gtest.h" #include "test/testsupport/rtc_expect_death.h" diff --git a/common_audio/resampler/push_sinc_resampler.cc b/common_audio/resampler/push_sinc_resampler.cc index 75bf33a7df..11d2992a8a 100644 --- a/common_audio/resampler/push_sinc_resampler.cc +++ b/common_audio/resampler/push_sinc_resampler.cc @@ -10,9 +10,11 @@ #include "common_audio/resampler/push_sinc_resampler.h" +#include #include #include "common_audio/include/audio_util.h" +#include "common_audio/resampler/sinc_resampler.h" #include "rtc_base/checks.h" namespace webrtc { @@ -34,7 +36,7 @@ size_t PushSincResampler::Resample(const int16_t* source, size_t source_length, int16_t* destination, size_t /* destination_capacity */) { - if (!float_buffer_.get()) + if (!float_buffer_) float_buffer_.reset(new float[destination_frames_]); source_ptr_int_ = source; diff --git a/common_audio/resampler/push_sinc_resampler_unittest.cc b/common_audio/resampler/push_sinc_resampler_unittest.cc index d3cfe9d82c..2b3a104c5d 100644 --- a/common_audio/resampler/push_sinc_resampler_unittest.cc +++ b/common_audio/resampler/push_sinc_resampler_unittest.cc @@ -12,20 +12,23 @@ #include #include +#include +#include #include #include +#include #include "common_audio/include/audio_util.h" +#include "common_audio/resampler/sinc_resampler.h" #include "common_audio/resampler/sinusoidal_linear_chirp_source.h" #include "rtc_base/time_utils.h" -#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { namespace { // Almost all conversions have an RMS error of around -14 dbFS. -const double kResamplingRMSError = -14.42; +constexpr double kResamplingRMSError = -14.42; // Used to convert errors to dbFS. template diff --git a/common_audio/resampler/resampler.cc b/common_audio/resampler/resampler.cc index 0fdb249052..1e97c11b1e 100644 --- a/common_audio/resampler/resampler.cc +++ b/common_audio/resampler/resampler.cc @@ -14,9 +14,9 @@ #include "common_audio/resampler/include/resampler.h" -#include -#include -#include +#include +#include +#include #include "common_audio/signal_processing/include/signal_processing_library.h" #include "rtc_base/logging.h" diff --git a/common_audio/resampler/resampler_unittest.cc b/common_audio/resampler/resampler_unittest.cc index b8043ec5fe..428fb65b59 100644 --- a/common_audio/resampler/resampler_unittest.cc +++ b/common_audio/resampler/resampler_unittest.cc @@ -11,6 +11,9 @@ #include "common_audio/resampler/include/resampler.h" #include +#include +#include +#include #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" @@ -21,11 +24,11 @@ namespace webrtc { namespace { // Rates we must support. -const int kMaxRate = 96000; -const int kRates[] = {8000, 16000, 32000, 44000, 48000, kMaxRate}; -const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates); -const int kMaxChannels = 2; -const size_t kDataSize = static_cast(kMaxChannels * kMaxRate / 100); +constexpr int kMaxRate = 96000; +constexpr int kRates[] = {8000, 16000, 32000, 44000, 48000, kMaxRate}; +constexpr size_t kRatesSize = sizeof(kRates) / sizeof(*kRates); +constexpr int kMaxChannels = 2; +constexpr size_t kDataSize = static_cast(kMaxChannels * kMaxRate / 100); // TODO(andrew): should we be supporting these combinations? bool ValidRates(int in_rate, int out_rate) { diff --git a/common_audio/resampler/sinc_resampler_avx2.cc b/common_audio/resampler/sinc_resampler_avx2.cc index d945a10be2..72dad56d98 100644 --- a/common_audio/resampler/sinc_resampler_avx2.cc +++ b/common_audio/resampler/sinc_resampler_avx2.cc @@ -9,10 +9,11 @@ */ #include -#include -#include #include +#include +#include + #include "common_audio/resampler/sinc_resampler.h" namespace webrtc { diff --git a/common_audio/resampler/sinc_resampler_sse.cc b/common_audio/resampler/sinc_resampler_sse.cc index 30a8d1b2d9..c3506c45cd 100644 --- a/common_audio/resampler/sinc_resampler_sse.cc +++ b/common_audio/resampler/sinc_resampler_sse.cc @@ -11,10 +11,11 @@ // Modified from the Chromium original: // src/media/base/simd/sinc_resampler_sse.cc -#include -#include #include +#include +#include + #include "common_audio/resampler/sinc_resampler.h" namespace webrtc { diff --git a/common_audio/resampler/sinusoidal_linear_chirp_source.h b/common_audio/resampler/sinusoidal_linear_chirp_source.h index ccd11bbd61..496ffd5a01 100644 --- a/common_audio/resampler/sinusoidal_linear_chirp_source.h +++ b/common_audio/resampler/sinusoidal_linear_chirp_source.h @@ -14,6 +14,8 @@ #ifndef COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_ #define COMMON_AUDIO_RESAMPLER_SINUSOIDAL_LINEAR_CHIRP_SOURCE_H_ +#include + #include "common_audio/resampler/sinc_resampler.h" namespace webrtc { diff --git a/common_audio/ring_buffer_unittest.cc b/common_audio/ring_buffer_unittest.cc index 0ead7e7981..f93f042d9c 100644 --- a/common_audio/ring_buffer_unittest.cc +++ b/common_audio/ring_buffer_unittest.cc @@ -10,10 +10,10 @@ #include "common_audio/ring_buffer.h" -#include -#include - #include +#include +#include +#include #include #include "test/gtest.h" diff --git a/common_audio/signal_processing/dot_product_with_scale.cc b/common_audio/signal_processing/dot_product_with_scale.cc index 56e0bcd5c7..0bbf7539c6 100644 --- a/common_audio/signal_processing/dot_product_with_scale.cc +++ b/common_audio/signal_processing/dot_product_with_scale.cc @@ -10,6 +10,9 @@ #include "common_audio/signal_processing/dot_product_with_scale.h" +#include +#include + #include "rtc_base/numerics/safe_conversions.h" int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, diff --git a/common_audio/signal_processing/include/signal_processing_library.h b/common_audio/signal_processing/include/signal_processing_library.h index 72c5fc400c..18a10d44c0 100644 --- a/common_audio/signal_processing/include/signal_processing_library.h +++ b/common_audio/signal_processing/include/signal_processing_library.h @@ -17,10 +17,9 @@ #ifndef COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SIGNAL_PROCESSING_LIBRARY_H_ #define COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SIGNAL_PROCESSING_LIBRARY_H_ +#include #include -#include "common_audio/signal_processing/dot_product_with_scale.h" - // Macros specific for the fixed point implementation #define WEBRTC_SPL_WORD16_MAX 32767 #define WEBRTC_SPL_WORD16_MIN -32768 @@ -95,7 +94,7 @@ extern "C" { memcpy(v1, v2, (length) * sizeof(int16_t)) // inline functions: -#include "common_audio/signal_processing/include/spl_inl.h" +#include "common_audio/signal_processing/include/spl_inl.h" // IWYU pragma: keep // third party math functions #include "common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.h" diff --git a/common_audio/signal_processing/real_fft_unittest.cc b/common_audio/signal_processing/real_fft_unittest.cc index 7cabe7d9fe..ea766caf88 100644 --- a/common_audio/signal_processing/real_fft_unittest.cc +++ b/common_audio/signal_processing/real_fft_unittest.cc @@ -10,6 +10,10 @@ #include "common_audio/signal_processing/include/real_fft.h" +#include +#include +#include + #include "common_audio/signal_processing/include/signal_processing_library.h" #include "test/gtest.h" @@ -17,16 +21,16 @@ namespace webrtc { namespace { // FFT order. -const int kOrder = 5; +constexpr int kOrder = 5; // Lengths for real FFT's time and frequency bufffers. // For N-point FFT, the length requirements from API are N and N+2 respectively. -const int kTimeDataLength = 1 << kOrder; -const int kFreqDataLength = (1 << kOrder) + 2; +constexpr int kTimeDataLength = 1 << kOrder; +constexpr int kFreqDataLength = (1 << kOrder) + 2; // For complex FFT's time and freq buffer. The implementation requires // 2*N 16-bit words. -const int kComplexFftDataLength = 2 << kOrder; +constexpr int kComplexFftDataLength = 2 << kOrder; // Reference data for time signal. -const int16_t kRefData[kTimeDataLength] = { +constexpr int16_t kRefData[kTimeDataLength] = { 11739, 6848, -8688, 31980, -30295, 25242, 27085, 19410, -26299, 15607, -10791, 11778, -23819, 14498, -25772, 10076, 1173, 6848, -8688, 31980, -30295, 2522, 27085, 19410, diff --git a/common_audio/smoothing_filter.cc b/common_audio/smoothing_filter.cc index 624182f3f4..b9d864a184 100644 --- a/common_audio/smoothing_filter.cc +++ b/common_audio/smoothing_filter.cc @@ -10,9 +10,9 @@ #include "common_audio/smoothing_filter.h" -#include - #include +#include +#include #include "rtc_base/checks.h" #include "rtc_base/time_utils.h" diff --git a/common_audio/smoothing_filter_unittest.cc b/common_audio/smoothing_filter_unittest.cc index 01bfa56fee..bc0f9e614c 100644 --- a/common_audio/smoothing_filter_unittest.cc +++ b/common_audio/smoothing_filter_unittest.cc @@ -11,8 +11,9 @@ #include "common_audio/smoothing_filter.h" #include -#include +#include +#include "api/units/time_delta.h" #include "rtc_base/fake_clock.h" #include "test/gtest.h" diff --git a/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc b/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc index 7f0802ddfa..64082dbbb1 100644 --- a/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc +++ b/common_audio/third_party/ooura/fft_size_128/ooura_fft_sse2.cc @@ -20,20 +20,6 @@ namespace webrtc { #if defined(WEBRTC_ARCH_X86_FAMILY) -namespace { -// These intrinsics were unavailable before VS 2008. -// TODO(andrew): move to a common file. -#if defined(_MSC_VER) && _MSC_VER < 1500 -static __inline __m128 _mm_castsi128_ps(__m128i a) { - return *(__m128*)&a; -} -static __inline __m128i _mm_castps_si128(__m128 a) { - return *(__m128i*)&a; -} -#endif - -} // namespace - void cft1st_128_SSE2(float* a) { const __m128 mm_swap_sign = _mm_load_ps(k_swap_sign); int j, k2; diff --git a/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_common.h b/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_common.h index 6db1dd9ae4..d0c34fd99f 100644 --- a/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_common.h +++ b/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_common.h @@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_PROCESSING_UTILITY_OOURA_FFT_TABLES_COMMON_H_ #define MODULES_AUDIO_PROCESSING_UTILITY_OOURA_FFT_TABLES_COMMON_H_ -#include "common_audio/third_party/ooura/fft_size_128/ooura_fft.h" +#include "common_audio/third_party/ooura/fft_size_128/ooura_fft.h" // IWYU pragma: keep namespace webrtc { diff --git a/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_neon_sse2.h b/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_neon_sse2.h index a63d187018..5dd11781c1 100644 --- a/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_neon_sse2.h +++ b/common_audio/third_party/ooura/fft_size_128/ooura_fft_tables_neon_sse2.h @@ -11,7 +11,7 @@ #ifndef MODULES_AUDIO_PROCESSING_UTILITY_OOURA_FFT_TABLES_NEON_SSE2_H_ #define MODULES_AUDIO_PROCESSING_UTILITY_OOURA_FFT_TABLES_NEON_SSE2_H_ -#include "common_audio/third_party/ooura/fft_size_128/ooura_fft.h" +#include "common_audio/third_party/ooura/fft_size_128/ooura_fft.h" // IWYU pragma: keep #include "rtc_base/system/arch.h" #ifdef _MSC_VER /* visual c++ */ diff --git a/common_audio/third_party/ooura/fft_size_256/fft4g.cc b/common_audio/third_party/ooura/fft_size_256/fft4g.cc index 2573f23dab..f8f91f306b 100644 --- a/common_audio/third_party/ooura/fft_size_256/fft4g.cc +++ b/common_audio/third_party/ooura/fft_size_256/fft4g.cc @@ -288,8 +288,8 @@ Appendix : #include "common_audio/third_party/ooura/fft_size_256/fft4g.h" -#include -#include +#include +#include namespace webrtc { diff --git a/common_audio/vad/include/vad.h b/common_audio/vad/include/vad.h index b15275b166..c34c5bdc28 100644 --- a/common_audio/vad/include/vad.h +++ b/common_audio/vad/include/vad.h @@ -11,10 +11,10 @@ #ifndef COMMON_AUDIO_VAD_INCLUDE_VAD_H_ #define COMMON_AUDIO_VAD_INCLUDE_VAD_H_ +#include +#include #include -#include "common_audio/vad/include/webrtc_vad.h" -#include "rtc_base/checks.h" namespace webrtc { diff --git a/common_audio/vad/mock/mock_vad.h b/common_audio/vad/mock/mock_vad.h index 5a554ce1f9..9e8ed2a48c 100644 --- a/common_audio/vad/mock/mock_vad.h +++ b/common_audio/vad/mock/mock_vad.h @@ -11,6 +11,9 @@ #ifndef COMMON_AUDIO_VAD_MOCK_MOCK_VAD_H_ #define COMMON_AUDIO_VAD_MOCK_MOCK_VAD_H_ +#include +#include + #include "common_audio/vad/include/vad.h" #include "test/gmock.h" diff --git a/common_audio/vad/vad.cc b/common_audio/vad/vad.cc index 1647246590..619b801acc 100644 --- a/common_audio/vad/vad.cc +++ b/common_audio/vad/vad.cc @@ -10,6 +10,8 @@ #include "common_audio/vad/include/vad.h" +#include +#include #include #include "common_audio/vad/include/webrtc_vad.h" diff --git a/common_audio/vad/vad_core.h b/common_audio/vad/vad_core.h index fbaf970065..7f60cf2e02 100644 --- a/common_audio/vad/vad_core.h +++ b/common_audio/vad/vad_core.h @@ -15,6 +15,9 @@ #ifndef COMMON_AUDIO_VAD_VAD_CORE_H_ #define COMMON_AUDIO_VAD_VAD_CORE_H_ +#include +#include + #include "common_audio/signal_processing/include/signal_processing_library.h" // TODO(https://bugs.webrtc.org/14476): When converted to C++, remove the macro. diff --git a/common_audio/vad/vad_core_unittest.cc b/common_audio/vad/vad_core_unittest.cc index 186ffa5e70..fc695b0357 100644 --- a/common_audio/vad/vad_core_unittest.cc +++ b/common_audio/vad/vad_core_unittest.cc @@ -8,7 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include +#include #include "common_audio/vad/vad_unittest.h" #include "test/gtest.h" diff --git a/common_audio/vad/vad_filterbank.h b/common_audio/vad/vad_filterbank.h index 205eac832c..d3217a8ed8 100644 --- a/common_audio/vad/vad_filterbank.h +++ b/common_audio/vad/vad_filterbank.h @@ -15,6 +15,9 @@ #ifndef COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ #define COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ +#include +#include + #include "common_audio/vad/vad_core.h" // Takes `data_length` samples of `data_in` and calculates the logarithm of the diff --git a/common_audio/vad/vad_filterbank_unittest.cc b/common_audio/vad/vad_filterbank_unittest.cc index 51d8d0fefd..f8e2fa2f6c 100644 --- a/common_audio/vad/vad_filterbank_unittest.cc +++ b/common_audio/vad/vad_filterbank_unittest.cc @@ -8,7 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include +#include #include "common_audio/vad/vad_unittest.h" #include "test/gtest.h" @@ -21,7 +23,7 @@ extern "C" { namespace webrtc { namespace test { -const int kNumValidFrameLengths = 3; +constexpr int kNumValidFrameLengths = 3; TEST_F(VadTest, vad_filterbank) { VadInstT* self = reinterpret_cast(malloc(sizeof(VadInstT))); diff --git a/common_audio/vad/vad_gmm_unittest.cc b/common_audio/vad/vad_gmm_unittest.cc index f203cf28c5..e881f6ec64 100644 --- a/common_audio/vad/vad_gmm_unittest.cc +++ b/common_audio/vad/vad_gmm_unittest.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "common_audio/vad/vad_unittest.h" #include "test/gtest.h" diff --git a/common_audio/vad/vad_sp.h b/common_audio/vad/vad_sp.h index 89138c57cf..96dde6957e 100644 --- a/common_audio/vad/vad_sp.h +++ b/common_audio/vad/vad_sp.h @@ -13,6 +13,9 @@ #ifndef COMMON_AUDIO_VAD_VAD_SP_H_ #define COMMON_AUDIO_VAD_VAD_SP_H_ +#include +#include + #include "common_audio/vad/vad_core.h" // Downsamples the signal by a factor 2, eg. 32->16 or 16->8. diff --git a/common_audio/vad/vad_sp_unittest.cc b/common_audio/vad/vad_sp_unittest.cc index bf208af3e1..8ffe349536 100644 --- a/common_audio/vad/vad_sp_unittest.cc +++ b/common_audio/vad/vad_sp_unittest.cc @@ -8,7 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include #include "common_audio/vad/vad_unittest.h" #include "test/gtest.h" diff --git a/common_audio/vad/vad_unittest.cc b/common_audio/vad/vad_unittest.cc index 5f6afb110d..3af797de4c 100644 --- a/common_audio/vad/vad_unittest.cc +++ b/common_audio/vad/vad_unittest.cc @@ -10,9 +10,8 @@ #include "common_audio/vad/vad_unittest.h" -#include - #include +#include #include #include "common_audio/signal_processing/include/signal_processing_library.h" diff --git a/common_audio/wav_file.cc b/common_audio/wav_file.cc index 127c9c0757..769d948a02 100644 --- a/common_audio/wav_file.cc +++ b/common_audio/wav_file.cc @@ -10,17 +10,19 @@ #include "common_audio/wav_file.h" -#include - #include #include +#include #include #include #include +#include "absl/strings/string_view.h" #include "common_audio/include/audio_util.h" +#include "common_audio/wav_header.h" #include "rtc_base/checks.h" #include "rtc_base/system/arch.h" +#include "rtc_base/system/file_wrapper.h" namespace webrtc { namespace { diff --git a/common_audio/wav_file.h b/common_audio/wav_file.h index 72a4db79c2..eb43837355 100644 --- a/common_audio/wav_file.h +++ b/common_audio/wav_file.h @@ -11,11 +11,10 @@ #ifndef COMMON_AUDIO_WAV_FILE_H_ #define COMMON_AUDIO_WAV_FILE_H_ -#include - #include -#include +#include +#include "absl/strings/string_view.h" #include "common_audio/wav_header.h" #include "rtc_base/system/file_wrapper.h" diff --git a/common_audio/wav_header.cc b/common_audio/wav_header.cc index 467dcc78bb..20e3048c02 100644 --- a/common_audio/wav_header.cc +++ b/common_audio/wav_header.cc @@ -14,6 +14,7 @@ #include "common_audio/wav_header.h" +#include #include #include #include diff --git a/common_audio/wav_header_unittest.cc b/common_audio/wav_header_unittest.cc index 95721dac65..9e0b8ae2a9 100644 --- a/common_audio/wav_header_unittest.cc +++ b/common_audio/wav_header_unittest.cc @@ -10,8 +10,8 @@ #include "common_audio/wav_header.h" -#include - +#include +#include #include #include "test/gtest.h" diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn index d8bc46c19e..04db2a7709 100644 --- a/common_video/BUILD.gn +++ b/common_video/BUILD.gn @@ -29,6 +29,7 @@ rtc_library("corruption_score_calculator") { deps = [ ":frame_instrumentation_data", "../api/video:video_frame", + "../api/video:video_rtp_headers", ] } @@ -192,7 +193,7 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:macromagic", "../rtc_base:rtc_base_tests_utils", "../rtc_base:timeutils", - "../system_wrappers:system_wrappers", + "../system_wrappers", "../test:fileutils", "../test:frame_utils", "../test:test_main", diff --git a/common_video/h264/h264_bitstream_parser.cc b/common_video/h264/h264_bitstream_parser.cc index d6a2e48603..7bc6ab40bf 100644 --- a/common_video/h264/h264_bitstream_parser.cc +++ b/common_video/h264/h264_bitstream_parser.cc @@ -9,9 +9,8 @@ */ #include "common_video/h264/h264_bitstream_parser.h" -#include - #include +#include #include #include diff --git a/common_video/h264/pps_parser_unittest.cc b/common_video/h264/pps_parser_unittest.cc index e3a9c08fd8..e0c1480152 100644 --- a/common_video/h264/pps_parser_unittest.cc +++ b/common_video/h264/pps_parser_unittest.cc @@ -26,14 +26,14 @@ namespace webrtc { namespace { // Contains enough of the image slice to contain slice QP. -const uint8_t kH264BitstreamChunk[] = { +constexpr uint8_t kH264BitstreamChunk[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x20, 0xda, 0x01, 0x40, 0x16, 0xe8, 0x06, 0xd0, 0xa1, 0x35, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x06, 0xe2, 0x00, 0x00, 0x00, 0x01, 0x65, 0xb8, 0x40, 0xf0, 0x8c, 0x03, 0xf2, 0x75, 0x67, 0xad, 0x41, 0x64, 0x24, 0x0e, 0xa0, 0xb2, 0x12, 0x1e, 0xf8, }; -const size_t kPpsBufferMaxSize = 256; -const uint32_t kIgnored = 0; +constexpr size_t kPpsBufferMaxSize = 256; +constexpr uint32_t kIgnored = 0; } // namespace void WritePps(const PpsParser::PpsState& pps, diff --git a/common_video/h264/sps_vui_rewriter.cc b/common_video/h264/sps_vui_rewriter.cc index 497f0932f6..a28e50a4f5 100644 --- a/common_video/h264/sps_vui_rewriter.cc +++ b/common_video/h264/sps_vui_rewriter.cc @@ -11,10 +11,9 @@ #include "common_video/h264/sps_vui_rewriter.h" -#include - #include #include +#include #include #include diff --git a/common_video/h264/sps_vui_rewriter_unittest.cc b/common_video/h264/sps_vui_rewriter_unittest.cc index 854196ab6b..cc88531f0e 100644 --- a/common_video/h264/sps_vui_rewriter_unittest.cc +++ b/common_video/h264/sps_vui_rewriter_unittest.cc @@ -35,15 +35,15 @@ enum SpsMode { kRewriteRequired_VuiSuboptimal, }; -const size_t kSpsBufferMaxSize = 256; -const size_t kWidth = 640; -const size_t kHeight = 480; - -const uint8_t kStartSequence[] = {0x00, 0x00, 0x00, 0x01}; -const uint8_t kAud[] = {H264::NaluType::kAud, 0x09, 0x10}; -const uint8_t kSpsNaluType[] = {H264::NaluType::kSps}; -const uint8_t kIdr1[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x00, 0x04}; -const uint8_t kIdr2[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x11}; +constexpr size_t kSpsBufferMaxSize = 256; +constexpr size_t kWidth = 640; +constexpr size_t kHeight = 480; + +constexpr uint8_t kStartSequence[] = {0x00, 0x00, 0x00, 0x01}; +constexpr uint8_t kAud[] = {H264::NaluType::kAud, 0x09, 0x10}; +constexpr uint8_t kSpsNaluType[] = {H264::NaluType::kSps}; +constexpr uint8_t kIdr1[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x00, 0x04}; +constexpr uint8_t kIdr2[] = {H264::NaluType::kIdr, 0xFF, 0x00, 0x11}; struct VuiHeader { uint32_t vui_parameters_present_flag; diff --git a/common_video/h265/h265_bitstream_parser.cc b/common_video/h265/h265_bitstream_parser.cc index b3f9793a2a..38ffe47db4 100644 --- a/common_video/h265/h265_bitstream_parser.cc +++ b/common_video/h265/h265_bitstream_parser.cc @@ -9,10 +9,9 @@ */ #include "common_video/h265/h265_bitstream_parser.h" -#include - #include #include +#include #include #include #include diff --git a/common_video/h265/h265_bitstream_parser_unittest.cc b/common_video/h265/h265_bitstream_parser_unittest.cc index 754300b8c7..ec629ea507 100644 --- a/common_video/h265/h265_bitstream_parser_unittest.cc +++ b/common_video/h265/h265_bitstream_parser_unittest.cc @@ -24,7 +24,7 @@ using ::testing::Optional; namespace webrtc { // VPS/SPS/PPS part of below chunk. -const uint8_t kH265VpsSpsPps[] = { +constexpr uint8_t kH265VpsSpsPps[] = { 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08, 0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78, 0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08, @@ -34,7 +34,7 @@ const uint8_t kH265VpsSpsPps[] = { 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc1, 0x72, 0xb4, 0x62, 0x40}; // Contains enough of the image slice to contain slice QP. -const uint8_t kH265BitstreamChunk[] = { +constexpr uint8_t kH265BitstreamChunk[] = { 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08, 0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78, 0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08, @@ -48,13 +48,13 @@ const uint8_t kH265BitstreamChunk[] = { }; // Contains enough of the image slice to contain slice QP. -const uint8_t kH265BitstreamNextImageSliceChunk[] = { +constexpr uint8_t kH265BitstreamNextImageSliceChunk[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0xe0, 0x24, 0xbf, 0x82, 0x05, 0x21, 0x12, 0x22, 0xa3, 0x29, 0xb4, 0x21, 0x91, 0xa1, 0xaa, 0x40, }; // Contains enough of the image slice to contain slice QP. -const uint8_t kH265SliceChunk[] = { +constexpr uint8_t kH265SliceChunk[] = { 0xa4, 0x04, 0x55, 0xa2, 0x6d, 0xce, 0xc0, 0xc3, 0xed, 0x0b, 0xac, 0xbc, 0x00, 0xc4, 0x44, 0x2e, 0xf7, 0x55, 0xfd, 0x05, 0x86, 0x92, 0x19, 0xdf, 0x58, 0xec, 0x38, 0x36, 0xb7, 0x7c, 0x00, 0x15, 0x33, 0x78, 0x03, 0x67, @@ -62,13 +62,13 @@ const uint8_t kH265SliceChunk[] = { }; // Contains enough of data for the second slice of a frame. -const uint8_t kH265SecondSliceChunkInAFrame[] = { +constexpr uint8_t kH265SecondSliceChunkInAFrame[] = { 0x02, 0x01, 0x23, 0xfc, 0x20, 0x22, 0xad, 0x13, 0x68, 0xce, 0xc3, 0x5a, 0x00, 0xdc, 0xeb, 0x86, 0x4b, 0x0b, 0xa7, 0x6a, 0xe1, 0x9c, 0x5c, 0xea, }; // Contains short term ref pic set slice to verify Log2Ceiling path. -const uint8_t kH265SliceStrChunk[] = { +constexpr uint8_t kH265SliceStrChunk[] = { 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x99, 0x94, 0x90, 0x24, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, @@ -82,7 +82,7 @@ const uint8_t kH265SliceStrChunk[] = { }; // Contains enough of the image slice to contain invalid slice QP -52. -const uint8_t kH265BitstreamInvalidQPChunk[] = { +constexpr uint8_t kH265BitstreamInvalidQPChunk[] = { 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08, 0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78, 0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08, @@ -94,7 +94,7 @@ const uint8_t kH265BitstreamInvalidQPChunk[] = { }; // Contains enough of the image slice to contain invalid slice QP 52. -const uint8_t kH265BitstreamInvalidQPChunk52[] = { +constexpr uint8_t kH265BitstreamInvalidQPChunk52[] = { 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x04, 0x08, 0x00, 0x00, 0x03, 0x00, 0x9d, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x78, 0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x04, 0x08, @@ -108,7 +108,7 @@ const uint8_t kH265BitstreamInvalidQPChunk52[] = { // Bitstream that contains pred_weight_table. Contains enough data to parse // over pred_weight_table for slice QP. This is bear.hevc from Chromium source, // used for H265 hardware decoder's parser test, with some slices truncated. -const uint8_t kH265BitstreamWithPredWeightTable[] = { +constexpr uint8_t kH265BitstreamWithPredWeightTable[] = { 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0x95, 0xc0, 0x90, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, diff --git a/common_video/h265/h265_inline.cc b/common_video/h265/h265_inline.cc index 3943a7a41e..d27c97e7f8 100644 --- a/common_video/h265/h265_inline.cc +++ b/common_video/h265/h265_inline.cc @@ -10,7 +10,7 @@ #include "common_video/h265/h265_inline.h" -#include +#include // Table used by WebRtcVideo_CountLeadingZeros32_NotBuiltin. For each uint32_t n // that's a sequence of 0 bits followed by a sequence of 1 bits, the entry at diff --git a/common_video/include/corruption_score_calculator.h b/common_video/include/corruption_score_calculator.h index 77ea5335f0..cb87dbb5c8 100644 --- a/common_video/include/corruption_score_calculator.h +++ b/common_video/include/corruption_score_calculator.h @@ -11,8 +11,7 @@ #ifndef COMMON_VIDEO_INCLUDE_CORRUPTION_SCORE_CALCULATOR_H_ #define COMMON_VIDEO_INCLUDE_CORRUPTION_SCORE_CALCULATOR_H_ -#include - +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "common_video/frame_instrumentation_data.h" @@ -24,9 +23,10 @@ class CorruptionScoreCalculator { public: virtual ~CorruptionScoreCalculator() = default; - virtual std::optional CalculateCorruptionScore( + virtual void CalculateCorruptionScore( const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data) = 0; + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type) = 0; }; } // namespace webrtc diff --git a/common_video/libyuv/libyuv_unittest.cc b/common_video/libyuv/libyuv_unittest.cc index 375eb4a3fd..6b47ec65ea 100644 --- a/common_video/libyuv/libyuv_unittest.cc +++ b/common_video/libyuv/libyuv_unittest.cc @@ -8,11 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include #include #include +#include #include #include #include @@ -148,10 +147,10 @@ TEST_F(TestLibYuv, ConvertTest) { int ret = libyuv::I420Copy( out_i420_buffer.get(), width_, out_i420_buffer.get() + y_size, width_ >> 1, out_i420_buffer.get() + y_size + u_size, width_ >> 1, - res_i420_buffer.get()->MutableDataY(), res_i420_buffer.get()->StrideY(), - res_i420_buffer.get()->MutableDataU(), res_i420_buffer.get()->StrideU(), - res_i420_buffer.get()->MutableDataV(), res_i420_buffer.get()->StrideV(), - width_, height_); + res_i420_buffer->MutableDataY(), res_i420_buffer->StrideY(), + res_i420_buffer->MutableDataU(), res_i420_buffer->StrideU(), + res_i420_buffer->MutableDataV(), res_i420_buffer->StrideV(), width_, + height_); EXPECT_EQ(0, ret); if (PrintVideoFrame(*res_i420_buffer, output_file) < 0) { @@ -174,10 +173,10 @@ TEST_F(TestLibYuv, ConvertTest) { res_rgb_buffer2.get())); ret = libyuv::ConvertToI420( - res_rgb_buffer2.get(), 0, res_i420_buffer.get()->MutableDataY(), - res_i420_buffer.get()->StrideY(), res_i420_buffer.get()->MutableDataU(), - res_i420_buffer.get()->StrideU(), res_i420_buffer.get()->MutableDataV(), - res_i420_buffer.get()->StrideV(), 0, 0, width_, height_, + res_rgb_buffer2.get(), 0, res_i420_buffer->MutableDataY(), + res_i420_buffer->StrideY(), res_i420_buffer->MutableDataU(), + res_i420_buffer->StrideU(), res_i420_buffer->MutableDataV(), + res_i420_buffer->StrideV(), 0, 0, width_, height_, res_i420_buffer->width(), res_i420_buffer->height(), libyuv::kRotate0, ConvertVideoType(VideoType::kRGB24)); @@ -198,10 +197,10 @@ TEST_F(TestLibYuv, ConvertTest) { out_uyvy_buffer.get())); ret = libyuv::ConvertToI420( - out_uyvy_buffer.get(), 0, res_i420_buffer.get()->MutableDataY(), - res_i420_buffer.get()->StrideY(), res_i420_buffer.get()->MutableDataU(), - res_i420_buffer.get()->StrideU(), res_i420_buffer.get()->MutableDataV(), - res_i420_buffer.get()->StrideV(), 0, 0, width_, height_, + out_uyvy_buffer.get(), 0, res_i420_buffer->MutableDataY(), + res_i420_buffer->StrideY(), res_i420_buffer->MutableDataU(), + res_i420_buffer->StrideU(), res_i420_buffer->MutableDataV(), + res_i420_buffer->StrideV(), 0, 0, width_, height_, res_i420_buffer->width(), res_i420_buffer->height(), libyuv::kRotate0, ConvertVideoType(VideoType::kUYVY)); @@ -220,10 +219,10 @@ TEST_F(TestLibYuv, ConvertTest) { out_yuy2_buffer.get())); ret = libyuv::ConvertToI420( - out_yuy2_buffer.get(), 0, res_i420_buffer.get()->MutableDataY(), - res_i420_buffer.get()->StrideY(), res_i420_buffer.get()->MutableDataU(), - res_i420_buffer.get()->StrideU(), res_i420_buffer.get()->MutableDataV(), - res_i420_buffer.get()->StrideV(), 0, 0, width_, height_, + out_yuy2_buffer.get(), 0, res_i420_buffer->MutableDataY(), + res_i420_buffer->StrideY(), res_i420_buffer->MutableDataU(), + res_i420_buffer->StrideU(), res_i420_buffer->MutableDataV(), + res_i420_buffer->StrideV(), 0, 0, width_, height_, res_i420_buffer->width(), res_i420_buffer->height(), libyuv::kRotate0, ConvertVideoType(VideoType::kYUY2)); @@ -244,10 +243,10 @@ TEST_F(TestLibYuv, ConvertTest) { out_rgb565_buffer.get())); ret = libyuv::ConvertToI420( - out_rgb565_buffer.get(), 0, res_i420_buffer.get()->MutableDataY(), - res_i420_buffer.get()->StrideY(), res_i420_buffer.get()->MutableDataU(), - res_i420_buffer.get()->StrideU(), res_i420_buffer.get()->MutableDataV(), - res_i420_buffer.get()->StrideV(), 0, 0, width_, height_, + out_rgb565_buffer.get(), 0, res_i420_buffer->MutableDataY(), + res_i420_buffer->StrideY(), res_i420_buffer->MutableDataU(), + res_i420_buffer->StrideU(), res_i420_buffer->MutableDataV(), + res_i420_buffer->StrideV(), 0, 0, width_, height_, res_i420_buffer->width(), res_i420_buffer->height(), libyuv::kRotate0, ConvertVideoType(VideoType::kRGB565)); @@ -271,10 +270,10 @@ TEST_F(TestLibYuv, ConvertTest) { out_argb8888_buffer.get())); ret = libyuv::ConvertToI420( - out_argb8888_buffer.get(), 0, res_i420_buffer.get()->MutableDataY(), - res_i420_buffer.get()->StrideY(), res_i420_buffer.get()->MutableDataU(), - res_i420_buffer.get()->StrideU(), res_i420_buffer.get()->MutableDataV(), - res_i420_buffer.get()->StrideV(), 0, 0, width_, height_, + out_argb8888_buffer.get(), 0, res_i420_buffer->MutableDataY(), + res_i420_buffer->StrideY(), res_i420_buffer->MutableDataU(), + res_i420_buffer->StrideU(), res_i420_buffer->MutableDataV(), + res_i420_buffer->StrideV(), 0, 0, width_, height_, res_i420_buffer->width(), res_i420_buffer->height(), libyuv::kRotate0, ConvertVideoType(VideoType::kARGB)); @@ -316,10 +315,10 @@ TEST_F(TestLibYuv, ConvertAlignedFrame) { int ret = libyuv::I420Copy( out_i420_buffer.get(), width_, out_i420_buffer.get() + y_size, width_ >> 1, out_i420_buffer.get() + y_size + u_size, width_ >> 1, - res_i420_buffer.get()->MutableDataY(), res_i420_buffer.get()->StrideY(), - res_i420_buffer.get()->MutableDataU(), res_i420_buffer.get()->StrideU(), - res_i420_buffer.get()->MutableDataV(), res_i420_buffer.get()->StrideV(), - width_, height_); + res_i420_buffer->MutableDataY(), res_i420_buffer->StrideY(), + res_i420_buffer->MutableDataU(), res_i420_buffer->StrideU(), + res_i420_buffer->MutableDataV(), res_i420_buffer->StrideV(), width_, + height_); EXPECT_EQ(0, ret); diff --git a/common_video/video_frame_buffer_pool_unittest.cc b/common_video/video_frame_buffer_pool_unittest.cc index 6c3feb85a3..dbb80af21a 100644 --- a/common_video/video_frame_buffer_pool_unittest.cc +++ b/common_video/video_frame_buffer_pool_unittest.cc @@ -10,8 +10,8 @@ #include "common_video/include/video_frame_buffer_pool.h" -#include -#include +#include +#include #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" diff --git a/common_video/video_frame_unittest.cc b/common_video/video_frame_unittest.cc index a10f322805..bd1d674a02 100644 --- a/common_video/video_frame_unittest.cc +++ b/common_video/video_frame_unittest.cc @@ -10,11 +10,9 @@ #include "api/video/video_frame.h" -#include -#include - #include #include +#include #include #include diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 4508146c93..6ec5e65609 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -482,6 +482,7 @@ if (is_ios || (is_mac && target_cpu != "x86")) { ] deps = [ + "../api:create_modular_peer_connection_factory", "../api:enable_media", "../api:libjingle_peerconnection_api", "../api:scoped_refptr", @@ -491,9 +492,6 @@ if (is_ios || (is_mac && target_cpu != "x86")) { "../api/audio_codecs:builtin_audio_decoder_factory", "../api/audio_codecs:builtin_audio_encoder_factory", "../api/rtc_event_log:rtc_event_log_factory", - "../api/task_queue:default_task_queue_factory", - "../modules/audio_processing", - "../pc:libjingle_peerconnection", "../rtc_base/synchronization:mutex", "../sdk:base_objc", "../sdk:default_codec_factory_objc", @@ -684,6 +682,7 @@ if (is_linux || is_chromeos || is_win) { "../api:async_dns_resolver", "../api:audio_options_api", "../api:create_frame_generator", + "../api:create_modular_peer_connection_factory", "../api:enable_media", "../api:field_trials", "../api:libjingle_peerconnection_api", @@ -716,6 +715,8 @@ if (is_linux || is_chromeos || is_win) { "../rtc_base:net_helpers", "../rtc_base:refcount", "../rtc_base:rtc_certificate_generator", + "../rtc_base:socket", + "../rtc_base:socket_address", "../rtc_base:ssl_adapter", "../rtc_base:stringutils", "../rtc_base:threading", @@ -822,7 +823,7 @@ if (is_linux || is_chromeos || is_win) { "../rtc_base:socket_address", "../rtc_base:socket_server", "../rtc_base:threading", - "//third_party/abseil-cpp/absl/strings:strings", + "//third_party/abseil-cpp/absl/strings", ] } rtc_executable("stunserver") { @@ -832,6 +833,7 @@ if (is_linux || is_chromeos || is_win) { "../p2p:p2p_server_utils", "../pc:rtc_pc", "../rtc_base:async_udp_socket", + "../rtc_base:checks", "../rtc_base:socket_address", "../rtc_base:socket_server", "../rtc_base:threading", diff --git a/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java b/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java index fd838119ff..81c55aba1f 100644 --- a/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java +++ b/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java @@ -333,12 +333,10 @@ public PeerConnectionClient(Context appContext, EglBase eglBase, Log.d(TAG, "Preferred video codec: " + getSdpVideoCodecName(peerConnectionParameters)); - final String fieldTrials = getFieldTrials(peerConnectionParameters); executor.execute(() -> { - Log.d(TAG, "Initialize WebRTC. Field trials: " + fieldTrials); + Log.d(TAG, "Initialize WebRTC."); PeerConnectionFactory.initialize( PeerConnectionFactory.InitializationOptions.builder(appContext) - .setFieldTrials(fieldTrials) .setEnableInternalTracer(true) .createInitializationOptions()); }); @@ -446,13 +444,15 @@ private void createPeerConnectionFactoryInternal(PeerConnectionFactory.Options o if (peerConnectionParameters.loopback) { options.disableEncryption = true; } + final String fieldTrials = getFieldTrials(peerConnectionParameters); factory = PeerConnectionFactory.builder() + .setFieldTrials(fieldTrials) .setOptions(options) .setAudioDeviceModule(adm) .setVideoEncoderFactory(encoderFactory) .setVideoDecoderFactory(decoderFactory) .createPeerConnectionFactory(); - Log.d(TAG, "Peer connection factory created."); + Log.d(TAG, "Peer connection factory created. Field trials: " + fieldTrials); adm.release(); } diff --git a/examples/androidnativeapi/BUILD.gn b/examples/androidnativeapi/BUILD.gn index 7211192206..64cd43e923 100644 --- a/examples/androidnativeapi/BUILD.gn +++ b/examples/androidnativeapi/BUILD.gn @@ -31,7 +31,6 @@ if (is_android) { testonly = true sources = [ "java/org/webrtc/examples/androidnativeapi/CallClient.java" ] namespace = "webrtc_examples" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } rtc_shared_library("examples_androidnativeapi_jni") { @@ -47,6 +46,7 @@ if (is_android) { deps = [ ":generated_jni", + "../../api:create_modular_peer_connection_factory", "../../api:enable_media_with_defaults", "../../api:make_ref_counted", "../../api:media_stream_interface", @@ -56,6 +56,7 @@ if (is_android) { "../../api/video:video_frame", "../../rtc_base:checks", "../../rtc_base:logging", + "../../rtc_base:macromagic", "../../rtc_base:ssl", "../../rtc_base:ssl_adapter", "../../rtc_base:threading", diff --git a/examples/androidnativeapi/jni/android_call_client.cc b/examples/androidnativeapi/jni/android_call_client.cc index 0735266511..e2fa4e79b4 100644 --- a/examples/androidnativeapi/jni/android_call_client.cc +++ b/examples/androidnativeapi/jni/android_call_client.cc @@ -16,6 +16,7 @@ #include #include +#include "api/create_modular_peer_connection_factory.h" #include "api/data_channel_interface.h" #include "api/enable_media_with_defaults.h" #include "api/jsep.h" diff --git a/examples/androidnativeapi/jni/android_call_client.h b/examples/androidnativeapi/jni/android_call_client.h index d50c58b3d1..6fffdada8e 100644 --- a/examples/androidnativeapi/jni/android_call_client.h +++ b/examples/androidnativeapi/jni/android_call_client.h @@ -14,12 +14,15 @@ #include #include -#include #include "api/peer_connection_interface.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" #include "sdk/android/native_api/video/video_source.h" diff --git a/examples/androidnativeapi/jni/onload.cc b/examples/androidnativeapi/jni/onload.cc index e85bc629ef..40e1ad9953 100644 --- a/examples/androidnativeapi/jni/onload.cc +++ b/examples/androidnativeapi/jni/onload.cc @@ -11,6 +11,7 @@ #include #include "modules/utility/include/jvm_android.h" +#include "rtc_base/checks.h" #include "rtc_base/ssl_adapter.h" #include "sdk/android/native_api/base/init.h" diff --git a/examples/androidvoip/BUILD.gn b/examples/androidvoip/BUILD.gn index 4c8af525ec..657e7a71f9 100644 --- a/examples/androidvoip/BUILD.gn +++ b/examples/androidvoip/BUILD.gn @@ -40,7 +40,6 @@ if (is_android) { testonly = true sources = [ "java/org/webrtc/examples/androidvoip/VoipClient.java" ] namespace = "webrtc_examples" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } rtc_shared_library("examples_androidvoip_jni") { @@ -56,11 +55,14 @@ if (is_android) { deps = [ ":generated_jni", + "../../api:array_view", "../../api/audio:builtin_audio_processing_builder", "../../api/environment:environment_factory", "../../rtc_base:async_packet_socket", "../../rtc_base:async_udp_socket", + "../../rtc_base:checks", "../../rtc_base:logging", + "../../rtc_base:macromagic", "../../rtc_base:network", "../../rtc_base:socket_address", "../../rtc_base:socket_server", @@ -77,7 +79,8 @@ if (is_android) { "//sdk/android:native_api_audio_device_module", "//sdk/android:native_api_base", "//sdk/android:native_api_jni", - "//third_party/abseil-cpp/absl/memory:memory", + "//third_party/abseil-cpp/absl/memory", + "//third_party/jni_zero", ] } diff --git a/examples/androidvoip/jni/android_voip_client.h b/examples/androidvoip/jni/android_voip_client.h index cb8b927978..0c62a100d3 100644 --- a/examples/androidvoip/jni/android_voip_client.h +++ b/examples/androidvoip/jni/android_voip_client.h @@ -13,10 +13,13 @@ #include +#include #include +#include #include #include +#include "api/array_view.h" #include "api/audio_codecs/audio_format.h" #include "api/call/transport.h" #include "api/voip/voip_base.h" @@ -26,7 +29,8 @@ #include "rtc_base/network/received_packet.h" #include "rtc_base/socket_address.h" #include "rtc_base/thread.h" -#include "sdk/android/native_api/jni/scoped_java_ref.h" +#include "rtc_base/thread_annotations.h" +#include "third_party/jni_zero/jni_zero.h" namespace webrtc_examples { diff --git a/examples/androidvoip/jni/onload.cc b/examples/androidvoip/jni/onload.cc index 9c1de12629..e558f2e2cf 100644 --- a/examples/androidvoip/jni/onload.cc +++ b/examples/androidvoip/jni/onload.cc @@ -10,6 +10,7 @@ #include +#include "rtc_base/checks.h" #include "rtc_base/ssl_adapter.h" #include "sdk/android/native_api/base/init.h" diff --git a/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m b/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m index 9a3b0d561a..fa0b0fb89a 100644 --- a/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m +++ b/examples/objc/AppRTCMobile/ios/ARDAppDelegate.m @@ -10,7 +10,6 @@ #import "ARDAppDelegate.h" -#import "sdk/objc/api/peerconnection/RTCFieldTrials.h" #import "sdk/objc/api/peerconnection/RTCSSLAdapter.h" #import "sdk/objc/api/peerconnection/RTCTracing.h" #import "sdk/objc/base/RTCLogging.h" @@ -25,8 +24,6 @@ @implementation ARDAppDelegate { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - NSDictionary *fieldTrials = @{}; - RTCInitFieldTrialDictionary(fieldTrials); RTCInitializeSSL(); RTCSetupInternalTracer(); _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; diff --git a/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm b/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm index c435d65c7d..7ca025c8ac 100644 --- a/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm +++ b/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm @@ -45,6 +45,7 @@ - (void)testRetrievingSetting { NSString *string = [_model currentVideoResolutionSettingFromStore]; XCTAssertEqualObjects(string, @"640x480"); + [storeMock verify]; } - (void)testStoringInvalidConstraintReturnsNo { diff --git a/examples/objcnativeapi/objc/objc_call_client.mm b/examples/objcnativeapi/objc/objc_call_client.mm index ea476ce417..834554579b 100644 --- a/examples/objcnativeapi/objc/objc_call_client.mm +++ b/examples/objcnativeapi/objc/objc_call_client.mm @@ -22,6 +22,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/create_modular_peer_connection_factory.h" #include "api/enable_media.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index 43c4cdd2f9..1381509986 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -10,8 +10,7 @@ #include "examples/peerconnection/client/conductor.h" -#include - +#include #include #include #include @@ -23,6 +22,7 @@ #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_modular_peer_connection_factory.h" #include "api/enable_media.h" #include "api/environment/environment.h" #include "api/jsep.h" @@ -170,7 +170,7 @@ bool Conductor::InitializePeerConnection() { RTC_DCHECK(!peer_connection_factory_); RTC_DCHECK(!peer_connection_); - if (!signaling_thread_.get()) { + if (!signaling_thread_) { signaling_thread_ = webrtc::Thread::CreateWithSocketServer(); signaling_thread_->Start(); } @@ -350,7 +350,7 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { RTC_DCHECK(peer_id_ == peer_id || peer_id_ == -1); RTC_DCHECK(!message.empty()); - if (!peer_connection_.get()) { + if (!peer_connection_) { RTC_DCHECK(peer_id_ == -1); peer_id_ = peer_id; @@ -439,7 +439,7 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { webrtc::SdpParseError error; std::unique_ptr candidate( webrtc::CreateIceCandidate(sdp_mid, sdp_mlineindex, sdp, &error)); - if (!candidate.get()) { + if (!candidate) { RTC_LOG(LS_WARNING) << "Can't parse received candidate message. " "SdpParseError was: " << error.description; @@ -483,7 +483,7 @@ void Conductor::ConnectToPeer(int peer_id) { RTC_DCHECK(peer_id_ == -1); RTC_DCHECK(peer_id != -1); - if (peer_connection_.get()) { + if (peer_connection_) { main_wnd_->MessageBox( "Error", "We only support connecting to one peer at a time", true); return; @@ -535,7 +535,7 @@ void Conductor::AddTracks() { void Conductor::DisconnectFromCurrentPeer() { RTC_LOG(LS_INFO) << __FUNCTION__; - if (peer_connection_.get()) { + if (peer_connection_) { client_->SendHangUp(peer_id_); DeletePeerConnection(); } @@ -582,7 +582,7 @@ void Conductor::UIThreadCallback(int msg_id, void* data) { delete msg; } - if (!peer_connection_.get()) + if (!peer_connection_) peer_id_ = -1; break; diff --git a/examples/peerconnection/client/defaults.cc b/examples/peerconnection/client/defaults.cc index 9ff7aeedf3..faf86cf642 100644 --- a/examples/peerconnection/client/defaults.cc +++ b/examples/peerconnection/client/defaults.cc @@ -10,9 +10,8 @@ #include "examples/peerconnection/client/defaults.h" -#include - #include +#include #include #include diff --git a/examples/peerconnection/client/linux/main.cc b/examples/peerconnection/client/linux/main.cc index 68ac5998cb..60b7b53a34 100644 --- a/examples/peerconnection/client/linux/main.cc +++ b/examples/peerconnection/client/linux/main.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include -#include +#include #include #include @@ -72,16 +71,6 @@ class CustomSocketServer : public webrtc::PhysicalSocketServer { int main(int argc, char* argv[]) { gtk_init(&argc, &argv); -// g_type_init API is deprecated (and does nothing) since glib 2.35.0, see: -// https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif -// g_thread_init API is deprecated since glib 2.31.0, see release note: -// http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html -#if !GLIB_CHECK_VERSION(2, 31, 0) - g_thread_init(NULL); -#endif absl::ParseCommandLine(argc, argv); diff --git a/examples/peerconnection/client/linux/main_wnd.cc b/examples/peerconnection/client/linux/main_wnd.cc index ef624f1a65..74a27f7ea5 100644 --- a/examples/peerconnection/client/linux/main_wnd.cc +++ b/examples/peerconnection/client/linux/main_wnd.cc @@ -18,11 +18,11 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include "api/media_stream_interface.h" diff --git a/examples/peerconnection/client/peer_connection_client.cc b/examples/peerconnection/client/peer_connection_client.cc index 6aa60e8746..5afed42ee9 100644 --- a/examples/peerconnection/client/peer_connection_client.cc +++ b/examples/peerconnection/client/peer_connection_client.cc @@ -10,12 +10,23 @@ #include "examples/peerconnection/client/peer_connection_client.h" +#include +#include +#include +#include +#include +#include +#include + +#include "api/async_dns_resolver.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "api/units/time_delta.h" #include "examples/peerconnection/client/defaults.h" #include "rtc_base/async_dns_resolver.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/net_helpers.h" +#include "rtc_base/socket.h" #include "rtc_base/thread.h" namespace { diff --git a/examples/peerconnection/client/peer_connection_client.h b/examples/peerconnection/client/peer_connection_client.h index bc82184ebe..3480a55a7d 100644 --- a/examples/peerconnection/client/peer_connection_client.h +++ b/examples/peerconnection/client/peer_connection_client.h @@ -11,14 +11,15 @@ #ifndef EXAMPLES_PEERCONNECTION_CLIENT_PEER_CONNECTION_CLIENT_H_ #define EXAMPLES_PEERCONNECTION_CLIENT_PEER_CONNECTION_CLIENT_H_ +#include #include #include #include #include "api/async_dns_resolver.h" #include "api/task_queue/pending_task_safety_flag.h" -#include "rtc_base/net_helpers.h" -#include "rtc_base/physical_socket_server.h" +#include "rtc_base/socket.h" +#include "rtc_base/socket_address.h" #include "rtc_base/third_party/sigslot/sigslot.h" typedef std::map Peers; diff --git a/examples/peerconnection/server/data_socket.cc b/examples/peerconnection/server/data_socket.cc index 9ece090a64..68d32463a9 100644 --- a/examples/peerconnection/server/data_socket.cc +++ b/examples/peerconnection/server/data_socket.cc @@ -10,11 +10,10 @@ #include "examples/peerconnection/server/data_socket.h" -#include -#include -#include - #include +#include +#include +#include #include #include "absl/strings/str_cat.h" @@ -24,7 +23,8 @@ #include "rtc_base/net_helpers.h" #if defined(WEBRTC_POSIX) -#include +#include +#include // IWYU pragma: keep #endif static const char kHeaderTerminator[] = "\r\n\r\n"; diff --git a/examples/peerconnection/server/data_socket.h b/examples/peerconnection/server/data_socket.h index 326ecc075b..31f50d1fc6 100644 --- a/examples/peerconnection/server/data_socket.h +++ b/examples/peerconnection/server/data_socket.h @@ -11,16 +11,15 @@ #ifndef EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_ #define EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_ +#include #include -#include "rtc_base/ip_address.h" -#include "rtc_base/net_helpers.h" #ifdef WIN32 +#include typedef int socklen_t; typedef SOCKET NativeSocket; #else -#include #define closesocket close typedef int NativeSocket; diff --git a/examples/peerconnection/server/main.cc b/examples/peerconnection/server/main.cc index 0b4e483427..2c797ffa8d 100644 --- a/examples/peerconnection/server/main.cc +++ b/examples/peerconnection/server/main.cc @@ -8,13 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include -#if defined(WEBRTC_POSIX) -#include -#endif -#include - +#include +#include +#include #include #include @@ -25,6 +21,10 @@ #include "examples/peerconnection/server/peer_channel.h" #include "rtc_base/checks.h" +#if defined(WEBRTC_POSIX) +#include +#endif + // 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 diff --git a/examples/peerconnection/server/peer_channel.cc b/examples/peerconnection/server/peer_channel.cc index 4b8a8d5253..67b31af90d 100644 --- a/examples/peerconnection/server/peer_channel.cc +++ b/examples/peerconnection/server/peer_channel.cc @@ -10,10 +10,9 @@ #include "examples/peerconnection/server/peer_channel.h" -#include -#include - #include +#include +#include #include #include #include diff --git a/examples/stunserver/stunserver_main.cc b/examples/stunserver/stunserver_main.cc index 1c8f505dcc..f1655f5df1 100644 --- a/examples/stunserver/stunserver_main.cc +++ b/examples/stunserver/stunserver_main.cc @@ -11,6 +11,7 @@ #include "p2p/test/stun_server.h" #include "rtc_base/async_udp_socket.h" +#include "rtc_base/checks.h" #include "rtc_base/socket_address.h" #include "rtc_base/socket_server.h" #include "rtc_base/thread.h" diff --git a/examples/turnserver/read_auth_file.cc b/examples/turnserver/read_auth_file.cc index d4cae5636f..c1b6eff2d6 100644 --- a/examples/turnserver/read_auth_file.cc +++ b/examples/turnserver/read_auth_file.cc @@ -10,7 +10,10 @@ #include "examples/turnserver/read_auth_file.h" -#include +#include +#include +#include +#include #include "absl/strings/string_view.h" #include "api/array_view.h" diff --git a/experiments/field_trials.py b/experiments/field_trials.py index 9fe38176fb..ccc815c22d 100755 --- a/experiments/field_trials.py +++ b/experiments/field_trials.py @@ -125,6 +125,12 @@ def bug_url(self) -> str: FieldTrial('WebRTC-NoSdpMangleNumberOfContents', 40567530, date(2025, 10, 11)), + FieldTrial('WebRTC-NoSdpMangleReject', + 40567530, + date(2026, 6, 1)), + FieldTrial('WebRTC-NoSdpMangleAllowForTesting', + 40567530, + date(2026, 6, 1)), FieldTrial('WebRTC-Pacer-FastRetransmissions', 40235589, date(2024, 4, 1)), diff --git a/g3doc/become_a_committer.md b/g3doc/become_a_committer.md index 725b9faa7a..0f16f06ee7 100644 --- a/g3doc/become_a_committer.md +++ b/g3doc/become_a_committer.md @@ -75,12 +75,14 @@ recommended to apply for WebRTC committer rights obtaining process. 6. Also as any contributor you must sign and return the [Contributor License Agreement][4] +Two-factor authentication with a security key is a requirement for adding your account as a committer. If you haven't done so already, you'll need to set up a security key on your account. + ## WebRTC Committers expiration If a WebRTC committer isn't active on Gerrit (e.g. by uploading a CL, or participating in code reviews) for more than 1 year, they will lose their status as a WebRTC Committer and removed from the list of committers. An email will be -sent one week before the expiration date, giving the committer 7 days to +sent one week before the expiration date, giving the committer 7 days to demonstrate activity and maintain their WebRTC Committer status. [1]: https://webrtc.googlesource.com/src/+/refs/heads/main/docs/faq.md#to-be-a-contributor_do-i-need-to-sign-any-agreements diff --git a/g3doc/supported-platforms-and-compilers.md b/g3doc/supported-platforms-and-compilers.md index 69a1d1f68c..32d03f544e 100644 --- a/g3doc/supported-platforms-and-compilers.md +++ b/g3doc/supported-platforms-and-compilers.md @@ -32,3 +32,6 @@ for some clang related documentation from Chromium. Other compilers are not officially supported (which means there is no CI coverage for them) but patches to keep WebRTC working with them are welcomed by the WebRTC Team. + +For Microsofts Visual C++ compiler the minimum supported version is `_MSC_VER 1929` +which means Visual Studio 2019 version 16.11 or higher. diff --git a/infra/config/commit-queue.cfg b/infra/config/commit-queue.cfg index 1038a5189d..bd72078103 100644 --- a/infra/config/commit-queue.cfg +++ b/infra/config/commit-queue.cfg @@ -153,9 +153,6 @@ config_groups { builders { name: "webrtc/try/mac_asan" } - builders { - name: "webrtc/try/mac_chromium_compile" - } builders { name: "webrtc/try/mac_compile_dbg" } diff --git a/infra/config/config.star b/infra/config/config.star index c9e5361484..188ec17952 100755 --- a/infra/config/config.star +++ b/infra/config/config.star @@ -1,8 +1,11 @@ #!/usr/bin/env lucicfg -# 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. +# 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. # https://chromium.googlesource.com/infra/luci/luci-go/+/main/lucicfg/doc/ @@ -781,7 +784,7 @@ ci_builder("Linux64 Release", "Linux|x64|rel") try_builder("linux_rel") ci_builder("Linux64 Builder", "Linux|x64|size", perf_cat = "Linux|x64|Builder|", prioritized = True) try_builder("linux_compile_rel") -perf_builder("Perf Linux Bionic", "Linux|x64|Tester|Bionic", triggered_by = ["Linux64 Builder"]) +perf_builder("Perf Linux", "Linux|x64|Tester", triggered_by = ["Linux64 Builder"]) ci_builder("Linux32 Debug (ARM)", "Linux|arm|dbg") try_builder("linux_compile_arm_dbg") ci_builder("Linux32 Release (ARM)", "Linux|arm|rel") @@ -829,7 +832,9 @@ try_builder("mac_asan") ci_builder("MacARM64 M1 Release", "Mac|arm64M1|rel", cpu = "arm64-64-Apple_M1") try_builder("mac_rel_m1") try_builder("mac_dbg_m1") -chromium_try_builder("mac_chromium_compile") + +# TODO b/427073823 - Re-enable once the slow compilation issue is fixed. +chromium_try_builder("mac_chromium_compile", cq = None) ci_builder("Win32 Debug (Clang)", "Win Clang|x86|dbg") try_builder("win_x86_clang_dbg", cq = None) @@ -896,10 +901,8 @@ lkgr_config = { # bucket alias: luci.chromium.webrtc.fyi "builders": [ "WebRTC Chromium FYI Android Builder (dbg)", - "WebRTC Chromium FYI Android Builder ARM64 (dbg)", "WebRTC Chromium FYI Android Builder", - "WebRTC Chromium FYI Android Tests (dbg)", - "WebRTC Chromium FYI Android Tests ARM64 (dbg)", + "WebRTC Chromium FYI Android Tester", "WebRTC Chromium FYI Linux Builder (dbg)", "WebRTC Chromium FYI Linux Builder", "WebRTC Chromium FYI Linux Tester", diff --git a/infra/config/cr-buildbucket.cfg b/infra/config/cr-buildbucket.cfg index 3630d8abd1..5d945759bf 100644 --- a/infra/config/cr-buildbucket.cfg +++ b/infra/config/cr-buildbucket.cfg @@ -2039,10 +2039,8 @@ buckets { ' "chromium/webrtc.fyi": {' ' "builders": [' ' "WebRTC Chromium FYI Android Builder (dbg)",' - ' "WebRTC Chromium FYI Android Builder ARM64 (dbg)",' ' "WebRTC Chromium FYI Android Builder",' - ' "WebRTC Chromium FYI Android Tests (dbg)",' - ' "WebRTC Chromium FYI Android Tests ARM64 (dbg)",' + ' "WebRTC Chromium FYI Android Tester",' ' "WebRTC Chromium FYI Linux Builder (dbg)",' ' "WebRTC Chromium FYI Linux Builder",' ' "WebRTC Chromium FYI Linux Tester",' @@ -2647,7 +2645,7 @@ buckets { } } builders { - name: "Perf Linux Bionic" + name: "Perf Linux" swarming_host: "chromium-swarm.appspot.com" swarming_tags: "vpython:native-python-wrapper" dimensions: "os:Linux" diff --git a/infra/config/luci-milo.cfg b/infra/config/luci-milo.cfg index 35cc997e42..4dff326fdf 100644 --- a/infra/config/luci-milo.cfg +++ b/infra/config/luci-milo.cfg @@ -301,9 +301,9 @@ consoles { category: "Linux|x64|Builder" } builders { - name: "buildbucket/luci.webrtc.perf/Perf Linux Bionic" - category: "Linux|x64|Tester" - short_name: "Bionic" + name: "buildbucket/luci.webrtc.perf/Perf Linux" + category: "Linux|x64" + short_name: "Tester" } builders { name: "buildbucket/luci.webrtc.perf/Fuchsia Builder" diff --git a/infra/config/luci-notify.cfg b/infra/config/luci-notify.cfg index 53a6c5eb3b..416b6f0f84 100644 --- a/infra/config/luci-notify.cfg +++ b/infra/config/luci-notify.cfg @@ -1291,7 +1291,7 @@ notifiers { } builders { bucket: "perf" - name: "Perf Linux Bionic" + name: "Perf Linux" repository: "https://webrtc.googlesource.com/src" } } diff --git a/infra/config/luci-scheduler.cfg b/infra/config/luci-scheduler.cfg index 275b169bd9..87430e7a57 100644 --- a/infra/config/luci-scheduler.cfg +++ b/infra/config/luci-scheduler.cfg @@ -420,7 +420,7 @@ job { } } job { - id: "Perf Linux Bionic" + id: "Perf Linux" realm: "perf" acls { role: TRIGGERER @@ -434,7 +434,7 @@ job { buildbucket { server: "cr-buildbucket.appspot.com" bucket: "perf" - builder: "Perf Linux Bionic" + builder: "Perf Linux" } } job { diff --git a/infra/config/project.cfg b/infra/config/project.cfg index 24599b5d9e..7456221c30 100644 --- a/infra/config/project.cfg +++ b/infra/config/project.cfg @@ -7,7 +7,7 @@ name: "webrtc" access: "group:all" lucicfg { - version: "1.45.0" + version: "1.45.6" package_dir: "." config_dir: "." entry_point: "config.star" diff --git a/infra/config/realms.cfg b/infra/config/realms.cfg index 409a7506c5..c4758512e7 100644 --- a/infra/config/realms.cfg +++ b/infra/config/realms.cfg @@ -122,7 +122,7 @@ realms { values: "Perf Android32 (R Pixel5)" values: "Perf Android64 (R Pixel5)" values: "Perf Fuchsia" - values: "Perf Linux Bionic" + values: "Perf Linux" values: "Perf Mac 11" values: "Perf Mac M1 Arm64 12" values: "Perf Win 10" diff --git a/infra/specs/client.webrtc.json b/infra/specs/client.webrtc.json index 31cb220344..98fc3b55fb 100644 --- a/infra/specs/client.webrtc.json +++ b/infra/specs/client.webrtc.json @@ -2341,7 +2341,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -2358,7 +2358,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -2375,7 +2375,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -2392,7 +2392,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -2409,7 +2409,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -2427,7 +2427,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -2445,7 +2445,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -2463,7 +2463,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -2480,7 +2480,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -2497,7 +2497,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -2514,7 +2514,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -2531,7 +2531,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -2549,7 +2549,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "shared_screencast_stream_test", @@ -2566,7 +2566,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -2583,7 +2583,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -2601,7 +2601,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -2618,7 +2618,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -2635,7 +2635,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -2652,7 +2652,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -2670,7 +2670,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -2687,7 +2687,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -2708,7 +2708,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -2725,7 +2725,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -2742,7 +2742,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -2759,7 +2759,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -2776,7 +2776,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -2794,7 +2794,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -2812,7 +2812,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -2830,7 +2830,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -2847,7 +2847,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -2864,7 +2864,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -2881,7 +2881,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -2898,7 +2898,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -2916,7 +2916,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -2933,7 +2933,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -2951,7 +2951,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -2968,7 +2968,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -2985,7 +2985,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -3002,7 +3002,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3020,7 +3020,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -3037,7 +3037,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -3058,7 +3058,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -3075,7 +3075,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -3092,7 +3092,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -3109,7 +3109,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -3126,7 +3126,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -3144,7 +3144,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -3162,7 +3162,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3180,7 +3180,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -3197,7 +3197,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -3214,7 +3214,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -3231,7 +3231,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -3248,7 +3248,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -3266,7 +3266,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -3283,7 +3283,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3301,7 +3301,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -3318,7 +3318,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -3335,7 +3335,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -3352,7 +3352,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3370,7 +3370,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -3387,7 +3387,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -3408,7 +3408,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -3425,7 +3425,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -3442,7 +3442,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -3459,7 +3459,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -3476,7 +3476,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -3494,7 +3494,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -3512,7 +3512,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3530,7 +3530,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -3547,7 +3547,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -3564,7 +3564,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -3581,7 +3581,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -3598,7 +3598,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -3616,7 +3616,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "shared_screencast_stream_test", @@ -3633,7 +3633,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -3650,7 +3650,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3668,7 +3668,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -3685,7 +3685,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -3702,7 +3702,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -3719,7 +3719,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3737,7 +3737,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -3754,7 +3754,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -3775,7 +3775,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -3792,7 +3792,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -3809,7 +3809,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -3826,7 +3826,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -3843,7 +3843,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -3861,7 +3861,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -3879,7 +3879,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -3897,7 +3897,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -3914,7 +3914,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -3931,7 +3931,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -3948,7 +3948,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -3965,7 +3965,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -3983,7 +3983,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "shared_screencast_stream_test", @@ -4000,7 +4000,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -4017,7 +4017,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -4035,7 +4035,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -4052,7 +4052,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -4069,7 +4069,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -4086,7 +4086,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -4104,7 +4104,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -4121,7 +4121,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -8463,7 +8463,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8512,7 +8512,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8561,7 +8561,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8609,7 +8609,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8657,7 +8657,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8705,7 +8705,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8753,7 +8753,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8801,7 +8801,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8849,7 +8849,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8897,7 +8897,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8945,7 +8945,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -8993,7 +8993,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9041,7 +9041,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9089,7 +9089,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9137,7 +9137,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9185,7 +9185,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9234,7 +9234,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9283,7 +9283,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9332,7 +9332,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9382,7 +9382,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9432,7 +9432,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9482,7 +9482,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9530,7 +9530,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9578,7 +9578,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9626,7 +9626,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9674,7 +9674,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9722,7 +9722,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9770,7 +9770,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9818,7 +9818,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9866,7 +9866,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9914,7 +9914,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -9962,7 +9962,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10010,7 +10010,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10059,7 +10059,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10108,7 +10108,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10157,7 +10157,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10206,7 +10206,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10255,7 +10255,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10304,7 +10304,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10352,7 +10352,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10402,7 +10402,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10452,7 +10452,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10502,7 +10502,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10550,7 +10550,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10598,7 +10598,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10646,7 +10646,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10694,7 +10694,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10742,7 +10742,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10790,7 +10790,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10838,7 +10838,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10886,7 +10886,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10934,7 +10934,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -10983,7 +10983,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -11032,7 +11032,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -11081,7 +11081,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -11129,7 +11129,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -11177,7 +11177,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -11225,7 +11225,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -11273,7 +11273,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -11321,7 +11321,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { diff --git a/infra/specs/client.webrtc.perf.json b/infra/specs/client.webrtc.perf.json index 6015ac0407..390ba9d724 100644 --- a/infra/specs/client.webrtc.perf.json +++ b/infra/specs/client.webrtc.perf.json @@ -218,7 +218,7 @@ } ] }, - "Perf Linux Bionic": { + "Perf Linux": { "isolated_scripts": [ { "args": [ @@ -239,7 +239,7 @@ "swarming": { "dimensions": { "gce": "0", - "os": "Ubuntu-18.04", + "os": "Ubuntu-22.04", "pool": "WebRTC-perf" }, "expiration": 10800, @@ -272,7 +272,7 @@ "swarming": { "dimensions": { "gce": "0", - "os": "Ubuntu-18.04", + "os": "Ubuntu-22.04", "pool": "WebRTC-perf" }, "expiration": 10800, diff --git a/infra/specs/internal.client.webrtc.json b/infra/specs/internal.client.webrtc.json index 87ae7fc306..7c85cacc4c 100644 --- a/infra/specs/internal.client.webrtc.json +++ b/infra/specs/internal.client.webrtc.json @@ -24,7 +24,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -63,7 +63,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -103,7 +103,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -145,7 +145,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -185,7 +185,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -224,7 +224,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -263,7 +263,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -302,7 +302,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -341,7 +341,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -380,7 +380,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -419,7 +419,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -469,7 +469,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -516,7 +516,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -555,7 +555,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -595,7 +595,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -637,7 +637,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -677,7 +677,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -716,7 +716,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -755,7 +755,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -794,7 +794,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -833,7 +833,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -872,7 +872,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -911,7 +911,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { diff --git a/infra/specs/mixins.pyl b/infra/specs/mixins.pyl index 3bba887503..69577b738a 100644 --- a/infra/specs/mixins.pyl +++ b/infra/specs/mixins.pyl @@ -115,20 +115,6 @@ 'expiration': 10800 } }, - 'linux-bionic': { - 'swarming': { - 'dimensions': { - 'os': 'Ubuntu-18.04' - } - } - }, - 'linux-focal': { - 'swarming': { - 'dimensions': { - 'os': 'Ubuntu-20.04' - } - } - }, 'linux-jammy': { 'fail_if_unused': False, 'swarming': { @@ -183,7 +169,7 @@ 'location': '.', 'revision': - 'git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d' + 'git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab' }] } }, diff --git a/infra/specs/mixins_webrtc.pyl b/infra/specs/mixins_webrtc.pyl index c9fcc40948..8daaddf338 100644 --- a/infra/specs/mixins_webrtc.pyl +++ b/infra/specs/mixins_webrtc.pyl @@ -93,6 +93,9 @@ ], }, }, + 'isolate_profile_data': { + 'isolate_profile_data': True + }, 'limited-capacity': { # Sometimes there are multiple tests that can be run only on one machine. # We need to increase timeouts so the tests dont expire before the machine is freed. @@ -101,13 +104,6 @@ 'expiration': 10800, }, }, - 'linux-focal': { - 'swarming': { - 'dimensions': { - 'os': 'Ubuntu-20.04' - } - } - }, 'mac-m1-cpu': { 'swarming': { 'dimensions': { @@ -138,13 +134,6 @@ } } }, - 'linux-bionic': { - 'swarming': { - 'dimensions': { - 'os': 'Ubuntu-18.04', - } - } - }, 'perf-output': { 'args': [ '--isolated-script-test-perf-output=${ISOLATED_OUTDIR}/perftest-output.pb', diff --git a/infra/specs/tryserver.webrtc.json b/infra/specs/tryserver.webrtc.json index 02f0450505..c24ce3b452 100644 --- a/infra/specs/tryserver.webrtc.json +++ b/infra/specs/tryserver.webrtc.json @@ -2534,7 +2534,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2583,7 +2583,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2632,7 +2632,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2680,7 +2680,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2728,7 +2728,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2776,7 +2776,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2824,7 +2824,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2872,7 +2872,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2920,7 +2920,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -2968,7 +2968,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3016,7 +3016,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3064,7 +3064,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3112,7 +3112,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3160,7 +3160,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3208,7 +3208,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3256,7 +3256,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3305,7 +3305,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3354,7 +3354,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3403,7 +3403,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3453,7 +3453,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3503,7 +3503,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3553,7 +3553,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3601,7 +3601,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3649,7 +3649,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3697,7 +3697,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3745,7 +3745,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3793,7 +3793,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3841,7 +3841,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3889,7 +3889,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3937,7 +3937,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -3985,7 +3985,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4033,7 +4033,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4081,7 +4081,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4130,7 +4130,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4179,7 +4179,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4228,7 +4228,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4277,7 +4277,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4326,7 +4326,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4375,7 +4375,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4423,7 +4423,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4473,7 +4473,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4523,7 +4523,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4573,7 +4573,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4621,7 +4621,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4669,7 +4669,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4717,7 +4717,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4765,7 +4765,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4813,7 +4813,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4861,7 +4861,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4909,7 +4909,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -4957,7 +4957,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5005,7 +5005,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5054,7 +5054,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5103,7 +5103,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5152,7 +5152,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5200,7 +5200,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5248,7 +5248,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5296,7 +5296,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5344,7 +5344,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5392,7 +5392,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:a18b7d95d26f3c6bf9591978b19cf0ca8268ac7d" + "revision": "git_revision:4c7290150d1c360cecc6a93c0214dc531585c3ab" } ], "dimensions": { @@ -5431,7 +5431,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -5448,7 +5448,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -5465,7 +5465,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -5482,7 +5482,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -5499,7 +5499,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -5517,7 +5517,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -5535,7 +5535,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -5553,7 +5553,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -5570,7 +5570,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -5587,7 +5587,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -5604,7 +5604,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -5621,7 +5621,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -5639,7 +5639,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "shared_screencast_stream_test", @@ -5656,7 +5656,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -5673,7 +5673,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -5691,7 +5691,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -5708,7 +5708,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -5725,7 +5725,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -5742,7 +5742,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -5760,7 +5760,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -5777,7 +5777,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -6630,7 +6630,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -6647,7 +6647,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -6664,7 +6664,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -6681,7 +6681,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -6698,7 +6698,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -6716,7 +6716,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -6734,7 +6734,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -6752,7 +6752,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -6769,7 +6769,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -6786,7 +6786,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -6803,7 +6803,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -6820,7 +6820,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -6838,7 +6838,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -6855,7 +6855,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -6873,7 +6873,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -6890,7 +6890,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -6907,7 +6907,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -6924,7 +6924,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -6942,7 +6942,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -6959,7 +6959,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -7393,7 +7393,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -7410,7 +7410,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -7427,7 +7427,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -7444,7 +7444,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -7461,7 +7461,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -7479,7 +7479,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -7497,7 +7497,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -7515,7 +7515,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -7532,7 +7532,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -7549,7 +7549,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -7566,7 +7566,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -7583,7 +7583,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -7601,7 +7601,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -7618,7 +7618,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -7636,7 +7636,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -7653,7 +7653,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -7670,7 +7670,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -7687,7 +7687,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -7705,7 +7705,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -7722,7 +7722,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -7743,7 +7743,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -7760,7 +7760,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -7777,7 +7777,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -7794,7 +7794,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -7811,7 +7811,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -7829,7 +7829,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -7847,7 +7847,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -7865,7 +7865,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -7882,7 +7882,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -7899,7 +7899,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -7916,7 +7916,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -7933,7 +7933,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -7951,7 +7951,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "shared_screencast_stream_test", @@ -7968,7 +7968,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -7985,7 +7985,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -8003,7 +8003,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -8020,7 +8020,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -8037,7 +8037,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -8054,7 +8054,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -8072,7 +8072,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -8089,7 +8089,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", @@ -8110,7 +8110,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "audio_decoder_unittests", @@ -8127,7 +8127,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_audio_unittests", @@ -8144,7 +8144,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "common_video_unittests", @@ -8161,7 +8161,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "dcsctp_unittests", @@ -8178,7 +8178,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 2 }, @@ -8196,7 +8196,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -8214,7 +8214,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -8232,7 +8232,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_media_unittests", @@ -8249,7 +8249,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_p2p_unittests", @@ -8266,7 +8266,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_pc_unittests", @@ -8283,7 +8283,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "rtc_stats_unittests", @@ -8300,7 +8300,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 6 }, @@ -8318,7 +8318,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "shared_screencast_stream_test", @@ -8335,7 +8335,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "slow_peer_connection_unittests", @@ -8352,7 +8352,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -8370,7 +8370,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "system_wrappers_unittests", @@ -8387,7 +8387,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "test_support_unittests", @@ -8404,7 +8404,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "tools_unittests", @@ -8421,7 +8421,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" }, "shards": 4 }, @@ -8439,7 +8439,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "voip_unittests", @@ -8456,7 +8456,7 @@ "swarming": { "dimensions": { "cpu": "x86-64", - "os": "Ubuntu-20.04" + "os": "Ubuntu-22.04" } }, "test": "webrtc_nonparallel_tests", diff --git a/infra/specs/waterfalls.pyl b/infra/specs/waterfalls.pyl index dacac43947..e371ca2e7a 100644 --- a/infra/specs/waterfalls.pyl +++ b/infra/specs/waterfalls.pyl @@ -86,14 +86,14 @@ }, 'Linux Asan': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { 'isolated_scripts': 'linux_tests', }, }, 'Linux MSan': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { # TODO(crbug.com/webrtc/14568): Using 'linux_tests' # fails on "MemorySanitizer: use-of-uninitialized-value in @@ -103,7 +103,7 @@ }, 'Linux Tsan v2': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { # TODO(crbug.com/webrtc/14568): Using 'linux_tests' # fails on "ThreadSanitizer: data race on vptr (ctor/dtor vs @@ -113,14 +113,14 @@ }, 'Linux UBSan': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { 'isolated_scripts': 'linux_tests', }, }, 'Linux UBSan vptr': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { 'isolated_scripts': 'linux_tests', }, @@ -272,12 +272,11 @@ 'isolated_scripts': 'perf_tests', } }, - 'Perf Linux Bionic': { + 'Perf Linux': { 'os_type': 'linux', 'mixins': [ - 'linux-bionic', 'perf-pool', 'timeout-3h', - 'resultdb-gtest-json-format' + 'linux-jammy', 'perf-pool', 'timeout-3h', 'resultdb-gtest-json-format' ], 'test_suites': { 'isolated_scripts': 'perf_tests_save_worst_frame', @@ -441,7 +440,7 @@ 'iwyu_verifier': {}, 'linux_asan': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { 'isolated_scripts': 'linux_tests', }, @@ -480,7 +479,7 @@ }, 'linux_msan': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { # TODO(crbug.com/webrtc/14568): Using 'linux_tests' # fails on "MemorySanitizer: use-of-uninitialized-value in @@ -497,7 +496,7 @@ }, 'linux_tsan2': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { # TODO(crbug.com/webrtc/14568): Using 'linux_tests' # fails on "ThreadSanitizer: data race on vptr (ctor/dtor vs @@ -507,14 +506,14 @@ }, 'linux_ubsan': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { 'isolated_scripts': 'linux_tests', }, }, 'linux_ubsan_vptr': { 'os_type': 'linux', - 'mixins': ['linux-focal', 'x86-64', 'resultdb-json-format'], + 'mixins': ['linux-jammy', 'x86-64', 'resultdb-json-format'], 'test_suites': { 'isolated_scripts': 'linux_tests', }, diff --git a/logging/BUILD.gn b/logging/BUILD.gn index 65fe4b69f5..85d3db59dc 100644 --- a/logging/BUILD.gn +++ b/logging/BUILD.gn @@ -377,7 +377,7 @@ rtc_library("rtc_event_log_impl_encoder") { "../api:array_view", "../api:candidate", "../api:dtls_transport_interface", - "../api/rtc_event_log:rtc_event_log", + "../api/rtc_event_log", "../api/transport:bandwidth_usage", "../api/units:timestamp", "../api/video:video_frame", @@ -600,6 +600,7 @@ if (rtc_enable_protobuf) { "../api:array_view", "../api:candidate", "../api:dtls_transport_interface", + "../api:field_trials", "../api:field_trials_view", "../api:libjingle_logging_api", "../api:rtc_event_log_output_file", @@ -626,7 +627,7 @@ if (rtc_enable_protobuf) { "../rtc_base:safe_conversions", "../rtc_base:timeutils", "../system_wrappers", - "../test:explicit_key_value_config", + "../test:create_test_field_trials", "../test:fileutils", "../test:test_support", "../test/logging:log_writer", diff --git a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc index 9dba1076cb..eaa75331c8 100644 --- a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc +++ b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc @@ -21,7 +21,7 @@ #include "logging/rtc_event_log/encoder/delta_encoding.h" #include "logging/rtc_event_log/encoder/optional_blob_encoding.h" #include "logging/rtc_event_log/events/rtc_event_log_parse_status.h" -#include "logging/rtc_event_log/rtc_event_log2_proto_include.h" +#include "logging/rtc_event_log/rtc_event_log2_proto_include.h" // IWYU pragma: keep #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h index 9c914eb0f2..80f35f22f6 100644 --- a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h +++ b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h @@ -18,7 +18,7 @@ #include "api/array_view.h" #include "logging/rtc_event_log/events/rtc_event_log_parse_status.h" -#include "logging/rtc_event_log/rtc_event_log2_proto_include.h" +#include "logging/rtc_event_log/rtc_event_log2_proto_include.h" // IWYU pragma: keep namespace webrtc { diff --git a/logging/rtc_event_log/dependency_descriptor_encoder_decoder_unittest.cc b/logging/rtc_event_log/dependency_descriptor_encoder_decoder_unittest.cc index 90f608e4d5..931b24eef7 100644 --- a/logging/rtc_event_log/dependency_descriptor_encoder_decoder_unittest.cc +++ b/logging/rtc_event_log/dependency_descriptor_encoder_decoder_unittest.cc @@ -16,7 +16,7 @@ #include "logging/rtc_event_log/encoder/delta_encoding.h" #include "logging/rtc_event_log/encoder/optional_blob_encoding.h" -#include "logging/rtc_event_log/rtc_event_log2_proto_include.h" +#include "logging/rtc_event_log/rtc_event_log2_proto_include.h" // IWYU pragma: keep #include "rtc_base/checks.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc index 05da112b0f..795780b9b5 100644 --- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc +++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc @@ -10,9 +10,8 @@ #include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h" -#include - #include +#include #include #include #include diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc index a83dc382d0..d97cfdf4c9 100644 --- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc +++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc @@ -23,6 +23,7 @@ #include #include +#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" @@ -70,13 +71,11 @@ #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/random.h" #include "rtc_base/time_utils.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" namespace webrtc { -using test::ExplicitKeyValueConfig; - class RtcEventLogEncoderTest : public ::testing::TestWithParam< std::tuple> { @@ -92,7 +91,7 @@ class RtcEventLogEncoderTest ~RtcEventLogEncoderTest() override = default; std::unique_ptr CreateEncoder( - const FieldTrialsView& field_trials = ExplicitKeyValueConfig("")) { + const FieldTrialsView& field_trials = CreateTestFieldTrials()) { std::unique_ptr encoder; switch (encoding_type_) { case RtcEventLog::EncodingType::Legacy: @@ -1377,7 +1376,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtpPacketOutgoing) { TEST_P(RtcEventLogEncoderTest, RtcEventRtpPacketIncomingNoDependencyDescriptor) { - ExplicitKeyValueConfig no_dd( + FieldTrials no_dd = CreateTestFieldTrials( "WebRTC-RtcEventLogEncodeDependencyDescriptor/Disabled/"); std::unique_ptr encoder = CreateEncoder(no_dd); verifier_.ExpectDependencyDescriptorExtensionIsSet(false); @@ -1386,7 +1385,7 @@ TEST_P(RtcEventLogEncoderTest, TEST_P(RtcEventLogEncoderTest, RtcEventRtpPacketOutgoingNoDependencyDescriptor) { - ExplicitKeyValueConfig no_dd( + FieldTrials no_dd = CreateTestFieldTrials( "WebRTC-RtcEventLogEncodeDependencyDescriptor/Disabled/"); std::unique_ptr encoder = CreateEncoder(no_dd); verifier_.ExpectDependencyDescriptorExtensionIsSet(false); @@ -1447,7 +1446,7 @@ class RtcEventLogEncoderSimpleTest break; case RtcEventLog::EncodingType::NewFormat: encoder_ = std::make_unique( - ExplicitKeyValueConfig("")); + CreateTestFieldTrials()); break; case RtcEventLog::EncodingType::ProtoFree: encoder_ = std::make_unique(); diff --git a/logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.cc b/logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.cc index b30461c969..a501f130dd 100644 --- a/logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.cc +++ b/logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.cc @@ -10,7 +10,7 @@ #include "logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.h" -#include +#include namespace webrtc { diff --git a/logging/rtc_event_log/fake_rtc_event_log_factory.h b/logging/rtc_event_log/fake_rtc_event_log_factory.h index 71489cc44a..e73411c13a 100644 --- a/logging/rtc_event_log/fake_rtc_event_log_factory.h +++ b/logging/rtc_event_log/fake_rtc_event_log_factory.h @@ -15,6 +15,7 @@ #include "absl/base/nullability.h" #include "api/environment/environment.h" +#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "logging/rtc_event_log/fake_rtc_event_log.h" diff --git a/logging/rtc_event_log/rtc_event_log2rtp_dump.cc b/logging/rtc_event_log/rtc_event_log2rtp_dump.cc index facffeea02..67b136e4c8 100644 --- a/logging/rtc_event_log/rtc_event_log2rtp_dump.cc +++ b/logging/rtc_event_log/rtc_event_log2rtp_dump.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include +#include #include #include #include diff --git a/logging/rtc_event_log/rtc_event_log_impl.cc b/logging/rtc_event_log/rtc_event_log_impl.cc index aece126bc4..da35199507 100644 --- a/logging/rtc_event_log/rtc_event_log_impl.cc +++ b/logging/rtc_event_log/rtc_event_log_impl.cc @@ -26,6 +26,7 @@ #include "api/rtc_event_log_output.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" +#include "api/task_queue/task_queue_factory.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h" diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index 61ab4f5ec9..35492d169b 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -10,10 +10,9 @@ #include "logging/rtc_event_log/rtc_event_log_parser.h" -#include -#include - #include +#include +#include #include #include #include @@ -27,7 +26,6 @@ #include "api/candidate.h" #include "api/dtls_transport_interface.h" #include "api/rtc_event_log/rtc_event.h" -#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" #include "api/transport/bandwidth_usage.h" @@ -87,6 +85,7 @@ #include "modules/rtp_rtcp/source/rtcp_packet/pli.h" #include "modules/rtp_rtcp/source/rtcp_packet/psfb.h" #include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" +#include "modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" #include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h" #include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" diff --git a/logging/rtc_event_log/rtc_event_log_unittest.cc b/logging/rtc_event_log/rtc_event_log_unittest.cc index a181a85891..ddcb83a2f5 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -21,8 +21,8 @@ #include #include -#include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -61,7 +61,7 @@ #include "rtc_base/fake_clock.h" #include "rtc_base/random.h" #include "rtc_base/time_utils.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" #include "test/logging/log_writer.h" #include "test/logging/memory_log_writer.h" @@ -71,8 +71,6 @@ namespace webrtc { namespace { -using test::ExplicitKeyValueConfig; - struct EventCounts { size_t audio_send_streams = 0; size_t audio_recv_streams = 0; @@ -124,11 +122,9 @@ std::unique_ptr CreateFieldTrialsFor( RtcEventLog::EncodingType encoding_type) { switch (encoding_type) { case RtcEventLog::EncodingType::Legacy: - return std::make_unique( - "WebRTC-RtcEventLogNewFormat/Disabled/"); + return CreateTestFieldTrialsPtr("WebRTC-RtcEventLogNewFormat/Disabled/"); case RtcEventLog::EncodingType::NewFormat: - return std::make_unique( - "WebRTC-RtcEventLogNewFormat/Enabled/"); + return CreateTestFieldTrialsPtr("WebRTC-RtcEventLogNewFormat/Enabled/"); case RtcEventLog::EncodingType::ProtoFree: RTC_CHECK(false); return nullptr; diff --git a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc index 0f5b265182..b2e3aa42de 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc @@ -10,10 +10,9 @@ #include "logging/rtc_event_log/rtc_event_log_unittest_helper.h" -#include // memcmp - #include #include +#include #include #include #include diff --git a/logging/rtc_event_log/rtc_event_processor_unittest.cc b/logging/rtc_event_log/rtc_event_processor_unittest.cc index 2427f15c1a..59d6581717 100644 --- a/logging/rtc_event_log/rtc_event_processor_unittest.cc +++ b/logging/rtc_event_log/rtc_event_processor_unittest.cc @@ -10,8 +10,7 @@ #include "logging/rtc_event_log/rtc_event_processor.h" -#include - +#include #include #include #include diff --git a/media/BUILD.gn b/media/BUILD.gn index 203a55ba9d..98a675a7c9 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -359,6 +359,7 @@ rtc_source_set("media_channel") { "../rtc_base/network:sent_packet", "../video/config:encoder_config", "//third_party/abseil-cpp/absl/functional:any_invocable", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -725,8 +726,8 @@ if (rtc_build_dcsctp) { "../api:rtc_error", "../api:sequence_checker", "../api/environment", + "../api/task_queue", "../api/task_queue:pending_task_safety_flag", - "../api/task_queue:task_queue", "../api/transport:datagram_transport_interface", "../net/dcsctp/public:factory", "../net/dcsctp/public:socket", @@ -735,6 +736,7 @@ if (rtc_build_dcsctp) { "../net/dcsctp/timer:task_queue_timeout", "../p2p:dtls_transport_internal", "../p2p:packet_transport_internal", + "../rtc_base:async_packet_socket", "../rtc_base:checks", "../rtc_base:copy_on_write_buffer", "../rtc_base:event_tracer", @@ -746,9 +748,9 @@ if (rtc_build_dcsctp) { "../rtc_base:threading", "../rtc_base/containers:flat_map", "../rtc_base/network:received_packet", - "../rtc_base/third_party/sigslot:sigslot", + "../rtc_base/third_party/sigslot", "../system_wrappers", - "//third_party/abseil-cpp/absl/strings:strings", + "//third_party/abseil-cpp/absl/strings", ] } } diff --git a/media/base/adapted_video_track_source.h b/media/base/adapted_video_track_source.h index a6ef9e5fcf..b25439bc89 100644 --- a/media/base/adapted_video_track_source.h +++ b/media/base/adapted_video_track_source.h @@ -104,12 +104,5 @@ class RTC_EXPORT AdaptedVideoTrackSource } // 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::AdaptedVideoTrackSource; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_ADAPTED_VIDEO_TRACK_SOURCE_H_ diff --git a/media/base/audio_source.h b/media/base/audio_source.h index f7a7f50060..04a7d19dfa 100644 --- a/media/base/audio_source.h +++ b/media/base/audio_source.h @@ -55,12 +55,5 @@ class AudioSource { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::AudioSource; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_AUDIO_SOURCE_H_ diff --git a/media/base/codec.h b/media/base/codec.h index 694589dd14..eef9665263 100644 --- a/media/base/codec.h +++ b/media/base/codec.h @@ -265,97 +265,5 @@ RTC_EXPORT void AddH264ConstrainedBaselineProfileToSupportedFormats( std::vector* supported_formats); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { - -using FeedbackParam ABSL_DEPRECATE_AND_INLINE() = webrtc::FeedbackParam; -using FeedbackParams ABSL_DEPRECATE_AND_INLINE() = webrtc::FeedbackParams; -using Codec ABSL_DEPRECATE_AND_INLINE() = webrtc::Codec; -using Codecs ABSL_DEPRECATE_AND_INLINE() = webrtc::Codecs; - -// TODO(webrtc:15214): Compatibility names, to be migrated away and removed. -using VideoCodec ABSL_DEPRECATE_AND_INLINE() = webrtc::Codec; -using AudioCodec ABSL_DEPRECATE_AND_INLINE() = webrtc::Codec; -using VideoCodecs ABSL_DEPRECATE_AND_INLINE() = webrtc::Codecs; -using AudioCodecs ABSL_DEPRECATE_AND_INLINE() = webrtc::Codecs; -using ::webrtc::AddH264ConstrainedBaselineProfileToSupportedFormats; - -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateAudioCodec(int id, - const std::string& name, - int clockrate, - size_t channels) { - return webrtc::CreateAudioCodec(id, name, clockrate, channels); -} -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateAudioCodec(const webrtc::SdpAudioFormat& c) { - return webrtc::CreateAudioCodec(c); -} -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateAudioRtxCodec(int rtx_payload_type, - int associated_payload_type) { - return webrtc::CreateAudioRtxCodec(rtx_payload_type, associated_payload_type); -} -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateVideoCodec(const std::string& name) { - return webrtc::CreateVideoCodec(name); -} -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateVideoCodec(int id, const std::string& name) { - return webrtc::CreateVideoCodec(id, name); -} -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateVideoCodec(const webrtc::SdpVideoFormat& c) { - return webrtc::CreateVideoCodec(c); -} -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateVideoCodec(int id, const webrtc::SdpVideoFormat& c) { - return webrtc::CreateVideoCodec(id, c); -} -ABSL_DEPRECATE_AND_INLINE() -inline webrtc::Codec CreateVideoRtxCodec(int rtx_payload_type, - int associated_payload_type) { - return webrtc::CreateVideoRtxCodec(rtx_payload_type, associated_payload_type); -} - -ABSL_DEPRECATE_AND_INLINE() -inline const webrtc::Codec* FindCodecById( - const std::vector& codecs, - int payload_type) { - return webrtc::FindCodecById(codecs, payload_type); -} - -ABSL_DEPRECATE_AND_INLINE() -inline bool HasLntf(const webrtc::Codec& codec) { - return webrtc::HasLntf(codec); -} -ABSL_DEPRECATE_AND_INLINE() -inline bool HasNack(const webrtc::Codec& codec) { - return webrtc::HasNack(codec); -} -ABSL_DEPRECATE_AND_INLINE() -inline bool HasRemb(const webrtc::Codec& codec) { - return webrtc::HasRemb(codec); -} -ABSL_DEPRECATE_AND_INLINE() inline bool HasRrtr(const webrtc::Codec& codec) { - return webrtc::HasRrtr(codec); -} -ABSL_DEPRECATE_AND_INLINE() -inline const webrtc::Codec* FindMatchingVideoCodec( - const webrtc::Codecs& supported_codecs, - const webrtc::Codec& codec) { - return webrtc::FindMatchingVideoCodec(supported_codecs, codec); -} -ABSL_DEPRECATE_AND_INLINE() -inline std::vector FindAllMatchingCodecs( - const webrtc::Codecs& supported_codecs, - const webrtc::Codec& codec) { - return webrtc::FindAllMatchingCodecs(supported_codecs, codec); -} - -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_CODEC_H_ diff --git a/media/base/codec_comparators.cc b/media/base/codec_comparators.cc index e71c52db26..9da9d4aca5 100644 --- a/media/base/codec_comparators.cc +++ b/media/base/codec_comparators.cc @@ -71,22 +71,12 @@ std::string AV1GetTierOrDefault(const CodecParameterMap& params) { return GetFmtpParameterOrDefault(params, kAv1FmtpTier, "0"); } -bool AV1IsSameTier(const CodecParameterMap& left, - const CodecParameterMap& right) { - return AV1GetTierOrDefault(left) == AV1GetTierOrDefault(right); -} - std::string AV1GetLevelIdxOrDefault(const CodecParameterMap& params) { // If the parameter is not present, it MUST be inferred to be 5 (level 3.1). // https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters return GetFmtpParameterOrDefault(params, kAv1FmtpLevelIdx, "5"); } -bool AV1IsSameLevelIdx(const CodecParameterMap& left, - const CodecParameterMap& right) { - return AV1GetLevelIdxOrDefault(left) == AV1GetLevelIdxOrDefault(right); -} - #ifdef RTC_ENABLE_H265 std::string GetH265TxModeOrDefault(const CodecParameterMap& params) { // If TxMode is not present, a value of "SRST" must be inferred. @@ -117,10 +107,13 @@ bool IsSameCodecSpecific(const std::string& name1, H264IsSamePacketizationMode(params1, params2); if (either_name_matches(kVp9CodecName)) return VP9IsSameProfile(params1, params2); + // https://aomediacodec.github.io/av1-rtp-spec/#723-usage-with-the-sdp-offeranswer-model + // These media configuration parameters are asymmetrical and the answerer + // MAY declare its own media configuration + // TODO(bugs.webrtc.org/396434695): for backward compability we currently + // compare profile. if (either_name_matches(kAv1CodecName)) - return AV1IsSameProfile(params1, params2) && - AV1IsSameTier(params1, params2) && - AV1IsSameLevelIdx(params1, params2); + return AV1IsSameProfile(params1, params2); #ifdef RTC_ENABLE_H265 if (either_name_matches(kH265CodecName)) { return H265IsSameProfile(params1, params2) && diff --git a/media/base/codec_comparators_unittest.cc b/media/base/codec_comparators_unittest.cc index 67b630aebc..2f78042c16 100644 --- a/media/base/codec_comparators_unittest.cc +++ b/media/base/codec_comparators_unittest.cc @@ -425,7 +425,7 @@ TEST(CodecTest, TestVideoCodecMatchesWithDifferentPacketization) { EXPECT_TRUE(c1.Matches(c0)); } -// AV1 codecs compare profile information. +// AV1 codecs do not compare profile information. TEST(CodecTest, TestAV1CodecMatches) { const char kProfile0[] = "0"; const char kProfile1[] = "1"; @@ -469,6 +469,24 @@ TEST(CodecTest, TestAV1CodecMatches) { // AV1 entries with different profiles (0 and 2) are seen as distinct. EXPECT_FALSE(c_profile0.Matches(c_profile2)); EXPECT_FALSE(c_no_profile.Matches(c_profile2)); + + // AV1 entries with same profile and different tier are seen as equal. + Codec c_tier0 = CreateVideoCodec(95, kAv1CodecName); + c_tier0.params[kAv1FmtpProfile] = kProfile0; + c_tier0.params[kAv1FmtpTier] = "0"; + Codec c_tier1 = CreateVideoCodec(95, kAv1CodecName); + c_tier1.params[kAv1FmtpProfile] = kProfile0; + c_tier1.params[kAv1FmtpTier] = "1"; + EXPECT_TRUE(c_tier0.Matches(c_tier1)); + + // AV1 entries with profile and different level are seen as equal. + Codec c_level0 = CreateVideoCodec(95, kAv1CodecName); + c_level0.params[kAv1FmtpProfile] = kProfile0; + c_level0.params[kAv1FmtpLevelIdx] = "0"; + Codec c_level1 = CreateVideoCodec(95, kAv1CodecName); + c_level1.params[kAv1FmtpProfile] = kProfile0; + c_level1.params[kAv1FmtpLevelIdx] = "1"; + EXPECT_TRUE(c_level0.Matches(c_level1)); } // VP9 codecs compare profile information. diff --git a/media/base/codec_list.h b/media/base/codec_list.h index ccfa3ed98b..f78222616f 100644 --- a/media/base/codec_list.h +++ b/media/base/codec_list.h @@ -85,12 +85,5 @@ class CodecList { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CodecList; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_CODEC_LIST_H_ diff --git a/media/base/fake_frame_source.h b/media/base/fake_frame_source.h index 7f3ad561aa..c53227eb13 100644 --- a/media/base/fake_frame_source.h +++ b/media/base/fake_frame_source.h @@ -49,12 +49,5 @@ class FakeFrameSource { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakeFrameSource; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_FAKE_FRAME_SOURCE_H_ diff --git a/media/base/fake_media_engine.h b/media/base/fake_media_engine.h index 8c05e4a797..d1d84fb36e 100644 --- a/media/base/fake_media_engine.h +++ b/media/base/fake_media_engine.h @@ -958,21 +958,5 @@ class FakeMediaEngine : public CompositeMediaEngine { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CompareDtmfInfo; -using ::webrtc::FakeMediaEngine; -using ::webrtc::FakeVideoEngine; -using ::webrtc::FakeVideoMediaReceiveChannel; -using ::webrtc::FakeVideoMediaSendChannel; -using ::webrtc::FakeVoiceEngine; -using ::webrtc::FakeVoiceMediaReceiveChannel; -using ::webrtc::FakeVoiceMediaSendChannel; -using ::webrtc::RtpReceiveChannelHelper; -using ::webrtc::RtpSendChannelHelper; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_FAKE_MEDIA_ENGINE_H_ diff --git a/media/base/fake_network_interface.h b/media/base/fake_network_interface.h index e3b60a1cf7..ea3c43b720 100644 --- a/media/base/fake_network_interface.h +++ b/media/base/fake_network_interface.h @@ -233,12 +233,5 @@ class FakeNetworkInterface : public MediaChannelNetworkInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakeNetworkInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_FAKE_NETWORK_INTERFACE_H_ diff --git a/media/base/fake_rtp.cc b/media/base/fake_rtp.cc index f76600a9cd..7a4ec2f43d 100644 --- a/media/base/fake_rtp.cc +++ b/media/base/fake_rtp.cc @@ -10,9 +10,8 @@ #include "media/base/fake_rtp.h" -#include -#include - +#include +#include #include #include "absl/algorithm/container.h" diff --git a/media/base/fake_video_renderer.h b/media/base/fake_video_renderer.h index 4b0e08eaa7..4cdc666de3 100644 --- a/media/base/fake_video_renderer.h +++ b/media/base/fake_video_renderer.h @@ -68,12 +68,5 @@ class FakeVideoRenderer : public VideoSinkInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakeVideoRenderer; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_FAKE_VIDEO_RENDERER_H_ diff --git a/media/base/media_channel.h b/media/base/media_channel.h index 1a74631f17..6a3463937c 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -23,6 +23,7 @@ #include #include "absl/functional/any_invocable.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio_codecs/audio_encoder.h" @@ -60,7 +61,6 @@ #include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" #include "rtc_base/socket.h" -#include "rtc_base/string_encode.h" #include "rtc_base/strings/string_builder.h" namespace webrtc { @@ -1006,45 +1006,5 @@ class VideoMediaReceiveChannelInterface : public MediaReceiveChannelInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using RtcpParameters = ::webrtc::MediaChannelParameters::RtcpParameters; -using ::webrtc::AudioReceiverParameters; -using ::webrtc::AudioSenderParameter; -using ::webrtc::BandwidthEstimationInfo; -using ::webrtc::kScreencastDefaultFps; -using ::webrtc::MediaChannelNetworkInterface; -using ::webrtc::MediaChannelParameters; -using ::webrtc::MediaReceiveChannelInterface; -using ::webrtc::MediaReceiverInfo; -using ::webrtc::MediaSendChannelInterface; -using ::webrtc::MediaSenderInfo; -using ::webrtc::RtpCodecParametersMap; -using ::webrtc::SenderParameters; -using ::webrtc::SsrcReceiverInfo; -using ::webrtc::SsrcSenderInfo; -using ::webrtc::ToStringIfSet; -using ::webrtc::VectorToString; -using ::webrtc::VideoMediaInfo; -using ::webrtc::VideoMediaReceiveChannelInterface; -using ::webrtc::VideoMediaReceiveInfo; -using ::webrtc::VideoMediaSendChannelInterface; -using ::webrtc::VideoMediaSendInfo; -using ::webrtc::VideoOptions; -using ::webrtc::VideoReceiverInfo; -using ::webrtc::VideoReceiverParameters; -using ::webrtc::VideoSenderInfo; -using ::webrtc::VideoSenderParameters; -using ::webrtc::VoiceMediaInfo; -using ::webrtc::VoiceMediaReceiveChannelInterface; -using ::webrtc::VoiceMediaReceiveInfo; -using ::webrtc::VoiceMediaSendChannelInterface; -using ::webrtc::VoiceMediaSendInfo; -using ::webrtc::VoiceReceiverInfo; -using ::webrtc::VoiceSenderInfo; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_MEDIA_CHANNEL_H_ diff --git a/media/base/media_config.h b/media/base/media_config.h index bb727b8e74..5b1f25e3d3 100644 --- a/media/base/media_config.h +++ b/media/base/media_config.h @@ -106,12 +106,5 @@ struct MediaConfig { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MediaConfig; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_MEDIA_CONFIG_H_ diff --git a/media/base/media_constants.h b/media/base/media_constants.h index a7af2cc263..44918ac904 100644 --- a/media/base/media_constants.h +++ b/media/base/media_constants.h @@ -169,107 +169,5 @@ extern const char kApplicationSpecificBandwidth[]; extern const char kTransportSpecificBandwidth[]; } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::kApplicationSpecificBandwidth; -using ::webrtc::kAv1CodecName; -using ::webrtc::kAv1FmtpLevelIdx; -using ::webrtc::kAv1FmtpProfile; -using ::webrtc::kAv1FmtpTier; -using ::webrtc::kCnCodecName; -using ::webrtc::kCodecParamAssociatedCodecName; -using ::webrtc::kCodecParamAssociatedPayloadType; -using ::webrtc::kCodecParamCbr; -using ::webrtc::kCodecParamMaxAverageBitrate; -using ::webrtc::kCodecParamMaxBitrate; -using ::webrtc::kCodecParamMaxPlaybackRate; -using ::webrtc::kCodecParamMaxPTime; -using ::webrtc::kCodecParamMaxQuantization; -using ::webrtc::kCodecParamMinBitrate; -using ::webrtc::kCodecParamMinPTime; -using ::webrtc::kCodecParamNotInNameValueFormat; -using ::webrtc::kCodecParamPerLayerPictureLossIndication; -using ::webrtc::kCodecParamPTime; -using ::webrtc::kCodecParamRtxTime; -using ::webrtc::kCodecParamSPropStereo; -using ::webrtc::kCodecParamStartBitrate; -using ::webrtc::kCodecParamStereo; -using ::webrtc::kCodecParamUseDtx; -using ::webrtc::kCodecParamUseInbandFec; -using ::webrtc::kComfortNoiseCodecName; -using ::webrtc::kConferenceDefaultNumTemporalLayers; -using ::webrtc::kConferenceMaxNumSpatialLayers; -using ::webrtc::kConferenceMaxNumTemporalLayers; -using ::webrtc::kDefaultVideoMaxFramerate; -using ::webrtc::kDefaultVideoMaxQpAv1; -using ::webrtc::kDefaultVideoMaxQpH26x; -using ::webrtc::kDefaultVideoMaxQpVpx; -using ::webrtc::kDtmfCodecName; -using ::webrtc::kFlexfecCodecName; -using ::webrtc::kFlexfecFmtpRepairWindow; -using ::webrtc::kG722CodecName; -using ::webrtc::kH264CodecName; -using ::webrtc::kH264FmtpLevelAsymmetryAllowed; -using ::webrtc::kH264FmtpPacketizationMode; -using ::webrtc::kH264FmtpProfileLevelId; -using ::webrtc::kH264FmtpSpropParameterSets; -using ::webrtc::kH264FmtpSpsPpsIdrInKeyframe; -using ::webrtc::kH264ProfileLevelConstrainedBaseline; -using ::webrtc::kH264ProfileLevelConstrainedHigh; -using ::webrtc::kH265CodecName; -using ::webrtc::kH265FmtpInteropConstraints; -using ::webrtc::kH265FmtpLevelId; -using ::webrtc::kH265FmtpProfileCompatibilityIndicator; -using ::webrtc::kH265FmtpProfileId; -using ::webrtc::kH265FmtpProfileSpace; -using ::webrtc::kH265FmtpTierFlag; -using ::webrtc::kH265FmtpTxMode; -using ::webrtc::kHighSystemCpuThreshold; -using ::webrtc::kL16CodecName; -using ::webrtc::kLowSystemCpuThreshold; -using ::webrtc::kMultiplexCodecName; -using ::webrtc::kOpusCodecName; -using ::webrtc::kOpusDefaultMaxPlaybackRate; -using ::webrtc::kOpusDefaultMaxPTime; -using ::webrtc::kOpusDefaultMinPTime; -using ::webrtc::kOpusDefaultPTime; -using ::webrtc::kOpusDefaultSPropStereo; -using ::webrtc::kOpusDefaultStereo; -using ::webrtc::kOpusDefaultUseDtx; -using ::webrtc::kOpusDefaultUseInbandFec; -using ::webrtc::kPacketizationParamRaw; -using ::webrtc::kParamValueEmpty; -using ::webrtc::kParamValueTrue; -using ::webrtc::kPcmaCodecName; -using ::webrtc::kPcmuCodecName; -using ::webrtc::kPreferredMaxPTime; -using ::webrtc::kPreferredMinPTime; -using ::webrtc::kPreferredSPropStereo; -using ::webrtc::kPreferredStereo; -using ::webrtc::kPreferredUseInbandFec; -using ::webrtc::kProcessCpuThreshold; -using ::webrtc::kRedCodecName; -using ::webrtc::kRtcpFbCcmParamFir; -using ::webrtc::kRtcpFbNackParamPli; -using ::webrtc::kRtcpFbParamCcm; -using ::webrtc::kRtcpFbParamLntf; -using ::webrtc::kRtcpFbParamNack; -using ::webrtc::kRtcpFbParamRemb; -using ::webrtc::kRtcpFbParamRrtr; -using ::webrtc::kRtcpFbParamTransportCc; -using ::webrtc::kRtxCodecName; -using ::webrtc::kTransportSpecificBandwidth; -using ::webrtc::kUlpfecCodecName; -using ::webrtc::kVideoCodecClockrate; -using ::webrtc::kVideoMtu; -using ::webrtc::kVideoRtpRecvBufferSize; -using ::webrtc::kVideoRtpSendBufferSize; -using ::webrtc::kVp8CodecName; -using ::webrtc::kVp9CodecName; -using ::webrtc::kVP9ProfileId; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_MEDIA_CONSTANTS_H_ diff --git a/media/base/media_engine.cc b/media/base/media_engine.cc index b81a8f4dd4..bdcad2a1ca 100644 --- a/media/base/media_engine.cc +++ b/media/base/media_engine.cc @@ -10,8 +10,7 @@ #include "media/base/media_engine.h" -#include - +#include #include #include #include @@ -322,19 +321,19 @@ bool CompositeMediaEngine::Init() { } VoiceEngineInterface& CompositeMediaEngine::voice() { - return *voice_engine_.get(); + return *voice_engine_; } VideoEngineInterface& CompositeMediaEngine::video() { - return *video_engine_.get(); + return *video_engine_; } const VoiceEngineInterface& CompositeMediaEngine::voice() const { - return *voice_engine_.get(); + return *voice_engine_; } const VideoEngineInterface& CompositeMediaEngine::video() const { - return *video_engine_.get(); + return *video_engine_; } } // namespace webrtc diff --git a/media/base/media_engine.h b/media/base/media_engine.h index 1cef38e9ec..3fbd91e4df 100644 --- a/media/base/media_engine.h +++ b/media/base/media_engine.h @@ -238,22 +238,5 @@ std::vector GetDefaultEnabledRtpHeaderExtensions( } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CheckRtpParametersInvalidModificationAndValues; -using ::webrtc::CheckRtpParametersValues; -using ::webrtc::CheckScalabilityModeValues; -using ::webrtc::CompositeMediaEngine; -using ::webrtc::CreateRtpParametersWithEncodings; -using ::webrtc::CreateRtpParametersWithOneEncoding; -using ::webrtc::GetDefaultEnabledRtpHeaderExtensions; -using ::webrtc::MediaEngineInterface; -using ::webrtc::RtpHeaderExtensionQueryInterface; -using ::webrtc::VideoEngineInterface; -using ::webrtc::VoiceEngineInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_MEDIA_ENGINE_H_ diff --git a/media/base/rid_description.h b/media/base/rid_description.h index 042e2840e4..688dc9a5f2 100644 --- a/media/base/rid_description.h +++ b/media/base/rid_description.h @@ -94,13 +94,5 @@ struct RidDescription final { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::RidDescription; -using ::webrtc::RidDirection; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_RID_DESCRIPTION_H_ diff --git a/media/base/rtp_utils.cc b/media/base/rtp_utils.cc index 76feba308e..8cc697f568 100644 --- a/media/base/rtp_utils.cc +++ b/media/base/rtp_utils.cc @@ -10,9 +10,8 @@ #include "media/base/rtp_utils.h" -#include - #include +#include #include // PacketTimeUpdateParams is defined in asyncpacketsocket.h. @@ -74,8 +73,7 @@ void UpdateAbsSendTimeExtensionValue(uint8_t* extension_data, // Assumes `length` is actual packet length + tag length. Updates HMAC at end of // the RTP packet. -void UpdateRtpAuthTag(uint8_t* rtp, - size_t length, +void UpdateRtpAuthTag(ArrayView rtp, const PacketTimeUpdateParams& packet_time_params) { // If there is no key, return. if (packet_time_params.srtp_auth_key.empty()) { @@ -86,12 +84,12 @@ void UpdateRtpAuthTag(uint8_t* rtp, // ROC (rollover counter) is at the beginning of the auth tag. const size_t kRocLength = 4; - if (tag_length < kRocLength || tag_length > length) { + if (tag_length < kRocLength || tag_length > rtp.size()) { RTC_DCHECK_NOTREACHED(); return; } - uint8_t* auth_tag = rtp + (length - tag_length); + uint8_t* auth_tag = rtp.data() + (rtp.size() - tag_length); // We should have a fake HMAC value @ auth_tag. RTC_DCHECK_EQ(0, memcmp(auth_tag, kFakeAuthTag, tag_length)); @@ -99,12 +97,12 @@ void UpdateRtpAuthTag(uint8_t* rtp, // Copy ROC after end of rtp packet. memcpy(auth_tag, &packet_time_params.srtp_packet_index, kRocLength); // Authentication of a RTP packet will have RTP packet + ROC size. - size_t auth_required_length = length - tag_length + kRocLength; + size_t auth_required_length = rtp.size() - tag_length + kRocLength; uint8_t output[64]; size_t result = ComputeHmac(DIGEST_SHA_1, &packet_time_params.srtp_auth_key[0], - packet_time_params.srtp_auth_key.size(), rtp, + packet_time_params.srtp_auth_key.size(), rtp.data(), auth_required_length, output, sizeof(output)); if (result < tag_length) { @@ -185,9 +183,8 @@ RtpPacketType InferRtpPacketType(ArrayView packet) { return RtpPacketType::kUnknown; } -bool ValidateRtpHeader(const uint8_t* rtp, - size_t length, - size_t* header_length) { +bool ValidateRtpHeader(ArrayView rtp, size_t* header_length) { + size_t length = rtp.size(); if (header_length) { *header_length = 0; } @@ -211,15 +208,14 @@ bool ValidateRtpHeader(const uint8_t* rtp, return true; } - rtp += header_length_without_extension; - if (header_length_without_extension + kRtpExtensionHeaderLen > length) { return false; } // Getting extension profile length. // Length is in 32 bit words. - uint16_t extension_length_in_32bits = GetBE16(rtp + 2); + uint16_t extension_length_in_32bits = + GetBE16(&rtp[header_length_without_extension + 2]); size_t extension_length = extension_length_in_32bits * 4; size_t rtp_header_length = extension_length + @@ -239,8 +235,7 @@ bool ValidateRtpHeader(const uint8_t* rtp, // ValidateRtpHeader() must be called before this method to make sure, we have // a sane rtp packet. -bool UpdateRtpAbsSendTimeExtension(uint8_t* rtp, - size_t /* length */, +bool UpdateRtpAbsSendTimeExtension(ArrayView packet, int extension_id, uint64_t time_us) { // 0 1 2 3 @@ -257,13 +252,14 @@ bool UpdateRtpAbsSendTimeExtension(uint8_t* rtp, // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // Return if extension bit is not set. - if (!(rtp[0] & 0x10)) { + if (!(packet[0] & 0x10)) { return true; } - size_t cc_count = rtp[0] & 0x0F; + size_t cc_count = packet[0] & 0x0F; size_t header_length_without_extension = kMinRtpPacketLen + 4 * cc_count; + uint8_t* rtp = packet.data(); rtp += header_length_without_extension; // Getting extension profile ID and length. @@ -354,12 +350,10 @@ bool UpdateRtpAbsSendTimeExtension(uint8_t* rtp, return found; } -bool ApplyPacketOptions(uint8_t* data, - size_t length, +bool ApplyPacketOptions(ArrayView data, const PacketTimeUpdateParams& packet_time_params, uint64_t time_us) { - RTC_DCHECK(data); - RTC_DCHECK(length); + RTC_DCHECK(data.size() > 0); // if there is no valid `rtp_sendtime_extension_id` and `srtp_auth_key` in // PacketOptions, nothing to be updated in this packet. @@ -373,30 +367,28 @@ bool ApplyPacketOptions(uint8_t* data, // indication. size_t rtp_start_pos; size_t rtp_length; - if (!UnwrapTurnPacket(data, length, &rtp_start_pos, &rtp_length)) { + if (!UnwrapTurnPacket(data.data(), data.size(), &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 (!IsRtpPacket(packet) || - !ValidateRtpHeader(data + rtp_start_pos, rtp_length, nullptr)) { + auto packet = data.subview(rtp_start_pos, rtp_length); + if (!IsRtpPacket(packet) || !ValidateRtpHeader(packet, nullptr)) { RTC_DCHECK_NOTREACHED(); return false; } - uint8_t* start = data + rtp_start_pos; // If packet option has non default value (-1) for sendtime extension id, // then we should parse the rtp packet to update the timestamp. Otherwise // just calculate HMAC and update packet with it. if (packet_time_params.rtp_sendtime_extension_id != -1) { - UpdateRtpAbsSendTimeExtension(start, rtp_length, - packet_time_params.rtp_sendtime_extension_id, - time_us); + UpdateRtpAbsSendTimeExtension( + packet, packet_time_params.rtp_sendtime_extension_id, time_us); } - UpdateRtpAuthTag(start, rtp_length, packet_time_params); + UpdateRtpAuthTag(packet, packet_time_params); return true; } diff --git a/media/base/rtp_utils.h b/media/base/rtp_utils.h index 991af8d16b..b9fae21a4a 100644 --- a/media/base/rtp_utils.h +++ b/media/base/rtp_utils.h @@ -56,52 +56,22 @@ bool IsValidRtpPacketSize(RtpPacketType packet_type, size_t size); absl::string_view RtpPacketTypeToString(RtpPacketType packet_type); // Verifies that a packet has a valid RTP header. -bool RTC_EXPORT ValidateRtpHeader(const uint8_t* rtp, - size_t length, +bool RTC_EXPORT ValidateRtpHeader(ArrayView rtp, size_t* header_length); // Helper method which updates the absolute send time extension if present. -bool UpdateRtpAbsSendTimeExtension(uint8_t* rtp, - size_t length, +bool UpdateRtpAbsSendTimeExtension(ArrayView rtp, int extension_id, uint64_t time_us); // Applies specified `options` to the packet. It updates the absolute send time // extension header if it is present present then updates HMAC. bool RTC_EXPORT -ApplyPacketOptions(uint8_t* data, - size_t length, +ApplyPacketOptions(ArrayView data, const PacketTimeUpdateParams& packet_time_params, uint64_t time_us); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ApplyPacketOptions; -using ::webrtc::GetRtcpSsrc; -using ::webrtc::GetRtcpType; -using ::webrtc::InferRtpPacketType; -using ::webrtc::IsValidRtpPacketSize; -using ::webrtc::IsValidRtpPayloadType; -using ::webrtc::kMaxRtpPacketLen; -using ::webrtc::kMinRtcpPacketLen; -using ::webrtc::kMinRtpPacketLen; -using ::webrtc::kRtcpTypeApp; -using ::webrtc::kRtcpTypeBye; -using ::webrtc::kRtcpTypePSFB; -using ::webrtc::kRtcpTypeRR; -using ::webrtc::kRtcpTypeRTPFB; -using ::webrtc::kRtcpTypeSDES; -using ::webrtc::kRtcpTypeSR; -using ::webrtc::RtcpTypes; -using ::webrtc::RtpPacketType; -using ::webrtc::RtpPacketTypeToString; -using ::webrtc::UpdateRtpAbsSendTimeExtension; -using ::webrtc::ValidateRtpHeader; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_RTP_UTILS_H_ diff --git a/media/base/rtp_utils_unittest.cc b/media/base/rtp_utils_unittest.cc index b3c07b5da9..af3263e7e2 100644 --- a/media/base/rtp_utils_unittest.cc +++ b/media/base/rtp_utils_unittest.cc @@ -10,9 +10,8 @@ #include "media/base/rtp_utils.h" -#include - #include +#include #include #include "api/array_view.h" @@ -107,8 +106,7 @@ TEST(RtpUtilsTest, InvalidRtpHeader) { 0xDD, 0xCC, 0xBB, 0xAA, // Only 1 CSRC, but CC count is 4. // clang-format on }; - EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidLength, - sizeof(kRtpMsgWithInvalidLength), nullptr)); + EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidLength, nullptr)); // Rtp message with single byte header extension, invalid extension length. const uint8_t kRtpMsgWithInvalidExtnLength[] = { @@ -116,27 +114,23 @@ TEST(RtpUtilsTest, InvalidRtpHeader) { 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE, 0x0A, 0x00, // Extn length - 0x0A00 }; EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidExtnLength, - sizeof(kRtpMsgWithInvalidExtnLength), nullptr)); } // Valid RTP packet with a 2byte header extension. TEST(RtpUtilsTest, Valid2ByteExtnHdrRtpMessage) { - EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWith2ByteExtnHeader, - sizeof(kRtpMsgWith2ByteExtnHeader), nullptr)); + EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWith2ByteExtnHeader, nullptr)); } // Valid RTP packet which has 1 byte header AbsSendTime extension in it. TEST(RtpUtilsTest, ValidRtpPacketWithOneByteAbsSendTimeExtension) { EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWithOneByteAbsSendTimeExtension, - sizeof(kRtpMsgWithOneByteAbsSendTimeExtension), nullptr)); } // Valid RTP packet which has 2 byte header AbsSendTime extension in it. TEST(RtpUtilsTest, ValidRtpPacketWithTwoByteAbsSendTimeExtension) { EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWithTwoByteAbsSendTimeExtension, - sizeof(kRtpMsgWithTwoByteAbsSendTimeExtension), nullptr)); } @@ -160,8 +154,7 @@ TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) { 0x00, 0x00, 0x00, 0x00, // clang-format on }; - EXPECT_TRUE(UpdateRtpAbsSendTimeExtension( - message_without_extension, sizeof(message_without_extension), 3, 0)); + EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(message_without_extension, 3, 0)); // A valid STUN indication message with a valid RTP header and a extension // header. @@ -181,7 +174,7 @@ TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) { 0x00, 0x02, 0x22, 0xaa, 0xbb, 0xcc, 0x32, 0xaa, 0xbb, 0xcc, // clang-format on }; - EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(message, sizeof(message), 3, 0)); + EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(message, 3, 0)); } // Test without any packet options variables set. This method should return @@ -193,8 +186,7 @@ TEST(RtpUtilsTest, ApplyPacketOptionsWithDefaultValues) { kRtpMsgWithOneByteAbsSendTimeExtension + sizeof(kRtpMsgWithOneByteAbsSendTimeExtension)); rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag)); - EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(), - packet_time_params, 0)); + EXPECT_TRUE(ApplyPacketOptions(rtp_packet, packet_time_params, 0)); // Making sure HMAC wasn't updated.. EXPECT_EQ(0, @@ -218,8 +210,7 @@ TEST(RtpUtilsTest, ApplyPacketOptionsWithAuthParams) { kRtpMsgWithOneByteAbsSendTimeExtension + sizeof(kRtpMsgWithOneByteAbsSendTimeExtension)); rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag)); - EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(), - packet_time_params, 0)); + EXPECT_TRUE(ApplyPacketOptions(rtp_packet, packet_time_params, 0)); uint8_t kExpectedTag[] = {0xc1, 0x7a, 0x8c, 0xa0}; EXPECT_EQ(0, @@ -238,8 +229,7 @@ TEST(RtpUtilsTest, UpdateOneByteAbsSendTimeExtensionInRtpPacket) { kRtpMsgWithOneByteAbsSendTimeExtension + sizeof(kRtpMsgWithOneByteAbsSendTimeExtension)); - EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(&rtp_packet[0], rtp_packet.size(), - 3, 51183266)); + EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(rtp_packet, 3, 51183266)); // Verify that the timestamp was updated. const uint8_t kExpectedTimestamp[3] = {0xcc, 0xbb, 0xaa}; @@ -254,8 +244,7 @@ TEST(RtpUtilsTest, UpdateTwoByteAbsSendTimeExtensionInRtpPacket) { kRtpMsgWithTwoByteAbsSendTimeExtension + sizeof(kRtpMsgWithTwoByteAbsSendTimeExtension)); - EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(&rtp_packet[0], rtp_packet.size(), - 3, 51183266)); + EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(rtp_packet, 3, 51183266)); // Verify that the timestamp was updated. const uint8_t kExpectedTimestamp[3] = {0xcc, 0xbb, 0xaa}; @@ -277,8 +266,7 @@ TEST(RtpUtilsTest, ApplyPacketOptionsWithAuthParamsAndAbsSendTime) { kRtpMsgWithOneByteAbsSendTimeExtension + sizeof(kRtpMsgWithOneByteAbsSendTimeExtension)); rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag)); - EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(), - packet_time_params, 51183266)); + EXPECT_TRUE(ApplyPacketOptions(rtp_packet, packet_time_params, 51183266)); const uint8_t kExpectedTag[] = {0x81, 0xd1, 0x2c, 0x0e}; EXPECT_EQ(0, diff --git a/media/base/sdp_video_format_utils_unittest.cc b/media/base/sdp_video_format_utils_unittest.cc index cde1e30e1c..f94aff371f 100644 --- a/media/base/sdp_video_format_utils_unittest.cc +++ b/media/base/sdp_video_format_utils_unittest.cc @@ -19,11 +19,11 @@ namespace webrtc { namespace { // Max frame rate for VP8 and VP9 video. -const char kVPxFmtpMaxFrameRate[] = "max-fr"; +constexpr char kVPxFmtpMaxFrameRate[] = "max-fr"; // Max frame size for VP8 and VP9 video. -const char kVPxFmtpMaxFrameSize[] = "max-fs"; +constexpr char kVPxFmtpMaxFrameSize[] = "max-fs"; // Nonstandard per-layer PLI for video. -const char kCodecParamPerLayerPictureLossIndication[] = +constexpr char kCodecParamPerLayerPictureLossIndication[] = "x-google-per-layer-pli"; } // namespace diff --git a/media/base/stream_params.cc b/media/base/stream_params.cc index 94e2dea50f..1d1597e827 100644 --- a/media/base/stream_params.cc +++ b/media/base/stream_params.cc @@ -10,9 +10,8 @@ #include "media/base/stream_params.h" -#include - #include +#include #include #include diff --git a/media/base/stream_params.h b/media/base/stream_params.h index 354d66d263..2cdb8e3b66 100644 --- a/media/base/stream_params.h +++ b/media/base/stream_params.h @@ -318,26 +318,5 @@ inline bool RemoveStreamByIds(StreamParamsVec* streams, const std::string& id) { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::GetStream; -using ::webrtc::GetStreamByIds; -using ::webrtc::GetStreamBySsrc; -using ::webrtc::HasStreamWithNoSsrcs; -using ::webrtc::kFecFrSsrcGroupSemantics; -using ::webrtc::kFecSsrcGroupSemantics; -using ::webrtc::kFidSsrcGroupSemantics; -using ::webrtc::kSimSsrcGroupSemantics; -using ::webrtc::RemoveStream; -using ::webrtc::RemoveStreamByIds; -using ::webrtc::RemoveStreamBySsrc; -using ::webrtc::SsrcGroup; -using ::webrtc::StreamParams; -using ::webrtc::StreamParamsVec; -using ::webrtc::StreamSelector; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_STREAM_PARAMS_H_ diff --git a/media/base/stream_params_unittest.cc b/media/base/stream_params_unittest.cc index 2b9a0f3243..49a8926c86 100644 --- a/media/base/stream_params_unittest.cc +++ b/media/base/stream_params_unittest.cc @@ -10,9 +10,8 @@ #include "media/base/stream_params.h" -#include - #include +#include #include #include diff --git a/media/base/test_utils.h b/media/base/test_utils.h index 76e4ea55a3..f0803b92e1 100644 --- a/media/base/test_utils.h +++ b/media/base/test_utils.h @@ -53,15 +53,5 @@ StreamParams CreatePrimaryWithFecFrStreamParams(const std::string& cname, } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CreatePrimaryWithFecFrStreamParams; -using ::webrtc::CreateSimStreamParams; -using ::webrtc::CreateSimWithRtxStreamParams; -using ::webrtc::MakeVector; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_TEST_UTILS_H_ diff --git a/media/base/turn_utils.h b/media/base/turn_utils.h index 689de19b23..902ba62123 100644 --- a/media/base/turn_utils.h +++ b/media/base/turn_utils.h @@ -27,12 +27,5 @@ bool RTC_EXPORT UnwrapTurnPacket(const uint8_t* packet, } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::UnwrapTurnPacket; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_TURN_UTILS_H_ diff --git a/media/base/video_adapter.h b/media/base/video_adapter.h index 670984eb1c..5105124d08 100644 --- a/media/base/video_adapter.h +++ b/media/base/video_adapter.h @@ -169,12 +169,5 @@ class RTC_EXPORT VideoAdapter { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::VideoAdapter; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_VIDEO_ADAPTER_H_ diff --git a/media/base/video_broadcaster.h b/media/base/video_broadcaster.h index c8fc17db5b..7b774536c1 100644 --- a/media/base/video_broadcaster.h +++ b/media/base/video_broadcaster.h @@ -81,12 +81,5 @@ class VideoBroadcaster : public VideoSourceBase, } // 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::VideoBroadcaster; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_VIDEO_BROADCASTER_H_ diff --git a/media/base/video_common.h b/media/base/video_common.h index 25c782f644..cf3743ab29 100644 --- a/media/base/video_common.h +++ b/media/base/video_common.h @@ -222,64 +222,5 @@ ABSL_DEPRECATE_AND_INLINE() int LeastCommonMultiple(int a, int b); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CanonicalFourCC; -using ::webrtc::FourCC; -using ::webrtc::FOURCC_24BG; -using ::webrtc::FOURCC_2VUY; -using ::webrtc::FOURCC_ABGR; -using ::webrtc::FOURCC_ANY; -using ::webrtc::FOURCC_ARGB; -using ::webrtc::FOURCC_BA81; -using ::webrtc::FOURCC_BGGR; -using ::webrtc::FOURCC_BGR3; -using ::webrtc::FOURCC_BGRA; -using ::webrtc::FOURCC_CM24; -using ::webrtc::FOURCC_CM32; -using ::webrtc::FOURCC_DMB1; -using ::webrtc::FOURCC_GBRG; -using ::webrtc::FOURCC_GRBG; -using ::webrtc::FOURCC_H264; -using ::webrtc::FOURCC_HDYC; -using ::webrtc::FOURCC_I400; -using ::webrtc::FOURCC_I411; -using ::webrtc::FOURCC_I420; -using ::webrtc::FOURCC_I422; -using ::webrtc::FOURCC_I444; -using ::webrtc::FOURCC_IYUV; -using ::webrtc::FOURCC_J400; -using ::webrtc::FOURCC_J420; -using ::webrtc::FOURCC_JPEG; -using ::webrtc::FOURCC_M420; -using ::webrtc::FOURCC_MJPG; -using ::webrtc::FOURCC_NV12; -using ::webrtc::FOURCC_NV21; -using ::webrtc::FOURCC_R444; -using ::webrtc::FOURCC_RAW; -using ::webrtc::FOURCC_RGB3; -using ::webrtc::FOURCC_RGBA; -using ::webrtc::FOURCC_RGBO; -using ::webrtc::FOURCC_RGBP; -using ::webrtc::FOURCC_RGGB; -using ::webrtc::FOURCC_UYVY; -using ::webrtc::FOURCC_YU12; -using ::webrtc::FOURCC_YU16; -using ::webrtc::FOURCC_YU24; -using ::webrtc::FOURCC_YUVS; -using ::webrtc::FOURCC_YUY2; -using ::webrtc::FOURCC_YUYV; -using ::webrtc::FOURCC_YV12; -using ::webrtc::FOURCC_YV16; -using ::webrtc::FOURCC_YV24; -using ::webrtc::GetFourccName; -using ::webrtc::GreatestCommonDivisor; -using ::webrtc::LeastCommonMultiple; -using ::webrtc::VideoFormat; -using ::webrtc::VideoFormatPod; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_VIDEO_COMMON_H_ diff --git a/media/base/video_source_base.h b/media/base/video_source_base.h index 068719cd75..1531a005e2 100644 --- a/media/base/video_source_base.h +++ b/media/base/video_source_base.h @@ -81,13 +81,5 @@ class VideoSourceBaseGuarded : public VideoSourceInterface { } // 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::VideoSourceBase; -using ::webrtc::VideoSourceBaseGuarded; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_BASE_VIDEO_SOURCE_BASE_H_ diff --git a/media/engine/fake_webrtc_call.cc b/media/engine/fake_webrtc_call.cc index 64a7dc61f6..293e898532 100644 --- a/media/engine/fake_webrtc_call.cc +++ b/media/engine/fake_webrtc_call.cc @@ -121,16 +121,15 @@ void FakeAudioReceiveStream::SetStats( stats_ = stats; } -bool FakeAudioReceiveStream::VerifyLastPacket(const uint8_t* data, - size_t length) const { - return last_packet_ == Buffer(data, length); +bool FakeAudioReceiveStream::VerifyLastPacket( + ArrayView data) const { + return last_packet_ == Buffer(data.data(), data.size()); } -bool FakeAudioReceiveStream::DeliverRtp(const uint8_t* packet, - size_t length, +bool FakeAudioReceiveStream::DeliverRtp(ArrayView packet, int64_t /* packet_time_us */) { ++received_packets_; - last_packet_.SetData(packet, length); + last_packet_.SetData(packet); return true; } @@ -690,7 +689,7 @@ bool FakeCall::DeliverPacketInternal(MediaType media_type, if (media_type == MediaType::AUDIO) { for (auto receiver : audio_receive_streams_) { if (receiver->GetConfig().rtp.remote_ssrc == ssrc) { - receiver->DeliverRtp(packet.cdata(), packet.size(), arrival_time.us()); + receiver->DeliverRtp(packet, arrival_time.us()); ++delivered_packets_by_ssrc_[ssrc]; return true; } diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h index 4324a90d1e..c4265fc744 100644 --- a/media/engine/fake_webrtc_call.h +++ b/media/engine/fake_webrtc_call.h @@ -124,10 +124,10 @@ class FakeAudioReceiveStream final : public AudioReceiveStreamInterface { const AudioReceiveStreamInterface::Config& GetConfig() const; void SetStats(const AudioReceiveStreamInterface::Stats& stats); int received_packets() const { return received_packets_; } - bool VerifyLastPacket(const uint8_t* data, size_t length) const; + bool VerifyLastPacket(ArrayView data) const; const AudioSinkInterface* sink() const { return sink_; } float gain() const { return gain_; } - bool DeliverRtp(const uint8_t* packet, size_t length, int64_t packet_time_us); + bool DeliverRtp(ArrayView packet, int64_t packet_time_us); bool started() const { return started_; } int base_mininum_playout_delay_ms() const { return base_mininum_playout_delay_ms_; @@ -529,16 +529,4 @@ class FakeCall final : public Call, public PacketReceiver { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakeAudioReceiveStream; -using ::webrtc::FakeAudioSendStream; -using ::webrtc::FakeCall; -using ::webrtc::FakeFlexfecReceiveStream; -using ::webrtc::FakeVideoReceiveStream; -using ::webrtc::FakeVideoSendStream; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_ENGINE_FAKE_WEBRTC_CALL_H_ diff --git a/media/engine/fake_webrtc_video_engine.h b/media/engine/fake_webrtc_video_engine.h index 1889214432..505455c97e 100644 --- a/media/engine/fake_webrtc_video_engine.h +++ b/media/engine/fake_webrtc_video_engine.h @@ -142,15 +142,5 @@ class FakeWebRtcVideoEncoderFactory : public VideoEncoderFactory { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakeWebRtcVideoDecoder; -using ::webrtc::FakeWebRtcVideoDecoderFactory; -using ::webrtc::FakeWebRtcVideoEncoder; -using ::webrtc::FakeWebRtcVideoEncoderFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_ENGINE_FAKE_WEBRTC_VIDEO_ENGINE_H_ diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc index ebd0e1b473..30bf83783a 100644 --- a/media/engine/simulcast_encoder_adapter.cc +++ b/media/engine/simulcast_encoder_adapter.cc @@ -10,11 +10,10 @@ #include "media/engine/simulcast_encoder_adapter.h" -#include -#include - #include #include +#include +#include #include #include #include diff --git a/media/engine/webrtc_media_engine.cc b/media/engine/webrtc_media_engine.cc index f375952eec..1700892027 100644 --- a/media/engine/webrtc_media_engine.cc +++ b/media/engine/webrtc_media_engine.cc @@ -16,7 +16,6 @@ #include #include "absl/algorithm/container.h" -#include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/field_trials_view.h" @@ -144,8 +143,7 @@ std::vector FilterRtpExtensions( result.erase(it, result.end()); // Keep just the highest priority extension of any in the following lists. - if (absl::StartsWith(trials.Lookup("WebRTC-FilterAbsSendTimeExtension"), - "Enabled")) { + if (trials.IsEnabled("WebRTC-FilterAbsSendTimeExtension")) { static const char* const kBweExtensionPriorities[] = { RtpExtension::kTransportSequenceNumberUri, RtpExtension::kAbsSendTimeUri, RtpExtension::kTimestampOffsetUri}; diff --git a/media/engine/webrtc_media_engine.h b/media/engine/webrtc_media_engine.h index 15eb5427ff..488fe3f3e8 100644 --- a/media/engine/webrtc_media_engine.h +++ b/media/engine/webrtc_media_engine.h @@ -41,14 +41,5 @@ BitrateConstraints GetBitrateConfigForCodec(const Codec& codec); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FilterRtpExtensions; -using ::webrtc::GetBitrateConfigForCodec; -using ::webrtc::ValidateRtpExtensions; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_H_ diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 9b71d020df..553020d3f0 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -10,10 +10,9 @@ #include "media/engine/webrtc_video_engine.h" -#include - #include #include +#include #include #include #include @@ -128,14 +127,6 @@ const char* StreamTypeToString(VideoSendStream::StreamStats::StreamType type) { return nullptr; } -bool IsEnabled(const FieldTrialsView& trials, absl::string_view name) { - return absl::StartsWith(trials.Lookup(name), "Enabled"); -} - -bool IsDisabled(const FieldTrialsView& trials, absl::string_view name) { - return absl::StartsWith(trials.Lookup(name), "Disabled"); -} - void AddDefaultFeedbackParams(Codec* codec, const FieldTrialsView& trials) { // Don't add any feedback params for RED and ULPFEC. if (codec->name == kRedCodecName || codec->name == kUlpfecCodecName) @@ -150,7 +141,7 @@ void AddDefaultFeedbackParams(Codec* codec, const FieldTrialsView& trials) { codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kParamValueEmpty)); codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamNack, kRtcpFbNackParamPli)); if (codec->name == kVp8CodecName && - IsEnabled(trials, "WebRTC-RtcpLossNotification")) { + trials.IsEnabled("WebRTC-RtcpLossNotification")) { codec->AddFeedbackParam(FeedbackParam(kRtcpFbParamLntf, kParamValueEmpty)); } } @@ -182,7 +173,7 @@ std::vector GetDefaultSupportedFormats( supported_formats.push_back(SdpVideoFormat(kUlpfecCodecName)); // flexfec-03 is always supported as receive codec and as send codec // only if WebRTC-FlexFEC-03-Advertised is enabled - if (is_decoder_factory || IsEnabled(trials, "WebRTC-FlexFEC-03-Advertised")) { + if (is_decoder_factory || trials.IsEnabled("WebRTC-FlexFEC-03-Advertised")) { SdpVideoFormat flexfec_format(kFlexfecCodecName); // This value is currently arbitrarily set to 10 seconds. (The unit // is microseconds.) This parameter MUST be present in the SDP, but @@ -886,22 +877,21 @@ WebRtcVideoEngine::GetRtpHeaderExtensions() const { result.emplace_back(uri, id, RtpTransceiverDirection::kStopped); } result.emplace_back(RtpExtension::kGenericFrameDescriptorUri00, id, - IsEnabled(trials_, "WebRTC-GenericDescriptorAdvertised") + trials_.IsEnabled("WebRTC-GenericDescriptorAdvertised") + ? RtpTransceiverDirection::kSendRecv + : RtpTransceiverDirection::kStopped); + result.emplace_back(RtpExtension::kDependencyDescriptorUri, id, + trials_.IsEnabled("WebRTC-DependencyDescriptorAdvertised") ? RtpTransceiverDirection::kSendRecv : RtpTransceiverDirection::kStopped); - result.emplace_back( - RtpExtension::kDependencyDescriptorUri, id, - IsEnabled(trials_, "WebRTC-DependencyDescriptorAdvertised") - ? RtpTransceiverDirection::kSendRecv - : RtpTransceiverDirection::kStopped); result.emplace_back( RtpExtension::kVideoLayersAllocationUri, id, - IsEnabled(trials_, "WebRTC-VideoLayersAllocationAdvertised") + trials_.IsEnabled("WebRTC-VideoLayersAllocationAdvertised") ? RtpTransceiverDirection::kSendRecv : RtpTransceiverDirection::kStopped); // VideoFrameTrackingId is a test-only extension. - if (IsEnabled(trials_, "WebRTC-VideoFrameTrackingIdAdvertised")) { + if (trials_.IsEnabled("WebRTC-VideoFrameTrackingIdAdvertised")) { result.emplace_back(RtpExtension::kVideoFrameTrackingIdUri, id, RtpTransceiverDirection::kSendRecv); } @@ -935,9 +925,8 @@ WebRtcVideoSendChannel::WebRtcVideoSendChannel( default_send_options_(options), last_send_stats_log_ms_(-1), last_receive_stats_log_ms_(-1), - discard_unknown_ssrc_packets_( - IsEnabled(call_->trials(), - "WebRTC-Video-DiscardPacketsWithUnknownSsrc")), + discard_unknown_ssrc_packets_(call_->trials().IsEnabled( + "WebRTC-Video-DiscardPacketsWithUnknownSsrc")), crypto_options_(crypto_options) { RTC_DCHECK_RUN_ON(&thread_checker_); rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; @@ -1020,7 +1009,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( // TODO(webrtc:329396373): Remove after flexible mode is fully deployed. vp9_settings.flexibleMode = - !IsDisabled(call_->trials(), "WebRTC-Video-Vp9FlexibleMode"); + !call_->trials().IsDisabled("WebRTC-Video-Vp9FlexibleMode"); } else { // Multiple spatial layers vp9 screenshare needs flexible mode. vp9_settings.flexibleMode = vp9_settings.numberOfSpatialLayers > 1; @@ -1104,7 +1093,7 @@ bool WebRtcVideoSendChannel::GetChangedSenderParameters( } // Never enable sending FlexFEC, unless we are in the experiment. - if (!IsEnabled(call_->trials(), "WebRTC-FlexFEC-03")) { + if (!call_->trials().IsEnabled("WebRTC-FlexFEC-03")) { for (VideoCodecSettings& codec : negotiated_codecs) codec.flexfec_payload_type = -1; } @@ -1807,7 +1796,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( rtp_parameters_(CreateRtpParametersWithEncodings(sp)), sending_(false), disable_automatic_resize_( - IsEnabled(call->trials(), "WebRTC-Video-DisableAutomaticResize")) { + call->trials().IsEnabled("WebRTC-Video-DisableAutomaticResize")) { // Maximum packet size may come in RtpConfig from external transport, for // example from QuicTransportInterface implementation, so do not exceed // given max_packet_size. @@ -1828,7 +1817,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( // FlexFEC SSRCs. // TODO(brandtr): This code needs to be generalized when we add support for // multistream protection. - if (IsEnabled(call_->trials(), "WebRTC-FlexFEC-03")) { + if (call_->trials().IsEnabled("WebRTC-FlexFEC-03")) { uint32_t flexfec_ssrc; bool flexfec_enabled = false; for (uint32_t primary_ssrc : parameters_.config.rtp.ssrcs) { @@ -1941,7 +1930,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::GetDegradationPreference() parameters_.options.content_hint == VideoTrackInterface::ContentHint::kText) { degradation_preference = DegradationPreference::MAINTAIN_RESOLUTION; - } else if (IsEnabled(call_->trials(), "WebRTC-Video-BalancedDegradation")) { + } else if (call_->trials().IsEnabled("WebRTC-Video-BalancedDegradation")) { // Standard wants balanced by default, but it needs to be tuned first. degradation_preference = DegradationPreference::BALANCED; } else { @@ -2745,9 +2734,8 @@ WebRtcVideoReceiveChannel::WebRtcVideoReceiveChannel( decoder_factory_(decoder_factory), default_send_options_(options), last_receive_stats_log_ms_(-1), - discard_unknown_ssrc_packets_( - IsEnabled(call_->trials(), - "WebRTC-Video-DiscardPacketsWithUnknownSsrc")), + discard_unknown_ssrc_packets_(call_->trials().IsEnabled( + "WebRTC-Video-DiscardPacketsWithUnknownSsrc")), crypto_options_(crypto_options), receive_buffer_size_(ParseReceiveBufferSize(call_->trials())) { RTC_DCHECK_RUN_ON(&thread_checker_); @@ -3076,7 +3064,7 @@ void WebRtcVideoReceiveChannel::ConfigureReceiverRtp( // TODO(brandtr): Generalize when we add support for multistream protection. flexfec_config->payload_type = recv_flexfec_payload_type_; - if (!IsDisabled(call_->trials(), "WebRTC-FlexFEC-03-Advertised") && + if (!call_->trials().IsDisabled("WebRTC-FlexFEC-03-Advertised") && sp.GetFecFrSsrc(ssrc, &flexfec_config->rtp.remote_ssrc)) { flexfec_config->protected_media_ssrcs = {ssrc}; flexfec_config->rtp.local_ssrc = config->rtp.local_ssrc; diff --git a/media/engine/webrtc_video_engine.h b/media/engine/webrtc_video_engine.h index b46c391ec6..522b060bdd 100644 --- a/media/engine/webrtc_video_engine.h +++ b/media/engine/webrtc_video_engine.h @@ -861,17 +861,5 @@ class WebRtcVideoChannel : public WebRtcVideoSendChannel { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MergeInfoAboutOutboundRtpSubstreamsForTesting; -using ::webrtc::VideoCodecSettings; -using ::webrtc::WebRtcVideoChannel; -using ::webrtc::WebRtcVideoEngine; -using ::webrtc::WebRtcVideoReceiveChannel; -using ::webrtc::WebRtcVideoSendChannel; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_ENGINE_WEBRTC_VIDEO_ENGINE_H_ diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index 5f22336d45..c9b1c8d314 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -152,26 +152,26 @@ using ::webrtc::test::FrameForwarder; using ::webrtc::test::FunctionVideoDecoderFactory; using ::webrtc::test::RtcpPacketParser; -const uint8_t kRedRtxPayloadType = 125; +constexpr uint8_t kRedRtxPayloadType = 125; -const uint32_t kSsrc = 1234u; -const uint32_t kSsrcs4[] = {1, 2, 3, 4}; -const int kVideoWidth = 640; -const int kVideoHeight = 360; -const int kFramerate = 30; +constexpr uint32_t kSsrc = 1234u; +constexpr uint32_t kSsrcs4[] = {1, 2, 3, 4}; +constexpr int kVideoWidth = 640; +constexpr int kVideoHeight = 360; +constexpr int kFramerate = 30; constexpr TimeDelta kFrameDuration = TimeDelta::Millis(1000 / kFramerate); -const uint32_t kSsrcs1[] = {1}; -const uint32_t kSsrcs3[] = {1, 2, 3}; -const uint32_t kRtxSsrcs1[] = {4}; -const uint32_t kFlexfecSsrc = 5; -const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE; -const int64_t kUnsignalledReceiveStreamCooldownMs = 500; +constexpr uint32_t kSsrcs1[] = {1}; +constexpr uint32_t kSsrcs3[] = {1, 2, 3}; +constexpr uint32_t kRtxSsrcs1[] = {4}; +constexpr uint32_t kFlexfecSsrc = 5; +constexpr uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE; +constexpr int64_t kUnsignalledReceiveStreamCooldownMs = 500; constexpr uint32_t kRtpHeaderSize = 12; constexpr size_t kNumSimulcastStreams = 3; -const char kUnsupportedExtensionName[] = +constexpr char kUnsupportedExtensionName[] = "urn:ietf:params:rtp-hdrext:unsupported"; Codec RemoveFeedbackParams(Codec&& codec) { diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h index fc4a0409d5..8caf1135a9 100644 --- a/media/engine/webrtc_voice_engine.h +++ b/media/engine/webrtc_voice_engine.h @@ -499,14 +499,5 @@ class WebRtcVoiceReceiveChannel final } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::WebRtcVoiceEngine; -using ::webrtc::WebRtcVoiceReceiveChannel; -using ::webrtc::WebRtcVoiceSendChannel; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_ENGINE_WEBRTC_VOICE_ENGINE_H_ diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 6dfe2bbea3..42de3b3d9f 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -22,6 +22,7 @@ #include #include "absl/strings/match.h" +#include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/audio_codecs/audio_codec_pair_id.h" @@ -79,6 +80,7 @@ #include "test/mock_audio_decoder_factory.h" #include "test/mock_audio_encoder_factory.h" +namespace webrtc { namespace { using ::testing::_; using ::testing::ContainerEq; @@ -122,13 +124,13 @@ const webrtc::Codec kTelephoneEventCodec2 = const webrtc::Codec kUnknownCodec = webrtc::CreateAudioCodec(127, "XYZ", 32000, 1); -const uint32_t kSsrc0 = 0; -const uint32_t kSsrc1 = 1; -const uint32_t kSsrcX = 0x99; -const uint32_t kSsrcY = 0x17; -const uint32_t kSsrcZ = 0x42; -const uint32_t kSsrcW = 0x02; -const uint32_t kSsrcs4[] = {11, 200, 30, 44}; +constexpr uint32_t kSsrc0 = 0; +constexpr uint32_t kSsrc1 = 1; +constexpr uint32_t kSsrcX = 0x99; +constexpr uint32_t kSsrcY = 0x17; +constexpr uint32_t kSsrcZ = 0x42; +constexpr uint32_t kSsrcW = 0x02; +constexpr uint32_t kSsrcs4[] = {11, 200, 30, 44}; constexpr int kRtpHistoryMs = 5000; @@ -211,8 +213,6 @@ std::vector ReceiveCodecsWithId( return AddIdToCodecs(pt_mapper, std::move(codecs)); } -} // namespace - // Tests that our stub library "works". TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { Environment env = CreateEnvironment(); @@ -351,9 +351,9 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { EXPECT_FALSE(call_.GetAudioSendStream(kSsrcX)); } - void DeliverPacket(const void* data, int len) { + void DeliverPacket(ArrayView data) { webrtc::RtpPacketReceived packet; - packet.Parse(reinterpret_cast(data), len); + packet.Parse(data); receive_channel_->OnPacketReceived(packet); webrtc::Thread::Current()->ProcessMessages(0); } @@ -1601,7 +1601,7 @@ TEST_P(WebRtcVoiceEngineTestFake, GetRtpReceiveParametersWithUnsignaledSsrc) { EXPECT_FALSE(rtp_parameters.encodings[0].ssrc); // Receive PCMU packet (SSRC=1). - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); // The `ssrc` member should still be unset. rtp_parameters = receive_channel_->GetDefaultRtpReceiveParameters(); @@ -2597,7 +2597,7 @@ TEST_P(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { { webrtc::VoiceMediaSendInfo send_info; webrtc::VoiceMediaReceiveInfo receive_info; - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); SetAudioReceiveStreamStats(); EXPECT_CALL(*adm_, GetPlayoutUnderrunCount()).WillOnce(Return(0)); EXPECT_EQ(true, send_channel_->GetStats(&send_info)); @@ -2756,7 +2756,7 @@ TEST_P(WebRtcVoiceEngineTestFake, GetStats) { // Deliver a new packet - a default receive stream should be created and we // should see stats again. { - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); SetAudioReceiveStreamStats(); EXPECT_CALL(*adm_, GetPlayoutUnderrunCount()).WillOnce(Return(0)); webrtc::VoiceMediaSendInfo send_info; @@ -2795,10 +2795,9 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { TEST_P(WebRtcVoiceEngineTestFake, Recv) { EXPECT_TRUE(SetupChannel()); EXPECT_TRUE(AddRecvStream(1)); - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); - EXPECT_TRUE( - GetRecvStream(1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); + EXPECT_TRUE(GetRecvStream(1).VerifyLastPacket(kPcmuFrame)); } // Test that we can properly receive packets on multiple streams. @@ -2811,7 +2810,7 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { EXPECT_TRUE(AddRecvStream(ssrc2)); EXPECT_TRUE(AddRecvStream(ssrc3)); // Create packets with the right SSRCs. - unsigned char packets[4][sizeof(kPcmuFrame)]; + uint8_t packets[4][sizeof(kPcmuFrame)]; for (size_t i = 0; i < std::size(packets); ++i) { memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); webrtc::SetBE32(packets[i] + 8, static_cast(i)); @@ -2825,28 +2824,28 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { EXPECT_EQ(s2.received_packets(), 0); EXPECT_EQ(s3.received_packets(), 0); - DeliverPacket(packets[0], sizeof(packets[0])); + DeliverPacket(packets[0]); EXPECT_EQ(s1.received_packets(), 0); EXPECT_EQ(s2.received_packets(), 0); EXPECT_EQ(s3.received_packets(), 0); - DeliverPacket(packets[1], sizeof(packets[1])); + DeliverPacket(packets[1]); EXPECT_EQ(s1.received_packets(), 1); - EXPECT_TRUE(s1.VerifyLastPacket(packets[1], sizeof(packets[1]))); + EXPECT_TRUE(s1.VerifyLastPacket(packets[1])); EXPECT_EQ(s2.received_packets(), 0); EXPECT_EQ(s3.received_packets(), 0); - DeliverPacket(packets[2], sizeof(packets[2])); + DeliverPacket(packets[2]); EXPECT_EQ(s1.received_packets(), 1); EXPECT_EQ(s2.received_packets(), 1); - EXPECT_TRUE(s2.VerifyLastPacket(packets[2], sizeof(packets[2]))); + EXPECT_TRUE(s2.VerifyLastPacket(packets[2])); EXPECT_EQ(s3.received_packets(), 0); - DeliverPacket(packets[3], sizeof(packets[3])); + DeliverPacket(packets[3]); EXPECT_EQ(s1.received_packets(), 1); EXPECT_EQ(s2.received_packets(), 1); EXPECT_EQ(s3.received_packets(), 1); - EXPECT_TRUE(s3.VerifyLastPacket(packets[3], sizeof(packets[3]))); + EXPECT_TRUE(s3.VerifyLastPacket(packets[3])); EXPECT_TRUE(receive_channel_->RemoveRecvStream(ssrc3)); EXPECT_TRUE(receive_channel_->RemoveRecvStream(ssrc2)); @@ -2858,11 +2857,10 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvUnsignaled) { EXPECT_TRUE(SetupChannel()); EXPECT_EQ(0u, call_.GetAudioReceiveStreams().size()); - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE( - GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); + EXPECT_TRUE(GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame)); } // Tests that when we add a stream without SSRCs, but contains a stream_id @@ -2877,12 +2875,10 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvUnsignaledSsrcWithSignaledStreamId) { // The stream shouldn't have been created at this point because it doesn't // have any SSRCs. EXPECT_EQ(0u, call_.GetAudioReceiveStreams().size()); - - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE( - GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); + EXPECT_TRUE(GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame)); EXPECT_EQ(kSyncLabel, GetRecvStream(kSsrc1).GetConfig().sync_group); // Remset the unsignaled stream to clear the cached parameters. If a new @@ -2890,11 +2886,10 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvUnsignaledSsrcWithSignaledStreamId) { receive_channel_->ResetUnsignaledRecvStream(); receive_channel_->RemoveRecvStream(kSsrc1); - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE( - GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); + EXPECT_TRUE(GetRecvStream(kSsrc1).VerifyLastPacket(kPcmuFrame)); EXPECT_TRUE(GetRecvStream(kSsrc1).GetConfig().sync_group.empty()); } @@ -2905,12 +2900,12 @@ TEST_P(WebRtcVoiceEngineTestFake, ASSERT_TRUE(call_.GetAudioReceiveStreams().empty()); // Deliver a couple packets with unsignaled SSRCs. - unsigned char packet[sizeof(kPcmuFrame)]; + uint8_t packet[sizeof(kPcmuFrame)]; memcpy(packet, kPcmuFrame, sizeof(kPcmuFrame)); webrtc::SetBE32(&packet[8], 0x1234); - DeliverPacket(packet, sizeof(packet)); + DeliverPacket(packet); webrtc::SetBE32(&packet[8], 0x5678); - DeliverPacket(packet, sizeof(packet)); + DeliverPacket(packet); // Verify that the receive streams were created. const auto& receivers1 = call_.GetAudioReceiveStreams(); @@ -2926,34 +2921,34 @@ TEST_P(WebRtcVoiceEngineTestFake, // that packets are forwarded to them all. TEST_P(WebRtcVoiceEngineTestFake, RecvMultipleUnsignaled) { EXPECT_TRUE(SetupChannel()); - unsigned char packet[sizeof(kPcmuFrame)]; + uint8_t packet[sizeof(kPcmuFrame)]; memcpy(packet, kPcmuFrame, sizeof(kPcmuFrame)); // Note that SSRC = 0 is not supported. for (uint32_t ssrc = 1; ssrc < (1 + kMaxUnsignaledRecvStreams); ++ssrc) { webrtc::SetBE32(&packet[8], ssrc); - DeliverPacket(packet, sizeof(packet)); + DeliverPacket(packet); // Verify we have one new stream for each loop iteration. EXPECT_EQ(ssrc, call_.GetAudioReceiveStreams().size()); EXPECT_EQ(1, GetRecvStream(ssrc).received_packets()); - EXPECT_TRUE(GetRecvStream(ssrc).VerifyLastPacket(packet, sizeof(packet))); + EXPECT_TRUE(GetRecvStream(ssrc).VerifyLastPacket(packet)); } // Sending on the same SSRCs again should not create new streams. for (uint32_t ssrc = 1; ssrc < (1 + kMaxUnsignaledRecvStreams); ++ssrc) { webrtc::SetBE32(&packet[8], ssrc); - DeliverPacket(packet, sizeof(packet)); + DeliverPacket(packet); EXPECT_EQ(kMaxUnsignaledRecvStreams, call_.GetAudioReceiveStreams().size()); EXPECT_EQ(2, GetRecvStream(ssrc).received_packets()); - EXPECT_TRUE(GetRecvStream(ssrc).VerifyLastPacket(packet, sizeof(packet))); + EXPECT_TRUE(GetRecvStream(ssrc).VerifyLastPacket(packet)); } // Send on another SSRC, the oldest unsignaled stream (SSRC=1) is replaced. constexpr uint32_t kAnotherSsrc = 667; webrtc::SetBE32(&packet[8], kAnotherSsrc); - DeliverPacket(packet, sizeof(packet)); + DeliverPacket(packet); const auto& streams = call_.GetAudioReceiveStreams(); EXPECT_EQ(kMaxUnsignaledRecvStreams, streams.size()); @@ -2972,32 +2967,30 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvMultipleUnsignaled) { // added, and that this stream will get any packets for unknown SSRCs. TEST_P(WebRtcVoiceEngineTestFake, RecvUnsignaledAfterSignaled) { EXPECT_TRUE(SetupChannel()); - unsigned char packet[sizeof(kPcmuFrame)]; + uint8_t packet[sizeof(kPcmuFrame)]; memcpy(packet, kPcmuFrame, sizeof(kPcmuFrame)); // Add a known stream, send packet and verify we got it. const uint32_t signaled_ssrc = 1; webrtc::SetBE32(&packet[8], signaled_ssrc); EXPECT_TRUE(AddRecvStream(signaled_ssrc)); - DeliverPacket(packet, sizeof(packet)); - EXPECT_TRUE( - GetRecvStream(signaled_ssrc).VerifyLastPacket(packet, sizeof(packet))); + DeliverPacket(packet); + EXPECT_TRUE(GetRecvStream(signaled_ssrc).VerifyLastPacket(packet)); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); // Note that the first unknown SSRC cannot be 0, because we only support // creating receive streams for SSRC!=0. const uint32_t unsignaled_ssrc = 7011; webrtc::SetBE32(&packet[8], unsignaled_ssrc); - DeliverPacket(packet, sizeof(packet)); - EXPECT_TRUE( - GetRecvStream(unsignaled_ssrc).VerifyLastPacket(packet, sizeof(packet))); + DeliverPacket(packet); + EXPECT_TRUE(GetRecvStream(unsignaled_ssrc).VerifyLastPacket(packet)); EXPECT_EQ(2u, call_.GetAudioReceiveStreams().size()); - DeliverPacket(packet, sizeof(packet)); + DeliverPacket(packet); EXPECT_EQ(2, GetRecvStream(unsignaled_ssrc).received_packets()); webrtc::SetBE32(&packet[8], signaled_ssrc); - DeliverPacket(packet, sizeof(packet)); + DeliverPacket(packet); EXPECT_EQ(2, GetRecvStream(signaled_ssrc).received_packets()); EXPECT_EQ(2u, call_.GetAudioReceiveStreams().size()); } @@ -3009,10 +3002,9 @@ TEST_P(WebRtcVoiceEngineTestFake, AddRecvStreamAfterUnsignaled_NoRecreate) { EXPECT_TRUE(SetupChannel()); // Spawn unsignaled stream with SSRC=1. - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE( - GetRecvStream(1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); + EXPECT_TRUE(GetRecvStream(1).VerifyLastPacket(kPcmuFrame)); // Verify that the underlying stream object in Call is not recreated when a // stream with SSRC=1 is added. @@ -3028,10 +3020,9 @@ TEST_P(WebRtcVoiceEngineTestFake, AddRecvStreamAfterUnsignaled_Updates) { EXPECT_TRUE(SetupChannel()); // Spawn unsignaled stream with SSRC=1. - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_EQ(1u, call_.GetAudioReceiveStreams().size()); - EXPECT_TRUE( - GetRecvStream(1).VerifyLastPacket(kPcmuFrame, sizeof(kPcmuFrame))); + EXPECT_TRUE(GetRecvStream(1).VerifyLastPacket(kPcmuFrame)); // Verify that the underlying stream object in Call gets updated when a // stream with SSRC=1 is added, and which has changed stream parameters. @@ -3461,7 +3452,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetOutputVolumeUnsignaledRecvStream) { EXPECT_TRUE(SetupChannel()); // Spawn an unsignaled stream by sending a packet - gain should be 1. - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_DOUBLE_EQ(1, GetRecvStream(kSsrc1).gain()); // Should remember the volume "2" which will be set on new unsignaled streams, @@ -3470,10 +3461,10 @@ TEST_P(WebRtcVoiceEngineTestFake, SetOutputVolumeUnsignaledRecvStream) { EXPECT_DOUBLE_EQ(2, GetRecvStream(kSsrc1).gain()); // Spawn an unsignaled stream by sending a packet - gain should be 2. - unsigned char pcmuFrame2[sizeof(kPcmuFrame)]; + uint8_t pcmuFrame2[sizeof(kPcmuFrame)]; memcpy(pcmuFrame2, kPcmuFrame, sizeof(kPcmuFrame)); webrtc::SetBE32(&pcmuFrame2[8], kSsrcX); - DeliverPacket(pcmuFrame2, sizeof(pcmuFrame2)); + DeliverPacket(pcmuFrame2); EXPECT_DOUBLE_EQ(2, GetRecvStream(kSsrcX).gain()); // Setting gain for all unsignaled streams. @@ -3511,7 +3502,7 @@ TEST_P(WebRtcVoiceEngineTestFake, EXPECT_TRUE(SetupChannel()); // Spawn an unsignaled stream by sending a packet - delay should be 0. - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_EQ( 0, receive_channel_->GetBaseMinimumPlayoutDelayMs(kSsrc1).value_or(-1)); // Check that it doesn't provide default values for unknown ssrc. @@ -3532,10 +3523,10 @@ TEST_P(WebRtcVoiceEngineTestFake, receive_channel_->GetBaseMinimumPlayoutDelayMs(kSsrcY).has_value()); // Spawn an unsignaled stream by sending a packet - delay should be 100. - unsigned char pcmuFrame2[sizeof(kPcmuFrame)]; + uint8_t pcmuFrame2[sizeof(kPcmuFrame)]; memcpy(pcmuFrame2, kPcmuFrame, sizeof(kPcmuFrame)); webrtc::SetBE32(&pcmuFrame2[8], kSsrcX); - DeliverPacket(pcmuFrame2, sizeof(pcmuFrame2)); + DeliverPacket(pcmuFrame2); EXPECT_EQ( 100, receive_channel_->GetBaseMinimumPlayoutDelayMs(kSsrcX).value_or(-1)); @@ -3636,7 +3627,7 @@ TEST_P(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { // Test that packets are forwarded to the Call when configured accordingly. const uint32_t kAudioSsrc = 1; webrtc::CopyOnWriteBuffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); - static const unsigned char kRtcp[] = { + static const uint8_t kRtcp[] = { 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -3719,7 +3710,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetRawAudioSinkUnsignaledRecvStream) { // Spawn an unsignaled stream by sending a packet - it should be assigned the // default sink. - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_NE(nullptr, GetRecvStream(kSsrc1).sink()); // Try resetting the default sink. @@ -3732,15 +3723,15 @@ TEST_P(WebRtcVoiceEngineTestFake, SetRawAudioSinkUnsignaledRecvStream) { // If we remove and add a default stream, it should get the same sink. EXPECT_TRUE(receive_channel_->RemoveRecvStream(kSsrc1)); - DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); + DeliverPacket(kPcmuFrame); EXPECT_NE(nullptr, GetRecvStream(kSsrc1).sink()); // Spawn another unsignaled stream - it should be assigned the default sink // and the previous unsignaled stream should lose it. - unsigned char pcmuFrame2[sizeof(kPcmuFrame)]; + uint8_t pcmuFrame2[sizeof(kPcmuFrame)]; memcpy(pcmuFrame2, kPcmuFrame, sizeof(kPcmuFrame)); webrtc::SetBE32(&pcmuFrame2[8], kSsrcX); - DeliverPacket(pcmuFrame2, sizeof(pcmuFrame2)); + DeliverPacket(pcmuFrame2); if (kMaxUnsignaledRecvStreams > 1) { EXPECT_EQ(nullptr, GetRecvStream(kSsrc1).sink()); } @@ -4214,3 +4205,6 @@ TEST(WebRtcVoiceEngineTest, CollectRecvCodecsWithLatePtAssignment) { EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); } } + +} // namespace +} // namespace webrtc diff --git a/media/sctp/dcsctp_transport.cc b/media/sctp/dcsctp_transport.cc index 529de89a41..faee56519f 100644 --- a/media/sctp/dcsctp_transport.cc +++ b/media/sctp/dcsctp_transport.cc @@ -43,6 +43,7 @@ #include "net/dcsctp/public/types.h" #include "p2p/base/packet_transport_internal.h" #include "p2p/dtls/dtls_transport_internal.h" +#include "rtc_base/async_packet_socket.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/logging.h" @@ -710,17 +711,14 @@ void DcSctpTransport::OnDtlsTransportState(DtlsTransportInternal* transport, if (state == DtlsTransportState::kNew && socket_) { // IF DTLS restart (DtlsTransportState::kNew) // THEN - // restart socket so that we send an SCPT init + // reset the socket so that we send an SCTP init // before any outgoing messages. This is needed // after DTLS fingerprint changed since peer will discard // messages with crypto derived from old fingerprint. + // The socket will be restarted (with changed parameters) + // later. RTC_DLOG(LS_INFO) << debug_name_ << " DTLS restart"; - dcsctp::DcSctpOptions options = socket_->options(); socket_.reset(); - RTC_DCHECK_LE(options.max_message_size, kSctpSendBufferSize); - Start({.local_port = options.local_port, - .remote_port = options.remote_port, - .max_message_size = static_cast(options.max_message_size)}); } } @@ -741,6 +739,12 @@ void DcSctpTransport::OnTransportReadPacket( } void DcSctpTransport::MaybeConnectSocket() { + RTC_DLOG(LS_VERBOSE) + << debug_name_ << "->MaybeConnectSocket(), writable=" + << (transport_ ? std::to_string(transport_->writable()) : "UNSET") + << " socket: " + << (socket_ ? std::to_string(static_cast(socket_->state())) + : "UNSET"); if (transport_ && transport_->writable() && socket_ && socket_->state() == dcsctp::SocketState::kClosed) { socket_->Connect(); diff --git a/media/sctp/sctp_transport_factory.h b/media/sctp/sctp_transport_factory.h index 77ef015727..01fa8d0075 100644 --- a/media/sctp/sctp_transport_factory.h +++ b/media/sctp/sctp_transport_factory.h @@ -34,12 +34,5 @@ class SctpTransportFactory : public SctpTransportFactoryInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::SctpTransportFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_SCTP_SCTP_TRANSPORT_FACTORY_H__ diff --git a/media/sctp/sctp_transport_internal.h b/media/sctp/sctp_transport_internal.h index 934fbde0a7..400d783d9c 100644 --- a/media/sctp/sctp_transport_internal.h +++ b/media/sctp/sctp_transport_internal.h @@ -150,18 +150,5 @@ class SctpTransportInternal { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::kMaxSctpSid; -using ::webrtc::kMaxSctpStreams; -using ::webrtc::kMinSctpSid; -using ::webrtc::kSctpDefaultPort; -using ::webrtc::kSpecMaxSctpSid; -using ::webrtc::SctpErrorCauseCode; -using ::webrtc::SctpTransportInternal; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // MEDIA_SCTP_SCTP_TRANSPORT_INTERNAL_H_ diff --git a/modules/BUILD.gn b/modules/BUILD.gn index cefed31d2b..2264302cae 100644 --- a/modules/BUILD.gn +++ b/modules/BUILD.gn @@ -79,7 +79,7 @@ if (rtc_include_tests && !build_with_chromium) { rtc_test("modules_unittests") { testonly = true defines = [] - sources = [ "module_common_types_unittest.cc" ] + sources = [ "module_common_types_public_unittest.cc" ] deps = [ ":module_api", diff --git a/modules/async_audio_processing/BUILD.gn b/modules/async_audio_processing/BUILD.gn index 0a8fc58520..ba6bdea4b7 100644 --- a/modules/async_audio_processing/BUILD.gn +++ b/modules/async_audio_processing/BUILD.gn @@ -14,14 +14,13 @@ rtc_library("async_audio_processing") { "async_audio_processing.h", ] - public = [ "async_audio_processing.h" ] - deps = [ + "../../api:ref_count", "../../api:scoped_refptr", "../../api:sequence_checker", "../../api/audio:audio_frame_api", "../../api/audio:audio_frame_processor", - "../../api/task_queue:task_queue", + "../../api/task_queue", "../../rtc_base:checks", "../../rtc_base:refcount", ] diff --git a/modules/async_audio_processing/async_audio_processing.cc b/modules/async_audio_processing/async_audio_processing.cc index d61b1264fc..eb62853109 100644 --- a/modules/async_audio_processing/async_audio_processing.cc +++ b/modules/async_audio_processing/async_audio_processing.cc @@ -10,11 +10,12 @@ */ #include "modules/async_audio_processing/async_audio_processing.h" +#include #include #include "api/audio/audio_frame.h" +#include "api/audio/audio_frame_processor.h" #include "api/task_queue/task_queue_factory.h" -#include "rtc_base/checks.h" namespace webrtc { diff --git a/modules/async_audio_processing/async_audio_processing.h b/modules/async_audio_processing/async_audio_processing.h index c5a28cf54a..43bb90ffce 100644 --- a/modules/async_audio_processing/async_audio_processing.h +++ b/modules/async_audio_processing/async_audio_processing.h @@ -14,8 +14,8 @@ #include #include "api/audio/audio_frame_processor.h" +#include "api/ref_count.h" #include "api/task_queue/task_queue_base.h" -#include "rtc_base/ref_count.h" namespace webrtc { diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index c3f061f69f..9649f0c940 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -528,6 +528,7 @@ rtc_library("neteq") { "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", "../../api/environment", + "../../api/neteq:delay_manager_api", "../../api/neteq:neteq_api", "../../api/neteq:neteq_controller_api", "../../api/neteq:tick_timer", @@ -570,8 +571,6 @@ rtc_library("neteq_tools_minimal") { "neteq/tools/neteq_input.h", "neteq/tools/neteq_test.cc", "neteq/tools/neteq_test.h", - "neteq/tools/packet.cc", - "neteq/tools/packet.h", "neteq/tools/packet_source.cc", "neteq/tools/packet_source.h", ] @@ -631,6 +630,7 @@ rtc_library("neteq_test_tools") { ":pcm16b", "../../api:array_view", "../../api:rtp_headers", + "../../api/units:timestamp", "../../common_audio", "../../rtc_base:buffer", "../../rtc_base:checks", @@ -765,6 +765,7 @@ rtc_library("audio_coding_modules_tests_shared") { "../../system_wrappers", "../../test:fileutils", "../../test:test_support", + "../rtp_rtcp:rtp_rtcp_format", "//testing/gtest", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", @@ -952,6 +953,7 @@ if (rtc_include_tests) { "../../api/neteq:default_neteq_factory", "../../api/neteq:neteq_api", "../../test:test_support", + "../rtp_rtcp:rtp_rtcp_format", "//testing/gtest", ] @@ -983,6 +985,7 @@ if (rtc_include_tests) { "../../rtc_base:copy_on_write_buffer", "../../rtc_base:stringutils", "../../test:test_support", + "../rtp_rtcp:rtp_rtcp_format", "//testing/gtest", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", @@ -1053,13 +1056,12 @@ if (rtc_include_tests) { "../../api:scoped_refptr", "../../api/audio_codecs:audio_codecs_api", "../../api/audio_codecs:builtin_audio_decoder_factory", - "../../api/environment:environment", + "../../api/environment", "../../api/neteq:neteq_api", "../../logging:rtc_event_log_parser", "../../rtc_base:checks", "../../rtc_base:refcount", "../../test:audio_test_common", - "../../test:field_trial", "../../test:fileutils", "../../test:test_support", "../rtp_rtcp:rtp_rtcp_format", @@ -1468,7 +1470,6 @@ if (rtc_include_tests) { "neteq/time_stretch_unittest.cc", "neteq/timestamp_scaler_unittest.cc", "neteq/tools/input_audio_file_unittest.cc", - "neteq/tools/packet_unittest.cc", "neteq/underrun_optimizer_unittest.cc", ] diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc index afa6f77d45..ac25d6faeb 100644 --- a/modules/audio_coding/acm2/acm_receive_test.cc +++ b/modules/audio_coding/acm2/acm_receive_test.cc @@ -10,14 +10,11 @@ #include "modules/audio_coding/acm2/acm_receive_test.h" -#include - -#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" @@ -26,8 +23,8 @@ #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" #include "modules/audio_coding/neteq/tools/packet_source.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "test/gtest.h" namespace webrtc { @@ -90,10 +87,10 @@ void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() { } void AcmReceiveTestOldApi::Run() { - for (std::unique_ptr packet(packet_source_->NextPacket()); packet; - packet = packet_source_->NextPacket()) { + for (std::unique_ptr packet = packet_source_->NextPacket(); + packet != nullptr; packet = packet_source_->NextPacket()) { // Pull audio until time to insert packet. - while (clock_.TimeInMilliseconds() < packet->time_ms()) { + while (clock_.CurrentTime() < packet->arrival_time()) { AudioFrame output_frame; bool muted; EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_frame, &muted)); @@ -118,16 +115,14 @@ void AcmReceiveTestOldApi::Run() { AfterGetAudio(); } - EXPECT_EQ(0, neteq_->InsertPacket( - packet->header(), - ArrayView(packet->payload(), - packet->payload_length_bytes()), - clock_.CurrentTime())) + RTPHeader rtp_header; + packet->GetHeader(&rtp_header); + EXPECT_EQ(0, neteq_->InsertPacket(rtp_header, packet->payload(), + clock_.CurrentTime())) << "Failure when inserting packet:" << std::endl - << " PT = " << static_cast(packet->header().payloadType) - << std::endl - << " TS = " << packet->header().timestamp << std::endl - << " SN = " << packet->header().sequenceNumber; + << " PT = " << static_cast(packet->PayloadType()) << std::endl + << " TS = " << packet->Timestamp() << std::endl + << " SN = " << packet->SequenceNumber(); } } diff --git a/modules/audio_coding/acm2/acm_remixing_unittest.cc b/modules/audio_coding/acm2/acm_remixing_unittest.cc index dfc3e50ad8..afdb591b93 100644 --- a/modules/audio_coding/acm2/acm_remixing_unittest.cc +++ b/modules/audio_coding/acm2/acm_remixing_unittest.cc @@ -18,7 +18,6 @@ #include "api/audio/audio_view.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/testsupport/file_utils.h" using ::testing::AllOf; using ::testing::Each; diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc index 64cd530934..54dc1c3a01 100644 --- a/modules/audio_coding/acm2/acm_send_test.cc +++ b/modules/audio_coding/acm2/acm_send_test.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/acm2/acm_send_test.h" -#include -#include - #include +#include +#include #include #include @@ -27,9 +26,8 @@ #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 "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" -#include "rtc_base/copy_on_write_buffer.h" namespace webrtc { namespace test { @@ -97,7 +95,7 @@ void AcmSendTestOldApi::RegisterExternalCodec( codec_registered_ = true; } -std::unique_ptr AcmSendTestOldApi::NextPacket() { +std::unique_ptr AcmSendTestOldApi::NextPacket() { RTC_DCHECK(codec_registered_); if (filter_.test(static_cast(payload_type_))) { // This payload type should be filtered out. Since the payload type is the @@ -141,35 +139,19 @@ int32_t AcmSendTestOldApi::SendData( return 0; } -std::unique_ptr AcmSendTestOldApi::CreatePacket() { - const size_t kRtpHeaderSize = 12; - CopyOnWriteBuffer packet_buffer(last_payload_vec_.size() + kRtpHeaderSize); - uint8_t* packet_memory = packet_buffer.MutableData(); - // Populate the header bytes. - packet_memory[0] = 0x80; - packet_memory[1] = static_cast(payload_type_); - packet_memory[2] = (sequence_number_ >> 8) & 0xFF; - packet_memory[3] = (sequence_number_) & 0xFF; - packet_memory[4] = (timestamp_ >> 24) & 0xFF; - packet_memory[5] = (timestamp_ >> 16) & 0xFF; - packet_memory[6] = (timestamp_ >> 8) & 0xFF; - packet_memory[7] = timestamp_ & 0xFF; - // Set SSRC to 0x12345678. - packet_memory[8] = 0x12; - packet_memory[9] = 0x34; - packet_memory[10] = 0x56; - packet_memory[11] = 0x78; +std::unique_ptr AcmSendTestOldApi::CreatePacket() { + auto rtp_packet = std::make_unique(); + // Populate the header. + rtp_packet->SetPayloadType(payload_type_); + rtp_packet->SetSequenceNumber(sequence_number_); + rtp_packet->SetTimestamp(timestamp_); + rtp_packet->SetSsrc(0x12345678); ++sequence_number_; - // Copy the payload data. - memcpy(packet_memory + kRtpHeaderSize, &last_payload_vec_[0], - last_payload_vec_.size()); - auto packet = std::make_unique(std::move(packet_buffer), - clock_.TimeInMilliseconds()); - RTC_DCHECK(packet); - RTC_DCHECK(packet->valid_header()); - return packet; + rtp_packet->SetPayload(last_payload_vec_); + rtp_packet->set_arrival_time(clock_.CurrentTime()); + return rtp_packet; } } // namespace test diff --git a/modules/audio_coding/acm2/acm_send_test.h b/modules/audio_coding/acm2/acm_send_test.h index 694c1f92ed..ce61c4e3be 100644 --- a/modules/audio_coding/acm2/acm_send_test.h +++ b/modules/audio_coding/acm2/acm_send_test.h @@ -22,6 +22,7 @@ #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 "modules/rtp_rtcp/source/rtp_packet_received.h" #include "system_wrappers/include/clock.h" namespace webrtc { @@ -29,7 +30,6 @@ class AudioEncoder; namespace test { class InputAudioFile; -class Packet; class AcmSendTestOldApi : public AudioPacketizationCallback, public PacketSource { @@ -54,7 +54,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback, std::unique_ptr external_speech_encoder); // Inherited from PacketSource. - std::unique_ptr NextPacket() override; + std::unique_ptr NextPacket() override; // Inherited from AudioPacketizationCallback. int32_t SendData(AudioFrameType frame_type, @@ -71,7 +71,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback, // Creates a Packet object from the last packet produced by ACM (and received // through the SendData method as a callback). - std::unique_ptr CreatePacket(); + std::unique_ptr CreatePacket(); SimulatedClock clock_; const Environment env_; diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc index 7982ffc1b3..cf24060992 100644 --- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -11,11 +11,12 @@ #include "modules/audio_coding/include/audio_coding_module.h" #include -#include #include #include #include +#include +#include #include #include #include @@ -54,7 +55,7 @@ #include "modules/audio_coding/neteq/tools/input_audio_file.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/packet.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/buffer.h" #include "rtc_base/event.h" #include "rtc_base/message_digest.h" @@ -666,7 +667,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() != nullptr; + return send_test_ != nullptr; } // Registers a send codec in the test::AcmSendTest object. Returns true on @@ -755,7 +756,7 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, } // Inherited from test::PacketSource. - std::unique_ptr NextPacket() override { + std::unique_ptr NextPacket() override { auto packet = send_test_->NextPacket(); if (!packet) return nullptr; @@ -768,24 +769,23 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test, } // Verifies the packet. - void VerifyPacket(const test::Packet* packet) { - EXPECT_TRUE(packet->valid_header()); + void VerifyPacket(const RtpPacketReceived* packet) { // (We can check the header fields even if valid_header() is false.) - EXPECT_EQ(payload_type_, packet->header().payloadType); + EXPECT_EQ(payload_type_, packet->PayloadType()); if (packet_count_ > 0) { // This is not the first packet. uint16_t sequence_number_diff = - packet->header().sequenceNumber - last_sequence_number_; + packet->SequenceNumber() - last_sequence_number_; EXPECT_EQ(1, sequence_number_diff); - uint32_t timestamp_diff = packet->header().timestamp - last_timestamp_; + uint32_t timestamp_diff = packet->Timestamp() - last_timestamp_; EXPECT_EQ(frame_size_rtp_timestamps_, timestamp_diff); } ++packet_count_; - last_sequence_number_ = packet->header().sequenceNumber; - last_timestamp_ = packet->header().timestamp; + last_sequence_number_ = packet->SequenceNumber(); + last_timestamp_ = packet->Timestamp(); // Update the checksum. - payload_checksum_->Update(packet->payload(), - packet->payload_length_bytes()); + payload_checksum_->Update(packet->payload().data(), + packet->payload().size()); } void SetUpTest(absl::string_view codec_name, @@ -1076,9 +1076,9 @@ class AcmSetBitRateTest : public ::testing::Test { void RunInner(int min_expected_total_bits, int max_expected_total_bits) { int nr_bytes = 0; - while (std::unique_ptr next_packet = + while (std::unique_ptr next_packet = send_test_->NextPacket()) { - nr_bytes += checked_cast(next_packet->payload_length_bytes()); + nr_bytes += checked_cast(next_packet->payload_size()); } EXPECT_LE(min_expected_total_bits, nr_bytes * 8); EXPECT_GE(max_expected_total_bits, nr_bytes * 8); @@ -1332,7 +1332,7 @@ class AcmSwitchingOutputFrequencyOldApi : public ::testing::Test, } // Inherited from test::PacketSource. - std::unique_ptr NextPacket() override { + std::unique_ptr NextPacket() override { // Check if it is time to terminate the test. The packet source is of type // ConstantPcmPacketSource, which is infinite, so we must end the test // "manually". 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 74979843fa..a6e1041e18 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 @@ -10,9 +10,8 @@ #include "modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h" -#include - #include +#include #include #include #include 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 3e12125bc8..e9bffa21b8 100644 --- a/modules/audio_coding/audio_network_adaptor/event_log_writer.cc +++ b/modules/audio_coding/audio_network_adaptor/event_log_writer.cc @@ -10,9 +10,8 @@ #include "modules/audio_coding/audio_network_adaptor/event_log_writer.h" -#include - #include +#include #include #include #include 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 4f5e3af616..9ba69d1575 100644 --- a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc +++ b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc @@ -41,9 +41,9 @@ using ::testing::SetArgPointee; namespace webrtc { namespace { -const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. -const size_t kMockReturnEncodedBytes = 17; -const int kCngPayloadType = 18; +constexpr size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. +constexpr size_t kMockReturnEncodedBytes = 17; +constexpr int kCngPayloadType = 18; } // namespace class AudioEncoderCngTest : public ::testing::Test { diff --git a/modules/audio_coding/codecs/g711/test/testG711.cc b/modules/audio_coding/codecs/g711/test/testG711.cc index 770836c337..bd9bf07bed 100644 --- a/modules/audio_coding/codecs/g711/test/testG711.cc +++ b/modules/audio_coding/codecs/g711/test/testG711.cc @@ -12,17 +12,15 @@ * testG711.cpp : Defines the entry point for the console application. */ -#include -#include -#include +#include +#include +#include +#include +#include -/* include API */ #include "modules/audio_coding/codecs/g711/g711_interface.h" /* Runtime statistics */ -#include - -#include #define CLOCKS_PER_SEC_G711 1000 /* function for reading audio data from PCM file */ diff --git a/modules/audio_coding/codecs/g722/audio_decoder_g722.cc b/modules/audio_coding/codecs/g722/audio_decoder_g722.cc index 0fbf91474f..7fdb7d6ded 100644 --- a/modules/audio_coding/codecs/g722/audio_decoder_g722.cc +++ b/modules/audio_coding/codecs/g722/audio_decoder_g722.cc @@ -10,9 +10,8 @@ #include "modules/audio_coding/codecs/g722/audio_decoder_g722.h" -#include - #include +#include #include #include diff --git a/modules/audio_coding/codecs/g722/test/testG722.cc b/modules/audio_coding/codecs/g722/test/testG722.cc index fcff08edd2..fc0fab6798 100644 --- a/modules/audio_coding/codecs/g722/test/testG722.cc +++ b/modules/audio_coding/codecs/g722/test/testG722.cc @@ -12,17 +12,15 @@ * testG722.cpp : Defines the entry point for the console application. */ -#include -#include -#include +#include +#include +#include +#include +#include -/* include API */ #include "modules/audio_coding/codecs/g722/g722_interface.h" /* Runtime statistics */ -#include - -#include #define CLOCKS_PER_SEC_G722 100000 // Forward declaration diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc index 85995137ef..73a6ea5b64 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -482,7 +482,7 @@ bool AudioEncoderOpusImpl::EnableAudioNetworkAdaptor( RtcEventLog* event_log) { audio_network_adaptor_ = audio_network_adaptor_creator_(config_string, event_log); - return audio_network_adaptor_.get() != nullptr; + return audio_network_adaptor_ != nullptr; } void AudioEncoderOpusImpl::DisableAudioNetworkAdaptor() { diff --git a/modules/audio_coding/codecs/opus/opus_unittest.cc b/modules/audio_coding/codecs/opus/opus_unittest.cc index af00347c3e..3d86918339 100644 --- a/modules/audio_coding/codecs/opus/opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/opus_unittest.cc @@ -113,7 +113,7 @@ using ::testing::TestWithParam; using ::testing::Values; // Maximum number of bytes in output bitstream. -const size_t kMaxBytes = 2000; +constexpr size_t kMaxBytes = 2000; class OpusTest : public TestWithParam<::testing::tuple> { diff --git a/modules/audio_coding/codecs/opus/test/blocker.cc b/modules/audio_coding/codecs/opus/test/blocker.cc index 33406cead9..321a3f9770 100644 --- a/modules/audio_coding/codecs/opus/test/blocker.cc +++ b/modules/audio_coding/codecs/opus/test/blocker.cc @@ -10,7 +10,7 @@ #include "modules/audio_coding/codecs/opus/test/blocker.h" -#include +#include #include "rtc_base/checks.h" diff --git a/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc b/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc index 28962853e9..adf5e4ead1 100644 --- a/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc +++ b/modules/audio_coding/codecs/pcm16b/pcm16b_common.cc @@ -10,8 +10,7 @@ #include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h" -#include - +#include #include #include 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 725aec0226..e7bb2952a8 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h" -#include - #include #include +#include #include #include #include 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 0349926d72..14d6e73395 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 @@ -43,8 +43,8 @@ using ::testing::SetArgPointee; namespace webrtc { namespace { -const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. -const size_t kRedLastHeaderLength = +constexpr size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. +constexpr size_t kRedLastHeaderLength = 1; // 1 byte RED header for the last element. } // namespace diff --git a/modules/audio_coding/neteq/audio_decoder_unittest.cc b/modules/audio_coding/neteq/audio_decoder_unittest.cc index a22b0f15d6..ff0ca8011a 100644 --- a/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -10,10 +10,9 @@ #include "api/audio_codecs/audio_decoder.h" -#include - #include #include +#include #include #include #include diff --git a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc index a7bc4ea323..857028d470 100644 --- a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc +++ b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc @@ -10,9 +10,8 @@ #include "modules/audio_coding/neteq/audio_multi_vector.h" -#include - #include +#include #include #include #include diff --git a/modules/audio_coding/neteq/audio_vector_unittest.cc b/modules/audio_coding/neteq/audio_vector_unittest.cc index f048594109..21ce8419ec 100644 --- a/modules/audio_coding/neteq/audio_vector_unittest.cc +++ b/modules/audio_coding/neteq/audio_vector_unittest.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/audio_vector.h" -#include - #include #include +#include #include "api/audio/audio_view.h" #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/neteq/background_noise.cc b/modules/audio_coding/neteq/background_noise.cc index 50c622eb21..36f2189f8f 100644 --- a/modules/audio_coding/neteq/background_noise.cc +++ b/modules/audio_coding/neteq/background_noise.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/background_noise.h" -#include // memcpy - #include // min, max #include +#include // memcpy #include "api/array_view.h" #include "common_audio/signal_processing/dot_product_with_scale.h" diff --git a/modules/audio_coding/neteq/buffer_level_filter.cc b/modules/audio_coding/neteq/buffer_level_filter.cc index d2070a4bae..31494fdbef 100644 --- a/modules/audio_coding/neteq/buffer_level_filter.cc +++ b/modules/audio_coding/neteq/buffer_level_filter.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/buffer_level_filter.h" -#include - #include #include +#include #include "rtc_base/numerics/safe_conversions.h" diff --git a/modules/audio_coding/neteq/buffer_level_filter_unittest.cc b/modules/audio_coding/neteq/buffer_level_filter_unittest.cc index 28452d6b62..091a281f69 100644 --- a/modules/audio_coding/neteq/buffer_level_filter_unittest.cc +++ b/modules/audio_coding/neteq/buffer_level_filter_unittest.cc @@ -12,7 +12,7 @@ #include "modules/audio_coding/neteq/buffer_level_filter.h" -#include // Access to pow function. +#include // Access to pow function. #include "rtc_base/strings/string_builder.h" #include "test/gtest.h" diff --git a/modules/audio_coding/neteq/decision_logic.cc b/modules/audio_coding/neteq/decision_logic.cc index accc34e7c8..75a2cd7086 100644 --- a/modules/audio_coding/neteq/decision_logic.cc +++ b/modules/audio_coding/neteq/decision_logic.cc @@ -10,18 +10,17 @@ #include "modules/audio_coding/neteq/decision_logic.h" -#include - #include +#include #include #include #include #include "api/environment/environment.h" +#include "api/neteq/delay_manager_interface.h" #include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" #include "modules/audio_coding/neteq/buffer_level_filter.h" -#include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/packet_arrival_history.h" #include "modules/audio_coding/neteq/packet_buffer.h" #include "rtc_base/checks.h" @@ -39,14 +38,6 @@ constexpr int kDelayAdjustmentGranularityMs = 20; constexpr int kPacketHistorySizeMs = 2000; constexpr size_t kCngTimeoutMs = 1000; -std::unique_ptr CreateDelayManager( - const Environment& env, - const NetEqController::Config& neteq_config) { - DelayManager::Config config(env.field_trials()); - config.Log(); - return std::make_unique(config, neteq_config.tick_timer); -} - bool IsTimestretch(NetEq::Mode mode) { return mode == NetEq::Mode::kAccelerateSuccess || mode == NetEq::Mode::kAccelerateLowEnergy || @@ -65,15 +56,17 @@ bool IsExpand(NetEq::Mode mode) { } // namespace -DecisionLogic::DecisionLogic(const Environment& env, - NetEqController::Config config) +DecisionLogic::DecisionLogic( + const Environment& env, + NetEqController::Config config, + std::unique_ptr delay_manager) : DecisionLogic(config, - CreateDelayManager(env, config), + std::move(delay_manager), std::make_unique()) {} DecisionLogic::DecisionLogic( NetEqController::Config config, - std::unique_ptr delay_manager, + std::unique_ptr delay_manager, std::unique_ptr buffer_level_filter, std::unique_ptr packet_arrival_history) : delay_manager_(std::move(delay_manager)), @@ -197,7 +190,7 @@ std::optional DecisionLogic::PacketArrived(int fs_hz, packet_arrival_history_->GetDelayMs(info.main_timestamp); bool reordered = !packet_arrival_history_->IsNewestRtpTimestamp(info.main_timestamp); - delay_manager_->Update(arrival_delay_ms, reordered); + delay_manager_->Update(arrival_delay_ms, reordered, info); return arrival_delay_ms; } diff --git a/modules/audio_coding/neteq/decision_logic.h b/modules/audio_coding/neteq/decision_logic.h index 26dd8a46ae..cbc37c495e 100644 --- a/modules/audio_coding/neteq/decision_logic.h +++ b/modules/audio_coding/neteq/decision_logic.h @@ -17,12 +17,12 @@ #include #include "api/environment/environment.h" +#include "api/neteq/delay_manager_interface.h" #include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/buffer_level_filter.h" #include "modules/audio_coding/neteq/delay_constraints.h" -#include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/packet_arrival_history.h" namespace webrtc { @@ -30,10 +30,12 @@ namespace webrtc { // This is the class for the decision tree implementation. class DecisionLogic : public NetEqController { public: - DecisionLogic(const Environment& env, NetEqController::Config config); + DecisionLogic(const Environment& env, + NetEqController::Config config, + std::unique_ptr delay_manager); DecisionLogic( NetEqController::Config config, - std::unique_ptr delay_manager, + std::unique_ptr delay_manager, std::unique_ptr buffer_level_filter, std::unique_ptr packet_arrival_history = nullptr); @@ -150,7 +152,7 @@ class DecisionLogic : public NetEqController { int GetPlayoutDelayMs(NetEqController::NetEqStatus status) const; - std::unique_ptr delay_manager_; + std::unique_ptr delay_manager_; DelayConstraints delay_constraints_; std::unique_ptr buffer_level_filter_; std::unique_ptr packet_arrival_history_; diff --git a/modules/audio_coding/neteq/decoder_database.cc b/modules/audio_coding/neteq/decoder_database.cc index dbeba60171..df2edbe04b 100644 --- a/modules/audio_coding/neteq/decoder_database.cc +++ b/modules/audio_coding/neteq/decoder_database.cc @@ -10,8 +10,7 @@ #include "modules/audio_coding/neteq/decoder_database.h" -#include - +#include #include #include #include diff --git a/modules/audio_coding/neteq/decoder_database_unittest.cc b/modules/audio_coding/neteq/decoder_database_unittest.cc index 6df9ab3892..62106974eb 100644 --- a/modules/audio_coding/neteq/decoder_database_unittest.cc +++ b/modules/audio_coding/neteq/decoder_database_unittest.cc @@ -10,9 +10,8 @@ #include "modules/audio_coding/neteq/decoder_database.h" -#include - #include +#include #include #include #include diff --git a/modules/audio_coding/neteq/delay_manager.cc b/modules/audio_coding/neteq/delay_manager.cc index e9a99cfc76..e1f6e97bc2 100644 --- a/modules/audio_coding/neteq/delay_manager.cc +++ b/modules/audio_coding/neteq/delay_manager.cc @@ -10,13 +10,12 @@ #include "modules/audio_coding/neteq/delay_manager.h" -#include -#include - #include +#include #include #include "api/field_trials_view.h" +#include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/reorder_optimizer.h" #include "rtc_base/experiments/struct_parameters_parser.h" @@ -74,9 +73,9 @@ DelayManager::DelayManager(const Config& config, const TickTimer* tick_timer) Reset(); } -DelayManager::~DelayManager() {} - -void DelayManager::Update(int arrival_delay_ms, bool reordered) { +void DelayManager::Update(int arrival_delay_ms, + bool reordered, + NetEqController::PacketArrivedInfo info) { if (!reorder_optimizer_ || !reordered) { underrun_optimizer_.Update(arrival_delay_ms); } diff --git a/modules/audio_coding/neteq/delay_manager.h b/modules/audio_coding/neteq/delay_manager.h index 2e00328084..ae2441509a 100644 --- a/modules/audio_coding/neteq/delay_manager.h +++ b/modules/audio_coding/neteq/delay_manager.h @@ -15,13 +15,15 @@ #include #include "api/field_trials_view.h" +#include "api/neteq/delay_manager_interface.h" +#include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/reorder_optimizer.h" #include "modules/audio_coding/neteq/underrun_optimizer.h" namespace webrtc { -class DelayManager { +class DelayManager : public DelayManagerInterface { public: struct Config { explicit Config(const FieldTrialsView& field_trials); @@ -40,7 +42,7 @@ class DelayManager { DelayManager(const Config& config, const TickTimer* tick_timer); - virtual ~DelayManager(); + ~DelayManager() override = default; DelayManager(const DelayManager&) = delete; DelayManager& operator=(const DelayManager&) = delete; @@ -49,15 +51,17 @@ class DelayManager { // `arrival_delay_ms`. This updates the statistics and a new target buffer // level is calculated. The `reordered` flag indicates if the packet was // reordered. - virtual void Update(int arrival_delay_ms, bool reordered); + void Update(int arrival_delay_ms, + bool reordered, + NetEqController::PacketArrivedInfo info) override; // Resets all state. - virtual void Reset(); + void Reset() override; // Gets the target buffer level in milliseconds. If a minimum or maximum delay // has been set, the target delay reported here also respects the configured // min/max delay. - virtual int TargetDelayMs() const; + int TargetDelayMs() const override; private: UnderrunOptimizer underrun_optimizer_; diff --git a/modules/audio_coding/neteq/delay_manager_unittest.cc b/modules/audio_coding/neteq/delay_manager_unittest.cc index 79fc982ae7..96f1fc43e9 100644 --- a/modules/audio_coding/neteq/delay_manager_unittest.cc +++ b/modules/audio_coding/neteq/delay_manager_unittest.cc @@ -12,6 +12,7 @@ #include "modules/audio_coding/neteq/delay_manager.h" +#include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "test/create_test_field_trials.h" #include "test/gtest.h" @@ -23,7 +24,7 @@ TEST(DelayManagerTest, UpdateNormal) { TickTimer tick_timer; DelayManager dm(DelayManager::Config(CreateTestFieldTrials()), &tick_timer); for (int i = 0; i < 50; ++i) { - dm.Update(0, false); + dm.Update(0, false, NetEqController::PacketArrivedInfo()); tick_timer.Increment(2); } EXPECT_EQ(20, dm.TargetDelayMs()); diff --git a/modules/audio_coding/neteq/dsp_helper.cc b/modules/audio_coding/neteq/dsp_helper.cc index af3edcb103..62af4f1299 100644 --- a/modules/audio_coding/neteq/dsp_helper.cc +++ b/modules/audio_coding/neteq/dsp_helper.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/dsp_helper.h" -#include // Access to memset. - #include // Access to min, max. #include +#include // Access to memset. #include "common_audio/signal_processing/include/signal_processing_library.h" #include "modules/audio_coding/neteq/audio_multi_vector.h" diff --git a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc index 7a7d65aeff..6ff10916fe 100644 --- a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc +++ b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc @@ -12,8 +12,7 @@ #include "modules/audio_coding/neteq/dtmf_tone_generator.h" -#include - +#include #include #include diff --git a/modules/audio_coding/neteq/expand.cc b/modules/audio_coding/neteq/expand.cc index 88a68382ab..2617f8dec6 100644 --- a/modules/audio_coding/neteq/expand.cc +++ b/modules/audio_coding/neteq/expand.cc @@ -10,11 +10,10 @@ #include "modules/audio_coding/neteq/expand.h" -#include // memset - #include // min, max #include -#include // numeric_limits +#include // memset +#include // numeric_limits #include #include "common_audio/signal_processing/dot_product_with_scale.h" diff --git a/modules/audio_coding/neteq/expand_unittest.cc b/modules/audio_coding/neteq/expand_unittest.cc index 6e2c28327c..c641c1c596 100644 --- a/modules/audio_coding/neteq/expand_unittest.cc +++ b/modules/audio_coding/neteq/expand_unittest.cc @@ -28,6 +28,28 @@ namespace webrtc { +namespace { +class FakeStatisticsCalculator : public StatisticsCalculator { + public: + FakeStatisticsCalculator(TickTimer* tick_timer) + : StatisticsCalculator(tick_timer) {} + + void LogDelayedPacketOutageEvent(int num_samples, int /* fs_hz */) override { + last_outage_duration_samples_ = num_samples; + } + + int last_outage_duration_samples() const { + return last_outage_duration_samples_; + } + + private: + int last_outage_duration_samples_ = 0; +}; + +// This is the same size that is given to the SyncBuffer object in NetEq. +constexpr size_t kNetEqSyncBufferLengthMs = 720; +} // namespace + TEST(Expand, CreateAndDestroy) { int fs = 8000; size_t channels = 1; @@ -54,28 +76,6 @@ TEST(Expand, CreateUsingFactory) { delete expand; } -namespace { -class FakeStatisticsCalculator : public StatisticsCalculator { - public: - FakeStatisticsCalculator(TickTimer* tick_timer) - : StatisticsCalculator(tick_timer) {} - - void LogDelayedPacketOutageEvent(int num_samples, int /* fs_hz */) override { - last_outage_duration_samples_ = num_samples; - } - - int last_outage_duration_samples() const { - return last_outage_duration_samples_; - } - - private: - int last_outage_duration_samples_ = 0; -}; - -// This is the same size that is given to the SyncBuffer object in NetEq. -const size_t kNetEqSyncBufferLengthMs = 720; -} // namespace - class ExpandTest : public ::testing::Test { protected: ExpandTest() diff --git a/modules/audio_coding/neteq/merge.cc b/modules/audio_coding/neteq/merge.cc index e6a05ae587..8abaff7dbb 100644 --- a/modules/audio_coding/neteq/merge.cc +++ b/modules/audio_coding/neteq/merge.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/merge.h" -#include // memmove, memcpy, memset, size_t - #include // min, max #include +#include // memmove, memcpy, memset, size_t #include #include diff --git a/modules/audio_coding/neteq/merge_unittest.cc b/modules/audio_coding/neteq/merge_unittest.cc index eb5ee93455..140b3c79f2 100644 --- a/modules/audio_coding/neteq/merge_unittest.cc +++ b/modules/audio_coding/neteq/merge_unittest.cc @@ -43,7 +43,7 @@ TEST(Merge, CreateAndDestroy) { namespace { // This is the same size that is given to the SyncBuffer object in NetEq. -const size_t kNetEqSyncBufferLengthMs = 720; +constexpr size_t kNetEqSyncBufferLengthMs = 720; } // namespace class MergeTest : public testing::TestWithParam { diff --git a/modules/audio_coding/neteq/nack_tracker_unittest.cc b/modules/audio_coding/neteq/nack_tracker_unittest.cc index f3629805b0..2830a5b480 100644 --- a/modules/audio_coding/neteq/nack_tracker_unittest.cc +++ b/modules/audio_coding/neteq/nack_tracker_unittest.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/nack_tracker.h" -#include - #include #include +#include #include #include @@ -24,10 +23,10 @@ namespace webrtc { namespace { -const int kSampleRateHz = 16000; -const int kPacketSizeMs = 30; -const uint32_t kTimestampIncrement = 480; // 30 ms. -const int64_t kShortRoundTripTimeMs = 1; +constexpr int kSampleRateHz = 16000; +constexpr int kPacketSizeMs = 30; +constexpr uint32_t kTimestampIncrement = 480; // 30 ms. +constexpr int64_t kShortRoundTripTimeMs = 1; bool IsNackListCorrect(const std::vector& nack_list, const uint16_t* lost_sequence_numbers, diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc index e1de77c906..1830dab71c 100644 --- a/modules/audio_coding/neteq/neteq_impl.cc +++ b/modules/audio_coding/neteq/neteq_impl.cc @@ -254,6 +254,11 @@ bool NetEqImpl::RegisterPayloadType(int rtp_payload_type, DecoderDatabase::kOK; } +bool NetEqImpl::CreateDecoder(int rtp_payload_type) { + MutexLock lock(&mutex_); + return decoder_database_->GetDecoder(rtp_payload_type) != nullptr; +} + int NetEqImpl::RemovePayloadType(uint8_t rtp_payload_type) { MutexLock lock(&mutex_); int ret = decoder_database_->Remove(rtp_payload_type); diff --git a/modules/audio_coding/neteq/neteq_impl.h b/modules/audio_coding/neteq/neteq_impl.h index 150a18584b..5002c30e76 100644 --- a/modules/audio_coding/neteq/neteq_impl.h +++ b/modules/audio_coding/neteq/neteq_impl.h @@ -157,6 +157,8 @@ class NetEqImpl : public NetEq { bool RegisterPayloadType(int rtp_payload_type, const SdpAudioFormat& audio_format) override; + bool CreateDecoder(int rtp_payload_type) override; + // Removes `rtp_payload_type` from the codec database. Returns 0 on success, // -1 on failure. int RemovePayloadType(uint8_t rtp_payload_type) override; diff --git a/modules/audio_coding/neteq/neteq_impl_unittest.cc b/modules/audio_coding/neteq/neteq_impl_unittest.cc index a336e4cb2a..f375644ee1 100644 --- a/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -36,6 +36,7 @@ #include "api/scoped_refptr.h" #include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" #include "modules/audio_coding/neteq/decision_logic.h" +#include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/expand.h" #include "modules/audio_coding/neteq/mock/mock_decoder_database.h" #include "modules/audio_coding/neteq/mock/mock_dtmf_buffer.h" @@ -141,8 +142,10 @@ class NetEqImplTest : public ::testing::Test { controller_config.base_min_delay_ms = config_.min_delay_ms; controller_config.allow_time_stretching = true; controller_config.max_packets_in_buffer = config_.max_packets_in_buffer; - deps.neteq_controller = - std::make_unique(env_, std::move(controller_config)); + auto delay_manager = std::make_unique( + DelayManager::Config(env_.field_trials()), tick_timer_); + deps.neteq_controller = std::make_unique( + env_, std::move(controller_config), std::move(delay_manager)); } neteq_controller_ = deps.neteq_controller.get(); @@ -154,7 +157,7 @@ class NetEqImplTest : public ::testing::Test { red_payload_splitter_ = deps.red_payload_splitter.get(); deps.timestamp_scaler = std::unique_ptr( - new TimestampScaler(*deps.decoder_database.get())); + new TimestampScaler(*deps.decoder_database)); neteq_.reset(new NetEqImpl(config_, std::move(deps))); ASSERT_TRUE(neteq_ != nullptr); @@ -283,6 +286,15 @@ TEST_F(NetEqImplTest, RegisterPayloadType) { neteq_->RegisterPayloadType(rtp_payload_type, format); } +TEST_F(NetEqImplTest, CreateDecoder) { + UseNoMocks(); + CreateInstance(); + constexpr int rtp_payload_type = 0; + const SdpAudioFormat format("pcmu", 8000, 1); + EXPECT_TRUE(neteq_->RegisterPayloadType(rtp_payload_type, format)); + EXPECT_TRUE(neteq_->CreateDecoder(rtp_payload_type)); +} + TEST_F(NetEqImplTest, RemovePayloadType) { CreateInstance(); uint8_t rtp_payload_type = 0; diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc index 2b1d28302f..897532fc51 100644 --- a/modules/audio_coding/neteq/neteq_unittest.cc +++ b/modules/audio_coding/neteq/neteq_unittest.cc @@ -10,12 +10,10 @@ #include "api/neteq/neteq.h" -#include -#include -#include // memset - #include #include +#include +#include // memset #include #include #include diff --git a/modules/audio_coding/neteq/normal.cc b/modules/audio_coding/neteq/normal.cc index c3748d8931..909e955684 100644 --- a/modules/audio_coding/neteq/normal.cc +++ b/modules/audio_coding/neteq/normal.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/normal.h" -#include // memset, memcpy - #include // min #include +#include // memset, memcpy #include #include "api/array_view.h" diff --git a/modules/audio_coding/neteq/red_payload_splitter.cc b/modules/audio_coding/neteq/red_payload_splitter.cc index d8c27db218..2600be3b6d 100644 --- a/modules/audio_coding/neteq/red_payload_splitter.cc +++ b/modules/audio_coding/neteq/red_payload_splitter.cc @@ -10,8 +10,7 @@ #include "modules/audio_coding/neteq/red_payload_splitter.h" -#include - +#include #include #include #include diff --git a/modules/audio_coding/neteq/reorder_optimizer.cc b/modules/audio_coding/neteq/reorder_optimizer.cc index 98dbedfaa4..4b6a9b9a15 100644 --- a/modules/audio_coding/neteq/reorder_optimizer.cc +++ b/modules/audio_coding/neteq/reorder_optimizer.cc @@ -10,9 +10,8 @@ #include "modules/audio_coding/neteq/reorder_optimizer.h" -#include - #include +#include #include #include #include diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc index 1ae4221a64..3a0271140a 100644 --- a/modules/audio_coding/neteq/statistics_calculator.cc +++ b/modules/audio_coding/neteq/statistics_calculator.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/statistics_calculator.h" -#include // memset - #include #include +#include // memset #include "absl/strings/string_view.h" #include "api/neteq/neteq.h" diff --git a/modules/audio_coding/neteq/test/neteq_decoding_test.cc b/modules/audio_coding/neteq/test/neteq_decoding_test.cc index e44a387b10..17e9258e05 100644 --- a/modules/audio_coding/neteq/test/neteq_decoding_test.cc +++ b/modules/audio_coding/neteq/test/neteq_decoding_test.cc @@ -51,14 +51,6 @@ void LoadDecoders(NetEq* neteq) { neteq->RegisterPayloadType(0, SdpAudioFormat("pcmu", 8000, 1))); ASSERT_EQ(true, neteq->RegisterPayloadType(8, SdpAudioFormat("pcma", 8000, 1))); -#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) - ASSERT_EQ(true, - neteq->RegisterPayloadType(103, SdpAudioFormat("isac", 16000, 1))); -#endif -#ifdef WEBRTC_CODEC_ISAC - ASSERT_EQ(true, - neteq->RegisterPayloadType(104, SdpAudioFormat("isac", 32000, 1))); -#endif #ifdef WEBRTC_CODEC_OPUS ASSERT_EQ(true, neteq->RegisterPayloadType( @@ -111,17 +103,12 @@ void NetEqDecodingTest::OpenInputFile(absl::string_view rtp_file) { void NetEqDecodingTest::Process() { // Check if time to receive. - while (packet_ && clock_.TimeInMilliseconds() >= packet_->time_ms()) { - if (packet_->payload_length_bytes() > 0) { -#ifndef WEBRTC_CODEC_ISAC - // Ignore payload type 104 (iSAC-swb) if ISAC is not supported. - if (packet_->header().payloadType != 104) -#endif - ASSERT_EQ(0, neteq_->InsertPacket(packet_->header(), - ArrayView( - packet_->payload(), - packet_->payload_length_bytes()), - clock_.CurrentTime())); + while (packet_ && clock_.CurrentTime() >= packet_->arrival_time()) { + if (packet_->payload_size() > 0) { + RTPHeader rtp_header; + packet_->GetHeader(&rtp_header); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_header, packet_->payload(), + clock_.CurrentTime())); } // Get next packet. 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 a7557dcf0a..b4273ae5de 100644 --- a/modules/audio_coding/neteq/test/neteq_decoding_test.h +++ b/modules/audio_coding/neteq/test/neteq_decoding_test.h @@ -21,8 +21,8 @@ #include "api/environment/environment.h" #include "api/neteq/neteq.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/source/rtp_packet_received.h" #include "system_wrappers/include/clock.h" #include "test/gtest.h" @@ -76,7 +76,7 @@ class NetEqDecodingTest : public ::testing::Test { std::unique_ptr neteq_; NetEq::Config config_; std::unique_ptr rtp_source_; - std::unique_ptr packet_; + std::unique_ptr packet_; AudioFrame out_frame_; int output_sample_rate_; int algorithmic_delay_ms_; 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 9f1fffaa9f..bcea7bf9b2 100644 --- a/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc @@ -22,7 +22,6 @@ #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 c365d839cb..d69b2cc166 100644 --- a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc +++ b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc @@ -22,7 +22,6 @@ #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_speed_test.cc b/modules/audio_coding/neteq/test/neteq_speed_test.cc index 0ffee03aed..a3f7bad63d 100644 --- a/modules/audio_coding/neteq/test/neteq_speed_test.cc +++ b/modules/audio_coding/neteq/test/neteq_speed_test.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include +#include #include #include #include diff --git a/modules/audio_coding/neteq/time_stretch_unittest.cc b/modules/audio_coding/neteq/time_stretch_unittest.cc index 539312ab17..0cf9fd39e5 100644 --- a/modules/audio_coding/neteq/time_stretch_unittest.cc +++ b/modules/audio_coding/neteq/time_stretch_unittest.cc @@ -28,7 +28,7 @@ namespace webrtc { namespace { -const size_t kNumChannels = 1; +constexpr size_t kNumChannels = 1; } // namespace TEST(TimeStretch, CreateAndDestroy) { diff --git a/modules/audio_coding/neteq/tools/audio_loop.cc b/modules/audio_coding/neteq/tools/audio_loop.cc index cff9fd1d1d..ba67a66709 100644 --- a/modules/audio_coding/neteq/tools/audio_loop.cc +++ b/modules/audio_coding/neteq/tools/audio_loop.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/neteq/tools/audio_loop.h" -#include -#include - #include +#include +#include #include #include "absl/strings/string_view.h" 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 20cd8356d6..30ec11e9fc 100644 --- a/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc +++ b/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc @@ -13,12 +13,11 @@ #include #include #include -#include +#include "api/units/timestamp.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" -#include "modules/audio_coding/neteq/tools/packet.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" -#include "rtc_base/copy_on_write_buffer.h" namespace webrtc { namespace test { @@ -39,36 +38,27 @@ ConstantPcmPacketSource::ConstantPcmPacketSource(size_t payload_len_samples, RTC_CHECK_EQ(2U, encoded_len); } -std::unique_ptr ConstantPcmPacketSource::NextPacket() { +std::unique_ptr ConstantPcmPacketSource::NextPacket() { RTC_CHECK_GT(packet_len_bytes_, kHeaderLenBytes); - CopyOnWriteBuffer packet_buffer(packet_len_bytes_); - uint8_t* packet_memory = packet_buffer.MutableData(); + auto rtp_packet = std::make_unique(); + rtp_packet->SetPayloadType(payload_type_); + rtp_packet->SetSequenceNumber(seq_number_); + rtp_packet->SetTimestamp(timestamp_); + rtp_packet->SetSsrc(payload_ssrc_); + ++seq_number_; + timestamp_ += static_cast(payload_len_samples_); + + uint8_t* packet_memory = + rtp_packet->AllocatePayload(2 * payload_len_samples_); // Fill the payload part of the packet memory with the pre-encoded value. - for (unsigned i = 0; i < 2 * payload_len_samples_; ++i) - packet_memory[kHeaderLenBytes + i] = encoded_sample_[i % 2]; - WriteHeader(packet_memory); - // `packet` assumes ownership of `packet_memory`. - auto packet = - std::make_unique(std::move(packet_buffer), next_arrival_time_ms_); + for (size_t i = 0; i < 2 * payload_len_samples_; ++i) { + packet_memory[i] = encoded_sample_[i % 2]; + } + + rtp_packet->set_arrival_time(Timestamp::Millis(next_arrival_time_ms_)); next_arrival_time_ms_ += payload_len_samples_ / samples_per_ms_; - return packet; -} -void ConstantPcmPacketSource::WriteHeader(uint8_t* packet_memory) { - packet_memory[0] = 0x80; - packet_memory[1] = static_cast(payload_type_); - packet_memory[2] = seq_number_ >> 8; - packet_memory[3] = seq_number_ & 0xFF; - packet_memory[4] = timestamp_ >> 24; - packet_memory[5] = (timestamp_ >> 16) & 0xFF; - packet_memory[6] = (timestamp_ >> 8) & 0xFF; - packet_memory[7] = timestamp_ & 0xFF; - packet_memory[8] = payload_ssrc_ >> 24; - packet_memory[9] = (payload_ssrc_ >> 16) & 0xFF; - packet_memory[10] = (payload_ssrc_ >> 8) & 0xFF; - packet_memory[11] = payload_ssrc_ & 0xFF; - ++seq_number_; - timestamp_ += static_cast(payload_len_samples_); + return rtp_packet; } } // 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 4727aff583..8bb5df1245 100644 --- a/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h +++ b/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h @@ -16,8 +16,8 @@ #include #include -#include "modules/audio_coding/neteq/tools/packet.h" #include "modules/audio_coding/neteq/tools/packet_source.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" namespace webrtc { namespace test { @@ -35,11 +35,9 @@ class ConstantPcmPacketSource : public PacketSource { ConstantPcmPacketSource(const ConstantPcmPacketSource&) = delete; ConstantPcmPacketSource& operator=(const ConstantPcmPacketSource&) = delete; - std::unique_ptr NextPacket() override; + std::unique_ptr NextPacket() override; private: - void WriteHeader(uint8_t* packet_memory); - const size_t kHeaderLenBytes = 12; const size_t payload_len_samples_; const size_t packet_len_bytes_; diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/modules/audio_coding/neteq/tools/neteq_quality_test.cc index 161914995a..53bbb310e0 100644 --- a/modules/audio_coding/neteq/tools/neteq_quality_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_quality_test.cc @@ -10,12 +10,11 @@ #include "modules/audio_coding/neteq/tools/neteq_quality_test.h" -#include - #include #include #include #include +#include #include #include #include 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 29831dca6a..d438900f61 100644 --- a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc @@ -10,7 +10,6 @@ #include "modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h" -#include #include #include #include @@ -19,9 +18,9 @@ #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" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" namespace webrtc { namespace test { @@ -60,28 +59,17 @@ class NetEqRtpDumpInput : public NetEqInput { void AdvanceSetMinimumDelay() override {} std::optional NextPacketTime() const override { - return packet_ ? std::optional( - static_cast(packet_->time_ms())) - : std::nullopt; + return packet_ ? std::optional(packet_->arrival_time().ms()) : std::nullopt; } std::unique_ptr PopPacket() override { if (!packet_) { return std::unique_ptr(); } - std::unique_ptr packet_data(new PacketData); - packet_data->header = packet_->header(); - if (packet_->payload_length_bytes() == 0 && - packet_->virtual_payload_length_bytes() > 0) { - // This is a header-only "dummy" packet. Set the payload to all zeros, - // with length according to the virtual length. - packet_data->payload.SetSize(packet_->virtual_payload_length_bytes()); - std::fill_n(packet_data->payload.data(), packet_data->payload.size(), 0); - } else { - packet_data->payload.SetData(packet_->payload(), - packet_->payload_length_bytes()); - } - packet_data->time_ms = packet_->time_ms(); + auto packet_data = std::make_unique(); + packet_->GetHeader(&packet_data->header); + packet_data->payload.SetData(packet_->payload()); + packet_data->time_ms = packet_->arrival_time().ms(); LoadNextPacket(); @@ -89,7 +77,12 @@ class NetEqRtpDumpInput : public NetEqInput { } std::optional NextHeader() const override { - return packet_ ? std::optional(packet_->header()) : std::nullopt; + if (packet_ == nullptr) { + return std::nullopt; + } + RTPHeader rtp_header; + packet_->GetHeader(&rtp_header); + return rtp_header; } bool ended() const override { return !next_output_event_ms_; } @@ -101,7 +94,7 @@ class NetEqRtpDumpInput : public NetEqInput { static constexpr int64_t kOutputPeriodMs = 10; std::unique_ptr source_; - std::unique_ptr packet_; + std::unique_ptr packet_; }; } // namespace diff --git a/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc b/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc index f207199226..44ea9a7f02 100644 --- a/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc +++ b/modules/audio_coding/neteq/tools/neteq_stats_plotter.cc @@ -10,11 +10,10 @@ #include "modules/audio_coding/neteq/tools/neteq_stats_plotter.h" -#include -#include - #include +#include #include +#include #include #include diff --git a/modules/audio_coding/neteq/tools/neteq_test_factory.cc b/modules/audio_coding/neteq/tools/neteq_test_factory.cc index 857c633859..c2599dd5c2 100644 --- a/modules/audio_coding/neteq/tools/neteq_test_factory.cc +++ b/modules/audio_coding/neteq/tools/neteq_test_factory.cc @@ -10,11 +10,8 @@ #include "modules/audio_coding/neteq/tools/neteq_test_factory.h" -#include // For ULONG_MAX returned by strtoul. -#include -#include // For strtoul. - #include +#include // For strtoul. #include #include #include @@ -54,7 +51,6 @@ #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "rtc_base/checks.h" #include "test/function_audio_decoder_factory.h" -#include "test/testsupport/file_utils.h" namespace webrtc { namespace test { diff --git a/modules/audio_coding/neteq/tools/packet.cc b/modules/audio_coding/neteq/tools/packet.cc deleted file mode 100644 index 3e9ef26f66..0000000000 --- a/modules/audio_coding/neteq/tools/packet.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "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" - -namespace webrtc { -namespace test { - -Packet::Packet(CopyOnWriteBuffer packet, - size_t virtual_packet_length_bytes, - double time_ms, - const RtpHeaderExtensionMap* extension_map) - : packet_(std::move(packet)), - virtual_packet_length_bytes_(virtual_packet_length_bytes), - time_ms_(time_ms), - valid_header_(ParseHeader(extension_map)) {} - -Packet::Packet(const RTPHeader& header, - size_t virtual_packet_length_bytes, - size_t virtual_payload_length_bytes, - double time_ms) - : header_(header), - virtual_packet_length_bytes_(virtual_packet_length_bytes), - virtual_payload_length_bytes_(virtual_payload_length_bytes), - time_ms_(time_ms), - valid_header_(true) {} - -Packet::~Packet() = default; - -bool Packet::ExtractRedHeaders(std::list* headers) const { - // - // 0 1 2 3 - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // |1| block PT | timestamp offset | block length | - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // |1| ... | - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // |0| block PT | - // +-+-+-+-+-+-+-+-+ - // - - const uint8_t* payload_ptr = payload(); - const uint8_t* payload_end_ptr = payload_ptr + payload_length_bytes(); - - // Find all RED headers with the extension bit set to 1. That is, all headers - // but the last one. - while ((payload_ptr < payload_end_ptr) && (*payload_ptr & 0x80)) { - RTPHeader* header = new RTPHeader; - CopyToHeader(header); - header->payloadType = payload_ptr[0] & 0x7F; - uint32_t offset = (payload_ptr[1] << 6) + ((payload_ptr[2] & 0xFC) >> 2); - header->timestamp -= offset; - headers->push_front(header); - payload_ptr += 4; - } - // Last header. - RTC_DCHECK_LT(payload_ptr, payload_end_ptr); - if (payload_ptr >= payload_end_ptr) { - return false; // Payload too short. - } - RTPHeader* header = new RTPHeader; - CopyToHeader(header); - header->payloadType = payload_ptr[0] & 0x7F; - headers->push_front(header); - return true; -} - -void Packet::DeleteRedHeaders(std::list* headers) { - while (!headers->empty()) { - delete headers->front(); - headers->pop_front(); - } -} - -bool Packet::ParseHeader(const RtpHeaderExtensionMap* extension_map) { - // Use RtpPacketReceived instead of RtpPacket because former already has a - // converter into legacy RTPHeader. - 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 - // padding manually. Regular RTP packet parser reports failure, but it is fine - // in this context. - bool padding = (packet_[0] & 0b0010'0000); - size_t padding_size = 0; - if (padding) { - // Clear the padding bit to prevent failure when rtp payload is omited. - CopyOnWriteBuffer packet(packet_); - packet.MutableData()[0] &= ~0b0010'0000; - if (!rtp_packet.Parse(std::move(packet))) { - return false; - } - if (rtp_packet.payload_size() > 0) { - padding_size = rtp_packet.data()[rtp_packet.size() - 1]; - } - if (padding_size > rtp_packet.payload_size()) { - return false; - } - } else { - if (!rtp_packet.Parse(packet_)) { - return false; - } - } - rtp_payload_ = MakeArrayView(packet_.data() + rtp_packet.headers_size(), - rtp_packet.payload_size() - padding_size); - rtp_packet.GetHeader(&header_); - - RTC_CHECK_GE(virtual_packet_length_bytes_, rtp_packet.size()); - RTC_DCHECK_GE(virtual_packet_length_bytes_, rtp_packet.headers_size()); - virtual_payload_length_bytes_ = - virtual_packet_length_bytes_ - rtp_packet.headers_size(); - return true; -} - -void Packet::CopyToHeader(RTPHeader* destination) const { - *destination = header_; -} - -} // namespace test -} // namespace webrtc diff --git a/modules/audio_coding/neteq/tools/packet.h b/modules/audio_coding/neteq/tools/packet.h deleted file mode 100644 index 6d13ba6d4e..0000000000 --- a/modules/audio_coding/neteq/tools/packet.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_H_ -#define MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_H_ - -#include -#include -#include - -#include "api/array_view.h" -#include "api/rtp_headers.h" -#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" -#include "rtc_base/copy_on_write_buffer.h" - -namespace webrtc { -namespace test { - -// Class for handling RTP packets in test applications. -class Packet { - public: - // Creates a packet, with the packet payload (including header bytes) in - // `packet`. The `time_ms` is an extra time associated with this packet, - // typically used to denote arrival time. - // `virtual_packet_length_bytes` is typically used when reading RTP dump files - // that only contain the RTP headers, and no payload (a.k.a RTP dummy files or - // RTP light). The `virtual_packet_length_bytes` tells what size the packet - // had on wire, including the now discarded payload. - Packet(CopyOnWriteBuffer packet, - size_t virtual_packet_length_bytes, - double time_ms, - const RtpHeaderExtensionMap* extension_map = nullptr); - - Packet(CopyOnWriteBuffer packet, - double time_ms, - const RtpHeaderExtensionMap* extension_map = nullptr) - : Packet(packet, packet.size(), time_ms, extension_map) {} - - // Same as above, but creates the packet from an already parsed RTPHeader. - // This is typically used when reading RTP dump files that only contain the - // RTP headers, and no payload. The `virtual_packet_length_bytes` tells what - // size the packet had on wire, including the now discarded payload, - // The `virtual_payload_length_bytes` tells the size of the payload. - Packet(const RTPHeader& header, - size_t virtual_packet_length_bytes, - size_t virtual_payload_length_bytes, - double time_ms); - - virtual ~Packet(); - - Packet(const Packet&) = delete; - Packet& operator=(const Packet&) = delete; - - // Parses the first bytes of the RTP payload, interpreting them as RED headers - // according to RFC 2198. The headers will be inserted into `headers`. The - // caller of the method assumes ownership of the objects in the list, and - // must delete them properly. - bool ExtractRedHeaders(std::list* headers) const; - - // Deletes all RTPHeader objects in `headers`, but does not delete `headers` - // itself. - static void DeleteRedHeaders(std::list* headers); - - const uint8_t* payload() const { return rtp_payload_.data(); } - - size_t packet_length_bytes() const { return packet_.size(); } - - size_t payload_length_bytes() const { return rtp_payload_.size(); } - - size_t virtual_packet_length_bytes() const { - return virtual_packet_length_bytes_; - } - - size_t virtual_payload_length_bytes() const { - return virtual_payload_length_bytes_; - } - - const RTPHeader& header() const { return header_; } - - double time_ms() const { return time_ms_; } - bool valid_header() const { return valid_header_; } - - private: - bool ParseHeader(const RtpHeaderExtensionMap* extension_map); - void CopyToHeader(RTPHeader* destination) const; - - RTPHeader header_; - const CopyOnWriteBuffer packet_; - ArrayView rtp_payload_; // Empty for dummy RTP packets. - // Virtual lengths are used when parsing RTP header files (dummy RTP files). - const size_t virtual_packet_length_bytes_; - size_t virtual_payload_length_bytes_ = 0; - const double time_ms_; // Used to denote a packet's arrival time. - const bool valid_header_; -}; - -} // namespace test -} // namespace webrtc -#endif // MODULES_AUDIO_CODING_NETEQ_TOOLS_PACKET_H_ diff --git a/modules/audio_coding/neteq/tools/packet_source.h b/modules/audio_coding/neteq/tools/packet_source.h index 68de0d51ed..c74bf00f4a 100644 --- a/modules/audio_coding/neteq/tools/packet_source.h +++ b/modules/audio_coding/neteq/tools/packet_source.h @@ -15,7 +15,7 @@ #include #include -#include "modules/audio_coding/neteq/tools/packet.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" namespace webrtc { namespace test { @@ -31,7 +31,7 @@ class PacketSource { // Returns next packet. Returns nullptr if the source is depleted, or if an // error occurred. - virtual std::unique_ptr NextPacket() = 0; + virtual std::unique_ptr NextPacket() = 0; virtual void FilterOutPayloadType(uint8_t payload_type); diff --git a/modules/audio_coding/neteq/tools/packet_unittest.cc b/modules/audio_coding/neteq/tools/packet_unittest.cc deleted file mode 100644 index df516d885c..0000000000 --- a/modules/audio_coding/neteq/tools/packet_unittest.cc +++ /dev/null @@ -1,233 +0,0 @@ -/* - * 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. - */ - -// Unit tests for test Packet class. - -#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 { -namespace test { - -namespace { -const int kHeaderLengthBytes = 12; - -void MakeRtpHeader(int payload_type, - int seq_number, - uint32_t timestamp, - uint32_t ssrc, - uint8_t* rtp_data) { - rtp_data[0] = 0x80; - rtp_data[1] = static_cast(payload_type); - rtp_data[2] = (seq_number >> 8) & 0xFF; - rtp_data[3] = (seq_number) & 0xFF; - rtp_data[4] = timestamp >> 24; - rtp_data[5] = (timestamp >> 16) & 0xFF; - rtp_data[6] = (timestamp >> 8) & 0xFF; - rtp_data[7] = timestamp & 0xFF; - rtp_data[8] = ssrc >> 24; - rtp_data[9] = (ssrc >> 16) & 0xFF; - rtp_data[10] = (ssrc >> 8) & 0xFF; - rtp_data[11] = ssrc & 0xFF; -} -} // namespace - -TEST(TestPacket, RegularPacket) { - const size_t kPacketLengthBytes = 100; - CopyOnWriteBuffer packet_memory(kPacketLengthBytes); - const uint8_t kPayloadType = 17; - const uint16_t kSequenceNumber = 4711; - const uint32_t kTimestamp = 47114711; - const uint32_t kSsrc = 0x12345678; - MakeRtpHeader(kPayloadType, kSequenceNumber, kTimestamp, kSsrc, - packet_memory.MutableData()); - const double kPacketTime = 1.0; - Packet packet(std::move(packet_memory), kPacketTime); - ASSERT_TRUE(packet.valid_header()); - EXPECT_EQ(kPayloadType, packet.header().payloadType); - EXPECT_EQ(kSequenceNumber, packet.header().sequenceNumber); - EXPECT_EQ(kTimestamp, packet.header().timestamp); - EXPECT_EQ(kSsrc, packet.header().ssrc); - EXPECT_EQ(0, packet.header().numCSRCs); - EXPECT_EQ(kPacketLengthBytes, packet.packet_length_bytes()); - EXPECT_EQ(kPacketLengthBytes - kHeaderLengthBytes, - packet.payload_length_bytes()); - EXPECT_EQ(kPacketLengthBytes, packet.virtual_packet_length_bytes()); - EXPECT_EQ(kPacketLengthBytes - kHeaderLengthBytes, - packet.virtual_payload_length_bytes()); - EXPECT_EQ(kPacketTime, packet.time_ms()); -} - -TEST(TestPacket, DummyPacket) { - const size_t kPacketLengthBytes = kHeaderLengthBytes; // Only RTP header. - const size_t kVirtualPacketLengthBytes = 100; - CopyOnWriteBuffer packet_memory(kPacketLengthBytes); - const uint8_t kPayloadType = 17; - const uint16_t kSequenceNumber = 4711; - const uint32_t kTimestamp = 47114711; - const uint32_t kSsrc = 0x12345678; - MakeRtpHeader(kPayloadType, kSequenceNumber, kTimestamp, kSsrc, - packet_memory.MutableData()); - const double kPacketTime = 1.0; - Packet packet(std::move(packet_memory), kVirtualPacketLengthBytes, - kPacketTime); - ASSERT_TRUE(packet.valid_header()); - EXPECT_EQ(kPayloadType, packet.header().payloadType); - EXPECT_EQ(kSequenceNumber, packet.header().sequenceNumber); - EXPECT_EQ(kTimestamp, packet.header().timestamp); - EXPECT_EQ(kSsrc, packet.header().ssrc); - EXPECT_EQ(0, packet.header().numCSRCs); - EXPECT_EQ(kPacketLengthBytes, packet.packet_length_bytes()); - EXPECT_EQ(kPacketLengthBytes - kHeaderLengthBytes, - packet.payload_length_bytes()); - EXPECT_EQ(kVirtualPacketLengthBytes, packet.virtual_packet_length_bytes()); - EXPECT_EQ(kVirtualPacketLengthBytes - kHeaderLengthBytes, - packet.virtual_payload_length_bytes()); - EXPECT_EQ(kPacketTime, packet.time_ms()); -} - -TEST(TestPacket, DummyPaddingPacket) { - const size_t kPacketLengthBytes = kHeaderLengthBytes; // Only RTP header. - const size_t kVirtualPacketLengthBytes = 100; - CopyOnWriteBuffer packet_memory(kPacketLengthBytes); - const uint8_t kPayloadType = 17; - const uint16_t kSequenceNumber = 4711; - const uint32_t kTimestamp = 47114711; - const uint32_t kSsrc = 0x12345678; - MakeRtpHeader(kPayloadType, kSequenceNumber, kTimestamp, kSsrc, - packet_memory.MutableData()); - packet_memory.MutableData()[0] |= 0b0010'0000; // Set the padding bit. - const double kPacketTime = 1.0; - Packet packet(std::move(packet_memory), kVirtualPacketLengthBytes, - kPacketTime); - ASSERT_TRUE(packet.valid_header()); - EXPECT_EQ(kPayloadType, packet.header().payloadType); - EXPECT_EQ(kSequenceNumber, packet.header().sequenceNumber); - EXPECT_EQ(kTimestamp, packet.header().timestamp); - EXPECT_EQ(kSsrc, packet.header().ssrc); - EXPECT_EQ(0, packet.header().numCSRCs); - EXPECT_EQ(kPacketLengthBytes, packet.packet_length_bytes()); - EXPECT_EQ(kPacketLengthBytes - kHeaderLengthBytes, - packet.payload_length_bytes()); - EXPECT_EQ(kVirtualPacketLengthBytes, packet.virtual_packet_length_bytes()); - EXPECT_EQ(kVirtualPacketLengthBytes - kHeaderLengthBytes, - packet.virtual_payload_length_bytes()); - EXPECT_EQ(kPacketTime, packet.time_ms()); -} - -namespace { -// Writes one RED block header starting at `rtp_data`, according to RFC 2198. -// returns the number of bytes written (1 or 4). -// -// Format if `last_payoad` is false: -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |1| block PT | timestamp offset | block length | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// Format if `last_payoad` is true: -// 0 1 2 3 4 5 6 7 -// +-+-+-+-+-+-+-+-+ -// |0| Block PT | -// +-+-+-+-+-+-+-+-+ - -int MakeRedHeader(int payload_type, - uint32_t timestamp_offset, - int block_length, - bool last_payload, - uint8_t* rtp_data) { - rtp_data[0] = 0x80 | (payload_type & 0x7F); // Set the first bit to 1. - if (last_payload) { - rtp_data[0] &= 0x7F; // Reset the first but to 0 to indicate last block. - return 1; - } - rtp_data[1] = timestamp_offset >> 6; - rtp_data[2] = (timestamp_offset & 0x3F) << 2; - rtp_data[2] |= block_length >> 8; - rtp_data[3] = block_length & 0xFF; - return 4; -} -} // namespace - -TEST(TestPacket, RED) { - const size_t kPacketLengthBytes = 100; - CopyOnWriteBuffer packet_memory(kPacketLengthBytes); - const uint8_t kRedPayloadType = 17; - const uint16_t kSequenceNumber = 4711; - const uint32_t kTimestamp = 47114711; - const uint32_t kSsrc = 0x12345678; - MakeRtpHeader(kRedPayloadType, kSequenceNumber, kTimestamp, kSsrc, - packet_memory.MutableData()); - // Create four RED headers. - // Payload types are just the same as the block index the offset is 100 times - // the block index. - const int kRedBlocks = 4; - uint8_t* payload_ptr = packet_memory.MutableData() + - kHeaderLengthBytes; // First byte after header. - for (int i = 0; i < kRedBlocks; ++i) { - int payload_type = i; - // Offset value is not used for the last block. - uint32_t timestamp_offset = 100 * i; - int block_length = 10 * i; - bool last_block = (i == kRedBlocks - 1) ? true : false; - payload_ptr += MakeRedHeader(payload_type, timestamp_offset, block_length, - last_block, payload_ptr); - } - const double kPacketTime = 1.0; - // Hand over ownership of `packet_memory` to `packet`. - Packet packet(packet_memory, kPacketLengthBytes, kPacketTime); - ASSERT_TRUE(packet.valid_header()); - EXPECT_EQ(kRedPayloadType, packet.header().payloadType); - EXPECT_EQ(kSequenceNumber, packet.header().sequenceNumber); - EXPECT_EQ(kTimestamp, packet.header().timestamp); - EXPECT_EQ(kSsrc, packet.header().ssrc); - EXPECT_EQ(0, packet.header().numCSRCs); - EXPECT_EQ(kPacketLengthBytes, packet.packet_length_bytes()); - EXPECT_EQ(kPacketLengthBytes - kHeaderLengthBytes, - packet.payload_length_bytes()); - EXPECT_EQ(kPacketLengthBytes, packet.virtual_packet_length_bytes()); - EXPECT_EQ(kPacketLengthBytes - kHeaderLengthBytes, - packet.virtual_payload_length_bytes()); - EXPECT_EQ(kPacketTime, packet.time_ms()); - std::list red_headers; - EXPECT_TRUE(packet.ExtractRedHeaders(&red_headers)); - EXPECT_EQ(kRedBlocks, static_cast(red_headers.size())); - int block_index = 0; - for (std::list::reverse_iterator it = red_headers.rbegin(); - it != red_headers.rend(); ++it) { - // Reading list from the back, since the extraction puts the main payload - // (which is the last one on wire) first. - RTPHeader* red_block = *it; - EXPECT_EQ(block_index, red_block->payloadType); - EXPECT_EQ(kSequenceNumber, red_block->sequenceNumber); - if (block_index == kRedBlocks - 1) { - // Last block has zero offset per definition. - EXPECT_EQ(kTimestamp, red_block->timestamp); - } else { - EXPECT_EQ(kTimestamp - 100 * block_index, red_block->timestamp); - } - EXPECT_EQ(kSsrc, red_block->ssrc); - EXPECT_EQ(0, red_block->numCSRCs); - ++block_index; - } - Packet::DeleteRedHeaders(&red_headers); -} - -} // namespace test -} // namespace webrtc diff --git a/modules/audio_coding/neteq/tools/rtp_analyze.cc b/modules/audio_coding/neteq/tools/rtp_analyze.cc index a4bf3dfe7f..26df8f00a8 100644 --- a/modules/audio_coding/neteq/tools/rtp_analyze.cc +++ b/modules/audio_coding/neteq/tools/rtp_analyze.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include -#include +#include #include #include #include @@ -19,9 +18,10 @@ #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 "modules/rtp_rtcp/source/rtp_header_extensions.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" ABSL_FLAG(int, red, 117, "RTP payload type for RED"); @@ -36,6 +36,54 @@ ABSL_FLAG(int, "Extension ID for absolute sender time; " "-1 not to print absolute send time"); +namespace { + +struct RedHeader { + uint32_t rtp_timestamp; + int payload_type; +}; +std::vector ExtractRedHeaders(const webrtc::RtpPacket& packet) { + // + // 0 1 2 3 + // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // |1| block PT | timestamp offset | block length | + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // |1| ... | + // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // |0| block PT | + // +-+-+-+-+-+-+-+-+ + // + const uint8_t* payload_ptr = packet.payload().data(); + const uint8_t* payload_end_ptr = + packet.payload().data() + packet.payload().size(); + + // Find all RED headers with the extension bit set to 1. That is, all headers + // but the last one. + std::vector red_headers; + while ((payload_ptr < payload_end_ptr) && (*payload_ptr & 0x80)) { + RedHeader header; + header.payload_type = payload_ptr[0] & 0x7F; + uint32_t offset = (payload_ptr[1] << 6) + ((payload_ptr[2] & 0xFC) >> 2); + header.rtp_timestamp = packet.Timestamp() - offset; + red_headers.push_back(header); + payload_ptr += 4; + } + // Last header. + RTC_DCHECK_LT(payload_ptr, payload_end_ptr); + if (payload_ptr >= payload_end_ptr) { + return {}; // Payload too short. + } + RedHeader header; + header.payload_type = payload_ptr[0] & 0x7F; + header.rtp_timestamp = packet.Timestamp(); + red_headers.push_back(header); + std::reverse(red_headers.begin(), red_headers.end()); + return red_headers; +} + +} // namespace + int main(int argc, char* argv[]) { std::vector args = absl::ParseCommandLine(argc, argv); std::string usage = @@ -101,68 +149,60 @@ int main(int argc, char* argv[]) { uint32_t max_abs_send_time = 0; int cycles = -1; - std::unique_ptr packet; + std::unique_ptr packet; while (true) { packet = file_source->NextPacket(); - if (!packet.get()) { + if (!packet) { // End of file reached. break; } // Write packet data to file. Use virtual_packet_length_bytes so that the // correct packet sizes are printed also for RTP header-only dumps. - fprintf(out_file, "%5u %10u %10u %5i %5i %2i %#08X", - packet->header().sequenceNumber, packet->header().timestamp, - static_cast(packet->time_ms()), - static_cast(packet->virtual_packet_length_bytes()), - packet->header().payloadType, packet->header().markerBit, - packet->header().ssrc); - if (print_audio_level && packet->header().extension.audio_level()) { - fprintf(out_file, " %5d (%1i)", - packet->header().extension.audio_level()->level(), - packet->header().extension.audio_level()->voice_activity()); + fprintf(out_file, "%5u %10u %10i %5zu %5i %2i %#08X", + packet->SequenceNumber(), packet->Timestamp(), + packet->arrival_time().ms(), packet->size(), + packet->PayloadType(), packet->Marker(), packet->Ssrc()); + webrtc::AudioLevel audio_level; + if (print_audio_level && + packet->GetExtension(&audio_level)) { + fprintf(out_file, " %5d (%1i)", audio_level.level(), + audio_level.voice_activity()); } - if (print_abs_send_time && packet->header().extension.hasAbsoluteSendTime) { + uint32_t abs_sent_time; + if (print_abs_send_time && + packet->GetExtension(&abs_sent_time)) { if (cycles == -1) { // Initialize. - max_abs_send_time = packet->header().extension.absoluteSendTime; + max_abs_send_time = abs_sent_time; cycles = 0; } // Abs sender time is 24 bit 6.18 fixed point. Shift by 8 to normalize to // 32 bits (unsigned). Calculate the difference between this packet's // send time and the maximum observed. Cast to signed 32-bit to get the // desired wrap-around behavior. - if (static_cast( - (packet->header().extension.absoluteSendTime << 8) - - (max_abs_send_time << 8)) >= 0) { + if (static_cast((abs_sent_time << 8) - + (max_abs_send_time << 8)) >= 0) { // The difference is non-negative, meaning that this packet is newer // than the previously observed maximum absolute send time. - if (packet->header().extension.absoluteSendTime < max_abs_send_time) { + if (abs_sent_time < max_abs_send_time) { // Wrap detected. cycles++; } - max_abs_send_time = packet->header().extension.absoluteSendTime; + max_abs_send_time = abs_sent_time; } // Abs sender time is 24 bit 6.18 fixed point. Divide by 2^18 to convert // to floating point representation. double send_time_seconds = - static_cast(packet->header().extension.absoluteSendTime) / - 262144 + - 64.0 * cycles; + static_cast(abs_sent_time) / 262144 + 64.0 * cycles; fprintf(out_file, " %11f", send_time_seconds); } fprintf(out_file, "\n"); - if (packet->header().payloadType == absl::GetFlag(FLAGS_red)) { - std::list red_headers; - packet->ExtractRedHeaders(&red_headers); - while (!red_headers.empty()) { - webrtc::RTPHeader* red = red_headers.front(); - RTC_DCHECK(red); - fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber, - red->timestamp, static_cast(packet->time_ms()), - red->payloadType); - red_headers.pop_front(); - delete red; + if (packet->PayloadType() == absl::GetFlag(FLAGS_red)) { + for (const RedHeader& red : ExtractRedHeaders(*packet)) { + fprintf(out_file, "* %5u %10u %10i %5i\n", packet->SequenceNumber(), + red.rtp_timestamp, packet->arrival_time().ms(), + red.payload_type); } } } diff --git a/modules/audio_coding/neteq/tools/rtp_encode.cc b/modules/audio_coding/neteq/tools/rtp_encode.cc index 93207bc15b..2b0bc2fc23 100644 --- a/modules/audio_coding/neteq/tools/rtp_encode.cc +++ b/modules/audio_coding/neteq/tools/rtp_encode.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include +#include #include #include diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.cc b/modules/audio_coding/neteq/tools/rtp_file_source.cc index 4a83cf70fa..cb975d0236 100644 --- a/modules/audio_coding/neteq/tools/rtp_file_source.cc +++ b/modules/audio_coding/neteq/tools/rtp_file_source.cc @@ -10,18 +10,18 @@ #include "modules/audio_coding/neteq/tools/rtp_file_source.h" -#include - +#include #include +#include #include #include #include "absl/strings/string_view.h" -#include "modules/audio_coding/neteq/tools/packet.h" +#include "api/units/timestamp.h" #include "modules/audio_coding/neteq/tools/packet_source.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" -#include "rtc_base/copy_on_write_buffer.h" #include "test/rtp_file_reader.h" namespace webrtc { @@ -53,7 +53,7 @@ bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type, return rtp_header_extension_map_.RegisterByType(id, type); } -std::unique_ptr RtpFileSource::NextPacket() { +std::unique_ptr RtpFileSource::NextPacket() { while (true) { RtpPacket temp_packet; if (!rtp_reader_->NextPacket(&temp_packet)) { @@ -64,19 +64,29 @@ std::unique_ptr RtpFileSource::NextPacket() { // Read the next one. continue; } - auto packet = std::make_unique( - CopyOnWriteBuffer(temp_packet.data, temp_packet.length), - temp_packet.original_length, temp_packet.time_ms, - &rtp_header_extension_map_); - if (!packet->valid_header()) { + auto rtp_packet = + std::make_unique(&rtp_header_extension_map_); + if (!rtp_packet->Parse(temp_packet.data, temp_packet.length)) { continue; } - if (filter_.test(packet->header().payloadType) || - (ssrc_filter_ && packet->header().ssrc != *ssrc_filter_)) { + if (filter_.test(rtp_packet->PayloadType()) || + (ssrc_filter_ && rtp_packet->Ssrc() != *ssrc_filter_)) { // This payload type should be filtered out. Continue to the next packet. continue; } - return packet; + rtp_packet->set_arrival_time(Timestamp::Millis(temp_packet.time_ms)); + if (temp_packet.original_length > rtp_packet->headers_size()) { + size_t payload_size = + temp_packet.original_length - rtp_packet->headers_size(); + if (rtp_packet->has_padding()) { + // If padding bit is set in the RTP header, assume it was a pure padding + // packet. + rtp_packet->SetPadding(payload_size); + } else { + std::fill_n(rtp_packet->AllocatePayload(payload_size), payload_size, 0); + } + } + return rtp_packet; } } diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.h b/modules/audio_coding/neteq/tools/rtp_file_source.h index 47005ca273..f7c0a427f0 100644 --- a/modules/audio_coding/neteq/tools/rtp_file_source.h +++ b/modules/audio_coding/neteq/tools/rtp_file_source.h @@ -18,10 +18,10 @@ #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" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" namespace webrtc { @@ -49,7 +49,7 @@ class RtpFileSource : public PacketSource { // Registers an RTP header extension and binds it to `id`. virtual bool RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id); - std::unique_ptr NextPacket() override; + std::unique_ptr NextPacket() override; private: static const int kFirstLineLength = 40; diff --git a/modules/audio_coding/neteq/tools/rtp_jitter.cc b/modules/audio_coding/neteq/tools/rtp_jitter.cc index 419a99a4b7..557ed33fef 100644 --- a/modules/audio_coding/neteq/tools/rtp_jitter.cc +++ b/modules/audio_coding/neteq/tools/rtp_jitter.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include #include +#include #include #include #include diff --git a/modules/audio_coding/neteq/tools/rtpcat.cc b/modules/audio_coding/neteq/tools/rtpcat.cc index 9e91490512..3fdad5802f 100644 --- a/modules/audio_coding/neteq/tools/rtpcat.cc +++ b/modules/audio_coding/neteq/tools/rtpcat.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc index ab298064d4..848e833f42 100644 --- a/modules/audio_coding/test/EncodeDecodeTest.cc +++ b/modules/audio_coding/test/EncodeDecodeTest.cc @@ -10,10 +10,9 @@ #include "modules/audio_coding/test/EncodeDecodeTest.h" -#include -#include - #include +#include +#include #include #include #include diff --git a/modules/audio_coding/test/PCMFile.cc b/modules/audio_coding/test/PCMFile.cc index b6c0d4c5cc..aa98f06c4d 100644 --- a/modules/audio_coding/test/PCMFile.cc +++ b/modules/audio_coding/test/PCMFile.cc @@ -10,12 +10,11 @@ #include "modules/audio_coding/test/PCMFile.h" -#include -#include -#include - +#include #include +#include #include +#include #include #include "absl/strings/string_view.h" diff --git a/modules/audio_coding/test/RTPFile.cc b/modules/audio_coding/test/RTPFile.cc index adb12fc630..5c190c9f19 100644 --- a/modules/audio_coding/test/RTPFile.cc +++ b/modules/audio_coding/test/RTPFile.cc @@ -10,11 +10,11 @@ #include "RTPFile.h" -#include #include #include #include +#include #include #include #include diff --git a/modules/audio_coding/test/TestRedFec.cc b/modules/audio_coding/test/TestRedFec.cc index f8dce3790b..9f2ad1997f 100644 --- a/modules/audio_coding/test/TestRedFec.cc +++ b/modules/audio_coding/test/TestRedFec.cc @@ -33,7 +33,6 @@ #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/field_trials.h" #include "api/neteq/default_neteq_factory.h" #include "api/neteq/neteq.h" #include "common_audio/vad/include/vad.h" @@ -49,8 +48,7 @@ namespace webrtc { TestRedFec::TestRedFec() - : env_(CreateEnvironment( - std::make_unique(CreateTestFieldTrials()))), + : env_(CreateEnvironment(CreateTestFieldTrialsPtr())), encoder_factory_(CreateAudioEncoderFactory #include "modules/audio_coding/test/EncodeDecodeTest.h" #include "modules/audio_coding/test/PacketLossTest.h" @@ -18,7 +17,6 @@ #include "modules/audio_coding/test/TestVADDTX.h" #include "modules/audio_coding/test/opus_test.h" #include "test/gtest.h" -#include "test/testsupport/file_utils.h" TEST(AudioCodingModuleTest, TestAllCodecs) { webrtc::TestAllCodecs().Perform(); diff --git a/modules/audio_coding/test/target_delay_unittest.cc b/modules/audio_coding/test/target_delay_unittest.cc index b437e834bb..96130b49d6 100644 --- a/modules/audio_coding/test/target_delay_unittest.cc +++ b/modules/audio_coding/test/target_delay_unittest.cc @@ -26,7 +26,6 @@ #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "modules/audio_coding/include/audio_coding_module.h" #include "test/gtest.h" -#include "test/testsupport/file_utils.h" namespace webrtc { diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn index b879e4f571..a26de6be15 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -50,10 +50,6 @@ rtc_source_set("audio_device_api") { deps = [ "../../api/audio:audio_device" ] } -rtc_library("audio_device_config") { - sources = [ "audio_device_config.h" ] -} - rtc_library("audio_device_buffer") { sources = [ "audio_device_buffer.cc", @@ -66,6 +62,7 @@ rtc_library("audio_device_buffer") { "../../api:sequence_checker", "../../api/audio:audio_device", "../../api/task_queue", + "../../api/units:time_delta", "../../common_audio:common_audio_c", "../../rtc_base:buffer", "../../rtc_base:checks", @@ -117,7 +114,7 @@ rtc_library("windows_core_audio_utility") { "../../rtc_base:platform_thread_types", "../../rtc_base:stringutils", "../../rtc_base/win:windows_version", - "//third_party/abseil-cpp/absl/strings:strings", + "//third_party/abseil-cpp/absl/strings", ] libs = [ "oleaut32.lib" ] @@ -162,7 +159,7 @@ rtc_library("audio_device_module_from_input_and_output") { "../../rtc_base:timeutils", "../../rtc_base/win:scoped_com_initializer", "../../rtc_base/win:windows_version", - "//third_party/abseil-cpp/absl/strings:strings", + "//third_party/abseil-cpp/absl/strings", ] } } @@ -177,10 +174,6 @@ if (!build_with_chromium) { "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", @@ -191,7 +184,6 @@ if (!build_with_chromium) { "../../api:scoped_refptr", "../../api/audio:audio_device", "../../api/environment", - "../../api/environment:environment_factory", "../../api/task_queue", "../../api/units:time_delta", "../../common_audio", @@ -239,7 +231,9 @@ if (!build_with_chromium) { defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ] } deps = [ + ":audio_device_buffer", ":audio_device_generic", + "../../api/audio:audio_device", "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:platform_thread", @@ -259,12 +253,12 @@ rtc_library("audio_device_impl") { visibility = [ "*" ] deps = [ ":audio_device_buffer", - ":audio_device_config", ":audio_device_default", ":audio_device_dummy", ":audio_device_generic", "../../api:array_view", "../../api:make_ref_counted", + "../../api:ref_count", "../../api:refcountedbase", "../../api:scoped_refptr", "../../api:sequence_checker", @@ -437,6 +431,7 @@ rtc_source_set("mock_audio_device") { ":audio_device_buffer", ":audio_device_impl", "../../api:make_ref_counted", + "../../api:scoped_refptr", "../../api/audio:audio_device", "../../test:test_support", ] diff --git a/modules/audio_device/audio_device_buffer.cc b/modules/audio_device/audio_device_buffer.cc index 75406b1ee9..916acdcb2b 100644 --- a/modules/audio_device/audio_device_buffer.cc +++ b/modules/audio_device/audio_device_buffer.cc @@ -10,16 +10,22 @@ #include "modules/audio_device/audio_device_buffer.h" -#include - #include #include #include +#include +#include +#include "api/audio/audio_device_defines.h" +#include "api/sequence_checker.h" +#include "api/task_queue/task_queue_factory.h" +#include "api/units/time_delta.h" #include "common_audio/signal_processing/include/signal_processing_library.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/time_utils.h" +#include "rtc_base/timestamp_aligner.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/metrics.h" diff --git a/modules/audio_device/audio_device_buffer.h b/modules/audio_device/audio_device_buffer.h index 4f2ae64211..8bdf5c65c8 100644 --- a/modules/audio_device/audio_device_buffer.h +++ b/modules/audio_device/audio_device_buffer.h @@ -11,11 +11,11 @@ #ifndef MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ #define MODULES_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H_ -#include -#include - #include +#include +#include #include +#include #include "api/audio/audio_device_defines.h" #include "api/sequence_checker.h" diff --git a/modules/audio_device/audio_device_config.h b/modules/audio_device/audio_device_config.h deleted file mode 100644 index fa51747b67..0000000000 --- a/modules/audio_device/audio_device_config.h +++ /dev/null @@ -1,30 +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 AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H_ -#define AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H_ - -// Enumerators -// -enum { GET_MIC_VOLUME_INTERVAL_MS = 1000 }; - -// Platform specifics -// -#if defined(_WIN32) -#if (_MSC_VER >= 1400) -#if !defined(WEBRTC_DUMMY_FILE_DEVICES) -// Windows Core Audio is the default audio layer in Windows. -// Only supported for VS 2005 and higher. -#define WEBRTC_WINDOWS_CORE_AUDIO_BUILD -#endif -#endif -#endif - -#endif // AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H_ diff --git a/modules/audio_device/audio_device_generic.cc b/modules/audio_device/audio_device_generic.cc index a99e015814..dba26b1acd 100644 --- a/modules/audio_device/audio_device_generic.cc +++ b/modules/audio_device/audio_device_generic.cc @@ -10,7 +10,7 @@ #include "modules/audio_device/audio_device_generic.h" -#include "rtc_base/logging.h" +#include namespace webrtc { diff --git a/modules/audio_device/audio_device_generic.h b/modules/audio_device/audio_device_generic.h index 3fa3ed9d8a..c74a6c95ab 100644 --- a/modules/audio_device/audio_device_generic.h +++ b/modules/audio_device/audio_device_generic.h @@ -11,7 +11,7 @@ #ifndef AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_ #define AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_ -#include +#include #include "api/audio/audio_device.h" #include "api/audio/audio_device_defines.h" diff --git a/modules/audio_device/audio_device_impl.cc b/modules/audio_device/audio_device_impl.cc index c63a478c5f..b2ffa53120 100644 --- a/modules/audio_device/audio_device_impl.cc +++ b/modules/audio_device/audio_device_impl.cc @@ -10,8 +10,6 @@ #include "modules/audio_device/audio_device_impl.h" -#include - #include #include #include @@ -23,16 +21,13 @@ #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" #include "rtc_base/logging.h" #include "system_wrappers/include/metrics.h" -#if defined(_WIN32) -#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) +#if defined(WEBRTC_WIN) #include "modules/audio_device/win/audio_device_core_win.h" -#endif #elif defined(WEBRTC_LINUX) #if defined(WEBRTC_ENABLE_LINUX_ALSA) #include "modules/audio_device/linux/audio_device_alsa_linux.h" @@ -186,8 +181,8 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects( // Real (non-dummy) ADM implementations. #else AudioLayer audio_layer(PlatformAudioLayer()); -// Windows ADM implementation. -#if defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) +#if defined(WEBRTC_WIN) + // Windows ADM implementation. if ((audio_layer == kWindowsCoreAudio) || (audio_layer == kPlatformDefaultAudio)) { RTC_LOG(LS_INFO) << "Attempting to use the Windows Core Audio APIs..."; @@ -196,7 +191,7 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects( RTC_LOG(LS_INFO) << "Windows Core Audio APIs will be utilized"; } } -#endif // defined(WEBRTC_WINDOWS_CORE_AUDIO_BUILD) +#endif // Linux ADM implementation. // Note that, WEBRTC_ENABLE_LINUX_ALSA is always defined by default when diff --git a/modules/audio_device/audio_device_impl.h b/modules/audio_device/audio_device_impl.h index c7a229d2d9..33c73c024e 100644 --- a/modules/audio_device/audio_device_impl.h +++ b/modules/audio_device/audio_device_impl.h @@ -13,8 +13,7 @@ #if defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE) -#include - +#include #include #include "absl/base/nullability.h" diff --git a/modules/audio_device/dummy/audio_device_dummy.cc b/modules/audio_device/dummy/audio_device_dummy.cc index bc7b95d881..2e0304d41e 100644 --- a/modules/audio_device/dummy/audio_device_dummy.cc +++ b/modules/audio_device/dummy/audio_device_dummy.cc @@ -10,6 +10,13 @@ #include "modules/audio_device/dummy/audio_device_dummy.h" +#include + +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "modules/audio_device/audio_device_buffer.h" +#include "modules/audio_device/audio_device_generic.h" + namespace webrtc { int32_t AudioDeviceDummy::ActiveAudioLayer( diff --git a/modules/audio_device/dummy/audio_device_dummy.h b/modules/audio_device/dummy/audio_device_dummy.h index 6550915974..f7dc46557b 100644 --- a/modules/audio_device/dummy/audio_device_dummy.h +++ b/modules/audio_device/dummy/audio_device_dummy.h @@ -11,7 +11,7 @@ #ifndef AUDIO_DEVICE_AUDIO_DEVICE_DUMMY_H_ #define AUDIO_DEVICE_AUDIO_DEVICE_DUMMY_H_ -#include +#include #include "api/audio/audio_device.h" #include "api/audio/audio_device_defines.h" diff --git a/modules/audio_device/dummy/file_audio_device.cc b/modules/audio_device/dummy/file_audio_device.cc index e33036b315..15f549fab1 100644 --- a/modules/audio_device/dummy/file_audio_device.cc +++ b/modules/audio_device/dummy/file_audio_device.cc @@ -10,12 +10,20 @@ #include "modules/audio_device/dummy/file_audio_device.h" -#include +#include +#include +#include #include "absl/strings/string_view.h" +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "modules/audio_device/audio_device_buffer.h" +#include "modules/audio_device/audio_device_generic.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" +#include "rtc_base/synchronization/mutex.h" +#include "rtc_base/system/file_wrapper.h" #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" diff --git a/modules/audio_device/dummy/file_audio_device.h b/modules/audio_device/dummy/file_audio_device.h index ab7dee0a98..f1c9285514 100644 --- a/modules/audio_device/dummy/file_audio_device.h +++ b/modules/audio_device/dummy/file_audio_device.h @@ -11,17 +11,18 @@ #ifndef AUDIO_DEVICE_FILE_AUDIO_DEVICE_H_ #define AUDIO_DEVICE_FILE_AUDIO_DEVICE_H_ -#include - -#include +#include +#include #include #include "absl/strings/string_view.h" +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "modules/audio_device/audio_device_buffer.h" #include "modules/audio_device/audio_device_generic.h" #include "rtc_base/platform_thread.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/file_wrapper.h" -#include "rtc_base/time_utils.h" namespace webrtc { diff --git a/modules/audio_device/dummy/file_audio_device_factory.cc b/modules/audio_device/dummy/file_audio_device_factory.cc index 600304a6ef..5dcb78502f 100644 --- a/modules/audio_device/dummy/file_audio_device_factory.cc +++ b/modules/audio_device/dummy/file_audio_device_factory.cc @@ -10,8 +10,7 @@ #include "modules/audio_device/dummy/file_audio_device_factory.h" -#include - +#include #include #include "absl/strings/string_view.h" diff --git a/modules/audio_device/dummy/file_audio_device_factory.h b/modules/audio_device/dummy/file_audio_device_factory.h index 18f9388f21..3caa13e1e9 100644 --- a/modules/audio_device/dummy/file_audio_device_factory.h +++ b/modules/audio_device/dummy/file_audio_device_factory.h @@ -11,7 +11,7 @@ #ifndef AUDIO_DEVICE_FILE_AUDIO_DEVICE_FACTORY_H_ #define AUDIO_DEVICE_FILE_AUDIO_DEVICE_FACTORY_H_ -#include +#include #include "absl/strings/string_view.h" diff --git a/modules/audio_device/fine_audio_buffer.cc b/modules/audio_device/fine_audio_buffer.cc index 2ec25413a5..0ab7023448 100644 --- a/modules/audio_device/fine_audio_buffer.cc +++ b/modules/audio_device/fine_audio_buffer.cc @@ -12,6 +12,7 @@ #include #include +#include #include "api/array_view.h" #include "modules/audio_device/audio_device_buffer.h" diff --git a/modules/audio_device/fine_audio_buffer_unittest.cc b/modules/audio_device/fine_audio_buffer_unittest.cc index c86af8d7df..2916909b64 100644 --- a/modules/audio_device/fine_audio_buffer_unittest.cc +++ b/modules/audio_device/fine_audio_buffer_unittest.cc @@ -10,8 +10,8 @@ #include "modules/audio_device/fine_audio_buffer.h" -#include - +#include +#include #include #include "api/array_view.h" @@ -27,9 +27,9 @@ using ::testing::Return; namespace webrtc { -const int kSampleRate = 44100; -const int kChannels = 2; -const int kSamplesPer10Ms = kSampleRate * 10 / 1000; +constexpr int kSampleRate = 44100; +constexpr int kChannels = 2; +constexpr int kSamplesPer10Ms = kSampleRate * 10 / 1000; // The fake audio data is 0,1,..SCHAR_MAX-1,0,1,... This is to make it easy // to detect errors. This function verifies that the buffers contain such data. diff --git a/modules/audio_device/include/audio_device_data_observer.h b/modules/audio_device/include/audio_device_data_observer.h index 4627caa10e..6191f23e65 100644 --- a/modules/audio_device/include/audio_device_data_observer.h +++ b/modules/audio_device/include/audio_device_data_observer.h @@ -11,9 +11,8 @@ #ifndef MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_DATA_OBSERVER_H_ #define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_DATA_OBSERVER_H_ -#include -#include - +#include +#include #include #include "api/audio/audio_device.h" diff --git a/modules/audio_device/include/audio_device_default.h b/modules/audio_device/include/audio_device_default.h index d38c5e81a1..33cd88e21e 100644 --- a/modules/audio_device/include/audio_device_default.h +++ b/modules/audio_device/include/audio_device_default.h @@ -11,7 +11,10 @@ #ifndef MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_DEFAULT_H_ #define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_DEFAULT_H_ +#include + #include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" namespace webrtc { namespace webrtc_impl { diff --git a/modules/audio_device/include/fake_audio_device.h b/modules/audio_device/include/fake_audio_device.h index 0eaa609f95..933a294fc5 100644 --- a/modules/audio_device/include/fake_audio_device.h +++ b/modules/audio_device/include/fake_audio_device.h @@ -12,6 +12,7 @@ #define MODULES_AUDIO_DEVICE_INCLUDE_FAKE_AUDIO_DEVICE_H_ #include "api/audio/audio_device.h" +#include "api/ref_count.h" #include "modules/audio_device/include/audio_device_default.h" namespace webrtc { diff --git a/modules/audio_device/include/mock_audio_device.h b/modules/audio_device/include/mock_audio_device.h index 191caf604f..276a0b5d77 100644 --- a/modules/audio_device/include/mock_audio_device.h +++ b/modules/audio_device/include/mock_audio_device.h @@ -11,10 +11,12 @@ #ifndef MODULES_AUDIO_DEVICE_INCLUDE_MOCK_AUDIO_DEVICE_H_ #define MODULES_AUDIO_DEVICE_INCLUDE_MOCK_AUDIO_DEVICE_H_ -#include +#include #include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" #include "api/make_ref_counted.h" +#include "api/scoped_refptr.h" #include "test/gmock.h" namespace webrtc { diff --git a/modules/audio_device/include/mock_audio_transport.h b/modules/audio_device/include/mock_audio_transport.h index 56f6905e9a..fd242f2a20 100644 --- a/modules/audio_device/include/mock_audio_transport.h +++ b/modules/audio_device/include/mock_audio_transport.h @@ -11,6 +11,10 @@ #ifndef MODULES_AUDIO_DEVICE_INCLUDE_MOCK_AUDIO_TRANSPORT_H_ #define MODULES_AUDIO_DEVICE_INCLUDE_MOCK_AUDIO_TRANSPORT_H_ +#include +#include +#include + #include "api/audio/audio_device_defines.h" #include "test/gmock.h" diff --git a/modules/audio_device/include/test_audio_device.cc b/modules/audio_device/include/test_audio_device.cc index 3b58ff21da..9a319d9378 100644 --- a/modules/audio_device/include/test_audio_device.cc +++ b/modules/audio_device/include/test_audio_device.cc @@ -22,10 +22,8 @@ #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/test_audio_device_impl.h" @@ -425,15 +423,6 @@ size_t TestAudioDeviceModule::SamplesPerFrame(int sampling_frequency_in_hz) { return CheckedDivExact(sampling_frequency_in_hz, kFramesPerSecond); } -scoped_refptr TestAudioDeviceModule::Create( - TaskQueueFactory* task_queue_factory, - std::unique_ptr capturer, - std::unique_ptr renderer, - float 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, @@ -441,8 +430,7 @@ scoped_refptr TestAudioDeviceModule::Create( float speed) { auto audio_device = make_ref_counted( AudioDeviceModule::AudioLayer::kDummyAudio, - std::make_unique(&env.task_queue_factory(), - std::move(capturer), + std::make_unique(env, std::move(capturer), std::move(renderer), speed), &env.task_queue_factory(), /*create_detached=*/true); diff --git a/modules/audio_device/include/test_audio_device.h b/modules/audio_device/include/test_audio_device.h index d7c556861d..79694846a6 100644 --- a/modules/audio_device/include/test_audio_device.h +++ b/modules/audio_device/include/test_audio_device.h @@ -10,9 +10,8 @@ #ifndef MODULES_AUDIO_DEVICE_INCLUDE_TEST_AUDIO_DEVICE_H_ #define MODULES_AUDIO_DEVICE_INCLUDE_TEST_AUDIO_DEVICE_H_ -#include -#include - +#include +#include #include #include "absl/strings/string_view.h" @@ -20,7 +19,6 @@ #include "api/audio/audio_device.h" #include "api/environment/environment.h" #include "api/scoped_refptr.h" -#include "api/task_queue/task_queue_factory.h" #include "rtc_base/buffer.h" namespace webrtc { @@ -86,13 +84,6 @@ class TestAudioDeviceModule { std::unique_ptr renderer, float speed = 1); - [[deprecated("bugs.webrtc.org/413413572")]] - static scoped_refptr Create( - TaskQueueFactory* task_queue_factory, - std::unique_ptr capturer, - std::unique_ptr renderer, - float speed = 1); - // Returns a Capturer instance that generates a signal of `num_channels` // channels where every second frame is zero and every second frame is evenly // distributed random noise with max amplitude `max_amplitude`. diff --git a/modules/audio_device/include/test_audio_device_unittest.cc b/modules/audio_device/include/test_audio_device_unittest.cc index 5e4888b372..923d8debc6 100644 --- a/modules/audio_device/include/test_audio_device_unittest.cc +++ b/modules/audio_device/include/test_audio_device_unittest.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/modules/audio_device/linux/alsasymboltable_linux.cc b/modules/audio_device/linux/alsasymboltable_linux.cc index 5dfb91d6f4..703fe53460 100644 --- a/modules/audio_device/linux/alsasymboltable_linux.cc +++ b/modules/audio_device/linux/alsasymboltable_linux.cc @@ -27,6 +27,8 @@ #include "modules/audio_device/linux/alsasymboltable_linux.h" +#include "modules/audio_device/linux/latebindingsymboltable_linux.h" + namespace webrtc { namespace adm_linux_alsa { diff --git a/modules/audio_device/linux/audio_device_alsa_linux.cc b/modules/audio_device/linux/audio_device_alsa_linux.cc index e9afc683bf..4e504f354d 100644 --- a/modules/audio_device/linux/audio_device_alsa_linux.cc +++ b/modules/audio_device/linux/audio_device_alsa_linux.cc @@ -10,11 +10,29 @@ #include "modules/audio_device/linux/audio_device_alsa_linux.h" -#include "modules/audio_device/audio_device_config.h" +#include + +#include +#include +#include +#include +#include + +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "modules/audio_device/audio_device_buffer.h" +#include "modules/audio_device/audio_device_generic.h" +#include "modules/audio_device/linux/latebindingsymboltable_linux.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/system/arch.h" +#include "rtc_base/platform_thread.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread.h" +#if defined(WEBRTC_USE_X11) +#include +#endif + WebRTCAlsaSymbolTable* GetAlsaSymbolTable() { static WebRTCAlsaSymbolTable* alsa_symbol_table = new WebRTCAlsaSymbolTable(); return alsa_symbol_table; diff --git a/modules/audio_device/linux/audio_device_alsa_linux.h b/modules/audio_device/linux/audio_device_alsa_linux.h index f40ee5a623..cb7c68ebe9 100644 --- a/modules/audio_device/linux/audio_device_alsa_linux.h +++ b/modules/audio_device/linux/audio_device_alsa_linux.h @@ -11,19 +11,27 @@ #ifndef AUDIO_DEVICE_AUDIO_DEVICE_ALSA_LINUX_H_ #define AUDIO_DEVICE_AUDIO_DEVICE_ALSA_LINUX_H_ -#include +#include +#include +#include + +#include +#include +#include +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "modules/audio_device/audio_device_buffer.h" #include "modules/audio_device/audio_device_generic.h" +#include "modules/audio_device/linux/alsasymboltable_linux.h" #include "modules/audio_device/linux/audio_mixer_manager_alsa_linux.h" #include "rtc_base/platform_thread.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" #if defined(WEBRTC_USE_X11) #include #endif -#include -#include -#include typedef webrtc::adm_linux_alsa::AlsaSymbolTable WebRTCAlsaSymbolTable; WebRTCAlsaSymbolTable* GetAlsaSymbolTable(); diff --git a/modules/audio_device/linux/audio_device_pulse_linux.cc b/modules/audio_device/linux/audio_device_pulse_linux.cc index dfdafa6517..8a09011dc0 100644 --- a/modules/audio_device/linux/audio_device_pulse_linux.cc +++ b/modules/audio_device/linux/audio_device_pulse_linux.cc @@ -10,12 +10,25 @@ #include "modules/audio_device/linux/audio_device_pulse_linux.h" -#include - +#include +#include +#include + +#include "api/audio/audio_device.h" +#include "api/audio/audio_device_defines.h" +#include "api/units/time_delta.h" +#include "modules/audio_device/audio_device_buffer.h" +#include "modules/audio_device/audio_device_generic.h" #include "modules/audio_device/linux/latebindingsymboltable_linux.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" +#include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" + +#if defined(WEBRTC_USE_X11) +#include +#endif WebRTCPulseSymbolTable* GetPulseSymbolTable() { static WebRTCPulseSymbolTable* pulse_symbol_table = diff --git a/modules/audio_device/linux/audio_device_pulse_linux.h b/modules/audio_device/linux/audio_device_pulse_linux.h index 2ee327bda8..eb394c1334 100644 --- a/modules/audio_device/linux/audio_device_pulse_linux.h +++ b/modules/audio_device/linux/audio_device_pulse_linux.h @@ -11,7 +11,10 @@ #ifndef AUDIO_DEVICE_AUDIO_DEVICE_PULSE_LINUX_H_ #define AUDIO_DEVICE_AUDIO_DEVICE_PULSE_LINUX_H_ -#include +#include + +#include +#include #include "api/audio/audio_device.h" #include "api/audio/audio_device_defines.h" @@ -29,10 +32,6 @@ #include #endif -#include -#include -#include - // We define this flag if it's missing from our headers, because we want to be // able to compile against old headers but still use PA_STREAM_ADJUST_LATENCY // if run against a recent version of the library. 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 76084c6bda..b77940c69a 100644 --- a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc +++ b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.cc @@ -10,8 +10,14 @@ #include "modules/audio_device/linux/audio_mixer_manager_alsa_linux.h" +#include +#include + +#include "api/audio/audio_device_defines.h" #include "modules/audio_device/linux/audio_device_alsa_linux.h" +#include "modules/audio_device/linux/latebindingsymboltable_linux.h" #include "rtc_base/logging.h" +#include "rtc_base/synchronization/mutex.h" // Accesses ALSA functions through our late-binding symbol table instead of // directly. This way we don't have to link to libasound, which means our binary diff --git a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h index ec6c781412..54eced874a 100644 --- a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h +++ b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h @@ -13,9 +13,11 @@ #include -#include "api/audio/audio_device.h" -#include "modules/audio_device/linux/alsasymboltable_linux.h" +#include + +#include "api/audio/audio_device_defines.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { 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 9f899158a9..4a572481e3 100644 --- a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.cc +++ b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.cc @@ -10,11 +10,10 @@ #include "modules/audio_device/linux/audio_mixer_manager_pulse_linux.h" -#include +#include #include "modules/audio_device/linux/audio_device_pulse_linux.h" #include "modules/audio_device/linux/latebindingsymboltable_linux.h" -#include "modules/audio_device/linux/pulseaudiosymboltable_linux.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h index 546440c4a6..bdce949188 100644 --- a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h +++ b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h @@ -12,13 +12,10 @@ #define AUDIO_DEVICE_AUDIO_MIXER_MANAGER_PULSE_LINUX_H_ #include -#include -#include "api/sequence_checker.h" +#include -#ifndef UINT32_MAX -#define UINT32_MAX ((uint32_t)-1) -#endif +#include "api/sequence_checker.h" namespace webrtc { diff --git a/modules/audio_device/linux/latebindingsymboltable_linux.cc b/modules/audio_device/linux/latebindingsymboltable_linux.cc index 751edafd8b..5c026e2fa2 100644 --- a/modules/audio_device/linux/latebindingsymboltable_linux.cc +++ b/modules/audio_device/linux/latebindingsymboltable_linux.cc @@ -10,6 +10,8 @@ #include "modules/audio_device/linux/latebindingsymboltable_linux.h" +#include + #include "absl/strings/string_view.h" #include "rtc_base/logging.h" diff --git a/modules/audio_device/linux/latebindingsymboltable_linux.h b/modules/audio_device/linux/latebindingsymboltable_linux.h index 00f3c5a449..222b77038c 100644 --- a/modules/audio_device/linux/latebindingsymboltable_linux.h +++ b/modules/audio_device/linux/latebindingsymboltable_linux.h @@ -11,8 +11,7 @@ #ifndef AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_ #define AUDIO_DEVICE_LATEBINDINGSYMBOLTABLE_LINUX_H_ -#include // for NULL -#include +#include #include "absl/strings/string_view.h" #include "rtc_base/checks.h" diff --git a/modules/audio_device/linux/pulseaudiosymboltable_linux.cc b/modules/audio_device/linux/pulseaudiosymboltable_linux.cc index e0759e6ca3..003c489076 100644 --- a/modules/audio_device/linux/pulseaudiosymboltable_linux.cc +++ b/modules/audio_device/linux/pulseaudiosymboltable_linux.cc @@ -27,6 +27,8 @@ #include "modules/audio_device/linux/pulseaudiosymboltable_linux.h" +#include "modules/audio_device/linux/latebindingsymboltable_linux.h" + namespace webrtc { namespace adm_linux_pulse { diff --git a/modules/audio_device/mac/audio_device_mac.cc b/modules/audio_device/mac/audio_device_mac.cc index d077a8b185..1ff98af0f4 100644 --- a/modules/audio_device/mac/audio_device_mac.cc +++ b/modules/audio_device/mac/audio_device_mac.cc @@ -17,7 +17,6 @@ #include #include -#include "modules/audio_device/audio_device_config.h" #include "modules/third_party/portaudio/pa_ringbuffer.h" #include "rtc_base/checks.h" #include "rtc_base/platform_thread.h" diff --git a/modules/audio_device/mock_audio_device_buffer.h b/modules/audio_device/mock_audio_device_buffer.h index d9c9a48b53..589954a571 100644 --- a/modules/audio_device/mock_audio_device_buffer.h +++ b/modules/audio_device/mock_audio_device_buffer.h @@ -11,6 +11,8 @@ #ifndef MODULES_AUDIO_DEVICE_MOCK_AUDIO_DEVICE_BUFFER_H_ #define MODULES_AUDIO_DEVICE_MOCK_AUDIO_DEVICE_BUFFER_H_ +#include +#include #include #include "modules/audio_device/audio_device_buffer.h" diff --git a/modules/audio_device/test_audio_device_impl.cc b/modules/audio_device/test_audio_device_impl.cc index a04dcfcb81..f4566363f5 100644 --- a/modules/audio_device/test_audio_device_impl.cc +++ b/modules/audio_device/test_audio_device_impl.cc @@ -9,17 +9,23 @@ */ #include "modules/audio_device/test_audio_device_impl.h" +#include +#include #include #include #include #include "api/array_view.h" +#include "api/environment/environment.h" #include "api/task_queue/task_queue_factory.h" #include "api/units/time_delta.h" +#include "modules/audio_device/audio_device_buffer.h" +#include "modules/audio_device/audio_device_generic.h" #include "modules/audio_device/include/test_audio_device.h" #include "rtc_base/checks.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_utils/repeating_task.h" +#include "rtc_base/time_utils.h" namespace webrtc { namespace { @@ -29,11 +35,11 @@ constexpr int kFrameLengthUs = 10000; } // namespace TestAudioDevice::TestAudioDevice( - TaskQueueFactory* task_queue_factory, + const Environment& env, std::unique_ptr capturer, std::unique_ptr renderer, float speed) - : task_queue_factory_(task_queue_factory), + : env_(env), capturer_(std::move(capturer)), renderer_(std::move(renderer)), process_interval_us_(kFrameLengthUs / speed), @@ -58,7 +64,7 @@ TestAudioDevice::TestAudioDevice( } AudioDeviceGeneric::InitStatus TestAudioDevice::Init() { - task_queue_ = task_queue_factory_->CreateTaskQueue( + task_queue_ = env_.task_queue_factory().CreateTaskQueue( "TestAudioDeviceModuleImpl", TaskQueueFactory::Priority::NORMAL); RepeatingTaskHandle::Start(task_queue_.get(), [this]() { diff --git a/modules/audio_device/test_audio_device_impl.h b/modules/audio_device/test_audio_device_impl.h index 4eda151da3..d8ebb7d623 100644 --- a/modules/audio_device/test_audio_device_impl.h +++ b/modules/audio_device/test_audio_device_impl.h @@ -11,18 +11,20 @@ #ifndef MODULES_AUDIO_DEVICE_TEST_AUDIO_DEVICE_IMPL_H_ #define MODULES_AUDIO_DEVICE_TEST_AUDIO_DEVICE_IMPL_H_ +#include #include #include #include "api/audio/audio_device.h" #include "api/audio/audio_device_defines.h" +#include "api/environment/environment.h" #include "api/task_queue/task_queue_base.h" -#include "api/task_queue/task_queue_factory.h" #include "modules/audio_device/audio_device_buffer.h" #include "modules/audio_device/audio_device_generic.h" #include "modules/audio_device/include/test_audio_device.h" #include "rtc_base/buffer.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { @@ -34,7 +36,7 @@ class TestAudioDevice : public AudioDeviceGeneric { // device is never used for recording. // `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. - TestAudioDevice(TaskQueueFactory* task_queue_factory, + TestAudioDevice(const Environment& env, std::unique_ptr capturer, std::unique_ptr renderer, float speed = 1); @@ -186,7 +188,7 @@ class TestAudioDevice : public AudioDeviceGeneric { private: void ProcessAudio(); - TaskQueueFactory* const task_queue_factory_; + const Environment env_; const std::unique_ptr capturer_ RTC_GUARDED_BY(lock_); const std::unique_ptr renderer_ diff --git a/modules/audio_device/test_audio_device_impl_test.cc b/modules/audio_device/test_audio_device_impl_test.cc index f8e9137458..4c881baae4 100644 --- a/modules/audio_device/test_audio_device_impl_test.cc +++ b/modules/audio_device/test_audio_device_impl_test.cc @@ -9,13 +9,16 @@ */ #include "modules/audio_device/test_audio_device_impl.h" +#include +#include +#include #include #include #include +#include -#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_factory.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/audio_device/audio_device_buffer.h" @@ -23,6 +26,7 @@ #include "modules/audio_device/include/test_audio_device.h" #include "rtc_base/checks.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" @@ -157,9 +161,11 @@ TEST(TestAudioDeviceTest, EnablingRecordingProducesAudio) { /*max_amplitude=*/1000, /*sampling_frequency_in_hz=*/48000, /*num_channels=*/2); - TestAudioDevice audio_device(time_controller.GetTaskQueueFactory(), - std::move(capturer), - /*renderer=*/nullptr); + TestAudioDevice audio_device( + CreateEnvironment(time_controller.GetClock(), + time_controller.GetTaskQueueFactory()), + std::move(capturer), + /*renderer=*/nullptr); ASSERT_EQ(audio_device.Init(), AudioDeviceGeneric::InitStatus::OK); audio_device.AttachAudioBuffer(&audio_buffer); @@ -189,9 +195,11 @@ TEST(TestAudioDeviceTest, RecordingIsAvailableWhenCapturerIsSet) { /*max_amplitude=*/1000, /*sampling_frequency_in_hz=*/48000, /*num_channels=*/2); - TestAudioDevice audio_device(time_controller.GetTaskQueueFactory(), - std::move(capturer), - /*renderer=*/nullptr); + TestAudioDevice audio_device( + CreateEnvironment(time_controller.GetClock(), + time_controller.GetTaskQueueFactory()), + std::move(capturer), + /*renderer=*/nullptr); ASSERT_EQ(audio_device.Init(), AudioDeviceGeneric::InitStatus::OK); bool available; @@ -201,9 +209,11 @@ TEST(TestAudioDeviceTest, RecordingIsAvailableWhenCapturerIsSet) { TEST(TestAudioDeviceTest, RecordingIsNotAvailableWhenCapturerIsNotSet) { GlobalSimulatedTimeController time_controller(kStartTime); - TestAudioDevice audio_device(time_controller.GetTaskQueueFactory(), - /*capturer=*/nullptr, - /*renderer=*/nullptr); + TestAudioDevice audio_device( + CreateEnvironment(time_controller.GetClock(), + time_controller.GetTaskQueueFactory()), + /*capturer=*/nullptr, + /*renderer=*/nullptr); ASSERT_EQ(audio_device.Init(), AudioDeviceGeneric::InitStatus::OK); bool available; @@ -220,8 +230,10 @@ TEST(TestAudioDeviceTest, EnablingPlayoutProducesAudio) { TestAudioDeviceModule::CreateDiscardRenderer( /*sampling_frequency_in_hz=*/48000, /*num_channels=*/2); - TestAudioDevice audio_device(time_controller.GetTaskQueueFactory(), - /*capturer=*/nullptr, std::move(renderer)); + TestAudioDevice audio_device( + CreateEnvironment(time_controller.GetClock(), + time_controller.GetTaskQueueFactory()), + /*capturer=*/nullptr, std::move(renderer)); ASSERT_EQ(audio_device.Init(), AudioDeviceGeneric::InitStatus::OK); audio_device.AttachAudioBuffer(&audio_buffer); @@ -250,8 +262,10 @@ TEST(TestAudioDeviceTest, PlayoutIsAvailableWhenRendererIsSet) { TestAudioDeviceModule::CreateDiscardRenderer( /*sampling_frequency_in_hz=*/48000, /*num_channels=*/2); - TestAudioDevice audio_device(time_controller.GetTaskQueueFactory(), - /*capturer=*/nullptr, std::move(renderer)); + TestAudioDevice audio_device( + CreateEnvironment(time_controller.GetClock(), + time_controller.GetTaskQueueFactory()), + /*capturer=*/nullptr, std::move(renderer)); ASSERT_EQ(audio_device.Init(), AudioDeviceGeneric::InitStatus::OK); bool available; @@ -261,9 +275,11 @@ TEST(TestAudioDeviceTest, PlayoutIsAvailableWhenRendererIsSet) { TEST(TestAudioDeviceTest, PlayoutIsNotAvailableWhenRendererIsNotSet) { GlobalSimulatedTimeController time_controller(kStartTime); - TestAudioDevice audio_device(time_controller.GetTaskQueueFactory(), - /*capturer=*/nullptr, - /*renderer=*/nullptr); + TestAudioDevice audio_device( + CreateEnvironment(time_controller.GetClock(), + time_controller.GetTaskQueueFactory()), + /*capturer=*/nullptr, + /*renderer=*/nullptr); ASSERT_EQ(audio_device.Init(), AudioDeviceGeneric::InitStatus::OK); bool available; diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc index f4321d115b..fee76426cb 100644 --- a/modules/audio_device/win/audio_device_core_win.cc +++ b/modules/audio_device/win/audio_device_core_win.cc @@ -10,19 +10,6 @@ #pragma warning(disable : 4995) // name was marked as #pragma deprecated -#if (_MSC_VER >= 1310) && (_MSC_VER < 1400) -// Reports the major and minor versions of the compiler. -// For example, 1310 for Microsoft Visual C++ .NET 2003. 1310 represents version -// 13 and a 1.0 point release. The Visual C++ 2005 compiler version is 1400. -// Type cl /? at the command line to see the major and minor versions of your -// compiler along with the build number. -#pragma message(">> INFO: Windows Core Audio is not supported in VS 2003") -#endif - -#include "modules/audio_device/audio_device_config.h" // IWYU pragma: keep - -#ifdef WEBRTC_WINDOWS_CORE_AUDIO_BUILD - // clang-format off // To get Windows includes in the right order, this must come before the Windows // includes below. @@ -4166,6 +4153,5 @@ bool AudioDeviceWindowsCore::KeyPressed() const { } return (key_down > 0); } -} // namespace webrtc -#endif // WEBRTC_WINDOWS_CORE_AUDIO_BUILD +} // namespace webrtc diff --git a/modules/audio_device/win/audio_device_core_win.h b/modules/audio_device/win/audio_device_core_win.h index c00bee500f..578a1f697b 100644 --- a/modules/audio_device/win/audio_device_core_win.h +++ b/modules/audio_device/win/audio_device_core_win.h @@ -11,8 +11,6 @@ #ifndef MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_CORE_WIN_H_ #define MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_CORE_WIN_H_ -#if (_MSC_VER >= 1400) // only include for VS 2005 and higher - #include // CLSID_CWMAudioAEC //(must be before audioclient.h) @@ -292,8 +290,6 @@ class AudioDeviceWindowsCore : public AudioDeviceGeneric { uint16_t _outputDeviceIndex; }; -#endif // #if (_MSC_VER >= 1400) - } // namespace webrtc #endif // MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_CORE_WIN_H_ diff --git a/modules/audio_mixer/audio_mixer_impl_unittest.cc b/modules/audio_mixer/audio_mixer_impl_unittest.cc index 82d2419cbe..9cd6b424be 100644 --- a/modules/audio_mixer/audio_mixer_impl_unittest.cc +++ b/modules/audio_mixer/audio_mixer_impl_unittest.cc @@ -45,7 +45,7 @@ namespace webrtc { namespace { constexpr int kDefaultSampleRateHz = 48000; -const char kSourceCountHistogramName[] = +constexpr char kSourceCountHistogramName[] = "WebRTC.Audio.AudioMixer.NewHighestSourceCount"; // Utility function that resets the frame member variables with diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index 20ee6256cc..d6a10ad458 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -400,7 +400,6 @@ if (rtc_include_tests) { "../../rtc_base/synchronization:mutex", "../../rtc_base/system:arch", "../../rtc_base/system:file_wrapper", - "../../test:field_trial", "../../test:fileutils", "../../test:rtc_expect_death", "../../test:test_support", diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index e643570330..0ebeecd30f 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -317,6 +317,7 @@ if (rtc_include_tests) { "..:audio_processing", "..:high_pass_filter", "../../../api:array_view", + "../../../api:field_trials", "../../../api/audio:aec3_config", "../../../api/audio:echo_control", "../../../api/environment", @@ -328,8 +329,7 @@ if (rtc_include_tests) { "../../../rtc_base:stringutils", "../../../rtc_base/system:arch", "../../../system_wrappers:metrics", - "../../../test:explicit_key_value_config", - "../../../test:field_trial", + "../../../test:create_test_field_trials", "../../../test:test_support", "../utility:cascaded_biquad_filter", ] diff --git a/modules/audio_processing/aec3/aec3_common.cc b/modules/audio_processing/aec3/aec3_common.cc index 4fb1f547c2..a55d3610a1 100644 --- a/modules/audio_processing/aec3/aec3_common.cc +++ b/modules/audio_processing/aec3/aec3_common.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/aec3/aec3_common.h" -#include +#include #include "rtc_base/checks.h" #include "rtc_base/cpu_info.h" diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 8856c4e6f0..08c3e76951 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -10,11 +10,10 @@ #include "modules/audio_processing/aec3/aec_state.h" -#include - #include #include #include +#include #include #include #include diff --git a/modules/audio_processing/aec3/block_processor.cc b/modules/audio_processing/aec3/block_processor.cc index e92b8ed7b4..488f4dd528 100644 --- a/modules/audio_processing/aec3/block_processor.cc +++ b/modules/audio_processing/aec3/block_processor.cc @@ -9,9 +9,8 @@ */ #include "modules/audio_processing/aec3/block_processor.h" -#include - #include +#include #include #include #include diff --git a/modules/audio_processing/aec3/decimator_unittest.cc b/modules/audio_processing/aec3/decimator_unittest.cc index 69785c12b0..2adb46f64c 100644 --- a/modules/audio_processing/aec3/decimator_unittest.cc +++ b/modules/audio_processing/aec3/decimator_unittest.cc @@ -10,8 +10,6 @@ #include "modules/audio_processing/aec3/decimator.h" -#include - #include #include #include diff --git a/modules/audio_processing/aec3/echo_canceller3_unittest.cc b/modules/audio_processing/aec3/echo_canceller3_unittest.cc index 01e1d9f6cc..6d99478409 100644 --- a/modules/audio_processing/aec3/echo_canceller3_unittest.cc +++ b/modules/audio_processing/aec3/echo_canceller3_unittest.cc @@ -24,6 +24,7 @@ #include "api/audio/echo_control.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/block.h" #include "modules/audio_processing/aec3/block_processor.h" @@ -33,14 +34,13 @@ #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" namespace webrtc { namespace { -using test::ExplicitKeyValueConfig; using ::testing::_; using ::testing::StrictMock; @@ -744,12 +744,12 @@ TEST(EchoCanceller3Messaging, EchoLeakage) { TEST(EchoCanceller3FieldTrials, Aec3SuppressorAntiHowlingGainOverride) { EchoCanceller3Config default_config; EchoCanceller3Config adjusted_config = - AdjustConfig(default_config, ExplicitKeyValueConfig("")); + AdjustConfig(default_config, CreateTestFieldTrials()); ASSERT_EQ( default_config.suppressor.high_bands_suppression.anti_howling_gain, adjusted_config.suppressor.high_bands_suppression.anti_howling_gain); - ExplicitKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-Aec3SuppressorAntiHowlingGainOverride/0.02/"); adjusted_config = AdjustConfig(default_config, field_trials); @@ -766,12 +766,12 @@ TEST(EchoCanceller3FieldTrials, Aec3SuppressorAntiHowlingGainOverride) { TEST(EchoCanceller3FieldTrials, Aec3EnforceLowActiveRenderLimit) { EchoCanceller3Config default_config; EchoCanceller3Config adjusted_config = - AdjustConfig(default_config, ExplicitKeyValueConfig("")); + AdjustConfig(default_config, CreateTestFieldTrials()); ASSERT_EQ(default_config.render_levels.active_render_limit, adjusted_config.render_levels.active_render_limit); - ExplicitKeyValueConfig field_trials( - "WebRTC-Aec3EnforceLowActiveRenderLimit/Enabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-Aec3EnforceLowActiveRenderLimit/Enabled/"); adjusted_config = AdjustConfig(default_config, field_trials); ASSERT_NE(default_config.render_levels.active_render_limit, @@ -782,7 +782,7 @@ TEST(EchoCanceller3FieldTrials, Aec3EnforceLowActiveRenderLimit) { // Testing the field trial-based override of the suppressor parameters for a // joint passing of all parameters. TEST(EchoCanceller3FieldTrials, Aec3SuppressorTuningOverrideAllParams) { - ExplicitKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-Aec3SuppressorTuningOverride/" "nearend_tuning_mask_lf_enr_transparent:0.1,nearend_tuning_mask_lf_enr_" "suppress:0.2,nearend_tuning_mask_hf_enr_transparent:0.3,nearend_tuning_" @@ -877,7 +877,7 @@ TEST(EchoCanceller3FieldTrials, Aec3SuppressorTuningOverrideAllParams) { // Testing the field trial-based override of the suppressor parameters for // passing one parameter. TEST(EchoCanceller3FieldTrials, Aec3SuppressorTuningOverrideOneParam) { - ExplicitKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-Aec3SuppressorTuningOverride/nearend_tuning_max_inc_factor:0.5/"); EchoCanceller3Config default_config; @@ -928,7 +928,7 @@ TEST(EchoCanceller3FieldTrials, Aec3SuppressorTuningOverrideOneParam) { // Testing the field trial-based that override the exponential decay parameters. TEST(EchoCanceller3FieldTrials, Aec3UseNearendReverb) { - ExplicitKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-Aec3UseNearendReverbLen/default_len:0.9,nearend_len:0.8/"); EchoCanceller3Config default_config; EchoCanceller3Config adjusted_config = @@ -940,7 +940,7 @@ TEST(EchoCanceller3FieldTrials, Aec3UseNearendReverb) { // Testing the field trial-based that overrides the maximum allowed ecess render // blocks in the render buffering. TEST(EchoCanceller3FieldTrials, Aec3BufferingMaxAllowedExcessRenderBlocks) { - ExplicitKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-Aec3BufferingMaxAllowedExcessRenderBlocksOverride/2/"); EchoCanceller3Config default_config; EchoCanceller3Config adjusted_config = diff --git a/modules/audio_processing/aec3/filter_analyzer.cc b/modules/audio_processing/aec3/filter_analyzer.cc index 8147a216ce..cf64737109 100644 --- a/modules/audio_processing/aec3/filter_analyzer.cc +++ b/modules/audio_processing/aec3/filter_analyzer.cc @@ -10,11 +10,10 @@ #include "modules/audio_processing/aec3/filter_analyzer.h" -#include - #include #include #include +#include #include #include #include diff --git a/modules/audio_processing/aec3/render_delay_buffer.cc b/modules/audio_processing/aec3/render_delay_buffer.cc index 0f72be4b62..072785d92b 100644 --- a/modules/audio_processing/aec3/render_delay_buffer.cc +++ b/modules/audio_processing/aec3/render_delay_buffer.cc @@ -10,13 +10,12 @@ #include "modules/audio_processing/aec3/render_delay_buffer.h" -#include - #include #include #include #include #include +#include #include #include #include diff --git a/modules/audio_processing/aec3/reverb_frequency_response.cc b/modules/audio_processing/aec3/reverb_frequency_response.cc index 3006af81e2..c375ad1820 100644 --- a/modules/audio_processing/aec3/reverb_frequency_response.cc +++ b/modules/audio_processing/aec3/reverb_frequency_response.cc @@ -10,10 +10,9 @@ #include "modules/audio_processing/aec3/reverb_frequency_response.h" -#include - #include #include +#include #include #include #include diff --git a/modules/audio_processing/aec3/vector_math_avx2.cc b/modules/audio_processing/aec3/vector_math_avx2.cc index 63b9c1e455..da4dd6e515 100644 --- a/modules/audio_processing/aec3/vector_math_avx2.cc +++ b/modules/audio_processing/aec3/vector_math_avx2.cc @@ -9,7 +9,8 @@ */ #include -#include + +#include #include "api/array_view.h" #include "modules/audio_processing/aec3/vector_math.h" diff --git a/modules/audio_processing/aecm/aecm_core_c.cc b/modules/audio_processing/aecm/aecm_core_c.cc index 439481c77b..f1921b8165 100644 --- a/modules/audio_processing/aecm/aecm_core_c.cc +++ b/modules/audio_processing/aecm/aecm_core_c.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include #include +#include #include #include "common_audio/signal_processing/include/signal_processing_library.h" diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn index f0824fea75..090fbd4604 100644 --- a/modules/audio_processing/agc/BUILD.gn +++ b/modules/audio_processing/agc/BUILD.gn @@ -119,6 +119,7 @@ if (rtc_include_tests) { "../../../rtc_base:safe_minmax", "../../../rtc_base:stringutils", "../../../system_wrappers:metrics", + "../../../test:create_test_field_trials", "../../../test:fileutils", "../../../test:test_support", "//testing/gtest", diff --git a/modules/audio_processing/agc/agc_manager_direct_unittest.cc b/modules/audio_processing/agc/agc_manager_direct_unittest.cc index 49c8c78990..742472d6b9 100644 --- a/modules/audio_processing/agc/agc_manager_direct_unittest.cc +++ b/modules/audio_processing/agc/agc_manager_direct_unittest.cc @@ -26,7 +26,6 @@ #include "api/audio/audio_processing.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "modules/audio_processing/agc/agc.h" #include "modules/audio_processing/agc/gain_control.h" #include "modules/audio_processing/agc/mock_agc.h" @@ -34,6 +33,7 @@ #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_minmax.h" #include "rtc_base/strings/string_builder.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -105,8 +105,7 @@ struct AgcManagerDirectTestParams { std::unique_ptr CreateAgcManagerDirect( AgcManagerDirectTestParams p = {}) { auto manager = std::make_unique( - CreateEnvironment(FieldTrials::CreateNoGlobal(p.field_trials)), - kNumChannels, + CreateEnvironment(CreateTestFieldTrialsPtr(p.field_trials)), kNumChannels, AnalogAgcConfig{.startup_min_volume = kInitialInputVolume, .clipped_level_min = p.clipped_level_min, .enable_digital_adaptive = p.enable_digital_adaptive, @@ -459,7 +458,7 @@ class AgcManagerDirectParametrizedTest : public ::testing::TestWithParam, bool>> { protected: AgcManagerDirectParametrizedTest() - : env_(CreateEnvironment(FieldTrials::CreateNoGlobal( + : env_(CreateEnvironment(CreateTestFieldTrialsPtr( GetAgcMinMicLevelExperimentFieldTrial(std::get<0>(GetParam()))))) {} bool IsMinMicLevelOverridden() const { diff --git a/modules/audio_processing/agc/loudness_histogram_unittest.cc b/modules/audio_processing/agc/loudness_histogram_unittest.cc index a4f1020ad3..63c443260b 100644 --- a/modules/audio_processing/agc/loudness_histogram_unittest.cc +++ b/modules/audio_processing/agc/loudness_histogram_unittest.cc @@ -12,10 +12,9 @@ #include "modules/audio_processing/agc/loudness_histogram.h" -#include - #include #include +#include #include #include @@ -33,7 +32,7 @@ struct InputOutput { double loudness; }; -const double kRelativeErrTol = 1e-10; +constexpr double kRelativeErrTol = 1e-10; class LoudnessHistogramTest : public ::testing::Test { protected: diff --git a/modules/audio_processing/agc/utility.cc b/modules/audio_processing/agc/utility.cc index b8fa3605ea..dd860f7406 100644 --- a/modules/audio_processing/agc/utility.cc +++ b/modules/audio_processing/agc/utility.cc @@ -10,8 +10,7 @@ #include "modules/audio_processing/agc/utility.h" -#include - +#include #include namespace webrtc { diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn index 36d7f983f1..83f8889fff 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn @@ -97,7 +97,7 @@ rtc_library("biquad_filter") { rtc_library("clipping_predictor") { visibility = [ - "../agc:agc", + "../agc", "./*", ] @@ -181,7 +181,7 @@ rtc_library("gain_applier") { rtc_source_set("gain_map") { visibility = [ "..:analog_mic_simulation", - "../agc:agc", + "../agc", "./*", ] @@ -425,7 +425,6 @@ rtc_library("input_volume_controller_unittests") { "../../../rtc_base:safe_minmax", "../../../rtc_base:stringutils", "../../../system_wrappers:metrics", - "../../../test:field_trial", "../../../test:fileutils", "../../../test:test_support", "//testing/gtest", diff --git a/modules/audio_processing/agc2/gain_applier_unittest.cc b/modules/audio_processing/agc2/gain_applier_unittest.cc index 4c8860d582..692a30006a 100644 --- a/modules/audio_processing/agc2/gain_applier_unittest.cc +++ b/modules/audio_processing/agc2/gain_applier_unittest.cc @@ -10,9 +10,8 @@ #include "modules/audio_processing/agc2/gain_applier.h" -#include - #include +#include #include #include #include diff --git a/modules/audio_processing/agc2/noise_level_estimator.cc b/modules/audio_processing/agc2/noise_level_estimator.cc index 76e7bfb0f5..7c0c97a1e2 100644 --- a/modules/audio_processing/agc2/noise_level_estimator.cc +++ b/modules/audio_processing/agc2/noise_level_estimator.cc @@ -10,10 +10,9 @@ #include "modules/audio_processing/agc2/noise_level_estimator.h" -#include - #include #include +#include #include #include diff --git a/modules/audio_processing/audio_buffer.cc b/modules/audio_processing/audio_buffer.cc index 0c9bbc9fea..7f25dbab7a 100644 --- a/modules/audio_processing/audio_buffer.cc +++ b/modules/audio_processing/audio_buffer.cc @@ -205,7 +205,7 @@ void AudioBuffer::CopyTo(AudioBuffer* buffer) const { void AudioBuffer::RestoreNumChannels() { num_channels_ = buffer_num_channels_; data_->set_num_channels(buffer_num_channels_); - if (split_data_.get()) { + if (split_data_) { split_data_->set_num_channels(buffer_num_channels_); } } @@ -214,7 +214,7 @@ void AudioBuffer::set_num_channels(size_t num_channels) { RTC_DCHECK_GE(buffer_num_channels_, num_channels); num_channels_ = num_channels; data_->set_num_channels(num_channels); - if (split_data_.get()) { + if (split_data_) { split_data_->set_num_channels(num_channels); } } diff --git a/modules/audio_processing/audio_buffer_unittest.cc b/modules/audio_processing/audio_buffer_unittest.cc index 19711c66a4..b2b928beb5 100644 --- a/modules/audio_processing/audio_buffer_unittest.cc +++ b/modules/audio_processing/audio_buffer_unittest.cc @@ -22,9 +22,9 @@ namespace webrtc { namespace { -const size_t kSampleRateHz = 48000u; -const size_t kStereo = 2u; -const size_t kMono = 1u; +constexpr size_t kSampleRateHz = 48000u; +constexpr size_t kStereo = 2u; +constexpr size_t kMono = 1u; void ExpectNumChannels(const AudioBuffer& ab, size_t num_channels) { EXPECT_EQ(ab.num_channels(), num_channels); diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index b4b6bbab4b..aa735e7ae4 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc @@ -820,7 +820,7 @@ void AudioProcessingImpl::HandleCaptureOutputUsedSetting( capture_.capture_output_used = capture_output_used || !constants_.minimize_processing_for_unused_output; - if (submodules_.agc_manager.get()) { + if (submodules_.agc_manager) { submodules_.agc_manager->HandleCaptureOutputUsedChange( capture_.capture_output_used); } @@ -2044,9 +2044,8 @@ void AudioProcessingImpl::InitializeGainController1() { return; } - if (!submodules_.agc_manager.get() || - submodules_.agc_manager->num_channels() != - static_cast(num_proc_channels())) { + if (!submodules_.agc_manager || submodules_.agc_manager->num_channels() != + static_cast(num_proc_channels())) { int stream_analog_level = -1; const bool re_creation = !!submodules_.agc_manager; if (re_creation) { diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc index 6882031850..61f00dea8a 100644 --- a/modules/audio_processing/audio_processing_unittest.cc +++ b/modules/audio_processing/audio_processing_unittest.cc @@ -85,7 +85,7 @@ using ::testing::WithoutArgs; // All sample rates used by APM internally during processing. Other input / // output rates are resampled to / from one of these. -const int kProcessSampleRates[] = {16000, 32000, 48000}; +constexpr int kProcessSampleRates[] = {16000, 32000, 48000}; enum StreamDirection { kForward = 0, kReverse }; diff --git a/modules/audio_processing/echo_control_mobile_bit_exact_unittest.cc b/modules/audio_processing/echo_control_mobile_bit_exact_unittest.cc index 4491054ad9..3b495a0cd6 100644 --- a/modules/audio_processing/echo_control_mobile_bit_exact_unittest.cc +++ b/modules/audio_processing/echo_control_mobile_bit_exact_unittest.cc @@ -26,7 +26,7 @@ namespace { // TODO(peah): Increase the number of frames to proces when the issue of // non repeatable test results have been found. -const int kNumFramesToProcess = 200; +constexpr int kNumFramesToProcess = 200; void SetupComponent(int sample_rate_hz, EchoControlMobileImpl::RoutingMode routing_mode, diff --git a/modules/audio_processing/echo_detector/mean_variance_estimator.cc b/modules/audio_processing/echo_detector/mean_variance_estimator.cc index a85740387b..ab744c35b5 100644 --- a/modules/audio_processing/echo_detector/mean_variance_estimator.cc +++ b/modules/audio_processing/echo_detector/mean_variance_estimator.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/echo_detector/mean_variance_estimator.h" -#include +#include #include "rtc_base/checks.h" diff --git a/modules/audio_processing/echo_detector/normalized_covariance_estimator.cc b/modules/audio_processing/echo_detector/normalized_covariance_estimator.cc index 8ec9fe9f0b..fa1573b5a7 100644 --- a/modules/audio_processing/echo_detector/normalized_covariance_estimator.cc +++ b/modules/audio_processing/echo_detector/normalized_covariance_estimator.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/echo_detector/normalized_covariance_estimator.h" -#include +#include #include "rtc_base/checks.h" diff --git a/modules/audio_processing/gain_control_unittest.cc b/modules/audio_processing/gain_control_unittest.cc index 050d2204aa..7db0cd3a73 100644 --- a/modules/audio_processing/gain_control_unittest.cc +++ b/modules/audio_processing/gain_control_unittest.cc @@ -26,7 +26,7 @@ namespace webrtc { namespace { -const int kNumFramesToProcess = 100; +constexpr int kNumFramesToProcess = 100; void ProcessOneFrame(int sample_rate_hz, AudioBuffer* render_audio_buffer, diff --git a/modules/audio_processing/ns/noise_suppressor.cc b/modules/audio_processing/ns/noise_suppressor.cc index c86ddfd3eb..47030c2acd 100644 --- a/modules/audio_processing/ns/noise_suppressor.cc +++ b/modules/audio_processing/ns/noise_suppressor.cc @@ -10,12 +10,11 @@ #include "modules/audio_processing/ns/noise_suppressor.h" -#include -#include -#include - #include #include +#include +#include +#include #include #include "api/array_view.h" diff --git a/modules/audio_processing/post_filter_unittest.cc b/modules/audio_processing/post_filter_unittest.cc index ecb7536373..cc62f1308d 100644 --- a/modules/audio_processing/post_filter_unittest.cc +++ b/modules/audio_processing/post_filter_unittest.cc @@ -9,8 +9,6 @@ */ #include "modules/audio_processing/post_filter.h" -#include - #include #include #include diff --git a/modules/audio_processing/splitting_filter_unittest.cc b/modules/audio_processing/splitting_filter_unittest.cc index 9c6a793422..773f4c945f 100644 --- a/modules/audio_processing/splitting_filter_unittest.cc +++ b/modules/audio_processing/splitting_filter_unittest.cc @@ -21,8 +21,8 @@ namespace webrtc { namespace { -const size_t kSamplesPer16kHzChannel = 160; -const size_t kSamplesPer48kHzChannel = 480; +constexpr size_t kSamplesPer16kHzChannel = 160; +constexpr size_t kSamplesPer48kHzChannel = 480; } // namespace diff --git a/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/modules/audio_processing/test/conversational_speech/generator_unittest.cc index 390ce675e6..e60fe07273 100644 --- a/modules/audio_processing/test/conversational_speech/generator_unittest.cc +++ b/modules/audio_processing/test/conversational_speech/generator_unittest.cc @@ -70,15 +70,15 @@ using conversational_speech::SaveTiming; using conversational_speech::Turn; using conversational_speech::WavReaderFactory; -const char* const audiotracks_path = "/path/to/audiotracks"; -const char* const timing_filepath = "/path/to/timing_file.txt"; -const char* const output_path = "/path/to/output_dir"; +constexpr char kAudioTracksPath[] = "/path/to/audiotracks"; +constexpr char kTimingFilePath[] = "/path/to/timing_file.txt"; +constexpr char kOutputPath[] = "/path/to/output_dir"; -const std::vector expected_timing = { +const std::vector kExpectedTiming = { {"A", "a1", 0, 0}, {"B", "b1", 0, 0}, {"A", "a2", 100, 0}, {"B", "b2", -200, 0}, {"A", "a3", 0, 0}, {"A", "a3", 0, 0}, }; -const std::size_t kNumberOfTurns = expected_timing.size(); +const size_t kNumberOfTurns = kExpectedTiming.size(); // Default arguments for MockWavReaderFactory ctor. // Fake audio track parameters. @@ -174,31 +174,31 @@ void DeleteFolderAndContents(absl::string_view dir) { using ::testing::_; TEST(ConversationalSpeechTest, Settings) { - const conversational_speech::Config config(audiotracks_path, timing_filepath, - output_path); + const conversational_speech::Config config(kAudioTracksPath, kTimingFilePath, + kOutputPath); // Test getters. - EXPECT_EQ(audiotracks_path, config.audiotracks_path()); - EXPECT_EQ(timing_filepath, config.timing_filepath()); - EXPECT_EQ(output_path, config.output_path()); + EXPECT_EQ(kAudioTracksPath, config.audiotracks_path()); + EXPECT_EQ(kTimingFilePath, config.timing_filepath()); + EXPECT_EQ(kOutputPath, config.output_path()); } TEST(ConversationalSpeechTest, TimingSaveLoad) { // Save test timing. const std::string temporary_filepath = TempFilename(OutputPath(), "TempTimingTestFile"); - SaveTiming(temporary_filepath, expected_timing); + SaveTiming(temporary_filepath, kExpectedTiming); // Create a std::vector instance by loading from file. std::vector actual_timing = LoadTiming(temporary_filepath); RemoveFile(temporary_filepath); // Check size. - EXPECT_EQ(expected_timing.size(), actual_timing.size()); + EXPECT_EQ(kExpectedTiming.size(), actual_timing.size()); // Check Turn instances. - for (size_t index = 0; index < expected_timing.size(); ++index) { - EXPECT_EQ(expected_timing[index], actual_timing[index]) + for (size_t index = 0; index < kExpectedTiming.size(); ++index) { + EXPECT_EQ(kExpectedTiming[index], actual_timing[index]) << "turn #" << index << " not matching"; } } @@ -211,7 +211,7 @@ TEST(ConversationalSpeechTest, MultiEndCallCreate) { // Inject the mock wav reader factory. conversational_speech::MultiEndCall multiend_call( - expected_timing, audiotracks_path, std::move(mock_wavreader_factory)); + kExpectedTiming, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -230,7 +230,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupDifferentSampleRates) { // There are two unique audio tracks to read. EXPECT_CALL(*mock_wavreader_factory, Create(::testing::_)).Times(2); - MultiEndCall multiend_call(timing, audiotracks_path, + MultiEndCall multiend_call(timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -245,7 +245,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupMultipleChannels) { // There is one unique audio track to read. EXPECT_CALL(*mock_wavreader_factory, Create(::testing::_)).Times(1); - MultiEndCall multiend_call(timing, audiotracks_path, + MultiEndCall multiend_call(timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -261,7 +261,7 @@ TEST(ConversationalSpeechTest, // There are two unique audio tracks to read. EXPECT_CALL(*mock_wavreader_factory, Create(::testing::_)).Times(2); - MultiEndCall multiend_call(timing, audiotracks_path, + MultiEndCall multiend_call(timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -277,7 +277,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupFirstOffsetNegative) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(1); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -296,7 +296,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupSimple) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(1); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -321,7 +321,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupPause) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(1); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -346,7 +346,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupCrossTalk) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(1); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -370,7 +370,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupInvalidOrder) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(1); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -390,7 +390,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupCrossTalkThree) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(2); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -417,7 +417,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupSelfCrossTalkNearInvalid) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(1); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -440,7 +440,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupSelfCrossTalkFarInvalid) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(2); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -461,7 +461,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupCrossTalkMiddleValid) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(2); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -489,7 +489,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupCrossTalkMiddleInvalid) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(2); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } @@ -510,7 +510,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupCrossTalkMiddleAndPause) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(2); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -534,7 +534,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupCrossTalkFullOverlapValid) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(1); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -562,7 +562,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupLongSequence) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(2); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_TRUE(multiend_call.valid()); // Test. @@ -592,7 +592,7 @@ TEST(ConversationalSpeechTest, MultiEndCallSetupLongSequenceInvalid) { EXPECT_CALL(*mock_wavreader_factory, Create(_)).Times(2); conversational_speech::MultiEndCall multiend_call( - timing, audiotracks_path, std::move(mock_wavreader_factory)); + timing, kAudioTracksPath, std::move(mock_wavreader_factory)); EXPECT_FALSE(multiend_call.valid()); } diff --git a/modules/audio_processing/test/debug_dump_replayer.cc b/modules/audio_processing/test/debug_dump_replayer.cc index cebc7feb43..1b2f2ae1f7 100644 --- a/modules/audio_processing/test/debug_dump_replayer.cc +++ b/modules/audio_processing/test/debug_dump_replayer.cc @@ -34,7 +34,7 @@ namespace { void MaybeResetBuffer(std::unique_ptr>* buffer, const StreamConfig& config) { auto& buffer_ref = *buffer; - if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() || + if (!buffer_ref || buffer_ref->num_frames() != config.num_frames() || buffer_ref->num_channels() != config.num_channels()) { buffer_ref.reset( new ChannelBuffer(config.num_frames(), config.num_channels())); diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc index 8f6051c941..b6a5f845cb 100644 --- a/modules/audio_processing/test/debug_dump_test.cc +++ b/modules/audio_processing/test/debug_dump_test.cc @@ -43,7 +43,7 @@ namespace { void MaybeResetBuffer(std::unique_ptr>* buffer, const StreamConfig& config) { auto& buffer_ref = *buffer; - if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() || + if (!buffer_ref || buffer_ref->num_frames() != config.num_frames() || buffer_ref->num_channels() != config.num_channels()) { buffer_ref.reset( new ChannelBuffer(config.num_frames(), config.num_channels())); diff --git a/modules/audio_processing/test/performance_timer.cc b/modules/audio_processing/test/performance_timer.cc index 42e915bba2..3cb7a43fa5 100644 --- a/modules/audio_processing/test/performance_timer.cc +++ b/modules/audio_processing/test/performance_timer.cc @@ -10,8 +10,7 @@ #include "modules/audio_processing/test/performance_timer.h" -#include - +#include #include #include #include diff --git a/modules/audio_processing/test/wav_based_simulator.cc b/modules/audio_processing/test/wav_based_simulator.cc index 24d68b63d8..3dda64936f 100644 --- a/modules/audio_processing/test/wav_based_simulator.cc +++ b/modules/audio_processing/test/wav_based_simulator.cc @@ -10,8 +10,7 @@ #include "modules/audio_processing/test/wav_based_simulator.h" -#include - +#include #include #include #include diff --git a/modules/audio_processing/utility/delay_estimator.cc b/modules/audio_processing/utility/delay_estimator.cc index 20609fbbfa..45ef77e8ba 100644 --- a/modules/audio_processing/utility/delay_estimator.cc +++ b/modules/audio_processing/utility/delay_estimator.cc @@ -10,11 +10,10 @@ #include "modules/audio_processing/utility/delay_estimator.h" -#include -#include - #include #include +#include +#include #include "rtc_base/checks.h" diff --git a/modules/audio_processing/utility/delay_estimator_unittest.cc b/modules/audio_processing/utility/delay_estimator_unittest.cc index ba77688fed..11b28fb922 100644 --- a/modules/audio_processing/utility/delay_estimator_unittest.cc +++ b/modules/audio_processing/utility/delay_estimator_unittest.cc @@ -30,11 +30,11 @@ constexpr int kHistorySize = kMaxDelay + kLookahead; // Length of binary spectrum sequence. constexpr int kSequenceLength = 400; -const int kDifferentHistorySize = 3; -const int kDifferentLookahead = 1; +constexpr int kDifferentHistorySize = 3; +constexpr int kDifferentLookahead = 1; -const int kEnable[] = {0, 1}; -const size_t kSizeEnable = sizeof(kEnable) / sizeof(*kEnable); +constexpr int kEnable[] = {0, 1}; +constexpr size_t kSizeEnable = sizeof(kEnable) / sizeof(*kEnable); class DelayEstimatorTest : public ::testing::Test { protected: diff --git a/modules/audio_processing/utility/delay_estimator_wrapper.cc b/modules/audio_processing/utility/delay_estimator_wrapper.cc index 05e4b74393..f962f41163 100644 --- a/modules/audio_processing/utility/delay_estimator_wrapper.cc +++ b/modules/audio_processing/utility/delay_estimator_wrapper.cc @@ -10,10 +10,9 @@ #include "modules/audio_processing/utility/delay_estimator_wrapper.h" -#include -#include - #include +#include +#include #include "modules/audio_processing/utility/delay_estimator.h" #include "modules/audio_processing/utility/delay_estimator_internal.h" diff --git a/modules/audio_processing/vad/gmm.cc b/modules/audio_processing/vad/gmm.cc index 3b8764c4d0..03615c0882 100644 --- a/modules/audio_processing/vad/gmm.cc +++ b/modules/audio_processing/vad/gmm.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/vad/gmm.h" -#include +#include namespace webrtc { diff --git a/modules/audio_processing/vad/gmm_unittest.cc b/modules/audio_processing/vad/gmm_unittest.cc index d895afab7b..9acae431e7 100644 --- a/modules/audio_processing/vad/gmm_unittest.cc +++ b/modules/audio_processing/vad/gmm_unittest.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/vad/gmm.h" -#include +#include #include "modules/audio_processing/vad/noise_gmm_tables.h" #include "modules/audio_processing/vad/voice_gmm_tables.h" diff --git a/modules/audio_processing/vad/pitch_internal_unittest.cc b/modules/audio_processing/vad/pitch_internal_unittest.cc index c851421ba7..c4374a1b46 100644 --- a/modules/audio_processing/vad/pitch_internal_unittest.cc +++ b/modules/audio_processing/vad/pitch_internal_unittest.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/vad/pitch_internal.h" -#include +#include #include "test/gtest.h" diff --git a/modules/audio_processing/vad/vad_circular_buffer.cc b/modules/audio_processing/vad/vad_circular_buffer.cc index e05b0a584f..57b64de36b 100644 --- a/modules/audio_processing/vad/vad_circular_buffer.cc +++ b/modules/audio_processing/vad/vad_circular_buffer.cc @@ -10,7 +10,7 @@ #include "modules/audio_processing/vad/vad_circular_buffer.h" -#include +#include namespace webrtc { diff --git a/modules/audio_processing/vad/vad_circular_buffer_unittest.cc b/modules/audio_processing/vad/vad_circular_buffer_unittest.cc index efbd70d9d9..4ddc9375b5 100644 --- a/modules/audio_processing/vad/vad_circular_buffer_unittest.cc +++ b/modules/audio_processing/vad/vad_circular_buffer_unittest.cc @@ -10,8 +10,6 @@ #include "modules/audio_processing/vad/vad_circular_buffer.h" -#include - #include #include "test/gtest.h" diff --git a/modules/audio_processing/vad/voice_activity_detector_unittest.cc b/modules/audio_processing/vad/voice_activity_detector_unittest.cc index 5922c8bf70..410209e042 100644 --- a/modules/audio_processing/vad/voice_activity_detector_unittest.cc +++ b/modules/audio_processing/vad/voice_activity_detector_unittest.cc @@ -24,11 +24,11 @@ namespace webrtc { namespace { -const int kStartTimeSec = 16; -const float kMeanSpeechProbability = 0.3f; -const float kMaxNoiseProbability = 0.1f; -const size_t kNumChunks = 300u; -const size_t kNumChunksPerIsacBlock = 3; +constexpr int kStartTimeSec = 16; +constexpr float kMeanSpeechProbability = 0.3f; +constexpr float kMaxNoiseProbability = 0.1f; +constexpr size_t kNumChunks = 300u; +constexpr size_t kNumChunksPerIsacBlock = 3; void GenerateNoise(std::vector* data) { for (size_t i = 0; i < data->size(); ++i) { diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index e1cd1c4813..b84156e8fc 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -25,7 +25,6 @@ rtc_library("goog_cc") { "../../../api:field_trials_view", "../../../api:network_state_predictor_api", "../../../api/environment", - "../../../api/rtc_event_log", "../../../api/transport:bandwidth_usage", "../../../api/transport:network_control", "../../../api/units:data_rate", @@ -33,15 +32,11 @@ rtc_library("goog_cc") { "../../../api/units:time_delta", "../../../api/units:timestamp", "../../../logging:rtc_event_bwe", - "../../../logging:rtc_event_pacing", "../../../rtc_base:checks", "../../../rtc_base:logging", - "../../../rtc_base/experiments:alr_experiment", "../../../rtc_base/experiments:field_trial_parser", "../../../rtc_base/experiments:rate_control_settings", - "../../../system_wrappers", "../../remote_bitrate_estimator", - "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -78,10 +73,14 @@ rtc_library("alr_detector") { ] deps = [ "../../../api:field_trials_view", + "../../../api/environment", "../../../api/rtc_event_log", + "../../../api/units:data_rate", + "../../../api/units:data_size", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../logging:rtc_event_pacing", "../../../rtc_base:checks", - "../../../rtc_base:safe_conversions", "../../../rtc_base:timeutils", "../../../rtc_base/experiments:alr_experiment", "../../../rtc_base/experiments:field_trial_parser", @@ -312,6 +311,7 @@ if (rtc_include_tests) { "../../../test/scenario:column_printer", "../../pacing", "//testing/gmock", + "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", ] } diff --git a/modules/congestion_controller/goog_cc/alr_detector.cc b/modules/congestion_controller/goog_cc/alr_detector.cc index 801d23a4be..d7fde1aa66 100644 --- a/modules/congestion_controller/goog_cc/alr_detector.cc +++ b/modules/congestion_controller/goog_cc/alr_detector.cc @@ -10,13 +10,16 @@ #include "modules/congestion_controller/goog_cc/alr_detector.h" -#include -#include #include #include +#include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event_log.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_alr_state.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/alr_experiment.h" @@ -25,89 +28,75 @@ namespace webrtc { -namespace { -AlrDetectorConfig GetConfigFromTrials(const FieldTrialsView* key_value_config) { - RTC_CHECK(AlrExperimentSettings::MaxOneFieldTrialEnabled(*key_value_config)); +AlrDetector::AlrDetectorConfig::AlrDetectorConfig( + const FieldTrialsView& key_value_config) { + RTC_CHECK(AlrExperimentSettings::MaxOneFieldTrialEnabled(key_value_config)); std::optional experiment_settings = AlrExperimentSettings::CreateFromFieldTrial( - *key_value_config, + key_value_config, AlrExperimentSettings::kScreenshareProbingBweExperimentName); if (!experiment_settings) { experiment_settings = AlrExperimentSettings::CreateFromFieldTrial( - *key_value_config, + key_value_config, AlrExperimentSettings::kStrictPacingAndProbingExperimentName); } - AlrDetectorConfig conf; if (experiment_settings) { - conf.bandwidth_usage_ratio = + bandwidth_usage_ratio = experiment_settings->alr_bandwidth_usage_percent / 100.0; - conf.start_budget_level_ratio = + start_budget_level_ratio = experiment_settings->alr_start_budget_level_percent / 100.0; - conf.stop_budget_level_ratio = + stop_budget_level_ratio = experiment_settings->alr_stop_budget_level_percent / 100.0; } - conf.Parser()->Parse( - key_value_config->Lookup("WebRTC-AlrDetectorParameters")); - return conf; -} -} // namespace - -std::unique_ptr AlrDetectorConfig::Parser() { - return StructParametersParser::Create( // + StructParametersParser::Create( // "bw_usage", &bandwidth_usage_ratio, // "start", &start_budget_level_ratio, // - "stop", &stop_budget_level_ratio); + "stop", &stop_budget_level_ratio) + ->Parse(key_value_config.Lookup("WebRTC-AlrDetectorParameters")); } -AlrDetector::AlrDetector(AlrDetectorConfig config, RtcEventLog* event_log) - : conf_(config), alr_budget_(0, true), event_log_(event_log) {} - -AlrDetector::AlrDetector(const FieldTrialsView* key_value_config) - : AlrDetector(GetConfigFromTrials(key_value_config), nullptr) {} +AlrDetector::AlrDetector(const Environment& env) + : env_(env), conf_(env_.field_trials()), alr_budget_(0, true) {} -AlrDetector::AlrDetector(const FieldTrialsView* key_value_config, - RtcEventLog* event_log) - : AlrDetector(GetConfigFromTrials(key_value_config), event_log) {} -AlrDetector::~AlrDetector() {} +AlrDetector::~AlrDetector() = default; -void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t send_time_ms) { - if (!last_send_time_ms_.has_value()) { - last_send_time_ms_ = send_time_ms; +void AlrDetector::OnBytesSent(DataSize bytes_sent, Timestamp send_time) { + if (!last_send_time_.has_value()) { + last_send_time_ = send_time; // Since the duration for sending the bytes is unknwon, return without // updating alr state. return; } - int64_t delta_time_ms = send_time_ms - *last_send_time_ms_; - last_send_time_ms_ = send_time_ms; + TimeDelta delta_time = send_time - *last_send_time_; + last_send_time_ = send_time; - alr_budget_.UseBudget(bytes_sent); - alr_budget_.IncreaseBudget(delta_time_ms); + alr_budget_.UseBudget(bytes_sent.bytes()); + alr_budget_.IncreaseBudget(delta_time.ms()); bool state_changed = false; if (alr_budget_.budget_ratio() > conf_.start_budget_level_ratio && - !alr_started_time_ms_) { - alr_started_time_ms_.emplace(TimeMillis()); + !alr_started_time_) { + alr_started_time_ = Timestamp::Millis(TimeMillis()); state_changed = true; } else if (alr_budget_.budget_ratio() < conf_.stop_budget_level_ratio && - alr_started_time_ms_) { + alr_started_time_) { state_changed = true; - alr_started_time_ms_.reset(); + alr_started_time_ = std::nullopt; } - if (event_log_ && state_changed) { - event_log_->Log( - std::make_unique(alr_started_time_ms_.has_value())); + if (state_changed) { + env_.event_log().Log( + std::make_unique(alr_started_time_.has_value())); } } -void AlrDetector::SetEstimatedBitrate(int bitrate_bps) { - RTC_DCHECK(bitrate_bps); - int target_rate_kbps = - static_cast(bitrate_bps) * conf_.bandwidth_usage_ratio / 1000; - alr_budget_.set_target_rate_kbps(target_rate_kbps); +void AlrDetector::SetEstimatedBitrate(DataRate bitrate) { + RTC_DCHECK_GT(bitrate, DataRate::Zero()); + alr_budget_.set_target_rate_kbps( + (bitrate * conf_.bandwidth_usage_ratio).kbps()); } -std::optional AlrDetector::GetApplicationLimitedRegionStartTime() +std::optional AlrDetector::GetApplicationLimitedRegionStartTime() const { - return alr_started_time_ms_; + return alr_started_time_; } } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/alr_detector.h b/modules/congestion_controller/goog_cc/alr_detector.h index e758b26c9a..c250e5d6b0 100644 --- a/modules/congestion_controller/goog_cc/alr_detector.h +++ b/modules/congestion_controller/goog_cc/alr_detector.h @@ -11,31 +11,17 @@ #ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_ALR_DETECTOR_H_ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_ALR_DETECTOR_H_ -#include -#include - -#include #include +#include "api/environment/environment.h" #include "api/field_trials_view.h" +#include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/timestamp.h" #include "modules/pacing/interval_budget.h" -#include "rtc_base/experiments/struct_parameters_parser.h" namespace webrtc { -class RtcEventLog; - -struct AlrDetectorConfig { - // Sent traffic ratio as a function of network capacity used to determine - // application-limited region. ALR region start when bandwidth usage drops - // below kAlrStartUsageRatio and ends when it raises above - // kAlrEndUsageRatio. NOTE: This is intentionally conservative at the moment - // until BW adjustments of application limited region is fine tuned. - double bandwidth_usage_ratio = 0.65; - double start_budget_level_ratio = 0.80; - double stop_budget_level_ratio = 0.50; - std::unique_ptr Parser(); -}; // Application limited region detector is a class that utilizes signals of // elapsed time and bytes sent to estimate whether network traffic is // currently limited by the application's ability to generate traffic. @@ -45,30 +31,44 @@ struct AlrDetectorConfig { // Note: This class is not thread-safe. class AlrDetector { public: - AlrDetector(AlrDetectorConfig config, RtcEventLog* event_log); - explicit AlrDetector(const FieldTrialsView* key_value_config); - AlrDetector(const FieldTrialsView* key_value_config, RtcEventLog* event_log); + explicit AlrDetector(const Environment& env); + + AlrDetector(const AlrDetector&) = delete; + AlrDetector& operator=(const AlrDetector&) = delete; + ~AlrDetector(); - void OnBytesSent(size_t bytes_sent, int64_t send_time_ms); + void OnBytesSent(DataSize bytes_sent, Timestamp send_time); // Set current estimated bandwidth. - void SetEstimatedBitrate(int bitrate_bps); + void SetEstimatedBitrate(DataRate bitrate); // Returns time in milliseconds when the current application-limited region // started or empty result if the sender is currently not application-limited. - std::optional GetApplicationLimitedRegionStartTime() const; + std::optional GetApplicationLimitedRegionStartTime() const; private: friend class GoogCcStatePrinter; + struct AlrDetectorConfig { + explicit AlrDetectorConfig(const FieldTrialsView& key_value_config); + + // Sent traffic ratio as a function of network capacity used to determine + // application-limited region. ALR region start when bandwidth usage drops + // below kAlrStartUsageRatio and ends when it raises above + // kAlrEndUsageRatio. NOTE: This is intentionally conservative at the moment + // until BW adjustments of application limited region is fine tuned. + double bandwidth_usage_ratio = 0.65; + double start_budget_level_ratio = 0.80; + double stop_budget_level_ratio = 0.50; + }; + + const Environment env_; const AlrDetectorConfig conf_; - std::optional last_send_time_ms_; + std::optional last_send_time_; IntervalBudget alr_budget_; - std::optional alr_started_time_ms_; - - RtcEventLog* event_log_; + std::optional alr_started_time_; }; } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/alr_detector_unittest.cc b/modules/congestion_controller/goog_cc/alr_detector_unittest.cc index 2fdba71dff..f08fb3bc71 100644 --- a/modules/congestion_controller/goog_cc/alr_detector_unittest.cc +++ b/modules/congestion_controller/goog_cc/alr_detector_unittest.cc @@ -10,33 +10,33 @@ #include "modules/congestion_controller/goog_cc/alr_detector.h" -#include #include +#include "absl/base/nullability.h" +#include "api/environment/environment_factory.h" #include "api/field_trials.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/alr_experiment.h" +#include "system_wrappers/include/clock.h" #include "test/create_test_field_trials.h" #include "test/gtest.h" +namespace webrtc { namespace { -constexpr int kEstimatedBitrateBps = 300000; - -} // namespace +constexpr DataRate kEstimatedBitrate = DataRate::BitsPerSec(300'000); -namespace webrtc { -namespace { class SimulateOutgoingTrafficIn { public: - explicit SimulateOutgoingTrafficIn(AlrDetector* alr_detector, - int64_t* timestamp_ms) - : alr_detector_(alr_detector), timestamp_ms_(timestamp_ms) { - RTC_CHECK(alr_detector_); - } + explicit SimulateOutgoingTrafficIn(AlrDetector* absl_nonnull alr_detector, + SimulatedClock* absl_nonnull clock) + : alr_detector_(*alr_detector), clock_(*clock) {} - SimulateOutgoingTrafficIn& ForTimeMs(int time_ms) { - interval_ms_ = time_ms; + SimulateOutgoingTrafficIn& ForTime(TimeDelta time) { + interval_ = time; ProduceTraffic(); return *this; } @@ -49,97 +49,92 @@ class SimulateOutgoingTrafficIn { private: void ProduceTraffic() { - if (!interval_ms_ || !usage_percentage_) + if (!interval_ || !usage_percentage_) return; - const int kTimeStepMs = 10; - for (int t = 0; t < *interval_ms_; t += kTimeStepMs) { - *timestamp_ms_ += kTimeStepMs; - alr_detector_->OnBytesSent(kEstimatedBitrateBps * *usage_percentage_ * - kTimeStepMs / (8 * 100 * 1000), - *timestamp_ms_); - } - int remainder_ms = *interval_ms_ % kTimeStepMs; - if (remainder_ms > 0) { - *timestamp_ms_ += kTimeStepMs; - alr_detector_->OnBytesSent(kEstimatedBitrateBps * *usage_percentage_ * - remainder_ms / (8 * 100 * 1000), - *timestamp_ms_); + const TimeDelta kTimeStep = TimeDelta::Millis(10); + for (TimeDelta t = TimeDelta::Zero(); t < *interval_; t += kTimeStep) { + clock_.AdvanceTime(kTimeStep); + alr_detector_.OnBytesSent( + kEstimatedBitrate * *usage_percentage_ * kTimeStep / 100, + clock_.CurrentTime()); } + // As of now all tests use interval that is a multiple of 10ms. + RTC_DCHECK_EQ(interval_->ms() % kTimeStep.ms(), 0); } - AlrDetector* const alr_detector_; - int64_t* timestamp_ms_; - std::optional interval_ms_; + AlrDetector& alr_detector_; + SimulatedClock& clock_; + std::optional interval_; std::optional usage_percentage_; }; } // namespace TEST(AlrDetectorTest, AlrDetection) { - FieldTrials field_trials = CreateTestFieldTrials(); - int64_t timestamp_ms = 1000; - AlrDetector alr_detector(&field_trials); - alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps); + SimulatedClock clock(Timestamp::Seconds(1)); + AlrDetector alr_detector( + CreateEnvironment(CreateTestFieldTrialsPtr(), &clock)); + alr_detector.SetEstimatedBitrate(kEstimatedBitrate); // Start in non-ALR state. EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); // Stay in non-ALR state when usage is close to 100%. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(1000) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Seconds(1)) .AtPercentOfEstimatedBitrate(90); EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); // Verify that we ALR starts when bitrate drops below 20%. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(1500) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Millis(1'500)) .AtPercentOfEstimatedBitrate(20); EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime()); // Verify that ALR ends when usage is above 65%. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(4000) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Seconds(4)) .AtPercentOfEstimatedBitrate(100); EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); } TEST(AlrDetectorTest, ShortSpike) { - FieldTrials field_trials = CreateTestFieldTrials(); - int64_t timestamp_ms = 1000; - AlrDetector alr_detector(&field_trials); - alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps); + SimulatedClock clock(Timestamp::Seconds(1)); + AlrDetector alr_detector( + CreateEnvironment(CreateTestFieldTrialsPtr(), &clock)); + alr_detector.SetEstimatedBitrate(kEstimatedBitrate); // Start in non-ALR state. EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); // Verify that we ALR starts when bitrate drops below 20%. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(1000) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Seconds(1)) .AtPercentOfEstimatedBitrate(20); EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime()); // Verify that we stay in ALR region even after a short bitrate spike. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(100) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Millis(100)) .AtPercentOfEstimatedBitrate(150); EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime()); // ALR ends when usage is above 65%. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(3000) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Seconds(3)) .AtPercentOfEstimatedBitrate(100); EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); } TEST(AlrDetectorTest, BandwidthEstimateChanges) { - FieldTrials field_trials = CreateTestFieldTrials(); - int64_t timestamp_ms = 1000; - AlrDetector alr_detector(&field_trials); - alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps); + SimulatedClock clock(Timestamp::Seconds(1)); + AlrDetector alr_detector( + CreateEnvironment(CreateTestFieldTrialsPtr(), &clock)); + alr_detector.SetEstimatedBitrate(kEstimatedBitrate); // Start in non-ALR state. EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); // ALR starts when bitrate drops below 20%. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(1000) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Seconds(1)) .AtPercentOfEstimatedBitrate(20); EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime()); @@ -147,10 +142,10 @@ TEST(AlrDetectorTest, BandwidthEstimateChanges) { // it shortly afterwards as the sender continues sending the same amount of // traffic. This is necessary to ensure that ProbeController can still react // to the BWE drop by initiating a new probe. - alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps / 5); + alr_detector.SetEstimatedBitrate(kEstimatedBitrate / 5); EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime()); - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(1000) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Seconds(1)) .AtPercentOfEstimatedBitrate(50); EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); } @@ -180,27 +175,27 @@ TEST(AlrDetectorTest, ParseActiveFieldTrial) { } TEST(AlrDetectorTest, ParseAlrSpecificFieldTrial) { - FieldTrials field_trials = CreateTestFieldTrials( - "WebRTC-AlrDetectorParameters/" - "bw_usage:90%,start:0%,stop:-10%/"); - AlrDetector alr_detector(&field_trials); - int64_t timestamp_ms = 1000; - alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps); + SimulatedClock clock(Timestamp::Seconds(1)); + AlrDetector alr_detector(CreateEnvironment( + CreateTestFieldTrialsPtr( + "WebRTC-AlrDetectorParameters/bw_usage:90%,start:0%,stop:-10%/"), + &clock)); + alr_detector.SetEstimatedBitrate(kEstimatedBitrate); // Start in non-ALR state. EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); // ALR does not start at 100% utilization. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(1000) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Seconds(1)) .AtPercentOfEstimatedBitrate(100); EXPECT_FALSE(alr_detector.GetApplicationLimitedRegionStartTime()); // ALR does start at 85% utilization. // Overused 10% above so it should take about 2s to reach a budget level of // 0%. - SimulateOutgoingTrafficIn(&alr_detector, ×tamp_ms) - .ForTimeMs(2100) + SimulateOutgoingTrafficIn(&alr_detector, &clock) + .ForTime(TimeDelta::Millis(2'100)) .AtPercentOfEstimatedBitrate(85); EXPECT_TRUE(alr_detector.GetApplicationLimitedRegionStartTime()); } 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 e3ee7f3299..24d3143373 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -10,10 +10,9 @@ #include "modules/congestion_controller/goog_cc/goog_cc_network_control.h" -#include - #include #include +#include #include #include #include @@ -114,8 +113,7 @@ GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config, bandwidth_estimation_( std::make_unique(&env_.field_trials(), &env_.event_log())), - alr_detector_(std::make_unique(&env_.field_trials(), - &env_.event_log())), + alr_detector_(env_), probe_bitrate_estimator_(new ProbeBitrateEstimator(&env_.event_log())), network_estimator_(std::move(goog_cc_config.network_state_estimator)), network_state_predictor_( @@ -128,7 +126,6 @@ GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config, initial_config_(config), last_loss_based_target_rate_(*config.constraints.starting_rate), last_pushback_target_rate_(last_loss_based_target_rate_), - last_stable_target_rate_(last_loss_based_target_rate_), last_loss_base_state_(LossBasedState::kDelayBasedEstimate), pacing_factor_(config.stream_based_config.pacing_factor.value_or( kDefaultPaceMultiplier)), @@ -222,9 +219,8 @@ NetworkControlUpdate GoogCcNetworkController::OnProcessInterval( msg.pacer_queue->bytes()); } bandwidth_estimation_->UpdateEstimate(msg.at_time); - std::optional start_time_ms = - alr_detector_->GetApplicationLimitedRegionStartTime(); - probe_controller_->SetAlrStartTimeMs(start_time_ms); + probe_controller_->SetAlrStartTime( + alr_detector_.GetApplicationLimitedRegionStartTime()); auto probes = probe_controller_->Process(msg.at_time); update.probe_cluster_configs.insert(update.probe_cluster_configs.end(), @@ -265,10 +261,9 @@ NetworkControlUpdate GoogCcNetworkController::OnRoundTripTimeUpdate( NetworkControlUpdate GoogCcNetworkController::OnSentPacket( SentPacket sent_packet) { - alr_detector_->OnBytesSent(sent_packet.size.bytes(), - sent_packet.send_time.ms()); + alr_detector_.OnBytesSent(sent_packet.size, sent_packet.send_time); acknowledged_bitrate_estimator_->SetAlr( - alr_detector_->GetApplicationLimitedRegionStartTime().has_value()); + alr_detector_.GetApplicationLimitedRegionStartTime().has_value()); if (!first_packet_sent_) { first_packet_sent_ = true; @@ -447,12 +442,11 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( min_propagation_rtt); } - std::optional alr_start_time = - alr_detector_->GetApplicationLimitedRegionStartTime(); + std::optional alr_start_time = + alr_detector_.GetApplicationLimitedRegionStartTime(); if (previously_in_alr_ && !alr_start_time.has_value()) { - int64_t now_ms = report.feedback_time.ms(); acknowledged_bitrate_estimator_->SetAlrEndedTime(report.feedback_time); - probe_controller_->SetAlrEndedTimeMs(now_ms); + probe_controller_->SetAlrEndedTime(report.feedback_time); } previously_in_alr_ = alr_start_time.has_value(); acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( @@ -522,7 +516,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( recovered_from_overuse = result.recovered_from_overuse; if (recovered_from_overuse) { - probe_controller_->SetAlrStartTimeMs(alr_start_time); + probe_controller_->SetAlrStartTime(alr_start_time); auto probes = probe_controller_->RequestProbe(report.feedback_time); update.probe_cluster_configs.insert(update.probe_cluster_configs.end(), probes.begin(), probes.end()); @@ -578,8 +572,6 @@ NetworkControlUpdate GoogCcNetworkController::GetNetworkState( update.target_rate->at_time = at_time; update.target_rate->target_rate = last_pushback_target_rate_; - update.target_rate->stable_target_rate = - bandwidth_estimation_->GetEstimatedLinkCapacity(); update.pacer_config = GetPacingRates(at_time); update.congestion_window = current_data_window_; return update; @@ -608,24 +600,19 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged( loss_based_target_rate.bps(); } } - DataRate stable_target_rate = - bandwidth_estimation_->GetEstimatedLinkCapacity(); - stable_target_rate = std::min(stable_target_rate, pushback_target_rate); if ((loss_based_target_rate != last_loss_based_target_rate_) || (loss_based_state != last_loss_base_state_) || (fraction_loss != last_estimated_fraction_loss_) || (round_trip_time != last_estimated_round_trip_time_) || - (pushback_target_rate != last_pushback_target_rate_) || - (stable_target_rate != last_stable_target_rate_)) { + (pushback_target_rate != last_pushback_target_rate_)) { last_loss_based_target_rate_ = loss_based_target_rate; last_pushback_target_rate_ = pushback_target_rate; last_estimated_fraction_loss_ = fraction_loss; last_estimated_round_trip_time_ = round_trip_time; - last_stable_target_rate_ = stable_target_rate; last_loss_base_state_ = loss_based_state; - alr_detector_->SetEstimatedBitrate(loss_based_target_rate.bps()); + alr_detector_.SetEstimatedBitrate(loss_based_target_rate); TimeDelta bwe_period = delay_based_bwe_->GetExpectedBwePeriod(); @@ -637,7 +624,10 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged( } else { target_rate_msg.target_rate = pushback_target_rate; } - target_rate_msg.stable_target_rate = stable_target_rate; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + target_rate_msg.stable_target_rate = loss_based_target_rate; +#pragma clang diagnostic pop target_rate_msg.network_estimate.at_time = at_time; target_rate_msg.network_estimate.round_trip_time = round_trip_time; target_rate_msg.network_estimate.loss_rate_ratio = fraction_loss / 255.0f; diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.h b/modules/congestion_controller/goog_cc/goog_cc_network_control.h index ade7b91f7a..38e6af42b0 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -98,7 +98,7 @@ class GoogCcNetworkController : public NetworkControllerInterface { congestion_window_pushback_controller_; std::unique_ptr bandwidth_estimation_; - std::unique_ptr alr_detector_; + AlrDetector alr_detector_; std::unique_ptr probe_bitrate_estimator_; std::unique_ptr network_estimator_; std::unique_ptr network_state_predictor_; @@ -121,7 +121,6 @@ class GoogCcNetworkController : public NetworkControllerInterface { DataRate last_loss_based_target_rate_; DataRate last_pushback_target_rate_; - DataRate last_stable_target_rate_; LossBasedState last_loss_base_state_; std::optional last_estimated_fraction_loss_ = 0; diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc index dbbdd4d1fd..bb08a9d108 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include #include #include @@ -72,9 +71,10 @@ int CountBandwidthDips(std::queue bandwidth_history, return dips; } -const uint32_t kInitialBitrateKbps = 60; -const DataRate kInitialBitrate = DataRate::KilobitsPerSec(kInitialBitrateKbps); -const float kDefaultPacingRate = 2.5f; +constexpr uint32_t kInitialBitrateKbps = 60; +constexpr DataRate kInitialBitrate = + DataRate::KilobitsPerSec(kInitialBitrateKbps); +constexpr float kDefaultPacingRate = 2.5f; CallClient* CreateVideoSendingClient( Scenario* s, @@ -590,43 +590,6 @@ TEST(GoogCcScenario, UpdatesTargetRateBasedOnLinkCapacity) { UpdatesTargetRateBasedOnLinkCapacity(); } -TEST(GoogCcScenario, StableEstimateDoesNotVaryInSteadyState) { - GoogCcNetworkControllerFactory factory; - Scenario s("googcc_unit/stable_target", false); - CallClientConfig config; - config.transport.cc_factory = &factory; - NetworkSimulationConfig net_conf; - net_conf.bandwidth = DataRate::KilobitsPerSec(500); - net_conf.delay = TimeDelta::Millis(100); - auto send_net = s.CreateSimulationNode(net_conf); - auto ret_net = s.CreateSimulationNode(net_conf); - - auto* client = CreateVideoSendingClient(&s, config, {send_net}, {ret_net}); - // Run for a while to allow the estimate to stabilize. - s.RunFor(TimeDelta::Seconds(30)); - DataRate min_stable_target = DataRate::PlusInfinity(); - DataRate max_stable_target = DataRate::MinusInfinity(); - DataRate min_target = DataRate::PlusInfinity(); - DataRate max_target = DataRate::MinusInfinity(); - - // Measure variation in steady state. - for (int i = 0; i < 20; ++i) { - auto stable_target_rate = client->stable_target_rate(); - auto target_rate = client->target_rate(); - EXPECT_LE(stable_target_rate, target_rate); - - min_stable_target = std::min(min_stable_target, stable_target_rate); - max_stable_target = std::max(max_stable_target, stable_target_rate); - min_target = std::min(min_target, target_rate); - max_target = std::max(max_target, target_rate); - s.RunFor(TimeDelta::Seconds(1)); - } - // We should expect drops by at least 15% (default backoff.) - EXPECT_LT(min_target / max_target, 0.85); - // We should expect the stable target to be more stable than the immediate one - EXPECT_GE(min_stable_target / max_stable_target, min_target / max_target); -} - TEST(GoogCcScenario, LossBasedControlDoesModestBackoffToHighLoss) { Scenario s("googcc_unit/high_loss_channel", false); CallClientConfig config; 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 75744b5cb2..55c78735bc 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -224,7 +224,12 @@ void LossBasedBweV2::UpdateBandwidthEstimate( NewtonsMethodUpdate(candidate); const double candidate_objective = GetObjective(candidate); - if (candidate_objective > objective_max) { + if (candidate_objective > objective_max || + (candidate_objective == objective_max && + candidate.loss_limited_bandwidth > + best_candidate.loss_limited_bandwidth)) { + // Select the candidate with the highest objective or the one with the + // same objective but higher bandwidth if they are tied. objective_max = candidate_objective; best_candidate = candidate; } 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 a9c8506d33..14dd12e346 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 @@ -1793,5 +1793,30 @@ TEST_F(LossBasedBweV2Test, kStartBitrate); } +TEST_F(LossBasedBweV2Test, SelectHigherCandidateIfHavingSameObjective) { + FieldTrials key_value_config = ShortObservationConfig(""); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + const DataRate kStartBitrate = DataRate::KilobitsPerSec(1000); + loss_based_bandwidth_estimator.SetBandwidthEstimate(kStartBitrate); + std::vector enough_feedback_01 = + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero()); + std::vector enough_feedback_02 = + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate(enough_feedback_01, + kStartBitrate, + /*in_alr=*/false); + DataRate delay_based_estimate = + DataRate::BytesPerSec(kStartBitrate.bytes_per_sec() * 1.02 + 1); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate(enough_feedback_02, + delay_based_estimate, + /*in_alr=*/false); + + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + delay_based_estimate); +} } // namespace } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc b/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc index a8113c9722..1d53290fbb 100644 --- a/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc +++ b/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc @@ -10,8 +10,7 @@ #include "modules/congestion_controller/goog_cc/probe_bitrate_estimator.h" -#include - +#include #include #include diff --git a/modules/congestion_controller/goog_cc/probe_controller.cc b/modules/congestion_controller/goog_cc/probe_controller.cc index 0847c19734..4912ed19e9 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.cc +++ b/modules/congestion_controller/goog_cc/probe_controller.cc @@ -11,13 +11,11 @@ #include "modules/congestion_controller/goog_cc/probe_controller.h" #include -#include #include #include #include #include -#include "absl/strings/match.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/transport/network_types.h" @@ -173,9 +171,8 @@ ProbeController::ProbeController(const FieldTrialsView* key_value_config, RtcEventLog* event_log) : network_available_(false), enable_periodic_alr_probing_(false), - in_rapid_recovery_experiment_(absl::StartsWith( - key_value_config->Lookup(kBweRapidRecoveryExperiment), - "Enabled")), + in_rapid_recovery_experiment_( + key_value_config->IsEnabled(kBweRapidRecoveryExperiment)), event_log_(event_log), config_(ProbeControllerConfig(key_value_config)) { Reset(Timestamp::Zero()); @@ -378,16 +375,11 @@ void ProbeController::EnableRepeatedInitialProbing(bool enable) { repeated_initial_probing_enabled_ = enable; } -void ProbeController::SetAlrStartTimeMs( - std::optional alr_start_time_ms) { - if (alr_start_time_ms) { - alr_start_time_ = Timestamp::Millis(*alr_start_time_ms); - } else { - alr_start_time_ = std::nullopt; - } +void ProbeController::SetAlrStartTime(std::optional alr_start_time) { + alr_start_time_ = alr_start_time; } -void ProbeController::SetAlrEndedTimeMs(int64_t alr_end_time_ms) { - alr_end_time_.emplace(Timestamp::Millis(alr_end_time_ms)); +void ProbeController::SetAlrEndedTime(Timestamp alr_end_time) { + alr_end_time_ = alr_end_time; } std::vector ProbeController::RequestProbe( diff --git a/modules/congestion_controller/goog_cc/probe_controller.h b/modules/congestion_controller/goog_cc/probe_controller.h index 08938f8b5d..9ef8c5459f 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.h +++ b/modules/congestion_controller/goog_cc/probe_controller.h @@ -146,8 +146,8 @@ class ProbeController { // SetBitrates. void EnableRepeatedInitialProbing(bool enable); - void SetAlrStartTimeMs(std::optional alr_start_time); - void SetAlrEndedTimeMs(int64_t alr_end_time); + void SetAlrStartTime(std::optional alr_start_time); + void SetAlrEndedTime(Timestamp alr_end_time); ABSL_MUST_USE_RESULT std::vector RequestProbe( Timestamp at_time); diff --git a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc index 7b6267dd7f..42691960a3 100644 --- a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc +++ b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc @@ -206,14 +206,14 @@ TEST(ProbeControllerTest, ProbesOnMaxAllocatedBitrateIncreaseOnlyWhenInAlr) { EXPECT_TRUE(probes.empty()); // Probe when in alr. - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); probes = probe_controller->OnMaxTotalAllocatedBitrate( kMaxBitrate + DataRate::BitsPerSec(1), fixture.CurrentTime()); EXPECT_EQ(probes.size(), 2u); EXPECT_EQ(probes.at(0).target_data_rate, kMaxBitrate); // Do not probe when not in alr. - probe_controller->SetAlrStartTimeMs(std::nullopt); + probe_controller->SetAlrStartTime(std::nullopt); probes = probe_controller->OnMaxTotalAllocatedBitrate( kMaxBitrate + DataRate::BitsPerSec(2), fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); @@ -240,7 +240,7 @@ TEST(ProbeControllerTest, ProbesOnMaxAllocatedBitrateLimitedByCurrentBwe) { EXPECT_TRUE(probes.empty()); // Probe when in alr. - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); probes = probe_controller->OnMaxTotalAllocatedBitrate(kMaxBitrate, fixture.CurrentTime()); EXPECT_EQ(probes.size(), 1u); @@ -271,10 +271,10 @@ TEST(ProbeControllerTest, CanDisableProbingOnMaxTotalAllocatedBitrateIncrease) { fixture.AdvanceTime(kExponentialProbingTimeout); probes = probe_controller->Process(fixture.CurrentTime()); ASSERT_TRUE(probes.empty()); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); // Do no probe, since probe_max_allocation:false. - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); probes = probe_controller->OnMaxTotalAllocatedBitrate( kMaxBitrate + DataRate::BitsPerSec(1), fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); @@ -496,7 +496,7 @@ TEST(ProbeControllerTest, RequestProbeInAlr) { DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); probes = probe_controller->SetEstimatedBitrate( @@ -522,13 +522,13 @@ TEST(ProbeControllerTest, RequestProbeWhenAlrEndedRecently) { DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(std::nullopt); + probe_controller->SetAlrStartTime(std::nullopt); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); probes = probe_controller->SetEstimatedBitrate( DataRate::BitsPerSec(250), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrEndedTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrEndedTime(fixture.CurrentTime()); fixture.AdvanceTime(kAlrEndedTimeout - TimeDelta::Millis(1)); probes = probe_controller->RequestProbe(fixture.CurrentTime()); @@ -550,13 +550,13 @@ TEST(ProbeControllerTest, RequestProbeWhenAlrNotEndedRecently) { DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(std::nullopt); + probe_controller->SetAlrStartTime(std::nullopt); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); probes = probe_controller->SetEstimatedBitrate( DataRate::BitsPerSec(250), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrEndedTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrEndedTime(fixture.CurrentTime()); fixture.AdvanceTime(kAlrEndedTimeout + TimeDelta::Millis(1)); probes = probe_controller->RequestProbe(fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); @@ -576,7 +576,7 @@ TEST(ProbeControllerTest, RequestProbeWhenBweDropNotRecent) { DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); probes = probe_controller->SetEstimatedBitrate( @@ -605,7 +605,7 @@ TEST(ProbeControllerTest, PeriodicProbing) { Timestamp start_time = fixture.CurrentTime(); // Expect the controller to send a new probe after 5s has passed. - probe_controller->SetAlrStartTimeMs(start_time.ms()); + probe_controller->SetAlrStartTime(start_time); fixture.AdvanceTime(TimeDelta::Seconds(5)); probes = probe_controller->Process(fixture.CurrentTime()); EXPECT_EQ(probes.size(), 1u); @@ -616,7 +616,7 @@ TEST(ProbeControllerTest, PeriodicProbing) { fixture.CurrentTime()); // The following probe should be sent at 10s into ALR. - probe_controller->SetAlrStartTimeMs(start_time.ms()); + probe_controller->SetAlrStartTime(start_time); fixture.AdvanceTime(TimeDelta::Seconds(4)); probes = probe_controller->Process(fixture.CurrentTime()); probes = probe_controller->SetEstimatedBitrate( @@ -624,7 +624,7 @@ TEST(ProbeControllerTest, PeriodicProbing) { fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); - probe_controller->SetAlrStartTimeMs(start_time.ms()); + probe_controller->SetAlrStartTime(start_time); fixture.AdvanceTime(TimeDelta::Seconds(1)); probes = probe_controller->Process(fixture.CurrentTime()); EXPECT_EQ(probes.size(), 1u); @@ -643,7 +643,7 @@ TEST(ProbeControllerTest, PeriodicProbingAfterReset) { IsEmpty()); Timestamp alr_start_time = fixture.CurrentTime(); - probe_controller->SetAlrStartTimeMs(alr_start_time.ms()); + probe_controller->SetAlrStartTime(alr_start_time); probe_controller->EnablePeriodicAlrProbing(true); auto probes = probe_controller->SetBitrates( kMinBitrate, kStartBitrate, kMaxBitrate, fixture.CurrentTime()); @@ -732,7 +732,7 @@ TEST(ProbeControllerTest, TestAllocatedBitrateCap) { // Configure ALR for periodic probing. probe_controller->EnablePeriodicAlrProbing(true); Timestamp alr_start_time = fixture.CurrentTime(); - probe_controller->SetAlrStartTimeMs(alr_start_time.ms()); + probe_controller->SetAlrStartTime(alr_start_time); DataRate estimated_bitrate = 10 * kMbpsMultiplier; probes = probe_controller->SetEstimatedBitrate( @@ -799,7 +799,7 @@ TEST(ProbeControllerTest, ConfigurableProbingFieldTrial) { fixture.AdvanceTime(TimeDelta::Seconds(5)); probes = probe_controller->Process(fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); probes = probe_controller->OnMaxTotalAllocatedBitrate( DataRate::KilobitsPerSec(200), fixture.CurrentTime()); EXPECT_EQ(probes.size(), 1u); @@ -820,7 +820,7 @@ TEST(ProbeControllerTest, LimitAlrProbeWhenLossBasedBweLimited) { DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); // Expect the controller to send a new probe after 5s has passed. - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); fixture.AdvanceTime(TimeDelta::Seconds(5)); probes = probe_controller->Process(fixture.CurrentTime()); ASSERT_EQ(probes.size(), 1u); @@ -919,7 +919,7 @@ TEST(ProbeControllerTest, AlrProbesLimitedByNetworkStateEstimate) { probes = probe_controller->SetEstimatedBitrate( DataRate::KilobitsPerSec(6), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); fixture.AdvanceTime(TimeDelta::Seconds(5)); probes = probe_controller->Process(fixture.CurrentTime()); @@ -982,7 +982,7 @@ TEST(ProbeControllerTest, ProbeInAlrIfLossBasedIncreasing) { ASSERT_TRUE(probes.empty()); // Probe when in alr. - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); ASSERT_EQ(probes.size(), 1u); @@ -1009,7 +1009,7 @@ TEST(ProbeControllerTest, NotProbeWhenInAlrIfLossBasedDecreases) { ASSERT_TRUE(probes.empty()); // Not probe in alr when loss based estimate decreases. - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); @@ -1034,7 +1034,7 @@ TEST(ProbeControllerTest, NotProbeIfLossBasedIncreasingOutsideAlr) { probes = probe_controller->Process(fixture.CurrentTime()); ASSERT_TRUE(probes.empty()); - probe_controller->SetAlrStartTimeMs(std::nullopt); + probe_controller->SetAlrStartTime(std::nullopt); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); @@ -1320,7 +1320,7 @@ TEST(ProbeControllerTest, SkipAlrProbeIfEstimateLargerThanMaxProbe) { fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); fixture.AdvanceTime(TimeDelta::Seconds(10)); probes = probe_controller->Process(fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); @@ -1350,7 +1350,7 @@ TEST(ProbeControllerTest, fixture.CurrentTime()); fixture.AdvanceTime(TimeDelta::Seconds(10)); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); probes = probe_controller->OnMaxTotalAllocatedBitrate(kMaxBitrate / 2, fixture.CurrentTime()); // No probes since total allocated is not higher than the current estimate. @@ -1453,7 +1453,7 @@ TEST(ProbeControllerTest, probes = probe_controller->Process(fixture.CurrentTime()); ASSERT_TRUE(probes.empty()); - probe_controller->SetAlrStartTimeMs(fixture.CurrentTime().ms()); + probe_controller->SetAlrStartTime(fixture.CurrentTime()); probe_controller->SetNetworkStateEstimate( {.link_capacity_upper = kStartBitrate / 2}); fixture.AdvanceTime(TimeDelta::Seconds(6)); diff --git a/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc b/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc index 3aad0c954c..ed021e7349 100644 --- a/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc +++ b/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc @@ -10,9 +10,8 @@ #include "modules/congestion_controller/goog_cc/robust_throughput_estimator.h" -#include - #include +#include #include #include #include diff --git a/modules/congestion_controller/goog_cc/robust_throughput_estimator_unittest.cc b/modules/congestion_controller/goog_cc/robust_throughput_estimator_unittest.cc index 6d5a7420c0..2a0879c47a 100644 --- a/modules/congestion_controller/goog_cc/robust_throughput_estimator_unittest.cc +++ b/modules/congestion_controller/goog_cc/robust_throughput_estimator_unittest.cc @@ -10,10 +10,9 @@ #include "modules/congestion_controller/goog_cc/robust_throughput_estimator.h" -#include -#include - #include +#include +#include #include #include "absl/strings/string_view.h" 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 d599958272..03c3f61de3 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -11,7 +11,6 @@ #include "modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h" #include -#include #include #include #include @@ -109,49 +108,6 @@ bool ReadBweLossExperimentParameters(const FieldTrialsView& field_trials, } } // namespace -void LinkCapacityTracker::UpdateDelayBasedEstimate( - Timestamp at_time, - DataRate delay_based_bitrate) { - if (delay_based_bitrate < last_delay_based_estimate_) { - capacity_estimate_bps_ = - std::min(capacity_estimate_bps_, delay_based_bitrate.bps()); - last_link_capacity_update_ = at_time; - } - last_delay_based_estimate_ = delay_based_bitrate; -} - -void LinkCapacityTracker::OnStartingRate(DataRate start_rate) { - if (last_link_capacity_update_.IsInfinite()) - capacity_estimate_bps_ = start_rate.bps(); -} - -void LinkCapacityTracker::OnRateUpdate(std::optional acknowledged, - DataRate target, - Timestamp at_time) { - if (!acknowledged) - return; - DataRate acknowledged_target = std::min(*acknowledged, target); - if (acknowledged_target.bps() > capacity_estimate_bps_) { - TimeDelta delta = at_time - last_link_capacity_update_; - double alpha = - delta.IsFinite() ? exp(-(delta / TimeDelta::Seconds(10))) : 0; - capacity_estimate_bps_ = alpha * capacity_estimate_bps_ + - (1 - alpha) * acknowledged_target.bps(); - } - last_link_capacity_update_ = at_time; -} - -void LinkCapacityTracker::OnRttBackoff(DataRate backoff_rate, - Timestamp at_time) { - capacity_estimate_bps_ = - std::min(capacity_estimate_bps_, backoff_rate.bps()); - last_link_capacity_update_ = at_time; -} - -DataRate LinkCapacityTracker::estimate() const { - return DataRate::BitsPerSec(capacity_estimate_bps_); -} - RttBasedBackoff::RttBasedBackoff(const FieldTrialsView& key_value_config) : disabled_("Disabled"), configured_limit_("limit", TimeDelta::Seconds(3)), @@ -284,7 +240,6 @@ void SendSideBandwidthEstimation::SetBitrates( Timestamp at_time) { SetMinMaxBitrate(min_bitrate, max_bitrate); if (send_bitrate) { - link_capacity_.OnStartingRate(*send_bitrate); SetSendBitrate(*send_bitrate, at_time); } } @@ -332,10 +287,6 @@ bool SendSideBandwidthEstimation::IsRttAboveLimit() const { return rtt_backoff_.IsRttAboveLimit(); } -DataRate SendSideBandwidthEstimation::GetEstimatedLinkCapacity() const { - return link_capacity_.estimate(); -} - void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time, DataRate bandwidth) { // TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no @@ -346,7 +297,6 @@ void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time, void SendSideBandwidthEstimation::UpdateDelayBasedEstimate(Timestamp at_time, DataRate bitrate) { - link_capacity_.UpdateDelayBasedEstimate(at_time, bitrate); // TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no // limitation. delay_based_limit_ = bitrate.IsZero() ? DataRate::PlusInfinity() : bitrate; @@ -466,7 +416,6 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) { DataRate new_bitrate = std::max(current_target_ * rtt_backoff_.drop_fraction_, rtt_backoff_.bandwidth_floor_.Get()); - link_capacity_.OnRttBackoff(new_bitrate, at_time); UpdateTargetBitrate(new_bitrate, at_time); return; } @@ -641,7 +590,6 @@ void SendSideBandwidthEstimation::UpdateTargetBitrate(DataRate new_bitrate, } current_target_ = new_bitrate; MaybeLogLossBasedEvent(at_time); - link_capacity_.OnRateUpdate(acknowledged_rate_, current_target_, at_time); } void SendSideBandwidthEstimation::ApplyTargetLimits(Timestamp at_time) { 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 6c701e0fd0..2795ba2386 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h @@ -34,26 +34,6 @@ namespace webrtc { class RtcEventLog; -class LinkCapacityTracker { - public: - LinkCapacityTracker() = default; - ~LinkCapacityTracker() = default; - // Call when a new delay-based estimate is available. - void UpdateDelayBasedEstimate(Timestamp at_time, - DataRate delay_based_bitrate); - void OnStartingRate(DataRate start_rate); - void OnRateUpdate(std::optional acknowledged, - DataRate target, - Timestamp at_time); - void OnRttBackoff(DataRate backoff_rate, Timestamp at_time); - DataRate estimate() const; - - private: - double capacity_estimate_bps_ = 0; - Timestamp last_link_capacity_update_ = Timestamp::MinusInfinity(); - DataRate last_delay_based_estimate_ = DataRate::PlusInfinity(); -}; - class RttBasedBackoff { public: explicit RttBasedBackoff(const FieldTrialsView& key_value_config); @@ -94,7 +74,6 @@ class SendSideBandwidthEstimation { uint8_t fraction_loss() const { return last_fraction_loss_; } TimeDelta round_trip_time() const { return last_round_trip_time_; } - DataRate GetEstimatedLinkCapacity() const; // Call periodically to update estimate. void UpdateEstimate(Timestamp at_time); void OnSentPacket(const SentPacket& sent_packet); @@ -165,7 +144,6 @@ class SendSideBandwidthEstimation { const FieldTrialsView* key_value_config_; RttBasedBackoff rtt_backoff_; - LinkCapacityTracker link_capacity_; std::deque > min_bitrate_history_; diff --git a/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc b/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc index 6e5bbb3b28..d1565816a6 100644 --- a/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc +++ b/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc @@ -9,8 +9,7 @@ */ #include "modules/congestion_controller/goog_cc/test/goog_cc_printer.h" -#include - +#include #include #include #include @@ -103,7 +102,6 @@ std::deque GoogCcStatePrinter::CreateLoggers() { Log("time", [this] { return target_.at_time; }), Log("rtt", [this] { return target_.network_estimate.round_trip_time; }), Log("target", [this] { return target_.target_rate; }), - Log("stable_target", [this] { return target_.stable_target_rate; }), Log("pacing", [this] { return pacing_.data_rate(); }), Log("padding", [this] { return pacing_.pad_rate(); }), Log("window", [this] { return congestion_window_; }), diff --git a/modules/congestion_controller/goog_cc/trendline_estimator.cc b/modules/congestion_controller/goog_cc/trendline_estimator.cc index 35ec1393c6..b8c14f08d4 100644 --- a/modules/congestion_controller/goog_cc/trendline_estimator.cc +++ b/modules/congestion_controller/goog_cc/trendline_estimator.cc @@ -10,9 +10,8 @@ #include "modules/congestion_controller/goog_cc/trendline_estimator.h" -#include - #include +#include #include #include #include diff --git a/modules/congestion_controller/pcc/bitrate_controller_unittest.cc b/modules/congestion_controller/pcc/bitrate_controller_unittest.cc index b16beaacea..566c25ed9d 100644 --- a/modules/congestion_controller/pcc/bitrate_controller_unittest.cc +++ b/modules/congestion_controller/pcc/bitrate_controller_unittest.cc @@ -41,13 +41,13 @@ constexpr double kThroughputPower = 0.99; constexpr double kDelayGradientThreshold = 0.01; constexpr double kDelayGradientNegativeBound = 10; -const DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300); -const double kEpsilon = 0.05; -const Timestamp kStartTime = Timestamp::Micros(0); -const TimeDelta kPacketsDelta = TimeDelta::Millis(1); -const TimeDelta kIntervalDuration = TimeDelta::Millis(1000); -const TimeDelta kDefaultRtt = TimeDelta::Millis(1000); -const DataSize kDefaultDataSize = DataSize::Bytes(100); +constexpr DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300); +constexpr double kEpsilon = 0.05; +constexpr Timestamp kStartTime = Timestamp::Micros(0); +constexpr TimeDelta kPacketsDelta = TimeDelta::Millis(1); +constexpr TimeDelta kIntervalDuration = TimeDelta::Millis(1000); +constexpr TimeDelta kDefaultRtt = TimeDelta::Millis(1000); +constexpr DataSize kDefaultDataSize = DataSize::Bytes(100); std::vector CreatePacketResults( const std::vector& packets_send_times, diff --git a/modules/congestion_controller/pcc/monitor_interval.cc b/modules/congestion_controller/pcc/monitor_interval.cc index 116dda6195..7417ee2312 100644 --- a/modules/congestion_controller/pcc/monitor_interval.cc +++ b/modules/congestion_controller/pcc/monitor_interval.cc @@ -10,9 +10,8 @@ #include "modules/congestion_controller/pcc/monitor_interval.h" -#include - #include +#include #include #include "api/transport/network_types.h" diff --git a/modules/congestion_controller/pcc/monitor_interval_unittest.cc b/modules/congestion_controller/pcc/monitor_interval_unittest.cc index 1d33f0040b..272dac7718 100644 --- a/modules/congestion_controller/pcc/monitor_interval_unittest.cc +++ b/modules/congestion_controller/pcc/monitor_interval_unittest.cc @@ -10,8 +10,7 @@ #include "modules/congestion_controller/pcc/monitor_interval.h" -#include - +#include #include #include "api/transport/network_types.h" @@ -25,12 +24,12 @@ namespace webrtc { namespace pcc { namespace test { namespace { -const DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300); -const Timestamp kStartTime = Timestamp::Micros(0); -const TimeDelta kPacketsDelta = TimeDelta::Millis(1); -const TimeDelta kIntervalDuration = TimeDelta::Millis(100); -const TimeDelta kDefaultDelay = TimeDelta::Millis(100); -const DataSize kDefaultPacketSize = DataSize::Bytes(100); +constexpr DataRate kTargetSendingRate = DataRate::KilobitsPerSec(300); +constexpr Timestamp kStartTime = Timestamp::Micros(0); +constexpr TimeDelta kPacketsDelta = TimeDelta::Millis(1); +constexpr TimeDelta kIntervalDuration = TimeDelta::Millis(100); +constexpr TimeDelta kDefaultDelay = TimeDelta::Millis(100); +constexpr DataSize kDefaultPacketSize = DataSize::Bytes(100); constexpr double kDelayGradientThreshold = 0.01; std::vector CreatePacketResults( diff --git a/modules/congestion_controller/pcc/pcc_network_controller_unittest.cc b/modules/congestion_controller/pcc/pcc_network_controller_unittest.cc index 6391f42368..389a7387b8 100644 --- a/modules/congestion_controller/pcc/pcc_network_controller_unittest.cc +++ b/modules/congestion_controller/pcc/pcc_network_controller_unittest.cc @@ -34,8 +34,8 @@ namespace webrtc { namespace test { namespace { -const DataRate kInitialBitrate = DataRate::KilobitsPerSec(60); -const Timestamp kDefaultStartTime = Timestamp::Millis(10000000); +constexpr DataRate kInitialBitrate = DataRate::KilobitsPerSec(60); +constexpr Timestamp kDefaultStartTime = Timestamp::Millis(10000000); constexpr double kDataRateMargin = 0.20; constexpr double kMinDataRateFactor = 1 - kDataRateMargin; diff --git a/modules/congestion_controller/pcc/rtt_tracker_unittest.cc b/modules/congestion_controller/pcc/rtt_tracker_unittest.cc index dbe6497afb..6ce8dd4e50 100644 --- a/modules/congestion_controller/pcc/rtt_tracker_unittest.cc +++ b/modules/congestion_controller/pcc/rtt_tracker_unittest.cc @@ -19,9 +19,9 @@ namespace webrtc { namespace pcc { namespace test { namespace { -const TimeDelta kInitialRtt = TimeDelta::Micros(10); +constexpr TimeDelta kInitialRtt = TimeDelta::Micros(10); constexpr double kAlpha = 0.9; -const Timestamp kStartTime = Timestamp::Seconds(0); +constexpr Timestamp kStartTime = Timestamp::Seconds(0); PacketResult GetPacketWithRtt(TimeDelta rtt) { SentPacket packet; diff --git a/modules/congestion_controller/pcc/utility_function_unittest.cc b/modules/congestion_controller/pcc/utility_function_unittest.cc index 8f4add6797..ab5bd7f201 100644 --- a/modules/congestion_controller/pcc/utility_function_unittest.cc +++ b/modules/congestion_controller/pcc/utility_function_unittest.cc @@ -10,9 +10,8 @@ #include "modules/congestion_controller/pcc/utility_function.h" -#include - #include +#include #include #include "api/transport/network_types.h" @@ -32,13 +31,13 @@ constexpr double kThroughputPower = 0.9; constexpr double kThroughputCoefficient = 1; constexpr double kDelayGradientNegativeBound = 10; -const Timestamp kStartTime = Timestamp::Micros(0); -const TimeDelta kPacketsDelta = TimeDelta::Millis(1); -const TimeDelta kIntervalDuration = TimeDelta::Millis(100); -const DataRate kSendingBitrate = DataRate::BitsPerSec(1000); +constexpr Timestamp kStartTime = Timestamp::Micros(0); +constexpr TimeDelta kPacketsDelta = TimeDelta::Millis(1); +constexpr TimeDelta kIntervalDuration = TimeDelta::Millis(100); +constexpr DataRate kSendingBitrate = DataRate::BitsPerSec(1000); -const DataSize kDefaultDataSize = DataSize::Bytes(100); -const TimeDelta kDefaultDelay = TimeDelta::Millis(100); +constexpr DataSize kDefaultDataSize = DataSize::Bytes(100); +constexpr TimeDelta kDefaultDelay = TimeDelta::Millis(100); std::vector CreatePacketResults( const std::vector& packets_send_times, diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter.cc b/modules/congestion_controller/rtp/transport_feedback_adapter.cc index 3b38b6dfa6..01dd43db0e 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter.cc +++ b/modules/congestion_controller/rtp/transport_feedback_adapter.cc @@ -10,10 +10,9 @@ #include "modules/congestion_controller/rtp/transport_feedback_adapter.h" -#include - #include #include +#include #include #include #include diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc index 7d74adf6f2..ad48cbbe01 100644 --- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc +++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc @@ -10,8 +10,7 @@ #include "modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h" -#include - +#include #include #include diff --git a/modules/desktop_capture/cropping_window_capturer.cc b/modules/desktop_capture/cropping_window_capturer.cc index b0aa492804..b0cbc70a04 100644 --- a/modules/desktop_capture/cropping_window_capturer.cc +++ b/modules/desktop_capture/cropping_window_capturer.cc @@ -10,8 +10,7 @@ #include "modules/desktop_capture/cropping_window_capturer.h" -#include - +#include #include #include @@ -48,7 +47,7 @@ void CroppingWindowCapturer::SetSharedMemoryFactory( void CroppingWindowCapturer::CaptureFrame() { if (ShouldUseScreenCapturer()) { - if (!screen_capturer_.get()) { + if (!screen_capturer_) { screen_capturer_ = DesktopCapturer::CreateRawScreenCapturer(options_); if (excluded_window_) { screen_capturer_->SetExcludedWindow(excluded_window_); @@ -63,7 +62,7 @@ void CroppingWindowCapturer::CaptureFrame() { void CroppingWindowCapturer::SetExcludedWindow(WindowId window) { excluded_window_ = window; - if (screen_capturer_.get()) { + if (screen_capturer_) { screen_capturer_->SetExcludedWindow(window); } } diff --git a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc index 913258f129..ba0a60d553 100644 --- a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc +++ b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc @@ -33,15 +33,15 @@ namespace { using testing::ElementsAre; -const int kFrameXCoord = 100; -const int kFrameYCoord = 200; -const int kScreenWidth = 100; -const int kScreenHeight = 100; -const int kCursorWidth = 10; -const int kCursorHeight = 10; - -const int kTestCursorSize = 3; -const uint32_t kTestCursorData[kTestCursorSize][kTestCursorSize] = { +constexpr int kFrameXCoord = 100; +constexpr int kFrameYCoord = 200; +constexpr int kScreenWidth = 100; +constexpr int kScreenHeight = 100; +constexpr int kCursorWidth = 10; +constexpr int kCursorHeight = 10; + +constexpr int kTestCursorSize = 3; +constexpr uint32_t kTestCursorData[kTestCursorSize][kTestCursorSize] = { { 0xffffffff, 0x99990000, diff --git a/modules/desktop_capture/full_screen_application_handler.h b/modules/desktop_capture/full_screen_application_handler.h index da9aa9e164..bde9b8e0fe 100644 --- a/modules/desktop_capture/full_screen_application_handler.h +++ b/modules/desktop_capture/full_screen_application_handler.h @@ -51,6 +51,9 @@ class FullScreenApplicationHandler { return use_heuristic_fullscreen_powerpoint_windows_; } + virtual void SetSlideShowCreationStateForTest( + bool fullscreen_slide_show_started_after_capture_start) {} + private: // `use_heuristic_fullscreen_powerpoint_windows_` is used to implement a // killswitch. diff --git a/modules/desktop_capture/full_screen_window_detector.cc b/modules/desktop_capture/full_screen_window_detector.cc index 2bbd1f8f51..89c0dc058e 100644 --- a/modules/desktop_capture/full_screen_window_detector.cc +++ b/modules/desktop_capture/full_screen_window_detector.cc @@ -17,6 +17,10 @@ #include "modules/desktop_capture/full_screen_application_handler.h" #include "rtc_base/time_utils.h" +#if defined(WEBRTC_WIN) +#include "modules/desktop_capture/win/full_screen_win_application_handler.h" +#endif + namespace webrtc { FullScreenWindowDetector::FullScreenWindowDetector( @@ -38,7 +42,9 @@ DesktopCapturer::SourceId FullScreenWindowDetector::FindFullScreenWindow( void FullScreenWindowDetector::UpdateWindowListIfNeeded( DesktopCapturer::SourceId original_source_id, FunctionView get_sources) { - const bool skip_update = previous_source_id_ != original_source_id; + // Don't skip update if app_handler_ exists. + const bool skip_update = + !app_handler_ && (previous_source_id_ != original_source_id); previous_source_id_ = original_source_id; // Here is an attempt to avoid redundant creating application handler in case @@ -65,7 +71,26 @@ void FullScreenWindowDetector::UpdateWindowListIfNeeded( DesktopCapturer::SourceList window_list; if (get_sources(&window_list)) { last_update_time_ms_ = TimeMillis(); - window_list_.swap(window_list); + + bool should_swap_windows = true; +#if defined(WEBRTC_WIN) + bool is_original_source_window_alive = + ::IsWindow(reinterpret_cast(original_source_id)); + bool is_original_source_enumerated = false; + for (auto& source : window_list) { + if (source.id == original_source_id) { + is_original_source_enumerated = true; + break; + } + } + // Don't swap window list if there is a mismatch between original window's + // state and its enumerated state. + should_swap_windows = + (is_original_source_enumerated == is_original_source_window_alive); +#endif + if (should_swap_windows) { + window_list_.swap(window_list); + } } } @@ -89,4 +114,17 @@ void FullScreenWindowDetector::CreateApplicationHandlerIfNeeded( } } +void FullScreenWindowDetector::CreateFullScreenApplicationHandlerForTest( + DesktopCapturer::SourceId source_id, + bool fullscreen_slide_show_started_after_capture_start) { + if (app_handler_) { + return; + } +#if defined(WEBRTC_WIN) + app_handler_ = std::make_unique(source_id); + app_handler_->SetSlideShowCreationStateForTest( + fullscreen_slide_show_started_after_capture_start); +#endif +} + } // namespace webrtc diff --git a/modules/desktop_capture/full_screen_window_detector.h b/modules/desktop_capture/full_screen_window_detector.h index 2c882790e9..5a0e0c3538 100644 --- a/modules/desktop_capture/full_screen_window_detector.h +++ b/modules/desktop_capture/full_screen_window_detector.h @@ -62,14 +62,22 @@ class FullScreenWindowDetector static scoped_refptr CreateFullScreenWindowDetector(); void SetUseHeuristicFullscreenPowerPointWindows( - bool use_heuristic_fullscreen_powerpoint_windows) { + bool use_heuristic_fullscreen_powerpoint_windows, + bool use_heuristic_for_wgc = false) { use_heuristic_fullscreen_powerpoint_windows_ = use_heuristic_fullscreen_powerpoint_windows; + use_heuristic_for_wgc_ = use_heuristic_for_wgc; if (app_handler_) { app_handler_->SetUseHeuristicFullscreenPowerPointWindows( use_heuristic_fullscreen_powerpoint_windows); } } + bool UseHeuristicForWGC() { return use_heuristic_for_wgc_; } + + // Used for tests. + void CreateFullScreenApplicationHandlerForTest( + DesktopCapturer::SourceId source_id, + bool fullscreen_slide_show_started_after_capture_start); protected: std::unique_ptr app_handler_; @@ -85,6 +93,12 @@ class FullScreenWindowDetector // available in stable for some milestones. bool use_heuristic_fullscreen_powerpoint_windows_ = true; + // `use_heuristic_for_wgc_` implements the finch experiment for + // the usage of FullScreenPowerPointHandler class for WGC API. + // TODO(crbug.com/409473386): Remove `use_heuristic_for_wgc_` once + // the feature has been rolled out to Stable for some milestones. + bool use_heuristic_for_wgc_ = false; + int64_t last_update_time_ms_; DesktopCapturer::SourceId previous_source_id_; diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.cc b/modules/desktop_capture/linux/wayland/screencast_portal.cc index d3c8c077fa..8c9d5de63b 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.cc +++ b/modules/desktop_capture/linux/wayland/screencast_portal.cc @@ -12,9 +12,7 @@ #include #include -#include #include -#include #include #include diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index b3e6553a05..403e07ba57 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -593,7 +593,6 @@ void SharedScreenCastStreamPrivate::StopAndCleanupStream() { // While we can stop the thread now, we cannot destroy it until we've cleaned // up the other members. - pw_thread_loop_wait(pw_main_loop_); pw_thread_loop_stop(pw_main_loop_); if (pw_stream_) { 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 59047dc03f..531130a876 100644 --- a/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc +++ b/modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc @@ -133,7 +133,7 @@ void MouseCursorMonitorX11::Capture() { x_display_->ProcessPendingXEvents(); // cursor_shape_| is set only if we were notified of a cursor shape change. - if (cursor_shape_.get()) + if (cursor_shape_) callback_->OnMouseCursor(cursor_shape_.release()); // Get cursor position if necessary. diff --git a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc index 4f32a27426..ce7312424b 100644 --- a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc +++ b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc @@ -512,7 +512,7 @@ std::unique_ptr ScreenCapturerX11::CreateRawScreenCapturer( return nullptr; std::unique_ptr capturer(new ScreenCapturerX11()); - if (!capturer.get()->Init(options)) { + if (!capturer->Init(options)) { return nullptr; } diff --git a/modules/desktop_capture/screen_capturer_fuchsia.cc b/modules/desktop_capture/screen_capturer_fuchsia.cc index 5cbe8d2c52..c3f51ef0fc 100644 --- a/modules/desktop_capture/screen_capturer_fuchsia.cc +++ b/modules/desktop_capture/screen_capturer_fuchsia.cc @@ -303,9 +303,8 @@ void ScreenCapturerFuchsia::SetupBuffers() { fuchsia::ui::composition::RegisterBufferCollectionArgs buffer_collection_args; buffer_collection_args.set_export_token(std::move(export_token)); - buffer_collection_args.set_buffer_collection_token( - fuchsia::sysmem::BufferCollectionTokenHandle( - flatland_token.Unbind().TakeChannel())); + buffer_collection_args.set_buffer_collection_token2( + std::move(flatland_token)); buffer_collection_args.set_usage( fuchsia::ui::composition::RegisterBufferCollectionUsage::SCREENSHOT); diff --git a/modules/desktop_capture/screen_capturer_integration_test.cc b/modules/desktop_capture/screen_capturer_integration_test.cc index 76e010281f..a1f61e343a 100644 --- a/modules/desktop_capture/screen_capturer_integration_test.cc +++ b/modules/desktop_capture/screen_capturer_integration_test.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include #include +#include #include #include // TODO(zijiehe): Remove once flaky has been resolved. #include diff --git a/modules/desktop_capture/screen_capturer_unittest.cc b/modules/desktop_capture/screen_capturer_unittest.cc index ccbce1c8db..bc33f0a32f 100644 --- a/modules/desktop_capture/screen_capturer_unittest.cc +++ b/modules/desktop_capture/screen_capturer_unittest.cc @@ -28,7 +28,7 @@ using ::testing::_; -const int kTestSharedMemoryId = 123; +constexpr int kTestSharedMemoryId = 123; namespace webrtc { diff --git a/modules/desktop_capture/screen_drawer_linux.cc b/modules/desktop_capture/screen_drawer_linux.cc index 5a04d37cde..bc8d88f99b 100644 --- a/modules/desktop_capture/screen_drawer_linux.cc +++ b/modules/desktop_capture/screen_drawer_linux.cc @@ -10,8 +10,8 @@ #include #include -#include +#include #include #include "api/scoped_refptr.h" @@ -176,7 +176,7 @@ std::unique_ptr ScreenDrawerLock::Create() { // static std::unique_ptr ScreenDrawer::Create() { - if (SharedXDisplay::CreateDefault().get()) { + if (SharedXDisplay::CreateDefault()) { return std::make_unique(); } return nullptr; 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 8f01d6a26b..47a29306ca 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler.cc +++ b/modules/desktop_capture/win/full_screen_win_application_handler.cc @@ -27,6 +27,13 @@ #include "modules/desktop_capture/full_screen_application_handler.h" #include "rtc_base/logging.h" // For RTC_LOG_GLE #include "rtc_base/string_utils.h" +#include "system_wrappers/include/metrics.h" + +void RecordFullScreenDetectorResult(FullScreenDetectorResult result) { + RTC_HISTOGRAM_ENUMERATION( + "WebRTC.Screenshare.FullScreenDetectorResult", static_cast(result), + static_cast(FullScreenDetectorResult::kMaxValue)); +} namespace webrtc { namespace { @@ -52,6 +59,26 @@ bool CheckWindowClassName(HWND window, const wchar_t* class_name) { return wcsncmp(buffer, class_name, classNameLength) == 0; } +bool IsFullScreenWindow(HWND wnd) { + // Get the monitor info of the display monitor where the window is. + MONITORINFO monitor_info = {sizeof(monitor_info)}; + if (!::GetMonitorInfo(::MonitorFromWindow(wnd, MONITOR_DEFAULTTONEAREST), + &monitor_info)) { + return false; + } + + // Verifies if the window rectangle is same as the monitor. + RECT wnd_rect; + if (!::GetWindowRect(wnd, &wnd_rect) || + !::EqualRect(&wnd_rect, &monitor_info.rcMonitor)) { + return false; + } + + // Check if the window style does not have WS_OVERLAPPEDWINDOW as the full + // screen window should not have a title bar or border. + return !(::GetWindowLongPtr(wnd, GWL_STYLE) & WS_OVERLAPPEDWINDOW); +} + std::string WindowText(HWND window) { size_t len = ::GetWindowTextLength(window); if (len == 0) { @@ -101,7 +128,9 @@ DesktopCapturer::SourceList GetProcessWindows( FullScreenPowerPointHandler::FullScreenPowerPointHandler( DesktopCapturer::SourceId sourceId) - : FullScreenApplicationHandler(sourceId) {} + : FullScreenApplicationHandler(sourceId), + was_slide_show_created_after_capture_started_(false), + full_screen_detector_result_(FullScreenDetectorResult::kUnknown) {} DesktopCapturer::SourceId FullScreenPowerPointHandler::FindFullScreenWindow( const DesktopCapturer::SourceList& window_list, @@ -121,22 +150,61 @@ DesktopCapturer::SourceId FullScreenPowerPointHandler::FindFullScreenWindow( // No relevant windows with the same process id as the `original_window` were // found. if (powerpoint_windows.empty()) { + was_slide_show_created_after_capture_started_ = true; return 0; } + bool do_same_title_editors_exist = false; + bool does_slide_show_exist = false; + DesktopCapturer::SourceId full_screen_slide_show_id = 0; const std::string original_document_title = GetDocumentTitleFromEditor(original_window); + auto result = full_screen_detector_result_; for (const auto& source : powerpoint_windows) { HWND window = reinterpret_cast(source.id); + // If another PowerPoint editor window with the same title exists, then we + // don't use the heuristic as we don't know which editor has opened the + // slide show. + if (GetWindowType(window) == WindowType::kEditor && + GetDocumentTitleFromEditor(window) == original_document_title) { + do_same_title_editors_exist = true; + result = FullScreenDetectorResult::kFailureDueToSameTitleWindows; + } + // Looking for fullscreen slide show window for the corresponding editor // document. if (GetWindowType(window) == WindowType::kSlideShow && GetDocumentTitleFromSlideShow(window) == original_document_title) { - return source.id; + does_slide_show_exist = true; + full_screen_slide_show_id = source.id; } } - return 0; + if (does_slide_show_exist) { + if (!was_slide_show_created_after_capture_started_) { + full_screen_slide_show_id = 0; + result = FullScreenDetectorResult::kFailureDueToSlideShowWasNotChosen; + } else if (do_same_title_editors_exist) { + full_screen_slide_show_id = 0; + result = FullScreenDetectorResult::kFailureDueToSameTitleWindows; + } else { + result = FullScreenDetectorResult::kSuccess; + } + } else { + was_slide_show_created_after_capture_started_ = true; + } + + if (full_screen_detector_result_ != result) { + full_screen_detector_result_ = result; + RecordFullScreenDetectorResult(result); + } + return full_screen_slide_show_id; +} + +void FullScreenPowerPointHandler::SetSlideShowCreationStateForTest( + bool fullscreen_slide_show_started_after_capture_start) { + was_slide_show_created_after_capture_started_ = + fullscreen_slide_show_started_after_capture_start; } FullScreenPowerPointHandler::WindowType @@ -185,12 +253,8 @@ bool FullScreenPowerPointHandler::IsEditorWindow(HWND window) const { } 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; + return CheckWindowClassName(window, L"screenClass") && + IsFullScreenWindow(window); } class OpenOfficeApplicationHandler : public FullScreenApplicationHandler { 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 7aebff50fa..96a3bd427c 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler.h +++ b/modules/desktop_capture/win/full_screen_win_application_handler.h @@ -20,6 +20,16 @@ #include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/full_screen_application_handler.h" +// Used for metrics; Entries should not be renumbered and numeric values should +// never be reused. +enum class FullScreenDetectorResult { + kUnknown = 0, + kSuccess = 1, + kFailureDueToSameTitleWindows = 2, + kFailureDueToSlideShowWasNotChosen = 3, + kMaxValue = kFailureDueToSlideShowWasNotChosen +}; + namespace webrtc { class FullScreenPowerPointHandler : public FullScreenApplicationHandler { @@ -34,6 +44,9 @@ class FullScreenPowerPointHandler : public FullScreenApplicationHandler { const DesktopCapturer::SourceList& window_list, int64_t timestamp) const override; + void SetSlideShowCreationStateForTest( + bool fullscreen_slide_show_started_after_capture_start) override; + private: WindowType GetWindowType(HWND window) const; @@ -52,6 +65,10 @@ class FullScreenPowerPointHandler : public FullScreenApplicationHandler { bool IsEditorWindow(HWND window) const; bool IsSlideShowWindow(HWND window) const; + + mutable bool was_slide_show_created_after_capture_started_; + + mutable FullScreenDetectorResult full_screen_detector_result_; }; std::unique_ptr 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 index 1fcd13bff0..848df0e0b8 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler_unittest.cc +++ b/modules/desktop_capture/win/full_screen_win_application_handler_unittest.cc @@ -27,16 +27,21 @@ WindowInfo CreateTestWindow(const WCHAR* window_title, class FullScreenWinApplicationHandlerTest : public ::testing::Test { public: - void CreateEditorWindow(const WCHAR* title, - const WCHAR* window_class = L"PPTFrameClass") { + void CreateEditorWindow( + const WCHAR* title, + const WCHAR* window_class = L"PPTFrameClass", + bool fullscreen_slide_show_started_after_capture_start = true) { editor_window_info_ = CreateTestWindow(title, window_class); full_screen_ppt_handler_ = std::make_unique( reinterpret_cast(editor_window_info_.hwnd)); + full_screen_ppt_handler_->SetSlideShowCreationStateForTest( + fullscreen_slide_show_started_after_capture_start); } HWND CreateSlideShowWindow(const WCHAR* title) { slide_show_window_info_ = CreateTestWindow(title, /*window_class=*/L"screenClass"); + ResizeTestWindowToFullScreen(slide_show_window_info_.hwnd); return slide_show_window_info_.hwnd; } @@ -257,6 +262,7 @@ TEST_F(FullScreenWinApplicationHandlerTest, EXPECT_EQ(FindFullScreenWindow(), correct_slide_show); } +// TODO(crbug.com/409473386): Add DestroyTestWindow to clean the tests. TEST_F(FullScreenWinApplicationHandlerTest, FullScreenWindowsFoundWhenMultipleEditorsAndSlideShowsExist) { std::vector editors = { @@ -269,8 +275,11 @@ TEST_F(FullScreenWinApplicationHandlerTest, std::vector> handlers; for (auto& editor : editors) { - handlers.push_back(std::make_unique( - reinterpret_cast(editor.hwnd))); + auto handler = std::make_unique( + reinterpret_cast(editor.hwnd)); + handler->SetSlideShowCreationStateForTest( + /*fullscreen_slide_show_started_after_capture_start=*/true); + handlers.push_back(std::move(handler)); } std::vector slide_shows = { @@ -290,4 +299,32 @@ TEST_F(FullScreenWinApplicationHandlerTest, } } +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowNotFoundWhenTwoEditorsWithSameTitleExist) { + const WCHAR* editor_title = L"My - Title - PowerPoint"; + CreateEditorWindow(editor_title); + WindowInfo second_editor_window_info = + CreateTestWindow(editor_title, /*window_class=*/L"PPTFrameClass"); + EXPECT_NE(editor_window_info_.hwnd, second_editor_window_info.hwnd); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"); + + EXPECT_NE(FindFullScreenWindow(), slide_show); + EXPECT_EQ(FindFullScreenWindow(), reinterpret_cast(0)); + + DestroyTestWindow(second_editor_window_info); +} + +TEST_F(FullScreenWinApplicationHandlerTest, + FullScreenWindowNotFoundWhenSlideShowWasCreatedBefore) { + const WCHAR* editor_title = L"My - Title - PowerPoint"; + CreateEditorWindow( + editor_title, /*window_class=*/L"PPTFrameClass", + /*fullscreen_slide_show_started_after_capture_start=*/false); + HWND slide_show = + CreateSlideShowWindow(L"PowerPoint Slide Show - [My - Title]"); + + EXPECT_NE(FindFullScreenWindow(), slide_show); + EXPECT_EQ(FindFullScreenWindow(), reinterpret_cast(0)); +} } // namespace webrtc diff --git a/modules/desktop_capture/win/test_support/test_window.cc b/modules/desktop_capture/win/test_support/test_window.cc index b699bf4ed0..35875e6dc9 100644 --- a/modules/desktop_capture/win/test_support/test_window.cc +++ b/modules/desktop_capture/win/test_support/test_window.cc @@ -84,6 +84,23 @@ void ResizeTestWindow(const HWND hwnd, const int width, const int height) { ::UpdateWindow(hwnd); } +void ResizeTestWindowToFullScreen(const HWND hwnd) { + ::SetWindowLongPtr(hwnd, GWL_STYLE, WS_VISIBLE); + + MONITORINFO monitor_info = {sizeof(monitor_info)}; + if (!::GetMonitorInfo(::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), + &monitor_info)) { + return; + } + + ::SetWindowPos( + hwnd, HWND_TOP, monitor_info.rcMonitor.left, monitor_info.rcMonitor.top, + /*width=*/monitor_info.rcMonitor.right - monitor_info.rcMonitor.left, + /*height=*/monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top, + SWP_SHOWWINDOW); + ::UpdateWindow(hwnd); +} + void MoveTestWindow(const HWND hwnd, const int x, const int y) { // SWP_NOSIZE results in the width and height params being ignored. ::SetWindowPos(hwnd, HWND_TOP, x, y, /*width=*/0, /*height=*/0, diff --git a/modules/desktop_capture/win/test_support/test_window.h b/modules/desktop_capture/win/test_support/test_window.h index 460acd35f2..a30017609c 100644 --- a/modules/desktop_capture/win/test_support/test_window.h +++ b/modules/desktop_capture/win/test_support/test_window.h @@ -38,6 +38,8 @@ WindowInfo CreateTestWindow(const WCHAR* window_title, void ResizeTestWindow(HWND hwnd, int width, int height); +void ResizeTestWindowToFullScreen(const HWND hwnd); + void MoveTestWindow(HWND hwnd, int x, int y); void MinimizeTestWindow(HWND hwnd); diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc index 039a49cf29..dc744d46c6 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc @@ -237,7 +237,7 @@ void WgcCaptureSession::EnsureFrame() { // We failed to process the frame, but we do have a frame so just return that. if (queue_.current_frame()) { - RTC_LOG(LS_ERROR) << "ProcessFrame failed, using existing frame: " << hr; + RTC_LOG(LS_VERBOSE) << "ProcessFrame failed, using existing frame: " << hr; return; } @@ -583,6 +583,15 @@ HRESULT WgcCaptureSession::ProcessFrame() { // Mark resized frames as damaged. damage_region_.SetRect(DesktopRect::MakeSize(current_frame->size())); } + } else{ + // Mark a `damage_region_` even if there is no previous frame. This + // condition does not create any increased overhead but is useful while + // using FullScreenWindowDetector, where it would create a new + // WgcCaptureSession(with no previous frame) for the slide show window but + // the DesktopCaptureDevice instance might have already received frames + // from the editor window's WgcCaptureSession which would have activated + // the zero-hertz mode. + damage_region_.SetRect(DesktopRect::MakeSize(current_frame->size())); } } diff --git a/modules/desktop_capture/win/wgc_capture_source_unittest.cc b/modules/desktop_capture/win/wgc_capture_source_unittest.cc index dc37ec2e0d..60039301c5 100644 --- a/modules/desktop_capture/win/wgc_capture_source_unittest.cc +++ b/modules/desktop_capture/win/wgc_capture_source_unittest.cc @@ -30,10 +30,10 @@ namespace { const WCHAR kWindowTitle[] = L"WGC Capture Source Test Window"; -const int kFirstXCoord = 25; -const int kFirstYCoord = 50; -const int kSecondXCoord = 50; -const int kSecondYCoord = 75; +constexpr int kFirstXCoord = 25; +constexpr int kFirstYCoord = 50; +constexpr int kSecondXCoord = 50; +constexpr int kSecondYCoord = 75; } // namespace diff --git a/modules/desktop_capture/win/wgc_capturer_win.cc b/modules/desktop_capture/win/wgc_capturer_win.cc index 609a3e226a..8fc2a12459 100644 --- a/modules/desktop_capture/win/wgc_capturer_win.cc +++ b/modules/desktop_capture/win/wgc_capturer_win.cc @@ -115,14 +115,15 @@ bool IsWgcSupported(CaptureType capture_type) { // There is a bug in `CreateForMonitor` that causes a crash if there are no // active displays. The crash was fixed in Win11, but we are still unable // to capture screens without an active display. - if (capture_type == CaptureType::kScreen) + if (capture_type == CaptureType::kScreen) { return false; - + } // There is a bug in the DWM (Desktop Window Manager) that prevents it from // providing image data if there are no displays attached. This was fixed in // Windows 11. - if (rtc_win::GetVersion() < rtc_win::Version::VERSION_WIN11) + if (rtc_win::GetVersion() < rtc_win::Version::VERSION_WIN11) { return false; + } } // A bug in the WGC API `CreateForMonitor` prevents capturing the entire @@ -134,8 +135,9 @@ bool IsWgcSupported(CaptureType capture_type) { return false; } - if (!ResolveCoreWinRTDelayload()) + if (!ResolveCoreWinRTDelayload()) { return false; + } // We need to check if the WGC APIs are present on the system. Certain SKUs // of Windows ship without these APIs. @@ -145,32 +147,37 @@ bool IsWgcSupported(CaptureType capture_type) { ABI::Windows::Foundation::Metadata::IApiInformationStatics, RuntimeClass_Windows_Foundation_Metadata_ApiInformation>( &api_info_statics); - if (FAILED(hr)) + if (FAILED(hr)) { return false; + } HSTRING api_contract; hr = CreateHstring(kApiContract, wcslen(kApiContract), &api_contract); - if (FAILED(hr)) + if (FAILED(hr)) { return false; + } boolean is_api_present; hr = api_info_statics->IsApiContractPresentByMajor( api_contract, kRequiredApiContractVersion, &is_api_present); DeleteHstring(api_contract); - if (FAILED(hr) || !is_api_present) + if (FAILED(hr) || !is_api_present) { return false; + } HSTRING wgc_session_type; hr = CreateHstring(kWgcSessionType, wcslen(kWgcSessionType), &wgc_session_type); - if (FAILED(hr)) + if (FAILED(hr)) { return false; + } boolean is_type_present; hr = api_info_statics->IsTypePresent(wgc_session_type, &is_type_present); DeleteHstring(wgc_session_type); - if (FAILED(hr) || !is_type_present) + if (FAILED(hr) || !is_type_present) { return false; + } // If the APIs are present, we need to check that they are supported. ComPtr capture_session_statics; @@ -178,13 +185,15 @@ bool IsWgcSupported(CaptureType capture_type) { WGC::IGraphicsCaptureSessionStatics, RuntimeClass_Windows_Graphics_Capture_GraphicsCaptureSession>( &capture_session_statics); - if (FAILED(hr)) + if (FAILED(hr)) { return false; + } boolean is_supported; hr = capture_session_statics->IsSupported(&is_supported); - if (FAILED(hr) || !is_supported) + if (FAILED(hr) || !is_supported) { return false; + } return true; } @@ -197,9 +206,11 @@ WgcCapturerWin::WgcCapturerWin( : options_(options), source_factory_(std::move(source_factory)), source_enumerator_(std::move(source_enumerator)), - allow_delayed_capturable_check_(allow_delayed_capturable_check) { - if (!core_messaging_library_) + allow_delayed_capturable_check_(allow_delayed_capturable_check), + full_screen_window_detector_(options.full_screen_window_detector()) { + if (!core_messaging_library_) { core_messaging_library_ = LoadLibraryW(kCoreMessagingDll); + } if (core_messaging_library_) { create_dispatcher_queue_controller_func_ = @@ -210,8 +221,9 @@ WgcCapturerWin::WgcCapturerWin( } WgcCapturerWin::~WgcCapturerWin() { - if (core_messaging_library_) + if (core_messaging_library_) { FreeLibrary(core_messaging_library_); + } } // static @@ -238,16 +250,41 @@ bool WgcCapturerWin::GetSourceList(SourceList* sources) { } bool WgcCapturerWin::SelectSource(DesktopCapturer::SourceId id) { - capture_source_ = source_factory_->CreateCaptureSource(id); - if (allow_delayed_capturable_check_) + selected_source_id_ = id; + + // Use `full_screen_window_detector_` to check if there is a corresponding + // full screen window for the `selected_source_id_`. + const DesktopCapturer::SourceId full_screen_source_id = + full_screen_window_detector_ && + full_screen_window_detector_->UseHeuristicForWGC() + ? full_screen_window_detector_->FindFullScreenWindow(id) + : 0; + + // `capture_id` represents the SourceId used to create the `capture_source_`, + // which is the module responsible for capturing the frames. + auto capture_id = full_screen_source_id ? full_screen_source_id : id; + if (capture_id != id && !fullscreen_usage_logged_) { + // Log the usage of FullScreenDetector only once and only if it's + // successful. + fullscreen_usage_logged_ = true; + LogDesktopCapturerFullscreenDetectorUsage(); + } + + if (!capture_source_ || capture_source_->GetSourceId() != capture_id) { + capture_source_ = source_factory_->CreateCaptureSource(capture_id); + } + + if (allow_delayed_capturable_check_) { return true; + } return capture_source_->IsCapturable(); } bool WgcCapturerWin::FocusOnSelectedSource() { - if (!capture_source_) + if (!capture_source_) { return false; + } return capture_source_->FocusOnSource(); } @@ -309,6 +346,15 @@ void WgcCapturerWin::CaptureFrame() { return; } + // Feed the actual list of windows into full screen window detector. + if (full_screen_window_detector_) { + full_screen_window_detector_->UpdateWindowListIfNeeded( + selected_source_id_, [this](DesktopCapturer::SourceList* sources) { + return GetSourceList(sources); + }); + SelectSource(selected_source_id_); + } + HRESULT hr; if (!dispatcher_queue_created_) { // Set the apartment type to NONE because this thread should already be COM @@ -407,10 +453,23 @@ void WgcCapturerWin::CaptureFrame() { bool WgcCapturerWin::IsSourceBeingCaptured(DesktopCapturer::SourceId id) { std::map::iterator session_iter = ongoing_captures_.find(id); - if (session_iter == ongoing_captures_.end()) + if (session_iter == ongoing_captures_.end()) { return false; + } return session_iter->second.IsCaptureStarted(); } +void WgcCapturerWin::SetUpFullScreenDetectorForTest( + bool use_heuristic, + DesktopCapturer::SourceId source_id, + bool fullscreen_slide_show_started_after_capture_start) { + if (full_screen_window_detector_) { + full_screen_window_detector_->SetUseHeuristicFullscreenPowerPointWindows( + /*use_heuristic_fullscreen_powerpoint_windows=*/true, use_heuristic); + full_screen_window_detector_->CreateFullScreenApplicationHandlerForTest( + source_id, fullscreen_slide_show_started_after_capture_start); + } +} + } // namespace webrtc diff --git a/modules/desktop_capture/win/wgc_capturer_win.h b/modules/desktop_capture/win/wgc_capturer_win.h index 60309d7b23..5d395f0b4a 100644 --- a/modules/desktop_capture/win/wgc_capturer_win.h +++ b/modules/desktop_capture/win/wgc_capturer_win.h @@ -19,9 +19,11 @@ #include #include +#include "api/scoped_refptr.h" #include "modules/desktop_capture/desktop_capture_options.h" #include "modules/desktop_capture/desktop_capture_types.h" #include "modules/desktop_capture/desktop_capturer.h" +#include "modules/desktop_capture/full_screen_window_detector.h" #include "modules/desktop_capture/win/screen_capture_utils.h" #include "modules/desktop_capture/win/wgc_capture_session.h" #include "modules/desktop_capture/win/wgc_capture_source.h" @@ -111,6 +113,10 @@ class WgcCapturerWin : public DesktopCapturer { // Used in WgcCapturerTests. bool IsSourceBeingCaptured(SourceId id); + void SetUpFullScreenDetectorForTest( + bool use_heuristic, + DesktopCapturer::SourceId source_id, + bool fullscreen_slide_show_started_after_capture_start = true); private: typedef HRESULT(WINAPI* CreateDispatcherQueueControllerFunc)( @@ -144,6 +150,11 @@ class WgcCapturerWin : public DesktopCapturer { // if the source is capturable and it creates the GraphicsCaptureItem for us. std::unique_ptr capture_source_; + // DesktopCapturer::SourceId of the source that was selected by the user. It + // might not necessarily correspond to the `capture_source_` when the + // `full_screen_window_detector_` is active. + DesktopCapturer::SourceId selected_source_id_; + // A map of all the sources we are capturing and the associated // WgcCaptureSession. Frames for the current source (indicated via // SelectSource) will be retrieved from the appropriate session when @@ -164,6 +175,13 @@ class WgcCapturerWin : public DesktopCapturer { // A Direct3D11 device that is shared amongst the WgcCaptureSessions, who // require one to perform the capture. Microsoft::WRL::ComPtr<::ID3D11Device> d3d11_device_; + + // This allows us to find full screen windows for applications in some + // specific cases. + scoped_refptr full_screen_window_detector_; + + // Used to make sure that we only log the usage of fullscreen detection once. + bool fullscreen_usage_logged_ = false; }; } // namespace webrtc diff --git a/modules/desktop_capture/win/wgc_capturer_win_unittest.cc b/modules/desktop_capture/win/wgc_capturer_win_unittest.cc index baeca2d924..942179c208 100644 --- a/modules/desktop_capture/win/wgc_capturer_win_unittest.cc +++ b/modules/desktop_capture/win/wgc_capturer_win_unittest.cc @@ -54,6 +54,15 @@ constexpr int kSourceClosed = 1; constexpr char kCaptureTimeHistogram[] = "WebRTC.DesktopCapture.Win.WgcCapturerFrameTime"; +constexpr char kFullScreenDetectorResult[] = + "WebRTC.Screenshare.FullScreenDetectorResult"; +constexpr int detector_result_success = 1; +constexpr int detector_result_failure_same_title_windows = 2; +constexpr int detector_result_failure_slide_show_not_chosen = 3; + +constexpr char kCaptureFullscreenDetectorHistogram[] = + "WebRTC.Screenshare.DesktopCapturerFullscreenDetector"; + // The capturer keeps `kNumBuffers` in its frame pool, so we need to request // that many frames to clear those out. The next frame will have the new size // (if the size has changed) so we will resize the frame pool at this point. @@ -570,4 +579,177 @@ TEST_F(WgcCapturerWindowTest, CloseWindowMidCapture) { EXPECT_EQ(result_, DesktopCapturer::Result::ERROR_PERMANENT); } +class WgcCapturerFullScreenDetectorTest : public WgcCapturerWindowTest { + public: + void SetUp() override { + capturer_ = WgcCapturerWin::CreateRawWindowCapturer( + DesktopCaptureOptions::CreateDefault()); + wgc_capturer_ = static_cast(capturer_.get()); + + editor_window_ = CreateEditorWindow(); + CreateSlideShowWindow(); + WgcCapturerWindowTest::SetUp(); + } + + WindowInfo CreateEditorWindow() { + return CreateTestWindow( + L"My - Title - PowerPoint", kMediumWindowHeight, kMediumWindowWidth, + /*extended_styles=*/0, /*window_class=*/L"PPTFrameClass"); + } + + void CreateSlideShowWindow() { + slide_show_window_ = + CreateTestWindow(L"PowerPoint Slide Show - [My - Title]", + kLargeWindowHeight, kLargeWindowWidth, + /*extended_styles=*/0, + /*window_class=*/L"screenClass"); + ResizeTestWindowToFullScreen(slide_show_window_.hwnd); + } + + WgcCapturerWin* wgc_capturer_; + WindowInfo editor_window_; + WindowInfo slide_show_window_; +}; + +TEST_F(WgcCapturerFullScreenDetectorTest, SlideShowNotFoundByDefaultConfig) { + // The default behavior on WGC capturer of `use_heuristic` is false. + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/false, + reinterpret_cast(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(editor_window_.hwnd))); + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, + CorrectSlideShowFoundForEditorWhenSlideShowCreatedAfter) { + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(editor_window_.hwnd))); + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(slide_show_window_.hwnd))); + + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 1); + EXPECT_EQ( + metrics::NumEvents(kFullScreenDetectorResult, detector_result_success), + 1); + EXPECT_EQ(metrics::NumEvents(kFullScreenDetectorResult, + detector_result_failure_slide_show_not_chosen), + 0); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, + SlideShowNotFoundForEditorWhenSlideShowCreatedBefore) { + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast(editor_window_.hwnd), + /*fullscreen_slide_show_started_after_capture_start=*/false); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(editor_window_.hwnd))); + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(slide_show_window_.hwnd))); + + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); + EXPECT_EQ( + metrics::NumEvents(kFullScreenDetectorResult, detector_result_success), + 0); + EXPECT_EQ(metrics::NumEvents(kFullScreenDetectorResult, + detector_result_failure_slide_show_not_chosen), + 1); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, LoggedOnlyOnce) { + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + DoCapture(); + + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 1); + EXPECT_EQ( + metrics::NumEvents(kFullScreenDetectorResult, detector_result_success), + 1); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, + SlideShowNotFoundWithMultipleSameTitleEditors) { + WindowInfo same_title_editor_window = CreateEditorWindow(); + EXPECT_NE(editor_window_.hwnd, same_title_editor_window.hwnd); + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast(editor_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast(editor_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(editor_window_.hwnd))); + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); + EXPECT_EQ( + metrics::NumEvents(kFullScreenDetectorResult, detector_result_success), + 0); + EXPECT_EQ(metrics::NumEvents(kFullScreenDetectorResult, + detector_result_failure_same_title_windows), + 1); +} + +TEST_F(WgcCapturerFullScreenDetectorTest, + CaptureTiedToSlideShowIfSlideShowIsShared) { + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast(editor_window_.hwnd)); + wgc_capturer_->SetUpFullScreenDetectorForTest( + /*use_heuristic=*/true, + reinterpret_cast(slide_show_window_.hwnd)); + + EXPECT_TRUE(wgc_capturer_->SelectSource( + reinterpret_cast(slide_show_window_.hwnd))); + wgc_capturer_->Start(this); + DoCapture(); + + EXPECT_FALSE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(editor_window_.hwnd))); + EXPECT_TRUE(wgc_capturer_->IsSourceBeingCaptured( + reinterpret_cast(slide_show_window_.hwnd))); + EXPECT_EQ(metrics::NumEvents(kCaptureFullscreenDetectorHistogram, true), 0); + EXPECT_EQ( + metrics::NumEvents(kFullScreenDetectorResult, detector_result_success), + 0); + EXPECT_EQ(metrics::NumEvents(kFullScreenDetectorResult, + detector_result_failure_slide_show_not_chosen), + 0); +} + } // namespace webrtc diff --git a/modules/desktop_capture/win/window_capture_utils_unittest.cc b/modules/desktop_capture/win/window_capture_utils_unittest.cc index ec70c80ed2..009fa33aca 100644 --- a/modules/desktop_capture/win/window_capture_utils_unittest.cc +++ b/modules/desktop_capture/win/window_capture_utils_unittest.cc @@ -25,9 +25,27 @@ namespace webrtc { namespace { -const char kWindowThreadName[] = "window_capture_utils_test_thread"; +constexpr char kWindowThreadName[] = "window_capture_utils_test_thread"; const WCHAR kWindowTitle[] = L"Window Capture Utils Test"; +TEST(WindowCaptureUtilsTest, GetWindowList) { + WindowInfo info = CreateTestWindow(kWindowTitle); + DesktopCapturer::SourceList window_list; + ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list)); + EXPECT_GT(window_list.size(), 0ULL); + EXPECT_NE(std::find_if(window_list.begin(), window_list.end(), + [&info](DesktopCapturer::Source window) { + return reinterpret_cast(window.id) == + info.hwnd; + }), + window_list.end()); + DestroyTestWindow(info); +} + +// Disable thread-safety-analysis in order to test unresponsive Windows. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wthread-safety-analysis" + std::unique_ptr SetUpUnresponsiveWindow(std::mutex& mtx, WindowInfo& info) { std::unique_ptr window_thread; @@ -47,22 +65,6 @@ std::unique_ptr SetUpUnresponsiveWindow(std::mutex& mtx, return window_thread; } -} // namespace - -TEST(WindowCaptureUtilsTest, GetWindowList) { - WindowInfo info = CreateTestWindow(kWindowTitle); - DesktopCapturer::SourceList window_list; - ASSERT_TRUE(GetWindowList(GetWindowListFlags::kNone, &window_list)); - EXPECT_GT(window_list.size(), 0ULL); - EXPECT_NE(std::find_if(window_list.begin(), window_list.end(), - [&info](DesktopCapturer::Source window) { - return reinterpret_cast(window.id) == - info.hwnd; - }), - window_list.end()); - DestroyTestWindow(info); -} - TEST(WindowCaptureUtilsTest, IncludeUnresponsiveWindows) { std::mutex mtx; WindowInfo info; @@ -107,6 +109,8 @@ TEST(WindowCaptureUtilsTest, IgnoreUnresponsiveWindows) { window_thread->Stop(); } +#pragma clang diagnostic pop + TEST(WindowCaptureUtilsTest, IncludeUntitledWindows) { WindowInfo info = CreateTestWindow(L""); DesktopCapturer::SourceList window_list; @@ -148,4 +152,5 @@ TEST(WindowCaptureUtilsTest, IgnoreCurrentProcessWindows) { DestroyTestWindow(info); } +} // namespace } // namespace webrtc diff --git a/modules/desktop_capture/window_capturer_unittest.cc b/modules/desktop_capture/window_capturer_unittest.cc index 4930f3d102..96193c1576 100644 --- a/modules/desktop_capture/window_capturer_unittest.cc +++ b/modules/desktop_capture/window_capturer_unittest.cc @@ -86,7 +86,7 @@ TEST_F(WindowCapturerTest, MAYBE_Capture) { } // If we failed to capture a window make sure it no longer exists. - if (!frame_.get()) { + if (!frame_) { DesktopCapturer::SourceList new_list; EXPECT_TRUE(capturer_->GetSourceList(&new_list)); for (auto new_list_it = new_list.begin(); new_list_it != new_list.end(); diff --git a/modules/desktop_capture/window_finder_unittest.cc b/modules/desktop_capture/window_finder_unittest.cc index ebceac4a92..f4f5d88d07 100644 --- a/modules/desktop_capture/window_finder_unittest.cc +++ b/modules/desktop_capture/window_finder_unittest.cc @@ -10,8 +10,7 @@ #include "modules/desktop_capture/window_finder.h" -#include - +#include #include #include "api/scoped_refptr.h" diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h index 8e4e5465fa..48e2359c23 100644 --- a/modules/include/module_common_types.h +++ b/modules/include/module_common_types.h @@ -11,8 +11,7 @@ #ifndef MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ #define MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ -#include - +#include #include namespace webrtc { diff --git a/modules/include/module_common_types_public.h b/modules/include/module_common_types_public.h index 289b5d0b64..712ecabe96 100644 --- a/modules/include/module_common_types_public.h +++ b/modules/include/module_common_types_public.h @@ -11,8 +11,8 @@ #ifndef MODULES_INCLUDE_MODULE_COMMON_TYPES_PUBLIC_H_ #define MODULES_INCLUDE_MODULE_COMMON_TYPES_PUBLIC_H_ +#include #include -#include namespace webrtc { diff --git a/modules/module_common_types_unittest.cc b/modules/module_common_types_public_unittest.cc similarity index 98% rename from modules/module_common_types_unittest.cc rename to modules/module_common_types_public_unittest.cc index bec3b5da22..e101780279 100644 --- a/modules/module_common_types_unittest.cc +++ b/modules/module_common_types_public_unittest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/include/module_common_types.h" - #include "modules/include/module_common_types_public.h" + #include "test/gtest.h" namespace webrtc { diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index 8a272f06b9..b8134b814a 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -54,7 +54,7 @@ constexpr DataRate kSecondClusterRate = DataRate::KilobitsPerSec(1800); // For 1.8 Mbps, this comes to be about 120 kbps with 1200 probe packets. constexpr DataRate kProbingErrorMargin = DataRate::KilobitsPerSec(150); -const float kPaceMultiplier = 2.5f; +constexpr float kPaceMultiplier = 2.5f; constexpr uint32_t kAudioSsrc = 12345; constexpr uint32_t kVideoSsrc = 234565; diff --git a/modules/portal/pipewire_utils.h b/modules/portal/pipewire_utils.h index c1327b85c9..c3d4f347a8 100644 --- a/modules/portal/pipewire_utils.h +++ b/modules/portal/pipewire_utils.h @@ -11,11 +11,13 @@ #ifndef MODULES_PORTAL_PIPEWIRE_UTILS_H_ #define MODULES_PORTAL_PIPEWIRE_UTILS_H_ -#include -#include +#include #include #include +#include +#include + // static struct dma_buf_sync { uint64_t flags; diff --git a/modules/portal/scoped_glib.cc b/modules/portal/scoped_glib.cc index 31ba8cb77a..3f040be872 100644 --- a/modules/portal/scoped_glib.cc +++ b/modules/portal/scoped_glib.cc @@ -10,6 +10,11 @@ #include "modules/portal/scoped_glib.h" +#include + +#include "rtc_base/system/rtc_export.h" +#include "rtc_base/system/rtc_export_template.h" + namespace webrtc { template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) Scoped; diff --git a/modules/portal/scoped_glib.h b/modules/portal/scoped_glib.h index d97e47ae1f..61e140b181 100644 --- a/modules/portal/scoped_glib.h +++ b/modules/portal/scoped_glib.h @@ -14,6 +14,7 @@ #include #include "rtc_base/checks.h" +#include "rtc_base/system/rtc_export.h" #include "rtc_base/system/rtc_export_template.h" namespace webrtc { diff --git a/modules/portal/xdg_desktop_portal_utils.cc b/modules/portal/xdg_desktop_portal_utils.cc index d911f0d106..ad4c6614d6 100644 --- a/modules/portal/xdg_desktop_portal_utils.cc +++ b/modules/portal/xdg_desktop_portal_utils.cc @@ -9,10 +9,13 @@ */ #include "modules/portal/xdg_desktop_portal_utils.h" +#include #include +#include #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" +#include "modules/portal/portal_request_response.h" #include "modules/portal/scoped_glib.h" #include "rtc_base/logging.h" #include "rtc_base/strings/str_join.h" diff --git a/modules/portal/xdg_desktop_portal_utils.h b/modules/portal/xdg_desktop_portal_utils.h index eff46a01ab..feb7da3da4 100644 --- a/modules/portal/xdg_desktop_portal_utils.h +++ b/modules/portal/xdg_desktop_portal_utils.h @@ -12,17 +12,13 @@ #define MODULES_PORTAL_XDG_DESKTOP_PORTAL_UTILS_H_ #include -#include +#include #include -#include #include "absl/strings/string_view.h" #include "modules/portal/portal_request_response.h" -#include "modules/portal/scoped_glib.h" -#include "modules/portal/xdg_session_details.h" -#include "rtc_base/checks.h" -#include "rtc_base/logging.h" +#include "rtc_base/system/rtc_export.h" namespace webrtc { namespace xdg_portal { diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn index a79b4363e0..b71dfe4ada 100644 --- a/modules/remote_bitrate_estimator/BUILD.gn +++ b/modules/remote_bitrate_estimator/BUILD.gn @@ -104,6 +104,7 @@ rtc_library("congestion_control_feedback_generator") { "../../api:field_trials_view", "../../api:sequence_checker", "../../api/environment", + "../../api/transport:ecn_marking", "../../api/units:data_rate", "../../api/units:data_size", "../../api/units:time_delta", @@ -112,7 +113,6 @@ rtc_library("congestion_control_feedback_generator") { "../../rtc_base:logging", "../../rtc_base:rtc_numerics", "../../rtc_base/experiments:field_trial_parser", - "../../rtc_base/network:ecn_marking", "../rtp_rtcp:ntp_time_util", "../rtp_rtcp:rtp_rtcp_format", "//third_party/abseil-cpp/absl/algorithm:container", @@ -170,9 +170,11 @@ if (rtc_include_tests) { ":remote_bitrate_estimator", ":transport_sequence_number_feedback_generator", "..:module_api_public", + "../../api:field_trials", "../../api:rtp_headers", "../../api/environment:environment_factory", "../../api/transport:bandwidth_usage", + "../../api/transport:ecn_marking", "../../api/transport:mock_network_control", "../../api/transport:network_control", "../../api/units:data_rate", @@ -183,9 +185,8 @@ if (rtc_include_tests) { "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:random", - "../../rtc_base/network:ecn_marking", "../../system_wrappers", - "../../test:explicit_key_value_config", + "../../test:create_test_field_trials", "../../test:fileutils", "../../test:test_support", "../pacing", diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 6a830f1418..6836f578ec 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -11,19 +11,18 @@ #include +#include "api/field_trials.h" #include "api/transport/bandwidth_usage.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 "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" namespace webrtc { namespace { -using test::ExplicitKeyValueConfig; - constexpr Timestamp kInitialTime = Timestamp::Millis(123'456); constexpr TimeDelta kMinBwePeriod = TimeDelta::Seconds(2); @@ -36,26 +35,26 @@ constexpr double kFractionAfterOveruse = 0.85; } // namespace TEST(AimdRateControlTest, MinNearMaxIncreaseRateOnLowBandwith) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); aimd_rate_control.SetEstimate(DataRate::BitsPerSec(30'000), kInitialTime); EXPECT_EQ(aimd_rate_control.GetNearMaxIncreaseRateBpsPerSecond(), 4'000); } TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn90kbpsAnd200msRtt) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); aimd_rate_control.SetEstimate(DataRate::BitsPerSec(90'000), kInitialTime); EXPECT_EQ(aimd_rate_control.GetNearMaxIncreaseRateBpsPerSecond(), 5'000); } TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn60kbpsAnd100msRtt) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); aimd_rate_control.SetEstimate(DataRate::BitsPerSec(60'000), kInitialTime); aimd_rate_control.SetRtt(TimeDelta::Millis(100)); EXPECT_EQ(aimd_rate_control.GetNearMaxIncreaseRateBpsPerSecond(), 5'000); } TEST(AimdRateControlTest, GetIncreaseRateAndBandwidthPeriod) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); constexpr DataRate kBitrate = DataRate::BitsPerSec(300'000); aimd_rate_control.SetEstimate(kBitrate, kInitialTime); aimd_rate_control.Update({BandwidthUsage::kBwOverusing, kBitrate}, @@ -66,7 +65,7 @@ TEST(AimdRateControlTest, GetIncreaseRateAndBandwidthPeriod) { } TEST(AimdRateControlTest, BweLimitedByAckedBitrate) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); constexpr DataRate kAckedBitrate = DataRate::BitsPerSec(10'000); Timestamp now = kInitialTime; aimd_rate_control.SetEstimate(kAckedBitrate, now); @@ -80,7 +79,7 @@ TEST(AimdRateControlTest, BweLimitedByAckedBitrate) { } TEST(AimdRateControlTest, BweNotLimitedByDecreasingAckedBitrate) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); constexpr DataRate kAckedBitrate = DataRate::BitsPerSec(10'000); Timestamp now = kInitialTime; aimd_rate_control.SetEstimate(kAckedBitrate, now); @@ -101,7 +100,7 @@ TEST(AimdRateControlTest, BweNotLimitedByDecreasingAckedBitrate) { } TEST(AimdRateControlTest, DefaultPeriodUntilFirstOveruse) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); aimd_rate_control.SetStartBitrate(DataRate::KilobitsPerSec(300)); EXPECT_EQ(aimd_rate_control.GetExpectedBandwidthPeriod(), kDefaultPeriod); aimd_rate_control.Update( @@ -111,7 +110,7 @@ TEST(AimdRateControlTest, DefaultPeriodUntilFirstOveruse) { } TEST(AimdRateControlTest, ExpectedPeriodAfterTypicalDrop) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); // The rate increase at 216 kbps should be 12 kbps. If we drop from // 216 + 4*12 = 264 kbps, it should take 4 seconds to recover. Since we // back off to 0.85*acked_rate-5kbps, the acked bitrate needs to be 260 @@ -131,7 +130,7 @@ TEST(AimdRateControlTest, ExpectedPeriodAfterTypicalDrop) { } TEST(AimdRateControlTest, BandwidthPeriodIsNotBelowMin) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); constexpr DataRate kInitialBitrate = DataRate::BitsPerSec(10'000); Timestamp now = kInitialTime; aimd_rate_control.SetEstimate(kInitialBitrate, now); @@ -144,7 +143,7 @@ TEST(AimdRateControlTest, BandwidthPeriodIsNotBelowMin) { } TEST(AimdRateControlTest, BandwidthPeriodIsNotAboveMaxNoSmoothingExp) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); constexpr DataRate kInitialBitrate = DataRate::BitsPerSec(10'010'000); Timestamp now = kInitialTime; aimd_rate_control.SetEstimate(kInitialBitrate, now); @@ -157,7 +156,7 @@ TEST(AimdRateControlTest, BandwidthPeriodIsNotAboveMaxNoSmoothingExp) { } TEST(AimdRateControlTest, SendingRateBoundedWhenThroughputNotEstimated) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig("")); + AimdRateControl aimd_rate_control(CreateTestFieldTrials()); constexpr DataRate kInitialBitrate = DataRate::BitsPerSec(123'000); Timestamp now = kInitialTime; aimd_rate_control.Update({BandwidthUsage::kBwNormal, kInitialBitrate}, now); @@ -180,8 +179,8 @@ TEST(AimdRateControlTest, EstimateDoesNotIncreaseInAlr) { // When alr is detected, the delay based estimator is not allowed to increase // bwe since there will be no feedback from the network if the new estimate // is correct. - ExplicitKeyValueConfig field_trials( - "WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); AimdRateControl aimd_rate_control(field_trials, /*send_side=*/true); Timestamp now = kInitialTime; constexpr DataRate kInitialBitrate = DataRate::BitsPerSec(123'000); @@ -198,8 +197,8 @@ TEST(AimdRateControlTest, EstimateDoesNotIncreaseInAlr) { } TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { - ExplicitKeyValueConfig field_trials( - "WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); AimdRateControl aimd_rate_control(field_trials, /*send_side=*/true); constexpr DataRate kInitialBitrate = DataRate::BitsPerSec(123'000); aimd_rate_control.SetEstimate(kInitialBitrate, kInitialTime); @@ -210,7 +209,7 @@ TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { } TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig(""), + AimdRateControl aimd_rate_control(CreateTestFieldTrials(), /*send_side=*/true); aimd_rate_control.SetEstimate(DataRate::BitsPerSec(300'000), kInitialTime); NetworkStateEstimate network_estimate; @@ -223,7 +222,7 @@ TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { TEST(AimdRateControlTest, SetEstimateDefaultUpperLimitedByCurrentBitrateIfNetworkEstimateIsLow) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig(""), + AimdRateControl aimd_rate_control(CreateTestFieldTrials(), /*send_side=*/true); aimd_rate_control.SetEstimate(DataRate::BitsPerSec(500'000), kInitialTime); ASSERT_EQ(aimd_rate_control.LatestEstimate(), DataRate::BitsPerSec(500'000)); @@ -238,7 +237,7 @@ TEST(AimdRateControlTest, TEST(AimdRateControlTest, SetEstimateNotUpperLimitedByCurrentBitrateIfNetworkEstimateIsLowIf) { AimdRateControl aimd_rate_control( - ExplicitKeyValueConfig( + CreateTestFieldTrials( "WebRTC-Bwe-EstimateBoundedIncrease/c_upper:false/"), /*send_side=*/true); @@ -253,7 +252,7 @@ TEST(AimdRateControlTest, } TEST(AimdRateControlTest, SetEstimateLowerLimitedByNetworkEstimate) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig(""), + AimdRateControl aimd_rate_control(CreateTestFieldTrials(), /*send_side=*/true); NetworkStateEstimate network_estimate; network_estimate.link_capacity_lower = DataRate::BitsPerSec(400'000); @@ -266,7 +265,7 @@ TEST(AimdRateControlTest, SetEstimateLowerLimitedByNetworkEstimate) { TEST(AimdRateControlTest, SetEstimateIgnoredIfLowerThanNetworkEstimateAndCurrent) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig(""), + AimdRateControl aimd_rate_control(CreateTestFieldTrials(), /*send_side=*/true); aimd_rate_control.SetEstimate(DataRate::KilobitsPerSec(200), kInitialTime); ASSERT_EQ(aimd_rate_control.LatestEstimate().kbps(), 200); @@ -282,8 +281,8 @@ TEST(AimdRateControlTest, TEST(AimdRateControlTest, EstimateIncreaseWhileNotInAlr) { // Allow the estimate to increase as long as alr is not detected to ensure // tha BWE can not get stuck at a certain bitrate. - ExplicitKeyValueConfig field_trials( - "WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); AimdRateControl aimd_rate_control(field_trials, /*send_side=*/true); Timestamp now = kInitialTime; constexpr DataRate kInitialBitrate = DataRate::BitsPerSec(123'000); @@ -298,8 +297,8 @@ TEST(AimdRateControlTest, EstimateIncreaseWhileNotInAlr) { } TEST(AimdRateControlTest, EstimateNotLimitedByNetworkEstimateIfDisabled) { - ExplicitKeyValueConfig field_trials( - "WebRTC-Bwe-EstimateBoundedIncrease/Disabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-Bwe-EstimateBoundedIncrease/Disabled/"); AimdRateControl aimd_rate_control(field_trials, /*send_side=*/true); Timestamp now = kInitialTime; constexpr DataRate kInitialBitrate = DataRate::BitsPerSec(123'000); diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc b/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc index 1f91735df9..583da42a1b 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc @@ -17,6 +17,7 @@ #include #include "api/environment/environment_factory.h" +#include "api/transport/ecn_marking.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" @@ -26,7 +27,6 @@ #include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/buffer.h" -#include "rtc_base/network/ecn_marking.h" #include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.cc b/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.cc index b871dd314b..34fe72f720 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.cc +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.cc @@ -16,13 +16,13 @@ #include #include "absl/algorithm/container.h" +#include "api/transport/ecn_marking.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/network/ecn_marking.h" namespace webrtc { diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.h b/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.h index f2b2727864..b964688dbb 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.h +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_tracker.h @@ -14,10 +14,10 @@ #include #include +#include "api/transport/ecn_marking.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "rtc_base/network/ecn_marking.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_tracker_unittest.cc b/modules/remote_bitrate_estimator/congestion_control_feedback_tracker_unittest.cc index e70e207a32..794f08d62f 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_tracker_unittest.cc +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_tracker_unittest.cc @@ -13,11 +13,11 @@ #include #include +#include "api/transport/ecn_marking.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "rtc_base/network/ecn_marking.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/modules/remote_bitrate_estimator/inter_arrival_unittest.cc b/modules/remote_bitrate_estimator/inter_arrival_unittest.cc index 50d3b0fe09..f03468043f 100644 --- a/modules/remote_bitrate_estimator/inter_arrival_unittest.cc +++ b/modules/remote_bitrate_estimator/inter_arrival_unittest.cc @@ -29,8 +29,9 @@ enum { kInterArrivalShift = kAbsSendTimeFraction + kAbsSendTimeInterArrivalUpshift, }; -const double kRtpTimestampToMs = 1.0 / 90.0; -const double kAstToMs = 1000.0 / static_cast(1 << kInterArrivalShift); +constexpr double kRtpTimestampToMs = 1.0 / 90.0; +constexpr double kAstToMs = + 1000.0 / static_cast(1 << kInterArrivalShift); class InterArrivalTest : public ::testing::Test { protected: diff --git a/modules/remote_bitrate_estimator/overuse_detector.cc b/modules/remote_bitrate_estimator/overuse_detector.cc index 33996add7d..121ec22b99 100644 --- a/modules/remote_bitrate_estimator/overuse_detector.cc +++ b/modules/remote_bitrate_estimator/overuse_detector.cc @@ -10,10 +10,8 @@ #include "modules/remote_bitrate_estimator/overuse_detector.h" -#include -#include - #include +#include #include #include "api/transport/bandwidth_usage.h" diff --git a/modules/remote_bitrate_estimator/overuse_detector_unittest.cc b/modules/remote_bitrate_estimator/overuse_detector_unittest.cc index 8b064bdbc4..d893b4c73b 100644 --- a/modules/remote_bitrate_estimator/overuse_detector_unittest.cc +++ b/modules/remote_bitrate_estimator/overuse_detector_unittest.cc @@ -10,12 +10,11 @@ #include "modules/remote_bitrate_estimator/overuse_detector.h" -#include -#include - #include #include +#include #include +#include #include "api/transport/bandwidth_usage.h" #include "modules/remote_bitrate_estimator/inter_arrival.h" @@ -26,7 +25,7 @@ namespace webrtc { namespace testing { -const double kRtpTimestampToMs = 1.0 / 90.0; +constexpr double kRtpTimestampToMs = 1.0 / 90.0; class OveruseDetectorTest : public ::testing::Test { public: diff --git a/modules/remote_bitrate_estimator/overuse_estimator.cc b/modules/remote_bitrate_estimator/overuse_estimator.cc index f02ebca4e8..8d4efaf41e 100644 --- a/modules/remote_bitrate_estimator/overuse_estimator.cc +++ b/modules/remote_bitrate_estimator/overuse_estimator.cc @@ -10,9 +10,8 @@ #include "modules/remote_bitrate_estimator/overuse_estimator.h" -#include - #include +#include #include #include "api/transport/bandwidth_usage.h" diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc index 5847b088b9..e1e55ddad7 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc @@ -10,8 +10,6 @@ #include "modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" -#include - #include #include #include diff --git a/modules/remote_bitrate_estimator/tools/bwe_rtp.cc b/modules/remote_bitrate_estimator/tools/bwe_rtp.cc index 539cadbd66..c38f5101e6 100644 --- a/modules/remote_bitrate_estimator/tools/bwe_rtp.cc +++ b/modules/remote_bitrate_estimator/tools/bwe_rtp.cc @@ -10,9 +10,8 @@ #include "modules/remote_bitrate_estimator/tools/bwe_rtp.h" -#include - #include +#include #include #include #include diff --git a/modules/remote_bitrate_estimator/tools/rtp_to_text.cc b/modules/remote_bitrate_estimator/tools/rtp_to_text.cc index d2cc762b9b..43e8521f4a 100644 --- a/modules/remote_bitrate_estimator/tools/rtp_to_text.cc +++ b/modules/remote_bitrate_estimator/tools/rtp_to_text.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include +#include #include #include diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index 5b7d5f4eee..e891203d40 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -9,8 +9,10 @@ import("../../webrtc.gni") rtc_library("leb128") { - public = [ "source/leb128.h" ] - sources = [ "source/leb128.cc" ] + sources = [ + "source/leb128.cc", + "source/leb128.h", + ] } rtc_library("rtp_rtcp_format") { @@ -119,6 +121,7 @@ rtc_library("rtp_rtcp_format") { "../../api:rtp_parameters", "../../api:scoped_refptr", "../../api/audio_codecs:audio_codecs_api", + "../../api/transport:ecn_marking", "../../api/transport:network_control", "../../api/transport/rtp:corruption_detection_message", "../../api/transport/rtp:dependency_descriptor", @@ -139,7 +142,6 @@ rtc_library("rtp_rtcp_format") { "../../rtc_base:safe_compare", "../../rtc_base:safe_conversions", "../../rtc_base:stringutils", - "../../rtc_base/network:ecn_marking", "../../system_wrappers", "../video_coding:codec_globals_headers", "//third_party/abseil-cpp/absl/algorithm:container", @@ -416,15 +418,13 @@ rtc_library("ntp_time_util") { rtc_library("rtcp_transceiver") { visibility = [ "*" ] - public = [ - "source/rtcp_transceiver.h", - "source/rtcp_transceiver_config.h", - "source/rtcp_transceiver_impl.h", - ] sources = [ "source/rtcp_transceiver.cc", + "source/rtcp_transceiver.h", "source/rtcp_transceiver_config.cc", + "source/rtcp_transceiver_config.h", "source/rtcp_transceiver_impl.cc", + "source/rtcp_transceiver_impl.h", ] deps = [ ":ntp_time_util", @@ -498,7 +498,6 @@ rtc_library("fec_test_helper") { deps = [ ":rtp_rtcp", ":rtp_rtcp_format", - "../../api:rtp_headers", "../../rtc_base:checks", "../../rtc_base:copy_on_write_buffer", "../../rtc_base:random", @@ -507,7 +506,7 @@ rtc_library("fec_test_helper") { rtc_library("mock_rtp_rtcp") { testonly = true - public = [ + sources = [ "mocks/mock_network_link_rtcp_observer.h", "mocks/mock_network_state_estimator_observer.h", "mocks/mock_recovered_packet_receiver.h", @@ -689,6 +688,7 @@ if (rtc_include_tests) { "..:module_fec_api", "../../api:array_view", "../../api:create_time_controller", + "../../api:field_trials", "../../api:field_trials_registry", "../../api:field_trials_view", "../../api:frame_transformer_factory", @@ -705,10 +705,11 @@ if (rtc_include_tests) { "../../api:scoped_refptr", "../../api:time_controller", "../../api:transport_api", - "../../api/environment:environment", + "../../api/environment", "../../api/environment:environment_factory", "../../api/rtc_event_log", "../../api/task_queue", + "../../api/transport:ecn_marking", "../../api/transport:network_control", "../../api/transport/rtp:corruption_detection_message", "../../api/transport/rtp:dependency_descriptor", @@ -750,15 +751,14 @@ if (rtc_include_tests) { "../../rtc_base:task_queue_for_test", "../../rtc_base:threading", "../../rtc_base:timeutils", - "../../rtc_base/network:ecn_marking", "../../system_wrappers", "../../system_wrappers:metrics", - "../../test:explicit_key_value_config", + "../../test:create_test_field_trials", "../../test:mock_transport", "../../test:rtp_test_utils", "../../test:run_loop", "../../test:test_support", - "../../test/time_controller:time_controller", + "../../test/time_controller", "../audio_coding:audio_coding_module_typedefs", "../video_coding:codec_globals_headers", "//testing/gtest", diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.cc b/modules/rtp_rtcp/include/rtp_rtcp_defines.cc index 1e11367512..cc06d1be41 100644 --- a/modules/rtp_rtcp/include/rtp_rtcp_defines.cc +++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include - #include +#include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" diff --git a/modules/rtp_rtcp/source/active_decode_targets_helper.cc b/modules/rtp_rtcp/source/active_decode_targets_helper.cc index d158532482..c1150a571b 100644 --- a/modules/rtp_rtcp/source/active_decode_targets_helper.cc +++ b/modules/rtp_rtcp/source/active_decode_targets_helper.cc @@ -10,10 +10,9 @@ #include "modules/rtp_rtcp/source/active_decode_targets_helper.h" -#include - #include #include +#include #include "api/array_view.h" #include "rtc_base/checks.h" diff --git a/modules/rtp_rtcp/source/dtmf_queue.cc b/modules/rtp_rtcp/source/dtmf_queue.cc index 9b9b98a9dc..3f054c7177 100644 --- a/modules/rtp_rtcp/source/dtmf_queue.cc +++ b/modules/rtp_rtcp/source/dtmf_queue.cc @@ -10,7 +10,7 @@ #include "modules/rtp_rtcp/source/dtmf_queue.h" -#include +#include #include "rtc_base/checks.h" #include "rtc_base/synchronization/mutex.h" diff --git a/modules/rtp_rtcp/source/fec_test_helper.cc b/modules/rtp_rtcp/source/fec_test_helper.cc index aa07e6b293..ee7da65194 100644 --- a/modules/rtp_rtcp/source/fec_test_helper.cc +++ b/modules/rtp_rtcp/source/fec_test_helper.cc @@ -16,7 +16,6 @@ #include #include -#include "api/rtp_headers.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/forward_error_correction.h" @@ -31,8 +30,6 @@ namespace fec { namespace { -constexpr uint8_t kRtpMarkerBitMask = 0x80; - constexpr uint8_t kFecPayloadType = 96; constexpr uint8_t kRedPayloadType = 97; constexpr uint8_t kVp8PayloadType = 120; @@ -125,37 +122,23 @@ uint16_t AugmentedPacketGenerator::NextPacketSeqNum() { return ++seq_num_; } -std::unique_ptr AugmentedPacketGenerator::NextPacket( - size_t offset, - size_t length) { - std::unique_ptr packet(new AugmentedPacket()); - - packet->data.SetSize(length + kRtpHeaderSize); - uint8_t* data = packet->data.MutableData(); +void AugmentedPacketGenerator::NextPacket(size_t offset, + size_t length, + RtpPacket& packet) { + // Write Rtp Header + packet.SetMarker(num_packets_ == 1); + packet.SetPayloadType(kVp8PayloadType); + packet.SetSequenceNumber(seq_num_); + packet.SetTimestamp(timestamp_); + packet.SetSsrc(ssrc_); + + // Generate RTP payload. + uint8_t* data = packet.AllocatePayload(length); for (size_t i = 0; i < length; ++i) - data[i + kRtpHeaderSize] = offset + i; - packet->data.SetSize(length + kRtpHeaderSize); - packet->header.headerLength = kRtpHeaderSize; - packet->header.markerBit = (num_packets_ == 1); - packet->header.payloadType = kVp8PayloadType; - packet->header.sequenceNumber = seq_num_; - packet->header.timestamp = timestamp_; - packet->header.ssrc = ssrc_; - WriteRtpHeader(packet->header, data); + data[i] = offset + i; + ++seq_num_; --num_packets_; - - return packet; -} - -void AugmentedPacketGenerator::WriteRtpHeader(const RTPHeader& header, - uint8_t* data) { - data[0] = 0x80; // Version 2. - data[1] = header.payloadType; - data[1] |= (header.markerBit ? kRtpMarkerBitMask : 0); - ByteWriter::WriteBigEndian(data + 2, header.sequenceNumber); - ByteWriter::WriteBigEndian(data + 4, header.timestamp); - ByteWriter::WriteBigEndian(data + 8, header.ssrc); } FlexfecPacketGenerator::FlexfecPacketGenerator(uint32_t media_ssrc, @@ -165,48 +148,37 @@ FlexfecPacketGenerator::FlexfecPacketGenerator(uint32_t media_ssrc, flexfec_seq_num_(0), flexfec_timestamp_(0) {} -std::unique_ptr FlexfecPacketGenerator::BuildFlexfecPacket( +RtpPacketReceived FlexfecPacketGenerator::BuildFlexfecPacket( const ForwardErrorCorrection::Packet& packet) { - RTC_DCHECK_LE(packet.data.size(), - static_cast(IP_PACKET_SIZE - kRtpHeaderSize)); + RtpPacketReceived flexfec_packet; - RTPHeader header; - header.sequenceNumber = flexfec_seq_num_; + flexfec_packet.SetSequenceNumber(flexfec_seq_num_); ++flexfec_seq_num_; - header.timestamp = flexfec_timestamp_; + flexfec_packet.SetTimestamp(flexfec_timestamp_); flexfec_timestamp_ += kPacketTimestampIncrement; - header.ssrc = flexfec_ssrc_; - - std::unique_ptr packet_with_rtp_header( - new AugmentedPacket()); - packet_with_rtp_header->data.SetSize(kRtpHeaderSize + packet.data.size()); - WriteRtpHeader(header, packet_with_rtp_header->data.MutableData()); - memcpy(packet_with_rtp_header->data.MutableData() + kRtpHeaderSize, - packet.data.cdata(), packet.data.size()); + flexfec_packet.SetSsrc(flexfec_ssrc_); + flexfec_packet.SetPayload(packet.data); - return packet_with_rtp_header; + return flexfec_packet; } UlpfecPacketGenerator::UlpfecPacketGenerator(uint32_t ssrc) : AugmentedPacketGenerator(ssrc) {} RtpPacketReceived UlpfecPacketGenerator::BuildMediaRedPacket( - const AugmentedPacket& packet, + const RtpPacket& packet, bool is_recovered) { - // Create a temporary buffer used to wrap the media packet in RED. - CopyOnWriteBuffer red_buffer; - const size_t kHeaderLength = packet.header.headerLength; + RtpPacketReceived red_packet; // Append header. - red_buffer.SetData(packet.data.data(), kHeaderLength); + red_packet.CopyHeaderFrom(packet); // Find payload type and add it as RED header. - uint8_t media_payload_type = red_buffer[1] & 0x7F; - red_buffer.AppendData({media_payload_type}); + uint8_t* rtp_payload = red_packet.SetPayloadSize(1 + packet.payload_size()); + rtp_payload[0] = packet.PayloadType(); // Append rest of payload/padding. - red_buffer.AppendData( - packet.data.Slice(kHeaderLength, packet.data.size() - kHeaderLength)); + std::memcpy(rtp_payload + 1, packet.payload().data(), + packet.payload().size()); + red_packet.SetPadding(packet.padding_size()); - RtpPacketReceived red_packet; - RTC_CHECK(red_packet.Parse(std::move(red_buffer))); red_packet.SetPayloadType(kRedPayloadType); red_packet.set_recovered(is_recovered); @@ -217,11 +189,9 @@ RtpPacketReceived UlpfecPacketGenerator::BuildUlpfecRedPacket( const ForwardErrorCorrection::Packet& packet) { // Create a fake media packet to get a correct header. 1 byte RED header. ++num_packets_; - std::unique_ptr fake_packet = - NextPacket(0, packet.data.size() + 1); + RtpPacketReceived red_packet = + NextPacket(0, packet.data.size() + 1); - RtpPacketReceived red_packet; - red_packet.Parse(fake_packet->data); red_packet.SetMarker(false); uint8_t* rtp_payload = red_packet.AllocatePayload(packet.data.size() + 1); rtp_payload[0] = kFecPayloadType; diff --git a/modules/rtp_rtcp/source/fec_test_helper.h b/modules/rtp_rtcp/source/fec_test_helper.h index 8d848b66d1..8a36133961 100644 --- a/modules/rtp_rtcp/source/fec_test_helper.h +++ b/modules/rtp_rtcp/source/fec_test_helper.h @@ -13,10 +13,9 @@ #include #include -#include -#include "api/rtp_headers.h" #include "modules/rtp_rtcp/source/forward_error_correction.h" +#include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/random.h" @@ -24,10 +23,6 @@ namespace webrtc { namespace test { namespace fec { -struct AugmentedPacket : public ForwardErrorCorrection::Packet { - RTPHeader header; -}; - // TODO(brandtr): Consider merging MediaPacketGenerator and // AugmentedPacketGenerator into a single class, since their functionality is // similar. @@ -72,16 +67,20 @@ class AugmentedPacketGenerator { uint16_t NextPacketSeqNum(); // Return the next packet in the current frame. - std::unique_ptr NextPacket(size_t offset, size_t length); + template + T NextPacket(size_t offset, size_t length) { + T rtp_packet(/*extensions=*/nullptr); + NextPacket(offset, length, rtp_packet); + return rtp_packet; + } protected: - // Given `header`, writes the appropriate RTP header fields in `data`. - static void WriteRtpHeader(const RTPHeader& header, uint8_t* data); - // Number of packets left to generate, in the current frame. size_t num_packets_; private: + void NextPacket(size_t offset, size_t length, RtpPacket& packet); + uint32_t ssrc_; uint16_t seq_num_; uint32_t timestamp_; @@ -94,7 +93,7 @@ class FlexfecPacketGenerator : public AugmentedPacketGenerator { // Creates a new AugmentedPacket (with RTP headers) from a // FlexFEC packet (without RTP headers). - std::unique_ptr BuildFlexfecPacket( + RtpPacketReceived BuildFlexfecPacket( const ForwardErrorCorrection::Packet& packet); private: @@ -110,7 +109,7 @@ class UlpfecPacketGenerator : public AugmentedPacketGenerator { explicit UlpfecPacketGenerator(uint32_t ssrc); // Creates a new RtpPacket with the RED header added to the packet. - static RtpPacketReceived BuildMediaRedPacket(const AugmentedPacket& packet, + static RtpPacketReceived BuildMediaRedPacket(const RtpPacket& packet, bool is_recovered); // Creates a new RtpPacket with FEC payload and RED header. Does this by diff --git a/modules/rtp_rtcp/source/flexfec_03_header_reader_writer.cc b/modules/rtp_rtcp/source/flexfec_03_header_reader_writer.cc index 3ecbec91af..f05f926847 100644 --- a/modules/rtp_rtcp/source/flexfec_03_header_reader_writer.cc +++ b/modules/rtp_rtcp/source/flexfec_03_header_reader_writer.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/flexfec_03_header_reader_writer.h" -#include - #include +#include #include "api/array_view.h" #include "api/scoped_refptr.h" diff --git a/modules/rtp_rtcp/source/flexfec_03_header_reader_writer_unittest.cc b/modules/rtp_rtcp/source/flexfec_03_header_reader_writer_unittest.cc index 80b4ba3373..862cbdcba4 100644 --- a/modules/rtp_rtcp/source/flexfec_03_header_reader_writer_unittest.cc +++ b/modules/rtp_rtcp/source/flexfec_03_header_reader_writer_unittest.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/flexfec_03_header_reader_writer.h" -#include - #include +#include #include #include diff --git a/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc b/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc index d1e0b99d3b..d467d53203 100644 --- a/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc +++ b/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/flexfec_header_reader_writer.h" -#include - #include +#include #include "api/array_view.h" #include "api/scoped_refptr.h" diff --git a/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc b/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc index 241675abb4..baeea9ddf3 100644 --- a/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc +++ b/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/flexfec_header_reader_writer.h" -#include - #include +#include #include #include "api/array_view.h" diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc index c6465fbccf..bde365fe18 100644 --- a/modules/rtp_rtcp/source/flexfec_receiver.cc +++ b/modules/rtp_rtcp/source/flexfec_receiver.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/include/flexfec_receiver.h" -#include - #include +#include #include #include "api/scoped_refptr.h" diff --git a/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc b/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc index da200ea0f5..a34ad9e029 100644 --- a/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc @@ -95,8 +95,9 @@ void FlexfecReceiverTest::PacketizeFrame(size_t num_media_packets, PacketList* media_packets) { packet_generator_.NewFrame(num_media_packets); for (size_t i = 0; i < num_media_packets; ++i) { - std::unique_ptr next_packet( - packet_generator_.NextPacket(frame_offset + i, kPayloadLength)); + auto next_packet = std::make_unique(); + next_packet->data = + packet_generator_.NextPacket(frame_offset + i, kPayloadLength).Buffer(); media_packets->push_back(std::move(next_packet)); } } @@ -119,11 +120,11 @@ std::list FlexfecReceiverTest::EncodeFec( TEST_F(FlexfecReceiverTest, ReceivesMediaPacket) { packet_generator_.NewFrame(1); - std::unique_ptr media_packet( - packet_generator_.NextPacket(0, kPayloadLength)); + RtpPacketReceived media_packet = + packet_generator_.NextPacket(0, kPayloadLength); std::unique_ptr received_packet = - receiver_.AddReceivedPacket(ParsePacket(*media_packet)); + receiver_.AddReceivedPacket(media_packet); ASSERT_TRUE(received_packet); receiver_.ProcessReceivedPacket(*received_packet); } @@ -142,7 +143,7 @@ TEST_F(FlexfecReceiverTest, ReceivesMediaAndFecPackets) { receiver_.AddReceivedPacket(ParsePacket(*media_packet)); ASSERT_TRUE(received_packet); receiver_.ProcessReceivedPacket(*received_packet); - received_packet = receiver_.AddReceivedPacket(ParsePacket(*fec_packet)); + received_packet = receiver_.AddReceivedPacket(fec_packet); ASSERT_TRUE(received_packet); receiver_.ProcessReceivedPacket(*received_packet); } @@ -163,7 +164,7 @@ TEST_F(FlexfecReceiverTest, FailsOnTruncatedFecPacket) { receiver_.AddReceivedPacket(ParsePacket(*media_packet)); ASSERT_TRUE(received_packet); receiver_.ProcessReceivedPacket(*received_packet); - EXPECT_FALSE(receiver_.AddReceivedPacket(ParsePacket(*fec_packet))); + EXPECT_FALSE(receiver_.AddReceivedPacket(fec_packet)); } TEST_F(FlexfecReceiverTest, FailsOnUnknownMediaSsrc) { @@ -191,16 +192,13 @@ TEST_F(FlexfecReceiverTest, FailsOnUnknownFecSsrc) { const auto& media_packet = media_packets.front(); auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front()); // Corrupt the SSRC. - fec_packet->data.MutableData()[8] = 4; - fec_packet->data.MutableData()[9] = 5; - fec_packet->data.MutableData()[10] = 6; - fec_packet->data.MutableData()[11] = 7; + fec_packet.SetSsrc(0x04050607); std::unique_ptr received_packet = receiver_.AddReceivedPacket(ParsePacket(*media_packet)); ASSERT_TRUE(received_packet); receiver_.ProcessReceivedPacket(*received_packet); - EXPECT_FALSE(receiver_.AddReceivedPacket(ParsePacket(*fec_packet))); + EXPECT_FALSE(receiver_.AddReceivedPacket(fec_packet)); } TEST_F(FlexfecReceiverTest, ReceivesMultiplePackets) { @@ -221,10 +219,10 @@ TEST_F(FlexfecReceiverTest, ReceivesMultiplePackets) { // Receive FEC packet. auto* fec_packet = fec_packets.front(); - std::unique_ptr packet_with_rtp_header = + RtpPacketReceived packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(*fec_packet); std::unique_ptr received_packet = - receiver_.AddReceivedPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.AddReceivedPacket(packet_with_rtp_header); ASSERT_TRUE(received_packet); receiver_.ProcessReceivedPacket(*received_packet); } @@ -243,13 +241,13 @@ TEST_F(FlexfecReceiverTest, RecoversFromSingleMediaLoss) { // Receive FEC packet and ensure recovery of lost media packet. auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header = + RtpPacketReceived packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); media_it++; EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket( Property(&RtpPacketReceived::Buffer, Eq((*media_it)->data)))); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); } TEST_F(FlexfecReceiverTest, RecoversFromDoubleMediaLoss) { @@ -264,13 +262,13 @@ TEST_F(FlexfecReceiverTest, RecoversFromDoubleMediaLoss) { // Receive first FEC packet and recover first lost media packet. auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header = + RtpPacketReceived packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); auto media_it = media_packets.begin(); EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket( Property(&RtpPacketReceived::Buffer, Eq((*media_it)->data)))); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); // Receive second FEC packet and recover second lost media packet. fec_it++; @@ -280,7 +278,7 @@ TEST_F(FlexfecReceiverTest, RecoversFromDoubleMediaLoss) { OnRecoveredPacket( Property(&RtpPacketReceived::Buffer, Eq((*media_it)->data)))); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); } TEST_F(FlexfecReceiverTest, DoesNotRecoverFromMediaAndFecLoss) { @@ -312,16 +310,16 @@ TEST_F(FlexfecReceiverTest, DoesNotCallbackTwice) { // Receive FEC packet and ensure recovery of lost media packet. auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header = + RtpPacketReceived packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); media_it++; EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket( Property(&RtpPacketReceived::Buffer, Eq((*media_it)->data)))); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); // Receive the FEC packet again, but do not call back. - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); // Receive the first media packet again, but do not call back. media_it = media_packets.begin(); @@ -361,7 +359,7 @@ TEST_F(FlexfecReceiverTest, RecoversFrom50PercentLoss) { // Receive all FEC packets. media_it = media_packets.begin(); for (const auto* fec_packet : fec_packets) { - std::unique_ptr fec_packet_with_rtp_header = + RtpPacketReceived fec_packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(*fec_packet); ++media_it; if (media_it == media_packets.end()) { @@ -370,7 +368,7 @@ TEST_F(FlexfecReceiverTest, RecoversFrom50PercentLoss) { EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(Property(&RtpPacketReceived::Buffer, Eq((*media_it)->data)))); - receiver_.OnRtpPacket(ParsePacket(*fec_packet_with_rtp_header)); + receiver_.OnRtpPacket(fec_packet_with_rtp_header); ++media_it; } } @@ -404,13 +402,13 @@ TEST_F(FlexfecReceiverTest, DelayedFecPacketDoesHelp) { // Receive FEC packet and recover first media packet. auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header = + RtpPacketReceived packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); media_it = media_packets.begin(); EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket( Property(&RtpPacketReceived::Buffer, Eq((*media_it)->data)))); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); } TEST_F(FlexfecReceiverTest, TooDelayedFecPacketDoesNotHelp) { @@ -443,9 +441,9 @@ TEST_F(FlexfecReceiverTest, TooDelayedFecPacketDoesNotHelp) { // Receive FEC packet. auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header = + RtpPacketReceived packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); // Do not expect a call back. } @@ -490,7 +488,7 @@ TEST_F(FlexfecReceiverTest, SurvivesOldRecoveredPacketBeingReinserted) { PacketizeFrame(1, 0, &protected_media_packet); const std::list fec_packets = EncodeFec(protected_media_packet, 1); EXPECT_EQ(1u, fec_packets.size()); - std::unique_ptr fec_packet_with_rtp_header = + RtpPacketReceived fec_packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(*fec_packets.front()); // Lose some packets, thus introducing a sequence number gap. @@ -507,7 +505,7 @@ TEST_F(FlexfecReceiverTest, SurvivesOldRecoveredPacketBeingReinserted) { } // Receive delayed FEC packet. - receiver.OnRtpPacket(ParsePacket(*fec_packet_with_rtp_header)); + receiver.OnRtpPacket(fec_packet_with_rtp_header); // Expect no crash. } @@ -541,12 +539,8 @@ TEST_F(FlexfecReceiverTest, RecoversWithMediaPacketsOutOfOrder) { OnRecoveredPacket(Property(&RtpPacketReceived::Buffer, Eq((*media_packet4)->data)))); // Add FEC packets. - auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header; - while (fec_it != fec_packets.end()) { - packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); - ++fec_it; + for (Packet* fec_packet : fec_packets) { + receiver_.OnRtpPacket(packet_generator_.BuildFlexfecPacket(*fec_packet)); } } @@ -606,9 +600,7 @@ TEST_F(FlexfecReceiverTest, RecoveryCallbackDoesNotLoopInfinitely) { // Receive FEC packet and verify that a packet was recovered. auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header = - packet_generator_.BuildFlexfecPacket(**fec_it); - receiver.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver.OnRtpPacket(packet_generator_.BuildFlexfecPacket(**fec_it)); EXPECT_TRUE(loopback_recovered_packet_receiver.DidReceiveCallback()); EXPECT_FALSE(loopback_recovered_packet_receiver.DeepRecursion()); } @@ -627,13 +619,13 @@ TEST_F(FlexfecReceiverTest, CalculatesNumberOfPackets) { // Receive FEC packet and ensure recovery of lost media packet. auto fec_it = fec_packets.begin(); - std::unique_ptr packet_with_rtp_header = + RtpPacketReceived packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); media_it++; EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket( Property(&RtpPacketReceived::Buffer, Eq((*media_it)->data)))); - receiver_.OnRtpPacket(ParsePacket(*packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_with_rtp_header); // Check stats calculations. FecPacketCounter packet_counter = receiver_.GetPacketCounter(); @@ -680,9 +672,7 @@ TEST_F(FlexfecReceiverTest, DoesNotDecodeWrappedMediaSequenceUsingOldFec) { // expect no recovery callback since it is delayed from first frame // by more than 192 packets. auto fec_it = fec_packets.begin(); - std::unique_ptr fec_packet_with_rtp_header = - packet_generator_.BuildFlexfecPacket(**fec_it); - receiver_.OnRtpPacket(ParsePacket(*fec_packet_with_rtp_header)); + receiver_.OnRtpPacket(packet_generator_.BuildFlexfecPacket(**fec_it)); // Receive remaining media packets. // NOTE: Because we sent enough to simulate wrap around, sequence 0 is diff --git a/modules/rtp_rtcp/source/flexfec_sender.cc b/modules/rtp_rtcp/source/flexfec_sender.cc index 9b5ceac577..32328fb511 100644 --- a/modules/rtp_rtcp/source/flexfec_sender.cc +++ b/modules/rtp_rtcp/source/flexfec_sender.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/include/flexfec_sender.h" -#include - #include +#include #include #include #include @@ -170,9 +169,7 @@ std::vector> FlexfecSender::GetFecPackets() { } // RTP payload. - uint8_t* payload = - fec_packet_to_send->AllocatePayload(fec_packet->data.size()); - memcpy(payload, fec_packet->data.cdata(), fec_packet->data.size()); + fec_packet_to_send->SetPayload(fec_packet->data); total_fec_data_bytes += fec_packet_to_send->size(); fec_packets_to_send.push_back(std::move(fec_packet_to_send)); diff --git a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc index 9c35cc897f..905fe0d5d3 100644 --- a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc +++ b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc @@ -34,13 +34,12 @@ namespace webrtc { namespace { -using test::fec::AugmentedPacket; using test::fec::AugmentedPacketGenerator; constexpr int kFlexfecPayloadType = 123; constexpr uint32_t kMediaSsrc = 1234; constexpr uint32_t kFlexfecSsrc = 5678; -const char kNoMid[] = ""; +constexpr char kNoMid[] = ""; const std::vector kNoRtpHeaderExtensions; const std::vector kNoRtpHeaderExtensionSizes; // Assume a single protected media SSRC. @@ -74,10 +73,8 @@ std::unique_ptr GenerateSingleFlexfecPacket( AugmentedPacketGenerator packet_generator(kMediaSsrc); packet_generator.NewFrame(kNumPackets); for (size_t i = 0; i < kNumPackets; ++i) { - std::unique_ptr packet = - packet_generator.NextPacket(i, kPayloadLength); - RtpPacketToSend rtp_packet(nullptr); // No header extensions. - rtp_packet.Parse(packet->data); + RtpPacketToSend rtp_packet = + packet_generator.NextPacket(i, kPayloadLength); sender->AddPacketAndGenerateFec(rtp_packet); } std::vector> fec_packets = @@ -146,10 +143,8 @@ TEST(FlexfecSenderTest, ProtectTwoFramesWithOneFecPacket) { for (size_t i = 0; i < kNumFrames; ++i) { packet_generator.NewFrame(kNumPacketsPerFrame); for (size_t j = 0; j < kNumPacketsPerFrame; ++j) { - std::unique_ptr packet = - packet_generator.NextPacket(i, kPayloadLength); - RtpPacketToSend rtp_packet(nullptr); - rtp_packet.Parse(packet->data); + RtpPacketToSend rtp_packet = + packet_generator.NextPacket(i, kPayloadLength); sender.AddPacketAndGenerateFec(rtp_packet); } } @@ -186,10 +181,8 @@ TEST(FlexfecSenderTest, ProtectTwoFramesWithTwoFecPackets) { for (size_t i = 0; i < kNumFrames; ++i) { packet_generator.NewFrame(kNumPacketsPerFrame); for (size_t j = 0; j < kNumPacketsPerFrame; ++j) { - std::unique_ptr packet = - packet_generator.NextPacket(i, kPayloadLength); - RtpPacketToSend rtp_packet(nullptr); - rtp_packet.Parse(packet->data); + RtpPacketToSend rtp_packet = + packet_generator.NextPacket(i, kPayloadLength); sender.AddPacketAndGenerateFec(rtp_packet); } std::vector> fec_packets = diff --git a/modules/rtp_rtcp/source/forward_error_correction.cc b/modules/rtp_rtcp/source/forward_error_correction.cc index 39c098a65c..0bb81a8ef0 100644 --- a/modules/rtp_rtcp/source/forward_error_correction.cc +++ b/modules/rtp_rtcp/source/forward_error_correction.cc @@ -10,10 +10,9 @@ #include "modules/rtp_rtcp/source/forward_error_correction.h" -#include - #include #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/forward_error_correction_internal.cc b/modules/rtp_rtcp/source/forward_error_correction_internal.cc index 98aa2b3ca5..d2f3b59ec4 100644 --- a/modules/rtp_rtcp/source/forward_error_correction_internal.cc +++ b/modules/rtp_rtcp/source/forward_error_correction_internal.cc @@ -10,10 +10,9 @@ #include "modules/rtp_rtcp/source/forward_error_correction_internal.h" -#include - #include #include +#include #include "api/array_view.h" #include "modules/include/module_fec_types.h" diff --git a/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/modules/rtp_rtcp/source/nack_rtx_unittest.cc index 8f2265dc02..11a0a99f74 100644 --- a/modules/rtp_rtcp/source/nack_rtx_unittest.cc +++ b/modules/rtp_rtcp/source/nack_rtx_unittest.cc @@ -43,16 +43,16 @@ namespace webrtc { -const int kVideoNackListSize = 30; -const uint32_t kTestSsrc = 3456; -const uint32_t kTestRtxSsrc = kTestSsrc + 1; -const uint16_t kTestSequenceNumber = 2345; -const uint32_t kTestNumberOfPackets = 1350; -const int kTestNumberOfRtxPackets = 149; -const int kNumFrames = 30; -const int kPayloadType = 123; -const int kRtxPayloadType = 98; -const int64_t kMaxRttMs = 1000; +constexpr int kVideoNackListSize = 30; +constexpr uint32_t kTestSsrc = 3456; +constexpr uint32_t kTestRtxSsrc = kTestSsrc + 1; +constexpr uint16_t kTestSequenceNumber = 2345; +constexpr uint32_t kTestNumberOfPackets = 1350; +constexpr int kTestNumberOfRtxPackets = 149; +constexpr int kNumFrames = 30; +constexpr int kPayloadType = 123; +constexpr int kRtxPayloadType = 98; +constexpr int64_t kMaxRttMs = 1000; class VerifyingMediaStream : public RtpPacketSinkInterface { public: diff --git a/modules/rtp_rtcp/source/receive_statistics_unittest.cc b/modules/rtp_rtcp/source/receive_statistics_unittest.cc index 5eb552be45..b45ff3e3ec 100644 --- a/modules/rtp_rtcp/source/receive_statistics_unittest.cc +++ b/modules/rtp_rtcp/source/receive_statistics_unittest.cc @@ -31,12 +31,12 @@ namespace { using ::testing::SizeIs; using ::testing::UnorderedElementsAre; -const size_t kPacketSize1 = 100; -const size_t kPacketSize2 = 300; -const uint32_t kSsrc1 = 101; -const uint32_t kSsrc2 = 202; -const uint32_t kSsrc3 = 203; -const uint32_t kSsrc4 = 304; +constexpr size_t kPacketSize1 = 100; +constexpr size_t kPacketSize2 = 300; +constexpr uint32_t kSsrc1 = 101; +constexpr uint32_t kSsrc2 = 202; +constexpr uint32_t kSsrc3 = 203; +constexpr uint32_t kSsrc4 = 304; RtpPacketReceived CreateRtpPacket(uint32_t ssrc, size_t header_size, diff --git a/modules/rtp_rtcp/source/rtcp_packet/app.cc b/modules/rtp_rtcp/source/rtcp_packet/app.cc index f90c84ed48..3d44b831cc 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/app.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/app.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtcp_packet/app.h" -#include - #include +#include #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" diff --git a/modules/rtp_rtcp/source/rtcp_packet/bye.cc b/modules/rtp_rtcp/source/rtcp_packet/bye.cc index d4c9107217..767edbb148 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/bye.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/bye.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtcp_packet/bye.h" -#include - #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtcp_packet/bye_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/bye_unittest.cc index af47d67d0a..ff79371546 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/bye_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/bye_unittest.cc @@ -25,9 +25,9 @@ using webrtc::rtcp::Bye; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kCsrc1 = 0x22232425; -const uint32_t kCsrc2 = 0x33343536; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kCsrc1 = 0x22232425; +constexpr uint32_t kCsrc2 = 0x33343536; } // namespace TEST(RtcpPacketByeTest, CreateAndParseWithoutReason) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/compound_packet_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/compound_packet_unittest.cc index 7645c267ba..39e09c9c9f 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/compound_packet_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/compound_packet_unittest.cc @@ -40,9 +40,9 @@ using webrtc::test::RtcpPacketParser; namespace webrtc { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrc = 0x23456789; -const uint8_t kSeqNo = 13; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrc = 0x23456789; +constexpr uint8_t kSeqNo = 13; TEST(RtcpCompoundPacketTest, AppendPacket) { CompoundPacket compound; diff --git a/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.cc b/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.cc index ff37b00fa9..b4e227c1cf 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.cc @@ -17,12 +17,12 @@ #include #include "api/array_view.h" +#include "api/transport/ecn_marking.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" #include "rtc_base/checks.h" -#include "rtc_base/network/ecn_marking.h" namespace webrtc { namespace rtcp { diff --git a/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h b/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h index 137c3d1e16..9f5f56c830 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h +++ b/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h @@ -15,10 +15,10 @@ #include #include "api/array_view.h" +#include "api/transport/ecn_marking.h" #include "api/units/time_delta.h" #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" #include "modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" -#include "rtc_base/network/ecn_marking.h" namespace webrtc { namespace rtcp { diff --git a/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback_unittest.cc index 55e4aae926..dc074f18ed 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback_unittest.cc @@ -17,12 +17,12 @@ #include "api/array_view.h" #include "api/function_view.h" +#include "api/transport/ecn_marking.h" #include "api/units/time_delta.h" #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" #include "modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" #include "rtc_base/buffer.h" #include "rtc_base/logging.h" -#include "rtc_base/network/ecn_marking.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/modules/rtp_rtcp/source/rtcp_packet/dlrr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/dlrr_unittest.cc index 751df2d2cc..7298e52817 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/dlrr_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/dlrr_unittest.cc @@ -22,12 +22,12 @@ using webrtc::rtcp::ReceiveTimeInfo; namespace webrtc { namespace { -const uint32_t kSsrc = 0x12345678; -const uint32_t kLastRR = 0x23344556; -const uint32_t kDelay = 0x33343536; -const uint8_t kBlock[] = {0x05, 0x00, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78, - 0x23, 0x34, 0x45, 0x56, 0x33, 0x34, 0x35, 0x36}; -const size_t kBlockSizeBytes = sizeof(kBlock); +constexpr uint32_t kSsrc = 0x12345678; +constexpr uint32_t kLastRR = 0x23344556; +constexpr uint32_t kDelay = 0x33343536; +constexpr uint8_t kBlock[] = {0x05, 0x00, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78, + 0x23, 0x34, 0x45, 0x56, 0x33, 0x34, 0x35, 0x36}; +constexpr size_t kBlockSizeBytes = sizeof(kBlock); } // namespace TEST(RtcpPacketDlrrTest, Empty) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc index 64d799e78a..fe737a91bd 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc @@ -23,11 +23,11 @@ using webrtc::rtcp::Pli; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrc = 0x23456789; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrc = 0x23456789; // Manually created Pli packet matching constants above. -const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, 0x12, 0x34, - 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; +constexpr uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; } // namespace TEST(RtcpPacketPliTest, Parse) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc index 450b7cd075..45b75e6180 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc @@ -23,11 +23,11 @@ using webrtc::rtcp::RapidResyncRequest; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrc = 0x23456789; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrc = 0x23456789; // Manually created packet matching constants above. -const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, 0x12, 0x34, - 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; +constexpr uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; } // namespace TEST(RtcpPacketRapidResyncRequestTest, Parse) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/receiver_report_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/receiver_report_unittest.cc index 98ff4d2989..916dfcd454 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/receiver_report_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/receiver_report_unittest.cc @@ -29,21 +29,21 @@ using webrtc::rtcp::ReportBlock; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrc = 0x23456789; -const uint8_t kFractionLost = 55; -const int32_t kCumulativeLost = 0x111213; -const uint32_t kExtHighestSeqNum = 0x22232425; -const uint32_t kJitter = 0x33343536; -const uint32_t kLastSr = 0x44454647; -const uint32_t kDelayLastSr = 0x55565758; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrc = 0x23456789; +constexpr uint8_t kFractionLost = 55; +constexpr int32_t kCumulativeLost = 0x111213; +constexpr uint32_t kExtHighestSeqNum = 0x22232425; +constexpr uint32_t kJitter = 0x33343536; +constexpr uint32_t kLastSr = 0x44454647; +constexpr uint32_t kDelayLastSr = 0x55565758; // Manually created ReceiverReport with one ReportBlock matching constants // above. // Having this block allows to test Create and Parse separately. -const uint8_t kPacket[] = {0x81, 201, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78, - 0x23, 0x45, 0x67, 0x89, 55, 0x11, 0x12, 0x13, - 0x22, 0x23, 0x24, 0x25, 0x33, 0x34, 0x35, 0x36, - 0x44, 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58}; +constexpr uint8_t kPacket[] = {0x81, 201, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78, + 0x23, 0x45, 0x67, 0x89, 55, 0x11, 0x12, 0x13, + 0x22, 0x23, 0x24, 0x25, 0x33, 0x34, 0x35, 0x36, + 0x44, 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58}; } // namespace TEST(RtcpPacketReceiverReportTest, ParseWithOneReportBlock) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/remb_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/remb_unittest.cc index 34fe54cceb..bc3fa0cd2d 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/remb_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/remb_unittest.cc @@ -28,15 +28,15 @@ using webrtc::rtcp::Remb; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrcs[] = {0x23456789, 0x2345678a, 0x2345678b}; -const uint32_t kBitrateBps = 0x3fb93 * 2; // 522022; -const int64_t kBitrateBps64bit = int64_t{0x3fb93} << 30; -const uint8_t kPacket[] = {0x8f, 206, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78, - 0x00, 0x00, 0x00, 0x00, 'R', 'E', 'M', 'B', - 0x03, 0x07, 0xfb, 0x93, 0x23, 0x45, 0x67, 0x89, - 0x23, 0x45, 0x67, 0x8a, 0x23, 0x45, 0x67, 0x8b}; -const size_t kPacketLength = sizeof(kPacket); +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrcs[] = {0x23456789, 0x2345678a, 0x2345678b}; +constexpr uint32_t kBitrateBps = 0x3fb93 * 2; // 522022; +constexpr int64_t kBitrateBps64bit = int64_t{0x3fb93} << 30; +constexpr uint8_t kPacket[] = {0x8f, 206, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78, + 0x00, 0x00, 0x00, 0x00, 'R', 'E', 'M', 'B', + 0x03, 0x07, 0xfb, 0x93, 0x23, 0x45, 0x67, 0x89, + 0x23, 0x45, 0x67, 0x8a, 0x23, 0x45, 0x67, 0x8b}; +constexpr size_t kPacketLength = sizeof(kPacket); } // namespace TEST(RtcpPacketRembTest, Create) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/report_block_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/report_block_unittest.cc index 68399f0c0c..a7fa06d230 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/report_block_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/report_block_unittest.cc @@ -22,15 +22,15 @@ using webrtc::rtcp::ReportBlock; namespace webrtc { namespace { -const uint32_t kRemoteSsrc = 0x23456789; -const uint8_t kFractionLost = 55; +constexpr uint32_t kRemoteSsrc = 0x23456789; +constexpr uint8_t kFractionLost = 55; // Use values that are streamed differently LE and BE. -const int32_t kCumulativeLost = 0x111213; -const uint32_t kExtHighestSeqNum = 0x22232425; -const uint32_t kJitter = 0x33343536; -const uint32_t kLastSr = 0x44454647; -const uint32_t kDelayLastSr = 0x55565758; -const size_t kBufferLength = ReportBlock::kLength; +constexpr int32_t kCumulativeLost = 0x111213; +constexpr uint32_t kExtHighestSeqNum = 0x22232425; +constexpr uint32_t kJitter = 0x33343536; +constexpr uint32_t kLastSr = 0x44454647; +constexpr uint32_t kDelayLastSr = 0x55565758; +constexpr size_t kBufferLength = ReportBlock::kLength; TEST(RtcpPacketReportBlockTest, ParseChecksLength) { uint8_t buffer[kBufferLength]; diff --git a/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc index ce8640c408..0e710898f4 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc @@ -22,11 +22,11 @@ using webrtc::rtcp::Rrtr; namespace webrtc { namespace { -const uint32_t kNtpSec = 0x12345678; -const uint32_t kNtpFrac = 0x23456789; -const uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02, 0x12, 0x34, - 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; -const size_t kBlockSizeBytes = sizeof(kBlock); +constexpr uint32_t kNtpSec = 0x12345678; +constexpr uint32_t kNtpFrac = 0x23456789; +constexpr uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02, 0x12, 0x34, + 0x56, 0x78, 0x23, 0x45, 0x67, 0x89}; +constexpr size_t kBlockSizeBytes = sizeof(kBlock); static_assert( kBlockSizeBytes == Rrtr::kLength, "Size of manually created Rrtr block should match class constant"); diff --git a/modules/rtp_rtcp/source/rtcp_packet/sdes.cc b/modules/rtp_rtcp/source/rtcp_packet/sdes.cc index d58ff62f51..2d28e51584 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/sdes.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/sdes.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtcp_packet/sdes.h" -#include - #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc index df1a7b441d..c20155f7d3 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc @@ -23,12 +23,12 @@ using webrtc::rtcp::Sdes; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint8_t kPadding = 0; -const uint8_t kTerminatorTag = 0; -const uint8_t kCnameTag = 1; -const uint8_t kNameTag = 2; -const uint8_t kEmailTag = 3; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint8_t kPadding = 0; +constexpr uint8_t kTerminatorTag = 0; +constexpr uint8_t kCnameTag = 1; +constexpr uint8_t kNameTag = 2; +constexpr uint8_t kEmailTag = 3; } // namespace TEST(RtcpPacketSdesTest, CreateAndParseWithoutChunks) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc index f7d2478220..9ffe6c7476 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc @@ -29,16 +29,16 @@ using webrtc::rtcp::SenderReport; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrc = 0x23456789; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrc = 0x23456789; const NtpTime kNtp(0x11121418, 0x22242628); -const uint32_t kRtpTimestamp = 0x33343536; -const uint32_t kPacketCount = 0x44454647; -const uint32_t kOctetCount = 0x55565758; -const uint8_t kPacket[] = {0x80, 200, 0x00, 0x06, 0x12, 0x34, 0x56, - 0x78, 0x11, 0x12, 0x14, 0x18, 0x22, 0x24, - 0x26, 0x28, 0x33, 0x34, 0x35, 0x36, 0x44, - 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58}; +constexpr uint32_t kRtpTimestamp = 0x33343536; +constexpr uint32_t kPacketCount = 0x44454647; +constexpr uint32_t kOctetCount = 0x55565758; +constexpr uint8_t kPacket[] = {0x80, 200, 0x00, 0x06, 0x12, 0x34, 0x56, + 0x78, 0x11, 0x12, 0x14, 0x18, 0x22, 0x24, + 0x26, 0x28, 0x33, 0x34, 0x35, 0x36, 0x44, + 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58}; } // namespace TEST(RtcpPacketSenderReportTest, CreateWithoutReportBlocks) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc index dcaa85ed69..1e467f94fb 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc @@ -29,13 +29,14 @@ using test::ParseSinglePacket; constexpr uint32_t kSsrc = 0x12345678; // clang-format off -const uint8_t kPacket[] = { TargetBitrate::kBlockType, // Block ID. - 0x00, // Reserved. - 0x00, 0x04, // Length = 4 words. - 0x00, 0x01, 0x02, 0x03, // S0T0 0x010203 kbps. - 0x01, 0x02, 0x03, 0x04, // S0T1 0x020304 kbps. - 0x10, 0x03, 0x04, 0x05, // S1T0 0x030405 kbps. - 0x11, 0x04, 0x05, 0x06 }; // S1T1 0x040506 kbps. +constexpr uint8_t kPacket[] = { + TargetBitrate::kBlockType, // Block ID. + 0x00, // Reserved. + 0x00, 0x04, // Length = 4 words. + 0x00, 0x01, 0x02, 0x03, // S0T0 0x010203 kbps. + 0x01, 0x02, 0x03, 0x04, // S0T1 0x020304 kbps. + 0x10, 0x03, 0x04, 0x05, // S1T0 0x030405 kbps. + 0x11, 0x04, 0x05, 0x06 }; // S1T1 0x040506 kbps. constexpr size_t kPacketLengthBlocks = ((sizeof(kPacket) + 3) / 4) - 1; // clang-format on diff --git a/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc index ce1544c263..00ea2d6693 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc @@ -26,13 +26,13 @@ using webrtc::rtcp::Tmmbn; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrc = 0x23456789; -const uint32_t kBitrateBps = 312000; -const uint16_t kOverhead = 0x1fe; -const uint8_t kPacket[] = {0x84, 205, 0x00, 0x04, 0x12, 0x34, 0x56, - 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, - 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe}; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrc = 0x23456789; +constexpr uint32_t kBitrateBps = 312000; +constexpr uint16_t kOverhead = 0x1fe; +constexpr uint8_t kPacket[] = {0x84, 205, 0x00, 0x04, 0x12, 0x34, 0x56, + 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, + 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe}; } // namespace TEST(RtcpPacketTmmbnTest, Create) { diff --git a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc index 4f45577e86..ecdd95907d 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc @@ -25,13 +25,13 @@ using webrtc::rtcp::Tmmbr; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345678; -const uint32_t kRemoteSsrc = 0x23456789; -const uint32_t kBitrateBps = 312000; -const uint16_t kOverhead = 0x1fe; -const uint8_t kPacket[] = {0x83, 205, 0x00, 0x04, 0x12, 0x34, 0x56, - 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, - 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe}; +constexpr uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kRemoteSsrc = 0x23456789; +constexpr uint32_t kBitrateBps = 312000; +constexpr uint16_t kOverhead = 0x1fe; +constexpr uint8_t kPacket[] = {0x83, 205, 0x00, 0x04, 0x12, 0x34, 0x56, + 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, + 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe}; } // namespace TEST(RtcpPacketTmmbrTest, Create) { diff --git a/modules/rtp_rtcp/source/rtcp_packet_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet_unittest.cc index 2a87759629..793535f0e4 100644 --- a/modules/rtp_rtcp/source/rtcp_packet_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet_unittest.cc @@ -26,7 +26,7 @@ using ::testing::MockFunction; using ::webrtc::rtcp::ReceiverReport; using ::webrtc::rtcp::ReportBlock; -const uint32_t kSenderSsrc = 0x12345678; +constexpr uint32_t kSenderSsrc = 0x12345678; TEST(RtcpPacketTest, BuildWithTooSmallBuffer) { ReportBlock rb; diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc index cf9975e764..d58823b4de 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -10,11 +10,10 @@ #include "modules/rtp_rtcp/source/rtcp_receiver.h" -#include - #include #include #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index d9a777d6de..44074b1ba1 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -59,7 +59,7 @@ #include "rtc_base/random.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/ntp_time.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" @@ -67,7 +67,6 @@ namespace webrtc { namespace { using rtcp::ReceiveTimeInfo; -using test::ExplicitKeyValueConfig; using ::testing::_; using ::testing::AllOf; using ::testing::ElementsAre; @@ -185,11 +184,9 @@ struct ReceiverMocks { }; RTCPReceiver Create(ReceiverMocks& mocks) { - return RTCPReceiver( - CreateEnvironment( - &mocks.clock, - std::make_unique(mocks.field_trials)), - mocks.config, &mocks.rtp_rtcp_impl); + return RTCPReceiver(CreateEnvironment(&mocks.clock, CreateTestFieldTrialsPtr( + mocks.field_trials)), + mocks.config, &mocks.rtp_rtcp_impl); } TEST(RtcpReceiverTest, BrokenPacketIsIgnored) { diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc index e06698e0db..403890209e 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/modules/rtp_rtcp/source/rtcp_sender.cc @@ -10,10 +10,9 @@ #include "modules/rtp_rtcp/source/rtcp_sender.h" -#include // memcpy - -#include // std::min +#include #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtp_format_h264.cc b/modules/rtp_rtcp/source/rtp_format_h264.cc index fd501a2f28..b779859203 100644 --- a/modules/rtp_rtcp/source/rtp_format_h264.cc +++ b/modules/rtp_rtcp/source/rtp_format_h264.cc @@ -10,10 +10,9 @@ #include "modules/rtp_rtcp/source/rtp_format_h264.h" -#include - #include #include +#include #include #include "absl/algorithm/container.h" @@ -231,9 +230,7 @@ bool RtpPacketizerH264::NextPacket(RtpPacketToSend* rtp_packet) { PacketUnit packet = packets_.front(); if (packet.first_fragment && packet.last_fragment) { // Single NAL unit packet. - size_t bytes_to_send = packet.source_fragment.size(); - uint8_t* buffer = rtp_packet->AllocatePayload(bytes_to_send); - memcpy(buffer, packet.source_fragment.data(), bytes_to_send); + rtp_packet->SetPayload(packet.source_fragment); packets_.pop(); input_fragments_.pop_front(); } else if (packet.aggregated) { diff --git a/modules/rtp_rtcp/source/rtp_format_video_generic.cc b/modules/rtp_rtcp/source/rtp_format_video_generic.cc index db64feb467..53c549efd1 100644 --- a/modules/rtp_rtcp/source/rtp_format_video_generic.cc +++ b/modules/rtp_rtcp/source/rtp_format_video_generic.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_format_video_generic.h" -#include - #include +#include #include #include "api/array_view.h" diff --git a/modules/rtp_rtcp/source/rtp_format_vp8.cc b/modules/rtp_rtcp/source/rtp_format_vp8.cc index 5550f48471..717d7463c4 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp8.cc +++ b/modules/rtp_rtcp/source/rtp_format_vp8.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_format_vp8.h" -#include -#include // memcpy - +#include +#include #include #include "api/array_view.h" diff --git a/modules/rtp_rtcp/source/rtp_format_vp9.cc b/modules/rtp_rtcp/source/rtp_format_vp9.cc index 4e8237e30f..661065cde1 100644 --- a/modules/rtp_rtcp/source/rtp_format_vp9.cc +++ b/modules/rtp_rtcp/source/rtp_format_vp9.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_format_vp9.h" -#include - #include +#include #include "api/array_view.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.cc b/modules/rtp_rtcp/source/rtp_header_extensions.cc index 3f9a852e18..2c31b17568 100644 --- a/modules/rtp_rtcp/source/rtp_header_extensions.cc +++ b/modules/rtp_rtcp/source/rtp_header_extensions.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtp_packet.cc b/modules/rtp_rtcp/source/rtp_packet.cc index fe9d3a7d95..66147a2ef0 100644 --- a/modules/rtp_rtcp/source/rtp_packet.cc +++ b/modules/rtp_rtcp/source/rtp_packet.cc @@ -402,6 +402,10 @@ uint8_t* RtpPacket::AllocatePayload(size_t size_bytes) { return SetPayloadSize(size_bytes); } +void RtpPacket::SetPayload(ArrayView payload) { + memcpy(AllocatePayload(payload.size()), payload.data(), payload.size()); +} + uint8_t* RtpPacket::SetPayloadSize(size_t size_bytes) { RTC_DCHECK_EQ(padding_size_, 0); payload_size_ = size_bytes; diff --git a/modules/rtp_rtcp/source/rtp_packet.h b/modules/rtp_rtcp/source/rtp_packet.h index 9f98d5bf99..3d27520b10 100644 --- a/modules/rtp_rtcp/source/rtp_packet.h +++ b/modules/rtp_rtcp/source/rtp_packet.h @@ -165,6 +165,9 @@ class RtpPacket { // Same as SetPayloadSize but doesn't guarantee to keep current payload. uint8_t* AllocatePayload(size_t size_bytes); + // Sets payload size to `payload.size()` and copies `payload`. + void SetPayload(ArrayView payload); + bool SetPadding(size_t padding_size); // Returns debug string of RTP packet (without detailed extension info). diff --git a/modules/rtp_rtcp/source/rtp_packet_received.cc b/modules/rtp_rtcp/source/rtp_packet_received.cc index f56c31a9fe..22b1c510fb 100644 --- a/modules/rtp_rtcp/source/rtp_packet_received.cc +++ b/modules/rtp_rtcp/source/rtp_packet_received.cc @@ -10,8 +10,7 @@ #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include - +#include #include #include diff --git a/modules/rtp_rtcp/source/rtp_packet_received.h b/modules/rtp_rtcp/source/rtp_packet_received.h index f4e2a98dbe..77ed8c74c2 100644 --- a/modules/rtp_rtcp/source/rtp_packet_received.h +++ b/modules/rtp_rtcp/source/rtp_packet_received.h @@ -17,9 +17,9 @@ #include "api/ref_counted_base.h" #include "api/rtp_headers.h" #include "api/scoped_refptr.h" +#include "api/transport/ecn_marking.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/rtp_packet.h" -#include "rtc_base/network/ecn_marking.h" namespace webrtc { // Class to hold rtp packet with metadata for receiver side. diff --git a/modules/rtp_rtcp/source/rtp_packet_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_unittest.cc index 80fe006c01..ab5cc141cc 100644 --- a/modules/rtp_rtcp/source/rtp_packet_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_unittest.cc @@ -435,6 +435,14 @@ TEST(RtpPacketTest, SetReservedExtensionsAfterPayload) { EXPECT_TRUE(packet.SetExtension(kTimeOffset)); } +TEST(RtpPacketTest, SetPayload) { + const uint8_t payload[] = {1, 2, 3, 4, 2, 0, 42}; + RtpPacket packet; + packet.SetPayload(payload); + + EXPECT_THAT(packet.payload(), ElementsAreArray(payload)); +} + TEST(RtpPacketTest, CreatePurePadding) { const size_t kPaddingSize = kMaxPaddingSize - 1; RtpPacketToSend packet(nullptr, 12 + kPaddingSize); diff --git a/modules/rtp_rtcp/source/rtp_packetizer_av1.cc b/modules/rtp_rtcp/source/rtp_packetizer_av1.cc index e5293a90e2..e96460e53b 100644 --- a/modules/rtp_rtcp/source/rtp_packetizer_av1.cc +++ b/modules/rtp_rtcp/source/rtp_packetizer_av1.cc @@ -9,10 +9,9 @@ */ #include "modules/rtp_rtcp/source/rtp_packetizer_av1.h" -#include -#include - #include +#include +#include #include #include diff --git a/modules/rtp_rtcp/source/rtp_packetizer_av1_test_helper.cc b/modules/rtp_rtcp/source/rtp_packetizer_av1_test_helper.cc index 1e38352950..80bf92fdaf 100644 --- a/modules/rtp_rtcp/source/rtp_packetizer_av1_test_helper.cc +++ b/modules/rtp_rtcp/source/rtp_packetizer_av1_test_helper.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_packetizer_av1_test_helper.h" -#include -#include - +#include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtp_packetizer_av1_unittest.cc b/modules/rtp_rtcp/source/rtp_packetizer_av1_unittest.cc index bb46fcdf33..a7e65134d6 100644 --- a/modules/rtp_rtcp/source/rtp_packetizer_av1_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packetizer_av1_unittest.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_packetizer_av1.h" -#include -#include - +#include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtp_packetizer_h265.cc b/modules/rtp_rtcp/source/rtp_packetizer_h265.cc index 0ae271c801..f404886ae0 100644 --- a/modules/rtp_rtcp/source/rtp_packetizer_h265.cc +++ b/modules/rtp_rtcp/source/rtp_packetizer_h265.cc @@ -210,9 +210,7 @@ bool RtpPacketizerH265::NextPacket(RtpPacketToSend* rtp_packet) { if (packet.first_fragment && packet.last_fragment) { // Single NAL unit packet. Do not support DONL for single NAL unit packets, // DONL field is not present. - size_t bytes_to_send = packet.source_fragment.size(); - uint8_t* buffer = rtp_packet->AllocatePayload(bytes_to_send); - memcpy(buffer, packet.source_fragment.data(), bytes_to_send); + rtp_packet->SetPayload(packet.source_fragment); packets_.pop(); input_fragments_.pop_front(); } else if (packet.aggregated) { diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index bc9ccfcebe..5750a7038a 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_rtcp_impl.h" -#include - #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc index f9952a04b0..3e90e257b6 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" -#include - #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc index 664b795ae6..0698b34f58 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include "api/rtp_headers.h" #include "api/rtp_parameters.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 "api/video/video_codec_type.h" @@ -106,22 +106,19 @@ class RtcpRttStatsTestImpl : public RtcpRttStats { int64_t rtt_ms_; }; -// TODO(bugs.webrtc.org/11581): remove inheritance once the ModuleRtpRtcpImpl2 -// Module/ProcessThread dependency is gone. -class SendTransport : public Transport, - public sim_time_impl::SimulatedSequenceRunner { +class SendTransport : public Transport { public: - SendTransport(TimeDelta delay, GlobalSimulatedTimeController* time_controller) + SendTransport(TimeDelta delay, TaskQueueFactory& task_queue_factory) : receiver_(nullptr), - time_controller_(time_controller), delay_(delay), rtp_packets_sent_(0), rtcp_packets_sent_(0), - last_packet_(&header_extensions_) { - time_controller_->Register(this); - } + last_packet_(&header_extensions_), + rtcp_packets_(task_queue_factory.CreateTaskQueue( + "transport", + TaskQueueFactory::Priority::NORMAL)) {} - ~SendTransport() override { time_controller_->Unregister(this); } + ~SendTransport() override = default; void SetRtpRtcpModule(ModuleRtpRtcpImpl2* receiver) { receiver_ = receiver; } void SimulateNetworkDelay(TimeDelta delay) { delay_ = delay; } @@ -136,49 +133,33 @@ class SendTransport : public Transport, test::RtcpPacketParser parser; parser.Parse(data); last_nack_list_ = parser.nack()->packet_ids(); - Timestamp current_time = time_controller_->GetClock()->CurrentTime(); - Timestamp delivery_time = current_time + delay_; - rtcp_packets_.push_back( - Packet{delivery_time, std::vector(data.begin(), data.end())}); - ++rtcp_packets_sent_; - RunReady(current_time); - return true; - } - // sim_time_impl::SimulatedSequenceRunner - Timestamp GetNextRunTime() const override { - if (!rtcp_packets_.empty()) - return rtcp_packets_.front().send_time; - return Timestamp::PlusInfinity(); - } - void RunReady(Timestamp at_time) override { - while (!rtcp_packets_.empty() && - rtcp_packets_.front().send_time <= at_time) { - Packet packet = std::move(rtcp_packets_.front()); - rtcp_packets_.pop_front(); - EXPECT_TRUE(receiver_); - receiver_->IncomingRtcpPacket(packet.data); + if (delay_ == TimeDelta::Zero()) { + receiver_->IncomingRtcpPacket(data); + } else { + ModuleRtpRtcpImpl2* receiver = receiver_; + std::vector packet(data.begin(), data.end()); + rtcp_packets_->PostDelayedTask( + [receiver, packet = std::move(packet)] { + receiver->IncomingRtcpPacket(packet); + }, + delay_); } - } - TaskQueueBase* GetAsTaskQueue() override { - return reinterpret_cast(this); + + ++rtcp_packets_sent_; + return true; } size_t NumRtcpSent() { return rtcp_packets_sent_; } ModuleRtpRtcpImpl2* receiver_; - GlobalSimulatedTimeController* const time_controller_; TimeDelta delay_; int rtp_packets_sent_; size_t rtcp_packets_sent_; std::vector last_nack_list_; RtpHeaderExtensionMap header_extensions_; RtpPacketReceived last_packet_; - struct Packet { - Timestamp send_time; - std::vector data; - }; - std::deque rtcp_packets_; + std::unique_ptr rtcp_packets_; }; class RtpRtcpModule : public RtcpPacketTypeCounterObserver, @@ -193,13 +174,11 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver, uint32_t ssrc; }; - RtpRtcpModule(const Environment& env, - GlobalSimulatedTimeController* time_controller, - bool is_sender) + RtpRtcpModule(const Environment& env, bool is_sender) : env_(env), is_sender_(is_sender), receive_statistics_(ReceiveStatistics::Create(&env.clock())), - transport_(kOneWayNetworkDelay, time_controller) { + transport_(kOneWayNetworkDelay, env_.task_queue_factory()) { CreateModuleImpl(); } @@ -304,12 +283,8 @@ class RtpRtcpImpl2Test : public ::testing::Test { : time_controller_(Timestamp::Micros(133590000000000)), env_(CreateEnvironment(time_controller_.GetClock(), time_controller_.CreateTaskQueueFactory())), - sender_(env_, - &time_controller_, - /*is_sender=*/true), - receiver_(env_, - &time_controller_, - /*is_sender=*/false) {} + sender_(env_, /*is_sender=*/true), + receiver_(env_, /*is_sender=*/false) {} void SetUp() override { // Send module. diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc index 153bc6ce3a..24c10114ec 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc @@ -21,6 +21,7 @@ #include "api/call/transport.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/rtp_headers.h" #include "api/units/time_delta.h" #include "api/video/video_codec_type.h" @@ -40,7 +41,7 @@ #include "modules/video_coding/codecs/vp8/include/vp8_globals.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/ntp_time.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/rtcp_packet_parser.h" @@ -54,15 +55,15 @@ using ::testing::Optional; namespace webrtc { namespace { -const uint32_t kSenderSsrc = 0x12345; -const uint32_t kReceiverSsrc = 0x23456; +constexpr uint32_t kSenderSsrc = 0x12345; +constexpr uint32_t kReceiverSsrc = 0x23456; constexpr TimeDelta kOneWayNetworkDelay = TimeDelta::Millis(100); -const uint8_t kBaseLayerTid = 0; -const uint8_t kHigherLayerTid = 1; -const uint16_t kSequenceNumber = 100; -const uint8_t kPayloadType = 100; -const int kWidth = 320; -const int kHeight = 100; +constexpr uint8_t kBaseLayerTid = 0; +constexpr uint8_t kHigherLayerTid = 1; +constexpr uint16_t kSequenceNumber = 100; +constexpr uint8_t kPayloadType = 100; +constexpr int kWidth = 320; +constexpr int kHeight = 100; MATCHER_P2(Near, value, margin, "") { return value - margin <= arg && arg <= value + margin; @@ -210,7 +211,7 @@ class RtpRtcpImplTest : public ::testing::Test { sender_.impl_->SetSequenceNumber(kSequenceNumber); sender_.impl_->SetStorePacketsStatus(true, 100); - test::ExplicitKeyValueConfig field_trials(""); + FieldTrials field_trials = CreateTestFieldTrials(); RTPSenderVideo::Config video_config; video_config.clock = &clock_; video_config.rtp_sender = sender_.impl_->RtpSender(); diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.cc b/modules/rtp_rtcp/source/rtp_sender_audio.cc index e6406a35a0..2b829a4efe 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_sender_audio.h" -#include - #include +#include #include #include #include @@ -256,9 +255,7 @@ bool RTPSenderAudio::SendAudio(const RtpAudioFrame& frame) { packet->SetExtension(*absolute_capture_time); } - uint8_t* payload = packet->AllocatePayload(frame.payload.size()); - RTC_CHECK(payload); - memcpy(payload, frame.payload.data(), frame.payload.size()); + packet->SetPayload(frame.payload); { MutexLock lock(&send_audio_mutex_); diff --git a/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc index 2cb508497f..7cc4e1ebf1 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc @@ -39,9 +39,9 @@ enum : int { // The first valid value is 1. kAbsoluteCaptureTimeExtensionId = 2, }; -const uint16_t kSeqNum = 33; -const uint32_t kSsrc = 725242; -const uint64_t kStartTime = 123456789; +constexpr uint16_t kSeqNum = 33; +constexpr uint32_t kSsrc = 725242; +constexpr uint64_t kStartTime = 123456789; using ::testing::ElementsAreArray; diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index 2607c58391..3049de6181 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -60,15 +60,15 @@ enum : int { // The first valid value is 1. kVideoTimingExtensionId, }; -const int kPayload = 100; -const int kRtxPayload = 98; -const uint32_t kTimestamp = 10; -const uint16_t kSeqNum = 33; -const uint32_t kSsrc = 725242; -const uint32_t kRtxSsrc = 12345; -const uint32_t kFlexFecSsrc = 45678; -const uint64_t kStartTime = 123456789; -const uint8_t kPayloadData[] = {47, 11, 32, 93, 89}; +constexpr int kPayload = 100; +constexpr int kRtxPayload = 98; +constexpr uint32_t kTimestamp = 10; +constexpr uint16_t kSeqNum = 33; +constexpr uint32_t kSsrc = 725242; +constexpr uint32_t kRtxSsrc = 12345; +constexpr uint32_t kFlexFecSsrc = 45678; +constexpr uint64_t kStartTime = 123456789; +constexpr uint8_t kPayloadData[] = {47, 11, 32, 93, 89}; constexpr TimeDelta kDefaultExpectedRetransmissionTime = TimeDelta::Millis(125); constexpr Frequency kRtpClockRate = Frequency::Hertz(90'000); constexpr absl::string_view kMid = "mid"; diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc index 8503b0db75..82e8b16791 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -10,10 +10,9 @@ #include "modules/rtp_rtcp/source/rtp_sender_video.h" -#include -#include - #include +#include +#include #include #include #include @@ -22,7 +21,6 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" -#include "absl/strings/match.h" #include "api/array_view.h" #include "api/crypto/frame_encryptor_interface.h" #include "api/field_trials_view.h" @@ -179,9 +177,8 @@ RTPSenderVideo::RTPSenderVideo(const Config& config) post_encode_overhead_bitrate_(/*max_window_size=*/TimeDelta::Seconds(1)), frame_encryptor_(config.frame_encryptor), require_frame_encryption_(config.require_frame_encryption), - generic_descriptor_auth_experiment_(!absl::StartsWith( - config.field_trials->Lookup("WebRTC-GenericDescriptorAuth"), - "Disabled")), + generic_descriptor_auth_experiment_( + !config.field_trials->IsDisabled("WebRTC-GenericDescriptorAuth")), absolute_capture_time_sender_(config.clock), frame_transformer_delegate_( config.frame_transformer diff --git a/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc b/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc index 57e0925a2f..d50902023a 100644 --- a/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc +++ b/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.h" -#include -#include - +#include +#include #include #include "absl/algorithm/container.h" diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc index 92860b1acf..18a0f67cf3 100644 --- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc @@ -54,8 +54,8 @@ using ::testing::NotNull; using ::testing::Return; using ::testing::SaveArg; -const int kFirstSeqNum = 1; -const int kLastSeqNum = 2; +constexpr int kFirstSeqNum = 1; +constexpr int kLastSeqNum = 2; std::unique_ptr CreateRtpFrameObject( const RTPVideoHeader& video_header, diff --git a/modules/rtp_rtcp/source/tmmbr_help.cc b/modules/rtp_rtcp/source/tmmbr_help.cc index 0eb7d602c7..9c0d41046e 100644 --- a/modules/rtp_rtcp/source/tmmbr_help.cc +++ b/modules/rtp_rtcp/source/tmmbr_help.cc @@ -10,8 +10,7 @@ #include "modules/rtp_rtcp/source/tmmbr_help.h" -#include - +#include #include #include #include diff --git a/modules/rtp_rtcp/source/ulpfec_generator.cc b/modules/rtp_rtcp/source/ulpfec_generator.cc index a29aeb5352..56c8ee38bc 100644 --- a/modules/rtp_rtcp/source/ulpfec_generator.cc +++ b/modules/rtp_rtcp/source/ulpfec_generator.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/ulpfec_generator.h" -#include - #include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/ulpfec_generator_unittest.cc b/modules/rtp_rtcp/source/ulpfec_generator_unittest.cc index 69ad59de23..ddcba4f95a 100644 --- a/modules/rtp_rtcp/source/ulpfec_generator_unittest.cc +++ b/modules/rtp_rtcp/source/ulpfec_generator_unittest.cc @@ -29,7 +29,6 @@ namespace webrtc { namespace { -using test::fec::AugmentedPacket; using test::fec::AugmentedPacketGenerator; constexpr int kFecPayloadType = 96; @@ -122,12 +121,10 @@ TEST_F(UlpfecGeneratorTest, OneFrameFec) { ulpfec_generator_.SetProtectionParameters(params, params); uint32_t last_timestamp = 0; for (size_t i = 0; i < kNumPackets; ++i) { - std::unique_ptr packet = - packet_generator_.NextPacket(i, 10); - RtpPacketToSend rtp_packet(nullptr); - EXPECT_TRUE(rtp_packet.Parse(packet->data.data(), packet->data.size())); + RtpPacketToSend rtp_packet = + packet_generator_.NextPacket(i, 10); ulpfec_generator_.AddPacketAndGenerateFec(rtp_packet); - last_timestamp = packet->header.timestamp; + last_timestamp = rtp_packet.Timestamp(); } std::vector> fec_packets = ulpfec_generator_.GetFecPackets(); @@ -160,12 +157,11 @@ TEST_F(UlpfecGeneratorTest, TwoFrameFec) { for (size_t i = 0; i < kNumFrames; ++i) { packet_generator_.NewFrame(kNumPackets); for (size_t j = 0; j < kNumPackets; ++j) { - std::unique_ptr packet = - packet_generator_.NextPacket(i * kNumPackets + j, 10); - RtpPacketToSend rtp_packet(nullptr); - EXPECT_TRUE(rtp_packet.Parse(packet->data.data(), packet->data.size())); + RtpPacketToSend rtp_packet = + packet_generator_.NextPacket(i * kNumPackets + j, + 10); ulpfec_generator_.AddPacketAndGenerateFec(rtp_packet); - last_timestamp = packet->header.timestamp; + last_timestamp = rtp_packet.Timestamp(); } } std::vector> fec_packets = @@ -188,10 +184,8 @@ TEST_F(UlpfecGeneratorTest, MixedMediaRtpHeaderLengths) { // Fill up internal buffer with media packets with short RTP header length. packet_generator_.NewFrame(kUlpfecMaxMediaPackets + 1); for (size_t i = 0; i < kUlpfecMaxMediaPackets; ++i) { - std::unique_ptr packet = - packet_generator_.NextPacket(i, 10); - RtpPacketToSend rtp_packet(nullptr); - EXPECT_TRUE(rtp_packet.Parse(packet->data.data(), packet->data.size())); + RtpPacketToSend rtp_packet = + packet_generator_.NextPacket(i, 10); EXPECT_EQ(rtp_packet.headers_size(), kShortRtpHeaderLength); ulpfec_generator_.AddPacketAndGenerateFec(rtp_packet); EXPECT_TRUE(ulpfec_generator_.GetFecPackets().empty()); @@ -199,10 +193,8 @@ TEST_F(UlpfecGeneratorTest, MixedMediaRtpHeaderLengths) { // Kick off FEC generation with media packet with long RTP header length. // Since the internal buffer is full, this packet will not be protected. - std::unique_ptr packet = - packet_generator_.NextPacket(kUlpfecMaxMediaPackets, 10); - RtpPacketToSend rtp_packet(nullptr); - EXPECT_TRUE(rtp_packet.Parse(packet->data.data(), packet->data.size())); + RtpPacketToSend rtp_packet = + packet_generator_.NextPacket(kUlpfecMaxMediaPackets, 10); EXPECT_TRUE(rtp_packet.SetPayloadSize(0) != nullptr); const uint32_t csrcs[]{1}; rtp_packet.SetCsrcs(csrcs); @@ -238,10 +230,8 @@ TEST_F(UlpfecGeneratorTest, UpdatesProtectionParameters) { // or delta-frame. auto add_frame = [&](bool is_keyframe) { packet_generator_.NewFrame(1); - std::unique_ptr packet = - packet_generator_.NextPacket(0, 10); - RtpPacketToSend rtp_packet(nullptr); - EXPECT_TRUE(rtp_packet.Parse(packet->data.data(), packet->data.size())); + RtpPacketToSend rtp_packet = + packet_generator_.NextPacket(0, 10); rtp_packet.set_is_key_frame(is_keyframe); ulpfec_generator_.AddPacketAndGenerateFec(rtp_packet); }; diff --git a/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc b/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc index 5bd4488573..95f3a2a9f1 100644 --- a/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc +++ b/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/ulpfec_header_reader_writer.h" -#include - #include +#include #include "api/array_view.h" #include "api/scoped_refptr.h" diff --git a/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc b/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc index 99ac1127a4..3ca4ccefc6 100644 --- a/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc +++ b/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/ulpfec_header_reader_writer.h" -#include - #include +#include #include #include "api/scoped_refptr.h" diff --git a/modules/rtp_rtcp/source/ulpfec_receiver.cc b/modules/rtp_rtcp/source/ulpfec_receiver.cc index b823ca1750..83bc10c5fe 100644 --- a/modules/rtp_rtcp/source/ulpfec_receiver.cc +++ b/modules/rtp_rtcp/source/ulpfec_receiver.cc @@ -53,7 +53,7 @@ UlpfecReceiver::~UlpfecReceiver() { if (packet_counter_.first_packet_time != Timestamp::MinusInfinity()) { const Timestamp now = clock_->CurrentTime(); TimeDelta elapsed = (now - packet_counter_.first_packet_time); - if (elapsed.seconds() >= metrics::kMinRunTimeInSeconds) { + if (elapsed >= metrics::kMinRunTime) { if (packet_counter_.num_packets > 0) { RTC_HISTOGRAM_PERCENTAGE( "WebRTC.Video.ReceivedFecPacketsInPercent", diff --git a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc index d36ebf559a..e9e33c55a4 100644 --- a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/ulpfec_receiver.h" -#include - #include +#include #include #include #include @@ -38,7 +37,6 @@ using ::testing::_; using ::testing::Eq; using ::testing::Property; -using test::fec::AugmentedPacket; using Packet = ForwardErrorCorrection::Packet; using test::fec::UlpfecPacketGenerator; @@ -70,12 +68,12 @@ class UlpfecReceiverTest : public ::testing::Test { // Generates `num_media_packets` corresponding to a single frame. void PacketizeFrame(size_t num_media_packets, size_t frame_offset, - std::list* augmented_packets, + std::list* augmented_packets, ForwardErrorCorrection::PacketList* packets); // Build a media packet using `packet_generator_` and add it // to the receiver. - void BuildAndAddRedMediaPacket(AugmentedPacket* packet, + void BuildAndAddRedMediaPacket(const RtpPacketReceived& packet, bool is_recovered = false); // Build a FEC packet using `packet_generator_` and add it @@ -84,8 +82,7 @@ class UlpfecReceiverTest : public ::testing::Test { // Ensure that `recovered_packet_receiver_` will be called correctly // and that the recovered packet will be identical to the lost packet. - void VerifyReconstructedMediaPacket(const AugmentedPacket& packet, - size_t times); + void VerifyReconstructedMediaPacket(const RtpPacket& packet, size_t times); void InjectGarbagePacketLength(size_t fec_garbage_offset); @@ -119,22 +116,25 @@ void UlpfecReceiverTest::EncodeFec( void UlpfecReceiverTest::PacketizeFrame( size_t num_media_packets, size_t frame_offset, - std::list* augmented_packets, + std::list* augmented_packets, ForwardErrorCorrection::PacketList* packets) { packet_generator_.NewFrame(num_media_packets); for (size_t i = 0; i < num_media_packets; ++i) { - std::unique_ptr next_packet( - packet_generator_.NextPacket(frame_offset + i, kRtpHeaderSize + 10)); - augmented_packets->push_back(next_packet.get()); - packets->push_back(std::move(next_packet)); + RtpPacketReceived next_packet = + packet_generator_.NextPacket(frame_offset + i, + kRtpHeaderSize + 10); + auto packet = std::make_unique(); + packet->data = next_packet.Buffer(); + augmented_packets->push_back(std::move(next_packet)); + packets->push_back(std::move(packet)); } } -void UlpfecReceiverTest::BuildAndAddRedMediaPacket(AugmentedPacket* packet, - bool is_recovered) { - RtpPacketReceived red_packet = - packet_generator_.BuildMediaRedPacket(*packet, is_recovered); - EXPECT_TRUE(receiver_fec_.AddReceivedRedPacket(red_packet)); +void UlpfecReceiverTest::BuildAndAddRedMediaPacket( + const RtpPacketReceived& packet, + bool is_recovered) { + EXPECT_TRUE(receiver_fec_.AddReceivedRedPacket( + packet_generator_.BuildMediaRedPacket(packet, is_recovered))); } void UlpfecReceiverTest::BuildAndAddRedFecPacket(Packet* packet) { @@ -143,15 +143,14 @@ void UlpfecReceiverTest::BuildAndAddRedFecPacket(Packet* packet) { EXPECT_TRUE(receiver_fec_.AddReceivedRedPacket(red_packet)); } -void UlpfecReceiverTest::VerifyReconstructedMediaPacket( - const AugmentedPacket& packet, - size_t times) { +void UlpfecReceiverTest::VerifyReconstructedMediaPacket(const RtpPacket& packet, + size_t times) { // Verify that the content of the reconstructed packet is equal to the // content of `packet`, and that the same content is received `times` number // of times in a row. - EXPECT_CALL( - recovered_packet_receiver_, - OnRecoveredPacket(Property(&RtpPacketReceived::Buffer, Eq(packet.data)))) + EXPECT_CALL(recovered_packet_receiver_, + OnRecoveredPacket( + Property(&RtpPacketReceived::Buffer, Eq(packet.Buffer())))) .Times(times); } @@ -159,7 +158,7 @@ void UlpfecReceiverTest::InjectGarbagePacketLength(size_t fec_garbage_offset) { EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_)); const size_t kNumFecPackets = 1; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); std::list fec_packets; @@ -193,7 +192,7 @@ void UlpfecReceiverTest::SurvivesMaliciousPacket(const uint8_t* data, TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { constexpr size_t kNumFecPackets = 1u; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); std::list fec_packets; @@ -206,7 +205,8 @@ TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { // Recovery auto it = augmented_media_packets.begin(); BuildAndAddRedMediaPacket(*it); - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); + receiver_fec_.ProcessReceivedFec(); counter = receiver_fec_.GetPacketCounter(); EXPECT_EQ(1u, counter.num_packets); @@ -219,7 +219,7 @@ TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { auto fec_it = fec_packets.begin(); BuildAndAddRedFecPacket(*fec_it); ++it; - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); counter = receiver_fec_.GetPacketCounter(); @@ -231,7 +231,7 @@ TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { TEST_F(UlpfecReceiverTest, TwoMediaOneFecNotUsesRecoveredPackets) { constexpr size_t kNumFecPackets = 1u; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); std::list fec_packets; @@ -244,7 +244,7 @@ TEST_F(UlpfecReceiverTest, TwoMediaOneFecNotUsesRecoveredPackets) { // Recovery auto it = augmented_media_packets.begin(); BuildAndAddRedMediaPacket(*it, /*is_recovered=*/true); - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); counter = receiver_fec_.GetPacketCounter(); EXPECT_EQ(1u, counter.num_packets); @@ -279,7 +279,7 @@ TEST_F(UlpfecReceiverTest, InjectGarbageFecLevelHeaderProtectionLength) { TEST_F(UlpfecReceiverTest, TwoMediaTwoFec) { const size_t kNumFecPackets = 2; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); std::list fec_packets; @@ -290,18 +290,18 @@ TEST_F(UlpfecReceiverTest, TwoMediaTwoFec) { auto it = augmented_media_packets.begin(); auto fec_it = fec_packets.begin(); BuildAndAddRedFecPacket(*fec_it); - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); ++fec_it; BuildAndAddRedFecPacket(*fec_it); ++it; - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); } TEST_F(UlpfecReceiverTest, TwoFramesOneFec) { const size_t kNumFecPackets = 1; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; PacketizeFrame(1, 0, &augmented_media_packets, &media_packets); PacketizeFrame(1, 1, &augmented_media_packets, &media_packets); @@ -311,18 +311,18 @@ TEST_F(UlpfecReceiverTest, TwoFramesOneFec) { // Recovery auto it = augmented_media_packets.begin(); BuildAndAddRedMediaPacket(augmented_media_packets.front()); - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); // Drop one media packet. BuildAndAddRedFecPacket(fec_packets.front()); ++it; - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); } TEST_F(UlpfecReceiverTest, OneCompleteOneUnrecoverableFrame) { const size_t kNumFecPackets = 1; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; PacketizeFrame(1, 0, &augmented_media_packets, &media_packets); PacketizeFrame(2, 1, &augmented_media_packets, &media_packets); @@ -333,18 +333,18 @@ TEST_F(UlpfecReceiverTest, OneCompleteOneUnrecoverableFrame) { // Recovery auto it = augmented_media_packets.begin(); BuildAndAddRedMediaPacket(*it); // First frame: one packet. - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); ++it; BuildAndAddRedMediaPacket(*it); // First packet of second frame. - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); } TEST_F(UlpfecReceiverTest, MaxFramesOneFec) { const size_t kNumFecPackets = 1; const size_t kNumMediaPackets = 48; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; for (size_t i = 0; i < kNumMediaPackets; ++i) { PacketizeFrame(1, i, &augmented_media_packets, &media_packets); @@ -357,19 +357,19 @@ TEST_F(UlpfecReceiverTest, MaxFramesOneFec) { ++it; // Drop first packet. for (; it != augmented_media_packets.end(); ++it) { BuildAndAddRedMediaPacket(*it); - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); } BuildAndAddRedFecPacket(fec_packets.front()); it = augmented_media_packets.begin(); - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); } TEST_F(UlpfecReceiverTest, TooManyFrames) { const size_t kNumFecPackets = 1; const size_t kNumMediaPackets = 49; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; for (size_t i = 0; i < kNumMediaPackets; ++i) { PacketizeFrame(1, i, &augmented_media_packets, &media_packets); @@ -386,7 +386,7 @@ TEST_F(UlpfecReceiverTest, PacketNotDroppedTooEarly) { Packet* delayed_fec = nullptr; const size_t kNumFecPacketsBatch1 = 1; const size_t kNumMediaPacketsBatch1 = 2; - std::list augmented_media_packets_batch1; + std::list augmented_media_packets_batch1; ForwardErrorCorrection::PacketList media_packets_batch1; PacketizeFrame(kNumMediaPacketsBatch1, 0, &augmented_media_packets_batch1, &media_packets_batch1); @@ -400,7 +400,7 @@ TEST_F(UlpfecReceiverTest, PacketNotDroppedTooEarly) { // Fill the FEC decoder. No packets should be dropped. const size_t kNumMediaPacketsBatch2 = 191; - std::list augmented_media_packets_batch2; + std::list augmented_media_packets_batch2; ForwardErrorCorrection::PacketList media_packets_batch2; for (size_t i = 0; i < kNumMediaPacketsBatch2; ++i) { PacketizeFrame(1, i, &augmented_media_packets_batch2, @@ -425,7 +425,7 @@ TEST_F(UlpfecReceiverTest, PacketDroppedWhenTooOld) { Packet* delayed_fec = nullptr; const size_t kNumFecPacketsBatch1 = 1; const size_t kNumMediaPacketsBatch1 = 2; - std::list augmented_media_packets_batch1; + std::list augmented_media_packets_batch1; ForwardErrorCorrection::PacketList media_packets_batch1; PacketizeFrame(kNumMediaPacketsBatch1, 0, &augmented_media_packets_batch1, &media_packets_batch1); @@ -439,7 +439,7 @@ TEST_F(UlpfecReceiverTest, PacketDroppedWhenTooOld) { // Fill the FEC decoder and force the last packet to be dropped. const size_t kNumMediaPacketsBatch2 = 192; - std::list augmented_media_packets_batch2; + std::list augmented_media_packets_batch2; ForwardErrorCorrection::PacketList media_packets_batch2; for (size_t i = 0; i < kNumMediaPacketsBatch2; ++i) { PacketizeFrame(1, i, &augmented_media_packets_batch2, @@ -463,10 +463,10 @@ TEST_F(UlpfecReceiverTest, OldFecPacketDropped) { // 49 frames with 2 media packets and one FEC packet. All media packets // missing. const size_t kNumMediaPackets = 49 * 2; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; for (size_t i = 0; i < kNumMediaPackets / 2; ++i) { - std::list frame_augmented_media_packets; + std::list frame_augmented_media_packets; ForwardErrorCorrection::PacketList frame_media_packets; std::list fec_packets; PacketizeFrame(2, 0, &frame_augmented_media_packets, &frame_media_packets); @@ -521,15 +521,12 @@ TEST_F(UlpfecReceiverTest, TruncatedPacketWithoutDataPastFirstBlock) { TEST_F(UlpfecReceiverTest, MediaWithPadding) { const size_t kNumFecPackets = 1; - std::list augmented_media_packets; + std::list augmented_media_packets; ForwardErrorCorrection::PacketList media_packets; PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); - // Append four bytes of padding to the first media packet. - const uint8_t kPadding[] = {0, 0, 0, 4}; - augmented_media_packets.front()->data.AppendData(kPadding); - augmented_media_packets.front()->data.MutableData()[0] |= 1 << 5; // P bit. - augmented_media_packets.front()->header.paddingLength = 4; + augmented_media_packets.front().SetPadding(/*padding_bytes=*/4); + media_packets.front()->data = augmented_media_packets.front().Buffer(); std::list fec_packets; EncodeFec(media_packets, kNumFecPackets, &fec_packets); @@ -537,12 +534,12 @@ TEST_F(UlpfecReceiverTest, MediaWithPadding) { auto it = augmented_media_packets.begin(); BuildAndAddRedMediaPacket(augmented_media_packets.front()); - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); BuildAndAddRedFecPacket(fec_packets.front()); ++it; - VerifyReconstructedMediaPacket(**it, 1); + VerifyReconstructedMediaPacket(*it, 1); receiver_fec_.ProcessReceivedFec(); } diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer.cc index 74a7522546..d44e38f03d 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" -#include -#include - +#include +#include #include #include "api/array_view.h" diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc index fd8d647045..9324851754 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc @@ -10,10 +10,9 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_av1.h" -#include -#include - #include +#include +#include #include #include #include diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc index 1ac96a2f2e..2f8f7fddb3 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h" -#include -#include - +#include +#include #include #include diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc index e808effca1..fe9a1d0ee5 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h" -#include - #include +#include #include #include diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc index 8d9bf6da7b..f3f4fb5ad3 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.h" -#include -#include - +#include +#include #include #include diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc index a0d21f4fdc..c69f48f952 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc @@ -10,9 +10,8 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.h" -#include - #include +#include #include #include diff --git a/modules/rtp_rtcp/test/testFec/test_fec.cc b/modules/rtp_rtcp/test/testFec/test_fec.cc index 4a7ceab3a1..067fa0c7eb 100644 --- a/modules/rtp_rtcp/test/testFec/test_fec.cc +++ b/modules/rtp_rtcp/test/testFec/test_fec.cc @@ -13,11 +13,10 @@ * functions in ForwardErrorCorrection directly. */ -#include -#include - #include #include +#include +#include #include #include #include diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn index 058b86bce4..39aa39a41c 100644 --- a/modules/video_capture/BUILD.gn +++ b/modules/video_capture/BUILD.gn @@ -59,6 +59,7 @@ if (!build_with_chromium || is_linux || is_chromeos) { "../../api:make_ref_counted", "../../api:scoped_refptr", "../../api:sequence_checker", + "../../api/video:video_rtp_headers", "../../common_video", "../../media:video_common", "../../rtc_base:checks", @@ -66,6 +67,7 @@ if (!build_with_chromium || is_linux || is_chromeos) { "../../rtc_base:macromagic", "../../rtc_base:platform_thread", "../../rtc_base:platform_thread_types", + "../../rtc_base:race_checker", "../../rtc_base:refcount", "../../rtc_base:stringutils", "../../rtc_base/synchronization:mutex", diff --git a/modules/video_capture/device_info_impl.cc b/modules/video_capture/device_info_impl.cc index 1d3e3ee89e..f96fda0903 100644 --- a/modules/video_capture/device_info_impl.cc +++ b/modules/video_capture/device_info_impl.cc @@ -10,9 +10,8 @@ #include "modules/video_capture/device_info_impl.h" -#include - #include +#include #include "absl/strings/match.h" #include "absl/strings/string_view.h" diff --git a/modules/video_capture/device_info_impl.h b/modules/video_capture/device_info_impl.h index 546265049c..c8d32179ed 100644 --- a/modules/video_capture/device_info_impl.h +++ b/modules/video_capture/device_info_impl.h @@ -11,8 +11,7 @@ #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_ #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_ -#include - +#include #include #include "api/video/video_rotation.h" diff --git a/modules/video_capture/linux/camera_portal.cc b/modules/video_capture/linux/camera_portal.cc index 093ad82419..b6c703f38c 100644 --- a/modules/video_capture/linux/camera_portal.cc +++ b/modules/video_capture/linux/camera_portal.cc @@ -10,12 +10,20 @@ #include "modules/video_capture/linux/camera_portal.h" -#include #include +#include +#include +#include + #include "modules/portal/pipewire_utils.h" +#include "modules/portal/portal_request_response.h" +#include "modules/portal/scoped_glib.h" #include "modules/portal/xdg_desktop_portal_utils.h" +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/modules/video_capture/linux/camera_portal.h b/modules/video_capture/linux/camera_portal.h index 36f2ec8b8a..8ccc7ad686 100644 --- a/modules/video_capture/linux/camera_portal.h +++ b/modules/video_capture/linux/camera_portal.h @@ -12,7 +12,6 @@ #define MODULES_VIDEO_CAPTURE_LINUX_CAMERA_PORTAL_H_ #include -#include #include "modules/portal/portal_request_response.h" #include "rtc_base/system/rtc_export.h" diff --git a/modules/video_capture/linux/device_info_linux.cc b/modules/video_capture/linux/device_info_linux.cc index 4f8b7c059b..c6ebc0d009 100644 --- a/modules/video_capture/linux/device_info_linux.cc +++ b/modules/video_capture/linux/device_info_linux.cc @@ -8,27 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include -#include -#include -#include -#include -#include -// v4l includes -#include +#include -#include - -#if defined(WEBRTC_USE_PIPEWIRE) -#include "modules/video_capture/linux/device_info_pipewire.h" -#endif #include "modules/video_capture/linux/device_info_v4l2.h" #include "modules/video_capture/video_capture.h" -#include "modules/video_capture/video_capture_defines.h" #include "modules/video_capture/video_capture_impl.h" #include "modules/video_capture/video_capture_options.h" -#include "rtc_base/logging.h" + +#if defined(WEBRTC_USE_PIPEWIRE) +#include "modules/video_capture/linux/device_info_pipewire.h" +#endif namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc index 0ec0da3933..7eaf5fbd70 100644 --- a/modules/video_capture/linux/device_info_pipewire.cc +++ b/modules/video_capture/linux/device_info_pipewire.cc @@ -10,20 +10,14 @@ #include "modules/video_capture/linux/device_info_pipewire.h" -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include "modules/video_capture/device_info_impl.h" #include "modules/video_capture/linux/pipewire_session.h" -#include "modules/video_capture/video_capture.h" -#include "modules/video_capture/video_capture_defines.h" #include "modules/video_capture/video_capture_impl.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" namespace webrtc { diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h index 0187e47e5f..5d0fc6740a 100644 --- a/modules/video_capture/linux/device_info_pipewire.h +++ b/modules/video_capture/linux/device_info_pipewire.h @@ -11,10 +11,12 @@ #ifndef MODULES_VIDEO_CAPTURE_LINUX_DEVICE_INFO_PIPEWIRE_H_ #define MODULES_VIDEO_CAPTURE_LINUX_DEVICE_INFO_PIPEWIRE_H_ -#include +#include +#include "api/scoped_refptr.h" #include "modules/video_capture/device_info_impl.h" #include "modules/video_capture/video_capture_options.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc index a472e41a41..289975b2e1 100644 --- a/modules/video_capture/linux/device_info_v4l2.cc +++ b/modules/video_capture/linux/device_info_v4l2.cc @@ -10,21 +10,21 @@ #include "modules/video_capture/linux/device_info_v4l2.h" -#include #include -#include -#include -#include +#include #include #include -// v4l includes -#include -#include +#include +#include +#include +#include +#include -#include "modules/video_capture/video_capture.h" +#include "common_video/libyuv/include/webrtc_libyuv.h" +#include "modules/video_capture/device_info_impl.h" #include "modules/video_capture/video_capture_defines.h" -#include "modules/video_capture/video_capture_impl.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" // These defines are here to support building on kernel 3.16 which some diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h index fb95a6020d..c08fbe6937 100644 --- a/modules/video_capture/linux/device_info_v4l2.h +++ b/modules/video_capture/linux/device_info_v4l2.h @@ -11,9 +11,10 @@ #ifndef MODULES_VIDEO_CAPTURE_LINUX_DEVICE_INFO_V4L2_H_ #define MODULES_VIDEO_CAPTURE_LINUX_DEVICE_INFO_V4L2_H_ -#include +#include #include "modules/video_capture/device_info_impl.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc index 990bfde912..2c533a0edb 100644 --- a/modules/video_capture/linux/pipewire_session.cc +++ b/modules/video_capture/linux/pipewire_session.cc @@ -17,13 +17,23 @@ #include #include +#include +#include +#include +#include +#include +#include "absl/strings/string_view.h" #include "common_video/libyuv/include/webrtc_libyuv.h" -#include "modules/video_capture/device_info_impl.h" +#include "modules/portal/pipewire_utils.h" +#include "modules/portal/portal_request_response.h" +#include "modules/video_capture/linux/camera_portal.h" +#include "modules/video_capture/video_capture_defines.h" +#include "modules/video_capture/video_capture_options.h" #include "rtc_base/logging.h" #include "rtc_base/sanitizer.h" -#include "rtc_base/string_encode.h" #include "rtc_base/string_to_number.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/pipewire_session.h b/modules/video_capture/linux/pipewire_session.h index aec268e008..b2a2023585 100644 --- a/modules/video_capture/linux/pipewire_session.h +++ b/modules/video_capture/linux/pipewire_session.h @@ -13,17 +13,20 @@ #include +#include #include +#include #include #include #include "api/ref_counted_base.h" -#include "api/scoped_refptr.h" #include "modules/portal/pipewire_utils.h" +#include "modules/portal/portal_request_response.h" #include "modules/video_capture/linux/camera_portal.h" -#include "modules/video_capture/video_capture.h" +#include "modules/video_capture/video_capture_defines.h" #include "modules/video_capture/video_capture_options.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc index 0b57cfe90c..8ff7beeccd 100644 --- a/modules/video_capture/linux/video_capture_linux.cc +++ b/modules/video_capture/linux/video_capture_linux.cc @@ -8,29 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - +#include "api/make_ref_counted.h" #include "api/scoped_refptr.h" -#include "media/base/video_common.h" -#if defined(WEBRTC_USE_PIPEWIRE) -#include "modules/video_capture/linux/video_capture_pipewire.h" -#endif #include "modules/video_capture/linux/video_capture_v4l2.h" #include "modules/video_capture/video_capture.h" +#include "modules/video_capture/video_capture_impl.h" #include "modules/video_capture/video_capture_options.h" -#include "rtc_base/logging.h" + +#if defined(WEBRTC_USE_PIPEWIRE) +#include "modules/video_capture/linux/video_capture_pipewire.h" +#endif namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/video_capture_pipewire.cc b/modules/video_capture/linux/video_capture_pipewire.cc index f6cd57ac36..e19af597da 100644 --- a/modules/video_capture/linux/video_capture_pipewire.cc +++ b/modules/video_capture/linux/video_capture_pipewire.cc @@ -14,14 +14,29 @@ #include #include #include - +#include + +#include +#include +#include +#include +#include +#include #include +#include "api/sequence_checker.h" +#include "api/video/video_rotation.h" #include "common_video/libyuv/include/webrtc_libyuv.h" #include "modules/portal/pipewire_utils.h" +#include "modules/video_capture/linux/pipewire_session.h" +#include "modules/video_capture/video_capture_defines.h" +#include "modules/video_capture/video_capture_impl.h" +#include "modules/video_capture/video_capture_options.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/race_checker.h" #include "rtc_base/sanitizer.h" -#include "rtc_base/string_to_number.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/video_capture_pipewire.h b/modules/video_capture/linux/video_capture_pipewire.h index 240e7da52b..17573037f7 100644 --- a/modules/video_capture/linux/video_capture_pipewire.h +++ b/modules/video_capture/linux/video_capture_pipewire.h @@ -11,9 +11,14 @@ #ifndef MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_PIPEWIRE_H_ #define MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_PIPEWIRE_H_ +#include + +#include "api/scoped_refptr.h" +#include "common_video/libyuv/include/webrtc_libyuv.h" #include "modules/video_capture/linux/pipewire_session.h" #include "modules/video_capture/video_capture_defines.h" #include "modules/video_capture/video_capture_impl.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc index 243656e782..bef2939ce6 100644 --- a/modules/video_capture/linux/video_capture_v4l2.cc +++ b/modules/video_capture/linux/video_capture_v4l2.cc @@ -10,24 +10,29 @@ #include "modules/video_capture/linux/video_capture_v4l2.h" -#include #include #include -#include -#include #include #include #include -#include #include +#include +#include +#include +#include #include -#include -#include "api/scoped_refptr.h" +#include "api/sequence_checker.h" +#include "common_video/libyuv/include/webrtc_libyuv.h" #include "media/base/video_common.h" -#include "modules/video_capture/video_capture.h" +#include "modules/video_capture/video_capture_defines.h" +#include "modules/video_capture/video_capture_impl.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/platform_thread.h" +#include "rtc_base/race_checker.h" +#include "rtc_base/synchronization/mutex.h" // These defines are here to support building on kernel 3.16 which some // downstream projects, e.g. Firefox, use. diff --git a/modules/video_capture/linux/video_capture_v4l2.h b/modules/video_capture/linux/video_capture_v4l2.h index 2611192d55..5de8358180 100644 --- a/modules/video_capture/linux/video_capture_v4l2.h +++ b/modules/video_capture/linux/video_capture_v4l2.h @@ -11,15 +11,14 @@ #ifndef MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_V4L2_H_ #define MODULES_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_V4L2_H_ -#include -#include - -#include +#include +#include #include "modules/video_capture/video_capture_defines.h" #include "modules/video_capture/video_capture_impl.h" #include "rtc_base/platform_thread.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { namespace videocapturemodule { diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc index e8165d9060..c4c2c71c23 100644 --- a/modules/video_capture/test/video_capture_unittest.cc +++ b/modules/video_capture/test/video_capture_unittest.cc @@ -10,9 +10,8 @@ #include "modules/video_capture/video_capture.h" -#include - #include +#include #include #include #include diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc index 6e205a215f..c5d3f989ab 100644 --- a/modules/video_capture/video_capture_impl.cc +++ b/modules/video_capture/video_capture_impl.cc @@ -219,10 +219,9 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame, } const int conversionResult = libyuv::ConvertToI420( - videoFrame, videoFrameLength, buffer.get()->MutableDataY(), - buffer.get()->StrideY(), buffer.get()->MutableDataU(), - buffer.get()->StrideU(), buffer.get()->MutableDataV(), - buffer.get()->StrideV(), 0, 0, // No Cropping + videoFrame, videoFrameLength, buffer->MutableDataY(), buffer->StrideY(), + buffer->MutableDataU(), buffer->StrideU(), buffer->MutableDataV(), + buffer->StrideV(), 0, 0, // No Cropping width, height, target_width, target_height, rotation_mode, ConvertVideoType(frameInfo.videoType)); if (conversionResult != 0) { diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h index d3ac5fe5ef..8c0f592e94 100644 --- a/modules/video_capture/video_capture_impl.h +++ b/modules/video_capture/video_capture_impl.h @@ -11,12 +11,8 @@ #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_IMPL_H_ #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_IMPL_H_ -/* - * video_capture_impl.h - */ - -#include -#include +#include +#include #include "api/scoped_refptr.h" #include "api/sequence_checker.h" diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 606c1161bc..b100541101 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -556,6 +556,9 @@ rtc_library("mock_libvpx_interface") { ":webrtc_libvpx_interface", "../../test:test_support", ] + if (rtc_build_libvpx) { + deps += [ rtc_libvpx_dir ] + } } # This target includes the internal SW codec. @@ -759,7 +762,7 @@ if (rtc_include_tests) { deps = [ "../../api/video_codecs:video_codecs_api", - "../../modules/utility:utility", + "../../modules/utility", "../../rtc_base:checks", "../../sdk/android:internal_jni", "../../sdk/android:native_api_base", @@ -866,7 +869,7 @@ if (rtc_include_tests) { "../../api:videocodec_test_stats_api", "../../api/environment", "../../api/environment:environment_factory", - "../../api/numerics:numerics", + "../../api/numerics", "../../api/task_queue", "../../api/task_queue:default_task_queue_factory", "../../api/test/metrics:global_metrics_logger_and_exporter", @@ -1326,8 +1329,8 @@ if (rtc_include_tests) { "../../test:test_support", "../../test:video_test_common", "../../test:video_test_support", - "../../test/time_controller:time_controller", - "../../third_party/libyuv:libyuv", + "../../test/time_controller", + "../../third_party/libyuv", "../../video/config:encoder_config", "../rtp_rtcp", "../rtp_rtcp:rtp_rtcp_format", diff --git a/modules/video_coding/chain_diff_calculator.cc b/modules/video_coding/chain_diff_calculator.cc index d8ce44acbd..0674a84ece 100644 --- a/modules/video_coding/chain_diff_calculator.cc +++ b/modules/video_coding/chain_diff_calculator.cc @@ -9,10 +9,9 @@ */ #include "modules/video_coding/chain_diff_calculator.h" -#include -#include - #include +#include +#include #include #include diff --git a/modules/video_coding/codecs/av1/BUILD.gn b/modules/video_coding/codecs/av1/BUILD.gn index eb48e4939e..e9fb4ac392 100644 --- a/modules/video_coding/codecs/av1/BUILD.gn +++ b/modules/video_coding/codecs/av1/BUILD.gn @@ -31,8 +31,10 @@ rtc_library("av1_svc_config") { rtc_library("dav1d_decoder") { visibility = [ "*" ] poisonous = [ "software_video_codecs" ] - public = [ "dav1d_decoder.h" ] - sources = [ "dav1d_decoder.cc" ] + sources = [ + "dav1d_decoder.cc", + "dav1d_decoder.h", + ] deps = [ "../..:video_codec_interface", @@ -52,8 +54,10 @@ rtc_library("dav1d_decoder") { rtc_library("libaom_av1_encoder") { visibility = [ "*" ] poisonous = [ "software_video_codecs" ] - public = [ "libaom_av1_encoder.h" ] - sources = [ "libaom_av1_encoder.cc" ] + sources = [ + "libaom_av1_encoder.cc", + "libaom_av1_encoder.h", + ] deps = [ "../..:video_codec_interface", "../../../../api:field_trials_view", @@ -114,7 +118,6 @@ if (rtc_include_tests) { "../../../../api/video_codecs:video_codecs_api", "../../../../rtc_base:checks", "../../../../test:create_test_field_trials", - "../../../../test:explicit_key_value_config", "../../../../test:test_support", ] @@ -133,7 +136,6 @@ if (rtc_include_tests) { "../../../../api/units:time_delta", "../../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../../test:fileutils", - "../../../../test:scoped_key_value_config", "../../../../test:video_test_support", "../../svc:scalability_mode_util", "../../svc:scalability_structures", diff --git a/modules/video_coding/codecs/av1/dav1d_decoder.cc b/modules/video_coding/codecs/av1/dav1d_decoder.cc index a9384b0c25..235916f92e 100644 --- a/modules/video_coding/codecs/av1/dav1d_decoder.cc +++ b/modules/video_coding/codecs/av1/dav1d_decoder.cc @@ -210,7 +210,7 @@ int32_t Dav1dDecoder::Decode(const EncodedImage& encoded_image, return WEBRTC_VIDEO_CODEC_ERROR; } - if (!wrapped_buffer.get()) { + if (!wrapped_buffer) { return WEBRTC_VIDEO_CODEC_ERROR; } diff --git a/modules/video_coding/codecs/av1/dav1d_decoder_unittest.cc b/modules/video_coding/codecs/av1/dav1d_decoder_unittest.cc index cfd1116c8e..08b86827c5 100644 --- a/modules/video_coding/codecs/av1/dav1d_decoder_unittest.cc +++ b/modules/video_coding/codecs/av1/dav1d_decoder_unittest.cc @@ -18,7 +18,6 @@ #include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "api/video/encoded_image.h" #include "api/video/video_frame.h" #include "api/video_codecs/video_decoder.h" @@ -97,9 +96,8 @@ TEST(Dav1dDecoderTest, KeepsDecodedResolutionByDefault) { } TEST(Dav1dDecoderTest, CropsToRenderResolutionWhenCropIsEnabled) { - TestAv1Decoder decoder( - CreateEnvironment(std::make_unique(CreateTestFieldTrials( - "WebRTC-Dav1dDecoder-CropToRenderResolution/Enabled/")))); + TestAv1Decoder decoder(CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Dav1dDecoder-CropToRenderResolution/Enabled/"))); decoder.Decode( CreateEncodedImage(kAv1FrameWith36x20EncodededAnd32x16RenderResolution)); EXPECT_EQ(decoder.decoded_frame().width(), 32); @@ -107,9 +105,8 @@ TEST(Dav1dDecoderTest, CropsToRenderResolutionWhenCropIsEnabled) { } TEST(Dav1dDecoderTest, DoesNotCropToRenderResolutionWhenCropIsDisabled) { - TestAv1Decoder decoder( - CreateEnvironment(std::make_unique(CreateTestFieldTrials( - "WebRTC-Dav1dDecoder-CropToRenderResolution/Disabled/")))); + TestAv1Decoder decoder(CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Dav1dDecoder-CropToRenderResolution/Disabled/"))); decoder.Decode( CreateEncodedImage(kAv1FrameWith36x20EncodededAnd32x16RenderResolution)); EXPECT_EQ(decoder.decoded_frame().width(), 36); diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index 1ebfe0da06..8c64a56eed 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -9,9 +9,8 @@ */ #include "modules/video_coding/codecs/av1/libaom_av1_encoder.h" -#include -#include - +#include +#include #include #include #include @@ -785,7 +784,7 @@ int32_t LibaomAv1Encoder::Encode( /*data=*/static_cast(pkt->data.frame.buf), /*size=*/pkt->data.frame.sz)); - if ((pkt->data.frame.flags & AOM_EFLAG_FORCE_KF) != 0) { + if ((pkt->data.frame.flags & AOM_FRAME_IS_KEY) != 0) { layer_frame->Keyframe(); } diff --git a/modules/video_coding/codecs/av1/libaom_av1_unittest.cc b/modules/video_coding/codecs/av1/libaom_av1_unittest.cc index 2993e3994d..cae31d5d22 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_unittest.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_unittest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include +#include #include #include #include diff --git a/modules/video_coding/codecs/h264/h264.cc b/modules/video_coding/codecs/h264/h264.cc index ffee2af7f5..919a80ce85 100644 --- a/modules/video_coding/codecs/h264/h264.cc +++ b/modules/video_coding/codecs/h264/h264.cc @@ -14,10 +14,19 @@ #include #include #include +#include +#include "absl/base/nullability.h" #include "absl/container/inlined_vector.h" +#include "api/environment/environment.h" +#include "api/video_codecs/h264_profile_level_id.h" +#include "api/video_codecs/scalability_mode.h" #include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_encoder.h" #include "media/base/media_constants.h" +#include "modules/video_coding/codecs/h264/include/h264_globals.h" +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" #include "rtc_base/trace_event.h" #if defined(WEBRTC_USE_H264) @@ -25,9 +34,6 @@ #include "modules/video_coding/codecs/h264/h264_encoder_impl.h" #endif -#include "rtc_base/checks.h" -#include "rtc_base/logging.h" - namespace webrtc { namespace { diff --git a/modules/video_coding/codecs/h264/h264_color_space.cc b/modules/video_coding/codecs/h264/h264_color_space.cc index 59921263e3..e5c103746a 100644 --- a/modules/video_coding/codecs/h264/h264_color_space.cc +++ b/modules/video_coding/codecs/h264/h264_color_space.cc @@ -15,6 +15,8 @@ #include "modules/video_coding/codecs/h264/h264_color_space.h" +#include "api/video/color_space.h" + namespace webrtc { ColorSpace ExtractH264ColorSpace(AVCodecContext* codec) { diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/modules/video_coding/codecs/h264/h264_decoder_impl.cc index b6c8417094..e40ce0ac1f 100644 --- a/modules/video_coding/codecs/h264/h264_decoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_decoder_impl.cc @@ -23,12 +23,28 @@ extern "C" { } // extern "C" #include +#include +#include +#include #include #include +#include +#include "api/scoped_refptr.h" #include "api/video/color_space.h" +#include "api/video/encoded_image.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/render_resolution.h" +#include "api/video/video_codec_type.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_buffer.h" +#include "api/video/video_rotation.h" +#include "api/video_codecs/video_decoder.h" #include "common_video/include/video_frame_buffer.h" #include "modules/video_coding/codecs/h264/h264_color_space.h" #include "modules/video_coding/include/video_error_codes.h" diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.h b/modules/video_coding/codecs/h264/h264_decoder_impl.h index 09530e7b0f..626d9e09f7 100644 --- a/modules/video_coding/codecs/h264/h264_decoder_impl.h +++ b/modules/video_coding/codecs/h264/h264_decoder_impl.h @@ -34,13 +34,15 @@ // some way depending on undocumented behavior. If any problems turn up, we may // have to add an extra copy operation, to enforce padding before buffers are // passed to ffmpeg. - extern "C" { #include } // extern "C" +#include #include +#include "api/video/encoded_image.h" +#include "api/video_codecs/video_decoder.h" #include "common_video/h264/h264_bitstream_parser.h" #include "common_video/include/video_frame_buffer_pool.h" #include "modules/video_coding/codecs/h264/include/h264.h" diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/modules/video_coding/codecs/h264/h264_encoder_impl.cc index 387a88b8cf..1b0f7a0a74 100644 --- a/modules/video_coding/codecs/h264/h264_encoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_encoder_impl.cc @@ -17,24 +17,42 @@ #include "modules/video_coding/codecs/h264/h264_encoder_impl.h" #include +#include +#include +#include #include #include #include - -#include "absl/strings/match.h" +#include + +#include "api/environment/environment.h" +#include "api/scoped_refptr.h" +#include "api/units/data_rate.h" +#include "api/video/encoded_image.h" +#include "api/video/i420_buffer.h" +#include "api/video/video_bitrate_allocation.h" +#include "api/video/video_bitrate_allocator.h" #include "api/video/video_codec_constants.h" +#include "api/video/video_codec_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_codecs/scalability_mode.h" +#include "api/video_codecs/video_codec.h" +#include "api/video_codecs/video_encoder.h" #include "common_video/libyuv/include/webrtc_libyuv.h" +#include "modules/video_coding/codecs/h264/include/h264.h" +#include "modules/video_coding/codecs/h264/include/h264_globals.h" +#include "modules/video_coding/codecs/interface/common_constants.h" #include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/include/video_error_codes.h" #include "modules/video_coding/svc/create_scalability_structure.h" +#include "modules/video_coding/svc/scalable_video_controller.h" #include "modules/video_coding/utility/simulcast_rate_allocator.h" #include "modules/video_coding/utility/simulcast_utility.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/time_utils.h" #include "system_wrappers/include/metrics.h" -#include "third_party/libyuv/include/libyuv/convert.h" #include "third_party/libyuv/include/libyuv/scale.h" #include "third_party/openh264/src/codec/api/wels/codec_api.h" #include "third_party/openh264/src/codec/api/wels/codec_app_def.h" diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.h b/modules/video_coding/codecs/h264/h264_encoder_impl.h index d8f1156a8f..cae05a176a 100644 --- a/modules/video_coding/codecs/h264/h264_encoder_impl.h +++ b/modules/video_coding/codecs/h264/h264_encoder_impl.h @@ -17,25 +17,33 @@ // #ifdef unless needed and tested. #ifdef WEBRTC_USE_H264 -#if defined(WEBRTC_WIN) && !defined(__clang__) -#error "See: bugs.webrtc.org/9213#c13." -#endif - +#include +#include #include +#include #include #include "absl/container/inlined_vector.h" -#include "api/transport/rtp/dependency_descriptor.h" +#include "api/environment/environment.h" +#include "api/scoped_refptr.h" +#include "api/video/encoded_image.h" #include "api/video/i420_buffer.h" #include "api/video/video_codec_constants.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_type.h" #include "api/video_codecs/scalability_mode.h" +#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "common_video/h264/h264_bitstream_parser.h" #include "modules/video_coding/codecs/h264/include/h264.h" +#include "modules/video_coding/codecs/h264/include/h264_globals.h" #include "modules/video_coding/svc/scalable_video_controller.h" -#include "modules/video_coding/utility/quality_scaler.h" #include "third_party/openh264/src/codec/api/wels/codec_app_def.h" +#if defined(WEBRTC_WIN) && !defined(__clang__) +#error "See: bugs.webrtc.org/9213#c13." +#endif + class ISVCEncoder; namespace webrtc { diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl_unittest.cc b/modules/video_coding/codecs/h264/h264_encoder_impl_unittest.cc index e714e277e8..ae9ed9b851 100644 --- a/modules/video_coding/codecs/h264/h264_encoder_impl_unittest.cc +++ b/modules/video_coding/codecs/h264/h264_encoder_impl_unittest.cc @@ -12,7 +12,10 @@ #include "modules/video_coding/codecs/h264/h264_encoder_impl.h" #include "api/environment/environment_factory.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/codecs/h264/include/h264_globals.h" #include "modules/video_coding/include/video_error_codes.h" #include "test/gtest.h" @@ -20,8 +23,8 @@ namespace webrtc { namespace { -const int kMaxPayloadSize = 1024; -const int kNumCores = 1; +constexpr int kMaxPayloadSize = 1024; +constexpr int kNumCores = 1; const VideoEncoder::Capabilities kCapabilities(false); const VideoEncoder::Settings kSettings(kCapabilities, diff --git a/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc b/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc index b9ea324ca2..39443fcdcc 100644 --- a/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc +++ b/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc @@ -9,11 +9,16 @@ */ #include +#include +#include "api/environment/environment.h" #include "api/test/create_simulcast_test_fixture.h" #include "api/test/simulcast_test_fixture.h" #include "api/test/video/function_video_decoder_factory.h" #include "api/test/video/function_video_encoder_factory.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder_factory.h" #include "modules/video_coding/codecs/h264/include/h264.h" #include "test/gtest.h" diff --git a/modules/video_coding/codecs/h264/include/h264_globals.h b/modules/video_coding/codecs/h264/include/h264_globals.h index dac36dd734..9b0b7b6b9e 100644 --- a/modules/video_coding/codecs/h264/include/h264_globals.h +++ b/modules/video_coding/codecs/h264/include/h264_globals.h @@ -14,11 +14,10 @@ #ifndef MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_GLOBALS_H_ #define MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_GLOBALS_H_ -#include +#include #include #include -#include "modules/video_coding/codecs/interface/common_constants.h" #include "rtc_base/checks.h" 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 6e9e58e717..3d2dd3dbc7 100644 --- a/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc +++ b/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc @@ -8,20 +8,19 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include "api/video/color_space.h" #include "api/video/encoded_image.h" +#include "api/video/video_codec_type.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_decoder.h" #include "api/video_codecs/video_encoder.h" #include "common_video/libyuv/include/webrtc_libyuv.h" -#include "media/base/codec.h" -#include "media/base/media_constants.h" #include "modules/video_coding/codecs/h264/include/h264.h" #include "modules/video_coding/codecs/test/video_codec_unittest.h" #include "modules/video_coding/include/video_codec_interface.h" diff --git a/modules/video_coding/codecs/interface/libvpx_interface.cc b/modules/video_coding/codecs/interface/libvpx_interface.cc index 73c23e71b9..dea2adefc1 100644 --- a/modules/video_coding/codecs/interface/libvpx_interface.cc +++ b/modules/video_coding/codecs/interface/libvpx_interface.cc @@ -14,11 +14,11 @@ #include #include "rtc_base/checks.h" -#include "vpx/vp8cx.h" -#include "vpx/vpx_codec.h" -#include "vpx/vpx_encoder.h" -#include "vpx/vpx_ext_ratectrl.h" -#include "vpx/vpx_image.h" +#include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_codec.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_ext_ratectrl.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_image.h" namespace webrtc { namespace { diff --git a/modules/video_coding/codecs/interface/libvpx_interface.h b/modules/video_coding/codecs/interface/libvpx_interface.h index 26ddca7289..db7ccb0727 100644 --- a/modules/video_coding/codecs/interface/libvpx_interface.h +++ b/modules/video_coding/codecs/interface/libvpx_interface.h @@ -15,11 +15,11 @@ #include -#include "vpx/vp8cx.h" -#include "vpx/vpx_codec.h" -#include "vpx/vpx_encoder.h" -#include "vpx/vpx_ext_ratectrl.h" -#include "vpx/vpx_image.h" +#include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_codec.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_ext_ratectrl.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_image.h" namespace webrtc { diff --git a/modules/video_coding/codecs/interface/mock_libvpx_interface.h b/modules/video_coding/codecs/interface/mock_libvpx_interface.h index 0f92e42e05..b641ca7d57 100644 --- a/modules/video_coding/codecs/interface/mock_libvpx_interface.h +++ b/modules/video_coding/codecs/interface/mock_libvpx_interface.h @@ -15,11 +15,11 @@ #include "modules/video_coding/codecs/interface/libvpx_interface.h" #include "test/gmock.h" -#include "vpx/vp8cx.h" -#include "vpx/vpx_codec.h" -#include "vpx/vpx_encoder.h" -#include "vpx/vpx_ext_ratectrl.h" -#include "vpx/vpx_image.h" +#include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_codec.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_ext_ratectrl.h" +#include "third_party/libvpx/source/libvpx/vpx/vpx_image.h" namespace webrtc { diff --git a/modules/video_coding/codecs/test/android_codec_factory_helper.cc b/modules/video_coding/codecs/test/android_codec_factory_helper.cc index d1be684cbb..8f53e8f1c3 100644 --- a/modules/video_coding/codecs/test/android_codec_factory_helper.cc +++ b/modules/video_coding/codecs/test/android_codec_factory_helper.cc @@ -10,12 +10,15 @@ #include "modules/video_coding/codecs/test/android_codec_factory_helper.h" +#include #include #include #include #include +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder_factory.h" #include "modules/utility/include/jvm_android.h" #include "rtc_base/checks.h" #include "sdk/android/native_api/codecs/wrapper.h" diff --git a/modules/video_coding/codecs/test/video_codec_test.cc b/modules/video_coding/codecs/test/video_codec_test.cc index 5f13099ae8..1542892e60 100644 --- a/modules/video_coding/codecs/test/video_codec_test.cc +++ b/modules/video_coding/codecs/test/video_codec_test.cc @@ -23,7 +23,6 @@ #include "absl/flags/flag.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" #include "api/units/data_rate.h" #include "api/units/frequency.h" @@ -575,8 +574,7 @@ INSTANTIATE_TEST_SUITE_P(All, FramerateAdaptationTest::TestParamsToString); TEST(VideoCodecTest, DISABLED_EncodeDecode) { - const Environment env = - CreateEnvironment(std::make_unique(CreateTestFieldTrials())); + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr()); VideoSourceSettings source_settings{ .file_path = absl::GetFlag(FLAGS_input_path), 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 581a6286a5..251428f297 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 @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include #include "api/test/videocodec_test_fixture.h" #include "api/video/video_codec_type.h" @@ -25,7 +25,7 @@ namespace test { using Config = VideoCodecTestFixture::Config; namespace { -const size_t kNumTemporalLayers = 2; +constexpr size_t kNumTemporalLayers = 2; } // namespace TEST(Config, NumberOfCoresWithUseSingleCore) { 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 39e7af4583..66e0c2f8de 100644 --- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc +++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc @@ -10,11 +10,10 @@ #include "modules/video_coding/codecs/test/videocodec_test_fixture_impl.h" -#include -#include - #include #include +#include +#include #include #include #include diff --git a/modules/video_coding/codecs/test/videocodec_test_stats_impl_unittest.cc b/modules/video_coding/codecs/test/videocodec_test_stats_impl_unittest.cc index a68d8ac0b9..b740efadae 100644 --- a/modules/video_coding/codecs/test/videocodec_test_stats_impl_unittest.cc +++ b/modules/video_coding/codecs/test/videocodec_test_stats_impl_unittest.cc @@ -23,7 +23,7 @@ using FrameStatistics = VideoCodecTestStatsImpl::FrameStatistics; namespace { -const size_t kTimestamp = 12345; +constexpr size_t kTimestamp = 12345; using ::testing::AllOf; using ::testing::Contains; diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc index bec0e353c6..5a89cad769 100644 --- a/modules/video_coding/codecs/test/videoprocessor.cc +++ b/modules/video_coding/codecs/test/videoprocessor.cc @@ -10,11 +10,10 @@ #include "modules/video_coding/codecs/test/videoprocessor.h" -#include - #include #include #include +#include #include #include #include diff --git a/modules/video_coding/codecs/test/videoprocessor_unittest.cc b/modules/video_coding/codecs/test/videoprocessor_unittest.cc index 0e44884260..c71c06bc10 100644 --- a/modules/video_coding/codecs/test/videoprocessor_unittest.cc +++ b/modules/video_coding/codecs/test/videoprocessor_unittest.cc @@ -41,8 +41,8 @@ namespace test { namespace { -const int kWidth = 352; -const int kHeight = 288; +constexpr int kWidth = 352; +constexpr int kHeight = 288; } // namespace diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.cc b/modules/video_coding/codecs/vp8/default_temporal_layers.cc index 0ad4bb8f62..651e990d84 100644 --- a/modules/video_coding/codecs/vp8/default_temporal_layers.cc +++ b/modules/video_coding/codecs/vp8/default_temporal_layers.cc @@ -9,12 +9,11 @@ #include "modules/video_coding/codecs/vp8/default_temporal_layers.h" -#include - #include #include #include #include +#include #include #include #include diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc index c05a91df34..13e7b3229b 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc @@ -10,11 +10,10 @@ #include "modules/video_coding/codecs/vp8/libvpx_vp8_decoder.h" -#include -#include - #include #include +#include +#include #include #include #include @@ -286,7 +285,7 @@ int LibvpxVp8Decoder::ReturnFrame(const vpx_image_t* img, scoped_refptr i420_buffer = buffer_pool_.CreateI420Buffer(img->d_w, img->d_h); buffer = i420_buffer; - if (i420_buffer.get()) { + if (i420_buffer) { libyuv::I420Copy(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y], img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U], img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V], @@ -296,7 +295,7 @@ int LibvpxVp8Decoder::ReturnFrame(const vpx_image_t* img, img->d_w, img->d_h); } - if (!buffer.get()) { + if (!buffer) { // Pool has too many pending frames. RTC_HISTOGRAM_BOOLEAN("WebRTC.Video.LibvpxVp8Decoder.TooManyPendingFrames", 1); diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc index 9e533cf33e..5446d837ec 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc @@ -10,11 +10,10 @@ #include "modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h" -#include - #include #include #include +#include #include #include #include diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.cc b/modules/video_coding/codecs/vp8/screenshare_layers.cc index 885d44bdf0..e12ebc109d 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers.cc @@ -9,10 +9,9 @@ #include "modules/video_coding/codecs/vp8/screenshare_layers.h" -#include - #include #include +#include #include #include #include @@ -597,7 +596,7 @@ void ScreenshareLayers::UpdateHistograms() { return; int64_t duration_sec = (TimeMillis() - stats_.first_frame_time_ms_ + 500) / 1000; - if (duration_sec >= metrics::kMinRunTimeInSeconds) { + if (duration_sec >= metrics::kMinRunTime.seconds()) { RTC_HISTOGRAM_COUNTS_10000( "WebRTC.Video.Screenshare.Layer0.FrameRate", (stats_.num_tl0_frames_ + (duration_sec / 2)) / duration_sec); diff --git a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc index cfafc7249e..0d3d517434 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc @@ -11,9 +11,10 @@ #include "modules/video_coding/codecs/vp8/screenshare_layers.h" #include -#include #include +#include +#include #include #include #include @@ -39,21 +40,21 @@ using ::testing::NiceMock; namespace webrtc { namespace { // 5 frames per second at 90 kHz. -const uint32_t kTimestampDelta5Fps = 90000 / 5; -const int kDefaultQp = 54; -const int kDefaultTl0BitrateKbps = 200; -const int kDefaultTl1BitrateKbps = 2000; -const int kFrameRate = 5; -const int kSyncPeriodSeconds = 2; -const int kMaxSyncPeriodSeconds = 4; +constexpr uint32_t kTimestampDelta5Fps = 90000 / 5; +constexpr int kDefaultQp = 54; +constexpr int kDefaultTl0BitrateKbps = 200; +constexpr int kDefaultTl1BitrateKbps = 2000; +constexpr int kFrameRate = 5; +constexpr int kSyncPeriodSeconds = 2; +constexpr int kMaxSyncPeriodSeconds = 4; // Expected flags for corresponding temporal layers. -const int kTl0Flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | - VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF; -const int kTl1Flags = +constexpr int kTl0Flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | + VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF; +constexpr int kTl1Flags = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST; -const int kTl1SyncFlags = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF | - VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST; +constexpr int kTl1SyncFlags = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF | + VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST; const std::vector kDefault2TlBitratesBps = { kDefaultTl0BitrateKbps * 1000, (kDefaultTl1BitrateKbps - kDefaultTl0BitrateKbps) * 1000}; @@ -534,7 +535,7 @@ TEST_F(ScreenshareLayerTest, UpdatesHistograms) { const int kTl0Qp = 35; const int kTl1Qp = 30; for (int64_t timestamp = 0; - timestamp < kTimestampDelta5Fps * 5 * metrics::kMinRunTimeInSeconds; + timestamp < kTimestampDelta5Fps * 5 * metrics::kMinRunTime.seconds(); timestamp += kTimestampDelta5Fps) { tl_config_ = NextFrameConfig(0, timestamp); if (tl_config_.drop_frame) { 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 f129cbc6f8..a8cb3bab12 100644 --- a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc +++ b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include #include +#include #include #include #include diff --git a/modules/video_coding/deprecated/BUILD.gn b/modules/video_coding/deprecated/BUILD.gn index d7227b86cf..533e01798f 100644 --- a/modules/video_coding/deprecated/BUILD.gn +++ b/modules/video_coding/deprecated/BUILD.gn @@ -204,7 +204,6 @@ rtc_library("deprecated_unittests") { "../../../rtc_base:checks", "../../../system_wrappers", "../../../test:create_test_field_trials", - "../../../test:scoped_key_value_config", "../../../test:test_support", "//third_party/abseil-cpp/absl/memory", ] diff --git a/modules/video_coding/deprecated/frame_buffer.cc b/modules/video_coding/deprecated/frame_buffer.cc index 0b7b2a9b7f..84511bbeb9 100644 --- a/modules/video_coding/deprecated/frame_buffer.cc +++ b/modules/video_coding/deprecated/frame_buffer.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/deprecated/frame_buffer.h" -#include - #include +#include #include #include "api/video/encoded_image.h" diff --git a/modules/video_coding/deprecated/receiver_unittest.cc b/modules/video_coding/deprecated/receiver_unittest.cc index 1221b4e02a..f6e30d8480 100644 --- a/modules/video_coding/deprecated/receiver_unittest.cc +++ b/modules/video_coding/deprecated/receiver_unittest.cc @@ -9,9 +9,8 @@ #include "modules/video_coding/deprecated/receiver.h" -#include - #include +#include #include #include #include diff --git a/modules/video_coding/deprecated/session_info.cc b/modules/video_coding/deprecated/session_info.cc index 0c937a4734..19a93b4122 100644 --- a/modules/video_coding/deprecated/session_info.cc +++ b/modules/video_coding/deprecated/session_info.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/deprecated/session_info.h" -#include - #include +#include #include #include #include diff --git a/modules/video_coding/deprecated/session_info_unittest.cc b/modules/video_coding/deprecated/session_info_unittest.cc index e648b77c2c..b965fb186b 100644 --- a/modules/video_coding/deprecated/session_info_unittest.cc +++ b/modules/video_coding/deprecated/session_info_unittest.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/deprecated/session_info.h" -#include - #include +#include #include "api/video/video_codec_type.h" #include "api/video/video_frame_type.h" diff --git a/modules/video_coding/deprecated/stream_generator.cc b/modules/video_coding/deprecated/stream_generator.cc index 2870991505..d9e5cceee2 100644 --- a/modules/video_coding/deprecated/stream_generator.cc +++ b/modules/video_coding/deprecated/stream_generator.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/deprecated/stream_generator.h" -#include - #include +#include #include #include "api/video/video_frame_type.h" diff --git a/modules/video_coding/encoded_frame.cc b/modules/video_coding/encoded_frame.cc index e79e3f6c1d..c69e67a430 100644 --- a/modules/video_coding/encoded_frame.cc +++ b/modules/video_coding/encoded_frame.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/encoded_frame.h" -#include - #include +#include #include #include "api/video/encoded_image.h" diff --git a/modules/video_coding/fec_controller_default.cc b/modules/video_coding/fec_controller_default.cc index 31c5f09687..6ca9724439 100644 --- a/modules/video_coding/fec_controller_default.cc +++ b/modules/video_coding/fec_controller_default.cc @@ -10,10 +10,9 @@ #include "modules/video_coding/fec_controller_default.h" // NOLINT -#include - #include #include +#include #include #include diff --git a/modules/video_coding/fec_controller_unittest.cc b/modules/video_coding/fec_controller_unittest.cc index 4a162e2472..88579af03e 100644 --- a/modules/video_coding/fec_controller_unittest.cc +++ b/modules/video_coding/fec_controller_unittest.cc @@ -10,8 +10,7 @@ #include "api/fec_controller.h" -#include - +#include #include #include "api/environment/environment_factory.h" diff --git a/modules/video_coding/frame_dependencies_calculator.cc b/modules/video_coding/frame_dependencies_calculator.cc index 64a44762f4..ca046f24bc 100644 --- a/modules/video_coding/frame_dependencies_calculator.cc +++ b/modules/video_coding/frame_dependencies_calculator.cc @@ -9,9 +9,8 @@ */ #include "modules/video_coding/frame_dependencies_calculator.h" -#include - #include +#include #include #include #include diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index ab23106f94..88c93170c6 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/generic_decoder.h" -#include - #include +#include #include #include #include @@ -24,6 +23,7 @@ #include "api/field_trials_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "api/video/color_space.h" #include "api/video/encoded_frame.h" #include "api/video/encoded_image.h" #include "api/video/video_content_type.h" @@ -146,20 +146,10 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, return; } - std::optional corruption_score; - if (corruption_score_calculator_ && - frame_info->frame_instrumentation_data.has_value()) { - if (const FrameInstrumentationData* data = - std::get_if( - &*frame_info->frame_instrumentation_data)) { - corruption_score = corruption_score_calculator_->CalculateCorruptionScore( - decodedImage, *data); - } - } - decodedImage.set_ntp_time_ms(frame_info->ntp_time_ms); decodedImage.set_packet_infos(frame_info->packet_infos); decodedImage.set_rotation(frame_info->rotation); + decodedImage.set_color_space(frame_info->color_space); VideoFrame::RenderParameters render_parameters = _timing->RenderParameters(); if (render_parameters.max_composition_delay_in_frames) { // Subtract frames that are in flight. @@ -253,8 +243,17 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, .qp = qp, .decode_time = decode_time, .content_type = frame_info->content_type, - .frame_type = frame_info->frame_type, - .corruption_score = corruption_score}); + .frame_type = frame_info->frame_type}); + + if (corruption_score_calculator_ && + frame_info->frame_instrumentation_data.has_value()) { + if (const FrameInstrumentationData* data = + std::get_if( + &*frame_info->frame_instrumentation_data)) { + corruption_score_calculator_->CalculateCorruptionScore( + decodedImage, *data, frame_info->content_type); + } + } } void VCMDecodedFrameCallback::OnDecoderInfoChanged( @@ -345,6 +344,9 @@ int32_t VCMGenericDecoder::Decode( frame_info.ntp_time_ms = frame.ntp_time_ms_; frame_info.packet_infos = frame.PacketInfos(); frame_info.frame_instrumentation_data = frame_instrumentation_data; + const webrtc::ColorSpace* color_space = frame.ColorSpace(); + if (color_space) + frame_info.color_space = *color_space; // Set correctly only for key frames. Thus, use latest key frame // content type. If the corresponding key frame was lost, decode will fail diff --git a/modules/video_coding/generic_decoder.h b/modules/video_coding/generic_decoder.h index 160576c3f4..83e1f4544e 100644 --- a/modules/video_coding/generic_decoder.h +++ b/modules/video_coding/generic_decoder.h @@ -22,6 +22,7 @@ #include "api/rtp_packet_infos.h" #include "api/sequence_checker.h" #include "api/units/timestamp.h" +#include "api/video/color_space.h" #include "api/video/encoded_frame.h" #include "api/video/encoded_image.h" #include "api/video/video_content_type.h" @@ -64,6 +65,7 @@ struct FrameInfo { std::optional< std::variant> frame_instrumentation_data; + std::optional color_space; }; class VCMDecodedFrameCallback : public DecodedImageCallback { diff --git a/modules/video_coding/generic_decoder_unittest.cc b/modules/video_coding/generic_decoder_unittest.cc index e75c040b04..944480c51e 100644 --- a/modules/video_coding/generic_decoder_unittest.cc +++ b/modules/video_coding/generic_decoder_unittest.cc @@ -41,6 +41,9 @@ #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" +using ::testing::Eq; +using ::testing::Field; +using ::testing::Property; using ::testing::Return; namespace webrtc { @@ -48,10 +51,11 @@ namespace video_coding { class MockCorruptionScoreCalculator : public CorruptionScoreCalculator { public: - MOCK_METHOD(std::optional, + MOCK_METHOD(void, CalculateCorruptionScore, (const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data), + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type), (override)); }; @@ -59,7 +63,6 @@ class ReceiveCallback : public VCMReceiveCallback { public: int32_t OnFrameToRender(const FrameToRender& arguments) override { frames_.push_back(arguments.video_frame); - last_corruption_score_ = arguments.corruption_score; return 0; } @@ -79,14 +82,9 @@ class ReceiveCallback : public VCMReceiveCallback { uint32_t frames_dropped() const { return frames_dropped_; } - std::optional last_corruption_score() const { - return last_corruption_score_; - } - private: std::vector frames_; uint32_t frames_dropped_ = 0; - std::optional last_corruption_score_; }; class GenericDecoderTest : public ::testing::Test { @@ -220,17 +218,13 @@ TEST_F(GenericDecoderTest, IsLowLatencyStreamActivatedByPlayoutDelay) { } TEST_F(GenericDecoderTest, CallCalculateCorruptionScoreInDecoded) { - constexpr double kCorruptionScore = 0.76; - - EXPECT_CALL(corruption_score_calculator_, CalculateCorruptionScore) - .WillOnce(Return(kCorruptionScore)); - constexpr uint32_t kRtpTimestamp = 1; FrameInfo frame_info; - frame_info.frame_instrumentation_data = FrameInstrumentationData{}; + frame_info.frame_instrumentation_data = + FrameInstrumentationData{.sequence_index = 1}; frame_info.rtp_timestamp = kRtpTimestamp; frame_info.decode_start = Timestamp::Zero(); - frame_info.content_type = VideoContentType::UNSPECIFIED; + frame_info.content_type = VideoContentType::SCREENSHARE; frame_info.frame_type = VideoFrameType::kVideoFrameDelta; VideoFrame video_frame = VideoFrame::Builder() .set_video_frame_buffer(I420Buffer::Create(5, 5)) @@ -238,9 +232,12 @@ TEST_F(GenericDecoderTest, CallCalculateCorruptionScoreInDecoded) { .build(); vcm_callback_.Map(std::move(frame_info)); + EXPECT_CALL(corruption_score_calculator_, + CalculateCorruptionScore( + Property(&VideoFrame::rtp_timestamp, Eq(kRtpTimestamp)), + Field(&FrameInstrumentationData::sequence_index, Eq(1)), + VideoContentType::SCREENSHARE)); vcm_callback_.Decoded(video_frame); - - EXPECT_EQ(user_callback_.last_corruption_score(), kCorruptionScore); } } // namespace video_coding diff --git a/modules/video_coding/h264_sprop_parameter_sets.cc b/modules/video_coding/h264_sprop_parameter_sets.cc index 4d398c7d81..9c8e382fdb 100644 --- a/modules/video_coding/h264_sprop_parameter_sets.cc +++ b/modules/video_coding/h264_sprop_parameter_sets.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/h264_sprop_parameter_sets.h" -#include -#include - +#include +#include #include #include #include diff --git a/modules/video_coding/h26x_packet_buffer_unittest.cc b/modules/video_coding/h26x_packet_buffer_unittest.cc index 467184ebef..f786776d41 100644 --- a/modules/video_coding/h26x_packet_buffer_unittest.cc +++ b/modules/video_coding/h26x_packet_buffer_unittest.cc @@ -50,7 +50,7 @@ using H264::NaluType::kStapA; constexpr int kBufferSize = 2048; // Example sprop string from https://tools.ietf.org/html/rfc3984. -const char kExampleSpropString[] = "Z0IACpZTBYmI,aMljiA=="; +constexpr char kExampleSpropString[] = "Z0IACpZTBYmI,aMljiA=="; const std::vector kExampleSpropRawSps{0x67, 0x42, 0x00, 0x0A, 0x96, 0x53, 0x05, 0x89, 0x88}; const std::vector kExampleSpropRawPps{0x68, 0xC9, 0x63, 0x88}; diff --git a/modules/video_coding/include/video_coding_defines.h b/modules/video_coding/include/video_coding_defines.h index 1a81d29bea..88c16ca733 100644 --- a/modules/video_coding/include/video_coding_defines.h +++ b/modules/video_coding/include/video_coding_defines.h @@ -58,7 +58,6 @@ class VCMReceiveCallback { TimeDelta decode_time; VideoContentType content_type; VideoFrameType frame_type; - std::optional corruption_score; }; virtual int32_t OnFrameToRender(const FrameToRender& arguments) = 0; diff --git a/modules/video_coding/loss_notification_controller.cc b/modules/video_coding/loss_notification_controller.cc index 43d4b19f72..97f86dc57a 100644 --- a/modules/video_coding/loss_notification_controller.cc +++ b/modules/video_coding/loss_notification_controller.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/loss_notification_controller.h" -#include - #include +#include #include "api/array_view.h" #include "api/sequence_checker.h" diff --git a/modules/video_coding/loss_notification_controller_unittest.cc b/modules/video_coding/loss_notification_controller_unittest.cc index aba0933682..a5cc6346d0 100644 --- a/modules/video_coding/loss_notification_controller_unittest.cc +++ b/modules/video_coding/loss_notification_controller_unittest.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/loss_notification_controller.h" -#include - #include +#include #include #include #include diff --git a/modules/video_coding/media_opt_util.cc b/modules/video_coding/media_opt_util.cc index 1a7ba66554..6b68a2ce94 100644 --- a/modules/video_coding/media_opt_util.cc +++ b/modules/video_coding/media_opt_util.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/media_opt_util.h" -#include - #include +#include #include #include #include diff --git a/modules/video_coding/nack_requester_unittest.cc b/modules/video_coding/nack_requester_unittest.cc index 411ddb22a0..85711e2034 100644 --- a/modules/video_coding/nack_requester_unittest.cc +++ b/modules/video_coding/nack_requester_unittest.cc @@ -90,7 +90,7 @@ class TestNackRequester : public ::testing::Test, TaskQueueBase::Current(), nack_periodic_processor_.get(), clock_.get(), this, this, CreateTestFieldTrials()); nack_module_->UpdateRtt(kDefaultRttMs); - return *nack_module_.get(); + return *nack_module_; } static constexpr int64_t kDefaultRttMs = 20; diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc index cfc16d5854..961b41e66f 100644 --- a/modules/video_coding/packet_buffer.cc +++ b/modules/video_coding/packet_buffer.cc @@ -10,10 +10,9 @@ #include "modules/video_coding/packet_buffer.h" -#include - #include #include +#include #include #include #include diff --git a/modules/video_coding/svc/BUILD.gn b/modules/video_coding/svc/BUILD.gn index 6cb19bfe8f..4175daafce 100644 --- a/modules/video_coding/svc/BUILD.gn +++ b/modules/video_coding/svc/BUILD.gn @@ -156,7 +156,6 @@ if (rtc_include_tests) { "../../../api/video_codecs:video_codecs_api", "../../../rtc_base:checks", "../../../test:create_test_field_trials", - "../../../test:explicit_key_value_config", "../../../test:test_support", "../codecs/av1:av1_svc_config", "//third_party/abseil-cpp/absl/container:inlined_vector", diff --git a/modules/video_coding/svc/scalability_structure_test_helpers.cc b/modules/video_coding/svc/scalability_structure_test_helpers.cc index e5cb1ef1d2..004b7d245e 100644 --- a/modules/video_coding/svc/scalability_structure_test_helpers.cc +++ b/modules/video_coding/svc/scalability_structure_test_helpers.cc @@ -9,10 +9,9 @@ */ #include "modules/video_coding/svc/scalability_structure_test_helpers.h" -#include - #include #include +#include #include #include diff --git a/modules/video_coding/svc/scalability_structure_unittest.cc b/modules/video_coding/svc/scalability_structure_unittest.cc index 9a66df3a10..849f08f147 100644 --- a/modules/video_coding/svc/scalability_structure_unittest.cc +++ b/modules/video_coding/svc/scalability_structure_unittest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include +#include #include #include #include diff --git a/modules/video_coding/timing/BUILD.gn b/modules/video_coding/timing/BUILD.gn index c242f3d4c4..ea1862f98f 100644 --- a/modules/video_coding/timing/BUILD.gn +++ b/modules/video_coding/timing/BUILD.gn @@ -89,7 +89,6 @@ rtc_library("timestamp_extrapolator") { "timestamp_extrapolator.h", ] deps = [ - "../../../api:field_trials", "../../../api:field_trials_view", "../../../api/units:time_delta", "../../../api/units:timestamp", @@ -150,10 +149,9 @@ rtc_library("timing_unittests") { "../../../api/units:timestamp", "../../../rtc_base:histogram_percentile_counter", "../../../rtc_base:timeutils", + "../../../system_wrappers", "../../../system_wrappers:metrics", - "../../../system_wrappers:system_wrappers", "../../../test:create_test_field_trials", - "../../../test:scoped_key_value_config", "../../../test:test_support", ] } diff --git a/modules/video_coding/timing/jitter_estimator.cc b/modules/video_coding/timing/jitter_estimator.cc index 7b394d13f8..0786a3e8da 100644 --- a/modules/video_coding/timing/jitter_estimator.cc +++ b/modules/video_coding/timing/jitter_estimator.cc @@ -10,10 +10,9 @@ #include "modules/video_coding/timing/jitter_estimator.h" -#include -#include - #include +#include +#include #include #include "absl/strings/string_view.h" diff --git a/modules/video_coding/timing/jitter_estimator_unittest.cc b/modules/video_coding/timing/jitter_estimator_unittest.cc index f12e49eda3..f30ab2c248 100644 --- a/modules/video_coding/timing/jitter_estimator_unittest.cc +++ b/modules/video_coding/timing/jitter_estimator_unittest.cc @@ -9,8 +9,7 @@ #include "modules/video_coding/timing/jitter_estimator.h" -#include - +#include #include #include #include diff --git a/modules/video_coding/timing/rtt_filter.cc b/modules/video_coding/timing/rtt_filter.cc index 6dd42af7e6..6bc361f10b 100644 --- a/modules/video_coding/timing/rtt_filter.cc +++ b/modules/video_coding/timing/rtt_filter.cc @@ -10,11 +10,10 @@ #include "modules/video_coding/timing/rtt_filter.h" -#include -#include - #include +#include #include +#include #include "absl/algorithm/container.h" #include "api/units/time_delta.h" diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc index 6f1be747eb..776d984dc2 100644 --- a/modules/video_coding/timing/timestamp_extrapolator.cc +++ b/modules/video_coding/timing/timestamp_extrapolator.cc @@ -11,6 +11,7 @@ #include "modules/video_coding/timing/timestamp_extrapolator.h" #include +#include #include #include #include @@ -32,6 +33,7 @@ constexpr double kLambda = 1; constexpr int kStartUpFilterDelayInPackets = 2; constexpr double kP00 = 1.0; constexpr double kP11 = 1e10; +constexpr double kStartResidualVariance = 3000 * 3000; } // namespace @@ -48,6 +50,39 @@ TimestampExtrapolator::Config TimestampExtrapolator::Config::ParseAndValidate( << config.hard_reset_timeout; config.hard_reset_timeout = defaults.hard_reset_timeout; } + if (config.hard_reset_rtp_timestamp_jump_threshold <= 0) { + RTC_LOG(LS_WARNING) + << "Skipping invalid hard_reset_rtp_timestamp_jump_threshold=" + << config.hard_reset_rtp_timestamp_jump_threshold; + config.hard_reset_rtp_timestamp_jump_threshold = + defaults.hard_reset_rtp_timestamp_jump_threshold; + } + if (config.outlier_rejection_startup_delay < 0) { + RTC_LOG(LS_WARNING) << "Skipping invalid outlier_rejection_startup_delay=" + << config.outlier_rejection_startup_delay; + config.outlier_rejection_startup_delay = + defaults.outlier_rejection_startup_delay; + } + if (config.outlier_rejection_max_consecutive <= 0) { + RTC_LOG(LS_WARNING) << "Skipping invalid outlier_rejection_max_consecutive=" + << config.outlier_rejection_max_consecutive; + config.outlier_rejection_max_consecutive = + defaults.outlier_rejection_max_consecutive; + } + if (config.outlier_rejection_forgetting_factor < 0 || + config.outlier_rejection_forgetting_factor >= 1) { + RTC_LOG(LS_WARNING) + << "Skipping invalid outlier_rejection_forgetting_factor=" + << config.outlier_rejection_forgetting_factor; + config.outlier_rejection_forgetting_factor = + defaults.outlier_rejection_forgetting_factor; + } + if (config.outlier_rejection_stddev.has_value() && + *config.outlier_rejection_stddev <= 0) { + RTC_LOG(LS_WARNING) << "Skipping invalid outlier_rejection_stddev=" + << *config.outlier_rejection_stddev; + config.outlier_rejection_stddev = defaults.outlier_rejection_stddev; + } if (config.alarm_threshold <= 0) { RTC_LOG(LS_WARNING) << "Skipping invalid alarm_threshold=" << config.alarm_threshold; @@ -73,6 +108,9 @@ TimestampExtrapolator::TimestampExtrapolator( start_(Timestamp::Zero()), prev_(Timestamp::Zero()), packet_count_(0), + residual_mean_(0), + residual_variance_(kStartResidualVariance), + outliers_consecutive_count_(0), detector_accumulator_pos_(0), detector_accumulator_neg_(0) { Reset(start); @@ -99,24 +137,48 @@ void TimestampExtrapolator::Reset(Timestamp start) { p_[0][1] = p_[1][0] = 0; unwrapper_ = RtpTimestampUnwrapper(); packet_count_ = 0; + // Hard outlier rejection. + residual_mean_ = 0.0; + residual_variance_ = kStartResidualVariance; + outliers_consecutive_count_ = 0; + // Soft outlier attenuation. detector_accumulator_pos_ = 0; detector_accumulator_neg_ = 0; } void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) { + // Hard reset based local clock timeouts. if (now - prev_ > config_.hard_reset_timeout) { - // No complete frame within the timeout. Reset(now); } else { prev_ = now; } + const int64_t unwrapped_ts90khz = unwrapper_.Unwrap(ts90khz); + + // Hard reset based on large RTP timestamp jumps. This is only enabled if + // outlier rejection is enabled, since that feature would by itself + // consistently block any long-term static offset changes due to, e.g., + // remote clock source replacements. + if (config_.OutlierRejectionEnabled() && prev_unwrapped_timestamp_) { + // Predict the expected RTP timestamp change based on elapsed wall clock + // time. + int64_t expected_rtp_diff = + static_cast((now - prev_).ms() * w_[0]); + int64_t actual_rtp_diff = unwrapped_ts90khz - *prev_unwrapped_timestamp_; + int64_t rtp_jump = actual_rtp_diff - expected_rtp_diff; + if (std::abs(rtp_jump) > config_.hard_reset_rtp_timestamp_jump_threshold) { + RTC_LOG(LS_WARNING) << "Large jump in RTP timestamp detected. " + "Difference between actual and expected change: " + << rtp_jump << " ticks. Resetting filter."; + Reset(now); + } + } + // Remove offset to prevent badly scaled matrices const TimeDelta offset = now - start_; double t_ms = offset.ms(); - int64_t unwrapped_ts90khz = unwrapper_.Unwrap(ts90khz); - if (!first_unwrapped_timestamp_) { // Make an initial guess of the offset, // should be almost correct since t_ms - start @@ -128,23 +190,46 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) { double residual = (static_cast(unwrapped_ts90khz) - *first_unwrapped_timestamp_) - t_ms * w_[0] - w_[1]; + + // Hard outlier rejection: reject outliers and avoid updating the filter state + // for frames whose residuals are too large. + if (config_.OutlierRejectionEnabled() && OutlierDetection(residual)) { + ++outliers_consecutive_count_; + if (outliers_consecutive_count_ <= + config_.outlier_rejection_max_consecutive) { + // This appears to be a transient spike. Reject it. + return; + } else { + // This appears to be a persistent delay change. Force the filter to + // adapt. + SoftReset(); + } + } + // Frame is an inlier, or we have reached `outlier_rejection_max_consecutive`. + outliers_consecutive_count_ = 0; + + // Soft outlier attenuation: boost the filter's uncertainty if the integrated + // delay has changed too much. + // TODO(brandtr): Move the packet count check into DelayChangeDetection. if (DelayChangeDetection(residual) && packet_count_ >= kStartUpFilterDelayInPackets) { // Force the filter to adjust its offset parameter by changing // the uncertainties. Don't do this during startup. - if (config_.reset_full_cov_on_alarm) { - p_[0][0] = kP00; - p_[0][1] = p_[1][0] = 0; - } - p_[1][1] = kP11; + SoftReset(); } - if (prev_unwrapped_timestamp_ && - unwrapped_ts90khz < prev_unwrapped_timestamp_) { + // If hard outlier rejection is enabled, we handle large RTP timestamp jumps + // above. + if (!config_.OutlierRejectionEnabled() && + (prev_unwrapped_timestamp_ && + unwrapped_ts90khz < prev_unwrapped_timestamp_)) { // Drop reordered frames. return; } + // Update recursive least squares filter. + // TODO(b/428657776): Document better. + // T = [t(k) 1]'; // that = T'*w; // K = P*T/(lambda + T'*P*T); @@ -209,15 +294,55 @@ std::optional TimestampExtrapolator::ExtrapolateLocalTime( return start_ + diff; } -bool TimestampExtrapolator::DelayChangeDetection(double error) { +void TimestampExtrapolator::SoftReset() { + if (config_.reset_full_cov_on_alarm) { + p_[0][0] = kP00; + p_[0][1] = p_[1][0] = 0; + } + p_[1][1] = kP11; +} + +bool TimestampExtrapolator::OutlierDetection(double residual) { + if (!config_.outlier_rejection_stddev.has_value()) { + return false; + } + + if (packet_count_ >= config_.outlier_rejection_startup_delay) { + double threshold = + *config_.outlier_rejection_stddev * std::sqrt(residual_variance_); + // Outlier frames trigger the alarm. + // We intentionally use a symmetric detection here, meaning that + // significantly early frames are also alarmed on. The main reason is to + // ensure a symmetric update to the running statistics below. + if (std::abs(residual - residual_mean_) > threshold) { + // Alarm. + return true; + } + } + + // Update residual statistics only with inliers. + double forgetting_factor = config_.outlier_rejection_forgetting_factor; + residual_mean_ = + forgetting_factor * residual_mean_ + (1.0 - forgetting_factor) * residual; + double residual_deviation = residual - residual_mean_; + double squared_residual_deviation = residual_deviation * residual_deviation; + residual_variance_ = + std::max(forgetting_factor * residual_variance_ + + (1.0 - forgetting_factor) * squared_residual_deviation, + 1.0); + + return false; +} + +bool TimestampExtrapolator::DelayChangeDetection(double residual) { // CUSUM detection of sudden delay changes double acc_max_error = static_cast(config_.acc_max_error); - error = (error > 0) ? std::min(error, acc_max_error) - : std::max(error, -acc_max_error); + residual = (residual > 0) ? std::min(residual, acc_max_error) + : std::max(residual, -acc_max_error); detector_accumulator_pos_ = std::max( - detector_accumulator_pos_ + error - config_.acc_drift, double{0}); + detector_accumulator_pos_ + residual - config_.acc_drift, double{0}); detector_accumulator_neg_ = std::min( - detector_accumulator_neg_ + error + config_.acc_drift, double{0}); + detector_accumulator_neg_ + residual + config_.acc_drift, double{0}); if (detector_accumulator_pos_ > config_.alarm_threshold || detector_accumulator_neg_ < -config_.alarm_threshold) { // Alarm diff --git a/modules/video_coding/timing/timestamp_extrapolator.h b/modules/video_coding/timing/timestamp_extrapolator.h index aed2e3f95d..bcce59b068 100644 --- a/modules/video_coding/timing/timestamp_extrapolator.h +++ b/modules/video_coding/timing/timestamp_extrapolator.h @@ -25,6 +25,22 @@ namespace webrtc { +// The `TimestampExtrapolator` is an adaptive filter that estimates the +// local clock time of incoming RTP timestamps. It's main purpose is to handle +// clock drift and clock offset, not to model network behaviour. +// +// The mechanisms applied for this are: +// * Recursive least-squares filter for estimating clock skew and clock offset. +// * Hard reset on wall clock timeout. +// * Hard reset on large incoming RTP timestamp jumps. +// * Hard outlier rejection based on the difference between the predicted and +// the actual wall clock time for an RTP timestamp. +// * Soft outlier attenuation based on the integrated (CUSUM style) difference +// between predicted and actual wall clock time for an RTP timestamp. +// +// Not all of the mechanisms are enabled by default. Use the field trial string +// to experiment with different settings. +// // Not thread safe. class TimestampExtrapolator { public: @@ -42,6 +58,13 @@ class TimestampExtrapolator { // clang-format off return StructParametersParser::Create( "hard_reset_timeout", &hard_reset_timeout, + "hard_reset_rtp_timestamp_jump_threshold", + &hard_reset_rtp_timestamp_jump_threshold, + "outlier_rejection_startup_delay", &outlier_rejection_startup_delay, + "outlier_rejection_max_consecutive", &outlier_rejection_max_consecutive, + "outlier_rejection_forgetting_factor", + &outlier_rejection_forgetting_factor, + "outlier_rejection_stddev", &outlier_rejection_stddev, "alarm_threshold", &alarm_threshold, "acc_drift", &acc_drift, "acc_max_error", &acc_max_error, @@ -49,9 +72,44 @@ class TimestampExtrapolator { // clang-format on } + bool OutlierRejectionEnabled() const { + return outlier_rejection_stddev.has_value(); + } + + // -- Hard reset behaviour -- + // If a frame has not been received within this timeout, do a full reset. TimeDelta hard_reset_timeout = TimeDelta::Seconds(10); + // A jump in the RTP timestamp of this magnitude, not accounted for by the + // passage of time, is considered a source clock replacement and will + // trigger a filter reset. 900000 ticks = 10 seconds. + // (Only enabled if hard outlier rejection is enabled.) + int hard_reset_rtp_timestamp_jump_threshold = 900'000; + + // -- Hard outlier rejection -- + + // Number of frames to wait before starting to update the residual + // statistics. 300 frames = 10 seconds@30fps. + int outlier_rejection_startup_delay = 300; + + // Number of consecutive frames that are allowed to be treated as outliers. + // If more frames than these are outliers, hard outlier rejection stops + // and soft outlier attentuation starts. + // 150 frames = 5 seconds@30fps. + int outlier_rejection_max_consecutive = 150; + + // Smoothing factor for the residual statistics. + // Half-life is log(0.5)/log(0.999) ~= 693 frames ~= 23 seconds@30fps. + double outlier_rejection_forgetting_factor = 0.999; + + // If set, will reject outliers based on this number of standard deviations + // of the filtered residuals. + // Setting this field to non-nullopt enables hard outlier rejection. + std::optional outlier_rejection_stddev = std::nullopt; + + // -- Soft outlier attenuation -- + // Alarm on sudden delay change if the (filtered; see below) accumulated // residuals are larger than this number of RTP ticks. After the // startup period, an alarm will result in a full or partial reset of the @@ -74,15 +132,21 @@ class TimestampExtrapolator { TimestampExtrapolator(Timestamp start, const FieldTrialsView& field_trials); ~TimestampExtrapolator(); + + // Update the filter with a new incoming local timestamp/RTP timestamp pair. void Update(Timestamp now, uint32_t ts90khz); + + // Return the expected local timestamp for an RTP timestamp. std::optional ExtrapolateLocalTime(uint32_t timestamp90khz) const; + void Reset(Timestamp start); Config GetConfigForTest() const { return config_; } private: - void CheckForWrapArounds(uint32_t ts90khz); - bool DelayChangeDetection(double error); + void SoftReset(); + bool OutlierDetection(double residual); + bool DelayChangeDetection(double residual); const Config config_; @@ -94,6 +158,13 @@ class TimestampExtrapolator { RtpTimestampUnwrapper unwrapper_; std::optional prev_unwrapped_timestamp_; int packet_count_; + + // Running residual statistics for the hard outlier rejection. + double residual_mean_; + double residual_variance_; + int outliers_consecutive_count_; + + // Integrated residual statistics for the soft outlier attenuation. double detector_accumulator_pos_; double detector_accumulator_neg_; }; diff --git a/modules/video_coding/timing/timestamp_extrapolator_unittest.cc b/modules/video_coding/timing/timestamp_extrapolator_unittest.cc index f03a50e2a0..5f932ad780 100644 --- a/modules/video_coding/timing/timestamp_extrapolator_unittest.cc +++ b/modules/video_coding/timing/timestamp_extrapolator_unittest.cc @@ -10,8 +10,7 @@ #include "modules/video_coding/timing/timestamp_extrapolator.h" -#include - +#include #include #include #include @@ -340,6 +339,11 @@ TEST(TimestampExtrapolatorTest, SetsValidConfig) { clock.CurrentTime(), CreateTestFieldTrials( "WebRTC-TimestampExtrapolatorConfig/" "hard_reset_timeout:1s," + "hard_reset_rtp_timestamp_jump_threshold:45000," + "outlier_rejection_startup_delay:123," + "outlier_rejection_max_consecutive:456," + "outlier_rejection_forgetting_factor:0.987," + "outlier_rejection_stddev:3.5," "alarm_threshold:123," "acc_drift:456," "acc_max_error:789," @@ -347,7 +351,13 @@ TEST(TimestampExtrapolatorTest, SetsValidConfig) { // clang-format on TimestampExtrapolator::Config config = ts_extrapolator.GetConfigForTest(); + EXPECT_TRUE(config.OutlierRejectionEnabled()); EXPECT_EQ(config.hard_reset_timeout, TimeDelta::Seconds(1)); + EXPECT_EQ(config.hard_reset_rtp_timestamp_jump_threshold, 45000); + EXPECT_EQ(config.outlier_rejection_startup_delay, 123); + EXPECT_EQ(config.outlier_rejection_max_consecutive, 456); + EXPECT_EQ(config.outlier_rejection_forgetting_factor, 0.987); + EXPECT_EQ(config.outlier_rejection_stddev, 3.5); EXPECT_EQ(config.alarm_threshold, 123); EXPECT_EQ(config.acc_drift, 456); EXPECT_EQ(config.acc_max_error, 789); @@ -361,16 +371,181 @@ TEST(TimestampExtrapolatorTest, DoesNotSetInvalidConfig) { clock.CurrentTime(), CreateTestFieldTrials( "WebRTC-TimestampExtrapolatorConfig/" "hard_reset_timeout:-1s," + "hard_reset_rtp_timestamp_jump_threshold:-1," + "outlier_rejection_startup_delay:-1," + "outlier_rejection_max_consecutive:0," + "outlier_rejection_forgetting_factor:1.1," + "outlier_rejection_stddev:-1," "alarm_threshold:-123," "acc_drift:-456," "acc_max_error:-789/")); // clang-format on TimestampExtrapolator::Config config = ts_extrapolator.GetConfigForTest(); + EXPECT_FALSE(config.OutlierRejectionEnabled()); EXPECT_EQ(config.hard_reset_timeout, TimeDelta::Seconds(10)); + EXPECT_EQ(config.hard_reset_rtp_timestamp_jump_threshold, 900000); + EXPECT_EQ(config.outlier_rejection_startup_delay, 300); + EXPECT_EQ(config.outlier_rejection_max_consecutive, 150); + EXPECT_EQ(config.outlier_rejection_forgetting_factor, 0.999); + EXPECT_FALSE(config.outlier_rejection_stddev.has_value()); EXPECT_EQ(config.alarm_threshold, 60000); EXPECT_EQ(config.acc_drift, 6600); EXPECT_EQ(config.acc_max_error, 7000); } +TEST(TimestampExtrapolatorTest, ExtrapolationNotAffectedByRtpTimestampJump) { + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator extrapolator( + clock.CurrentTime(), + CreateTestFieldTrials("WebRTC-TimestampExtrapolatorConfig/" + "outlier_rejection_stddev:3,hard_reset_rtp_" + "timestamp_jump_threshold:900000/")); + + // Stabilize filter. + uint32_t rtp = 0; + for (int i = 0; i < 2000; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + } + + // Last frame before jump is expected on time. + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); + + // Next frame arrives on time, but with a 20 second RTP timestamp jump. + rtp += 2 * 900000; // 20 seconds. + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); + + // First frame after jump is expected on time. + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); +} + +TEST(TimestampExtrapolatorTest, ExtrapolationNotAffectedByFrameOutliers) { + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator extrapolator( + clock.CurrentTime(), + CreateTestFieldTrials( + "WebRTC-TimestampExtrapolatorConfig/outlier_rejection_stddev:3/")); + + // Stabilize filter. + uint32_t rtp = 0; + for (int i = 0; i < 2000; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + } + + // Last frame before outlier arrives on time. + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); + + // Outlier frame arrives 1000ms late, but is expected on time. + rtp += kRtpHz / k25Fps; + Timestamp expected = clock.CurrentTime() + k25FpsDelay; + clock.AdvanceTime(TimeDelta::Millis(1000)); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), expected); + + // Congested frames arrive back-to-back, but are expected on time. + for (int i = 0; i < 24; ++i) { + rtp += kRtpHz / k25Fps; + expected += k25FpsDelay; + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), expected); + } + + // Regular frame after outliers arrives on time. + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); +} + +TEST(TimestampExtrapolatorTest, + ExtrapolationAffectedByFrameOutliersAfterRejectionPeriod) { + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator extrapolator( + clock.CurrentTime(), + CreateTestFieldTrials( + "WebRTC-TimestampExtrapolatorConfig/" + "outlier_rejection_stddev:3,outlier_rejection_max_consecutive:20/")); + + // Stabilize filter. + uint32_t rtp = 0; + for (int i = 0; i < 2000; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + } + + // Last frame before outlier arrives on time. + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); + + // Outlier frame arrives 1000ms late, but is expected on time. + rtp += kRtpHz / k25Fps; + Timestamp expected = clock.CurrentTime() + k25FpsDelay; + clock.AdvanceTime(TimeDelta::Millis(1000)); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), expected); + + // Congested frames arrive back-to-back. The first 19 are expected on time. + for (int i = 0; i < 19; ++i) { + rtp += kRtpHz / k25Fps; + expected += k25FpsDelay; + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), expected); + } + + // After the 20 consecutive outlier frames, the filter soft resets and starts + // expecting frames on the new baseline, which is partially congested. + rtp += kRtpHz / k25Fps; + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); + for (int i = 0; i < 4; ++i) { + rtp += kRtpHz / k25Fps; + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), + clock.CurrentTime() + (i + 1) * k25FpsDelay); + } + + // Now we have caught up with realtime, but since the soft reset happened + // 4 frames too early, the new baseline is 4 * 1000/25 = 160ms off. + for (int i = 0; i < 10; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), + clock.CurrentTime() + 4 * k25FpsDelay); + } + + // Let the filter stabilize at a realtime rate again. + for (int i = 0; i < 2000; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + } + + // After the stabilization, the 160ms congestion offset has been canceled. + for (int i = 0; i < 10; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_EQ(extrapolator.ExtrapolateLocalTime(rtp), clock.CurrentTime()); + } +} + } // namespace webrtc diff --git a/modules/video_coding/utility/frame_dropper_unittest.cc b/modules/video_coding/utility/frame_dropper_unittest.cc index ac3fade782..2ec4fdeb95 100644 --- a/modules/video_coding/utility/frame_dropper_unittest.cc +++ b/modules/video_coding/utility/frame_dropper_unittest.cc @@ -18,14 +18,14 @@ namespace webrtc { namespace { -const float kTargetBitRateKbps = 300; -const float kIncomingFrameRate = 30; -const size_t kFrameSizeBytes = 1250; +constexpr float kTargetBitRateKbps = 300; +constexpr float kIncomingFrameRate = 30; +constexpr size_t kFrameSizeBytes = 1250; -const size_t kLargeFrameSizeBytes = 25000; +constexpr size_t kLargeFrameSizeBytes = 25000; -const bool kIncludeKeyFrame = true; -const bool kDoNotIncludeKeyFrame = false; +constexpr bool kIncludeKeyFrame = true; +constexpr bool kDoNotIncludeKeyFrame = false; } // namespace diff --git a/modules/video_coding/utility/framerate_controller_deprecated.cc b/modules/video_coding/utility/framerate_controller_deprecated.cc index 56fd631fa5..4e41442e1d 100644 --- a/modules/video_coding/utility/framerate_controller_deprecated.cc +++ b/modules/video_coding/utility/framerate_controller_deprecated.cc @@ -10,8 +10,7 @@ #include "modules/video_coding/utility/framerate_controller_deprecated.h" -#include - +#include #include #include diff --git a/modules/video_coding/utility/framerate_controller_deprecated_unittest.cc b/modules/video_coding/utility/framerate_controller_deprecated_unittest.cc index dc4d45b9f2..544bdbb866 100644 --- a/modules/video_coding/utility/framerate_controller_deprecated_unittest.cc +++ b/modules/video_coding/utility/framerate_controller_deprecated_unittest.cc @@ -10,8 +10,7 @@ #include "modules/video_coding/utility/framerate_controller_deprecated.h" -#include - +#include #include #include "test/gtest.h" diff --git a/modules/video_coding/utility/ivf_file_writer_unittest.cc b/modules/video_coding/utility/ivf_file_writer_unittest.cc index bc6c87722f..2b791820cb 100644 --- a/modules/video_coding/utility/ivf_file_writer_unittest.cc +++ b/modules/video_coding/utility/ivf_file_writer_unittest.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/utility/ivf_file_writer.h" -#include - #include +#include #include #include @@ -26,8 +25,8 @@ namespace webrtc { namespace { -const int kHeaderSize = 32; -const int kFrameHeaderSize = 12; +constexpr int kHeaderSize = 32; +constexpr int kFrameHeaderSize = 12; uint8_t dummy_payload[4] = {0, 1, 2, 3}; // As the default parameter when the width and height of encodedImage are 0, // the values are copied from ivf_file_writer.cc diff --git a/modules/video_coding/utility/qp_parser_unittest.cc b/modules/video_coding/utility/qp_parser_unittest.cc index a7fe387015..2facc5b018 100644 --- a/modules/video_coding/utility/qp_parser_unittest.cc +++ b/modules/video_coding/utility/qp_parser_unittest.cc @@ -10,8 +10,7 @@ #include "modules/video_coding/utility/qp_parser.h" -#include - +#include #include #include @@ -24,14 +23,14 @@ namespace webrtc { namespace { // ffmpeg -s 16x16 -f rawvideo -pix_fmt rgb24 -r 30 -i /dev/zero -c:v libvpx // -qmin 20 -qmax 20 -crf 20 -frames:v 1 -y out.ivf -const uint8_t kCodedFrameVp8Qp25[] = { +constexpr uint8_t kCodedFrameVp8Qp25[] = { 0x10, 0x02, 0x00, 0x9d, 0x01, 0x2a, 0x10, 0x00, 0x10, 0x00, 0x02, 0x47, 0x08, 0x85, 0x85, 0x88, 0x85, 0x84, 0x88, 0x0c, 0x82, 0x00, 0x0c, 0x0d, 0x60, 0x00, 0xfe, 0xfc, 0x5c, 0xd0}; // ffmpeg -s 16x16 -f rawvideo -pix_fmt rgb24 -r 30 -i /dev/zero -c:v libvpx-vp9 // -qmin 24 -qmax 24 -crf 24 -frames:v 1 -y out.ivf -const uint8_t kCodedFrameVp9Qp96[] = { +constexpr uint8_t kCodedFrameVp9Qp96[] = { 0xa2, 0x49, 0x83, 0x42, 0xe0, 0x00, 0xf0, 0x00, 0xf6, 0x00, 0x38, 0x24, 0x1c, 0x18, 0xc0, 0x00, 0x00, 0x30, 0x70, 0x00, 0x00, 0x4a, 0xa7, 0xff, 0xfc, 0xb9, 0x01, 0xbf, 0xff, 0xff, @@ -39,22 +38,22 @@ const uint8_t kCodedFrameVp9Qp96[] = { // ffmpeg -s 16x16 -f rawvideo -pix_fmt yuv420p -r 30 -i /dev/zero -c:v libx264 // -qmin 38 -qmax 38 -crf 38 -profile:v baseline -frames:v 2 -y out.264 -const uint8_t kCodedFrameH264SpsPpsIdrQp38[] = { +constexpr uint8_t kCodedFrameH264SpsPpsIdrQp38[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xc0, 0x0a, 0xd9, 0x1e, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x48, 0x99, 0x20, 0x00, 0x00, 0x00, 0x01, 0x68, 0xcb, 0x80, 0xc4, 0xb2, 0x00, 0x00, 0x01, 0x65, 0x88, 0x84, 0xf1, 0x18, 0xa0, 0x00, 0x20, 0x5b, 0x1c, 0x00, 0x04, 0x07, 0xe3, 0x80, 0x00, 0x80, 0xfe}; -const uint8_t kCodedFrameH264SpsPpsIdrQp49[] = { +constexpr uint8_t kCodedFrameH264SpsPpsIdrQp49[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xc0, 0x0a, 0xd9, 0x1e, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x48, 0x99, 0x20, 0x00, 0x00, 0x00, 0x01, 0x68, 0xcb, 0x80, 0x5d, 0x2c, 0x80, 0x00, 0x00, 0x01, 0x65, 0x88, 0x84, 0xf1, 0x18, 0xa0, 0x00, 0x5e, 0x38, 0x00, 0x08, 0x03, 0xc7, 0x00, 0x01, 0x00, 0x7c}; -const uint8_t kCodedFrameH264InterSliceQpDelta0[] = {0x00, 0x00, 0x00, 0x01, - 0x41, 0x9a, 0x39, 0xea}; +constexpr uint8_t kCodedFrameH264InterSliceQpDelta0[] = { + 0x00, 0x00, 0x00, 0x01, 0x41, 0x9a, 0x39, 0xea}; } // namespace diff --git a/modules/video_coding/utility/quality_scaler_unittest.cc b/modules/video_coding/utility/quality_scaler_unittest.cc index dca0f4a9af..677654c6d1 100644 --- a/modules/video_coding/utility/quality_scaler_unittest.cc +++ b/modules/video_coding/utility/quality_scaler_unittest.cc @@ -24,10 +24,10 @@ namespace webrtc { namespace { -const int kFramerate = 30; -const int kLowQp = 15; -const int kHighQp = 40; -const int kMinFramesNeededToScale = 60; // From quality_scaler.cc. +constexpr int kFramerate = 30; +constexpr int kLowQp = 15; +constexpr int kHighQp = 40; +constexpr int kMinFramesNeededToScale = 60; // From quality_scaler.cc. constexpr TimeDelta kDefaultTimeout = TimeDelta::Millis(150); } // namespace diff --git a/modules/video_coding/utility/simulcast_rate_allocator.cc b/modules/video_coding/utility/simulcast_rate_allocator.cc index 5083d1b888..400ea6f9a3 100644 --- a/modules/video_coding/utility/simulcast_rate_allocator.cc +++ b/modules/video_coding/utility/simulcast_rate_allocator.cc @@ -10,10 +10,9 @@ #include "modules/video_coding/utility/simulcast_rate_allocator.h" -#include - #include #include +#include #include #include #include diff --git a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc index 8909182707..4392e7b12a 100644 --- a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc +++ b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc @@ -46,7 +46,7 @@ constexpr uint32_t kSimulcastScreenshareMinBitrateKbps = 600; constexpr uint32_t kSimulcastScreenshareMaxBitrateKbps = 1250; // Default video hysteresis factor: allocatable bitrate for next layer must // exceed 20% of min setting in order to be initially turned on. -const double kDefaultHysteresis = 1.2; +constexpr double kDefaultHysteresis = 1.2; class MockTemporalLayers : public Vp8FrameBufferController { public: diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc index 4ad2060f35..c6f9b5af30 100644 --- a/modules/video_coding/video_codec_initializer.cc +++ b/modules/video_coding/video_codec_initializer.cc @@ -10,10 +10,9 @@ #include "modules/video_coding/include/video_codec_initializer.h" -#include -#include - #include +#include +#include #include #include diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc index 045c86a6ad..6c827b7b91 100644 --- a/modules/video_coding/video_codec_initializer_unittest.cc +++ b/modules/video_coding/video_codec_initializer_unittest.cc @@ -10,9 +10,8 @@ #include "modules/video_coding/include/video_codec_initializer.h" -#include -#include - +#include +#include #include #include #include @@ -40,21 +39,21 @@ namespace webrtc { namespace { -const int kDefaultWidth = 1280; -const int kDefaultHeight = 720; -const int kDefaultFrameRate = 30; -const uint32_t kDefaultMinBitrateBps = 60000; -const uint32_t kDefaultTargetBitrateBps = 2000000; -const uint32_t kDefaultMaxBitrateBps = 2000000; -const uint32_t kDefaultMinTransmitBitrateBps = 400000; -const int kDefaultMaxQp = 48; -const uint32_t kScreenshareTl0BitrateBps = 120000; -const uint32_t kScreenshareConferenceTl0BitrateBps = 200000; -const uint32_t kScreenshareCodecTargetBitrateBps = 200000; -const uint32_t kScreenshareDefaultFramerate = 5; +constexpr int kDefaultWidth = 1280; +constexpr int kDefaultHeight = 720; +constexpr int kDefaultFrameRate = 30; +constexpr uint32_t kDefaultMinBitrateBps = 60000; +constexpr uint32_t kDefaultTargetBitrateBps = 2000000; +constexpr uint32_t kDefaultMaxBitrateBps = 2000000; +constexpr uint32_t kDefaultMinTransmitBitrateBps = 400000; +constexpr int kDefaultMaxQp = 48; +constexpr uint32_t kScreenshareTl0BitrateBps = 120000; +constexpr uint32_t kScreenshareConferenceTl0BitrateBps = 200000; +constexpr uint32_t kScreenshareCodecTargetBitrateBps = 200000; +constexpr uint32_t kScreenshareDefaultFramerate = 5; // Bitrates for the temporal layers of the higher screenshare simulcast stream. -const uint32_t kHighScreenshareTl0Bps = 800000; -const uint32_t kHighScreenshareTl1Bps = 1200000; +constexpr uint32_t kHighScreenshareTl0Bps = 800000; +constexpr uint32_t kHighScreenshareTl1Bps = 1200000; } // namespace // TODO(sprang): Extend coverage to handle the rest of the codec initializer. diff --git a/modules/video_coding/video_receiver.cc b/modules/video_coding/video_receiver.cc index dce294e8c4..53b922aa4b 100644 --- a/modules/video_coding/video_receiver.cc +++ b/modules/video_coding/video_receiver.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include diff --git a/modules/video_coding/video_receiver2.cc b/modules/video_coding/video_receiver2.cc index 75b5b1daae..0549b7a7b0 100644 --- a/modules/video_coding/video_receiver2.cc +++ b/modules/video_coding/video_receiver2.cc @@ -10,8 +10,7 @@ #include "modules/video_coding/video_receiver2.h" -#include - +#include #include #include #include diff --git a/net/dcsctp/common/BUILD.gn b/net/dcsctp/common/BUILD.gn index d496c64a56..5e2a32daf7 100644 --- a/net/dcsctp/common/BUILD.gn +++ b/net/dcsctp/common/BUILD.gn @@ -40,6 +40,7 @@ if (rtc_include_tests) { "../../../api:array_view", "../../../rtc_base:checks", "../../../rtc_base:gunit_helpers", + "../../../rtc_base:strong_alias", "../../../test:test_support", ] sources = [ diff --git a/net/dcsctp/common/handover_testing.cc b/net/dcsctp/common/handover_testing.cc index 1081766ea5..3a4e799f82 100644 --- a/net/dcsctp/common/handover_testing.cc +++ b/net/dcsctp/common/handover_testing.cc @@ -9,6 +9,8 @@ */ #include "net/dcsctp/common/handover_testing.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" + namespace dcsctp { namespace { // Default transformer function does nothing - dcSCTP does not implement diff --git a/net/dcsctp/common/internal_types.h b/net/dcsctp/common/internal_types.h index 4f3b1935a2..f05dc96f5d 100644 --- a/net/dcsctp/common/internal_types.h +++ b/net/dcsctp/common/internal_types.h @@ -10,10 +10,8 @@ #ifndef NET_DCSCTP_COMMON_INTERNAL_TYPES_H_ #define NET_DCSCTP_COMMON_INTERNAL_TYPES_H_ -#include -#include +#include -#include "net/dcsctp/public/types.h" #include "rtc_base/strong_alias.h" namespace dcsctp { diff --git a/net/dcsctp/common/math_test.cc b/net/dcsctp/common/math_test.cc index f95dfbdb55..2cbe0b6583 100644 --- a/net/dcsctp/common/math_test.cc +++ b/net/dcsctp/common/math_test.cc @@ -9,7 +9,9 @@ */ #include "net/dcsctp/common/math.h" -#include "test/gmock.h" +#include + +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/common/sequence_numbers_test.cc b/net/dcsctp/common/sequence_numbers_test.cc index c4842f089e..f050d320f7 100644 --- a/net/dcsctp/common/sequence_numbers_test.cc +++ b/net/dcsctp/common/sequence_numbers_test.cc @@ -9,7 +9,10 @@ */ #include "net/dcsctp/common/sequence_numbers.h" -#include "test/gmock.h" +#include + +#include "rtc_base/strong_alias.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/fuzzers/BUILD.gn b/net/dcsctp/fuzzers/BUILD.gn index 302c828684..a79de79803 100644 --- a/net/dcsctp/fuzzers/BUILD.gn +++ b/net/dcsctp/fuzzers/BUILD.gn @@ -12,16 +12,21 @@ rtc_library("dcsctp_fuzzers") { testonly = true deps = [ "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:logging", + "../common:internal_types", "../common:math", "../packet:chunk", + "../packet:data", "../packet:error_cause", "../packet:parameter", + "../packet:sctp_packet", "../public:socket", "../public:types", "../socket:dcsctp_socket", + "//third_party/abseil-cpp/absl/strings:string_view", ] sources = [ "dcsctp_fuzzers.cc", @@ -42,6 +47,7 @@ if (rtc_include_tests) { "../../../test:test_support", "../packet:sctp_packet", "../public:socket", + "../public:types", "../socket:dcsctp_socket", "../testing:testing_macros", ] diff --git a/net/dcsctp/fuzzers/dcsctp_fuzzers.cc b/net/dcsctp/fuzzers/dcsctp_fuzzers.cc index 35deb0ee17..90ad3f179d 100644 --- a/net/dcsctp/fuzzers/dcsctp_fuzzers.cc +++ b/net/dcsctp/fuzzers/dcsctp_fuzzers.cc @@ -9,27 +9,49 @@ */ #include "net/dcsctp/fuzzers/dcsctp_fuzzers.h" +#include +#include +#include #include #include #include -#include "net/dcsctp/common/math.h" +#include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/packet/chunk/abort_chunk.h" +#include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/chunk/cookie_ack_chunk.h" #include "net/dcsctp/packet/chunk/cookie_echo_chunk.h" #include "net/dcsctp/packet/chunk/data_chunk.h" +#include "net/dcsctp/packet/chunk/error_chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" +#include "net/dcsctp/packet/chunk/heartbeat_request_chunk.h" +#include "net/dcsctp/packet/chunk/idata_chunk.h" +#include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" +#include "net/dcsctp/packet/chunk/init_ack_chunk.h" +#include "net/dcsctp/packet/chunk/init_chunk.h" +#include "net/dcsctp/packet/chunk/reconfig_chunk.h" +#include "net/dcsctp/packet/chunk/sack_chunk.h" +#include "net/dcsctp/packet/chunk/shutdown_ack_chunk.h" #include "net/dcsctp/packet/chunk/shutdown_chunk.h" +#include "net/dcsctp/packet/chunk/shutdown_complete_chunk.h" +#include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/error_cause/protocol_violation_cause.h" #include "net/dcsctp/packet/error_cause/user_initiated_abort_cause.h" #include "net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h" +#include "net/dcsctp/packet/parameter/heartbeat_info_parameter.h" #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/parameter/state_cookie_parameter.h" +#include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/socket/dcsctp_socket.h" #include "net/dcsctp/socket/state_cookie.h" -#include "rtc_base/logging.h" +#include "rtc_base/checks.h" namespace dcsctp { namespace dcsctp_fuzzers { diff --git a/net/dcsctp/fuzzers/dcsctp_fuzzers.h b/net/dcsctp/fuzzers/dcsctp_fuzzers.h index 756eaf4b89..62f7b7f0b4 100644 --- a/net/dcsctp/fuzzers/dcsctp_fuzzers.h +++ b/net/dcsctp/fuzzers/dcsctp_fuzzers.h @@ -10,14 +10,24 @@ #ifndef NET_DCSCTP_FUZZERS_DCSCTP_FUZZERS_H_ #define NET_DCSCTP_FUZZERS_DCSCTP_FUZZERS_H_ +#include +#include #include +#include #include +#include #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/timeout.h" +#include "net/dcsctp/public/types.h" +#include "rtc_base/checks.h" namespace dcsctp { namespace dcsctp_fuzzers { diff --git a/net/dcsctp/fuzzers/dcsctp_fuzzers_test.cc b/net/dcsctp/fuzzers/dcsctp_fuzzers_test.cc index c7d2cd7c99..bbb00d72ba 100644 --- a/net/dcsctp/fuzzers/dcsctp_fuzzers_test.cc +++ b/net/dcsctp/fuzzers/dcsctp_fuzzers_test.cc @@ -9,14 +9,12 @@ */ #include "net/dcsctp/fuzzers/dcsctp_fuzzers.h" +#include + #include "api/array_view.h" -#include "net/dcsctp/packet/sctp_packet.h" -#include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/socket/dcsctp_socket.h" -#include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" -#include "rtc_base/logging.h" -#include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace dcsctp_fuzzers { diff --git a/net/dcsctp/packet/BUILD.gn b/net/dcsctp/packet/BUILD.gn index f1ab075eb3..651f9c1710 100644 --- a/net/dcsctp/packet/BUILD.gn +++ b/net/dcsctp/packet/BUILD.gn @@ -39,6 +39,7 @@ rtc_library("tlv_trait") { rtc_source_set("data") { deps = [ "../../../rtc_base:checks", + "../../../rtc_base:strong_alias", "../common:internal_types", "../public:types", ] @@ -159,6 +160,7 @@ rtc_library("chunk") { "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:stringutils", + "../../../rtc_base:strong_alias", "../common:internal_types", "../common:math", "../packet:bounded_io", @@ -213,6 +215,7 @@ rtc_library("chunk_validators") { ":chunk", "../../../rtc_base:checks", "../../../rtc_base:logging", + "//third_party/abseil-cpp/absl/algorithm:container", ] sources = [ "chunk_validators.cc", @@ -249,6 +252,7 @@ if (rtc_include_tests) { ":chunk", ":chunk_validators", ":crc32c", + ":data", ":error_cause", ":parameter", ":sctp_packet", diff --git a/net/dcsctp/packet/bounded_byte_reader.h b/net/dcsctp/packet/bounded_byte_reader.h index 3ce6d6d0b5..26f4ff91fc 100644 --- a/net/dcsctp/packet/bounded_byte_reader.h +++ b/net/dcsctp/packet/bounded_byte_reader.h @@ -11,9 +11,11 @@ #ifndef NET_DCSCTP_PACKET_BOUNDED_BYTE_READER_H_ #define NET_DCSCTP_PACKET_BOUNDED_BYTE_READER_H_ +#include #include #include "api/array_view.h" +#include "rtc_base/checks.h" namespace dcsctp { diff --git a/net/dcsctp/packet/bounded_byte_reader_test.cc b/net/dcsctp/packet/bounded_byte_reader_test.cc index 2fb4a86785..6aaeb01a26 100644 --- a/net/dcsctp/packet/bounded_byte_reader_test.cc +++ b/net/dcsctp/packet/bounded_byte_reader_test.cc @@ -10,11 +10,11 @@ #include "net/dcsctp/packet/bounded_byte_reader.h" +#include + #include "api/array_view.h" -#include "rtc_base/buffer.h" -#include "rtc_base/checks.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/bounded_byte_writer.h b/net/dcsctp/packet/bounded_byte_writer.h index 08dda4f5e7..738b35bd78 100644 --- a/net/dcsctp/packet/bounded_byte_writer.h +++ b/net/dcsctp/packet/bounded_byte_writer.h @@ -12,8 +12,12 @@ #define NET_DCSCTP_PACKET_BOUNDED_BYTE_WRITER_H_ #include +#include +#include +#include #include "api/array_view.h" +#include "rtc_base/checks.h" namespace dcsctp { diff --git a/net/dcsctp/packet/bounded_byte_writer_test.cc b/net/dcsctp/packet/bounded_byte_writer_test.cc index 3cea0a2f7c..e1591897bf 100644 --- a/net/dcsctp/packet/bounded_byte_writer_test.cc +++ b/net/dcsctp/packet/bounded_byte_writer_test.cc @@ -10,13 +10,12 @@ #include "net/dcsctp/packet/bounded_byte_writer.h" +#include #include #include "api/array_view.h" -#include "rtc_base/buffer.h" -#include "rtc_base/checks.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/chunk/abort_chunk.h b/net/dcsctp/packet/chunk/abort_chunk.h index 771bbe9b38..772c52087a 100644 --- a/net/dcsctp/packet/chunk/abort_chunk.h +++ b/net/dcsctp/packet/chunk/abort_chunk.h @@ -9,17 +9,17 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_ABORT_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_ABORT_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/chunk.cc b/net/dcsctp/packet/chunk/chunk.cc index 73d675593c..9332f37c5b 100644 --- a/net/dcsctp/packet/chunk/chunk.cc +++ b/net/dcsctp/packet/chunk/chunk.cc @@ -10,12 +10,10 @@ #include "net/dcsctp/packet/chunk/chunk.h" #include -#include #include -#include +#include #include "api/array_view.h" -#include "net/dcsctp/common/math.h" #include "net/dcsctp/packet/chunk/abort_chunk.h" #include "net/dcsctp/packet/chunk/cookie_ack_chunk.h" #include "net/dcsctp/packet/chunk/cookie_echo_chunk.h" @@ -33,7 +31,7 @@ #include "net/dcsctp/packet/chunk/shutdown_ack_chunk.h" #include "net/dcsctp/packet/chunk/shutdown_chunk.h" #include "net/dcsctp/packet/chunk/shutdown_complete_chunk.h" -#include "net/dcsctp/packet/tlv_trait.h" +#include "rtc_base/strings/string_builder.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/chunk.h b/net/dcsctp/packet/chunk/chunk.h index 810cd92790..3eac270ac9 100644 --- a/net/dcsctp/packet/chunk/chunk.h +++ b/net/dcsctp/packet/chunk/chunk.h @@ -10,24 +10,12 @@ #ifndef NET_DCSCTP_PACKET_CHUNK_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_CHUNK_H_ -#include -#include #include -#include -#include -#include #include -#include #include -#include "absl/algorithm/container.h" -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/data.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" -#include "net/dcsctp/packet/parameter/parameter.h" -#include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/cookie_ack_chunk.h b/net/dcsctp/packet/chunk/cookie_ack_chunk.h index 0af7bfa5a2..872757c73b 100644 --- a/net/dcsctp/packet/chunk/cookie_ack_chunk.h +++ b/net/dcsctp/packet/chunk/cookie_ack_chunk.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_COOKIE_ACK_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_COOKIE_ACK_CHUNK_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/cookie_echo_chunk.h b/net/dcsctp/packet/chunk/cookie_echo_chunk.h index 58d730bbd4..94cb10435c 100644 --- a/net/dcsctp/packet/chunk/cookie_echo_chunk.h +++ b/net/dcsctp/packet/chunk/cookie_echo_chunk.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_COOKIE_ECHO_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_COOKIE_ECHO_CHUNK_H_ -#include +#include #include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/data_chunk.h b/net/dcsctp/packet/chunk/data_chunk.h index cdd037a671..54bcdfb9aa 100644 --- a/net/dcsctp/packet/chunk/data_chunk.h +++ b/net/dcsctp/packet/chunk/data_chunk.h @@ -9,20 +9,21 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_DATA_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_DATA_CHUNK_H_ -#include -#include +#include #include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/chunk/data_common.h" #include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/tlv_trait.h" +#include "net/dcsctp/public/types.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/data_chunk_test.cc b/net/dcsctp/packet/chunk/data_chunk_test.cc index def99ceb23..e8791f74fa 100644 --- a/net/dcsctp/packet/chunk/data_chunk_test.cc +++ b/net/dcsctp/packet/chunk/data_chunk_test.cc @@ -10,13 +10,14 @@ #include "net/dcsctp/packet/chunk/data_chunk.h" #include -#include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/chunk/data_common.h b/net/dcsctp/packet/chunk/data_common.h index 7f85c82b23..5ded1e8879 100644 --- a/net/dcsctp/packet/chunk/data_common.h +++ b/net/dcsctp/packet/chunk/data_common.h @@ -9,14 +9,17 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_DATA_COMMON_H_ #define NET_DCSCTP_PACKET_CHUNK_DATA_COMMON_H_ -#include +#include #include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/types.h" +#include "rtc_base/strong_alias.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/error_chunk.h b/net/dcsctp/packet/chunk/error_chunk.h index b8bac5348b..b395b6b1c2 100644 --- a/net/dcsctp/packet/chunk/error_chunk.h +++ b/net/dcsctp/packet/chunk/error_chunk.h @@ -9,17 +9,17 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_ERROR_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_ERROR_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/error_chunk_test.cc b/net/dcsctp/packet/chunk/error_chunk_test.cc index f2b8be1edc..0d034da2b2 100644 --- a/net/dcsctp/packet/chunk/error_chunk_test.cc +++ b/net/dcsctp/packet/chunk/error_chunk_test.cc @@ -10,15 +10,14 @@ #include "net/dcsctp/packet/chunk/error_chunk.h" #include -#include #include #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" #include "net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/chunk/forward_tsn_chunk.h b/net/dcsctp/packet/chunk/forward_tsn_chunk.h index ae4250f524..b65d2ff124 100644 --- a/net/dcsctp/packet/chunk/forward_tsn_chunk.h +++ b/net/dcsctp/packet/chunk/forward_tsn_chunk.h @@ -9,15 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/forward_tsn_common.h b/net/dcsctp/packet/chunk/forward_tsn_common.h index ede879c599..b2e9168835 100644 --- a/net/dcsctp/packet/chunk/forward_tsn_common.h +++ b/net/dcsctp/packet/chunk/forward_tsn_common.h @@ -9,13 +9,14 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_COMMON_H_ #define NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_COMMON_H_ -#include #include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" +#include "net/dcsctp/public/types.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h b/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h index ed7b77f8bc..3e6ecd4e0f 100644 --- a/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h +++ b/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h @@ -9,14 +9,14 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_HEARTBEAT_ACK_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_HEARTBEAT_ACK_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/parameter/heartbeat_info_parameter.h" diff --git a/net/dcsctp/packet/chunk/heartbeat_request_chunk.h b/net/dcsctp/packet/chunk/heartbeat_request_chunk.h index 3b940a410b..31eefbcb88 100644 --- a/net/dcsctp/packet/chunk/heartbeat_request_chunk.h +++ b/net/dcsctp/packet/chunk/heartbeat_request_chunk.h @@ -9,14 +9,14 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_HEARTBEAT_REQUEST_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_HEARTBEAT_REQUEST_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/parameter/heartbeat_info_parameter.h" diff --git a/net/dcsctp/packet/chunk/idata_chunk.h b/net/dcsctp/packet/chunk/idata_chunk.h index c2298d02b8..23b38ef645 100644 --- a/net/dcsctp/packet/chunk/idata_chunk.h +++ b/net/dcsctp/packet/chunk/idata_chunk.h @@ -9,20 +9,21 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_IDATA_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_IDATA_CHUNK_H_ -#include -#include +#include #include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/chunk/data_common.h" #include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/tlv_trait.h" +#include "net/dcsctp/public/types.h" namespace dcsctp { diff --git a/net/dcsctp/packet/chunk/idata_chunk_test.cc b/net/dcsctp/packet/chunk/idata_chunk_test.cc index d1cc0d8f90..d65b31b925 100644 --- a/net/dcsctp/packet/chunk/idata_chunk_test.cc +++ b/net/dcsctp/packet/chunk/idata_chunk_test.cc @@ -10,13 +10,15 @@ #include "net/dcsctp/packet/chunk/idata_chunk.h" #include -#include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/chunk/iforward_tsn_chunk.h b/net/dcsctp/packet/chunk/iforward_tsn_chunk.h index 43ef648d6e..ae60fd71eb 100644 --- a/net/dcsctp/packet/chunk/iforward_tsn_chunk.h +++ b/net/dcsctp/packet/chunk/iforward_tsn_chunk.h @@ -9,15 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_IFORWARD_TSN_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_IFORWARD_TSN_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/init_ack_chunk.h b/net/dcsctp/packet/chunk/init_ack_chunk.h index 0b11007a98..19baea6776 100644 --- a/net/dcsctp/packet/chunk/init_ack_chunk.h +++ b/net/dcsctp/packet/chunk/init_ack_chunk.h @@ -9,15 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_INIT_ACK_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_INIT_ACK_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/init_chunk.h b/net/dcsctp/packet/chunk/init_chunk.h index fba4504102..d86ca4b534 100644 --- a/net/dcsctp/packet/chunk/init_chunk.h +++ b/net/dcsctp/packet/chunk/init_chunk.h @@ -9,15 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_INIT_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_INIT_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/reconfig_chunk.h b/net/dcsctp/packet/chunk/reconfig_chunk.h index d9c85da6b7..227a1d2991 100644 --- a/net/dcsctp/packet/chunk/reconfig_chunk.h +++ b/net/dcsctp/packet/chunk/reconfig_chunk.h @@ -9,14 +9,14 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_RECONFIG_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_RECONFIG_CHUNK_H_ -#include -#include +#include +#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/parameter/parameter.h" diff --git a/net/dcsctp/packet/chunk/reconfig_chunk_test.cc b/net/dcsctp/packet/chunk/reconfig_chunk_test.cc index dbf40ff8c0..296f7ec5fe 100644 --- a/net/dcsctp/packet/chunk/reconfig_chunk_test.cc +++ b/net/dcsctp/packet/chunk/reconfig_chunk_test.cc @@ -10,16 +10,16 @@ #include "net/dcsctp/packet/chunk/reconfig_chunk.h" #include -#include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" #include "net/dcsctp/packet/parameter/parameter.h" -#include "net/dcsctp/packet/tlv_trait.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/chunk/sack_chunk.h b/net/dcsctp/packet/chunk/sack_chunk.h index 59347f4dc4..026d52d8c1 100644 --- a/net/dcsctp/packet/chunk/sack_chunk.h +++ b/net/dcsctp/packet/chunk/sack_chunk.h @@ -9,16 +9,17 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_SACK_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_SACK_CHUNK_H_ -#include +#include #include +#include #include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/sack_chunk_test.cc b/net/dcsctp/packet/chunk/sack_chunk_test.cc index 9122945308..2f5c0d0931 100644 --- a/net/dcsctp/packet/chunk/sack_chunk_test.cc +++ b/net/dcsctp/packet/chunk/sack_chunk_test.cc @@ -10,13 +10,13 @@ #include "net/dcsctp/packet/chunk/sack_chunk.h" #include -#include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/chunk/shutdown_ack_chunk.h b/net/dcsctp/packet/chunk/shutdown_ack_chunk.h index e7ae03ff66..18550f85a9 100644 --- a/net/dcsctp/packet/chunk/shutdown_ack_chunk.h +++ b/net/dcsctp/packet/chunk/shutdown_ack_chunk.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_SHUTDOWN_ACK_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_SHUTDOWN_ACK_CHUNK_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/shutdown_chunk.h b/net/dcsctp/packet/chunk/shutdown_chunk.h index bdb412e03d..2dec9c172c 100644 --- a/net/dcsctp/packet/chunk/shutdown_chunk.h +++ b/net/dcsctp/packet/chunk/shutdown_chunk.h @@ -9,14 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_SHUTDOWN_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_SHUTDOWN_CHUNK_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk/shutdown_complete_chunk.h b/net/dcsctp/packet/chunk/shutdown_complete_chunk.h index 73a6d92645..e8cc570d5c 100644 --- a/net/dcsctp/packet/chunk/shutdown_complete_chunk.h +++ b/net/dcsctp/packet/chunk/shutdown_complete_chunk.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_CHUNK_SHUTDOWN_COMPLETE_CHUNK_H_ #define NET_DCSCTP_PACKET_CHUNK_SHUTDOWN_COMPLETE_CHUNK_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/chunk_validators.cc b/net/dcsctp/packet/chunk_validators.cc index 48d351827e..748efff8d4 100644 --- a/net/dcsctp/packet/chunk_validators.cc +++ b/net/dcsctp/packet/chunk_validators.cc @@ -10,9 +10,12 @@ #include "net/dcsctp/packet/chunk_validators.h" #include +#include +#include #include #include +#include "absl/algorithm/container.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" #include "rtc_base/logging.h" diff --git a/net/dcsctp/packet/chunk_validators_test.cc b/net/dcsctp/packet/chunk_validators_test.cc index d59fd4ec48..fdd712f147 100644 --- a/net/dcsctp/packet/chunk_validators_test.cc +++ b/net/dcsctp/packet/chunk_validators_test.cc @@ -11,8 +11,10 @@ #include -#include "rtc_base/gunit.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/packet/chunk/sack_chunk.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/crc32c.cc b/net/dcsctp/packet/crc32c.cc index adcb4aff17..8318b0dc75 100644 --- a/net/dcsctp/packet/crc32c.cc +++ b/net/dcsctp/packet/crc32c.cc @@ -11,6 +11,7 @@ #include +#include "api/array_view.h" #include "third_party/crc32c/src/include/crc32c/crc32c.h" namespace dcsctp { diff --git a/net/dcsctp/packet/crc32c_test.cc b/net/dcsctp/packet/crc32c_test.cc index 0821c4ef75..3650a8c760 100644 --- a/net/dcsctp/packet/crc32c_test.cc +++ b/net/dcsctp/packet/crc32c_test.cc @@ -9,7 +9,10 @@ */ #include "net/dcsctp/packet/crc32c.h" -#include "test/gmock.h" +#include +#include + +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/data.h b/net/dcsctp/packet/data.h index 08174dc052..6b2620c49f 100644 --- a/net/dcsctp/packet/data.h +++ b/net/dcsctp/packet/data.h @@ -10,12 +10,14 @@ #ifndef NET_DCSCTP_PACKET_DATA_H_ #define NET_DCSCTP_PACKET_DATA_H_ +#include #include #include #include #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/public/types.h" +#include "rtc_base/strong_alias.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h b/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h index cf5c2f3392..360a31664d 100644 --- a/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h +++ b/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h @@ -9,15 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_COOKIE_RECEIVED_WHILE_SHUTTING_DOWN_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_COOKIE_RECEIVED_WHILE_SHUTTING_DOWN_CAUSE_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/error_cause.h b/net/dcsctp/packet/error_cause/error_cause.h index a4247cbff6..ebfb219cb4 100644 --- a/net/dcsctp/packet/error_cause/error_cause.h +++ b/net/dcsctp/packet/error_cause/error_cause.h @@ -10,22 +10,10 @@ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_ERROR_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_ERROR_CAUSE_H_ -#include -#include -#include -#include -#include #include -#include -#include -#include -#include "absl/algorithm/container.h" -#include "absl/strings/string_view.h" -#include "api/array_view.h" #include "net/dcsctp/packet/parameter/parameter.h" -#include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h b/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h index cdb2a06370..734b72979d 100644 --- a/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h +++ b/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h @@ -9,15 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_INVALID_MANDATORY_PARAMETER_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_INVALID_MANDATORY_PARAMETER_CAUSE_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h b/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h index 795f138de5..b58809e51a 100644 --- a/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h +++ b/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h @@ -9,15 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_INVALID_STREAM_IDENTIFIER_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_INVALID_STREAM_IDENTIFIER_CAUSE_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" #include "net/dcsctp/public/types.h" diff --git a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h index a777c5f189..04b33d8236 100644 --- a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h +++ b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h @@ -9,15 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_MISSING_MANDATORY_PARAMETER_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_MISSING_MANDATORY_PARAMETER_CAUSE_H_ -#include +#include #include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/no_user_data_cause.h b/net/dcsctp/packet/error_cause/no_user_data_cause.h index a462a698cf..ad67b33356 100644 --- a/net/dcsctp/packet/error_cause/no_user_data_cause.h +++ b/net/dcsctp/packet/error_cause/no_user_data_cause.h @@ -9,16 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_NO_USER_DATA_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_NO_USER_DATA_CAUSE_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h b/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h index b8b511ef2a..6e4e9eef24 100644 --- a/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h +++ b/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h @@ -9,15 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_OUT_OF_RESOURCE_ERROR_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_OUT_OF_RESOURCE_ERROR_CAUSE_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/protocol_violation_cause.h b/net/dcsctp/packet/error_cause/protocol_violation_cause.h index bf7f1fb87e..9e265e9391 100644 --- a/net/dcsctp/packet/error_cause/protocol_violation_cause.h +++ b/net/dcsctp/packet/error_cause/protocol_violation_cause.h @@ -9,15 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_PROTOCOL_VIOLATION_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_PROTOCOL_VIOLATION_CAUSE_H_ -#include -#include +#include +#include +#include #include #include #include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h b/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h index d7729e28f5..14b6c4ec3c 100644 --- a/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h +++ b/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h @@ -9,15 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_RESTART_OF_AN_ASSOCIATION_WITH_NEW_ADDRESS_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_RESTART_OF_AN_ASSOCIATION_WITH_NEW_ADDRESS_CAUSE_H_ -#include +#include #include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h b/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h index d44f3db976..cb5bace37c 100644 --- a/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h +++ b/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h @@ -9,15 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_STALE_COOKIE_ERROR_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_STALE_COOKIE_ERROR_CAUSE_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc index 4745142daf..504e9adc4b 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc +++ b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc @@ -18,7 +18,6 @@ #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" -#include "net/dcsctp/packet/tlv_trait.h" #include "rtc_base/strings/string_builder.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h index 2467c56d4f..48c9bc9f36 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h +++ b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h @@ -9,17 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_UNRECOGNIZED_CHUNK_TYPE_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_UNRECOGNIZED_CHUNK_TYPE_CAUSE_H_ -#include -#include +#include #include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause_test.cc b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause_test.cc index baff852f40..e058f5f827 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause_test.cc +++ b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause_test.cc @@ -10,13 +10,12 @@ #include "net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h" #include -#include #include #include "api/array_view.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h b/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h index 8c0df7f618..3088705258 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h +++ b/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h @@ -9,16 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_UNRECOGNIZED_PARAMETER_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_UNRECOGNIZED_PARAMETER_CAUSE_H_ -#include -#include +#include #include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/unresolvable_address_cause.h b/net/dcsctp/packet/error_cause/unresolvable_address_cause.h index e42d3f2060..3ab94eb674 100644 --- a/net/dcsctp/packet/error_cause/unresolvable_address_cause.h +++ b/net/dcsctp/packet/error_cause/unresolvable_address_cause.h @@ -9,16 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_UNRESOLVABLE_ADDRESS_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_UNRESOLVABLE_ADDRESS_CAUSE_H_ -#include -#include +#include #include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h b/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h index 4dc452252a..8cea2bcf70 100644 --- a/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h +++ b/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h @@ -9,15 +9,16 @@ */ #ifndef NET_DCSCTP_PACKET_ERROR_CAUSE_USER_INITIATED_ABORT_CAUSE_H_ #define NET_DCSCTP_PACKET_ERROR_CAUSE_USER_INITIATED_ABORT_CAUSE_H_ -#include -#include +#include +#include +#include #include #include #include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" namespace dcsctp { diff --git a/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h b/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h index 2eebd51d5d..fe3b306af5 100644 --- a/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h +++ b/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_ADD_INCOMING_STREAMS_REQUEST_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_ADD_INCOMING_STREAMS_REQUEST_PARAMETER_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/parameter.h" diff --git a/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h b/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h index e7f9fe6354..ac1735f95f 100644 --- a/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h +++ b/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_ADD_OUTGOING_STREAMS_REQUEST_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_ADD_OUTGOING_STREAMS_REQUEST_PARAMETER_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/parameter.h" diff --git a/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h b/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h index 649b2dee05..03e492f8c7 100644 --- a/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h +++ b/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_FORWARD_TSN_SUPPORTED_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_FORWARD_TSN_SUPPORTED_PARAMETER_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/parameter/heartbeat_info_parameter.h b/net/dcsctp/packet/parameter/heartbeat_info_parameter.h index b07da8eeac..82c18dbe31 100644 --- a/net/dcsctp/packet/parameter/heartbeat_info_parameter.h +++ b/net/dcsctp/packet/parameter/heartbeat_info_parameter.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_HEARTBEAT_INFO_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_HEARTBEAT_INFO_PARAMETER_H_ -#include +#include #include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h index 1ad9dfc179..77e453a2e9 100644 --- a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h +++ b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h @@ -9,17 +9,18 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_INCOMING_SSN_RESET_REQUEST_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_INCOMING_SSN_RESET_REQUEST_PARAMETER_H_ -#include +#include #include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/parameter.h" +#include "net/dcsctp/packet/tlv_trait.h" #include "net/dcsctp/public/types.h" namespace dcsctp { diff --git a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter_test.cc b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter_test.cc index 17793f6638..5b10fb371f 100644 --- a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter_test.cc +++ b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter_test.cc @@ -10,13 +10,14 @@ #include "net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h" #include -#include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h index 109f742a15..71399afb6a 100644 --- a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h +++ b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h @@ -9,15 +9,14 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_OUTGOING_SSN_RESET_REQUEST_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_OUTGOING_SSN_RESET_REQUEST_PARAMETER_H_ -#include -#include +#include #include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/parameter.h" diff --git a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter_test.cc b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter_test.cc index dae73c2fba..f61b8a0cec 100644 --- a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter_test.cc +++ b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter_test.cc @@ -10,15 +10,14 @@ #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" #include -#include #include #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/parameter/parameter.h b/net/dcsctp/packet/parameter/parameter.h index 5042f16e1b..e64de97170 100644 --- a/net/dcsctp/packet/parameter/parameter.h +++ b/net/dcsctp/packet/parameter/parameter.h @@ -10,23 +10,15 @@ #ifndef NET_DCSCTP_PACKET_PARAMETER_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_PARAMETER_H_ -#include -#include #include -#include -#include #include #include #include #include #include -#include "absl/algorithm/container.h" -#include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/tlv_trait.h" -#include "rtc_base/strings/string_builder.h" namespace dcsctp { diff --git a/net/dcsctp/packet/parameter/parameter_test.cc b/net/dcsctp/packet/parameter/parameter_test.cc index 2ff49f320f..366a740dba 100644 --- a/net/dcsctp/packet/parameter/parameter_test.cc +++ b/net/dcsctp/packet/parameter/parameter_test.cc @@ -10,15 +10,15 @@ #include "net/dcsctp/packet/parameter/parameter.h" #include -#include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" -#include "net/dcsctp/packet/tlv_trait.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h b/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h index 37bc7452a5..6fb4b357d8 100644 --- a/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h +++ b/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h @@ -9,8 +9,8 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_RECONFIGURATION_RESPONSE_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_RECONFIGURATION_RESPONSE_PARAMETER_H_ -#include +#include #include #include #include diff --git a/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h b/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h index 4d83044483..1beb0b867a 100644 --- a/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h +++ b/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_SSN_TSN_RESET_REQUEST_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_SSN_TSN_RESET_REQUEST_PARAMETER_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/parameter.h" diff --git a/net/dcsctp/packet/parameter/state_cookie_parameter.h b/net/dcsctp/packet/parameter/state_cookie_parameter.h index d11ce8e22d..30de131402 100644 --- a/net/dcsctp/packet/parameter/state_cookie_parameter.h +++ b/net/dcsctp/packet/parameter/state_cookie_parameter.h @@ -9,14 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_STATE_COOKIE_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_STATE_COOKIE_PARAMETER_H_ -#include -#include +#include #include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/parameter/supported_extensions_parameter.cc b/net/dcsctp/packet/parameter/supported_extensions_parameter.cc index 4163016757..a695cd6940 100644 --- a/net/dcsctp/packet/parameter/supported_extensions_parameter.cc +++ b/net/dcsctp/packet/parameter/supported_extensions_parameter.cc @@ -18,7 +18,6 @@ #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" -#include "net/dcsctp/packet/tlv_trait.h" #include "rtc_base/strings/str_join.h" #include "rtc_base/strings/string_builder.h" diff --git a/net/dcsctp/packet/parameter/supported_extensions_parameter.h b/net/dcsctp/packet/parameter/supported_extensions_parameter.h index c7fdbcb1ab..1953391a61 100644 --- a/net/dcsctp/packet/parameter/supported_extensions_parameter.h +++ b/net/dcsctp/packet/parameter/supported_extensions_parameter.h @@ -9,16 +9,15 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_SUPPORTED_EXTENSIONS_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_SUPPORTED_EXTENSIONS_PARAMETER_H_ -#include #include +#include #include -#include +#include #include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/parameter/supported_extensions_parameter_test.cc b/net/dcsctp/packet/parameter/supported_extensions_parameter_test.cc index c870af2e70..e76d3b0fe2 100644 --- a/net/dcsctp/packet/parameter/supported_extensions_parameter_test.cc +++ b/net/dcsctp/packet/parameter/supported_extensions_parameter_test.cc @@ -10,13 +10,12 @@ #include "net/dcsctp/packet/parameter/supported_extensions_parameter.h" #include -#include #include #include "api/array_view.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h b/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h index 8b0132d2cf..139b6f612f 100644 --- a/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h +++ b/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h @@ -9,13 +9,13 @@ */ #ifndef NET_DCSCTP_PACKET_PARAMETER_ZERO_CHECKSUM_ACCEPTABLE_CHUNK_PARAMETER_H_ #define NET_DCSCTP_PACKET_PARAMETER_ZERO_CHECKSUM_ACCEPTABLE_CHUNK_PARAMETER_H_ -#include -#include +#include +#include +#include #include #include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/sctp_packet.h b/net/dcsctp/packet/sctp_packet.h index 3a5ba973db..bd602eddcc 100644 --- a/net/dcsctp/packet/sctp_packet.h +++ b/net/dcsctp/packet/sctp_packet.h @@ -10,11 +10,9 @@ #ifndef NET_DCSCTP_PACKET_SCTP_PACKET_H_ #define NET_DCSCTP_PACKET_SCTP_PACKET_H_ -#include - +#include #include -#include -#include +#include #include #include diff --git a/net/dcsctp/packet/sctp_packet_test.cc b/net/dcsctp/packet/sctp_packet_test.cc index aab01df19c..2209f21bea 100644 --- a/net/dcsctp/packet/sctp_packet_test.cc +++ b/net/dcsctp/packet/sctp_packet_test.cc @@ -9,8 +9,8 @@ */ #include "net/dcsctp/packet/sctp_packet.h" +#include #include -#include #include #include "api/array_view.h" @@ -21,14 +21,13 @@ #include "net/dcsctp/packet/chunk/data_chunk.h" #include "net/dcsctp/packet/chunk/init_chunk.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" #include "net/dcsctp/packet/error_cause/user_initiated_abort_cause.h" #include "net/dcsctp/packet/parameter/parameter.h" -#include "net/dcsctp/packet/tlv_trait.h" #include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/packet/tlv_trait.cc b/net/dcsctp/packet/tlv_trait.cc index 493b6a4613..f955a465be 100644 --- a/net/dcsctp/packet/tlv_trait.cc +++ b/net/dcsctp/packet/tlv_trait.cc @@ -9,6 +9,8 @@ */ #include "net/dcsctp/packet/tlv_trait.h" +#include + #include "rtc_base/logging.h" namespace dcsctp { diff --git a/net/dcsctp/packet/tlv_trait.h b/net/dcsctp/packet/tlv_trait.h index fd463479b3..cbe047dcfb 100644 --- a/net/dcsctp/packet/tlv_trait.h +++ b/net/dcsctp/packet/tlv_trait.h @@ -10,14 +10,10 @@ #ifndef NET_DCSCTP_PACKET_TLV_TRAIT_H_ #define NET_DCSCTP_PACKET_TLV_TRAIT_H_ -#include -#include - -#include #include #include +#include #include -#include #include #include "api/array_view.h" diff --git a/net/dcsctp/packet/tlv_trait_test.cc b/net/dcsctp/packet/tlv_trait_test.cc index 737534bddf..1c43ee65b2 100644 --- a/net/dcsctp/packet/tlv_trait_test.cc +++ b/net/dcsctp/packet/tlv_trait_test.cc @@ -9,13 +9,16 @@ */ #include "net/dcsctp/packet/tlv_trait.h" +#include +#include +#include #include #include "api/array_view.h" -#include "rtc_base/buffer.h" -#include "rtc_base/checks.h" -#include "rtc_base/gunit.h" +#include "net/dcsctp/packet/bounded_byte_reader.h" +#include "net/dcsctp/packet/bounded_byte_writer.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/public/BUILD.gn b/net/dcsctp/public/BUILD.gn index a744681942..b42d53ef01 100644 --- a/net/dcsctp/public/BUILD.gn +++ b/net/dcsctp/public/BUILD.gn @@ -25,10 +25,11 @@ rtc_library("socket") { deps = [ ":types", "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:strong_alias", + "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/strings:string_view", ] sources = [ @@ -62,7 +63,10 @@ rtc_source_set("mocks") { deps = [ ":factory", ":socket", + ":types", + "../../../api:array_view", "../../../test:test_support", + "//third_party/abseil-cpp/absl/strings:string_view", ] } diff --git a/net/dcsctp/public/dcsctp_handover_state.cc b/net/dcsctp/public/dcsctp_handover_state.cc index 6a1bd06eba..e163f0892c 100644 --- a/net/dcsctp/public/dcsctp_handover_state.cc +++ b/net/dcsctp/public/dcsctp_handover_state.cc @@ -9,6 +9,7 @@ */ #include "net/dcsctp/public/dcsctp_handover_state.h" +#include #include #include "absl/strings/string_view.h" diff --git a/net/dcsctp/public/dcsctp_options.h b/net/dcsctp/public/dcsctp_options.h index f5a9aac907..d608bdbc5d 100644 --- a/net/dcsctp/public/dcsctp_options.h +++ b/net/dcsctp/public/dcsctp_options.h @@ -10,9 +10,8 @@ #ifndef NET_DCSCTP_PUBLIC_DCSCTP_OPTIONS_H_ #define NET_DCSCTP_PUBLIC_DCSCTP_OPTIONS_H_ -#include -#include - +#include +#include #include #include "net/dcsctp/public/types.h" diff --git a/net/dcsctp/public/dcsctp_socket.h b/net/dcsctp/public/dcsctp_socket.h index 803bf8efe5..12a30bc78b 100644 --- a/net/dcsctp/public/dcsctp_socket.h +++ b/net/dcsctp/public/dcsctp_socket.h @@ -10,12 +10,13 @@ #ifndef NET_DCSCTP_PUBLIC_DCSCTP_SOCKET_H_ #define NET_DCSCTP_PUBLIC_DCSCTP_SOCKET_H_ +#include #include #include #include -#include #include +#include "absl/base/attributes.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" @@ -23,7 +24,6 @@ #include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_options.h" -#include "net/dcsctp/public/packet_observer.h" #include "net/dcsctp/public/timeout.h" #include "net/dcsctp/public/types.h" diff --git a/net/dcsctp/public/mock_dcsctp_socket.h b/net/dcsctp/public/mock_dcsctp_socket.h index 399a193464..df6d2965cd 100644 --- a/net/dcsctp/public/mock_dcsctp_socket.h +++ b/net/dcsctp/public/mock_dcsctp_socket.h @@ -10,9 +10,17 @@ #ifndef NET_DCSCTP_PUBLIC_MOCK_DCSCTP_SOCKET_H_ #define NET_DCSCTP_PUBLIC_MOCK_DCSCTP_SOCKET_H_ +#include +#include +#include #include +#include "api/array_view.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" +#include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/types.h" #include "test/gmock.h" namespace dcsctp { diff --git a/net/dcsctp/public/mock_dcsctp_socket_factory.h b/net/dcsctp/public/mock_dcsctp_socket_factory.h index 61f05577f2..eeaa8760ab 100644 --- a/net/dcsctp/public/mock_dcsctp_socket_factory.h +++ b/net/dcsctp/public/mock_dcsctp_socket_factory.h @@ -12,7 +12,11 @@ #include +#include "absl/strings/string_view.h" +#include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/dcsctp_socket_factory.h" +#include "net/dcsctp/public/packet_observer.h" #include "test/gmock.h" namespace dcsctp { diff --git a/net/dcsctp/public/mock_dcsctp_socket_test.cc b/net/dcsctp/public/mock_dcsctp_socket_test.cc index 57013e4ce2..aabc7d9d64 100644 --- a/net/dcsctp/public/mock_dcsctp_socket_test.cc +++ b/net/dcsctp/public/mock_dcsctp_socket_test.cc @@ -9,8 +9,8 @@ */ #include "net/dcsctp/public/mock_dcsctp_socket.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { diff --git a/net/dcsctp/public/packet_observer.h b/net/dcsctp/public/packet_observer.h index 0eb1d4f997..c0fa6b937d 100644 --- a/net/dcsctp/public/packet_observer.h +++ b/net/dcsctp/public/packet_observer.h @@ -10,7 +10,7 @@ #ifndef NET_DCSCTP_PUBLIC_PACKET_OBSERVER_H_ #define NET_DCSCTP_PUBLIC_PACKET_OBSERVER_H_ -#include +#include #include "api/array_view.h" #include "net/dcsctp/public/types.h" diff --git a/net/dcsctp/public/text_pcap_packet_observer.cc b/net/dcsctp/public/text_pcap_packet_observer.cc index e43585223b..467112dd9a 100644 --- a/net/dcsctp/public/text_pcap_packet_observer.cc +++ b/net/dcsctp/public/text_pcap_packet_observer.cc @@ -9,6 +9,9 @@ */ #include "net/dcsctp/public/text_pcap_packet_observer.h" +#include + +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/public/types.h" #include "rtc_base/logging.h" diff --git a/net/dcsctp/public/text_pcap_packet_observer.h b/net/dcsctp/public/text_pcap_packet_observer.h index 2434511dd3..c368b3da74 100644 --- a/net/dcsctp/public/text_pcap_packet_observer.h +++ b/net/dcsctp/public/text_pcap_packet_observer.h @@ -10,6 +10,7 @@ #ifndef NET_DCSCTP_PUBLIC_TEXT_PCAP_PACKET_OBSERVER_H_ #define NET_DCSCTP_PUBLIC_TEXT_PCAP_PACKET_OBSERVER_H_ +#include #include #include "absl/strings/string_view.h" diff --git a/net/dcsctp/public/timeout.h b/net/dcsctp/public/timeout.h index 64ba351093..17074e1a3c 100644 --- a/net/dcsctp/public/timeout.h +++ b/net/dcsctp/public/timeout.h @@ -10,7 +10,6 @@ #ifndef NET_DCSCTP_PUBLIC_TIMEOUT_H_ #define NET_DCSCTP_PUBLIC_TIMEOUT_H_ -#include #include "net/dcsctp/public/types.h" diff --git a/net/dcsctp/public/types_test.cc b/net/dcsctp/public/types_test.cc index d3d1240751..05290c546e 100644 --- a/net/dcsctp/public/types_test.cc +++ b/net/dcsctp/public/types_test.cc @@ -9,8 +9,7 @@ */ #include "net/dcsctp/public/types.h" -#include "rtc_base/gunit.h" -#include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/rx/BUILD.gn b/net/dcsctp/rx/BUILD.gn index 33d5228d01..b2045ff3ea 100644 --- a/net/dcsctp/rx/BUILD.gn +++ b/net/dcsctp/rx/BUILD.gn @@ -14,6 +14,7 @@ rtc_library("data_tracker") { "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:stringutils", + "../common:internal_types", "../common:sequence_numbers", "../packet:chunk", "../packet:data", @@ -119,7 +120,9 @@ if (rtc_include_tests) { ":reassembly_streams", ":traditional_reassembly_streams", "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:gunit_helpers", "../../../test:test_support", diff --git a/net/dcsctp/rx/data_tracker.cc b/net/dcsctp/rx/data_tracker.cc index 627478a2b2..51cafebadd 100644 --- a/net/dcsctp/rx/data_tracker.cc +++ b/net/dcsctp/rx/data_tracker.cc @@ -10,21 +10,22 @@ #include "net/dcsctp/rx/data_tracker.h" #include +#include #include -#include -#include #include -#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" +#include "net/dcsctp/packet/chunk/data_common.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/timer/timer.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/strings/string_builder.h" namespace dcsctp { diff --git a/net/dcsctp/rx/data_tracker.h b/net/dcsctp/rx/data_tracker.h index 9991ee6139..2c400aabd6 100644 --- a/net/dcsctp/rx/data_tracker.h +++ b/net/dcsctp/rx/data_tracker.h @@ -10,20 +10,16 @@ #ifndef NET_DCSCTP_RX_DATA_TRACKER_H_ #define NET_DCSCTP_RX_DATA_TRACKER_H_ -#include -#include - +#include #include #include -#include -#include #include #include "absl/strings/string_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/data_common.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" -#include "net/dcsctp/packet/data.h" #include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/timer/timer.h" diff --git a/net/dcsctp/rx/data_tracker_test.cc b/net/dcsctp/rx/data_tracker_test.cc index e0bf4cf739..fed9f2fac1 100644 --- a/net/dcsctp/rx/data_tracker_test.cc +++ b/net/dcsctp/rx/data_tracker_test.cc @@ -9,19 +9,23 @@ */ #include "net/dcsctp/rx/data_tracker.h" +#include #include #include #include -#include -#include "api/array_view.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "net/dcsctp/common/handover_testing.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/packet/chunk/data_common.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/timer/fake_timeout.h" #include "net/dcsctp/timer/timer.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/rx/interleaved_reassembly_streams.h b/net/dcsctp/rx/interleaved_reassembly_streams.h index 2213fbb8d0..f1b8b60dfb 100644 --- a/net/dcsctp/rx/interleaved_reassembly_streams.h +++ b/net/dcsctp/rx/interleaved_reassembly_streams.h @@ -10,16 +10,18 @@ #ifndef NET_DCSCTP_RX_INTERLEAVED_REASSEMBLY_STREAMS_H_ #define NET_DCSCTP_RX_INTERLEAVED_REASSEMBLY_STREAMS_H_ -#include +#include #include -#include #include #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/reassembly_streams.h" namespace dcsctp { diff --git a/net/dcsctp/rx/interleaved_reassembly_streams_test.cc b/net/dcsctp/rx/interleaved_reassembly_streams_test.cc index 480fbadda5..3de4f3aede 100644 --- a/net/dcsctp/rx/interleaved_reassembly_streams_test.cc +++ b/net/dcsctp/rx/interleaved_reassembly_streams_test.cc @@ -10,18 +10,21 @@ #include "net/dcsctp/rx/interleaved_reassembly_streams.h" #include -#include #include #include "net/dcsctp/common/handover_testing.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" +#include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/reassembly_streams.h" #include "net/dcsctp/testing/data_generator.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/rx/reassembly_queue.h b/net/dcsctp/rx/reassembly_queue.h index 1cf4cb90e9..504584243c 100644 --- a/net/dcsctp/rx/reassembly_queue.h +++ b/net/dcsctp/rx/reassembly_queue.h @@ -10,13 +10,10 @@ #ifndef NET_DCSCTP_RX_REASSEMBLY_QUEUE_H_ #define NET_DCSCTP_RX_REASSEMBLY_QUEUE_H_ -#include - -#include +#include #include #include -#include -#include +#include #include #include @@ -27,9 +24,9 @@ #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/data.h" -#include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" -#include "net/dcsctp/packet/parameter/reconfiguration_response_parameter.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/reassembly_streams.h" #include "rtc_base/containers/flat_set.h" diff --git a/net/dcsctp/rx/reassembly_streams.h b/net/dcsctp/rx/reassembly_streams.h index fab596645e..d801ef729e 100644 --- a/net/dcsctp/rx/reassembly_streams.h +++ b/net/dcsctp/rx/reassembly_streams.h @@ -10,19 +10,16 @@ #ifndef NET_DCSCTP_RX_REASSEMBLY_STREAMS_H_ #define NET_DCSCTP_RX_REASSEMBLY_STREAMS_H_ -#include -#include - +#include #include -#include -#include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/data.h" #include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/public/types.h" namespace dcsctp { diff --git a/net/dcsctp/rx/traditional_reassembly_streams.h b/net/dcsctp/rx/traditional_reassembly_streams.h index f755c5f0bd..dca34fbed5 100644 --- a/net/dcsctp/rx/traditional_reassembly_streams.h +++ b/net/dcsctp/rx/traditional_reassembly_streams.h @@ -9,17 +9,18 @@ */ #ifndef NET_DCSCTP_RX_TRADITIONAL_REASSEMBLY_STREAMS_H_ #define NET_DCSCTP_RX_TRADITIONAL_REASSEMBLY_STREAMS_H_ -#include -#include +#include #include -#include #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/reassembly_streams.h" namespace dcsctp { diff --git a/net/dcsctp/rx/traditional_reassembly_streams_test.cc b/net/dcsctp/rx/traditional_reassembly_streams_test.cc index 9aa0cec40b..a9f0b5ba44 100644 --- a/net/dcsctp/rx/traditional_reassembly_streams_test.cc +++ b/net/dcsctp/rx/traditional_reassembly_streams_test.cc @@ -10,18 +10,21 @@ #include "net/dcsctp/rx/traditional_reassembly_streams.h" #include -#include #include #include "net/dcsctp/common/handover_testing.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" +#include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/reassembly_streams.h" #include "net/dcsctp/testing/data_generator.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/socket/BUILD.gn b/net/dcsctp/socket/BUILD.gn index 5c26ea0231..f410755777 100644 --- a/net/dcsctp/socket/BUILD.gn +++ b/net/dcsctp/socket/BUILD.gn @@ -54,6 +54,7 @@ rtc_library("stream_reset_handler") { "../../../rtc_base:stringutils", "../../../rtc_base/containers:flat_set", "../common:internal_types", + "../common:sequence_numbers", "../packet:chunk", "../packet:parameter", "../packet:sctp_packet", @@ -75,6 +76,7 @@ rtc_library("stream_reset_handler") { rtc_library("packet_sender") { deps = [ + "../../../api:array_view", "../packet:sctp_packet", "../public:socket", "../public:types", @@ -93,11 +95,13 @@ rtc_library("transmission_control_block") { ":packet_sender", ":stream_reset_handler", "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:stringutils", + "../common:internal_types", "../common:sequence_numbers", "../packet:chunk", "../packet:sctp_packet", @@ -131,7 +135,9 @@ rtc_library("dcsctp_socket") { "../../../api:make_ref_counted", "../../../api:refcountedbase", "../../../api:scoped_refptr", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:stringutils", @@ -174,7 +180,9 @@ if (rtc_include_tests) { sources = [ "mock_dcsctp_socket_callbacks.h" ] deps = [ "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:logging", "../../../rtc_base:random", "../../../test:test_support", @@ -191,6 +199,7 @@ if (rtc_include_tests) { deps = [ ":context", ":mock_callbacks", + "../../../api/units:time_delta", "../../../test:test_support", "../common:internal_types", "../packet:sctp_packet", @@ -214,10 +223,13 @@ if (rtc_include_tests) { "../../../api:array_view", "../../../api:create_network_emulation_manager", "../../../api:network_emulation_manager_api", + "../../../api:simulated_network_api", "../../../api/task_queue", "../../../api/task_queue:pending_task_safety_flag", + "../../../api/test/network_emulation", "../../../api/units:data_rate", "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:copy_on_write_buffer", "../../../rtc_base:gunit_helpers", @@ -226,12 +238,14 @@ if (rtc_include_tests) { "../../../rtc_base:rtc_base_tests_utils", "../../../rtc_base:socket_address", "../../../rtc_base:stringutils", + "../../../rtc_base:threading", "../../../rtc_base:timeutils", "../../../test:test_support", "../common:handover_testing", "../common:internal_types", "../common:math", "../packet:chunk", + "../packet:data", "../packet:error_cause", "../packet:parameter", "../packet:sctp_packet", diff --git a/net/dcsctp/socket/callback_deferrer.cc b/net/dcsctp/socket/callback_deferrer.cc index dcd54a9a91..09cbd917cd 100644 --- a/net/dcsctp/socket/callback_deferrer.cc +++ b/net/dcsctp/socket/callback_deferrer.cc @@ -9,7 +9,21 @@ */ #include "net/dcsctp/socket/callback_deferrer.h" -#include "api/make_ref_counted.h" +#include +#include +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/task_queue/task_queue_base.h" +#include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/timeout.h" +#include "net/dcsctp/public/types.h" +#include "rtc_base/checks.h" namespace dcsctp { diff --git a/net/dcsctp/socket/callback_deferrer.h b/net/dcsctp/socket/callback_deferrer.h index 1b0d23d394..83e41528a8 100644 --- a/net/dcsctp/socket/callback_deferrer.h +++ b/net/dcsctp/socket/callback_deferrer.h @@ -11,7 +11,6 @@ #define NET_DCSCTP_SOCKET_CALLBACK_DEFERRER_H_ #include -#include #include #include #include @@ -20,11 +19,12 @@ #include "absl/strings/string_view.h" #include "api/array_view.h" -#include "api/ref_counted_base.h" -#include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/timestamp.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/timeout.h" +#include "net/dcsctp/public/types.h" namespace dcsctp { // Defers callbacks until they can be safely triggered. diff --git a/net/dcsctp/socket/context.h b/net/dcsctp/socket/context.h index 8e970e8c8e..25e2fc6629 100644 --- a/net/dcsctp/socket/context.h +++ b/net/dcsctp/socket/context.h @@ -10,14 +10,12 @@ #ifndef NET_DCSCTP_SOCKET_CONTEXT_H_ #define NET_DCSCTP_SOCKET_CONTEXT_H_ -#include #include "absl/strings/string_view.h" #include "api/units/time_delta.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/public/dcsctp_socket.h" -#include "net/dcsctp/public/types.h" namespace dcsctp { diff --git a/net/dcsctp/socket/dcsctp_socket.cc b/net/dcsctp/socket/dcsctp_socket.cc index eac23dfeb2..e160721bec 100644 --- a/net/dcsctp/socket/dcsctp_socket.cc +++ b/net/dcsctp/socket/dcsctp_socket.cc @@ -10,6 +10,7 @@ #include "net/dcsctp/socket/dcsctp_socket.h" #include +#include #include #include #include @@ -19,9 +20,12 @@ #include #include "absl/functional/bind_front.h" -#include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/abort_chunk.h" #include "net/dcsctp/packet/chunk/chunk.h" #include "net/dcsctp/packet/chunk/cookie_ack_chunk.h" @@ -57,7 +61,7 @@ #include "net/dcsctp/packet/parameter/supported_extensions_parameter.h" #include "net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h" #include "net/dcsctp/packet/sctp_packet.h" -#include "net/dcsctp/packet/tlv_trait.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" @@ -73,7 +77,6 @@ #include "net/dcsctp/socket/transmission_control_block.h" #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/retransmission_queue.h" -#include "net/dcsctp/tx/send_queue.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" diff --git a/net/dcsctp/socket/dcsctp_socket.h b/net/dcsctp/socket/dcsctp_socket.h index 18435e4aa6..9baa7e3e12 100644 --- a/net/dcsctp/socket/dcsctp_socket.h +++ b/net/dcsctp/socket/dcsctp_socket.h @@ -10,50 +10,32 @@ #ifndef NET_DCSCTP_SOCKET_DCSCTP_SOCKET_H_ #define NET_DCSCTP_SOCKET_DCSCTP_SOCKET_H_ +#include #include #include +#include #include -#include #include #include "absl/strings/string_view.h" #include "api/array_view.h" -#include "net/dcsctp/packet/chunk/abort_chunk.h" -#include "net/dcsctp/packet/chunk/chunk.h" -#include "net/dcsctp/packet/chunk/cookie_ack_chunk.h" -#include "net/dcsctp/packet/chunk/cookie_echo_chunk.h" -#include "net/dcsctp/packet/chunk/data_chunk.h" +#include "api/units/time_delta.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/data_common.h" -#include "net/dcsctp/packet/chunk/error_chunk.h" -#include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" -#include "net/dcsctp/packet/chunk/heartbeat_ack_chunk.h" -#include "net/dcsctp/packet/chunk/heartbeat_request_chunk.h" -#include "net/dcsctp/packet/chunk/idata_chunk.h" -#include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" -#include "net/dcsctp/packet/chunk/init_ack_chunk.h" -#include "net/dcsctp/packet/chunk/init_chunk.h" -#include "net/dcsctp/packet/chunk/reconfig_chunk.h" -#include "net/dcsctp/packet/chunk/sack_chunk.h" -#include "net/dcsctp/packet/chunk/shutdown_ack_chunk.h" -#include "net/dcsctp/packet/chunk/shutdown_chunk.h" -#include "net/dcsctp/packet/chunk/shutdown_complete_chunk.h" -#include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/sctp_packet.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/packet_observer.h" -#include "net/dcsctp/rx/data_tracker.h" -#include "net/dcsctp/rx/reassembly_queue.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/socket/callback_deferrer.h" +#include "net/dcsctp/socket/capabilities.h" #include "net/dcsctp/socket/packet_sender.h" #include "net/dcsctp/socket/state_cookie.h" #include "net/dcsctp/socket/transmission_control_block.h" #include "net/dcsctp/timer/timer.h" -#include "net/dcsctp/tx/retransmission_error_counter.h" -#include "net/dcsctp/tx/retransmission_queue.h" -#include "net/dcsctp/tx/retransmission_timeout.h" #include "net/dcsctp/tx/rr_send_queue.h" namespace dcsctp { diff --git a/net/dcsctp/socket/dcsctp_socket_network_test.cc b/net/dcsctp/socket/dcsctp_socket_network_test.cc index 09a8bbb6c2..ff8d68ae6c 100644 --- a/net/dcsctp/socket/dcsctp_socket_network_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_network_test.cc @@ -7,37 +7,44 @@ * 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 -#include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "api/test/create_network_emulation_manager.h" +#include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/test/network_emulation_manager.h" +#include "api/test/simulated_network.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/timeout.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/socket/dcsctp_socket.h" #include "net/dcsctp/testing/testing_macros.h" #include "net/dcsctp/timer/task_queue_timeout.h" #include "rtc_base/copy_on_write_buffer.h" -#include "rtc_base/gunit.h" #include "rtc_base/logging.h" #include "rtc_base/random.h" #include "rtc_base/socket_address.h" +#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_format.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "test/gmock.h" +#include "test/gtest.h" #if !defined(WEBRTC_ANDROID) && defined(NDEBUG) && \ !defined(THREAD_SANITIZER) && !defined(MEMORY_SANITIZER) diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc index 9e0ea0f8c5..0d8ad72c6c 100644 --- a/net/dcsctp/socket/dcsctp_socket_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_test.cc @@ -10,8 +10,8 @@ #include "net/dcsctp/socket/dcsctp_socket.h" #include +#include #include -#include #include #include #include @@ -19,10 +19,12 @@ #include #include "absl/flags/flag.h" -#include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "net/dcsctp/common/handover_testing.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/packet/chunk/abort_chunk.h" #include "net/dcsctp/packet/chunk/chunk.h" @@ -34,13 +36,12 @@ #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/heartbeat_ack_chunk.h" #include "net/dcsctp/packet/chunk/heartbeat_request_chunk.h" -#include "net/dcsctp/packet/chunk/idata_chunk.h" #include "net/dcsctp/packet/chunk/init_ack_chunk.h" #include "net/dcsctp/packet/chunk/init_chunk.h" #include "net/dcsctp/packet/chunk/reconfig_chunk.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" #include "net/dcsctp/packet/chunk/shutdown_chunk.h" -#include "net/dcsctp/packet/error_cause/error_cause.h" +#include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h" #include "net/dcsctp/packet/parameter/heartbeat_info_parameter.h" #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" @@ -48,16 +49,19 @@ #include "net/dcsctp/packet/parameter/reconfiguration_response_parameter.h" #include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/packet/tlv_trait.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/packet_observer.h" #include "net/dcsctp/public/text_pcap_packet_observer.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/reassembly_queue.h" #include "net/dcsctp/socket/mock_dcsctp_socket_callbacks.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" +#include "rtc_base/logging.h" #include "test/gmock.h" +#include "test/gtest.h" ABSL_FLAG(bool, dcsctp_capture_packets, false, "Print packet capture."); diff --git a/net/dcsctp/socket/heartbeat_handler.h b/net/dcsctp/socket/heartbeat_handler.h index ac58b97a64..51cdc619e8 100644 --- a/net/dcsctp/socket/heartbeat_handler.h +++ b/net/dcsctp/socket/heartbeat_handler.h @@ -10,15 +10,13 @@ #ifndef NET_DCSCTP_SOCKET_HEARTBEAT_HANDLER_H_ #define NET_DCSCTP_SOCKET_HEARTBEAT_HANDLER_H_ -#include #include -#include #include "absl/strings/string_view.h" +#include "api/units/time_delta.h" #include "net/dcsctp/packet/chunk/heartbeat_ack_chunk.h" #include "net/dcsctp/packet/chunk/heartbeat_request_chunk.h" -#include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/socket/context.h" #include "net/dcsctp/timer/timer.h" diff --git a/net/dcsctp/socket/heartbeat_handler_test.cc b/net/dcsctp/socket/heartbeat_handler_test.cc index 8f6af0ce31..802ab02fed 100644 --- a/net/dcsctp/socket/heartbeat_handler_test.cc +++ b/net/dcsctp/socket/heartbeat_handler_test.cc @@ -9,19 +9,26 @@ */ #include "net/dcsctp/socket/heartbeat_handler.h" -#include +#include +#include #include #include #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "net/dcsctp/packet/chunk/heartbeat_ack_chunk.h" #include "net/dcsctp/packet/chunk/heartbeat_request_chunk.h" #include "net/dcsctp/packet/parameter/heartbeat_info_parameter.h" +#include "net/dcsctp/packet/parameter/parameter.h" +#include "net/dcsctp/packet/sctp_packet.h" +#include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/socket/mock_context.h" +#include "net/dcsctp/socket/mock_dcsctp_socket_callbacks.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" +#include "net/dcsctp/timer/timer.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/socket/mock_context.h b/net/dcsctp/socket/mock_context.h index 59801696d8..642376d6c6 100644 --- a/net/dcsctp/socket/mock_context.h +++ b/net/dcsctp/socket/mock_context.h @@ -10,10 +10,10 @@ #ifndef NET_DCSCTP_SOCKET_MOCK_CONTEXT_H_ #define NET_DCSCTP_SOCKET_MOCK_CONTEXT_H_ -#include -#include #include "absl/strings/string_view.h" +#include "api/units/time_delta.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" diff --git a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h index 9094c73814..7e405e5379 100644 --- a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h +++ b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h @@ -21,6 +21,8 @@ #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/timeout.h" diff --git a/net/dcsctp/socket/packet_sender.cc b/net/dcsctp/socket/packet_sender.cc index cdaf95c963..9abe1b48d7 100644 --- a/net/dcsctp/socket/packet_sender.cc +++ b/net/dcsctp/socket/packet_sender.cc @@ -9,10 +9,14 @@ */ #include "net/dcsctp/socket/packet_sender.h" +#include +#include #include #include -#include "net/dcsctp/public/types.h" +#include "api/array_view.h" +#include "net/dcsctp/packet/sctp_packet.h" +#include "net/dcsctp/public/dcsctp_socket.h" namespace dcsctp { diff --git a/net/dcsctp/socket/packet_sender.h b/net/dcsctp/socket/packet_sender.h index 273e0948f0..69a74f9ff8 100644 --- a/net/dcsctp/socket/packet_sender.h +++ b/net/dcsctp/socket/packet_sender.h @@ -10,6 +10,10 @@ #ifndef NET_DCSCTP_SOCKET_PACKET_SENDER_H_ #define NET_DCSCTP_SOCKET_PACKET_SENDER_H_ +#include +#include + +#include "api/array_view.h" #include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/public/dcsctp_socket.h" diff --git a/net/dcsctp/socket/packet_sender_test.cc b/net/dcsctp/socket/packet_sender_test.cc index d10786a9cc..be54580908 100644 --- a/net/dcsctp/socket/packet_sender_test.cc +++ b/net/dcsctp/socket/packet_sender_test.cc @@ -9,11 +9,17 @@ */ #include "net/dcsctp/socket/packet_sender.h" +#include + +#include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/cookie_ack_chunk.h" +#include "net/dcsctp/packet/sctp_packet.h" +#include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/socket/mock_dcsctp_socket_callbacks.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/socket/state_cookie.cc b/net/dcsctp/socket/state_cookie.cc index d9493826e9..3f8fdfb372 100644 --- a/net/dcsctp/socket/state_cookie.cc +++ b/net/dcsctp/socket/state_cookie.cc @@ -9,11 +9,13 @@ */ #include "net/dcsctp/socket/state_cookie.h" +#include #include #include #include #include "api/array_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" #include "net/dcsctp/socket/capabilities.h" diff --git a/net/dcsctp/socket/state_cookie.h b/net/dcsctp/socket/state_cookie.h index 387744a39f..90073586ab 100644 --- a/net/dcsctp/socket/state_cookie.h +++ b/net/dcsctp/socket/state_cookie.h @@ -10,6 +10,7 @@ #ifndef NET_DCSCTP_SOCKET_STATE_COOKIE_H_ #define NET_DCSCTP_SOCKET_STATE_COOKIE_H_ +#include #include #include #include diff --git a/net/dcsctp/socket/state_cookie_test.cc b/net/dcsctp/socket/state_cookie_test.cc index 806ea2024b..8ab2da6b93 100644 --- a/net/dcsctp/socket/state_cookie_test.cc +++ b/net/dcsctp/socket/state_cookie_test.cc @@ -9,9 +9,15 @@ */ #include "net/dcsctp/socket/state_cookie.h" +#include +#include + +#include "absl/strings/string_view.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/socket/capabilities.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/socket/stream_reset_handler.cc b/net/dcsctp/socket/stream_reset_handler.cc index 8d109ea071..700c5a6a5d 100644 --- a/net/dcsctp/socket/stream_reset_handler.cc +++ b/net/dcsctp/socket/stream_reset_handler.cc @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "api/array_view.h" @@ -27,15 +26,18 @@ #include "net/dcsctp/packet/parameter/reconfiguration_response_parameter.h" #include "net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h" #include "net/dcsctp/packet/sctp_packet.h" -#include "net/dcsctp/packet/tlv_trait.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/data_tracker.h" #include "net/dcsctp/rx/reassembly_queue.h" #include "net/dcsctp/socket/context.h" #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/retransmission_queue.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/str_join.h" +#include "rtc_base/strings/string_builder.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/socket/stream_reset_handler.h b/net/dcsctp/socket/stream_reset_handler.h index dba402e29e..c1bd24b993 100644 --- a/net/dcsctp/socket/stream_reset_handler.h +++ b/net/dcsctp/socket/stream_reset_handler.h @@ -10,10 +10,8 @@ #ifndef NET_DCSCTP_SOCKET_STREAM_RESET_HANDLER_H_ #define NET_DCSCTP_SOCKET_STREAM_RESET_HANDLER_H_ -#include #include #include -#include #include #include @@ -22,18 +20,17 @@ #include "api/array_view.h" #include "api/units/time_delta.h" #include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/reconfig_chunk.h" -#include "net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h" -#include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" +#include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/parameter/reconfiguration_response_parameter.h" -#include "net/dcsctp/packet/sctp_packet.h" -#include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/data_tracker.h" #include "net/dcsctp/rx/reassembly_queue.h" #include "net/dcsctp/socket/context.h" #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/retransmission_queue.h" -#include "rtc_base/containers/flat_set.h" namespace dcsctp { diff --git a/net/dcsctp/socket/stream_reset_handler_test.cc b/net/dcsctp/socket/stream_reset_handler_test.cc index 716eb9a649..92c55a57bf 100644 --- a/net/dcsctp/socket/stream_reset_handler_test.cc +++ b/net/dcsctp/socket/stream_reset_handler_test.cc @@ -13,11 +13,12 @@ #include #include #include -#include +#include #include #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "net/dcsctp/common/handover_testing.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" @@ -26,7 +27,9 @@ #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/parameter/reconfiguration_response_parameter.h" -#include "net/dcsctp/public/dcsctp_message.h" +#include "net/dcsctp/packet/sctp_packet.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" +#include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/data_tracker.h" #include "net/dcsctp/rx/reassembly_queue.h" @@ -37,8 +40,8 @@ #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/mock_send_queue.h" #include "net/dcsctp/tx/retransmission_queue.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/socket/transmission_control_block.cc b/net/dcsctp/socket/transmission_control_block.cc index 29f958be8d..8c7adbb8e9 100644 --- a/net/dcsctp/socket/transmission_control_block.cc +++ b/net/dcsctp/socket/transmission_control_block.cc @@ -10,30 +10,38 @@ #include "net/dcsctp/socket/transmission_control_block.h" #include -#include +#include +#include #include #include #include #include #include +#include "absl/functional/bind_front.h" +#include "absl/strings/string_view.h" +#include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/data_chunk.h" -#include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/idata_chunk.h" -#include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/reconfig_chunk.h" -#include "net/dcsctp/packet/chunk/sack_chunk.h" #include "net/dcsctp/packet/sctp_packet.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/rx/data_tracker.h" #include "net/dcsctp/rx/reassembly_queue.h" #include "net/dcsctp/socket/capabilities.h" +#include "net/dcsctp/socket/packet_sender.h" #include "net/dcsctp/socket/stream_reset_handler.h" #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/retransmission_queue.h" #include "net/dcsctp/tx/retransmission_timeout.h" +#include "net/dcsctp/tx/send_queue.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" diff --git a/net/dcsctp/socket/transmission_control_block.h b/net/dcsctp/socket/transmission_control_block.h index e4c58219fc..3211acdb8b 100644 --- a/net/dcsctp/socket/transmission_control_block.h +++ b/net/dcsctp/socket/transmission_control_block.h @@ -10,19 +10,20 @@ #ifndef NET_DCSCTP_SOCKET_TRANSMISSION_CONTROL_BLOCK_H_ #define NET_DCSCTP_SOCKET_TRANSMISSION_CONTROL_BLOCK_H_ -#include +#include #include #include +#include #include #include -#include -#include "absl/functional/bind_front.h" #include "absl/strings/string_view.h" -#include "api/task_queue/task_queue_base.h" -#include "net/dcsctp/common/sequence_numbers.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/chunk/cookie_echo_chunk.h" #include "net/dcsctp/packet/sctp_packet.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/rx/data_tracker.h" diff --git a/net/dcsctp/socket/transmission_control_block_test.cc b/net/dcsctp/socket/transmission_control_block_test.cc index 60876b3932..005df89d09 100644 --- a/net/dcsctp/socket/transmission_control_block_test.cc +++ b/net/dcsctp/socket/transmission_control_block_test.cc @@ -9,35 +9,21 @@ */ #include "net/dcsctp/socket/transmission_control_block.h" -#include +#include #include -#include -#include -#include -#include #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" -#include "net/dcsctp/common/handover_testing.h" #include "net/dcsctp/common/internal_types.h" -#include "net/dcsctp/packet/chunk/reconfig_chunk.h" -#include "net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h" -#include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" -#include "net/dcsctp/packet/parameter/parameter.h" -#include "net/dcsctp/packet/parameter/reconfiguration_response_parameter.h" -#include "net/dcsctp/public/dcsctp_message.h" -#include "net/dcsctp/rx/data_tracker.h" -#include "net/dcsctp/rx/reassembly_queue.h" +#include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/socket/capabilities.h" -#include "net/dcsctp/socket/mock_context.h" #include "net/dcsctp/socket/mock_dcsctp_socket_callbacks.h" -#include "net/dcsctp/testing/data_generator.h" -#include "net/dcsctp/testing/testing_macros.h" +#include "net/dcsctp/socket/packet_sender.h" #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/mock_send_queue.h" -#include "net/dcsctp/tx/retransmission_queue.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/testing/data_generator.cc b/net/dcsctp/testing/data_generator.cc index 417695c9d0..fabe23409f 100644 --- a/net/dcsctp/testing/data_generator.cc +++ b/net/dcsctp/testing/data_generator.cc @@ -15,6 +15,7 @@ #include #include "absl/strings/string_view.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/data.h" #include "net/dcsctp/public/types.h" diff --git a/net/dcsctp/testing/data_generator.h b/net/dcsctp/testing/data_generator.h index f8853298f9..9cae14b96d 100644 --- a/net/dcsctp/testing/data_generator.h +++ b/net/dcsctp/testing/data_generator.h @@ -15,9 +15,9 @@ #include #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/types.h" namespace dcsctp { diff --git a/net/dcsctp/testing/testing_macros.h b/net/dcsctp/testing/testing_macros.h index dafa76fc12..891e6c866f 100644 --- a/net/dcsctp/testing/testing_macros.h +++ b/net/dcsctp/testing/testing_macros.h @@ -10,7 +10,7 @@ #ifndef NET_DCSCTP_TESTING_TESTING_MACROS_H_ #define NET_DCSCTP_TESTING_TESTING_MACROS_H_ -#include +#include // IWYU pragma: keep namespace dcsctp { diff --git a/net/dcsctp/timer/BUILD.gn b/net/dcsctp/timer/BUILD.gn index 5b2eb1e620..c33473df41 100644 --- a/net/dcsctp/timer/BUILD.gn +++ b/net/dcsctp/timer/BUILD.gn @@ -11,7 +11,7 @@ import("../../../webrtc.gni") rtc_library("timer") { deps = [ "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", "../../../api/units:time_delta", "../../../api/units:timestamp", "../../../rtc_base:checks", @@ -33,12 +33,15 @@ rtc_library("timer") { rtc_library("task_queue_timeout") { deps = [ "../../../api:array_view", + "../../../api:scoped_refptr", + "../../../api:sequence_checker", + "../../../api/task_queue", "../../../api/task_queue:pending_task_safety_flag", - "../../../api/task_queue:task_queue", "../../../api/units:time_delta", "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:logging", + "../../../rtc_base/system:no_unique_address", "../public:socket", "../public:types", ] @@ -57,14 +60,17 @@ if (rtc_include_tests) { ":task_queue_timeout", ":timer", "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", "../../../api/task_queue/test:mock_task_queue_base", "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:gunit_helpers", + "../../../rtc_base:threading", "../../../test:test_support", - "../../../test/time_controller:time_controller", + "../../../test/time_controller", "../public:socket", + "../public:types", ] sources = [ "task_queue_timeout_test.cc", diff --git a/net/dcsctp/timer/fake_timeout.h b/net/dcsctp/timer/fake_timeout.h index 52a1b13dc7..1118eeaf6b 100644 --- a/net/dcsctp/timer/fake_timeout.h +++ b/net/dcsctp/timer/fake_timeout.h @@ -10,15 +10,14 @@ #ifndef NET_DCSCTP_TIMER_FAKE_TIMEOUT_H_ #define NET_DCSCTP_TIMER_FAKE_TIMEOUT_H_ -#include #include -#include #include #include #include #include #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "net/dcsctp/public/timeout.h" #include "net/dcsctp/public/types.h" diff --git a/net/dcsctp/timer/task_queue_timeout.cc b/net/dcsctp/timer/task_queue_timeout.cc index ef891e186d..03f9fab8a3 100644 --- a/net/dcsctp/timer/task_queue_timeout.cc +++ b/net/dcsctp/timer/task_queue_timeout.cc @@ -9,8 +9,13 @@ */ #include "net/dcsctp/timer/task_queue_timeout.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 "net/dcsctp/public/types.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" namespace dcsctp { diff --git a/net/dcsctp/timer/task_queue_timeout.h b/net/dcsctp/timer/task_queue_timeout.h index 7dccd2adc2..c8693aab35 100644 --- a/net/dcsctp/timer/task_queue_timeout.h +++ b/net/dcsctp/timer/task_queue_timeout.h @@ -10,13 +10,18 @@ #ifndef NET_DCSCTP_TIMER_TASK_QUEUE_TIMEOUT_H_ #define NET_DCSCTP_TIMER_TASK_QUEUE_TIMEOUT_H_ +#include #include #include +#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/timestamp.h" #include "net/dcsctp/public/timeout.h" +#include "net/dcsctp/public/types.h" +#include "rtc_base/system/no_unique_address.h" namespace dcsctp { diff --git a/net/dcsctp/timer/task_queue_timeout_test.cc b/net/dcsctp/timer/task_queue_timeout_test.cc index 07e1a592d7..66d06f2677 100644 --- a/net/dcsctp/timer/task_queue_timeout_test.cc +++ b/net/dcsctp/timer/task_queue_timeout_test.cc @@ -13,8 +13,13 @@ #include "api/task_queue/task_queue_base.h" #include "api/task_queue/test/mock_task_queue_base.h" -#include "rtc_base/gunit.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/public/timeout.h" +#include "net/dcsctp/public/types.h" +#include "rtc_base/thread.h" #include "test/gmock.h" +#include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" namespace dcsctp { diff --git a/net/dcsctp/timer/timer.cc b/net/dcsctp/timer/timer.cc index 07c9f3d786..aa49a1f53b 100644 --- a/net/dcsctp/timer/timer.cc +++ b/net/dcsctp/timer/timer.cc @@ -17,7 +17,9 @@ #include "absl/memory/memory.h" #include "absl/strings/string_view.h" +#include "api/units/time_delta.h" #include "net/dcsctp/public/timeout.h" +#include "net/dcsctp/public/types.h" #include "rtc_base/checks.h" namespace dcsctp { diff --git a/net/dcsctp/timer/timer.h b/net/dcsctp/timer/timer.h index cfacdda403..0e06210ec5 100644 --- a/net/dcsctp/timer/timer.h +++ b/net/dcsctp/timer/timer.h @@ -10,9 +10,9 @@ #ifndef NET_DCSCTP_TIMER_TIMER_H_ #define NET_DCSCTP_TIMER_TIMER_H_ -#include #include +#include #include #include #include @@ -24,6 +24,7 @@ #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "net/dcsctp/public/timeout.h" +#include "net/dcsctp/public/types.h" #include "rtc_base/strong_alias.h" namespace dcsctp { diff --git a/net/dcsctp/timer/timer_test.cc b/net/dcsctp/timer/timer_test.cc index 5d5091e1ca..65ad665969 100644 --- a/net/dcsctp/timer/timer_test.cc +++ b/net/dcsctp/timer/timer_test.cc @@ -9,15 +9,17 @@ */ #include "net/dcsctp/timer/timer.h" +#include #include #include #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" -#include "net/dcsctp/public/timeout.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/timer/fake_timeout.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/tx/BUILD.gn b/net/dcsctp/tx/BUILD.gn index 0e21d91cde..147bee6906 100644 --- a/net/dcsctp/tx/BUILD.gn +++ b/net/dcsctp/tx/BUILD.gn @@ -26,6 +26,8 @@ rtc_library("rr_send_queue") { ":send_queue", ":stream_scheduler", "../../../api:array_view", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:stringutils", @@ -47,6 +49,7 @@ rtc_library("stream_scheduler") { deps = [ ":send_queue", "../../../api:array_view", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:stringutils", @@ -124,9 +127,12 @@ rtc_library("retransmission_queue") { ":retransmission_timeout", ":send_queue", "../../../api:array_view", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:stringutils", + "../common:internal_types", "../common:math", "../common:sequence_numbers", "../packet:chunk", @@ -151,6 +157,8 @@ if (rtc_include_tests) { "../../../api:array_view", "../../../api/units:timestamp", "../../../test:test_support", + "../common:internal_types", + "../public:types", ] sources = [ "mock_send_queue.h" ] } @@ -168,7 +176,9 @@ if (rtc_include_tests) { ":send_queue", ":stream_scheduler", "../../../api:array_view", - "../../../api/task_queue:task_queue", + "../../../api/task_queue", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:gunit_helpers", "../../../test:test_support", diff --git a/net/dcsctp/tx/mock_send_queue.h b/net/dcsctp/tx/mock_send_queue.h index ba412f7ba2..3e61a8ee6f 100644 --- a/net/dcsctp/tx/mock_send_queue.h +++ b/net/dcsctp/tx/mock_send_queue.h @@ -10,12 +10,13 @@ #ifndef NET_DCSCTP_TX_MOCK_SEND_QUEUE_H_ #define NET_DCSCTP_TX_MOCK_SEND_QUEUE_H_ -#include +#include #include #include -#include "api/array_view.h" #include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/tx/send_queue.h" #include "test/gmock.h" diff --git a/net/dcsctp/tx/outstanding_data.cc b/net/dcsctp/tx/outstanding_data.cc index a92fc6f638..074e3c0461 100644 --- a/net/dcsctp/tx/outstanding_data.cc +++ b/net/dcsctp/tx/outstanding_data.cc @@ -10,14 +10,24 @@ #include "net/dcsctp/tx/outstanding_data.h" #include +#include +#include +#include +#include #include #include #include +#include "api/array_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/common/sequence_numbers.h" +#include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" +#include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" +#include "net/dcsctp/packet/chunk/sack_chunk.h" +#include "net/dcsctp/packet/data.h" #include "net/dcsctp/public/types.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/net/dcsctp/tx/outstanding_data.h b/net/dcsctp/tx/outstanding_data.h index a25969734a..512385e6fe 100644 --- a/net/dcsctp/tx/outstanding_data.h +++ b/net/dcsctp/tx/outstanding_data.h @@ -10,13 +10,17 @@ #ifndef NET_DCSCTP_TX_OUTSTANDING_DATA_H_ #define NET_DCSCTP_TX_OUTSTANDING_DATA_H_ +#include +#include #include -#include +#include #include #include #include #include +#include "api/array_view.h" +#include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" diff --git a/net/dcsctp/tx/outstanding_data_test.cc b/net/dcsctp/tx/outstanding_data_test.cc index e737035feb..fac4d7b0e3 100644 --- a/net/dcsctp/tx/outstanding_data_test.cc +++ b/net/dcsctp/tx/outstanding_data_test.cc @@ -12,17 +12,19 @@ #include #include +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/data_chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" -#include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/packet/chunk/sack_chunk.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/testing/data_generator.h" #include "net/dcsctp/testing/testing_macros.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/tx/retransmission_error_counter.h b/net/dcsctp/tx/retransmission_error_counter.h index 589e66b472..da1a457520 100644 --- a/net/dcsctp/tx/retransmission_error_counter.h +++ b/net/dcsctp/tx/retransmission_error_counter.h @@ -10,9 +10,7 @@ #ifndef NET_DCSCTP_TX_RETRANSMISSION_ERROR_COUNTER_H_ #define NET_DCSCTP_TX_RETRANSMISSION_ERROR_COUNTER_H_ -#include -#include -#include +#include #include "absl/strings/string_view.h" #include "net/dcsctp/public/dcsctp_options.h" diff --git a/net/dcsctp/tx/retransmission_error_counter_test.cc b/net/dcsctp/tx/retransmission_error_counter_test.cc index dc53740f0f..256aa99f87 100644 --- a/net/dcsctp/tx/retransmission_error_counter_test.cc +++ b/net/dcsctp/tx/retransmission_error_counter_test.cc @@ -9,9 +9,10 @@ */ #include "net/dcsctp/tx/retransmission_error_counter.h" +#include + #include "net/dcsctp/public/dcsctp_options.h" -#include "rtc_base/gunit.h" -#include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/tx/retransmission_queue.cc b/net/dcsctp/tx/retransmission_queue.cc index dae64a0207..9557a9be22 100644 --- a/net/dcsctp/tx/retransmission_queue.cc +++ b/net/dcsctp/tx/retransmission_queue.cc @@ -10,29 +10,28 @@ #include "net/dcsctp/tx/retransmission_queue.h" #include +#include #include #include -#include -#include #include -#include -#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/data_chunk.h" -#include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" -#include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/chunk/idata_chunk.h" -#include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/outstanding_data.h" diff --git a/net/dcsctp/tx/retransmission_queue.h b/net/dcsctp/tx/retransmission_queue.h index 4d8766c148..ad15b28f5d 100644 --- a/net/dcsctp/tx/retransmission_queue.h +++ b/net/dcsctp/tx/retransmission_queue.h @@ -10,17 +10,17 @@ #ifndef NET_DCSCTP_TX_RETRANSMISSION_QUEUE_H_ #define NET_DCSCTP_TX_RETRANSMISSION_QUEUE_H_ +#include #include #include -#include #include -#include -#include #include #include #include "absl/strings/string_view.h" -#include "api/array_view.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" @@ -29,9 +29,9 @@ #include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/outstanding_data.h" -#include "net/dcsctp/tx/retransmission_timeout.h" #include "net/dcsctp/tx/send_queue.h" namespace dcsctp { diff --git a/net/dcsctp/tx/retransmission_queue_test.cc b/net/dcsctp/tx/retransmission_queue_test.cc index 2f2f3943c4..760e457581 100644 --- a/net/dcsctp/tx/retransmission_queue_test.cc +++ b/net/dcsctp/tx/retransmission_queue_test.cc @@ -17,8 +17,9 @@ #include #include -#include "api/array_view.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "net/dcsctp/common/handover_testing.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/math.h" @@ -28,7 +29,9 @@ #include "net/dcsctp/packet/chunk/iforward_tsn_chunk.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/types.h" #include "net/dcsctp/socket/mock_dcsctp_socket_callbacks.h" #include "net/dcsctp/testing/data_generator.h" #include "net/dcsctp/testing/testing_macros.h" @@ -36,8 +39,8 @@ #include "net/dcsctp/timer/timer.h" #include "net/dcsctp/tx/mock_send_queue.h" #include "net/dcsctp/tx/send_queue.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/tx/retransmission_timeout.cc b/net/dcsctp/tx/retransmission_timeout.cc index 3456ed2910..f28f455c5d 100644 --- a/net/dcsctp/tx/retransmission_timeout.cc +++ b/net/dcsctp/tx/retransmission_timeout.cc @@ -10,7 +10,6 @@ #include "net/dcsctp/tx/retransmission_timeout.h" #include -#include #include "api/units/time_delta.h" #include "net/dcsctp/public/dcsctp_options.h" diff --git a/net/dcsctp/tx/retransmission_timeout.h b/net/dcsctp/tx/retransmission_timeout.h index b87501d79f..b65ab39fa9 100644 --- a/net/dcsctp/tx/retransmission_timeout.h +++ b/net/dcsctp/tx/retransmission_timeout.h @@ -10,9 +10,7 @@ #ifndef NET_DCSCTP_TX_RETRANSMISSION_TIMEOUT_H_ #define NET_DCSCTP_TX_RETRANSMISSION_TIMEOUT_H_ -#include -#include - +#include "api/units/time_delta.h" #include "net/dcsctp/public/dcsctp_options.h" namespace dcsctp { diff --git a/net/dcsctp/tx/retransmission_timeout_test.cc b/net/dcsctp/tx/retransmission_timeout_test.cc index 8686fbe012..3dafb59b95 100644 --- a/net/dcsctp/tx/retransmission_timeout_test.cc +++ b/net/dcsctp/tx/retransmission_timeout_test.cc @@ -9,9 +9,10 @@ */ #include "net/dcsctp/tx/retransmission_timeout.h" +#include "api/units/time_delta.h" #include "net/dcsctp/public/dcsctp_options.h" -#include "rtc_base/gunit.h" -#include "test/gmock.h" +#include "net/dcsctp/public/types.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/tx/rr_send_queue.cc b/net/dcsctp/tx/rr_send_queue.cc index 26d84363f1..537f5f35a7 100644 --- a/net/dcsctp/tx/rr_send_queue.cc +++ b/net/dcsctp/tx/rr_send_queue.cc @@ -9,25 +9,32 @@ */ #include "net/dcsctp/tx/rr_send_queue.h" +#include #include #include -#include #include #include #include +#include #include #include #include "absl/algorithm/container.h" +#include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/tx/send_queue.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/str_join.h" +#include "rtc_base/strings/string_builder.h" namespace dcsctp { using ::webrtc::TimeDelta; diff --git a/net/dcsctp/tx/rr_send_queue.h b/net/dcsctp/tx/rr_send_queue.h index 19c30e19c9..07148cccc9 100644 --- a/net/dcsctp/tx/rr_send_queue.h +++ b/net/dcsctp/tx/rr_send_queue.h @@ -10,24 +10,26 @@ #ifndef NET_DCSCTP_TX_RR_SEND_QUEUE_H_ #define NET_DCSCTP_TX_RR_SEND_QUEUE_H_ -#include +#include #include +#include #include #include #include -#include #include #include -#include "absl/algorithm/container.h" #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/tx/send_queue.h" #include "net/dcsctp/tx/stream_scheduler.h" +#include "rtc_base/checks.h" namespace dcsctp { diff --git a/net/dcsctp/tx/rr_send_queue_test.cc b/net/dcsctp/tx/rr_send_queue_test.cc index 3af511d841..7330893ef5 100644 --- a/net/dcsctp/tx/rr_send_queue_test.cc +++ b/net/dcsctp/tx/rr_send_queue_test.cc @@ -9,21 +9,24 @@ */ #include "net/dcsctp/tx/rr_send_queue.h" +#include #include -#include +#include #include +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/data.h" +#include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" -#include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/socket/mock_dcsctp_socket_callbacks.h" #include "net/dcsctp/testing/testing_macros.h" #include "net/dcsctp/tx/send_queue.h" -#include "rtc_base/gunit.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/net/dcsctp/tx/send_queue.h b/net/dcsctp/tx/send_queue.h index 5f7ca2a758..9fca8e293e 100644 --- a/net/dcsctp/tx/send_queue.h +++ b/net/dcsctp/tx/send_queue.h @@ -10,13 +10,11 @@ #ifndef NET_DCSCTP_TX_SEND_QUEUE_H_ #define NET_DCSCTP_TX_SEND_QUEUE_H_ -#include -#include +#include #include #include #include -#include "api/array_view.h" #include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/data.h" diff --git a/net/dcsctp/tx/stream_scheduler.cc b/net/dcsctp/tx/stream_scheduler.cc index ef3c52c560..a09cff519d 100644 --- a/net/dcsctp/tx/stream_scheduler.cc +++ b/net/dcsctp/tx/stream_scheduler.cc @@ -10,18 +10,20 @@ #include "net/dcsctp/tx/stream_scheduler.h" #include +#include #include +#include #include "absl/algorithm/container.h" -#include "api/array_view.h" +#include "api/units/timestamp.h" #include "net/dcsctp/packet/data.h" -#include "net/dcsctp/public/dcsctp_message.h" -#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/tx/send_queue.h" #include "rtc_base/checks.h" +#include "rtc_base/containers/flat_set.h" #include "rtc_base/logging.h" #include "rtc_base/strings/str_join.h" +#include "rtc_base/strings/string_builder.h" namespace dcsctp { diff --git a/net/dcsctp/tx/stream_scheduler.h b/net/dcsctp/tx/stream_scheduler.h index f5377fa7ed..0c1715f6b2 100644 --- a/net/dcsctp/tx/stream_scheduler.h +++ b/net/dcsctp/tx/stream_scheduler.h @@ -11,24 +11,16 @@ #define NET_DCSCTP_TX_STREAM_SCHEDULER_H_ #include -#include -#include -#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/array_view.h" +#include "api/units/timestamp.h" #include "net/dcsctp/packet/chunk/idata_chunk.h" #include "net/dcsctp/packet/sctp_packet.h" -#include "net/dcsctp/public/dcsctp_message.h" -#include "net/dcsctp/public/dcsctp_socket.h" #include "net/dcsctp/public/types.h" #include "net/dcsctp/tx/send_queue.h" #include "rtc_base/containers/flat_set.h" diff --git a/net/dcsctp/tx/stream_scheduler_test.cc b/net/dcsctp/tx/stream_scheduler_test.cc index 024e7430c4..9dfb5bc0bc 100644 --- a/net/dcsctp/tx/stream_scheduler_test.cc +++ b/net/dcsctp/tx/stream_scheduler_test.cc @@ -9,11 +9,23 @@ */ #include "net/dcsctp/tx/stream_scheduler.h" +#include +#include +#include +#include +#include +#include #include +#include "api/units/timestamp.h" +#include "net/dcsctp/common/internal_types.h" +#include "net/dcsctp/packet/chunk/idata_chunk.h" +#include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/public/types.h" +#include "net/dcsctp/tx/send_queue.h" #include "test/gmock.h" +#include "test/gtest.h" namespace dcsctp { namespace { diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 5dab31046b..ef49a919c4 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -77,6 +77,7 @@ rtc_library("basic_ice_controller") { ":ice_switch_reason", ":ice_transport_internal", ":p2p_constants", + ":p2p_transport_channel_ice_field_trials", ":transport_description", "../api:array_view", "../api:candidate", @@ -134,6 +135,7 @@ rtc_library("basic_port_allocator") { ":turn_port_factory", "../api:candidate", "../api:field_trials_view", + "../api:local_network_access_permission", "../api:packet_socket_factory", "../api:sequence_checker", "../api:turn_customizer", @@ -180,6 +182,7 @@ rtc_library("connection") { ":candidate_pair_interface", ":connection_info", ":dtls_stun_piggyback_controller", + ":dtls_utils", ":ice_credentials_iterator", ":p2p_constants", ":p2p_transport_channel_ice_field_trials", @@ -307,7 +310,6 @@ rtc_library("dtls_transport") { "../rtc_base:stringutils", "../rtc_base:threading", "../rtc_base:timeutils", - "../rtc_base/network:ecn_marking", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", "../rtc_base/system:no_unique_address", @@ -380,6 +382,7 @@ rtc_source_set("ice_controller_factory_interface") { ":connection", ":ice_controller_interface", ":ice_transport_internal", + ":p2p_transport_channel_ice_field_trials", ":transport_description", ] } @@ -539,6 +542,7 @@ rtc_library("packet_transport_internal") { "../rtc_base:network_route", "../rtc_base:socket", "../rtc_base/network:received_packet", + "../rtc_base/network:sent_packet", "../rtc_base/system:rtc_export", "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/functional:any_invocable", @@ -560,6 +564,7 @@ rtc_library("port") { "../api:array_view", "../api:candidate", "../api:field_trials_view", + "../api:local_network_access_permission", "../api:packet_socket_factory", "../api:rtc_error", "../api:sequence_checker", @@ -589,6 +594,8 @@ rtc_library("port") { "../rtc_base/network:sent_packet", "../rtc_base/system:rtc_export", "../rtc_base/third_party/sigslot", + "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", @@ -631,7 +638,7 @@ rtc_library("port_interface") { "../api:candidate", "../api:field_trials_view", "../api:packet_socket_factory", - "../api/task_queue:task_queue", + "../api/task_queue", "../rtc_base:async_packet_socket", "../rtc_base:callback_list", "../rtc_base:dscp", @@ -645,26 +652,6 @@ rtc_library("port_interface") { ] } -rtc_library("pseudo_tcp") { - sources = [ - "base/pseudo_tcp.cc", - "base/pseudo_tcp.h", - ] - deps = [ - "../api:array_view", - "../rtc_base:byte_buffer", - "../rtc_base:byte_order", - "../rtc_base:checks", - "../rtc_base:logging", - "../rtc_base:macromagic", - "../rtc_base:safe_minmax", - "../rtc_base:socket", - "../rtc_base:timeutils", - "../rtc_base/synchronization:mutex", - "../rtc_base/system:rtc_export", - ] -} - rtc_library("regathering_controller") { sources = [ "base/regathering_controller.cc", @@ -756,6 +743,7 @@ rtc_library("stun_port") { "../api:async_dns_resolver", "../api:candidate", "../api:field_trials_view", + "../api:local_network_access_permission", "../api:packet_socket_factory", "../api/transport:stun_types", "../rtc_base:async_packet_socket", @@ -900,6 +888,7 @@ rtc_library("turn_port") { "../api:array_view", "../api:async_dns_resolver", "../api:candidate", + "../api:local_network_access_permission", "../api:packet_socket_factory", "../api:scoped_refptr", "../api:turn_customizer", @@ -951,6 +940,7 @@ rtc_source_set("relay_port_factory_interface") { deps = [ ":port", ":port_allocator", + "../api:local_network_access_permission", "../api:packet_socket_factory", "../api/environment", "../rtc_base:async_packet_socket", @@ -1003,6 +993,7 @@ if (rtc_include_tests) { ":transport_description", "../api:array_view", "../api:candidate", + "../api:field_trials", "../api:ice_transport_interface", "../api:libjingle_peerconnection_api", "../api:sequence_checker", @@ -1023,7 +1014,7 @@ if (rtc_include_tests) { "../rtc_base:timeutils", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", - "../test:explicit_key_value_config", + "../test:create_test_field_trials", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", @@ -1143,6 +1134,7 @@ if (rtc_include_tests) { "../rtc_base:threading", "../rtc_base:timeutils", "../rtc_base/network:received_packet", + "../rtc_base/network:sent_packet", "../rtc_base/synchronization:mutex", "../rtc_base/third_party/sigslot", "../test:test_support", @@ -1160,7 +1152,6 @@ if (rtc_include_tests) { "base/packet_transport_internal_unittest.cc", "base/port_allocator_unittest.cc", "base/port_unittest.cc", - "base/pseudo_tcp_unittest.cc", "base/regathering_controller_unittest.cc", "base/stun_dictionary_unittest.cc", "base/stun_port_unittest.cc", @@ -1207,7 +1198,6 @@ if (rtc_include_tests) { ":port", ":port_allocator", ":port_interface", - ":pseudo_tcp", ":regathering_controller", ":relay_port_factory_interface", ":stun_dictionary", @@ -1241,6 +1231,7 @@ if (rtc_include_tests) { "../api/task_queue", "../api/task_queue:pending_task_safety_flag", "../api/test/network_emulation", + "../api/transport:ecn_marking", "../api/transport:enums", "../api/transport:stun_types", "../api/units:data_rate", @@ -1278,13 +1269,11 @@ if (rtc_include_tests) { "../rtc_base:testclient", "../rtc_base:threading", "../rtc_base:timeutils", - "../rtc_base/network:ecn_marking", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", "../rtc_base/third_party/sigslot", "../system_wrappers:metrics", - "../test:explicit_key_value_config", - "../test:scoped_key_value_config", + "../test:create_test_field_trials", "../test:test_support", "../test:wait_until", "//third_party/abseil-cpp/absl/algorithm:container", diff --git a/p2p/base/active_ice_controller_factory_interface.h b/p2p/base/active_ice_controller_factory_interface.h index 8b8246f487..24c7e50955 100644 --- a/p2p/base/active_ice_controller_factory_interface.h +++ b/p2p/base/active_ice_controller_factory_interface.h @@ -36,13 +36,5 @@ class ActiveIceControllerFactoryInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ActiveIceControllerFactoryArgs; -using ::webrtc::ActiveIceControllerFactoryInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ACTIVE_ICE_CONTROLLER_FACTORY_INTERFACE_H_ diff --git a/p2p/base/active_ice_controller_interface.h b/p2p/base/active_ice_controller_interface.h index 252cdc4642..bd1ee15335 100644 --- a/p2p/base/active_ice_controller_interface.h +++ b/p2p/base/active_ice_controller_interface.h @@ -80,12 +80,5 @@ class ActiveIceControllerInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ActiveIceControllerInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ACTIVE_ICE_CONTROLLER_INTERFACE_H_ diff --git a/p2p/base/async_stun_tcp_socket.cc b/p2p/base/async_stun_tcp_socket.cc index 9a1c906619..8cbf16d79a 100644 --- a/p2p/base/async_stun_tcp_socket.cc +++ b/p2p/base/async_stun_tcp_socket.cc @@ -10,10 +10,7 @@ #include "p2p/base/async_stun_tcp_socket.h" -#include -#include -#include - +#include #include #include diff --git a/p2p/base/async_stun_tcp_socket.h b/p2p/base/async_stun_tcp_socket.h index d4146d6e54..b7f983f9f8 100644 --- a/p2p/base/async_stun_tcp_socket.h +++ b/p2p/base/async_stun_tcp_socket.h @@ -11,8 +11,7 @@ #ifndef P2P_BASE_ASYNC_STUN_TCP_SOCKET_H_ #define P2P_BASE_ASYNC_STUN_TCP_SOCKET_H_ -#include - +#include #include #include "api/array_view.h" @@ -51,12 +50,5 @@ class AsyncStunTCPSocket : public AsyncTCPSocketBase { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::AsyncStunTCPSocket; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ASYNC_STUN_TCP_SOCKET_H_ diff --git a/p2p/base/async_stun_tcp_socket_unittest.cc b/p2p/base/async_stun_tcp_socket_unittest.cc index 5e3bd96b4d..39515dd5c0 100644 --- a/p2p/base/async_stun_tcp_socket_unittest.cc +++ b/p2p/base/async_stun_tcp_socket_unittest.cc @@ -10,9 +10,8 @@ #include "p2p/base/async_stun_tcp_socket.h" -#include -#include - +#include +#include #include #include #include diff --git a/p2p/base/basic_ice_controller.h b/p2p/base/basic_ice_controller.h index e8593dbed0..b2aa3c3cee 100644 --- a/p2p/base/basic_ice_controller.h +++ b/p2p/base/basic_ice_controller.h @@ -26,6 +26,7 @@ #include "p2p/base/ice_switch_reason.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/p2p_constants.h" +#include "p2p/base/p2p_transport_channel_ice_field_trials.h" #include "p2p/base/transport_description.h" #include "rtc_base/network.h" #include "rtc_base/network_constants.h" @@ -174,12 +175,5 @@ class BasicIceController : public IceControllerInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::BasicIceController; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_BASIC_ICE_CONTROLLER_H_ diff --git a/p2p/base/basic_packet_socket_factory.cc b/p2p/base/basic_packet_socket_factory.cc index 785f80b330..3810e2b324 100644 --- a/p2p/base/basic_packet_socket_factory.cc +++ b/p2p/base/basic_packet_socket_factory.cc @@ -10,8 +10,6 @@ #include "p2p/base/basic_packet_socket_factory.h" -#include - #include #include #include diff --git a/p2p/base/basic_packet_socket_factory.h b/p2p/base/basic_packet_socket_factory.h index 276e30956d..40bf94cce4 100644 --- a/p2p/base/basic_packet_socket_factory.h +++ b/p2p/base/basic_packet_socket_factory.h @@ -11,8 +11,7 @@ #ifndef P2P_BASE_BASIC_PACKET_SOCKET_FACTORY_H_ #define P2P_BASE_BASIC_PACKET_SOCKET_FACTORY_H_ -#include - +#include #include #include "api/async_dns_resolver.h" @@ -55,12 +54,5 @@ class RTC_EXPORT BasicPacketSocketFactory : public PacketSocketFactory { } // 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::BasicPacketSocketFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_BASIC_PACKET_SOCKET_FACTORY_H_ diff --git a/p2p/base/candidate_pair_interface.h b/p2p/base/candidate_pair_interface.h index 65ab7883f2..9c63a0af66 100644 --- a/p2p/base/candidate_pair_interface.h +++ b/p2p/base/candidate_pair_interface.h @@ -37,13 +37,5 @@ struct CandidatePair final : public CandidatePairInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CandidatePair; -using ::webrtc::CandidatePairInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_CANDIDATE_PAIR_INTERFACE_H_ diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index 92403b4d78..286e98fc06 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -10,9 +10,8 @@ #include "p2p/base/connection.h" -#include - #include +#include #include #include #include @@ -41,6 +40,7 @@ #include "p2p/base/stun_request.h" #include "p2p/base/transport_description.h" #include "p2p/dtls/dtls_stun_piggyback_callbacks.h" +#include "p2p/dtls/dtls_utils.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/checks.h" @@ -607,7 +607,8 @@ void Connection::MaybeAddDtlsPiggybackingAttributes(StunMessage* msg) { if (ack) { size_t msg_length = msg->length(); - size_t need_length = ack->length() + kStunAttributeHeaderSize; + size_t need_length = + kStunAttributeHeaderSize + ack->size() * sizeof(uint32_t); if (msg_length + need_length <= kMaxStunBindingLength) { msg->AddAttribute(std::make_unique( STUN_ATTR_META_DTLS_IN_STUN_ACK, *ack)); @@ -630,6 +631,41 @@ void Connection::MaybeAddDtlsPiggybackingAttributes(StunMessage* msg) { } } +void Connection::MaybeHandleDtlsPiggybackingAttributes( + const StunMessage* msg, + const StunRequest* original_request) { + if (dtls_stun_piggyback_callbacks_.empty()) { + return; + } + const StunByteStringAttribute* dtls_piggyback_attr = + msg->GetByteString(STUN_ATTR_META_DTLS_IN_STUN); + const StunByteStringAttribute* dtls_piggyback_ack = + msg->GetByteString(STUN_ATTR_META_DTLS_IN_STUN_ACK); + std::optional> piggyback_data; + if (dtls_piggyback_attr != nullptr) { + piggyback_data = dtls_piggyback_attr->array_view(); + } + std::optional> piggyback_acks; + if (dtls_piggyback_ack != nullptr) { + piggyback_acks = dtls_piggyback_ack->GetUInt32Vector(); + } + // A response implicitly acknowledges the original embedded packet + // when the ack attribute is included. + if (dtls_piggyback_ack != nullptr && original_request != nullptr) { + const StunByteStringAttribute* request_dtls_piggyback = + original_request->msg()->GetByteString(STUN_ATTR_META_DTLS_IN_STUN); + if (request_dtls_piggyback) { + uint32_t sent_hash = + ComputeDtlsPacketHash(request_dtls_piggyback->array_view()); + if (!piggyback_acks) { + piggyback_acks = {}; + } + piggyback_acks->push_back(sent_hash); + } + } + dtls_stun_piggyback_callbacks_.recv_data(piggyback_data, piggyback_acks); +} + void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) { RTC_DCHECK_RUN_ON(network_thread_); // This connection should now be receiving. @@ -672,14 +708,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) { // This is a validated stun request from remote peer. if (msg->type() == STUN_BINDING_REQUEST) { - if (!dtls_stun_piggyback_callbacks_.empty()) { - const StunByteStringAttribute* dtls_piggyback_attribute = - msg->GetByteString(STUN_ATTR_META_DTLS_IN_STUN); - const StunByteStringAttribute* dtls_piggyback_ack = - msg->GetByteString(STUN_ATTR_META_DTLS_IN_STUN_ACK); - dtls_stun_piggyback_callbacks_.recv_data(dtls_piggyback_attribute, - dtls_piggyback_ack); - } + MaybeHandleDtlsPiggybackingAttributes(msg, /*original_request=*/nullptr); SendStunBindingResponse(msg); } else { RTC_DCHECK(msg->type() == GOOG_PING_REQUEST); @@ -1542,20 +1571,12 @@ void Connection::OnConnectionRequestResponse(StunRequest* request, RTC_LOG(LS_ERROR) << "Discard GOOG_DELTA_ACK, no consumer"; } - if (!dtls_stun_piggyback_callbacks_.empty()) { - const bool sent_dtls_piggyback = - request->msg()->GetByteString(STUN_ATTR_META_DTLS_IN_STUN) != nullptr; - const bool sent_dtls_piggyback_ack = - request->msg()->GetByteString(STUN_ATTR_META_DTLS_IN_STUN_ACK) != - nullptr; - const StunByteStringAttribute* dtls_piggyback_attr = - response->GetByteString(STUN_ATTR_META_DTLS_IN_STUN); - const StunByteStringAttribute* dtls_piggyback_ack = - response->GetByteString(STUN_ATTR_META_DTLS_IN_STUN_ACK); - if (sent_dtls_piggyback || sent_dtls_piggyback_ack) { - dtls_stun_piggyback_callbacks_.recv_data(dtls_piggyback_attr, - dtls_piggyback_ack); - } + const bool sent_dtls_piggyback = + request->msg()->GetByteString(STUN_ATTR_META_DTLS_IN_STUN) != nullptr; + const bool sent_dtls_piggyback_ack = + request->msg()->GetByteString(STUN_ATTR_META_DTLS_IN_STUN_ACK) != nullptr; + if (sent_dtls_piggyback || sent_dtls_piggyback_ack) { + MaybeHandleDtlsPiggybackingAttributes(response, request); } } diff --git a/p2p/base/connection.h b/p2p/base/connection.h index 79cb94a0b6..b62ed99438 100644 --- a/p2p/base/connection.h +++ b/p2p/base/connection.h @@ -11,8 +11,7 @@ #ifndef P2P_BASE_CONNECTION_H_ #define P2P_BASE_CONNECTION_H_ -#include - +#include #include #include #include @@ -520,6 +519,9 @@ class RTC_EXPORT Connection : public CandidatePairInterface { received_packet_callback_; void MaybeAddDtlsPiggybackingAttributes(StunMessage* msg); + void MaybeHandleDtlsPiggybackingAttributes( + const StunMessage* msg, + const StunRequest* original_request); DtlsStunPiggybackCallbacks dtls_stun_piggyback_callbacks_; }; @@ -541,15 +543,5 @@ class ProxyConnection : public Connection { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::Connection; -using ::webrtc::kGoogPingVersion; -using ::webrtc::kMaxStunBindingLength; -using ::webrtc::ProxyConnection; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_CONNECTION_H_ diff --git a/p2p/base/connection_info.h b/p2p/base/connection_info.h index 03d0f96d85..435605059f 100644 --- a/p2p/base/connection_info.h +++ b/p2p/base/connection_info.h @@ -86,14 +86,5 @@ typedef std::vector ConnectionInfos; } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ConnectionInfo; -using ::webrtc::ConnectionInfos; -using ::webrtc::IceCandidatePairState; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_CONNECTION_INFO_H_ diff --git a/p2p/base/ice_agent_interface.h b/p2p/base/ice_agent_interface.h index faf28d76a7..d646f0a7be 100644 --- a/p2p/base/ice_agent_interface.h +++ b/p2p/base/ice_agent_interface.h @@ -80,12 +80,5 @@ class IceAgentInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IceAgentInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ICE_AGENT_INTERFACE_H_ diff --git a/p2p/base/ice_controller_factory_interface.h b/p2p/base/ice_controller_factory_interface.h index bcf493da21..2f8754e3aa 100644 --- a/p2p/base/ice_controller_factory_interface.h +++ b/p2p/base/ice_controller_factory_interface.h @@ -18,6 +18,7 @@ #include "p2p/base/connection.h" #include "p2p/base/ice_controller_interface.h" #include "p2p/base/ice_transport_internal.h" +#include "p2p/base/p2p_transport_channel_ice_field_trials.h" #include "p2p/base/transport_description.h" namespace webrtc { @@ -40,13 +41,5 @@ class IceControllerFactoryInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IceControllerFactoryArgs; -using ::webrtc::IceControllerFactoryInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ICE_CONTROLLER_FACTORY_INTERFACE_H_ diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h index a082d22606..9234bb3e06 100644 --- a/p2p/base/ice_controller_interface.h +++ b/p2p/base/ice_controller_interface.h @@ -20,7 +20,6 @@ #include "p2p/base/connection.h" #include "p2p/base/ice_switch_reason.h" #include "p2p/base/ice_transport_internal.h" -#include "p2p/base/p2p_transport_channel_ice_field_trials.h" #include "p2p/base/transport_description.h" #include "rtc_base/checks.h" #include "rtc_base/system/rtc_export.h" @@ -150,13 +149,5 @@ class IceControllerInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IceControllerInterface; -using ::webrtc::IceRecheckEvent; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ICE_CONTROLLER_INTERFACE_H_ diff --git a/p2p/base/ice_credentials_iterator.h b/p2p/base/ice_credentials_iterator.h index 5bab55fc62..f9beaa012e 100644 --- a/p2p/base/ice_credentials_iterator.h +++ b/p2p/base/ice_credentials_iterator.h @@ -34,12 +34,5 @@ class IceCredentialsIterator { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IceCredentialsIterator; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ICE_CREDENTIALS_ITERATOR_H_ diff --git a/p2p/base/ice_switch_reason.h b/p2p/base/ice_switch_reason.h index fec3c99f84..2917a14e69 100644 --- a/p2p/base/ice_switch_reason.h +++ b/p2p/base/ice_switch_reason.h @@ -40,13 +40,5 @@ RTC_EXPORT std::string IceSwitchReasonToString(IceSwitchReason reason); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IceSwitchReason; -using ::webrtc::IceSwitchReasonToString; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ICE_SWITCH_REASON_H_ diff --git a/p2p/base/ice_transport_internal.h b/p2p/base/ice_transport_internal.h index ac6362459e..c1f3e0c747 100644 --- a/p2p/base/ice_transport_internal.h +++ b/p2p/base/ice_transport_internal.h @@ -11,8 +11,7 @@ #ifndef P2P_BASE_ICE_TRANSPORT_INTERNAL_H_ #define P2P_BASE_ICE_TRANSPORT_INTERNAL_H_ -#include - +#include #include #include #include @@ -382,11 +381,6 @@ class RTC_EXPORT IceTransportInternal : public PacketTransportInternal { // agents. sigslot::signal1 SignalRoleConflict; - // Emitted whenever the transport state changed. - // TODO(bugs.webrtc.org/9308): Remove once all uses have migrated to the new - // IceTransportState. - sigslot::signal1 SignalStateChanged; - // Emitted whenever the new standards-compliant transport state changed. sigslot::signal1 SignalIceTransportStateChanged; @@ -446,32 +440,5 @@ class RTC_EXPORT IceTransportInternal : public PacketTransportInternal { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::Candidates; -using ::webrtc::ContinualGatheringPolicy; -using ::webrtc::GATHER_CONTINUALLY; -using ::webrtc::GATHER_ONCE; -using ::webrtc::IceConfig; -using ::webrtc::IceConnectionState; -using ::webrtc::IceGatheringState; -using ::webrtc::IceTransportInternal; -using ::webrtc::IceTransportStats; -using ::webrtc::kIceConnectionCompleted; -using ::webrtc::kIceConnectionConnected; -using ::webrtc::kIceConnectionConnecting; -using ::webrtc::kIceConnectionFailed; -using ::webrtc::kIceGatheringComplete; -using ::webrtc::kIceGatheringGathering; -using ::webrtc::kIceGatheringNew; -using ::webrtc::NominationMode; -using ::webrtc::VerifyCandidate; -using ::webrtc::VerifyCandidates; - -using IceTransportState = ::webrtc::IceTransportStateInternal; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_ICE_TRANSPORT_INTERNAL_H_ diff --git a/p2p/base/p2p_constants.h b/p2p/base/p2p_constants.h index 80aa37639b..3857f66cc1 100644 --- a/p2p/base/p2p_constants.h +++ b/p2p/base/p2p_constants.h @@ -11,8 +11,8 @@ #ifndef P2P_BASE_P2P_CONSTANTS_H_ #define P2P_BASE_P2P_CONSTANTS_H_ -#include -#include +#include +#include #include "rtc_base/system/rtc_export.h" @@ -23,12 +23,16 @@ namespace webrtc { // names (since Gingle has no content names). But when we receive a // Jingle call, the content name can be anything, so don't rely on // these values being the same as the ones received. +// Note: these were used in the deprecated "plan-b". +[[deprecated("plan-b")]] extern const char CN_AUDIO[]; +[[deprecated("plan-b")]] extern const char CN_VIDEO[]; +[[deprecated("plan-b")]] extern const char CN_DATA[]; +[[deprecated("plan-b")]] extern const char CN_OTHER[]; -// GN stands for group name extern const char GROUP_TYPE_BUNDLE[]; RTC_EXPORT extern const int ICE_UFRAG_LENGTH; @@ -128,57 +132,5 @@ const int kMaxTurnUsernameLength = 509; // RFC 8489 section 14.3 } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::BACKUP_CONNECTION_PING_INTERVAL; -using ::webrtc::CN_AUDIO; -using ::webrtc::CN_DATA; -using ::webrtc::CN_OTHER; -using ::webrtc::CN_VIDEO; -using ::webrtc::CONNECTION_RESPONSE_TIMEOUT; -using ::webrtc::CONNECTION_WRITE_CONNECT_FAILURES; -using ::webrtc::CONNECTION_WRITE_CONNECT_TIMEOUT; -using ::webrtc::CONNECTION_WRITE_TIMEOUT; -using ::webrtc::CONNECTIONROLE_ACTIVE_STR; -using ::webrtc::CONNECTIONROLE_ACTPASS_STR; -using ::webrtc::CONNECTIONROLE_HOLDCONN_STR; -using ::webrtc::CONNECTIONROLE_PASSIVE_STR; -using ::webrtc::DEAD_CONNECTION_RECEIVE_TIMEOUT; -using ::webrtc::GROUP_TYPE_BUNDLE; -using ::webrtc::ICE_CANDIDATE_COMPONENT_DEFAULT; -using ::webrtc::ICE_CANDIDATE_COMPONENT_RTCP; -using ::webrtc::ICE_CANDIDATE_COMPONENT_RTP; -using ::webrtc::ICE_PWD_LENGTH; -using ::webrtc::ICE_PWD_MAX_LENGTH; -using ::webrtc::ICE_PWD_MIN_LENGTH; -using ::webrtc::ICE_TYPE_PREFERENCE_HOST; -using ::webrtc::ICE_TYPE_PREFERENCE_HOST_TCP; -using ::webrtc::ICE_TYPE_PREFERENCE_PRFLX; -using ::webrtc::ICE_TYPE_PREFERENCE_PRFLX_TCP; -using ::webrtc::ICE_TYPE_PREFERENCE_RELAY_TCP; -using ::webrtc::ICE_TYPE_PREFERENCE_RELAY_TLS; -using ::webrtc::ICE_TYPE_PREFERENCE_RELAY_UDP; -using ::webrtc::ICE_TYPE_PREFERENCE_SRFLX; -using ::webrtc::ICE_UFRAG_LENGTH; -using ::webrtc::ICE_UFRAG_MAX_LENGTH; -using ::webrtc::ICE_UFRAG_MIN_LENGTH; -using ::webrtc::IcePriorityValue; -using ::webrtc::LOCAL_TLD; -using ::webrtc::MIN_CHECK_RECEIVING_INTERVAL; -using ::webrtc::MIN_CONNECTION_LIFETIME; -using ::webrtc::MIN_PINGS_AT_WEAK_PING_INTERVAL; -using ::webrtc::RECEIVING_SWITCHING_DELAY; -using ::webrtc::RECEIVING_TIMEOUT; -using ::webrtc::REGATHER_ON_FAILED_NETWORKS_INTERVAL; -using ::webrtc::STRONG_AND_STABLE_WRITABLE_CONNECTION_PING_INTERVAL; -using ::webrtc::STRONG_PING_INTERVAL; -using ::webrtc::STUN_KEEPALIVE_INTERVAL; -using ::webrtc::WEAK_CONNECTION_RECEIVE_TIMEOUT; -using ::webrtc::WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL; -using ::webrtc::WEAK_PING_INTERVAL; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_P2P_CONSTANTS_H_ diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 81af5da411..3a04b25dac 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -10,12 +10,11 @@ #include "p2p/base/p2p_transport_channel.h" -#include -#include - #include +#include #include #include +#include #include #include #include @@ -1980,12 +1979,13 @@ void P2PTransportChannel::UpdateTransportState() { RTC_DCHECK_NOTREACHED(); break; } - state_ = state; - SignalStateChanged(this); } - if (standardized_state_ != current_standardized_state) { + if (standardized_state_ != current_standardized_state || state_ != state) { standardized_state_ = current_standardized_state; + state_ = state; + // Unconditionally signal change, no matter what changed. + // TODO: issues.webrtc.org/42234495 - rmeove nonstandard state_ SignalIceTransportStateChanged(this); } } @@ -2220,14 +2220,8 @@ void P2PTransportChannel::OnCandidatesRemoved( if (!config_.gather_continually() || session != allocator_session()) { return; } - - std::vector candidates_to_remove; - for (Candidate candidate : candidates) { - candidate.set_transport_name(transport_name()); - candidates_to_remove.push_back(candidate); - } if (candidates_removed_callback_) { - candidates_removed_callback_(this, candidates_to_remove); + candidates_removed_callback_(this, candidates); } } diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h index 479c2e50a1..738e48e26a 100644 --- a/p2p/base/p2p_transport_channel.h +++ b/p2p/base/p2p_transport_channel.h @@ -20,9 +20,8 @@ #ifndef P2P_BASE_P2P_TRANSPORT_CHANNEL_H_ #define P2P_BASE_P2P_TRANSPORT_CHANNEL_H_ -#include -#include - +#include +#include #include #include #include @@ -544,14 +543,5 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal, } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IceCredentialsChanged; -using ::webrtc::P2PTransportChannel; -using ::webrtc::RemoteCandidate; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_P2P_TRANSPORT_CHANNEL_H_ diff --git a/p2p/base/p2p_transport_channel_ice_field_trials.h b/p2p/base/p2p_transport_channel_ice_field_trials.h index a176fad401..3497f9e629 100644 --- a/p2p/base/p2p_transport_channel_ice_field_trials.h +++ b/p2p/base/p2p_transport_channel_ice_field_trials.h @@ -78,12 +78,5 @@ struct IceFieldTrials { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IceFieldTrials; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_P2P_TRANSPORT_CHANNEL_ICE_FIELD_TRIALS_H_ diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 5a207730db..87e2fdebe2 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -96,6 +96,7 @@ #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/wait_until.h" @@ -128,14 +129,14 @@ using ::webrtc::SocketAddress; // Default timeout for tests in this file. // Should be large enough for slow buildbots to run the tests reliably. -const int kDefaultTimeout = 10000; -const int kMediumTimeout = 3000; -const int kShortTimeout = 1000; - -const int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP; -const int LOW_RTT = 20; +constexpr int kDefaultTimeout = 10000; +constexpr int kMediumTimeout = 3000; +constexpr int kShortTimeout = 1000; + +constexpr int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN | + webrtc::PORTALLOCATOR_DISABLE_RELAY | + webrtc::PORTALLOCATOR_DISABLE_TCP; +constexpr int LOW_RTT = 20; // Addresses on the public internet. const SocketAddress kPublicAddrs[2] = {SocketAddress("11.11.11.11", 0), SocketAddress("22.22.22.22", 0)}; @@ -282,32 +283,6 @@ class ResolverFactoryFixture : public webrtc::MockAsyncDnsResolverFactory { absl::AnyInvocable saved_callback_; }; -class PermissionFactoryFixture - : public webrtc::MockLocalNetworkAccessPermissionFactory { - public: - explicit PermissionFactoryFixture( - webrtc::LocalNetworkAccessPermissionStatus result) { - EXPECT_CALL(*this, Create()).WillRepeatedly([result]() { - auto mock_lna_permission = - std::make_unique(); - - EXPECT_CALL(*mock_lna_permission, RequestPermission(_, _)) - .WillRepeatedly( - [result]( - const SocketAddress& /* addr */, - absl::AnyInvocable callback) { - webrtc::Thread::Current()->PostTask( - [callback = std::move(callback), result]() mutable { - callback(result); - }); - }); - - return mock_lna_permission; - }); - } -}; - bool HasLocalAddress(const webrtc::CandidatePairInterface* pair, const SocketAddress& address) { return pair->local_candidate().address().EqualIPs(address); @@ -1304,7 +1279,7 @@ const P2PTransportChannelMatrixTest::Result* #define P2P_TEST_DECLARATION(x, y, z) \ TEST_P(P2PTransportChannelMatrixTest, z##Test##x##To##y) { \ const Environment env = \ - CreateEnvironment(FieldTrials::CreateNoGlobal(GetParam())); \ + CreateEnvironment(CreateTestFieldTrialsPtr(GetParam())); \ ConfigureEndpoints(env, x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ PORTALLOCATOR_ENABLE_SHARED_SOCKET); \ if (kMatrix[x][y] != NULL) \ @@ -2568,7 +2543,7 @@ TEST_F(P2PTransportChannelTest, TEST_F(P2PTransportChannelTest, CanConnectWithPiggybackCheckAcknowledgementWhenCheckResponseBlocked) { ScopedFakeClock clock; - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-PiggybackIceCheckAcknowledgement/Enabled/")); ConfigureEndpoints(env, OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts); IceConfig ep1_config; @@ -3881,7 +3856,7 @@ class P2PTransportChannelPingTest : public ::testing::Test, this, &P2PTransportChannelPingTest::OnNetworkRouteChanged); ch->SignalReadyToSend.connect(this, &P2PTransportChannelPingTest::OnReadyToSend); - ch->SignalStateChanged.connect( + ch->SignalIceTransportStateChanged.connect( this, &P2PTransportChannelPingTest::OnChannelStateChanged); ch->SetCandidatePairChangeCallback( [this](const CandidatePairChangeEvent& event) { @@ -4617,7 +4592,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { // that sends a ping directly when a connection has been nominated // i.e on the ICE_CONTROLLED-side. TEST_F(P2PTransportChannelPingTest, TestPingOnNomination) { - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/send_ping_on_nomination_ice_controlled:true/")); FakePortAllocator pa(env, ss()); P2PTransportChannel ch("receiving state change", 1, &pa, &env.field_trials()); @@ -4663,7 +4638,7 @@ TEST_F(P2PTransportChannelPingTest, TestPingOnNomination) { // that sends a ping directly when switching to a new connection // on the ICE_CONTROLLING-side. TEST_F(P2PTransportChannelPingTest, TestPingOnSwitch) { - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/send_ping_on_switch_ice_controlling:true/")); FakePortAllocator pa(env, ss()); P2PTransportChannel ch("receiving state change", 1, &pa, &env.field_trials()); @@ -4706,7 +4681,7 @@ TEST_F(P2PTransportChannelPingTest, TestPingOnSwitch) { // that sends a ping directly when selecteing a new connection // on the ICE_CONTROLLING-side (i.e also initial selection). TEST_F(P2PTransportChannelPingTest, TestPingOnSelected) { - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/send_ping_on_selected_ice_controlling:true/")); FakePortAllocator pa(env, ss()); P2PTransportChannel ch("receiving state change", 1, &pa, &env.field_trials()); @@ -5570,7 +5545,7 @@ TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { } TEST_F(P2PTransportChannelPingTest, TestMaxOutstandingPingsFieldTrial) { - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/max_outstanding_pings:3/")); FakePortAllocator pa(env, ss()); P2PTransportChannel ch("max", 1, &pa, &env.field_trials()); @@ -5831,7 +5806,7 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, // I.e that we never create connection between relay and non-relay. TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, TestSkipRelayToNonRelayConnectionsFieldTrial) { - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/")); CreatePortAllocator(env); P2PTransportChannel& ch = StartTransportChannel(env, true, 500); @@ -6818,7 +6793,7 @@ TEST_F(P2PTransportChannelTest, // coordination outside of webrtc to function properly. TEST_F(P2PTransportChannelTest, SurfaceRequiresCoordination) { ScopedFakeClock clock; - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/")); ConfigureEndpoints( @@ -6898,7 +6873,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening0) { constexpr int kMargin = 10; ScopedFakeClock clock; clock.AdvanceTime(TimeDelta::Seconds(1)); - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/initial_select_dampening:0/")); FakePortAllocator pa(env, ss()); @@ -6925,7 +6900,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening) { constexpr int kMargin = 10; ScopedFakeClock clock; clock.AdvanceTime(TimeDelta::Seconds(1)); - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/initial_select_dampening:100/")); FakePortAllocator pa(env, ss()); @@ -6952,7 +6927,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningPingReceived) { constexpr int kMargin = 10; ScopedFakeClock clock; clock.AdvanceTime(TimeDelta::Seconds(1)); - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/initial_select_dampening_ping_received:100/")); FakePortAllocator pa(env, ss()); @@ -6980,7 +6955,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningBoth) { constexpr int kMargin = 10; ScopedFakeClock clock; clock.AdvanceTime(TimeDelta::Seconds(1)); - const Environment env = CreateEnvironment(FieldTrials::CreateNoGlobal( + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( "WebRTC-IceFieldTrials/" "initial_select_dampening:100,initial_select_dampening_ping_received:" "50/")); @@ -7262,7 +7237,7 @@ class LocalAreaNetworkPermissionTest TEST_P(LocalAreaNetworkPermissionTest, LiteralAddresses) { const Environment env = CreateEnvironment(); FakePortAllocator pa(env, ss()); - PermissionFactoryFixture lna_permission_factory( + webrtc::FakeLocalNetworkAccessPermissionFactory lna_permission_factory( GetParam().lna_permission_status); IceTransportInit init; @@ -7291,7 +7266,7 @@ TEST_P(LocalAreaNetworkPermissionTest, LiteralAddresses) { TEST_P(LocalAreaNetworkPermissionTest, UnresolvedAddresses) { const Environment env = CreateEnvironment(); FakePortAllocator pa(env, ss()); - PermissionFactoryFixture lna_permission_factory( + webrtc::FakeLocalNetworkAccessPermissionFactory lna_permission_factory( GetParam().lna_permission_status); ResolverFactoryFixture resolver_fixture; @@ -7339,7 +7314,7 @@ TEST_P(GatherAfterConnectedTest, GatherAfterConnected) { ScopedFakeClock clock; const Environment env = - CreateEnvironment(FieldTrials::CreateNoGlobal(field_trial)); + CreateEnvironment(CreateTestFieldTrialsPtr(field_trial)); // Use local + relay constexpr uint32_t flags = kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET | @@ -7419,7 +7394,7 @@ TEST_P(GatherAfterConnectedTest, GatherAfterConnectedMultiHomed) { ScopedFakeClock clock; const Environment env = - CreateEnvironment(FieldTrials::CreateNoGlobal(field_trial)); + CreateEnvironment(CreateTestFieldTrialsPtr(field_trial)); // Use local + relay constexpr uint32_t flags = @@ -7569,13 +7544,14 @@ class P2PTransportChannelTestDtlsInStun : public P2PTransportChannelTestBase { DestroyChannels(); } - std::pair, std::optional> + std::pair, + std::optional>> data_to_piggyback_func(StunMessageType type) { return make_pair(absl::string_view(pending_packet_), std::nullopt); } - void piggyback_data_received(const StunByteStringAttribute* data, - const StunByteStringAttribute* ack) {} + void piggyback_data_received(std::optional> data, + std::optional> ack) {} ScopedFakeClock clock_; Buffer pending_packet_; diff --git a/p2p/base/packet_transport_internal.h b/p2p/base/packet_transport_internal.h index 2418cf4b3c..32d7f7e6b6 100644 --- a/p2p/base/packet_transport_internal.h +++ b/p2p/base/packet_transport_internal.h @@ -20,6 +20,7 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/callback_list.h" #include "rtc_base/network/received_packet.h" +#include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" #include "rtc_base/socket.h" #include "rtc_base/system/rtc_export.h" @@ -115,12 +116,5 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> { } // 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::PacketTransportInternal; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_PACKET_TRANSPORT_INTERNAL_H_ diff --git a/p2p/base/packet_transport_internal_unittest.cc b/p2p/base/packet_transport_internal_unittest.cc index 0ffb26b8bb..533e6a0c62 100644 --- a/p2p/base/packet_transport_internal_unittest.cc +++ b/p2p/base/packet_transport_internal_unittest.cc @@ -12,8 +12,8 @@ #include +#include "api/transport/ecn_marking.h" #include "p2p/test/fake_packet_transport.h" -#include "rtc_base/network/ecn_marking.h" #include "rtc_base/network/received_packet.h" #include "rtc_base/socket_address.h" #include "test/gmock.h" diff --git a/p2p/base/port.cc b/p2p/base/port.cc index f488e61106..d91143db2f 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -19,12 +19,14 @@ #include #include +#include "absl/algorithm/container.h" +#include "absl/functional/any_invocable.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/candidate.h" -#include "api/rtc_error.h" +#include "api/local_network_access_permission.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" #include "api/transport/stun.h" @@ -114,6 +116,7 @@ Port::Port(const PortParametersRef& args, : env_(args.env), thread_(args.network_thread), factory_(args.socket_factory), + lna_permission_factory_(args.lna_permission_factory), type_(type), send_retransmit_count_attribute_(false), network_(args.network), @@ -939,4 +942,50 @@ void Port::CopyPortInformationToPacketInfo(PacketInfo* info) const { info->network_id = Network()->id(); } +void Port::MaybeRequestLocalNetworkAccessPermission( + const SocketAddress& address, + absl::AnyInvocable callback) { + if (!lna_permission_factory_) { + std::move(callback)(LocalNetworkAccessPermissionStatus::kGranted); + return; + } + + if (!address.IsPrivateIP() && !address.IsLoopbackIP()) { + std::move(callback)(LocalNetworkAccessPermissionStatus::kGranted); + return; + } + + RTC_LOG(LS_VERBOSE) << "Asynchronously requesting LNA permission." + << address.HostAsSensitiveURIString(); + + std::unique_ptr permission_query = + lna_permission_factory_->Create(); + auto* permission_query_ptr = permission_query.get(); + permission_queries_.push_back(std::move(permission_query)); + + permission_query_ptr->RequestPermission( + address, [this, permission_query_ptr, callback = std::move(callback)]( + LocalNetworkAccessPermissionStatus status) mutable { + OnRequestLocalNetworkAccessPermission(permission_query_ptr, + std::move(callback), status); + }); +} + +void Port::OnRequestLocalNetworkAccessPermission( + LocalNetworkAccessPermissionInterface* permission_query, + absl::AnyInvocable callback, + LocalNetworkAccessPermissionStatus status) { + auto it = + absl::c_find_if(permission_queries_, [permission_query](const auto& q) { + return q.get() == permission_query; + }); + if (it == permission_queries_.end()) { + RTC_LOG(LS_ERROR) << "Unexpected LocalNetworkAccessPermission return"; + RTC_DCHECK_NOTREACHED(); + } + + permission_queries_.erase(it); + std::move(callback)(status); +} + } // namespace webrtc diff --git a/p2p/base/port.h b/p2p/base/port.h index b7dbe49a3d..bae110f0c2 100644 --- a/p2p/base/port.h +++ b/p2p/base/port.h @@ -11,9 +11,8 @@ #ifndef P2P_BASE_PORT_H_ #define P2P_BASE_PORT_H_ -#include -#include - +#include +#include #include #include #include @@ -23,10 +22,12 @@ #include #include +#include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/candidate.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" @@ -168,6 +169,8 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { const ::webrtc::Network* network; absl::string_view ice_username_fragment; absl::string_view ice_password; + LocalNetworkAccessPermissionFactoryInterface* lna_permission_factory = + nullptr; }; protected: @@ -432,6 +435,15 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { IceCandidateType type() const { return type_; } + // Requests the Local Network Access Permission if necessary. Asynchronously + // calls `callback` with the result of requesting the permission. If the + // permission is not needed e.g. because `address` is public, it calls + // `callback` synchronously. It's guaranteed that the callback won't be called + // after this class is destroyed. + void MaybeRequestLocalNetworkAccessPermission( + const SocketAddress& address, + absl::AnyInvocable callback); + private: bool MaybeObfuscateAddress(const Candidate& c, bool is_final) RTC_RUN_ON(thread_); @@ -454,9 +466,15 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { void OnNetworkTypeChanged(const ::webrtc::Network* network); + void OnRequestLocalNetworkAccessPermission( + LocalNetworkAccessPermissionInterface* permission_query, + absl::AnyInvocable callback, + LocalNetworkAccessPermissionStatus status); + const Environment env_; TaskQueueBase* const thread_; PacketSocketFactory* const factory_; + LocalNetworkAccessPermissionFactoryInterface* const lna_permission_factory_; const IceCandidateType type_; bool send_retransmit_count_attribute_; const ::webrtc::Network* network_; @@ -494,6 +512,9 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { MdnsNameRegistrationStatus mdns_name_registration_status_ = MdnsNameRegistrationStatus::kNotStarted; + std::vector> + permission_queries_; + CallbackList port_destroyed_callback_list_; // Keep as the last member variable. @@ -502,26 +523,5 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CandidatePairChangeEvent; -using ::webrtc::CandidateStats; -using ::webrtc::CandidateStatsList; -using ::webrtc::DISCARD_PORT; -using ::webrtc::IceCandidateErrorEvent; -using ::webrtc::MdnsNameRegistrationStatus; -using ::webrtc::Port; -using ::webrtc::ProtocolAddress; -using ::webrtc::ProtoToString; -using ::webrtc::ServerAddresses; -using ::webrtc::StringToProto; -using ::webrtc::StunStats; -using ::webrtc::TCPTYPE_ACTIVE_STR; -using ::webrtc::TCPTYPE_PASSIVE_STR; -using ::webrtc::TCPTYPE_SIMOPEN_STR; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_PORT_H_ diff --git a/p2p/base/port_allocator.cc b/p2p/base/port_allocator.cc index 0e7c1ad1df..ba95687415 100644 --- a/p2p/base/port_allocator.cc +++ b/p2p/base/port_allocator.cc @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/p2p/base/port_allocator.h b/p2p/base/port_allocator.h index 997ddfb852..87490f2652 100644 --- a/p2p/base/port_allocator.h +++ b/p2p/base/port_allocator.h @@ -11,8 +11,7 @@ #ifndef P2P_BASE_PORT_ALLOCATOR_H_ #define P2P_BASE_PORT_ALLOCATOR_H_ -#include - +#include #include #include #include @@ -643,41 +642,5 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CF_ALL; -using ::webrtc::CF_HOST; -using ::webrtc::CF_NONE; -using ::webrtc::CF_REFLEXIVE; -using ::webrtc::CF_RELAY; -using ::webrtc::IceRegatheringReason; -using ::webrtc::kDefaultMaxIPv6Networks; -using ::webrtc::kDefaultPortAllocatorFlags; -using ::webrtc::kDefaultStepDelay; -using ::webrtc::kMinimumStepDelay; -using ::webrtc::PortAllocator; -using ::webrtc::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; -using ::webrtc::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS; -using ::webrtc::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE; -using ::webrtc::PORTALLOCATOR_DISABLE_LINK_LOCAL_NETWORKS; -using ::webrtc::PORTALLOCATOR_DISABLE_RELAY; -using ::webrtc::PORTALLOCATOR_DISABLE_STUN; -using ::webrtc::PORTALLOCATOR_DISABLE_TCP; -using ::webrtc::PORTALLOCATOR_DISABLE_UDP; -using ::webrtc::PORTALLOCATOR_DISABLE_UDP_RELAY; -using ::webrtc::PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS; -using ::webrtc::PORTALLOCATOR_ENABLE_IPV6; -using ::webrtc::PORTALLOCATOR_ENABLE_IPV6_ON_WIFI; -using ::webrtc::PORTALLOCATOR_ENABLE_SHARED_SOCKET; -using ::webrtc::PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE; -using ::webrtc::PortAllocatorSession; -using ::webrtc::PortList; -using ::webrtc::RelayCredentials; -using ::webrtc::RelayServerConfig; -using ::webrtc::TlsCertPolicy; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_PORT_ALLOCATOR_H_ diff --git a/p2p/base/port_allocator_unittest.cc b/p2p/base/port_allocator_unittest.cc index ec53ea30b4..8bc61dadd8 100644 --- a/p2p/base/port_allocator_unittest.cc +++ b/p2p/base/port_allocator_unittest.cc @@ -30,13 +30,19 @@ using ::webrtc::CreateEnvironment; using ::webrtc::IceCandidateType; -static const char kContentName[] = "test content"; +namespace { +constexpr char kContentName[] = "test content"; // Based on ICE_UFRAG_LENGTH -static const char kIceUfrag[] = "UF00"; +constexpr char kIceUfrag[] = "UF00"; // Based on ICE_PWD_LENGTH -static const char kIcePwd[] = "TESTICEPWD00000000000000"; -static const char kTurnUsername[] = "test"; -static const char kTurnPassword[] = "test"; +constexpr char kIcePwd[] = "TESTICEPWD00000000000000"; +constexpr char kTurnUsername[] = "test"; +constexpr char kTurnPassword[] = "test"; + +// Constants for testing candidates +constexpr char kIpv4Address[] = "12.34.56.78"; +constexpr char kIpv4AddressWithPort[] = "12.34.56.78:443"; +} // namespace class PortAllocatorTest : public ::testing::Test, public sigslot::has_slots<> { public: @@ -288,10 +294,6 @@ TEST_F(PortAllocatorTest, RestrictIceCredentialsChange) { allocator_->DiscardCandidatePool(); } -// Constants for testing candidates -const char kIpv4Address[] = "12.34.56.78"; -const char kIpv4AddressWithPort[] = "12.34.56.78:443"; - TEST_F(PortAllocatorTest, SanitizeEmptyCandidateDefaultConfig) { webrtc::Candidate input; webrtc::Candidate output = allocator_->SanitizeCandidate(input); diff --git a/p2p/base/port_interface.h b/p2p/base/port_interface.h index 3d0b014522..2335fc2434 100644 --- a/p2p/base/port_interface.h +++ b/p2p/base/port_interface.h @@ -205,18 +205,5 @@ class PortInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::PortInterface; -using ::webrtc::PROTO_LAST; -using ::webrtc::PROTO_SSLTCP; -using ::webrtc::PROTO_TCP; -using ::webrtc::PROTO_TLS; -using ::webrtc::PROTO_UDP; -using ::webrtc::ProtocolType; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_PORT_INTERFACE_H_ diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 68b0aea338..759594b5ee 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -10,10 +10,10 @@ #include "p2p/base/port.h" -#include - #include +#include #include +#include #include #include #include @@ -29,6 +29,7 @@ #include "api/candidate.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/packet_socket_factory.h" #include "api/rtc_error.h" #include "api/test/rtc_error_matchers.h" @@ -71,9 +72,9 @@ #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" #include "test/wait_until.h" using ::testing::Eq; @@ -123,7 +124,7 @@ constexpr int kTiebreaker1 = 11111; constexpr int kTiebreaker2 = 22222; constexpr int kTiebreakerDefault = 44444; -const char* kTestData = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; +constexpr char kTestData[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; Candidate GetCandidate(Port* port) { RTC_DCHECK_GE(port->Candidates().size(), 1); @@ -2808,7 +2809,7 @@ TEST_F(PortTest, TestComputeCandidatePriority) { } TEST_F(PortTest, TestComputeCandidatePriorityWithPriorityAdjustment) { - test::ScopedKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-IncreaseIceCandidatePriorityHostSrflx/Enabled/"); auto port = CreateTestPort(kLocalAddr1, "name", "pass", &field_trials); port->SetIceTiebreaker(kTiebreakerDefault); @@ -3025,7 +3026,7 @@ TEST_F(PortTest, TestConnectionPriority) { // Test the Connection priority is calculated correctly. TEST_F(PortTest, TestConnectionPriorityWithPriorityAdjustment) { - test::ScopedKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-IncreaseIceCandidatePriorityHostSrflx/Enabled/"); auto lport = CreateTestPort(kLocalAddr1, "lfrag", "lpass", &field_trials); lport->SetIceTiebreaker(kTiebreakerDefault); diff --git a/p2p/base/pseudo_tcp.cc b/p2p/base/pseudo_tcp.cc deleted file mode 100644 index a3e336e199..0000000000 --- a/p2p/base/pseudo_tcp.cc +++ /dev/null @@ -1,1435 +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. - */ - -#include "p2p/base/pseudo_tcp.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include "api/array_view.h" -#include "rtc_base/byte_buffer.h" -#include "rtc_base/byte_order.h" -#include "rtc_base/checks.h" -#include "rtc_base/logging.h" -#include "rtc_base/numerics/safe_minmax.h" -#include "rtc_base/socket.h" -#include "rtc_base/synchronization/mutex.h" -#include "rtc_base/time_utils.h" - -// The following logging is for detailed (packet-level) analysis only. -#define _DBG_NONE 0 -#define _DBG_NORMAL 1 -#define _DBG_VERBOSE 2 -#define _DEBUGMSG _DBG_NONE - -namespace webrtc { - -////////////////////////////////////////////////////////////////////// -// Network Constants -////////////////////////////////////////////////////////////////////// - -// Standard MTUs -const uint16_t PACKET_MAXIMUMS[] = { - 65535, // Theoretical maximum, Hyperchannel - 32000, // Nothing - 17914, // 16Mb IBM Token Ring - 8166, // IEEE 802.4 - // 4464, // IEEE 802.5 (4Mb max) - 4352, // FDDI - // 2048, // Wideband Network - 2002, // IEEE 802.5 (4Mb recommended) - // 1536, // Expermental Ethernet Networks - // 1500, // Ethernet, Point-to-Point (default) - 1492, // IEEE 802.3 - 1006, // SLIP, ARPANET - // 576, // X.25 Networks - // 544, // DEC IP Portal - // 512, // NETBIOS - 508, // IEEE 802/Source-Rt Bridge, ARCNET - 296, // Point-to-Point (low delay) - // 68, // Official minimum - 0, // End of list marker -}; - -const uint32_t MAX_PACKET = 65535; -// Note: we removed lowest level because packet overhead was larger! -const uint32_t MIN_PACKET = 296; - -const uint32_t IP_HEADER_SIZE = 20; // (+ up to 40 bytes of options?) -const uint32_t UDP_HEADER_SIZE = 8; -// TODO(?): Make JINGLE_HEADER_SIZE transparent to this code? -const uint32_t JINGLE_HEADER_SIZE = 64; // when relay framing is in use - -// Default size for receive and send buffer. -const uint32_t DEFAULT_RCV_BUF_SIZE = 60 * 1024; -const uint32_t DEFAULT_SND_BUF_SIZE = 90 * 1024; - -////////////////////////////////////////////////////////////////////// -// Global Constants and Functions -////////////////////////////////////////////////////////////////////// -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// 0 | Conversation Number | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// 4 | Sequence Number | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// 8 | Acknowledgment Number | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | |U|A|P|R|S|F| | -// 12 | Control | |R|C|S|S|Y|I| Window | -// | | |G|K|H|T|N|N| | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// 16 | Timestamp sending | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// 20 | Timestamp receiving | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// 24 | data | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -////////////////////////////////////////////////////////////////////// - -#define PSEUDO_KEEPALIVE 0 - -const uint32_t HEADER_SIZE = 24; -const uint32_t PACKET_OVERHEAD = - HEADER_SIZE + UDP_HEADER_SIZE + IP_HEADER_SIZE + JINGLE_HEADER_SIZE; - -const uint32_t MIN_RTO = - 250; // 250 ms (RFC1122, Sec 4.2.3.1 "fractions of a second") -const uint32_t DEF_RTO = 3000; // 3 seconds (RFC1122, Sec 4.2.3.1) -const uint32_t MAX_RTO = 60000; // 60 seconds -const uint32_t DEF_ACK_DELAY = 100; // 100 milliseconds - -const uint8_t FLAG_CTL = 0x02; -const uint8_t FLAG_RST = 0x04; - -const uint8_t CTL_CONNECT = 0; - -// TCP options. -const uint8_t TCP_OPT_EOL = 0; // End of list. -const uint8_t TCP_OPT_NOOP = 1; // No-op. -const uint8_t TCP_OPT_MSS = 2; // Maximum segment size. -const uint8_t TCP_OPT_WND_SCALE = 3; // Window scale factor. - -const long DEFAULT_TIMEOUT = - 4000; // If there are no pending clocks, wake up every 4 seconds -const long CLOSED_TIMEOUT = - 60 * 1000; // If the connection is closed, once per minute - -#if PSEUDO_KEEPALIVE -// !?! Rethink these times -const uint32_t IDLE_PING = - 20 * - 1000; // 20 seconds (note: WinXP SP2 firewall udp timeout is 90 seconds) -const uint32_t IDLE_TIMEOUT = 90 * 1000; // 90 seconds; -#endif // PSEUDO_KEEPALIVE - -////////////////////////////////////////////////////////////////////// -// Helper Functions -////////////////////////////////////////////////////////////////////// - -inline void long_to_bytes(uint32_t val, void* buf) { - *static_cast(buf) = HostToNetwork32(val); -} - -inline void short_to_bytes(uint16_t val, void* buf) { - *static_cast(buf) = HostToNetwork16(val); -} - -inline uint32_t bytes_to_long(const void* buf) { - return NetworkToHost32(*static_cast(buf)); -} - -inline uint16_t bytes_to_short(const void* buf) { - return NetworkToHost16(*static_cast(buf)); -} - -////////////////////////////////////////////////////////////////////// -// Debugging Statistics -////////////////////////////////////////////////////////////////////// - -#if 0 // Not used yet - -enum Stat { - S_SENT_PACKET, // All packet sends - S_RESENT_PACKET, // All packet sends that are retransmits - S_RECV_PACKET, // All packet receives - S_RECV_NEW, // All packet receives that are too new - S_RECV_OLD, // All packet receives that are too old - S_NUM_STATS -}; - -const char* const STAT_NAMES[S_NUM_STATS] = { - "snt", - "snt-r", - "rcv" - "rcv-n", - "rcv-o" -}; - -int g_stats[S_NUM_STATS]; -inline void Incr(Stat s) { ++g_stats[s]; } -void ReportStats() { - char buffer[256]; - size_t len = 0; - for (int i = 0; i < S_NUM_STATS; ++i) { - len += snprintf(buffer, std::size(buffer), "%s%s:%d", - (i == 0) ? "" : ",", STAT_NAMES[i], g_stats[i]); - g_stats[i] = 0; - } - RTC_LOG(LS_INFO) << "Stats[" << buffer << "]"; -} - -#endif - -////////////////////////////////////////////////////////////////////// -// PseudoTcp -////////////////////////////////////////////////////////////////////// - -uint32_t PseudoTcp::Now() { -#if 0 // Use this to synchronize timers with logging timestamps (easier debug) - return static_cast(TimeSince(StartTime())); -#else - return Time32(); -#endif -} - -PseudoTcp::PseudoTcp(IPseudoTcpNotify* notify, uint32_t conv) - : m_notify(notify), - m_shutdown(SD_NONE), - m_error(0), - m_rbuf_len(DEFAULT_RCV_BUF_SIZE), - m_rbuf(m_rbuf_len), - m_sbuf_len(DEFAULT_SND_BUF_SIZE), - m_sbuf(m_sbuf_len) { - // Sanity check on buffer sizes (needed for OnTcpWriteable notification logic) - RTC_DCHECK(m_rbuf_len + MIN_PACKET < m_sbuf_len); - - uint32_t now = Now(); - - m_state = TCP_LISTEN; - m_conv = conv; - m_rcv_wnd = m_rbuf_len; - m_rwnd_scale = m_swnd_scale = 0; - m_snd_nxt = 0; - m_snd_wnd = 1; - m_snd_una = m_rcv_nxt = 0; - m_bReadEnable = true; - m_bWriteEnable = false; - m_t_ack = 0; - - m_msslevel = 0; - m_largest = 0; - RTC_DCHECK(MIN_PACKET > PACKET_OVERHEAD); - m_mss = MIN_PACKET - PACKET_OVERHEAD; - m_mtu_advise = MAX_PACKET; - - m_rto_base = 0; - - m_cwnd = 2 * m_mss; - m_ssthresh = m_rbuf_len; - m_lastrecv = m_lastsend = m_lasttraffic = now; - m_bOutgoing = false; - - m_dup_acks = 0; - m_recover = 0; - - m_ts_recent = m_ts_lastack = 0; - - m_rx_rto = DEF_RTO; - m_rx_srtt = m_rx_rttvar = 0; - - m_use_nagling = true; - m_ack_delay = DEF_ACK_DELAY; - m_support_wnd_scale = true; -} - -PseudoTcp::~PseudoTcp() {} - -int PseudoTcp::Connect() { - if (m_state != TCP_LISTEN) { - m_error = EINVAL; - return -1; - } - - m_state = TCP_SYN_SENT; - RTC_LOG(LS_INFO) << "State: TCP_SYN_SENT"; - - queueConnectMessage(); - attemptSend(); - - return 0; -} - -void PseudoTcp::NotifyMTU(uint16_t mtu) { - m_mtu_advise = mtu; - if (m_state == TCP_ESTABLISHED) { - adjustMTU(); - } -} - -void PseudoTcp::NotifyClock(uint32_t now) { - if (m_state == TCP_CLOSED) - return; - - // Check if it's time to retransmit a segment - if (m_rto_base && (TimeDiff32(m_rto_base + m_rx_rto, now) <= 0)) { - if (m_slist.empty()) { - RTC_DCHECK_NOTREACHED(); - } else { -// Note: (m_slist.front().xmit == 0)) { -// retransmit segments -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "timeout retransmit (rto: " << m_rx_rto - << ") (rto_base: " << m_rto_base << ") (now: " << now - << ") (dup_acks: " << static_cast(m_dup_acks) - << ")"; -#endif // _DEBUGMSG - if (!transmit(m_slist.begin(), now)) { - closedown(ECONNABORTED); - return; - } - - uint32_t nInFlight = m_snd_nxt - m_snd_una; - m_ssthresh = std::max(nInFlight / 2, 2 * m_mss); - // RTC_LOG(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << - // nInFlight << " m_mss: " << m_mss; - m_cwnd = m_mss; - - // Back off retransmit timer. Note: the limit is lower when connecting. - uint32_t rto_limit = (m_state < TCP_ESTABLISHED) ? DEF_RTO : MAX_RTO; - m_rx_rto = std::min(rto_limit, m_rx_rto * 2); - m_rto_base = now; - } - } - - // Check if it's time to probe closed windows - if ((m_snd_wnd == 0) && (TimeDiff32(m_lastsend + m_rx_rto, now) <= 0)) { - if (TimeDiff32(now, m_lastrecv) >= 15000) { - closedown(ECONNABORTED); - return; - } - - // probe the window - packet(m_snd_nxt - 1, 0, 0, 0); - m_lastsend = now; - - // back off retransmit timer - m_rx_rto = std::min(MAX_RTO, m_rx_rto * 2); - } - - // Check if it's time to send delayed acks - if (m_t_ack && (TimeDiff32(m_t_ack + m_ack_delay, now) <= 0)) { - packet(m_snd_nxt, 0, 0, 0); - } - -#if PSEUDO_KEEPALIVE - // Check for idle timeout - if ((m_state == TCP_ESTABLISHED) && - (TimeDiff32(m_lastrecv + IDLE_TIMEOUT, now) <= 0)) { - closedown(ECONNABORTED); - return; - } - - // Check for ping timeout (to keep udp mapping open) - if ((m_state == TCP_ESTABLISHED) && - (TimeDiff32(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3 / 2 : IDLE_PING), - now) <= 0)) { - packet(m_snd_nxt, 0, 0, 0); - } -#endif // PSEUDO_KEEPALIVE -} - -bool PseudoTcp::NotifyPacket(const char* buffer, size_t len) { - if (len > MAX_PACKET) { - RTC_LOG_F(LS_WARNING) << "packet too large"; - return false; - } - return parse(reinterpret_cast(buffer), uint32_t(len)); -} - -bool PseudoTcp::GetNextClock(uint32_t now, long& timeout) { - return clock_check(now, timeout); -} - -void PseudoTcp::GetOption(Option opt, int* value) { - if (opt == OPT_NODELAY) { - *value = m_use_nagling ? 0 : 1; - } else if (opt == OPT_ACKDELAY) { - *value = m_ack_delay; - } else if (opt == OPT_SNDBUF) { - *value = m_sbuf_len; - } else if (opt == OPT_RCVBUF) { - *value = m_rbuf_len; - } else { - RTC_DCHECK_NOTREACHED(); - } -} -void PseudoTcp::SetOption(Option opt, int value) { - if (opt == OPT_NODELAY) { - m_use_nagling = value == 0; - } else if (opt == OPT_ACKDELAY) { - m_ack_delay = value; - } else if (opt == OPT_SNDBUF) { - RTC_DCHECK(m_state == TCP_LISTEN); - resizeSendBuffer(value); - } else if (opt == OPT_RCVBUF) { - RTC_DCHECK(m_state == TCP_LISTEN); - resizeReceiveBuffer(value); - } else { - RTC_DCHECK_NOTREACHED(); - } -} - -uint32_t PseudoTcp::GetCongestionWindow() const { - return m_cwnd; -} - -uint32_t PseudoTcp::GetBytesInFlight() const { - return m_snd_nxt - m_snd_una; -} - -uint32_t PseudoTcp::GetBytesBufferedNotSent() const { - return static_cast(m_snd_una + m_sbuf.GetBuffered() - m_snd_nxt); -} - -uint32_t PseudoTcp::GetRoundTripTimeEstimateMs() const { - return m_rx_srtt; -} - -// -// IPStream Implementation -// - -int PseudoTcp::Recv(char* buffer, size_t len) { - if (m_state != TCP_ESTABLISHED) { - m_error = ENOTCONN; - return SOCKET_ERROR; - } - - size_t read = 0; - if (!m_rbuf.Read(buffer, len, &read)) { - m_bReadEnable = true; - m_error = EWOULDBLOCK; - return SOCKET_ERROR; - } - - size_t available_space = 0; - m_rbuf.GetWriteRemaining(&available_space); - - if (uint32_t(available_space) - m_rcv_wnd >= - std::min(m_rbuf_len / 2, m_mss)) { - // TODO(jbeda): !?! Not sure about this was closed business - bool bWasClosed = (m_rcv_wnd == 0); - m_rcv_wnd = static_cast(available_space); - - if (bWasClosed) { - attemptSend(sfImmediateAck); - } - } - - return static_cast(read); -} - -int PseudoTcp::Send(const char* buffer, size_t len) { - if (m_state != TCP_ESTABLISHED) { - m_error = ENOTCONN; - return SOCKET_ERROR; - } - - size_t available_space = 0; - m_sbuf.GetWriteRemaining(&available_space); - - if (!available_space) { - m_bWriteEnable = true; - m_error = EWOULDBLOCK; - return SOCKET_ERROR; - } - - int written = queue(buffer, uint32_t(len), false); - attemptSend(); - return written; -} - -void PseudoTcp::Close(bool force) { - RTC_LOG_F(LS_VERBOSE) << "(" << (force ? "true" : "false") << ")"; - m_shutdown = force ? SD_FORCEFUL : SD_GRACEFUL; -} - -int PseudoTcp::GetError() { - return m_error; -} - -// -// Internal Implementation -// - -uint32_t PseudoTcp::queue(const char* data, uint32_t len, bool bCtrl) { - size_t available_space = 0; - m_sbuf.GetWriteRemaining(&available_space); - - if (len > static_cast(available_space)) { - RTC_DCHECK(!bCtrl); - len = static_cast(available_space); - } - - // We can concatenate data if the last segment is the same type - // (control v. regular data), and has not been transmitted yet - if (!m_slist.empty() && (m_slist.back().bCtrl == bCtrl) && - (m_slist.back().xmit == 0)) { - m_slist.back().len += len; - } else { - SSegment sseg(static_cast(m_snd_una + m_sbuf.GetBuffered()), len, - bCtrl); - m_slist.push_back(sseg); - } - - size_t written = 0; - m_sbuf.Write(data, len, &written); - return static_cast(written); -} - -IPseudoTcpNotify::WriteResult PseudoTcp::packet(uint32_t seq, - uint8_t flags, - uint32_t offset, - uint32_t len) { - RTC_DCHECK(HEADER_SIZE + len <= MAX_PACKET); - - uint32_t now = Now(); - - std::unique_ptr buffer(new uint8_t[MAX_PACKET]); - long_to_bytes(m_conv, buffer.get()); - long_to_bytes(seq, buffer.get() + 4); - long_to_bytes(m_rcv_nxt, buffer.get() + 8); - buffer[12] = 0; - buffer[13] = flags; - short_to_bytes(static_cast(m_rcv_wnd >> m_rwnd_scale), - buffer.get() + 14); - - // Timestamp computations - long_to_bytes(now, buffer.get() + 16); - long_to_bytes(m_ts_recent, buffer.get() + 20); - m_ts_lastack = m_rcv_nxt; - - if (len) { - size_t bytes_read = 0; - bool result = - m_sbuf.ReadOffset(buffer.get() + HEADER_SIZE, len, offset, &bytes_read); - RTC_DCHECK(result); - RTC_DCHECK(static_cast(bytes_read) == len); - } - -#if _DEBUGMSG >= _DBG_VERBOSE - RTC_LOG(LS_INFO) << "<-- (flags) - << ">"; -#endif // _DEBUGMSG - - IPseudoTcpNotify::WriteResult wres = m_notify->TcpWritePacket( - this, reinterpret_cast(buffer.get()), len + HEADER_SIZE); - // Note: When len is 0, this is an ACK packet. We don't read the return value - // for those, and thus we won't retry. So go ahead and treat the packet as a - // success (basically simulate as if it were dropped), which will prevent our - // timers from being messed up. - if ((wres != IPseudoTcpNotify::WR_SUCCESS) && (0 != len)) - return wres; - - m_t_ack = 0; - if (len > 0) { - m_lastsend = now; - } - m_lasttraffic = now; - m_bOutgoing = true; - - return IPseudoTcpNotify::WR_SUCCESS; -} - -bool PseudoTcp::parse(const uint8_t* buffer, uint32_t size) { - if (size < HEADER_SIZE) - return false; - - Segment seg; - seg.conv = bytes_to_long(buffer); - seg.seq = bytes_to_long(buffer + 4); - seg.ack = bytes_to_long(buffer + 8); - seg.flags = buffer[13]; - seg.wnd = bytes_to_short(buffer + 14); - - seg.tsval = bytes_to_long(buffer + 16); - seg.tsecr = bytes_to_long(buffer + 20); - - seg.data = reinterpret_cast(buffer) + HEADER_SIZE; - seg.len = size - HEADER_SIZE; - -#if _DEBUGMSG >= _DBG_VERBOSE - RTC_LOG(LS_INFO) << "--> (seg.flags) - << ">"; -#endif // _DEBUGMSG - - return process(seg); -} - -bool PseudoTcp::clock_check(uint32_t now, long& nTimeout) { - if (m_shutdown == SD_FORCEFUL) - return false; - - if ((m_shutdown == SD_GRACEFUL) && - ((m_state != TCP_ESTABLISHED) || - ((m_sbuf.GetBuffered() == 0) && (m_t_ack == 0)))) { - return false; - } - - if (m_state == TCP_CLOSED) { - nTimeout = CLOSED_TIMEOUT; - return true; - } - - nTimeout = DEFAULT_TIMEOUT; - - if (m_t_ack) { - nTimeout = - std::min(nTimeout, TimeDiff32(m_t_ack + m_ack_delay, now)); - } - if (m_rto_base) { - nTimeout = - std::min(nTimeout, TimeDiff32(m_rto_base + m_rx_rto, now)); - } - if (m_snd_wnd == 0) { - nTimeout = - std::min(nTimeout, TimeDiff32(m_lastsend + m_rx_rto, now)); - } -#if PSEUDO_KEEPALIVE - if (m_state == TCP_ESTABLISHED) { - nTimeout = std::min( - nTimeout, TimeDiff32(m_lasttraffic + - (m_bOutgoing ? IDLE_PING * 3 / 2 : IDLE_PING), - now)); - } -#endif // PSEUDO_KEEPALIVE - return true; -} - -bool PseudoTcp::process(Segment& seg) { - // If this is the wrong conversation, send a reset!?! (with the correct - // conversation?) - if (seg.conv != m_conv) { - // if ((seg.flags & FLAG_RST) == 0) { - // packet(tcb, seg.ack, 0, FLAG_RST, 0, 0); - //} - RTC_LOG_F(LS_ERROR) << "wrong conversation"; - return false; - } - - uint32_t now = Now(); - m_lasttraffic = m_lastrecv = now; - m_bOutgoing = false; - - if (m_state == TCP_CLOSED) { - // !?! send reset? - RTC_LOG_F(LS_ERROR) << "closed"; - return false; - } - - // Check if this is a reset segment - if (seg.flags & FLAG_RST) { - closedown(ECONNRESET); - return false; - } - - // Check for control data - bool bConnect = false; - if (seg.flags & FLAG_CTL) { - if (seg.len == 0) { - RTC_LOG_F(LS_ERROR) << "Missing control code"; - return false; - } else if (seg.data[0] == CTL_CONNECT) { - bConnect = true; - - // TCP options are in the remainder of the payload after CTL_CONNECT. - parseOptions(&seg.data[1], seg.len - 1); - - if (m_state == TCP_LISTEN) { - m_state = TCP_SYN_RECEIVED; - RTC_LOG(LS_INFO) << "State: TCP_SYN_RECEIVED"; - // m_notify->associate(addr); - queueConnectMessage(); - } else if (m_state == TCP_SYN_SENT) { - m_state = TCP_ESTABLISHED; - RTC_LOG(LS_INFO) << "State: TCP_ESTABLISHED"; - adjustMTU(); - if (m_notify) { - m_notify->OnTcpOpen(this); - } - // notify(evOpen); - } - } else { - RTC_LOG_F(LS_WARNING) << "Unknown control code: " << seg.data[0]; - return false; - } - } - - // Update timestamp - if ((seg.seq <= m_ts_lastack) && (m_ts_lastack < seg.seq + seg.len)) { - m_ts_recent = seg.tsval; - } - - // Check if this is a valuable ack - if ((seg.ack > m_snd_una) && (seg.ack <= m_snd_nxt)) { - // Calculate round-trip time - if (seg.tsecr) { - int32_t rtt = TimeDiff32(now, seg.tsecr); - if (rtt >= 0) { - if (m_rx_srtt == 0) { - m_rx_srtt = rtt; - m_rx_rttvar = rtt / 2; - } else { - uint32_t unsigned_rtt = static_cast(rtt); - uint32_t abs_err = unsigned_rtt > m_rx_srtt - ? unsigned_rtt - m_rx_srtt - : m_rx_srtt - unsigned_rtt; - m_rx_rttvar = (3 * m_rx_rttvar + abs_err) / 4; - m_rx_srtt = (7 * m_rx_srtt + rtt) / 8; - } - 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; -#endif // _DEBUGMSG - } else { - RTC_LOG(LS_WARNING) << "rtt < 0"; - } - } - - m_snd_wnd = static_cast(seg.wnd) << m_swnd_scale; - - uint32_t nAcked = seg.ack - m_snd_una; - m_snd_una = seg.ack; - - m_rto_base = (m_snd_una == m_snd_nxt) ? 0 : now; - - m_sbuf.ConsumeReadData(nAcked); - - for (uint32_t nFree = nAcked; nFree > 0;) { - RTC_DCHECK(!m_slist.empty()); - if (nFree < m_slist.front().len) { - m_slist.front().len -= nFree; - nFree = 0; - } else { - if (m_slist.front().len > m_largest) { - m_largest = m_slist.front().len; - } - nFree -= m_slist.front().len; - m_slist.pop_front(); - } - } - - if (m_dup_acks >= 3) { - if (m_snd_una >= m_recover) { // NewReno - uint32_t nInFlight = m_snd_nxt - m_snd_una; - m_cwnd = std::min(m_ssthresh, nInFlight + m_mss); // (Fast Retransmit) -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "exit recovery"; -#endif // _DEBUGMSG - m_dup_acks = 0; - } else { -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "recovery retransmit"; -#endif // _DEBUGMSG - if (!transmit(m_slist.begin(), now)) { - closedown(ECONNABORTED); - return false; - } - m_cwnd += m_mss - std::min(nAcked, m_cwnd); - } - } else { - m_dup_acks = 0; - // Slow start, congestion avoidance - if (m_cwnd < m_ssthresh) { - m_cwnd += m_mss; - } else { - m_cwnd += std::max(1, m_mss * m_mss / m_cwnd); - } - } - } else if (seg.ack == m_snd_una) { - // !?! Note, tcp says don't do this... but otherwise how does a closed - // window become open? - m_snd_wnd = static_cast(seg.wnd) << m_swnd_scale; - - // Check duplicate acks - if (seg.len > 0) { - // it's a dup ack, but with a data payload, so don't modify m_dup_acks - } else if (m_snd_una != m_snd_nxt) { - m_dup_acks += 1; - if (m_dup_acks == 3) { // (Fast Retransmit) -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "enter recovery"; - RTC_LOG(LS_INFO) << "recovery retransmit"; -#endif // _DEBUGMSG - if (!transmit(m_slist.begin(), now)) { - closedown(ECONNABORTED); - return false; - } - m_recover = m_snd_nxt; - uint32_t nInFlight = m_snd_nxt - m_snd_una; - m_ssthresh = std::max(nInFlight / 2, 2 * m_mss); - // RTC_LOG(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " - // << nInFlight << " m_mss: " << m_mss; - m_cwnd = m_ssthresh + 3 * m_mss; - } else if (m_dup_acks > 3) { - m_cwnd += m_mss; - } - } else { - m_dup_acks = 0; - } - } - - // !?! A bit hacky - if ((m_state == TCP_SYN_RECEIVED) && !bConnect) { - m_state = TCP_ESTABLISHED; - RTC_LOG(LS_INFO) << "State: TCP_ESTABLISHED"; - adjustMTU(); - if (m_notify) { - m_notify->OnTcpOpen(this); - } - // notify(evOpen); - } - - // If we make room in the send queue, notify the user - // The goal it to make sure we always have at least enough data to fill the - // window. We'd like to notify the app when we are halfway to that point. - const uint32_t kIdealRefillSize = (m_sbuf_len + m_rbuf_len) / 2; - if (m_bWriteEnable && - static_cast(m_sbuf.GetBuffered()) < kIdealRefillSize) { - m_bWriteEnable = false; - if (m_notify) { - m_notify->OnTcpWriteable(this); - } - // notify(evWrite); - } - - // Conditions were acks must be sent: - // 1) Segment is too old (they missed an ACK) (immediately) - // 2) Segment is too new (we missed a segment) (immediately) - // 3) Segment has data (so we need to ACK!) (delayed) - // ... so the only time we don't need to ACK, is an empty segment that points - // to rcv_nxt! - - SendFlags sflags = sfNone; - if (seg.seq != m_rcv_nxt) { - sflags = sfImmediateAck; // (Fast Recovery) - } else if (seg.len != 0) { - if (m_ack_delay == 0) { - sflags = sfImmediateAck; - } else { - sflags = sfDelayedAck; - } - } -#if _DEBUGMSG >= _DBG_NORMAL - if (sflags == sfImmediateAck) { - if (seg.seq > m_rcv_nxt) { - RTC_LOG_F(LS_INFO) << "too new"; - } else if (seg.seq + seg.len <= m_rcv_nxt) { - RTC_LOG_F(LS_INFO) << "too old"; - } - } -#endif // _DEBUGMSG - - // Adjust the incoming segment to fit our receive buffer - if (seg.seq < m_rcv_nxt) { - uint32_t nAdjust = m_rcv_nxt - seg.seq; - if (nAdjust < seg.len) { - seg.seq += nAdjust; - seg.data += nAdjust; - seg.len -= nAdjust; - } else { - seg.len = 0; - } - } - - size_t available_space = 0; - m_rbuf.GetWriteRemaining(&available_space); - - if ((seg.seq + seg.len - m_rcv_nxt) > - static_cast(available_space)) { - uint32_t nAdjust = - seg.seq + seg.len - m_rcv_nxt - static_cast(available_space); - if (nAdjust < seg.len) { - seg.len -= nAdjust; - } else { - seg.len = 0; - } - } - - bool bIgnoreData = (seg.flags & FLAG_CTL) || (m_shutdown != SD_NONE); - bool bNewData = false; - - if (seg.len > 0) { - bool bRecover = false; - if (bIgnoreData) { - if (seg.seq == m_rcv_nxt) { - m_rcv_nxt += seg.len; - // If we received a data segment out of order relative to a control - // segment, then we wrote it into the receive buffer at an offset (see - // "WriteOffset") below. So we need to advance the position in the - // buffer to avoid corrupting data. See bugs.webrtc.org/9208 - // - // We advance the position in the buffer by N bytes by acting like we - // wrote N bytes and then immediately read them. We can only do this if - // there's not already data ready to read, but this should always be - // true in the problematic scenario, since control frames are always - // sent first in the stream. - if (m_rbuf.GetBuffered() == 0) { - m_rbuf.ConsumeWriteBuffer(seg.len); - m_rbuf.ConsumeReadData(seg.len); - // After shifting the position in the buffer, we may have - // out-of-order packets ready to be recovered. - bRecover = true; - } - } - } else { - uint32_t nOffset = seg.seq - m_rcv_nxt; - - if (!m_rbuf.WriteOffset(seg.data, seg.len, nOffset, nullptr)) { - // Ignore incoming packets outside of the receive window. - return false; - } - - if (seg.seq == m_rcv_nxt) { - m_rbuf.ConsumeWriteBuffer(seg.len); - m_rcv_nxt += seg.len; - m_rcv_wnd -= seg.len; - bNewData = true; - // May be able to recover packets previously received out-of-order - // now. - bRecover = true; - } else { -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "Saving " << seg.len << " bytes (" << seg.seq - << " -> " << seg.seq + seg.len << ")"; -#endif // _DEBUGMSG - RSegment rseg; - rseg.seq = seg.seq; - rseg.len = seg.len; - RList::iterator it = m_rlist.begin(); - while ((it != m_rlist.end()) && (it->seq < rseg.seq)) { - ++it; - } - m_rlist.insert(it, rseg); - } - } - if (bRecover) { - RList::iterator it = m_rlist.begin(); - while ((it != m_rlist.end()) && (it->seq <= m_rcv_nxt)) { - if (it->seq + it->len > m_rcv_nxt) { - sflags = sfImmediateAck; // (Fast Recovery) - uint32_t nAdjust = (it->seq + it->len) - m_rcv_nxt; -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "Recovered " << nAdjust << " bytes (" << m_rcv_nxt - << " -> " << m_rcv_nxt + nAdjust << ")"; -#endif // _DEBUGMSG - m_rbuf.ConsumeWriteBuffer(nAdjust); - m_rcv_nxt += nAdjust; - m_rcv_wnd -= nAdjust; - bNewData = true; - } - it = m_rlist.erase(it); - } - } - } - - attemptSend(sflags); - - // If we have new data, notify the user - if (bNewData && m_bReadEnable) { - m_bReadEnable = false; - if (m_notify) { - m_notify->OnTcpReadable(this); - } - // notify(evRead); - } - - return true; -} - -bool PseudoTcp::transmit(const SList::iterator& seg, uint32_t now) { - if (seg->xmit >= ((m_state == TCP_ESTABLISHED) ? 15 : 30)) { - RTC_LOG_F(LS_VERBOSE) << "too many retransmits"; - return false; - } - - uint32_t nTransmit = std::min(seg->len, m_mss); - - while (true) { - uint32_t seq = seg->seq; - uint8_t flags = (seg->bCtrl ? FLAG_CTL : 0); - IPseudoTcpNotify::WriteResult wres = - packet(seq, flags, seg->seq - m_snd_una, nTransmit); - - if (wres == IPseudoTcpNotify::WR_SUCCESS) - break; - - if (wres == IPseudoTcpNotify::WR_FAIL) { - RTC_LOG_F(LS_VERBOSE) << "packet failed"; - return false; - } - - RTC_DCHECK(wres == IPseudoTcpNotify::WR_TOO_LARGE); - - while (true) { - if (PACKET_MAXIMUMS[m_msslevel + 1] == 0) { - RTC_LOG_F(LS_VERBOSE) << "MTU too small"; - return false; - } - // !?! We need to break up all outstanding and pending packets and then - // retransmit!?! - - m_mss = PACKET_MAXIMUMS[++m_msslevel] - PACKET_OVERHEAD; - m_cwnd = 2 * m_mss; // I added this... haven't researched actual formula - if (m_mss < nTransmit) { - nTransmit = m_mss; - break; - } - } -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "Adjusting mss to " << m_mss << " bytes"; -#endif // _DEBUGMSG - } - - if (nTransmit < seg->len) { - RTC_LOG_F(LS_VERBOSE) << "mss reduced to " << m_mss; - - SSegment subseg(seg->seq + nTransmit, seg->len - nTransmit, seg->bCtrl); - // subseg.tstamp = seg->tstamp; - subseg.xmit = seg->xmit; - seg->len = nTransmit; - - SList::iterator next = seg; - m_slist.insert(++next, subseg); - } - - if (seg->xmit == 0) { - m_snd_nxt += seg->len; - } - seg->xmit += 1; - // seg->tstamp = now; - if (m_rto_base == 0) { - m_rto_base = now; - } - - return true; -} - -void PseudoTcp::attemptSend(SendFlags sflags) { - uint32_t now = Now(); - - if (TimeDiff32(now, m_lastsend) > static_cast(m_rx_rto)) { - m_cwnd = m_mss; - } - -#if _DEBUGMSG - bool bFirst = true; -#endif // _DEBUGMSG - - while (true) { - uint32_t cwnd = m_cwnd; - if ((m_dup_acks == 1) || (m_dup_acks == 2)) { // Limited Transmit - cwnd += m_dup_acks * m_mss; - } - uint32_t nWindow = std::min(m_snd_wnd, cwnd); - uint32_t nInFlight = m_snd_nxt - m_snd_una; - uint32_t nUseable = (nInFlight < nWindow) ? (nWindow - nInFlight) : 0; - - size_t snd_buffered = m_sbuf.GetBuffered(); - uint32_t nAvailable = - std::min(static_cast(snd_buffered) - nInFlight, m_mss); - - if (nAvailable > nUseable) { - if (nUseable * 4 < nWindow) { - // RFC 813 - avoid SWS - nAvailable = 0; - } else { - nAvailable = nUseable; - } - } - -#if _DEBUGMSG >= _DBG_VERBOSE - if (bFirst) { - size_t available_space = 0; - m_sbuf.GetWriteRemaining(&available_space); - - bFirst = false; - RTC_LOG(LS_INFO) << "[cwnd: " << m_cwnd << " nWindow: " << nWindow - << " nInFlight: " << nInFlight - << " nAvailable: " << nAvailable - << " nQueued: " << snd_buffered - << " nEmpty: " << available_space - << " ssthresh: " << m_ssthresh << "]"; - } -#endif // _DEBUGMSG - - if (nAvailable == 0) { - if (sflags == sfNone) - return; - - // If this is an immediate ack, or the second delayed ack - if ((sflags == sfImmediateAck) || m_t_ack) { - packet(m_snd_nxt, 0, 0, 0); - } else { - m_t_ack = Now(); - } - return; - } - - // Nagle's algorithm. - // If there is data already in-flight, and we haven't a full segment of - // data ready to send then hold off until we get more to send, or the - // in-flight data is acknowledged. - if (m_use_nagling && (m_snd_nxt > m_snd_una) && (nAvailable < m_mss)) { - return; - } - - // Find the next segment to transmit - SList::iterator it = m_slist.begin(); - while (it->xmit > 0) { - ++it; - RTC_DCHECK(it != m_slist.end()); - } - SList::iterator seg = it; - - // If the segment is too large, break it into two - if (seg->len > nAvailable) { - SSegment subseg(seg->seq + nAvailable, seg->len - nAvailable, seg->bCtrl); - seg->len = nAvailable; - m_slist.insert(++it, subseg); - } - - if (!transmit(seg, now)) { - RTC_LOG_F(LS_VERBOSE) << "transmit failed"; - // TODO(?): consider closing socket - return; - } - - sflags = sfNone; - } -} - -void PseudoTcp::closedown(uint32_t err) { - RTC_LOG(LS_INFO) << "State: TCP_CLOSED"; - m_state = TCP_CLOSED; - if (m_notify) { - m_notify->OnTcpClosed(this, err); - } - // notify(evClose, err); -} - -void PseudoTcp::adjustMTU() { - // Determine our current mss level, so that we can adjust appropriately later - for (m_msslevel = 0; PACKET_MAXIMUMS[m_msslevel + 1] > 0; ++m_msslevel) { - if (static_cast(PACKET_MAXIMUMS[m_msslevel]) <= m_mtu_advise) { - break; - } - } - m_mss = m_mtu_advise - PACKET_OVERHEAD; -// !?! Should we reset m_largest here? -#if _DEBUGMSG >= _DBG_NORMAL - RTC_LOG(LS_INFO) << "Adjusting mss to " << m_mss << " bytes"; -#endif // _DEBUGMSG - // Enforce minimums on ssthresh and cwnd - m_ssthresh = std::max(m_ssthresh, 2 * m_mss); - m_cwnd = std::max(m_cwnd, m_mss); -} - -bool PseudoTcp::isReceiveBufferFull() const { - size_t available_space = 0; - m_rbuf.GetWriteRemaining(&available_space); - return !available_space; -} - -void PseudoTcp::disableWindowScale() { - m_support_wnd_scale = false; -} - -void PseudoTcp::queueConnectMessage() { - ByteBufferWriter buf; - - buf.WriteUInt8(CTL_CONNECT); - if (m_support_wnd_scale) { - buf.WriteUInt8(TCP_OPT_WND_SCALE); - buf.WriteUInt8(1); - buf.WriteUInt8(m_rwnd_scale); - } - m_snd_wnd = static_cast(buf.Length()); - queue(reinterpret_cast(buf.Data()), - static_cast(buf.Length()), true); -} - -void PseudoTcp::parseOptions(const char* data, uint32_t len) { - std::set options_specified; - - // See http://www.freesoft.org/CIE/Course/Section4/8.htm for - // parsing the options list. - ByteBufferReader buf( - MakeArrayView(reinterpret_cast(data), len)); - while (buf.Length()) { - uint8_t kind = TCP_OPT_EOL; - buf.ReadUInt8(&kind); - - if (kind == TCP_OPT_EOL) { - // End of option list. - break; - } else if (kind == TCP_OPT_NOOP) { - // No op. - continue; - } - - // Length of this option. - RTC_DCHECK(len != 0); - uint8_t opt_len = 0; - buf.ReadUInt8(&opt_len); - - // Content of this option. - if (opt_len <= buf.Length()) { - applyOption(kind, reinterpret_cast(buf.Data()), opt_len); - buf.Consume(opt_len); - } else { - RTC_LOG(LS_ERROR) << "Invalid option length received."; - return; - } - options_specified.insert(kind); - } - - if (options_specified.find(TCP_OPT_WND_SCALE) == options_specified.end()) { - RTC_LOG(LS_WARNING) << "Peer doesn't support window scaling"; - - if (m_rwnd_scale > 0) { - // Peer doesn't support TCP options and window scaling. - // Revert receive buffer size to default value. - resizeReceiveBuffer(DEFAULT_RCV_BUF_SIZE); - m_swnd_scale = 0; - } - } -} - -void PseudoTcp::applyOption(char kind, const char* data, uint32_t len) { - if (kind == TCP_OPT_MSS) { - RTC_LOG(LS_WARNING) << "Peer specified MSS option which is not supported."; - // TODO(?): Implement. - } else if (kind == TCP_OPT_WND_SCALE) { - // Window scale factor. - // http://www.ietf.org/rfc/rfc1323.txt - if (len != 1) { - RTC_LOG_F(LS_WARNING) << "Invalid window scale option received."; - return; - } - applyWindowScaleOption(data[0]); - } -} - -void PseudoTcp::applyWindowScaleOption(uint8_t scale_factor) { - m_swnd_scale = scale_factor; -} - -void PseudoTcp::resizeSendBuffer(uint32_t new_size) { - m_sbuf_len = new_size; - m_sbuf.SetCapacity(new_size); -} - -void PseudoTcp::resizeReceiveBuffer(uint32_t new_size) { - uint8_t scale_factor = 0; - - // Determine the scale factor such that the scaled window size can fit - // in a 16-bit unsigned integer. - while (new_size > 0xFFFF) { - ++scale_factor; - new_size >>= 1; - } - - // Determine the proper size of the buffer. - new_size <<= scale_factor; - bool result = m_rbuf.SetCapacity(new_size); - - // Make sure the new buffer is large enough to contain data in the old - // buffer. This should always be true because this method is called either - // before connection is established or when peers are exchanging connect - // messages. - RTC_DCHECK(result); - m_rbuf_len = new_size; - m_rwnd_scale = scale_factor; - m_ssthresh = new_size; - - size_t available_space = 0; - m_rbuf.GetWriteRemaining(&available_space); - m_rcv_wnd = static_cast(available_space); -} - -PseudoTcp::LockedFifoBuffer::LockedFifoBuffer(size_t size) - : buffer_(new char[size]), - buffer_length_(size), - data_length_(0), - read_position_(0) {} - -PseudoTcp::LockedFifoBuffer::~LockedFifoBuffer() {} - -size_t PseudoTcp::LockedFifoBuffer::GetBuffered() const { - MutexLock lock(&mutex_); - return data_length_; -} - -bool PseudoTcp::LockedFifoBuffer::SetCapacity(size_t size) { - MutexLock lock(&mutex_); - if (data_length_ > size) - return false; - - if (size != buffer_length_) { - char* buffer = new char[size]; - const size_t copy = data_length_; - const size_t tail_copy = std::min(copy, buffer_length_ - read_position_); - memcpy(buffer, &buffer_[read_position_], tail_copy); - memcpy(buffer + tail_copy, &buffer_[0], copy - tail_copy); - buffer_.reset(buffer); - read_position_ = 0; - buffer_length_ = size; - } - - return true; -} - -bool PseudoTcp::LockedFifoBuffer::ReadOffset(void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_read) { - MutexLock lock(&mutex_); - return ReadOffsetLocked(buffer, bytes, offset, bytes_read); -} - -bool PseudoTcp::LockedFifoBuffer::WriteOffset(const void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_written) { - MutexLock lock(&mutex_); - return WriteOffsetLocked(buffer, bytes, offset, bytes_written); -} - -bool PseudoTcp::LockedFifoBuffer::Read(void* buffer, - size_t bytes, - size_t* bytes_read) { - MutexLock lock(&mutex_); - size_t copy = 0; - if (!ReadOffsetLocked(buffer, bytes, 0, ©)) - return false; - - // If read was successful then adjust the read position and number of - // bytes buffered. - read_position_ = (read_position_ + copy) % buffer_length_; - data_length_ -= copy; - if (bytes_read) - *bytes_read = copy; - - return true; -} - -bool PseudoTcp::LockedFifoBuffer::Write(const void* buffer, - size_t bytes, - size_t* bytes_written) { - MutexLock lock(&mutex_); - size_t copy = 0; - if (!WriteOffsetLocked(buffer, bytes, 0, ©)) - return false; - - // If write was successful then adjust the number of readable bytes. - data_length_ += copy; - if (bytes_written) { - *bytes_written = copy; - } - - return true; -} - -void PseudoTcp::LockedFifoBuffer::ConsumeReadData(size_t size) { - MutexLock lock(&mutex_); - RTC_DCHECK(size <= data_length_); - read_position_ = (read_position_ + size) % buffer_length_; - data_length_ -= size; -} - -void PseudoTcp::LockedFifoBuffer::ConsumeWriteBuffer(size_t size) { - MutexLock lock(&mutex_); - RTC_DCHECK(size <= buffer_length_ - data_length_); - data_length_ += size; -} - -bool PseudoTcp::LockedFifoBuffer::GetWriteRemaining(size_t* size) const { - MutexLock lock(&mutex_); - *size = buffer_length_ - data_length_; - return true; -} - -bool PseudoTcp::LockedFifoBuffer::ReadOffsetLocked(void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_read) { - if (offset >= data_length_) - return false; - - const size_t available = data_length_ - offset; - const size_t read_position = (read_position_ + offset) % buffer_length_; - const size_t copy = std::min(bytes, available); - const size_t tail_copy = std::min(copy, buffer_length_ - read_position); - char* const p = static_cast(buffer); - memcpy(p, &buffer_[read_position], tail_copy); - memcpy(p + tail_copy, &buffer_[0], copy - tail_copy); - - if (bytes_read) - *bytes_read = copy; - - return true; -} - -bool PseudoTcp::LockedFifoBuffer::WriteOffsetLocked(const void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_written) { - if (data_length_ + offset >= buffer_length_) - return false; - - const size_t available = buffer_length_ - data_length_ - offset; - const size_t write_position = - (read_position_ + data_length_ + offset) % buffer_length_; - const size_t copy = std::min(bytes, available); - const size_t tail_copy = std::min(copy, buffer_length_ - write_position); - const char* const p = static_cast(buffer); - memcpy(&buffer_[write_position], p, tail_copy); - memcpy(&buffer_[0], p + tail_copy, copy - tail_copy); - - if (bytes_written) - *bytes_written = copy; - - return true; -} - -} // namespace webrtc diff --git a/p2p/base/pseudo_tcp.h b/p2p/base/pseudo_tcp.h deleted file mode 100644 index 9ba5799b73..0000000000 --- a/p2p/base/pseudo_tcp.h +++ /dev/null @@ -1,305 +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 P2P_BASE_PSEUDO_TCP_H_ -#define P2P_BASE_PSEUDO_TCP_H_ - -#include -#include - -#include -#include - -#include "rtc_base/synchronization/mutex.h" -#include "rtc_base/system/rtc_export.h" -#include "rtc_base/thread_annotations.h" - -namespace webrtc { - -////////////////////////////////////////////////////////////////////// -// IPseudoTcpNotify -////////////////////////////////////////////////////////////////////// - -class PseudoTcp; - -class IPseudoTcpNotify { - public: - // Notification of tcp events - virtual void OnTcpOpen(PseudoTcp* tcp) = 0; - virtual void OnTcpReadable(PseudoTcp* tcp) = 0; - virtual void OnTcpWriteable(PseudoTcp* tcp) = 0; - virtual void OnTcpClosed(PseudoTcp* tcp, uint32_t error) = 0; - - // Write the packet onto the network - enum WriteResult { WR_SUCCESS, WR_TOO_LARGE, WR_FAIL }; - virtual WriteResult TcpWritePacket(PseudoTcp* tcp, - const char* buffer, - size_t len) = 0; - - protected: - virtual ~IPseudoTcpNotify() {} -}; - -////////////////////////////////////////////////////////////////////// -// PseudoTcp -////////////////////////////////////////////////////////////////////// - -class RTC_EXPORT PseudoTcp { - public: - static uint32_t Now(); - - PseudoTcp(IPseudoTcpNotify* notify, uint32_t conv); - virtual ~PseudoTcp(); - - int Connect(); - int Recv(char* buffer, size_t len); - int Send(const char* buffer, size_t len); - void Close(bool force); - int GetError(); - - enum TcpState { - TCP_LISTEN, - TCP_SYN_SENT, - TCP_SYN_RECEIVED, - TCP_ESTABLISHED, - TCP_CLOSED - }; - TcpState State() const { return m_state; } - - // Call this when the PMTU changes. - void NotifyMTU(uint16_t mtu); - - // Call this based on timeout value returned from GetNextClock. - // It's ok to call this too frequently. - void NotifyClock(uint32_t now); - - // Call this whenever a packet arrives. - // Returns true if the packet was processed successfully. - bool NotifyPacket(const char* buffer, size_t len); - - // Call this to determine the next time NotifyClock should be called. - // Returns false if the socket is ready to be destroyed. - bool GetNextClock(uint32_t now, long& timeout); - - // Call these to get/set option values to tailor this PseudoTcp - // instance's behaviour for the kind of data it will carry. - // If an unrecognized option is set or got, an assertion will fire. - // - // Setting options for OPT_RCVBUF or OPT_SNDBUF after Connect() is called - // will result in an assertion. - enum Option { - OPT_NODELAY, // Whether to enable Nagle's algorithm (0 == off) - OPT_ACKDELAY, // The Delayed ACK timeout (0 == off). - OPT_RCVBUF, // Set the receive buffer size, in bytes. - OPT_SNDBUF, // Set the send buffer size, in bytes. - }; - void GetOption(Option opt, int* value); - void SetOption(Option opt, int value); - - // Returns current congestion window in bytes. - uint32_t GetCongestionWindow() const; - - // Returns amount of data in bytes that has been sent, but haven't - // been acknowledged. - uint32_t GetBytesInFlight() const; - - // Returns number of bytes that were written in buffer and haven't - // been sent. - uint32_t GetBytesBufferedNotSent() const; - - // Returns current round-trip time estimate in milliseconds. - uint32_t GetRoundTripTimeEstimateMs() const; - - protected: - enum SendFlags { sfNone, sfDelayedAck, sfImmediateAck }; - - struct Segment { - uint32_t conv, seq, ack; - uint8_t flags; - uint16_t wnd; - const char* data; - uint32_t len; - uint32_t tsval, tsecr; - }; - - struct SSegment { - SSegment(uint32_t s, uint32_t l, bool c) - : seq(s), len(l), /*tstamp(0),*/ xmit(0), bCtrl(c) {} - uint32_t seq, len; - // uint32_t tstamp; - uint8_t xmit; - bool bCtrl; - }; - typedef std::list SList; - - struct RSegment { - uint32_t seq, len; - }; - - uint32_t queue(const char* data, uint32_t len, bool bCtrl); - - // Creates a packet and submits it to the network. This method can either - // send payload or just an ACK packet. - // - // `seq` is the sequence number of this packet. - // `flags` is the flags for sending this packet. - // `offset` is the offset to read from `m_sbuf`. - // `len` is the number of bytes to read from `m_sbuf` as payload. If this - // value is 0 then this is an ACK packet, otherwise this packet has payload. - IPseudoTcpNotify::WriteResult packet(uint32_t seq, - uint8_t flags, - uint32_t offset, - uint32_t len); - bool parse(const uint8_t* buffer, uint32_t size); - - void attemptSend(SendFlags sflags = sfNone); - - void closedown(uint32_t err = 0); - - bool clock_check(uint32_t now, long& nTimeout); - - bool process(Segment& seg); - bool transmit(const SList::iterator& seg, uint32_t now); - - void adjustMTU(); - - protected: - // This method is used in test only to query receive buffer state. - bool isReceiveBufferFull() const; - - // This method is only used in tests, to disable window scaling - // support for testing backward compatibility. - void disableWindowScale(); - - private: - // Queue the connect message with TCP options. - void queueConnectMessage(); - - // Parse TCP options in the header. - void parseOptions(const char* data, uint32_t len); - - // Apply a TCP option that has been read from the header. - void applyOption(char kind, const char* data, uint32_t len); - - // Apply window scale option. - void applyWindowScaleOption(uint8_t scale_factor); - - // Resize the send buffer with `new_size` in bytes. - void resizeSendBuffer(uint32_t new_size); - - // Resize the receive buffer with `new_size` in bytes. This call adjusts - // window scale factor `m_swnd_scale` accordingly. - void resizeReceiveBuffer(uint32_t new_size); - - class LockedFifoBuffer final { - public: - explicit LockedFifoBuffer(size_t size); - ~LockedFifoBuffer(); - - size_t GetBuffered() const; - bool SetCapacity(size_t size); - bool ReadOffset(void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_read); - bool WriteOffset(const void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_written); - bool Read(void* buffer, size_t bytes, size_t* bytes_read); - bool Write(const void* buffer, size_t bytes, size_t* bytes_written); - void ConsumeReadData(size_t size); - void ConsumeWriteBuffer(size_t size); - bool GetWriteRemaining(size_t* size) const; - - private: - bool ReadOffsetLocked(void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_read) - RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); - bool WriteOffsetLocked(const void* buffer, - size_t bytes, - size_t offset, - size_t* bytes_written) - RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); - - // the allocated buffer - std::unique_ptr buffer_ RTC_GUARDED_BY(mutex_); - // size of the allocated buffer - size_t buffer_length_ RTC_GUARDED_BY(mutex_); - // amount of readable data in the buffer - size_t data_length_ RTC_GUARDED_BY(mutex_); - // offset to the readable data - size_t read_position_ RTC_GUARDED_BY(mutex_); - mutable Mutex mutex_; - }; - - IPseudoTcpNotify* m_notify; - enum Shutdown { SD_NONE, SD_GRACEFUL, SD_FORCEFUL } m_shutdown; - int m_error; - - // TCB data - TcpState m_state; - uint32_t m_conv; - bool m_bReadEnable, m_bWriteEnable, m_bOutgoing; - uint32_t m_lasttraffic; - - // Incoming data - typedef std::list RList; - RList m_rlist; - uint32_t m_rbuf_len, m_rcv_nxt, m_rcv_wnd, m_lastrecv; - uint8_t m_rwnd_scale; // Window scale factor. - LockedFifoBuffer m_rbuf; - - // Outgoing data - SList m_slist; - uint32_t m_sbuf_len, m_snd_nxt, m_snd_wnd, m_lastsend, m_snd_una; - uint8_t m_swnd_scale; // Window scale factor. - LockedFifoBuffer m_sbuf; - - // Maximum segment size, estimated protocol level, largest segment sent - uint32_t m_mss, m_msslevel, m_largest, m_mtu_advise; - // Retransmit timer - uint32_t m_rto_base; - - // Timestamp tracking - uint32_t m_ts_recent, m_ts_lastack; - - // Round-trip calculation - uint32_t m_rx_rttvar, m_rx_srtt, m_rx_rto; - - // Congestion avoidance, Fast retransmit/recovery, Delayed ACKs - uint32_t m_ssthresh, m_cwnd; - uint8_t m_dup_acks; - uint32_t m_recover; - uint32_t m_t_ack; - - // Configuration options - bool m_use_nagling; - uint32_t m_ack_delay; - - // This is used by unit tests to test backward compatibility of - // PseudoTcp implementations that don't support window scaling. - bool m_support_wnd_scale; -}; - -} // namespace webrtc - -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IPseudoTcpNotify; -using ::webrtc::PseudoTcp; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES - -#endif // P2P_BASE_PSEUDO_TCP_H_ diff --git a/p2p/base/pseudo_tcp_unittest.cc b/p2p/base/pseudo_tcp_unittest.cc deleted file mode 100644 index 7d5400f2ed..0000000000 --- a/p2p/base/pseudo_tcp_unittest.cc +++ /dev/null @@ -1,908 +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 "p2p/base/pseudo_tcp.h" - -#include - -#include -#include -#include -#include -#include -#include - -#include "api/array_view.h" -#include "api/task_queue/pending_task_safety_flag.h" -#include "api/task_queue/task_queue_base.h" -#include "api/test/rtc_error_matchers.h" -#include "api/units/time_delta.h" -#include "rtc_base/crypto_random.h" -#include "rtc_base/logging.h" -#include "rtc_base/memory_stream.h" -#include "rtc_base/stream.h" -#include "rtc_base/thread.h" -#include "rtc_base/time_utils.h" -#include "test/gmock.h" -#include "test/gtest.h" -#include "test/wait_until.h" - -using ::testing::IsTrue; -using ::webrtc::PseudoTcp; -using ::webrtc::ScopedTaskSafety; -using ::webrtc::TaskQueueBase; -using ::webrtc::TimeDelta; - -static const int kConnectTimeoutMs = 10000; // ~3 * default RTO of 3000ms -static const int kTransferTimeoutMs = 15000; -static const int kBlockSize = 4096; - -class PseudoTcpForTest : public webrtc::PseudoTcp { - public: - PseudoTcpForTest(webrtc::IPseudoTcpNotify* notify, uint32_t conv) - : webrtc::PseudoTcp(notify, conv) {} - - bool isReceiveBufferFull() const { - return webrtc::PseudoTcp::isReceiveBufferFull(); - } - - void disableWindowScale() { webrtc::PseudoTcp::disableWindowScale(); } -}; - -class PseudoTcpTestBase : public ::testing::Test, - public webrtc::IPseudoTcpNotify { - public: - PseudoTcpTestBase() - : local_(this, 1), - remote_(this, 1), - have_connected_(false), - have_disconnected_(false), - local_mtu_(65535), - remote_mtu_(65535), - delay_(0), - loss_(0) { - // Set use of the test RNG to get predictable loss patterns. Otherwise, - // this test would occasionally get really unlucky loss and time out. - webrtc::SetRandomTestMode(true); - } - ~PseudoTcpTestBase() override { - // Put it back for the next test. - webrtc::SetRandomTestMode(false); - } - // If true, both endpoints will send the "connect" segment simultaneously, - // rather than `local_` sending it followed by a response from `remote_`. - // Note that this is what chromoting ends up doing. - void SetSimultaneousOpen(bool enabled) { simultaneous_open_ = enabled; } - void SetLocalMtu(int mtu) { - local_.NotifyMTU(mtu); - local_mtu_ = mtu; - } - void SetRemoteMtu(int mtu) { - remote_.NotifyMTU(mtu); - remote_mtu_ = mtu; - } - void SetDelay(int delay) { delay_ = delay; } - void SetLoss(int percent) { loss_ = percent; } - // Used to cause the initial "connect" segment to be lost, needed for a - // regression test. - void DropNextPacket() { drop_next_packet_ = true; } - void SetOptNagling(bool enable_nagles) { - local_.SetOption(PseudoTcp::OPT_NODELAY, !enable_nagles); - remote_.SetOption(PseudoTcp::OPT_NODELAY, !enable_nagles); - } - void SetOptAckDelay(int ack_delay) { - local_.SetOption(PseudoTcp::OPT_ACKDELAY, ack_delay); - remote_.SetOption(PseudoTcp::OPT_ACKDELAY, ack_delay); - } - void SetOptSndBuf(int size) { - local_.SetOption(PseudoTcp::OPT_SNDBUF, size); - remote_.SetOption(PseudoTcp::OPT_SNDBUF, size); - } - void SetRemoteOptRcvBuf(int size) { - remote_.SetOption(PseudoTcp::OPT_RCVBUF, size); - } - void SetLocalOptRcvBuf(int size) { - local_.SetOption(PseudoTcp::OPT_RCVBUF, size); - } - void DisableRemoteWindowScale() { remote_.disableWindowScale(); } - void DisableLocalWindowScale() { local_.disableWindowScale(); } - - protected: - int Connect() { - int ret = local_.Connect(); - if (ret == 0) { - UpdateLocalClock(); - } - if (simultaneous_open_) { - ret = remote_.Connect(); - if (ret == 0) { - UpdateRemoteClock(); - } - } - return ret; - } - void Close() { - local_.Close(false); - UpdateLocalClock(); - } - - void OnTcpOpen(PseudoTcp* tcp) override { - // Consider ourselves connected when the local side gets OnTcpOpen. - // OnTcpWriteable isn't fired at open, so we trigger it now. - RTC_LOG(LS_VERBOSE) << "Opened"; - if (tcp == &local_) { - have_connected_ = true; - OnTcpWriteable(tcp); - } - } - // Test derived from the base should override - // virtual void OnTcpReadable(PseudoTcp* tcp) - // and - // virtual void OnTcpWritable(PseudoTcp* tcp) - void OnTcpClosed(PseudoTcp* tcp, uint32_t error) override { - // Consider ourselves closed when the remote side gets OnTcpClosed. - // TODO(?): OnTcpClosed is only ever notified in case of error in - // the current implementation. Solicited close is not (yet) supported. - RTC_LOG(LS_VERBOSE) << "Closed"; - EXPECT_EQ(0U, error); - if (tcp == &remote_) { - have_disconnected_ = true; - } - } - WriteResult TcpWritePacket(PseudoTcp* tcp, - const char* buffer, - size_t len) override { - // Drop a packet if the test called DropNextPacket. - if (drop_next_packet_) { - drop_next_packet_ = false; - RTC_LOG(LS_VERBOSE) << "Dropping packet due to DropNextPacket, size=" - << len; - return WR_SUCCESS; - } - // Randomly drop the desired percentage of packets. - if (webrtc::CreateRandomId() % 100 < static_cast(loss_)) { - RTC_LOG(LS_VERBOSE) << "Randomly dropping packet, size=" << len; - return WR_SUCCESS; - } - // Also drop packets that are larger than the configured MTU. - if (len > static_cast(std::min(local_mtu_, remote_mtu_))) { - RTC_LOG(LS_VERBOSE) << "Dropping packet that exceeds path MTU, size=" - << len; - return WR_SUCCESS; - } - PseudoTcp* other; - ScopedTaskSafety* timer; - if (tcp == &local_) { - other = &remote_; - timer = &remote_timer_; - } else { - other = &local_; - timer = &local_timer_; - } - std::string packet(buffer, len); - ++packets_in_flight_; - TaskQueueBase::Current()->PostDelayedTask( - [other, timer, packet = std::move(packet), this] { - --packets_in_flight_; - other->NotifyPacket(packet.c_str(), packet.size()); - UpdateClock(*other, *timer); - }, - TimeDelta::Millis(delay_)); - return WR_SUCCESS; - } - - void UpdateLocalClock() { UpdateClock(local_, local_timer_); } - void UpdateRemoteClock() { UpdateClock(remote_, remote_timer_); } - static void UpdateClock(PseudoTcp& tcp, ScopedTaskSafety& timer) { - long interval = 0; // NOLINT - tcp.GetNextClock(PseudoTcp::Now(), interval); - interval = std::max(interval, 0L); // sometimes interval is < 0 - timer.reset(); - TaskQueueBase::Current()->PostDelayedTask( - SafeTask(timer.flag(), - [&tcp, &timer] { - tcp.NotifyClock(PseudoTcp::Now()); - UpdateClock(tcp, timer); - }), - TimeDelta::Millis(interval)); - } - - webrtc::AutoThread main_thread_; - PseudoTcpForTest local_; - PseudoTcpForTest remote_; - ScopedTaskSafety local_timer_; - ScopedTaskSafety remote_timer_; - webrtc::MemoryStream send_stream_; - webrtc::MemoryStream recv_stream_; - bool have_connected_; - bool have_disconnected_; - int local_mtu_; - int remote_mtu_; - int delay_; - int loss_; - bool drop_next_packet_ = false; - bool simultaneous_open_ = false; - int packets_in_flight_ = 0; -}; - -class PseudoTcpTest : public PseudoTcpTestBase { - public: - void TestTransfer(int size) { - uint32_t start; - int32_t elapsed; - size_t received; - // Create some dummy data to send. - send_stream_.ReserveSize(size); - for (int i = 0; i < size; ++i) { - uint8_t ch = static_cast(i); - size_t written; - int error; - send_stream_.Write(webrtc::MakeArrayView(&ch, 1), written, error); - } - send_stream_.Rewind(); - // Prepare the receive stream. - recv_stream_.ReserveSize(size); - // Connect and wait until connected. - start = webrtc::Time32(); - EXPECT_EQ(0, Connect()); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return have_connected_; }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kConnectTimeoutMs)}), - webrtc::IsRtcOk()); - // Sending will start from OnTcpWriteable and complete when all data has - // been received. - EXPECT_THAT(webrtc::WaitUntil( - [&] { return have_disconnected_; }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTransferTimeoutMs)}), - webrtc::IsRtcOk()); - elapsed = webrtc::Time32() - start; - recv_stream_.GetSize(&received); - // Ensure we closed down OK and we got the right data. - // TODO(?): Ensure the errors are cleared properly. - // EXPECT_EQ(0, local_.GetError()); - // EXPECT_EQ(0, remote_.GetError()); - EXPECT_EQ(static_cast(size), received); - EXPECT_EQ(0, - memcmp(send_stream_.GetBuffer(), recv_stream_.GetBuffer(), size)); - RTC_LOG(LS_INFO) << "Transferred " << received << " bytes in " << elapsed - << " ms (" << size * 8 / elapsed << " Kbps)"; - } - - private: - // IPseudoTcpNotify interface - - void OnTcpReadable(PseudoTcp* tcp) override { - // Stream bytes to the recv stream as they arrive. - if (tcp == &remote_) { - ReadData(); - - // TODO(?): OnTcpClosed() is currently only notified on error - - // there is no on-the-wire equivalent of TCP FIN. - // So we fake the notification when all the data has been read. - size_t received, required; - recv_stream_.GetPosition(&received); - send_stream_.GetSize(&required); - if (received == required) - OnTcpClosed(&remote_, 0); - } - } - void OnTcpWriteable(PseudoTcp* tcp) override { - // Write bytes from the send stream when we can. - // Shut down when we've sent everything. - if (tcp == &local_) { - RTC_LOG(LS_VERBOSE) << "Flow Control Lifted"; - bool done; - WriteData(&done); - if (done) { - Close(); - } - } - } - - void ReadData() { - char block[kBlockSize]; - size_t position; - int received; - do { - received = remote_.Recv(block, sizeof(block)); - if (received != -1) { - size_t written; - int error; - recv_stream_.Write( - webrtc::MakeArrayView(reinterpret_cast(block), received), - written, error); - recv_stream_.GetPosition(&position); - RTC_LOG(LS_VERBOSE) << "Received: " << position; - } - } while (received > 0); - } - void WriteData(bool* done) { - size_t position, tosend; - int sent; - char block[kBlockSize]; - do { - send_stream_.GetPosition(&position); - int error; - if (send_stream_.Read(webrtc::MakeArrayView( - reinterpret_cast(block), kBlockSize), - tosend, error) != webrtc::SR_EOS) { - sent = local_.Send(block, tosend); - UpdateLocalClock(); - if (sent != -1) { - send_stream_.SetPosition(position + sent); - RTC_LOG(LS_VERBOSE) << "Sent: " << position + sent; - } else { - send_stream_.SetPosition(position); - RTC_LOG(LS_VERBOSE) << "Flow Controlled"; - } - } else { - sent = static_cast(tosend = 0); - } - } while (sent > 0); - *done = (tosend == 0); - } - - private: - webrtc::MemoryStream send_stream_; - webrtc::MemoryStream recv_stream_; -}; - -class PseudoTcpTestPingPong : public PseudoTcpTestBase { - public: - PseudoTcpTestPingPong() - : iterations_remaining_(0), - sender_(nullptr), - receiver_(nullptr), - bytes_per_send_(0) {} - void SetBytesPerSend(int bytes) { bytes_per_send_ = bytes; } - void TestPingPong(int size, int iterations) { - uint32_t start, elapsed; - iterations_remaining_ = iterations; - receiver_ = &remote_; - sender_ = &local_; - // Create some dummy data to send. - send_stream_.ReserveSize(size); - for (int i = 0; i < size; ++i) { - uint8_t ch = static_cast(i); - size_t written; - int error; - send_stream_.Write(webrtc::MakeArrayView(&ch, 1), written, error); - } - send_stream_.Rewind(); - // Prepare the receive stream. - recv_stream_.ReserveSize(size); - // Connect and wait until connected. - start = webrtc::Time32(); - EXPECT_EQ(0, Connect()); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return have_connected_; }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kConnectTimeoutMs)}), - webrtc::IsRtcOk()); - // Sending will start from OnTcpWriteable and stop when the required - // number of iterations have completed. - EXPECT_THAT(webrtc::WaitUntil( - [&] { return have_disconnected_; }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTransferTimeoutMs)}), - webrtc::IsRtcOk()); - elapsed = webrtc::TimeSince(start); - RTC_LOG(LS_INFO) << "Performed " << iterations << " pings in " << elapsed - << " ms"; - } - - private: - // IPseudoTcpNotify interface - - void OnTcpReadable(PseudoTcp* tcp) override { - if (tcp != receiver_) { - RTC_LOG_F(LS_ERROR) << "unexpected OnTcpReadable"; - return; - } - // Stream bytes to the recv stream as they arrive. - ReadData(); - // If we've received the desired amount of data, rewind things - // and send it back the other way! - size_t position, desired; - recv_stream_.GetPosition(&position); - send_stream_.GetSize(&desired); - if (position == desired) { - if (receiver_ == &local_ && --iterations_remaining_ == 0) { - Close(); - // TODO(?): Fake OnTcpClosed() on the receiver for now. - OnTcpClosed(&remote_, 0); - return; - } - PseudoTcp* tmp = receiver_; - receiver_ = sender_; - sender_ = tmp; - recv_stream_.Rewind(); - send_stream_.Rewind(); - OnTcpWriteable(sender_); - } - } - void OnTcpWriteable(PseudoTcp* tcp) override { - if (tcp != sender_) - return; - // Write bytes from the send stream when we can. - // Shut down when we've sent everything. - RTC_LOG(LS_VERBOSE) << "Flow Control Lifted"; - WriteData(); - } - - void ReadData() { - char block[kBlockSize]; - size_t position; - int received; - do { - received = receiver_->Recv(block, sizeof(block)); - if (received != -1) { - size_t written; - int error; - recv_stream_.Write( - webrtc::MakeArrayView(reinterpret_cast(block), - received), - written, error); - recv_stream_.GetPosition(&position); - RTC_LOG(LS_VERBOSE) << "Received: " << position; - } - } while (received > 0); - } - void WriteData() { - size_t position, tosend; - int sent; - char block[kBlockSize]; - do { - send_stream_.GetPosition(&position); - tosend = bytes_per_send_ ? bytes_per_send_ : sizeof(block); - int error; - if (send_stream_.Read( - webrtc::MakeArrayView(reinterpret_cast(block), tosend), - tosend, error) != webrtc::SR_EOS) { - sent = sender_->Send(block, tosend); - UpdateLocalClock(); - if (sent != -1) { - send_stream_.SetPosition(position + sent); - RTC_LOG(LS_VERBOSE) << "Sent: " << position + sent; - } else { - send_stream_.SetPosition(position); - RTC_LOG(LS_VERBOSE) << "Flow Controlled"; - } - } else { - sent = static_cast(tosend = 0); - } - } while (sent > 0); - } - - private: - int iterations_remaining_; - PseudoTcp* sender_; - PseudoTcp* receiver_; - int bytes_per_send_; -}; - -// Fill the receiver window until it is full, drain it and then -// fill it with the same amount. This is to test that receiver window -// contracts and enlarges correctly. -class PseudoTcpTestReceiveWindow : public PseudoTcpTestBase { - public: - // Not all the data are transfered, `size` just need to be big enough - // to fill up the receiver window twice. - void TestTransfer(int size) { - // Create some dummy data to send. - send_stream_.ReserveSize(size); - for (int i = 0; i < size; ++i) { - uint8_t ch = static_cast(i); - size_t written; - int error; - send_stream_.Write(webrtc::MakeArrayView(&ch, 1), written, error); - } - send_stream_.Rewind(); - - // Prepare the receive stream. - recv_stream_.ReserveSize(size); - - // Connect and wait until connected. - EXPECT_EQ(0, Connect()); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return have_connected_; }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kConnectTimeoutMs)}), - webrtc::IsRtcOk()); - - TaskQueueBase::Current()->PostTask([this] { WriteData(); }); - EXPECT_THAT(webrtc::WaitUntil( - [&] { return have_disconnected_; }, IsTrue(), - {.timeout = webrtc::TimeDelta::Millis(kTransferTimeoutMs)}), - webrtc::IsRtcOk()); - - ASSERT_EQ(2u, send_position_.size()); - ASSERT_EQ(2u, recv_position_.size()); - - const size_t estimated_recv_window = EstimateReceiveWindowSize(); - - // The difference in consecutive send positions should equal the - // receive window size or match very closely. This verifies that receive - // window is open after receiver drained all the data. - const size_t send_position_diff = send_position_[1] - send_position_[0]; - EXPECT_GE(1024u, estimated_recv_window - send_position_diff); - - // Receiver drained the receive window twice. - EXPECT_EQ(2 * estimated_recv_window, recv_position_[1]); - } - - uint32_t EstimateReceiveWindowSize() const { - return static_cast(recv_position_[0]); - } - - uint32_t EstimateSendWindowSize() const { - return static_cast(send_position_[0] - recv_position_[0]); - } - - private: - // IPseudoTcpNotify interface - void OnTcpReadable(PseudoTcp* /* tcp */) override {} - - void OnTcpWriteable(PseudoTcp* /* tcp */) override {} - - void ReadUntilIOPending() { - char block[kBlockSize]; - size_t position; - int received; - - do { - received = remote_.Recv(block, sizeof(block)); - if (received != -1) { - size_t written; - int error; - recv_stream_.Write( - webrtc::MakeArrayView(reinterpret_cast(block), received), - written, error); - recv_stream_.GetPosition(&position); - RTC_LOG(LS_VERBOSE) << "Received: " << position; - } - } while (received > 0); - - recv_stream_.GetPosition(&position); - recv_position_.push_back(position); - - // Disconnect if we have done two transfers. - if (recv_position_.size() == 2u) { - Close(); - OnTcpClosed(&remote_, 0); - } else { - WriteData(); - } - } - - void WriteData() { - size_t position, tosend; - int sent; - char block[kBlockSize]; - do { - send_stream_.GetPosition(&position); - int error; - if (send_stream_.Read( - webrtc::MakeArrayView(reinterpret_cast(block), - sizeof(block)), - tosend, error) != webrtc::SR_EOS) { - sent = local_.Send(block, tosend); - UpdateLocalClock(); - if (sent != -1) { - send_stream_.SetPosition(position + sent); - RTC_LOG(LS_VERBOSE) << "Sent: " << position + sent; - } else { - send_stream_.SetPosition(position); - RTC_LOG(LS_VERBOSE) << "Flow Controlled"; - } - } else { - sent = static_cast(tosend = 0); - } - } while (sent > 0); - // At this point, we've filled up the available space in the send queue. - - if (packets_in_flight_ > 0) { - // If there are packet tasks, attempt to continue sending after giving - // those packets time to process, which should free up the send buffer. - webrtc::Thread::Current()->PostDelayedTask([this] { WriteData(); }, - TimeDelta::Millis(10)); - } else { - if (!remote_.isReceiveBufferFull()) { - RTC_LOG(LS_ERROR) << "This shouldn't happen - the send buffer is full, " - "the receive buffer is not, and there are no " - "remaining messages to process."; - } - send_stream_.GetPosition(&position); - send_position_.push_back(position); - - // Drain the receiver buffer. - ReadUntilIOPending(); - } - } - - private: - webrtc::MemoryStream send_stream_; - webrtc::MemoryStream recv_stream_; - - std::vector send_position_; - std::vector recv_position_; -}; - -// Basic end-to-end data transfer tests - -// Test the normal case of sending data from one side to the other. -TEST_F(PseudoTcpTest, TestSend) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - TestTransfer(1000000); -} - -// Test sending data with a 50 ms RTT. Transmission should take longer due -// to a slower ramp-up in send rate. -TEST_F(PseudoTcpTest, TestSendWithDelay) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetDelay(50); - TestTransfer(1000000); -} - -// Test sending data with packet loss. Transmission should take much longer due -// to send back-off when loss occurs. -TEST_F(PseudoTcpTest, TestSendWithLoss) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetLoss(10); - TestTransfer(100000); // less data so test runs faster -} - -// Test sending data with a 50 ms RTT and 10% packet loss. Transmission should -// take much longer due to send back-off and slower detection of loss. -TEST_F(PseudoTcpTest, TestSendWithDelayAndLoss) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetDelay(50); - SetLoss(10); - TestTransfer(100000); // less data so test runs faster -} - -// Test sending data with 10% packet loss and Nagling disabled. Transmission -// should take about the same time as with Nagling enabled. -TEST_F(PseudoTcpTest, TestSendWithLossAndOptNaglingOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetLoss(10); - SetOptNagling(false); - TestTransfer(100000); // less data so test runs faster -} - -// Regression test for bugs.webrtc.org/9208. -// -// This bug resulted in corrupted data if a "connect" segment was received after -// a data segment. This is only possible if: -// -// * The initial "connect" segment is lost, and retransmitted later. -// * Both sides send "connect"s simultaneously, such that the local side thinks -// a connection is established even before its "connect" has been -// acknowledged. -// * Nagle algorithm disabled, allowing a data segment to be sent before the -// "connect" has been acknowledged. -TEST_F(PseudoTcpTest, - TestSendWhenFirstPacketLostWithOptNaglingOffAndSimultaneousOpen) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - DropNextPacket(); - SetOptNagling(false); - SetSimultaneousOpen(true); - TestTransfer(10000); -} - -// Test sending data with 10% packet loss and Delayed ACK disabled. -// Transmission should be slightly faster than with it enabled. -TEST_F(PseudoTcpTest, TestSendWithLossAndOptAckDelayOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetLoss(10); - SetOptAckDelay(0); - TestTransfer(100000); -} - -// Test sending data with 50ms delay and Nagling disabled. -TEST_F(PseudoTcpTest, TestSendWithDelayAndOptNaglingOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetDelay(50); - SetOptNagling(false); - TestTransfer(100000); // less data so test runs faster -} - -// Test sending data with 50ms delay and Delayed ACK disabled. -TEST_F(PseudoTcpTest, TestSendWithDelayAndOptAckDelayOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetDelay(50); - SetOptAckDelay(0); - TestTransfer(100000); // less data so test runs faster -} - -// Test a large receive buffer with a sender that doesn't support scaling. -TEST_F(PseudoTcpTest, TestSendRemoteNoWindowScale) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetLocalOptRcvBuf(100000); - DisableRemoteWindowScale(); - TestTransfer(1000000); -} - -// Test a large sender-side receive buffer with a receiver that doesn't support -// scaling. -TEST_F(PseudoTcpTest, TestSendLocalNoWindowScale) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetRemoteOptRcvBuf(100000); - DisableLocalWindowScale(); - TestTransfer(1000000); -} - -// Test when both sides use window scaling. -TEST_F(PseudoTcpTest, TestSendBothUseWindowScale) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetRemoteOptRcvBuf(100000); - SetLocalOptRcvBuf(100000); - TestTransfer(1000000); -} - -// Test using a large window scale value. -TEST_F(PseudoTcpTest, TestSendLargeInFlight) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetRemoteOptRcvBuf(100000); - SetLocalOptRcvBuf(100000); - SetOptSndBuf(150000); - TestTransfer(1000000); -} - -TEST_F(PseudoTcpTest, TestSendBothUseLargeWindowScale) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetRemoteOptRcvBuf(1000000); - SetLocalOptRcvBuf(1000000); - TestTransfer(10000000); -} - -// Test using a small receive buffer. -TEST_F(PseudoTcpTest, TestSendSmallReceiveBuffer) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetRemoteOptRcvBuf(10000); - SetLocalOptRcvBuf(10000); - TestTransfer(1000000); -} - -// Test using a very small receive buffer. -TEST_F(PseudoTcpTest, TestSendVerySmallReceiveBuffer) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetRemoteOptRcvBuf(100); - SetLocalOptRcvBuf(100); - TestTransfer(100000); -} - -// Ping-pong (request/response) tests - -// Test sending <= 1x MTU of data in each ping/pong. Should take <10ms. -TEST_F(PseudoTcpTestPingPong, TestPingPong1xMtu) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - TestPingPong(100, 100); -} - -// Test sending 2x-3x MTU of data in each ping/pong. Should take <10ms. -TEST_F(PseudoTcpTestPingPong, TestPingPong3xMtu) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - TestPingPong(400, 100); -} - -// Test sending 1x-2x MTU of data in each ping/pong. -// Should take ~1s, due to interaction between Nagling and Delayed ACK. -TEST_F(PseudoTcpTestPingPong, TestPingPong2xMtu) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - TestPingPong(2000, 5); -} - -// Test sending 1x-2x MTU of data in each ping/pong with Delayed ACK off. -// Should take <10ms. -TEST_F(PseudoTcpTestPingPong, TestPingPong2xMtuWithAckDelayOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetOptAckDelay(0); - TestPingPong(2000, 100); -} - -// Test sending 1x-2x MTU of data in each ping/pong with Nagling off. -// Should take <10ms. -TEST_F(PseudoTcpTestPingPong, TestPingPong2xMtuWithNaglingOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetOptNagling(false); - TestPingPong(2000, 5); -} - -// Test sending a ping as pair of short (non-full) segments. -// Should take ~1s, due to Delayed ACK interaction with Nagling. -TEST_F(PseudoTcpTestPingPong, TestPingPongShortSegments) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetOptAckDelay(5000); - SetBytesPerSend(50); // i.e. two Send calls per payload - TestPingPong(100, 5); -} - -// Test sending ping as a pair of short (non-full) segments, with Nagling off. -// Should take <10ms. -TEST_F(PseudoTcpTestPingPong, TestPingPongShortSegmentsWithNaglingOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetOptNagling(false); - SetBytesPerSend(50); // i.e. two Send calls per payload - TestPingPong(100, 5); -} - -// Test sending <= 1x MTU of data ping/pong, in two segments, no Delayed ACK. -// Should take ~1s. -TEST_F(PseudoTcpTestPingPong, TestPingPongShortSegmentsWithAckDelayOff) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetBytesPerSend(50); // i.e. two Send calls per payload - SetOptAckDelay(0); - TestPingPong(100, 5); -} - -// Test that receive window expands and contract correctly. -TEST_F(PseudoTcpTestReceiveWindow, TestReceiveWindow) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetOptNagling(false); - SetOptAckDelay(0); - TestTransfer(1024 * 1000); -} - -// Test setting send window size to a very small value. -TEST_F(PseudoTcpTestReceiveWindow, TestSetVerySmallSendWindowSize) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetOptNagling(false); - SetOptAckDelay(0); - SetOptSndBuf(900); - TestTransfer(1024 * 1000); - EXPECT_EQ(900u, EstimateSendWindowSize()); -} - -// Test setting receive window size to a value other than default. -TEST_F(PseudoTcpTestReceiveWindow, TestSetReceiveWindowSize) { - SetLocalMtu(1500); - SetRemoteMtu(1500); - SetOptNagling(false); - SetOptAckDelay(0); - SetRemoteOptRcvBuf(100000); - SetLocalOptRcvBuf(100000); - TestTransfer(1024 * 1000); - EXPECT_EQ(100000u, EstimateReceiveWindowSize()); -} - -/* Test sending data with mismatched MTUs. We should detect this and reduce -// our packet size accordingly. -// TODO(?): This doesn't actually work right now. The current code -// doesn't detect if the MTU is set too high on either side. -TEST_F(PseudoTcpTest, TestSendWithMismatchedMtus) { - SetLocalMtu(1500); - SetRemoteMtu(1280); - TestTransfer(1000000); -} -*/ diff --git a/p2p/base/regathering_controller.cc b/p2p/base/regathering_controller.cc index 57575e2948..bbebc60549 100644 --- a/p2p/base/regathering_controller.cc +++ b/p2p/base/regathering_controller.cc @@ -27,7 +27,7 @@ BasicRegatheringController::BasicRegatheringController( RTC_DCHECK(thread_); RTC_DCHECK_RUN_ON(thread_); RTC_DCHECK(ice_transport_); - ice_transport_->SignalStateChanged.connect( + ice_transport_->SignalIceTransportStateChanged.connect( this, &BasicRegatheringController::OnIceTransportStateChanged); ice_transport->SignalWritableState.connect( this, &BasicRegatheringController::OnIceTransportWritableState); diff --git a/p2p/base/regathering_controller_unittest.cc b/p2p/base/regathering_controller_unittest.cc index 33ead46919..51f82148dc 100644 --- a/p2p/base/regathering_controller_unittest.cc +++ b/p2p/base/regathering_controller_unittest.cc @@ -34,17 +34,17 @@ namespace { -const int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN | - webrtc::PORTALLOCATOR_DISABLE_RELAY | - webrtc::PORTALLOCATOR_DISABLE_TCP; +constexpr int kOnlyLocalPorts = webrtc::PORTALLOCATOR_DISABLE_STUN | + webrtc::PORTALLOCATOR_DISABLE_RELAY | + webrtc::PORTALLOCATOR_DISABLE_TCP; // The address of the public STUN server. const webrtc::SocketAddress kStunAddr("99.99.99.1", webrtc::STUN_SERVER_PORT); // The addresses for the public TURN server. const webrtc::SocketAddress kTurnUdpIntAddr("99.99.99.3", webrtc::STUN_SERVER_PORT); const webrtc::RelayCredentials kRelayCredentials("test", "test"); -const char kIceUfrag[] = "UF00"; -const char kIcePwd[] = "TESTICEPWD00000000000000"; +constexpr char kIceUfrag[] = "UF00"; +constexpr char kIcePwd[] = "TESTICEPWD00000000000000"; } // namespace diff --git a/p2p/base/stun_dictionary.h b/p2p/base/stun_dictionary.h index a16d7a9b26..393c41ba0d 100644 --- a/p2p/base/stun_dictionary.h +++ b/p2p/base/stun_dictionary.h @@ -204,13 +204,5 @@ class StunDictionaryWriter { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::StunDictionaryView; -using ::webrtc::StunDictionaryWriter; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_STUN_DICTIONARY_H_ diff --git a/p2p/base/stun_port.cc b/p2p/base/stun_port.cc index d87ed42abb..29d49c67a8 100644 --- a/p2p/base/stun_port.cc +++ b/p2p/base/stun_port.cc @@ -23,6 +23,7 @@ #include "api/async_dns_resolver.h" #include "api/candidate.h" #include "api/field_trials_view.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/transport/stun.h" #include "p2p/base/connection.h" @@ -479,7 +480,7 @@ void UDPPort::SendStunBindingRequest(const SocketAddress& stun_addr) { return; } - // Check if `server_addr_` is compatible with the port's ip. + // Check if `server_addr_` is compatible with the port's ip. if (!IsCompatibleAddress(stun_addr)) { // 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 @@ -495,7 +496,21 @@ void UDPPort::SendStunBindingRequest(const SocketAddress& stun_addr) { static_cast(stun_addr.GetIPAddressType()), static_cast(IPAddressType::kMaxValue)); - request_manager_.Send(new StunBindingRequest(this, stun_addr, TimeMillis())); + MaybeRequestLocalNetworkAccessPermission( + stun_addr, [this, stun_addr](LocalNetworkAccessPermissionStatus status) { + if (status != LocalNetworkAccessPermissionStatus::kGranted) { + RTC_LOG(LS_WARNING) + << ToString() << ": Permission denied to connect to STUN server " + << stun_addr.HostAsSensitiveURIString(); + OnStunBindingOrResolveRequestFailed( + stun_addr, STUN_ERROR_NOT_AN_ERROR, + "Not allowed to connecto to STUN server."); + return; + } + + request_manager_.Send( + new StunBindingRequest(this, stun_addr, TimeMillis())); + }); } bool UDPPort::MaybeSetDefaultLocalAddress(SocketAddress* addr) const { diff --git a/p2p/base/stun_port.h b/p2p/base/stun_port.h index c04e9a18c8..1dc4da71ce 100644 --- a/p2p/base/stun_port.h +++ b/p2p/base/stun_port.h @@ -269,15 +269,5 @@ class StunPort : public UDPPort { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::HIGH_COST_PORT_KEEPALIVE_LIFETIME; -using ::webrtc::INFINITE_LIFETIME; -using ::webrtc::StunPort; -using ::webrtc::UDPPort; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_STUN_PORT_H_ diff --git a/p2p/base/stun_port_unittest.cc b/p2p/base/stun_port_unittest.cc index e59dd92bee..ce28fdda9a 100644 --- a/p2p/base/stun_port_unittest.cc +++ b/p2p/base/stun_port_unittest.cc @@ -16,15 +16,19 @@ #include #include #include +#include #include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/candidate.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/field_trials_view.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/test/mock_async_dns_resolver.h" +#include "api/test/mock_local_network_access_permission.h" #include "api/test/rtc_error_matchers.h" #include "api/transport/stun.h" #include "api/units/time_delta.h" @@ -56,11 +60,12 @@ #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" #include "test/wait_until.h" +namespace webrtc { namespace { using ::testing::_; @@ -70,10 +75,6 @@ using ::testing::IsTrue; using ::testing::Return; using ::testing::ReturnPointee; using ::testing::SetArgPointee; -using ::webrtc::CreateEnvironment; -using ::webrtc::IceCandidateType; -using ::webrtc::ServerAddresses; -using ::webrtc::SocketAddress; const SocketAddress kPrivateIP("192.168.1.12", 0); const SocketAddress kMsdnAddress("unittest-mdns-host-name.local", 0); @@ -94,13 +95,14 @@ const SocketAddress kValidHostnameAddr("valid-hostname", 5000); const SocketAddress kBadHostnameAddr("not-a-real-hostname", 5000); // STUN timeout (with all retries) is webrtc::STUN_TOTAL_TIMEOUT. // Add some margin of error for slow bots. -const int kTimeoutMs = webrtc::STUN_TOTAL_TIMEOUT; +constexpr int kTimeoutMs = webrtc::STUN_TOTAL_TIMEOUT; // stun prio = 100 (srflx) << 24 | 30 (IPv4) << 8 | 256 - 1 (component) -const uint32_t kStunCandidatePriority = (100 << 24) | (30 << 8) | (256 - 1); +constexpr uint32_t kStunCandidatePriority = (100 << 24) | (30 << 8) | (256 - 1); // stun prio = 100 (srflx) << 24 | 40 (IPv6) << 8 | 256 - 1 (component) -const uint32_t kIPv6StunCandidatePriority = (100 << 24) | (40 << 8) | (256 - 1); -const int kInfiniteLifetime = -1; -const int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000; +constexpr uint32_t kIPv6StunCandidatePriority = + (100 << 24) | (40 << 8) | (256 - 1); +constexpr int kInfiniteLifetime = -1; +constexpr int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000; constexpr uint64_t kTiebreakerDefault = 44444; @@ -193,21 +195,26 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { } void CreateStunPort(const webrtc::SocketAddress& server_addr, - const webrtc::FieldTrialsView* field_trials = nullptr) { + const webrtc::FieldTrialsView* field_trials = nullptr, + webrtc::LocalNetworkAccessPermissionFactoryInterface* + lna_permission_factory = nullptr) { ServerAddresses stun_servers; stun_servers.insert(server_addr); - CreateStunPort(stun_servers, field_trials); + CreateStunPort(stun_servers, field_trials, lna_permission_factory); } void CreateStunPort(const ServerAddresses& stun_servers, - const webrtc::FieldTrialsView* field_trials = nullptr) { + const webrtc::FieldTrialsView* field_trials = nullptr, + webrtc::LocalNetworkAccessPermissionFactoryInterface* + lna_permission_factory = nullptr) { stun_port_ = webrtc::StunPort::Create( {.env = CreateEnvironment(field_trials), .network_thread = &thread_, .socket_factory = socket_factory(), .network = network_, .ice_username_fragment = webrtc::CreateRandomString(16), - .ice_password = webrtc::CreateRandomString(22)}, + .ice_password = webrtc::CreateRandomString(22), + .lna_permission_factory = lna_permission_factory}, 0, 0, stun_servers, std::nullopt); stun_port_->SetIceTiebreaker(kTiebreakerDefault); stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_); @@ -276,11 +283,6 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { } protected: - static void SetUpTestSuite() { - // Ensure the RNG is inited. - webrtc::InitRandom(nullptr, 0); - } - void OnPortComplete(webrtc::Port* /* port */) { ASSERT_FALSE(done_); done_ = true; @@ -459,7 +461,7 @@ TEST_F(StunPortWithMockDnsResolverTest, TestPrepareAddressHostname) { TEST_F(StunPortWithMockDnsResolverTest, TestPrepareAddressHostnameWithPriorityAdjustment) { - webrtc::test::ScopedKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-IncreaseIceCandidatePriorityHostSrflx/Enabled/"); SetDnsResolverExpectations( [](webrtc::MockAsyncDnsResolver* resolver, @@ -474,7 +476,7 @@ TEST_F(StunPortWithMockDnsResolverTest, EXPECT_CALL(*resolver_result, GetResolvedAddress(AF_INET, _)) .WillOnce(DoAll(SetArgPointee<1>(kStunServerAddr1), Return(true))); }); - CreateStunPort(kValidHostnameAddr); + CreateStunPort(kValidHostnameAddr, &field_trials); PrepareAddress(); EXPECT_THAT( webrtc::WaitUntil([&] { return done(); }, IsTrue(), @@ -774,6 +776,161 @@ INSTANTIATE_TEST_SUITE_P(All, StunPortIPAddressTypeMetricsTest, ::testing::ValuesIn(kAllIPAddressTypeTestConfigs)); +struct LocalAreaNetworkPermissionTestConfig { + template + friend void AbslStringify( + Sink& sink, + const LocalAreaNetworkPermissionTestConfig& config) { + sink.Append(config.address); + sink.Append("_"); + switch (config.lna_permission_status) { + case webrtc::LocalNetworkAccessPermissionStatus::kDenied: + sink.Append("Denied"); + break; + case webrtc::LocalNetworkAccessPermissionStatus::kGranted: + sink.Append("Granted"); + break; + } + } + + webrtc::LocalNetworkAccessPermissionStatus lna_permission_status; + absl::string_view address; + bool should_succeed; +} kAllLocalAreNetworkPermissionTestConfigs[] = { + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "127.0.0.1", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "10.0.0.3", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "1.1.1.1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "::1", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, + "fd00:4860:4860::8844", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, + "2001:4860:4860::8888", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "127.0.0.1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "10.0.0.3", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "1.1.1.1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "::1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, + "fd00:4860:4860::8844", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, + "2001:4860:4860::8888", + /*should_succeed=*/true}, +}; + +class StunPortLocalNetworkAccessPermissionTest + : public FakeClockBase, + public StunPortTestBase, + public ::testing::WithParamInterface< + LocalAreaNetworkPermissionTestConfig> { + public: + StunPortLocalNetworkAccessPermissionTest() + : StunPortTestBase( + /*address=*/using_ipv6_address() ? kPrivateIPv6.ipaddr() + : kPrivateIP.ipaddr(), + /*stun_server_addresses=*/{{GetParam().address, 5000}}, + /*nat_server_address=*/ + using_ipv6_address() ? kNatAddrIPv6 : kNatAddr), + socket_factory_(ss()) {} + + protected: + webrtc::PacketSocketFactory* socket_factory() override { + return &socket_factory_; + } + + void setup_dns_resolver_mock() { + auto expectations = + [](webrtc::MockAsyncDnsResolver* resolver, + webrtc::MockAsyncDnsResolverResult* resolver_result) { + EXPECT_CALL(*resolver, Start(_, _, _)) + .WillOnce( + [](const webrtc::SocketAddress& /* addr */, int /* family */, + absl::AnyInvocable callback) { callback(); }); + + EXPECT_CALL(*resolver, result) + .WillRepeatedly(ReturnPointee(resolver_result)); + EXPECT_CALL(*resolver_result, GetError).WillOnce(Return(0)); + EXPECT_CALL(*resolver_result, GetResolvedAddress(_, _)) + .WillOnce(DoAll( + SetArgPointee<1>(SocketAddress(GetParam().address, 5000)), + Return(true))); + }; + + socket_factory_.SetExpectations(std::move(expectations)); + } + + private: + bool using_ipv6_address() { + return SocketAddress(GetParam().address, 5000).family() == AF_INET6; + } + + webrtc::MockDnsResolvingPacketSocketFactory socket_factory_; +}; + +TEST_P(StunPortLocalNetworkAccessPermissionTest, ResolvedAddresses) { + webrtc::FakeLocalNetworkAccessPermissionFactory factory( + GetParam().lna_permission_status); + + CreateStunPort({GetParam().address, 5000}, /*field_trials=*/nullptr, + &factory); + + PrepareAddress(); + EXPECT_THAT( + webrtc::WaitUntil([&] { return done(); }, IsTrue(), + {.timeout = webrtc::TimeDelta::Millis(kTimeoutMs), + .clock = &fake_clock}), + webrtc::IsRtcOk()); + + if (GetParam().should_succeed) { + EXPECT_FALSE(error()); + EXPECT_EQ(1U, port()->Candidates().size()); + EXPECT_EQ(0, error_event_.error_code); + } else { + EXPECT_TRUE(error()); + EXPECT_EQ(0U, port()->Candidates().size()); + EXPECT_EQ(0, error_event_.error_code); + } +} + +TEST_P(StunPortLocalNetworkAccessPermissionTest, UnresolvedAddresses) { + setup_dns_resolver_mock(); + + webrtc::FakeLocalNetworkAccessPermissionFactory factory( + GetParam().lna_permission_status); + CreateStunPort({"fakehost.test", 5000}, /*field_trials=*/nullptr, &factory); + + PrepareAddress(); + EXPECT_THAT( + webrtc::WaitUntil([&] { return done(); }, IsTrue(), + {.timeout = webrtc::TimeDelta::Millis(kTimeoutMs), + .clock = &fake_clock}), + webrtc::IsRtcOk()); + + if (GetParam().should_succeed) { + EXPECT_FALSE(error()); + EXPECT_EQ(1U, port()->Candidates().size()); + EXPECT_EQ(0, error_event_.error_code); + } else { + EXPECT_TRUE(error()); + EXPECT_EQ(0U, port()->Candidates().size()); + EXPECT_EQ(0, error_event_.error_code); + } +} + +INSTANTIATE_TEST_SUITE_P( + All, + StunPortLocalNetworkAccessPermissionTest, + ::testing::ValuesIn(kAllLocalAreNetworkPermissionTestConfigs)); + class MockAsyncPacketSocket : public webrtc::AsyncPacketSocket { public: ~MockAsyncPacketSocket() override = default; @@ -972,7 +1129,7 @@ TEST_F(StunIPv6PortTestWithMockDnsResolver, TestPrepareAddressHostname) { // Same as before but with a field trial that changes the priority. TEST_F(StunIPv6PortTestWithMockDnsResolver, TestPrepareAddressHostnameWithPriorityAdjustment) { - webrtc::test::ScopedKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-IncreaseIceCandidatePriorityHostSrflx/Enabled/"); SetDnsResolverExpectations( [](webrtc::MockAsyncDnsResolver* resolver, @@ -1033,3 +1190,4 @@ INSTANTIATE_TEST_SUITE_P(All, ::testing::ValuesIn(kAllIPv6AddressTypeTestConfigs)); } // namespace +} // namespace webrtc diff --git a/p2p/base/stun_request.h b/p2p/base/stun_request.h index 22a252ecc1..8d6a7f56af 100644 --- a/p2p/base/stun_request.h +++ b/p2p/base/stun_request.h @@ -11,9 +11,8 @@ #ifndef P2P_BASE_STUN_REQUEST_H_ #define P2P_BASE_STUN_REQUEST_H_ -#include -#include - +#include +#include #include #include #include @@ -165,15 +164,5 @@ class StunRequest { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::kAllRequestsForTest; -using ::webrtc::STUN_TOTAL_TIMEOUT; -using ::webrtc::StunRequest; -using ::webrtc::StunRequestManager; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_STUN_REQUEST_H_ diff --git a/p2p/base/tcp_port.cc b/p2p/base/tcp_port.cc index 625ff766fd..76fe9c0c86 100644 --- a/p2p/base/tcp_port.cc +++ b/p2p/base/tcp_port.cc @@ -66,8 +66,7 @@ #include "p2p/base/tcp_port.h" -#include - +#include #include #include #include diff --git a/p2p/base/tcp_port.h b/p2p/base/tcp_port.h index 6ea517abe6..2b44dfae1c 100644 --- a/p2p/base/tcp_port.h +++ b/p2p/base/tcp_port.h @@ -201,13 +201,5 @@ class TCPConnection : public Connection, public sigslot::has_slots<> { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TCPConnection; -using ::webrtc::TCPPort; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_TCP_PORT_H_ diff --git a/p2p/base/transport_description.h b/p2p/base/transport_description.h index 7f113e35f3..c92f3500b3 100644 --- a/p2p/base/transport_description.h +++ b/p2p/base/transport_description.h @@ -135,30 +135,5 @@ struct TransportDescription { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ConnectionRole; -using ::webrtc::CONNECTIONROLE_ACTIVE; -using ::webrtc::CONNECTIONROLE_ACTPASS; -using ::webrtc::CONNECTIONROLE_HOLDCONN; -using ::webrtc::CONNECTIONROLE_NONE; -using ::webrtc::CONNECTIONROLE_PASSIVE; -using ::webrtc::ConnectionRoleToString; -using ::webrtc::ICE_OPTION_RENOMINATION; -using ::webrtc::ICE_OPTION_TRICKLE; -using ::webrtc::IceMode; -using ::webrtc::ICEMODE_FULL; -using ::webrtc::ICEMODE_LITE; -using ::webrtc::IceParameters; -using ::webrtc::IceRole; -using ::webrtc::ICEROLE_CONTROLLED; -using ::webrtc::ICEROLE_CONTROLLING; -using ::webrtc::ICEROLE_UNKNOWN; -using ::webrtc::StringToConnectionRole; -using ::webrtc::TransportDescription; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_TRANSPORT_DESCRIPTION_H_ diff --git a/p2p/base/transport_description_factory.cc b/p2p/base/transport_description_factory.cc index 6391e89d0d..7b8663e870 100644 --- a/p2p/base/transport_description_factory.cc +++ b/p2p/base/transport_description_factory.cc @@ -10,8 +10,6 @@ #include "p2p/base/transport_description_factory.h" -#include - #include #include @@ -95,10 +93,10 @@ std::unique_ptr TransportDescriptionFactory::CreateAnswer( // Special affordance for testing: Answer without DTLS params // if we are insecure without a certificate, or if we are // insecure with a non-DTLS offer. - if ((!certificate_ || !offer->identity_fingerprint.get()) && insecure()) { + if ((!certificate_ || !offer->identity_fingerprint) && insecure()) { return desc; } - if (!offer->identity_fingerprint.get()) { + if (!offer->identity_fingerprint) { if (require_transport_attributes) { // We require DTLS, but the other side didn't offer it. Fail. RTC_LOG(LS_WARNING) << "Failed to create TransportDescription answer " diff --git a/p2p/base/transport_description_factory.h b/p2p/base/transport_description_factory.h index b1a7cc956b..cdd55347f8 100644 --- a/p2p/base/transport_description_factory.h +++ b/p2p/base/transport_description_factory.h @@ -19,7 +19,6 @@ #include "p2p/base/ice_credentials_iterator.h" #include "p2p/base/transport_description.h" #include "rtc_base/rtc_certificate.h" -#include "rtc_base/ssl_identity.h" namespace webrtc { @@ -88,13 +87,5 @@ class TransportDescriptionFactory { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TransportDescriptionFactory; -using ::webrtc::TransportOptions; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_TRANSPORT_DESCRIPTION_FACTORY_H_ diff --git a/p2p/base/transport_description_factory_unittest.cc b/p2p/base/transport_description_factory_unittest.cc index fe081185ce..37b0c53276 100644 --- a/p2p/base/transport_description_factory_unittest.cc +++ b/p2p/base/transport_description_factory_unittest.cc @@ -10,13 +10,13 @@ #include "p2p/base/transport_description_factory.h" -#include - +#include #include #include #include #include "absl/strings/string_view.h" +#include "api/field_trials.h" #include "api/scoped_refptr.h" #include "p2p/base/ice_credentials_iterator.h" #include "p2p/base/p2p_constants.h" @@ -27,21 +27,22 @@ #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_fingerprint.h" #include "rtc_base/ssl_identity.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" + +namespace webrtc { +namespace { using ::testing::Contains; using ::testing::Not; using ::testing::NotNull; -using ::webrtc::TransportDescription; -using ::webrtc::TransportDescriptionFactory; -using ::webrtc::TransportOptions; class TransportDescriptionFactoryTest : public ::testing::Test { public: TransportDescriptionFactoryTest() - : ice_credentials_({}), + : field_trials_(CreateTestFieldTrials()), + ice_credentials_({}), f1_(field_trials_), f2_(field_trials_), cert1_( @@ -143,12 +144,12 @@ class TransportDescriptionFactoryTest : public ::testing::Test { // The initial offer / answer exchange. std::unique_ptr offer = f1_.CreateOffer(options, nullptr, &ice_credentials_); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); EXPECT_THAT(offer->transport_options, Not(Contains("renomination"))); std::unique_ptr answer = f2_.CreateAnswer( offer.get(), options, true, nullptr, &ice_credentials_); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); EXPECT_THAT(answer->transport_options, Not(Contains("renomination"))); options.enable_ice_renomination = true; @@ -179,7 +180,7 @@ class TransportDescriptionFactoryTest : public ::testing::Test { f2_.set_certificate(nullptr); } - webrtc::test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_; webrtc::IceCredentialsIterator ice_credentials_; TransportDescriptionFactory f1_; TransportDescriptionFactory f2_; @@ -399,3 +400,6 @@ TEST_F(TransportDescriptionFactoryTest, CreateAnswerToDtlsPassiveOffer) { f2_.CreateAnswer(offer.get(), options, false, nullptr, &ice_credentials_); EXPECT_EQ(answer->connection_role, webrtc::CONNECTIONROLE_ACTIVE); } + +} // namespace +} // namespace webrtc diff --git a/p2p/base/transport_info.h b/p2p/base/transport_info.h index 54689b5d1d..da47946a1d 100644 --- a/p2p/base/transport_info.h +++ b/p2p/base/transport_info.h @@ -36,13 +36,5 @@ typedef std::vector TransportInfos; } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TransportInfo; -using ::webrtc::TransportInfos; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_TRANSPORT_INFO_H_ diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc index 01580b8bf7..72f449d78e 100644 --- a/p2p/base/turn_port.cc +++ b/p2p/base/turn_port.cc @@ -25,6 +25,7 @@ #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/candidate.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/scoped_refptr.h" #include "api/task_queue/pending_task_safety_flag.h" @@ -367,7 +368,7 @@ void TurnPort::PrepareAddress() { << ": Attempt to start allocation with disallowed port# " << server_address_.address.port(); OnAllocateError(STUN_ERROR_SERVER_ERROR, - "Attempt to start allocation to a disallowed port"); + "Attempt to start allocation to a disallowed port."); return; } @@ -392,6 +393,24 @@ void TurnPort::PrepareAddress() { static_cast(server_address_.address.GetIPAddressType()), static_cast(IPAddressType::kMaxValue)); + MaybeRequestLocalNetworkAccessPermission( + server_address_.address, + [this](LocalNetworkAccessPermissionStatus status) { + if (status != LocalNetworkAccessPermissionStatus::kGranted) { + RTC_LOG(LS_ERROR) + << ToString() << ": Permission denied to connect to TURN server " + << server_address_.address.HostAsSensitiveURIString(); + OnAllocateError(STUN_ERROR_NOT_AN_ERROR, + "Attempt to start allocation without Local Network " + "Access Permission."); + return; + } + + OnLocalNetworkAccessPermissionGranted(); + }); +} + +void TurnPort::OnLocalNetworkAccessPermissionGranted() { // Insert the current address to prevent redirection pingpong. attempted_server_addresses_.insert(server_address_.address); @@ -1411,13 +1430,16 @@ void TurnAllocateRequest::OnErrorResponse(StunMessage* response) { port->thread()->PostTask(SafeTask( port->task_safety_.flag(), [port] { port->OnAllocateMismatch(); })); } break; - default: - RTC_LOG(LS_WARNING) << port_->ToString() - << ": Received TURN allocate error response, id=" - << hex_encode(id()) << ", code=" << error_code - << ", rtt=" << Elapsed(); + default: { const StunErrorCodeAttribute* attr = response->GetErrorCode(); - port_->OnAllocateError(error_code, attr ? attr->reason() : ""); + RTC_LOG(LS_WARNING) << port_->ToString() + << ": Received TURN allocate error response" + << ", id=" << hex_encode(id()) + << ", code=" << error_code << ", rtt=" << Elapsed() + << ", reason='" << (attr ? attr->reason() : "") + << "'"; + port_->OnAllocateError(error_code, "TURN allocate error."); + } break; } } @@ -1430,11 +1452,12 @@ void TurnAllocateRequest::OnTimeout() { void TurnAllocateRequest::OnAuthChallenge(StunMessage* response, int code) { // If we failed to authenticate even after we sent our credentials, fail hard. if (code == STUN_ERROR_UNAUTHORIZED && !port_->hash().empty()) { + const StunErrorCodeAttribute* attr = response->GetErrorCode(); RTC_LOG(LS_WARNING) << port_->ToString() << ": Failed to authenticate with the server " - "after challenge."; - const StunErrorCodeAttribute* attr = response->GetErrorCode(); - port_->OnAllocateError(STUN_ERROR_UNAUTHORIZED, attr ? attr->reason() : ""); + "after challenge, reason='" + << (attr ? attr->reason() : "") << "'"; + port_->OnAllocateError(STUN_ERROR_UNAUTHORIZED, "Unauthorized."); return; } @@ -1467,21 +1490,22 @@ void TurnAllocateRequest::OnTryAlternate(StunMessage* response, int code) { // According to RFC 5389 section 11, there are use cases where // authentication of response is not possible, we're not validating // message integrity. - const StunErrorCodeAttribute* error_code_attr = response->GetErrorCode(); // Get the alternate server address attribute value. const StunAddressAttribute* alternate_server_attr = response->GetAddress(STUN_ATTR_ALTERNATE_SERVER); if (!alternate_server_attr) { + const StunErrorCodeAttribute* attr = response->GetErrorCode(); RTC_LOG(LS_WARNING) << port_->ToString() << ": Missing STUN_ATTR_ALTERNATE_SERVER " - "attribute in try alternate error response"; + "attribute in try alternate error response, reason='" + << (attr ? attr->reason() : "") << "'"; port_->OnAllocateError(STUN_ERROR_TRY_ALTERNATE, - error_code_attr ? error_code_attr->reason() : ""); + "Missing alternate server attribute."); return; } if (!port_->SetAlternateServer(alternate_server_attr->GetAddress())) { port_->OnAllocateError(STUN_ERROR_TRY_ALTERNATE, - error_code_attr ? error_code_attr->reason() : ""); + "Failed to set alternate server."); return; } diff --git a/p2p/base/turn_port.h b/p2p/base/turn_port.h index 794e4a41ad..c74feae432 100644 --- a/p2p/base/turn_port.h +++ b/p2p/base/turn_port.h @@ -11,8 +11,7 @@ #ifndef P2P_BASE_TURN_PORT_H_ #define P2P_BASE_TURN_PORT_H_ -#include - +#include #include #include #include @@ -93,7 +92,8 @@ class TurnPort : public Port { .socket_factory = args.socket_factory, .network = args.network, .ice_username_fragment = args.username, - .ice_password = args.password}, + .ice_password = args.password, + .lna_permission_factory = args.lna_permission_factory}, socket, *args.server_address, args.config->credentials, args.relative_priority, args.config->tls_alpn_protocols, args.config->tls_elliptic_curves, args.turn_customizer, @@ -115,7 +115,8 @@ class TurnPort : public Port { .socket_factory = args.socket_factory, .network = args.network, .ice_username_fragment = args.username, - .ice_password = args.password}, + .ice_password = args.password, + .lna_permission_factory = args.lna_permission_factory}, min_port, max_port, *args.server_address, args.config->credentials, args.relative_priority, args.config->tls_alpn_protocols, args.config->tls_elliptic_curves, args.turn_customizer, @@ -259,6 +260,7 @@ class TurnPort : public Port { bool SetAlternateServer(const SocketAddress& address); void ResolveTurnAddress(const SocketAddress& address); void OnResolveResult(const AsyncDnsResolverResult& result); + void OnLocalNetworkAccessPermissionGranted(); void AddRequestAuthInfo(StunMessage* msg); void OnSendStunPacket(const void* data, size_t size, StunRequest* request); @@ -368,12 +370,5 @@ class TurnPort : public Port { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TurnPort; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_TURN_PORT_H_ diff --git a/p2p/base/turn_port_unittest.cc b/p2p/base/turn_port_unittest.cc index c5da027d43..d0c7124ef0 100644 --- a/p2p/base/turn_port_unittest.cc +++ b/p2p/base/turn_port_unittest.cc @@ -7,69 +7,70 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ +#include "p2p/base/turn_port.h" + #include #include +#include +#include +#include #include +#include +#include #include "absl/functional/any_invocable.h" +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/candidate.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/test/mock_async_dns_resolver.h" +#include "api/test/mock_local_network_access_permission.h" #include "api/test/rtc_error_matchers.h" #include "api/transport/stun.h" -#include "p2p/base/connection_info.h" -#include "p2p/base/port.h" -#include "p2p/base/port_interface.h" -#include "p2p/base/stun_request.h" -#include "p2p/client/relay_port_factory_interface.h" -#include "rtc_base/async_packet_socket.h" -#include "rtc_base/ip_address.h" -#include "rtc_base/net_helpers.h" -#include "rtc_base/network.h" -#include "rtc_base/network/received_packet.h" -#include "rtc_base/third_party/sigslot/sigslot.h" -#include "system_wrappers/include/metrics.h" -#include "test/gmock.h" -#include "test/wait_until.h" -#if defined(WEBRTC_POSIX) -#include // IWYU pragma: keep - -#include "absl/strings/string_view.h" -#endif - -#include -#include -#include -#include -#include - #include "api/units/time_delta.h" #include "p2p/base/basic_packet_socket_factory.h" #include "p2p/base/connection.h" +#include "p2p/base/connection_info.h" #include "p2p/base/p2p_constants.h" +#include "p2p/base/port.h" #include "p2p/base/port_allocator.h" +#include "p2p/base/port_interface.h" #include "p2p/base/stun_port.h" +#include "p2p/base/stun_request.h" #include "p2p/base/transport_description.h" -#include "p2p/base/turn_port.h" +#include "p2p/client/relay_port_factory_interface.h" #include "p2p/test/mock_dns_resolving_packet_socket_factory.h" #include "p2p/test/test_turn_customizer.h" #include "p2p/test/test_turn_server.h" #include "p2p/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" #include "rtc_base/fake_clock.h" #include "rtc_base/gunit.h" +#include "rtc_base/ip_address.h" #include "rtc_base/net_helper.h" +#include "rtc_base/net_helpers.h" +#include "rtc_base/network.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" +#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" +#include "system_wrappers/include/metrics.h" +#include "test/gmock.h" #include "test/gtest.h" +#include "test/wait_until.h" + +#if defined(WEBRTC_POSIX) +#include // IWYU pragma: keep +#endif namespace { using ::testing::_; @@ -111,13 +112,13 @@ const SocketAddress kTurnUdpIPv6IntAddr("2400:4030:1:2c00:be30:abcd:efab:cdef", const SocketAddress kTurnInvalidAddr("www.google.invalid.", 3478); const SocketAddress kTurnValidAddr("www.google.valid.", 3478); -const char kCandidateFoundation[] = "foundation"; -const char kIceUfrag1[] = "TESTICEUFRAG0001"; -const char kIceUfrag2[] = "TESTICEUFRAG0002"; -const char kIcePwd1[] = "TESTICEPWD00000000000001"; -const char kIcePwd2[] = "TESTICEPWD00000000000002"; -const char kTurnUsername[] = "test"; -const char kTurnPassword[] = "test"; +constexpr char kCandidateFoundation[] = "foundation"; +constexpr char kIceUfrag1[] = "TESTICEUFRAG0001"; +constexpr char kIceUfrag2[] = "TESTICEUFRAG0002"; +constexpr char kIcePwd1[] = "TESTICEPWD00000000000001"; +constexpr char kIcePwd2[] = "TESTICEPWD00000000000002"; +constexpr char kTurnUsername[] = "test"; +constexpr char kTurnPassword[] = "test"; // This test configures the virtual socket server to simulate delay so that we // can verify operations take no more than the expected number of round trips. constexpr unsigned int kSimulatedRtt = 50; @@ -280,9 +281,12 @@ class TurnPortTest : public ::testing::Test, bool CreateTurnPort(const SocketAddress& local_address, absl::string_view username, absl::string_view password, - const ProtocolAddress& server_address) { + const ProtocolAddress& server_address, + LocalNetworkAccessPermissionFactoryInterface* + lna_permission_factory = nullptr) { return CreateTurnPortWithAllParams(MakeNetwork(local_address), username, - password, server_address); + password, server_address, + lna_permission_factory); } bool CreateTurnPortWithNetwork(const Network* network, @@ -299,7 +303,9 @@ class TurnPortTest : public ::testing::Test, bool CreateTurnPortWithAllParams(const Network* network, absl::string_view username, absl::string_view password, - const ProtocolAddress& server_address) { + const ProtocolAddress& server_address, + LocalNetworkAccessPermissionFactoryInterface* + lna_permission_factory = nullptr) { RelayServerConfig config; config.credentials = RelayCredentials(username, password); CreateRelayPortArgs args = {.env = env_}; @@ -311,6 +317,7 @@ class TurnPortTest : public ::testing::Test, args.server_address = &server_address; args.config = &config; args.turn_customizer = turn_customizer_.get(); + args.lna_permission_factory = lna_permission_factory; turn_port_ = TurnPort::Create(args, 0, 0); if (!turn_port_) { @@ -1051,7 +1058,7 @@ TEST_F(TurnPortTest, TestTurnBadCredentials) { {.timeout = TimeDelta::Millis(kSimulatedRtt * 3), .clock = &fake_clock_}), IsRtcOk()); - EXPECT_EQ(error_event_.error_text, "Unauthorized"); + EXPECT_EQ(error_event_.error_text, "Unauthorized."); } // Test that we fail without emitting an error if we try to get an address from @@ -2238,4 +2245,150 @@ INSTANTIATE_TEST_SUITE_P(All, TurnPortIPAddressTypeMetricsTest, ::testing::ValuesIn(kAllIPAddressTypeTestConfigs)); +struct LocalAreaNetworkPermissionTestConfig { + template + friend void AbslStringify( + Sink& sink, + const LocalAreaNetworkPermissionTestConfig& config) { + sink.Append(config.address); + sink.Append("_"); + switch (config.lna_permission_status) { + case webrtc::LocalNetworkAccessPermissionStatus::kDenied: + sink.Append("Denied"); + break; + case webrtc::LocalNetworkAccessPermissionStatus::kGranted: + sink.Append("Granted"); + break; + } + } + + webrtc::LocalNetworkAccessPermissionStatus lna_permission_status; + absl::string_view address; + bool should_succeed; +} kAllLocalAreNetworkPermissionTestConfigs[] = { + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "127.0.0.1", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "10.0.0.3", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "1.1.1.1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, "::1", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, + "fd00:4860:4860::8844", + /*should_succeed=*/false}, + {webrtc::LocalNetworkAccessPermissionStatus::kDenied, + "2001:4860:4860::8888", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "127.0.0.1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "10.0.0.3", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "1.1.1.1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, "::1", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, + "fd00:4860:4860::8844", + /*should_succeed=*/true}, + {webrtc::LocalNetworkAccessPermissionStatus::kGranted, + "2001:4860:4860::8888", + /*should_succeed=*/true}, +}; + +class TurnPortLocalNetworkAccessPermissionTest + : public TurnPortWithMockDnsResolverTest, + public ::testing::WithParamInterface< + LocalAreaNetworkPermissionTestConfig> { + protected: + void CreateTurnPort( + absl::string_view address, + LocalNetworkAccessPermissionFactoryInterface* lna_permission_factory) { + ProtocolAddress server_address({address, 5000}, PROTO_UDP); + + // Use the test's address instead of `server_address` because + // `server_address` might not be a resolved address with an unknown family. + SocketAddress local_address = + SocketAddress(GetParam().address, 5000).family() == AF_INET6 + ? kLocalIPv6Addr + : kLocalAddr1; + TurnPortWithMockDnsResolverTest::CreateTurnPort( + local_address, kTurnUsername, kTurnPassword, server_address, + lna_permission_factory); + } + + void setup_dns_resolver_mock() { + auto expectations = + [](webrtc::MockAsyncDnsResolver* resolver, + webrtc::MockAsyncDnsResolverResult* resolver_result) { + EXPECT_CALL(*resolver, Start(_, _, _)) + .WillOnce( + [](const webrtc::SocketAddress& /* addr */, int /* family */, + absl::AnyInvocable callback) { callback(); }); + + EXPECT_CALL(*resolver, result) + .WillRepeatedly(ReturnPointee(resolver_result)); + EXPECT_CALL(*resolver_result, GetError).WillRepeatedly(Return(0)); + EXPECT_CALL(*resolver_result, GetResolvedAddress(_, _)) + .WillOnce(DoAll( + SetArgPointee<1>(SocketAddress(GetParam().address, 5000)), + Return(true))); + }; + + SetDnsResolverExpectations(std::move(expectations)); + } +}; + +TEST_P(TurnPortLocalNetworkAccessPermissionTest, ResolvedAddresses) { + turn_server_.AddInternalSocket({GetParam().address, 5000}, PROTO_UDP); + + FakeLocalNetworkAccessPermissionFactory factory( + GetParam().lna_permission_status); + CreateTurnPort(GetParam().address, &factory); + turn_port_->PrepareAddress(); + + if (GetParam().should_succeed) { + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), + {.clock = &fake_clock_}), + IsRtcOk()); + EXPECT_EQ(1u, turn_port_->Candidates().size()); + EXPECT_NE(SOCKET_ERROR, turn_port_->error()); + } else { + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), + {.clock = &fake_clock_}), + IsRtcOk()); + EXPECT_EQ(0u, turn_port_->Candidates().size()); + EXPECT_NE(SOCKET_ERROR, turn_port_->error()); + } +} + +TEST_P(TurnPortLocalNetworkAccessPermissionTest, UnresolvedAddresses) { + turn_server_.AddInternalSocket({GetParam().address, 5000}, PROTO_UDP); + setup_dns_resolver_mock(); + + FakeLocalNetworkAccessPermissionFactory factory( + GetParam().lna_permission_status); + CreateTurnPort("fakehost.test", &factory); + turn_port_->PrepareAddress(); + + if (GetParam().should_succeed) { + EXPECT_THAT(WaitUntil([&] { return turn_ready_; }, IsTrue(), + {.clock = &fake_clock_}), + IsRtcOk()); + EXPECT_EQ(1u, turn_port_->Candidates().size()); + EXPECT_NE(SOCKET_ERROR, turn_port_->error()); + } else { + EXPECT_THAT(WaitUntil([&] { return turn_error_; }, IsTrue(), + {.clock = &fake_clock_}), + IsRtcOk()); + EXPECT_EQ(0u, turn_port_->Candidates().size()); + EXPECT_NE(SOCKET_ERROR, turn_port_->error()); + } +} + +INSTANTIATE_TEST_SUITE_P( + All, + TurnPortLocalNetworkAccessPermissionTest, + ::testing::ValuesIn(kAllLocalAreNetworkPermissionTestConfigs)); + } // namespace webrtc diff --git a/p2p/base/wrapping_active_ice_controller.h b/p2p/base/wrapping_active_ice_controller.h index 63a5836f27..44446ab6fc 100644 --- a/p2p/base/wrapping_active_ice_controller.h +++ b/p2p/base/wrapping_active_ice_controller.h @@ -93,12 +93,5 @@ class WrappingActiveIceController : public ActiveIceControllerInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::WrappingActiveIceController; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_BASE_WRAPPING_ACTIVE_ICE_CONTROLLER_H_ diff --git a/p2p/base/wrapping_active_ice_controller_unittest.cc b/p2p/base/wrapping_active_ice_controller_unittest.cc index 113e6b6574..df313766d6 100644 --- a/p2p/base/wrapping_active_ice_controller_unittest.cc +++ b/p2p/base/wrapping_active_ice_controller_unittest.cc @@ -67,7 +67,7 @@ const Connection* kConnectionThree = const std::vector kEmptyConnsList = std::vector(); -const TimeDelta kTick = TimeDelta::Millis(1); +constexpr TimeDelta kTick = TimeDelta::Millis(1); TEST(WrappingActiveIceControllerTest, CreateLegacyIceControllerFromFactory) { AutoThread main; diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc index cf370d9ad9..babe2265d8 100644 --- a/p2p/client/basic_port_allocator.cc +++ b/p2p/client/basic_port_allocator.cc @@ -28,6 +28,7 @@ #include "api/candidate.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" @@ -42,7 +43,6 @@ #include "p2p/client/relay_port_factory_interface.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/checks.h" -#include "rtc_base/crypto_random.h" #include "rtc_base/ip_address.h" #include "rtc_base/logging.h" #include "rtc_base/net_helper.h" @@ -182,11 +182,14 @@ BasicPortAllocator::BasicPortAllocator( NetworkManager* absl_nonnull network_manager, PacketSocketFactory* absl_nonnull socket_factory, TurnCustomizer* absl_nullable turn_customizer, - RelayPortFactoryInterface* absl_nullable relay_port_factory) + RelayPortFactoryInterface* absl_nullable relay_port_factory, + std::unique_ptr absl_nullable + lna_permission_factory) : env_(env), network_manager_(network_manager), socket_factory_(socket_factory), - relay_port_factory_(relay_port_factory) { + relay_port_factory_(relay_port_factory), + lna_permission_factory_(std::move(lna_permission_factory)) { RTC_CHECK(socket_factory_); RTC_DCHECK(network_manager_); SetConfiguration(ServerAddresses(), std::vector(), 0, @@ -1457,7 +1460,9 @@ void AllocationSequence::CreateUDPPorts() { .socket_factory = session_->socket_factory(), .network = network_, .ice_username_fragment = session_->username(), - .ice_password = session_->password()}, + .ice_password = session_->password(), + .lna_permission_factory = + session_->allocator()->lna_permission_factory()}, udp_socket_.get(), emit_local_candidate_for_anyaddress, session_->allocator()->stun_candidate_keepalive_interval()); } else { @@ -1467,7 +1472,9 @@ void AllocationSequence::CreateUDPPorts() { .socket_factory = session_->socket_factory(), .network = network_, .ice_username_fragment = session_->username(), - .ice_password = session_->password()}, + .ice_password = session_->password(), + .lna_permission_factory = + session_->allocator()->lna_permission_factory()}, session_->allocator()->min_port(), session_->allocator()->max_port(), emit_local_candidate_for_anyaddress, session_->allocator()->stun_candidate_keepalive_interval()); @@ -1542,7 +1549,9 @@ void AllocationSequence::CreateStunPorts() { .socket_factory = session_->socket_factory(), .network = network_, .ice_username_fragment = session_->username(), - .ice_password = session_->password()}, + .ice_password = session_->password(), + .lna_permission_factory = + session_->allocator()->lna_permission_factory()}, session_->allocator()->min_port(), session_->allocator()->max_port(), config_->StunServers(), session_->allocator()->stun_candidate_keepalive_interval()); @@ -1614,6 +1623,8 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config, args.config = &config; args.turn_customizer = session_->allocator()->turn_customizer(); args.relative_priority = relative_priority; + args.lna_permission_factory = + session_->allocator()->lna_permission_factory(); std::unique_ptr port; // Shared socket mode must be enabled only for UDP based ports. Hence diff --git a/p2p/client/basic_port_allocator.h b/p2p/client/basic_port_allocator.h index 01d118a33b..6a275ec4ab 100644 --- a/p2p/client/basic_port_allocator.h +++ b/p2p/client/basic_port_allocator.h @@ -24,6 +24,7 @@ #include "api/candidate.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/transport/enums.h" @@ -55,7 +56,9 @@ class RTC_EXPORT BasicPortAllocator : public PortAllocator { NetworkManager* absl_nonnull network_manager, PacketSocketFactory* absl_nonnull socket_factory, TurnCustomizer* absl_nullable turn_customizer = nullptr, - RelayPortFactoryInterface* absl_nullable relay_port_factory = nullptr); + RelayPortFactoryInterface* absl_nullable relay_port_factory = nullptr, + std::unique_ptr + absl_nullable lna_permission_factory = nullptr); BasicPortAllocator(const BasicPortAllocator&) = delete; BasicPortAllocator& operator=(const BasicPortAllocator&) = delete; @@ -78,6 +81,11 @@ class RTC_EXPORT BasicPortAllocator : public PortAllocator { return socket_factory_; } + LocalNetworkAccessPermissionFactoryInterface* lna_permission_factory() { + CheckRunOnValidThreadIfInitialized(); + return lna_permission_factory_.get(); + } + PortAllocatorSession* CreateSessionInternal( absl::string_view content_name, int component, @@ -107,6 +115,9 @@ class RTC_EXPORT BasicPortAllocator : public PortAllocator { AlwaysValidPointer relay_port_factory_; + + std::unique_ptr + lna_permission_factory_; }; struct PortConfiguration; @@ -416,16 +427,5 @@ class AllocationSequence { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::AllocationSequence; -using ::webrtc::BasicPortAllocator; -using ::webrtc::BasicPortAllocatorSession; -using ::webrtc::PortConfiguration; -using ::webrtc::SessionState; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_CLIENT_BASIC_PORT_ALLOCATOR_H_ diff --git a/p2p/client/basic_port_allocator_unittest.cc b/p2p/client/basic_port_allocator_unittest.cc index c8e5464593..f6ac9f8c94 100644 --- a/p2p/client/basic_port_allocator_unittest.cc +++ b/p2p/client/basic_port_allocator_unittest.cc @@ -23,6 +23,7 @@ #include "api/candidate.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/test/rtc_error_matchers.h" #include "api/transport/enums.h" #include "api/units/time_delta.h" @@ -56,9 +57,9 @@ #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" #include "test/wait_until.h" using ::testing::Contains; @@ -1272,7 +1273,7 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) { TEST_F(BasicPortAllocatorTest, TestSetupVideoRtpPortsWithNormalSendBuffers) { AddInterface(kClientAddr); - ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP, CN_VIDEO)); + ASSERT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP, "video")); session_->StartGettingPorts(); ASSERT_THAT( WaitUntil([&] { return candidate_allocation_done_; }, IsTrue(), @@ -2727,8 +2728,8 @@ TEST_F(BasicPortAllocatorTest, TestUseTurnServerAsStunSever) { } TEST_F(BasicPortAllocatorTest, TestDoNotUseTurnServerAsStunSever) { - test::ScopedKeyValueConfig field_trials( - "WebRTC-UseTurnServerAsStunServer/Disabled/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-UseTurnServerAsStunServer/Disabled/"); ServerAddresses stun_servers; stun_servers.insert(kStunAddr); PortConfiguration port_config(stun_servers, "" /* user_name */, diff --git a/p2p/client/relay_port_factory_interface.h b/p2p/client/relay_port_factory_interface.h index 3d5106d2f2..63b7c8bd77 100644 --- a/p2p/client/relay_port_factory_interface.h +++ b/p2p/client/relay_port_factory_interface.h @@ -15,6 +15,7 @@ #include #include "api/environment/environment.h" +#include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "p2p/base/port.h" #include "p2p/base/port_allocator.h" @@ -44,6 +45,8 @@ struct CreateRelayPortArgs { // to the candidates from other servers. Required because ICE priorities // need to be unique. int relative_priority = 0; + LocalNetworkAccessPermissionFactoryInterface* lna_permission_factory = + nullptr; }; // A factory for creating RelayPort's. @@ -64,13 +67,5 @@ class RelayPortFactoryInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CreateRelayPortArgs; -using ::webrtc::RelayPortFactoryInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_CLIENT_RELAY_PORT_FACTORY_INTERFACE_H_ diff --git a/p2p/client/turn_port_factory.h b/p2p/client/turn_port_factory.h index e1c33c13e0..a63f7aacbc 100644 --- a/p2p/client/turn_port_factory.h +++ b/p2p/client/turn_port_factory.h @@ -34,12 +34,5 @@ class TurnPortFactory : public RelayPortFactoryInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TurnPortFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_CLIENT_TURN_PORT_FACTORY_H_ diff --git a/p2p/dtls/dtls_ice_integrationtest.cc b/p2p/dtls/dtls_ice_integrationtest.cc index 536b89ea78..1e42998d4f 100644 --- a/p2p/dtls/dtls_ice_integrationtest.cc +++ b/p2p/dtls/dtls_ice_integrationtest.cc @@ -48,6 +48,7 @@ #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/wait_until.h" @@ -81,7 +82,7 @@ class DtlsIceIntegrationTest : public ::testing::TestWithParam #include #include +#include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" +#include "api/array_view.h" #include "api/transport/stun.h" #include "rtc_base/checks.h" @@ -29,16 +32,17 @@ class DtlsStunPiggybackCallbacks { // Function invoked when sending a `request-type` (e.g. // STUN_BINDING_REQUEST). Returns a pair of data that will be sent: // - an optional DTLS_IN_STUN attribute - // - an optional DTLS_IN_STUN_ACK attribute + // - an optional std::vector for the DTLS_IN_STUN_ACK attribute absl::AnyInvocable, - std::optional>( + std::optional>>( /* request-type */ StunMessageType)>&& send_data, // Function invoked when receiving a STUN_BINDING { REQUEST / RESPONSE } - // contains the (nullable) DTLS_IN_STUN and DTLS_IN_STUN_ACK attributes. + // contains the optional ArrayView of the DTLS_IN_STUN attribute and the + // optional uint32_t vector DTLS_IN_STUN_ACK attribute. absl::AnyInvocable&& recv_data) + std::optional> /* recv_data */, + std::optional> /* recv_acks */)>&& recv_data) : send_data_(std::move(send_data)), recv_data_(std::move(recv_data)) { RTC_DCHECK( // either all set @@ -47,16 +51,17 @@ class DtlsStunPiggybackCallbacks { (send_data_ == nullptr && recv_data_ == nullptr)); } - std::pair, std::optional> + std::pair, + std::optional>> send_data(StunMessageType request_type) { RTC_DCHECK(send_data_); return send_data_(request_type); } - void recv_data(const StunByteStringAttribute* data, - const StunByteStringAttribute* ack) { + void recv_data(std::optional> data, + std::optional> acks) { RTC_DCHECK(recv_data_); - return recv_data_(data, ack); + return recv_data_(data, acks); } bool empty() const { return send_data_ == nullptr; } @@ -67,23 +72,15 @@ class DtlsStunPiggybackCallbacks { private: absl::AnyInvocable, - std::optional>( + std::optional>>( /* request-type */ StunMessageType)> send_data_; - absl::AnyInvocable + absl::AnyInvocable> /* recv_data */, + std::optional> /* recv_acks */)> recv_data_; }; } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::DtlsStunPiggybackCallbacks; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_DTLS_DTLS_STUN_PIGGYBACK_CALLBACKS_H_ diff --git a/p2p/dtls/dtls_stun_piggyback_controller.cc b/p2p/dtls/dtls_stun_piggyback_controller.cc index 4cc5ffc612..7fdeb73c4b 100644 --- a/p2p/dtls/dtls_stun_piggyback_controller.cc +++ b/p2p/dtls/dtls_stun_piggyback_controller.cc @@ -23,7 +23,6 @@ #include "api/sequence_checker.h" #include "api/transport/stun.h" #include "p2p/dtls/dtls_utils.h" -#include "rtc_base/byte_buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/str_join.h" @@ -128,19 +127,20 @@ DtlsStunPiggybackController::GetDataToPiggyback( packet.size()); } -std::optional DtlsStunPiggybackController::GetAckToPiggyback( +std::optional> +DtlsStunPiggybackController::GetAckToPiggyback( StunMessageType stun_message_type) { RTC_DCHECK_RUN_ON(&sequence_checker_); if (state_ == State::OFF || state_ == State::COMPLETE) { return std::nullopt; } - return handshake_ack_writer_.DataAsStringView(); + return handshake_messages_received_; } void DtlsStunPiggybackController::ReportDataPiggybacked( - const StunByteStringAttribute* data, - const StunByteStringAttribute* ack) { + std::optional> data, + std::optional> acks) { RTC_DCHECK_RUN_ON(&sequence_checker_); // Drop silently when receiving acked data when the peer previously did not @@ -152,7 +152,7 @@ void DtlsStunPiggybackController::ReportDataPiggybacked( // We sent dtls piggybacked but got nothing in return or // we received a stun request with neither attribute set // => peer does not support. - if (state_ == State::TENTATIVE && data == nullptr && ack == nullptr) { + if (state_ == State::TENTATIVE && !data.has_value() && !acks.has_value()) { RTC_LOG(LS_INFO) << "DTLS-STUN piggybacking not supported by peer."; state_ = State::OFF; return; @@ -160,11 +160,10 @@ void DtlsStunPiggybackController::ReportDataPiggybacked( // In PENDING state the peer may have stopped sending the ack // when it moved to the COMPLETE state. Move to the same state. - if (state_ == State::PENDING && data == nullptr && ack == nullptr) { + if (state_ == State::PENDING && !data.has_value() && !acks.has_value()) { RTC_LOG(LS_INFO) << "DTLS-STUN piggybacking complete."; state_ = State::COMPLETE; pending_packets_.clear(); - handshake_ack_writer_.Clear(); handshake_messages_received_.clear(); return; } @@ -174,16 +173,12 @@ void DtlsStunPiggybackController::ReportDataPiggybacked( state_ = State::CONFIRMED; } - if (ack != nullptr) { + if (acks.has_value()) { if (!pending_packets_.empty()) { // Unpack the ACK attribute (a list of uint32_t) absl::flat_hash_set acked_packets; - { - ByteBufferReader ack_reader(ack->array_view()); - uint32_t packet_hash; - while (ack_reader.ReadUInt32(&packet_hash)) { - acked_packets.insert(packet_hash); - } + for (const auto& ack : *acks) { + acked_packets.insert(ack); } RTC_LOG(LS_VERBOSE) << "DTLS-STUN piggybacking ACK: " << StrJoin(acked_packets, ","); @@ -197,21 +192,20 @@ void DtlsStunPiggybackController::ReportDataPiggybacked( // the DTLS data but will contain an ack. // Must not happen on the initial server to client packet which // has no DTLS data yet. - if (data == nullptr && ack != nullptr && state_ == State::PENDING) { + if (!data.has_value() && acks.has_value() && state_ == State::PENDING) { RTC_LOG(LS_INFO) << "DTLS-STUN piggybacking complete."; state_ = State::COMPLETE; pending_packets_.clear(); - handshake_ack_writer_.Clear(); handshake_messages_received_.clear(); return; } - if (!data || data->length() == 0) { + if (!data.has_value() || data->size() == 0) { return; } // Drop non-DTLS packets. - if (!IsDtlsPacket(data->array_view())) { + if (!IsDtlsPacket(*data)) { RTC_LOG(LS_WARNING) << "Dropping non-DTLS data."; return; } @@ -219,28 +213,20 @@ void DtlsStunPiggybackController::ReportDataPiggybacked( // Extract the received message id of the handshake // from the packet and prepare the ack to be sent. - uint32_t hash = ComputeDtlsPacketHash(data->array_view()); + uint32_t hash = ComputeDtlsPacketHash(*data); // Check if we already received this packet. if (std::find(handshake_messages_received_.begin(), handshake_messages_received_.end(), hash) == handshake_messages_received_.end()) { - handshake_messages_received_.push_back(hash); - handshake_ack_writer_.WriteUInt32(hash); - - if (handshake_ack_writer_.Length() > kMaxAckSize) { - // If needed, limit size of ack attribute...by removing oldest ack. + // If needed, limit size of ack attribute by removing oldest ack. + while (handshake_messages_received_.size() >= kMaxAckSize) { handshake_messages_received_.erase(handshake_messages_received_.begin()); - handshake_ack_writer_.Clear(); - for (const auto& val : handshake_messages_received_) { - handshake_ack_writer_.WriteUInt32(val); - } } - - RTC_DCHECK(handshake_ack_writer_.Length() <= kMaxAckSize); + handshake_messages_received_.push_back(hash); } - dtls_data_callback_(data->array_view()); + dtls_data_callback_(*data); } } // namespace webrtc diff --git a/p2p/dtls/dtls_stun_piggyback_controller.h b/p2p/dtls/dtls_stun_piggyback_controller.h index ad9b97a32c..9348b3f52b 100644 --- a/p2p/dtls/dtls_stun_piggyback_controller.h +++ b/p2p/dtls/dtls_stun_piggyback_controller.h @@ -21,7 +21,6 @@ #include "api/sequence_checker.h" #include "api/transport/stun.h" #include "p2p/dtls/dtls_utils.h" -#include "rtc_base/byte_buffer.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" @@ -32,7 +31,7 @@ namespace webrtc { class DtlsStunPiggybackController { public: // Never ack more than 4 packets. - static constexpr unsigned kMaxAckSize = 16; + static constexpr unsigned kMaxAckSize = 4; // dtls_data_callback will be called with any DTLS packets received // piggybacked. @@ -78,12 +77,12 @@ class DtlsStunPiggybackController { // to obtain optional DTLS data or ACKs. std::optional GetDataToPiggyback( StunMessageType stun_message_type); - std::optional GetAckToPiggyback( + std::optional> GetAckToPiggyback( StunMessageType stun_message_type); // Called by Connection when receiving a STUN BINDING { REQUEST / RESPONSE }. - void ReportDataPiggybacked(const StunByteStringAttribute* data, - const StunByteStringAttribute* ack); + void ReportDataPiggybacked(std::optional> data, + std::optional> acks); int GetCountOfReceivedData() const { return data_recv_count_; } @@ -96,7 +95,6 @@ class DtlsStunPiggybackController { std::vector handshake_messages_received_ RTC_GUARDED_BY(sequence_checker_); - ByteBufferWriter handshake_ack_writer_ RTC_GUARDED_BY(sequence_checker_); // Count of data attributes received. int data_recv_count_ = 0; @@ -107,12 +105,5 @@ class DtlsStunPiggybackController { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::DtlsStunPiggybackController; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_DTLS_DTLS_STUN_PIGGYBACK_CONTROLLER_H_ diff --git a/p2p/dtls/dtls_stun_piggyback_controller_unittest.cc b/p2p/dtls/dtls_stun_piggyback_controller_unittest.cc index 75a44df698..a086055dce 100644 --- a/p2p/dtls/dtls_stun_piggyback_controller_unittest.cc +++ b/p2p/dtls/dtls_stun_piggyback_controller_unittest.cc @@ -21,6 +21,7 @@ #include "api/transport/stun.h" #include "p2p/dtls/dtls_utils.h" #include "rtc_base/byte_buffer.h" +#include "rtc_base/checks.h" #include "test/gmock.h" #include "test/gtest.h" @@ -56,12 +57,15 @@ const std::vector dtls_flight4 = { const std::vector empty = {}; -std::string AsAckAttribute(const std::vector& list) { - webrtc::ByteBufferWriter writer; - for (const auto& val : list) { - writer.WriteUInt32(val); +std::vector FromAckAttribute(webrtc::ArrayView attr) { + webrtc::ByteBufferReader ack_reader(attr); + std::vector values; + uint32_t value; + while (ack_reader.ReadUInt32(&value)) { + values.push_back(value); } - return std::string(writer.DataAsStringView()); + RTC_DCHECK_EQ(ack_reader.Length(), 0); + return values; } std::vector FakeDtlsPacket(uint16_t packet_number) { @@ -71,10 +75,30 @@ std::vector FakeDtlsPacket(uint16_t packet_number) { return packet; } +std::unique_ptr WrapInStun( + webrtc::IceAttributeType type, + absl::string_view data) { + return std::make_unique(type, data); +} + +std::unique_ptr WrapInStun( + webrtc::IceAttributeType type, + const std::vector& data) { + return std::make_unique(type, data.data(), + data.size()); +} + +std::unique_ptr WrapInStun( + webrtc::IceAttributeType type, + const std::vector& data) { + return std::make_unique(type, data); +} + } // namespace namespace webrtc { +using ::testing::ElementsAreArray; using ::testing::MockFunction; using State = DtlsStunPiggybackController::State; @@ -87,7 +111,7 @@ class DtlsStunPiggybackControllerTest : public ::testing::Test { ServerPacketSink(data); }) {} - void SendClientToServer(const std::vector packet, + void SendClientToServer(const std::vector& packet, StunMessageType type) { if (!packet.empty()) { client_.CapturePacket(packet); @@ -96,16 +120,20 @@ class DtlsStunPiggybackControllerTest : public ::testing::Test { client_.ClearCachedPacketForTesting(); } std::unique_ptr attr_data; + std::optional> view_data; if (auto data = client_.GetDataToPiggyback(type)) { attr_data = WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, *data); + view_data = attr_data->array_view(); } std::unique_ptr attr_ack; + std::optional> view_acks; if (auto ack = client_.GetAckToPiggyback(type)) { attr_ack = WrapInStun(STUN_ATTR_META_DTLS_IN_STUN_ACK, *ack); + view_acks = FromAckAttribute(attr_ack->array_view()); } - server_.ReportDataPiggybacked(attr_data.get(), attr_ack.get()); + server_.ReportDataPiggybacked(view_data, view_acks); } - void SendServerToClient(const std::vector packet, + void SendServerToClient(const std::vector& packet, StunMessageType type) { if (!packet.empty()) { server_.CapturePacket(packet); @@ -114,14 +142,18 @@ class DtlsStunPiggybackControllerTest : public ::testing::Test { server_.ClearCachedPacketForTesting(); } std::unique_ptr attr_data; + std::optional> view_data; if (auto data = server_.GetDataToPiggyback(type)) { attr_data = WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, *data); + view_data = attr_data->array_view(); } std::unique_ptr attr_ack; + std::optional> view_acks; if (auto ack = server_.GetAckToPiggyback(type)) { attr_ack = WrapInStun(STUN_ATTR_META_DTLS_IN_STUN_ACK, *ack); + view_acks = FromAckAttribute(attr_ack->array_view()); } - client_.ReportDataPiggybacked(attr_data.get(), attr_ack.get()); + client_.ReportDataPiggybacked(view_data, view_acks); if (packet == dtls_flight4) { // After sending flight 4, the server handshake is complete. server_.SetDtlsHandshakeComplete(/*is_client=*/false, @@ -131,21 +163,9 @@ class DtlsStunPiggybackControllerTest : public ::testing::Test { } } - std::unique_ptr WrapInStun(IceAttributeType type, - absl::string_view data) { - return std::make_unique(type, data); - } - - std::unique_ptr WrapInStun( - IceAttributeType type, - const std::vector& data) { - return std::make_unique(type, data.data(), - data.size()); - } - void DisableSupport(DtlsStunPiggybackController& client_or_server) { ASSERT_EQ(client_or_server.state(), State::TENTATIVE); - client_or_server.ReportDataPiggybacked(nullptr, nullptr); + client_or_server.ReportDataPiggybacked(std::nullopt, std::nullopt); ASSERT_EQ(client_or_server.state(), State::OFF); } @@ -286,30 +306,32 @@ TEST_F(DtlsStunPiggybackControllerTest, } TEST_F(DtlsStunPiggybackControllerTest, BasicHandshakeAckData) { - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_RESPONSE), ""); - EXPECT_EQ(client_.GetAckToPiggyback(STUN_BINDING_REQUEST), ""); + EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_RESPONSE), + std::vector({})); + EXPECT_EQ(client_.GetAckToPiggyback(STUN_BINDING_RESPONSE), + std::vector({})); // Flight 1+2 SendClientToServer(dtls_flight1, STUN_BINDING_REQUEST); SendServerToClient(dtls_flight2, STUN_BINDING_RESPONSE); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST), - AsAckAttribute({ComputeDtlsPacketHash(dtls_flight1)})); - EXPECT_EQ(client_.GetAckToPiggyback(STUN_BINDING_RESPONSE), - AsAckAttribute({ComputeDtlsPacketHash(dtls_flight2)})); + EXPECT_THAT(*server_.GetAckToPiggyback(STUN_BINDING_REQUEST), + ElementsAreArray({ComputeDtlsPacketHash(dtls_flight1)})); + EXPECT_THAT(*client_.GetAckToPiggyback(STUN_BINDING_RESPONSE), + ElementsAreArray({ComputeDtlsPacketHash(dtls_flight2)})); // Flight 3+4 SendClientToServer(dtls_flight3, STUN_BINDING_REQUEST); SendServerToClient(dtls_flight4, STUN_BINDING_RESPONSE); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_RESPONSE), - AsAckAttribute({ - ComputeDtlsPacketHash(dtls_flight1), - ComputeDtlsPacketHash(dtls_flight3), - })); - EXPECT_EQ(client_.GetAckToPiggyback(STUN_BINDING_REQUEST), - AsAckAttribute({ - ComputeDtlsPacketHash(dtls_flight2), - ComputeDtlsPacketHash(dtls_flight4), - })); + EXPECT_THAT(*server_.GetAckToPiggyback(STUN_BINDING_RESPONSE), + ElementsAreArray({ + ComputeDtlsPacketHash(dtls_flight1), + ComputeDtlsPacketHash(dtls_flight3), + })); + EXPECT_THAT(*client_.GetAckToPiggyback(STUN_BINDING_REQUEST), + ElementsAreArray({ + ComputeDtlsPacketHash(dtls_flight2), + ComputeDtlsPacketHash(dtls_flight4), + })); // Post-handshake ACK SendServerToClient(empty, STUN_BINDING_REQUEST); @@ -323,22 +345,22 @@ TEST_F(DtlsStunPiggybackControllerTest, BasicHandshakeAckData) { TEST_F(DtlsStunPiggybackControllerTest, AckDataNoDuplicates) { // Flight 1+2 SendClientToServer(dtls_flight1, STUN_BINDING_REQUEST); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST), - AsAckAttribute({ComputeDtlsPacketHash(dtls_flight1)})); + EXPECT_THAT(*server_.GetAckToPiggyback(STUN_BINDING_REQUEST), + ElementsAreArray({ComputeDtlsPacketHash(dtls_flight1)})); SendClientToServer(dtls_flight3, STUN_BINDING_REQUEST); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST), - AsAckAttribute({ - ComputeDtlsPacketHash(dtls_flight1), - ComputeDtlsPacketHash(dtls_flight3), - })); + EXPECT_THAT(*server_.GetAckToPiggyback(STUN_BINDING_REQUEST), + ElementsAreArray({ + ComputeDtlsPacketHash(dtls_flight1), + ComputeDtlsPacketHash(dtls_flight3), + })); // Receive Flight 1 again, no change expected. SendClientToServer(dtls_flight1, STUN_BINDING_REQUEST); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST), - AsAckAttribute({ - ComputeDtlsPacketHash(dtls_flight1), - ComputeDtlsPacketHash(dtls_flight3), - })); + EXPECT_THAT(*server_.GetAckToPiggyback(STUN_BINDING_REQUEST), + ElementsAreArray({ + ComputeDtlsPacketHash(dtls_flight1), + ComputeDtlsPacketHash(dtls_flight3), + })); } TEST_F(DtlsStunPiggybackControllerTest, IgnoresNonDtlsData) { @@ -346,7 +368,8 @@ TEST_F(DtlsStunPiggybackControllerTest, IgnoresNonDtlsData) { EXPECT_CALL(*this, ServerPacketSink).Times(0); server_.ReportDataPiggybacked( - WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, ascii).get(), nullptr); + WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, ascii)->array_view(), + std::nullopt); EXPECT_EQ(0, server_.GetCountOfReceivedData()); } @@ -355,9 +378,8 @@ TEST_F(DtlsStunPiggybackControllerTest, DontSendAckedPackets) { server_.Flush(); EXPECT_TRUE(server_.GetDataToPiggyback(STUN_BINDING_REQUEST).has_value()); server_.ReportDataPiggybacked( - nullptr, WrapInStun(STUN_ATTR_META_DTLS_IN_STUN_ACK, - AsAckAttribute({ComputeDtlsPacketHash(dtls_flight1)})) - .get()); + std::nullopt, + std::vector({ComputeDtlsPacketHash(dtls_flight1)})); // No unacked packet exists. EXPECT_FALSE(server_.GetDataToPiggyback(STUN_BINDING_REQUEST).has_value()); } @@ -366,30 +388,35 @@ TEST_F(DtlsStunPiggybackControllerTest, LimitAckSize) { std::vector dtls_flight5 = FakeDtlsPacket(0x5487); server_.ReportDataPiggybacked( - WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight1).get(), nullptr); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 4u); + WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight1)->array_view(), + std::nullopt); + EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 1u); server_.ReportDataPiggybacked( - WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight2).get(), nullptr); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 8u); + WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight2)->array_view(), + std::nullopt); + EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 2u); server_.ReportDataPiggybacked( - WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight3).get(), nullptr); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 12u); + WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight3)->array_view(), + std::nullopt); + EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 3u); server_.ReportDataPiggybacked( - WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight4).get(), nullptr); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 16u); + WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight4)->array_view(), + std::nullopt); + EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), 4u); // Limit size of ack so that it does not grow unbounded. server_.ReportDataPiggybacked( - WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight5).get(), nullptr); + WrapInStun(STUN_ATTR_META_DTLS_IN_STUN, dtls_flight5)->array_view(), + std::nullopt); EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST)->size(), DtlsStunPiggybackController::kMaxAckSize); - EXPECT_EQ(server_.GetAckToPiggyback(STUN_BINDING_REQUEST), - AsAckAttribute({ - ComputeDtlsPacketHash(dtls_flight2), - ComputeDtlsPacketHash(dtls_flight3), - ComputeDtlsPacketHash(dtls_flight4), - ComputeDtlsPacketHash(dtls_flight5), - })); + EXPECT_THAT(*server_.GetAckToPiggyback(STUN_BINDING_REQUEST), + ElementsAreArray({ + ComputeDtlsPacketHash(dtls_flight2), + ComputeDtlsPacketHash(dtls_flight3), + ComputeDtlsPacketHash(dtls_flight4), + ComputeDtlsPacketHash(dtls_flight5), + })); } TEST_F(DtlsStunPiggybackControllerTest, MultiPacketRoundRobin) { @@ -406,9 +433,8 @@ TEST_F(DtlsStunPiggybackControllerTest, MultiPacketRoundRobin) { std::string(dtls_flight3.begin(), dtls_flight3.end())); server_.ReportDataPiggybacked( - nullptr, WrapInStun(STUN_ATTR_META_DTLS_IN_STUN_ACK, - AsAckAttribute({ComputeDtlsPacketHash(dtls_flight1)})) - .get()); + std::nullopt, + std::vector({ComputeDtlsPacketHash(dtls_flight1)})); EXPECT_EQ(server_.GetDataToPiggyback(STUN_BINDING_REQUEST), std::string(dtls_flight2.begin(), dtls_flight2.end())); @@ -416,9 +442,8 @@ TEST_F(DtlsStunPiggybackControllerTest, MultiPacketRoundRobin) { std::string(dtls_flight3.begin(), dtls_flight3.end())); server_.ReportDataPiggybacked( - nullptr, WrapInStun(STUN_ATTR_META_DTLS_IN_STUN_ACK, - AsAckAttribute({ComputeDtlsPacketHash(dtls_flight3)})) - .get()); + std::nullopt, + std::vector({ComputeDtlsPacketHash(dtls_flight3)})); EXPECT_EQ(server_.GetDataToPiggyback(STUN_BINDING_REQUEST), std::string(dtls_flight2.begin(), dtls_flight2.end())); @@ -426,4 +451,13 @@ TEST_F(DtlsStunPiggybackControllerTest, MultiPacketRoundRobin) { std::string(dtls_flight2.begin(), dtls_flight2.end())); } +TEST_F(DtlsStunPiggybackControllerTest, DuplicateAck) { + server_.CapturePacket(dtls_flight1); + server_.Flush(); + server_.ReportDataPiggybacked( + std::nullopt, + std::vector({ComputeDtlsPacketHash(dtls_flight1), + ComputeDtlsPacketHash(dtls_flight1)})); +} + } // namespace webrtc diff --git a/p2p/dtls/dtls_transport.cc b/p2p/dtls/dtls_transport.cc index 0d2dbc82b0..52020f3585 100644 --- a/p2p/dtls/dtls_transport.cc +++ b/p2p/dtls/dtls_transport.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" @@ -639,7 +640,7 @@ void DtlsTransportInternalImpl::ConnectToIceTransport() { DtlsStunPiggybackCallbacks( [&](auto stun_message_type) { std::optional data; - std::optional ack; + std::optional> ack; if (dtls_in_stun_) { data = dtls_stun_piggyback_controller_.GetDataToPiggyback( stun_message_type); @@ -648,11 +649,12 @@ void DtlsTransportInternalImpl::ConnectToIceTransport() { } return std::make_pair(data, ack); }, - [&](auto data, auto ack) { + [&](std::optional> data, + std::optional> acks) { if (!dtls_in_stun_) { return; } - dtls_stun_piggyback_controller_.ReportDataPiggybacked(data, ack); + dtls_stun_piggyback_controller_.ReportDataPiggybacked(data, acks); })); SetPiggybackDtlsDataCallback([this](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { diff --git a/p2p/dtls/dtls_transport.h b/p2p/dtls/dtls_transport.h index edf0635dc6..d387c96a18 100644 --- a/p2p/dtls/dtls_transport.h +++ b/p2p/dtls/dtls_transport.h @@ -327,13 +327,5 @@ class DtlsTransportInternalImpl : public DtlsTransportInternal { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using DtlsTransport = ::webrtc::DtlsTransportInternalImpl; -using ::webrtc::StreamInterfaceChannel; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_DTLS_DTLS_TRANSPORT_H_ diff --git a/p2p/dtls/dtls_transport_factory.h b/p2p/dtls/dtls_transport_factory.h index 62e9eeec34..edfab6c8c7 100644 --- a/p2p/dtls/dtls_transport_factory.h +++ b/p2p/dtls/dtls_transport_factory.h @@ -38,12 +38,5 @@ class DtlsTransportFactory { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::DtlsTransportFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_DTLS_DTLS_TRANSPORT_FACTORY_H_ diff --git a/p2p/dtls/dtls_transport_internal.h b/p2p/dtls/dtls_transport_internal.h index c54d56727d..8858f1227f 100644 --- a/p2p/dtls/dtls_transport_internal.h +++ b/p2p/dtls/dtls_transport_internal.h @@ -11,9 +11,8 @@ #ifndef P2P_DTLS_DTLS_TRANSPORT_INTERNAL_H_ #define P2P_DTLS_DTLS_TRANSPORT_INTERNAL_H_ -#include -#include - +#include +#include #include #include #include @@ -158,15 +157,5 @@ class DtlsTransportInternal : public PacketTransportInternal { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::DtlsTransportInternal; -using ::webrtc::PacketFlags; -using ::webrtc::PF_NORMAL; -using ::webrtc::PF_SRTP_BYPASS; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_DTLS_DTLS_TRANSPORT_INTERNAL_H_ diff --git a/p2p/dtls/dtls_transport_unittest.cc b/p2p/dtls/dtls_transport_unittest.cc index 1e7067d118..b1dced7958 100644 --- a/p2p/dtls/dtls_transport_unittest.cc +++ b/p2p/dtls/dtls_transport_unittest.cc @@ -67,7 +67,7 @@ static const size_t kPacketHeaderLen = 12; static const int kFakePacketId = 0x1234; static const int kTimeout = 10000; -const uint8_t kRtpLeadByte = 0x80; +constexpr uint8_t kRtpLeadByte = 0x80; static bool IsRtpLeadByte(uint8_t b) { return b == kRtpLeadByte; diff --git a/p2p/dtls/dtls_utils.h b/p2p/dtls/dtls_utils.h index 88e6521dfd..71be932445 100644 --- a/p2p/dtls/dtls_utils.h +++ b/p2p/dtls/dtls_utils.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "absl/container/flat_hash_set.h" @@ -30,9 +29,6 @@ bool IsDtlsPacket(ArrayView payload); bool IsDtlsClientHelloPacket(ArrayView payload); bool IsDtlsHandshakePacket(ArrayView payload); -std::optional> GetDtlsHandshakeAcks( - ArrayView dtls_packet); - uint32_t ComputeDtlsPacketHash(ArrayView dtls_packet); class PacketStash { @@ -71,17 +67,5 @@ class PacketStash { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::GetDtlsHandshakeAcks; -using ::webrtc::IsDtlsClientHelloPacket; -using ::webrtc::IsDtlsHandshakePacket; -using ::webrtc::IsDtlsPacket; -using ::webrtc::kDtlsRecordHeaderLen; -using ::webrtc::kMaxDtlsPacketLen; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_DTLS_DTLS_UTILS_H_ diff --git a/p2p/dtls/fake_dtls_transport.h b/p2p/dtls/fake_dtls_transport.h index dc99ed5227..4bdf69dc16 100644 --- a/p2p/dtls/fake_dtls_transport.h +++ b/p2p/dtls/fake_dtls_transport.h @@ -334,12 +334,5 @@ class FakeDtlsTransport : public DtlsTransportInternal { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakeDtlsTransport; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_DTLS_FAKE_DTLS_TRANSPORT_H_ diff --git a/p2p/test/fake_ice_transport.h b/p2p/test/fake_ice_transport.h index ef4a90c13d..28e8be22fa 100644 --- a/p2p/test/fake_ice_transport.h +++ b/p2p/test/fake_ice_transport.h @@ -19,11 +19,13 @@ #include #include #include +#include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/candidate.h" +#include "api/field_trials.h" #include "api/ice_transport_interface.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" @@ -50,7 +52,7 @@ #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" namespace webrtc { using ::webrtc::SafeTask; @@ -68,7 +70,7 @@ class FakeIceTransport : public IceTransportInternal { : name_(name), component_(component), network_thread_(network_thread ? network_thread : Thread::Current()), - field_trials_(field_trials_string) { + field_trials_(CreateTestFieldTrials(field_trials_string)) { RTC_DCHECK(network_thread_); } @@ -162,7 +164,7 @@ class FakeIceTransport : public IceTransportInternal { // In this fake transport channel, `connection_count_` determines the // transport state. if (connection_count_ < old_connection_count) { - SignalStateChanged(this); + SignalIceTransportStateChanged(this); } } @@ -579,8 +581,15 @@ class FakeIceTransport : public IceTransportInternal { << " attr: " << (dtls_piggyback_attr != nullptr) << " ack: " << (dtls_piggyback_ack != nullptr); if (!dtls_stun_piggyback_callbacks_.empty()) { - dtls_stun_piggyback_callbacks_.recv_data(dtls_piggyback_attr, - dtls_piggyback_ack); + std::optional> piggyback_attr; + if (dtls_piggyback_attr) { + piggyback_attr = dtls_piggyback_attr->array_view(); + } + std::optional> piggyback_ack; + if (dtls_piggyback_ack) { + piggyback_ack = dtls_piggyback_ack->GetUInt32Vector(); + } + dtls_stun_piggyback_callbacks_.recv_data(piggyback_attr, piggyback_ack); } if (msg->type() == STUN_BINDING_RESPONSE) { @@ -658,7 +667,7 @@ class FakeIceTransport : public IceTransportInternal { DtlsStunPiggybackCallbacks dtls_stun_piggyback_callbacks_; std::map received_stun_messages_per_type; int received_packets_ = 0; - test::ExplicitKeyValueConfig field_trials_; + FieldTrials field_trials_; bool drop_non_stun_unless_writable_ = false; }; @@ -675,15 +684,5 @@ class FakeIceTransportWrapper : public IceTransportInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakeIceTransport; -using ::webrtc::FakeIceTransportWrapper; -using ::webrtc::SafeTask; -using ::webrtc::TimeDelta; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_FAKE_ICE_TRANSPORT_H_ diff --git a/p2p/test/fake_packet_transport.h b/p2p/test/fake_packet_transport.h index d563ba5339..168e95d155 100644 --- a/p2p/test/fake_packet_transport.h +++ b/p2p/test/fake_packet_transport.h @@ -19,8 +19,10 @@ #include "api/transport/ecn_marking.h" #include "api/units/timestamp.h" #include "p2p/base/packet_transport_internal.h" +#include "rtc_base/async_packet_socket.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/network/received_packet.h" +#include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" @@ -154,12 +156,5 @@ class FakePacketTransport : public PacketTransportInternal { } // 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::FakePacketTransport; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_FAKE_PACKET_TRANSPORT_H_ diff --git a/p2p/test/fake_port_allocator.h b/p2p/test/fake_port_allocator.h index 3853b2198f..5658ef5f16 100644 --- a/p2p/test/fake_port_allocator.h +++ b/p2p/test/fake_port_allocator.h @@ -267,14 +267,5 @@ class FakePortAllocator : public PortAllocator { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::FakePortAllocator; -using ::webrtc::FakePortAllocatorSession; -using ::webrtc::TestUDPPort; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_FAKE_PORT_ALLOCATOR_H_ diff --git a/p2p/test/mock_active_ice_controller.h b/p2p/test/mock_active_ice_controller.h index 98d6cb91f0..3e09180b2e 100644 --- a/p2p/test/mock_active_ice_controller.h +++ b/p2p/test/mock_active_ice_controller.h @@ -67,13 +67,5 @@ class MockActiveIceControllerFactory } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MockActiveIceController; -using ::webrtc::MockActiveIceControllerFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_MOCK_ACTIVE_ICE_CONTROLLER_H_ diff --git a/p2p/test/mock_dns_resolving_packet_socket_factory.h b/p2p/test/mock_dns_resolving_packet_socket_factory.h index f2e2ed7fd7..37efd70a52 100644 --- a/p2p/test/mock_dns_resolving_packet_socket_factory.h +++ b/p2p/test/mock_dns_resolving_packet_socket_factory.h @@ -51,12 +51,5 @@ class MockDnsResolvingPacketSocketFactory : public BasicPacketSocketFactory { } // 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::MockDnsResolvingPacketSocketFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_MOCK_DNS_RESOLVING_PACKET_SOCKET_FACTORY_H_ diff --git a/p2p/test/mock_ice_agent.h b/p2p/test/mock_ice_agent.h index 3ae3f755e0..6b0d5ef7df 100644 --- a/p2p/test/mock_ice_agent.h +++ b/p2p/test/mock_ice_agent.h @@ -48,12 +48,5 @@ class MockIceAgent : public IceAgentInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MockIceAgent; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_MOCK_ICE_AGENT_H_ diff --git a/p2p/test/mock_ice_controller.h b/p2p/test/mock_ice_controller.h index 5cc4f316f0..ecad4c7355 100644 --- a/p2p/test/mock_ice_controller.h +++ b/p2p/test/mock_ice_controller.h @@ -77,13 +77,5 @@ class MockIceControllerFactory : public IceControllerFactoryInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MockIceController; -using ::webrtc::MockIceControllerFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_MOCK_ICE_CONTROLLER_H_ diff --git a/p2p/test/mock_ice_transport.h b/p2p/test/mock_ice_transport.h index d886c5869e..b1be7421d4 100644 --- a/p2p/test/mock_ice_transport.h +++ b/p2p/test/mock_ice_transport.h @@ -82,12 +82,5 @@ class MockIceTransport : public IceTransportInternal { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MockIceTransport; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_MOCK_ICE_TRANSPORT_H_ diff --git a/p2p/test/nat_server.h b/p2p/test/nat_server.h index 510d9ea36b..5bf55f0d18 100644 --- a/p2p/test/nat_server.h +++ b/p2p/test/nat_server.h @@ -130,16 +130,5 @@ class NATServer { } // 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::AddrCmp; -using ::webrtc::NAT_SERVER_TCP_PORT; -using ::webrtc::NAT_SERVER_UDP_PORT; -using ::webrtc::NATServer; -using ::webrtc::RouteCmp; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_NAT_SERVER_H_ diff --git a/p2p/test/nat_socket_factory.h b/p2p/test/nat_socket_factory.h index 2da761dfb8..f782b4e0b4 100644 --- a/p2p/test/nat_socket_factory.h +++ b/p2p/test/nat_socket_factory.h @@ -11,8 +11,7 @@ #ifndef P2P_TEST_NAT_SOCKET_FACTORY_H_ #define P2P_TEST_NAT_SOCKET_FACTORY_H_ -#include - +#include #include #include #include @@ -178,18 +177,5 @@ size_t UnpackAddressFromNAT(ArrayView buf, SocketAddress* remote_addr); } // 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::kNATEncodedIPv4AddressSize; -using ::webrtc::kNATEncodedIPv6AddressSize; -using ::webrtc::NATInternalSocketFactory; -using ::webrtc::NATSocketFactory; -using ::webrtc::NATSocketServer; -using ::webrtc::PackAddressForNAT; -using ::webrtc::UnpackAddressFromNAT; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_NAT_SOCKET_FACTORY_H_ diff --git a/p2p/test/nat_types.h b/p2p/test/nat_types.h index 9ef70026ef..24a257af8b 100644 --- a/p2p/test/nat_types.h +++ b/p2p/test/nat_types.h @@ -44,17 +44,5 @@ class NAT { } // 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::NAT; -using ::webrtc::NAT_ADDR_RESTRICTED; -using ::webrtc::NAT_OPEN_CONE; -using ::webrtc::NAT_PORT_RESTRICTED; -using ::webrtc::NAT_SYMMETRIC; -using ::webrtc::NATType; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_NAT_TYPES_H_ diff --git a/p2p/test/nat_unittest.cc b/p2p/test/nat_unittest.cc index e98bd176ef..9f80568c22 100644 --- a/p2p/test/nat_unittest.cc +++ b/p2p/test/nat_unittest.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include #include +#include #include #include diff --git a/p2p/test/stun_server.h b/p2p/test/stun_server.h index 517fa1dece..a44c5958aa 100644 --- a/p2p/test/stun_server.h +++ b/p2p/test/stun_server.h @@ -11,8 +11,6 @@ #ifndef P2P_TEST_STUN_SERVER_H_ #define P2P_TEST_STUN_SERVER_H_ -#include - #include #include "absl/strings/string_view.h" @@ -65,13 +63,5 @@ class StunServer { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::STUN_SERVER_PORT; -using ::webrtc::StunServer; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_STUN_SERVER_H_ diff --git a/p2p/test/stun_server_unittest.cc b/p2p/test/stun_server_unittest.cc index 1a86a3059b..8baa8b7b37 100644 --- a/p2p/test/stun_server_unittest.cc +++ b/p2p/test/stun_server_unittest.cc @@ -10,8 +10,7 @@ #include "p2p/test/stun_server.h" -#include - +#include #include #include diff --git a/p2p/test/test_stun_server.h b/p2p/test/test_stun_server.h index 9cee166f68..5a9f5bea73 100644 --- a/p2p/test/test_stun_server.h +++ b/p2p/test/test_stun_server.h @@ -51,12 +51,5 @@ class TestStunServer : StunServer { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TestStunServer; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_TEST_STUN_SERVER_H_ diff --git a/p2p/test/test_turn_customizer.h b/p2p/test/test_turn_customizer.h index 0d447eb7d0..62fb45e5bf 100644 --- a/p2p/test/test_turn_customizer.h +++ b/p2p/test/test_turn_customizer.h @@ -59,12 +59,5 @@ class TestTurnCustomizer : public TurnCustomizer { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TestTurnCustomizer; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_TEST_TURN_CUSTOMIZER_H_ diff --git a/p2p/test/test_turn_server.h b/p2p/test/test_turn_server.h index 6f26b3697c..083c5850c8 100644 --- a/p2p/test/test_turn_server.h +++ b/p2p/test/test_turn_server.h @@ -165,15 +165,5 @@ class TestTurnServer : public TurnAuthInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::kTestRealm; -using ::webrtc::kTestSoftware; -using ::webrtc::TestTurnRedirector; -using ::webrtc::TestTurnServer; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_TEST_TURN_SERVER_H_ diff --git a/p2p/test/turn_server.h b/p2p/test/turn_server.h index 59397a6764..27cb321fd5 100644 --- a/p2p/test/turn_server.h +++ b/p2p/test/turn_server.h @@ -368,20 +368,5 @@ class TurnServer : public sigslot::has_slots<> { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::kMaxTurnChannelNumber; -using ::webrtc::kMinTurnChannelNumber; -using ::webrtc::StunMessageObserver; -using ::webrtc::TURN_SERVER_PORT; -using ::webrtc::TurnAuthInterface; -using ::webrtc::TurnRedirectInterface; -using ::webrtc::TurnServer; -using ::webrtc::TurnServerAllocation; -using ::webrtc::TurnServerConnection; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // P2P_TEST_TURN_SERVER_H_ diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 9b4f1ce01f..5a064183f3 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -75,6 +75,7 @@ rtc_library("channel") { ":rtp_transport_internal", ":session_description", "../api:libjingle_peerconnection_api", + "../api:rtc_error", "../api:rtp_headers", "../api:rtp_parameters", "../api:rtp_transceiver_direction", @@ -557,7 +558,15 @@ rtc_source_set("rtp_sender_proxy") { sources = [ "rtp_sender_proxy.h" ] deps = [ ":proxy", + "../api:dtls_transport_interface", + "../api:frame_transformer_interface", "../api:libjingle_peerconnection_api", + "../api:media_stream_interface", + "../api:rtc_error", + "../api:rtp_parameters", + "../api:scoped_refptr", + "../api/crypto:frame_encryptor_interface", + "../api/video_codecs:video_codecs_api", ] } @@ -574,6 +583,7 @@ rtc_library("rtp_transport") { "../api:field_trials_view", "../api/task_queue", "../api/task_queue:pending_task_safety_flag", + "../api/transport:ecn_marking", "../api/units:timestamp", "../call:rtp_receiver", "../call:video_receive_stream_api", @@ -588,7 +598,6 @@ rtc_library("rtp_transport") { "../rtc_base:network_route", "../rtc_base:socket", "../rtc_base/containers:flat_set", - "../rtc_base/network:ecn_marking", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", ] @@ -604,6 +613,7 @@ rtc_source_set("rtp_transport_internal") { ":session_description", "../call:rtp_receiver", "../p2p:ice_transport_internal", + "../rtc_base:async_packet_socket", "../rtc_base:callback_list", "../rtc_base:copy_on_write_buffer", "../rtc_base:network_route", @@ -886,13 +896,11 @@ rtc_library("connection_context") { "../media:rtc_data_sctp_transport_factory", "../p2p:basic_packet_socket_factory", "../rtc_base:checks", - "../rtc_base:crypto_random", "../rtc_base:macromagic", "../rtc_base:network", "../rtc_base:socket_factory", "../rtc_base:socket_server", "../rtc_base:threading", - "../rtc_base:timeutils", "../rtc_base:unique_id_generator", "../rtc_base/memory:always_valid_pointer", ] @@ -928,6 +936,7 @@ rtc_library("data_channel_controller") { "../rtc_base:timeutils", "../rtc_base:weak_ptr", "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/functional:any_invocable", ] } @@ -959,6 +968,7 @@ rtc_source_set("peer_connection_internal") { "../rtc_base:ssl", "../rtc_base:ssl_adapter", "../rtc_base:threading", + "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -1059,6 +1069,7 @@ rtc_library("sdp_munging_detector") { ] deps = [ ":session_description", + "../api:field_trials_view", "../api:libjingle_peerconnection_api", "../api:rtp_parameters", "../media:codec", @@ -1069,6 +1080,8 @@ rtc_library("sdp_munging_detector") { "../rtc_base:checks", "../rtc_base:logging", "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/strings:string_view", ] } rtc_library("sdp_offer_answer") { @@ -1150,6 +1163,7 @@ rtc_library("sdp_offer_answer") { "../rtc_base:weak_ptr", "../system_wrappers:metrics", "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", @@ -1276,6 +1290,7 @@ rtc_library("peer_connection") { "../rtc_base:weak_ptr", "../system_wrappers:metrics", "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -1367,7 +1382,12 @@ rtc_library("legacy_stats_collector") { rtc_source_set("stream_collection") { visibility = [ ":*" ] sources = [ "stream_collection.h" ] - deps = [ "../api:libjingle_peerconnection_api" ] + deps = [ + "../api:libjingle_peerconnection_api", + "../api:make_ref_counted", + "../api:media_stream_interface", + "../api:scoped_refptr", + ] } rtc_library("track_media_info_map") { visibility = [ ":*" ] @@ -1596,6 +1616,7 @@ rtc_library("peer_connection_message_handler") { "../api/task_queue:pending_task_safety_flag", "../api/units:time_delta", "../rtc_base:checks", + "../rtc_base:threading", ] } @@ -1696,6 +1717,7 @@ rtc_library("rtp_transmission_manager") { "../rtc_base:threading", "../rtc_base:unique_id_generator", "../rtc_base:weak_ptr", + "//third_party/abseil-cpp/absl/functional:any_invocable", ] } @@ -1710,6 +1732,7 @@ rtc_library("transceiver_list") { "../api:libjingle_peerconnection_api", "../api:rtc_error", "../api:rtp_parameters", + "../api:rtp_transceiver_direction", "../api:scoped_refptr", "../api:sequence_checker", "../rtc_base:checks", @@ -1861,7 +1884,10 @@ rtc_library("video_track") { rtc_source_set("sdp_state_provider") { visibility = [ ":*" ] sources = [ "sdp_state_provider.h" ] - deps = [ "../api:libjingle_peerconnection_api" ] + deps = [ + "../api:libjingle_peerconnection_api", + "../rtc_base:ssl_adapter", + ] } rtc_library("jitter_buffer_delay") { @@ -2231,6 +2257,7 @@ if (rtc_include_tests && !build_with_chromium) { ":peerconnection_wrapper", ":sdp_utils", "../api:audio_options_api", + "../api:create_modular_peer_connection_factory", "../api:enable_media_with_defaults", "../api:field_trials", "../api:field_trials_view", @@ -2330,7 +2357,7 @@ if (rtc_include_tests && !build_with_chromium) { "../test:test_main", "../test:test_support", "../test:wait_until", - "../test/time_controller:time_controller", + "../test/time_controller", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", ] @@ -2430,6 +2457,7 @@ if (rtc_include_tests && !build_with_chromium) { ":sctp_data_channel", ":sctp_transport", ":sctp_utils", + ":sdp_munging_detector", ":sdp_utils", ":session_description", ":simulcast_description", @@ -2446,6 +2474,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api:array_view", "../api:audio_options_api", "../api:candidate", + "../api:create_modular_peer_connection_factory", "../api:create_peerconnection_factory", "../api:dtls_transport_interface", "../api:enable_media", @@ -2663,7 +2692,7 @@ if (rtc_include_tests && !build_with_chromium) { "test/android_test_initializer.h", ] deps = [ - "../modules/utility:utility", + "../modules/utility", "../rtc_base:checks", "../rtc_base:ssl_adapter", "../sdk/android:internal_jni", @@ -2687,6 +2716,7 @@ if (rtc_include_tests && !build_with_chromium) { ":video_track_source", "../api:audio_options_api", "../api:candidate", + "../api:create_modular_peer_connection_factory", "../api:dtls_transport_interface", "../api:enable_media_with_defaults", "../api:field_trials", @@ -2852,6 +2882,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api/environment:environment_factory", "../api/task_queue", "../api/task_queue:default_task_queue_factory", + "../api/task_queue:pending_task_safety_flag", "../api/transport:bandwidth_estimation_settings", "../api/transport:bitrate_settings", "../api/transport:datagram_transport_interface", diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc index 10bd129390..328207d214 100644 --- a/pc/audio_rtp_receiver.cc +++ b/pc/audio_rtp_receiver.cc @@ -10,8 +10,7 @@ #include "pc/audio_rtp_receiver.h" -#include - +#include #include #include #include diff --git a/pc/channel.cc b/pc/channel.cc index bccd1e2480..55135391fa 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -24,6 +24,7 @@ #include "api/crypto/crypto_options.h" #include "api/jsep.h" #include "api/media_types.h" +#include "api/rtc_error.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" #include "api/sequence_checker.h" @@ -88,8 +89,6 @@ struct StreamFinder { const StreamParams* target_; }; -} // namespace - void MediaChannelParametersFromMediaDescription( const MediaContentDescription* desc, const RtpHeaderExtensions& extensions, @@ -118,6 +117,58 @@ void RtpSendParametersFromMediaDescription( send_params->extmap_allow_mixed = desc->extmap_allow_mixed(); } +// Ensure that there is a matching packetization for each codec in +// new_params. If old_params had a special packetization but the +// response in new_params has no special packetization we amend +// old_params by ignoring the packetization and fall back to standard +// packetization instead. +RTCError MaybeIgnorePacketization(const MediaChannelParameters& new_params, + MediaChannelParameters& old_params) { + flat_set matched_codecs; + for (Codec& codec : old_params.codecs) { + if (absl::c_any_of(matched_codecs, + [&](const Codec* c) { return codec.Matches(*c); })) { + continue; + } + + std::vector new_codecs = + FindAllMatchingCodecs(new_params.codecs, codec); + if (new_codecs.empty()) { + continue; + } + + bool may_ignore_packetization = false; + bool has_matching_packetization = false; + for (const Codec* new_codec : new_codecs) { + if (!new_codec->packetization.has_value() && + codec.packetization.has_value()) { + may_ignore_packetization = true; + } else if (new_codec->packetization == codec.packetization) { + has_matching_packetization = true; + break; + } + } + + if (may_ignore_packetization) { + // Note: this writes into old_params + codec.packetization = std::nullopt; + } else if (!has_matching_packetization) { + std::string error_desc = StringFormat( + "Failed to set local answer due to incompatible codec " + "packetization for pt='%d' specified.", + codec.id); + return RTCError(RTCErrorType::INTERNAL_ERROR, error_desc); + } + + if (has_matching_packetization) { + matched_codecs.insert(&codec); + } + } + return RTCError::OK(); +} + +} // namespace + BaseChannel::BaseChannel( TaskQueueBase* worker_thread, Thread* network_thread, @@ -1035,6 +1086,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, RtpHeaderExtensions header_extensions = GetDeduplicatedRtpHeaderExtensions(content->rtp_header_extensions()); bool update_header_extensions = true; + // TODO: issues.webrtc.org/396640 - remove if pushdown on answer is enough. media_send_channel()->SetExtmapAllowMixed(content->extmap_allow_mixed()); VideoReceiverParameters recv_params = last_recv_params_; @@ -1044,54 +1096,18 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, RtpTransceiverDirectionHasRecv(content->direction()), &recv_params); VideoSenderParameters send_params = last_send_params_; + send_params.extmap_allow_mixed = content->extmap_allow_mixed(); // Ensure that there is a matching packetization for each send codec. If the // other peer offered to exclusively send non-standard packetization but we // only accept to receive standard packetization we effectively amend their // offer by ignoring the packetiztion and fall back to standard packetization // instead. - bool needs_send_params_update = false; if (type == SdpType::kAnswer || type == SdpType::kPrAnswer) { - flat_set matched_codecs; - for (Codec& send_codec : send_params.codecs) { - if (absl::c_any_of(matched_codecs, [&](const Codec* c) { - return send_codec.Matches(*c); - })) { - continue; - } - - std::vector recv_codecs = - FindAllMatchingCodecs(recv_params.codecs, send_codec); - if (recv_codecs.empty()) { - continue; - } - - bool may_ignore_packetization = false; - bool has_matching_packetization = false; - for (const Codec* recv_codec : recv_codecs) { - if (!recv_codec->packetization.has_value() && - send_codec.packetization.has_value()) { - may_ignore_packetization = true; - } else if (recv_codec->packetization == send_codec.packetization) { - has_matching_packetization = true; - break; - } - } - - if (may_ignore_packetization) { - send_codec.packetization = std::nullopt; - needs_send_params_update = true; - } else if (!has_matching_packetization) { - 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()); - return false; - } - - if (has_matching_packetization) { - matched_codecs.insert(&send_codec); - } + RTCError status = MaybeIgnorePacketization(recv_params, send_params); + if (!status.ok()) { + error_desc = status.message(); + return false; } } @@ -1113,7 +1129,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, last_recv_params_ = recv_params; - if (needs_send_params_update) { + if (type == SdpType::kAnswer || type == SdpType::kPrAnswer) { if (!media_send_channel()->SetSenderParameters(send_params)) { error_desc = StringFormat( "Failed to set send parameters for m-section with mid='%s'.", @@ -1164,48 +1180,11 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, // peer only accepts to send standard packetization we effectively amend our // offer by ignoring the packetiztion and fall back to standard packetization // instead. - bool needs_recv_params_update = false; if (type == SdpType::kAnswer || type == SdpType::kPrAnswer) { - flat_set matched_codecs; - for (Codec& recv_codec : recv_params.codecs) { - if (absl::c_any_of(matched_codecs, [&](const Codec* c) { - return recv_codec.Matches(*c); - })) { - continue; - } - - std::vector send_codecs = - FindAllMatchingCodecs(send_params.codecs, recv_codec); - if (send_codecs.empty()) { - continue; - } - - bool may_ignore_packetization = false; - bool has_matching_packetization = false; - for (const Codec* send_codec : send_codecs) { - if (!send_codec->packetization.has_value() && - recv_codec.packetization.has_value()) { - may_ignore_packetization = true; - } else if (send_codec->packetization == recv_codec.packetization) { - has_matching_packetization = true; - break; - } - } - - if (may_ignore_packetization) { - recv_codec.packetization = std::nullopt; - needs_recv_params_update = true; - } else if (!has_matching_packetization) { - 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()); - return false; - } - - if (has_matching_packetization) { - matched_codecs.insert(&recv_codec); - } + RTCError status = MaybeIgnorePacketization(send_params, recv_params); + if (!status.ok()) { + error_desc = status.message(); + return false; } } @@ -1216,15 +1195,8 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, mid().c_str()); return false; } - // adjust receive streams based on send codec - media_receive_channel()->SetReceiverFeedbackParameters( - media_send_channel()->SendCodecHasLntf(), - media_send_channel()->SendCodecHasNack(), - media_send_channel()->SendCodecRtcpMode(), - media_send_channel()->SendCodecRtxTime()); - last_send_params_ = send_params; - - if (needs_recv_params_update) { + if (type == SdpType::kAnswer || type == SdpType::kPrAnswer) { + recv_params.extensions = send_params.extensions; if (!media_receive_channel()->SetReceiverParameters(recv_params)) { error_desc = StringFormat( "Failed to set recv parameters for m-section with mid='%s'.", @@ -1233,6 +1205,13 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, } last_recv_params_ = recv_params; } + // adjust receive streams based on send codec + media_receive_channel()->SetReceiverFeedbackParameters( + media_send_channel()->SendCodecHasLntf(), + media_send_channel()->SendCodecHasNack(), + media_send_channel()->SendCodecRtcpMode(), + media_send_channel()->SendCodecRtxTime()); + last_send_params_ = send_params; return UpdateRemoteStreams_w(content, type, error_desc); } diff --git a/pc/channel.h b/pc/channel.h index 36744ceb53..3cd0f919cb 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -501,14 +501,5 @@ class VideoChannel : public BaseChannel { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::BaseChannel; -using ::webrtc::VideoChannel; -using ::webrtc::VoiceChannel; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_CHANNEL_H_ diff --git a/pc/channel_interface.h b/pc/channel_interface.h index c89ada5ccd..c1c05e9525 100644 --- a/pc/channel_interface.h +++ b/pc/channel_interface.h @@ -19,7 +19,6 @@ #include "api/jsep.h" #include "api/media_types.h" #include "media/base/media_channel.h" -#include "media/base/media_config.h" #include "media/base/stream_params.h" #include "pc/rtp_transport_internal.h" #include "pc/session_description.h" @@ -103,12 +102,5 @@ class ChannelInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ChannelInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_CHANNEL_INTERFACE_H_ diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index e3488a98a9..cc9d653178 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -10,8 +10,7 @@ #include "pc/channel.h" -#include - +#include #include #include #include @@ -88,12 +87,14 @@ const webrtc::Codec kIsacCodec = webrtc::CreateAudioCodec(103, "ISAC", 40000, 1); const webrtc::Codec kH264Codec = webrtc::CreateVideoCodec(97, "H264"); const webrtc::Codec kH264SvcCodec = webrtc::CreateVideoCodec(99, "H264-SVC"); -const uint32_t kSsrc1 = 0x1111; -const uint32_t kSsrc2 = 0x2222; -const uint32_t kSsrc3 = 0x3333; -const uint32_t kSsrc4 = 0x4444; -const int kAudioPts[] = {0, 8}; -const int kVideoPts[] = {97, 99}; +constexpr uint32_t kSsrc1 = 0x1111; +constexpr uint32_t kSsrc2 = 0x2222; +constexpr uint32_t kSsrc3 = 0x3333; +constexpr uint32_t kSsrc4 = 0x4444; +constexpr int kAudioPts[] = {0, 8}; +constexpr int kVideoPts[] = {97, 99}; +constexpr char kAudioMid[] = "0"; +constexpr char kVideoMid[] = "1"; enum class NetworkIsWorker { Yes, No }; template ChannelTest::CreateChannel( webrtc::Thread* signaling_thread = webrtc::Thread::Current(); auto channel = std::make_unique( worker_thread, network_thread, signaling_thread, std::move(send_ch), - std::move(receive_ch), webrtc::CN_AUDIO, (flags & DTLS) != 0, + std::move(receive_ch), kAudioMid, (flags & DTLS) != 0, webrtc::CryptoOptions(), &ssrc_generator_); SendTask(network_thread, [&]() { RTC_DCHECK_RUN_ON(channel->network_thread()); @@ -1689,7 +1690,7 @@ std::unique_ptr ChannelTest::CreateChannel( webrtc::Thread* signaling_thread = webrtc::Thread::Current(); auto channel = std::make_unique( worker_thread, network_thread, signaling_thread, std::move(send_ch), - std::move(receive_ch), webrtc::CN_VIDEO, (flags & DTLS) != 0, + std::move(receive_ch), kVideoMid, (flags & DTLS) != 0, webrtc::CryptoOptions(), &ssrc_generator_); SendTask(network_thread, [&]() { RTC_DCHECK_RUN_ON(channel->network_thread()); @@ -2415,16 +2416,16 @@ TEST_F(VideoChannelSingleThreadTest, ASSERT_TRUE(channel1_->SetRemoteContent(&remote, SdpType::kAnswer, err)) << err; - EXPECT_THAT( - media_receive_channel1_impl()->recv_codecs(), - ElementsAre(AllOf(Field(&webrtc::Codec::id, 96), + EXPECT_THAT(media_receive_channel1_impl()->recv_codecs(), + UnorderedElementsAre( + AllOf(Field(&webrtc::Codec::id, 96), Field(&webrtc::Codec::packetization, std::nullopt)), AllOf(Field(&webrtc::Codec::id, 97), Field(&webrtc::Codec::packetization, webrtc::kPacketizationParamRaw)))); - EXPECT_THAT( - media_send_channel1_impl()->send_codecs(), - ElementsAre(AllOf(Field(&webrtc::Codec::id, 97), + EXPECT_THAT(media_send_channel1_impl()->send_codecs(), + UnorderedElementsAre( + AllOf(Field(&webrtc::Codec::id, 97), Field(&webrtc::Codec::packetization, webrtc::kPacketizationParamRaw)), AllOf(Field(&webrtc::Codec::id, 96), diff --git a/pc/codec_vendor.cc b/pc/codec_vendor.cc index 42d52f6487..7c5d335b5b 100644 --- a/pc/codec_vendor.cc +++ b/pc/codec_vendor.cc @@ -9,9 +9,8 @@ */ #include "pc/codec_vendor.h" -#include - #include +#include #include #include #include diff --git a/pc/codec_vendor.h b/pc/codec_vendor.h index 1472225a00..aaddc4f250 100644 --- a/pc/codec_vendor.h +++ b/pc/codec_vendor.h @@ -128,13 +128,5 @@ class CodecLookupHelper { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::CodecLookupHelper; -using ::webrtc::CodecVendor; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_CODEC_VENDOR_H_ diff --git a/pc/codec_vendor_unittest.cc b/pc/codec_vendor_unittest.cc index 8dd99f25a8..22fe53a37e 100644 --- a/pc/codec_vendor_unittest.cc +++ b/pc/codec_vendor_unittest.cc @@ -10,8 +10,7 @@ #include "pc/codec_vendor.h" -#include - +#include #include #include diff --git a/pc/congestion_control_integrationtest.cc b/pc/congestion_control_integrationtest.cc index a0bb6a6997..0851bca44b 100644 --- a/pc/congestion_control_integrationtest.cc +++ b/pc/congestion_control_integrationtest.cc @@ -11,10 +11,12 @@ // This file contains tests that verify that congestion control options // are correctly negotiated in the SDP offer/answer. +#include #include #include #include "absl/strings/str_cat.h" +#include "api/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" #include "api/rtp_parameters.h" @@ -27,13 +29,11 @@ namespace webrtc { -using ::testing::Contains; using ::testing::Eq; using ::testing::Field; using ::testing::Gt; using ::testing::HasSubstr; using ::testing::IsTrue; -using ::testing::Ne; using ::testing::Not; class PeerConnectionCongestionControlTest @@ -47,7 +47,8 @@ TEST_F(PeerConnectionCongestionControlTest, OfferContainsCcfbIfEnabled) { SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/"); ASSERT_TRUE(CreatePeerConnectionWrappers()); caller()->AddAudioVideoTracks(); - auto offer = caller()->CreateOfferAndWait(); + std::unique_ptr offer = + caller()->CreateOfferAndWait(); std::string offer_str = absl::StrCat(*offer); EXPECT_THAT(offer_str, HasSubstr("a=rtcp-fb:* ack ccfb\r\n")); } @@ -84,60 +85,10 @@ TEST_F(PeerConnectionCongestionControlTest, ReceiveOfferSetsCcfbFlag) { EXPECT_THAT(answer_str, Not(HasSubstr("transport-cc"))); } -TEST_F(PeerConnectionCongestionControlTest, CcfbGetsUsed) { +TEST_F(PeerConnectionCongestionControlTest, NegotiatingCcfbRemovesTsn) { SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/"); ASSERT_TRUE(CreatePeerConnectionWrappers()); - ConnectFakeSignaling(); - caller()->AddAudioVideoTracks(); - caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), - IsRtcOk()); - MediaExpectations media_expectations; - media_expectations.CalleeExpectsSomeAudio(); - media_expectations.CalleeExpectsSomeVideo(); - ASSERT_TRUE(ExpectNewFrames(media_expectations)); - auto pc_internal = caller()->pc_internal(); - EXPECT_THAT( - WaitUntil( - [&] { - return pc_internal->FeedbackAccordingToRfc8888CountForTesting(); - }, - Gt(0)), - IsRtcOk()); - // There should be no transport-cc generated. - EXPECT_THAT(pc_internal->FeedbackAccordingToTransportCcCountForTesting(), - Eq(0)); -} - -TEST_F(PeerConnectionCongestionControlTest, TransportCcGetsUsed) { - SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Disabled/"); - ASSERT_TRUE(CreatePeerConnectionWrappers()); - ConnectFakeSignaling(); - caller()->AddAudioVideoTracks(); - caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), - IsRtcOk()); - MediaExpectations media_expectations; - media_expectations.CalleeExpectsSomeAudio(); - media_expectations.CalleeExpectsSomeVideo(); - ASSERT_TRUE(ExpectNewFrames(media_expectations)); - auto pc_internal = caller()->pc_internal(); - EXPECT_THAT( - WaitUntil( - [&] { - return pc_internal->FeedbackAccordingToTransportCcCountForTesting(); - }, - Gt(0)), - IsRtcOk()); - // Test that RFC 8888 feedback is NOT generated when field trial disabled. - EXPECT_THAT(pc_internal->FeedbackAccordingToRfc8888CountForTesting(), Eq(0)); -} - -TEST_F(PeerConnectionCongestionControlTest, - DISABLED_CcfbGetsUsedCalleeToCaller) { - SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/"); - ASSERT_TRUE(CreatePeerConnectionWrappers()); - ConnectFakeSignaling(); + ConnectFakeSignalingForSdpOnly(); callee()->AddVideoTrack(); // Add transceivers to caller in order to accomodate reception caller()->pc()->AddTransceiver(MediaType::VIDEO); @@ -167,33 +118,68 @@ TEST_F(PeerConnectionCongestionControlTest, Not(Contains(Field("uri", &RtpExtension::uri, RtpExtension::kTransportSequenceNumberUri)))) << " in caller receiver parameters"; - + /* Callee senders are not fixed yet. + TODO: issues.webrtc.org/383078466 - enable parameters = callee()->pc()->GetSenders()[0]->GetParameters(); EXPECT_THAT(parameters.header_extensions, Not(Contains(Field("uri", &RtpExtension::uri, RtpExtension::kTransportSequenceNumberUri)))) << " in callee sender parameters"; - + */ parameters = callee()->pc()->GetReceivers()[0]->GetParameters(); EXPECT_THAT(parameters.header_extensions, Not(Contains(Field("uri", &RtpExtension::uri, RtpExtension::kTransportSequenceNumberUri)))) << " in callee receiver parameters"; +} +TEST_F(PeerConnectionCongestionControlTest, CcfbGetsUsed) { + SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/"); + ASSERT_TRUE(CreatePeerConnectionWrappers()); + ConnectFakeSignaling(); + caller()->AddAudioVideoTracks(); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; - media_expectations.CallerExpectsSomeVideo(); + media_expectations.CalleeExpectsSomeAudio(); + media_expectations.CalleeExpectsSomeVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); - auto pc_internal = callee()->pc_internal(); + auto pc_internal = caller()->pc_internal(); EXPECT_THAT( WaitUntil( [&] { - return pc_internal->FeedbackAccordingToRfc8888CountForTesting() > 2; + return pc_internal->FeedbackAccordingToRfc8888CountForTesting(); }, - IsTrue()), + Gt(0)), IsRtcOk()); // There should be no transport-cc generated. EXPECT_THAT(pc_internal->FeedbackAccordingToTransportCcCountForTesting(), Eq(0)); } +TEST_F(PeerConnectionCongestionControlTest, TransportCcGetsUsed) { + SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Disabled/"); + ASSERT_TRUE(CreatePeerConnectionWrappers()); + ConnectFakeSignaling(); + caller()->AddAudioVideoTracks(); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); + MediaExpectations media_expectations; + media_expectations.CalleeExpectsSomeAudio(); + media_expectations.CalleeExpectsSomeVideo(); + ASSERT_TRUE(ExpectNewFrames(media_expectations)); + auto pc_internal = caller()->pc_internal(); + EXPECT_THAT( + WaitUntil( + [&] { + return pc_internal->FeedbackAccordingToTransportCcCountForTesting(); + }, + Gt(0)), + IsRtcOk()); + // Test that RFC 8888 feedback is NOT generated when field trial disabled. + EXPECT_THAT(pc_internal->FeedbackAccordingToRfc8888CountForTesting(), Eq(0)); +} + } // namespace webrtc diff --git a/pc/connection_context.cc b/pc/connection_context.cc index 0e208ea067..9c144f05a9 100644 --- a/pc/connection_context.cc +++ b/pc/connection_context.cc @@ -22,13 +22,11 @@ #include "p2p/base/basic_packet_socket_factory.h" #include "pc/media_factory.h" #include "rtc_base/checks.h" -#include "rtc_base/crypto_random.h" #include "rtc_base/internal/default_socket_server.h" #include "rtc_base/network.h" #include "rtc_base/socket_factory.h" #include "rtc_base/socket_server.h" #include "rtc_base/thread.h" -#include "rtc_base/time_utils.h" namespace webrtc { @@ -140,8 +138,6 @@ ConnectionContext::ConnectionContext( }); } - InitRandom(Time32()); - SocketFactory* socket_factory = dependencies->socket_factory; if (socket_factory == nullptr) { if (owned_socket_factory_) { diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc index f8018d7187..14f085737a 100644 --- a/pc/data_channel_controller.cc +++ b/pc/data_channel_controller.cc @@ -19,10 +19,10 @@ #include #include "absl/algorithm/container.h" +#include "absl/functional/any_invocable.h" #include "api/array_view.h" #include "api/data_channel_event_observer_interface.h" #include "api/data_channel_interface.h" -#include "api/peer_connection_interface.h" #include "api/priority.h" #include "api/rtc_error.h" #include "api/scoped_refptr.h" @@ -330,7 +330,7 @@ void DataChannelController::OnDataChannelOpenMessage( channel_usage_ = DataChannelUsage::kInUse; auto proxy = SctpDataChannel::CreateProxy(channel, signaling_safety_.flag()); - pc_->Observer()->OnDataChannel(proxy); + pc_->RunWithObserver([&](auto observer) { observer->OnDataChannel(proxy); }); pc_->NoteDataAddedEvent(); if (ready_to_send) { diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc index 9b0800a41e..03111a3e4e 100644 --- a/pc/data_channel_integrationtest.cc +++ b/pc/data_channel_integrationtest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include +#include #include #include #include @@ -63,6 +62,7 @@ namespace { using ::testing::Eq; using ::testing::IsTrue; using ::testing::Ne; +using ::testing::NotNull; using ::testing::ValuesIn; // All tests in this file require SCTP support. @@ -75,6 +75,13 @@ using ::testing::ValuesIn; #define DISABLED_ON_ANDROID(t) t #endif +void VerifySctpState(PeerConnectionIntegrationWrapper* pc, + SctpTransportState expected_state) { + auto sctp_transport = pc->pc()->GetSctpTransport(); + ASSERT_TRUE(sctp_transport); + EXPECT_EQ(sctp_transport->Information().state(), expected_state); +} + class DataChannelIntegrationTest : public PeerConnectionIntegrationBaseTest, public ::testing::WithParamInterface> { @@ -1383,6 +1390,94 @@ TEST_P(DataChannelIntegrationTest, callee()->data_observer()->received_message_count()); } +TEST_P(DataChannelIntegrationTest, ChangingSctpPortIsNotAllowed) { + ASSERT_TRUE(CreatePeerConnectionWrappers()); + ConnectFakeSignaling(); + caller()->CreateDataChannel(); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)), + IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()), + IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()), + IsRtcOk()); + + std::unique_ptr answer; + caller()->SetReceivedSdpMunger( + [&answer](std::unique_ptr& desc) { + // Change the SCTP port. + ContentInfo* sctp_content = GetFirstDataContent(desc->description()); + ASSERT_TRUE(sctp_content); + auto sctp_description = sctp_content->media_description()->as_sctp(); + ASSERT_TRUE(sctp_description); + sctp_description->set_port(sctp_description->port() + 1); + + // Capture and suppress the answer. + answer.reset(desc.release()); + }); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT(answer, NotNull()); + + // Currently SRD succeeds. + EXPECT_TRUE(caller()->SetRemoteDescription(std::move(answer))); + // Check the state of the SCTP transport. + VerifySctpState(caller(), SctpTransportState::kClosed); +} + +TEST_P(DataChannelIntegrationTest, ChangingSctpPortIsAllowedWithDtlsRestart) { + ASSERT_TRUE(CreatePeerConnectionWrappers()); + ConnectFakeSignaling(); + caller()->CreateDataChannel(); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return callee()->data_channel(); }, Ne(nullptr)), + IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return caller()->data_observer()->IsOpen(); }, IsTrue()), + IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return callee()->data_observer()->IsOpen(); }, IsTrue()), + IsRtcOk()); + + // Recreate the second peerconnection. + PeerConnectionDependencies dependencies(nullptr); + std::unique_ptr cert_generator( + new FakeRTCCertificateGenerator()); + cert_generator->use_alternate_key(); + dependencies.cert_generator = std::move(cert_generator); + SetCalleePcWrapperAndReturnCurrent(CreatePeerConnectionWrapper( + "Callee2", nullptr, {}, std::move(dependencies), nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false, + /*create_media_engine=*/false)); + ConnectFakeSignaling(); + + std::unique_ptr answer; + caller()->SetReceivedSdpMunger( + [&answer](std::unique_ptr& desc) { + // Change the SCTP port. + ContentInfo* sctp_content = GetFirstDataContent(desc->description()); + ASSERT_TRUE(sctp_content); + auto sctp_description = sctp_content->media_description()->as_sctp(); + ASSERT_TRUE(sctp_description); + sctp_description->set_port(sctp_description->port() + 1); + + // Capture and suppress the answer. + answer.reset(desc.release()); + }); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_THAT(answer, NotNull()); + + EXPECT_TRUE(caller()->SetRemoteDescription(std::move(answer))); + // Check the state of the SCTP transport. + VerifySctpState(caller(), SctpTransportState::kConnected); +} + INSTANTIATE_TEST_SUITE_P(DataChannelIntegrationTest, DataChannelIntegrationTest, Combine(Values(SdpSemantics::kPlanB_DEPRECATED, @@ -1626,14 +1721,17 @@ class DataChannelIntegrationTestUnifiedPlanFieldTrials const char* CheckSupported() { const bool callee_active = std::get<0>(GetParam()); + const bool caller_has_dtls_in_stun = absl::StrContains( + std::get<1>(GetParam()), "WebRTC-IceHandshakeDtls/Enabled/"); const bool callee_has_dtls_in_stun = absl::StrContains( std::get<2>(GetParam()), "WebRTC-IceHandshakeDtls/Enabled/"); const bool callee2_has_dtls_in_stun = absl::StrContains( std::get<3>(GetParam()), "WebRTC-IceHandshakeDtls/Enabled/"); - if (callee_active && - (callee_has_dtls_in_stun || callee2_has_dtls_in_stun)) { + if (callee_active && (caller_has_dtls_in_stun || callee_has_dtls_in_stun || + callee2_has_dtls_in_stun)) { return "dtls-in-stun when callee(s) are dtls clients"; } + return nullptr; } }; @@ -1674,6 +1772,14 @@ TEST_P(DataChannelIntegrationTestUnifiedPlanFieldTrials, // Capture offer so that it can be sent to Callee2 too. offer = sdp->Clone(); }); + callee2->SetReceivedSdpMunger( + [&](std::unique_ptr& sdp) { + if (callee_active) { + MakeOfferHavePassiveDtlsRole(sdp); + } else { + MakeOfferHaveActiveDtlsRole(sdp); + } + }); callee()->SetGeneratedSdpMunger( [&](std::unique_ptr& sdp) { // Modify offer to kPrAnswer @@ -1684,6 +1790,14 @@ TEST_P(DataChannelIntegrationTestUnifiedPlanFieldTrials, MakeOfferHavePassiveDtlsRole(sdp); } }); + callee2->SetGeneratedSdpMunger( + [&](std::unique_ptr& sdp) { + if (callee_active) { + MakeOfferHaveActiveDtlsRole(sdp); + } else { + MakeOfferHavePassiveDtlsRole(sdp); + } + }); caller()->CreateAndSetAndSignalOffer(); ASSERT_FALSE(HasFailure()); WaitConnectedAndDcOpen(/* prAnswer= */ true, caller(), callee()); @@ -1716,6 +1830,9 @@ TEST_P(DataChannelIntegrationTestUnifiedPlanFieldTrials, VerifyReceivedDcMessages(caller(), "KENT", callee2_sent_on_dc); VerifyReceivedDcMessages(callee2.get(), "KESO", caller_sent_on_dc); VerifyDtlsRoles(caller(), callee2.get()); + VerifySctpState(caller(), SctpTransportState::kConnected); + VerifySctpState(callee(), SctpTransportState::kClosed); + VerifySctpState(callee2.get(), SctpTransportState::kConnected); ASSERT_FALSE(HasFailure()); } @@ -1738,6 +1855,14 @@ TEST_P(DataChannelIntegrationTestUnifiedPlanFieldTrials, // Capture offer so that it can be sent to Callee2 too. offer = sdp->Clone(); }); + callee2->SetReceivedSdpMunger( + [&](std::unique_ptr& sdp) { + if (callee_active) { + MakeOfferHavePassiveDtlsRole(sdp); + } else { + MakeOfferHaveActiveDtlsRole(sdp); + } + }); callee()->SetGeneratedSdpMunger( [&](std::unique_ptr& sdp) { // Modify offer to kPrAnswer @@ -1748,6 +1873,14 @@ TEST_P(DataChannelIntegrationTestUnifiedPlanFieldTrials, MakeOfferHavePassiveDtlsRole(sdp); } }); + callee2->SetGeneratedSdpMunger( + [&](std::unique_ptr& sdp) { + if (callee_active) { + MakeOfferHaveActiveDtlsRole(sdp); + } else { + MakeOfferHavePassiveDtlsRole(sdp); + } + }); bool first_answer = true; std::unique_ptr answer; caller()->SetReceivedSdpMunger( @@ -1806,6 +1939,7 @@ TEST_P(DataChannelIntegrationTestUnifiedPlanFieldTrials, ASSERT_THAT(answer, testing::Not(testing::IsNull())); std::string answer_sdp; EXPECT_TRUE(answer->ToString(&answer_sdp)); + caller()->ReceiveSdpMessage(SdpType::kAnswer, answer_sdp); EXPECT_EQ(caller()->pc()->signaling_state(), diff --git a/pc/data_channel_unittest.cc b/pc/data_channel_unittest.cc index 9b4802afa3..603b7f91d6 100644 --- a/pc/data_channel_unittest.cc +++ b/pc/data_channel_unittest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include +#include #include #include #include diff --git a/pc/dtls_srtp_transport_unittest.cc b/pc/dtls_srtp_transport_unittest.cc index a4c27fe017..40108df646 100644 --- a/pc/dtls_srtp_transport_unittest.cc +++ b/pc/dtls_srtp_transport_unittest.cc @@ -10,9 +10,8 @@ #include "pc/dtls_srtp_transport.h" -#include - #include +#include #include #include @@ -46,7 +45,7 @@ using ::webrtc::FieldTrials; using ::webrtc::RtpTransport; using ::webrtc::SrtpTransport; -const int kRtpAuthTagLen = 10; +constexpr int kRtpAuthTagLen = 10; class DtlsSrtpTransportTest : public ::testing::Test, public sigslot::has_slots<> { diff --git a/pc/dtmf_sender.cc b/pc/dtmf_sender.cc index 6ecc285c08..703fe9b459 100644 --- a/pc/dtmf_sender.cc +++ b/pc/dtmf_sender.cc @@ -10,10 +10,9 @@ #include "pc/dtmf_sender.h" -#include -#include - +#include #include +#include #include #include "api/dtmf_sender_interface.h" diff --git a/pc/dtmf_sender_unittest.cc b/pc/dtmf_sender_unittest.cc index 82b149b9db..deb18fe769 100644 --- a/pc/dtmf_sender_unittest.cc +++ b/pc/dtmf_sender_unittest.cc @@ -10,8 +10,7 @@ #include "pc/dtmf_sender.h" -#include - +#include #include #include #include diff --git a/pc/external_hmac.cc b/pc/external_hmac.cc index 77f11a32d7..a0ee51b5c5 100644 --- a/pc/external_hmac.cc +++ b/pc/external_hmac.cc @@ -10,10 +10,9 @@ #include "pc/external_hmac.h" -#include // For malloc/free. -#include - #include +#include +#include #include "rtc_base/logging.h" #include "rtc_base/zero_memory.h" diff --git a/pc/ice_server_parsing.cc b/pc/ice_server_parsing.cc index ee3b4467d2..58bc996b80 100644 --- a/pc/ice_server_parsing.cc +++ b/pc/ice_server_parsing.cc @@ -10,9 +10,8 @@ #include "pc/ice_server_parsing.h" -#include - -#include // For std::isdigit. +#include +#include #include #include #include diff --git a/pc/jsep_session_description.cc b/pc/jsep_session_description.cc index bbeb4c3c07..f4a955eff7 100644 --- a/pc/jsep_session_description.cc +++ b/pc/jsep_session_description.cc @@ -10,7 +10,9 @@ #include "api/jsep_session_description.h" +#include #include +#include #include #include #include @@ -101,7 +103,6 @@ void UpdateConnectionAddress( } media_desc->set_connection_address(connection_addr); } - } // namespace // TODO(steveanton): Remove this default implementation once Chromium has been @@ -278,23 +279,6 @@ bool JsepSessionDescription::RemoveCandidate(const IceCandidate* candidate) { return true; } -size_t JsepSessionDescription::RemoveCandidates( - const std::vector& candidates) { - size_t num_removed = 0; - for (auto& candidate : candidates) { - int mediasection_index = GetMediasectionIndex(candidate); - if (mediasection_index < 0) { - // Not found. - continue; - } - num_removed += candidate_collection_[mediasection_index].remove(candidate); - UpdateConnectionAddress( - candidate_collection_[mediasection_index], - description_->contents()[mediasection_index].media_description()); - } - return num_removed; -} - size_t JsepSessionDescription::number_of_mediasections() const { if (!description_) return 0; @@ -316,51 +300,33 @@ bool JsepSessionDescription::ToString(std::string* out) const { return !out->empty(); } -bool JsepSessionDescription::GetMediasectionIndex(const IceCandidate* candidate, - size_t* index) { - if (!candidate || !index) { - return false; - } +bool JsepSessionDescription::IsValidMLineIndex(int index) const { + RTC_DCHECK(description_); + return index >= 0 && + index < static_cast(description_->contents().size()); +} - // If the candidate has no valid mline index or sdp_mid, it is impossible - // to find a match. - if (candidate->sdp_mid().empty() && - (candidate->sdp_mline_index() < 0 || - static_cast(candidate->sdp_mline_index()) >= - description_->contents().size())) { +bool JsepSessionDescription::GetMediasectionIndex(const IceCandidate* candidate, + size_t* index) const { + if (!candidate || !index || !description_) { return false; } - if (candidate->sdp_mline_index() >= 0) + auto mid = candidate->sdp_mid(); + if (!mid.empty()) { + *index = GetMediasectionIndex(mid); + } else { + // An sdp_mline_index of -1 will be treated as invalid. *index = static_cast(candidate->sdp_mline_index()); - if (description_ && !candidate->sdp_mid().empty()) { - bool found = false; - // Try to match the sdp_mid with content name. - for (size_t i = 0; i < description_->contents().size(); ++i) { - if (candidate->sdp_mid() == description_->contents().at(i).mid()) { - *index = i; - found = true; - break; - } - } - if (!found) { - // If the sdp_mid is presented but we can't find a match, we consider - // this as an error. - return false; - } } - return true; + return IsValidMLineIndex(*index); } -int JsepSessionDescription::GetMediasectionIndex(const Candidate& candidate) { - // Find the description with a matching transport name of the candidate. - const std::string& transport_name = candidate.transport_name(); - for (size_t i = 0; i < description_->contents().size(); ++i) { - if (transport_name == description_->contents().at(i).mid()) { - return static_cast(i); - } - } - return -1; +int JsepSessionDescription::GetMediasectionIndex(absl::string_view mid) const { + const auto& contents = description_->contents(); + auto it = + std::find_if(contents.begin(), contents.end(), + [&](const auto& content) { return mid == content.mid(); }); + return it == contents.end() ? -1 : std::distance(contents.begin(), it); } - } // namespace webrtc diff --git a/pc/jsep_session_description_unittest.cc b/pc/jsep_session_description_unittest.cc index d561a3b1d3..5a90b3e82f 100644 --- a/pc/jsep_session_description_unittest.cc +++ b/pc/jsep_session_description_unittest.cc @@ -10,9 +10,8 @@ #include "api/jsep_session_description.h" -#include -#include - +#include +#include #include #include #include @@ -33,67 +32,65 @@ #include "test/gmock.h" #include "test/gtest.h" +namespace webrtc { + using ::testing::NotNull; using ::testing::Values; -using webrtc::IceCandidate; -using webrtc::IceCandidateCollection; -using webrtc::IceCandidateType; -using webrtc::JsepSessionDescription; -using ::webrtc::MediaProtocolType; -using webrtc::SdpType; -using webrtc::SessionDescriptionInterface; - -static const char kCandidateUfrag[] = "ufrag"; -static const char kCandidatePwd[] = "pwd"; -static const char kCandidateUfragVoice[] = "ufrag_voice"; -static const char kCandidatePwdVoice[] = "pwd_voice"; -static const char kCandidateUfragVideo[] = "ufrag_video"; -static const char kCandidatePwdVideo[] = "pwd_video"; -static const char kCandidateFoundation[] = "a0+B/1"; -static const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0 -static const uint32_t kCandidateGeneration = 2; + +namespace { +constexpr char kAudioMid[] = "audio"; +constexpr char kVideoMid[] = "video"; +constexpr char kCandidateUfrag[] = "ufrag"; +constexpr char kCandidatePwd[] = "pwd"; +constexpr char kCandidateUfragVoice[] = "ufrag_voice"; +constexpr char kCandidatePwdVoice[] = "pwd_voice"; +constexpr char kCandidateUfragVideo[] = "ufrag_video"; +constexpr char kCandidatePwdVideo[] = "pwd_video"; +constexpr char kCandidateFoundation[] = "a0+B/1"; +constexpr uint32_t kCandidatePriority = 2130706432U; // pref = 1.0 +constexpr uint32_t kCandidateGeneration = 2; // This creates a session description with both audio and video media contents. // In SDP this is described by two m lines, one audio and one video. -static std::unique_ptr -CreateCricketSessionDescription() { - auto desc = std::make_unique(); +std::unique_ptr CreateCricketSessionDescription() { + auto desc = std::make_unique(); // AudioContentDescription - auto audio = std::make_unique(); + auto audio = std::make_unique(); // VideoContentDescription - auto video = std::make_unique(); - - audio->AddCodec(webrtc::CreateAudioCodec(103, "ISAC", 16000, 0)); - desc->AddContent(webrtc::CN_AUDIO, MediaProtocolType::kRtp, std::move(audio)); - - video->AddCodec(webrtc::CreateVideoCodec(120, "VP8")); - desc->AddContent(webrtc::CN_VIDEO, MediaProtocolType::kRtp, std::move(video)); - - desc->AddTransportInfo(webrtc::TransportInfo( - webrtc::CN_AUDIO, - webrtc::TransportDescription( - std::vector(), kCandidateUfragVoice, kCandidatePwdVoice, - 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, nullptr))); + auto video = std::make_unique(); + + audio->AddCodec(CreateAudioCodec(103, "ISAC", 16000, 0)); + desc->AddContent(kAudioMid, MediaProtocolType::kRtp, std::move(audio)); + + video->AddCodec(CreateVideoCodec(120, "VP8")); + desc->AddContent(kVideoMid, MediaProtocolType::kRtp, std::move(video)); + + desc->AddTransportInfo(TransportInfo( + kAudioMid, + TransportDescription(std::vector(), kCandidateUfragVoice, + kCandidatePwdVoice, ICEMODE_FULL, + CONNECTIONROLE_NONE, nullptr))); + desc->AddTransportInfo(TransportInfo( + kVideoMid, + TransportDescription(std::vector(), kCandidateUfragVideo, + kCandidatePwdVideo, ICEMODE_FULL, + CONNECTIONROLE_NONE, nullptr))); return desc; } +} // namespace + class JsepSessionDescriptionTest : public ::testing::Test { protected: void SetUp() override { int port = 1234; - webrtc::SocketAddress address("127.0.0.1", port++); - webrtc::Candidate candidate(webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - address, 1, "", "", IceCandidateType::kHost, 0, - "1"); + SocketAddress address("127.0.0.1", port++); + Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "udp", address, 1, "", "", + IceCandidateType::kHost, 0, "1"); candidate_ = candidate; - const std::string session_id = absl::StrCat(webrtc::CreateRandomId64()); - const std::string session_version = absl::StrCat(webrtc::CreateRandomId()); + const std::string session_id = absl::StrCat(CreateRandomId64()); + const std::string session_version = absl::StrCat(CreateRandomId()); jsep_desc_ = std::make_unique(SdpType::kOffer); ASSERT_TRUE(jsep_desc_->Initialize(CreateCricketSessionDescription(), session_id, session_version)); @@ -109,11 +106,11 @@ class JsepSessionDescriptionTest : public ::testing::Test { std::unique_ptr DeSerialize( const std::string& sdp) { auto jsep_desc = std::make_unique(SdpType::kOffer); - EXPECT_TRUE(webrtc::SdpDeserialize(sdp, jsep_desc.get(), nullptr)); + EXPECT_TRUE(SdpDeserialize(sdp, jsep_desc.get(), nullptr)); return std::move(jsep_desc); } - webrtc::Candidate candidate_; + Candidate candidate_; std::unique_ptr jsep_desc_; }; @@ -136,14 +133,14 @@ TEST_F(JsepSessionDescriptionTest, CloneRollback) { } TEST_F(JsepSessionDescriptionTest, CloneWithCandidates) { - webrtc::Candidate candidate_v4( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("192.168.1.5", 1234), kCandidatePriority, "", "", - IceCandidateType::kSrflx, kCandidateGeneration, kCandidateFoundation); - webrtc::Candidate candidate_v6( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); + Candidate candidate_v4(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("192.168.1.5", 1234), kCandidatePriority, + "", "", IceCandidateType::kSrflx, kCandidateGeneration, + kCandidateFoundation); + Candidate candidate_v6(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("::1", 1234), kCandidatePriority, "", "", + IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation); IceCandidate jice_v4("audio", 0, candidate_v4); IceCandidate jice_v6("audio", 0, candidate_v6); @@ -168,6 +165,16 @@ TEST_F(JsepSessionDescriptionTest, CheckSessionDescription) { EXPECT_EQ(2u, jsep_desc_->number_of_mediasections()); } +TEST_F(JsepSessionDescriptionTest, IsValidMLineIndex) { + ASSERT_GT(jsep_desc_->number_of_mediasections(), 0u); + // Create a candidate with no mid and an illegal index. + IceCandidate ice_candidate("", -1, candidate_); + EXPECT_FALSE(jsep_desc_->AddCandidate(&ice_candidate)); + IceCandidate ice_candidate2("", jsep_desc_->number_of_mediasections(), + candidate_); + EXPECT_FALSE(jsep_desc_->AddCandidate(&ice_candidate2)); +} + // Test that we can add a candidate to a session description without MID. TEST_F(JsepSessionDescriptionTest, AddCandidateWithoutMid) { IceCandidate jsep_candidate("", 0, candidate_); @@ -228,9 +235,7 @@ TEST_F(JsepSessionDescriptionTest, AddAndRemoveCandidatesWithMid) { // The mline index should have been updated according to mid. EXPECT_EQ(1, ice_candidate->sdp_mline_index()); - std::vector candidates(1, candidate_); - candidates[0].set_transport_name(mid); - EXPECT_EQ(1u, jsep_desc_->RemoveCandidates(candidates)); + EXPECT_EQ(1u, jsep_desc_->RemoveCandidate(ice_candidate)); EXPECT_EQ(0u, jsep_desc_->candidates(0)->count()); EXPECT_EQ(0u, jsep_desc_->candidates(1)->count()); } @@ -287,10 +292,10 @@ TEST_F(JsepSessionDescriptionTest, AddCandidateDuplicates) { // Test that the connection address is set to a hostname address after adding a // hostname candidate. TEST_F(JsepSessionDescriptionTest, AddHostnameCandidate) { - webrtc::Candidate c; - c.set_component(webrtc::ICE_CANDIDATE_COMPONENT_RTP); - c.set_protocol(webrtc::UDP_PROTOCOL_NAME); - c.set_address(webrtc::SocketAddress("example.local", 1234)); + Candidate c; + c.set_component(ICE_CANDIDATE_COMPONENT_RTP); + c.set_protocol(UDP_PROTOCOL_NAME); + c.set_address(SocketAddress("example.local", 1234)); c.set_type(IceCandidateType::kHost); const size_t audio_index = 0; IceCandidate hostname_candidate("audio", audio_index, c); @@ -318,10 +323,10 @@ TEST_F(JsepSessionDescriptionTest, SerializeDeserialize) { // is the default destination and deserialize it again. The connection address // in the deserialized description should be the dummy address 0.0.0.0:9. TEST_F(JsepSessionDescriptionTest, SerializeDeserializeWithHostnameCandidate) { - webrtc::Candidate c; - c.set_component(webrtc::ICE_CANDIDATE_COMPONENT_RTP); - c.set_protocol(webrtc::UDP_PROTOCOL_NAME); - c.set_address(webrtc::SocketAddress("example.local", 1234)); + Candidate c; + c.set_component(ICE_CANDIDATE_COMPONENT_RTP); + c.set_protocol(UDP_PROTOCOL_NAME); + c.set_address(SocketAddress("example.local", 1234)); c.set_type(IceCandidateType::kHost); const size_t audio_index = 0; const size_t video_index = 1; @@ -371,14 +376,14 @@ TEST_F(JsepSessionDescriptionTest, SerializeDeserializeWithCandidates) { // is used as default address in c line according to preference. TEST_F(JsepSessionDescriptionTest, SerializeSessionDescriptionWithIPv6Only) { // Stun has a high preference than local host. - webrtc::Candidate candidate1( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", - IceCandidateType::kSrflx, kCandidateGeneration, kCandidateFoundation); - webrtc::Candidate candidate2( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("::2", 1235), kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); + Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("::1", 1234), kCandidatePriority, "", "", + IceCandidateType::kSrflx, kCandidateGeneration, + kCandidateFoundation); + Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("::2", 1235), kCandidatePriority, "", "", + IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation); IceCandidate jice1("audio", 0, candidate1); IceCandidate jice2("audio", 0, candidate2); @@ -401,14 +406,14 @@ TEST_F(JsepSessionDescriptionTest, SerializeSessionDescriptionWithIPv6Only) { // preference of IPv4 is lower. TEST_F(JsepSessionDescriptionTest, SerializeSessionDescriptionWithBothIPFamilies) { - webrtc::Candidate candidate_v4( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("192.168.1.5", 1234), kCandidatePriority, "", "", - IceCandidateType::kSrflx, kCandidateGeneration, kCandidateFoundation); - webrtc::Candidate candidate_v6( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); + Candidate candidate_v4(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("192.168.1.5", 1234), kCandidatePriority, + "", "", IceCandidateType::kSrflx, kCandidateGeneration, + kCandidateFoundation); + Candidate candidate_v6(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("::1", 1234), kCandidatePriority, "", "", + IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation); IceCandidate jice_v4("audio", 0, candidate_v4); IceCandidate jice_v6("audio", 0, candidate_v6); @@ -432,15 +437,14 @@ TEST_F(JsepSessionDescriptionTest, TEST_F(JsepSessionDescriptionTest, SerializeSessionDescriptionWithBothProtocols) { // Stun has a high preference than local host. - webrtc::Candidate candidate1( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "tcp", - webrtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", - IceCandidateType::kSrflx, kCandidateGeneration, kCandidateFoundation); - webrtc::Candidate candidate2( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("fe80::1234:5678:abcd:ef12", 1235), - kCandidatePriority, "", "", IceCandidateType::kHost, kCandidateGeneration, - kCandidateFoundation); + Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "tcp", + SocketAddress("::1", 1234), kCandidatePriority, "", "", + IceCandidateType::kSrflx, kCandidateGeneration, + kCandidateFoundation); + Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("fe80::1234:5678:abcd:ef12", 1235), + kCandidatePriority, "", "", IceCandidateType::kHost, + kCandidateGeneration, kCandidateFoundation); IceCandidate jice1("audio", 0, candidate1); IceCandidate jice2("audio", 0, candidate2); @@ -463,14 +467,14 @@ TEST_F(JsepSessionDescriptionTest, // null IPv4 is used as default address in c line. TEST_F(JsepSessionDescriptionTest, SerializeSessionDescriptionWithTCPOnly) { // Stun has a high preference than local host. - webrtc::Candidate candidate1( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "tcp", - webrtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", - IceCandidateType::kSrflx, kCandidateGeneration, kCandidateFoundation); - webrtc::Candidate candidate2( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "tcp", - webrtc::SocketAddress("::2", 1235), kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); + Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "tcp", + SocketAddress("::1", 1234), kCandidatePriority, "", "", + IceCandidateType::kSrflx, kCandidateGeneration, + kCandidateFoundation); + Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTP, "tcp", + SocketAddress("::2", 1235), kCandidatePriority, "", "", + IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation); IceCandidate jice1("audio", 0, candidate1); IceCandidate jice2("audio", 0, candidate2); @@ -490,24 +494,18 @@ TEST_F(JsepSessionDescriptionTest, SerializeSessionDescriptionWithTCPOnly) { // Tests that the connection address will be correctly set when the Candidate is // removed. TEST_F(JsepSessionDescriptionTest, RemoveCandidateAndSetConnectionAddress) { - webrtc::Candidate candidate1( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("::1", 1234), kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); - candidate1.set_transport_name("audio"); - - webrtc::Candidate candidate2( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "tcp", - webrtc::SocketAddress("::2", 1235), kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); - candidate2.set_transport_name("audio"); - - webrtc::Candidate candidate3( - webrtc::ICE_CANDIDATE_COMPONENT_RTP, "udp", - webrtc::SocketAddress("192.168.1.1", 1236), kCandidatePriority, "", "", - IceCandidateType::kHost, kCandidateGeneration, kCandidateFoundation); - candidate3.set_transport_name("audio"); - + Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("::1", 1234), kCandidatePriority, "", "", + IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation); + Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTP, "tcp", + SocketAddress("::2", 1235), kCandidatePriority, "", "", + IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation); + Candidate candidate3(ICE_CANDIDATE_COMPONENT_RTP, "udp", + SocketAddress("192.168.1.1", 1236), kCandidatePriority, + "", "", IceCandidateType::kHost, kCandidateGeneration, + kCandidateFoundation); IceCandidate jice1("audio", 0, candidate1); IceCandidate jice2("audio", 0, candidate2); IceCandidate jice3("audio", 0, candidate3); @@ -520,21 +518,15 @@ TEST_F(JsepSessionDescriptionTest, RemoveCandidateAndSetConnectionAddress) { ASSERT_TRUE(jsep_desc_->AddCandidate(&jice2)); ASSERT_TRUE(jsep_desc_->AddCandidate(&jice3)); - std::vector candidates; EXPECT_EQ("192.168.1.1:1236", media_desc->connection_address().ToString()); - candidates.push_back(candidate3); - ASSERT_TRUE(jsep_desc_->RemoveCandidates(candidates)); + ASSERT_TRUE(jsep_desc_->RemoveCandidate(&jice3)); EXPECT_EQ("[::1]:1234", media_desc->connection_address().ToString()); - candidates.clear(); - candidates.push_back(candidate2); - ASSERT_TRUE(jsep_desc_->RemoveCandidates(candidates)); + ASSERT_TRUE(jsep_desc_->RemoveCandidate(&jice2)); EXPECT_EQ("[::1]:1234", media_desc->connection_address().ToString()); - candidates.clear(); - candidates.push_back(candidate1); - ASSERT_TRUE(jsep_desc_->RemoveCandidates(candidates)); + ASSERT_TRUE(jsep_desc_->RemoveCandidate(&jice1)); EXPECT_EQ("0.0.0.0:9", media_desc->connection_address().ToString()); } @@ -545,8 +537,8 @@ class EnumerateAllSdpTypesTest : public ::testing::Test, TEST_P(EnumerateAllSdpTypesTest, TestIdentity) { SdpType type = GetParam(); - const char* str = webrtc::SdpTypeToString(type); - EXPECT_EQ(type, webrtc::SdpTypeFromString(str)); + const char* str = SdpTypeToString(type); + EXPECT_EQ(type, SdpTypeFromString(str)); } INSTANTIATE_TEST_SUITE_P(JsepSessionDescriptionTest, @@ -554,3 +546,5 @@ INSTANTIATE_TEST_SUITE_P(JsepSessionDescriptionTest, Values(SdpType::kOffer, SdpType::kPrAnswer, SdpType::kAnswer)); + +} // namespace webrtc diff --git a/pc/jsep_transport.cc b/pc/jsep_transport.cc index b1f179cef6..91b123cc1f 100644 --- a/pc/jsep_transport.cc +++ b/pc/jsep_transport.cc @@ -10,9 +10,8 @@ #include "pc/jsep_transport.h" -#include -#include - +#include +#include #include #include #include @@ -34,6 +33,7 @@ #include "p2p/base/p2p_constants.h" #include "p2p/base/p2p_transport_channel.h" #include "p2p/base/transport_description.h" +#include "p2p/dtls/dtls_transport_internal.h" #include "pc/dtls_srtp_transport.h" #include "pc/dtls_transport.h" #include "pc/rtp_transport.h" diff --git a/pc/jsep_transport.h b/pc/jsep_transport.h index 2840cc2461..017aad7fc7 100644 --- a/pc/jsep_transport.h +++ b/pc/jsep_transport.h @@ -329,13 +329,5 @@ class JsepTransport { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::JsepTransport; -using ::webrtc::JsepTransportDescription; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_JSEP_TRANSPORT_H_ diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index 0d706a20c9..6c7e539526 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -10,8 +10,7 @@ #include "pc/jsep_transport_controller.h" -#include - +#include #include #include #include @@ -408,52 +407,32 @@ RTCError JsepTransportController::AddRemoteCandidates( return jsep_transport->AddRemoteCandidates(candidates); } -RTCError JsepTransportController::RemoveRemoteCandidates( - const Candidates& candidates) { +bool JsepTransportController::RemoveRemoteCandidate(const IceCandidate* c) { if (!network_thread_->IsCurrent()) { return network_thread_->BlockingCall( - [&] { return RemoveRemoteCandidates(candidates); }); + [&] { return RemoveRemoteCandidate(c); }); } RTC_DCHECK_RUN_ON(network_thread_); - - // Verify each candidate before passing down to the transport layer. - RTCError error = VerifyCandidates(candidates); - if (!error.ok()) { - return error; + std::string mid = c->sdp_mid(); + if (!VerifyCandidate(c->candidate()).ok() || mid.empty()) { + RTC_LOG(LS_ERROR) << "Candidate invalid or missing sdp_mid: " + << c->candidate().ToSensitiveString(); + return false; } - - std::map candidates_by_transport_name; - for (const Candidate& cand : candidates) { - if (!cand.transport_name().empty()) { - candidates_by_transport_name[cand.transport_name()].push_back(cand); - } else { - RTC_LOG(LS_ERROR) << "Not removing candidate because it does not have a " - "transport name set: " - << cand.ToSensitiveString(); - } + JsepTransport* jsep_transport = GetJsepTransportForMid(mid); + if (!jsep_transport) { + RTC_LOG(LS_WARNING) << "No Transport for mid=" << mid; + return false; } - - for (const auto& kv : candidates_by_transport_name) { - const std::string& transport_name = kv.first; - const Candidates& transport_candidates = kv.second; - JsepTransport* jsep_transport = GetJsepTransportByName(transport_name); - if (!jsep_transport) { - RTC_LOG(LS_WARNING) - << "Not removing candidate because the JsepTransport doesn't exist."; - continue; - } - for (const Candidate& candidate : transport_candidates) { - DtlsTransportInternal* dtls = - candidate.component() == ICE_CANDIDATE_COMPONENT_RTP - ? jsep_transport->rtp_dtls_transport() - : jsep_transport->rtcp_dtls_transport(); - if (dtls) { - dtls->ice_transport()->RemoveRemoteCandidate(candidate); - } - } + DtlsTransportInternal* dtls = + c->candidate().component() == ICE_CANDIDATE_COMPONENT_RTP + ? jsep_transport->rtp_dtls_transport() + : jsep_transport->rtcp_dtls_transport(); + if (dtls) { + dtls->ice_transport()->RemoveRemoteCandidate(c->candidate()); } - return RTCError::OK(); + return true; } bool JsepTransportController::GetStats(const std::string& transport_name, @@ -562,8 +541,6 @@ JsepTransportController::CreateDtlsTransport(const ContentInfo& content_info, }); dtls->ice_transport()->SignalRoleConflict.connect( this, &JsepTransportController::OnTransportRoleConflict_n); - dtls->ice_transport()->SignalStateChanged.connect( - this, &JsepTransportController::OnTransportStateChanged_n); dtls->ice_transport()->SignalIceTransportStateChanged.connect( this, &JsepTransportController::OnTransportStateChanged_n); dtls->ice_transport()->SetCandidatePairChangeCallback( @@ -1321,7 +1298,7 @@ void JsepTransportController::OnTransportCandidateError_n( void JsepTransportController::OnTransportCandidatesRemoved_n( IceTransportInternal* transport, const Candidates& candidates) { - signal_ice_candidates_removed_.Send(candidates); + signal_ice_candidates_removed_.Send(transport, candidates); } void JsepTransportController::OnTransportCandidatePairChanged_n( const CandidatePairChangeEvent& event) { diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h index 202da8dc1e..374334cb90 100644 --- a/pc/jsep_transport_controller.h +++ b/pc/jsep_transport_controller.h @@ -210,7 +210,7 @@ class JsepTransportController : public PayloadTypeSuggester, void MaybeStartGathering(); RTCError AddRemoteCandidates(const std::string& mid, const std::vector& candidates); - RTCError RemoveRemoteCandidates(const std::vector& candidates); + bool RemoveRemoteCandidate(const IceCandidate* candidate); /********************** * DTLS-related methods @@ -334,8 +334,8 @@ class JsepTransportController : public PayloadTypeSuggester, CallbackList signal_ice_candidate_error_ RTC_GUARDED_BY(network_thread_); - CallbackList&> signal_ice_candidates_removed_ - RTC_GUARDED_BY(network_thread_); + CallbackList&> + signal_ice_candidates_removed_ RTC_GUARDED_BY(network_thread_); CallbackList signal_ice_candidate_pair_changed_ RTC_GUARDED_BY(network_thread_); diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc index dc106922a9..085a9afe28 100644 --- a/pc/jsep_transport_controller_unittest.cc +++ b/pc/jsep_transport_controller_unittest.cc @@ -278,9 +278,8 @@ class JsepTransportControllerTest : public JsepTransportController::Observer, return config; } - Candidate CreateCandidate(const std::string& transport_name, int component) { + Candidate CreateCandidate(int component = ICE_CANDIDATE_COMPONENT_RTP) { Candidate c; - c.set_transport_name(transport_name); c.set_address(SocketAddress("192.168.1.1", 8000)); c.set_component(component); c.set_protocol(UDP_PROTOCOL_NAME); @@ -308,11 +307,9 @@ class JsepTransportControllerTest : public JsepTransportController::Observer, auto fake_video_dtls = static_cast( transport_controller_->GetDtlsTransport(kVideoMid1)); fake_audio_dtls->fake_ice_transport()->SignalCandidateGathered( - fake_audio_dtls->fake_ice_transport(), - CreateCandidate(kAudioMid1, /*component=*/1)); + fake_audio_dtls->fake_ice_transport(), CreateCandidate()); fake_video_dtls->fake_ice_transport()->SignalCandidateGathered( - fake_video_dtls->fake_ice_transport(), - CreateCandidate(kVideoMid1, /*component=*/1)); + fake_video_dtls->fake_ice_transport(), CreateCandidate()); fake_audio_dtls->fake_ice_transport()->SetCandidatesGatheringComplete(); fake_video_dtls->fake_ice_transport()->SetCandidatesGatheringComplete(); fake_audio_dtls->fake_ice_transport()->SetConnectionCount(2); @@ -581,14 +578,14 @@ TEST_F(JsepTransportControllerTest, AddRemoveRemoteCandidates) { transport_controller_->GetDtlsTransport(kAudioMid1)); ASSERT_NE(nullptr, fake_audio_dtls); Candidates candidates; - candidates.push_back( - CreateCandidate(kAudioMid1, ICE_CANDIDATE_COMPONENT_RTP)); + candidates.push_back(CreateCandidate()); EXPECT_TRUE( transport_controller_->AddRemoteCandidates(kAudioMid1, candidates).ok()); EXPECT_EQ(1U, fake_audio_dtls->fake_ice_transport()->remote_candidates().size()); - EXPECT_TRUE(transport_controller_->RemoveRemoteCandidates(candidates).ok()); + IceCandidate ice_candidate(kAudioMid1, -1, candidates[0]); + EXPECT_TRUE(transport_controller_->RemoveRemoteCandidate(&ice_candidate)); EXPECT_EQ(0U, fake_audio_dtls->fake_ice_transport()->remote_candidates().size()); } @@ -1122,7 +1119,7 @@ TEST_F(JsepTransportControllerTest, SignalCandidatesGathered) { auto fake_audio_dtls = static_cast( transport_controller_->GetDtlsTransport(kAudioMid1)); fake_audio_dtls->fake_ice_transport()->SignalCandidateGathered( - fake_audio_dtls->fake_ice_transport(), CreateCandidate(kAudioMid1, 1)); + fake_audio_dtls->fake_ice_transport(), CreateCandidate()); EXPECT_THAT( WaitUntil([&] { return 1; }, ::testing::Eq(candidates_signal_count_), {.timeout = TimeDelta::Millis(kTimeout)}), diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc index f4257774f6..48a41472ad 100644 --- a/pc/jsep_transport_unittest.cc +++ b/pc/jsep_transport_unittest.cc @@ -10,9 +10,8 @@ #include "pc/jsep_transport.h" -#include -#include - +#include +#include #include #include #include @@ -61,11 +60,11 @@ namespace webrtc { namespace { -const char kIceUfrag1[] = "U001"; -const char kIcePwd1[] = "TESTICEPWD00000000000001"; -const char kIceUfrag2[] = "U002"; -const char kIcePwd2[] = "TESTIEPWD00000000000002"; -const char kTransportName[] = "Test Transport"; +constexpr char kIceUfrag1[] = "U001"; +constexpr char kIcePwd1[] = "TESTICEPWD00000000000001"; +constexpr char kIceUfrag2[] = "U002"; +constexpr char kIcePwd2[] = "TESTIEPWD00000000000002"; +constexpr char kTransportName[] = "Test Transport"; struct NegotiateRoleParams { ConnectionRole local_role; diff --git a/pc/legacy_stats_collector.cc b/pc/legacy_stats_collector.cc index e871468183..b4bf87f75e 100644 --- a/pc/legacy_stats_collector.cc +++ b/pc/legacy_stats_collector.cc @@ -10,11 +10,10 @@ #include "pc/legacy_stats_collector.h" -#include -#include - #include #include +#include +#include #include #include #include @@ -1394,7 +1393,7 @@ void LegacyStatsCollector::UpdateReportFromAudioTrack( auto audio_processor(track->GetAudioProcessor()); - if (audio_processor.get()) { + if (audio_processor) { AudioProcessorInterface::AudioProcessorStatistics stats = audio_processor->GetStats(has_remote_tracks); diff --git a/pc/legacy_stats_collector_unittest.cc b/pc/legacy_stats_collector_unittest.cc index 5f6aff4ffa..c5e0b1a248 100644 --- a/pc/legacy_stats_collector_unittest.cc +++ b/pc/legacy_stats_collector_unittest.cc @@ -10,9 +10,8 @@ #include "pc/legacy_stats_collector.h" -#include - #include +#include #include #include #include @@ -61,30 +60,21 @@ #include "test/gmock.h" #include "test/gtest.h" +namespace webrtc { + using ::testing::_; using ::testing::AtMost; using ::testing::Eq; using ::testing::Return; using ::testing::UnorderedElementsAre; -using ::webrtc::ConnectionInfo; -using ::webrtc::SsrcReceiverInfo; -using ::webrtc::TransportChannelStats; -using ::webrtc::VideoMediaInfo; -using ::webrtc::VideoReceiverInfo; -using ::webrtc::VideoSenderInfo; -using ::webrtc::VoiceMediaInfo; -using ::webrtc::VoiceReceiverInfo; -using ::webrtc::VoiceSenderInfo; - -namespace webrtc { // Error return values -const char kNotFound[] = "NOT FOUND"; +constexpr char kNotFound[] = "NOT FOUND"; // Constant names for track identification. -const char kLocalTrackId[] = "local_track_id"; -const char kRemoteTrackId[] = "remote_track_id"; -const uint32_t kSsrcOfTrack = 1234; +constexpr char kLocalTrackId[] = "local_track_id"; +constexpr char kRemoteTrackId[] = "remote_track_id"; +constexpr uint32_t kSsrcOfTrack = 1234; class FakeAudioProcessor : public AudioProcessorInterface { public: diff --git a/pc/media_options.h b/pc/media_options.h index 731efac709..dc37ee7adc 100644 --- a/pc/media_options.h +++ b/pc/media_options.h @@ -117,15 +117,5 @@ struct MediaSessionOptions { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::kDefaultRtcpCname; -using ::webrtc::MediaDescriptionOptions; -using ::webrtc::MediaSessionOptions; -using ::webrtc::SenderOptions; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_MEDIA_OPTIONS_H_ diff --git a/pc/media_protocol_names.cc b/pc/media_protocol_names.cc index d2416cd5c7..65123dc6e7 100644 --- a/pc/media_protocol_names.cc +++ b/pc/media_protocol_names.cc @@ -10,11 +10,12 @@ #include "pc/media_protocol_names.h" -#include -#include - +#include +#include #include +#include "absl/strings/string_view.h" + namespace webrtc { // The official registry of RTP parameters is at diff --git a/pc/media_protocol_names.h b/pc/media_protocol_names.h index 3d34348736..d87a803b66 100644 --- a/pc/media_protocol_names.h +++ b/pc/media_protocol_names.h @@ -44,24 +44,5 @@ bool IsDtlsRtp(absl::string_view protocol); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::IsDtlsRtp; -using ::webrtc::IsDtlsSctp; -using ::webrtc::IsPlainRtp; -using ::webrtc::IsPlainSctp; -using ::webrtc::IsRtpProtocol; -using ::webrtc::IsSctpProtocol; -using ::webrtc::kMediaProtocolAvpf; -using ::webrtc::kMediaProtocolDtlsSavpf; -using ::webrtc::kMediaProtocolDtlsSctp; -using ::webrtc::kMediaProtocolSavpf; -using ::webrtc::kMediaProtocolSctp; -using ::webrtc::kMediaProtocolTcpDtlsSctp; -using ::webrtc::kMediaProtocolUdpDtlsSctp; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_MEDIA_PROTOCOL_NAMES_H_ diff --git a/pc/media_session.cc b/pc/media_session.cc index 12a6c0f032..38dcebed57 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc @@ -10,9 +10,8 @@ #include "pc/media_session.h" -#include - #include +#include #include #include #include diff --git a/pc/media_session.h b/pc/media_session.h index f33cd49a19..7c954e9f9c 100644 --- a/pc/media_session.h +++ b/pc/media_session.h @@ -225,24 +225,5 @@ SctpDataContentDescription* GetFirstSctpDataContentDescription( } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::GetFirstAudioContent; -using ::webrtc::GetFirstAudioContentDescription; -using ::webrtc::GetFirstDataContent; -using ::webrtc::GetFirstMediaContent; -using ::webrtc::GetFirstSctpDataContentDescription; -using ::webrtc::GetFirstVideoContent; -using ::webrtc::GetFirstVideoContentDescription; -using ::webrtc::IsAudioContent; -using ::webrtc::IsDataContent; -using ::webrtc::IsMediaContent; -using ::webrtc::IsUnsupportedContent; -using ::webrtc::IsVideoContent; -using ::webrtc::MediaSessionDescriptionFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_MEDIA_SESSION_H_ diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index c0df6a61e9..c9f8e755be 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -10,8 +10,7 @@ #include "pc/media_session.h" -#include - +#include #include #include #include @@ -77,6 +76,7 @@ using ::testing::Field; using ::testing::Gt; using ::testing::IsEmpty; using ::testing::Not; +using ::testing::NotNull; using ::testing::Pointwise; using ::testing::SizeIs; using ::testing::UnorderedElementsAreArray; @@ -86,6 +86,10 @@ using ::webrtc::UniqueRandomIdGenerator; using Candidates = std::vector; +constexpr char kAudioMid[] = "0"; +constexpr char kVideoMid[] = "1"; +constexpr char kDataMid[] = "2"; + class CodecLookupHelperForTesting : public CodecLookupHelper { public: explicit CodecLookupHelperForTesting(const FieldTrialsView& field_trials) @@ -139,11 +143,11 @@ const Codec kVideoCodecsAnswer[] = {CreateVideoCodec(97, "H264")}; // H.265 level-id, according to H.265 spec, is calculated this way: // For any given H.265 level a.b, level-id = (a * 10 + b) * 3. For level 6.0, // level-id = (6 * 10 + 0) * 3 = 180. Similar for all other H.265 levels. -const char kVideoCodecsH265Level6LevelId[] = "180"; -const char kVideoCodecsH265Level52LevelId[] = "156"; -const char kVideoCodecsH265Level5LevelId[] = "150"; -const char kVideoCodecsH265Level4LevelId[] = "120"; -const char kVideoCodecsH265Level31LevelId[] = "93"; +constexpr char kVideoCodecsH265Level6LevelId[] = "180"; +constexpr char kVideoCodecsH265Level52LevelId[] = "156"; +constexpr char kVideoCodecsH265Level5LevelId[] = "150"; +constexpr char kVideoCodecsH265Level4LevelId[] = "120"; +constexpr char kVideoCodecsH265Level31LevelId[] = "93"; const SdpVideoFormat kH265MainProfileLevel31Sdp( "H265", @@ -352,19 +356,19 @@ const RtpExtension kRtpExtensionGenericFrameDescriptorUri00[] = { 3), }; -const uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31}; -const uint32_t kSimSsrc[] = {10, 20, 30}; -const uint32_t kFec1Ssrc[] = {10, 11}; -const uint32_t kFec2Ssrc[] = {20, 21}; -const uint32_t kFec3Ssrc[] = {30, 31}; +constexpr uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31}; +constexpr uint32_t kSimSsrc[] = {10, 20, 30}; +constexpr uint32_t kFec1Ssrc[] = {10, 11}; +constexpr uint32_t kFec2Ssrc[] = {20, 21}; +constexpr uint32_t kFec3Ssrc[] = {30, 31}; -const char kMediaStream1[] = "stream_1"; -const char kMediaStream2[] = "stream_2"; -const char kVideoTrack1[] = "video_1"; -const char kVideoTrack2[] = "video_2"; -const char kAudioTrack1[] = "audio_1"; -const char kAudioTrack2[] = "audio_2"; -const char kAudioTrack3[] = "audio_3"; +constexpr char kMediaStream1[] = "stream_1"; +constexpr char kMediaStream2[] = "stream_2"; +constexpr char kVideoTrack1[] = "video_1"; +constexpr char kVideoTrack2[] = "video_2"; +constexpr char kAudioTrack1[] = "audio_1"; +constexpr char kAudioTrack2[] = "audio_2"; +constexpr char kAudioTrack3[] = "audio_3"; const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF", "RTP/SAVPF"}; @@ -451,15 +455,15 @@ void AddMediaDescriptionOptions(webrtc::MediaType type, void AddAudioVideoSections(RtpTransceiverDirection direction, MediaSessionOptions* opts) { - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", direction, + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, direction, kActive, opts); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", direction, + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, direction, kActive, opts); } void AddDataSection(RtpTransceiverDirection direction, MediaSessionOptions* opts) { - AddMediaDescriptionOptions(webrtc::MediaType::DATA, "data", direction, + AddMediaDescriptionOptions(webrtc::MediaType::DATA, kDataMid, direction, kActive, opts); } @@ -514,7 +518,7 @@ void DetachSenderFromMediaSection(const std::string& mid, // Helper function used to create recv-only audio MediaSessionOptions. MediaSessionOptions CreateAudioMediaSession() { MediaSessionOptions session_options; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &session_options); return session_options; @@ -596,13 +600,14 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { if (has_current_desc) { current_desc = std::make_unique(); current_desc->AddTransportInfo(TransportInfo( - "audio", + kAudioMid, TransportDescription(current_audio_ufrag, current_audio_pwd))); current_desc->AddTransportInfo(TransportInfo( - "video", + kVideoMid, TransportDescription(current_video_ufrag, current_video_pwd))); current_desc->AddTransportInfo(TransportInfo( - "data", TransportDescription(current_data_ufrag, current_data_pwd))); + kDataMid, + TransportDescription(current_data_ufrag, current_data_pwd))); } if (offer) { desc = f1_.CreateOfferOrError(options, current_desc.get()).MoveValue(); @@ -614,7 +619,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { .MoveValue(); } ASSERT_TRUE(desc); - const TransportInfo* ti_audio = desc->GetTransportInfoByName("audio"); + const TransportInfo* ti_audio = desc->GetTransportInfoByName(kAudioMid); if (options.has_audio()) { if (has_current_desc) { EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); @@ -626,15 +631,15 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { ti_audio->description.ice_pwd.size()); } auto media_desc_options_it = - FindFirstMediaDescriptionByMid("audio", options); + FindFirstMediaDescriptionByMid(kAudioMid, options); EXPECT_EQ( media_desc_options_it->transport_options.enable_ice_renomination, GetIceRenomination(ti_audio)); } - const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); + const TransportInfo* ti_video = desc->GetTransportInfoByName(kVideoMid); if (options.has_video()) { auto media_desc_options_it = - FindFirstMediaDescriptionByMid("video", options); + FindFirstMediaDescriptionByMid(kVideoMid, options); if (options.bundle_enabled) { EXPECT_EQ(ti_audio->description.ice_ufrag, ti_video->description.ice_ufrag); @@ -654,7 +659,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { media_desc_options_it->transport_options.enable_ice_renomination, GetIceRenomination(ti_video)); } - const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); + const TransportInfo* ti_data = desc->GetTransportInfoByName(kDataMid); if (options.has_data()) { if (options.bundle_enabled) { EXPECT_EQ(ti_audio->description.ice_ufrag, @@ -672,7 +677,7 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { } } auto media_desc_options_it = - FindFirstMediaDescriptionByMid("data", options); + FindFirstMediaDescriptionByMid(kDataMid, options); EXPECT_EQ( media_desc_options_it->transport_options.enable_ice_renomination, GetIceRenomination(ti_data)); @@ -691,9 +696,9 @@ class MediaSessionDescriptionFactoryTest : public testing::Test { std::unique_ptr offer = f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* ac_offer = offer->GetContentByName("audio"); + ContentInfo* ac_offer = offer->GetContentByName(kAudioMid); ASSERT_TRUE(ac_offer); - ContentInfo* vc_offer = offer->GetContentByName("video"); + ContentInfo* vc_offer = offer->GetContentByName(kVideoMid); ASSERT_TRUE(vc_offer); MediaSessionOptions answer_opts; @@ -793,8 +798,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { std::unique_ptr offer = f1_.CreateOfferOrError(CreateAudioMediaSession(), nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* ac = offer->GetContentByName("audio"); - const ContentInfo* vc = offer->GetContentByName("video"); + const ContentInfo* ac = offer->GetContentByName(kAudioMid); + const ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); EXPECT_FALSE(vc); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -826,8 +831,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* ac = offer->GetContentByName("audio"); - const ContentInfo* vc = offer->GetContentByName("video"); + const ContentInfo* ac = offer->GetContentByName(kAudioMid); + const ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac != nullptr); ASSERT_TRUE(vc == nullptr); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -854,8 +859,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOfferWithRedForOpus) { std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* ac = offer->GetContentByName("audio"); - const ContentInfo* vc = offer->GetContentByName("video"); + const ContentInfo* ac = offer->GetContentByName(kAudioMid); + const ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac != nullptr); ASSERT_TRUE(vc == nullptr); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -873,8 +878,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* ac = offer->GetContentByName("audio"); - const ContentInfo* vc = offer->GetContentByName("video"); + const ContentInfo* ac = offer->GetContentByName(kAudioMid); + const ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -956,7 +961,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerWithCustomCodecs) { Codec custom_audio_codec = CreateAudioCodec(audio_format); custom_audio_codec.id = 123; // picked at random, but valid auto audio_options = - MediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + MediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive); audio_options.codecs_to_include.push_back(custom_audio_codec); answer_opts.media_description_options.push_back(audio_options); @@ -964,7 +969,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerWithCustomCodecs) { Codec custom_video_codec = CreateVideoCodec("custom-video"); custom_video_codec.id = 124; auto video_options = - MediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + MediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive); video_options.codecs_to_include.push_back(custom_video_codec); answer_opts.media_description_options.push_back(video_options); @@ -974,8 +979,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerWithCustomCodecs) { ASSERT_TRUE(offer.get()); std::unique_ptr answer = f1_.CreateAnswerOrError(offer.get(), answer_opts, nullptr).MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -1024,10 +1029,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestBundleOfferWithSameCodecPlType) { TEST_F(MediaSessionDescriptionFactoryTest, TestCreateUpdatedVideoOfferWithBundle) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kInactive, kStopped, &opts); opts.bundle_enabled = true; @@ -1061,7 +1066,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); EXPECT_TRUE(offer.get()); - EXPECT_TRUE(offer->GetContentByName("data")); + EXPECT_TRUE(offer->GetContentByName(kDataMid)); auto dcd = GetFirstSctpDataContentDescription(offer.get()); ASSERT_TRUE(dcd); // Since this transport is insecure, the protocol should be "SCTP". @@ -1076,7 +1081,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSecureSctpDataOffer) { std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); EXPECT_TRUE(offer.get()); - EXPECT_TRUE(offer->GetContentByName("data")); + EXPECT_TRUE(offer->GetContentByName(kDataMid)); auto dcd = GetFirstSctpDataContentDescription(offer.get()); ASSERT_TRUE(dcd); // The protocol should now be "UDP/DTLS/SCTP" @@ -1091,13 +1096,13 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { std::unique_ptr offer1( f1_.CreateOfferOrError(opts, nullptr).MoveValue()); ASSERT_TRUE(offer1.get()); - const ContentInfo* data = offer1->GetContentByName("data"); + const ContentInfo* data = offer1->GetContentByName(kDataMid); ASSERT_TRUE(data); ASSERT_EQ(kMediaProtocolUdpDtlsSctp, data->media_description()->protocol()); std::unique_ptr offer2( f1_.CreateOfferOrError(opts, offer1.get()).MoveValue()); - data = offer2->GetContentByName("data"); + data = offer2->GetContentByName(kDataMid); ASSERT_TRUE(data); EXPECT_EQ(kMediaProtocolUdpDtlsSctp, data->media_description()->protocol()); } @@ -1107,7 +1112,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { TEST_F(MediaSessionDescriptionFactoryTest, ReOfferNoBundleGroupIfAllRejected) { MediaSessionOptions opts; opts.bundle_enabled = true; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr offer = @@ -1126,7 +1131,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReOfferNoBundleGroupIfAllRejected) { TEST_F(MediaSessionDescriptionFactoryTest, ReAnswerNoBundleGroupIfAllRejected) { MediaSessionOptions opts; opts.bundle_enabled = true; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr offer = @@ -1149,7 +1154,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReAnswerNoBundleGroupIfAllRejected) { TEST_F(MediaSessionDescriptionFactoryTest, ReOfferChangeBundleOffererTagged) { MediaSessionOptions opts; opts.bundle_enabled = true; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr offer = @@ -1157,7 +1162,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReOfferChangeBundleOffererTagged) { // Reject the audio m= section and add a video m= section. opts.media_description_options[0].stopped = true; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr reoffer = @@ -1165,8 +1170,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReOfferChangeBundleOffererTagged) { const ContentGroup* bundle_group = reoffer->GetGroupByName(GROUP_TYPE_BUNDLE); ASSERT_TRUE(bundle_group); - EXPECT_FALSE(bundle_group->HasContentName("audio")); - EXPECT_TRUE(bundle_group->HasContentName("video")); + EXPECT_FALSE(bundle_group->HasContentName(kAudioMid)); + EXPECT_TRUE(bundle_group->HasContentName(kVideoMid)); } // Test that if BUNDLE is enabled and the previous offerer-tagged media section @@ -1175,7 +1180,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReOfferChangeBundleOffererTagged) { TEST_F(MediaSessionDescriptionFactoryTest, ReAnswerChangedBundleOffererTagged) { MediaSessionOptions opts; opts.bundle_enabled = true; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr offer = @@ -1185,7 +1190,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReAnswerChangedBundleOffererTagged) { // Reject the audio m= section and add a video m= section. opts.media_description_options[0].stopped = true; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr reoffer = @@ -1196,8 +1201,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReAnswerChangedBundleOffererTagged) { const ContentGroup* bundle_group = reanswer->GetGroupByName(GROUP_TYPE_BUNDLE); ASSERT_TRUE(bundle_group); - EXPECT_FALSE(bundle_group->HasContentName("audio")); - EXPECT_TRUE(bundle_group->HasContentName("video")); + EXPECT_FALSE(bundle_group->HasContentName(kAudioMid)); + EXPECT_TRUE(bundle_group->HasContentName(kVideoMid)); } TEST_F(MediaSessionDescriptionFactoryTest, @@ -1281,10 +1286,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_.CreateOfferOrError(opts, offer.get()).MoveValue(); const TransportDescription* offer_tagged = - offer->GetTransportDescriptionByName("audio"); + offer->GetTransportDescriptionByName(kAudioMid); ASSERT_TRUE(offer_tagged); const TransportDescription* reoffer_tagged = - reoffer->GetTransportDescriptionByName("video"); + reoffer->GetTransportDescriptionByName(kVideoMid); ASSERT_TRUE(reoffer_tagged); EXPECT_EQ(offer_tagged->ice_ufrag, reoffer_tagged->ice_ufrag); EXPECT_EQ(offer_tagged->ice_pwd, reoffer_tagged->ice_pwd); @@ -1312,10 +1317,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, f2_.CreateAnswerOrError(reoffer.get(), opts, answer.get()).MoveValue(); const TransportDescription* answer_tagged = - answer->GetTransportDescriptionByName("audio"); + answer->GetTransportDescriptionByName(kAudioMid); ASSERT_TRUE(answer_tagged); const TransportDescription* reanswer_tagged = - reanswer->GetTransportDescriptionByName("video"); + reanswer->GetTransportDescriptionByName(kVideoMid); ASSERT_TRUE(reanswer_tagged); EXPECT_EQ(answer_tagged->ice_ufrag, reanswer_tagged->ice_ufrag); EXPECT_EQ(answer_tagged->ice_pwd, reanswer_tagged->ice_pwd); @@ -1329,8 +1334,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* ac = offer->GetContentByName("audio"); - const ContentInfo* vc = offer->GetContentByName("video"); + const ContentInfo* ac = offer->GetContentByName(kAudioMid); + const ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); const MediaContentDescription* acd = ac->media_description(); @@ -1344,10 +1349,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { MediaSessionOptions opts; AddAudioVideoSections(RtpTransceiverDirection::kSendOnly, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack1, {kMediaStream1}, 1, &opts); @@ -1379,7 +1384,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { EXPECT_TRUE( IsMediaContentOfType(&offer1->contents()[0], webrtc::MediaType::DATA)); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer2( @@ -1391,7 +1396,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { EXPECT_TRUE( IsMediaContentOfType(&offer2->contents()[1], webrtc::MediaType::VIDEO)); - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer3( @@ -1414,8 +1419,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), CreateAudioMediaSession(), nullptr) .MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); EXPECT_FALSE(vc); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -1437,8 +1442,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { ASSERT_TRUE(offer.get()); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); EXPECT_FALSE(vc); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -1455,7 +1460,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerWithNoCommonCodecs) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::vector f1_codecs = {CreateAudioCodec(96, "opus", 48000, 1)}; @@ -1470,7 +1475,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_.CreateOfferOrError(opts, nullptr).MoveValue(); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); ASSERT_TRUE(ac); EXPECT_TRUE(ac->rejected); } @@ -1484,8 +1489,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { ASSERT_TRUE(offer.get()); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -1508,7 +1513,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerWithNoCommonCodecs) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::vector f1_codecs = {CreateVideoCodec(96, "H264")}; @@ -1523,7 +1528,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_.CreateOfferOrError(opts, nullptr).MoveValue(); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(vc); EXPECT_TRUE(vc->rejected); } @@ -1533,7 +1538,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerWithOnlyFecCodecsCommon) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::vector f1_codecs = {CreateVideoCodec(96, "H264"), @@ -1550,7 +1555,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_.CreateOfferOrError(opts, nullptr).MoveValue(); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(vc); EXPECT_TRUE(vc->rejected); } @@ -1563,7 +1568,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) { std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* dc_offer = offer->GetContentByName("data"); + ContentInfo* dc_offer = offer->GetContentByName(kDataMid); ASSERT_TRUE(dc_offer); SctpDataContentDescription* dcd_offer = dc_offer->media_description()->as_sctp(); @@ -1571,7 +1576,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) { std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* dc_answer = answer->GetContentByName("data"); + const ContentInfo* dc_answer = answer->GetContentByName(kDataMid); ASSERT_TRUE(dc_answer); const SctpDataContentDescription* dcd_answer = dc_answer->media_description()->as_sctp(); @@ -1585,7 +1590,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerWithoutSctpmap) { std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* dc_offer = offer->GetContentByName("data"); + ContentInfo* dc_offer = offer->GetContentByName(kDataMid); ASSERT_TRUE(dc_offer); SctpDataContentDescription* dcd_offer = dc_offer->media_description()->as_sctp(); @@ -1593,7 +1598,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerWithoutSctpmap) { std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* dc_answer = answer->GetContentByName("data"); + const ContentInfo* dc_answer = answer->GetContentByName(kDataMid); ASSERT_TRUE(dc_answer); const SctpDataContentDescription* dcd_answer = dc_answer->media_description()->as_sctp(); @@ -1609,7 +1614,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* dc_offer = offer->GetContentByName("data"); + ContentInfo* dc_offer = offer->GetContentByName(kDataMid); ASSERT_TRUE(dc_offer); SctpDataContentDescription* dcd_offer = dc_offer->media_description()->as_sctp(); @@ -1621,7 +1626,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, dcd_offer->set_protocol(proto); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* dc_answer = answer->GetContentByName("data"); + const ContentInfo* dc_answer = answer->GetContentByName(kDataMid); ASSERT_TRUE(dc_answer); const SctpDataContentDescription* dcd_answer = dc_answer->media_description()->as_sctp(); @@ -1637,7 +1642,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* dc_offer = offer->GetContentByName("data"); + ContentInfo* dc_offer = offer->GetContentByName(kDataMid); ASSERT_TRUE(dc_offer); SctpDataContentDescription* dcd_offer = dc_offer->media_description()->as_sctp(); @@ -1645,7 +1650,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, dcd_offer->set_max_message_size(1234); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* dc_answer = answer->GetContentByName("data"); + const ContentInfo* dc_answer = answer->GetContentByName(kDataMid); ASSERT_TRUE(dc_answer); const SctpDataContentDescription* dcd_answer = dc_answer->media_description()->as_sctp(); @@ -1660,7 +1665,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* dc_offer = offer->GetContentByName("data"); + ContentInfo* dc_offer = offer->GetContentByName(kDataMid); ASSERT_TRUE(dc_offer); SctpDataContentDescription* dcd_offer = dc_offer->media_description()->as_sctp(); @@ -1668,7 +1673,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, dcd_offer->set_max_message_size(0); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* dc_answer = answer->GetContentByName("data"); + const ContentInfo* dc_answer = answer->GetContentByName(kDataMid); ASSERT_TRUE(dc_answer); const SctpDataContentDescription* dcd_answer = dc_answer->media_description()->as_sctp(); @@ -1688,7 +1693,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { ASSERT_TRUE(offer1.get()); // Appends audio to the offer. - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer2( @@ -1696,7 +1701,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { ASSERT_TRUE(offer2.get()); // Appends video to the offer. - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer3( @@ -1764,7 +1769,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* ac_answer = answer->GetContentByName("audio"); + const ContentInfo* ac_answer = answer->GetContentByName(kAudioMid); ASSERT_TRUE(ac_answer); EXPECT_FALSE(ac_answer->rejected); @@ -1996,7 +2001,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, OffersUnstoppedExtensionsWithAudioVideoExtensionStopped) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); opts.media_description_options.back().header_extensions = { @@ -2012,7 +2017,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpTransceiverDirection::kStopped), RtpHeaderExtensionCapability("uri3", 7, RtpTransceiverDirection::kSendOnly)}; - auto offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); + std::unique_ptr offer = + f1_.CreateOfferOrError(opts, nullptr).MoveValue(); EXPECT_THAT( offer->contents(), ElementsAre( @@ -2029,7 +2035,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, OffersUnstoppedExtensionsWithAudioExtensionStopped) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); opts.media_description_options.back().header_extensions = { @@ -2045,7 +2051,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpTransceiverDirection::kSendRecv), RtpHeaderExtensionCapability("uri3", 7, RtpTransceiverDirection::kSendOnly)}; - auto offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); + std::unique_ptr offer = + f1_.CreateOfferOrError(opts, nullptr).MoveValue(); EXPECT_THAT( offer->contents(), ElementsAre( @@ -2064,7 +2071,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, OffersUnstoppedExtensionsWithVideoExtensionStopped) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); opts.media_description_options.back().header_extensions = { @@ -2080,7 +2087,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpTransceiverDirection::kSendRecv), RtpHeaderExtensionCapability("uri3", 7, RtpTransceiverDirection::kStopped)}; - auto offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); + std::unique_ptr offer = + f1_.CreateOfferOrError(opts, nullptr).MoveValue(); EXPECT_THAT( offer->contents(), ElementsAre( @@ -2098,7 +2106,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, AnswersUnstoppedExtensions) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); opts.media_description_options.back().header_extensions = { @@ -2110,7 +2118,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, AnswersUnstoppedExtensions) { RtpTransceiverDirection::kRecvOnly), RtpHeaderExtensionCapability("uri4", 1, RtpTransceiverDirection::kSendRecv)}; - auto offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); + std::unique_ptr offer = + f1_.CreateOfferOrError(opts, nullptr).MoveValue(); opts.media_description_options.back().header_extensions = { RtpHeaderExtensionCapability("uri1", 4, RtpTransceiverDirection::kSendOnly), @@ -2120,7 +2129,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, AnswersUnstoppedExtensions) { RtpTransceiverDirection::kStopped), RtpHeaderExtensionCapability("uri4", 1, RtpTransceiverDirection::kSendRecv)}; - auto answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); + std::unique_ptr answer = + f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); EXPECT_THAT( answer->contents(), ElementsAre(Property( @@ -2133,13 +2143,14 @@ TEST_F(MediaSessionDescriptionFactoryTest, AnswersUnstoppedExtensions) { TEST_F(MediaSessionDescriptionFactoryTest, AppendsUnstoppedExtensionsToCurrentDescription) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); opts.media_description_options.back().header_extensions = { RtpHeaderExtensionCapability("uri1", 1, RtpTransceiverDirection::kSendRecv)}; - auto offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); + std::unique_ptr offer = + f1_.CreateOfferOrError(opts, nullptr).MoveValue(); opts.media_description_options.back().header_extensions = { RtpHeaderExtensionCapability("uri1", 2, RtpTransceiverDirection::kSendRecv), @@ -2163,7 +2174,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, AppendsStoppedExtensionIfKnownAndPresentInTheOffer) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); opts.media_description_options.back().header_extensions = { @@ -2171,7 +2182,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpTransceiverDirection::kSendRecv), RtpHeaderExtensionCapability("uri2", 2, RtpTransceiverDirection::kSendRecv)}; - auto offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); + std::unique_ptr offer = + f1_.CreateOfferOrError(opts, nullptr).MoveValue(); // Check that a subsequent offer after setting "uri2" to stopped no longer // contains the extension. @@ -2404,8 +2416,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, ASSERT_TRUE(offer.get()); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); const MediaContentDescription* acd = ac->media_description(); @@ -2486,10 +2498,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerRtcpMux) { // Create an audio-only answer to a video offer. TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer = @@ -2499,8 +2511,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { opts.media_description_options[1].stopped = true; std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); ASSERT_TRUE(vc->media_description()); @@ -2515,16 +2527,16 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* ac = offer->GetContentByName("audio"); - ContentInfo* vc = offer->GetContentByName("video"); + ContentInfo* ac = offer->GetContentByName(kAudioMid); + ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); ac->rejected = true; vc->rejected = true; std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ac = answer->GetContentByName("audio"); - vc = answer->GetContentByName("video"); + ac = answer->GetContentByName(kAudioMid); + vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); EXPECT_TRUE(ac->rejected); @@ -2569,9 +2581,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_.CreateOfferOrError(opts, /*current_description=*/nullptr).MoveValue(); offer->set_extmap_allow_mixed(false); MediaContentDescription* audio_offer = - offer->GetContentDescriptionByName("audio"); + offer->GetContentDescriptionByName(kAudioMid); MediaContentDescription* video_offer = - offer->GetContentDescriptionByName("video"); + offer->GetContentDescriptionByName(kVideoMid); ASSERT_EQ(MediaContentDescription::kNo, audio_offer->extmap_allow_mixed_enum()); ASSERT_EQ(MediaContentDescription::kNo, @@ -2583,9 +2595,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, .MoveValue()); MediaContentDescription* audio_answer = - answer->GetContentDescriptionByName("audio"); + answer->GetContentDescriptionByName(kAudioMid); MediaContentDescription* video_answer = - answer->GetContentDescriptionByName("video"); + answer->GetContentDescriptionByName(kVideoMid); EXPECT_EQ(MediaContentDescription::kNo, audio_answer->extmap_allow_mixed_enum()); EXPECT_EQ(MediaContentDescription::kNo, @@ -2600,10 +2612,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_.CreateOfferOrError(opts, /*current_description=*/nullptr).MoveValue(); offer->set_extmap_allow_mixed(false); MediaContentDescription* audio_offer = - offer->GetContentDescriptionByName("audio"); + offer->GetContentDescriptionByName(kAudioMid); audio_offer->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia); MediaContentDescription* video_offer = - offer->GetContentDescriptionByName("video"); + offer->GetContentDescriptionByName(kVideoMid); video_offer->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia); std::unique_ptr answer( @@ -2612,9 +2624,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, .MoveValue()); MediaContentDescription* audio_answer = - answer->GetContentDescriptionByName("audio"); + answer->GetContentDescriptionByName(kAudioMid); MediaContentDescription* video_answer = - answer->GetContentDescriptionByName("video"); + answer->GetContentDescriptionByName(kVideoMid); EXPECT_EQ(MediaContentDescription::kMedia, audio_answer->extmap_allow_mixed_enum()); EXPECT_EQ(MediaContentDescription::kMedia, @@ -2629,10 +2641,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_.CreateOfferOrError(opts, /*current_description=*/nullptr).MoveValue(); offer->set_extmap_allow_mixed(false); MediaContentDescription* audio_offer = - offer->GetContentDescriptionByName("audio"); + offer->GetContentDescriptionByName(kAudioMid); audio_offer->set_extmap_allow_mixed_enum(MediaContentDescription::kNo); MediaContentDescription* video_offer = - offer->GetContentDescriptionByName("video"); + offer->GetContentDescriptionByName(kVideoMid); video_offer->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia); std::unique_ptr answer( @@ -2641,9 +2653,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, .MoveValue()); MediaContentDescription* audio_answer = - answer->GetContentDescriptionByName("audio"); + answer->GetContentDescriptionByName(kAudioMid); MediaContentDescription* video_answer = - answer->GetContentDescriptionByName("video"); + answer->GetContentDescriptionByName(kVideoMid); EXPECT_EQ(MediaContentDescription::kNo, audio_answer->extmap_allow_mixed_enum()); EXPECT_EQ(MediaContentDescription::kMedia, @@ -2658,13 +2670,13 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { MediaSessionOptions opts; AddAudioVideoSections(RtpTransceiverDirection::kSendRecv, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack1, {kMediaStream1}, 1, &opts); - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack2, {kMediaStream1}, 1, &opts); @@ -2672,8 +2684,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* ac = offer->GetContentByName("audio"); - const ContentInfo* vc = offer->GetContentByName("video"); + const ContentInfo* ac = offer->GetContentByName(kAudioMid); + const ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); const MediaContentDescription* acd = ac->media_description(); @@ -2712,19 +2724,19 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { // Update the offer. Add a new video track that is not synched to the // other tracks and replace audio track 2 with audio track 3. - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack2, {kMediaStream2}, 1, &opts); - DetachSenderFromMediaSection("audio", kAudioTrack2, &opts); - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + DetachSenderFromMediaSection(kAudioMid, kAudioTrack2, &opts); + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack3, {kMediaStream1}, 1, &opts); std::unique_ptr updated_offer( f1_.CreateOfferOrError(opts, offer.get()).MoveValue()); ASSERT_TRUE(updated_offer.get()); - ac = updated_offer->GetContentByName("audio"); - vc = updated_offer->GetContentByName("video"); + ac = updated_offer->GetContentByName(kAudioMid); + vc = updated_offer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); const MediaContentDescription* updated_acd = ac->media_description(); @@ -2754,21 +2766,21 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { // Create an offer with simulcast video stream. TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); const int num_sim_layers = 3; - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, num_sim_layers, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* vc = offer->GetContentByName("video"); + const ContentInfo* vc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(vc); const MediaContentDescription* vcd = vc->media_description(); @@ -2817,7 +2829,7 @@ void CheckSimulcastInSessionDescription( // Create an offer with spec-compliant simulcast video stream. TEST_F(MediaSessionDescriptionFactoryTest, TestCreateCompliantSimulcastOffer) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::vector send_rids; @@ -2828,13 +2840,13 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateCompliantSimulcastOffer) { simulcast_layers.AddLayer(SimulcastLayer(send_rids[0].rid, false)); simulcast_layers.AddLayer(SimulcastLayer(send_rids[1].rid, true)); simulcast_layers.AddLayer(SimulcastLayer(send_rids[2].rid, false)); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, send_rids, simulcast_layers, 0, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - CheckSimulcastInSessionDescription(offer.get(), "video", send_rids, + CheckSimulcastInSessionDescription(offer.get(), kVideoMid, send_rids, simulcast_layers); } @@ -2842,18 +2854,18 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateCompliantSimulcastOffer) { // In this scenario, RIDs do not need to be negotiated (there is only one). TEST_F(MediaSessionDescriptionFactoryTest, TestOfferWithRidsNoSimulcast) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); RidDescription rid("f", RidDirection::kSend); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, {rid}, SimulcastLayerList(), 0, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_NE(offer.get(), nullptr); - const ContentInfo* content = offer->GetContentByName("video"); + const ContentInfo* content = offer->GetContentByName(kVideoMid); ASSERT_NE(content, nullptr); const MediaContentDescription* cd = content->media_description(); ASSERT_NE(cd, nullptr); @@ -2869,17 +2881,17 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferWithRidsNoSimulcast) { // In this scenario, the SFU is the caller requesting that we send Simulcast. TEST_F(MediaSessionDescriptionFactoryTest, TestCreateCompliantSimulcastAnswer) { MediaSessionOptions offer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &offer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &offer_opts); std::unique_ptr offer = f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue(); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); @@ -2893,12 +2905,12 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateCompliantSimulcastAnswer) { simulcast_layers.AddLayer(SimulcastLayer(rid_descriptions[1].rid, true)); simulcast_layers.AddLayer(SimulcastLayer(rid_descriptions[2].rid, false)); AttachSenderToMediaDescriptionOptions( - "video", webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, + kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, rid_descriptions, simulcast_layers, 0, &answer_opts); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), answer_opts, nullptr).MoveValue(); - CheckSimulcastInSessionDescription(answer.get(), "video", rid_descriptions, + CheckSimulcastInSessionDescription(answer.get(), kVideoMid, rid_descriptions, simulcast_layers); } @@ -2907,30 +2919,30 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateCompliantSimulcastAnswer) { // Note that RID Direction is not the same as the transceiver direction. TEST_F(MediaSessionDescriptionFactoryTest, TestAnswerWithRidsNoSimulcast) { MediaSessionOptions offer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &offer_opts); RidDescription rid_offer("f", RidDirection::kSend); AttachSenderToMediaDescriptionOptions( - "video", webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, + kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, {rid_offer}, SimulcastLayerList(), 0, &offer_opts); std::unique_ptr offer = f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue(); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); RidDescription rid_answer("f", RidDirection::kReceive); AttachSenderToMediaDescriptionOptions( - "video", webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, + kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, {rid_answer}, SimulcastLayerList(), 0, &answer_opts); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), answer_opts, nullptr).MoveValue(); ASSERT_NE(answer.get(), nullptr); - const ContentInfo* content = offer->GetContentByName("video"); + const ContentInfo* content = offer->GetContentByName(kVideoMid); ASSERT_NE(content, nullptr); const MediaContentDescription* cd = content->media_description(); ASSERT_NE(cd, nullptr); @@ -2950,29 +2962,29 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestAnswerWithRidsNoSimulcast) { // adding a new video track and removes one of the audio tracks. TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { MediaSessionOptions offer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &offer_opts); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &offer_opts); std::unique_ptr offer = f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue(); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack1, {kMediaStream1}, 1, &answer_opts); - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack2, {kMediaStream1}, 1, &answer_opts); @@ -2980,8 +2992,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { f2_.CreateAnswerOrError(offer.get(), answer_opts, nullptr).MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); const MediaContentDescription* acd = ac->media_description(); @@ -3017,17 +3029,17 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { // Update the answer. Add a new video track that is not synched to the // other tracks and remove 1 audio track. - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack2, {kMediaStream2}, 1, &answer_opts); - DetachSenderFromMediaSection("audio", kAudioTrack2, &answer_opts); + DetachSenderFromMediaSection(kAudioMid, kAudioTrack2, &answer_opts); std::unique_ptr updated_answer( f2_.CreateAnswerOrError(offer.get(), answer_opts, answer.get()) .MoveValue()); ASSERT_TRUE(updated_answer.get()); - ac = updated_answer->GetContentByName("audio"); - vc = updated_answer->GetContentByName("video"); + ac = updated_answer->GetContentByName(kAudioMid); + vc = updated_answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); const MediaContentDescription* updated_acd = ac->media_description(); @@ -3153,7 +3165,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - auto answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); + std::unique_ptr answer = + f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); // Recycle the media section by changing its mid. opts.media_description_options[0].mid = "v1"; @@ -3241,7 +3254,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, RespondentCreatesOfferAfterCreatingAnswerWithRtx) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::vector f1_codecs = MAKE_VECTOR(kVideoCodecs1); @@ -3294,7 +3307,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, RespondentCreatesOfferAfterCreatingAnswerWithRemappedRtxPayloadType) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); // We specifically choose different preferred payload types for VP8 to @@ -3356,7 +3369,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, f1_codecs); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); @@ -3452,7 +3465,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, // Test that RTX is ignored when there is no associated payload type parameter. TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::vector f1_codecs = MAKE_VECTOR(kVideoCodecs1); @@ -3475,7 +3488,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { // is possible to test that that RTX is dropped when // kCodecParamAssociatedPayloadType is missing in the offer. MediaContentDescription* media_desc = - offer->GetContentDescriptionByName(CN_VIDEO); + offer->GetContentDescriptionByName(kVideoMid); ASSERT_TRUE(media_desc); std::vector codecs = media_desc->codecs(); for (Codec& codec : codecs) { @@ -3497,7 +3510,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { // type doesn't match the local value. TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::vector f1_codecs = MAKE_VECTOR(kVideoCodecs1); @@ -3530,7 +3543,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { TEST_F(MediaSessionDescriptionFactoryTest, FilterOutUnsupportedRtxWhenCreatingAnswer) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::vector f1_codecs = MAKE_VECTOR(kVideoCodecs1); @@ -3569,7 +3582,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, // to add another. TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::vector f1_codecs = MAKE_VECTOR(kVideoCodecs1); @@ -3580,7 +3593,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); const VideoContentDescription* vcd = GetFirstVideoContentDescription(offer.get()); @@ -3606,11 +3619,11 @@ TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { // generated for each simulcast ssrc and correctly grouped. TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); // Add simulcast streams. - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, "stream1", {"stream1label"}, 3, &opts); // Use a single real codec, and then add RTX for it. @@ -3626,7 +3639,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); MediaContentDescription* media_desc = - offer->GetContentDescriptionByName(CN_VIDEO); + offer->GetContentDescriptionByName(kVideoMid); ASSERT_TRUE(media_desc); const StreamParamsVec& streams = media_desc->streams(); // Single stream. @@ -3650,11 +3663,11 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { field_trials_.Set("WebRTC-FlexFEC-03", "Enabled"); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); // Add single stream. - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, "stream1", {"stream1label"}, 1, &opts); // Use a single real codec, and then add FlexFEC for it. @@ -3670,7 +3683,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); MediaContentDescription* media_desc = - offer->GetContentDescriptionByName(CN_VIDEO); + offer->GetContentDescriptionByName(kVideoMid); ASSERT_TRUE(media_desc); const StreamParamsVec& streams = media_desc->streams(); // Single stream. @@ -3693,11 +3706,11 @@ TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { field_trials_.Set("WebRTC-FlexFEC-03", "Enabled"); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); // Add simulcast streams. - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, "stream1", {"stream1label"}, 3, &opts); // Use a single real codec, and then add FlexFEC for it. @@ -3713,7 +3726,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { f1_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); MediaContentDescription* media_desc = - offer->GetContentDescriptionByName(CN_VIDEO); + offer->GetContentDescriptionByName(kVideoMid); ASSERT_TRUE(media_desc); const StreamParamsVec& streams = media_desc->streams(); // Single stream. @@ -3830,24 +3843,24 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { TEST(MediaSessionDescription, CopySessionDescription) { SessionDescription source; - ContentGroup group(CN_AUDIO); + ContentGroup group(kAudioMid); source.AddGroup(group); std::unique_ptr acd = std::make_unique(); acd->set_codecs(MAKE_VECTOR(kAudioCodecs1)); acd->AddLegacyStream(1); - source.AddContent(CN_AUDIO, MediaProtocolType::kRtp, acd->Clone()); + source.AddContent(kAudioMid, MediaProtocolType::kRtp, acd->Clone()); std::unique_ptr vcd = std::make_unique(); vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1)); vcd->AddLegacyStream(2); - source.AddContent(CN_VIDEO, MediaProtocolType::kRtp, vcd->Clone()); + source.AddContent(kVideoMid, MediaProtocolType::kRtp, vcd->Clone()); std::unique_ptr copy = source.Clone(); ASSERT_TRUE(copy.get()); - EXPECT_TRUE(copy->HasGroup(CN_AUDIO)); - const ContentInfo* ac = copy->GetContentByName("audio"); - const ContentInfo* vc = copy->GetContentByName("video"); + EXPECT_TRUE(copy->HasGroup(kAudioMid)); + const ContentInfo* ac = copy->GetContentByName(kAudioMid); + const ContentInfo* vc = copy->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); EXPECT_EQ(MediaProtocolType::kRtp, ac->type); @@ -3865,7 +3878,7 @@ TEST(MediaSessionDescription, CopySessionDescription) { // ensure the TransportInfo in the SessionDescription matches what we expect. TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) { MediaSessionOptions options; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &options); TestTransportInfo(true, options, false); @@ -3874,7 +3887,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) { TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferIceRenomination) { MediaSessionOptions options; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &options); options.media_description_options[0] @@ -3884,7 +3897,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudioCurrent) { MediaSessionOptions options; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &options); TestTransportInfo(true, options, true); @@ -3920,7 +3933,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) { MediaSessionOptions options; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &options); TestTransportInfo(false, options, false); @@ -3929,7 +3942,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) { TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerIceRenomination) { MediaSessionOptions options; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &options); options.media_description_options[0] @@ -3940,7 +3953,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudioCurrent) { MediaSessionOptions options; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kRecvOnly, kActive, &options); TestTransportInfo(false, options, true); @@ -3980,7 +3993,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { std::unique_ptr offer = f1_.CreateOfferOrError(CreateAudioMediaSession(), nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* offer_content = offer->GetContentByName("audio"); + ContentInfo* offer_content = offer->GetContentByName(kAudioMid); ASSERT_TRUE(offer_content); MediaContentDescription* offer_audio_desc = offer_content->media_description(); @@ -3989,9 +4002,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), CreateAudioMediaSession(), nullptr) .MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); - const ContentInfo* answer_content = answer->GetContentByName("audio"); + const ContentInfo* answer_content = answer->GetContentByName(kAudioMid); ASSERT_TRUE(answer_content); ASSERT_FALSE(answer_content->rejected); @@ -4018,10 +4031,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { ASSERT_TRUE(offer.get()); const TransportDescription* audio_offer_trans_desc = - offer->GetTransportDescriptionByName("audio"); + offer->GetTransportDescriptionByName(kAudioMid); ASSERT_TRUE(audio_offer_trans_desc->identity_fingerprint.get()); const TransportDescription* video_offer_trans_desc = - offer->GetTransportDescriptionByName("video"); + offer->GetTransportDescriptionByName(kVideoMid); ASSERT_TRUE(video_offer_trans_desc->identity_fingerprint.get()); // Generate an answer with DTLS. @@ -4030,10 +4043,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { ASSERT_TRUE(answer.get()); const TransportDescription* audio_answer_trans_desc = - answer->GetTransportDescriptionByName("audio"); + answer->GetTransportDescriptionByName(kAudioMid); EXPECT_TRUE(audio_answer_trans_desc->identity_fingerprint.get()); const TransportDescription* video_answer_trans_desc = - answer->GetTransportDescriptionByName("video"); + answer->GetTransportDescriptionByName(kVideoMid); EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get()); } @@ -4045,18 +4058,18 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { std::unique_ptr offer = f1_.CreateOfferOrError(options, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* audio_content = offer->GetContentByName("audio"); + const ContentInfo* audio_content = offer->GetContentByName(kAudioMid); EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); options.vad_enabled = false; offer = f1_.CreateOfferOrError(options, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - audio_content = offer->GetContentByName("audio"); + audio_content = offer->GetContentByName(kAudioMid); EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); std::unique_ptr answer = f1_.CreateAnswerOrError(offer.get(), options, nullptr).MoveValue(); ASSERT_TRUE(answer.get()); - audio_content = answer->GetContentByName("audio"); + audio_content = answer->GetContentByName(kAudioMid); EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); } @@ -4124,7 +4137,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(4u, offer->contents().size()); EXPECT_FALSE(offer->contents()[0].rejected); @@ -4187,7 +4200,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); @@ -4233,7 +4246,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, &offer_opts); std::unique_ptr offer = f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(2u, offer->contents().size()); EXPECT_FALSE(offer->contents()[0].rejected); EXPECT_TRUE(offer->contents()[1].rejected); @@ -4253,7 +4266,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, &offer_opts); std::unique_ptr offer = f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(2u, offer->contents().size()); EXPECT_FALSE(offer->contents()[0].rejected); EXPECT_TRUE(offer->contents()[1].rejected); @@ -4287,7 +4300,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, &offer_opts); std::unique_ptr offer = f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(2u, offer->contents().size()); ASSERT_FALSE(offer->contents()[0].rejected); ASSERT_FALSE(offer->contents()[1].rejected); @@ -4318,19 +4331,19 @@ TEST_F(MediaSessionDescriptionFactoryTest, MediaSessionOptions opts; // This tests put video section first because normally audio comes first by // default. - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(2u, offer->contents().size()); - EXPECT_EQ("video", offer->contents()[0].mid()); - EXPECT_EQ("audio", offer->contents()[1].mid()); + EXPECT_EQ(kVideoMid, offer->contents()[0].mid()); + EXPECT_EQ(kAudioMid, offer->contents()[1].mid()); } // Test that different media sections using the same codec have same payload @@ -4347,7 +4360,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, // Create an offer with two video sections using same codecs. std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(2u, offer->contents().size()); const MediaContentDescription* vcd1 = offer->contents()[0].media_description(); @@ -4363,7 +4376,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, // Create answer and negotiate the codecs. std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); ASSERT_EQ(2u, answer->contents().size()); vcd1 = answer->contents()[0].media_description(); vcd2 = answer->contents()[1].media_description(); @@ -4395,7 +4408,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, H265TxModeIsEqualRetainIt) { // Create an offer with two video sections using same codecs. std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(1u, offer->contents().size()); const MediaContentDescription* vcd1 = offer->contents()[0].media_description(); @@ -4405,7 +4418,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, H265TxModeIsEqualRetainIt) { // Create answer and negotiate the codecs. std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); ASSERT_EQ(1u, answer->contents().size()); vcd1 = answer->contents()[0].media_description(); ASSERT_EQ(1u, vcd1->codecs().size()); @@ -4433,7 +4446,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, H265TxModeIsDifferentDropCodecs) { // Create an offer with two video sections using same codecs. std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(1u, offer->contents().size()); const VideoContentDescription* vcd1 = offer->contents()[0].media_description()->as_video(); @@ -4443,7 +4456,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, H265TxModeIsDifferentDropCodecs) { // Create answer and negotiate the codecs. std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); ASSERT_EQ(1u, answer->contents().size()); vcd1 = answer->contents()[0].media_description()->as_video(); ASSERT_EQ(1u, vcd1->codecs().size()); @@ -4472,7 +4485,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) { // Create an offer with two video sections using same codecs. std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(1u, offer->contents().size()); const MediaContentDescription* vcd1 = offer->contents()[0].media_description(); @@ -4482,7 +4495,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) { // Create answer and negotiate the codecs. std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); ASSERT_EQ(1u, answer->contents().size()); vcd1 = answer->contents()[0].media_description(); ASSERT_EQ(1u, vcd1->codecs().size()); @@ -4510,7 +4523,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsDifferent) { // Create an offer with two video sections using same codecs. std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(1u, offer->contents().size()); const VideoContentDescription* vcd1 = offer->contents()[0].media_description()->as_video(); @@ -4520,7 +4533,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsDifferent) { // Create answer and negotiate the codecs. std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); ASSERT_EQ(1u, answer->contents().size()); vcd1 = answer->contents()[0].media_description()->as_video(); ASSERT_EQ(1u, vcd1->codecs().size()); @@ -4541,7 +4554,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, // Create an offer with two video sections using same codecs. std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(2u, offer->contents().size()); MediaContentDescription* vcd1 = offer->contents()[0].media_description(); const MediaContentDescription* vcd2 = @@ -4577,7 +4590,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, // Create an offer with two video sections using same codecs. std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); ASSERT_EQ(2u, offer->contents().size()); MediaContentDescription* vcd1 = offer->contents()[0].media_description(); const MediaContentDescription* vcd2 = @@ -4630,16 +4643,16 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerWithLocalCodecParams) { video_codecs2); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); auto offer_acd = offer->contents()[0].media_description(); auto offer_vcd = offer->contents()[1].media_description(); std::string value; @@ -4650,7 +4663,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerWithLocalCodecParams) { std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); auto answer_acd = answer->contents()[0].media_description(); auto answer_vcd = answer->contents()[1].media_description(); // Use the parameters from the local codecs. @@ -4686,17 +4699,17 @@ TEST_F(MediaSessionDescriptionFactoryTest, {h264_pm1}); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); std::unique_ptr offer = f1_.CreateOfferOrError(opts, nullptr).MoveValue(); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); // Answer should have one negotiated codec with packetization-mode=1 using the // offered payload type. @@ -4754,8 +4767,8 @@ TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) { } std::unique_ptr answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); - const ContentInfo* vc = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); + const ContentInfo* vc = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); ASSERT_TRUE(vc); EXPECT_FALSE(ac->rejected); // the offer is accepted @@ -4805,12 +4818,12 @@ void TestAudioCodecsOffer(RtpTransceiverDirection direction) { recv_codecs); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", direction, + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, direction, kActive, &opts); if (direction == RtpTransceiverDirection::kSendRecv || direction == RtpTransceiverDirection::kSendOnly) { - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack1, {kMediaStream1}, 1, &opts); } @@ -4818,7 +4831,7 @@ void TestAudioCodecsOffer(RtpTransceiverDirection direction) { std::unique_ptr offer = sf.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - ContentInfo* ac = offer->GetContentByName("audio"); + ContentInfo* ac = offer->GetContentByName(kAudioMid); // If the factory didn't add any audio content to the offer, we cannot check // that the codecs put in are right. This happens when we neither want to @@ -4869,18 +4882,18 @@ const Codec kOfferAnswerCodecs[] = {CreateAudioCodec(40, "codec0", 16000, 1), * 6 | x x x | x x x | x x x x x */ // Codecs used by offerer in the AudioCodecsAnswerTest -const int kOfferSendCodecs[] = {0, 1, 3, 5, 6}; -const int kOfferRecvCodecs[] = {1, 2, 3, 4, 6}; +constexpr int kOfferSendCodecs[] = {0, 1, 3, 5, 6}; +constexpr int kOfferRecvCodecs[] = {1, 2, 3, 4, 6}; // Codecs used in the answerer in the AudioCodecsAnswerTest. The order is // jumbled to catch the answer not following the order in the offer. -const int kAnswerSendCodecs[] = {6, 5, 2, 3, 4}; -const int kAnswerRecvCodecs[] = {6, 5, 4, 1, 0}; +constexpr int kAnswerSendCodecs[] = {6, 5, 2, 3, 4}; +constexpr int kAnswerRecvCodecs[] = {6, 5, 4, 1, 0}; // The resulting sets of codecs in the answer in the AudioCodecsAnswerTest -const int kResultSend_RecvCodecs[] = {0, 1, 5, 6}; -const int kResultRecv_SendCodecs[] = {2, 3, 4, 6}; -const int kResultSendrecv_SendCodecs[] = {3, 6}; -const int kResultSendrecv_RecvCodecs[] = {1, 6}; -const int kResultSendrecv_SendrecvCodecs[] = {6}; +constexpr int kResultSend_RecvCodecs[] = {0, 1, 5, 6}; +constexpr int kResultRecv_SendCodecs[] = {2, 3, 4, 6}; +constexpr int kResultSendrecv_SendCodecs[] = {3, 6}; +constexpr int kResultSendrecv_RecvCodecs[] = {1, 6}; +constexpr int kResultSendrecv_SendrecvCodecs[] = {6}; template std::vector VectorFromIndices(const T* array, const int (&indices)[IDXS]) { @@ -4919,11 +4932,11 @@ void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction, VectorFromIndices(kOfferAnswerCodecs, kAnswerRecvCodecs)); MediaSessionOptions offer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", offer_direction, - kActive, &offer_opts); + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, + offer_direction, kActive, &offer_opts); if (webrtc::RtpTransceiverDirectionHasSend(offer_direction)) { - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack1, {kMediaStream1}, 1, &offer_opts); } @@ -4933,18 +4946,18 @@ void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction, ASSERT_TRUE(offer.get()); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, "audio", + AddMediaDescriptionOptions(webrtc::MediaType::AUDIO, kAudioMid, answer_direction, kActive, &answer_opts); if (webrtc::RtpTransceiverDirectionHasSend(answer_direction)) { - AttachSenderToMediaDescriptionOptions("audio", webrtc::MediaType::AUDIO, + AttachSenderToMediaDescriptionOptions(kAudioMid, webrtc::MediaType::AUDIO, kAudioTrack1, {kMediaStream1}, 1, &answer_opts); } std::unique_ptr answer = answer_factory.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); - const ContentInfo* ac = answer->GetContentByName("audio"); + const ContentInfo* ac = answer->GetContentByName(kAudioMid); // If the factory didn't add any audio content to the answer, we cannot // check that the codecs put in are right. This happens when we neither want @@ -5111,28 +5124,28 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, TestSendRecvSymmetrical) { .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5140,7 +5153,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, TestSendRecvSymmetrical) { sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), acd->codecs())); @@ -5164,24 +5177,24 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, TestSendOnlySymmetrical) { .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level6LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &answer_opts); @@ -5189,7 +5202,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, TestSendOnlySymmetrical) { sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), acd->codecs())); @@ -5213,21 +5226,21 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, TestRecvOnlySymmetrical) { .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &answer_opts); @@ -5235,7 +5248,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, TestRecvOnlySymmetrical) { sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), acd->codecs())); @@ -5268,28 +5281,28 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5297,7 +5310,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), acd->codecs())); @@ -5330,28 +5343,28 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5359,7 +5372,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), acd->codecs())); @@ -5392,28 +5405,28 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5421,7 +5434,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level31), acd->codecs())); @@ -5430,7 +5443,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, std::unique_ptr reoffer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(reoffer.get()); - const ContentInfo* reoffer_oc = reoffer->GetContentByName("video"); + const ContentInfo* reoffer_oc = reoffer->GetContentByName(kVideoMid); ASSERT_TRUE(reoffer_oc); const MediaContentDescription* reoffer_ocd = reoffer_oc->media_description(); EXPECT_TRUE( @@ -5464,28 +5477,28 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5493,7 +5506,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), acd->codecs())); @@ -5526,28 +5539,28 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level4LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5555,7 +5568,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), acd->codecs())); @@ -5588,24 +5601,24 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level6LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5613,7 +5626,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), acd->codecs())); @@ -5646,24 +5659,24 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5671,7 +5684,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), acd->codecs())); @@ -5704,24 +5717,24 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5729,7 +5742,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level31), acd->codecs())); @@ -5762,24 +5775,24 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5787,7 +5800,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), acd->codecs())); @@ -5820,24 +5833,24 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level6LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &answer_opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &answer_opts); @@ -5845,7 +5858,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), acd->codecs())); @@ -5878,25 +5891,25 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level52LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &answer_opts); @@ -5904,7 +5917,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level52), acd->codecs())); @@ -5937,25 +5950,25 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level6LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &answer_opts); @@ -5963,7 +5976,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), acd->codecs())); @@ -5996,25 +6009,25 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level6LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &answer_opts); @@ -6022,7 +6035,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level5), acd->codecs())); @@ -6055,25 +6068,25 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level6LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &answer_opts); @@ -6081,7 +6094,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level6), acd->codecs())); @@ -6114,25 +6127,25 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendOnly, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level4LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &answer_opts); @@ -6140,7 +6153,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), acd->codecs())); @@ -6169,11 +6182,11 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, .codecs()); MediaSessionOptions opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kSendRecv, kActive, &opts); - AttachSenderToMediaDescriptionOptions("video", webrtc::MediaType::VIDEO, + AttachSenderToMediaDescriptionOptions(kVideoMid, webrtc::MediaType::VIDEO, kVideoTrack1, {kMediaStream1}, 1, &opts); std::vector preferences; @@ -6186,14 +6199,14 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, std::unique_ptr offer = sf_offerer_.CreateOfferOrError(opts, nullptr).MoveValue(); ASSERT_TRUE(offer.get()); - const ContentInfo* oc = offer->GetContentByName("video"); + const ContentInfo* oc = offer->GetContentByName(kVideoMid); ASSERT_TRUE(oc); const MediaContentDescription* ocd = oc->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), ocd->codecs())); CheckH265Level(ocd->codecs(), kVideoCodecsH265Level4LevelId); MediaSessionOptions answer_opts; - AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, "video", + AddMediaDescriptionOptions(webrtc::MediaType::VIDEO, kVideoMid, RtpTransceiverDirection::kRecvOnly, kActive, &answer_opts); @@ -6201,7 +6214,7 @@ TEST_F(VideoCodecsOfferH265LevelIdTest, sf_answerer_.CreateAnswerOrError(offer.get(), answer_opts, nullptr) .MoveValue(); ASSERT_TRUE(answer.get()); - const ContentInfo* ac = answer->GetContentByName("video"); + const ContentInfo* ac = answer->GetContentByName(kVideoMid); ASSERT_TRUE(ac); const MediaContentDescription* acd = ac->media_description(); EXPECT_TRUE(CodecsMatch(MAKE_VECTOR(kVideoCodecsH265Level4), acd->codecs())); diff --git a/pc/media_stream.cc b/pc/media_stream.cc index ceafb52c31..e4f52356e4 100644 --- a/pc/media_stream.cc +++ b/pc/media_stream.cc @@ -10,8 +10,7 @@ #include "pc/media_stream.h" -#include - +#include #include #include diff --git a/pc/media_stream_unittest.cc b/pc/media_stream_unittest.cc index 35a518f95e..de82b201e7 100644 --- a/pc/media_stream_unittest.cc +++ b/pc/media_stream_unittest.cc @@ -10,7 +10,7 @@ #include "pc/media_stream.h" -#include +#include #include "api/media_stream_interface.h" #include "api/scoped_refptr.h" diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index efc37f4cc1..f2cc52bee2 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -10,9 +10,8 @@ #include "pc/peer_connection.h" -#include -#include - +#include +#include #include #include #include @@ -24,6 +23,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/functional/any_invocable.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -297,6 +297,7 @@ RTCErrorOr ApplyConfiguration( existing_configuration; modified_config.servers = configuration.servers; modified_config.type = configuration.type; + modified_config.crypto_options = configuration.crypto_options; modified_config.ice_candidate_pool_size = configuration.ice_candidate_pool_size; modified_config.prune_turn_ports = configuration.prune_turn_ports; @@ -686,11 +687,9 @@ JsepTransportController* PeerConnection::InitializeTransportController_n( config.disable_encryption = options_.disable_encryption; config.bundle_policy = configuration.bundle_policy; config.rtcp_mux_policy = configuration.rtcp_mux_policy; - // TODO(bugs.webrtc.org/9891) - Remove options_.crypto_options then remove - // this stub. config.crypto_options = configuration.crypto_options.has_value() ? *configuration.crypto_options - : options_.crypto_options; + : CryptoOptions(); // Maybe enable PQC from FieldTrials config.crypto_options.ephemeral_key_exchange_cipher_groups.Update( @@ -779,12 +778,13 @@ JsepTransportController* PeerConnection::InitializeTransportController_n( })); }); transport_controller_->SubscribeIceCandidatesRemoved( - [this](const std::vector& c) { + [this](IceTransportInternal* transport, const std::vector& c) { RTC_DCHECK_RUN_ON(network_thread()); - signaling_thread()->PostTask( - SafeTask(signaling_thread_safety_.flag(), [this, c = c]() { + std::string mid = transport->transport_name(); + signaling_thread()->PostTask(SafeTask( + signaling_thread_safety_.flag(), [this, mid = mid, c = c]() { RTC_DCHECK_RUN_ON(signaling_thread()); - OnTransportControllerCandidatesRemoved(c); + OnTransportControllerCandidatesRemoved(mid, c); })); }); transport_controller_->SubscribeIceCandidatePairChanged( @@ -798,8 +798,7 @@ JsepTransportController* PeerConnection::InitializeTransportController_n( }); IceConfig ice_config(configuration); - ice_config.dtls_handshake_in_stun = - CanAttemptDtlsStunPiggybacking(configuration); + ice_config.dtls_handshake_in_stun = CanAttemptDtlsStunPiggybacking(); transport_controller_->SetIceConfig(ice_config); return transport_controller_.get(); @@ -1495,7 +1494,8 @@ RTCError PeerConnection::SetConfiguration( } if (has_local_description && - configuration.crypto_options != configuration_.crypto_options) { + configuration.crypto_options.value_or(CryptoOptions()) != + configuration_.crypto_options) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_MODIFICATION, "Can't change crypto_options after calling " "SetLocalDescription."); @@ -1528,8 +1528,7 @@ RTCError PeerConnection::SetConfiguration( modified_config.GetTurnPortPrunePolicy() != configuration_.GetTurnPortPrunePolicy(); IceConfig ice_config(modified_config); - ice_config.dtls_handshake_in_stun = - CanAttemptDtlsStunPiggybacking(modified_config); + ice_config.dtls_handshake_in_stun = CanAttemptDtlsStunPiggybacking(); // Apply part of the configuration on the network thread. In theory this // shouldn't fail. @@ -1579,6 +1578,12 @@ void PeerConnection::AddIceCandidate(std::unique_ptr candidate, }); } +bool PeerConnection::RemoveIceCandidate(const IceCandidate* candidate) { + TRACE_EVENT0("webrtc", "PeerConnection::RemoveIceCandidate"); + RTC_DCHECK_RUN_ON(signaling_thread()); + return sdp_handler_->RemoveIceCandidate(candidate); +} + bool PeerConnection::RemoveIceCandidates( const std::vector& candidates) { TRACE_EVENT0("webrtc", "PeerConnection::RemoveIceCandidates"); @@ -1776,11 +1781,17 @@ void PeerConnection::Close() { legacy_stats_->UpdateStats(kStatsOutputLevelStandard); ice_connection_state_ = PeerConnectionInterface::kIceConnectionClosed; - Observer()->OnIceConnectionChange(ice_connection_state_); + RunWithObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + observer->OnIceConnectionChange(ice_connection_state_); + }); standardized_ice_connection_state_ = PeerConnectionInterface::IceConnectionState::kIceConnectionClosed; connection_state_ = PeerConnectionInterface::PeerConnectionState::kClosed; - Observer()->OnConnectionChange(connection_state_); + RunWithObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + observer->OnConnectionChange(connection_state_); + }); sdp_handler_->Close(); @@ -1868,7 +1879,10 @@ void PeerConnection::SetIceConnectionState(IceConnectionState new_state) { PeerConnectionInterface::kIceConnectionClosed); ice_connection_state_ = new_state; - Observer()->OnIceConnectionChange(ice_connection_state_); + RunWithObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + observer->OnIceConnectionChange(ice_connection_state_); + }); } void PeerConnection::SetStandardizedIceConnectionState( @@ -1885,7 +1899,9 @@ void PeerConnection::SetStandardizedIceConnectionState( << standardized_ice_connection_state_ << " => " << new_state; standardized_ice_connection_state_ = new_state; - Observer()->OnStandardizedIceConnectionChange(new_state); + RunWithObserver([&](auto observer) { + observer->OnStandardizedIceConnectionChange(new_state); + }); } void PeerConnection::SetConnectionState( @@ -1895,7 +1911,8 @@ void PeerConnection::SetConnectionState( if (IsClosed()) return; connection_state_ = new_state; - Observer()->OnConnectionChange(new_state); + RunWithObserver( + [&](auto observer) { observer->OnConnectionChange(new_state); }); // The first connection state change to connected happens once per // connection which makes it a good point to report metrics. @@ -2031,7 +2048,10 @@ void PeerConnection::OnIceGatheringChange( return; } ice_gathering_state_ = new_state; - Observer()->OnIceGatheringChange(ice_gathering_state_); + RunWithObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + observer->OnIceGatheringChange(ice_gathering_state_); + }); } void PeerConnection::OnIceCandidate(std::unique_ptr candidate) { @@ -2040,7 +2060,8 @@ void PeerConnection::OnIceCandidate(std::unique_ptr candidate) { } ReportIceCandidateCollected(candidate->candidate()); ClearStatsCache(); - Observer()->OnIceCandidate(candidate.get()); + RunWithObserver( + [&](auto observer) { observer->OnIceCandidate(candidate.get()); }); } void PeerConnection::OnIceCandidateError(const std::string& address, @@ -2051,15 +2072,30 @@ void PeerConnection::OnIceCandidateError(const std::string& address, if (IsClosed()) { return; } - Observer()->OnIceCandidateError(address, port, url, error_code, error_text); + RunWithObserver([&](auto observer) { + observer->OnIceCandidateError(address, port, url, error_code, error_text); + }); } void PeerConnection::OnIceCandidatesRemoved( + absl::string_view mid, const std::vector& candidates) { if (IsClosed()) { return; } - Observer()->OnIceCandidatesRemoved(candidates); + // Since this callback is based on the Candidate type, and not IceCandidate, + // all candidate instances should have the transport_name() property set to + // `mid`. See BasicPortAllocatorSession::PrunePortsAndRemoveCandidates for + // where the list of candidates is initially gathered. + std::vector candidates_for_notification; + candidates_for_notification.reserve(candidates.size()); + for (Candidate candidate : candidates) { // Create a copy. + candidate.set_transport_name(mid); + candidates_for_notification.push_back(candidate); + } + RunWithObserver([&](auto observer) { + observer->OnIceCandidatesRemoved(candidates_for_notification); + }); } void PeerConnection::OnSelectedCandidatePairChanged( @@ -2073,7 +2109,9 @@ void PeerConnection::OnSelectedCandidatePairChanged( NoteUsageEvent(UsageEvent::DIRECT_CONNECTION_SELECTED); } - Observer()->OnIceSelectedCandidatePairChanged(event); + RunWithObserver([&](auto observer) { + observer->OnIceSelectedCandidatePairChanged(event); + }); } bool PeerConnection::CreateDataChannelTransport(absl::string_view mid) { @@ -2431,18 +2469,11 @@ void PeerConnection::OnTransportControllerCandidateError( } void PeerConnection::OnTransportControllerCandidatesRemoved( + absl::string_view mid, const std::vector& candidates) { - // Sanity check. - for (const Candidate& candidate : candidates) { - if (candidate.transport_name().empty()) { - RTC_LOG(LS_ERROR) << "OnTransportControllerCandidatesRemoved: " - "empty content name in candidate " - << candidate.ToString(); - return; - } - } - sdp_handler_->RemoveLocalIceCandidates(candidates); - OnIceCandidatesRemoved(candidates); + RTC_DCHECK(!mid.empty()); + sdp_handler_->RemoveLocalIceCandidates(mid, candidates); + OnIceCandidatesRemoved(mid, candidates); } void PeerConnection::OnTransportControllerCandidateChanged( @@ -2686,7 +2717,10 @@ void PeerConnection::AddRemoteCandidate(absl::string_view mid, } void PeerConnection::ReportUsagePattern() const { - usage_pattern_.ReportUsagePattern(observer_); + RunWithMaybeNullObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + usage_pattern_.ReportUsagePattern(observer); + }); } void PeerConnection::ReportRemoteIceCandidateAdded(const Candidate& candidate) { @@ -2910,10 +2944,17 @@ bool PeerConnection::OnTransportChanged( return ret; } -PeerConnectionObserver* PeerConnection::Observer() const { +void PeerConnection::RunWithObserver( + absl::AnyInvocable task) { RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(observer_); - return observer_; + std::move(task)(observer_); +} + +void PeerConnection::RunWithMaybeNullObserver( + absl::AnyInvocable task) const { + RTC_DCHECK_RUN_ON(signaling_thread()); + std::move(task)(observer_); } RTCError PeerConnection::StartSctpTransport(const SctpOptions& options) { @@ -2932,11 +2973,10 @@ RTCError PeerConnection::StartSctpTransport(const SctpOptions& options) { CryptoOptions PeerConnection::GetCryptoOptions() { RTC_DCHECK_RUN_ON(signaling_thread()); - // TODO(bugs.webrtc.org/9891) - Remove PeerConnectionFactory::CryptoOptions - // after it has been removed. - return configuration_.crypto_options.has_value() - ? *configuration_.crypto_options - : options_.crypto_options; + if (!configuration_.crypto_options) { + configuration_.crypto_options = CryptoOptions(); + } + return *configuration_.crypto_options; } void PeerConnection::ClearStatsCache() { @@ -3006,13 +3046,8 @@ PeerConnection::InitializeUnDemuxablePacketHandler() { }; } -bool PeerConnection::CanAttemptDtlsStunPiggybacking( - const RTCConfiguration& configuration) { - // Enable DTLS-in-STUN only if no certificates were passed those - // may be RSA certificates and this feature only works with small - // ECDSA certificates. Determining the type of the key is - // not trivially possible at this point. - return dtls_enabled_ && configuration.certificates.empty() && +bool PeerConnection::CanAttemptDtlsStunPiggybacking() { + return dtls_enabled_ && env_.field_trials().IsEnabled("WebRTC-IceHandshakeDtls"); } diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 1a4cc90a5e..f9ef0b50de 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -21,6 +21,7 @@ #include #include +#include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/adaptation/resource.h" #include "api/async_dns_resolver.h" @@ -235,6 +236,7 @@ class PeerConnection : public PeerConnectionInternal, bool AddIceCandidate(const IceCandidate* candidate) override; void AddIceCandidate(std::unique_ptr candidate, std::function callback) override; + bool RemoveIceCandidate(const IceCandidate* candidate) override; bool RemoveIceCandidates(const std::vector& candidates) override; RTCError SetBitrate(const BitrateSettings& bitrate) override; @@ -308,8 +310,15 @@ class PeerConnection : public PeerConnectionInternal, // Functions needed by DataChannelController void NoteDataAddedEvent() override { NoteUsageEvent(UsageEvent::DATA_ADDED); } - // Returns the observer. Will crash on CHECK if the observer is removed. - PeerConnectionObserver* Observer() const override; + + void RunWithObserver( + absl::AnyInvocable) override + RTC_RUN_ON(signaling_thread()); + + void RunWithMaybeNullObserver( + absl::AnyInvocable) const + RTC_RUN_ON(signaling_thread()); + bool IsClosed() const override { RTC_DCHECK_RUN_ON(signaling_thread()); return !sdp_handler_ || @@ -405,8 +414,8 @@ class PeerConnection : public PeerConnectionInternal, RTCError StartSctpTransport(const SctpOptions& options) override; // Returns the CryptoOptions for this PeerConnection. This will always - // return the RTCConfiguration.crypto_options if set and will only default - // back to the PeerConnectionFactory settings if nothing was set. + // return the RTCConfiguration.crypto_options if set and return a stock + // configuration if nothing was set. CryptoOptions GetCryptoOptions() override; // Internal implementation for AddTransceiver family of methods. If @@ -512,7 +521,8 @@ class PeerConnection : public PeerConnectionInternal, const std::string& error_text) RTC_RUN_ON(signaling_thread()); // Some local ICE candidates have been removed. - void OnIceCandidatesRemoved(const std::vector& candidates) + void OnIceCandidatesRemoved(absl::string_view mid, + const std::vector& candidates) RTC_RUN_ON(signaling_thread()); void OnSelectedCandidatePairChanged(const CandidatePairChangeEvent& event) @@ -573,6 +583,7 @@ class PeerConnection : public PeerConnectionInternal, void OnTransportControllerCandidateError(const IceCandidateErrorEvent& event) RTC_RUN_ON(signaling_thread()); void OnTransportControllerCandidatesRemoved( + absl::string_view mid, const std::vector& candidates) RTC_RUN_ON(signaling_thread()); void OnTransportControllerCandidateChanged( const CandidatePairChangeEvent& event) RTC_RUN_ON(signaling_thread()); @@ -618,7 +629,7 @@ class PeerConnection : public PeerConnectionInternal, std::function InitializeUnDemuxablePacketHandler(); - bool CanAttemptDtlsStunPiggybacking(const RTCConfiguration& configuration); + bool CanAttemptDtlsStunPiggybacking(); const Environment env_; const scoped_refptr context_; diff --git a/pc/peer_connection_adaptation_integrationtest.cc b/pc/peer_connection_adaptation_integrationtest.cc index da4f387ea6..cdb8ea823f 100644 --- a/pc/peer_connection_adaptation_integrationtest.cc +++ b/pc/peer_connection_adaptation_integrationtest.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include #include diff --git a/pc/peer_connection_bundle_unittest.cc b/pc/peer_connection_bundle_unittest.cc index 95eed4e1ec..4f785f2333 100644 --- a/pc/peer_connection_bundle_unittest.cc +++ b/pc/peer_connection_bundle_unittest.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include @@ -18,6 +17,7 @@ #include #include "api/candidate.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/jsep.h" #include "api/media_types.h" @@ -111,7 +111,6 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper { for (size_t i = 0; i < desc->contents().size(); i++) { const auto& content = desc->contents()[i]; if (content.media_description()->type() == media_type) { - candidate->set_transport_name(content.mid()); std::unique_ptr jsep_candidate = CreateIceCandidate(content.mid(), i, *candidate); return pc()->AddIceCandidate(jsep_candidate.get()); @@ -320,7 +319,8 @@ TEST_P(PeerConnectionBundleTest, ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); RTCOfferAnswerOptions options_no_bundle; options_no_bundle.use_rtp_mux = false; - auto answer = callee->CreateAnswer(options_no_bundle); + std::unique_ptr answer = + callee->CreateAnswer(options_no_bundle); SdpContentsForEach(RemoveRtcpMux(), answer->description()); ASSERT_TRUE( callee->SetLocalDescription(CloneSessionDescription(answer.get()))); @@ -612,7 +612,8 @@ TEST_P(PeerConnectionBundleTest, FailToSetDescriptionWithBundleAndNoRtcpMux) { RTCOfferAnswerOptions options; options.use_rtp_mux = true; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); SdpContentsForEach(RemoveRtcpMux(), offer->description()); std::string error; @@ -699,7 +700,7 @@ TEST_P(PeerConnectionBundleTest, BundleOnFirstMidInAnswer) { auto* old_video_transport = caller->video_rtp_transport(); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto* old_bundle_group = answer->description()->GetGroupByName(GROUP_TYPE_BUNDLE); std::string first_mid = old_bundle_group->content_names()[0]; @@ -725,7 +726,8 @@ TEST_P(PeerConnectionBundleTest, ApplyDescriptionWithSameSsrcsBundledFails) { RTCOfferAnswerOptions options; options.use_rtp_mux = true; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); // Modify the remote SDP to make two m= sections have the same SSRC. @@ -744,7 +746,8 @@ TEST_P(PeerConnectionBundleTest, ApplyDescriptionWithSameSsrcsBundledFails) { EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); // When BUNDLE is enabled, applying the description is expected to fail // because the demuxing criteria can not be satisfied. - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); EXPECT_FALSE(callee->SetLocalDescription(std::move(answer))); } @@ -756,7 +759,8 @@ TEST_P(PeerConnectionBundleTest, RTCOfferAnswerOptions options; options.use_rtp_mux = false; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); // Modify the remote SDP to make two m= sections have the same SSRC. @@ -774,7 +778,8 @@ TEST_P(PeerConnectionBundleTest, EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); // Without BUNDLE, demuxing is done per-transport. - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); EXPECT_TRUE(callee->SetLocalDescription(std::move(answer))); } @@ -787,7 +792,8 @@ TEST_P(PeerConnectionBundleTest, RejectDescriptionChangingBundleTag) { RTCOfferAnswerOptions options; options.use_rtp_mux = true; - auto offer = caller->CreateOfferAndSetAsLocal(options); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(options); // Create a new bundle-group with different bundled_mid. auto* old_bundle_group = @@ -799,7 +805,8 @@ TEST_P(PeerConnectionBundleTest, RejectDescriptionChangingBundleTag) { auto re_offer = CloneSessionDescription(offer.get()); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); // Reject the first MID. answer->description()->contents()[0].rejected = true; // Remove the first MID from the bundle group. @@ -826,7 +833,8 @@ TEST_P(PeerConnectionBundleTest, RemovingContentAndRejectBundleGroup) { auto caller = CreatePeerConnectionWithAudioVideo(config); caller->CreateDataChannel("dc"); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); auto re_offer = CloneSessionDescription(offer.get()); // Removing the second MID from the BUNDLE group. @@ -854,7 +862,7 @@ TEST_P(PeerConnectionBundleTest, AddContentToBundleGroupInAnswerNotSupported) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); const auto first_mid = offer->description()->contents()[0].mid(); const auto second_mid = offer->description()->contents()[1].mid(); @@ -866,7 +874,7 @@ TEST_P(PeerConnectionBundleTest, AddContentToBundleGroupInAnswerNotSupported) { caller->SetLocalDescription(CloneSessionDescription(offer.get()))); EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); bundle_group.AddContentName(second_mid); answer->description()->RemoveGroupByName(GROUP_TYPE_BUNDLE); answer->description()->AddGroup(bundle_group); @@ -881,7 +889,7 @@ TEST_P(PeerConnectionBundleTest, RejectBundleGroupWithNonExistingMid) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto invalid_bundle_group = *offer->description()->GetGroupByName(GROUP_TYPE_BUNDLE); invalid_bundle_group.AddContentName("non-existing-MID"); @@ -904,7 +912,7 @@ TEST_P(PeerConnectionBundleTest, RemoveContentFromBundleGroup) { caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal())); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); const auto second_mid = answer->description()->contents()[1].mid(); auto invalid_bundle_group = @@ -960,7 +968,8 @@ TEST_F(PeerConnectionBundleTestUnifiedPlan, MultipleBundleGroups) { caller->AddVideoTrack("3_audio"); auto callee = CreatePeerConnection(); - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); // Modify the GROUP to have two BUNDLEs. We know that the MIDs will be 0,1,2,4 // because our implementation has predictable MIDs. offer->description()->RemoveGroupByName(GROUP_TYPE_BUNDLE); @@ -976,7 +985,7 @@ TEST_F(PeerConnectionBundleTestUnifiedPlan, MultipleBundleGroups) { EXPECT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); EXPECT_TRUE( callee->SetLocalDescription(CloneSessionDescription(answer.get()))); EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); @@ -1015,11 +1024,12 @@ TEST_F(PeerConnectionBundleTestUnifiedPlan, AddNonBundledSection) { auto callee = CreatePeerConnection(config); // Establish an existing BUNDLE group. - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); EXPECT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); EXPECT_TRUE( callee->SetLocalDescription(CloneSessionDescription(answer.get()))); EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); diff --git a/pc/peer_connection_callsetup_perf_tests.cc b/pc/peer_connection_callsetup_perf_tests.cc index 04f4462df7..8b77b72b56 100644 --- a/pc/peer_connection_callsetup_perf_tests.cc +++ b/pc/peer_connection_callsetup_perf_tests.cc @@ -21,7 +21,6 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/data_channel_interface.h" -#include "api/field_trials.h" #include "api/jsep.h" #include "api/make_ref_counted.h" #include "api/rtc_error.h" @@ -72,10 +71,9 @@ class PeerConnectionDataChannelOpenTest absl::string_view field_trials = "") { auto pc_wrapper = make_ref_counted( "pc", &vss_, background_thread_.get(), background_thread_.get()); - pc_wrapper->CreatePc( - {}, CreateBuiltinAudioEncoderFactory(), - CreateBuiltinAudioDecoderFactory(), - std::make_unique(CreateTestFieldTrials(field_trials))); + pc_wrapper->CreatePc({}, CreateBuiltinAudioEncoderFactory(), + CreateBuiltinAudioDecoderFactory(), + CreateTestFieldTrialsPtr(field_trials)); return pc_wrapper; } diff --git a/pc/peer_connection_crypto_unittest.cc b/pc/peer_connection_crypto_unittest.cc index 1a4eab3ee2..215e7adc3c 100644 --- a/pc/peer_connection_crypto_unittest.cc +++ b/pc/peer_connection_crypto_unittest.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include @@ -65,8 +64,10 @@ namespace webrtc { using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; + using ::testing::Combine; using ::testing::HasSubstr; +using ::testing::NotNull; using ::testing::Values; constexpr int kGenerateCertTimeout = 1000; @@ -191,8 +192,8 @@ TEST_P(PeerConnectionCryptoTest, CorrectCryptoInOfferWhenDtlsEnabled) { RTCConfiguration config; auto caller = CreatePeerConnectionWithAudioVideo(config); - auto offer = caller->CreateOffer(); - ASSERT_TRUE(offer); + std::unique_ptr offer = caller->CreateOffer(); + ASSERT_THAT(offer, NotNull()); ASSERT_FALSE(offer->description()->contents().empty()); EXPECT_TRUE(SdpContentsAll(HaveDtlsFingerprint(), offer->description())); @@ -205,8 +206,8 @@ TEST_P(PeerConnectionCryptoTest, CorrectCryptoInAnswerWhenDtlsEnabled) { auto callee = CreatePeerConnectionWithAudioVideo(config); callee->SetRemoteDescription(caller->CreateOffer()); - auto answer = callee->CreateAnswer(); - ASSERT_TRUE(answer); + std::unique_ptr answer = callee->CreateAnswer(); + ASSERT_THAT(answer, NotNull()); ASSERT_FALSE(answer->description()->contents().empty()); EXPECT_TRUE(SdpContentsAll(HaveDtlsFingerprint(), answer->description())); @@ -222,12 +223,14 @@ TEST_P(PeerConnectionCryptoTest, ExchangeOfferAnswerWhenDtlsOn) { auto caller = CreatePeerConnectionWithAudioVideo(config); auto callee = CreatePeerConnectionWithAudioVideo(config); - auto offer = caller->CreateOfferAndSetAsLocal(); - ASSERT_TRUE(offer); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); + ASSERT_THAT(offer, NotNull()); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswerAndSetAsLocal(); - ASSERT_TRUE(answer); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); + ASSERT_THAT(answer, NotNull()); ASSERT_TRUE(caller->SetRemoteDescription(std::move(answer))); } TEST_P(PeerConnectionCryptoTest, @@ -235,7 +238,7 @@ TEST_P(PeerConnectionCryptoTest, RTCConfiguration config; auto caller = CreatePeerConnectionWithAudioVideo(config); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); SdpContentsForEach(RemoveDtlsFingerprint(), offer->description()); EXPECT_FALSE(caller->SetLocalDescription(std::move(offer))); @@ -246,7 +249,7 @@ TEST_P(PeerConnectionCryptoTest, auto caller = CreatePeerConnectionWithAudioVideo(config); auto callee = CreatePeerConnectionWithAudioVideo(config); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); SdpContentsForEach(RemoveDtlsFingerprint(), offer->description()); EXPECT_FALSE(callee->SetRemoteDescription(std::move(offer))); @@ -258,7 +261,7 @@ TEST_P(PeerConnectionCryptoTest, auto callee = CreatePeerConnectionWithAudioVideo(config); callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); SdpContentsForEach(RemoveDtlsFingerprint(), answer->description()); } TEST_P(PeerConnectionCryptoTest, @@ -268,7 +271,8 @@ TEST_P(PeerConnectionCryptoTest, auto callee = CreatePeerConnectionWithAudioVideo(config); callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); SdpContentsForEach(RemoveDtlsFingerprint(), answer->description()); EXPECT_FALSE(caller->SetRemoteDescription(std::move(answer))); @@ -288,12 +292,14 @@ TEST_P(PeerConnectionCryptoTest, FakeRTCCertificateGenerator::GenerateCertificate()); auto callee = CreatePeerConnectionWithAudioVideo(callee_config); - auto offer = caller->CreateOfferAndSetAsLocal(); - ASSERT_TRUE(offer); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); + ASSERT_THAT(offer, NotNull()); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswerAndSetAsLocal(); - ASSERT_TRUE(answer); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); + ASSERT_THAT(answer, NotNull()); ASSERT_TRUE(caller->SetRemoteDescription(std::move(answer))); } @@ -431,7 +437,8 @@ TEST_P(PeerConnectionCryptoTest, CreateAnswerWithDifferentSslRoles) { // First, negotiate different SSL roles for audio and video. ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(options_no_bundle); + std::unique_ptr answer = + callee->CreateAnswer(options_no_bundle); AudioConnectionRole(answer->description()) = CONNECTIONROLE_ACTIVE; VideoConnectionRole(answer->description()) = CONNECTIONROLE_PASSIVE; diff --git a/pc/peer_connection_data_channel_unittest.cc b/pc/peer_connection_data_channel_unittest.cc index 707c34b3ef..a01940c603 100644 --- a/pc/peer_connection_data_channel_unittest.cc +++ b/pc/peer_connection_data_channel_unittest.cc @@ -14,12 +14,12 @@ #include #include +#include "api/create_modular_peer_connection_factory.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" #include "api/scoped_refptr.h" #include "api/sctp_transport_interface.h" -#include "p2p/base/p2p_constants.h" #include "pc/media_session.h" #include "pc/peer_connection.h" #include "pc/peer_connection_wrapper.h" @@ -42,12 +42,15 @@ namespace webrtc { -using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; -using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; using ::testing::HasSubstr; +using ::testing::IsEmpty; using ::testing::Not; +using ::testing::NotNull; using ::testing::Values; +using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; +using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; + namespace { PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies() { @@ -206,7 +209,7 @@ TEST_P(PeerConnectionDataChannelTest, SctpContentAndTransportNameSetCorrectly) { caller->AddVideoTrack("v"); caller->pc()->CreateDataChannelOrError("dc", nullptr); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); const auto& offer_contents = offer->description()->contents(); ASSERT_EQ(MediaType::AUDIO, offer_contents[0].media_description()->type()); auto audio_mid = offer_contents[0].mid(); @@ -238,10 +241,8 @@ TEST_P(PeerConnectionDataChannelTest, SctpContentAndTransportNameSetCorrectly) { TEST_P(PeerConnectionDataChannelTest, CreateOfferWithNoDataChannelsGivesNoDataSection) { auto caller = CreatePeerConnection(); - auto offer = caller->CreateOffer(); - - EXPECT_FALSE(offer->description()->GetContentByName(CN_DATA)); - EXPECT_FALSE(offer->description()->GetTransportInfoByName(CN_DATA)); + std::unique_ptr offer = caller->CreateOffer(); + EXPECT_THAT(offer->description()->contents(), IsEmpty()); } TEST_P(PeerConnectionDataChannelTest, @@ -251,8 +252,8 @@ TEST_P(PeerConnectionDataChannelTest, ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); - ASSERT_TRUE(answer); + std::unique_ptr answer = callee->CreateAnswer(); + ASSERT_THAT(answer, NotNull()); auto* data_content = GetFirstDataContent(answer->description()); ASSERT_TRUE(data_content); EXPECT_FALSE(data_content->rejected); @@ -267,11 +268,11 @@ TEST_P(PeerConnectionDataChannelTest, SctpPortPropagatedFromSdpToTransport) { auto caller = CreatePeerConnectionWithDataChannel(); auto callee = CreatePeerConnectionWithDataChannel(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ChangeSctpPortOnDescription(offer->description(), kNewSendPort); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); ChangeSctpPortOnDescription(answer->description(), kNewRecvPort); std::string sdp; answer->ToString(&sdp); @@ -286,7 +287,8 @@ TEST_P(PeerConnectionDataChannelTest, SctpPortPropagatedFromSdpToTransport) { TEST_P(PeerConnectionDataChannelTest, ModernSdpSyntaxByDefault) { PeerConnectionInterface::RTCOfferAnswerOptions options; auto caller = CreatePeerConnectionWithDataChannel(); - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_FALSE( GetFirstSctpDataContentDescription(offer->description())->use_sctpmap()); std::string sdp; @@ -300,7 +302,8 @@ TEST_P(PeerConnectionDataChannelTest, ObsoleteSdpSyntaxIfSet) { PeerConnectionInterface::RTCOfferAnswerOptions options; options.use_obsolete_sctp_sdp = true; auto caller = CreatePeerConnectionWithDataChannel(); - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_TRUE( GetFirstSctpDataContentDescription(offer->description())->use_sctpmap()); std::string sdp; diff --git a/pc/peer_connection_encodings_integrationtest.cc b/pc/peer_connection_encodings_integrationtest.cc index 4de839059a..142967f892 100644 --- a/pc/peer_connection_encodings_integrationtest.cc +++ b/pc/peer_connection_encodings_integrationtest.cc @@ -26,7 +26,6 @@ #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/field_trials.h" #include "api/field_trials_view.h" #include "api/jsep.h" #include "api/make_ref_counted.h" @@ -235,10 +234,9 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test { absl::string_view field_trials = "") { auto pc_wrapper = make_ref_counted( "pc", &pss_, background_thread_.get(), background_thread_.get()); - pc_wrapper->CreatePc( - {}, CreateBuiltinAudioEncoderFactory(), - CreateBuiltinAudioDecoderFactory(), - std::make_unique(CreateTestFieldTrials(field_trials))); + pc_wrapper->CreatePc({}, CreateBuiltinAudioEncoderFactory(), + CreateBuiltinAudioDecoderFactory(), + CreateTestFieldTrialsPtr(field_trials)); return pc_wrapper; } diff --git a/pc/peer_connection_end_to_end_unittest.cc b/pc/peer_connection_end_to_end_unittest.cc index 2fcf4dc435..fccedba165 100644 --- a/pc/peer_connection_end_to_end_unittest.cc +++ b/pc/peer_connection_end_to_end_unittest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include +#include #include #include #include @@ -73,7 +72,7 @@ using ::webrtc::SdpSemantics; namespace { -const int kMaxWait = 25000; +constexpr int kMaxWait = 25000; } // namespace diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index fb248a9ee9..39038d5660 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -18,7 +18,6 @@ #include #include -#include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "api/audio_options.h" #include "api/environment/environment.h" @@ -87,6 +86,9 @@ Environment AssembleEnvironment(PeerConnectionFactoryDependencies& deps) { } // namespace +// TODO: bugs.webrtc.org/42220069 - Move this function to +// 'create_modular_peer_connection_factory' build target when all users of this +// function would depend on that build target. scoped_refptr CreateModularPeerConnectionFactory( PeerConnectionFactoryDependencies dependencies) { @@ -400,7 +402,8 @@ std::unique_ptr PeerConnectionFactory::CreateCall_w( RTC_LOG(LS_INFO) << "Using pc injected network controller factory"; call_config.per_call_network_controller_factory = std::move(per_call_network_controller_factory); - } else if (IsTrialEnabled("WebRTC-Bwe-InjectedCongestionController")) { + } else if (field_trials().IsEnabled( + "WebRTC-Bwe-InjectedCongestionController")) { RTC_LOG(LS_INFO) << "Using pcf injected network controller factory"; call_config.network_controller_factory = injected_network_controller_factory_.get(); @@ -416,8 +419,4 @@ std::unique_ptr PeerConnectionFactory::CreateCall_w( return context_->call_factory()->CreateCall(std::move(call_config)); } -bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const { - return absl::StartsWith(field_trials().Lookup(key), "Enabled"); -} - } // namespace webrtc diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h index 5b99a69674..ec0611abc9 100644 --- a/pc/peer_connection_factory.h +++ b/pc/peer_connection_factory.h @@ -39,7 +39,6 @@ #include "call/call.h" #include "call/rtp_transport_controller_send_factory_interface.h" #include "media/base/media_engine.h" -#include "p2p/base/port_allocator.h" #include "pc/codec_vendor.h" #include "pc/connection_context.h" #include "rtc_base/thread.h" @@ -126,8 +125,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { private: Thread* network_thread() const { return context_->network_thread(); } - bool IsTrialEnabled(absl::string_view key) const; - std::unique_ptr CreateCall_w( const Environment& env, const PeerConnectionInterface::RTCConfiguration& configuration, diff --git a/pc/peer_connection_factory_unittest.cc b/pc/peer_connection_factory_unittest.cc index 568c123d2f..d245f0f7ce 100644 --- a/pc/peer_connection_factory_unittest.cc +++ b/pc/peer_connection_factory_unittest.cc @@ -20,6 +20,7 @@ #include "api/audio/audio_device.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/create_peerconnection_factory.h" #include "api/data_channel_interface.h" #include "api/enable_media.h" @@ -87,23 +88,25 @@ using ::testing::NotNull; using ::testing::Return; using ::testing::UnorderedElementsAre; -const char kStunIceServer[] = "stun:stun.l.google.com:19302"; -const char kTurnIceServer[] = "turn:test.com:1234"; -const char kTurnIceServerWithTransport[] = "turn:hello.com?transport=tcp"; -const char kSecureTurnIceServer[] = "turns:hello.com?transport=tcp"; -const char kSecureTurnIceServerWithoutTransportParam[] = "turns:hello.com:443"; -const char kSecureTurnIceServerWithoutTransportAndPortParam[] = +constexpr char kStunIceServer[] = "stun:stun.l.google.com:19302"; +constexpr char kTurnIceServer[] = "turn:test.com:1234"; +constexpr char kTurnIceServerWithTransport[] = "turn:hello.com?transport=tcp"; +constexpr char kSecureTurnIceServer[] = "turns:hello.com?transport=tcp"; +constexpr char kSecureTurnIceServerWithoutTransportParam[] = + "turns:hello.com:443"; +constexpr char kSecureTurnIceServerWithoutTransportAndPortParam[] = "turns:hello.com"; -const char kTurnIceServerWithNoUsernameInUri[] = "turn:test.com:1234"; -const char kTurnPassword[] = "turnpassword"; -const int kDefaultStunPort = 3478; -const int kDefaultStunTlsPort = 5349; -const char kTurnUsername[] = "test"; -const char kStunIceServerWithIPv4Address[] = "stun:1.2.3.4:1234"; -const char kStunIceServerWithIPv4AddressWithoutPort[] = "stun:1.2.3.4"; -const char kStunIceServerWithIPv6Address[] = "stun:[2401:fa00:4::]:1234"; -const char kStunIceServerWithIPv6AddressWithoutPort[] = "stun:[2401:fa00:4::]"; -const char kTurnIceServerWithIPv6Address[] = "turn:[2401:fa00:4::]:1234"; +constexpr char kTurnIceServerWithNoUsernameInUri[] = "turn:test.com:1234"; +constexpr char kTurnPassword[] = "turnpassword"; +constexpr int kDefaultStunPort = 3478; +constexpr int kDefaultStunTlsPort = 5349; +constexpr char kTurnUsername[] = "test"; +constexpr char kStunIceServerWithIPv4Address[] = "stun:1.2.3.4:1234"; +constexpr char kStunIceServerWithIPv4AddressWithoutPort[] = "stun:1.2.3.4"; +constexpr char kStunIceServerWithIPv6Address[] = "stun:[2401:fa00:4::]:1234"; +constexpr char kStunIceServerWithIPv6AddressWithoutPort[] = + "stun:[2401:fa00:4::]"; +constexpr char kTurnIceServerWithIPv6Address[] = "turn:[2401:fa00:4::]:1234"; class NullPeerConnectionObserver : public PeerConnectionObserver { public: diff --git a/pc/peer_connection_field_trial_tests.cc b/pc/peer_connection_field_trial_tests.cc index c2bbcf8943..4977bdd07f 100644 --- a/pc/peer_connection_field_trial_tests.cc +++ b/pc/peer_connection_field_trial_tests.cc @@ -17,9 +17,10 @@ #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" +#include "api/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" #include "api/rtp_parameters.h" @@ -66,8 +67,7 @@ class PeerConnectionFieldTrialTest : public ::testing::Test { void CreatePCFactory(absl::string_view field_trials) { PeerConnectionFactoryDependencies pcf_deps; pcf_deps.signaling_thread = Thread::Current(); - pcf_deps.env = CreateEnvironment( - std::make_unique(CreateTestFieldTrials(field_trials))); + pcf_deps.env = CreateEnvironment(CreateTestFieldTrialsPtr(field_trials)); pcf_deps.adm = FakeAudioCaptureModule::Create(); EnableMediaWithDefaults(pcf_deps); pc_factory_ = CreateModularPeerConnectionFactory(std::move(pcf_deps)); @@ -106,7 +106,7 @@ TEST_F(PeerConnectionFieldTrialTest, EnableDependencyDescriptorAdvertised) { WrapperPtr caller = CreatePeerConnection(); caller->AddTransceiver(MediaType::VIDEO); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents1 = offer->description()->contents(); ASSERT_EQ(1u, contents1.size()); @@ -139,7 +139,7 @@ TEST_F(PeerConnectionFieldTrialTest, MAYBE_InjectDependencyDescriptor) { WrapperPtr callee = CreatePeerConnection(); caller->AddTransceiver(MediaType::VIDEO); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ContentInfos& contents1 = offer->description()->contents(); ASSERT_EQ(1u, contents1.size()); @@ -182,7 +182,7 @@ TEST_F(PeerConnectionFieldTrialTest, MAYBE_InjectDependencyDescriptor) { caller->SetLocalDescription(offer->Clone()); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); ContentInfos& contents2 = answer->description()->contents(); ASSERT_EQ(1u, contents2.size()); diff --git a/pc/peer_connection_header_extension_unittest.cc b/pc/peer_connection_header_extension_unittest.cc index 5342b3b9f9..a4c0eb6b51 100644 --- a/pc/peer_connection_header_extension_unittest.cc +++ b/pc/peer_connection_header_extension_unittest.cc @@ -16,6 +16,7 @@ #include #include "absl/strings/string_view.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/environment/environment_factory.h" #include "api/jsep.h" #include "api/media_types.h" @@ -198,8 +199,9 @@ TEST_P(PeerConnectionHeaderExtensionTest, AnswersUnstoppedModifiedExtensions) { CreatePeerConnection(media_type, semantics); auto transceiver1 = pc1->AddTransceiver(media_type); - auto offer = pc1->CreateOfferAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr offer = + pc1->CreateOfferAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); pc2->SetRemoteDescription(std::move(offer)); ASSERT_EQ(pc2->pc()->GetTransceivers().size(), 1u); @@ -209,8 +211,9 @@ TEST_P(PeerConnectionHeaderExtensionTest, AnswersUnstoppedModifiedExtensions) { modified_extensions[3].direction = RtpTransceiverDirection::kStopped; transceiver2->SetHeaderExtensionsToNegotiate(modified_extensions); - auto answer = pc2->CreateAnswerAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr answer = + pc2->CreateAnswerAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); EXPECT_THAT(answer->description() ->contents()[0] .media_description() @@ -231,15 +234,17 @@ TEST_P(PeerConnectionHeaderExtensionTest, NegotiatedExtensionsAreAccessible) { auto modified_extensions = transceiver1->GetHeaderExtensionsToNegotiate(); modified_extensions[3].direction = RtpTransceiverDirection::kStopped; transceiver1->SetHeaderExtensionsToNegotiate(modified_extensions); - auto offer = pc1->CreateOfferAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr offer = + pc1->CreateOfferAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); std::unique_ptr pc2 = CreatePeerConnection(media_type, semantics); auto transceiver2 = pc2->AddTransceiver(media_type); pc2->SetRemoteDescription(std::move(offer)); - auto answer = pc2->CreateAnswerAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr answer = + pc2->CreateAnswerAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); pc1->SetRemoteDescription(std::move(answer)); // PC1 has exts 2-4 unstopped and PC2 has exts 1-3 unstopped -> ext 2, 3 @@ -297,11 +302,13 @@ TEST_P(PeerConnectionHeaderExtensionTest, RemovalAfterRenegotiation) { CreatePeerConnection(media_type, semantics); auto transceiver1 = pc1->AddTransceiver(media_type); - auto offer = pc1->CreateOfferAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr offer = + pc1->CreateOfferAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); pc2->SetRemoteDescription(std::move(offer)); - auto answer = pc2->CreateAnswerAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr answer = + pc2->CreateAnswerAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); pc1->SetRemoteDescription(std::move(answer)); auto modified_extensions = transceiver1->GetHeaderExtensionsToNegotiate(); @@ -329,11 +336,13 @@ TEST_P(PeerConnectionHeaderExtensionTest, CreatePeerConnection(media_type, semantics); auto transceiver1 = pc1->AddTransceiver(media_type); - auto offer = pc1->CreateOfferAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr offer = + pc1->CreateOfferAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); pc2->SetRemoteDescription(std::move(offer)); - auto answer = pc2->CreateAnswerAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr answer = + pc2->CreateAnswerAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); std::string sdp; ASSERT_TRUE(answer->ToString(&sdp)); // We support uri1 but it is stopped by default. Let the remote reactivate it. @@ -386,7 +395,8 @@ TEST_P(PeerConnectionHeaderExtensionTest, "a=mid:audio\r\n" "a=setup:actpass\r\n" "a=extmap:1 urn:bogus\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); pc->SetRemoteDescription(std::move(offer)); pc->CreateAnswerAndSetAsLocal( PeerConnectionInterface::RTCOfferAnswerOptions()); @@ -440,9 +450,10 @@ TEST_P(PeerConnectionHeaderExtensionTest, "a=mid:audio\r\n" "a=setup:actpass\r\n" "a=extmap:1 uri1\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); pc->SetRemoteDescription(std::move(offer)); - auto answer = + std::unique_ptr answer = pc->CreateAnswer(PeerConnectionInterface::RTCOfferAnswerOptions()); std::string modified_sdp; ASSERT_TRUE(answer->ToString(&modified_sdp)); @@ -473,7 +484,7 @@ TEST_P(PeerConnectionHeaderExtensionTest, CreatePeerConnection(media_type, semantics); pc->AddTransceiver(media_type); - auto offer = + std::unique_ptr offer = pc->CreateOffer(PeerConnectionInterface::RTCOfferAnswerOptions()); std::string modified_sdp; ASSERT_TRUE(offer->ToString(&modified_sdp)); @@ -527,7 +538,8 @@ TEST_P(PeerConnectionHeaderExtensionTest, EnablingExtensionsAfterRemoteOffer) { "a=mid:audio\r\n" "a=setup:actpass\r\n" "a=extmap:5 uri1\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); pc->SetRemoteDescription(std::move(offer)); ASSERT_GT(pc->pc()->GetTransceivers().size(), 0u); @@ -570,11 +582,13 @@ TEST_P(PeerConnectionHeaderExtensionTest, SenderParametersReflectNegotiation) { EXPECT_THAT(sender_parameters.header_extensions, IsEmpty()); } - auto offer = pc1->CreateOfferAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr offer = + pc1->CreateOfferAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); pc2->SetRemoteDescription(std::move(offer)); - auto answer = pc2->CreateAnswerAndSetAsLocal( - PeerConnectionInterface::RTCOfferAnswerOptions()); + std::unique_ptr answer = + pc2->CreateAnswerAndSetAsLocal( + PeerConnectionInterface::RTCOfferAnswerOptions()); pc1->SetRemoteDescription(std::move(answer)); { auto sender_parameters = pc1->pc()->GetSenders()[0]->GetParameters(); diff --git a/pc/peer_connection_histogram_unittest.cc b/pc/peer_connection_histogram_unittest.cc index ddc5a3face..10f6455549 100644 --- a/pc/peer_connection_histogram_unittest.cc +++ b/pc/peer_connection_histogram_unittest.cc @@ -18,6 +18,7 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/jsep.h" #include "api/jsep_session_description.h" #include "api/peer_connection_interface.h" @@ -48,9 +49,15 @@ #include "test/wait_until.h" namespace webrtc { - namespace { +using ::testing::NiceMock; +using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; +using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; + +class PeerConnectionWrapperForUsageHistogramTest; +typedef PeerConnectionWrapperForUsageHistogramTest* RawWrapperPtr; + constexpr const char kBasicRemoteDescription[] = R"(v=0 o=- 0 0 IN IP4 127.0.0.1 s=- @@ -68,11 +75,7 @@ a=rtcp-mux a=rtpmap:101 fake_audio_codec/8000 )"; -using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; -using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; -using ::testing::NiceMock; - -const char kUsagePatternMetric[] = "WebRTC.PeerConnection.UsagePattern"; +constexpr char kUsagePatternMetric[] = "WebRTC.PeerConnection.UsagePattern"; constexpr TimeDelta kDefaultTimeout = TimeDelta::Millis(10000); const SocketAddress kLocalAddrs[2] = {SocketAddress("1.1.1.1", 0), SocketAddress("2.2.2.2", 0)}; @@ -87,10 +90,6 @@ int MakeUsageFingerprint(std::set events) { return signature; } -class PeerConnectionWrapperForUsageHistogramTest; - -typedef PeerConnectionWrapperForUsageHistogramTest* RawWrapperPtr; - class ObserverForUsageHistogramTest : public MockPeerConnectionObserver { public: void OnIceCandidate(const IceCandidate* candidate) override; @@ -189,7 +188,8 @@ class PeerConnectionWrapperForUsageHistogramTest } bool GenerateOfferAndCollectCandidates() { - auto offer = CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + CreateOffer(RTCOfferAnswerOptions()); if (!offer) { return false; } @@ -698,7 +698,7 @@ TEST_F(PeerConnectionUsageHistogramTest, ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); // By default, the Answer created does not contain ICE candidates. - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); callee->SetLocalDescription(CloneSessionDescription(answer.get())); caller->SetRemoteDescription(std::move(answer)); EXPECT_THAT( @@ -811,5 +811,4 @@ TEST_F(PeerConnectionUsageHistogramTest, #endif } // namespace - } // namespace webrtc diff --git a/pc/peer_connection_ice_unittest.cc b/pc/peer_connection_ice_unittest.cc index fbcdb5bbd1..33d4897dc4 100644 --- a/pc/peer_connection_ice_unittest.cc +++ b/pc/peer_connection_ice_unittest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include +#include #include #include #include @@ -19,6 +18,7 @@ #include #include "api/candidate.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" #include "api/ice_transport_interface.h" @@ -87,7 +87,10 @@ using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; using ::testing::Combine; using ::testing::ElementsAre; +using ::testing::IsEmpty; +using ::testing::NotNull; using ::testing::Pair; +using ::testing::SizeIs; using ::testing::Values; constexpr int kIceCandidatesTimeout = 10000; @@ -103,7 +106,6 @@ class PeerConnectionWrapperForIceTest : public PeerConnectionWrapper { const auto* desc = pc()->remote_description()->description(); RTC_DCHECK(!desc->contents().empty()); const auto& first_content = desc->contents()[0]; - candidate->set_transport_name(first_content.mid()); return CreateIceCandidate(first_content.mid(), -1, *candidate); } @@ -304,7 +306,6 @@ class PeerConnectionIceBaseTest : public ::testing::Test { auto* desc = sdesc->description(); RTC_DCHECK(!desc->contents().empty()); const auto& first_content = desc->contents()[0]; - candidate->set_transport_name(first_content.mid()); std::unique_ptr jsep_candidate = CreateIceCandidate(first_content.mid(), 0, *candidate); return sdesc->AddCandidate(jsep_candidate.get()); @@ -366,7 +367,7 @@ TEST_P(PeerConnectionIceTest, OfferContainsGatheredCandidates) { {.timeout = TimeDelta::Millis(kIceCandidatesTimeout)}), IsRtcOk()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); EXPECT_LT(0u, caller->observer()->GetCandidatesByMline(0).size()); EXPECT_EQ(caller->observer()->GetCandidatesByMline(0).size(), offer->candidates(0)->count()); @@ -406,7 +407,8 @@ TEST_P(PeerConnectionIceTest, auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); Candidate candidate = CreateLocalUdpCandidate(kCallerAddress); AddCandidateToFirstTransport(&candidate, offer.get()); @@ -420,7 +422,7 @@ TEST_P(PeerConnectionIceTest, TEST_P(PeerConnectionIceTest, SetLocalDescriptionFailsIfNoIceCredentials) { auto caller = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); RemoveIceUfragPwd(offer.get()); EXPECT_FALSE(caller->SetLocalDescription(std::move(offer))); @@ -430,7 +432,8 @@ TEST_P(PeerConnectionIceTest, SetRemoteDescriptionFailsIfNoIceCredentials) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); RemoveIceUfragPwd(offer.get()); EXPECT_FALSE(callee->SetRemoteDescription(std::move(offer))); @@ -473,7 +476,8 @@ TEST_P(PeerConnectionIceTest, auto callee = CreatePeerConnectionWithAudioVideo(); caller->network()->AddInterface(kCallerAddress); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); Candidate candidate = CreateLocalUdpCandidate(kCallerAddress); AddCandidateToFirstTransport(&candidate, offer.get()); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); @@ -488,13 +492,17 @@ TEST_P(PeerConnectionIceTest, CannotAddCandidateWhenRemoteDescriptionNotSet) { const SocketAddress kCalleeAddress("1.1.1.1", 1111); auto caller = CreatePeerConnectionWithAudioVideo(); + std::unique_ptr offer = caller->CreateOffer(); + ASSERT_THAT(offer, NotNull()); + ASSERT_THAT(offer->description()->contents(), SizeIs(2)); + std::string mid = offer->description()->contents()[0].mid(); Candidate candidate = CreateLocalUdpCandidate(kCalleeAddress); std::unique_ptr jsep_candidate = - CreateIceCandidate(CN_AUDIO, 0, candidate); + CreateIceCandidate(mid, 0, candidate); EXPECT_FALSE(caller->pc()->AddIceCandidate(jsep_candidate.get())); - caller->CreateOfferAndSetAsLocal(); + caller->SetLocalDescription(std::move(offer)); EXPECT_FALSE(caller->pc()->AddIceCandidate(jsep_candidate.get())); EXPECT_METRIC_THAT( @@ -546,7 +554,8 @@ TEST_P(PeerConnectionIceTest, DISABLED_ErrorOnInvalidRemoteIceCandidateAdded) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); // Add a candidate to the remote description with a candidate that has an // invalid address (port number == 2). - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); Candidate bad_candidate = CreateLocalUdpCandidate(SocketAddress("2.2.2.2", 2)); RTC_LOG(LS_INFO) << "Bad candidate: " << bad_candidate.ToString(); @@ -573,8 +582,7 @@ TEST_P(PeerConnectionIceTest, ASSERT_TRUE(caller->pc()->AddIceCandidate(ice_candidate.get())); caller->pc()->Close(); - - EXPECT_FALSE(caller->pc()->RemoveIceCandidates({candidate})); + EXPECT_FALSE(caller->pc()->RemoveIceCandidate(ice_candidate.get())); } TEST_P(PeerConnectionIceTest, @@ -595,7 +603,7 @@ TEST_P(PeerConnectionIceTest, std::unique_ptr ice_candidate = CreateIceCandidate(audio_content->mid(), 0, candidate); EXPECT_TRUE(caller->pc()->AddIceCandidate(ice_candidate.get())); - EXPECT_TRUE(caller->pc()->RemoveIceCandidates({candidate})); + EXPECT_TRUE(caller->pc()->RemoveIceCandidate(ice_candidate.get())); } TEST_P(PeerConnectionIceTest, RemoveCandidateRemovesFromRemoteDescription) { @@ -609,8 +617,11 @@ TEST_P(PeerConnectionIceTest, RemoveCandidateRemovesFromRemoteDescription) { caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal())); Candidate candidate = CreateLocalUdpCandidate(kCalleeAddress); - ASSERT_TRUE(caller->AddIceCandidate(&candidate)); - EXPECT_TRUE(caller->pc()->RemoveIceCandidates({candidate})); + std::unique_ptr ice_candidate = + caller->CreateJsepCandidateForFirstTransport(&candidate); + + ASSERT_TRUE(caller->pc()->AddIceCandidate(ice_candidate.get())); + EXPECT_TRUE(caller->pc()->RemoveIceCandidate(ice_candidate.get())); EXPECT_EQ(0u, caller->GetIceCandidatesFromRemoteDescription().size()); } @@ -634,13 +645,13 @@ TEST_P(PeerConnectionIceTest, ASSERT_TRUE(callee->AddIceCandidate(&candidate1)); // Add the second candidate via a reoffer. - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); Candidate candidate2 = CreateLocalUdpCandidate(kCallerAddress2); AddCandidateToFirstTransport(&candidate2, offer.get()); // Expect both candidates to appear in the callee's remote description. ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - EXPECT_EQ(2u, callee->GetIceCandidatesFromRemoteDescription().size()); + EXPECT_THAT(callee->GetIceCandidatesFromRemoteDescription(), SizeIs(2)); } // The follow test verifies that SetLocal/RemoteDescription fails when an offer @@ -654,7 +665,7 @@ TEST_P(PeerConnectionIceTest, VerifyUfragPwdLength) { // Because local munging is forbidden by spec, we have to disable the // check for it. pc->GetInternalPeerConnection()->DisableSdpMungingChecksForTesting(); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); SetIceUfragPwd(offer.get(), std::string(ufrag_len, 'x'), std::string(pwd_len, 'x')); bool result = pc->SetLocalDescription(std::move(offer)); @@ -665,7 +676,7 @@ TEST_P(PeerConnectionIceTest, VerifyUfragPwdLength) { auto set_remote_description_with_ufrag_pwd_length = [this](int ufrag_len, int pwd_len) { auto pc = CreatePeerConnectionWithAudioVideo(); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); SetIceUfragPwd(offer.get(), std::string(ufrag_len, 'x'), std::string(pwd_len, 'x')); bool result = pc->SetRemoteDescription(std::move(offer)); @@ -759,7 +770,7 @@ TEST_P(PeerConnectionIceTest, TwoTrickledCandidatesAddedToRemoteDescription) { caller->AddIceCandidate(&candidate2); auto candidates = caller->GetIceCandidatesFromRemoteDescription(); - ASSERT_EQ(2u, candidates.size()); + ASSERT_THAT(candidates, SizeIs(2)); EXPECT_PRED_FORMAT2(AssertCandidatesEqual, candidate1, candidates[0]->candidate()); EXPECT_PRED_FORMAT2(AssertCandidatesEqual, candidate2, @@ -848,8 +859,12 @@ TEST_P(PeerConnectionIceTest, auto candidate = CreateLocalUdpCandidate(SocketAddress("1.1.1.1", 1111)); auto caller = CreatePeerConnectionWithAudioVideo(); + std::unique_ptr offer = caller->CreateOffer(); + ASSERT_THAT(offer, NotNull()); + ASSERT_THAT(offer->description()->contents(), SizeIs(2)); + std::string mid = offer->description()->contents()[0].mid(); std::unique_ptr jsep_candidate = - CreateIceCandidate(CN_AUDIO, 0, candidate); + CreateIceCandidate(mid, 0, candidate); bool operation_completed = false; caller->pc()->AddIceCandidate( @@ -1002,7 +1017,8 @@ TEST_P(PeerConnectionIceTest, IceRestartOfferClearsExistingCandidate) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); Candidate candidate = CreateLocalUdpCandidate(kCallerAddress); AddCandidateToFirstTransport(&candidate, offer.get()); @@ -1023,7 +1039,8 @@ TEST_P(PeerConnectionIceTest, auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); Candidate old_candidate = CreateLocalUdpCandidate(kFirstCallerAddress); AddCandidateToFirstTransport(&old_candidate, offer.get()); @@ -1056,7 +1073,7 @@ TEST_P(PeerConnectionIceTest, LaterAnswerHasSameIceCredentialsIfNoIceRestart) { // Re-offer. ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto* answer_transport_desc = GetFirstTransportDescription(answer.get()); auto* local_transport_desc = GetFirstTransportDescription(callee->pc()->local_description()); @@ -1320,7 +1337,7 @@ TEST_P(PeerConnectionIceUfragPwdAnswerTest, TestIncludedInAnswer) { ASSERT_TRUE( caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal())); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto* offer_transport_desc = GetFirstTransportDescription(offer.get()); if (offer_new_ufrag_) { offer_transport_desc->ice_ufrag += "+new"; @@ -1331,7 +1348,7 @@ TEST_P(PeerConnectionIceUfragPwdAnswerTest, TestIncludedInAnswer) { ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto* answer_transport_desc = GetFirstTransportDescription(answer.get()); auto* local_transport_desc = GetFirstTransportDescription(callee->pc()->local_description()); @@ -1365,7 +1382,8 @@ TEST_P(PeerConnectionIceTest, RTCOfferAnswerOptions disable_bundle_options; disable_bundle_options.use_rtp_mux = false; - auto offer = caller->CreateOffer(disable_bundle_options); + std::unique_ptr offer = + caller->CreateOffer(disable_bundle_options); // Signal ICE restart on the first media section. auto* offer_transport_desc = GetFirstTransportDescription(offer.get()); @@ -1374,7 +1392,8 @@ TEST_P(PeerConnectionIceTest, ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(disable_bundle_options); + std::unique_ptr answer = + callee->CreateAnswer(disable_bundle_options); const auto& answer_transports = answer->description()->transport_infos(); const auto& local_transports = callee->pc()->local_description()->description()->transport_infos(); @@ -1398,13 +1417,13 @@ TEST_P(PeerConnectionIceTest, auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); SetIceMode(offer.get(), IceMode::ICEMODE_LITE); ASSERT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); SetIceMode(answer.get(), IceMode::ICEMODE_FULL); ASSERT_TRUE( callee->SetLocalDescription(CloneSessionDescription(answer.get()))); @@ -1422,13 +1441,13 @@ TEST_P(PeerConnectionIceTest, auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); SetIceMode(offer.get(), IceMode::ICEMODE_LITE); ASSERT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); SetIceMode(answer.get(), IceMode::ICEMODE_LITE); ASSERT_TRUE( callee->SetLocalDescription(CloneSessionDescription(answer.get()))); @@ -1540,7 +1559,7 @@ TEST_P(PeerConnectionIceTest, IceCredentialsCreateOffer) { config.ice_candidate_pool_size = 1; auto pc = CreatePeerConnectionWithAudioVideo(config); ASSERT_NE(pc->GetInternalPeerConnection()->port_allocator(), nullptr); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto credentials = pc->GetInternalPeerConnection() ->port_allocator() ->GetPooledIceCredentials(); @@ -1560,9 +1579,9 @@ TEST_P(PeerConnectionIceTest, IceCredentialsCreateAnswer) { config.ice_candidate_pool_size = 1; auto pc = CreatePeerConnectionWithAudioVideo(config); ASSERT_NE(pc->GetInternalPeerConnection()->port_allocator(), nullptr); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); ASSERT_TRUE(pc->SetRemoteDescription(std::move(offer))); - auto answer = pc->CreateAnswer(); + std::unique_ptr answer = pc->CreateAnswer(); auto credentials = pc->GetInternalPeerConnection() ->port_allocator() @@ -1596,14 +1615,13 @@ TEST_P(PeerConnectionIceTest, PrefersMidOverMLineIndex) { ASSERT_TRUE( caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal())); - // `candidate.transport_name()` is empty. Candidate candidate = CreateLocalUdpCandidate(kCalleeAddress); auto* audio_content = GetFirstAudioContent(caller->pc()->local_description()->description()); std::unique_ptr ice_candidate = CreateIceCandidate(audio_content->mid(), 65535, candidate); EXPECT_TRUE(caller->pc()->AddIceCandidate(ice_candidate.get())); - EXPECT_TRUE(caller->pc()->RemoveIceCandidates({candidate})); + EXPECT_TRUE(caller->pc()->RemoveIceCandidate(ice_candidate.get())); } } // namespace webrtc diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 3a2babda3e..b109ebb26a 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -15,10 +15,9 @@ // do NOT add it here, but instead add it to the file // slow_peer_connection_integrationtest.cc -#include - #include #include +#include #include #include #include @@ -106,15 +105,18 @@ namespace { using ::testing::AtLeast; using ::testing::Eq; using ::testing::Field; +using ::testing::Gt; using ::testing::InSequence; +using ::testing::Invoke; +using ::testing::IsTrue; using ::testing::MockFunction; using ::testing::NiceMock; using ::testing::NotNull; using ::testing::Return; +using ::testing::WithParamInterface; -class PeerConnectionIntegrationTest - : public PeerConnectionIntegrationBaseTest, - public ::testing::WithParamInterface { +class PeerConnectionIntegrationTest : public PeerConnectionIntegrationBaseTest, + public WithParamInterface { protected: PeerConnectionIntegrationTest() : PeerConnectionIntegrationBaseTest(GetParam()) {} @@ -169,9 +171,8 @@ TEST_P(PeerConnectionIntegrationTest, callee()->AddAudioVideoTracks(); // Start offer/answer exchange and wait for it to complete. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Should be one receiver each for audio/video. EXPECT_EQ(2U, caller()->rtp_receiver_observers().size()); EXPECT_EQ(2U, callee()->rtp_receiver_observers().size()); @@ -184,7 +185,7 @@ TEST_P(PeerConnectionIntegrationTest, return o->first_packet_received(); }); }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT(WaitUntil( [&] { @@ -194,7 +195,7 @@ TEST_P(PeerConnectionIntegrationTest, return o->first_packet_received(); }); }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // If new observers are set after the first packet was already received, the // callback should still be invoked. @@ -221,9 +222,8 @@ TEST_P(PeerConnectionIntegrationTest, RtpSenderObserverOnFirstPacketSent) { callee()->AddAudioVideoTracks(); // Start offer/answer exchange and wait for it to complete. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Should be one sender each for audio/video. EXPECT_EQ(2U, caller()->rtp_sender_observers().size()); EXPECT_EQ(2U, callee()->rtp_sender_observers().size()); @@ -236,7 +236,7 @@ TEST_P(PeerConnectionIntegrationTest, RtpSenderObserverOnFirstPacketSent) { return o->first_packet_sent(); }); }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); EXPECT_THAT(WaitUntil( [&] { @@ -246,7 +246,7 @@ TEST_P(PeerConnectionIntegrationTest, RtpSenderObserverOnFirstPacketSent) { return o->first_packet_sent(); }); }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // If new observers are set after the first packet was already sent, the // callback should still be invoked. @@ -301,9 +301,8 @@ void TestDtmfFromSenderToReceiver(PeerConnectionIntegrationWrapper* sender, EXPECT_TRUE(dtmf_sender->CanInsertDtmf()); EXPECT_TRUE(dtmf_sender->InsertDtmf("1a", 100, 50)); - EXPECT_THAT( - WaitUntil([&] { return observer.completed(); }, ::testing::IsTrue()), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer.completed(); }, IsTrue()), + IsRtcOk()); std::vector tones = {"1", "a", ""}; EXPECT_EQ(tones, observer.tones()); dtmf_sender->UnregisterObserver(); @@ -319,12 +318,10 @@ TEST_P(PeerConnectionIntegrationTest, DtmfSenderObserver) { caller()->AddAudioTrack(); callee()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - // DTLS must finish before the DTMF sender can be used reliably. - ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()), + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), IsRtcOk()); + // DTLS must finish before the DTMF sender can be used reliably. + ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue()), IsRtcOk()); TestDtmfFromSenderToReceiver(caller(), callee()); TestDtmfFromSenderToReceiver(callee(), caller()); } @@ -340,9 +337,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithDtls) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -367,9 +363,8 @@ TEST_P(PeerConnectionIntegrationTest, caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -399,7 +394,7 @@ TEST_P(PeerConnectionIntegrationTest, 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Check rendered aspect ratio. @@ -437,9 +432,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithSendOnlyVideo) { options.offer_to_receive_video = 0; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); // Expect video to be received in one direction. @@ -464,9 +458,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithReceiveOnlyVideo) { options.offer_to_receive_video = 1; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(caller()->pc()->GetReceivers().size(), 1u); // Expect video to be received in one direction. @@ -486,18 +479,16 @@ TEST_P(PeerConnectionIntegrationTest, caller()->CreateLocalVideoTrack(); caller()->AddTrack(caller_track); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Add receive video. scoped_refptr callee_track = callee()->CreateLocalVideoTrack(); callee()->AddTrack(callee_track); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Ensure that video frames are received end-to-end. MediaExpectations media_expectations; @@ -514,18 +505,16 @@ TEST_P(PeerConnectionIntegrationTest, callee()->CreateLocalVideoTrack(); callee()->AddTrack(callee_track); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Add send video. scoped_refptr caller_track = caller()->CreateLocalVideoTrack(); caller()->AddTrack(caller_track); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Expect video to be received in one direction. MediaExpectations media_expectations; @@ -549,17 +538,15 @@ TEST_P(PeerConnectionIntegrationTest, scoped_refptr callee_sender = callee()->AddTrack(callee_track); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Remove receive video (i.e., callee sender track). callee()->pc()->RemoveTrackOrError(callee_sender); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Expect one-directional video. MediaExpectations media_expectations; @@ -585,17 +572,15 @@ TEST_P(PeerConnectionIntegrationTest, scoped_refptr callee_sender = callee()->AddTrack(callee_track); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Remove send video (i.e., caller sender track). caller()->pc()->RemoveTrackOrError(caller_sender); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Expect one-directional video. MediaExpectations media_expectations; @@ -626,9 +611,8 @@ TEST_P(PeerConnectionIntegrationTest, AudioToVideoUpgrade) { } // Do offer/answer and make sure audio is still received end-to-end. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); { MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudio(); @@ -664,9 +648,8 @@ TEST_P(PeerConnectionIntegrationTest, AudioToVideoUpgrade) { }); } callee()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); { // Expect additional audio frames to be received after the upgrade. MediaExpectations media_expectations; @@ -684,16 +667,14 @@ TEST_P(PeerConnectionIntegrationTest, AddAudioToVideoOnlyCall) { caller()->AddVideoTrack(); callee()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Now add an audio track and do another offer/answer. caller()->AddAudioTrack(); callee()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Ensure both audio and video frames are received end-to-end. MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); @@ -715,9 +696,8 @@ TEST_P(PeerConnectionIntegrationTest, BundlingEnabledWhileIceRestartOccurs) { sdp->description()->RemoveGroupByName("BUNDLE"); }); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); { MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); @@ -727,9 +707,8 @@ TEST_P(PeerConnectionIntegrationTest, BundlingEnabledWhileIceRestartOccurs) { callee()->SetReceivedSdpMunger(nullptr); caller()->SetOfferAnswerOptions(IceRestartOfferAnswerOptions()); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Expect additional frames to be received after the ICE restart. { @@ -754,16 +733,15 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithCVOExtension) { // Wait for video frames to be received by both sides. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_THAT(WaitUntil( [&] { return caller()->min_video_frames_received_per_track() > 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Ensure that the aspect ratio is unmodified. @@ -798,16 +776,15 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithoutCVOExtension) { }); // Wait for video frames to be received by both sides. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_THAT(WaitUntil( [&] { return caller()->min_video_frames_received_per_track() > 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Expect that the aspect ratio is inversed to account for the 90/270 degree @@ -845,9 +822,8 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsAudioSection) { callee()->AddTrack(callee()->CreateLocalVideoTrack()); // Do offer/answer and wait for successful end-to-end video frames. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalVideo(); media_expectations.ExpectNoAudio(); @@ -888,9 +864,8 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsVideoSection) { callee()->AddTrack(callee()->CreateLocalAudioTrack()); // Do offer/answer and wait for successful end-to-end audio frames. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudio(); media_expectations.ExpectNoVideo(); @@ -935,9 +910,8 @@ TEST_P(PeerConnectionIntegrationTest, AnswererRejectsAudioAndVideoSections) { } // Do offer/answer and wait for stable signaling state. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Sanity check that the callee's description has rejected m= sections. ASSERT_NE(nullptr, callee()->pc()->local_description()); @@ -961,9 +935,8 @@ TEST_P(PeerConnectionIntegrationTest, VideoRejectedInSubsequentOffer) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); { MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); @@ -983,10 +956,9 @@ TEST_P(PeerConnectionIntegrationTest, VideoRejectedInSubsequentOffer) { caller()->GetFirstTransceiverOfType(MediaType::VIDEO)->StopInternal(); } caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = kMaxWaitForActivation}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue(), + {.timeout = kMaxWaitForActivation}), + IsRtcOk()); // Sanity check that the caller's description has a rejected video section. ASSERT_NE(nullptr, caller()->pc()->local_description()); @@ -1015,9 +987,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, EnableAudioAfterRejecting) { scoped_refptr sender = caller()->pc()->AddTrack(track, {"stream"}).MoveValue(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Remove audio track, and set offer_to_receive_audio to false to cause the // m= section to be completely disabled, not just "recvonly". @@ -1026,9 +997,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, EnableAudioAfterRejecting) { options.offer_to_receive_audio = 0; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Add the audio track again, expecting negotiation to succeed and frames to // flow. @@ -1036,9 +1006,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, EnableAudioAfterRejecting) { options.offer_to_receive_audio = 1; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudio(); @@ -1059,9 +1028,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithoutSsrcOrMsidSignaling) { // Remove SSRCs and MSIDs from the received offer SDP. callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1082,9 +1050,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, // Remove SSRCs from the received offer SDP. callee()->SetReceivedSdpMunger(RemoveSsrcsAndKeepMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudio(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1103,9 +1070,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto video_sender = caller()->pc()->AddTransceiver(track, video_transceiver_init).MoveValue(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Add receive direction. video_sender->SetDirectionWithError(RtpTransceiverDirection::kSendRecv); @@ -1115,9 +1081,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, callee()->AddTrack(callee_track); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Ensure that video frames are received end-to-end. MediaExpectations media_expectations; media_expectations.ExpectBidirectionalVideo(); @@ -1139,9 +1104,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids); callee()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(2u, caller()->pc()->GetReceivers().size()); ASSERT_EQ(2u, callee()->pc()->GetReceivers().size()); @@ -1186,9 +1150,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->SetReceivedSdpMunger(&RemoveBundleGroupSsrcsAndMidExtension); callee()->SetReceivedSdpMunger(&RemoveBundleGroupSsrcsAndMidExtension); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(2u, caller()->pc()->GetReceivers().size()); ASSERT_EQ(2u, callee()->pc()->GetReceivers().size()); // Make sure we are not bundled. @@ -1238,9 +1201,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids); callee()->SetReceivedSdpMunger(&RemoveSsrcsAndKeepMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(2u, caller()->pc()->GetReceivers().size()); ASSERT_EQ(2u, callee()->pc()->GetReceivers().size()); // Make sure we are bundled. @@ -1259,9 +1221,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, NoStreamsMsidLinePresent) { caller()->AddAudioTrack(); caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); auto callee_receivers = callee()->pc()->GetReceivers(); ASSERT_EQ(2u, callee_receivers.size()); EXPECT_TRUE(callee_receivers[0]->stream_ids().empty()); @@ -1275,9 +1236,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, NoStreamsMsidLineMissing) { caller()->AddVideoTrack(); callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); auto callee_receivers = callee()->pc()->GetReceivers(); ASSERT_EQ(2u, callee_receivers.size()); ASSERT_EQ(1u, callee_receivers[0]->stream_ids().size()); @@ -1315,15 +1275,14 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, EndToEndCallForwardsCsrcs) { caller()->CreateAndSetAndSignalOffer(); // Wait for some packets to arrive. - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_THAT(WaitUntil( [&] { return callee()->audio_frames_received() > 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); std::vector> audio_receivers = @@ -1363,15 +1322,14 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, EndToEndCallCanUpdateCsrcs) { caller()->CreateAndSetAndSignalOffer(); // Wait for some packets to arrive. - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_THAT(WaitUntil( [&] { return callee()->audio_frames_received() > 0 && callee()->min_video_frames_received_per_track() > 0; }, - ::testing::IsTrue(), {.timeout = kMaxWaitForFrames}), + IsTrue(), {.timeout = kMaxWaitForFrames}), IsRtcOk()); // Update the CSRCs. @@ -1411,9 +1369,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithTwoVideoTracks) { caller()->AddAudioVideoTracks(); caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(3u, callee()->pc()->GetReceivers().size()); MediaExpectations media_expectations; @@ -1462,9 +1419,8 @@ TEST_P(PeerConnectionIntegrationTest, // but the first m= section. callee()->SetReceivedSdpMunger(MakeSpecCompliantMaxBundleOffer); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1479,15 +1435,14 @@ TEST_P(PeerConnectionIntegrationTest, GetAudioOutputLevelStatsWithOldStatsApi) { // Just add an audio track. caller()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Get the audio output level stats. Note that the level is not available // until an RTCP packet has been received. EXPECT_THAT( WaitUntil([&] { return callee()->OldGetStats()->AudioOutputLevel(); }, - ::testing::Gt(0), {.timeout = kMaxWaitForFrames}), + Gt(0), {.timeout = kMaxWaitForFrames}), IsRtcOk()); } @@ -1500,15 +1455,14 @@ TEST_P(PeerConnectionIntegrationTest, GetAudioInputLevelStatsWithOldStatsApi) { // Just add an audio track. caller()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Get the audio input level stats. The level should be available very // soon after the test starts. EXPECT_THAT( WaitUntil([&] { return caller()->OldGetStats()->AudioInputLevel(); }, - ::testing::Gt(0), {.timeout = kMaxWaitForStats}), + Gt(0), {.timeout = kMaxWaitForStats}), IsRtcOk()); } @@ -1519,9 +1473,8 @@ TEST_P(PeerConnectionIntegrationTest, GetBytesReceivedStatsWithOldStatsApi) { caller()->AddAudioVideoTracks(); // Do offer/answer, wait for the callee to receive some frames. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudioAndVideo(); @@ -1548,9 +1501,8 @@ TEST_P(PeerConnectionIntegrationTest, GetBytesSentStatsWithOldStatsApi) { caller()->AddTrack(video_track); // Do offer/answer, wait for the callee to receive some frames. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1573,15 +1525,14 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto audio_sender_2 = caller()->AddAudioTrack(); auto video_sender_2 = caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudioAndVideo(); - ASSERT_THAT(WaitUntil([&] { return ExpectNewFrames(media_expectations); }, - ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return ExpectNewFrames(media_expectations); }, IsTrue()), + IsRtcOk()); std::vector track_ids = { audio_sender_1->track()->id(), video_sender_1->track()->id(), @@ -1604,15 +1555,14 @@ TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) { auto audio_sender_2 = caller()->AddAudioTrack(); auto video_sender_2 = caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudioAndVideo(); - ASSERT_THAT(WaitUntil([&] { return ExpectNewFrames(media_expectations); }, - ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT( + WaitUntil([&] { return ExpectNewFrames(media_expectations); }, IsTrue()), + IsRtcOk()); std::vector track_ids = { audio_sender_1->track()->id(), video_sender_1->track()->id(), @@ -1673,9 +1623,8 @@ TEST_P(PeerConnectionIntegrationTest, // Remove SSRCs and MSIDs from the received offer SDP. callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudio(1); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1700,9 +1649,8 @@ TEST_P(PeerConnectionIntegrationTest, // Remove SSRCs and MSIDs from the received offer SDP. callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Note that, since the old stats implementation associates SSRCs with tracks // using SDP, when SSRCs aren't signaled in SDP these stats won't have an @@ -1712,7 +1660,7 @@ TEST_P(PeerConnectionIntegrationTest, // return cached stats if not enough time has passed since the last update. EXPECT_THAT( WaitUntil([&] { return callee()->OldGetStats()->BytesReceived(); }, - ::testing::Gt(0)), + Gt(0)), IsRtcOk()); } @@ -1726,9 +1674,8 @@ TEST_P(PeerConnectionIntegrationTest, // Remove SSRCs and MSIDs from the received offer SDP. callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudio(1); media_expectations.CalleeExpectsSomeVideo(1); @@ -1755,9 +1702,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1773,19 +1719,17 @@ TEST_P(PeerConnectionIntegrationTest, Dtls10CipherStatsAndUmaMetrics) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue()), IsRtcOk()); EXPECT_THAT(WaitUntil( [&] { return SSLStreamAdapter::IsAcceptableCipher( caller()->OldGetStats()->DtlsCipher(), KT_DEFAULT); }, - ::testing::IsTrue()), + IsTrue()), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller()->OldGetStats()->SrtpCipher(); }, + Eq(SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite))), IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return caller()->OldGetStats()->SrtpCipher(); }, - ::testing::Eq(SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite))), - IsRtcOk()); } // Test getting cipher stats and UMA metrics when DTLS 1.2 is negotiated. @@ -1798,19 +1742,17 @@ TEST_P(PeerConnectionIntegrationTest, Dtls12CipherStatsAndUmaMetrics) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue()), IsRtcOk()); EXPECT_THAT(WaitUntil( [&] { return SSLStreamAdapter::IsAcceptableCipher( caller()->OldGetStats()->DtlsCipher(), KT_DEFAULT); }, - ::testing::IsTrue()), + IsTrue()), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller()->OldGetStats()->SrtpCipher(); }, + Eq(SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite))), IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return caller()->OldGetStats()->SrtpCipher(); }, - ::testing::Eq(SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite))), - IsRtcOk()); } // Test that DTLS 1.0 can be used if the caller supports DTLS 1.2 and the @@ -1828,9 +1770,8 @@ TEST_P(PeerConnectionIntegrationTest, CallerDtls12ToCalleeDtls10) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1851,9 +1792,8 @@ TEST_P(PeerConnectionIntegrationTest, CallerDtls10ToCalleeDtls12) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1863,35 +1803,45 @@ TEST_P(PeerConnectionIntegrationTest, CallerDtls10ToCalleeDtls12) { // works as expected; the cipher should only be used if enabled by both sides. TEST_P(PeerConnectionIntegrationTest, Aes128Sha1_32_CipherNotUsedWhenOnlyCallerSupported) { - PeerConnectionFactory::Options caller_options; - caller_options.crypto_options.srtp.enable_aes128_sha1_32_crypto_cipher = true; - PeerConnectionFactory::Options callee_options; - callee_options.crypto_options.srtp.enable_aes128_sha1_32_crypto_cipher = - false; + RTCConfiguration caller_config; + CryptoOptions caller_crypto; + caller_crypto.srtp.enable_aes128_sha1_32_crypto_cipher = true; + caller_config.crypto_options = caller_crypto; + RTCConfiguration callee_config; + CryptoOptions callee_crypto; + callee_crypto.srtp.enable_aes128_sha1_32_crypto_cipher = false; + callee_config.crypto_options = callee_crypto; int expected_cipher_suite = kSrtpAes128CmSha1_80; - TestNegotiatedCipherSuite(caller_options, callee_options, + TestNegotiatedCipherSuite(caller_config, callee_config, expected_cipher_suite); } TEST_P(PeerConnectionIntegrationTest, Aes128Sha1_32_CipherNotUsedWhenOnlyCalleeSupported) { - PeerConnectionFactory::Options caller_options; - caller_options.crypto_options.srtp.enable_aes128_sha1_32_crypto_cipher = - false; - PeerConnectionFactory::Options callee_options; - callee_options.crypto_options.srtp.enable_aes128_sha1_32_crypto_cipher = true; + RTCConfiguration caller_config; + CryptoOptions caller_crypto; + caller_crypto.srtp.enable_aes128_sha1_32_crypto_cipher = false; + caller_config.crypto_options = caller_crypto; + RTCConfiguration callee_config; + CryptoOptions callee_crypto; + callee_crypto.srtp.enable_aes128_sha1_32_crypto_cipher = true; + callee_config.crypto_options = callee_crypto; int expected_cipher_suite = kSrtpAes128CmSha1_80; - TestNegotiatedCipherSuite(caller_options, callee_options, + TestNegotiatedCipherSuite(caller_config, callee_config, expected_cipher_suite); } TEST_P(PeerConnectionIntegrationTest, Aes128Sha1_32_CipherUsedWhenSupported) { - PeerConnectionFactory::Options caller_options; - caller_options.crypto_options.srtp.enable_aes128_sha1_32_crypto_cipher = true; - PeerConnectionFactory::Options callee_options; - callee_options.crypto_options.srtp.enable_aes128_sha1_32_crypto_cipher = true; + RTCConfiguration caller_config; + CryptoOptions caller_crypto; + caller_crypto.srtp.enable_aes128_sha1_32_crypto_cipher = true; + caller_config.crypto_options = caller_crypto; + RTCConfiguration callee_config; + CryptoOptions callee_crypto; + callee_crypto.srtp.enable_aes128_sha1_32_crypto_cipher = true; + callee_config.crypto_options = callee_crypto; int expected_cipher_suite = kSrtpAes128CmSha1_32; - TestNegotiatedCipherSuite(caller_options, callee_options, + TestNegotiatedCipherSuite(caller_config, callee_config, expected_cipher_suite); } @@ -1921,20 +1871,20 @@ TEST_P(PeerConnectionIntegrationTest, GcmCipherUsedWhenOnlyGcmSupported) { // only verify that a GCM cipher is negotiated, and not necessarily that SRTP // works with it. TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithGcmCipher) { - PeerConnectionFactory::Options gcm_options; - gcm_options.crypto_options.srtp.enable_gcm_crypto_suites = true; - gcm_options.crypto_options.srtp.enable_aes128_sha1_80_crypto_cipher = false; - ASSERT_TRUE( - CreatePeerConnectionWrappersWithOptions(gcm_options, gcm_options)); + RTCConfiguration gcm_config; + CryptoOptions gcm_options; + gcm_options.srtp.enable_gcm_crypto_suites = true; + gcm_options.srtp.enable_aes128_sha1_80_crypto_cipher = false; + gcm_config.crypto_options = gcm_options; + ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(gcm_config, gcm_config)); ConnectFakeSignaling(); // Do normal offer/answer and wait for some frames to be received in each // direction. caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -1949,31 +1899,26 @@ TEST_P(PeerConnectionIntegrationTest, IceStatesReachCompletion) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return caller()->ice_gathering_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee()->ice_gathering_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller()->ice_gathering_state(); }, + Eq(PeerConnectionInterface::kIceGatheringComplete), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee()->ice_gathering_state(); }, + Eq(PeerConnectionInterface::kIceGatheringComplete), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); // After the best candidate pair is selected and all candidates are signaled, // the ICE connection state should reach "complete". // TODO(deadbeef): Currently, the ICE "controlled" agent (the // answerer/"callee" by default) only reaches "connected". When this is // fixed, this test should be updated. EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionCompleted)), + Eq(PeerConnectionInterface::kIceConnectionCompleted)), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionConnected)), + Eq(PeerConnectionInterface::kIceConnectionConnected)), IsRtcOk()); } @@ -2035,16 +1980,13 @@ TEST_P(PeerConnectionIntegrationTest, caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionCompleted)), + Eq(PeerConnectionInterface::kIceConnectionCompleted)), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionConnected)), + Eq(PeerConnectionInterface::kIceConnectionConnected)), IsRtcOk()); // Part of reporting the stats will occur on the network thread, so flush it @@ -2061,7 +2003,7 @@ TEST_P(PeerConnectionIntegrationTest, // disconnected state and then removing the firewall causes them to reconnect. class PeerConnectionIntegrationIceStatesTest : public PeerConnectionIntegrationBaseTest, - public ::testing::WithParamInterface< + public WithParamInterface< std::tuple>> { protected: PeerConnectionIntegrationIceStatesTest() @@ -2150,7 +2092,7 @@ TEST_P(PeerConnectionIntegrationIceStatesTestWithFakeClock, ScopedFakeClock& fake_clock = FakeClock(); ASSERT_THAT( WaitUntil([&] { return caller()->standardized_ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionFailed), + Eq(PeerConnectionInterface::kIceConnectionFailed), {.timeout = kConsentTimeout, .clock = &fake_clock}), IsRtcOk()); } @@ -2175,16 +2117,13 @@ TEST_P(PeerConnectionIntegrationIceStatesTest, MAYBE_VerifyBestConnection) { callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionCompleted)), + Eq(PeerConnectionInterface::kIceConnectionCompleted)), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionConnected)), + Eq(PeerConnectionInterface::kIceConnectionConnected)), IsRtcOk()); // Part of reporting the stats will occur on the network thread, so flush it @@ -2250,19 +2189,16 @@ TEST_P(PeerConnectionIntegrationTest, MediaContinuesFlowingAfterIceRestart) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionCompleted), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionConnected), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); // To verify that the ICE restart actually occurs, get // ufrag/password/candidates before and after restart. @@ -2289,19 +2225,16 @@ TEST_P(PeerConnectionIntegrationTest, MediaContinuesFlowingAfterIceRestart) { // Have the caller initiate an ICE restart. caller()->SetOfferAnswerOptions(IceRestartOfferAnswerOptions()); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionCompleted), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionConnected), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); // Grab the ufrags/candidates again. audio_candidates_caller = caller()->pc()->local_description()->candidates(0); @@ -2323,7 +2256,11 @@ TEST_P(PeerConnectionIntegrationTest, MediaContinuesFlowingAfterIceRestart) { ASSERT_NE(callee_candidate_pre_restart, callee_candidate_post_restart); ASSERT_NE(caller_ufrag_pre_restart, caller_ufrag_post_restart); ASSERT_NE(callee_ufrag_pre_restart, callee_ufrag_post_restart); - EXPECT_GT(caller()->ice_candidate_pair_change_history().size(), 1u); + EXPECT_THAT( + WaitUntil( + [&] { return caller()->ice_candidate_pair_change_history().size(); }, + Gt(1U), {.timeout = kMaxWaitForFrames}), + IsRtcOk()); // Ensure that additional frames are received after the ICE restart. MediaExpectations media_expectations; @@ -2343,9 +2280,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithIceRenomination) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Sanity check that ICE renomination was actually negotiated. const SessionDescription* desc = caller()->pc()->local_description()->description(); @@ -2364,16 +2300,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithIceRenomination) { // With a max bundle policy and RTCP muxing, adding a new media description to // the connection should not affect ICE at all because the new media will use // the existing connection. -// TODO(bugs.webrtc.org/12538): Fails on tsan. -#if defined(THREAD_SANITIZER) -#define MAYBE_AddMediaToConnectedBundleDoesNotRestartIce \ - DISABLED_AddMediaToConnectedBundleDoesNotRestartIce -#else -#define MAYBE_AddMediaToConnectedBundleDoesNotRestartIce \ - AddMediaToConnectedBundleDoesNotRestartIce -#endif TEST_P(PeerConnectionIntegrationTest, - MAYBE_AddMediaToConnectedBundleDoesNotRestartIce) { + AddMediaToConnectedBundleDoesNotRestartIce) { PeerConnectionInterface::RTCConfiguration config; config.bundle_policy = PeerConnectionInterface::kBundlePolicyMaxBundle; config.rtcp_mux_policy = PeerConnectionInterface::kRtcpMuxPolicyRequire; @@ -2383,21 +2311,18 @@ TEST_P(PeerConnectionIntegrationTest, caller()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionCompleted)), + Eq(PeerConnectionInterface::kIceConnectionCompleted)), IsRtcOk()); caller()->clear_ice_connection_state_history(); caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); EXPECT_EQ(0u, caller()->ice_connection_state_history().size()); } @@ -2414,9 +2339,8 @@ TEST_P(PeerConnectionIntegrationTest, // video and audio recvonly "m=" sections. caller()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Negotiate again, disabling the video "m=" section (the callee will set the // port to 0 due to offer_to_receive_video = 0). @@ -2430,9 +2354,8 @@ TEST_P(PeerConnectionIntegrationTest, }); } caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Sanity check that video "m=" section was actually rejected. const ContentInfo* answer_video_content = GetFirstVideoContent(callee()->pc()->local_description()->description()); @@ -2455,9 +2378,8 @@ TEST_P(PeerConnectionIntegrationTest, callee()->AddVideoTrack(); callee()->SetRemoteOfferHandler(nullptr); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Verify the caller receives frames from the newly added stream, and the // callee receives additional frames from the re-enabled video m= section. @@ -2483,21 +2405,18 @@ TEST_F(PeerConnectionIntegrationTestPlanB, auto callee_video_sender = callee()->pc()->CreateSender("video", "callee_stream"); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = kMaxWaitForActivation}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue(), + {.timeout = kMaxWaitForActivation}), + IsRtcOk()); // Wait for ICE to complete, without any tracks being set. - EXPECT_THAT( - WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionCompleted), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionConnected), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); // Now set the tracks, and expect frames to immediately start flowing. EXPECT_TRUE( caller_audio_sender->SetTrack(caller()->CreateLocalAudioTrack().get())); @@ -2533,21 +2452,18 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, RtpTransceiverDirection::kSendRecv); }); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = kMaxWaitForActivation}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue(), + {.timeout = kMaxWaitForActivation}), + IsRtcOk()); // Wait for ICE to complete, without any tracks being set. - EXPECT_THAT( - WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionCompleted), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionCompleted), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionConnected), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); // Now set the tracks, and expect frames to immediately start flowing. auto callee_audio_sender = callee()->pc()->GetSenders()[0]; auto callee_video_sender = callee()->pc()->GetSenders()[1]; @@ -2574,20 +2490,18 @@ TEST_F(PeerConnectionIntegrationTestPlanB, CanSendRemoteVideoTrack) { // Just send a video track from the caller. caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = kMaxWaitForActivation}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue(), + {.timeout = kMaxWaitForActivation}), + IsRtcOk()); ASSERT_EQ(1U, callee()->remote_streams()->count()); // Echo the stream back, and do a new offer/anwer (initiated by callee this // time). callee()->pc()->AddStream(callee()->remote_streams()->at(0)); callee()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue(), - {.timeout = kMaxWaitForActivation}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue(), + {.timeout = kMaxWaitForActivation}), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalVideo(); @@ -2675,7 +2589,7 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock, options.offer_to_receive_video = 1; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - EXPECT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue(), + EXPECT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue(), {.timeout = TimeDelta::Millis(total_connection_time_ms), .clock = &FakeClock()}), IsRtcOk()); @@ -2723,7 +2637,7 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock, // signalled. caller()->CreateAndSetAndSignalOffer(); ASSERT_THAT(WaitUntil([&] { return caller()->IceGatheringStateComplete(); }, - ::testing::IsTrue(), {.clock = &FakeClock()}), + IsTrue(), {.clock = &FakeClock()}), IsRtcOk()); // Call getStats, assert there are no candidates. @@ -2741,9 +2655,8 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock, "candidate:2214029314 1 udp 2122260223 127.0.0.1 49152 typ host", nullptr)), [&result](RTCError r) { result = r; }); - ASSERT_THAT( - WaitUntil([&] { return result.has_value(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return result.has_value(); }, IsTrue()), + IsRtcOk()); ASSERT_TRUE(result.value().ok()); // Call getStats again, assert there is a remote candidate now. @@ -2804,8 +2717,7 @@ TEST_P(PeerConnectionIntegrationTest, TurnCustomizerUsedForTurnConnections) { options.offer_to_receive_video = 1; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue()), IsRtcOk()); ExpectTurnCustomizerCountersIncremented(customizer1); ExpectTurnCustomizerCountersIncremented(customizer2); @@ -2842,14 +2754,12 @@ TEST_P(PeerConnectionIntegrationTest, TCPUsedForTurnConnections) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceConnectionConnected), - {.timeout = kMaxWaitForFrames}), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, + Eq(PeerConnectionInterface::kIceConnectionConnected), + {.timeout = kMaxWaitForFrames}), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); @@ -2914,8 +2824,7 @@ TEST_P(PeerConnectionIntegrationTest, options.offer_to_receive_video = 1; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue()), IsRtcOk()); EXPECT_GT(client_1_cert_verifier->call_count_, 0u); EXPECT_GT(client_2_cert_verifier->call_count_, 0u); @@ -2986,9 +2895,8 @@ TEST_P(PeerConnectionIntegrationTest, CodecNamesAreCaseInsensitive) { }); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Verify frames are still received end-to-end. MediaExpectations media_expectations; @@ -3001,9 +2909,8 @@ TEST_P(PeerConnectionIntegrationTest, GetSourcesAudio) { ConnectFakeSignaling(); caller()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Wait for one audio frame to be received by the callee. MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudio(1); @@ -3023,9 +2930,8 @@ TEST_P(PeerConnectionIntegrationTest, GetSourcesVideo) { ConnectFakeSignaling(); caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Wait for two video frames to be received by the callee. // TODO: https://issues.webrtc.org/42220900 - wait for only one frame again MediaExpectations media_expectations; @@ -3048,9 +2954,8 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesAudio) { caller()->AddAudioTrack(); callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); auto receiver = callee()->pc()->GetReceivers()[0]; std::vector sources; @@ -3061,7 +2966,7 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesAudio) { return !sources.empty(); })(); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); ASSERT_GT(sources.size(), 0u); EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type()); @@ -3073,9 +2978,8 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesVideo) { caller()->AddVideoTrack(); callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); auto receiver = callee()->pc()->GetReceivers()[0]; std::vector sources; @@ -3086,7 +2990,7 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesVideo) { return !sources.empty(); })(); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); ASSERT_GT(sources.size(), 0u); EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type()); @@ -3104,9 +3008,8 @@ TEST_P(PeerConnectionIntegrationTest, caller()->AddVideoTrack(); callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Wait for one video frame to be received by the callee. MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeVideo(1); @@ -3125,9 +3028,8 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetParametersAudio) { caller()->AddAudioTrack(); callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); auto receiver = callee()->pc()->GetReceivers()[0]; RtpParameters parameters; @@ -3139,7 +3041,7 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetParametersAudio) { parameters.encodings[0].ssrc.has_value(); })(); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); ASSERT_EQ(parameters.encodings.size(), 1u); EXPECT_TRUE(parameters.encodings[0].ssrc.has_value()); @@ -3151,9 +3053,8 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetParametersVideo) { caller()->AddVideoTrack(); callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); auto receiver = callee()->pc()->GetReceivers()[0]; RtpParameters parameters; @@ -3165,7 +3066,7 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetParametersVideo) { parameters.encodings[0].ssrc.has_value(); })(); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); ASSERT_EQ(parameters.encodings.size(), 1u); EXPECT_TRUE(parameters.encodings[0].ssrc.has_value()); @@ -3195,9 +3096,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, RemoveAndAddTrackWithNewStreamId) { scoped_refptr sender = caller()->AddTrack(track, {"stream_1"}); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); { MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudio(1); @@ -3207,9 +3107,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, RemoveAndAddTrackWithNewStreamId) { caller()->pc()->RemoveTrackOrError(sender); sender = caller()->AddTrack(track, {"stream_2"}); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Wait for additional audio frames to be received by the callee. { MediaExpectations media_expectations; @@ -3231,9 +3130,8 @@ TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalled) { caller()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); } TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalledOnStop) { @@ -3257,9 +3155,8 @@ TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalledOnStop) { caller()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); caller()->pc()->StopRtcEventLog(); test_is_complete.Call(); @@ -3286,9 +3183,8 @@ TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalledOnClose) { caller()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); caller()->pc()->Close(); test_is_complete.Call(); @@ -3309,21 +3205,18 @@ TEST_P(PeerConnectionIntegrationTest, MediaFlowsWhenCandidatesSetOnlyInSdp) { caller()->CreateAndSetAndSignalOffer(); // Wait for all candidates to be gathered on both the caller and callee. - ASSERT_THAT( - WaitUntil([&] { return caller()->ice_gathering_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete)), - IsRtcOk()); - ASSERT_THAT( - WaitUntil([&] { return callee()->ice_gathering_state(); }, - ::testing::Eq(PeerConnectionInterface::kIceGatheringComplete)), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return caller()->ice_gathering_state(); }, + Eq(PeerConnectionInterface::kIceGatheringComplete)), + IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return callee()->ice_gathering_state(); }, + Eq(PeerConnectionInterface::kIceGatheringComplete)), + IsRtcOk()); // The candidates will now be included in the session description, so // signaling them will start the ICE connection. caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Ensure that media flows in both directions. MediaExpectations media_expectations; @@ -3347,9 +3240,8 @@ TEST_P(PeerConnectionIntegrationTest, DisableAndEnableAudioPlayout) { caller()->AddAudioTrack(); callee()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Pump messages for a second. WAIT(false, 1000); @@ -3392,13 +3284,12 @@ TEST_P(PeerConnectionIntegrationTest, caller()->pc()->SetAudioPlayout(false); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Wait for the callee to receive audio stats. - EXPECT_THAT(WaitUntil([&] { return GetAudioEnergyStat(caller()); }, - ::testing::Gt(0), {.timeout = kMaxWaitForFrames}), + EXPECT_THAT(WaitUntil([&] { return GetAudioEnergyStat(caller()); }, Gt(0), + {.timeout = kMaxWaitForFrames}), IsRtcOk()); } @@ -3417,9 +3308,8 @@ TEST_P(PeerConnectionIntegrationTest, DisableAndEnableAudioRecording) { caller()->AddAudioTrack(); callee()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Pump messages for a second. WAIT(false, 1000); @@ -3445,8 +3335,7 @@ TEST_P(PeerConnectionIntegrationTest, options.offer_to_receive_audio = 1; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue()), IsRtcOk()); ASSERT_NE(nullptr, caller()->event_log_factory()); ASSERT_NE(nullptr, callee()->event_log_factory()); FakeRtcEventLog* caller_event_log = @@ -3500,20 +3389,17 @@ TEST_P(PeerConnectionIntegrationTest, RegatherAfterChangingIceTransportType) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Since we are doing continual gathering, the ICE transport does not reach // kIceGatheringComplete (see // P2PTransportChannel::OnCandidatesAllocationDone), and consequently not // kIceConnectionComplete. EXPECT_THAT(WaitUntil([&] { return caller()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionConnected)), + Eq(PeerConnectionInterface::kIceConnectionConnected)), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return callee()->ice_connection_state(); }, - ::testing::Eq( - PeerConnectionInterface::kIceConnectionConnected)), + Eq(PeerConnectionInterface::kIceConnectionConnected)), IsRtcOk()); // Note that we cannot use the metric // `WebRTC.PeerConnection.CandidatePairType_UDP` in this test since this @@ -3529,7 +3415,7 @@ TEST_P(PeerConnectionIntegrationTest, RegatherAfterChangingIceTransportType) { // We should have gathered a new host candidate. EXPECT_THAT( WaitUntil([&] { return caller()->last_candidate_gathered().is_local(); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); // Loosen the callee's candidate filter. @@ -3538,7 +3424,7 @@ TEST_P(PeerConnectionIntegrationTest, RegatherAfterChangingIceTransportType) { callee()->pc()->SetConfiguration(callee_config); EXPECT_THAT( WaitUntil([&] { return callee()->last_candidate_gathered().is_local(); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); // Create an offer and verify that it does not contain an ICE restart (i.e new @@ -3588,13 +3474,12 @@ TEST_P(PeerConnectionIntegrationTest, OnIceCandidateError) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - EXPECT_THAT(WaitUntil([&] { return caller()->error_event().error_code; }, - ::testing::Eq(401)), + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), IsRtcOk()); - EXPECT_EQ("Unauthorized", caller()->error_event().error_text); + EXPECT_THAT( + WaitUntil([&] { return caller()->error_event().error_code; }, Eq(401)), + IsRtcOk()); + EXPECT_EQ("Unauthorized.", caller()->error_event().error_text); EXPECT_EQ("turn:88.88.88.0:3478?transport=udp", caller()->error_event().url); EXPECT_NE(caller()->error_event().address, ""); } @@ -3623,12 +3508,11 @@ TEST_P(PeerConnectionIntegrationTest, OnIceCandidateErrorWithEmptyAddress) { caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - EXPECT_THAT(WaitUntil([&] { return caller()->error_event().error_code; }, - ::testing::Eq(701)), + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return caller()->error_event().error_code; }, Eq(701)), + IsRtcOk()); EXPECT_EQ(caller()->error_event().address, ""); } @@ -3644,9 +3528,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->AddAudioTrack(); callee()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudio(); ASSERT_TRUE(ExpectNewFrames(media_expectations)); @@ -3656,13 +3539,11 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto observer = make_ref_counted(); callee()->pc()->SetLocalDescription(observer.get(), callee()->CreateOfferAndWait().release()); - EXPECT_THAT( - WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer->called(); }, IsTrue()), + IsRtcOk()); caller()->CreateAndSetAndSignalOffer(); // Implicit rollback. - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_TRUE(ExpectNewFrames(media_expectations)); } @@ -3677,17 +3558,15 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto sld_observer = make_ref_counted(); callee()->pc()->SetLocalDescription(sld_observer.get(), callee()->CreateOfferAndWait().release()); - EXPECT_THAT( - WaitUntil([&] { return sld_observer->called(); }, ::testing::IsTrue()), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return sld_observer->called(); }, IsTrue()), + IsRtcOk()); EXPECT_EQ(sld_observer->error(), ""); auto srd_observer = make_ref_counted(); callee()->pc()->SetRemoteDescription( srd_observer.get(), caller()->CreateOfferAndWait().release()); - EXPECT_THAT( - WaitUntil([&] { return srd_observer->called(); }, ::testing::IsTrue()), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return srd_observer->called(); }, IsTrue()), + IsRtcOk()); EXPECT_EQ(srd_observer->error(), ""); EXPECT_THAT(callee()->peer_connection_signaling_state_history(), @@ -3722,9 +3601,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, // Munge remote answer for SRD. caller()->SetReceivedSdpMunger(munger); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Observe that after munging the parameter is present in generated SDP. caller()->SetGeneratedSdpMunger( [](std::unique_ptr& sdp) { @@ -3749,9 +3627,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->pc()->AddTransceiver(MediaType::AUDIO); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); int current_size = caller()->pc()->GetTransceivers().size(); // Add more tracks until we get close to having issues. // Issues have been seen at: @@ -3767,9 +3644,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto start_time_ms = TimeMillis(); caller()->CreateAndSetAndSignalOffer(); // We want to stop when the time exceeds one second. - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); auto elapsed_time_ms = TimeMillis() - start_time_ms; RTC_LOG(LS_INFO) << "Renegotiating took " << elapsed_time_ms << " ms"; ASSERT_GT(1000, elapsed_time_ms) @@ -3787,9 +3663,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->pc()->AddTransceiver(MediaType::VIDEO); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); int current_size = caller()->pc()->GetTransceivers().size(); // Add more tracks until we get close to having issues. // Issues have been seen at: @@ -3807,9 +3682,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto start_time_ms = TimeMillis(); caller()->CreateAndSetAndSignalOffer(); // We want to stop when the time exceeds one second. - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); auto elapsed_time_ms = TimeMillis() - start_time_ms; RTC_LOG(LS_INFO) << "Renegotiating took " << elapsed_time_ms << " ms"; ASSERT_GT(1000, elapsed_time_ms) @@ -3827,9 +3701,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->AddAudioTrack(); callee()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Wait until we can see the audio flowing. MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudio(); @@ -3853,9 +3726,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto start_time_ms = TimeMillis(); caller()->CreateAndSetAndSignalOffer(); // We want to stop when the time exceeds one second. - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); auto elapsed_time_ms = TimeMillis() - start_time_ms; RTC_LOG(LS_INFO) << "Renegotiating took " << elapsed_time_ms << " ms"; // This is a guard against the test using excessive amounts of time. @@ -3903,8 +3775,7 @@ INSTANTIATE_TEST_SUITE_P(PeerConnectionIntegrationTest, // PeerConnections. class PeerConnectionIntegrationInteropTest : public PeerConnectionIntegrationBaseTest, - public ::testing::WithParamInterface< - std::tuple> { + public WithParamInterface> { protected: // Setting the SdpSemantics for the base test to kDefault does not matter // because we specify not to use the test semantics when creating @@ -3928,9 +3799,8 @@ TEST_P(PeerConnectionIntegrationInteropTest, NoMediaLocalToNoMediaRemote) { ConnectFakeSignaling(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); } TEST_P(PeerConnectionIntegrationInteropTest, OneAudioLocalToNoMediaRemote) { @@ -3939,9 +3809,8 @@ TEST_P(PeerConnectionIntegrationInteropTest, OneAudioLocalToNoMediaRemote) { auto audio_sender = caller()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Verify that one audio receiver has been created on the remote and that it // has the same track ID as the sending track. @@ -3962,9 +3831,8 @@ TEST_P(PeerConnectionIntegrationInteropTest, OneAudioOneVideoToNoMediaRemote) { auto audio_sender = caller()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // 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. @@ -3988,9 +3856,8 @@ TEST_P(PeerConnectionIntegrationInteropTest, callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.ExpectBidirectionalAudioAndVideo(); @@ -4005,9 +3872,8 @@ TEST_P(PeerConnectionIntegrationInteropTest, callee()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Verify that only the audio track has been negotiated. EXPECT_EQ(0u, caller()->GetReceiversOfType(MediaType::VIDEO).size()); @@ -4015,9 +3881,8 @@ TEST_P(PeerConnectionIntegrationInteropTest, // Reverse roles. callee()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); MediaExpectations media_expectations; media_expectations.CallerExpectsSomeVideo(); @@ -4030,18 +3895,15 @@ TEST_P(PeerConnectionIntegrationTest, NewTracksDoNotCauseNewCandidates) { ConnectFakeSignaling(); caller()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, ::testing::IsTrue()), + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return DtlsConnected(); }, IsTrue()), IsRtcOk()); caller()->ExpectCandidates(0); callee()->ExpectCandidates(0); caller()->AddAudioTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); } TEST_P(PeerConnectionIntegrationTest, MediaCallWithoutMediaEngineFails) { @@ -4069,9 +3931,8 @@ TEST_F(PeerConnectionIntegrationTestPlanB, TwoVideoUnifiedPlanToNoMediaPlanB) { caller()->AddVideoTrack(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); // Verify that there is only one receiver and it corresponds to the first // added track. @@ -4102,9 +3963,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto audio_transceiver = audio_transceiver_or_error.MoveValue(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); { MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeAudio(); @@ -4115,9 +3975,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack()); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); { MediaExpectations media_expectations; media_expectations.CalleeExpectsSomeVideo(); @@ -4136,15 +3995,13 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto audio_transceiver = audio_transceiver_or_error.MoveValue(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); audio_transceiver->StopStandard(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(0U, caller()->pc()->GetTransceivers().size()); EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, caller()->pc()->ice_gathering_state()); @@ -4165,16 +4022,14 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto caller_transceiver = audio_transceiver_or_error.MoveValue(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); caller_transceiver->StopStandard(); auto callee_transceiver = callee()->pc()->GetTransceivers()[0]; caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); EXPECT_EQ(0U, caller()->pc()->GetTransceivers().size()); EXPECT_EQ(0U, callee()->pc()->GetTransceivers().size()); EXPECT_EQ(0U, caller()->pc()->GetSenders().size()); @@ -4196,18 +4051,16 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto audio_transceiver = audio_transceiver_or_error.MoveValue(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); auto caller_track = audio_transceiver->receiver()->track(); auto callee_track = callee()->pc()->GetReceivers()[0]->track(); audio_transceiver->StopStandard(); EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded, caller_track->state()); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded, callee_track->state()); } @@ -4223,18 +4076,16 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto audio_transceiver = audio_transceiver_or_error.MoveValue(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); auto caller_track = audio_transceiver->receiver()->track(); auto callee_track = callee()->pc()->GetReceivers()[0]->track(); audio_transceiver->StopStandard(); EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded, caller_track->state()); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); EXPECT_EQ(MediaStreamTrackInterface::TrackState::kEnded, callee_track->state()); } @@ -4251,9 +4102,8 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndRtpSenderVideoEncoderSelector) { options.offer_to_receive_video = 0; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); std::unique_ptr encoder_selector = @@ -4283,25 +4133,24 @@ TEST_P(PeerConnectionIntegrationTest, options.offer_to_receive_video = 0; caller()->SetOfferAnswerOptions(options); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); std::unique_ptr encoder_selector = std::make_unique(); std::optional next_format; EXPECT_CALL(*encoder_selector, OnCurrentEncoder) - .WillOnce(::testing::Invoke([&](const SdpVideoFormat& format) { + .WillOnce(Invoke([&](const SdpVideoFormat& format) { EXPECT_EQ(format.name, "VP8"); next_format = SdpVideoFormat::VP9Profile0(); })) - .WillOnce(::testing::Invoke([&](const SdpVideoFormat& format) { + .WillOnce(Invoke([&](const SdpVideoFormat& format) { EXPECT_EQ(format.name, "VP9"); })); EXPECT_CALL(*encoder_selector, OnAvailableBitrate) .WillRepeatedly( - ::testing::Invoke([&](const DataRate& rate) { return next_format; })); + Invoke([&](const DataRate& rate) { return next_format; })); sender->SetEncoderSelector(std::move(encoder_selector)); @@ -4386,15 +4235,13 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, // Wait until callee has sent at least one NACK. // Note that due to stats caching, this might only be visible 50 ms // after the nack was in fact sent. - EXPECT_THAT( - WaitUntil([&] { return NacksSentCount(*callee()); }, ::testing::Gt(0)), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return NacksSentCount(*callee()); }, Gt(0)), + IsRtcOk()); ASSERT_FALSE(HasFailure()); virtual_socket_server()->set_drop_probability(0.0); // Wait until caller has received at least one NACK - EXPECT_THAT(WaitUntil([&] { return NacksReceivedCount(*caller()); }, - ::testing::Gt(0)), + EXPECT_THAT(WaitUntil([&] { return NacksReceivedCount(*caller()); }, Gt(0)), IsRtcOk()); } @@ -4439,14 +4286,12 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, VideoPacketLossCausesNack) { // Wait until callee has sent at least one NACK. // Note that due to stats caching, this might only be visible 50 ms // after the nack was in fact sent. - EXPECT_THAT( - WaitUntil([&] { return NacksSentCount(*callee()); }, ::testing::Gt(0)), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return NacksSentCount(*callee()); }, Gt(0)), + IsRtcOk()); ASSERT_FALSE(HasFailure()); // Wait until caller has received at least one NACK - EXPECT_THAT(WaitUntil([&] { return NacksReceivedCount(*caller()); }, - ::testing::Gt(0)), + EXPECT_THAT(WaitUntil([&] { return NacksReceivedCount(*caller()); }, Gt(0)), IsRtcOk()); } @@ -4631,8 +4476,10 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, PeerConnectionInterface::kStable); } +// TODO: issues.webrtc.org/425336456 - figure out correct behavior and reenable. +// TODO: issues.webrtc.org/383078466 - should pass when this bug is fixed. TEST_F(PeerConnectionIntegrationTestUnifiedPlan, - OnlyOnePairWantsCorruptionScorePlumbing) { + DISABLED_OnlyOnePairWantsCorruptionScorePlumbingShouldFailToGetIt) { // In order for corruption score to be logged, encryption of RTP header // extensions must be allowed. CryptoOptions crypto_options; @@ -4644,24 +4491,30 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, ConnectFakeSignaling(); // Do normal offer/answer and wait for some frames to be received in each - // direction, and `corruption_score` to be aggregated. + // direction. caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); - // Negotiate the corruption detection header extension in SDP. - // If caller adds corruption detection header extension to its SDP offer, it - // will receive it from the callee. + + // Negotiate the corruption detection header extension in SDP only in one + // direction. caller()->NegotiateCorruptionDetectionHeader(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); - ASSERT_THAT(WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, - ::testing::Gt(0), {.timeout = kMaxWaitForStats}), + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), IsRtcOk()); + std::vector negotiated_extensions = + caller()->pc()->GetTransceivers()[0]->GetNegotiatedHeaderExtensions(); + ASSERT_THAT(negotiated_extensions, + Contains(Field("uri", &RtpHeaderExtensionCapability::uri, + RtpExtension::kCorruptionDetectionUri))); + ASSERT_THAT(WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, + Eq(3), {.timeout = kMaxWaitForStats}), + IsRtcOk()) + << "Waiting for caller corruption score count > 0"; ASSERT_THAT(WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, - ::testing::Eq(0), {.timeout = kMaxWaitForStats}), - IsRtcOk()); + Eq(3), {.timeout = kMaxWaitForStats}), + IsRtcOk()) + << "Waiting for callee corruption score count > 0"; for (const auto& pair : {caller(), callee()}) { scoped_refptr report = pair->NewGetStats(); @@ -4670,22 +4523,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, report->GetStatsOfType(); for (const auto& stat : inbound_stream_stats) { if (*stat->kind == "video") { - if (pair == caller()) { - EXPECT_TRUE(stat->total_corruption_probability.has_value()); - EXPECT_TRUE(stat->total_squared_corruption_probability.has_value()); - - double average_corruption_score = - (*stat->total_corruption_probability) / - static_cast(*stat->corruption_measurements); - EXPECT_GE(average_corruption_score, 0.0); - EXPECT_LE(average_corruption_score, 1.0); - } - if (pair == callee()) { - // Since only `caller` requests corruption score calculation the - // callee should not aggregate it. EXPECT_FALSE(stat->total_corruption_probability.has_value()); EXPECT_FALSE(stat->total_squared_corruption_probability.has_value()); - } } } } @@ -4715,14 +4554,13 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, callee()->NegotiateCorruptionDetectionHeader(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_THAT(WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, - ::testing::Gt(0), {.timeout = kMaxWaitForStats}), + Gt(0), {.timeout = kMaxWaitForStats}), IsRtcOk()); ASSERT_THAT(WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, - ::testing::Gt(0), {.timeout = kMaxWaitForStats}), + Gt(0), {.timeout = kMaxWaitForStats}), IsRtcOk()); for (const auto& pair : {caller(), callee()}) { @@ -4768,14 +4606,13 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); ASSERT_THAT(WaitUntil([&] { return caller()->GetCorruptionScoreCount(); }, - ::testing::Eq(0), {.timeout = kMaxWaitForStats}), + Eq(0), {.timeout = kMaxWaitForStats}), IsRtcOk()); ASSERT_THAT(WaitUntil([&] { return callee()->GetCorruptionScoreCount(); }, - ::testing::Eq(0), {.timeout = kMaxWaitForStats}), + Eq(0), {.timeout = kMaxWaitForStats}), IsRtcOk()); for (const auto& pair : {caller(), callee()}) { @@ -4812,9 +4649,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, ASSERT_TRUE(transceiver->SetHeaderExtensionsToNegotiate(extensions).ok()); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); const auto& negotiated_header_extensions = caller() ->pc() ->remote_description() @@ -4830,7 +4666,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, [&] { return metrics::NumSamples("WebRTC.Call.AbsCapture.ExtensionWait"); }, - ::testing::Gt(0)), + Gt(0)), IsRtcOk()); // Observed deltas are more than 100 msec. Use 1 minute as tolerance; // this is a check against wrong timebase. @@ -4840,7 +4676,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, [&] { return metrics::NumSamples("WebRTC.Call.AbsCapture.OffsetWait"); }, - ::testing::Gt(0)), + Gt(0)), IsRtcOk()); // On a point-to-point call, we expect the offset to be zero. EXPECT_LT(metrics::MinSample("WebRTC.Call.AbsCapture.Offset"), 2); @@ -4880,11 +4716,11 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, }; caller()->SetGeneratedSdpMunger(munger); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); caller()->SetGeneratedSdpMunger(nullptr); - auto offer = caller()->CreateOfferAndWait(); + std::unique_ptr offer = + caller()->CreateOfferAndWait(); ASSERT_NE(nullptr, offer); // The offer should be acceptable. EXPECT_TRUE(caller()->SetLocalDescriptionAndSendSdpMessage(std::move(offer))); @@ -4924,9 +4760,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, }; caller()->SetGeneratedSdpMunger(munger); caller()->CreateAndSetAndSignalOffer(); - ASSERT_THAT( - WaitUntil([&] { return SignalingStateStable(); }, ::testing::IsTrue()), - IsRtcOk()); + ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()), + IsRtcOk()); caller()->SetGeneratedSdpMunger(nullptr); if (!has_munged) { @@ -4963,8 +4798,9 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, ASSERT_EQ(transceivers.size(), 1u); transceivers[0]->SetCodecPreferences(codecs); - auto offer = caller()->CreateOfferAndWait(); - ASSERT_NE(offer, nullptr); + std::unique_ptr offer = + caller()->CreateOfferAndWait(); + ASSERT_THAT(offer, NotNull()); // The offer should be acceptable. EXPECT_TRUE(caller()->SetLocalDescriptionAndSendSdpMessage(std::move(offer))); @@ -5035,7 +4871,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, // associated RTX codec. std::unique_ptr answer = caller()->CreateAnswerForTest(); - ASSERT_NE(answer, nullptr); + ASSERT_THAT(answer, NotNull()); RTC_LOG(LS_ERROR) << "Answer is " << *answer; ASSERT_THAT(answer->description()->contents().size(), Eq(1)); auto codecs = @@ -5062,7 +4898,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, ASSERT_TRUE(CreatePeerConnectionWrappers()); // Add first video track. caller()->AddVideoTrack(); - auto offer = caller()->CreateOfferAndWait(); + std::unique_ptr offer = + caller()->CreateOfferAndWait(); EXPECT_EQ(offer->description()->contents().size(), 1U); // Observe that packetization is NOT raw. for (const auto& content : offer->description()->contents()) { @@ -5087,9 +4924,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, auto observer = make_ref_counted(); caller()->pc()->SetLocalDescription(observer.get(), offer.release()); // Wait for SLD to complete. - EXPECT_THAT( - WaitUntil([&] { return observer->called(); }, ::testing::IsTrue()), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer->called(); }, IsTrue()), + IsRtcOk()); // Add a second video track. caller()->AddVideoTrack(); auto offer2 = caller()->CreateOfferAndWait(); @@ -5144,7 +4980,7 @@ TEST_P(PeerConnectionIntegrationTest, DtlsPqc) { return PeerConnectionStateIs( PeerConnectionInterface::PeerConnectionState::kConnected); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); uint16_t expected = @@ -5185,7 +5021,7 @@ TEST_P(PeerConnectionIntegrationTest, DtlsPqcFieldTrial) { return PeerConnectionStateIs( PeerConnectionInterface::PeerConnectionState::kConnected); }, - ::testing::IsTrue()), + IsTrue()), IsRtcOk()); uint16_t expected = diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc index 13fd3c393a..ec44e1218c 100644 --- a/pc/peer_connection_interface_unittest.cc +++ b/pc/peer_connection_interface_unittest.cc @@ -10,10 +10,9 @@ #include "api/peer_connection_interface.h" -#include -#include - +#include #include +#include #include #include #include @@ -26,6 +25,7 @@ #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/crypto/crypto_options.h" #include "api/data_channel_interface.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" @@ -98,30 +98,40 @@ namespace webrtc { namespace { -const char kStreamId1[] = "local_stream_1"; -const char kStreamId2[] = "local_stream_2"; -const char kStreamId3[] = "local_stream_3"; -const int kDefaultStunPort = 3478; -const char kStunAddressOnly[] = "stun:address"; -const char kStunInvalidPort[] = "stun:address:-1"; -const char kStunAddressPortAndMore1[] = "stun:address:port:more"; -const char kStunAddressPortAndMore2[] = "stun:address:port more"; -const char kTurnIceServerUri[] = "turn:turn.example.org"; -const char kTurnUsername[] = "user"; -const char kTurnPassword[] = "password"; -const char kTurnHostname[] = "turn.example.org"; -const uint32_t kTimeout = 10000U; - -const char kStreams[][8] = {"stream1", "stream2"}; -const char kAudioTracks[][32] = {"audiotrack0", "audiotrack1"}; -const char kVideoTracks[][32] = {"videotrack0", "videotrack1"}; - -const char kRecvonly[] = "recvonly"; -const char kSendrecv[] = "sendrecv"; +using ::testing::Eq; +using ::testing::Exactly; +using ::testing::IsTrue; +using ::testing::NotNull; +using ::testing::SizeIs; +using ::testing::Values; + +using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; +using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; + +constexpr char kStreamId1[] = "local_stream_1"; +constexpr char kStreamId2[] = "local_stream_2"; +constexpr char kStreamId3[] = "local_stream_3"; +constexpr int kDefaultStunPort = 3478; +constexpr char kStunAddressOnly[] = "stun:address"; +constexpr char kStunInvalidPort[] = "stun:address:-1"; +constexpr char kStunAddressPortAndMore1[] = "stun:address:port:more"; +constexpr char kStunAddressPortAndMore2[] = "stun:address:port more"; +constexpr char kTurnIceServerUri[] = "turn:turn.example.org"; +constexpr char kTurnUsername[] = "user"; +constexpr char kTurnPassword[] = "password"; +constexpr char kTurnHostname[] = "turn.example.org"; +constexpr uint32_t kTimeout = 10000U; + +constexpr char kStreams[][8] = {"stream1", "stream2"}; +constexpr char kAudioTracks[][32] = {"audiotrack0", "audiotrack1"}; +constexpr char kVideoTracks[][32] = {"videotrack0", "videotrack1"}; + +constexpr char kRecvonly[] = "recvonly"; +constexpr char kSendrecv[] = "sendrecv"; // Reference SDP with a MediaStream with label "stream1" and audio track with // id "audio_1" and a video track with id "video_1; -const char kSdpStringWithStream1PlanB[] = +constexpr char kSdpStringWithStream1PlanB[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -151,7 +161,7 @@ const char kSdpStringWithStream1PlanB[] = // Same string as above but with the MID changed to the Unified Plan default and // a=msid added. This is needed so that this SDP can be used as an answer for a // Unified Plan offer. -const char kSdpStringWithStream1UnifiedPlan[] = +constexpr char kSdpStringWithStream1UnifiedPlan[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -181,7 +191,7 @@ const char kSdpStringWithStream1UnifiedPlan[] = // Reference SDP with a MediaStream with label "stream1" and audio track with // id "audio_1"; -const char kSdpStringWithStream1AudioTrackOnly[] = +constexpr char kSdpStringWithStream1AudioTrackOnly[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -201,7 +211,7 @@ const char kSdpStringWithStream1AudioTrackOnly[] = // Reference SDP with two MediaStreams with label "stream1" and "stream2. Each // MediaStreams have one audio track and one video track. // This uses MSID. -const char kSdpStringWithStream1And2PlanB[] = +constexpr char kSdpStringWithStream1And2PlanB[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -233,7 +243,7 @@ const char kSdpStringWithStream1And2PlanB[] = "a=ssrc:2 msid:stream1 videotrack0\r\n" "a=ssrc:4 cname:stream2\r\n" "a=ssrc:4 msid:stream2 videotrack1\r\n"; -const char kSdpStringWithStream1And2UnifiedPlan[] = +constexpr char kSdpStringWithStream1And2UnifiedPlan[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -285,7 +295,7 @@ const char kSdpStringWithStream1And2UnifiedPlan[] = "a=ssrc:4 msid:stream2 videotrack1\r\n"; // Reference SDP without MediaStreams. Msid is not supported. -const char kSdpStringWithoutStreams[] = +constexpr char kSdpStringWithoutStreams[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -310,7 +320,7 @@ const char kSdpStringWithoutStreams[] = "a=rtpmap:120 VP8/90000\r\n"; // Reference SDP without MediaStreams. Msid is supported. -const char kSdpStringWithMsidWithoutStreams[] = +constexpr char kSdpStringWithMsidWithoutStreams[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -336,7 +346,7 @@ const char kSdpStringWithMsidWithoutStreams[] = "a=rtpmap:120 VP8/90000\r\n"; // Reference SDP without MediaStreams and audio only. -const char kSdpStringWithoutStreamsAudioOnly[] = +constexpr char kSdpStringWithoutStreamsAudioOnly[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -352,7 +362,7 @@ const char kSdpStringWithoutStreamsAudioOnly[] = "a=rtpmap:111 OPUS/48000/2\r\n"; // Reference SENDONLY SDP without MediaStreams. Msid is not supported. -const char kSdpStringSendOnlyWithoutStreams[] = +constexpr char kSdpStringSendOnlyWithoutStreams[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -378,14 +388,14 @@ const char kSdpStringSendOnlyWithoutStreams[] = "a=rtcp-mux\r\n" "a=rtpmap:120 VP8/90000\r\n"; -const char kSdpStringInit[] = +constexpr char kSdpStringInit[] = "v=0\r\n" "o=- 0 0 IN IP4 127.0.0.1\r\n" "s=-\r\n" "t=0 0\r\n" "a=msid-semantic: WMS\r\n"; -const char kSdpStringAudio[] = +constexpr char kSdpStringAudio[] = "m=audio 1 RTP/AVPF 111\r\n" "a=ice-ufrag:e5785931\r\n" "a=ice-pwd:36fb7878390db89481c1d46daa4278d8\r\n" @@ -396,7 +406,7 @@ const char kSdpStringAudio[] = "a=rtcp-mux\r\n" "a=rtpmap:111 OPUS/48000/2\r\n"; -const char kSdpStringVideo[] = +constexpr char kSdpStringVideo[] = "m=video 1 RTP/AVPF 120\r\n" "a=ice-ufrag:e5785931\r\n" "a=ice-pwd:36fb7878390db89481c1d46daa4278d8\r\n" @@ -407,19 +417,19 @@ const char kSdpStringVideo[] = "a=rtcp-mux\r\n" "a=rtpmap:120 VP8/90000\r\n"; -const char kSdpStringMs1Audio0[] = +constexpr char kSdpStringMs1Audio0[] = "a=ssrc:1 cname:stream1\r\n" "a=ssrc:1 msid:stream1 audiotrack0\r\n"; -const char kSdpStringMs1Video0[] = +constexpr char kSdpStringMs1Video0[] = "a=ssrc:2 cname:stream1\r\n" "a=ssrc:2 msid:stream1 videotrack0\r\n"; -const char kSdpStringMs1Audio1[] = +constexpr char kSdpStringMs1Audio1[] = "a=ssrc:3 cname:stream1\r\n" "a=ssrc:3 msid:stream1 audiotrack1\r\n"; -const char kSdpStringMs1Video1[] = +constexpr char kSdpStringMs1Video1[] = "a=ssrc:4 cname:stream1\r\n" "a=ssrc:4 msid:stream1 videotrack1\r\n"; @@ -429,14 +439,6 @@ class RtcEventLogOutputNull final : public RtcEventLogOutput { bool Write(const absl::string_view /*output*/) override { return true; } }; -using ::testing::Eq; -using ::testing::Exactly; -using ::testing::SizeIs; -using ::testing::Values; - -using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; -using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions; - // Gets the first ssrc of given content type from the ContentInfo. bool GetFirstSsrc(const ContentInfo* content_info, int* ssrc) { if (!content_info || !ssrc) { @@ -850,10 +852,9 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { pc_->CreateAnswer(observer.get(), options ? *options : RTCOfferAnswerOptions()); } - EXPECT_THAT( - WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer->called(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); *desc = observer->MoveDescription(); return observer->result(); } @@ -878,10 +879,9 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { pc_->SetRemoteDescription(observer.get(), desc.release()); } if (pc_->signaling_state() != PeerConnectionInterface::kClosed) { - EXPECT_THAT( - WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer->called(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); } return observer->result(); } @@ -904,10 +904,9 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { if (!pc_->GetStats(observer.get(), track, PeerConnectionInterface::kStatsOutputLevelStandard)) return false; - EXPECT_THAT( - WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer->called(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); return observer->called(); } @@ -915,10 +914,9 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { bool DoGetRTCStats() { auto callback = make_ref_counted(); pc_->GetStats(callback.get()); - EXPECT_THAT( - WaitUntil([&] { return callback->called(); }, ::testing::IsTrue(), - {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return callback->called(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); return callback->called(); } @@ -1024,15 +1022,14 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_); // Wait for the ice_complete message, so that SDP will have candidates. EXPECT_THAT(WaitUntil([&] { return observer_.ice_gathering_complete_; }, - ::testing::IsTrue(), - {.timeout = TimeDelta::Millis(kTimeout)}), + IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } void CreateAnswerAsRemoteDescription(const std::string& sdp) { std::unique_ptr answer( CreateSessionDescription(SdpType::kAnswer, sdp)); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); EXPECT_TRUE(DoSetRemoteDescription(std::move(answer))); EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); } @@ -1045,7 +1042,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { EXPECT_EQ(PeerConnectionInterface::kHaveRemotePrAnswer, observer_.state_); std::unique_ptr answer( CreateSessionDescription(SdpType::kAnswer, sdp)); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); EXPECT_TRUE(DoSetRemoteDescription(std::move(answer))); EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); } @@ -1056,15 +1053,14 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { void WaitAndVerifyOnAddStream(const std::string& stream_id, int expected_num_tracks) { // Verify that both OnAddStream and OnAddTrack are called. - EXPECT_THAT(WaitUntil([&] { return observer_.GetLastAddedStreamId(); }, - ::testing::Eq(stream_id), - {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT( + WaitUntil([&] { return observer_.GetLastAddedStreamId(); }, + Eq(stream_id), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); EXPECT_THAT( WaitUntil( [&] { return observer_.CountAddTrackEventsForStream(stream_id); }, - ::testing::Eq(expected_num_tracks), - {.timeout = TimeDelta::Millis(kTimeout)}), + Eq(expected_num_tracks), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } @@ -1180,10 +1176,9 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test { RTC_DCHECK(pc_); auto observer = make_ref_counted(); pc_->CreateOffer(observer.get(), offer_answer_options); - EXPECT_THAT( - WaitUntil([&] { return observer->called(); }, ::testing::IsTrue(), - {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer->called(); }, IsTrue(), + {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); return observer->MoveDescription(); } @@ -1765,10 +1760,9 @@ TEST_P(PeerConnectionInterfaceTest, IceCandidates) { ::testing::Ne(nullptr), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); - EXPECT_THAT( - WaitUntil([&] { return observer_.ice_gathering_complete_; }, - ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer_.ice_gathering_complete_; }, + IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate())); } @@ -2073,7 +2067,7 @@ TEST_P(PeerConnectionInterfaceTest, DISABLED_TestRejectSctpDataChannelInAnswer) EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); std::unique_ptr answer( CreateSessionDescription(SdpType::kAnswer, sdp)); - ASSERT_TRUE(answer); + ASSERT_THAT(answer, NotNull()); ContentInfo* data_info = GetFirstDataContent(answer->description()); data_info->rejected = true; @@ -2405,6 +2399,125 @@ TEST_P(PeerConnectionInterfaceTest, RTCErrorType::INVALID_PARAMETER); } +TEST_P(PeerConnectionInterfaceTest, UnmodifiedSetConfigurationSucceeds) { + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + std::unique_ptr offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } +} + +TEST_P(PeerConnectionInterfaceTest, + SetConfigurationSucceedsWithMatchingCryptoOptions) { + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + config.crypto_options = CryptoOptions(); + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + std::unique_ptr offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + config.crypto_options = CryptoOptions(); + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + CryptoOptions options; + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768, + }); + config.crypto_options = options; + + CreatePeerConnection(config); + + std::unique_ptr offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } +} + +TEST_P(PeerConnectionInterfaceTest, + SetConfigurationFailsWithMismatchingCryptoOptions) { + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + std::unique_ptr offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + CryptoOptions options; + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768, + }); + config.crypto_options = options; + + RTCError error = pc_->SetConfiguration(config); + EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + CryptoOptions options; + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768, + }); + config.crypto_options = options; + + CreatePeerConnection(config); + + std::unique_ptr offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kSECP521R1, + }); + config.crypto_options = options; + + RTCError error = pc_->SetConfiguration(config); + EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); + } +} + // Test that PeerConnection::Close changes the states to closed and all remote // tracks change state to ended. TEST_P(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { @@ -2444,11 +2557,11 @@ TEST_P(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { ASSERT_TRUE(video_receiver); // Track state may be updated asynchronously. EXPECT_THAT(WaitUntil([&] { return audio_receiver->track()->state(); }, - ::testing::Eq(MediaStreamTrackInterface::kEnded), + Eq(MediaStreamTrackInterface::kEnded), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return video_receiver->track()->state(); }, - ::testing::Eq(MediaStreamTrackInterface::kEnded), + Eq(MediaStreamTrackInterface::kEnded), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } else { @@ -2570,11 +2683,11 @@ TEST_F(PeerConnectionInterfaceTestPlanB, reference_collection_.get())); // Track state may be updated asynchronously. EXPECT_THAT(WaitUntil([&] { return audio_track2->state(); }, - ::testing::Eq(MediaStreamTrackInterface::kEnded), + Eq(MediaStreamTrackInterface::kEnded), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return video_track2->state(); }, - ::testing::Eq(MediaStreamTrackInterface::kEnded), + Eq(MediaStreamTrackInterface::kEnded), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } @@ -2621,11 +2734,11 @@ TEST_P(PeerConnectionInterfaceTest, RejectMediaContent) { EXPECT_TRUE(DoSetLocalDescription(std::move(local_offer))); // Track state may be updated asynchronously. EXPECT_THAT(WaitUntil([&] { return remote_audio->state(); }, - ::testing::Eq(MediaStreamTrackInterface::kEnded), + Eq(MediaStreamTrackInterface::kEnded), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); EXPECT_THAT(WaitUntil([&] { return remote_video->state(); }, - ::testing::Eq(MediaStreamTrackInterface::kEnded), + Eq(MediaStreamTrackInterface::kEnded), {.timeout = TimeDelta::Millis(kTimeout)}), IsRtcOk()); } @@ -3485,7 +3598,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateOfferWithAudioVideoOptions) { std::unique_ptr offer; CreatePeerConnection(); offer = CreateOfferWithOptions(rtc_options); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); EXPECT_NE(nullptr, GetFirstAudioContent(offer->description())); EXPECT_NE(nullptr, GetFirstVideoContent(offer->description())); } @@ -3500,7 +3613,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateOfferWithAudioOnlyOptions) { std::unique_ptr offer; CreatePeerConnection(); offer = CreateOfferWithOptions(rtc_options); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); EXPECT_NE(nullptr, GetFirstAudioContent(offer->description())); EXPECT_EQ(nullptr, GetFirstVideoContent(offer->description())); } @@ -3515,7 +3628,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateOfferWithVideoOnlyOptions) { std::unique_ptr offer; CreatePeerConnection(); offer = CreateOfferWithOptions(rtc_options); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); EXPECT_EQ(nullptr, GetFirstAudioContent(offer->description())); EXPECT_NE(nullptr, GetFirstVideoContent(offer->description())); } @@ -3528,7 +3641,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateOfferWithDefaultOfferAnswerOptions) { std::unique_ptr offer; CreatePeerConnection(); offer = CreateOfferWithOptions(rtc_options); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); EXPECT_EQ(nullptr, GetFirstAudioContent(offer->description())); EXPECT_EQ(nullptr, GetFirstVideoContent(offer->description())); } @@ -3583,14 +3696,14 @@ TEST_P(PeerConnectionInterfaceTest, CreateOfferWithRtpMux) { rtc_options.use_rtp_mux = true; offer = CreateOfferWithOptions(rtc_options); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); EXPECT_NE(nullptr, GetFirstAudioContent(offer->description())); EXPECT_NE(nullptr, GetFirstVideoContent(offer->description())); EXPECT_TRUE(offer->description()->HasGroup(GROUP_TYPE_BUNDLE)); rtc_options.use_rtp_mux = false; offer = CreateOfferWithOptions(rtc_options); - ASSERT_TRUE(offer); + ASSERT_THAT(offer, NotNull()); EXPECT_NE(nullptr, GetFirstAudioContent(offer->description())); EXPECT_NE(nullptr, GetFirstVideoContent(offer->description())); EXPECT_FALSE(offer->description()->HasGroup(GROUP_TYPE_BUNDLE)); @@ -3613,34 +3726,30 @@ TEST_F(PeerConnectionInterfaceTestPlanB, scoped_refptr video_track( CreateVideoTrack("video_track")); stream->AddTrack(audio_track); - EXPECT_THAT( - WaitUntil([&] { return observer_.renegotiation_needed_; }, - ::testing::IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, + 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 = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, + 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 = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, + 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 = TimeDelta::Millis(kTimeout)}), - IsRtcOk()); + EXPECT_THAT(WaitUntil([&] { return observer_.renegotiation_needed_; }, + IsTrue(), {.timeout = TimeDelta::Millis(kTimeout)}), + IsRtcOk()); observer_.renegotiation_needed_ = false; } diff --git a/pc/peer_connection_internal.h b/pc/peer_connection_internal.h index daa0649fb4..ab508d7e01 100644 --- a/pc/peer_connection_internal.h +++ b/pc/peer_connection_internal.h @@ -18,6 +18,7 @@ #include #include +#include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/audio/audio_device.h" #include "api/candidate.h" @@ -87,17 +88,17 @@ class PeerConnectionSdpMethods { virtual bool dtls_enabled() const = 0; virtual const PeerConnectionFactoryInterface::Options* options() const = 0; - // Returns the CryptoOptions for this PeerConnection. This will always - // return the RTCConfiguration.crypto_options if set and will only default - // back to the PeerConnectionFactory settings if nothing was set. + // Returns the CryptoOptions for this PeerConnection. virtual CryptoOptions GetCryptoOptions() = 0; virtual JsepTransportController* transport_controller_s() = 0; virtual JsepTransportController* transport_controller_n() = 0; virtual DataChannelController* data_channel_controller() = 0; virtual PortAllocator* port_allocator() = 0; virtual LegacyStatsCollector* legacy_stats() = 0; - // Returns the observer. Will crash on CHECK if the observer is removed. - virtual PeerConnectionObserver* Observer() const = 0; + // Run lambda on the PeerConnectionObserver. Will crash on CHECK if the + // observer is removed. + virtual void RunWithObserver( + absl::AnyInvocable) = 0; virtual std::optional GetSctpSslRole_n() = 0; virtual PeerConnectionInterface::IceConnectionState ice_connection_state_internal() = 0; diff --git a/pc/peer_connection_jsep_unittest.cc b/pc/peer_connection_jsep_unittest.cc index 90016662d6..eb3922ac14 100644 --- a/pc/peer_connection_jsep_unittest.cc +++ b/pc/peer_connection_jsep_unittest.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include +#include #include #include #include @@ -20,6 +19,7 @@ #include #include "absl/strings/string_view.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/jsep.h" #include "api/media_stream_interface.h" @@ -120,7 +120,7 @@ class PeerConnectionJsepTest : public ::testing::Test { TEST_F(PeerConnectionJsepTest, EmptyInitialOffer) { auto caller = CreatePeerConnection(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ASSERT_EQ(0u, offer->description()->contents().size()); } @@ -130,7 +130,7 @@ TEST_F(PeerConnectionJsepTest, AudioOnlyInitialOffer) { auto caller = CreatePeerConnection(); caller->AddTransceiver(MediaType::AUDIO); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); EXPECT_EQ(MediaType::AUDIO, contents[0].media_description()->type()); @@ -142,7 +142,7 @@ TEST_F(PeerConnectionJsepTest, VideoOnlyInitialOffer) { auto caller = CreatePeerConnection(); caller->AddTransceiver(MediaType::VIDEO); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); EXPECT_EQ(MediaType::VIDEO, contents[0].media_description()->type()); @@ -154,7 +154,7 @@ TEST_F(PeerConnectionJsepTest, DataOnlyInitialOffer) { auto caller = CreatePeerConnection(); caller->CreateDataChannel("dc"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); EXPECT_EQ(MediaType::DATA, contents[0].media_description()->type()); @@ -168,7 +168,7 @@ TEST_F(PeerConnectionJsepTest, MultipleDataChannelsCreateOnlyOneDataSection) { caller->CreateDataChannel("second"); caller->CreateDataChannel("third"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ASSERT_EQ(1u, offer->description()->contents().size()); } @@ -183,7 +183,7 @@ TEST_F(PeerConnectionJsepTest, MediaSectionsInInitialOfferOrderedCorrectly) { init.direction = RtpTransceiverDirection::kSendOnly; caller->AddTransceiver(MediaType::VIDEO, init); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(3u, contents.size()); @@ -212,7 +212,7 @@ TEST_F(PeerConnectionJsepTest, MediaSectionsInInitialOfferHaveDifferentMids) { caller->AddTransceiver(MediaType::AUDIO); caller->AddTransceiver(MediaType::AUDIO); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(2u, contents.size()); EXPECT_NE(contents[0].mid(), contents[1].mid()); @@ -224,7 +224,7 @@ TEST_F(PeerConnectionJsepTest, auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->StopInternal(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); EXPECT_EQ(0u, offer->description()->contents().size()); } @@ -245,7 +245,7 @@ TEST_F(PeerConnectionJsepTest, SetLocalOfferSetsTransceiverMid) { auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto video_transceiver = caller->AddTransceiver(MediaType::VIDEO); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto audio_mid = offer->description()->contents()[0].mid(); auto video_mid = offer->description()->contents()[1].mid(); @@ -416,13 +416,13 @@ TEST_F(PeerConnectionJsepTest, CreateAnswerHasSameMidsAsOffer) { caller->CreateDataChannel("dc"); auto callee = CreatePeerConnection(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); const auto* offer_data = GetFirstDataContent(offer->description()); ASSERT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto contents = answer->description()->contents(); ASSERT_EQ(4u, contents.size()); EXPECT_EQ(MediaType::VIDEO, contents[0].media_description()->type()); @@ -446,7 +446,7 @@ TEST_F(PeerConnectionJsepTest, CreateAnswerRejectsStoppedTransceiver) { callee->pc()->GetTransceivers()[0]->StopInternal(); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto contents = answer->description()->contents(); ASSERT_EQ(1u, contents.size()); EXPECT_TRUE(contents[0].rejected); @@ -465,7 +465,7 @@ TEST_F(PeerConnectionJsepTest, CreateAnswerNegotiatesDirection) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto contents = answer->description()->contents(); ASSERT_EQ(1u, contents.size()); EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, @@ -671,7 +671,7 @@ TEST_F(PeerConnectionJsepTest, // correctly. caller->AddAudioTrack("audio2"); callee->AddAudioTrack("audio2"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto offer_contents = offer->description()->contents(); auto second_mid = offer_contents[0].mid(); ASSERT_EQ(1u, offer_contents.size()); @@ -690,7 +690,7 @@ TEST_F(PeerConnectionJsepTest, EXPECT_EQ(second_mid, callee->pc()->GetTransceivers()[0]->mid()); // The new answer should also recycle the m section correctly. - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(1u, answer_contents.size()); EXPECT_FALSE(answer_contents[0].rejected); @@ -722,7 +722,7 @@ TEST_F(PeerConnectionJsepTest, CreateOfferRecyclesWhenOfferingTwice) { // Create a new offer that recycles the media section and set it as a local // description. - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto offer_contents = offer->description()->contents(); ASSERT_EQ(1u, offer_contents.size()); EXPECT_FALSE(offer_contents[0].rejected); @@ -788,7 +788,7 @@ TEST_P(RecycleMediaSectionTest, CurrentLocalAndCurrentRemoteRejected) { // The offer should reuse the previous media section but allocate a new MID // and change the media type. - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto offer_contents = offer->description()->contents(); ASSERT_EQ(1u, offer_contents.size()); EXPECT_FALSE(offer_contents[0].rejected); @@ -812,7 +812,7 @@ TEST_P(RecycleMediaSectionTest, CurrentLocalAndCurrentRemoteRejected) { EXPECT_EQ(second_type_, callee_transceivers[0]->media_type()); // The answer should have only one media section for the new transceiver. - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(1u, answer_contents.size()); EXPECT_FALSE(answer_contents[0].rejected); @@ -851,7 +851,7 @@ TEST_P(RecycleMediaSectionTest, CurrentRemoteOnlyRejected) { // The offer should reuse the previous media section but allocate a new MID // and change the media type. auto caller_second_transceiver = caller->AddTransceiver(second_type_); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); const auto& offer_contents = offer->description()->contents(); ASSERT_EQ(1u, offer_contents.size()); EXPECT_FALSE(offer_contents[0].rejected); @@ -875,7 +875,7 @@ TEST_P(RecycleMediaSectionTest, CurrentRemoteOnlyRejected) { EXPECT_EQ(second_type_, callee_transceivers[0]->media_type()); // The answer should have only one media section for the new transceiver. - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(1u, answer_contents.size()); EXPECT_FALSE(answer_contents[0].rejected); @@ -914,7 +914,7 @@ TEST_P(RecycleMediaSectionTest, CurrentLocalOnlyRejected) { // The offer should reuse the previous media section but allocate a new MID // and change the media type. auto callee_second_transceiver = callee->AddTransceiver(second_type_); - auto offer = callee->CreateOffer(); + std::unique_ptr offer = callee->CreateOffer(); const auto& offer_contents = offer->description()->contents(); ASSERT_EQ(1u, offer_contents.size()); EXPECT_FALSE(offer_contents[0].rejected); @@ -938,7 +938,7 @@ TEST_P(RecycleMediaSectionTest, CurrentLocalOnlyRejected) { EXPECT_EQ(second_type_, caller_transceivers[0]->media_type()); // The answer should have only one media section for the new transceiver. - auto answer = caller->CreateAnswer(); + std::unique_ptr answer = caller->CreateAnswer(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(1u, answer_contents.size()); EXPECT_FALSE(answer_contents[0].rejected); @@ -1130,7 +1130,7 @@ TEST_F(PeerConnectionJsepTest, DataChannelDoesNotRecycleMediaSection) { caller->CreateDataChannel("dc"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto offer_contents = offer->description()->contents(); ASSERT_EQ(2u, offer_contents.size()); EXPECT_EQ(MediaType::AUDIO, offer_contents[0].media_description()->type()); @@ -1140,7 +1140,7 @@ TEST_F(PeerConnectionJsepTest, DataChannelDoesNotRecycleMediaSection) { caller->SetLocalDescription(CloneSessionDescription(offer.get()))); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(2u, answer_contents.size()); EXPECT_EQ(MediaType::AUDIO, answer_contents[0].media_description()->type()); @@ -1159,7 +1159,7 @@ TEST_F(PeerConnectionJsepTest, AudioTrackAddedAfterDataSectionInReoffer) { caller->AddAudioTrack("a"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(2u, contents.size()); EXPECT_EQ(MediaType::DATA, contents[0].media_description()->type()); @@ -1197,7 +1197,7 @@ TEST_F(PeerConnectionJsepTest, OfferAnswerWithChangedMids) { caller->AddAudioTrack("b"); auto callee = CreatePeerConnection(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); RenameSection(0, kFirstMid, offer.get()); RenameSection(1, kSecondMid, offer.get()); @@ -1212,7 +1212,7 @@ TEST_F(PeerConnectionJsepTest, OfferAnswerWithChangedMids) { EXPECT_EQ(kFirstMid, callee_transceivers[0]->mid()); EXPECT_EQ(kSecondMid, callee_transceivers[1]->mid()); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto answer_contents = answer->description()->contents(); EXPECT_EQ(kFirstMid, answer_contents[0].mid()); EXPECT_EQ(kSecondMid, answer_contents[1].mid()); @@ -1240,7 +1240,7 @@ TEST_F(PeerConnectionJsepTest, CreateOfferGeneratesUniqueMidIfAlreadyTaken) { caller->AddAudioTrack("a"); auto callee = CreatePeerConnection(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); RenameSection(0, default_second_mid, offer.get()); ASSERT_TRUE( @@ -1273,7 +1273,7 @@ TEST_F(PeerConnectionJsepTest, caller->AddAudioTrack("a"); auto callee = CreatePeerConnection(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); RenameSection(0, default_data_mid, offer.get()); ASSERT_TRUE( @@ -1319,7 +1319,7 @@ TEST_F(PeerConnectionJsepTest, AddingTrackWithAddTrackSpecifiesTrackId) { auto caller = CreatePeerConnection(); caller->AddAudioTrack(kTrackId); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); auto streams = contents[0].media_description()->streams(); @@ -1337,7 +1337,7 @@ TEST_F(PeerConnectionJsepTest, auto transceiver = caller->AddTransceiver(MediaType::AUDIO); transceiver->sender()->SetTrack(caller->CreateAudioTrack(kTrackId).get()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); auto streams = contents[0].media_description()->streams(); @@ -1358,7 +1358,7 @@ TEST_F(PeerConnectionJsepTest, NoMsidInOfferIfTransceiverDirectionHasNoSend) { init_inactive.direction = RtpTransceiverDirection::kInactive; ASSERT_TRUE(caller->AddTransceiver(MediaType::VIDEO, init_inactive)); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto contents = offer->description()->contents(); ASSERT_EQ(2u, contents.size()); // MSID is specified in the first stream, so no streams means no MSID. @@ -1386,7 +1386,7 @@ TEST_F(PeerConnectionJsepTest, NoMsidInAnswerIfNoRespondingTracks) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto contents = answer->description()->contents(); ASSERT_EQ(2u, contents.size()); // MSID is specified in the first stream, so no streams means no MSID. @@ -1682,7 +1682,7 @@ TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioOnlyOffer) { auto callee = CreatePeerConnection(); callee->AddAudioTrack("audio"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ClearMids(offer.get()); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); @@ -1696,7 +1696,7 @@ TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioVideoOffer) { callee->AddAudioTrack("audio"); callee->AddVideoTrack("video"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ClearMids(offer.get()); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); @@ -1710,7 +1710,7 @@ TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioOnlyAnswer) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); ClearMids(answer.get()); EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); @@ -1725,7 +1725,7 @@ TEST_F(PeerConnectionJsepTest, LegacyNoMidAudioVideoAnswer) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); ClearMids(answer.get()); ASSERT_TRUE(caller->SetRemoteDescription(std::move(answer))); @@ -1740,7 +1740,7 @@ TEST_F(PeerConnectionJsepTest, LegacyNoMidTwoRemoteOffers) { auto callee = CreatePeerConnection(); callee->AddAudioTrack("audio"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ClearMids(offer.get()); ASSERT_TRUE( @@ -1754,7 +1754,7 @@ TEST_F(PeerConnectionJsepTest, SetLocalDescriptionFailsMissingMid) { auto caller = CreatePeerConnection(); caller->AddAudioTrack("audio"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); ClearMids(offer.get()); std::string error; @@ -1963,7 +1963,7 @@ TEST_F(PeerConnectionJsepTest, RollbackRestoresMid) { caller->AddTransceiver(MediaType::AUDIO); auto callee = CreatePeerConnection(); callee->AddAudioTrack("a"); - auto offer = callee->CreateOffer(); + std::unique_ptr offer = callee->CreateOffer(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_EQ(callee->pc()->GetTransceivers().size(), 1u); EXPECT_NE(callee->pc()->GetTransceivers()[0]->mid(), std::nullopt); @@ -2014,7 +2014,7 @@ TEST_F(PeerConnectionJsepTest, RollbackDoesNotAffectSendEncodings) { EXPECT_TRUE(params.encodings[0].active); params.encodings[0].active = false; caller->pc()->GetTransceivers()[0]->sender()->SetParameters(params); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); std::string offer_string; EXPECT_TRUE(offer.get()->ToString(&offer_string)); std::string simulcast_line = @@ -2037,7 +2037,7 @@ TEST_F(PeerConnectionJsepTest, RollbackDoesNotAffectSendEncodings) { TEST_F(PeerConnectionJsepTest, RollbackRestoresMidAndRemovesTransceiver) { auto callee = CreatePeerConnection(); callee->AddVideoTrack("a"); - auto offer = callee->CreateOffer(); + std::unique_ptr offer = callee->CreateOffer(); auto caller = CreatePeerConnection(); caller->AddAudioTrack("b"); caller->AddVideoTrack("c"); @@ -2136,7 +2136,7 @@ TEST_F(PeerConnectionJsepTest, RollbackHasToDestroyTransport) { pc->AddAudioTrack("a"); pc->AddVideoTrack("b"); EXPECT_TRUE(pc->CreateOfferAndSetAsLocal()); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); EXPECT_EQ(pc->pc()->GetTransceivers().size(), 2u); auto audio_transport = pc->pc()->GetTransceivers()[0]->sender()->dtls_transport(); @@ -2381,7 +2381,7 @@ TEST_F(PeerConnectionJsepTest, BundleOnlySectionDoesNotNeedRtcpMux) { auto callee = CreatePeerConnection(); caller->AddTransceiver(MediaType::AUDIO); caller->AddTransceiver(MediaType::VIDEO); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); // Remove rtcp-mux and set bundle-only on the second content. offer->description()->contents()[1].media_description()->set_rtcp_mux(false); offer->description()->contents()[1].bundle_only = true; @@ -2398,7 +2398,7 @@ TEST_F(PeerConnectionJsepTest, OfferRollbackRemoveReoffer) { caller->SetRemoteDescription(caller->CreateRollback()); RTCError error = caller->pc()->RemoveTrackOrError(sender); EXPECT_THAT(error, IsRtcOk()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); caller->SetLocalDescription(std::move(offer)); } diff --git a/pc/peer_connection_media_unittest.cc b/pc/peer_connection_media_unittest.cc index b47febc085..745076bd67 100644 --- a/pc/peer_connection_media_unittest.cc +++ b/pc/peer_connection_media_unittest.cc @@ -24,6 +24,7 @@ #include #include "absl/algorithm/container.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/environment/environment_factory.h" #include "api/jsep.h" #include "api/media_types.h" @@ -387,7 +388,8 @@ TEST_F(PeerConnectionMediaTestPlanB, SimulcastOffer) { auto caller_video_track = caller->AddVideoTrack("v"); RTCOfferAnswerOptions options; options.num_simulcast_layers = 3; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); auto* description = GetFirstMediaContent(offer->description(), MediaType::VIDEO) ->media_description(); @@ -408,13 +410,14 @@ TEST_F(PeerConnectionMediaTestPlanB, SimulcastOffer) { TEST_F(PeerConnectionMediaTestPlanB, SimulcastAnswer) { auto caller = CreatePeerConnection(); caller->AddVideoTrack("v0"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto callee = CreatePeerConnection(); auto callee_video_track = callee->AddVideoTrack("v1"); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); RTCOfferAnswerOptions options; options.num_simulcast_layers = 3; - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); auto* description = GetFirstMediaContent(answer->description(), MediaType::VIDEO) ->media_description(); @@ -551,7 +554,7 @@ TEST_P(PeerConnectionMediaTest, auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnection(); ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); const auto* audio_content = GetFirstAudioContent(answer->description()); ASSERT_TRUE(audio_content); @@ -574,7 +577,8 @@ TEST_P(PeerConnectionMediaTest, RawPacketizationNotSetInOffer) { caller_fake_engine->SetVideoCodecs(fake_codecs); auto caller = CreatePeerConnectionWithVideo(std::move(caller_fake_engine)); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); auto* offer_description = GetFirstVideoContentDescription(offer->description()); for (const auto& codec : offer_description->codecs()) { @@ -600,7 +604,8 @@ TEST_P(PeerConnectionMediaTest, RawPacketizationSetInOfferAndAnswer) { options.raw_packetization_for_video = true; auto caller = CreatePeerConnectionWithVideo(std::move(caller_fake_engine)); - auto offer = caller->CreateOfferAndSetAsLocal(options); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(options); auto* offer_description = GetFirstVideoContentDescription(offer->description()); for (const auto& codec : offer_description->codecs()) { @@ -611,7 +616,8 @@ TEST_P(PeerConnectionMediaTest, RawPacketizationSetInOfferAndAnswer) { auto callee = CreatePeerConnectionWithVideo(std::move(callee_fake_engine)); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswerAndSetAsLocal(options); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(options); auto* answer_description = GetFirstVideoContentDescription(answer->description()); for (const auto& codec : answer_description->codecs()) { @@ -644,11 +650,13 @@ TEST_P(PeerConnectionMediaTest, callee_options.raw_packetization_for_video = true; auto caller = CreatePeerConnectionWithVideo(std::move(caller_fake_engine)); - auto offer = caller->CreateOfferAndSetAsLocal(caller_options); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(caller_options); auto callee = CreatePeerConnectionWithVideo(std::move(callee_fake_engine)); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswerAndSetAsLocal(callee_options); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(callee_options); auto* answer_description = GetFirstVideoContentDescription(answer->description()); @@ -688,7 +696,8 @@ TEST_P(PeerConnectionMediaOfferDirectionTest, VerifyDirection) { RTCOfferAnswerOptions options; options.offer_to_receive_audio = offer_to_receive_; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); auto* content = GetFirstMediaContent(offer->description(), MediaType::AUDIO); if (expected_direction_ == RtpTransceiverDirection::kInactive) { @@ -744,7 +753,7 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyDirection) { caller->AddAudioTrack("a"); // Create the offer with an audio section and set its direction. - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); GetFirstAudioContentDescription(offer->description()) ->set_direction(offer_direction_); @@ -757,7 +766,8 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyDirection) { // Create the answer according to the test parameters. RTCOfferAnswerOptions options; options.offer_to_receive_audio = offer_to_receive_; - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); // The expected direction in the answer is the intersection of each side's // capability to send/recv media. @@ -794,7 +804,7 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyRejected) { caller->AddAudioTrack("a"); // Create the offer with an audio section and set its direction. - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); GetFirstAudioContentDescription(offer->description()) ->set_direction(offer_direction_); @@ -807,7 +817,8 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyRejected) { // Create the answer according to the test parameters. RTCOfferAnswerOptions options; options.offer_to_receive_audio = offer_to_receive_; - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); // The media section is rejected if and only if offer_to_receive is explicitly // set to 0 and there is no media to send. @@ -834,7 +845,8 @@ TEST_P(PeerConnectionMediaTest, OfferHasDifferentDirectionForAudioVideo) { RTCOfferAnswerOptions options; options.offer_to_receive_audio = 1; options.offer_to_receive_video = 0; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, GetMediaContentDirection(offer.get(), MediaType::AUDIO)); @@ -858,7 +870,8 @@ TEST_P(PeerConnectionMediaTest, AnswerHasDifferentDirectionsForAudioVideo) { RTCOfferAnswerOptions options; options.offer_to_receive_audio = 1; options.offer_to_receive_video = 0; - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, GetMediaContentDirection(answer.get(), MediaType::AUDIO)); @@ -919,7 +932,8 @@ TEST_P(PeerConnectionMediaTest, RTCOfferAnswerOptions options; options.voice_activity_detection = false; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_FALSE(HasAnyComfortNoiseCodecs(offer->description())); } @@ -932,7 +946,8 @@ TEST_P(PeerConnectionMediaTest, RTCOfferAnswerOptions options; options.voice_activity_detection = true; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_TRUE(HasAnyComfortNoiseCodecs(offer->description())); } @@ -950,7 +965,8 @@ TEST_P(PeerConnectionMediaTest, RTCOfferAnswerOptions options; options.voice_activity_detection = true; - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); EXPECT_FALSE(HasAnyComfortNoiseCodecs(answer->description())); } @@ -971,7 +987,8 @@ TEST_P(PeerConnectionMediaTest, RTCOfferAnswerOptions options; options.voice_activity_detection = false; - auto answer = callee->CreateAnswer(options); + std::unique_ptr answer = + callee->CreateAnswer(options); EXPECT_FALSE(HasAnyComfortNoiseCodecs(answer->description())); } @@ -1004,7 +1021,7 @@ TEST_P(PeerConnectionMediaInvalidMediaTest, FailToSetRemoteAnswer) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); mutator_(answer->description()); std::string error; @@ -1018,7 +1035,7 @@ TEST_P(PeerConnectionMediaInvalidMediaTest, FailToSetLocalAnswer) { ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); mutator_(answer->description()); std::string error; @@ -1151,12 +1168,12 @@ TEST_P(PeerConnectionMediaTest, AnswerHasSameMidsAsOffer) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); RenameContent(offer->description(), MediaType::AUDIO, kAudioMid); RenameContent(offer->description(), MediaType::VIDEO, kVideoMid); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); EXPECT_EQ(kAudioMid, GetFirstAudioContent(answer->description())->mid()); EXPECT_EQ(kVideoMid, GetFirstVideoContent(answer->description())->mid()); } @@ -1170,7 +1187,7 @@ TEST_P(PeerConnectionMediaTest, ReOfferHasSameMidsAsFirstOffer) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); RenameContent(offer->description(), MediaType::AUDIO, kAudioMid); RenameContent(offer->description(), MediaType::VIDEO, kVideoMid); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); @@ -1187,7 +1204,7 @@ TEST_P(PeerConnectionMediaTest, SetRemoteDescriptionFailsWithDuplicateMids) { auto caller = CreatePeerConnectionWithAudioVideo(); auto callee = CreatePeerConnectionWithAudioVideo(); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); RenameContent(offer->description(), MediaType::AUDIO, "same"); RenameContent(offer->description(), MediaType::VIDEO, "same"); @@ -1221,9 +1238,11 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeReassigned) { auto callee = CreatePeerConnectionWithAudio(std::move(callee_fake_engine)); // Offer from the caller establishes 100 as the "foo" payload type. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto answer_description = GetFirstAudioContentDescription(answer->description()); ASSERT_EQ(1u, answer_description->codecs().size()); @@ -1267,9 +1286,11 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeNoFmtpMatchNoFmtp) { // Offer from the caller establishes 100 as the "foo" payload type. // Red (without fmtp) is negotiated. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto answer_description = GetFirstAudioContentDescription(answer->description()); ASSERT_EQ(2u, answer_description->codecs().size()); @@ -1313,9 +1334,11 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeNoFmtpNoMatchFmtp) { // Offer from the caller establishes 100 as the "foo" payload type. // It should not negotiate RED. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto answer_description = GetFirstAudioContentDescription(answer->description()); ASSERT_EQ(1u, answer_description->codecs().size()); @@ -1365,9 +1388,11 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadTypeMustMatchBaseCodecs) { // Offer from the caller establishes 100 as the "foo" payload type. // It should not negotiate RED since RED is associated with foo, not bar. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto answer_description = GetFirstAudioContentDescription(answer->description()); ASSERT_EQ(1u, answer_description->codecs().size()); @@ -1401,9 +1426,11 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadMixed) { auto callee = CreatePeerConnectionWithAudio(std::move(callee_fake_engine)); // Offer from the caller establishes 100 as the "foo" payload type. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto answer_description = GetFirstAudioContentDescription(answer->description()); // RED is not negotiated. @@ -1436,9 +1463,11 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadDifferentRedundancy) { auto callee = CreatePeerConnectionWithAudio(std::move(callee_fake_engine)); // Offer from the caller establishes 100 as the "foo" payload type. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto answer_description = GetFirstAudioContentDescription(answer->description()); // RED is negotiated. @@ -1571,7 +1600,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllAudioCodecs) { // Normal case, set all capabilities as preferences EXPECT_TRUE(audio_transceiver->SetCodecPreferences(sender_audio_codecs).ok()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); EXPECT_TRUE(CompareCodecs(sender_audio_codecs, codecs)); @@ -1589,7 +1618,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, // Normal case, reset codec preferences EXPECT_TRUE(audio_transceiver->SetCodecPreferences(empty_codecs).ok()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); EXPECT_TRUE(CompareCodecs(sender_audio_codecs, codecs)); @@ -1649,7 +1678,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllVideoCodecs) { // Normal case, setting preferences to normal capabilities EXPECT_TRUE(video_transceiver->SetCodecPreferences(sender_video_codecs).ok()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); EXPECT_TRUE(CompareCodecs(sender_video_codecs, codecs)); @@ -1668,7 +1697,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, // Normal case, resetting preferences with empty list of codecs EXPECT_TRUE(video_transceiver->SetCodecPreferences(empty_codecs).ok()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); EXPECT_TRUE(CompareCodecs(sender_video_codecs, codecs)); @@ -1692,7 +1721,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, duplicate_codec.push_back(duplicate_codec.front()); EXPECT_TRUE(video_transceiver->SetCodecPreferences(duplicate_codec).ok()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); EXPECT_TRUE(CompareCodecs(single_codec, codecs)); @@ -1731,7 +1760,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesVideoWithRtx) { EXPECT_EQ(video_codecs_vpx_rtx.size(), 3u); // VP8, VP9, RTX EXPECT_TRUE( video_transceiver->SetCodecPreferences(video_codecs_vpx_rtx).ok()); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); @@ -1774,7 +1803,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, EXPECT_EQ(video_codecs_vpx.size(), 2u); // VP8, VP9 EXPECT_TRUE(send_transceiver->SetCodecPreferences(video_codecs_vpx).ok()); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); @@ -1795,7 +1825,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, EXPECT_EQ(video_codecs_vp8_rtx.size(), 2u); // VP8, RTX recv_transceiver->SetCodecPreferences(video_codecs_vp8_rtx); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto recv_codecs = answer->description()->contents()[0].media_description()->codecs(); @@ -1840,7 +1871,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto video_codecs_vpx_reverse = video_codecs_vpx; absl::c_reverse(video_codecs_vpx_reverse); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); auto codecs = offer->description()->contents()[0].media_description()->codecs(); EXPECT_EQ(codecs.size(), 2u); // VP9, VP8 @@ -1851,7 +1883,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto recv_transceiver = callee->pc()->GetTransceivers().front(); recv_transceiver->SetCodecPreferences(video_codecs_vpx_reverse); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); auto recv_codecs = answer->description()->contents()[0].media_description()->codecs(); @@ -1866,7 +1899,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, auto caller = CreatePeerConnectionWithAudio(std::move(fake_engine)); RTCOfferAnswerOptions options; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_TRUE(HasAnyComfortNoiseCodecs(offer->description())); auto transceiver = caller->pc()->GetTransceivers().front(); @@ -1913,7 +1947,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, EXPECT_TRUE(video_transceiver->SetCodecPreferences(capabilities.codecs).ok()); RTCOfferAnswerOptions options; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); EXPECT_FALSE(HasPayloadTypeConflict(offer->description())); // Sanity check that we got the primary codec and RTX. EXPECT_EQ( @@ -1958,7 +1993,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, caller->pc_factory()->GetRtpSenderCapabilities(MediaType::VIDEO); EXPECT_TRUE(video_transceiver->SetCodecPreferences(capabilities.codecs).ok()); - auto answer = caller->CreateAnswer(options); + std::unique_ptr answer = + caller->CreateAnswer(options); EXPECT_FALSE(HasPayloadTypeConflict(answer->description())); // Sanity check that we got the primary codec and RTX. @@ -2077,7 +2113,8 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesVideoNoRtx) { EXPECT_TRUE(video_transceiver->SetCodecPreferences(capabilities.codecs).ok()); RTCOfferAnswerOptions options; - auto offer = caller->CreateOffer(options); + std::unique_ptr offer = + caller->CreateOffer(options); const auto& content = offer->description()->contents()[0]; auto& codecs = content.media_description()->codecs(); ASSERT_EQ(codecs.size(), 2u); diff --git a/pc/peer_connection_message_handler.h b/pc/peer_connection_message_handler.h index b9498e85e8..652d69754f 100644 --- a/pc/peer_connection_message_handler.h +++ b/pc/peer_connection_message_handler.h @@ -14,13 +14,13 @@ #include #include "api/jsep.h" -#include "api/legacy_stats_types.h" #include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" #include "api/rtc_error.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "pc/legacy_stats_collector_interface.h" +#include "rtc_base/thread.h" namespace webrtc { diff --git a/pc/peer_connection_proxy.h b/pc/peer_connection_proxy.h index e84c487187..330005bc62 100644 --- a/pc/peer_connection_proxy.h +++ b/pc/peer_connection_proxy.h @@ -158,7 +158,11 @@ PROXY_METHOD2(void, AddIceCandidate, std::unique_ptr, std::function) +PROXY_METHOD1(bool, RemoveIceCandidate, const IceCandidate*) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" PROXY_METHOD1(bool, RemoveIceCandidates, const std::vector&) +#pragma clang diagnostic pop PROXY_METHOD1(RTCError, SetBitrate, const BitrateSettings&) PROXY_METHOD1(void, ReconfigureBandwidthEstimation, diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc index ecf672dff6..ee7e50f2d4 100644 --- a/pc/peer_connection_rampup_tests.cc +++ b/pc/peer_connection_rampup_tests.cc @@ -15,6 +15,7 @@ #include #include "api/audio_options.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/jsep.h" #include "api/make_ref_counted.h" diff --git a/pc/peer_connection_rtp_unittest.cc b/pc/peer_connection_rtp_unittest.cc index a07bfc4c32..41f630d3ea 100644 --- a/pc/peer_connection_rtp_unittest.cc +++ b/pc/peer_connection_rtp_unittest.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include @@ -181,13 +180,14 @@ class PeerConnectionRtpTestUnifiedPlan : public PeerConnectionRtpBaseTest { PeerConnectionWrapper* caller, PeerConnectionWrapper* callee, size_t mid_to_stop) { - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); caller->SetLocalDescription(CloneSessionDescription(offer.get())); callee->SetRemoteDescription(std::move(offer)); EXPECT_LT(mid_to_stop, callee->pc()->GetTransceivers().size()); // Must use StopInternal in order to do instant reject. callee->pc()->GetTransceivers()[mid_to_stop]->StopInternal(); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = + callee->CreateAnswer(); EXPECT_TRUE(answer); bool set_local_answer = callee->SetLocalDescription(CloneSessionDescription(answer.get())); @@ -321,7 +321,8 @@ TEST_F(PeerConnectionRtpTestPlanB, EXPECT_EQ(callee->observer()->add_track_events_.size(), 1u); // Change the stream ID of the sender in the session description. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); auto* audio_desc = GetFirstAudioContentDescription(offer->description()); ASSERT_EQ(audio_desc->mutable_streams().size(), 1u); audio_desc->mutable_streams()[0].set_stream_ids({kStreamId2}); @@ -772,7 +773,8 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, UnsignaledSsrcCreatesReceiverStreams) { caller->AddTrack(caller->CreateAudioTrack("audio_track1"), {kStreamId1, kStreamId2}); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); // Munge the offer to take out everything but the stream_ids. auto contents = offer->description()->contents(); ASSERT_TRUE(!contents.empty()); @@ -819,7 +821,7 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, TracksDoNotEndWhenSsrcChanges) { // Do a follow-up offer/answer exchange where the SSRCs are modified. ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); auto& contents = answer->description()->contents(); ASSERT_TRUE(!contents.empty()); for (size_t i = 0; i < contents.size(); ++i) { @@ -863,7 +865,8 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, EXPECT_EQ(callee->observer()->add_track_events_.size(), 1u); // Change the stream id of the sender in the session description. - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); auto contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); ASSERT_EQ(contents[0].media_description()->mutable_streams().size(), 1u); @@ -895,7 +898,8 @@ TEST_F(PeerConnectionRtpTestPlanB, caller->AddAudioTrack("audio_track1", {kStreamId1}); caller->AddAudioTrack("audio_track2", {kStreamId2}); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); auto mutable_streams = GetFirstAudioContentDescription(offer->description())->mutable_streams(); ASSERT_EQ(mutable_streams.size(), 2u); @@ -936,7 +940,8 @@ TEST_P(PeerConnectionRtpTest, scoped_refptr observer = make_ref_counted(); - auto offer = caller->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); callee->pc()->SetRemoteDescription(observer.get(), offer.release()); callee = nullptr; Thread::Current()->ProcessMessages(0); @@ -1912,7 +1917,7 @@ TEST_F(PeerConnectionMsidSignalingTest, PureUnifiedPlanToUs) { auto callee = CreatePeerConnectionWithUnifiedPlan(); callee->AddAudioTrack("callee_audio"); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); // Simulate a pure Unified Plan offerer by setting the MSID signaling to media // section only. offer->description()->set_msid_signaling(kMsidSignalingSemantic | @@ -1923,7 +1928,7 @@ TEST_F(PeerConnectionMsidSignalingTest, PureUnifiedPlanToUs) { ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); // Answer should have only a=msid to match the offer. - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); EXPECT_EQ(kMsidSignalingSemantic | kMsidSignalingMediaSection, answer->description()->msid_signaling()); } diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc index 2412660fb3..571d224aaa 100644 --- a/pc/peer_connection_signaling_unittest.cc +++ b/pc/peer_connection_signaling_unittest.cc @@ -82,7 +82,7 @@ using ::testing::StartsWith; using ::testing::Values; namespace { -const int64_t kWaitTimeout = 10000; +constexpr int64_t kWaitTimeout = 10000; } // namespace class PeerConnectionWrapperForSignalingTest : public PeerConnectionWrapper { @@ -289,7 +289,8 @@ class PeerConnectionSignalingStateTest case SignalingState::kHaveLocalPrAnswer: { auto caller = CreatePeerConnectionWithAudioVideo(GetConfig()); wrapper->SetRemoteDescription(caller->CreateOffer()); - auto answer = wrapper->CreateAnswer(); + std::unique_ptr answer = + wrapper->CreateAnswer(); wrapper->SetLocalDescription( CloneSessionDescriptionAsType(answer.get(), SdpType::kPrAnswer)); break; @@ -302,7 +303,8 @@ class PeerConnectionSignalingStateTest case SignalingState::kHaveRemotePrAnswer: { auto callee = CreatePeerConnectionWithAudioVideo(GetConfig()); callee->SetRemoteDescription(wrapper->CreateOfferAndSetAsLocal()); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = + callee->CreateAnswer(); wrapper->SetRemoteDescription( CloneSessionDescriptionAsType(answer.get(), SdpType::kPrAnswer)); break; @@ -365,7 +367,7 @@ TEST_P(PeerConnectionSignalingStateTest, SetLocalOffer) { } else { auto wrapper_for_offer = CreatePeerConnectionInState(SignalingState::kHaveLocalOffer); - auto offer = + std::unique_ptr offer = CloneSessionDescription(wrapper_for_offer->pc()->local_description()); std::string error; @@ -398,7 +400,8 @@ TEST_P(PeerConnectionSignalingStateTest, SetLocalPrAnswer) { TEST_P(PeerConnectionSignalingStateTest, SetLocalAnswer) { auto wrapper_for_answer = CreatePeerConnectionInState(SignalingState::kHaveRemoteOffer); - auto answer = wrapper_for_answer->CreateAnswer(); + std::unique_ptr answer = + wrapper_for_answer->CreateAnswer(); auto wrapper = CreatePeerConnectionUnderTest(); if (wrapper->signaling_state() == SignalingState::kHaveLocalPrAnswer || @@ -416,7 +419,7 @@ TEST_P(PeerConnectionSignalingStateTest, SetLocalAnswer) { TEST_P(PeerConnectionSignalingStateTest, SetRemoteOffer) { auto wrapper_for_offer = CreatePeerConnectionInState(SignalingState::kHaveRemoteOffer); - auto offer = + std::unique_ptr offer = CloneSessionDescription(wrapper_for_offer->pc()->remote_description()); auto wrapper = CreatePeerConnectionUnderTest(); @@ -455,7 +458,8 @@ TEST_P(PeerConnectionSignalingStateTest, SetRemotePrAnswer) { TEST_P(PeerConnectionSignalingStateTest, SetRemoteAnswer) { auto wrapper_for_answer = CreatePeerConnectionInState(SignalingState::kHaveRemoteOffer); - auto answer = wrapper_for_answer->CreateAnswer(); + std::unique_ptr answer = + wrapper_for_answer->CreateAnswer(); auto wrapper = CreatePeerConnectionUnderTest(); if (wrapper->signaling_state() == SignalingState::kHaveLocalOffer || @@ -674,7 +678,8 @@ TEST_P(PeerConnectionSignalingTest, CloseAfterImplicitCreateOfferAndShutdown) { TEST_P(PeerConnectionSignalingTest, SetLocalDescriptionNewObserverIsInvokedImmediately) { auto caller = CreatePeerConnection(); - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); auto observer = make_ref_counted(); caller->pc()->SetLocalDescription(std::move(offer), observer); @@ -686,7 +691,8 @@ TEST_P(PeerConnectionSignalingTest, TEST_P(PeerConnectionSignalingTest, SetLocalDescriptionOldObserverIsInvokedInAPostedMessage) { auto caller = CreatePeerConnection(); - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); auto observer = MockSetSessionDescriptionObserver::Create(); caller->pc()->SetLocalDescription(observer.get(), offer.release()); @@ -708,7 +714,8 @@ TEST_P(PeerConnectionSignalingTest, SetRemoteDescriptionExecutesImmediately) { auto callee = CreatePeerConnection(); // This offer will cause receivers to be created. - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); // By not waiting for the observer's callback we can verify that the operation // executed immediately. @@ -722,7 +729,8 @@ TEST_P(PeerConnectionSignalingTest, CreateOfferBlocksSetRemoteDescription) { auto callee = CreatePeerConnection(); // This offer will cause receivers to be created. - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); EXPECT_EQ(0u, callee->pc()->GetReceivers().size()); auto offer_observer = @@ -919,7 +927,7 @@ TEST_P(PeerConnectionSignalingTest, UnsupportedContentType) { EXPECT_TRUE(caller->SetRemoteDescription(std::move(remote_description))); // Assert we respond back with something meaningful. - auto answer = caller->CreateAnswer(); + std::unique_ptr answer = caller->CreateAnswer(); ASSERT_EQ(answer->description()->contents().size(), 1u); EXPECT_NE(answer->description() ->contents()[0] @@ -943,7 +951,7 @@ TEST_P(PeerConnectionSignalingTest, UnsupportedContentType) { EXPECT_TRUE(caller->SetLocalDescription(std::move(answer))); // Assert we keep this in susequent offers. - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); EXPECT_EQ(offer->description() ->contents()[0] .media_description() @@ -999,7 +1007,7 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFec) { EXPECT_TRUE(caller->SetRemoteDescription(std::move(remote_description))); - auto answer = caller->CreateAnswer(); + std::unique_ptr answer = caller->CreateAnswer(); ASSERT_EQ(answer->description()->contents().size(), 1u); ASSERT_NE(answer->description()->contents()[0].media_description(), nullptr); auto codecs = @@ -1050,7 +1058,7 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFecReoffer) { EXPECT_TRUE(caller->SetRemoteDescription(std::move(remote_description))); - auto answer = caller->CreateAnswer(); + std::unique_ptr answer = caller->CreateAnswer(); ASSERT_EQ(answer->description()->contents().size(), 1u); ASSERT_NE(answer->description()->contents()[0].media_description(), nullptr); auto codecs = @@ -1062,7 +1070,8 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFecReoffer) { EXPECT_TRUE(caller->SetLocalDescription(std::move(answer))); // This generates a collision for AV1 which needs to be remapped. - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); auto offer_codecs = offer->description()->contents()[0].media_description()->codecs(); auto flexfec_it = std::find_if( @@ -1135,7 +1144,8 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, auto caller = CreatePeerConnectionWithAudioVideo(); // This offer will cause transceiver mids to get assigned. - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); // By not waiting for the observer's callback we can verify that the operation // executed immediately. The old observer is invoked in a posted message, so @@ -1152,7 +1162,8 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, auto caller = CreatePeerConnectionWithAudioVideo(); // This offer will cause transceiver mids to get assigned. - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); // Verify that mids were assigned without waiting for the observer. (However, // the new observer should also be invoked synchronously - as is ensured by @@ -1168,7 +1179,8 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, auto caller = CreatePeerConnectionWithAudioVideo(); // This offer will cause transceiver mids to get assigned. - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); auto offer_observer = make_ref_counted( @@ -1197,12 +1209,14 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, EXPECT_FALSE(HasDtlsTransport(caller)); EXPECT_FALSE(HasDtlsTransport(callee)); - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); caller->SetLocalDescription(CloneSessionDescription(offer.get())); EXPECT_TRUE(HasDtlsTransport(caller)); callee->SetRemoteDescription(std::move(offer)); EXPECT_FALSE(HasDtlsTransport(callee)); - auto answer = callee->CreateAnswer(RTCOfferAnswerOptions()); + std::unique_ptr answer = + callee->CreateAnswer(RTCOfferAnswerOptions()); callee->SetLocalDescription(CloneSessionDescription(answer.get())); EXPECT_TRUE(HasDtlsTransport(callee)); caller->SetRemoteDescription(std::move(answer)); @@ -1217,11 +1231,13 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, DtlsTransportsMergeWhenBundled) { EXPECT_FALSE(HasDtlsTransport(caller)); EXPECT_FALSE(HasDtlsTransport(callee)); - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); caller->SetLocalDescription(CloneSessionDescription(offer.get())); EXPECT_EQ(2, NumberOfDtlsTransports(caller)); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswer(RTCOfferAnswerOptions()); + std::unique_ptr answer = + callee->CreateAnswer(RTCOfferAnswerOptions()); callee->SetLocalDescription(CloneSessionDescription(answer.get())); caller->SetRemoteDescription(std::move(answer)); EXPECT_EQ(1, NumberOfDtlsTransports(caller)); @@ -1238,11 +1254,13 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, EXPECT_FALSE(HasDtlsTransport(callee)); RTCOfferAnswerOptions unbundle_options; unbundle_options.use_rtp_mux = false; - auto offer = caller->CreateOffer(unbundle_options); + std::unique_ptr offer = + caller->CreateOffer(unbundle_options); caller->SetLocalDescription(CloneSessionDescription(offer.get())); EXPECT_EQ(2, NumberOfDtlsTransports(caller)); callee->SetRemoteDescription(std::move(offer)); - auto answer = callee->CreateAnswer(RTCOfferAnswerOptions()); + std::unique_ptr answer = + callee->CreateAnswer(RTCOfferAnswerOptions()); callee->SetLocalDescription(CloneSessionDescription(answer.get())); EXPECT_EQ(2, NumberOfDtlsTransports(callee)); caller->SetRemoteDescription(std::move(answer)); @@ -1294,7 +1312,8 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, SuppressNegotiationNeededWhenSignalingStateIsNotStable) { auto caller = CreatePeerConnection(); auto callee = CreatePeerConnection(); - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); EXPECT_FALSE(caller->observer()->has_negotiation_needed_event()); auto transceiver = @@ -1351,7 +1370,8 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, RtxReofferApt) { EXPECT_TRUE(callee->SetRemoteDescription(std::move(remote_description))); - auto answer = callee->CreateAnswer(RTCOfferAnswerOptions()); + std::unique_ptr answer = + callee->CreateAnswer(RTCOfferAnswerOptions()); EXPECT_TRUE( callee->SetLocalDescription(CloneSessionDescription(answer.get()))); @@ -1377,13 +1397,15 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, LoopbackSdpIsPossible) { auto transceiver = caller->AddTransceiver(MediaType::AUDIO, RtpTransceiverInit()); - auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); + std::unique_ptr offer = + caller->CreateOffer(RTCOfferAnswerOptions()); std::string offer_sdp; ASSERT_TRUE(offer->ToString(&offer_sdp)); std::string answer_sdp = absl::StrReplaceAll(offer_sdp, {{"a=setup:actpass", "a=setup:active"}}); EXPECT_TRUE(caller->SetLocalDescription(std::move(offer))); - auto answer = CreateSessionDescription(SdpType::kAnswer, answer_sdp); + std::unique_ptr answer = + CreateSessionDescription(SdpType::kAnswer, answer_sdp); EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); } diff --git a/pc/peer_connection_simulcast_unittest.cc b/pc/peer_connection_simulcast_unittest.cc index 802cc41740..2cd0df043b 100644 --- a/pc/peer_connection_simulcast_unittest.cc +++ b/pc/peer_connection_simulcast_unittest.cc @@ -53,6 +53,8 @@ #include "test/gmock.h" #include "test/gtest.h" +namespace webrtc { + using ::testing::Contains; using ::testing::Each; using ::testing::ElementsAre; @@ -62,19 +64,12 @@ using ::testing::Field; using ::testing::IsEmpty; using ::testing::Le; using ::testing::Ne; +using ::testing::NotNull; using ::testing::Pair; using ::testing::Property; using ::testing::SizeIs; using ::testing::StartsWith; -using webrtc::MediaContentDescription; -using ::webrtc::RidDescription; -using ::webrtc::SimulcastDescription; -using ::webrtc::SimulcastLayer; -using ::webrtc::StreamParams; - -namespace webrtc { - class PeerConnectionSimulcastTests : public ::testing::Test { public: PeerConnectionSimulcastTests() @@ -120,12 +115,14 @@ class PeerConnectionSimulcastTests : public ::testing::Test { void ExchangeOfferAnswer(PeerConnectionWrapper* local, PeerConnectionWrapper* remote, const std::vector& answer_layers) { - auto offer = local->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + local->CreateOfferAndSetAsLocal(); // Remove simulcast as the second peer connection won't support it. RemoveSimulcast(offer.get()); std::string err; EXPECT_TRUE(remote->SetRemoteDescription(std::move(offer), &err)) << err; - auto answer = remote->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + remote->CreateAnswerAndSetAsLocal(); // Setup the answer to look like a server response. auto mcd_answer = answer->description()->contents()[0].media_description(); auto& receive_layers = mcd_answer->simulcast_description().receive_layers(); @@ -230,8 +227,9 @@ TEST_F(PeerConnectionSimulcastTests, ChecksForIllegalRidValues) { TEST_F(PeerConnectionSimulcastTests, SingleRidIsRemovedFromSessionDescription) { auto pc = CreatePeerConnectionWrapper(); auto transceiver = AddTransceiver(pc.get(), CreateLayers({"1"}, true)); - auto offer = pc->CreateOfferAndSetAsLocal(); - ASSERT_TRUE(offer); + std::unique_ptr offer = + pc->CreateOfferAndSetAsLocal(); + ASSERT_THAT(offer, NotNull()); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); EXPECT_THAT(contents[0].media_description()->streams(), @@ -257,8 +255,8 @@ TEST_F(PeerConnectionSimulcastTests, SimulcastAppearsInSessionDescription) { std::vector rids({"f", "h", "q"}); auto layers = CreateLayers(rids, true); auto transceiver = AddTransceiver(pc.get(), layers); - auto offer = pc->CreateOffer(); - ASSERT_TRUE(offer); + std::unique_ptr offer = pc->CreateOffer(); + ASSERT_THAT(offer, NotNull()); auto contents = offer->description()->contents(); ASSERT_EQ(1u, contents.size()); auto content = contents[0]; @@ -287,7 +285,8 @@ TEST_F(PeerConnectionSimulcastTests, SimulcastLayersAreSetInSender) { auto remote = CreatePeerConnectionWrapper(); auto layers = CreateLayers({"f", "h", "q"}, true); auto transceiver = AddTransceiver(local.get(), layers); - auto offer = local->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + local->CreateOfferAndSetAsLocal(); { SCOPED_TRACE("after create offer"); ValidateTransceiverParameters(transceiver, layers); @@ -296,7 +295,8 @@ TEST_F(PeerConnectionSimulcastTests, SimulcastLayersAreSetInSender) { auto simulcast = RemoveSimulcast(offer.get()); std::string error; EXPECT_TRUE(remote->SetRemoteDescription(std::move(offer), &error)) << error; - auto answer = remote->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + remote->CreateAnswerAndSetAsLocal(); // Setup an answer that mimics a server accepting simulcast. auto mcd_answer = answer->description()->contents()[0].media_description(); @@ -321,7 +321,8 @@ TEST_F(PeerConnectionSimulcastTests, PausedSimulcastLayersAreDisabledInSender) { auto server_layers = CreateLayers({"f", "h", "q"}, {true, false, false}); RTC_DCHECK_EQ(layers.size(), server_layers.size()); auto transceiver = AddTransceiver(local.get(), layers); - auto offer = local->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + local->CreateOfferAndSetAsLocal(); { SCOPED_TRACE("after create offer"); ValidateTransceiverParameters(transceiver, layers); @@ -331,7 +332,8 @@ TEST_F(PeerConnectionSimulcastTests, PausedSimulcastLayersAreDisabledInSender) { RemoveSimulcast(offer.get()); std::string error; EXPECT_TRUE(remote->SetRemoteDescription(std::move(offer), &error)) << error; - auto answer = remote->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + remote->CreateAnswerAndSetAsLocal(); // Setup an answer that mimics a server accepting simulcast. auto mcd_answer = answer->description()->contents()[0].media_description(); @@ -369,7 +371,8 @@ TEST_F(PeerConnectionSimulcastTests, RejectedSimulcastLayersAreDeactivated) { auto layers = CreateLayers({"1", "2", "3"}, true); auto expected_layers = CreateLayers({"2", "3"}, true); auto transceiver = AddTransceiver(local.get(), layers); - auto offer = local->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + local->CreateOfferAndSetAsLocal(); { SCOPED_TRACE("after create offer"); ValidateTransceiverParameters(transceiver, layers); @@ -378,7 +381,8 @@ TEST_F(PeerConnectionSimulcastTests, RejectedSimulcastLayersAreDeactivated) { auto removed_simulcast = RemoveSimulcast(offer.get()); std::string error; EXPECT_TRUE(remote->SetRemoteDescription(std::move(offer), &error)) << error; - auto answer = remote->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + remote->CreateAnswerAndSetAsLocal(); auto mcd_answer = answer->description()->contents()[0].media_description(); // Setup the answer to look like a server response. // Remove one of the layers to reject it in the answer. @@ -403,7 +407,8 @@ TEST_F(PeerConnectionSimulcastTests, ServerSendsOfferToReceiveSimulcast) { auto remote = CreatePeerConnectionWrapper(); auto layers = CreateLayers({"f", "h", "q"}, true); AddTransceiver(local.get(), layers); - auto offer = local->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + local->CreateOfferAndSetAsLocal(); // Remove simulcast as a sender and set it up as a receiver. RemoveSimulcast(offer.get()); AddRequestToReceiveSimulcast(layers, offer.get()); @@ -422,7 +427,8 @@ TEST_F(PeerConnectionSimulcastTests, TransceiverIsNotRecycledWithSimulcast) { auto remote = CreatePeerConnectionWrapper(); auto layers = CreateLayers({"f", "h", "q"}, true); AddTransceiver(local.get(), layers); - auto offer = local->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + local->CreateOfferAndSetAsLocal(); // Remove simulcast as a sender and set it up as a receiver. RemoveSimulcast(offer.get()); AddRequestToReceiveSimulcast(layers, offer.get()); @@ -483,12 +489,14 @@ TEST_F(PeerConnectionSimulcastTests, NegotiationDoesNotHaveRidExtensionFails) { auto layers = CreateLayers({"1", "2", "3"}, true); auto expected_layers = CreateLayers({"1"}, true); auto transceiver = AddTransceiver(local.get(), layers); - auto offer = local->CreateOfferAndSetAsLocal(); + std::unique_ptr offer = + local->CreateOfferAndSetAsLocal(); // Remove simulcast as the second peer connection won't support it. RemoveSimulcast(offer.get()); std::string err; EXPECT_TRUE(remote->SetRemoteDescription(std::move(offer), &err)) << err; - auto answer = remote->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + remote->CreateAnswerAndSetAsLocal(); // Setup the answer to look like a server response. // Drop the RID header extension. auto mcd_answer = answer->description()->contents()[0].media_description(); @@ -535,7 +543,7 @@ TEST_F(PeerConnectionSimulcastTests, SimulcastSldModificationRejected) { auto remote = CreatePeerConnectionWrapper(); auto layers = CreateLayers({"1", "2", "3"}, true); AddTransceiver(local.get(), layers); - auto offer = local->CreateOffer(); + std::unique_ptr offer = local->CreateOffer(); std::string as_string; EXPECT_TRUE(offer->ToString(&as_string)); auto simulcast_marker = "a=rid:3 send\r\na=simulcast:send 1;2;3\r\n"; diff --git a/pc/peer_connection_stability_integrationtest.cc b/pc/peer_connection_stability_integrationtest.cc index 61c6ba0ac4..8d3052215b 100644 --- a/pc/peer_connection_stability_integrationtest.cc +++ b/pc/peer_connection_stability_integrationtest.cc @@ -14,8 +14,6 @@ // The error messages when the tests fail are intended to contain C++ code // that can be pasted into the test when updating it. -#include - #include #include #include diff --git a/pc/peer_connection_svc_integrationtest.cc b/pc/peer_connection_svc_integrationtest.cc index 9e61012710..3fae4e8040 100644 --- a/pc/peer_connection_svc_integrationtest.cc +++ b/pc/peer_connection_svc_integrationtest.cc @@ -11,8 +11,6 @@ // Integration tests for PeerConnection. // These tests exercise a full stack for the SVC extension. -#include - #include #include diff --git a/pc/peer_connection_wrapper.cc b/pc/peer_connection_wrapper.cc index d95538b733..35fa45a789 100644 --- a/pc/peer_connection_wrapper.cc +++ b/pc/peer_connection_wrapper.cc @@ -10,8 +10,6 @@ #include "pc/peer_connection_wrapper.h" -#include - #include #include #include @@ -108,7 +106,7 @@ PeerConnectionWrapper::CreateOfferAndSetAsLocal() { std::unique_ptr PeerConnectionWrapper::CreateOfferAndSetAsLocal( const PeerConnectionInterface::RTCOfferAnswerOptions& options) { - auto offer = CreateOffer(options); + std::unique_ptr offer = CreateOffer(options); if (!offer) { return nullptr; } @@ -140,7 +138,7 @@ PeerConnectionWrapper::CreateAnswerAndSetAsLocal() { std::unique_ptr PeerConnectionWrapper::CreateAnswerAndSetAsLocal( const PeerConnectionInterface::RTCOfferAnswerOptions& options) { - auto answer = CreateAnswer(options); + std::unique_ptr answer = CreateAnswer(options); if (!answer) { return nullptr; } @@ -244,7 +242,8 @@ bool PeerConnectionWrapper::ExchangeOfferAnswerWith( RTC_LOG(LS_ERROR) << "Cannot exchange offer/answer with ourself!"; return false; } - auto offer = CreateOffer(offer_options); + std::unique_ptr offer = + CreateOffer(offer_options); EXPECT_TRUE(offer); if (!offer) { return false; @@ -260,7 +259,8 @@ bool PeerConnectionWrapper::ExchangeOfferAnswerWith( if (!set_remote_offer) { return false; } - auto answer = answerer->CreateAnswer(answer_options); + std::unique_ptr answer = + answerer->CreateAnswer(answer_options); EXPECT_TRUE(answer); if (!answer) { return false; diff --git a/pc/proxy.h b/pc/proxy.h index fbc66343ea..7adcdd9781 100644 --- a/pc/proxy.h +++ b/pc/proxy.h @@ -56,20 +56,13 @@ #ifndef PC_PROXY_H_ #define PC_PROXY_H_ -#include - -#include -#include +#include +#include // IWYU pragma: keep #include -#include #include -#include "api/make_ref_counted.h" -#include "api/scoped_refptr.h" -#include "api/task_queue/task_queue_base.h" #include "rtc_base/event.h" -#include "rtc_base/string_utils.h" -#include "rtc_base/system/rtc_export.h" +#include "rtc_base/string_utils.h" // IWYU pragma: keep #include "rtc_base/thread.h" #include "rtc_base/trace_event.h" diff --git a/pc/remote_audio_source.cc b/pc/remote_audio_source.cc index 706c7f410f..82eb9ae727 100644 --- a/pc/remote_audio_source.cc +++ b/pc/remote_audio_source.cc @@ -10,8 +10,7 @@ #include "pc/remote_audio_source.h" -#include - +#include #include #include #include diff --git a/pc/remote_audio_source.h b/pc/remote_audio_source.h index 7b54dca464..a18c31cd2a 100644 --- a/pc/remote_audio_source.h +++ b/pc/remote_audio_source.h @@ -15,7 +15,6 @@ #include #include -#include #include "api/call/audio_sink.h" #include "api/media_stream_interface.h" diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 3be877c5a5..021baae6d3 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -10,11 +10,9 @@ #include "pc/rtc_stats_collector.h" -#include -#include - #include #include +#include #include #include #include @@ -86,8 +84,8 @@ namespace webrtc { namespace { -const char kDirectionInbound = 'I'; -const char kDirectionOutbound = 'O'; +constexpr char kDirectionInbound = 'I'; +constexpr char kDirectionOutbound = 'O'; constexpr char kAudioPlayoutSingletonId[] = "AP"; @@ -1431,11 +1429,11 @@ void RTCStatsCollector::ProduceCertificateStats_n( for (const auto& transport_cert_stats_pair : transport_cert_stats) { if (transport_cert_stats_pair.second.local) { ProduceCertificateStatsFromSSLCertificateStats( - timestamp, *transport_cert_stats_pair.second.local.get(), report); + timestamp, *transport_cert_stats_pair.second.local, report); } if (transport_cert_stats_pair.second.remote) { ProduceCertificateStatsFromSSLCertificateStats( - timestamp, *transport_cert_stats_pair.second.remote.get(), report); + timestamp, *transport_cert_stats_pair.second.remote, report); } } } @@ -1624,7 +1622,7 @@ void RTCStatsCollector::ProduceMediaSourceStats_s( // Audio processor may be attached to either the track or the send // stream, so look in both places. auto audio_processor(audio_track->GetAudioProcessor()); - if (audio_processor.get()) { + if (audio_processor) { // The `has_remote_tracks` argument is obsolete; makes no difference // if it's set to true or false. AudioProcessorInterface::AudioProcessorStatistics ap_stats = @@ -1972,8 +1970,11 @@ void RTCStatsCollector::ProduceTransportStats_n( channel_stats.ice_transport_stats.selected_candidate_pair_changes; channel_transport_stats->ice_role = IceRoleToRTCIceRole(channel_stats.ice_transport_stats.ice_role); - channel_transport_stats->ice_local_username_fragment = - channel_stats.ice_transport_stats.ice_local_username_fragment; + if (!channel_stats.ice_transport_stats.ice_local_username_fragment + .empty()) { + channel_transport_stats->ice_local_username_fragment = + channel_stats.ice_transport_stats.ice_local_username_fragment; + } channel_transport_stats->ice_state = IceTransportStateToRTCIceTransportState( channel_stats.ice_transport_stats.ice_state); diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index f3f2a92e8a..8686354d73 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -10,9 +10,8 @@ #include "pc/rtc_stats_collector.h" -#include -#include - +#include +#include #include #include #include @@ -105,7 +104,7 @@ namespace webrtc { namespace { -const int64_t kGetStatsReportTimeoutMs = 1000; +constexpr int64_t kGetStatsReportTimeoutMs = 1000; // Fake data used by `SetupExampleStatsVoiceGraph()` to fill in remote outbound // stats. diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 2e3b69dc5f..f2e92dd160 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include diff --git a/pc/rtcp_mux_filter.h b/pc/rtcp_mux_filter.h index 29838fc0f5..2066c70bf9 100644 --- a/pc/rtcp_mux_filter.h +++ b/pc/rtcp_mux_filter.h @@ -75,12 +75,5 @@ class RtcpMuxFilter { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::RtcpMuxFilter; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_RTCP_MUX_FILTER_H_ diff --git a/pc/rtp_parameters_conversion.h b/pc/rtp_parameters_conversion.h index e32bc2e03c..2b8311785c 100644 --- a/pc/rtp_parameters_conversion.h +++ b/pc/rtp_parameters_conversion.h @@ -14,10 +14,8 @@ #include #include -#include "api/rtc_error.h" #include "api/rtp_parameters.h" #include "media/base/codec.h" -#include "media/base/stream_params.h" #include "pc/session_description.h" namespace webrtc { diff --git a/pc/rtp_receiver.cc b/pc/rtp_receiver.cc index e09c89301c..31a20df17a 100644 --- a/pc/rtp_receiver.cc +++ b/pc/rtp_receiver.cc @@ -10,9 +10,8 @@ #include "pc/rtp_receiver.h" -#include - #include +#include #include #include #include diff --git a/pc/rtp_sender.h b/pc/rtp_sender.h index ef7310ff5e..09c2b7a30d 100644 --- a/pc/rtp_sender.h +++ b/pc/rtp_sender.h @@ -27,7 +27,6 @@ #include "api/dtls_transport_interface.h" #include "api/dtmf_sender_interface.h" #include "api/environment/environment.h" -#include "api/field_trials_view.h" #include "api/frame_transformer_interface.h" #include "api/media_stream_interface.h" #include "api/media_types.h" @@ -36,11 +35,12 @@ #include "api/rtp_sender_interface.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" +#include "api/video_codecs/video_encoder_factory.h" #include "media/base/audio_source.h" +#include "media/base/codec.h" #include "media/base/media_channel.h" #include "pc/dtmf_sender.h" #include "pc/legacy_stats_collector_interface.h" -#include "rtc_base/checks.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" diff --git a/pc/rtp_sender_proxy.h b/pc/rtp_sender_proxy.h index ec2f8a9053..68caa3b835 100644 --- a/pc/rtp_sender_proxy.h +++ b/pc/rtp_sender_proxy.h @@ -11,11 +11,22 @@ #ifndef PC_RTP_SENDER_PROXY_H_ #define PC_RTP_SENDER_PROXY_H_ +#include #include #include #include +#include "api/crypto/frame_encryptor_interface.h" +#include "api/dtls_transport_interface.h" +#include "api/dtmf_sender_interface.h" +#include "api/frame_transformer_interface.h" +#include "api/media_stream_interface.h" +#include "api/media_types.h" +#include "api/rtc_error.h" +#include "api/rtp_parameters.h" #include "api/rtp_sender_interface.h" +#include "api/scoped_refptr.h" +#include "api/video_codecs/video_encoder_factory.h" #include "pc/proxy.h" namespace webrtc { diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc index 5074c1dfd9..7ff31bad14 100644 --- a/pc/rtp_sender_receiver_unittest.cc +++ b/pc/rtp_sender_receiver_unittest.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include @@ -71,15 +70,15 @@ namespace { -const char kStreamId1[] = "local_stream_1"; -const char kVideoTrackId[] = "video_1"; -const char kAudioTrackId[] = "audio_1"; -const uint32_t kVideoSsrc = 98; -const uint32_t kVideoSsrc2 = 100; -const uint32_t kAudioSsrc = 99; -const uint32_t kAudioSsrc2 = 101; -const uint32_t kVideoSsrcSimulcast = 102; -const uint32_t kVideoSimulcastLayerCount = 2; +constexpr char kStreamId1[] = "local_stream_1"; +constexpr char kVideoTrackId[] = "video_1"; +constexpr char kAudioTrackId[] = "audio_1"; +constexpr uint32_t kVideoSsrc = 98; +constexpr uint32_t kVideoSsrc2 = 100; +constexpr uint32_t kAudioSsrc = 99; +constexpr uint32_t kAudioSsrc2 = 101; +constexpr uint32_t kVideoSsrcSimulcast = 102; +constexpr uint32_t kVideoSimulcastLayerCount = 2; class MockSetStreamsObserver : public webrtc::RtpSenderBase::SetStreamsObserver { diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index dadc9de064..4697da81b1 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc @@ -10,9 +10,8 @@ #include "pc/rtp_transceiver.h" -#include - #include +#include #include #include #include diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index 4d4f9a8666..a2f9eb9ebb 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/functional/any_invocable.h" #include "api/environment/environment.h" #include "api/make_ref_counted.h" #include "api/media_stream_interface.h" @@ -92,11 +93,11 @@ void RtpTransmissionManager::OnNegotiationNeeded() { on_negotiation_needed_(); } -// Function that returns the currently valid observer -PeerConnectionObserver* RtpTransmissionManager::Observer() const { - RTC_DCHECK(!closed_); +void RtpTransmissionManager::RunWithObserver( + absl::AnyInvocable task) { + RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(observer_); - return observer_; + std::move(task)(observer_); } VoiceMediaSendChannelInterface* @@ -524,7 +525,8 @@ void RtpTransmissionManager::CreateAudioReceiver( auto receiver = RtpReceiverProxyWithInternal::Create( signaling_thread(), worker_thread(), std::move(audio_receiver)); GetAudioTransceiver()->internal()->AddReceiver(receiver); - Observer()->OnAddTrack(receiver, streams); + RunWithObserver( + [&](auto observer) { observer->OnAddTrack(receiver, streams); }); NoteUsageEvent(UsageEvent::AUDIO_ADDED); } @@ -548,7 +550,8 @@ void RtpTransmissionManager::CreateVideoReceiver( auto receiver = RtpReceiverProxyWithInternal::Create( signaling_thread(), worker_thread(), std::move(video_receiver)); GetVideoTransceiver()->internal()->AddReceiver(receiver); - Observer()->OnAddTrack(receiver, streams); + RunWithObserver( + [&](auto observer) { observer->OnAddTrack(receiver, streams); }); NoteUsageEvent(UsageEvent::VIDEO_ADDED); } @@ -624,7 +627,7 @@ void RtpTransmissionManager::OnRemoteSenderRemoved( } if (receiver) { RTC_DCHECK(!closed_); - Observer()->OnRemoveTrack(receiver); + RunWithObserver([&](auto observer) { observer->OnRemoveTrack(receiver); }); } } diff --git a/pc/rtp_transmission_manager.h b/pc/rtp_transmission_manager.h index 6afb454ab3..4a21965527 100644 --- a/pc/rtp_transmission_manager.h +++ b/pc/rtp_transmission_manager.h @@ -17,6 +17,7 @@ #include #include +#include "absl/functional/any_invocable.h" #include "api/environment/environment.h" #include "api/media_stream_interface.h" #include "api/media_types.h" @@ -28,6 +29,7 @@ #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "media/base/media_channel.h" +#include "media/base/media_engine.h" #include "pc/codec_vendor.h" #include "pc/connection_context.h" #include "pc/legacy_stats_collector_interface.h" @@ -239,7 +241,8 @@ class RtpTransmissionManager : public RtpSenderBase::SetStreamsObserver { scoped_refptr RemoveAndStopReceiver( const RtpSenderInfo& remote_sender_info) RTC_RUN_ON(signaling_thread()); - PeerConnectionObserver* Observer() const; + void RunWithObserver( + absl::AnyInvocable); void OnNegotiationNeeded(); MediaEngineInterface* media_engine() const; diff --git a/pc/rtp_transport.cc b/pc/rtp_transport.cc index b0cef00f74..c8a91e74fd 100644 --- a/pc/rtp_transport.cc +++ b/pc/rtp_transport.cc @@ -10,8 +10,7 @@ #include "pc/rtp_transport.h" -#include - +#include #include #include #include @@ -20,6 +19,7 @@ #include "api/array_view.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" +#include "api/transport/ecn_marking.h" #include "api/units/timestamp.h" #include "call/rtp_demuxer.h" #include "media/base/rtp_utils.h" @@ -27,11 +27,11 @@ #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "p2p/base/packet_transport_internal.h" #include "pc/session_description.h" +#include "rtc_base/async_packet_socket.h" #include "rtc_base/checks.h" #include "rtc_base/containers/flat_set.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/logging.h" -#include "rtc_base/network/ecn_marking.h" #include "rtc_base/network/received_packet.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" diff --git a/pc/rtp_transport.h b/pc/rtp_transport.h index 4394b16b3b..e6c7acfdca 100644 --- a/pc/rtp_transport.h +++ b/pc/rtp_transport.h @@ -19,6 +19,7 @@ #include "api/field_trials_view.h" #include "api/task_queue/pending_task_safety_flag.h" +#include "api/transport/ecn_marking.h" #include "api/units/timestamp.h" #include "call/rtp_demuxer.h" #include "call/video_receive_stream.h" @@ -29,7 +30,6 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/containers/flat_set.h" #include "rtc_base/copy_on_write_buffer.h" -#include "rtc_base/network/ecn_marking.h" #include "rtc_base/network/received_packet.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" diff --git a/pc/rtp_transport_internal.h b/pc/rtp_transport_internal.h index faac226fda..1bcb5c9f5c 100644 --- a/pc/rtp_transport_internal.h +++ b/pc/rtp_transport_internal.h @@ -19,6 +19,7 @@ #include "absl/functional/any_invocable.h" #include "call/rtp_demuxer.h" #include "pc/session_description.h" +#include "rtc_base/async_packet_socket.h" #include "rtc_base/callback_list.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/network/sent_packet.h" diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc index 2ee8e3574f..e98df00333 100644 --- a/pc/sctp_data_channel.cc +++ b/pc/sctp_data_channel.cc @@ -730,7 +730,7 @@ void SctpDataChannel::OnDataReceived(DataMessageType type, if (state_ == kOpen && observer_) { ++messages_received_; bytes_received_ += buffer->size(); - observer_->OnMessage(*buffer.get()); + observer_->OnMessage(*buffer); } else { if (queued_received_data_.byte_count() + payload.size() > kMaxQueuedReceivedDataBytes) { diff --git a/pc/sctp_data_channel.h b/pc/sctp_data_channel.h index 71ccd2cac0..b8b954dab7 100644 --- a/pc/sctp_data_channel.h +++ b/pc/sctp_data_channel.h @@ -11,13 +11,13 @@ #ifndef PC_SCTP_DATA_CHANNEL_H_ #define PC_SCTP_DATA_CHANNEL_H_ -#include - +#include +#include #include #include -#include #include +#include "absl/functional/any_invocable.h" #include "api/data_channel_interface.h" #include "api/priority.h" #include "api/rtc_error.h" diff --git a/pc/sctp_utils.cc b/pc/sctp_utils.cc index edf15721ea..49cdb71839 100644 --- a/pc/sctp_utils.cc +++ b/pc/sctp_utils.cc @@ -10,8 +10,7 @@ #include "pc/sctp_utils.h" -#include - +#include #include #include #include diff --git a/pc/sctp_utils.h b/pc/sctp_utils.h index 098f6e9659..1189123e08 100644 --- a/pc/sctp_utils.h +++ b/pc/sctp_utils.h @@ -11,16 +11,14 @@ #ifndef PC_SCTP_UTILS_H_ #define PC_SCTP_UTILS_H_ +#include +#include #include #include "api/data_channel_interface.h" #include "api/priority.h" -#include "api/transport/data_channel_transport_interface.h" -#include "media/base/media_channel.h" -#include "media/sctp/sctp_transport_internal.h" #include "net/dcsctp/public/types.h" #include "rtc_base/copy_on_write_buffer.h" -#include "rtc_base/ssl_stream_adapter.h" // For SSLRole namespace webrtc { class CopyOnWriteBuffer; diff --git a/pc/sctp_utils_unittest.cc b/pc/sctp_utils_unittest.cc index 5e7d099632..df02229ad5 100644 --- a/pc/sctp_utils_unittest.cc +++ b/pc/sctp_utils_unittest.cc @@ -10,8 +10,7 @@ #include "pc/sctp_utils.h" -#include - +#include #include #include #include diff --git a/pc/sdp_munging_detector.cc b/pc/sdp_munging_detector.cc index 95e29d575d..f54aeaa86a 100644 --- a/pc/sdp_munging_detector.cc +++ b/pc/sdp_munging_detector.cc @@ -13,8 +13,12 @@ #include #include #include +#include #include "absl/algorithm/container.h" +#include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "api/field_trials_view.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/uma_metrics.h" @@ -82,6 +86,18 @@ SdpMungingType DetermineTransportModification( if (!created_renomination && set_renomination) { return SdpMungingType::kIceOptionsRenomination; } + bool created_trickle = + absl::c_find( + last_created_transport_infos[i].description.transport_options, + ICE_OPTION_TRICKLE) != + last_created_transport_infos[i].description.transport_options.end(); + bool set_trickle = + absl::c_find(transport_infos_to_set[i].description.transport_options, + ICE_OPTION_TRICKLE) != + transport_infos_to_set[i].description.transport_options.end(); + if (created_trickle && !set_trickle) { + return SdpMungingType::kIceOptionsTrickle; + } return SdpMungingType::kIceOptions; } } @@ -408,6 +424,12 @@ SdpMungingType DetermineSdpMungingType( } // Validate video and audio contents. MediaType media_type = last_created_media_description->type(); + bool is_rtp = + media_type == MediaType::AUDIO || media_type == MediaType::VIDEO; + if (!is_rtp) { + // The checks that follow only apply for RTP-based contents. + continue; + } if (media_type == MediaType::VIDEO) { type = DetermineVideoSdpMungingType(last_created_media_description, media_description_to_set); @@ -422,6 +444,22 @@ SdpMungingType DetermineSdpMungingType( } } + // rtcp-mux. + if (last_created_media_description->rtcp_mux() != + media_description_to_set->rtcp_mux()) { + RTC_LOG(LS_WARNING) << "SDP munging: rtcp-mux modified."; + return SdpMungingType::kRtcpMux; + } + + // rtcp-rsize. + if (last_created_media_description->rtcp_reduced_size() != + media_description_to_set->rtcp_reduced_size()) { + RTC_LOG(LS_WARNING) << "SDP munging: rtcp-rsize modified."; + return media_type == MediaType::AUDIO + ? SdpMungingType::kAudioCodecsRtcpReducedSize + : SdpMungingType::kVideoCodecsRtcpReducedSize; + } + // Validate codecs. We should have bailed out earlier if codecs were added // or removed. auto last_created_codecs = last_created_media_description->codecs(); @@ -466,6 +504,7 @@ SdpMungingType DetermineSdpMungingType( } } + // sendrecv et al. if (last_created_media_description->direction() != media_description_to_set->direction()) { RTC_LOG(LS_WARNING) << "SDP munging: transceiver direction modified."; @@ -563,4 +602,33 @@ bool HasUfragSdpMunging(const SessionDescriptionInterface* sdesc, return false; } +bool IsSdpMungingAllowed(SdpMungingType sdp_munging_type, + const FieldTrialsView& trials) { + if (sdp_munging_type == SdpMungingType::kNoModification) { + return true; + } + std::string type_as_string = + std::to_string(static_cast(sdp_munging_type)); + + std::string trial; + // NoSdpMangleReject is for rollout, disallowing specific types of munging + // via Finch. It is a comma-separated list of SdpMungingTypes + if (trials.IsEnabled("WebRTC-NoSdpMangleReject")) { + trial = trials.Lookup("WebRTC-NoSdpMangleReject"); + const std::vector rejected_types = + absl::StrSplit(trial, ','); + return absl::c_find(rejected_types, type_as_string) == rejected_types.end(); + } + // NoSdpMangleAllowForTesting is for running E2E tests which should reject + // by default with a test-supplied list of exceptions as a comma-separated + // list. + if (!trials.IsEnabled("WebRTC-NoSdpMangleAllowForTesting")) { + return true; + } + trial = trials.Lookup("WebRTC-NoSdpMangleAllowForTesting"); + const std::vector allowed_types = + absl::StrSplit(trial, ','); + return absl::c_find(allowed_types, type_as_string) != allowed_types.end(); +} + } // namespace webrtc diff --git a/pc/sdp_munging_detector.h b/pc/sdp_munging_detector.h index ec8af1a634..3e2308ee6e 100644 --- a/pc/sdp_munging_detector.h +++ b/pc/sdp_munging_detector.h @@ -11,6 +11,7 @@ #ifndef PC_SDP_MUNGING_DETECTOR_H_ #define PC_SDP_MUNGING_DETECTOR_H_ +#include "api/field_trials_view.h" #include "api/jsep.h" #include "api/uma_metrics.h" @@ -24,6 +25,11 @@ SdpMungingType DetermineSdpMungingType( bool HasUfragSdpMunging(const SessionDescriptionInterface* sdesc, const SessionDescriptionInterface* last_created_desc); +// Determines if SDP munging is allowed. This is determined based on the field +// trials WebRTC-NoSdpMangle and WebRTC-NoSdpMangleForTesting. +bool IsSdpMungingAllowed(SdpMungingType sdp_munging_type, + const FieldTrialsView& trials); + } // namespace webrtc #endif // PC_SDP_MUNGING_DETECTOR_H_ diff --git a/pc/sdp_munging_detector_unittest.cc b/pc/sdp_munging_detector_unittest.cc index 9627fd8303..cd655e8d61 100644 --- a/pc/sdp_munging_detector_unittest.cc +++ b/pc/sdp_munging_detector_unittest.cc @@ -7,6 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ +#include "pc/sdp_munging_detector.h" #include #include @@ -26,7 +27,6 @@ #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/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" @@ -51,6 +51,7 @@ #include "media/base/media_constants.h" #include "media/base/stream_params.h" #include "p2p/base/transport_description.h" +#include "pc/peer_connection.h" #include "pc/peer_connection_wrapper.h" #include "pc/test/fake_audio_capture_module.h" #include "pc/test/fake_rtc_certificate_generator.h" @@ -72,6 +73,7 @@ namespace webrtc { +using ::testing::ElementsAre; using ::testing::Eq; using ::testing::IsTrue; using ::testing::Pair; @@ -127,8 +129,7 @@ class SdpMungingTest : public ::testing::Test { absl::string_view field_trials) { auto observer = std::make_unique(); PeerConnectionDependencies pc_deps(observer.get()); - pc_deps.trials = - std::make_unique(CreateTestFieldTrials(field_trials)); + pc_deps.trials = CreateTestFieldTrialsPtr(field_trials); auto result = pc_factory_->CreatePeerConnectionOrError(config, std::move(pc_deps)); EXPECT_TRUE(result.ok()); @@ -204,6 +205,138 @@ TEST_F(SdpMungingTest, DISABLED_ReportUMAMetricsWithNoMunging) { ElementsAre(Pair(SdpMungingType::kNoModification, 1))); } +TEST_F(SdpMungingTest, AllowWithDenyListForRollout) { + // Don't munge and you are good. + EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kNoModification, + CreateTestFieldTrials())); + // Empty string (default) means everything is allowed from the perspective of + // the trial. + EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kUnknownModification, + CreateTestFieldTrials())); + + // Deny list is set, modification on deny list is rejected. + EXPECT_FALSE(IsSdpMungingAllowed( + SdpMungingType::kUnknownModification /*=1*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1/"))); + + // Deny list is set, modification not on deny list is allowed. + EXPECT_TRUE(IsSdpMungingAllowed( + SdpMungingType::kWithoutCreateAnswer /*=2*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1/"))); + + // Split by comma. + EXPECT_FALSE(IsSdpMungingAllowed( + SdpMungingType::kUnknownModification /*=1*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1,2/"))); + EXPECT_FALSE(IsSdpMungingAllowed( + SdpMungingType::kWithoutCreateAnswer /*=2*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1,2/"))); + EXPECT_TRUE(IsSdpMungingAllowed( + SdpMungingType::kWithoutCreateOffer /*=3*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleReject/Enabled,1,2,4/"))); +} + +TEST_F(SdpMungingTest, DenyWithAllowListForTesting) { + // Don't munge and you are good. + EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kNoModification, + CreateTestFieldTrials())); + // Empty string (default) means everything is allowed from the perspective of + // the trial. + EXPECT_TRUE(IsSdpMungingAllowed(SdpMungingType::kUnknownModification, + CreateTestFieldTrials())); + + // Allow-list is set, modification is on allow list. + EXPECT_TRUE(IsSdpMungingAllowed( + SdpMungingType::kUnknownModification /*=1*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1/"))); + + // Allow-list is set, modification is not on allow list. + EXPECT_FALSE(IsSdpMungingAllowed( + SdpMungingType::kWithoutCreateAnswer /*=2*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1/"))); + + // Split by comma. + EXPECT_TRUE(IsSdpMungingAllowed( + SdpMungingType::kUnknownModification /*=1*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2/"))); + EXPECT_TRUE(IsSdpMungingAllowed( + SdpMungingType::kWithoutCreateAnswer /*=2*/, + CreateTestFieldTrials("WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2/"))); + EXPECT_FALSE(IsSdpMungingAllowed( + SdpMungingType::kWithoutCreateOffer /*=3*/, + CreateTestFieldTrials( + "WebRTC-NoSdpMangleAllowForTesting/Enabled,1,2,4/"))); +} + +TEST_F(SdpMungingTest, AllowListAcceptsUnmunged) { + auto pc = CreatePeerConnection("WebRTC-NoSdpMangle/Enabled/"); + pc->AddAudioTrack("audio_track", {}); + + std::unique_ptr offer = pc->CreateOffer(); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); +} + +TEST_F(SdpMungingTest, DenyListAcceptsUnmunged) { + auto pc = CreatePeerConnection("WebRTC-NoSdpMangleAllowForTesting/Enabled/"); + pc->AddAudioTrack("audio_track", {}); + + std::unique_ptr offer = pc->CreateOffer(); + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); +} + +TEST_F(SdpMungingTest, DenyListThrows) { + // This test needs to use a feature that is not throwing by default. + // kAudioCodecsFmtpOpusStereo=68 is going to stay with us for quite a while. + auto pc = CreatePeerConnection("WebRTC-NoSdpMangleAllowForTesting/Enabled/"); + pc->AddAudioTrack("audio_track", {}); + + std::unique_ptr 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_FALSE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsFmtpOpusStereo, 1))); +} + +TEST_F(SdpMungingTest, DenyListExceptionDoesNotThrow) { + // This test needs to use a feature that is not throwing by default. + // kAudioCodecsFmtpOpusStereo=68 is going to stay with us for quite a while. + auto pc = + CreatePeerConnection("WebRTC-NoSdpMangleAllowForTesting/Enabled,68/"); + pc->AddAudioTrack("audio_track", {}); + + std::unique_ptr 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, InitialSetLocalDescriptionWithoutCreateOffer) { RTCConfiguration config; config.certificates.push_back( @@ -219,7 +352,8 @@ TEST_F(SdpMungingTest, InitialSetLocalDescriptionWithoutCreateOffer) { "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); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); RTCError error; EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); EXPECT_THAT( @@ -248,11 +382,13 @@ TEST_F(SdpMungingTest, InitialSetLocalDescriptionWithoutCreateAnswer) { "a=sendrecv\r\n" "a=mid:0\r\n" "a=rtpmap:111 opus/48000/2\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); RTCError error; - auto answer = CreateSessionDescription(SdpType::kAnswer, sdp); + std::unique_ptr answer = + CreateSessionDescription(SdpType::kAnswer, sdp); answer->description()->transport_infos()[0].description.connection_role = CONNECTIONROLE_ACTIVE; EXPECT_TRUE(pc->SetLocalDescription(std::move(answer), &error)); @@ -265,7 +401,7 @@ TEST_F(SdpMungingTest, IceUfrag) { auto pc = CreatePeerConnection("WebRTC-NoSdpMangleUfrag/Enabled/"); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_ufrag = @@ -288,7 +424,7 @@ TEST_F(SdpMungingTest, IceUfragCheckDisabledByFieldTrial) { auto pc = CreatePeerConnection("WebRTC-NoSdpMangleUfrag/Disabled/"); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_ufrag = @@ -312,7 +448,7 @@ TEST_F(SdpMungingTest, IceUfragWithCheckDisabledForTesting) { pc->GetInternalPeerConnection()->DisableSdpMungingChecksForTesting(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_ufrag = @@ -328,7 +464,7 @@ TEST_F(SdpMungingTest, IcePwdCheckDisabledByFieldTrial) { auto pc = CreatePeerConnection("WebRTC-NoSdpMangleUfrag/Disabled/"); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_pwd = "amungedicepwdthisshouldberejected"; @@ -349,7 +485,7 @@ TEST_F(SdpMungingTest, IcePwd) { auto pc = CreatePeerConnection("WebRTC-NoSdpMangleUfrag/Enabled/"); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_pwd = "amungedicepwdthisshouldberejected"; @@ -376,7 +512,7 @@ TEST_F(SdpMungingTest, IceUfragRestrictedAddresses) { "127.0.0.1:12345|127.0.0.*:23456|*:34567/"); auto callee = CreatePeerConnection(); caller->AddAudioTrack("audio_track", {}); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_ufrag = "amungediceufrag"; @@ -384,7 +520,7 @@ TEST_F(SdpMungingTest, IceUfragRestrictedAddresses) { EXPECT_TRUE(caller->SetLocalDescription(offer->Clone())); EXPECT_TRUE(callee->SetRemoteDescription(std::move(offer))); - auto answer = callee->CreateAnswer(); + std::unique_ptr answer = callee->CreateAnswer(); EXPECT_TRUE(callee->SetLocalDescription(answer->Clone())); EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); @@ -444,7 +580,7 @@ TEST_F(SdpMungingTest, IceUfragSdpRejectedAndRestrictedAddresses) { "WebRTC-NoSdpMangleUfrag/Enabled/"); auto callee = CreatePeerConnection(); caller->AddAudioTrack("audio_track", {}); - auto offer = caller->CreateOffer(); + std::unique_ptr offer = caller->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_ufrag = "amungediceufrag"; @@ -465,7 +601,7 @@ TEST_F(SdpMungingTest, IceMode) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.ice_mode = ICEMODE_LITE; @@ -480,7 +616,7 @@ TEST_F(SdpMungingTest, IceOptions) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); transport_infos[0].description.transport_options.push_back( @@ -496,9 +632,11 @@ TEST_F(SdpMungingTest, IceOptionsRenomination) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); + ASSERT_THAT(transport_infos[0].description.transport_options, + ElementsAre("trickle")); transport_infos[0].description.transport_options.push_back( ICE_OPTION_RENOMINATION); RTCError error; @@ -508,13 +646,31 @@ TEST_F(SdpMungingTest, IceOptionsRenomination) { ElementsAre(Pair(SdpMungingType::kIceOptionsRenomination, 1))); } -TEST_F(SdpMungingTest, DtlsRole) { +TEST_F(SdpMungingTest, IceOptionsTrickle) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); auto offer = pc->CreateOffer(); auto& transport_infos = offer->description()->transport_infos(); ASSERT_EQ(transport_infos.size(), 1u); + ASSERT_THAT(transport_infos[0].description.transport_options, + ElementsAre("trickle")); + transport_infos[0].description.transport_options.clear(); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kIceOptionsTrickle, 1))); +} + +TEST_F(SdpMungingTest, DtlsRole) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + std::unique_ptr 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)); @@ -527,7 +683,7 @@ TEST_F(SdpMungingTest, RemoveContentDefault) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto name = contents[0].mid(); @@ -556,7 +712,7 @@ TEST_F(SdpMungingTest, RemoveContentKillswitch) { CreatePeerConnection("WebRTC-NoSdpMangleNumberOfContents/Disabled/"); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto name = contents[0].mid(); @@ -584,7 +740,7 @@ TEST_F(SdpMungingTest, TransceiverDirection) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); @@ -607,7 +763,7 @@ TEST_F(SdpMungingTest, Mid) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); std::string name(contents[0].mid()); @@ -634,7 +790,7 @@ TEST_F(SdpMungingTest, LegacySimulcast) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -666,7 +822,7 @@ TEST_F(SdpMungingTest, H264SpsPpsIdrInKeyFrame) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -692,7 +848,7 @@ TEST_F(SdpMungingTest, OpusStereo) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -715,7 +871,7 @@ TEST_F(SdpMungingTest, OpusFec) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -739,7 +895,7 @@ TEST_F(SdpMungingTest, OpusDtx) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -762,7 +918,7 @@ TEST_F(SdpMungingTest, OpusCbr) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -785,7 +941,7 @@ TEST_F(SdpMungingTest, AudioCodecsRemoved) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -804,7 +960,7 @@ TEST_F(SdpMungingTest, AudioCodecsAdded) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -825,7 +981,7 @@ TEST_F(SdpMungingTest, VideoCodecsRemoved) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -844,7 +1000,7 @@ TEST_F(SdpMungingTest, VideoCodecsAdded) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -865,7 +1021,7 @@ TEST_F(SdpMungingTest, VideoCodecsAddedWithRawPacketization) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -888,7 +1044,7 @@ TEST_F(SdpMungingTest, VideoCodecsModifiedWithRawPacketization) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -909,7 +1065,7 @@ TEST_F(SdpMungingTest, MultiOpus) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -934,7 +1090,7 @@ TEST_F(SdpMungingTest, L16) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -957,7 +1113,7 @@ TEST_F(SdpMungingTest, AudioSsrc) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -976,7 +1132,7 @@ TEST_F(SdpMungingTest, HeaderExtensionAdded) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -996,7 +1152,7 @@ TEST_F(SdpMungingTest, HeaderExtensionRemoved) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1014,7 +1170,7 @@ TEST_F(SdpMungingTest, HeaderExtensionModified) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1035,7 +1191,7 @@ TEST_F(SdpMungingTest, PayloadTypeChanged) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1056,7 +1212,7 @@ TEST_F(SdpMungingTest, AudioCodecsReordered) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1077,7 +1233,7 @@ TEST_F(SdpMungingTest, VideoCodecsReordered) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1098,7 +1254,7 @@ TEST_F(SdpMungingTest, AudioCodecsFmtp) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1119,7 +1275,7 @@ TEST_F(SdpMungingTest, VideoCodecsFmtp) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1140,7 +1296,7 @@ TEST_F(SdpMungingTest, AudioCodecsRtcpFb) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1161,7 +1317,7 @@ TEST_F(SdpMungingTest, AudioCodecsRtcpFbNack) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1182,7 +1338,7 @@ TEST_F(SdpMungingTest, AudioCodecsRtcpFbRrtr) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1199,11 +1355,53 @@ TEST_F(SdpMungingTest, AudioCodecsRtcpFbRrtr) { ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpFbRrtr, 1))); } +TEST_F(SdpMungingTest, RtcpMux) { + RTCConfiguration config; + config.rtcp_mux_policy = PeerConnection::kRtcpMuxPolicyNegotiate; + auto pc = CreatePeerConnection(config, /*field_trials=*/""); + // rtcp-mux is required by BUNDLE so set a remote description without BUNDLE + // and then remove rtcp-mux from the answer. + 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"; + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); + EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); + + std::unique_ptr answer = pc->CreateAnswer(); + auto& contents = answer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + EXPECT_TRUE(media_description->rtcp_mux()); + media_description->set_rtcp_mux(false); + // BUNDLE needs to be disabled too for this to work. + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(answer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Answer.Initial"), + ElementsAre(Pair(SdpMungingType::kRtcpMux, 1))); +} + TEST_F(SdpMungingTest, VideoCodecsRtcpFb) { auto pc = CreatePeerConnection(); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& contents = offer->description()->contents(); ASSERT_EQ(contents.size(), 1u); auto* media_description = contents[0].media_description(); @@ -1220,4 +1418,42 @@ TEST_F(SdpMungingTest, VideoCodecsRtcpFb) { ElementsAre(Pair(SdpMungingType::kVideoCodecsRtcpFb, 1))); } +TEST_F(SdpMungingTest, AudioCodecsRtcpReducedSize) { + auto pc = CreatePeerConnection(); + pc->AddAudioTrack("audio_track", {}); + + std::unique_ptr offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + EXPECT_TRUE(media_description->rtcp_reduced_size()); + media_description->set_rtcp_reduced_size(false); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kAudioCodecsRtcpReducedSize, 1))); +} + +TEST_F(SdpMungingTest, VideoCodecsRtcpReducedSize) { + auto pc = CreatePeerConnection(); + pc->AddVideoTrack("video_track", {}); + + std::unique_ptr offer = pc->CreateOffer(); + auto& contents = offer->description()->contents(); + ASSERT_EQ(contents.size(), 1u); + auto* media_description = contents[0].media_description(); + ASSERT_TRUE(media_description); + EXPECT_TRUE(media_description->rtcp_reduced_size()); + media_description->set_rtcp_reduced_size(false); + + RTCError error; + EXPECT_TRUE(pc->SetLocalDescription(std::move(offer), &error)); + EXPECT_THAT( + metrics::Samples("WebRTC.PeerConnection.SdpMunging.Offer.Initial"), + ElementsAre(Pair(SdpMungingType::kVideoCodecsRtcpReducedSize, 1))); +} + } // namespace webrtc diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index cfdefdc6ad..900f337a5c 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -25,6 +25,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/functional/any_invocable.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -717,7 +718,9 @@ 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(MediaType media_type) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +std::string GetDefaultMidForPlanB(MediaType media_type) { switch (media_type) { case MediaType::AUDIO: return CN_AUDIO; @@ -734,6 +737,7 @@ absl::string_view GetDefaultMidForPlanB(MediaType media_type) { RTC_DCHECK_NOTREACHED(); return ""; } +#pragma clang diagnostic pop // Add options to |[audio/video]_media_description_options| from `senders`. void AddPlanBRtpSenderOptions( @@ -1035,7 +1039,7 @@ class SdpOfferAnswerHandler::RemoteDescriptionOperation { void ReportOfferAnswerUma() { RTC_DCHECK(ok()); if (type_ == SdpType::kOffer || type_ == SdpType::kAnswer) { - handler_->pc_->ReportSdpBundleUsage(*desc_.get()); + handler_->pc_->ReportSdpBundleUsage(*desc_); } } @@ -1801,8 +1805,7 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( CS_LOCAL, *local_description(), old_local_description, remote_description(), bundle_groups_by_mid); if (!error.ok()) { - RTC_LOG(LS_ERROR) << error.message() << " (" << SdpTypeToString(type) - << ")"; + RTC_LOG(LS_ERROR) << error.message() << " (" << type << ")"; return error; } if (ConfiguredForMedia()) { @@ -1852,13 +1855,14 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( transceiver->set_fired_direction(media_desc->direction()); } } - auto observer = pc_->Observer(); - for (const auto& transceiver : remove_list) { - observer->OnRemoveTrack(transceiver->receiver()); - } - for (const auto& stream : removed_streams) { - observer->OnRemoveStream(stream); - } + pc_->RunWithObserver([&](auto observer) { + for (const auto& transceiver : remove_list) { + observer->OnRemoveTrack(transceiver->receiver()); + } + for (const auto& stream : removed_streams) { + observer->OnRemoveStream(stream); + } + }); } } else { // Media channels will be created only when offer is set. These may use new @@ -1868,8 +1872,7 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( // description is applied. Restore back to old description. error = CreateChannels(*local_description()->description()); if (!error.ok()) { - RTC_LOG(LS_ERROR) << error.message() << " (" << SdpTypeToString(type) - << ")"; + RTC_LOG(LS_ERROR) << error.message() << " (" << type << ")"; return error; } } @@ -1880,8 +1883,7 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( error = UpdateSessionState(type, CS_LOCAL, local_description()->description(), bundle_groups_by_mid); if (!error.ok()) { - RTC_LOG(LS_ERROR) << error.message() << " (" << SdpTypeToString(type) - << ")"; + RTC_LOG(LS_ERROR) << error.message() << " (" << type << ")"; return error; } @@ -2304,22 +2306,23 @@ void SdpOfferAnswerHandler::ApplyRemoteDescriptionUpdateTransceiverState( } } // Once all processing has finished, fire off callbacks. - auto observer = pc_->Observer(); - for (const auto& transceiver : now_receiving_transceivers) { - pc_->legacy_stats()->AddTrack(transceiver->receiver()->track().get()); - observer->OnTrack(transceiver); - observer->OnAddTrack(transceiver->receiver(), - transceiver->receiver()->streams()); - } - for (const auto& stream : added_streams) { - observer->OnAddStream(stream); - } - for (const auto& transceiver : remove_list) { - observer->OnRemoveTrack(transceiver->receiver()); - } - for (const auto& stream : removed_streams) { - observer->OnRemoveStream(stream); - } + pc_->RunWithObserver([&](auto observer) { + for (const auto& transceiver : now_receiving_transceivers) { + pc_->legacy_stats()->AddTrack(transceiver->receiver()->track().get()); + observer->OnTrack(transceiver); + observer->OnAddTrack(transceiver->receiver(), + transceiver->receiver()->streams()); + } + for (const auto& stream : added_streams) { + observer->OnAddStream(stream); + } + for (const auto& transceiver : remove_list) { + observer->OnRemoveTrack(transceiver->receiver()); + } + for (const auto& stream : removed_streams) { + observer->OnRemoveStream(stream); + } + }); } void SdpOfferAnswerHandler::PlanBUpdateSendersAndReceivers( @@ -2373,12 +2376,13 @@ void SdpOfferAnswerHandler::PlanBUpdateSendersAndReceivers( } // Iterate new_streams and notify the observer about new MediaStreams. - auto observer = pc_->Observer(); - for (size_t i = 0; i < new_streams->count(); ++i) { - MediaStreamInterface* new_stream = new_streams->at(i); - pc_->legacy_stats()->AddStream(new_stream); - observer->OnAddStream(scoped_refptr(new_stream)); - } + pc_->RunWithObserver([&](auto observer) { + for (size_t i = 0; i < new_streams->count(); ++i) { + MediaStreamInterface* new_stream = new_streams->at(i); + pc_->legacy_stats()->AddStream(new_stream); + observer->OnAddStream(scoped_refptr(new_stream)); + } + }); UpdateEndedRemoteMediaStreams(); } @@ -2483,6 +2487,8 @@ void SdpOfferAnswerHandler::DoSetLocalDescription( !pc_->trials().IsDisabled( "WebRTC-NoSdpMangleNumberOfContents")) { reject_error = true; + } else { + reject_error = !IsSdpMungingAllowed(sdp_munging_type, pc_->trials()); } SdpMungingOutcome outcome = reject_error ? SdpMungingOutcome::kRejected : SdpMungingOutcome::kAccepted; @@ -2595,7 +2601,8 @@ void SdpOfferAnswerHandler::DoSetLocalDescription( if (signaling_state() == PeerConnectionInterface::kStable && was_negotiation_needed && is_negotiation_needed_) { // Legacy version. - pc_->Observer()->OnRenegotiationNeeded(); + pc_->RunWithObserver( + [&](auto observer) { observer->OnRenegotiationNeeded(); }); // Spec-compliant version; the event may get invalidated before firing. GenerateNegotiationNeededEvent(); } @@ -2820,7 +2827,8 @@ void SdpOfferAnswerHandler::SetRemoteDescriptionPostProcess(bool was_answer) { if (signaling_state() == PeerConnectionInterface::kStable && was_negotiation_needed && is_negotiation_needed_) { // Legacy version. - pc_->Observer()->OnRenegotiationNeeded(); + pc_->RunWithObserver( + [&](auto observer) { observer->OnRenegotiationNeeded(); }); // Spec-compliant version; the event may get invalidated before firing. GenerateNegotiationNeededEvent(); } @@ -2981,42 +2989,37 @@ void SdpOfferAnswerHandler::AddIceCandidate( }); } -bool SdpOfferAnswerHandler::RemoveIceCandidates( - const std::vector& candidates) { - TRACE_EVENT0("webrtc", "SdpOfferAnswerHandler::RemoveIceCandidates"); +bool SdpOfferAnswerHandler::RemoveIceCandidate(const IceCandidate* candidate) { + TRACE_EVENT0("webrtc", "SdpOfferAnswerHandler::RemoveIceCandidate"); RTC_DCHECK_RUN_ON(signaling_thread()); - if (pc_->IsClosed()) { - RTC_LOG(LS_ERROR) << "RemoveIceCandidates: PeerConnection is closed."; + if (pc_->IsClosed() || !remote_description() || !candidate) { + RTC_LOG(LS_ERROR) << "RemoveIceCandidate: PeerConnection is closed."; return false; } - if (!remote_description()) { - RTC_LOG(LS_ERROR) << "RemoveIceCandidates: ICE candidates can't be removed " - "without any remote session description."; - return false; - } + bool removed = mutable_remote_description()->RemoveCandidate(candidate); + // Remove the candidates from the transport controller. + // This involves a hop to the network thread - should we rather do this + // asynchronously? + transport_controller_s()->RemoveRemoteCandidate(candidate); + return removed; +} - if (candidates.empty()) { - RTC_LOG(LS_ERROR) << "RemoveIceCandidates: candidates are empty."; - return false; - } +bool SdpOfferAnswerHandler::RemoveIceCandidates( + const std::vector& candidates) { + TRACE_EVENT0("webrtc", "SdpOfferAnswerHandler::RemoveIceCandidates"); + RTC_DCHECK_RUN_ON(signaling_thread()); - size_t number_removed = - mutable_remote_description()->RemoveCandidates(candidates); - if (number_removed != candidates.size()) { - RTC_LOG(LS_ERROR) - << "RemoveIceCandidates: Failed to remove candidates. Requested " - << candidates.size() << " but only " << number_removed - << " are removed."; + for (const auto& c : candidates) { + IceCandidate candidate(c.transport_name(), /*sdp_mline_index=*/-1, c); + if (!RemoveIceCandidate(&candidate)) { + RTC_LOG(LS_ERROR) << "RemoveIceCandidates: Failed to remove candidate: " + << c.ToSensitiveString(); + } } - // Remove the candidates from the transport controller. - RTCError error = transport_controller_s()->RemoveRemoteCandidates(candidates); - if (!error.ok()) { - RTC_LOG(LS_ERROR) - << "RemoveIceCandidates: Error when removing remote candidates: " - << error.message(); - } + // Technically it would be more correct to return `number_removed != 0u` here, + // but some downstream code needs to be updated first. return true; } @@ -3029,10 +3032,14 @@ void SdpOfferAnswerHandler::AddLocalIceCandidate( } void SdpOfferAnswerHandler::RemoveLocalIceCandidates( + absl::string_view mid, const std::vector& candidates) { RTC_DCHECK_RUN_ON(signaling_thread()); if (local_description()) { - mutable_local_description()->RemoveCandidates(candidates); + for (const auto& c : candidates) { + IceCandidate ice_candidate(mid, -1, c); + mutable_local_description()->RemoveCandidate(&ice_candidate); + } } } @@ -3092,7 +3099,10 @@ void SdpOfferAnswerHandler::ChangeSignalingState( << " New state: " << PeerConnectionInterface::AsString(signaling_state); signaling_state_ = signaling_state; - pc_->Observer()->OnSignalingChange(signaling_state_); + pc_->RunWithObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + observer->OnSignalingChange(signaling_state_); + }); } RTCError SdpOfferAnswerHandler::UpdateSessionState( @@ -3397,20 +3407,22 @@ RTCError SdpOfferAnswerHandler::Rollback(SdpType desc_type) { ChangeSignalingState(PeerConnectionInterface::kStable); // Once all processing has finished, fire off callbacks. - for (const auto& transceiver : now_receiving_transceivers) { - pc_->Observer()->OnTrack(transceiver); - pc_->Observer()->OnAddTrack(transceiver->receiver(), - transceiver->receiver()->streams()); - } - for (const auto& receiver : removed_receivers) { - pc_->Observer()->OnRemoveTrack(receiver); - } - for (const auto& stream : all_added_streams) { - pc_->Observer()->OnAddStream(stream); - } - for (const auto& stream : all_removed_streams) { - pc_->Observer()->OnRemoveStream(stream); - } + pc_->RunWithObserver([&](auto observer) { + for (const auto& transceiver : now_receiving_transceivers) { + observer->OnTrack(transceiver); + observer->OnAddTrack(transceiver->receiver(), + transceiver->receiver()->streams()); + } + for (const auto& receiver : removed_receivers) { + observer->OnRemoveTrack(receiver); + } + for (const auto& stream : all_added_streams) { + observer->OnAddStream(stream); + } + for (const auto& stream : all_removed_streams) { + observer->OnRemoveStream(stream); + } + }); // The assumption is that in case of implicit rollback // UpdateNegotiationNeeded gets called in SetRemoteDescription. @@ -3418,7 +3430,8 @@ RTCError SdpOfferAnswerHandler::Rollback(SdpType desc_type) { UpdateNegotiationNeeded(); if (is_negotiation_needed_) { // Legacy version. - pc_->Observer()->OnRenegotiationNeeded(); + pc_->RunWithObserver( + [&](auto observer) { observer->OnRenegotiationNeeded(); }); // Spec-compliant version; the event may get invalidated before firing. GenerateNegotiationNeededEvent(); } @@ -3474,7 +3487,8 @@ std::optional SdpOfferAnswerHandler::GetDtlsRole( void SdpOfferAnswerHandler::UpdateNegotiationNeeded() { RTC_DCHECK_RUN_ON(signaling_thread()); if (!IsUnifiedPlan()) { - pc_->Observer()->OnRenegotiationNeeded(); + pc_->RunWithObserver( + [&](auto observer) { observer->OnRenegotiationNeeded(); }); GenerateNegotiationNeededEvent(); return; } @@ -3527,7 +3541,8 @@ void SdpOfferAnswerHandler::UpdateNegotiationNeeded() { // If connection's [[IsClosed]] slot is true, abort these steps. // If connection's [[NegotiationNeeded]] slot is false, abort these steps. // Fire an event named negotiationneeded at connection. - pc_->Observer()->OnRenegotiationNeeded(); + pc_->RunWithObserver( + [&](auto observer) { observer->OnRenegotiationNeeded(); }); // Fire the spec-compliant version; when ShouldFireNegotiationNeededEvent() // is used in the task queued by the observer, this event will only fire // when the chain is empty. @@ -3754,7 +3769,10 @@ bool SdpOfferAnswerHandler::CheckIfNegotiationIsNeeded() { void SdpOfferAnswerHandler::GenerateNegotiationNeededEvent() { RTC_DCHECK_RUN_ON(signaling_thread()); ++negotiation_needed_event_id_; - pc_->Observer()->OnNegotiationNeededEvent(negotiation_needed_event_id_); + pc_->RunWithObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + observer->OnNegotiationNeededEvent(negotiation_needed_event_id_); + }); } RTCError SdpOfferAnswerHandler::ValidateSessionDescription( @@ -4254,8 +4272,7 @@ void SdpOfferAnswerHandler::FillInMissingRemoteMids( source_explanation = "generated just now"; } } else { - new_mid = std::string( - GetDefaultMidForPlanB(content.media_description()->type())); + new_mid = GetDefaultMidForPlanB(content.media_description()->type()); source_explanation = "to match pre-existing behavior"; } RTC_DCHECK(!new_mid.empty()); @@ -4400,7 +4417,7 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer( // Add audio/video/data m= sections to the end if needed. if (!audio_index && offer_new_audio_description) { MediaDescriptionOptions options( - MediaType::AUDIO, CN_AUDIO, + MediaType::AUDIO, GetDefaultMidForPlanB(MediaType::AUDIO), RtpTransceiverDirectionFromSendRecv(send_audio, recv_audio), false); options.header_extensions = media_engine()->voice().GetRtpHeaderExtensions(); @@ -4409,7 +4426,7 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer( } if (!video_index && offer_new_video_description) { MediaDescriptionOptions options( - MediaType::VIDEO, CN_VIDEO, + MediaType::VIDEO, GetDefaultMidForPlanB(MediaType::VIDEO), RtpTransceiverDirectionFromSendRecv(send_video, recv_video), false); options.header_extensions = media_engine()->video().GetRtpHeaderExtensions(); @@ -4432,7 +4449,8 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer( } if (!data_index && offer_new_data_description) { session_options->media_description_options.push_back( - GetMediaDescriptionOptionsForActiveData(CN_DATA)); + GetMediaDescriptionOptionsForActiveData( + GetDefaultMidForPlanB(MediaType::DATA))); } } @@ -5099,8 +5117,7 @@ RTCError SdpOfferAnswerHandler::PushdownMediaDescription( } // If local and remote are both set, we assume that it's safe to trigger // CCFB. - if (context_->env().field_trials().IsEnabled( - "WebRTC-RFC8888CongestionControlFeedback")) { + if (pc_->trials().IsEnabled("WebRTC-RFC8888CongestionControlFeedback")) { if (use_ccfb && local_description() && remote_description()) { // The call and the congestion controller live on the worker thread. context_->worker_thread()->PostTask([call = pc_->call_ptr()] { @@ -5240,10 +5257,13 @@ void SdpOfferAnswerHandler::UpdateEndedRemoteMediaStreams() { } } - for (auto& stream : streams_to_remove) { - remote_streams_->RemoveStream(stream.get()); - pc_->Observer()->OnRemoveStream(std::move(stream)); - } + pc_->RunWithObserver([&](auto observer) { + RTC_DCHECK_RUN_ON(signaling_thread()); + for (auto& stream : streams_to_remove) { + remote_streams_->RemoveStream(stream.get()); + observer->OnRemoveStream(std::move(stream)); + } + }); } bool SdpOfferAnswerHandler::UseCandidatesInRemoteDescription() { @@ -5338,6 +5358,7 @@ bool SdpOfferAnswerHandler::ReadyToUseRemoteCandidate( const std::string host = candidate->candidate().address().HostAsURIString(); const std::vector restricted_address_list = absl::StrSplit(restricted_addresses, '|'); + bool allowed = true; for (const absl::string_view restricted_address : restricted_address_list) { const std::pair address = absl::StrSplit(restricted_address, ':'); @@ -5358,11 +5379,14 @@ bool SdpOfferAnswerHandler::ReadyToUseRemoteCandidate( RTC_HISTOGRAM_ENUMERATION_SPARSE( "WebRTC.PeerConnection.RestrictedCandidates.Port", candidate->candidate().address().port(), 65536); - return false; + allowed = false; + break; } } + RTC_HISTOGRAM_BOOLEAN( + "WebRTC.PeerConnection.RestrictedCandidates.MungeAllowed", allowed); + return allowed; } - return true; } diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index 899354107f..f925f402d4 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -22,6 +22,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/audio_options.h" #include "api/candidate.h" #include "api/jsep.h" @@ -149,10 +150,12 @@ class SdpOfferAnswerHandler : public SdpStateProvider { bool AddIceCandidate(const IceCandidate* candidate); void AddIceCandidate(std::unique_ptr candidate, std::function callback); + bool RemoveIceCandidate(const IceCandidate* candidate); bool RemoveIceCandidates(const std::vector& candidates); // Adds a locally generated candidate to the local description. void AddLocalIceCandidate(const IceCandidate* candidate); - void RemoveLocalIceCandidates(const std::vector& candidates); + void RemoveLocalIceCandidates(absl::string_view mid, + const std::vector& candidates); bool ShouldFireNegotiationNeededEvent(uint32_t event_id); bool AddStream(MediaStreamInterface* local_stream); diff --git a/pc/sdp_offer_answer_unittest.cc b/pc/sdp_offer_answer_unittest.cc index 263c684245..f86840d54b 100644 --- a/pc/sdp_offer_answer_unittest.cc +++ b/pc/sdp_offer_answer_unittest.cc @@ -25,7 +25,6 @@ #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/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" @@ -70,8 +69,10 @@ namespace webrtc { using ::testing::ElementsAre; using ::testing::Eq; using ::testing::IsTrue; +using ::testing::NotNull; using ::testing::Pair; using ::testing::SizeIs; + using RTCConfiguration = PeerConnectionInterface::RTCConfiguration; namespace { @@ -125,8 +126,7 @@ class SdpOfferAnswerTest : public ::testing::Test { absl::string_view field_trials) { auto observer = std::make_unique(); PeerConnectionDependencies pc_deps(observer.get()); - pc_deps.trials = - std::make_unique(CreateTestFieldTrials(field_trials)); + pc_deps.trials = CreateTestFieldTrialsPtr(field_trials); auto result = pc_factory_->CreatePeerConnectionOrError(config, std::move(pc_deps)); EXPECT_TRUE(result.ok()); @@ -540,11 +540,12 @@ TEST_F(SdpOfferAnswerTest, RejectedDataChannelsDoNotGetReoffered) { "a=max-message-size:262144\r\n" "a=mid:" + mid + "\r\n"; - auto answer = CreateSessionDescription(SdpType::kAnswer, sdp); + std::unique_ptr answer = + CreateSessionDescription(SdpType::kAnswer, sdp); ASSERT_TRUE(pc->SetRemoteDescription(std::move(answer))); // The subsequent offer should not recycle the m-line since the existing data // channel is closed. - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); const auto& offer_contents = offer->description()->contents(); ASSERT_EQ(offer_contents.size(), 1u); EXPECT_EQ(offer_contents[0].mid(), mid); @@ -575,7 +576,8 @@ TEST_F(SdpOfferAnswerTest, RejectedDataChannelsDoGetReofferedWhenActive) { "a=max-message-size:262144\r\n" "a=mid:" + mid + "\r\n"; - auto answer = CreateSessionDescription(SdpType::kAnswer, sdp); + std::unique_ptr answer = + CreateSessionDescription(SdpType::kAnswer, sdp); ASSERT_TRUE(pc->SetRemoteDescription(std::move(answer))); // The subsequent offer should recycle the m-line when there is a new data @@ -584,7 +586,7 @@ TEST_F(SdpOfferAnswerTest, RejectedDataChannelsDoGetReofferedWhenActive) { EXPECT_TRUE(pc->pc()->ShouldFireNegotiationNeededEvent( pc->observer()->latest_negotiation_needed_event())); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); const auto& offer_contents = offer->description()->contents(); ASSERT_EQ(offer_contents.size(), 1u); EXPECT_EQ(offer_contents[0].mid(), mid); @@ -636,7 +638,8 @@ TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithNoRidsIsRejected) { std::string extensions = "a=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid\r\n" "a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\n"; - auto answer = CreateSessionDescription(SdpType::kAnswer, sdp); + std::unique_ptr answer = + CreateSessionDescription(SdpType::kAnswer, sdp); EXPECT_FALSE(pc->SetRemoteDescription(std::move(answer))); auto answer_with_extensions = @@ -672,7 +675,7 @@ TEST_F(SdpOfferAnswerTest, SimulcastOfferWithMixedCodec) { init.send_encodings.push_back(rid2); auto transceiver = pc->AddTransceiver(MediaType::VIDEO, init); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& offer_contents = offer->description()->contents(); auto send_codecs = offer_contents[0].media_description()->codecs(); // Verify that the serialized SDP includes pt=. @@ -734,7 +737,8 @@ TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithPayloadType) { "a=rid:2 recv pt=97\r\n" "a=simulcast:recv 1;2\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); auto transceiver = pc->pc()->GetTransceivers()[0]; @@ -743,7 +747,7 @@ TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithPayloadType) { .ok()); // Check the generated SDP. - auto answer = pc->CreateAnswer(); + std::unique_ptr answer = pc->CreateAnswer(); answer->ToString(&sdp); EXPECT_THAT(sdp, testing::HasSubstr("a=rid:1 send pt=96\r\n")); EXPECT_THAT(sdp, testing::HasSubstr("a=rid:2 send pt=97\r\n")); @@ -777,7 +781,8 @@ TEST_F(SdpOfferAnswerTest, ExpectAllSsrcsSpecifiedInSsrcGroupFid) { "a=fmtp:97 apt=96\r\n" "a=ssrc-group:FID 1 2\r\n" "a=ssrc:1 cname:test\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); RTCError error; pc->SetRemoteDescription(std::move(offer), &error); EXPECT_FALSE(error.ok()); @@ -810,7 +815,8 @@ TEST_F(SdpOfferAnswerTest, ExpectAllSsrcsSpecifiedInSsrcGroupFecFr) { "a=fmtp:98 repair-window=10000000\r\n" "a=ssrc-group:FEC-FR 1 2\r\n" "a=ssrc:1 cname:test\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); RTCError error; pc->SetRemoteDescription(std::move(offer), &error); EXPECT_FALSE(error.ok()); @@ -845,7 +851,8 @@ TEST_F(SdpOfferAnswerTest, ExpectTwoSsrcsInSsrcGroupFid) { "a=ssrc:1 cname:test\r\n" "a=ssrc:2 cname:test\r\n" "a=ssrc:3 cname:test\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); RTCError error; pc->SetRemoteDescription(std::move(offer), &error); EXPECT_FALSE(error.ok()); @@ -880,7 +887,8 @@ TEST_F(SdpOfferAnswerTest, ExpectTwoSsrcsInSsrcGroupFecFr) { "a=ssrc:1 cname:test\r\n" "a=ssrc:2 cname:test\r\n" "a=ssrc:3 cname:test\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); RTCError error; pc->SetRemoteDescription(std::move(offer), &error); EXPECT_FALSE(error.ok()); @@ -916,7 +924,8 @@ TEST_F(SdpOfferAnswerTest, ExpectAtMostFourSsrcsInSsrcGroupSIM) { "a=ssrc:2 cname:test\r\n" "a=ssrc:3 cname:test\r\n" "a=ssrc:4 cname:test\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); RTCError error; pc->SetRemoteDescription(std::move(offer), &error); EXPECT_FALSE(error.ok()); @@ -927,7 +936,7 @@ TEST_F(SdpOfferAnswerTest, DuplicateSsrcsDisallowedInLocalDescription) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& offer_contents = offer->description()->contents(); ASSERT_EQ(offer_contents.size(), 2u); uint32_t second_ssrc = offer_contents[1].media_description()->first_ssrc(); @@ -946,7 +955,7 @@ TEST_F(SdpOfferAnswerTest, pc->AddAudioTrack("audio_track", {}); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& offer_contents = offer->description()->contents(); ASSERT_EQ(offer_contents.size(), 2u); uint32_t audio_ssrc = offer_contents[0].media_description()->first_ssrc(); @@ -987,7 +996,7 @@ TEST_F(SdpOfferAnswerTest, pc->AddAudioTrack("audio_track", {}); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& offer_contents = offer->description()->contents(); ASSERT_EQ(offer_contents.size(), 2u); uint32_t audio_ssrc = offer_contents[0].media_description()->first_ssrc(); @@ -1027,7 +1036,7 @@ TEST_F(SdpOfferAnswerTest, AllowOnlyOneSsrcGroupPerSemanticAndPrimarySsrc) { pc->AddAudioTrack("audio_track", {}); pc->AddVideoTrack("video_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); auto& offer_contents = offer->description()->contents(); ASSERT_EQ(offer_contents.size(), 2u); uint32_t audio_ssrc = offer_contents[0].media_description()->first_ssrc(); @@ -1087,7 +1096,8 @@ TEST_F(SdpOfferAnswerTest, OfferWithRtxAndNoMsidIsNotRejected) { "a=ssrc-group:FID 1 2\r\n" "a=ssrc:1 cname:test\r\n" "a=ssrc:2 cname:test\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); } @@ -1129,7 +1139,7 @@ TEST_F(SdpOfferAnswerTest, SdpMungingWithInvalidPayloadTypeIsRejected) { auto pc = CreatePeerConnection(); pc->AddAudioTrack("audio_track", {}); - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); ASSERT_EQ(offer->description()->contents().size(), 1u); auto* audio = offer->description()->contents()[0].media_description(); ASSERT_GT(audio->codecs().size(), 0u); @@ -1168,11 +1178,12 @@ TEST_F(SdpOfferAnswerTest, MsidSignalingInSubsequentOfferAnswer) { "a=rtcp-mux\r\n" "a=rtpmap:111 opus/48000/2\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); // Check the generated SDP. - auto answer = pc->CreateAnswer(); + std::unique_ptr answer = pc->CreateAnswer(); answer->ToString(&sdp); EXPECT_NE(std::string::npos, sdp.find("a=msid:- audio_track\r\n")); @@ -1218,14 +1229,15 @@ TEST_F(SdpOfferAnswerTest, MsidSignalingUnknownRespondsWithMsidAndKeepsSsrc) { "a=mid:0\r\n" "a=rtpmap:111 opus/48000/2\r\n"; - auto offer = CreateSessionDescription(SdpType::kOffer, sdp); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp); EXPECT_TRUE(pc->SetRemoteDescription(std::move(offer))); auto first_transceiver = pc->pc()->GetTransceivers()[0]; EXPECT_TRUE(first_transceiver ->SetDirectionWithError(RtpTransceiverDirection::kSendOnly) .ok()); // Check the generated *serialized* SDP. - auto answer = pc->CreateAnswer(); + std::unique_ptr answer = pc->CreateAnswer(); const auto& answer_contents = answer->description()->contents(); ASSERT_EQ(answer_contents.size(), 1u); auto answer_streams = answer_contents[0].media_description()->streams(); @@ -1329,7 +1341,7 @@ TEST_P(SdpOfferAnswerWithPayloadTypeTest, EXPECT_TRUE( pc->SetRemoteDescription(CreateSessionDescription(SdpType::kOffer, sdp))); // The answer should accept the PT for VP9. - auto answer = pc->CreateAnswer(); + std::unique_ptr answer = pc->CreateAnswer(); { const auto* mid_0 = answer->description()->GetContentDescriptionByName("0"); ASSERT_TRUE(mid_0); @@ -1344,7 +1356,7 @@ TEST_P(SdpOfferAnswerWithPayloadTypeTest, EXPECT_TRUE(pc->SetLocalDescription(std::move(answer))); // The follow-up offer should continue to use the same PT for VP9. - auto offer = pc->CreateOffer(); + std::unique_ptr offer = pc->CreateOffer(); { const auto* mid_0 = offer->description()->GetContentDescriptionByName("0"); ASSERT_TRUE(mid_0); @@ -1418,13 +1430,13 @@ TEST_P(SdpOfferAnswerShuffleMediaTypes, CreateSessionDescription(SdpType::kAnswer, rejected_answer_sdp); EXPECT_TRUE(pc1->SetRemoteDescription(std::move(rejected_answer))); - auto offer = + std::unique_ptr offer = pc2->CreateOfferAndSetAsLocal(); // This will generate a mid=0 too ASSERT_EQ(offer->description()->contents().size(), 1u); auto mid2 = offer->description()->contents()[0].mid(); EXPECT_EQ(mid1, mid2); // Check that the mids collided. EXPECT_TRUE(pc1->SetRemoteDescription(std::move(offer))); - auto answer = pc1->CreateAnswer(); + std::unique_ptr answer = pc1->CreateAnswer(); EXPECT_FALSE(pc1->SetLocalDescription(std::move(answer))); } @@ -1459,7 +1471,7 @@ TEST_P(SdpOfferAnswerShuffleMediaTypes, CreateSessionDescription(SdpType::kAnswer, rejected_answer_sdp); EXPECT_TRUE(pc1->SetRemoteDescription(std::move(rejected_answer))); - auto offer = + std::unique_ptr offer = pc2->CreateOfferAndSetAsLocal(); // This will generate a mid=0 too ASSERT_EQ(offer->description()->contents().size(), 1u); auto mid2 = offer->description()->contents()[0].mid(); @@ -1504,7 +1516,7 @@ TEST_F(SdpOfferAnswerTest, OfferWithNoCompatibleCodecsIsRejectedInAnswer) { pc->SetRemoteDescription(std::move(desc), &error); EXPECT_TRUE(error.ok()); - auto answer = pc->CreateAnswer(); + std::unique_ptr answer = pc->CreateAnswer(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(answer_contents.size(), 2u); EXPECT_EQ(answer_contents[0].rejected, true); @@ -1534,7 +1546,7 @@ TEST_F(SdpOfferAnswerTest, OfferWithRejectedMlineWithoutFingerprintIsAccepted) { pc->SetRemoteDescription(std::move(desc), &error); EXPECT_TRUE(error.ok()); - auto answer = pc->CreateAnswer(); + std::unique_ptr answer = pc->CreateAnswer(); EXPECT_TRUE(pc->SetLocalDescription(std::move(answer))); } @@ -1571,7 +1583,8 @@ TEST_F(SdpOfferAnswerTest, MidBackfillAnswer) { pc->pc()->remote_description()->description()->contents(); ASSERT_EQ(offer_contents.size(), 1u); EXPECT_EQ(offer_contents[0].mid(), "0"); - auto answer = pc->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + pc->CreateAnswerAndSetAsLocal(); auto answer_contents = answer->description()->contents(); ASSERT_EQ(answer_contents.size(), 1u); EXPECT_EQ(answer_contents[0].mid(), offer_contents[0].mid()); @@ -1639,15 +1652,17 @@ TEST_F(SdpOfferAnswerTest, ReducedSizeNotNegotiated) { auto audio_transceiver = caller->AddTransceiver(MediaType::AUDIO); auto video_transceiver = caller->AddTransceiver(MediaType::VIDEO); - auto offer = caller->CreateOfferAndSetAsLocal(); - ASSERT_NE(offer, nullptr); + std::unique_ptr offer = + caller->CreateOfferAndSetAsLocal(); + ASSERT_THAT(offer, NotNull()); std::string sdp; offer->ToString(&sdp); // Remove rtcp-rsize attribute. auto modified_offer = CreateSessionDescription( SdpType::kOffer, absl::StrReplaceAll(sdp, {{"a=rtcp-rsize\r\n", ""}})); EXPECT_TRUE(callee->SetRemoteDescription(std::move(modified_offer))); - auto answer = callee->CreateAnswerAndSetAsLocal(); + std::unique_ptr answer = + callee->CreateAnswerAndSetAsLocal(); EXPECT_TRUE(caller->SetRemoteDescription(std::move(answer))); auto receivers = callee->pc()->GetReceivers(); diff --git a/pc/sdp_state_provider.h b/pc/sdp_state_provider.h index 85c2e19ab9..00f759b91a 100644 --- a/pc/sdp_state_provider.h +++ b/pc/sdp_state_provider.h @@ -11,10 +11,12 @@ #ifndef PC_SDP_STATE_PROVIDER_H_ #define PC_SDP_STATE_PROVIDER_H_ +#include #include #include "api/jsep.h" #include "api/peer_connection_interface.h" +#include "rtc_base/ssl_stream_adapter.h" namespace webrtc { diff --git a/pc/sdp_utils.h b/pc/sdp_utils.h index 14f5a1cc68..78f5a2025b 100644 --- a/pc/sdp_utils.h +++ b/pc/sdp_utils.h @@ -13,7 +13,6 @@ #include #include -#include #include "api/jsep.h" #include "p2p/base/transport_info.h" diff --git a/pc/session_description.h b/pc/session_description.h index 37272c4106..b672ce934d 100644 --- a/pc/session_description.h +++ b/pc/session_description.h @@ -586,34 +586,5 @@ enum ContentSource { CS_LOCAL, CS_REMOTE }; } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::AudioContentDescription; -using ::webrtc::ContentGroup; -using ::webrtc::ContentGroups; -using ::webrtc::ContentInfo; -using ::webrtc::ContentInfos; -using ::webrtc::ContentNames; -using ::webrtc::ContentSource; -using ::webrtc::CS_LOCAL; -using ::webrtc::CS_REMOTE; -using ::webrtc::kAutoBandwidth; -using ::webrtc::kMsidSignalingMediaSection; -using ::webrtc::kMsidSignalingNotUsed; -using ::webrtc::kMsidSignalingSemantic; -using ::webrtc::kMsidSignalingSsrcAttribute; -using ::webrtc::MediaContentDescription; -using ::webrtc::MediaProtocolType; -using ::webrtc::MsidSignaling; -using ::webrtc::RtpHeaderExtensions; -using ::webrtc::RtpMediaContentDescription; -using ::webrtc::SctpDataContentDescription; -using ::webrtc::SessionDescription; -using ::webrtc::UnsupportedContentDescription; -using ::webrtc::VideoContentDescription; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_SESSION_DESCRIPTION_H_ diff --git a/pc/simulcast_description.h b/pc/simulcast_description.h index 3de057e152..258b5e67c4 100644 --- a/pc/simulcast_description.h +++ b/pc/simulcast_description.h @@ -112,14 +112,5 @@ class SimulcastDescription final { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::SimulcastDescription; -using ::webrtc::SimulcastLayer; -using ::webrtc::SimulcastLayerList; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_SIMULCAST_DESCRIPTION_H_ diff --git a/pc/simulcast_sdp_serializer_unittest.cc b/pc/simulcast_sdp_serializer_unittest.cc index c92f08d638..baf230cda5 100644 --- a/pc/simulcast_sdp_serializer_unittest.cc +++ b/pc/simulcast_sdp_serializer_unittest.cc @@ -10,8 +10,7 @@ #include "pc/simulcast_sdp_serializer.h" -#include - +#include #include #include #include diff --git a/pc/slow_peer_connection_integration_test.cc b/pc/slow_peer_connection_integration_test.cc index 8666edc077..42d91abb5c 100644 --- a/pc/slow_peer_connection_integration_test.cc +++ b/pc/slow_peer_connection_integration_test.cc @@ -11,8 +11,7 @@ // This file is intended for PeerConnection integration tests that are // slow to execute (currently defined as more than 5 seconds per test). -#include - +#include #include #include #include diff --git a/pc/srtp_session.cc b/pc/srtp_session.cc index 6d94c4921a..d1c533c91f 100644 --- a/pc/srtp_session.cc +++ b/pc/srtp_session.cc @@ -10,8 +10,6 @@ #include "pc/srtp_session.h" -#include - #include #include #include diff --git a/pc/srtp_session.h b/pc/srtp_session.h index 1134e4393f..18918549f1 100644 --- a/pc/srtp_session.h +++ b/pc/srtp_session.h @@ -163,13 +163,5 @@ class SrtpSession { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::ProhibitLibsrtpInitialization; -using ::webrtc::SrtpSession; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_SRTP_SESSION_H_ diff --git a/pc/srtp_session_unittest.cc b/pc/srtp_session_unittest.cc index af004104c7..79a87ec9c5 100644 --- a/pc/srtp_session_unittest.cc +++ b/pc/srtp_session_unittest.cc @@ -10,8 +10,6 @@ #include "pc/srtp_session.h" -#include - #include #include #include diff --git a/pc/srtp_transport_unittest.cc b/pc/srtp_transport_unittest.cc index f0e84154ae..6de46be562 100644 --- a/pc/srtp_transport_unittest.cc +++ b/pc/srtp_transport_unittest.cc @@ -10,9 +10,8 @@ #include "pc/srtp_transport.h" -#include - #include +#include #include #include diff --git a/pc/stream_collection.h b/pc/stream_collection.h index d417b77e91..648dff28ec 100644 --- a/pc/stream_collection.h +++ b/pc/stream_collection.h @@ -11,11 +11,15 @@ #ifndef PC_STREAM_COLLECTION_H_ #define PC_STREAM_COLLECTION_H_ +#include #include #include #include +#include "api/make_ref_counted.h" +#include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" namespace webrtc { diff --git a/pc/test/android_test_initializer.cc b/pc/test/android_test_initializer.cc index db180acce2..dca1ae4c79 100644 --- a/pc/test/android_test_initializer.cc +++ b/pc/test/android_test_initializer.cc @@ -10,6 +10,7 @@ #include "pc/test/android_test_initializer.h" +#include #include #include #include diff --git a/pc/test/fake_audio_capture_module.cc b/pc/test/fake_audio_capture_module.cc index b9e429471b..5283c3211b 100644 --- a/pc/test/fake_audio_capture_module.cc +++ b/pc/test/fake_audio_capture_module.cc @@ -10,9 +10,8 @@ #include "pc/test/fake_audio_capture_module.h" -#include - #include +#include #include "api/audio/audio_device_defines.h" #include "api/make_ref_counted.h" diff --git a/pc/test/fake_audio_capture_module_unittest.cc b/pc/test/fake_audio_capture_module_unittest.cc index b4249166e5..ca0d104ff3 100644 --- a/pc/test/fake_audio_capture_module_unittest.cc +++ b/pc/test/fake_audio_capture_module_unittest.cc @@ -10,10 +10,9 @@ #include "pc/test/fake_audio_capture_module.h" -#include - #include #include +#include #include "api/audio/audio_device_defines.h" #include "api/scoped_refptr.h" diff --git a/pc/test/fake_peer_connection_base.h b/pc/test/fake_peer_connection_base.h index fda2a03c25..949d3a9b93 100644 --- a/pc/test/fake_peer_connection_base.h +++ b/pc/test/fake_peer_connection_base.h @@ -20,6 +20,7 @@ #include #include +#include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/adaptation/resource.h" #include "api/audio/audio_device.h" @@ -59,6 +60,7 @@ #include "pc/session_description.h" #include "pc/transport_stats.h" #include "pc/usage_pattern.h" +#include "rtc_base/checks.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/rtc_certificate.h" #include "rtc_base/ssl_certificate.h" @@ -227,6 +229,10 @@ class FakePeerConnectionBase : public PeerConnectionInternal { bool AddIceCandidate(const IceCandidate* candidate) override { return false; } + bool RemoveIceCandidate(const IceCandidate* candidate) override { + return false; + } + bool RemoveIceCandidates(const std::vector& candidates) override { return false; } @@ -361,7 +367,10 @@ class FakePeerConnectionBase : public PeerConnectionInternal { DataChannelController* data_channel_controller() override { return nullptr; } PortAllocator* port_allocator() override { return nullptr; } LegacyStatsCollector* legacy_stats() override { return nullptr; } - PeerConnectionObserver* Observer() const override { return nullptr; } + void RunWithObserver( + absl::AnyInvocable) override { + RTC_DCHECK_NOTREACHED(); + } std::optional GetSctpSslRole_n() override { return std::nullopt; } PeerConnectionInterface::IceConnectionState ice_connection_state_internal() override { diff --git a/pc/test/fake_rtc_certificate_generator.h b/pc/test/fake_rtc_certificate_generator.h index 64879c188d..2253366e49 100644 --- a/pc/test/fake_rtc_certificate_generator.h +++ b/pc/test/fake_rtc_certificate_generator.h @@ -17,6 +17,7 @@ #include #include "api/scoped_refptr.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" @@ -158,10 +159,11 @@ class FakeRTCCertificateGenerator RTC_DCHECK_EQ(key_params.ec_curve(), webrtc::EC_NIST_P256); } webrtc::KeyType key_type = key_params.type(); - webrtc::TaskQueueBase::Current()->PostTask( + webrtc::TaskQueueBase::Current()->PostTask(webrtc::SafeTask( + pending_delete_.flag(), [this, key_type, callback = std::move(callback)]() mutable { GenerateCertificate(key_type, std::move(callback)); - }); + })); } static webrtc::scoped_refptr GenerateCertificate() { @@ -202,9 +204,11 @@ class FakeRTCCertificateGenerator // set_should_wait(false) is called. if (should_wait_) { webrtc::TaskQueueBase::Current()->PostDelayedTask( - [this, key_type, callback = std::move(callback)]() mutable { - GenerateCertificate(key_type, std::move(callback)); - }, + webrtc::SafeTask( + pending_delete_.flag(), + [this, key_type, callback = std::move(callback)]() mutable { + GenerateCertificate(key_type, std::move(callback)); + }), webrtc::TimeDelta::Millis(1)); return; } @@ -220,6 +224,8 @@ class FakeRTCCertificateGenerator } } + webrtc::ScopedTaskSafetyDetached pending_delete_; + bool should_fail_; bool should_wait_; int key_index_ = 0; diff --git a/pc/test/integration_test_helpers.cc b/pc/test/integration_test_helpers.cc index ecd2aa311e..f5edd53d14 100644 --- a/pc/test/integration_test_helpers.cc +++ b/pc/test/integration_test_helpers.cc @@ -19,6 +19,7 @@ #include "absl/functional/any_invocable.h" #include "api/audio/builtin_audio_processing_builder.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" #include "api/field_trials_view.h" diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index dc695d5e6e..619db89092 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -34,7 +34,6 @@ #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" #include "api/jsep.h" @@ -254,7 +253,7 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, // will set the whole offer/answer exchange in motion. Just need to wait for // the signaling state to reach "stable". void CreateAndSetAndSignalOffer() { - auto offer = CreateOfferAndWait(); + std::unique_ptr offer = CreateOfferAndWait(); ASSERT_NE(nullptr, offer); EXPECT_TRUE(SetLocalDescriptionAndSendSdpMessage(std::move(offer))); } @@ -735,6 +734,18 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, return 0; } + uint32_t GetReceivedFrameCount() { + scoped_refptr report = NewGetStats(); + auto inbound_stream_stats = + report->GetStatsOfType(); + for (const auto& stat : inbound_stream_stats) { + if (*stat->kind == "video") { + return stat->frames_received.value_or(0); + } + } + return 0; + } + void set_connection_change_callback( std::function func) { connection_change_callback_ = std::move(func); @@ -860,14 +871,14 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, if (remote_offer_handler_) { remote_offer_handler_(); } - auto answer = CreateAnswer(); + std::unique_ptr answer = CreateAnswer(); ASSERT_NE(nullptr, answer); EXPECT_TRUE(SetLocalDescriptionAndSendSdpMessage(std::move(answer))); } void HandleIncomingAnswer(SdpType type, const std::string& msg) { RTC_LOG(LS_INFO) << debug_name_ << ": HandleIncomingAnswer of type " - << SdpTypeToString(type); + << type; std::unique_ptr desc = CreateSessionDescription(type, msg); if (received_sdp_munger_) { @@ -1469,12 +1480,11 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { if (it != field_trials_overrides_.end()) { field_trials = it->second; } - if (!client->Init( - options, &modified_config, std::move(dependencies), fss_.get(), - network_thread_.get(), worker_thread_.get(), - std::make_unique(CreateTestFieldTrials(field_trials)), - std::move(event_log_factory), reset_encoder_factory, - reset_decoder_factory, create_media_engine)) { + if (!client->Init(options, &modified_config, std::move(dependencies), + fss_.get(), network_thread_.get(), worker_thread_.get(), + CreateTestFieldTrialsPtr(field_trials), + std::move(event_log_factory), reset_encoder_factory, + reset_decoder_factory, create_media_engine)) { return nullptr; } return client; @@ -1864,12 +1874,11 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { callee()->pc()->Close(); } - void TestNegotiatedCipherSuite( - const PeerConnectionFactory::Options& caller_options, - const PeerConnectionFactory::Options& callee_options, - int expected_cipher_suite) { - ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(caller_options, - callee_options)); + void TestNegotiatedCipherSuite(const RTCConfiguration& caller_config, + const RTCConfiguration& callee_config, + int expected_cipher_suite) { + ASSERT_TRUE( + CreatePeerConnectionWrappersWithConfig(caller_config, callee_config)); ConnectFakeSignaling(); caller()->AddAudioVideoTracks(); callee()->AddAudioVideoTracks(); @@ -1886,17 +1895,17 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { bool remote_gcm_enabled, bool aes_ctr_enabled, int expected_cipher_suite) { - PeerConnectionFactory::Options caller_options; - caller_options.crypto_options.srtp.enable_gcm_crypto_suites = - local_gcm_enabled; - caller_options.crypto_options.srtp.enable_aes128_sha1_80_crypto_cipher = - aes_ctr_enabled; - PeerConnectionFactory::Options callee_options; - callee_options.crypto_options.srtp.enable_gcm_crypto_suites = - remote_gcm_enabled; - callee_options.crypto_options.srtp.enable_aes128_sha1_80_crypto_cipher = - aes_ctr_enabled; - TestNegotiatedCipherSuite(caller_options, callee_options, + RTCConfiguration caller_config; + CryptoOptions caller_crypto; + caller_crypto.srtp.enable_gcm_crypto_suites = local_gcm_enabled; + caller_crypto.srtp.enable_aes128_sha1_80_crypto_cipher = aes_ctr_enabled; + caller_config.crypto_options = caller_crypto; + RTCConfiguration callee_config; + CryptoOptions callee_crypto; + callee_crypto.srtp.enable_gcm_crypto_suites = remote_gcm_enabled; + callee_crypto.srtp.enable_aes128_sha1_80_crypto_cipher = aes_ctr_enabled; + callee_config.crypto_options = callee_crypto; + TestNegotiatedCipherSuite(caller_config, callee_config, expected_cipher_suite); } diff --git a/pc/test/mock_channel_interface.h b/pc/test/mock_channel_interface.h index b86f168433..ffcc528705 100644 --- a/pc/test/mock_channel_interface.h +++ b/pc/test/mock_channel_interface.h @@ -22,6 +22,7 @@ #include "media/base/stream_params.h" #include "pc/channel_interface.h" #include "pc/rtp_transport_internal.h" +#include "pc/session_description.h" #include "test/gmock.h" namespace webrtc { @@ -88,12 +89,5 @@ class MockChannelInterface : public ChannelInterface { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MockChannelInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_TEST_MOCK_CHANNEL_INTERFACE_H_ diff --git a/pc/test/mock_peer_connection_internal.h b/pc/test/mock_peer_connection_internal.h index 51c4eafec7..95aa5b73cf 100644 --- a/pc/test/mock_peer_connection_internal.h +++ b/pc/test/mock_peer_connection_internal.h @@ -19,6 +19,7 @@ #include #include +#include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/adaptation/resource.h" #include "api/audio/audio_device.h" @@ -209,6 +210,10 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { (const PeerConnectionInterface::RTCConfiguration&), (override)); MOCK_METHOD(bool, AddIceCandidate, (const IceCandidate*), (override)); + MOCK_METHOD(bool, + RemoveIceCandidate, + (const IceCandidate* candidate), + (override)); MOCK_METHOD(bool, RemoveIceCandidates, (const std::vector&), @@ -286,7 +291,10 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { MOCK_METHOD(DataChannelController*, data_channel_controller, (), (override)); MOCK_METHOD(PortAllocator*, port_allocator, (), (override)); MOCK_METHOD(LegacyStatsCollector*, legacy_stats, (), (override)); - MOCK_METHOD(PeerConnectionObserver*, Observer, (), (const, override)); + MOCK_METHOD(void, + RunWithObserver, + (absl::AnyInvocable), + (override)); MOCK_METHOD(std::optional, GetSctpSslRole_n, (), (override)); MOCK_METHOD(PeerConnectionInterface::IceConnectionState, ice_connection_state_internal, diff --git a/pc/test/mock_voice_media_receive_channel_interface.h b/pc/test/mock_voice_media_receive_channel_interface.h index 7eca40c94b..d4139039a3 100644 --- a/pc/test/mock_voice_media_receive_channel_interface.h +++ b/pc/test/mock_voice_media_receive_channel_interface.h @@ -137,12 +137,5 @@ static_assert(!std::is_abstract_v, ""); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::MockVoiceMediaReceiveChannelInterface; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_TEST_MOCK_VOICE_MEDIA_RECEIVE_CHANNEL_INTERFACE_H_ diff --git a/pc/test/peer_connection_test_wrapper.cc b/pc/test/peer_connection_test_wrapper.cc index 95be4b30bf..c70ce25ebc 100644 --- a/pc/test/peer_connection_test_wrapper.cc +++ b/pc/test/peer_connection_test_wrapper.cc @@ -10,8 +10,7 @@ #include "pc/test/peer_connection_test_wrapper.h" -#include - +#include #include #include #include @@ -299,8 +298,7 @@ void PeerConnectionTestWrapper::OnSuccess(SessionDescriptionInterface* desc) { EXPECT_TRUE(desc->ToString(&sdp)); RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ << ": " - << webrtc::SdpTypeToString(desc->GetType()) - << " sdp created: " << sdp; + << desc->GetType() << " sdp created: " << sdp; SetLocalDescription(desc->GetType(), sdp); @@ -334,8 +332,7 @@ void PeerConnectionTestWrapper::ReceiveAnswerSdp(const std::string& sdp) { void PeerConnectionTestWrapper::SetLocalDescription(SdpType type, const std::string& sdp) { RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ - << ": SetLocalDescription " << webrtc::SdpTypeToString(type) - << " " << sdp; + << ": SetLocalDescription " << type << " " << sdp; auto observer = webrtc::make_ref_counted(); peer_connection_->SetLocalDescription( @@ -345,8 +342,7 @@ void PeerConnectionTestWrapper::SetLocalDescription(SdpType type, void PeerConnectionTestWrapper::SetRemoteDescription(SdpType type, const std::string& sdp) { RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ - << ": SetRemoteDescription " << webrtc::SdpTypeToString(type) - << " " << sdp; + << ": SetRemoteDescription " << type << " " << sdp; auto observer = webrtc::make_ref_counted(); peer_connection_->SetRemoteDescription( diff --git a/pc/test/srtp_test_util.h b/pc/test/srtp_test_util.h index e3118cd947..d451a558fc 100644 --- a/pc/test/srtp_test_util.h +++ b/pc/test/srtp_test_util.h @@ -53,15 +53,5 @@ static int rtcp_auth_tag_len(int crypto_suite) { } // 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::kTestKey1; -using ::webrtc::kTestKey2; -using ::webrtc::rtcp_auth_tag_len; -using ::webrtc::rtp_auth_tag_len; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_TEST_SRTP_TEST_UTIL_H_ diff --git a/pc/track_media_info_map.h b/pc/track_media_info_map.h index eb202553d0..64a2cbacdb 100644 --- a/pc/track_media_info_map.h +++ b/pc/track_media_info_map.h @@ -11,13 +11,9 @@ #ifndef PC_TRACK_MEDIA_INFO_MAP_H_ #define PC_TRACK_MEDIA_INFO_MAP_H_ -#include - +#include #include -#include #include -#include -#include #include "api/array_view.h" #include "api/media_stream_interface.h" @@ -25,7 +21,7 @@ #include "media/base/media_channel.h" #include "pc/rtp_receiver.h" #include "pc/rtp_sender.h" -#include "rtc_base/ref_count.h" +#include "rtc_base/checks.h" namespace webrtc { diff --git a/pc/track_media_info_map_unittest.cc b/pc/track_media_info_map_unittest.cc index cd6bf36a2e..e1c9822414 100644 --- a/pc/track_media_info_map_unittest.cc +++ b/pc/track_media_info_map_unittest.cc @@ -10,8 +10,7 @@ #include "pc/track_media_info_map.h" -#include - +#include #include #include #include diff --git a/pc/transceiver_list.h b/pc/transceiver_list.h index 1abb7d2a4f..9916b62db5 100644 --- a/pc/transceiver_list.h +++ b/pc/transceiver_list.h @@ -11,18 +11,16 @@ #ifndef PC_TRANSCEIVER_LIST_H_ #define PC_TRANSCEIVER_LIST_H_ -#include - #include +#include #include #include #include #include -#include "api/media_types.h" -#include "api/rtc_error.h" #include "api/rtp_parameters.h" #include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_direction.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "pc/rtp_transceiver.h" diff --git a/pc/transport_stats.h b/pc/transport_stats.h index 1771d1fa8e..f27fad99bb 100644 --- a/pc/transport_stats.h +++ b/pc/transport_stats.h @@ -51,14 +51,5 @@ struct TransportStats { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TransportChannelStats; -using ::webrtc::TransportChannelStatsList; -using ::webrtc::TransportStats; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_TRANSPORT_STATS_H_ diff --git a/pc/typed_codec_vendor.cc b/pc/typed_codec_vendor.cc index 486bd16657..2f831d8283 100644 --- a/pc/typed_codec_vendor.cc +++ b/pc/typed_codec_vendor.cc @@ -10,8 +10,7 @@ #include "pc/typed_codec_vendor.h" -#include - +#include #include #include #include diff --git a/pc/typed_codec_vendor.h b/pc/typed_codec_vendor.h index 41165abfe2..071b8465b7 100644 --- a/pc/typed_codec_vendor.h +++ b/pc/typed_codec_vendor.h @@ -43,12 +43,5 @@ class TypedCodecVendor { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::TypedCodecVendor; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_TYPED_CODEC_VENDOR_H_ diff --git a/pc/used_ids.h b/pc/used_ids.h index fe80531006..ac8f118814 100644 --- a/pc/used_ids.h +++ b/pc/used_ids.h @@ -16,7 +16,6 @@ #include "api/rtp_parameters.h" #include "media/base/codec.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" namespace webrtc { template @@ -185,14 +184,5 @@ class UsedRtpHeaderExtensionIds : public UsedIds { } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::UsedIds; -using ::webrtc::UsedPayloadTypes; -using ::webrtc::UsedRtpHeaderExtensionIds; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // PC_USED_IDS_H_ diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc index 0e18ade560..402c27fabd 100644 --- a/pc/video_rtp_receiver.cc +++ b/pc/video_rtp_receiver.cc @@ -10,8 +10,7 @@ #include "pc/video_rtp_receiver.h" -#include - +#include #include #include #include diff --git a/pc/video_rtp_track_source.cc b/pc/video_rtp_track_source.cc index 7537de9aa7..48fa27d08f 100644 --- a/pc/video_rtp_track_source.cc +++ b/pc/video_rtp_track_source.cc @@ -10,9 +10,8 @@ #include "pc/video_rtp_track_source.h" -#include - #include +#include #include "api/sequence_checker.h" #include "api/video/recordable_encoded_frame.h" diff --git a/pc/video_rtp_track_source_unittest.cc b/pc/video_rtp_track_source_unittest.cc index 4aefb17380..e941e223e8 100644 --- a/pc/video_rtp_track_source_unittest.cc +++ b/pc/video_rtp_track_source_unittest.cc @@ -19,6 +19,7 @@ #include "api/video/encoded_image.h" #include "api/video/recordable_encoded_frame.h" #include "api/video/video_codec_type.h" +#include "api/video/video_rotation.h" #include "api/video/video_sink_interface.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/pc/video_track.h b/pc/video_track.h index 4c415505e4..7e5f2db85b 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -11,9 +11,9 @@ #ifndef PC_VIDEO_TRACK_H_ #define PC_VIDEO_TRACK_H_ -#include #include +#include "absl/strings/string_view.h" #include "api/media_stream_interface.h" #include "api/media_stream_track.h" #include "api/scoped_refptr.h" diff --git a/pc/video_track_source.h b/pc/video_track_source.h index 644c11f27e..4b8c6ccd18 100644 --- a/pc/video_track_source.h +++ b/pc/video_track_source.h @@ -21,7 +21,6 @@ #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" #include "media/base/media_channel.h" -#include "rtc_base/checks.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/thread_annotations.h" diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index 6e434676f9..4adec0a80a 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -10,10 +10,9 @@ #include "pc/webrtc_sdp.h" -#include -#include - #include +#include +#include #include #include #include @@ -1769,7 +1768,7 @@ bool ParseSessionDescription(absl::string_view message, return false; } } else if (HasAttribute(*aline, kAttributeFingerprint)) { - if (session_td->identity_fingerprint.get()) { + if (session_td->identity_fingerprint) { return ParseFailed( *aline, "Can't have multiple fingerprint attributes at the same level.", @@ -3127,7 +3126,7 @@ bool ParseMediaDescription( unsupported_desc->set_protocol(protocol); content = std::move(unsupported_desc); } - if (!content.get()) { + if (!content) { // ParseContentDescription returns NULL if failed. return false; } diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc index 5bb0a0c5b8..1f2e29fe3a 100644 --- a/pc/webrtc_sdp_unittest.cc +++ b/pc/webrtc_sdp_unittest.cc @@ -8,10 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - #include +#include +#include #include #include #include @@ -64,39 +63,45 @@ using ::testing::ElementsAre; using ::testing::Field; using ::testing::Property; -const uint32_t kDefaultSctpPort = 5000; -const uint16_t kUnusualSctpPort = 9556; -const char kSessionTime[] = "t=0 0\r\n"; -const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0 -const char kAttributeIceUfragVoice[] = "a=ice-ufrag:ufrag_voice\r\n"; -const char kAttributeIcePwdVoice[] = "a=ice-pwd:pwd_voice\r\n"; -const char kAttributeIceUfragVideo[] = "a=ice-ufrag:ufrag_video\r\n"; -const char kAttributeIcePwdVideo[] = "a=ice-pwd:pwd_video\r\n"; -const uint32_t kCandidateGeneration = 2; -const char kCandidateFoundation1[] = "a0+B/1"; -const char kCandidateFoundation2[] = "a0+B/2"; -const char kCandidateFoundation3[] = "a0+B/3"; -const char kCandidateFoundation4[] = "a0+B/4"; -const char kFingerprint[] = +constexpr uint32_t kDefaultSctpPort = 5000; +constexpr uint16_t kUnusualSctpPort = 9556; +constexpr char kSessionTime[] = "t=0 0\r\n"; +constexpr uint32_t kCandidatePriority = 2130706432U; // pref = 1.0 +constexpr char kAttributeIceUfragVoice[] = "a=ice-ufrag:ufrag_voice\r\n"; +constexpr char kAttributeIcePwdVoice[] = "a=ice-pwd:pwd_voice\r\n"; +constexpr char kAttributeIceUfragVideo[] = "a=ice-ufrag:ufrag_video\r\n"; +constexpr char kAttributeIcePwdVideo[] = "a=ice-pwd:pwd_video\r\n"; +constexpr uint32_t kCandidateGeneration = 2; +constexpr char kCandidateFoundation1[] = "a0+B/1"; +constexpr char kCandidateFoundation2[] = "a0+B/2"; +constexpr char kCandidateFoundation3[] = "a0+B/3"; +constexpr char kCandidateFoundation4[] = "a0+B/4"; +constexpr char kFingerprint[] = "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"; -const char kExtmapAllowMixed[] = "a=extmap-allow-mixed\r\n"; -const int kExtmapId = 1; -const char kExtmapUri[] = "http://example.com/082005/ext.htm#ttime"; -const char kExtmap[] = "a=extmap:1 http://example.com/082005/ext.htm#ttime\r\n"; -const char kExtmapWithDirectionAndAttribute[] = +constexpr char kExtmapAllowMixed[] = "a=extmap-allow-mixed\r\n"; +constexpr int kExtmapId = 1; +constexpr char kExtmapUri[] = "http://example.com/082005/ext.htm#ttime"; +constexpr char kExtmap[] = + "a=extmap:1 http://example.com/082005/ext.htm#ttime\r\n"; +constexpr char kExtmapWithDirectionAndAttribute[] = "a=extmap:1/sendrecv http://example.com/082005/ext.htm#ttime a1 a2\r\n"; -const char kExtmapWithDirectionAndAttributeEncrypted[] = +constexpr char kExtmapWithDirectionAndAttributeEncrypted[] = "a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:encrypt " "http://example.com/082005/ext.htm#ttime a1 a2\r\n"; -const uint8_t kIdentityDigest[] = {0x4A, 0xAD, 0xB9, 0xB1, 0x3F, 0x82, 0x18, - 0x3B, 0x54, 0x02, 0x12, 0xDF, 0x3E, 0x5D, - 0x49, 0x6B, 0x19, 0xE5, 0x7C, 0xAB}; +constexpr uint8_t kIdentityDigest[] = {0x4A, 0xAD, 0xB9, 0xB1, 0x3F, 0x82, 0x18, + 0x3B, 0x54, 0x02, 0x12, 0xDF, 0x3E, 0x5D, + 0x49, 0x6B, 0x19, 0xE5, 0x7C, 0xAB}; + +constexpr char kDtlsSctp[] = "DTLS/SCTP"; +constexpr char kUdpDtlsSctp[] = "UDP/DTLS/SCTP"; +constexpr char kTcpDtlsSctp[] = "TCP/DTLS/SCTP"; -const char kDtlsSctp[] = "DTLS/SCTP"; -const char kUdpDtlsSctp[] = "UDP/DTLS/SCTP"; -const char kTcpDtlsSctp[] = "TCP/DTLS/SCTP"; +constexpr char kMediaSectionMsidLine[] = + "a=msid:local_stream_1 audio_track_id_1"; +constexpr char kSsrcAttributeMsidLine[] = + "a=ssrc:1 msid:local_stream_1 audio_track_id_1"; struct CodecParams { int max_ptime; @@ -109,7 +114,7 @@ struct CodecParams { }; // Reference sdp string -const char kSdpFullString[] = +constexpr char kSdpFullString[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -172,7 +177,7 @@ const char kSdpFullString[] = "a=ssrc:3 cname:stream_1_cname\r\n"; // SDP reference string without the candidates. -const char kSdpString[] = +constexpr char kSdpString[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -211,7 +216,7 @@ const char kSdpString[] = "a=ssrc:3 cname:stream_1_cname\r\n"; // draft-ietf-mmusic-sctp-sdp-03 -const char kSdpSctpDataChannelString[] = +constexpr char kSdpSctpDataChannelString[] = "m=application 9 UDP/DTLS/SCTP 5000\r\n" "c=IN IP4 0.0.0.0\r\n" "a=ice-ufrag:ufrag_data\r\n" @@ -225,7 +230,7 @@ const char kSdpSctpDataChannelString[] = // draft-ietf-mmusic-sctp-sdp-12 // Note - this is invalid per draft-ietf-mmusic-sctp-sdp-26, // since the separator after "sctp-port" needs to be a colon. -const char kSdpSctpDataChannelStringWithSctpPort[] = +constexpr char kSdpSctpDataChannelStringWithSctpPort[] = "m=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n" "a=sctp-port 5000\r\n" "c=IN IP4 0.0.0.0\r\n" @@ -237,7 +242,7 @@ const char kSdpSctpDataChannelStringWithSctpPort[] = "a=mid:data_content_name\r\n"; // draft-ietf-mmusic-sctp-sdp-26 -const char kSdpSctpDataChannelStringWithSctpColonPort[] = +constexpr char kSdpSctpDataChannelStringWithSctpColonPort[] = "m=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n" "a=sctp-port:5000\r\n" "c=IN IP4 0.0.0.0\r\n" @@ -248,7 +253,7 @@ const char kSdpSctpDataChannelStringWithSctpColonPort[] = "a=mid:data_content_name\r\n"; -const char kSdpSctpDataChannelWithCandidatesString[] = +constexpr char kSdpSctpDataChannelWithCandidatesString[] = "m=application 2345 UDP/DTLS/SCTP 5000\r\n" "c=IN IP4 74.125.127.126\r\n" "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host " @@ -266,7 +271,7 @@ const char kSdpSctpDataChannelWithCandidatesString[] = "a=mid:data_content_name\r\n" "a=sctpmap:5000 webrtc-datachannel 1024\r\n"; -const char kSdpConferenceString[] = +constexpr char kSdpConferenceString[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -279,14 +284,14 @@ const char kSdpConferenceString[] = "c=IN IP4 0.0.0.0\r\n" "a=x-google-flag:conference\r\n"; -const char kSdpSessionString[] = +constexpr char kSdpSessionString[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" "t=0 0\r\n" "a=msid-semantic: WMS local_stream\r\n"; -const char kSdpAudioString[] = +constexpr char kSdpAudioString[] = "m=audio 9 RTP/SAVPF 111\r\n" "c=IN IP4 0.0.0.0\r\n" "a=rtcp:9 IN IP4 0.0.0.0\r\n" @@ -300,7 +305,7 @@ const char kSdpAudioString[] = "a=ssrc:1 cname:stream_1_cname\r\n" "a=ssrc:1 msid:local_stream audio_track_id_1\r\n"; -const char kSdpVideoString[] = +constexpr char kSdpVideoString[] = "m=video 9 RTP/SAVPF 120\r\n" "c=IN IP4 0.0.0.0\r\n" "a=rtcp:9 IN IP4 0.0.0.0\r\n" @@ -315,7 +320,7 @@ const char kSdpVideoString[] = "a=ssrc:2 msid:local_stream video_track_id_1\r\n"; // Reference sdp string using bundle-only. -const char kBundleOnlySdpFullString[] = +constexpr char kBundleOnlySdpFullString[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -369,7 +374,7 @@ const char kBundleOnlySdpFullString[] = // Plan B SDP reference string, with 2 streams, 2 audio tracks and 3 video // tracks. -const char kPlanBSdpFullString[] = +constexpr char kPlanBSdpFullString[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -442,7 +447,7 @@ const char kPlanBSdpFullString[] = // Unified Plan SDP reference string, with 2 streams, 2 audio tracks and 3 video // tracks. -const char kUnifiedPlanSdpFullString[] = +constexpr char kUnifiedPlanSdpFullString[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -558,7 +563,7 @@ const char kUnifiedPlanSdpFullString[] = // there are 0 media stream ids. // This Unified Plan SDP represents a SDP that signals the msid using both // a=msid and a=ssrc msid semantics. -const char kUnifiedPlanSdpFullStringWithSpecialMsid[] = +constexpr char kUnifiedPlanSdpFullStringWithSpecialMsid[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -638,7 +643,7 @@ const char kUnifiedPlanSdpFullStringWithSpecialMsid[] = "a=ssrc:7 msid:- audio_track_id_3\r\n"; // SDP string for unified plan without SSRCs -const char kUnifiedPlanSdpFullStringNoSsrc[] = +constexpr char kUnifiedPlanSdpFullStringNoSsrc[] = "v=0\r\n" "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n" "s=-\r\n" @@ -732,101 +737,101 @@ const char kUnifiedPlanSdpFullStringNoSsrc[] = // One candidate reference string as per W3c spec. // candidate: not a=candidate:CRLF -const char kRawCandidate[] = +constexpr char kRawCandidate[] = "candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host generation 2"; // One candidate reference string. -const char kSdpOneCandidate[] = +constexpr char kSdpOneCandidate[] = "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host " "generation 2\r\n"; -const char kSdpTcpActiveCandidate[] = +constexpr char kSdpTcpActiveCandidate[] = "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host " "tcptype active generation 2"; -const char kSdpTcpPassiveCandidate[] = +constexpr char kSdpTcpPassiveCandidate[] = "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host " "tcptype passive generation 2"; -const char kSdpTcpSOCandidate[] = +constexpr char kSdpTcpSOCandidate[] = "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host " "tcptype so generation 2"; -const char kSdpTcpInvalidCandidate[] = +constexpr char kSdpTcpInvalidCandidate[] = "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host " "tcptype invalid generation 2"; // One candidate reference string with IPV6 address. -const char kRawIPV6Candidate[] = +constexpr char kRawIPV6Candidate[] = "candidate:a0+B/1 1 udp 2130706432 " "abcd:abcd:abcd:abcd:abcd:abcd:abcd:abcd 1234 typ host generation 2"; // One candidate reference string. -const char kSdpOneCandidateWithUfragPwd[] = +constexpr char kSdpOneCandidateWithUfragPwd[] = "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host network_name" " eth0 ufrag user_rtp pwd password_rtp generation 2\r\n"; -const char kRawHostnameCandidate[] = +constexpr char kRawHostnameCandidate[] = "candidate:a0+B/1 1 udp 2130706432 a.test 1234 typ host generation 2"; // Session id and version -const char kSessionId[] = "18446744069414584320"; -const char kSessionVersion[] = "18446462598732840960"; +constexpr char kSessionId[] = "18446744069414584320"; +constexpr char kSessionVersion[] = "18446462598732840960"; // ICE options. -const char kIceOption1[] = "iceoption1"; -const char kIceOption2[] = "iceoption2"; -const char kIceOption3[] = "iceoption3"; +constexpr char kIceOption1[] = "iceoption1"; +constexpr char kIceOption2[] = "iceoption2"; +constexpr char kIceOption3[] = "iceoption3"; // ICE ufrags/passwords. -const char kUfragVoice[] = "ufrag_voice"; -const char kPwdVoice[] = "pwd_voice"; -const char kUfragVideo[] = "ufrag_video"; -const char kPwdVideo[] = "pwd_video"; -const char kUfragData[] = "ufrag_data"; -const char kPwdData[] = "pwd_data"; +constexpr char kUfragVoice[] = "ufrag_voice"; +constexpr char kPwdVoice[] = "pwd_voice"; +constexpr char kUfragVideo[] = "ufrag_video"; +constexpr char kPwdVideo[] = "pwd_video"; +constexpr char kUfragData[] = "ufrag_data"; +constexpr char kPwdData[] = "pwd_data"; // Extra ufrags/passwords for extra unified plan m= sections. -const char kUfragVoice2[] = "ufrag_voice_2"; -const char kPwdVoice2[] = "pwd_voice_2"; -const char kUfragVoice3[] = "ufrag_voice_3"; -const char kPwdVoice3[] = "pwd_voice_3"; -const char kUfragVideo2[] = "ufrag_video_2"; -const char kPwdVideo2[] = "pwd_video_2"; -const char kUfragVideo3[] = "ufrag_video_3"; -const char kPwdVideo3[] = "pwd_video_3"; +constexpr char kUfragVoice2[] = "ufrag_voice_2"; +constexpr char kPwdVoice2[] = "pwd_voice_2"; +constexpr char kUfragVoice3[] = "ufrag_voice_3"; +constexpr char kPwdVoice3[] = "pwd_voice_3"; +constexpr char kUfragVideo2[] = "ufrag_video_2"; +constexpr char kPwdVideo2[] = "pwd_video_2"; +constexpr char kUfragVideo3[] = "ufrag_video_3"; +constexpr char kPwdVideo3[] = "pwd_video_3"; // Content name -const char kAudioContentName[] = "audio_content_name"; -const char kVideoContentName[] = "video_content_name"; -const char kDataContentName[] = "data_content_name"; +constexpr char kAudioContentName[] = "audio_content_name"; +constexpr char kVideoContentName[] = "video_content_name"; +constexpr char kDataContentName[] = "data_content_name"; // Extra content names for extra unified plan m= sections. -const char kAudioContentName2[] = "audio_content_name_2"; -const char kAudioContentName3[] = "audio_content_name_3"; -const char kVideoContentName2[] = "video_content_name_2"; -const char kVideoContentName3[] = "video_content_name_3"; +constexpr char kAudioContentName2[] = "audio_content_name_2"; +constexpr char kAudioContentName3[] = "audio_content_name_3"; +constexpr char kVideoContentName2[] = "video_content_name_2"; +constexpr char kVideoContentName3[] = "video_content_name_3"; // MediaStream 1 -const char kStreamId1[] = "local_stream_1"; -const char kStream1Cname[] = "stream_1_cname"; -const char kAudioTrackId1[] = "audio_track_id_1"; -const uint32_t kAudioTrack1Ssrc = 1; -const char kVideoTrackId1[] = "video_track_id_1"; -const uint32_t kVideoTrack1Ssrc1 = 2; -const uint32_t kVideoTrack1Ssrc2 = 3; +constexpr char kStreamId1[] = "local_stream_1"; +constexpr char kStream1Cname[] = "stream_1_cname"; +constexpr char kAudioTrackId1[] = "audio_track_id_1"; +constexpr uint32_t kAudioTrack1Ssrc = 1; +constexpr char kVideoTrackId1[] = "video_track_id_1"; +constexpr uint32_t kVideoTrack1Ssrc1 = 2; +constexpr uint32_t kVideoTrack1Ssrc2 = 3; // MediaStream 2 -const char kStreamId2[] = "local_stream_2"; -const char kStream2Cname[] = "stream_2_cname"; -const char kAudioTrackId2[] = "audio_track_id_2"; -const uint32_t kAudioTrack2Ssrc = 4; -const char kVideoTrackId2[] = "video_track_id_2"; -const uint32_t kVideoTrack2Ssrc = 5; -const char kVideoTrackId3[] = "video_track_id_3"; -const uint32_t kVideoTrack3Ssrc = 6; -const char kAudioTrackId3[] = "audio_track_id_3"; -const uint32_t kAudioTrack3Ssrc = 7; +constexpr char kStreamId2[] = "local_stream_2"; +constexpr char kStream2Cname[] = "stream_2_cname"; +constexpr char kAudioTrackId2[] = "audio_track_id_2"; +constexpr uint32_t kAudioTrack2Ssrc = 4; +constexpr char kVideoTrackId2[] = "video_track_id_2"; +constexpr uint32_t kVideoTrack2Ssrc = 5; +constexpr char kVideoTrackId3[] = "video_track_id_3"; +constexpr uint32_t kVideoTrack3Ssrc = 6; +constexpr char kAudioTrackId3[] = "audio_track_id_3"; +constexpr uint32_t kAudioTrack3Ssrc = 7; // Candidate -const char kDummyMid[] = "dummy_mid"; -const int kDummyIndex = 123; +constexpr char kDummyMid[] = "dummy_mid"; +constexpr int kDummyIndex = 123; // Misc SdpType kDummyType = SdpType::kOffer; @@ -1076,13 +1081,12 @@ class WebRtcSdpTest : public ::testing::Test { const IceCandidateCollection* video_candidates_collection = jdesc_.candidates(1); ASSERT_NE(nullptr, video_candidates_collection); - std::vector video_candidates; - for (size_t i = 0; i < video_candidates_collection->count(); ++i) { - Candidate c = video_candidates_collection->at(i)->candidate(); - c.set_transport_name("video_content_name"); - video_candidates.push_back(c); + // Since this loop modifies video_candidates_collection, just loop until + // it's empty instead of using a for loop. + while (!video_candidates_collection->candidates().empty()) { + ASSERT_TRUE(jdesc_.RemoveCandidate( + video_candidates_collection->candidates().back().get())); } - jdesc_.RemoveCandidates(video_candidates); } // Turns the existing reference description into a description using @@ -3745,10 +3749,6 @@ TEST_F(WebRtcSdpTest, UnifiedPlanHasMediaSectionMsidSignaling) { jsep_desc.description()->msid_signaling()); } -const char kMediaSectionMsidLine[] = "a=msid:local_stream_1 audio_track_id_1"; -const char kSsrcAttributeMsidLine[] = - "a=ssrc:1 msid:local_stream_1 audio_track_id_1"; - TEST_F(WebRtcSdpTest, SerializeOnlyMediaSectionMsid) { jdesc_.description()->set_msid_signaling(kMsidSignalingMediaSection); std::string sdp = SdpSerialize(jdesc_); diff --git a/pc/webrtc_session_description_factory.cc b/pc/webrtc_session_description_factory.cc index 2c59f9e5f0..248991b5b0 100644 --- a/pc/webrtc_session_description_factory.cc +++ b/pc/webrtc_session_description_factory.cc @@ -10,8 +10,7 @@ #include "pc/webrtc_session_description_factory.h" -#include - +#include #include #include #include diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 216b91fcfd..62268d946d 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -181,8 +181,10 @@ rtc_library("copy_on_write_buffer") { rtc_library("denormal_disabler") { visibility = [ "*" ] - public = [ "denormal_disabler.h" ] - sources = [ "denormal_disabler.cc" ] + sources = [ + "denormal_disabler.cc", + "denormal_disabler.h", + ] deps = [ "../rtc_base:checks", "../rtc_base/system:arch", @@ -419,7 +421,6 @@ rtc_library("rtc_event") { ] deps = [ ":checks", - ":timeutils", "../api/units:time_delta", "synchronization:yield_policy", "system:warn_current_thread_is_deadlocked", @@ -1007,7 +1008,6 @@ rtc_library("threading") { "../api/transport:ecn_marking", "../api/units:time_delta", "../api/units:timestamp", - "./network:ecn_marking", "synchronization:mutex", "system:no_unique_address", "system:rtc_export", @@ -1059,8 +1059,8 @@ rtc_library("socket") { ":ip_address", ":net_helpers", ":socket_address", + "../api/transport:ecn_marking", "../api/units:timestamp", - "./network:ecn_marking", "system:rtc_export", "third_party/sigslot", ] @@ -1341,7 +1341,6 @@ rtc_library("async_packet_socket") { if (rtc_include_tests) { rtc_library("async_packet_socket_unittest") { testonly = true - visibility = [ "*" ] sources = [ "async_packet_socket_unittest.cc" ] deps = [ ":async_packet_socket", @@ -1356,7 +1355,6 @@ if (rtc_include_tests) { rtc_library("async_udp_socket_unittest") { testonly = true - visibility = [ "*" ] sources = [ "async_udp_socket_unittest.cc" ] deps = [ ":async_packet_socket", @@ -1371,6 +1369,20 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/memory", ] } + rtc_library("async_tcp_socket_unittest") { + testonly = true + sources = [ "async_tcp_socket_unittest.cc" ] + deps = [ + ":async_packet_socket", + ":async_tcp_socket", + ":gunit_helpers", + ":net_helpers", + ":rtc_base_tests_utils", + ":socket", + "../test:test_support", + "third_party/sigslot", + ] + } } rtc_library("mdns_responder_interface") { @@ -1741,6 +1753,7 @@ rtc_library("rtc_base_tests_utils") { ":async_udp_socket", ":buffer", ":byte_buffer", + ":byte_order", ":checks", ":digest", ":ip_address", @@ -1779,8 +1792,8 @@ rtc_library("rtc_base_tests_utils") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//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" ] @@ -1823,77 +1836,46 @@ rtc_library("task_queue_for_test") { ] } -rtc_library("base64") { - sources = [ - "base64.cc", - "base64.h", - ] - deps = [ - "../api:array_view", - "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/strings:string_view", - ] -} - -if (rtc_rusty_base64) { - import("//build/config/rust.gni") - import("//build/rust/rust_static_library.gni") - - rtc_source_set("base64_header") { - sources = [ "base64.h" ] +# Base64 implementation is backed by either Rust or Abseil. +if (!rtc_rusty_base64) { + # abseil backed base64. + rtc_library("base64") { + sources = [ + "base64.cc", + "base64.h", + ] deps = [ "../api:array_view", + "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", ] } +} else { + import("//build/config/rust.gni") + import("//build/rust/rust_static_library.gni") 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" ] + deps = [ "//third_party/rust/base64/v0_22:lib" ] + visibility = [ ":base64" ] } - rtc_library("rusty_base64") { - sources = [ "base64_rust.cc" ] + rtc_library("base64") { + sources = [ + "base64.h", + "base64_rust.cc", + ] deps = [ - ":base64_header", ":base64_rust_bridge", + "../api:array_view", "//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") { @@ -2007,7 +1989,6 @@ if (rtc_include_tests) { "../test:test_main", "../test:test_support", "../test:wait_until", - "network:ecn_marking", "system:file_wrapper", "third_party/sigslot", "//testing/gtest", @@ -2160,6 +2141,7 @@ if (rtc_include_tests) { ":rtc_event", ":task_queue_for_test", ":timeutils", + "../api/task_queue", "../api/units:time_delta", "../test:test_main", "../test:test_support", @@ -2248,6 +2230,7 @@ if (rtc_include_tests) { ":async_udp_socket", ":buffer", ":buffer_queue", + ":byte_order", ":checks", ":crc32", ":crypto_random", diff --git a/rtc_base/async_dns_resolver.cc b/rtc_base/async_dns_resolver.cc index a3d3f1e76a..b11175a475 100644 --- a/rtc_base/async_dns_resolver.cc +++ b/rtc_base/async_dns_resolver.cc @@ -31,6 +31,10 @@ #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" +#if defined(WEBRTC_POSIX) +#include +#endif + #if defined(WEBRTC_MAC) || defined(WEBRTC_IOS) #include #endif @@ -39,15 +43,6 @@ namespace webrtc { namespace { -#ifdef __native_client__ -int ResolveHostname(absl::string_view hostname, - int family, - std::vector* addresses) { - RTC_DCHECK_NOTREACHED(); - RTC_LOG(LS_WARNING) << "ResolveHostname() is not implemented for NaCl"; - return -1; -} -#else // notdef(__native_client__) int ResolveHostname(absl::string_view hostname, int family, std::vector& addresses) { @@ -90,7 +85,6 @@ int ResolveHostname(absl::string_view hostname, freeaddrinfo(result); return 0; } -#endif // !__native_client__ // Special task posting for Mac/iOS #if defined(WEBRTC_MAC) || defined(WEBRTC_IOS) diff --git a/rtc_base/async_dns_resolver_unittest.cc b/rtc_base/async_dns_resolver_unittest.cc index ae03b204b2..f60032bc3e 100644 --- a/rtc_base/async_dns_resolver_unittest.cc +++ b/rtc_base/async_dns_resolver_unittest.cc @@ -28,8 +28,8 @@ namespace { using ::testing::IsTrue; -const TimeDelta kDefaultTimeout = TimeDelta::Millis(1000); -const int kPortNumber = 3027; +constexpr TimeDelta kDefaultTimeout = TimeDelta::Millis(1000); +constexpr int kPortNumber = 3027; TEST(AsyncDnsResolver, ConstructorWorks) { AsyncDnsResolver resolver; diff --git a/rtc_base/async_packet_socket.h b/rtc_base/async_packet_socket.h index b1a20452ed..1c75080acc 100644 --- a/rtc_base/async_packet_socket.h +++ b/rtc_base/async_packet_socket.h @@ -200,16 +200,5 @@ void CopySocketInformationToPacketInfo(size_t packet_size_bytes, } // 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::AsyncListenSocket; -using ::webrtc::AsyncPacketSocket; -using ::webrtc::CopySocketInformationToPacketInfo; -using ::webrtc::PacketTimeUpdateParams; -using PacketOptions = ::webrtc::AsyncSocketPacketOptions; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_ASYNC_PACKET_SOCKET_H_ diff --git a/rtc_base/async_socket.h b/rtc_base/async_socket.h index efd0ced760..33de0b024e 100644 --- a/rtc_base/async_socket.h +++ b/rtc_base/async_socket.h @@ -62,12 +62,5 @@ class AsyncSocketAdapter : public Socket, public sigslot::has_slots<> { } // 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::AsyncSocketAdapter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_ASYNC_SOCKET_H_ diff --git a/rtc_base/async_tcp_socket.cc b/rtc_base/async_tcp_socket.cc index a13549cdeb..b6046ebd0f 100644 --- a/rtc_base/async_tcp_socket.cc +++ b/rtc_base/async_tcp_socket.cc @@ -10,12 +10,10 @@ #include "rtc_base/async_tcp_socket.h" -#include -#include - #include #include #include +#include #include #include @@ -29,10 +27,10 @@ #include "rtc_base/network/sent_packet.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" -#include "rtc_base/time_utils.h" // for TimeMillis +#include "rtc_base/time_utils.h" #if defined(WEBRTC_POSIX) -#include +#include #endif // WEBRTC_POSIX namespace webrtc { diff --git a/rtc_base/async_tcp_socket.h b/rtc_base/async_tcp_socket.h index daf890cdaa..6cf489115d 100644 --- a/rtc_base/async_tcp_socket.h +++ b/rtc_base/async_tcp_socket.h @@ -123,14 +123,5 @@ class AsyncTcpListenSocket : public AsyncListenSocket { } // 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::AsyncTcpListenSocket; -using ::webrtc::AsyncTCPSocket; -using ::webrtc::AsyncTCPSocketBase; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_ASYNC_TCP_SOCKET_H_ diff --git a/rtc_base/async_tcp_socket_unittest.cc b/rtc_base/async_tcp_socket_unittest.cc index f531ed9cc2..682a51c245 100644 --- a/rtc_base/async_tcp_socket_unittest.cc +++ b/rtc_base/async_tcp_socket_unittest.cc @@ -11,10 +11,13 @@ #include "rtc_base/async_tcp_socket.h" #include -#include -#include "rtc_base/gunit.h" +#include "rtc_base/async_packet_socket.h" +#include "rtc_base/net_helpers.h" +#include "rtc_base/socket.h" +#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/virtual_socket_server.h" +#include "test/gtest.h" namespace webrtc { @@ -22,8 +25,8 @@ class AsyncTCPSocketTest : public ::testing::Test, public sigslot::has_slots<> { public: AsyncTCPSocketTest() : vss_(new VirtualSocketServer()), - socket_(vss_->CreateSocket(SOCK_STREAM)), - tcp_socket_(new AsyncTCPSocket(socket_, true)), + socket_(vss_->CreateSocket(AF_INET, SOCK_STREAM)), + tcp_socket_(new AsyncTCPSocket(socket_)), ready_to_send_(false) { tcp_socket_->SignalReadyToSend.connect(this, &AsyncTCPSocketTest::OnReadyToSend); diff --git a/rtc_base/async_udp_socket.h b/rtc_base/async_udp_socket.h index 8f30ce7fa0..df078ac482 100644 --- a/rtc_base/async_udp_socket.h +++ b/rtc_base/async_udp_socket.h @@ -77,12 +77,5 @@ class AsyncUDPSocket : public AsyncPacketSocket { } // 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::AsyncUDPSocket; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_ASYNC_UDP_SOCKET_H_ diff --git a/rtc_base/base64.rs b/rtc_base/base64.rs index f9397dd457..68c0251619 100644 --- a/rtc_base/base64.rs +++ b/rtc_base/base64.rs @@ -18,21 +18,16 @@ 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; + enum Base64DecodeSetting { + Strict, + Forgiving, } extern "Rust" { fn rs_base64_encode(data: &[u8]) -> String; fn rs_base64_decode( data: &[u8], - options: Base64DecodeOptions, + options: Base64DecodeSetting, output: Pin<&mut CxxString>, ) -> bool; } @@ -50,12 +45,12 @@ const FORGIVING_ENGINE: general_purpose::GeneralPurpose = general_purpose::Gener fn rs_base64_decode( data: &[u8], - options: ffi::Base64DecodeOptions, + options: ffi::Base64DecodeSetting, output: Pin<&mut CxxString>, ) -> bool { let result = match options { - ffi::Base64DecodeOptions::kStrict => general_purpose::STANDARD.decode(data), - ffi::Base64DecodeOptions::kForgiving => { + ffi::Base64DecodeSetting::Strict => general_purpose::STANDARD.decode(data), + ffi::Base64DecodeSetting::Forgiving => { let data_without_whitespace: Vec = data.iter().filter(|&c| !c.is_ascii_whitespace()).copied().collect(); FORGIVING_ENGINE.decode(data_without_whitespace) diff --git a/rtc_base/base64_rust.cc b/rtc_base/base64_rust.cc index 30061046c9..bc0b01a1ca 100644 --- a/rtc_base/base64_rust.cc +++ b/rtc_base/base64_rust.cc @@ -19,6 +19,19 @@ namespace webrtc { +namespace { + +Base64DecodeSetting ToRustDecodeSetting(Base64DecodeOptions options) { + switch (options) { + case Base64DecodeOptions::kStrict: + return Base64DecodeSetting::Strict; + case Base64DecodeOptions::kForgiving: + return Base64DecodeSetting::Forgiving; + } +} + +} // namespace + std::string Base64Encode(absl::string_view data) { rust::Slice input_slice( reinterpret_cast(data.data()), data.size()); @@ -32,7 +45,7 @@ std::optional Base64Decode(absl::string_view data, rust::Slice input_slice( reinterpret_cast(data.data()), data.size()); std::string output; - if (!rs_base64_decode(input_slice, options, output)) { + if (!rs_base64_decode(input_slice, ToRustDecodeSetting(options), output)) { return std::nullopt; } return output; diff --git a/rtc_base/bit_buffer.h b/rtc_base/bit_buffer.h index 870ddc883b..105acac2b6 100644 --- a/rtc_base/bit_buffer.h +++ b/rtc_base/bit_buffer.h @@ -96,12 +96,5 @@ class BitBufferWriter { } // 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::BitBufferWriter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_BIT_BUFFER_H_ diff --git a/rtc_base/bitstream_reader.cc b/rtc_base/bitstream_reader.cc index 3a5372133f..fb61bc78f0 100644 --- a/rtc_base/bitstream_reader.cc +++ b/rtc_base/bitstream_reader.cc @@ -10,9 +10,8 @@ #include "rtc_base/bitstream_reader.h" -#include - #include +#include #include #include "absl/numeric/bits.h" diff --git a/rtc_base/bitstream_reader_unittest.cc b/rtc_base/bitstream_reader_unittest.cc index c85d05452b..4d76546f69 100644 --- a/rtc_base/bitstream_reader_unittest.cc +++ b/rtc_base/bitstream_reader_unittest.cc @@ -10,10 +10,9 @@ #include "rtc_base/bitstream_reader.h" -#include -#include - #include +#include +#include #include #include #include diff --git a/rtc_base/boringssl_certificate.h b/rtc_base/boringssl_certificate.h index 926dd332ec..b5a18d0843 100644 --- a/rtc_base/boringssl_certificate.h +++ b/rtc_base/boringssl_certificate.h @@ -70,12 +70,5 @@ class BoringSSLCertificate final : public SSLCertificate { } // 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::BoringSSLCertificate; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_BORINGSSL_CERTIFICATE_H_ diff --git a/rtc_base/boringssl_identity.cc b/rtc_base/boringssl_identity.cc index 4406962fac..007c99a764 100644 --- a/rtc_base/boringssl_identity.cc +++ b/rtc_base/boringssl_identity.cc @@ -14,9 +14,9 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -175,7 +175,7 @@ const BoringSSLCertificate& BoringSSLIdentity::certificate() const { } const SSLCertChain& BoringSSLIdentity::cert_chain() const { - return *cert_chain_.get(); + return *cert_chain_; } std::unique_ptr BoringSSLIdentity::CloneInternal() const { diff --git a/rtc_base/boringssl_identity.h b/rtc_base/boringssl_identity.h index 1c6f5ab377..e361d2ff3f 100644 --- a/rtc_base/boringssl_identity.h +++ b/rtc_base/boringssl_identity.h @@ -74,12 +74,5 @@ class BoringSSLIdentity final : public SSLIdentity { } // 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::BoringSSLIdentity; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_BORINGSSL_IDENTITY_H_ diff --git a/rtc_base/buffer.h b/rtc_base/buffer.h index 95e8857ed4..f4b86a3e24 100644 --- a/rtc_base/buffer.h +++ b/rtc_base/buffer.h @@ -449,16 +449,5 @@ using ZeroOnFreeBuffer = BufferT; } // 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 { -template -using BufferT = ::webrtc::BufferT; -using ::webrtc::Buffer; -template -using ZeroOnFreeBuffer = ::webrtc::ZeroOnFreeBuffer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_BUFFER_H_ diff --git a/rtc_base/buffer_queue.cc b/rtc_base/buffer_queue.cc index c23365c130..e791e91322 100644 --- a/rtc_base/buffer_queue.cc +++ b/rtc_base/buffer_queue.cc @@ -10,10 +10,9 @@ #include "rtc_base/buffer_queue.h" -#include -#include - #include +#include +#include #include "api/sequence_checker.h" #include "rtc_base/buffer.h" diff --git a/rtc_base/buffer_queue.h b/rtc_base/buffer_queue.h index fdcc2ba893..9d15b3da8c 100644 --- a/rtc_base/buffer_queue.h +++ b/rtc_base/buffer_queue.h @@ -67,12 +67,5 @@ class BufferQueue final { } // 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::BufferQueue; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_BUFFER_QUEUE_H_ diff --git a/rtc_base/buffer_queue_unittest.cc b/rtc_base/buffer_queue_unittest.cc index b0ebdd782d..7348e5f758 100644 --- a/rtc_base/buffer_queue_unittest.cc +++ b/rtc_base/buffer_queue_unittest.cc @@ -10,7 +10,7 @@ #include "rtc_base/buffer_queue.h" -#include +#include #include "test/gtest.h" diff --git a/rtc_base/buffer_unittest.cc b/rtc_base/buffer_unittest.cc index 47eb2e4931..405d8fbce6 100644 --- a/rtc_base/buffer_unittest.cc +++ b/rtc_base/buffer_unittest.cc @@ -28,10 +28,8 @@ namespace { using ::testing::ElementsAre; using ::testing::ElementsAreArray; -// clang-format off -const uint8_t kTestData[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, - 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; -// clang-format on +constexpr uint8_t kTestData[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, + 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; void TestBuf(const Buffer& b1, size_t size, size_t capacity) { EXPECT_EQ(b1.size(), size); diff --git a/rtc_base/byte_buffer.cc b/rtc_base/byte_buffer.cc index 0cf153fe7e..0b06d83426 100644 --- a/rtc_base/byte_buffer.cc +++ b/rtc_base/byte_buffer.cc @@ -10,9 +10,8 @@ #include "rtc_base/byte_buffer.h" -#include - #include +#include #include #include "absl/strings/string_view.h" diff --git a/rtc_base/byte_buffer.h b/rtc_base/byte_buffer.h index edf236a58f..cc7d6487a8 100644 --- a/rtc_base/byte_buffer.h +++ b/rtc_base/byte_buffer.h @@ -207,14 +207,5 @@ class ByteBufferReader { } // 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::ByteBufferReader; -using ::webrtc::ByteBufferWriter; -using ::webrtc::ByteBufferWriterT; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_BYTE_BUFFER_H_ diff --git a/rtc_base/byte_buffer_unittest.cc b/rtc_base/byte_buffer_unittest.cc index d0b93e2e22..07752b1092 100644 --- a/rtc_base/byte_buffer_unittest.cc +++ b/rtc_base/byte_buffer_unittest.cc @@ -10,9 +10,8 @@ #include "rtc_base/byte_buffer.h" -#include - #include +#include #include #include diff --git a/rtc_base/byte_order.h b/rtc_base/byte_order.h index 95c8ebc864..3a9bfe46e0 100644 --- a/rtc_base/byte_order.h +++ b/rtc_base/byte_order.h @@ -11,15 +11,16 @@ #ifndef RTC_BASE_BYTE_ORDER_H_ #define RTC_BASE_BYTE_ORDER_H_ -#include - +#include +#include #include -#if defined(WEBRTC_POSIX) && !defined(__native_client__) -#include +#include "rtc_base/system/arch.h" // IWYU pragma: keep + +#if defined(WEBRTC_POSIX) +#include // IWYU pragma: keep #endif -#include "rtc_base/system/arch.h" #if defined(WEBRTC_MAC) #include @@ -38,10 +39,9 @@ #define le32toh(v) OSSwapLittleToHostInt32(v) #define le64toh(v) OSSwapLittleToHostInt64(v) -#elif defined(WEBRTC_WIN) || defined(__native_client__) +#elif defined(WEBRTC_WIN) #if defined(WEBRTC_WIN) -#include #include #else #include // no-presubmit-check @@ -62,10 +62,6 @@ #define htobe64(v) _byteswap_uint64(v) #define be64toh(v) _byteswap_uint64(v) #endif // defined(WEBRTC_WIN) -#if defined(__native_client__) -#define htobe64(v) __builtin_bswap64(v) -#define be64toh(v) __builtin_bswap64(v) -#endif // defined(__native_client__) #elif defined(WEBRTC_ARCH_BIG_ENDIAN) #define htobe16(v) (v) @@ -82,10 +78,6 @@ #define htobe64(v) (v) #define be64toh(v) (v) #endif // defined(WEBRTC_WIN) -#if defined(__native_client__) -#define htobe64(v) (v) -#define be64toh(v) (v) -#endif // defined(__native_client__) #else #error WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN must be defined. #endif // defined(WEBRTC_ARCH_LITTLE_ENDIAN) @@ -209,32 +201,5 @@ inline uint64_t NetworkToHost64(uint64_t n) { } // 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::Get8; -using ::webrtc::GetBE16; -using ::webrtc::GetBE32; -using ::webrtc::GetBE64; -using ::webrtc::GetLE16; -using ::webrtc::GetLE32; -using ::webrtc::GetLE64; -using ::webrtc::HostToNetwork16; -using ::webrtc::HostToNetwork32; -using ::webrtc::HostToNetwork64; -using ::webrtc::IsHostBigEndian; -using ::webrtc::NetworkToHost16; -using ::webrtc::NetworkToHost32; -using ::webrtc::NetworkToHost64; -using ::webrtc::Set8; -using ::webrtc::SetBE16; -using ::webrtc::SetBE32; -using ::webrtc::SetBE64; -using ::webrtc::SetLE16; -using ::webrtc::SetLE32; -using ::webrtc::SetLE64; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_BYTE_ORDER_H_ diff --git a/rtc_base/byte_order_unittest.cc b/rtc_base/byte_order_unittest.cc index da31631452..8c1e10edf2 100644 --- a/rtc_base/byte_order_unittest.cc +++ b/rtc_base/byte_order_unittest.cc @@ -12,6 +12,8 @@ #include +#include + #include "test/gtest.h" namespace webrtc { diff --git a/rtc_base/checks.cc b/rtc_base/checks.cc index 6fa0514c36..a2e4079f23 100644 --- a/rtc_base/checks.cc +++ b/rtc_base/checks.cc @@ -11,9 +11,11 @@ // Most of this was borrowed (with minor modifications) from V8's and Chromium's // src/base/logging.cc. +#include #include #include #include +#include #include "absl/strings/string_view.h" @@ -28,10 +30,8 @@ #if defined(WEBRTC_WIN) #define LAST_SYSTEM_ERROR (::GetLastError()) -#elif defined(__native_client__) && __native_client__ -#define LAST_SYSTEM_ERROR (0) #elif defined(WEBRTC_POSIX) -#include +#include #define LAST_SYSTEM_ERROR (errno) #endif // WEBRTC_WIN diff --git a/rtc_base/checks.h b/rtc_base/checks.h index 838da2b7e5..992c98d4da 100644 --- a/rtc_base/checks.h +++ b/rtc_base/checks.h @@ -489,13 +489,6 @@ inline T CheckedDivExact(T a, T b) { } // 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::CheckedDivExact; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #else // __cplusplus not defined // C version. Lacks many features compared to the C++ version, but usage diff --git a/rtc_base/containers/BUILD.gn b/rtc_base/containers/BUILD.gn index f80dfce88f..2e29c91d9a 100644 --- a/rtc_base/containers/BUILD.gn +++ b/rtc_base/containers/BUILD.gn @@ -48,8 +48,8 @@ rtc_library("unittests") { ":flat_map", ":flat_set", "../../test:test_support", - "//testing/gmock:gmock", - "//testing/gtest:gtest", + "//testing/gmock", + "//testing/gtest", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", ] diff --git a/rtc_base/copy_on_write_buffer.cc b/rtc_base/copy_on_write_buffer.cc index ab53c9538a..3eaab59f8a 100644 --- a/rtc_base/copy_on_write_buffer.cc +++ b/rtc_base/copy_on_write_buffer.cc @@ -10,9 +10,8 @@ #include "rtc_base/copy_on_write_buffer.h" -#include - #include +#include #include #include diff --git a/rtc_base/copy_on_write_buffer.h b/rtc_base/copy_on_write_buffer.h index 7970fa9524..be8a261173 100644 --- a/rtc_base/copy_on_write_buffer.h +++ b/rtc_base/copy_on_write_buffer.h @@ -317,12 +317,5 @@ class RTC_EXPORT CopyOnWriteBuffer { } // 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::CopyOnWriteBuffer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_COPY_ON_WRITE_BUFFER_H_ diff --git a/rtc_base/copy_on_write_buffer_unittest.cc b/rtc_base/copy_on_write_buffer_unittest.cc index 6d73ee228e..59247e5762 100644 --- a/rtc_base/copy_on_write_buffer_unittest.cc +++ b/rtc_base/copy_on_write_buffer_unittest.cc @@ -24,10 +24,8 @@ namespace webrtc { namespace { -// clang-format off -const uint8_t kTestData[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, - 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; -// clang-format on +constexpr uint8_t kTestData[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, + 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; } // namespace diff --git a/rtc_base/cpu_info.cc b/rtc_base/cpu_info.cc index 56aba5ee63..32e2eb35b2 100644 --- a/rtc_base/cpu_info.cc +++ b/rtc_base/cpu_info.cc @@ -10,7 +10,15 @@ #include "rtc_base/cpu_info.h" +#include #include +#include +#include + +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" +#include "rtc_base/system/arch.h" +#include "rtc_base/system/unused.h" // IWYU pragma: keep #if defined(WEBRTC_WIN) #include @@ -22,36 +30,15 @@ #elif defined(WEBRTC_FUCHSIA) #include #elif defined(WEBRTC_LINUX) -#include -#include -#include // IWYU pragma: keep #include - -#ifdef __GLIBC_PREREQ -#define WEBRTC_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) -#else -#define WEBRTC_GLIBC_PREREQ(a, b) 0 -#endif - -#if WEBRTC_GLIBC_PREREQ(2, 16) -#include // IWYU pragma: keep -#else -#include -#include -#include -#endif #endif // WEBRTC_LINUX -#include "rtc_base/checks.h" -#include "rtc_base/logging.h" -#include "rtc_base/system/arch.h" -#include "rtc_base/system/unused.h" // IWYU pragma: keep - #if defined(WEBRTC_ARCH_X86_FAMILY) && defined(_MSC_VER) #include #endif #if defined(WEBRTC_ARCH_ARM_FAMILY) && defined(WEBRTC_LINUX) #include +#include #endif // Parts of this file derived from Chromium's base/cpu.cc. @@ -191,26 +178,7 @@ bool Supports(ISA instruction_set_architecture) { return 0 != (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON); #elif defined(WEBRTC_LINUX) uint64_t hwcap = 0; -#if WEBRTC_GLIBC_PREREQ(2, 16) hwcap = getauxval(AT_HWCAP); -#else - ElfW(auxv_t) auxv; - int fd = open("/proc/self/auxv", O_RDONLY); - if (fd >= 0) { - while (hwcap == 0) { - if (read(fd, &auxv, sizeof(auxv)) < (ssize_t)sizeof(auxv)) { - if (errno == EINTR) { - continue; - } - break; - } - if (AT_HWCAP == auxv.a_type) { - hwcap = auxv.a_un.a_val; - } - } - close(fd); - } -#endif // WEBRTC_GLIBC_PREREQ(2, 16) #if defined(__aarch64__) if ((hwcap & HWCAP_ASIMD) != 0) { return true; diff --git a/rtc_base/cpu_time.cc b/rtc_base/cpu_time.cc index 0ae890632e..2da8c5e570 100644 --- a/rtc_base/cpu_time.cc +++ b/rtc_base/cpu_time.cc @@ -10,13 +10,15 @@ #include "rtc_base/cpu_time.h" +#include + #include #include "rtc_base/logging.h" #include "rtc_base/time_utils.h" #if defined(WEBRTC_LINUX) -#include +#include #elif defined(WEBRTC_MAC) #include #include diff --git a/rtc_base/cpu_time.h b/rtc_base/cpu_time.h index 870a5a5ffa..5301656eb7 100644 --- a/rtc_base/cpu_time.h +++ b/rtc_base/cpu_time.h @@ -25,13 +25,5 @@ int64_t GetThreadCpuTimeNanos(); } // 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::GetProcessCpuTimeNanos; -using ::webrtc::GetThreadCpuTimeNanos; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_CPU_TIME_H_ diff --git a/rtc_base/cpu_time_unittest.cc b/rtc_base/cpu_time_unittest.cc index 591ae8001d..8bbc48c5b2 100644 --- a/rtc_base/cpu_time_unittest.cc +++ b/rtc_base/cpu_time_unittest.cc @@ -27,9 +27,9 @@ #endif namespace { -const int kAllowedErrorMillisecs = 30; -const int kProcessingTimeMillisecs = 500; -const int kWorkingThreads = 2; +constexpr int kAllowedErrorMillisecs = 30; +constexpr int kProcessingTimeMillisecs = 500; +constexpr int kWorkingThreads = 2; // Consumes approximately kProcessingTimeMillisecs of CPU time in single thread. void WorkingFunction(int64_t* counter) { diff --git a/rtc_base/crc32.h b/rtc_base/crc32.h index 6d208b9664..e175271d9f 100644 --- a/rtc_base/crc32.h +++ b/rtc_base/crc32.h @@ -11,10 +11,8 @@ #ifndef RTC_BASE_CRC32_H_ #define RTC_BASE_CRC32_H_ -#include -#include - -#include +#include +#include #include "absl/strings/string_view.h" @@ -34,13 +32,5 @@ inline uint32_t ComputeCrc32(absl::string_view str) { } // 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::ComputeCrc32; -using ::webrtc::UpdateCrc32; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_CRC32_H_ diff --git a/rtc_base/crypto_random.cc b/rtc_base/crypto_random.cc index 97f1778c13..873f3da88c 100644 --- a/rtc_base/crypto_random.cc +++ b/rtc_base/crypto_random.cc @@ -34,9 +34,8 @@ namespace { // The OpenSSL RNG. class SecureRandomGenerator : public RandomGenerator { public: - SecureRandomGenerator() {} - ~SecureRandomGenerator() override {} - bool Init(const void* /* seed */, size_t /* len */) override { return true; } + SecureRandomGenerator() = default; + ~SecureRandomGenerator() override = default; bool Generate(void* buf, size_t len) override { return (RAND_bytes(reinterpret_cast(buf), len) > 0); } @@ -46,8 +45,7 @@ class SecureRandomGenerator : public RandomGenerator { class TestRandomGenerator : public RandomGenerator { public: TestRandomGenerator() : seed_(7) {} - ~TestRandomGenerator() override {} - bool Init(const void* /* seed */, size_t /* len */) override { return true; } + ~TestRandomGenerator() override = default; bool Generate(void* buf, size_t len) override { for (size_t i = 0; i < len; ++i) { static_cast(buf)[i] = static_cast(GetRandom()); diff --git a/rtc_base/crypto_random.h b/rtc_base/crypto_random.h index aaa180356f..5b2745bc17 100644 --- a/rtc_base/crypto_random.h +++ b/rtc_base/crypto_random.h @@ -25,8 +25,10 @@ namespace webrtc { // Interface for RNG implementations. class RandomGenerator { public: - virtual ~RandomGenerator() {} - virtual bool Init(const void* seed, size_t len) = 0; + virtual ~RandomGenerator() = default; + [[deprecated]] virtual bool Init(const void* seed, size_t len) { + return true; + } virtual bool Generate(void* buf, size_t len) = 0; }; @@ -43,8 +45,8 @@ void SetRandomGenerator(std::unique_ptr generator); void SetRandomTestMode(bool test); // Initializes the RNG, and seeds it with the specified entropy. -bool InitRandom(int seed); -bool InitRandom(const char* seed, size_t len); +[[deprecated]] bool InitRandom(int seed); +[[deprecated]] bool InitRandom(const char* seed, size_t len); // Generates a (cryptographically) random string of the given length. // We generate base64 values so that they will be printable. @@ -85,23 +87,5 @@ double CreateRandomDouble(); } // 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::CreateRandomData; -using ::webrtc::CreateRandomDouble; -using ::webrtc::CreateRandomId; -using ::webrtc::CreateRandomId64; -using ::webrtc::CreateRandomNonZeroId; -using ::webrtc::CreateRandomString; -using ::webrtc::CreateRandomUuid; -using ::webrtc::InitRandom; -using ::webrtc::RandomGenerator; -using ::webrtc::SetDefaultRandomGenerator; -using ::webrtc::SetRandomGenerator; -using ::webrtc::SetRandomTestMode; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_CRYPTO_RANDOM_H_ diff --git a/rtc_base/crypto_random_unittest.cc b/rtc_base/crypto_random_unittest.cc index efc3617f28..58c8e499a5 100644 --- a/rtc_base/crypto_random_unittest.cc +++ b/rtc_base/crypto_random_unittest.cc @@ -10,8 +10,6 @@ #include "rtc_base/crypto_random.h" -#include - #include #include #include @@ -130,7 +128,6 @@ class MockRandomGenerator : public RandomGenerator { MOCK_METHOD(void, Die, ()); ~MockRandomGenerator() override { Die(); } - MOCK_METHOD(bool, Init, (const void* seed, size_t len), (override)); MOCK_METHOD(bool, Generate, (void* buf, size_t len), (override)); }; @@ -140,14 +137,6 @@ TEST(RandomTest, TestSetRandomGenerator) { MockRandomGenerator* generator = will_move.get(); SetRandomGenerator(std::move(will_move)); - EXPECT_CALL(*generator, Init(_, sizeof(int))).WillOnce(Return(true)); - EXPECT_TRUE(InitRandom(5)); - - std::string seed = "seed"; - EXPECT_CALL(*generator, Init(seed.data(), seed.size())) - .WillOnce(Return(true)); - EXPECT_TRUE(InitRandom(seed.data(), seed.size())); - uint32_t id = 4658; EXPECT_CALL(*generator, Generate(_, sizeof(uint32_t))) .WillOnce(DoAll(WithArg<0>(Invoke([&id](void* p) { diff --git a/rtc_base/data_rate_limiter.h b/rtc_base/data_rate_limiter.h index 088cb63755..e2c5059a61 100644 --- a/rtc_base/data_rate_limiter.h +++ b/rtc_base/data_rate_limiter.h @@ -55,12 +55,5 @@ class RTC_EXPORT DataRateLimiter { }; } // 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::DataRateLimiter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_DATA_RATE_LIMITER_H_ diff --git a/rtc_base/deprecated/recursive_critical_section.h b/rtc_base/deprecated/recursive_critical_section.h index e4a2053632..09c9a19c38 100644 --- a/rtc_base/deprecated/recursive_critical_section.h +++ b/rtc_base/deprecated/recursive_critical_section.h @@ -104,13 +104,5 @@ class RTC_SCOPED_LOCKABLE CritScope { } // 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::CritScope; -using ::webrtc::RecursiveCriticalSection; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_ diff --git a/rtc_base/deprecated/recursive_critical_section_unittest.cc b/rtc_base/deprecated/recursive_critical_section_unittest.cc index fedaaf5fbb..0aac9bbf13 100644 --- a/rtc_base/deprecated/recursive_critical_section_unittest.cc +++ b/rtc_base/deprecated/recursive_critical_section_unittest.cc @@ -10,10 +10,9 @@ #include "rtc_base/deprecated/recursive_critical_section.h" -#include -#include - #include +#include +#include #include #include #include diff --git a/rtc_base/dscp.h b/rtc_base/dscp.h index db3eb74cb5..21fdf8e1d9 100644 --- a/rtc_base/dscp.h +++ b/rtc_base/dscp.h @@ -42,35 +42,5 @@ enum DiffServCodePoint { } // 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::DiffServCodePoint; -using ::webrtc::DSCP_AF11; -using ::webrtc::DSCP_AF12; -using ::webrtc::DSCP_AF13; -using ::webrtc::DSCP_AF21; -using ::webrtc::DSCP_AF22; -using ::webrtc::DSCP_AF23; -using ::webrtc::DSCP_AF31; -using ::webrtc::DSCP_AF32; -using ::webrtc::DSCP_AF33; -using ::webrtc::DSCP_AF41; -using ::webrtc::DSCP_AF42; -using ::webrtc::DSCP_AF43; -using ::webrtc::DSCP_CS0; -using ::webrtc::DSCP_CS1; -using ::webrtc::DSCP_CS2; -using ::webrtc::DSCP_CS3; -using ::webrtc::DSCP_CS4; -using ::webrtc::DSCP_CS5; -using ::webrtc::DSCP_CS6; -using ::webrtc::DSCP_CS7; -using ::webrtc::DSCP_DEFAULT; -using ::webrtc::DSCP_EF; -using ::webrtc::DSCP_NO_CHANGE; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_DSCP_H_ diff --git a/rtc_base/event.cc b/rtc_base/event.cc index e7ad91c6c9..560b036cb9 100644 --- a/rtc_base/event.cc +++ b/rtc_base/event.cc @@ -10,24 +10,30 @@ #include "rtc_base/event.h" +#include + +#include +#include + +#include "api/units/time_delta.h" +#include "rtc_base/checks.h" +#include "rtc_base/synchronization/yield_policy.h" +#include "rtc_base/system/warn_current_thread_is_deadlocked.h" + #if defined(WEBRTC_WIN) #include #elif defined(WEBRTC_POSIX) -#include #include + +#include +#ifdef WEBRTC_MAC #include -#include +#endif +#include #else #error "Must define either WEBRTC_WIN or WEBRTC_POSIX." #endif -#include - -#include "rtc_base/checks.h" -#include "rtc_base/synchronization/yield_policy.h" -#include "rtc_base/system/warn_current_thread_is_deadlocked.h" -#include "rtc_base/time_utils.h" - namespace webrtc { Event::Event() : Event(false, false) {} @@ -112,7 +118,7 @@ void Event::Reset() { namespace { -timespec GetTimespec(TimeDelta duration_from_now) { +timespec GetTimespec(TimeDelta from_now) { timespec ts; // Get the current time. @@ -122,20 +128,15 @@ timespec GetTimespec(TimeDelta duration_from_now) { timeval tv; gettimeofday(&tv, nullptr); ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec * kNumNanosecsPerMicrosec; + ts.tv_nsec = TimeDelta::Micros(tv.tv_usec).ns(); #endif - // Add the specified number of milliseconds to it. - int64_t microsecs_from_now = duration_from_now.us(); - ts.tv_sec += microsecs_from_now / kNumMicrosecsPerSec; - ts.tv_nsec += - (microsecs_from_now % kNumMicrosecsPerSec) * kNumNanosecsPerMicrosec; - - // Normalize. - if (ts.tv_nsec >= kNumNanosecsPerSec) { - ts.tv_sec++; - ts.tv_nsec -= kNumNanosecsPerSec; - } + // Add the specified number of nanoseconds to it. + // Use integer division to transfer full seconds to `tv_sec`. + // `ns` has type either std::ldiv_t or std::lldiv_t. + auto ns = std::div(ts.tv_nsec + from_now.ns(), TimeDelta::Seconds(1).ns()); + ts.tv_sec += ns.quot; + ts.tv_nsec = ns.rem; return ts; } diff --git a/rtc_base/event.h b/rtc_base/event.h index 908247aefd..80bcd96fe5 100644 --- a/rtc_base/event.h +++ b/rtc_base/event.h @@ -12,17 +12,17 @@ #define RTC_BASE_EVENT_H_ #include "api/units/time_delta.h" +#include "rtc_base/checks.h" +#include "rtc_base/synchronization/yield_policy.h" #if defined(WEBRTC_WIN) #include #elif defined(WEBRTC_POSIX) -#include +#include // IWYU pragma: keep #else #error "Must define either WEBRTC_WIN or WEBRTC_POSIX." #endif -#include "rtc_base/synchronization/yield_policy.h" - namespace webrtc { // RTC_DISALLOW_WAIT() utility @@ -134,14 +134,5 @@ class ScopedDisallowWait { } // 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::Event; -using ::webrtc::ScopedAllowBaseSyncPrimitives; -using ::webrtc::ScopedAllowBaseSyncPrimitivesForTesting; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_EVENT_H_ diff --git a/rtc_base/event_tracer.cc b/rtc_base/event_tracer.cc index b42757ce1f..82ed2c446b 100644 --- a/rtc_base/event_tracer.cc +++ b/rtc_base/event_tracer.cc @@ -10,7 +10,7 @@ #include "rtc_base/event_tracer.h" -#include +#include #include "api/units/time_delta.h" #include "rtc_base/trace_event.h" @@ -19,11 +19,10 @@ #include "rtc_base/trace_categories.h" #include "third_party/perfetto/include/perfetto/tracing/tracing.h" #else -#include -#include -#include - #include +#include +#include +#include #include #include diff --git a/rtc_base/event_tracer.h b/rtc_base/event_tracer.h index 941c44c0f7..a13cdea5c5 100644 --- a/rtc_base/event_tracer.h +++ b/rtc_base/event_tracer.h @@ -85,18 +85,5 @@ RTC_EXPORT void ShutdownInternalTracer(); } // 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 { -namespace tracing { -using ::webrtc::tracing::SetupInternalTracer; -using ::webrtc::tracing::ShutdownInternalTracer; -using ::webrtc::tracing::StartInternalCapture; -using ::webrtc::tracing::StartInternalCaptureToFile; -using ::webrtc::tracing::StopInternalCapture; -} // namespace tracing -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_EVENT_TRACER_H_ diff --git a/rtc_base/event_unittest.cc b/rtc_base/event_unittest.cc index 8e64252012..87529a4e8d 100644 --- a/rtc_base/event_unittest.cc +++ b/rtc_base/event_unittest.cc @@ -11,6 +11,7 @@ #include "rtc_base/event.h" #include "api/units/time_delta.h" +#include "rtc_base/checks.h" #include "rtc_base/platform_thread.h" #include "system_wrappers/include/clock.h" #include "test/gtest.h" diff --git a/rtc_base/experiments/alr_experiment.cc b/rtc_base/experiments/alr_experiment.cc index 2138e34f90..a0fe9d9090 100644 --- a/rtc_base/experiments/alr_experiment.cc +++ b/rtc_base/experiments/alr_experiment.cc @@ -10,9 +10,8 @@ #include "rtc_base/experiments/alr_experiment.h" -#include -#include - +#include +#include #include #include diff --git a/rtc_base/experiments/encoder_info_settings.cc b/rtc_base/experiments/encoder_info_settings.cc index bfc55029dd..4acfeacaa3 100644 --- a/rtc_base/experiments/encoder_info_settings.cc +++ b/rtc_base/experiments/encoder_info_settings.cc @@ -10,10 +10,9 @@ #include "rtc_base/experiments/encoder_info_settings.h" -#include - #include #include +#include #include #include #include diff --git a/rtc_base/experiments/field_trial_parser.cc b/rtc_base/experiments/field_trial_parser.cc index ada8f5cc5f..88e2b1afdf 100644 --- a/rtc_base/experiments/field_trial_parser.cc +++ b/rtc_base/experiments/field_trial_parser.cc @@ -9,8 +9,7 @@ */ #include "rtc_base/experiments/field_trial_parser.h" -#include - +#include #include #include #include diff --git a/rtc_base/experiments/field_trial_units.cc b/rtc_base/experiments/field_trial_units.cc index e7a5b11fe1..f65db331f4 100644 --- a/rtc_base/experiments/field_trial_units.cc +++ b/rtc_base/experiments/field_trial_units.cc @@ -9,8 +9,7 @@ */ #include "rtc_base/experiments/field_trial_units.h" -#include - +#include #include #include #include diff --git a/rtc_base/experiments/normalize_simulcast_size_experiment.cc b/rtc_base/experiments/normalize_simulcast_size_experiment.cc index 3e949c56e1..81c1752b79 100644 --- a/rtc_base/experiments/normalize_simulcast_size_experiment.cc +++ b/rtc_base/experiments/normalize_simulcast_size_experiment.cc @@ -10,8 +10,7 @@ #include "rtc_base/experiments/normalize_simulcast_size_experiment.h" -#include - +#include #include #include diff --git a/rtc_base/experiments/quality_scaling_experiment.cc b/rtc_base/experiments/quality_scaling_experiment.cc index 30a80d3b64..82b7f27625 100644 --- a/rtc_base/experiments/quality_scaling_experiment.cc +++ b/rtc_base/experiments/quality_scaling_experiment.cc @@ -9,12 +9,10 @@ */ #include "rtc_base/experiments/quality_scaling_experiment.h" -#include - +#include #include #include -#include "absl/strings/match.h" #include "api/field_trials_view.h" #include "api/video/video_codec_type.h" #include "api/video_codecs/video_encoder.h" @@ -87,9 +85,9 @@ bool QualityScalingExperiment::Enabled(const FieldTrialsView& field_trials) { WebRTCH265QualityScaling h265_quality_scaling(field_trials); return #if defined(WEBRTC_IOS) - absl::StartsWith(field_trials.Lookup(kFieldTrial), "Enabled") || + field_trials.IsEnabled(kFieldTrial) || #else - !absl::StartsWith(field_trials.Lookup(kFieldTrial), "Disabled") || + !field_trials.IsDisabled(kFieldTrial) || #endif h265_quality_scaling.IsEnabled(); } diff --git a/rtc_base/experiments/rate_control_settings.cc b/rtc_base/experiments/rate_control_settings.cc index 2d37c2d3fc..06c5e6f1b5 100644 --- a/rtc_base/experiments/rate_control_settings.cc +++ b/rtc_base/experiments/rate_control_settings.cc @@ -10,8 +10,6 @@ #include "rtc_base/experiments/rate_control_settings.h" -#include - #include #include #include diff --git a/rtc_base/fake_clock.cc b/rtc_base/fake_clock.cc index 0ab8b52e94..71c6ae1d53 100644 --- a/rtc_base/fake_clock.cc +++ b/rtc_base/fake_clock.cc @@ -10,8 +10,14 @@ #include "rtc_base/fake_clock.h" +#include + +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "rtc_base/checks.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread.h" +#include "rtc_base/time_utils.h" namespace webrtc { diff --git a/rtc_base/fake_clock.h b/rtc_base/fake_clock.h index a529b6cebd..c23405af86 100644 --- a/rtc_base/fake_clock.h +++ b/rtc_base/fake_clock.h @@ -80,15 +80,5 @@ class ScopedFakeClock : public ThreadProcessingFakeClock { } // 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::FakeClock; -using ::webrtc::ScopedBaseFakeClock; -using ::webrtc::ScopedFakeClock; -using ::webrtc::ThreadProcessingFakeClock; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_FAKE_CLOCK_H_ diff --git a/rtc_base/fake_mdns_responder.h b/rtc_base/fake_mdns_responder.h index ee9517b457..35ad0c8ea8 100644 --- a/rtc_base/fake_mdns_responder.h +++ b/rtc_base/fake_mdns_responder.h @@ -11,8 +11,8 @@ #ifndef RTC_BASE_FAKE_MDNS_RESPONDER_H_ #define RTC_BASE_FAKE_MDNS_RESPONDER_H_ +#include #include -#include #include #include "absl/strings/string_view.h" diff --git a/rtc_base/fake_network.h b/rtc_base/fake_network.h index 7fede142c8..2fbda2f625 100644 --- a/rtc_base/fake_network.h +++ b/rtc_base/fake_network.h @@ -163,14 +163,5 @@ class FakeNetworkManager : public NetworkManagerBase { } // 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::FakeNetworkManager; -using ::webrtc::kFakeIPv4NetworkPrefixLength; -using ::webrtc::kFakeIPv6NetworkPrefixLength; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_FAKE_NETWORK_H_ diff --git a/rtc_base/fake_ssl_identity.cc b/rtc_base/fake_ssl_identity.cc index 31ce4400b4..3731358824 100644 --- a/rtc_base/fake_ssl_identity.cc +++ b/rtc_base/fake_ssl_identity.cc @@ -106,7 +106,7 @@ const SSLCertificate& FakeSSLIdentity::certificate() const { } const SSLCertChain& FakeSSLIdentity::cert_chain() const { - return *cert_chain_.get(); + return *cert_chain_; } std::string FakeSSLIdentity::PrivateKeyToPEMString() const { diff --git a/rtc_base/fake_ssl_identity.h b/rtc_base/fake_ssl_identity.h index 24c8ad6aaf..5fad4a3615 100644 --- a/rtc_base/fake_ssl_identity.h +++ b/rtc_base/fake_ssl_identity.h @@ -82,13 +82,5 @@ class FakeSSLIdentity : public SSLIdentity { } // 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::FakeSSLCertificate; -using ::webrtc::FakeSSLIdentity; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_FAKE_SSL_IDENTITY_H_ diff --git a/rtc_base/file_rotating_stream.h b/rtc_base/file_rotating_stream.h index de122efcd1..72e78a3933 100644 --- a/rtc_base/file_rotating_stream.h +++ b/rtc_base/file_rotating_stream.h @@ -169,15 +169,5 @@ class CallSessionFileRotatingStreamReader : public FileRotatingStreamReader { } // 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::CallSessionFileRotatingStream; -using ::webrtc::CallSessionFileRotatingStreamReader; -using ::webrtc::FileRotatingStream; -using ::webrtc::FileRotatingStreamReader; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_FILE_ROTATING_STREAM_H_ diff --git a/rtc_base/file_rotating_stream_unittest.cc b/rtc_base/file_rotating_stream_unittest.cc index 50a0fe96d6..1270cdd1ea 100644 --- a/rtc_base/file_rotating_stream_unittest.cc +++ b/rtc_base/file_rotating_stream_unittest.cc @@ -10,10 +10,9 @@ #include "rtc_base/file_rotating_stream.h" -#include - #include #include +#include #include #include diff --git a/rtc_base/firewall_socket_server.cc b/rtc_base/firewall_socket_server.cc index ab8c331d82..aaf68f4b0b 100644 --- a/rtc_base/firewall_socket_server.cc +++ b/rtc_base/firewall_socket_server.cc @@ -10,11 +10,10 @@ #include "rtc_base/firewall_socket_server.h" -#include -#include -#include - #include +#include +#include +#include #include #include "absl/algorithm/container.h" diff --git a/rtc_base/firewall_socket_server.h b/rtc_base/firewall_socket_server.h index 18d6862df3..a0b75b83c4 100644 --- a/rtc_base/firewall_socket_server.h +++ b/rtc_base/firewall_socket_server.h @@ -127,21 +127,5 @@ class FirewallManager { } // 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::FD_ANY; -using ::webrtc::FD_IN; -using ::webrtc::FD_OUT; -using ::webrtc::FirewallDirection; -using ::webrtc::FirewallManager; -using ::webrtc::FirewallProtocol; -using ::webrtc::FirewallSocketServer; -using ::webrtc::FP_ANY; -using ::webrtc::FP_TCP; -using ::webrtc::FP_UDP; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_FIREWALL_SOCKET_SERVER_H_ diff --git a/rtc_base/gunit.h b/rtc_base/gunit.h index 5d259b39fc..014f353121 100644 --- a/rtc_base/gunit.h +++ b/rtc_base/gunit.h @@ -11,11 +11,9 @@ #ifndef RTC_BASE_GUNIT_H_ #define RTC_BASE_GUNIT_H_ -#include "absl/strings/string_view.h" -#include "rtc_base/fake_clock.h" -#include "rtc_base/logging.h" -#include "rtc_base/thread.h" -#include "test/gtest.h" +// TODO(bugs.webrtc.org/42226242): remove transitive includes +#include "rtc_base/thread.h" // IWYU pragma: keep +#include "test/gtest.h" // IWYU pragma: keep // Wait until "ex" is true, or "timeout" expires. #define WAIT(ex, timeout) \ diff --git a/rtc_base/ifaddrs_android.cc b/rtc_base/ifaddrs_android.cc index 8388bfec71..19a50d8ae0 100644 --- a/rtc_base/ifaddrs_android.cc +++ b/rtc_base/ifaddrs_android.cc @@ -11,21 +11,26 @@ #if defined(WEBRTC_ANDROID) #include "rtc_base/ifaddrs_android.h" -#include +#include +#include +#include +#include #include #include +#include #include -#include // no-presubmit-check -#include -#include -#include #include // no-presubmit-check #include -#include #include +#include +#include +#include + #include "absl/cleanup/cleanup.h" +namespace webrtc { + namespace { struct netlinkrequest { @@ -33,12 +38,10 @@ struct netlinkrequest { ifaddrmsg msg; }; -const int kMaxReadSize = 4096; +constexpr int kMaxReadSize = 4096; } // namespace -namespace webrtc { - int set_ifname(struct ifaddrs* ifaddr, int interface) { char buf[IFNAMSIZ] = {0}; char* name = if_indextoname(interface, buf); diff --git a/rtc_base/ifaddrs_converter.h b/rtc_base/ifaddrs_converter.h index 6e8cd63c85..4f51b59e61 100644 --- a/rtc_base/ifaddrs_converter.h +++ b/rtc_base/ifaddrs_converter.h @@ -44,13 +44,5 @@ IfAddrsConverter* CreateIfAddrsConverter(); } // 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::CreateIfAddrsConverter; -using ::webrtc::IfAddrsConverter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_IFADDRS_CONVERTER_H_ diff --git a/rtc_base/internal/default_socket_server.cc b/rtc_base/internal/default_socket_server.cc index 1ebe391a2c..d49c2bba32 100644 --- a/rtc_base/internal/default_socket_server.cc +++ b/rtc_base/internal/default_socket_server.cc @@ -13,21 +13,12 @@ #include #include "rtc_base/socket_server.h" - -#if defined(__native_client__) -#include "rtc_base/null_socket_server.h" -#else #include "rtc_base/physical_socket_server.h" -#endif namespace webrtc { std::unique_ptr CreateDefaultSocketServer() { -#if defined(__native_client__) - return std::unique_ptr(new NullSocketServer); -#else return std::unique_ptr(new PhysicalSocketServer); -#endif } } // namespace webrtc diff --git a/rtc_base/internal/default_socket_server.h b/rtc_base/internal/default_socket_server.h index 173db0b250..1eaa3c791e 100644 --- a/rtc_base/internal/default_socket_server.h +++ b/rtc_base/internal/default_socket_server.h @@ -21,12 +21,5 @@ std::unique_ptr CreateDefaultSocketServer(); } // 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::CreateDefaultSocketServer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_INTERNAL_DEFAULT_SOCKET_SERVER_H_ diff --git a/rtc_base/ip_address.cc b/rtc_base/ip_address.cc index 5c349dc1f8..179bc37bbc 100644 --- a/rtc_base/ip_address.cc +++ b/rtc_base/ip_address.cc @@ -8,26 +8,26 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "rtc_base/ip_address.h" + #include #include #include #include #include + +#include "absl/strings/string_view.h" +#include "rtc_base/byte_order.h" +#include "rtc_base/net_helpers.h" +#include "rtc_base/string_utils.h" + #if defined(WEBRTC_POSIX) #ifdef OPENBSD #include #endif -#ifndef __native_client__ -#endif #include #endif -#include "absl/strings/string_view.h" -#include "rtc_base/byte_order.h" -#include "rtc_base/ip_address.h" -#include "rtc_base/net_helpers.h" -#include "rtc_base/string_utils.h" - namespace webrtc { // Prefixes used for categorizing IPv6 addresses. diff --git a/rtc_base/ip_address.h b/rtc_base/ip_address.h index efcabcbaae..daf56209f5 100644 --- a/rtc_base/ip_address.h +++ b/rtc_base/ip_address.h @@ -12,27 +12,26 @@ #define RTC_BASE_IP_ADDRESS_H_ #include +#include +#include + +#include "absl/strings/string_view.h" +#include "rtc_base/byte_order.h" +#include "rtc_base/net_helpers.h" +#include "rtc_base/system/rtc_export.h" + #if defined(WEBRTC_POSIX) #include // IWYU pragma: keep #include #include // IWYU pragma: export - -#include "absl/strings/string_view.h" #endif + #if defined(WEBRTC_WIN) #include -#endif -#include - -#include -#include "rtc_base/byte_order.h" -#if defined(WEBRTC_WIN) #include "rtc_base/win32.h" #endif -#include "absl/strings/string_view.h" -#include "rtc_base/net_helpers.h" -#include "rtc_base/system/rtc_export.h" + namespace webrtc { enum IPv6AddressFlag { @@ -213,40 +212,5 @@ int CountIPMaskBits(const IPAddress& mask); } // 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::CountIPMaskBits; -using ::webrtc::GetAnyIP; -using ::webrtc::GetLoopbackIP; -using ::webrtc::HashIP; -using ::webrtc::InterfaceAddress; -using ::webrtc::IPAddress; -using ::webrtc::IPAddressPrecedence; -using ::webrtc::IPFromAddrInfo; -using ::webrtc::IPFromString; -using ::webrtc::IPIs6Bone; -using ::webrtc::IPIs6To4; -using ::webrtc::IPIsAny; -using ::webrtc::IPIsLinkLocal; -using ::webrtc::IPIsLoopback; -using ::webrtc::IPIsMacBased; -using ::webrtc::IPIsPrivate; -using ::webrtc::IPIsPrivateNetwork; -using ::webrtc::IPIsSharedNetwork; -using ::webrtc::IPIsSiteLocal; -using ::webrtc::IPIsTeredo; -using ::webrtc::IPIsULA; -using ::webrtc::IPIsUnspec; -using ::webrtc::IPIsV4Compatibility; -using ::webrtc::IPIsV4Mapped; -using ::webrtc::IPV6_ADDRESS_FLAG_DEPRECATED; -using ::webrtc::IPV6_ADDRESS_FLAG_NONE; -using ::webrtc::IPV6_ADDRESS_FLAG_TEMPORARY; -using ::webrtc::IPv6AddressFlag; -using ::webrtc::TruncateIP; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_IP_ADDRESS_H_ diff --git a/rtc_base/ip_address_unittest.cc b/rtc_base/ip_address_unittest.cc index ff6a1829a9..b4ad770ab7 100644 --- a/rtc_base/ip_address_unittest.cc +++ b/rtc_base/ip_address_unittest.cc @@ -10,9 +10,18 @@ #include "rtc_base/ip_address.h" +#include +#include + #include "absl/strings/string_view.h" +#include "rtc_base/byte_order.h" +#include "rtc_base/net_helpers.h" #include "test/gtest.h" +#if defined(WEBRTC_POSIX) +#include +#endif + namespace webrtc { static const unsigned int kIPv4AddrSize = 4; diff --git a/rtc_base/log_sinks.cc b/rtc_base/log_sinks.cc index 7f5b3835a7..0db3475f1a 100644 --- a/rtc_base/log_sinks.cc +++ b/rtc_base/log_sinks.cc @@ -10,9 +10,8 @@ #include "rtc_base/log_sinks.h" -#include - #include +#include #include #include "absl/strings/string_view.h" diff --git a/rtc_base/log_sinks.h b/rtc_base/log_sinks.h index a1b4b872f1..56634edf0f 100644 --- a/rtc_base/log_sinks.h +++ b/rtc_base/log_sinks.h @@ -77,13 +77,5 @@ class CallSessionFileRotatingLogSink : public FileRotatingLogSink { } // 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::CallSessionFileRotatingLogSink; -using ::webrtc::FileRotatingLogSink; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_LOG_SINKS_H_ diff --git a/rtc_base/logging.cc b/rtc_base/logging.cc index 1a07e9641e..f157205e7d 100644 --- a/rtc_base/logging.cc +++ b/rtc_base/logging.cc @@ -10,19 +10,33 @@ #include "rtc_base/logging.h" -#include - +#include #include +#include +#include #include +#include +#include +#include #include +#include + +#include "absl/base/attributes.h" +#include "absl/strings/string_view.h" +#include "api/units/timestamp.h" +#include "rtc_base/checks.h" +#include "rtc_base/platform_thread_types.h" +#include "rtc_base/string_encode.h" +#include "rtc_base/string_utils.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" #if RTC_LOG_ENABLED() #if defined(WEBRTC_WIN) #include -#if _MSC_VER < 1900 -#define snprintf _snprintf -#endif #undef ERROR // wingdi.h #endif @@ -37,26 +51,6 @@ static const int kMaxLogLineSize = 1024 - 60; #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) || WEBRTC_ANDROID -#include -#include -#include - -#include -#include -#include - -#include "absl/base/attributes.h" -#include "absl/strings/string_view.h" -#include "api/units/timestamp.h" -#include "rtc_base/checks.h" -#include "rtc_base/platform_thread_types.h" -#include "rtc_base/string_encode.h" -#include "rtc_base/string_utils.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" - namespace webrtc { namespace { diff --git a/rtc_base/logging.h b/rtc_base/logging.h index c87e707ebc..0023684501 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -672,9 +672,6 @@ inline bool LogCheckLevel(LoggingSeverity sev) { #define RTC_LOG_GLE(sev) RTC_LOG_GLE_EX(sev, static_cast(GetLastError())) #define RTC_LOG_ERR_EX(sev, err) RTC_LOG_GLE_EX(sev, err) #define RTC_LOG_ERR(sev) RTC_LOG_GLE(sev) -#elif defined(__native_client__) && __native_client__ -#define RTC_LOG_ERR_EX(sev, err) RTC_LOG(sev) -#define RTC_LOG_ERR(sev) RTC_LOG(sev) #elif defined(WEBRTC_POSIX) #define RTC_LOG_ERR_EX(sev, err) RTC_LOG_ERRNO_EX(sev, err) #define RTC_LOG_ERR(sev) RTC_LOG_ERRNO(sev) @@ -729,20 +726,5 @@ inline const char* AdaptString(const std::string& str) { } // 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::LoggingSeverity; -using ::webrtc::LogLineRef; -using ::webrtc::LogMessage; -using ::webrtc::LogSink; -using ::webrtc::LS_ERROR; -using ::webrtc::LS_INFO; -using ::webrtc::LS_NONE; -using ::webrtc::LS_VERBOSE; -using ::webrtc::LS_WARNING; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_LOGGING_H_ diff --git a/rtc_base/memory/aligned_malloc.cc b/rtc_base/memory/aligned_malloc.cc index e0bae74dc3..36aa749898 100644 --- a/rtc_base/memory/aligned_malloc.cc +++ b/rtc_base/memory/aligned_malloc.cc @@ -10,15 +10,15 @@ #include "rtc_base/memory/aligned_malloc.h" -#include // for free, malloc -#include // for memcpy +#include +#include #include "rtc_base/checks.h" #ifdef _WIN32 #include #else -#include +#include #endif // Reference on memory alignment: diff --git a/rtc_base/memory/aligned_malloc_unittest.cc b/rtc_base/memory/aligned_malloc_unittest.cc index 56ec95df1b..0ef6bea62a 100644 --- a/rtc_base/memory/aligned_malloc_unittest.cc +++ b/rtc_base/memory/aligned_malloc_unittest.cc @@ -16,7 +16,7 @@ #ifdef _WIN32 #include #else -#include +#include #endif #include "test/gtest.h" @@ -27,7 +27,7 @@ namespace webrtc { bool CorrectUsage(size_t size, size_t alignment) { std::unique_ptr scoped( static_cast(AlignedMalloc(size, alignment))); - if (scoped.get() == nullptr) { + if (scoped == nullptr) { return false; } const uintptr_t scoped_address = reinterpret_cast(scoped.get()); diff --git a/rtc_base/memory/fifo_buffer.h b/rtc_base/memory/fifo_buffer.h index a153ddf9cc..f221c563ab 100644 --- a/rtc_base/memory/fifo_buffer.h +++ b/rtc_base/memory/fifo_buffer.h @@ -120,12 +120,5 @@ class FifoBuffer final : public StreamInterface { } // 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::FifoBuffer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_MEMORY_FIFO_BUFFER_H_ diff --git a/rtc_base/memory/fifo_buffer_unittest.cc b/rtc_base/memory/fifo_buffer_unittest.cc index c78cf90cd5..22f78a4461 100644 --- a/rtc_base/memory/fifo_buffer_unittest.cc +++ b/rtc_base/memory/fifo_buffer_unittest.cc @@ -10,9 +10,8 @@ #include "rtc_base/memory/fifo_buffer.h" -#include - #include +#include #include "api/array_view.h" #include "rtc_base/stream.h" diff --git a/rtc_base/memory_stream.cc b/rtc_base/memory_stream.cc index d0b6acbff6..9134d610e4 100644 --- a/rtc_base/memory_stream.cc +++ b/rtc_base/memory_stream.cc @@ -10,11 +10,10 @@ #include "rtc_base/memory_stream.h" -#include -#include - #include +#include #include +#include #include "api/array_view.h" #include "rtc_base/checks.h" diff --git a/rtc_base/memory_stream.h b/rtc_base/memory_stream.h index c01d590286..312bde6703 100644 --- a/rtc_base/memory_stream.h +++ b/rtc_base/memory_stream.h @@ -59,12 +59,5 @@ class MemoryStream final : public StreamInterface { } // 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::MemoryStream; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_MEMORY_STREAM_H_ diff --git a/rtc_base/memory_usage.h b/rtc_base/memory_usage.h index bd1b5ea49b..c937501585 100644 --- a/rtc_base/memory_usage.h +++ b/rtc_base/memory_usage.h @@ -21,12 +21,5 @@ int64_t GetProcessResidentSizeBytes(); } // 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::GetProcessResidentSizeBytes; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_MEMORY_USAGE_H_ diff --git a/rtc_base/message_digest.cc b/rtc_base/message_digest.cc index d25ab403d5..d63187d4c9 100644 --- a/rtc_base/message_digest.cc +++ b/rtc_base/message_digest.cc @@ -10,9 +10,8 @@ #include "rtc_base/message_digest.h" -#include - #include +#include #include #include diff --git a/rtc_base/message_digest.h b/rtc_base/message_digest.h index 22a86c7af4..ef3edb1366 100644 --- a/rtc_base/message_digest.h +++ b/rtc_base/message_digest.h @@ -130,23 +130,5 @@ bool ComputeHmac(absl::string_view alg, } // 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::ComputeDigest; -using ::webrtc::ComputeHmac; -using ::webrtc::DIGEST_MD5; -using ::webrtc::DIGEST_SHA_1; -using ::webrtc::DIGEST_SHA_224; -using ::webrtc::DIGEST_SHA_256; -using ::webrtc::DIGEST_SHA_384; -using ::webrtc::DIGEST_SHA_512; -using ::webrtc::IsFips180DigestAlgorithm; -using ::webrtc::MD5; -using ::webrtc::MessageDigest; -using ::webrtc::MessageDigestFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_MESSAGE_DIGEST_H_ diff --git a/rtc_base/net_helper.h b/rtc_base/net_helper.h index 95d22603ef..04233553d5 100644 --- a/rtc_base/net_helper.h +++ b/rtc_base/net_helper.h @@ -31,18 +31,5 @@ int GetProtocolOverhead(absl::string_view protocol); } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::GetProtocolOverhead; -using ::webrtc::kTcpHeaderSize; -using ::webrtc::kUdpHeaderSize; -using ::webrtc::SSLTCP_PROTOCOL_NAME; -using ::webrtc::TCP_PROTOCOL_NAME; -using ::webrtc::TLS_PROTOCOL_NAME; -using ::webrtc::UDP_PROTOCOL_NAME; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NET_HELPER_H_ diff --git a/rtc_base/net_helpers.cc b/rtc_base/net_helpers.cc index 51db569a88..6edd2c744e 100644 --- a/rtc_base/net_helpers.cc +++ b/rtc_base/net_helpers.cc @@ -17,11 +17,10 @@ #if defined(WEBRTC_WIN) #include #include - #endif -#if defined(WEBRTC_POSIX) && !defined(__native_client__) +#if defined(WEBRTC_POSIX) #include -#endif // defined(WEBRTC_POSIX) && !defined(__native_client__) +#endif // defined(WEBRTC_POSIX) namespace webrtc { diff --git a/rtc_base/net_helpers.h b/rtc_base/net_helpers.h index d27c263e93..3e74ecf7e0 100644 --- a/rtc_base/net_helpers.h +++ b/rtc_base/net_helpers.h @@ -30,13 +30,5 @@ int inet_pton(int af, absl::string_view src, void* dst); } // 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::inet_ntop; -using ::webrtc::inet_pton; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NET_HELPERS_H_ diff --git a/rtc_base/net_test_helpers.cc b/rtc_base/net_test_helpers.cc index f21a0ebb04..91ad83969c 100644 --- a/rtc_base/net_test_helpers.cc +++ b/rtc_base/net_test_helpers.cc @@ -18,18 +18,18 @@ #include "rtc_base/win/windows_version.h" #endif -#if defined(WEBRTC_POSIX) && !defined(__native_client__) +#if defined(WEBRTC_POSIX) #if defined(WEBRTC_ANDROID) #include "rtc_base/ifaddrs_android.h" #else #include #endif -#endif // defined(WEBRTC_POSIX) && !defined(__native_client__) +#endif // defined(WEBRTC_POSIX) namespace webrtc { bool HasIPv4Enabled() { -#if defined(WEBRTC_POSIX) && !defined(__native_client__) +#if defined(WEBRTC_POSIX) bool has_ipv4 = false; struct ifaddrs* ifa; if (getifaddrs(&ifa) < 0) { @@ -88,7 +88,7 @@ bool HasIPv6Enabled() { } } return false; -#elif defined(WEBRTC_POSIX) && !defined(__native_client__) +#elif defined(WEBRTC_POSIX) bool has_ipv6 = false; struct ifaddrs* ifa; if (getifaddrs(&ifa) < 0) { @@ -106,4 +106,5 @@ bool HasIPv6Enabled() { return true; #endif } + } // namespace webrtc diff --git a/rtc_base/net_test_helpers.h b/rtc_base/net_test_helpers.h index 3fb2a15ceb..c24213e8d7 100644 --- a/rtc_base/net_test_helpers.h +++ b/rtc_base/net_test_helpers.h @@ -20,11 +20,5 @@ RTC_EXPORT bool HasIPv6Enabled(); } // namespace webrtc -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { -using webrtc::HasIPv4Enabled; -using webrtc::HasIPv6Enabled; -} -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NET_TEST_HELPERS_H_ diff --git a/rtc_base/network.cc b/rtc_base/network.cc index 5a0f0df743..4798b84383 100644 --- a/rtc_base/network.cc +++ b/rtc_base/network.cc @@ -55,7 +55,7 @@ #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/string_utils.h" #include "rtc_base/win32.h" -#elif !defined(__native_client__) +#else #include "rtc_base/ifaddrs_converter.h" #endif // IWYU pragma: end_keep @@ -158,7 +158,6 @@ uint16_t ComputeNetworkCostByType(int type, } } -#if !defined(__native_client__) bool IsIgnoredIPv6(bool allow_mac_based_ipv6, const InterfaceAddress& ip) { if (ip.family() != AF_INET6) { return false; @@ -186,7 +185,6 @@ bool IsIgnoredIPv6(bool allow_mac_based_ipv6, const InterfaceAddress& ip) { return false; } -#endif // !defined(__native_client__) // Note: consider changing to const Network* as arguments // if/when considering other changes that should not trigger @@ -573,17 +571,7 @@ void BasicNetworkManager::OnNetworksChanged() { UpdateNetworksOnce(); } -#if defined(__native_client__) - -bool BasicNetworkManager::CreateNetworks( - bool include_ignored, - std::vector>* networks) const { - RTC_DCHECK_NOTREACHED(); - RTC_LOG(LS_WARNING) << "BasicNetworkManager doesn't work on NaCl yet"; - return false; -} - -#elif defined(WEBRTC_POSIX) +#if defined(WEBRTC_POSIX) NetworkMonitorInterface::InterfaceInfo BasicNetworkManager::GetInterfaceInfo( struct ifaddrs* cursor) const { if (cursor->ifa_flags & IFF_LOOPBACK) { diff --git a/rtc_base/network.h b/rtc_base/network.h index c87142e500..1ae363949e 100644 --- a/rtc_base/network.h +++ b/rtc_base/network.h @@ -578,23 +578,5 @@ class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase, } // 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::BasicNetworkManager; -using ::webrtc::DefaultLocalAddressProvider; -using ::webrtc::GetAdapterTypeFromName; -using ::webrtc::kDefaultNetworkIgnoreMask; -using ::webrtc::kPublicIPv4Host; -using ::webrtc::kPublicIPv6Host; -using ::webrtc::MakeNetworkKey; -using ::webrtc::MdnsResponderProvider; -using ::webrtc::Network; -using ::webrtc::NetworkManager; -using ::webrtc::NetworkManagerBase; -using ::webrtc::NetworkMask; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NETWORK_H_ diff --git a/rtc_base/network/BUILD.gn b/rtc_base/network/BUILD.gn index 8d18cbc560..b6627ac3a7 100644 --- a/rtc_base/network/BUILD.gn +++ b/rtc_base/network/BUILD.gn @@ -16,12 +16,6 @@ rtc_library("sent_packet") { deps = [ "../system:rtc_export" ] } -rtc_source_set("ecn_marking") { - visibility = [ "*" ] - sources = [ "ecn_marking.h" ] - deps = [ "../../api/transport:ecn_marking" ] -} - rtc_library("received_packet") { visibility = [ "*" ] sources = [ @@ -29,7 +23,6 @@ rtc_library("received_packet") { "received_packet.h", ] deps = [ - ":ecn_marking", "..:checks", "..:socket_address", "../../api:array_view", diff --git a/rtc_base/network/ecn_marking.h b/rtc_base/network/ecn_marking.h deleted file mode 100644 index d181eb7ddd..0000000000 --- a/rtc_base/network/ecn_marking.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2024 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_NETWORK_ECN_MARKING_H_ -#define RTC_BASE_NETWORK_ECN_MARKING_H_ - -// // TODO: bugs.webrtc.org/42225697 - delete this file. -#include "api/transport/ecn_marking.h" - -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { -using ::webrtc::EcnMarking; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES - -#endif // RTC_BASE_NETWORK_ECN_MARKING_H_ diff --git a/rtc_base/network/received_packet.h b/rtc_base/network/received_packet.h index b0cee33248..1078f807a6 100644 --- a/rtc_base/network/received_packet.h +++ b/rtc_base/network/received_packet.h @@ -83,12 +83,5 @@ class RTC_EXPORT ReceivedIpPacket { } // 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 ReceivedPacket = ::webrtc::ReceivedIpPacket; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NETWORK_RECEIVED_PACKET_H_ diff --git a/rtc_base/network/sent_packet.h b/rtc_base/network/sent_packet.h index 805b442d75..8b89845b16 100644 --- a/rtc_base/network/sent_packet.h +++ b/rtc_base/network/sent_packet.h @@ -70,15 +70,5 @@ struct RTC_EXPORT SentPacketInfo { } // 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::PacketInfo; -using SentPacket = ::webrtc::SentPacketInfo; -using ::webrtc::PacketInfoProtocolType; -using ::webrtc::PacketType; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NETWORK_SENT_PACKET_H_ diff --git a/rtc_base/network_constants.h b/rtc_base/network_constants.h index 884141c4b3..b074c2212c 100644 --- a/rtc_base/network_constants.h +++ b/rtc_base/network_constants.h @@ -69,36 +69,5 @@ constexpr AdapterType kAllAdapterTypes[] = { } // 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::ADAPTER_TYPE_ANY; -using ::webrtc::ADAPTER_TYPE_CELLULAR; -using ::webrtc::ADAPTER_TYPE_CELLULAR_2G; -using ::webrtc::ADAPTER_TYPE_CELLULAR_3G; -using ::webrtc::ADAPTER_TYPE_CELLULAR_4G; -using ::webrtc::ADAPTER_TYPE_CELLULAR_5G; -using ::webrtc::ADAPTER_TYPE_ETHERNET; -using ::webrtc::ADAPTER_TYPE_LOOPBACK; -using ::webrtc::ADAPTER_TYPE_UNKNOWN; -using ::webrtc::ADAPTER_TYPE_VPN; -using ::webrtc::ADAPTER_TYPE_WIFI; -using ::webrtc::AdapterType; -using ::webrtc::AdapterTypeToString; -using ::webrtc::kAllAdapterTypes; -using ::webrtc::kNetworkCostCellular; -using ::webrtc::kNetworkCostCellular2G; -using ::webrtc::kNetworkCostCellular3G; -using ::webrtc::kNetworkCostCellular4G; -using ::webrtc::kNetworkCostCellular5G; -using ::webrtc::kNetworkCostHigh; -using ::webrtc::kNetworkCostLow; -using ::webrtc::kNetworkCostMax; -using ::webrtc::kNetworkCostMin; -using ::webrtc::kNetworkCostUnknown; -using ::webrtc::kNetworkCostVpn; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NETWORK_CONSTANTS_H_ diff --git a/rtc_base/network_monitor.h b/rtc_base/network_monitor.h index 02dc830bbb..34f4e1d8f8 100644 --- a/rtc_base/network_monitor.h +++ b/rtc_base/network_monitor.h @@ -135,16 +135,5 @@ class NetworkMonitorInterface { } // 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::NetworkBinderInterface; -using ::webrtc::NetworkBindingResult; -using ::webrtc::NetworkMonitorInterface; -using ::webrtc::NetworkPreference; -using ::webrtc::NetworkPreferenceToString; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NETWORK_MONITOR_H_ diff --git a/rtc_base/network_monitor_factory.h b/rtc_base/network_monitor_factory.h index 8cdcdb7b93..cfcea8cb38 100644 --- a/rtc_base/network_monitor_factory.h +++ b/rtc_base/network_monitor_factory.h @@ -39,12 +39,5 @@ class NetworkMonitorFactory { } // 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::NetworkMonitorFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NETWORK_MONITOR_FACTORY_H_ diff --git a/rtc_base/network_route.h b/rtc_base/network_route.h index 153836c76c..b28a12d935 100644 --- a/rtc_base/network_route.h +++ b/rtc_base/network_route.h @@ -93,13 +93,5 @@ struct NetworkRoute { } // 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::NetworkRoute; -using ::webrtc::RouteEndpoint; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NETWORK_ROUTE_H_ diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc index dde29cbdb5..3b7edc22f9 100644 --- a/rtc_base/network_unittest.cc +++ b/rtc_base/network_unittest.cc @@ -10,9 +10,8 @@ #include "rtc_base/network.h" -#include - #include +#include #include #include #include diff --git a/rtc_base/null_socket_server.cc b/rtc_base/null_socket_server.cc index 47896a4213..088e4ad826 100644 --- a/rtc_base/null_socket_server.cc +++ b/rtc_base/null_socket_server.cc @@ -13,7 +13,7 @@ #include "api/units/time_delta.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" -#include "rtc_base/socket_server.h" +#include "rtc_base/socket.h" namespace webrtc { diff --git a/rtc_base/null_socket_server.h b/rtc_base/null_socket_server.h index 747c6d01d0..ccad464715 100644 --- a/rtc_base/null_socket_server.h +++ b/rtc_base/null_socket_server.h @@ -11,6 +11,7 @@ #ifndef RTC_BASE_NULL_SOCKET_SERVER_H_ #define RTC_BASE_NULL_SOCKET_SERVER_H_ +#include "api/units/time_delta.h" #include "rtc_base/event.h" #include "rtc_base/socket.h" #include "rtc_base/socket_server.h" @@ -34,12 +35,5 @@ class RTC_EXPORT NullSocketServer : public SocketServer { } // 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::NullSocketServer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NULL_SOCKET_SERVER_H_ diff --git a/rtc_base/null_socket_server_unittest.cc b/rtc_base/null_socket_server_unittest.cc index 81da9c3128..3b47acc5df 100644 --- a/rtc_base/null_socket_server_unittest.cc +++ b/rtc_base/null_socket_server_unittest.cc @@ -10,8 +10,7 @@ #include "rtc_base/null_socket_server.h" -#include - +#include #include #include "api/test/rtc_error_matchers.h" diff --git a/rtc_base/numerics/event_based_exponential_moving_average.h b/rtc_base/numerics/event_based_exponential_moving_average.h index 478263c2c2..100934a06b 100644 --- a/rtc_base/numerics/event_based_exponential_moving_average.h +++ b/rtc_base/numerics/event_based_exponential_moving_average.h @@ -67,12 +67,5 @@ class EventBasedExponentialMovingAverage { } // 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::EventBasedExponentialMovingAverage; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_EVENT_BASED_EXPONENTIAL_MOVING_AVERAGE_H_ diff --git a/rtc_base/numerics/exp_filter.h b/rtc_base/numerics/exp_filter.h index fe411c489c..b051e710f1 100644 --- a/rtc_base/numerics/exp_filter.h +++ b/rtc_base/numerics/exp_filter.h @@ -45,12 +45,5 @@ class ExpFilter { }; } // 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::ExpFilter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_EXP_FILTER_H_ diff --git a/rtc_base/numerics/histogram_percentile_counter.h b/rtc_base/numerics/histogram_percentile_counter.h index f1cb02e3da..4fc4104782 100644 --- a/rtc_base/numerics/histogram_percentile_counter.h +++ b/rtc_base/numerics/histogram_percentile_counter.h @@ -42,11 +42,4 @@ class HistogramPercentileCounter { }; } // 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::HistogramPercentileCounter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_HISTOGRAM_PERCENTILE_COUNTER_H_ diff --git a/rtc_base/numerics/mod_ops_unittest.cc b/rtc_base/numerics/mod_ops_unittest.cc index 3bd20345a7..839e9b046a 100644 --- a/rtc_base/numerics/mod_ops_unittest.cc +++ b/rtc_base/numerics/mod_ops_unittest.cc @@ -10,7 +10,7 @@ #include "rtc_base/numerics/mod_ops.h" -#include +#include #include "test/gtest.h" diff --git a/rtc_base/numerics/moving_average.h b/rtc_base/numerics/moving_average.h index 6011d0c23f..9cbab966c7 100644 --- a/rtc_base/numerics/moving_average.h +++ b/rtc_base/numerics/moving_average.h @@ -63,11 +63,4 @@ class MovingAverage { } // 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::MovingAverage; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_MOVING_AVERAGE_H_ diff --git a/rtc_base/numerics/moving_max_counter.h b/rtc_base/numerics/moving_max_counter.h index 88557a191b..0ee7f720de 100644 --- a/rtc_base/numerics/moving_max_counter.h +++ b/rtc_base/numerics/moving_max_counter.h @@ -115,12 +115,5 @@ void MovingMaxCounter::RollWindow(int64_t new_time_ms) { } // 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::MovingMaxCounter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_MOVING_MAX_COUNTER_H_ diff --git a/rtc_base/numerics/moving_percentile_filter_unittest.cc b/rtc_base/numerics/moving_percentile_filter_unittest.cc index f456108973..bcf9bd9959 100644 --- a/rtc_base/numerics/moving_percentile_filter_unittest.cc +++ b/rtc_base/numerics/moving_percentile_filter_unittest.cc @@ -10,10 +10,9 @@ #include "rtc_base/numerics/moving_percentile_filter.h" -#include - #include #include +#include #include "test/gtest.h" diff --git a/rtc_base/numerics/percentile_filter_unittest.cc b/rtc_base/numerics/percentile_filter_unittest.cc index d6826f42e1..ce4183db39 100644 --- a/rtc_base/numerics/percentile_filter_unittest.cc +++ b/rtc_base/numerics/percentile_filter_unittest.cc @@ -10,11 +10,10 @@ #include "rtc_base/numerics/percentile_filter.h" -#include - #include #include #include +#include #include #include diff --git a/rtc_base/numerics/running_statistics_unittest.cc b/rtc_base/numerics/running_statistics_unittest.cc index 7f8adfba24..f946bc3e14 100644 --- a/rtc_base/numerics/running_statistics_unittest.cc +++ b/rtc_base/numerics/running_statistics_unittest.cc @@ -10,8 +10,7 @@ #include "rtc_base/numerics/running_statistics.h" -#include - +#include #include #include diff --git a/rtc_base/numerics/safe_compare.h b/rtc_base/numerics/safe_compare.h index ef8d384d9b..578ea7707f 100644 --- a/rtc_base/numerics/safe_compare.h +++ b/rtc_base/numerics/safe_compare.h @@ -172,17 +172,5 @@ RTC_SAFECMP_MAKE_FUN(Ge) } // 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::SafeEq; -using ::webrtc::SafeGe; -using ::webrtc::SafeGt; -using ::webrtc::SafeLe; -using ::webrtc::SafeLt; -using ::webrtc::SafeNe; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_SAFE_COMPARE_H_ diff --git a/rtc_base/numerics/safe_conversions.h b/rtc_base/numerics/safe_conversions.h index 8b981ac9d1..4d0859a063 100644 --- a/rtc_base/numerics/safe_conversions.h +++ b/rtc_base/numerics/safe_conversions.h @@ -71,15 +71,5 @@ inline constexpr Dst saturated_cast(Src value) { } // 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::checked_cast; -using ::webrtc::dchecked_cast; -using ::webrtc::IsValueInRangeForNumericType; -using ::webrtc::saturated_cast; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_SAFE_CONVERSIONS_H_ diff --git a/rtc_base/numerics/safe_minmax.h b/rtc_base/numerics/safe_minmax.h index 959937967c..9c67727679 100644 --- a/rtc_base/numerics/safe_minmax.h +++ b/rtc_base/numerics/safe_minmax.h @@ -333,14 +333,5 @@ R2 SafeClamp(T x, L min, H max) { } // 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::SafeClamp; -using ::webrtc::SafeMax; -using ::webrtc::SafeMin; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_SAFE_MINMAX_H_ diff --git a/rtc_base/numerics/sample_counter.h b/rtc_base/numerics/sample_counter.h index 86a1691c91..635b55ed09 100644 --- a/rtc_base/numerics/sample_counter.h +++ b/rtc_base/numerics/sample_counter.h @@ -58,12 +58,4 @@ class SampleCounterWithVariance : public SampleCounter { } // 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::SampleCounter; -using ::webrtc::SampleCounterWithVariance; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_NUMERICS_SAMPLE_COUNTER_H_ diff --git a/rtc_base/openssl_adapter.cc b/rtc_base/openssl_adapter.cc index 4a74944be9..6ac2c66547 100644 --- a/rtc_base/openssl_adapter.cc +++ b/rtc_base/openssl_adapter.cc @@ -10,13 +10,13 @@ #include "rtc_base/openssl_adapter.h" -#include #include #include #include #include #include +#include #include #include #include diff --git a/rtc_base/openssl_adapter.h b/rtc_base/openssl_adapter.h index 3f3951d434..a015ab5468 100644 --- a/rtc_base/openssl_adapter.h +++ b/rtc_base/openssl_adapter.h @@ -235,14 +235,5 @@ std::string TransformAlpnProtocols(const std::vector& protos); } // 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::OpenSSLAdapter; -using ::webrtc::OpenSSLAdapterFactory; -using ::webrtc::TransformAlpnProtocols; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_ADAPTER_H_ diff --git a/rtc_base/openssl_certificate.h b/rtc_base/openssl_certificate.h index 044edca3f1..4da960bca4 100644 --- a/rtc_base/openssl_certificate.h +++ b/rtc_base/openssl_certificate.h @@ -68,14 +68,5 @@ class OpenSSLCertificate final : public SSLCertificate { } // 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::OpenSSLCertificate; - -} -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_CERTIFICATE_H_ diff --git a/rtc_base/openssl_digest.h b/rtc_base/openssl_digest.h index 345fe4a9bc..f4a7a3dff4 100644 --- a/rtc_base/openssl_digest.h +++ b/rtc_base/openssl_digest.h @@ -48,12 +48,5 @@ class OpenSSLDigest final : public MessageDigest { } // 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::OpenSSLDigest; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_DIGEST_H_ diff --git a/rtc_base/openssl_identity.h b/rtc_base/openssl_identity.h index 68392dc19d..b30c434963 100644 --- a/rtc_base/openssl_identity.h +++ b/rtc_base/openssl_identity.h @@ -73,12 +73,5 @@ class OpenSSLIdentity final : public SSLIdentity { } // 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::OpenSSLIdentity; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_IDENTITY_H_ diff --git a/rtc_base/openssl_key_pair.h b/rtc_base/openssl_key_pair.h index a8a3aa0d9a..a9525b2cc0 100644 --- a/rtc_base/openssl_key_pair.h +++ b/rtc_base/openssl_key_pair.h @@ -58,12 +58,5 @@ class OpenSSLKeyPair final { } // 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::OpenSSLKeyPair; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_KEY_PAIR_H_ diff --git a/rtc_base/openssl_session_cache.h b/rtc_base/openssl_session_cache.h index 0bcbad0e34..80d8867c50 100644 --- a/rtc_base/openssl_session_cache.h +++ b/rtc_base/openssl_session_cache.h @@ -69,12 +69,5 @@ class OpenSSLSessionCache final { } // 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::OpenSSLSessionCache; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_SESSION_CACHE_H_ diff --git a/rtc_base/openssl_session_cache_unittest.cc b/rtc_base/openssl_session_cache_unittest.cc index 1d4f18145a..4b4da72211 100644 --- a/rtc_base/openssl_session_cache_unittest.cc +++ b/rtc_base/openssl_session_cache_unittest.cc @@ -11,7 +11,8 @@ #include "rtc_base/openssl_session_cache.h" #include -#include + +#include #include "rtc_base/ssl_stream_adapter.h" #include "test/gtest.h" diff --git a/rtc_base/openssl_stream_adapter.cc b/rtc_base/openssl_stream_adapter.cc index 604a9465c7..0bf0d8ea62 100644 --- a/rtc_base/openssl_stream_adapter.cc +++ b/rtc_base/openssl_stream_adapter.cc @@ -852,10 +852,15 @@ void OpenSSLStreamAdapter::SetTimeout(int delay_ms) { // We check the timer even after SSL_CONNECTED, // but ContinueSSL() is only needed when SSL_CONNECTING if (state_ == SSL_CONNECTING) { + // Note: timeout is set inside ContinueSSL() ContinueSSL(); + } else if (state_ == SSL_CONNECTED) { + MaybeSetTimeout(); + } else { + RTC_DCHECK_NOTREACHED() << "state_: " << state_; } } else { - RTC_DCHECK_NOTREACHED(); + RTC_DCHECK_NOTREACHED() << "flag->alive() == false"; } // This callback will never run again (stopped above). return TimeDelta::PlusInfinity(); @@ -970,6 +975,12 @@ int OpenSSLStreamAdapter::ContinueSSL() { } } + MaybeSetTimeout(); + + return 0; +} + +void OpenSSLStreamAdapter::MaybeSetTimeout() { if (ssl_ != nullptr) { struct timeval timeout; if (DTLSv1_get_timeout(ssl_, &timeout)) { @@ -977,8 +988,6 @@ int OpenSSLStreamAdapter::ContinueSSL() { SetTimeout(delay); } } - - return 0; } void OpenSSLStreamAdapter::Error(absl::string_view context, diff --git a/rtc_base/openssl_stream_adapter.h b/rtc_base/openssl_stream_adapter.h index 2cce9c1c01..c10e93e3d4 100644 --- a/rtc_base/openssl_stream_adapter.h +++ b/rtc_base/openssl_stream_adapter.h @@ -210,6 +210,8 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { !peer_certificate_digest_value_.empty(); } + void MaybeSetTimeout(); + const std::unique_ptr stream_; absl::AnyInvocable handshake_error_; @@ -277,12 +279,5 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { } // 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::OpenSSLStreamAdapter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_STREAM_ADAPTER_H_ diff --git a/rtc_base/openssl_utility.h b/rtc_base/openssl_utility.h index bdab3ce90a..c2cc25a2e1 100644 --- a/rtc_base/openssl_utility.h +++ b/rtc_base/openssl_utility.h @@ -57,26 +57,5 @@ CRYPTO_BUFFER_POOL* GetBufferPool(); } // namespace openssl } // 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 { -namespace openssl { - -#ifndef WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS -using ::webrtc::openssl::LoadBuiltinSSLRootCertificates; -#endif - -using ::webrtc::openssl::LogSSLErrors; -using ::webrtc::openssl::VerifyPeerCertMatchesHost; - -#ifdef OPENSSL_IS_BORINGSSL -using ::webrtc::openssl::GetBufferPool; -using ::webrtc::openssl::ParseCertificate; -#endif - -} // namespace openssl -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPENSSL_UTILITY_H_ diff --git a/rtc_base/openssl_utility_unittest.cc b/rtc_base/openssl_utility_unittest.cc index a2f1f5cd54..f1c3b8880e 100644 --- a/rtc_base/openssl_utility_unittest.cc +++ b/rtc_base/openssl_utility_unittest.cc @@ -34,7 +34,7 @@ namespace webrtc { namespace { // Fake P-256 key for use with the test certificates below. -const unsigned char kFakeSSLPrivateKey[] = { +constexpr unsigned char kFakeSSLPrivateKey[] = { 0x30, 0x81, 0x87, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04, 0x20, @@ -50,7 +50,7 @@ const unsigned char kFakeSSLPrivateKey[] = { // A self-signed certificate with CN *.webrtc.org and SANs foo.test, *.bar.test, // and test.webrtc.org. -const unsigned char kFakeSSLCertificate[] = { +constexpr unsigned char kFakeSSLCertificate[] = { 0x30, 0x82, 0x02, 0x9e, 0x30, 0x82, 0x02, 0x42, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xc8, 0x83, 0x59, 0x4d, 0x90, 0xc3, 0x5f, 0xc8, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, @@ -110,7 +110,7 @@ const unsigned char kFakeSSLCertificate[] = { 0xc3, 0x71}; // A self-signed SSL certificate with only the legacy CN field *.webrtc.org. -const unsigned char kFakeSSLCertificateLegacy[] = { +constexpr unsigned char kFakeSSLCertificateLegacy[] = { 0x30, 0x82, 0x02, 0x6a, 0x30, 0x82, 0x02, 0x0e, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xc8, 0x83, 0x59, 0x4d, 0x90, 0xc3, 0x5f, 0xc8, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, diff --git a/rtc_base/operations_chain.h b/rtc_base/operations_chain.h index 7c83b0a006..6a2e4a8bf5 100644 --- a/rtc_base/operations_chain.h +++ b/rtc_base/operations_chain.h @@ -198,12 +198,5 @@ class OperationsChain final : public RefCountedNonVirtual { } // 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::OperationsChain; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_OPERATIONS_CHAIN_H_ diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc index 0844b7fa66..2116af1381 100644 --- a/rtc_base/physical_socket_server.cc +++ b/rtc_base/physical_socket_server.cc @@ -10,6 +10,7 @@ #include "rtc_base/physical_socket_server.h" #include +#include #include #include #include @@ -19,14 +20,19 @@ #include "api/transport/ecn_marking.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "rtc_base/async_dns_resolver.h" +#include "rtc_base/checks.h" #include "rtc_base/deprecated/recursive_critical_section.h" +#include "rtc_base/event.h" +#include "rtc_base/ip_address.h" +#include "rtc_base/logging.h" +#include "rtc_base/net_helpers.h" +#include "rtc_base/network_monitor.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" - -#if defined(_MSC_VER) && _MSC_VER < 1300 -#pragma warning(disable : 4786) -#endif +#include "rtc_base/time_utils.h" #ifdef MEMORY_SANITIZER #include @@ -34,9 +40,11 @@ #if defined(WEBRTC_POSIX) #include +#include // for TCP_NODELAY #if defined(WEBRTC_USE_EPOLL) // "poll" will be used to wait for the signal dispatcher. #include +#include #elif defined(WEBRTC_USE_POLL) #include #endif @@ -53,40 +61,24 @@ #undef SetPort #endif -#include - -#include "rtc_base/async_dns_resolver.h" -#include "rtc_base/checks.h" -#include "rtc_base/event.h" -#include "rtc_base/ip_address.h" -#include "rtc_base/logging.h" -#include "rtc_base/network/ecn_marking.h" -#include "rtc_base/network_monitor.h" -#include "rtc_base/synchronization/mutex.h" -#include "rtc_base/time_utils.h" - #if defined(WEBRTC_LINUX) +#include #include +#include #endif #if defined(WEBRTC_WIN) #define LAST_SYSTEM_ERROR (::GetLastError()) -#elif defined(__native_client__) && __native_client__ -#define LAST_SYSTEM_ERROR (0) #elif defined(WEBRTC_POSIX) #define LAST_SYSTEM_ERROR (errno) #endif // WEBRTC_WIN #if defined(WEBRTC_POSIX) -#include // for TCP_NODELAY - #define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h typedef void* SockOptArg; - #endif // WEBRTC_POSIX -#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(__native_client__) - +#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) int64_t GetSocketRecvTimestamp(int socket) { struct timeval tv_ioctl; int ret = ioctl(socket, SIOCGSTAMP, &tv_ioctl); @@ -99,7 +91,6 @@ int64_t GetSocketRecvTimestamp(int socket) { } #else - int64_t GetSocketRecvTimestamp(int /* socket */) { return -1; } @@ -707,7 +698,7 @@ int PhysicalSocket::TranslateOption(Option opt, int* slevel, int* sopt) { *slevel = IPPROTO_IP; *sopt = IP_DONTFRAGMENT; break; -#elif defined(WEBRTC_MAC) || defined(BSD) || defined(__native_client__) +#elif defined(WEBRTC_MAC) || defined(BSD) RTC_LOG(LS_WARNING) << "Socket::OPT_DONTFRAGMENT not supported."; return -1; #elif defined(WEBRTC_POSIX) diff --git a/rtc_base/physical_socket_server.h b/rtc_base/physical_socket_server.h index e06bd10387..b542aaa558 100644 --- a/rtc_base/physical_socket_server.h +++ b/rtc_base/physical_socket_server.h @@ -310,21 +310,5 @@ class SocketDispatcher : public Dispatcher, public PhysicalSocket { } // 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::DE_ACCEPT; -using ::webrtc::DE_CLOSE; -using ::webrtc::DE_CONNECT; -using ::webrtc::DE_READ; -using ::webrtc::DE_WRITE; -using ::webrtc::Dispatcher; -using ::webrtc::DispatcherEvent; -using ::webrtc::PhysicalSocket; -using ::webrtc::PhysicalSocketServer; -using ::webrtc::SocketDispatcher; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_PHYSICAL_SOCKET_SERVER_H_ diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc index 7f11696b21..861dacae95 100644 --- a/rtc_base/platform_thread.cc +++ b/rtc_base/platform_thread.cc @@ -47,7 +47,7 @@ bool SetPriority(ThreadPriority priority) { #if defined(WEBRTC_WIN) return SetThreadPriority(GetCurrentThread(), Win32PriorityFromThreadPriority(priority)) != FALSE; -#elif defined(__native_client__) || defined(WEBRTC_FUCHSIA) || \ +#elif defined(WEBRTC_FUCHSIA) || \ (defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)) // Setting thread priorities is not supported in NaCl, Fuchsia or Emscripten // without pthreads. diff --git a/rtc_base/platform_thread.h b/rtc_base/platform_thread.h index df7ca46fda..7a15a726e7 100644 --- a/rtc_base/platform_thread.h +++ b/rtc_base/platform_thread.h @@ -12,15 +12,14 @@ #define RTC_BASE_PLATFORM_THREAD_H_ #include -#include -#if !defined(WEBRTC_WIN) -#include -#endif - #include #include "absl/strings/string_view.h" -#include "rtc_base/platform_thread_types.h" +#include "rtc_base/platform_thread_types.h" // IWYU pragma: keep + +#if !defined(WEBRTC_WIN) +#include // IWYU pragma: keep +#endif namespace webrtc { @@ -118,14 +117,5 @@ class PlatformThread final { } // 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::PlatformThread; -using ::webrtc::ThreadAttributes; -using ::webrtc::ThreadPriority; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_PLATFORM_THREAD_H_ diff --git a/rtc_base/platform_thread_types.cc b/rtc_base/platform_thread_types.cc index f057d4b7c3..20bf4afc44 100644 --- a/rtc_base/platform_thread_types.cc +++ b/rtc_base/platform_thread_types.cc @@ -12,8 +12,13 @@ // IWYU pragma: begin_keep #if defined(WEBRTC_LINUX) +#include #include #include + +#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) +#include +#endif #endif #if defined(WEBRTC_WIN) @@ -27,7 +32,6 @@ typedef HRESULT(WINAPI* RTC_SetThreadDescription)(HANDLE hThread, #endif #if defined(WEBRTC_FUCHSIA) -#include #include #include "rtc_base/checks.h" diff --git a/rtc_base/platform_thread_types.h b/rtc_base/platform_thread_types.h index 603e46ff08..f5c90682e9 100644 --- a/rtc_base/platform_thread_types.h +++ b/rtc_base/platform_thread_types.h @@ -21,6 +21,7 @@ #include #include #elif defined(WEBRTC_FUCHSIA) +#include #include #include #elif defined(WEBRTC_POSIX) @@ -33,6 +34,10 @@ // clang-format on // IWYU pragma: end_exports +#if !defined(WEBRTC_WIN) +#include +#endif + namespace webrtc { #if defined(WEBRTC_WIN) typedef DWORD PlatformThreadId; @@ -61,17 +66,5 @@ void SetCurrentThreadName(const char* name); } // 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::CurrentThreadId; -using ::webrtc::CurrentThreadRef; -using ::webrtc::IsThreadRefEqual; -using ::webrtc::PlatformThreadId; -using ::webrtc::PlatformThreadRef; -using ::webrtc::SetCurrentThreadName; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_PLATFORM_THREAD_TYPES_H_ diff --git a/rtc_base/platform_thread_unittest.cc b/rtc_base/platform_thread_unittest.cc index 921138de22..6ccf78b01a 100644 --- a/rtc_base/platform_thread_unittest.cc +++ b/rtc_base/platform_thread_unittest.cc @@ -11,9 +11,11 @@ #include "rtc_base/platform_thread.h" #include +#include +#include "api/units/time_delta.h" #include "rtc_base/event.h" -#include "test/gmock.h" +#include "test/gtest.h" namespace webrtc { diff --git a/rtc_base/protobuf_utils.h b/rtc_base/protobuf_utils.h index 497b7f488f..8ca9f2e3d8 100644 --- a/rtc_base/protobuf_utils.h +++ b/rtc_base/protobuf_utils.h @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #ifndef RTC_BASE_PROTOBUF_UTILS_H_ #define RTC_BASE_PROTOBUF_UTILS_H_ @@ -16,7 +15,9 @@ #if WEBRTC_ENABLE_PROTOBUF #include "third_party/protobuf/src/google/protobuf/message_lite.h" // nogncheck +// IWYU pragma: begin_keep #include "third_party/protobuf/src/google/protobuf/repeated_field.h" // nogncheck +// IWYU pragma: end_keep namespace webrtc { diff --git a/rtc_base/proxy_server.cc b/rtc_base/proxy_server.cc index d9b94c5c25..8ef45cf2a4 100644 --- a/rtc_base/proxy_server.cc +++ b/rtc_base/proxy_server.cc @@ -10,9 +10,8 @@ #include "rtc_base/proxy_server.h" -#include - #include +#include #include #include "rtc_base/checks.h" diff --git a/rtc_base/proxy_server.h b/rtc_base/proxy_server.h index ded2478da8..81fd84bd43 100644 --- a/rtc_base/proxy_server.h +++ b/rtc_base/proxy_server.h @@ -90,13 +90,5 @@ class ProxyServer : public sigslot::has_slots<> { } // 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::ProxyBinding; -using ::webrtc::ProxyServer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_PROXY_SERVER_H_ diff --git a/rtc_base/race_checker.h b/rtc_base/race_checker.h index 4a0c594fea..92c8b72a4d 100644 --- a/rtc_base/race_checker.h +++ b/rtc_base/race_checker.h @@ -62,13 +62,6 @@ class RTC_SCOPED_LOCKABLE RaceCheckerScopeDoNothing { } // namespace internal } // 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::RaceChecker; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #define RTC_CHECK_RUNS_SERIALIZED(x) RTC_CHECK_RUNS_SERIALIZED_NEXT(x, __LINE__) diff --git a/rtc_base/random.cc b/rtc_base/random.cc index 319ad72177..8fd23ea7ad 100644 --- a/rtc_base/random.cc +++ b/rtc_base/random.cc @@ -9,8 +9,7 @@ */ #include "rtc_base/random.h" -#include - +#include #include #include diff --git a/rtc_base/random_unittest.cc b/rtc_base/random_unittest.cc index d1827cd71c..3c3d2765ed 100644 --- a/rtc_base/random_unittest.cc +++ b/rtc_base/random_unittest.cc @@ -10,8 +10,7 @@ #include "rtc_base/random.h" -#include - +#include #include #include #include diff --git a/rtc_base/rate_statistics_unittest.cc b/rtc_base/rate_statistics_unittest.cc index a037b7b4ec..e5fda5c71a 100644 --- a/rtc_base/rate_statistics_unittest.cc +++ b/rtc_base/rate_statistics_unittest.cc @@ -21,7 +21,7 @@ namespace { using webrtc::RateStatistics; -const int64_t kWindowMs = 500; +constexpr int64_t kWindowMs = 500; class RateStatisticsTest : public ::testing::Test { protected: diff --git a/rtc_base/rate_tracker.h b/rtc_base/rate_tracker.h index 37155878c4..df8d9e82fc 100644 --- a/rtc_base/rate_tracker.h +++ b/rtc_base/rate_tracker.h @@ -69,12 +69,5 @@ class RateTracker { } // 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::RateTracker; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_RATE_TRACKER_H_ diff --git a/rtc_base/rate_tracker_unittest.cc b/rtc_base/rate_tracker_unittest.cc index 7eed504f93..d2ceabaed4 100644 --- a/rtc_base/rate_tracker_unittest.cc +++ b/rtc_base/rate_tracker_unittest.cc @@ -16,7 +16,7 @@ namespace webrtc { namespace { -const uint32_t kBucketIntervalMs = 100; +constexpr uint32_t kBucketIntervalMs = 100; } // namespace class RateTrackerForTest : public RateTracker { diff --git a/rtc_base/ref_count.h b/rtc_base/ref_count.h index d1ef143360..fc9caa73bd 100644 --- a/rtc_base/ref_count.h +++ b/rtc_base/ref_count.h @@ -15,17 +15,5 @@ #include "api/ref_count.h" -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { - -// TODO(bugs.webrtc.org/15622): Deprecate and remove these aliases. -using RefCountInterface [[deprecated("Use webrtc::RefCountInterface")]] = - webrtc::RefCountInterface; -using RefCountReleaseStatus - [[deprecated("Use webrtc::RefCountReleaseStatus")]] = - webrtc::RefCountReleaseStatus; - -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_REF_COUNT_H_ diff --git a/rtc_base/ref_counted_object.h b/rtc_base/ref_counted_object.h index 5caba330f3..eee0731128 100644 --- a/rtc_base/ref_counted_object.h +++ b/rtc_base/ref_counted_object.h @@ -87,13 +87,5 @@ class FinalRefCountedObject final : public T { } // namespace webrtc -// Backwards compatibe aliases. -// TODO: https://issues.webrtc.org/42225969 - deprecate and remove. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace rtc { -using ::webrtc::FinalRefCountedObject; -using ::webrtc::RefCountedObject; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_REF_COUNTED_OBJECT_H_ diff --git a/rtc_base/ref_counted_object_unittest.cc b/rtc_base/ref_counted_object_unittest.cc index fff301cac2..6f4b4eda5d 100644 --- a/rtc_base/ref_counted_object_unittest.cc +++ b/rtc_base/ref_counted_object_unittest.cc @@ -17,8 +17,8 @@ #include "absl/strings/string_view.h" #include "api/make_ref_counted.h" +#include "api/ref_count.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_count.h" #include "test/gtest.h" namespace webrtc { diff --git a/rtc_base/rolling_accumulator.h b/rtc_base/rolling_accumulator.h index 8a46d5fe2c..4886db54f3 100644 --- a/rtc_base/rolling_accumulator.h +++ b/rtc_base/rolling_accumulator.h @@ -142,12 +142,5 @@ class RollingAccumulator { } // 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::RollingAccumulator; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_ROLLING_ACCUMULATOR_H_ diff --git a/rtc_base/rolling_accumulator_unittest.cc b/rtc_base/rolling_accumulator_unittest.cc index b32aa8c67d..c321e3c71e 100644 --- a/rtc_base/rolling_accumulator_unittest.cc +++ b/rtc_base/rolling_accumulator_unittest.cc @@ -18,7 +18,7 @@ namespace webrtc { namespace { -const double kLearningRate = 0.5; +constexpr double kLearningRate = 0.5; // Add `n` samples drawn from uniform distribution in [a;b]. void FillStatsFromUniformDistribution(RollingAccumulator& stats, diff --git a/rtc_base/rtc_certificate.h b/rtc_base/rtc_certificate.h index 7d47656521..8eca23bc0d 100644 --- a/rtc_base/rtc_certificate.h +++ b/rtc_base/rtc_certificate.h @@ -91,13 +91,5 @@ class RTC_EXPORT RTCCertificate final } // 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::RTCCertificate; -using ::webrtc::RTCCertificatePEM; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_RTC_CERTIFICATE_H_ diff --git a/rtc_base/rtc_certificate_generator.cc b/rtc_base/rtc_certificate_generator.cc index d496e2fb15..bbcec2c6eb 100644 --- a/rtc_base/rtc_certificate_generator.cc +++ b/rtc_base/rtc_certificate_generator.cc @@ -10,10 +10,9 @@ #include "rtc_base/rtc_certificate_generator.h" -#include - #include #include +#include #include #include #include diff --git a/rtc_base/rtc_certificate_generator.h b/rtc_base/rtc_certificate_generator.h index b5be2067aa..01e2553c51 100644 --- a/rtc_base/rtc_certificate_generator.h +++ b/rtc_base/rtc_certificate_generator.h @@ -80,13 +80,5 @@ class RTC_EXPORT RTCCertificateGenerator } // 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::RTCCertificateGenerator; -using ::webrtc::RTCCertificateGeneratorInterface; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_RTC_CERTIFICATE_GENERATOR_H_ diff --git a/rtc_base/rtc_certificate_unittest.cc b/rtc_base/rtc_certificate_unittest.cc index 9b021ec447..9f95bffb93 100644 --- a/rtc_base/rtc_certificate_unittest.cc +++ b/rtc_base/rtc_certificate_unittest.cc @@ -10,9 +10,8 @@ #include "rtc_base/rtc_certificate.h" -#include - #include +#include #include #include @@ -27,7 +26,7 @@ namespace webrtc { namespace { -const char* kTestCertCommonName = "RTCCertificateTest's certificate"; +constexpr char kTestCertCommonName[] = "RTCCertificateTest's certificate"; } // namespace diff --git a/rtc_base/sanitizer.h b/rtc_base/sanitizer.h index 2f5045d18e..9b68f56b15 100644 --- a/rtc_base/sanitizer.h +++ b/rtc_base/sanitizer.h @@ -159,17 +159,6 @@ inline void MsanCheckInitialized(const T& mem) { } // 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::AsanPoison; -using ::webrtc::AsanUnpoison; -using ::webrtc::MsanCheckInitialized; -using ::webrtc::MsanMarkUninitialized; -using ::webrtc::MsanUninitialized; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // __cplusplus diff --git a/rtc_base/sanitizer_unittest.cc b/rtc_base/sanitizer_unittest.cc index e293a43c23..d77a5c67fd 100644 --- a/rtc_base/sanitizer_unittest.cc +++ b/rtc_base/sanitizer_unittest.cc @@ -10,7 +10,7 @@ #include "rtc_base/sanitizer.h" -#include +#include #include "rtc_base/logging.h" #include "test/gtest.h" diff --git a/rtc_base/server_socket_adapters.h b/rtc_base/server_socket_adapters.h index 93e3127e0f..8f53cf4aaa 100644 --- a/rtc_base/server_socket_adapters.h +++ b/rtc_base/server_socket_adapters.h @@ -45,13 +45,5 @@ class AsyncSSLServerSocket : public BufferedReadAdapter { } // 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::AsyncProxyServerSocket; -using ::webrtc::AsyncSSLServerSocket; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SERVER_SOCKET_ADAPTERS_H_ diff --git a/rtc_base/socket.cc b/rtc_base/socket.cc index 26a5081886..639e78bb80 100644 --- a/rtc_base/socket.cc +++ b/rtc_base/socket.cc @@ -12,6 +12,7 @@ #include +#include "api/units/timestamp.h" #include "rtc_base/buffer.h" namespace webrtc { diff --git a/rtc_base/socket.h b/rtc_base/socket.h index ac220cb0e5..ad4e132418 100644 --- a/rtc_base/socket.h +++ b/rtc_base/socket.h @@ -11,12 +11,19 @@ #ifndef RTC_BASE_SOCKET_H_ #define RTC_BASE_SOCKET_H_ -#include - +#include #include #include #include +#include "api/transport/ecn_marking.h" +#include "api/units/timestamp.h" +#include "rtc_base/buffer.h" +#include "rtc_base/checks.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/system/rtc_export.h" +#include "rtc_base/third_party/sigslot/sigslot.h" + // IWYU pragma: begin_exports #if defined(WEBRTC_POSIX) #include @@ -25,20 +32,9 @@ #endif // IWYU pragma: end_exports -#include "api/units/timestamp.h" -#include "rtc_base/buffer.h" -#include "rtc_base/checks.h" -#include "rtc_base/ip_address.h" -#include "rtc_base/net_helpers.h" -#include "rtc_base/network/ecn_marking.h" -#include "rtc_base/socket_address.h" -#include "rtc_base/system/rtc_export.h" -#include "rtc_base/third_party/sigslot/sigslot.h" - // Rather than converting errors into a private namespace, // Reuse the POSIX socket api errors. Note this depends on // Win32 compatibility. - #if defined(WEBRTC_WIN) #undef EWOULDBLOCK // Remove errno.h's definition for each macro below. #define EWOULDBLOCK WSAEWOULDBLOCK @@ -174,13 +170,5 @@ class RTC_EXPORT Socket { } // 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::IsBlockingError; -using ::webrtc::Socket; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SOCKET_H_ diff --git a/rtc_base/socket_adapters.cc b/rtc_base/socket_adapters.cc index 3cd523b5b8..a3ff8bdcc5 100644 --- a/rtc_base/socket_adapters.cc +++ b/rtc_base/socket_adapters.cc @@ -8,22 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ -#if defined(_MSC_VER) && _MSC_VER < 1300 -#pragma warning(disable : 4786) -#endif - #include "rtc_base/socket_adapters.h" #include +#include +#include +#include +#include -#include "absl/strings/match.h" -#include "absl/strings/string_view.h" -#include "rtc_base/buffer.h" -#include "rtc_base/byte_buffer.h" +#include "api/array_view.h" +#include "rtc_base/async_socket.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "rtc_base/strings/string_builder.h" -#include "rtc_base/zero_memory.h" +#include "rtc_base/socket.h" +#include "rtc_base/socket_address.h" namespace webrtc { diff --git a/rtc_base/socket_adapters.h b/rtc_base/socket_adapters.h index 2e0731e6b4..3abd888ad3 100644 --- a/rtc_base/socket_adapters.h +++ b/rtc_base/socket_adapters.h @@ -76,13 +76,5 @@ class AsyncSSLSocket : public BufferedReadAdapter { } // 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::AsyncSSLSocket; -using ::webrtc::BufferedReadAdapter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SOCKET_ADAPTERS_H_ diff --git a/rtc_base/socket_address.cc b/rtc_base/socket_address.cc index f9c21f92f4..98455f8a83 100644 --- a/rtc_base/socket_address.cc +++ b/rtc_base/socket_address.cc @@ -20,8 +20,6 @@ #if defined(OPENBSD) #include #endif -#if !defined(__native_client__) -#endif #endif #include "absl/strings/string_view.h" diff --git a/rtc_base/socket_address.h b/rtc_base/socket_address.h index 25547b2061..3cfd6b6adb 100644 --- a/rtc_base/socket_address.h +++ b/rtc_base/socket_address.h @@ -201,14 +201,5 @@ SocketAddress EmptySocketAddressWithFamily(int family); } // 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::EmptySocketAddressWithFamily; -using ::webrtc::SocketAddress; -using ::webrtc::SocketAddressFromSockAddrStorage; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SOCKET_ADDRESS_H_ diff --git a/rtc_base/socket_address_pair.cc b/rtc_base/socket_address_pair.cc index b97c086f02..c956b3cc6c 100644 --- a/rtc_base/socket_address_pair.cc +++ b/rtc_base/socket_address_pair.cc @@ -10,6 +10,10 @@ #include "rtc_base/socket_address_pair.h" +#include + +#include "rtc_base/socket_address.h" + namespace webrtc { SocketAddressPair::SocketAddressPair(const SocketAddress& src, diff --git a/rtc_base/socket_address_pair.h b/rtc_base/socket_address_pair.h index 1da190c8c0..3634299e4e 100644 --- a/rtc_base/socket_address_pair.h +++ b/rtc_base/socket_address_pair.h @@ -40,12 +40,5 @@ class SocketAddressPair { } // 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::SocketAddressPair; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SOCKET_ADDRESS_PAIR_H_ diff --git a/rtc_base/socket_address_unittest.cc b/rtc_base/socket_address_unittest.cc index e81fb6daa0..fa9bf82159 100644 --- a/rtc_base/socket_address_unittest.cc +++ b/rtc_base/socket_address_unittest.cc @@ -10,8 +10,7 @@ #include "rtc_base/socket_address.h" -#include - +#include #include #include "rtc_base/ip_address.h" diff --git a/rtc_base/socket_factory.h b/rtc_base/socket_factory.h index 2aa8acc7df..6cbc4b4e8c 100644 --- a/rtc_base/socket_factory.h +++ b/rtc_base/socket_factory.h @@ -25,12 +25,5 @@ class SocketFactory { } // 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::SocketFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SOCKET_FACTORY_H_ diff --git a/rtc_base/socket_server.h b/rtc_base/socket_server.h index a655271cdf..6b05f58acd 100644 --- a/rtc_base/socket_server.h +++ b/rtc_base/socket_server.h @@ -66,12 +66,5 @@ class SocketServer : public SocketFactory { } // 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::SocketServer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SOCKET_SERVER_H_ diff --git a/rtc_base/socket_unittest.cc b/rtc_base/socket_unittest.cc index bd3c8606b2..90dd485544 100644 --- a/rtc_base/socket_unittest.cc +++ b/rtc_base/socket_unittest.cc @@ -10,12 +10,10 @@ #include "rtc_base/socket.h" -#include -#include -#include - +#include #include #include +#include #include #include #include diff --git a/rtc_base/socket_unittest.h b/rtc_base/socket_unittest.h index 48c7ee11d4..4532a067c9 100644 --- a/rtc_base/socket_unittest.h +++ b/rtc_base/socket_unittest.h @@ -110,13 +110,5 @@ bool IsUnspecOrEmptyIP(const IPAddress& address); } // 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::IsUnspecOrEmptyIP; -using ::webrtc::SocketTest; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SOCKET_UNITTEST_H_ diff --git a/rtc_base/ssl_adapter.h b/rtc_base/ssl_adapter.h index 084e2be78f..7b91c56928 100644 --- a/rtc_base/ssl_adapter.h +++ b/rtc_base/ssl_adapter.h @@ -125,15 +125,5 @@ RTC_EXPORT bool CleanupSSL(); } // 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::CleanupSSL; -using ::webrtc::InitializeSSL; -using ::webrtc::SSLAdapter; -using ::webrtc::SSLAdapterFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SSL_ADAPTER_H_ diff --git a/rtc_base/ssl_certificate.h b/rtc_base/ssl_certificate.h index 825953b470..3aef01518e 100644 --- a/rtc_base/ssl_certificate.h +++ b/rtc_base/ssl_certificate.h @@ -137,15 +137,5 @@ class SSLCertificateVerifier { } // 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::SSLCertChain; -using ::webrtc::SSLCertificate; -using ::webrtc::SSLCertificateStats; -using ::webrtc::SSLCertificateVerifier; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SSL_CERTIFICATE_H_ diff --git a/rtc_base/ssl_fingerprint.cc b/rtc_base/ssl_fingerprint.cc index ca15d11bda..f3f6fa6228 100644 --- a/rtc_base/ssl_fingerprint.cc +++ b/rtc_base/ssl_fingerprint.cc @@ -10,8 +10,7 @@ #include "rtc_base/ssl_fingerprint.h" -#include - +#include #include #include #include diff --git a/rtc_base/ssl_fingerprint.h b/rtc_base/ssl_fingerprint.h index 9c9524f1f9..89757f4865 100644 --- a/rtc_base/ssl_fingerprint.h +++ b/rtc_base/ssl_fingerprint.h @@ -74,12 +74,5 @@ struct RTC_EXPORT SSLFingerprint { } // 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::SSLFingerprint; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SSL_FINGERPRINT_H_ diff --git a/rtc_base/ssl_identity.cc b/rtc_base/ssl_identity.cc index 35930f8fe1..2186d3a60f 100644 --- a/rtc_base/ssl_identity.cc +++ b/rtc_base/ssl_identity.cc @@ -12,10 +12,10 @@ #include "rtc_base/ssl_identity.h" #include -#include -#include #include +#include +#include #include #include #include diff --git a/rtc_base/ssl_identity.h b/rtc_base/ssl_identity.h index 2d426e6986..9d00db21cb 100644 --- a/rtc_base/ssl_identity.h +++ b/rtc_base/ssl_identity.h @@ -165,33 +165,5 @@ extern const char kPemTypeEcPrivateKey[]; } // 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::ASN1TimeToSec; -using ::webrtc::EC_LAST; -using ::webrtc::EC_NIST_P256; -using ::webrtc::ECCurve; -using ::webrtc::kCertificateWindowInSeconds; -using ::webrtc::kDefaultCertificateLifetimeInSeconds; -using ::webrtc::KeyParams; -using ::webrtc::KeyType; -using ::webrtc::kPemTypeCertificate; -using ::webrtc::kPemTypeEcPrivateKey; -using ::webrtc::kPemTypeRsaPrivateKey; -using ::webrtc::kRsaDefaultExponent; -using ::webrtc::kRsaDefaultModSize; -using ::webrtc::kRsaMaxModSize; -using ::webrtc::kRsaMinModSize; -using ::webrtc::KT_DEFAULT; -using ::webrtc::KT_ECDSA; -using ::webrtc::KT_LAST; -using ::webrtc::KT_RSA; -using ::webrtc::RSAParams; -using ::webrtc::SSLIdentity; -using ::webrtc::SSLIdentityParams; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SSL_IDENTITY_H_ diff --git a/rtc_base/ssl_identity_unittest.cc b/rtc_base/ssl_identity_unittest.cc index ec1a80078b..fb6ff0803d 100644 --- a/rtc_base/ssl_identity_unittest.cc +++ b/rtc_base/ssl_identity_unittest.cc @@ -16,7 +16,6 @@ #include // IWYU pragma: keep #endif #include -#include #include #include @@ -41,7 +40,7 @@ namespace webrtc { namespace { -const char kTestCertificate[] = +constexpr char kTestCertificate[] = "-----BEGIN CERTIFICATE-----\n" "MIIB6TCCAVICAQYwDQYJKoZIhvcNAQEEBQAwWzELMAkGA1UEBhMCQVUxEzARBgNV\n" "BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYD\n" @@ -56,23 +55,23 @@ const char kTestCertificate[] = "itAE+OjGF+PFKbwX8Q==\n" "-----END CERTIFICATE-----\n"; -const unsigned char kTestCertSha1[] = {0xA6, 0xC8, 0x59, 0xEA, 0xC3, 0x7E, 0x6D, - 0x33, 0xCF, 0xE2, 0x69, 0x9D, 0x74, 0xE6, - 0xF6, 0x8A, 0x9E, 0x47, 0xA7, 0xCA}; -const unsigned char kTestCertSha224[] = { +constexpr unsigned char kTestCertSha1[] = { + 0xA6, 0xC8, 0x59, 0xEA, 0xC3, 0x7E, 0x6D, 0x33, 0xCF, 0xE2, + 0x69, 0x9D, 0x74, 0xE6, 0xF6, 0x8A, 0x9E, 0x47, 0xA7, 0xCA}; +constexpr unsigned char kTestCertSha224[] = { 0xd4, 0xce, 0xc6, 0xcf, 0x28, 0xcb, 0xe9, 0x77, 0x38, 0x36, 0xcf, 0xb1, 0x3b, 0x4a, 0xd7, 0xbd, 0xae, 0x24, 0x21, 0x08, 0xcf, 0x6a, 0x44, 0x0d, 0x3f, 0x94, 0x2a, 0x5b}; -const unsigned char kTestCertSha256[] = { +constexpr unsigned char kTestCertSha256[] = { 0x41, 0x6b, 0xb4, 0x93, 0x47, 0x79, 0x77, 0x24, 0x77, 0x0b, 0x8b, 0x2e, 0xa6, 0x2b, 0xe0, 0xf9, 0x0a, 0xed, 0x1f, 0x31, 0xa6, 0xf7, 0x5c, 0xa1, 0x5a, 0xc4, 0xb0, 0xa2, 0xa4, 0x78, 0xb9, 0x76}; -const unsigned char kTestCertSha384[] = { +constexpr unsigned char kTestCertSha384[] = { 0x42, 0x31, 0x9a, 0x79, 0x1d, 0xd6, 0x08, 0xbf, 0x3b, 0xba, 0x36, 0xd8, 0x37, 0x4a, 0x9a, 0x75, 0xd3, 0x25, 0x6e, 0x28, 0x92, 0xbe, 0x06, 0xb7, 0xc5, 0xa0, 0x83, 0xe3, 0x86, 0xb1, 0x03, 0xfc, 0x64, 0x47, 0xd6, 0xd8, 0xaa, 0xd9, 0x36, 0x60, 0x04, 0xcc, 0xbe, 0x7d, 0x6a, 0xe8, 0x34, 0x49}; -const unsigned char kTestCertSha512[] = { +constexpr unsigned char kTestCertSha512[] = { 0x51, 0x1d, 0xec, 0x02, 0x3d, 0x51, 0x45, 0xd3, 0xd8, 0x1d, 0xa4, 0x9d, 0x43, 0xc9, 0xee, 0x32, 0x6f, 0x4f, 0x37, 0xee, 0xab, 0x3f, 0x25, 0xdf, 0x72, 0xfc, 0x61, 0x1a, 0xd5, 0x92, 0xff, 0x6b, 0x28, @@ -87,7 +86,7 @@ const unsigned char kTestCertSha512[] = { // and the update changes the string form of the keys, these will have to be // updated too. The fingerprint, fingerprint algorithm and base64 certificate // were created by calling `identity->certificate().GetStats()`. -const char kRSA_PRIVATE_KEY_PEM[] = +constexpr char kRSA_PRIVATE_KEY_PEM[] = "-----BEGIN PRI" // Linebreak to avoid detection of private "VATE KEY-----\n" // keys by linters. "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMQPqDStRlYeDpkX\n" @@ -105,14 +104,14 @@ const char kRSA_PRIVATE_KEY_PEM[] = "bhvEzY/fu8gEp+EzsER96/D79az5z1BaMGL5OPM2xHBPJATKlswnAa7Lp3QKGZGk\n" "TxslfL18J71s\n" "-----END PRIVATE KEY-----\n"; -const char kRSA_PUBLIC_KEY_PEM[] = +constexpr char kRSA_PUBLIC_KEY_PEM[] = "-----BEGIN PUBLIC KEY-----\n" "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDED6g0rUZWHg6ZF3q0Zr/mtZ2j\n" "PL0lUmNIBtqZZ656H1YlkVtzEalgvtNtDLCI94T2XkgJ7f8vxS/56+BGuzV3MHUa\n" "Nf9cRCu1P3/3I0oNWrp8rxwh8HBXDK99Ryxbx69GYHBcG4CLhSzRJe5CuRzDvQD8\n" "9Z7VI3pPAZgY/MjJfQIDAQAB\n" "-----END PUBLIC KEY-----\n"; -const char kRSA_CERT_PEM[] = +constexpr char kRSA_CERT_PEM[] = "-----BEGIN CERTIFICATE-----\n" "MIIBnDCCAQWgAwIBAgIJAOEHLgeWYwrpMA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNV\n" "BAMMBXRlc3QxMB4XDTE2MDQyNDE4MTAyMloXDTE2MDUyNTE4MTAyMlowEDEOMAwG\n" @@ -124,11 +123,11 @@ const char kRSA_CERT_PEM[] = "yTpU3ixErjQvoZew5ngXTEvTY8BSQUijJEaLWh8n6NDKRbEGTdAk8nPAmq9hdCFq\n" "e3UkexqNHm3g/VxG4NUC1Y+w29ai0/Rgh+VvgbDwK+Q=\n" "-----END CERTIFICATE-----\n"; -const char kRSA_FINGERPRINT[] = +constexpr char kRSA_FINGERPRINT[] = "3C:E8:B2:70:09:CF:A9:09:5A:F4:EF:8F:8D:8A:32:FF:EA:04:91:BA:6E:D4:17:78:16" ":2A:EE:F9:9A:DD:E2:2B"; -const char kRSA_FINGERPRINT_ALGORITHM[] = "sha-256"; -const char kRSA_BASE64_CERTIFICATE[] = +constexpr char kRSA_FINGERPRINT_ALGORITHM[] = "sha-256"; +constexpr char kRSA_BASE64_CERTIFICATE[] = "MIIBnDCCAQWgAwIBAgIJAOEHLgeWYwrpMA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNVBAMMBXRlc3" "QxMB4XDTE2MDQyNDE4MTAyMloXDTE2MDUyNTE4MTAyMlowEDEOMAwGA1UEAwwFdGVzdDEwgZ8w" "DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMQPqDStRlYeDpkXerRmv+a1naM8vSVSY0gG2plnrn" @@ -138,19 +137,19 @@ const char kRSA_BASE64_CERTIFICATE[] = "i8dxyTpU3ixErjQvoZew5ngXTEvTY8BSQUijJEaLWh8n6NDKRbEGTdAk8nPAmq9hdCFqe3Ukex" "qNHm3g/VxG4NUC1Y+w29ai0/Rgh+VvgbDwK+Q="; -const char kECDSA_PRIVATE_KEY_PEM[] = +constexpr char kECDSA_PRIVATE_KEY_PEM[] = "-----BEGIN PRI" // Linebreak to avoid detection of private "VATE KEY-----\n" // keys by linters. "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg/AkEA2hklq7dQ2rN\n" "ZxYL6hOUACL4pn7P4FYlA3ZQhIChRANCAAR7YgdO3utP/8IqVRq8G4VZKreMAxeN\n" "rUa12twthv4uFjuHAHa9D9oyAjncmn+xvZZRyVmKrA56jRzENcEEHoAg\n" "-----END PRIVATE KEY-----\n"; -const char kECDSA_PUBLIC_KEY_PEM[] = +constexpr char kECDSA_PUBLIC_KEY_PEM[] = "-----BEGIN PUBLIC KEY-----\n" "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEe2IHTt7rT//CKlUavBuFWSq3jAMX\n" "ja1GtdrcLYb+LhY7hwB2vQ/aMgI53Jp/sb2WUclZiqwOeo0cxDXBBB6AIA==\n" "-----END PUBLIC KEY-----\n"; -const char kECDSA_CERT_PEM[] = +constexpr char kECDSA_CERT_PEM[] = "-----BEGIN CERTIFICATE-----\n" "MIIBFDCBu6ADAgECAgkArpkxjw62sW4wCgYIKoZIzj0EAwIwEDEOMAwGA1UEAwwF\n" "dGVzdDMwHhcNMTYwNDI0MTgxNDM4WhcNMTYwNTI1MTgxNDM4WjAQMQ4wDAYDVQQD\n" @@ -159,11 +158,11 @@ const char kECDSA_CERT_PEM[] = "gCAwCgYIKoZIzj0EAwIDSAAwRQIhANyreQ/K5yuPPpirsd0e/4WGLHou6bIOSQks\n" "DYzo56NmAiAKOr3u8ol3LmygbUCwEvtWrS8QcJDygxHPACo99hkekw==\n" "-----END CERTIFICATE-----\n"; -const char kECDSA_FINGERPRINT[] = +constexpr char kECDSA_FINGERPRINT[] = "9F:47:FA:88:76:3D:18:B8:00:A0:59:9D:C3:5D:34:0B:1F:B8:99:9E:68:DA:F3:A5:DA" ":50:33:A9:FF:4D:31:89"; -const char kECDSA_FINGERPRINT_ALGORITHM[] = "sha-256"; -const char kECDSA_BASE64_CERTIFICATE[] = +constexpr char kECDSA_FINGERPRINT_ALGORITHM[] = "sha-256"; +constexpr char kECDSA_BASE64_CERTIFICATE[] = "MIIBFDCBu6ADAgECAgkArpkxjw62sW4wCgYIKoZIzj0EAwIwEDEOMAwGA1UEAwwFdGVzdDMwHh" "cNMTYwNDI0MTgxNDM4WhcNMTYwNTI1MTgxNDM4WjAQMQ4wDAYDVQQDDAV0ZXN0MzBZMBMGByqG" "SM49AgEGCCqGSM49AwEHA0IABHtiB07e60//wipVGrwbhVkqt4wDF42tRrXa3C2G/i4WO4cAdr" diff --git a/rtc_base/ssl_stream_adapter.h b/rtc_base/ssl_stream_adapter.h index baa491235e..ca2f6c48c4 100644 --- a/rtc_base/ssl_stream_adapter.h +++ b/rtc_base/ssl_stream_adapter.h @@ -246,7 +246,7 @@ class SSLStreamAdapter : public StreamInterface { static std::set GetSupportedEphemeralKeyExchangeCipherGroups(); static std::optional GetEphemeralKeyExchangeCipherGroupName( - uint16_t); + uint16_t group_id); static std::vector GetDefaultEphemeralKeyExchangeCipherGroups( const FieldTrialsView* field_trials); @@ -293,50 +293,5 @@ class SSLStreamAdapter : public StreamInterface { } // 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::GetSrtpKeyAndSaltLengths; -using ::webrtc::IsGcmCryptoSuite; -using ::webrtc::kCsAeadAes128Gcm; -using ::webrtc::kCsAeadAes256Gcm; -using ::webrtc::kCsAesCm128HmacSha1_32; -using ::webrtc::kCsAesCm128HmacSha1_80; -using ::webrtc::kDtls10VersionBytes; -using ::webrtc::kDtls12VersionBytes; -using ::webrtc::kDtls13VersionBytes; -using ::webrtc::kSrtpAeadAes128Gcm; -using ::webrtc::kSrtpAeadAes256Gcm; -using ::webrtc::kSrtpAes128CmSha1_32; -using ::webrtc::kSrtpAes128CmSha1_80; -using ::webrtc::kSrtpCryptoSuiteMaxValue; -using ::webrtc::kSrtpInvalidCryptoSuite; -using ::webrtc::kSslCipherSuiteMaxValue; -using ::webrtc::kSslSignatureAlgorithmMaxValue; -using ::webrtc::kSslSignatureAlgorithmUnknown; -using ::webrtc::kTlsNullWithNullNull; -using ::webrtc::SrtpCryptoSuiteToName; -using ::webrtc::SSE_MSG_TRUNC; -using ::webrtc::SSL_CLIENT; -using ::webrtc::SSL_MODE_DTLS; -using ::webrtc::SSL_MODE_TLS; -using ::webrtc::SSL_PROTOCOL_DTLS_10; -using ::webrtc::SSL_PROTOCOL_DTLS_12; -using ::webrtc::SSL_PROTOCOL_DTLS_13; -using ::webrtc::SSL_PROTOCOL_NOT_GIVEN; -using ::webrtc::SSL_PROTOCOL_TLS_10; -using ::webrtc::SSL_PROTOCOL_TLS_11; -using ::webrtc::SSL_PROTOCOL_TLS_12; -using ::webrtc::SSL_PROTOCOL_TLS_13; -using ::webrtc::SSL_SERVER; -using ::webrtc::SSLHandshakeError; -using ::webrtc::SSLMode; -using ::webrtc::SSLPeerCertificateDigestError; -using ::webrtc::SSLProtocolVersion; -using ::webrtc::SSLRole; -using ::webrtc::SSLStreamAdapter; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SSL_STREAM_ADAPTER_H_ diff --git a/rtc_base/ssl_stream_adapter_unittest.cc b/rtc_base/ssl_stream_adapter_unittest.cc index f78aaf17c8..6c193236d2 100644 --- a/rtc_base/ssl_stream_adapter_unittest.cc +++ b/rtc_base/ssl_stream_adapter_unittest.cc @@ -68,7 +68,7 @@ using ::testing::Values; using ::testing::WithParamInterface; // Generated using `openssl genrsa -out key.pem 2048` -const char kRSA_PRIVATE_KEY_PEM[] = +constexpr char kRSA_PRIVATE_KEY_PEM[] = "-----BEGIN RSA PRI" // Linebreak to avoid detection of private "VATE KEY-----\n" // keys by linters. "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC4XOJ6agj673j+\n" @@ -104,7 +104,7 @@ const char kRSA_PRIVATE_KEY_PEM[] = // `openssl req -new -x509 -key key.pem -out cert.pem -days 365` // after setting the machine date to something that will ensure the // certificate is expired. -const char kCERT_PEM[] = +constexpr char kCERT_PEM[] = "-----BEGIN CERTIFICATE-----\n" "MIIDjTCCAnWgAwIBAgIUTkCy4o8+4W/86RYmgWc8FEhWTzYwDQYJKoZIhvcNAQEL\n" "BQAwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM\n" @@ -129,7 +129,7 @@ const char kCERT_PEM[] = "-----END CERTIFICATE-----\n"; // Google GTS CA 1C3 certificate. Obtained from https://www.webrtc.org -const char kIntCert1[] = +constexpr char kIntCert1[] = "-----BEGIN CERTIFICATE-----\n" "MIIFljCCA36gAwIBAgINAgO8U1lrNMcY9QFQZjANBgkqhkiG9w0BAQsFADBHMQsw\n" "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" @@ -164,7 +164,7 @@ const char kIntCert1[] = "-----END CERTIFICATE-----\n"; // Google GTS Root R1 certificate. Obtained from https://www.webrtc.org -const char kCACert[] = +constexpr char kCACert[] = "-----BEGIN CERTIFICATE-----\n" "MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBH\n" "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" @@ -403,8 +403,8 @@ class BufferQueueStream : public StreamInterface { BufferQueue buffer_; }; -const int kBufferCapacity = 1; -const size_t kDefaultBufferSize = 2048; +constexpr int kBufferCapacity = 1; +constexpr size_t kDefaultBufferSize = 2048; class SSLStreamAdapterTestBase : public ::testing::Test, public sigslot::has_slots<> { diff --git a/rtc_base/stream.cc b/rtc_base/stream.cc index 696f1ad24d..973178121d 100644 --- a/rtc_base/stream.cc +++ b/rtc_base/stream.cc @@ -9,9 +9,8 @@ */ #include "rtc_base/stream.h" -#include - #include +#include #include "api/array_view.h" diff --git a/rtc_base/stream.h b/rtc_base/stream.h index 938f70c22f..c6690b5082 100644 --- a/rtc_base/stream.h +++ b/rtc_base/stream.h @@ -21,7 +21,6 @@ #include "rtc_base/checks.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/system/rtc_export.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread_annotations.h" namespace webrtc { @@ -101,10 +100,6 @@ class RTC_EXPORT StreamInterface { callback_ = std::move(callback); } - // TODO(bugs.webrtc.org/11943): Remove after updating downstream code. - sigslot::signal3 SignalEvent - [[deprecated("Use SetEventCallback instead")]]; - // Return true if flush is successful. virtual bool Flush(); @@ -131,12 +126,6 @@ class RTC_EXPORT StreamInterface { if (callback_) { callback_(stream_events, err); } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - // TODO(tommi): This is for backwards compatibility only while `SignalEvent` - // is being replaced by `SetEventCallback`. - SignalEvent(this, stream_events, err); -#pragma clang diagnostic pop } RTC_NO_UNIQUE_ADDRESS SequenceChecker callback_sequence_{ @@ -149,26 +138,5 @@ class RTC_EXPORT StreamInterface { } // 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::SE_CLOSE; -using ::webrtc::SE_OPEN; -using ::webrtc::SE_READ; -using ::webrtc::SE_WRITE; -using ::webrtc::SR_BLOCK; -using ::webrtc::SR_EOS; -using ::webrtc::SR_ERROR; -using ::webrtc::SR_SUCCESS; -using ::webrtc::SS_CLOSED; -using ::webrtc::SS_OPEN; -using ::webrtc::SS_OPENING; -using ::webrtc::StreamEvent; -using ::webrtc::StreamInterface; -using ::webrtc::StreamResult; -using ::webrtc::StreamState; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_STREAM_H_ diff --git a/rtc_base/string_encode.h b/rtc_base/string_encode.h index 4d840c6821..fb2a6e021a 100644 --- a/rtc_base/string_encode.h +++ b/rtc_base/string_encode.h @@ -94,56 +94,5 @@ static inline T FromString(absl::string_view str) { } // 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::FromString; -using ::webrtc::hex_decode; -using ::webrtc::hex_decode_with_delimiter; -using ::webrtc::hex_encode; -using ::webrtc::hex_encode_with_delimiter; -using ::webrtc::split; -using ::webrtc::tokenize; -using ::webrtc::tokenize_first; - -namespace internal { -template -struct is_absl_strcat_callable : std::false_type {}; - -template -struct is_absl_strcat_callable< - T, - std::void_t()))>> : std::true_type {}; -} // namespace internal - -template -ABSL_DEPRECATE_AND_INLINE() -inline auto ToString(T value) -> - typename std::enable_if && - internal::is_absl_strcat_callable::value, - std::string>::type { - return absl::StrCat(value); -} - -template -ABSL_DEPRECATE_AND_INLINE() -inline auto ToString(T p) -> - typename std::enable_if::value && - std::is_pointer::value, - std::string>::type { - return webrtc::StringFormat("%p", p); -} - -template -ABSL_DEPRECATE_AND_INLINE() -inline auto ToString(T value) -> - typename std::enable_if && std::is_same_v, - std::string>::type { - return webrtc::BoolToString(value); -} - -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_STRING_ENCODE_H__ diff --git a/rtc_base/string_encode_unittest.cc b/rtc_base/string_encode_unittest.cc index 103d33c427..d26cd6b82e 100644 --- a/rtc_base/string_encode_unittest.cc +++ b/rtc_base/string_encode_unittest.cc @@ -10,8 +10,7 @@ #include "rtc_base/string_encode.h" -#include - +#include #include #include diff --git a/rtc_base/string_to_number.cc b/rtc_base/string_to_number.cc index 837a6bbca3..443b8c5ee7 100644 --- a/rtc_base/string_to_number.cc +++ b/rtc_base/string_to_number.cc @@ -10,8 +10,7 @@ #include "rtc_base/string_to_number.h" -#include - +#include #include #include #include diff --git a/rtc_base/string_to_number.h b/rtc_base/string_to_number.h index cf22827b50..b3cf98aa80 100644 --- a/rtc_base/string_to_number.h +++ b/rtc_base/string_to_number.h @@ -101,12 +101,5 @@ StringToNumber(absl::string_view str, int /* base */ = 10) { } // 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::StringToNumber; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_STRING_TO_NUMBER_H_ diff --git a/rtc_base/string_to_number_unittest.cc b/rtc_base/string_to_number_unittest.cc index 77b1437375..3aa6afc04c 100644 --- a/rtc_base/string_to_number_unittest.cc +++ b/rtc_base/string_to_number_unittest.cc @@ -10,8 +10,7 @@ #include "rtc_base/string_to_number.h" -#include - +#include #include #include #include diff --git a/rtc_base/string_utils.h b/rtc_base/string_utils.h index 3c6d19073d..4c94bcfe7d 100644 --- a/rtc_base/string_utils.h +++ b/rtc_base/string_utils.h @@ -132,16 +132,5 @@ constexpr auto MakeCompileTimeString(const char (&a)[N]) { } // 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::AbslStringViewCmp; -using ::webrtc::MakeCompileTimeString; -using ::webrtc::SIZE_UNKNOWN; -using ::webrtc::strcpyn; -using ::webrtc::ToHex; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_STRING_UTILS_H_ diff --git a/rtc_base/strings/json.cc b/rtc_base/strings/json.cc index c488304969..a7e071ed75 100644 --- a/rtc_base/strings/json.cc +++ b/rtc_base/strings/json.cc @@ -10,10 +10,9 @@ #include "rtc_base/strings/json.h" -#include -#include -#include - +#include +#include +#include #include #include diff --git a/rtc_base/strings/json.h b/rtc_base/strings/json.h index 90e9080d4e..383b6b5aa2 100644 --- a/rtc_base/strings/json.h +++ b/rtc_base/strings/json.h @@ -83,41 +83,5 @@ std::string JsonValueToString(const Json::Value& json); } // 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::BoolVectorToJsonArray; -using ::webrtc::DoubleVectorToJsonArray; -using ::webrtc::GetBoolFromJson; -using ::webrtc::GetBoolFromJsonArray; -using ::webrtc::GetBoolFromJsonObject; -using ::webrtc::GetDoubleFromJson; -using ::webrtc::GetDoubleFromJsonArray; -using ::webrtc::GetDoubleFromJsonObject; -using ::webrtc::GetIntFromJson; -using ::webrtc::GetIntFromJsonArray; -using ::webrtc::GetIntFromJsonObject; -using ::webrtc::GetStringFromJson; -using ::webrtc::GetStringFromJsonArray; -using ::webrtc::GetStringFromJsonObject; -using ::webrtc::GetUIntFromJson; -using ::webrtc::GetUIntFromJsonArray; -using ::webrtc::GetUIntFromJsonObject; -using ::webrtc::GetValueFromJsonArray; -using ::webrtc::GetValueFromJsonObject; -using ::webrtc::IntVectorToJsonArray; -using ::webrtc::JsonArrayToBoolVector; -using ::webrtc::JsonArrayToDoubleVector; -using ::webrtc::JsonArrayToIntVector; -using ::webrtc::JsonArrayToStringVector; -using ::webrtc::JsonArrayToUIntVector; -using ::webrtc::JsonArrayToValueVector; -using ::webrtc::JsonValueToString; -using ::webrtc::StringVectorToJsonArray; -using ::webrtc::UIntVectorToJsonArray; -using ::webrtc::ValueVectorToJsonArray; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_STRINGS_JSON_H_ diff --git a/rtc_base/strings/string_builder.cc b/rtc_base/strings/string_builder.cc index e411150fa9..094bbd1939 100644 --- a/rtc_base/strings/string_builder.cc +++ b/rtc_base/strings/string_builder.cc @@ -10,8 +10,7 @@ #include "rtc_base/strings/string_builder.h" -#include - +#include #include #include diff --git a/rtc_base/strings/string_builder.h b/rtc_base/strings/string_builder.h index 072fd1e6eb..acab39217f 100644 --- a/rtc_base/strings/string_builder.h +++ b/rtc_base/strings/string_builder.h @@ -162,13 +162,5 @@ class StringBuilder { } // 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::SimpleStringBuilder; -using ::webrtc::StringBuilder; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_STRINGS_STRING_BUILDER_H_ diff --git a/rtc_base/strings/string_builder_unittest.cc b/rtc_base/strings/string_builder_unittest.cc index 18d502047c..4d7629e9fc 100644 --- a/rtc_base/strings/string_builder_unittest.cc +++ b/rtc_base/strings/string_builder_unittest.cc @@ -10,8 +10,7 @@ #include "rtc_base/strings/string_builder.h" -#include - +#include #include #include "rtc_base/checks.h" diff --git a/rtc_base/strings/string_format.h b/rtc_base/strings/string_format.h index 707cab0ed6..24c8be6694 100644 --- a/rtc_base/strings/string_format.h +++ b/rtc_base/strings/string_format.h @@ -28,12 +28,5 @@ namespace webrtc { std::string StringFormat(const char* fmt, ...) RTC_PRINTF_FORMAT(1, 2); } // 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::StringFormat; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_STRINGS_STRING_FORMAT_H_ diff --git a/rtc_base/strong_alias_unittest.cc b/rtc_base/strong_alias_unittest.cc index 91d454ce57..7ce4f47790 100644 --- a/rtc_base/strong_alias_unittest.cc +++ b/rtc_base/strong_alias_unittest.cc @@ -312,8 +312,8 @@ TYPED_TEST(StrongAliasTest, CanDifferentiateOverloads) { using BarAlias = StrongAlias; class Scope { public: - static std::string Overload(FooAlias) { return "FooAlias"; } - static std::string Overload(BarAlias) { return "BarAlias"; } + static std::string Overload(FooAlias /*unused*/) { return "FooAlias"; } + static std::string Overload(BarAlias /*unused*/) { return "BarAlias"; } }; EXPECT_EQ("FooAlias", Scope::Overload(FooAlias())); EXPECT_EQ("BarAlias", Scope::Overload(BarAlias())); diff --git a/rtc_base/swap_queue_unittest.cc b/rtc_base/swap_queue_unittest.cc index e8ce02aab0..207a28cd94 100644 --- a/rtc_base/swap_queue_unittest.cc +++ b/rtc_base/swap_queue_unittest.cc @@ -22,7 +22,7 @@ namespace webrtc { namespace { // Test parameter for the basic sample based SwapQueue Tests. -const size_t kChunkSize = 3; +constexpr size_t kChunkSize = 3; // Queue item verification function for the vector test. bool LengthVerifierFunction(const std::vector& v) { diff --git a/rtc_base/synchronization/BUILD.gn b/rtc_base/synchronization/BUILD.gn index 934f71d31d..2a197152b9 100644 --- a/rtc_base/synchronization/BUILD.gn +++ b/rtc_base/synchronization/BUILD.gn @@ -87,9 +87,11 @@ if (rtc_include_tests && rtc_enable_google_benchmarks) { ":yield", ":yield_policy", "..:checks", + "..:macromagic", "..:platform_thread", "..:rtc_event", "..:threading", + "../../api/units:time_delta", "../../test:test_support", "//third_party/google_benchmark", ] diff --git a/rtc_base/synchronization/mutex.h b/rtc_base/synchronization/mutex.h index 1144b4b8e6..749d4803bf 100644 --- a/rtc_base/synchronization/mutex.h +++ b/rtc_base/synchronization/mutex.h @@ -11,10 +11,7 @@ #ifndef RTC_BASE_SYNCHRONIZATION_MUTEX_H_ #define RTC_BASE_SYNCHRONIZATION_MUTEX_H_ -#include - #include "absl/base/attributes.h" -#include "rtc_base/checks.h" #include "rtc_base/thread_annotations.h" #if defined(WEBRTC_ABSL_MUTEX) diff --git a/rtc_base/synchronization/mutex_benchmark.cc b/rtc_base/synchronization/mutex_benchmark.cc index ae0e3c38e7..362dcb0c10 100644 --- a/rtc_base/synchronization/mutex_benchmark.cc +++ b/rtc_base/synchronization/mutex_benchmark.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "benchmark/benchmark.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/unused.h" diff --git a/rtc_base/synchronization/mutex_pthread.h b/rtc_base/synchronization/mutex_pthread.h index a532bd229a..d09a4e67c4 100644 --- a/rtc_base/synchronization/mutex_pthread.h +++ b/rtc_base/synchronization/mutex_pthread.h @@ -14,14 +14,16 @@ #if defined(WEBRTC_POSIX) #include -#if defined(WEBRTC_MAC) -#include -#endif #include "absl/base/attributes.h" +#include "rtc_base/checks.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" +#if defined(WEBRTC_MAC) +#include +#endif + namespace webrtc { class RTC_LOCKABLE MutexImpl final { diff --git a/rtc_base/synchronization/mutex_unittest.cc b/rtc_base/synchronization/mutex_unittest.cc index cafd24cf7e..44113e2da2 100644 --- a/rtc_base/synchronization/mutex_unittest.cc +++ b/rtc_base/synchronization/mutex_unittest.cc @@ -10,27 +10,22 @@ #include "rtc_base/synchronization/mutex.h" -#include -#include - #include +#include #include -#include #include #include +#include "api/units/time_delta.h" #include "benchmark/benchmark.h" -#include "rtc_base/checks.h" #include "rtc_base/event.h" -#include "rtc_base/platform_thread.h" #include "rtc_base/synchronization/yield.h" #include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "test/gtest.h" namespace webrtc { namespace { - - constexpr int kNumThreads = 16; template diff --git a/rtc_base/synchronization/sequence_checker_internal.h b/rtc_base/synchronization/sequence_checker_internal.h index ea801497b4..19370706ff 100644 --- a/rtc_base/synchronization/sequence_checker_internal.h +++ b/rtc_base/synchronization/sequence_checker_internal.h @@ -14,6 +14,7 @@ #include #include "api/task_queue/task_queue_base.h" +#include "rtc_base/checks.h" #include "rtc_base/platform_thread_types.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/rtc_export.h" diff --git a/rtc_base/synchronization/yield.cc b/rtc_base/synchronization/yield.cc index cbb58d12ab..812dfe68bd 100644 --- a/rtc_base/synchronization/yield.cc +++ b/rtc_base/synchronization/yield.cc @@ -10,11 +10,12 @@ #include "rtc_base/synchronization/yield.h" +#include + #if defined(WEBRTC_WIN) #include #else -#include -#include +#include #endif namespace webrtc { diff --git a/rtc_base/synchronization/yield_policy.cc b/rtc_base/synchronization/yield_policy.cc index c8ba9f22c4..0c34be48ea 100644 --- a/rtc_base/synchronization/yield_policy.cc +++ b/rtc_base/synchronization/yield_policy.cc @@ -11,7 +11,6 @@ #include "absl/base/attributes.h" #include "absl/base/config.h" -#include "rtc_base/checks.h" #if !defined(ABSL_HAVE_THREAD_LOCAL) && defined(WEBRTC_POSIX) #include #endif diff --git a/rtc_base/synchronization/yield_policy.h b/rtc_base/synchronization/yield_policy.h index 1756cf2105..2c3d3daff4 100644 --- a/rtc_base/synchronization/yield_policy.h +++ b/rtc_base/synchronization/yield_policy.h @@ -35,13 +35,5 @@ class ScopedYieldPolicy final { } // 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::ScopedYieldPolicy; -using ::webrtc::YieldInterface; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SYNCHRONIZATION_YIELD_POLICY_H_ diff --git a/rtc_base/system/file_wrapper.cc b/rtc_base/system/file_wrapper.cc index ed4ac3fcdb..8cba0159fa 100644 --- a/rtc_base/system/file_wrapper.cc +++ b/rtc_base/system/file_wrapper.cc @@ -10,12 +10,13 @@ #include "rtc_base/system/file_wrapper.h" -#include - #include +#include #include +#include #include #include +#include #include "absl/strings/string_view.h" #include "rtc_base/checks.h" @@ -26,8 +27,6 @@ #else #endif -#include - namespace webrtc { namespace { FILE* FileOpen(absl::string_view file_name_utf8, bool read_only, int* error) { diff --git a/rtc_base/system/file_wrapper.h b/rtc_base/system/file_wrapper.h index eafc685e27..7e27dc31d7 100644 --- a/rtc_base/system/file_wrapper.h +++ b/rtc_base/system/file_wrapper.h @@ -11,12 +11,10 @@ #ifndef RTC_BASE_SYSTEM_FILE_WRAPPER_H_ #define RTC_BASE_SYSTEM_FILE_WRAPPER_H_ -#include -#include -#include - +#include +#include +#include #include -#include #include "absl/strings/string_view.h" diff --git a/rtc_base/system/file_wrapper_unittest.cc b/rtc_base/system/file_wrapper_unittest.cc index b83c1df933..d1ba182b13 100644 --- a/rtc_base/system/file_wrapper_unittest.cc +++ b/rtc_base/system/file_wrapper_unittest.cc @@ -10,7 +10,14 @@ #include "rtc_base/system/file_wrapper.h" -#include "rtc_base/checks.h" +#include + +#include +#include +#include +#include +#include + #include "test/gtest.h" #include "test/testsupport/file_utils.h" diff --git a/rtc_base/system_time.cc b/rtc_base/system_time.cc index 83a08f64f4..d5076431d3 100644 --- a/rtc_base/system_time.cc +++ b/rtc_base/system_time.cc @@ -11,16 +11,22 @@ // If WEBRTC_EXCLUDE_SYSTEM_TIME is set, an implementation of // webrtc::SystemTimeNanos() must be provided externally. #ifndef WEBRTC_EXCLUDE_SYSTEM_TIME +#include "rtc_base/system_time.h" -#include +#include -#include +#include +#include + +#include "rtc_base/time_utils.h" -#if defined(WEBRTC_POSIX) -#include #if defined(WEBRTC_MAC) #include -#endif + +#include + +#include "rtc_base/checks.h" +#include "rtc_base/numerics/safe_conversions.h" #endif #if defined(WEBRTC_WIN) @@ -33,11 +39,6 @@ // clang-format on #endif -#include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" -#include "rtc_base/system_time.h" -#include "rtc_base/time_utils.h" - namespace webrtc { int64_t SystemTimeNanos() { diff --git a/rtc_base/system_time.h b/rtc_base/system_time.h index 2cae4286af..c9c8a2a31a 100644 --- a/rtc_base/system_time.h +++ b/rtc_base/system_time.h @@ -21,15 +21,7 @@ int64_t SystemTimeNanos(); } // namespace webrtc -// TODO(bugs.webrtc.org/4222596): Remove once Chrome has migrated. #define RTC_SYSTEM_TIME_IN_WEBRTC_NAMESPACE 1 -// 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::SystemTimeNanos; -} -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_SYSTEM_TIME_H_ diff --git a/rtc_base/task_queue_unittest.cc b/rtc_base/task_queue_unittest.cc index 6bd99d3cce..9ad911cfc7 100644 --- a/rtc_base/task_queue_unittest.cc +++ b/rtc_base/task_queue_unittest.cc @@ -8,28 +8,23 @@ * be found in the AUTHORS file in the root of the source tree. */ -#if defined(WEBRTC_WIN) -// clang-format off -#include // Must come first. -#include -// clang-format on -#endif - -#include - -#include -#include -#include +#include -#include "absl/memory/memory.h" +#include "api/task_queue/task_queue_factory.h" #include "api/units/time_delta.h" #include "rtc_base/event.h" #include "rtc_base/task_queue_for_test.h" #include "rtc_base/time_utils.h" #include "test/gtest.h" -namespace webrtc { +#if defined(WEBRTC_WIN) +// clang-format off +#include // Must come first. +#include +// clang-format on +#endif +namespace webrtc { namespace { // Noop on all platforms except Windows, where it turns on high precision diff --git a/rtc_base/task_utils/BUILD.gn b/rtc_base/task_utils/BUILD.gn index 6a5db79a2d..a5ef17a0f3 100644 --- a/rtc_base/task_utils/BUILD.gn +++ b/rtc_base/task_utils/BUILD.gn @@ -25,7 +25,7 @@ rtc_library("repeating_task") { "../../api/task_queue:pending_task_safety_flag", "../../api/units:time_delta", "../../api/units:timestamp", - "../../system_wrappers:system_wrappers", + "../../system_wrappers", "//third_party/abseil-cpp/absl/functional:any_invocable", ] } @@ -43,7 +43,7 @@ if (rtc_include_tests) { "../../api/task_queue/test:mock_task_queue_base", "../../api/units:time_delta", "../../api/units:timestamp", - "../../system_wrappers:system_wrappers", + "../../system_wrappers", "../../test:test_support", "//third_party/abseil-cpp/absl/functional:any_invocable", ] diff --git a/rtc_base/test_certificate_verifier.h b/rtc_base/test_certificate_verifier.h index 2fcbc921bd..ca2ad34ccb 100644 --- a/rtc_base/test_certificate_verifier.h +++ b/rtc_base/test_certificate_verifier.h @@ -33,12 +33,5 @@ class TestCertificateVerifier : public SSLCertificateVerifier { } // 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::TestCertificateVerifier; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_TEST_CERTIFICATE_VERIFIER_H_ diff --git a/rtc_base/test_client.cc b/rtc_base/test_client.cc index a204d1c80e..a7577d54bd 100644 --- a/rtc_base/test_client.cc +++ b/rtc_base/test_client.cc @@ -10,9 +10,8 @@ #include "rtc_base/test_client.h" -#include - #include +#include #include #include #include diff --git a/rtc_base/test_client.h b/rtc_base/test_client.h index ab3fbd0cb9..355f578711 100644 --- a/rtc_base/test_client.h +++ b/rtc_base/test_client.h @@ -116,12 +116,5 @@ class TestClient : public sigslot::has_slots<> { } // 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::TestClient; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_TEST_CLIENT_H_ diff --git a/rtc_base/test_echo_server.cc b/rtc_base/test_echo_server.cc index 484ed848b7..5b270d17e1 100644 --- a/rtc_base/test_echo_server.cc +++ b/rtc_base/test_echo_server.cc @@ -10,6 +10,7 @@ #include "rtc_base/test_echo_server.h" +#include "rtc_base/socket_address.h" #include "rtc_base/socket_server.h" namespace webrtc { diff --git a/rtc_base/test_echo_server.h b/rtc_base/test_echo_server.h index 758218a309..ec084706ff 100644 --- a/rtc_base/test_echo_server.h +++ b/rtc_base/test_echo_server.h @@ -74,12 +74,5 @@ class TestEchoServer : public sigslot::has_slots<> { } // 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::TestEchoServer; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_TEST_ECHO_SERVER_H_ diff --git a/rtc_base/third_party/sigslot/sigslot.cc b/rtc_base/third_party/sigslot/sigslot.cc index d852a2b536..73f37d2860 100644 --- a/rtc_base/third_party/sigslot/sigslot.cc +++ b/rtc_base/third_party/sigslot/sigslot.cc @@ -8,15 +8,16 @@ #include "rtc_base/third_party/sigslot/sigslot.h" -namespace sigslot { - #ifdef _SIGSLOT_HAS_POSIX_THREADS +#include + +namespace sigslot { pthread_mutex_t* multi_threaded_global::get_mutex() { static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; return &g_mutex; } -#endif // _SIGSLOT_HAS_POSIX_THREADS - } // namespace sigslot + +#endif // _SIGSLOT_HAS_POSIX_THREADS diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 815ac34694..04fa8f2e66 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -10,6 +10,8 @@ #include "rtc_base/thread.h" +#include + #include #include #include @@ -32,7 +34,8 @@ #include #elif defined(WEBRTC_POSIX) #include -#include + +#include #else #error "Either WEBRTC_WIN or WEBRTC_POSIX needs to be defined." #endif @@ -43,8 +46,7 @@ #pragma warning(disable : 4722) #endif -#include - +#include #include #include "absl/algorithm/container.h" diff --git a/rtc_base/thread.h b/rtc_base/thread.h index ef970b40e5..61d427c07e 100644 --- a/rtc_base/thread.h +++ b/rtc_base/thread.h @@ -11,9 +11,10 @@ #ifndef RTC_BASE_THREAD_H_ #define RTC_BASE_THREAD_H_ -#include - -#include +#include +#include +#include +#include #include #include #include @@ -23,24 +24,22 @@ #include #include -#include "absl/strings/string_view.h" - -#if defined(WEBRTC_POSIX) -#include -#endif -#include "absl/base/attributes.h" #include "absl/functional/any_invocable.h" +#include "absl/strings/string_view.h" #include "api/function_view.h" #include "api/location.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "rtc_base/checks.h" -#include "rtc_base/platform_thread_types.h" #include "rtc_base/socket_server.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/thread_annotations.h" +#if defined(WEBRTC_POSIX) +#include // IWYU pragma: keep +#endif + #if defined(WEBRTC_WIN) #include "rtc_base/win32.h" #endif @@ -566,15 +565,5 @@ class AutoSocketServerThread : public Thread { }; } // 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::AutoSocketServerThread; -using ::webrtc::AutoThread; -using ::webrtc::Thread; -using ::webrtc::ThreadManager; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_THREAD_H_ diff --git a/rtc_base/time_utils.cc b/rtc_base/time_utils.cc index d8ce42a539..2e8670d8e2 100644 --- a/rtc_base/time_utils.cc +++ b/rtc_base/time_utils.cc @@ -8,14 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include #if defined(WEBRTC_POSIX) #include #endif #include "rtc_base/checks.h" -#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/system_time.h" #include "rtc_base/time_utils.h" #if defined(WEBRTC_WIN) diff --git a/rtc_base/time_utils.h b/rtc_base/time_utils.h index d4dbb2b57f..d1615d5cea 100644 --- a/rtc_base/time_utils.h +++ b/rtc_base/time_utils.h @@ -14,9 +14,7 @@ #include #include -#include "rtc_base/checks.h" #include "rtc_base/system/rtc_export.h" -#include "rtc_base/system_time.h" namespace webrtc { @@ -137,35 +135,5 @@ RTC_EXPORT int64_t TimeUTCMillis(); } // 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::ClockInterface; -using ::webrtc::GetClockForTesting; -using ::webrtc::kNtpJan1970Millisecs; -using ::webrtc::kNumMicrosecsPerMillisec; -using ::webrtc::kNumMicrosecsPerSec; -using ::webrtc::kNumMillisecsPerSec; -using ::webrtc::kNumNanosecsPerMicrosec; -using ::webrtc::kNumNanosecsPerMillisec; -using ::webrtc::kNumNanosecsPerSec; -using ::webrtc::SetClockForTesting; -using ::webrtc::SystemTimeMillis; -using ::webrtc::Time; -using ::webrtc::Time32; -using ::webrtc::TimeAfter; -using ::webrtc::TimeDiff; -using ::webrtc::TimeDiff32; -using ::webrtc::TimeMicros; -using ::webrtc::TimeMillis; -using ::webrtc::TimeNanos; -using ::webrtc::TimeSince; -using ::webrtc::TimeUntil; -using ::webrtc::TimeUTCMicros; -using ::webrtc::TimeUTCMillis; -using ::webrtc::TmToSeconds; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_TIME_UTILS_H_ diff --git a/rtc_base/time_utils_unittest.cc b/rtc_base/time_utils_unittest.cc index 06d98f9dca..fff5f74382 100644 --- a/rtc_base/time_utils_unittest.cc +++ b/rtc_base/time_utils_unittest.cc @@ -10,9 +10,12 @@ #include "rtc_base/time_utils.h" +#include +#include #include #include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "rtc_base/crypto_random.h" #include "rtc_base/event.h" #include "rtc_base/fake_clock.h" diff --git a/rtc_base/timestamp_aligner.h b/rtc_base/timestamp_aligner.h index a3eda6c964..f1e0cbc333 100644 --- a/rtc_base/timestamp_aligner.h +++ b/rtc_base/timestamp_aligner.h @@ -90,12 +90,5 @@ class RTC_EXPORT TimestampAligner { } // 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::TimestampAligner; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_TIMESTAMP_ALIGNER_H_ diff --git a/rtc_base/timestamp_aligner_unittest.cc b/rtc_base/timestamp_aligner_unittest.cc index 2582c78812..d8df07a0c1 100644 --- a/rtc_base/timestamp_aligner_unittest.cc +++ b/rtc_base/timestamp_aligner_unittest.cc @@ -10,9 +10,8 @@ #include "rtc_base/timestamp_aligner.h" -#include - #include +#include #include #include diff --git a/rtc_base/trace_categories.h b/rtc_base/trace_categories.h index ef4070ca07..e6b3ab5273 100644 --- a/rtc_base/trace_categories.h +++ b/rtc_base/trace_categories.h @@ -27,8 +27,9 @@ PERFETTO_DEFINE_CATEGORIES_IN_NAMESPACE_WITH_ATTRS( RTC_EXPORT, perfetto::Category("webrtc"), perfetto::Category("webrtc_stats"), - perfetto::Category(TRACE_DISABLED_BY_DEFAULT("webrtc")), - perfetto::Category(TRACE_DISABLED_BY_DEFAULT("webrtc_stats"))); + perfetto::Category(TRACE_DISABLED_BY_DEFAULT("webrtc")).SetTags("slow"), + perfetto::Category(TRACE_DISABLED_BY_DEFAULT("webrtc_stats")) + .SetTags("slow")); PERFETTO_USE_CATEGORIES_FROM_NAMESPACE(webrtc); diff --git a/rtc_base/type_traits.h b/rtc_base/type_traits.h index 4247d7c9f2..fccaf33718 100644 --- a/rtc_base/type_traits.h +++ b/rtc_base/type_traits.h @@ -13,6 +13,7 @@ #include #include +#include namespace webrtc { @@ -137,15 +138,5 @@ static_assert(!IsIntlike::value, ""); } // 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 { -template -using HasDataAndSize = ::webrtc::HasDataAndSize; -template -using IsIntlike = ::webrtc::IsIntlike; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_TYPE_TRAITS_H_ diff --git a/rtc_base/unique_id_generator.h b/rtc_base/unique_id_generator.h index e08742b9b7..64491c4eba 100644 --- a/rtc_base/unique_id_generator.h +++ b/rtc_base/unique_id_generator.h @@ -151,14 +151,5 @@ bool UniqueNumberGenerator::AddKnownId(TIntegral value) { } } // 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::UniqueNumberGenerator; -using ::webrtc::UniqueRandomIdGenerator; -using ::webrtc::UniqueStringGenerator; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_UNIQUE_ID_GENERATOR_H_ diff --git a/rtc_base/unique_id_generator_unittest.cc b/rtc_base/unique_id_generator_unittest.cc index b640fd913c..3406b6863c 100644 --- a/rtc_base/unique_id_generator_unittest.cc +++ b/rtc_base/unique_id_generator_unittest.cc @@ -21,7 +21,6 @@ #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "rtc_base/checks.h" -#include "rtc_base/crypto_random.h" #include "test/gmock.h" #include "test/gtest.h" @@ -79,15 +78,12 @@ TYPED_TEST(UniqueIdGeneratorTest, ElementsDoNotRepeat) { TYPED_TEST(UniqueIdGeneratorTest, KnownElementsAreNotGenerated) { typedef TypeParam Generator; const size_t num_elements = 100; - InitRandom(0); Generator generator1; std::vector known_values; for (size_t i = 0; i < num_elements; i++) { known_values.push_back(generator1.Generate()); } EXPECT_EQ(num_elements, known_values.size()); - - InitRandom(0); Generator generator2(known_values); std::vector values; @@ -106,7 +102,6 @@ TYPED_TEST(UniqueIdGeneratorTest, KnownElementsAreNotGenerated) { TYPED_TEST(UniqueIdGeneratorTest, AddedElementsAreNotGenerated) { typedef TypeParam Generator; const size_t num_elements = 100; - InitRandom(0); Generator generator1; std::vector known_values; for (size_t i = 0; i < num_elements; i++) { @@ -114,7 +109,6 @@ TYPED_TEST(UniqueIdGeneratorTest, AddedElementsAreNotGenerated) { } EXPECT_EQ(num_elements, known_values.size()); - InitRandom(0); Generator generator2; for (const typename Generator::value_type& value : known_values) { @@ -137,11 +131,9 @@ TYPED_TEST(UniqueIdGeneratorTest, AddedElementsAreNotGenerated) { TYPED_TEST(UniqueIdGeneratorTest, AddKnownIdOnNewIdReturnsTrue) { typedef TypeParam Generator; - InitRandom(0); Generator generator1; const typename Generator::value_type id = generator1.Generate(); - InitRandom(0); Generator generator2; EXPECT_TRUE(generator2.AddKnownId(id)); } @@ -149,11 +141,9 @@ TYPED_TEST(UniqueIdGeneratorTest, AddKnownIdOnNewIdReturnsTrue) { TYPED_TEST(UniqueIdGeneratorTest, AddKnownIdCalledAgainForSameIdReturnsFalse) { typedef TypeParam Generator; - InitRandom(0); Generator generator1; const typename Generator::value_type id = generator1.Generate(); - InitRandom(0); Generator generator2; ASSERT_TRUE(generator2.AddKnownId(id)); EXPECT_FALSE(generator2.AddKnownId(id)); @@ -163,12 +153,10 @@ TYPED_TEST(UniqueIdGeneratorTest, AddKnownIdOnIdProvidedAsKnownToCtorReturnsFalse) { typedef TypeParam Generator; - InitRandom(0); Generator generator1; const typename Generator::value_type id = generator1.Generate(); std::vector known_values = {id}; - InitRandom(0); Generator generator2(known_values); EXPECT_FALSE(generator2.AddKnownId(id)); } diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc index 20ae7890c4..d4b84a318f 100644 --- a/rtc_base/virtual_socket_server.cc +++ b/rtc_base/virtual_socket_server.cc @@ -10,28 +10,39 @@ #include "rtc_base/virtual_socket_server.h" -#include -#include - +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include #include #include "absl/algorithm/container.h" +#include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/units/time_delta.h" +#include "rtc_base/byte_order.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" #include "rtc_base/fake_clock.h" +#include "rtc_base/ip_address.h" #include "rtc_base/logging.h" -#include "rtc_base/physical_socket_server.h" +#include "rtc_base/net_helpers.h" +#include "rtc_base/socket.h" +#include "rtc_base/socket_address.h" #include "rtc_base/socket_address_pair.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" namespace webrtc { - #if defined(WEBRTC_WIN) const in_addr kInitialNextIPv4 = {{{0x01, 0, 0, 0}}}; #else diff --git a/rtc_base/virtual_socket_server.h b/rtc_base/virtual_socket_server.h index 32e1765e2a..9beef0011d 100644 --- a/rtc_base/virtual_socket_server.h +++ b/rtc_base/virtual_socket_server.h @@ -11,21 +11,30 @@ #ifndef RTC_BASE_VIRTUAL_SOCKET_SERVER_H_ #define RTC_BASE_VIRTUAL_SOCKET_SERVER_H_ +#include +#include #include +#include #include +#include #include +#include #include #include "api/make_ref_counted.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" -#include "api/task_queue/task_queue_base.h" -#include "rtc_base/checks.h" +#include "api/units/time_delta.h" #include "rtc_base/event.h" #include "rtc_base/fake_clock.h" +#include "rtc_base/ip_address.h" +#include "rtc_base/socket.h" +#include "rtc_base/socket_address.h" #include "rtc_base/socket_address_pair.h" #include "rtc_base/socket_server.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/third_party/sigslot/sigslot.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { @@ -480,12 +489,5 @@ class VirtualSocketServer : public SocketServer { } // 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::VirtualSocketServer; -} -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_VIRTUAL_SOCKET_SERVER_H_ diff --git a/rtc_base/virtual_socket_unittest.cc b/rtc_base/virtual_socket_unittest.cc index 22988a540f..5d6a1e018d 100644 --- a/rtc_base/virtual_socket_unittest.cc +++ b/rtc_base/virtual_socket_unittest.cc @@ -8,13 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include -#include -#include -#include - #include +#include +#include +#include +#include +#include #include #include "absl/memory/memory.h" diff --git a/rtc_base/weak_ptr.cc b/rtc_base/weak_ptr.cc index 80c25a7294..493ff2c4d8 100644 --- a/rtc_base/weak_ptr.cc +++ b/rtc_base/weak_ptr.cc @@ -57,7 +57,7 @@ WeakReference WeakReferenceOwner::GetRef() const { } void WeakReferenceOwner::Invalidate() { - if (flag_.get()) { + if (flag_) { flag_->Invalidate(); flag_ = nullptr; } diff --git a/rtc_base/weak_ptr.h b/rtc_base/weak_ptr.h index 5ed82ac1d6..d540e1e4c8 100644 --- a/rtc_base/weak_ptr.h +++ b/rtc_base/weak_ptr.h @@ -278,13 +278,5 @@ class WeakPtrFactory { } // 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::WeakPtr; -using ::webrtc::WeakPtrFactory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_WEAK_PTR_H_ diff --git a/rtc_base/win/create_direct3d_device.cc b/rtc_base/win/create_direct3d_device.cc index 35bbec1156..1854fc57cb 100644 --- a/rtc_base/win/create_direct3d_device.cc +++ b/rtc_base/win/create_direct3d_device.cc @@ -12,8 +12,6 @@ #include -#include - namespace { FARPROC LoadD3D11Function(const char* function_name) { diff --git a/rtc_base/win/get_activation_factory.cc b/rtc_base/win/get_activation_factory.cc index b3be9abfa7..0559fe7ac2 100644 --- a/rtc_base/win/get_activation_factory.cc +++ b/rtc_base/win/get_activation_factory.cc @@ -13,6 +13,8 @@ #include #include +#include "rtc_base/win/hstring.h" + namespace { FARPROC LoadComBaseFunction(const char* function_name) { diff --git a/rtc_base/win/hstring.cc b/rtc_base/win/hstring.cc index 5a362a97c9..d92112f6c6 100644 --- a/rtc_base/win/hstring.cc +++ b/rtc_base/win/hstring.cc @@ -13,6 +13,8 @@ #include #include +#include + namespace { FARPROC LoadComBaseFunction(const char* function_name) { diff --git a/rtc_base/win/hstring.h b/rtc_base/win/hstring.h index 8fb119a9e6..5462620559 100644 --- a/rtc_base/win/hstring.h +++ b/rtc_base/win/hstring.h @@ -12,9 +12,10 @@ #define RTC_BASE_WIN_HSTRING_H_ #include -#include #include +#include + namespace webrtc { // Callers must check the return value of ResolveCoreWinRTStringDelayLoad() diff --git a/rtc_base/win/scoped_com_initializer.cc b/rtc_base/win/scoped_com_initializer.cc index 4b56772ebf..23c9c1cc40 100644 --- a/rtc_base/win/scoped_com_initializer.cc +++ b/rtc_base/win/scoped_com_initializer.cc @@ -10,6 +10,8 @@ #include "rtc_base/win/scoped_com_initializer.h" +#include + #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/rtc_base/win/windows_version.cc b/rtc_base/win/windows_version.cc index 6ea62aca36..f059ea258a 100644 --- a/rtc_base/win/windows_version.cc +++ b/rtc_base/win/windows_version.cc @@ -12,7 +12,8 @@ #include -#include +#include +#include #include "rtc_base/checks.h" #include "rtc_base/string_utils.h" diff --git a/rtc_base/win/windows_version.h b/rtc_base/win/windows_version.h index cb75ae220c..fd0aefbd2f 100644 --- a/rtc_base/win/windows_version.h +++ b/rtc_base/win/windows_version.h @@ -11,8 +11,7 @@ #ifndef RTC_BASE_WIN_WINDOWS_VERSION_H_ #define RTC_BASE_WIN_WINDOWS_VERSION_H_ -#include - +#include #include typedef void* HANDLE; diff --git a/rtc_base/win32.h b/rtc_base/win32.h index 19bc067a5d..e2e410eb91 100644 --- a/rtc_base/win32.h +++ b/rtc_base/win32.h @@ -45,13 +45,5 @@ int win32_inet_pton(int af, const char* src, void* dst); } // 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::win32_inet_ntop; -using ::webrtc::win32_inet_pton; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_WIN32_H_ diff --git a/rtc_base/win32_unittest.cc b/rtc_base/win32_unittest.cc index 36e20c2a35..902f91532a 100644 --- a/rtc_base/win32_unittest.cc +++ b/rtc_base/win32_unittest.cc @@ -13,7 +13,9 @@ #include #include "rtc_base/gunit.h" +#include "rtc_base/ip_address.h" #include "rtc_base/net_helpers.h" +#include "test/gtest.h" #if !defined(WEBRTC_WIN) #error Only for Windows diff --git a/rtc_base/zero_memory.cc b/rtc_base/zero_memory.cc index 2727ed9e7b..66e6b1c83d 100644 --- a/rtc_base/zero_memory.cc +++ b/rtc_base/zero_memory.cc @@ -11,7 +11,7 @@ #if defined(WEBRTC_WIN) #include #else -#include +#include #endif #include "rtc_base/checks.h" diff --git a/rtc_base/zero_memory.h b/rtc_base/zero_memory.h index 1babf3708e..6229a1e3f6 100644 --- a/rtc_base/zero_memory.h +++ b/rtc_base/zero_memory.h @@ -32,12 +32,5 @@ void ExplicitZeroMemory(ArrayView a) { } // 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::ExplicitZeroMemory; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // RTC_BASE_ZERO_MEMORY_H_ diff --git a/rtc_base/zero_memory_unittest.cc b/rtc_base/zero_memory_unittest.cc index f333266d92..5a8804c216 100644 --- a/rtc_base/zero_memory_unittest.cc +++ b/rtc_base/zero_memory_unittest.cc @@ -10,9 +10,8 @@ #include "rtc_base/zero_memory.h" -#include - #include +#include #include "api/array_view.h" #include "test/gtest.h" diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn index c853f3408b..12e06d643b 100644 --- a/rtc_tools/BUILD.gn +++ b/rtc_tools/BUILD.gn @@ -76,6 +76,7 @@ rtc_library("video_file_writer") { "../api:scoped_refptr", "../api/video:video_frame", "../api/video:video_rtp_headers", + "../rtc_base:checks", "../rtc_base:logging", "//third_party/abseil-cpp/absl/strings", ] @@ -139,12 +140,13 @@ if (!is_component_build) { ":video_file_reader", ":video_file_writer", ":video_quality_analysis", + "../api:array_view", "../api:make_ref_counted", "../api:scoped_refptr", "../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:stdout_metrics_exporter", "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", @@ -161,74 +163,6 @@ if (!is_component_build) { # This target can be built from Chromium but it doesn't support # is_component_build=true because it depends on WebRTC testonly code # which is not part of //third_party/webrtc_overrides:webrtc_component. - - rtc_executable("rtp_generator") { - visibility = [ "*" ] - testonly = true - sources = [ - "rtp_generator/main.cc", - "rtp_generator/rtp_generator.cc", - "rtp_generator/rtp_generator.h", - ] - - deps = [ - "..//api/video_codecs:video_decoder_factory_template", - "..//api/video_codecs:video_decoder_factory_template_dav1d_adapter", - "..//api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter", - "..//api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter", - "..//api/video_codecs:video_decoder_factory_template_open_h264_adapter", - "..//api/video_codecs:video_encoder_factory_template", - "..//api/video_codecs:video_encoder_factory_template_libaom_av1_adapter", - "..//api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter", - "..//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", - "../call:fake_network", - "../call:rtp_interfaces", - "../call:rtp_sender", - "../call:simulated_packet_receiver", - "../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", - "../video/config:encoder_config", - "../video/config:streams_config", - "//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", - ] - if (build_with_chromium) { - # When building from Chromium, WebRTC's metrics and field trial - # implementations need to be replaced by the Chromium ones. - deps += [ "//third_party/webrtc_overrides:webrtc_component" ] - } - } - - # This target can be built from Chromium but it doesn't support - # is_component_build=true because it depends on WebRTC testonly code - # which is not part of //third_party/webrtc_overrides:webrtc_component. - rtc_executable("video_replay") { visibility = [ "*" ] testonly = true @@ -278,11 +212,11 @@ if (!is_component_build) { "../test:video_frame_writer", "../test:video_test_common", "../test:video_test_constants", - "../test/time_controller:time_controller", + "../test/time_controller", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:str_format", - "//third_party/abseil-cpp/absl/strings:strings", ] if (build_with_chromium) { # When building from Chromium, WebRTC's metrics and field trial @@ -381,7 +315,7 @@ if (!build_with_chromium) { "../api/environment", "../api/environment:environment_factory", "../api/neteq:neteq_api", - "../api/rtc_event_log:rtc_event_log", + "../api/rtc_event_log", "../api/transport:bandwidth_usage", "../api/transport:ecn_marking", "../api/transport:goog_cc", @@ -479,6 +413,7 @@ if (!build_with_chromium) { "../api/video_codecs:scalability_mode", "../rtc_base:checks", "../rtc_base:stringutils", + "../rtc_base/system:file_wrapper", "//api:create_frame_generator", "//api:frame_generator_api", "//api/environment", @@ -487,7 +422,7 @@ if (!build_with_chromium) { "//api/video_codecs:builtin_video_decoder_factory", "//api/video_codecs:builtin_video_encoder_factory", "//api/video_codecs:video_codecs_api", - "//common_video:common_video", + "//common_video", "//media:media_constants", "//modules/video_coding:video_codec_interface", "//modules/video_coding:video_coding_utility", @@ -498,7 +433,7 @@ if (!build_with_chromium) { "//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:strings", + "//third_party/abseil-cpp/absl/strings", ] } } @@ -664,6 +599,7 @@ if (rtc_include_tests) { deps = [ "../api:function_view", + "../api/audio:audio_frame_api", "../common_audio", "../modules/audio_processing", "../modules/audio_processing:audioproc_debug_proto", diff --git a/rtc_tools/data_channel_benchmark/BUILD.gn b/rtc_tools/data_channel_benchmark/BUILD.gn index 28a8df9c61..9f8435372e 100644 --- a/rtc_tools/data_channel_benchmark/BUILD.gn +++ b/rtc_tools/data_channel_benchmark/BUILD.gn @@ -76,5 +76,6 @@ rtc_executable("data_channel_benchmark") { "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/strings:string_view", + "//third_party/abseil-cpp/absl/time", ] } diff --git a/rtc_tools/data_channel_benchmark/DEPS b/rtc_tools/data_channel_benchmark/DEPS new file mode 100644 index 0000000000..7493559553 --- /dev/null +++ b/rtc_tools/data_channel_benchmark/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+absl/time/clock.h", + "+absl/time/time.h", +] diff --git a/rtc_tools/data_channel_benchmark/grpc_signaling.cc b/rtc_tools/data_channel_benchmark/grpc_signaling.cc index e158a4b2a2..a92995fe55 100644 --- a/rtc_tools/data_channel_benchmark/grpc_signaling.cc +++ b/rtc_tools/data_channel_benchmark/grpc_signaling.cc @@ -20,6 +20,8 @@ #include #include +#include "absl/time/clock.h" +#include "absl/time/time.h" #include "api/jsep.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/rtc_tools/data_channel_benchmark/grpc_signaling.h b/rtc_tools/data_channel_benchmark/grpc_signaling.h index 3c0bb12731..8aefe5ae32 100644 --- a/rtc_tools/data_channel_benchmark/grpc_signaling.h +++ b/rtc_tools/data_channel_benchmark/grpc_signaling.h @@ -10,10 +10,10 @@ #ifndef RTC_TOOLS_DATA_CHANNEL_BENCHMARK_GRPC_SIGNALING_H_ #define RTC_TOOLS_DATA_CHANNEL_BENCHMARK_GRPC_SIGNALING_H_ +#include #include #include -#include "api/jsep.h" #include "rtc_tools/data_channel_benchmark/signaling_interface.h" namespace webrtc { diff --git a/rtc_tools/data_channel_benchmark/peer_connection_client.h b/rtc_tools/data_channel_benchmark/peer_connection_client.h index c7e71b4e1a..60a071187c 100644 --- a/rtc_tools/data_channel_benchmark/peer_connection_client.h +++ b/rtc_tools/data_channel_benchmark/peer_connection_client.h @@ -10,8 +10,7 @@ #ifndef RTC_TOOLS_DATA_CHANNEL_BENCHMARK_PEER_CONNECTION_CLIENT_H_ #define RTC_TOOLS_DATA_CHANNEL_BENCHMARK_PEER_CONNECTION_CLIENT_H_ -#include - +#include #include #include #include diff --git a/rtc_tools/data_channel_benchmark/signaling_interface.h b/rtc_tools/data_channel_benchmark/signaling_interface.h index dcc126e5d5..b8f5f6690b 100644 --- a/rtc_tools/data_channel_benchmark/signaling_interface.h +++ b/rtc_tools/data_channel_benchmark/signaling_interface.h @@ -10,6 +10,7 @@ #ifndef RTC_TOOLS_DATA_CHANNEL_BENCHMARK_SIGNALING_INTERFACE_H_ #define RTC_TOOLS_DATA_CHANNEL_BENCHMARK_SIGNALING_INTERFACE_H_ +#include #include #include "api/jsep.h" diff --git a/rtc_tools/frame_analyzer/frame_analyzer.cc b/rtc_tools/frame_analyzer/frame_analyzer.cc index ca59f6c66c..71367c6640 100644 --- a/rtc_tools/frame_analyzer/frame_analyzer.cc +++ b/rtc_tools/frame_analyzer/frame_analyzer.cc @@ -8,21 +8,25 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include #include +#include +#include +#include +#include #include +#include #include #include "absl/flags/flag.h" #include "absl/flags/parse.h" #include "absl/strings/match.h" +#include "api/array_view.h" #include "api/scoped_refptr.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/stdout_metrics_exporter.h" #include "rtc_base/strings/string_builder.h" #include "rtc_tools/frame_analyzer/video_color_aligner.h" #include "rtc_tools/frame_analyzer/video_geometry_aligner.h" @@ -73,6 +77,98 @@ std::string JoinFilename(std::string directory, std::string filename) { return directory + kPathDelimiter + filename; } +// FrameAnalyzerMetricsExporter is a fork of +// webrtc::test::StdoutMetricsExporter. The fork was required because: +// 1. frame_analyzer must be compiled with build_with_chromium=true +// 2. The api/metrics:stdout_metrics_exporter depends on absl/flags which cannot +// be build when build_with_chromium=true unless the target is an +// rtc_executable (which is not the case for +// api/metrics:stdout_metrics_exporter). So this fork allows to cut the +// dependency. + +// Returns positive integral part of the number. +int64_t IntegralPart(double value) { + return std::lround(std::floor(std::abs(value))); +} + +void AppendWithPrecision(double value, + int digits_after_comma, + webrtc::StringBuilder& out) { + int64_t multiplier = std::lround(std::pow(10, digits_after_comma)); + int64_t integral_part = IntegralPart(value); + double decimal_part = std::abs(value) - integral_part; + + // If decimal part has leading zeros then when it will be multiplied on + // `multiplier`, leading zeros will be lost. To preserve them we add "1" + // so then leading digit will be greater than 0 and won't be removed. + // + // During conversion to the string leading digit has to be stripped. + // + // Also due to rounding it may happen that leading digit may be incremented, + // like with `digits_after_comma` 3 number 1.9995 will be rounded to 2. In + // such case this increment has to be propagated to the `integral_part`. + int64_t decimal_holder = std::lround((1 + decimal_part) * multiplier); + if (decimal_holder >= 2 * multiplier) { + // Rounding incremented added leading digit, so we need to transfer 1 to + // integral part. + integral_part++; + decimal_holder -= multiplier; + } + // Remove trailing zeros. + while (decimal_holder % 10 == 0) { + decimal_holder /= 10; + } + + // Print serialized number to output. + if (value < 0) { + out << "-"; + } + out << integral_part; + if (decimal_holder != 1) { + out << "." << std::to_string(decimal_holder).substr(1, digits_after_comma); + } +} + +class FrameAnalyzerMetricsExporter : public webrtc::test::MetricsExporter { + public: + FrameAnalyzerMetricsExporter() : output_(stdout) {} + ~FrameAnalyzerMetricsExporter() override = default; + + FrameAnalyzerMetricsExporter(const FrameAnalyzerMetricsExporter&) = delete; + FrameAnalyzerMetricsExporter& operator=(const FrameAnalyzerMetricsExporter&) = + delete; + + bool Export(webrtc::ArrayView metrics) override { + for (const webrtc::test::Metric& metric : metrics) { + PrintMetric(metric); + } + return true; + } + + private: + void PrintMetric(const webrtc::test::Metric& metric) { + webrtc::StringBuilder value_stream; + value_stream << metric.test_case << " / " << metric.name << "= {mean="; + if (metric.stats.mean.has_value()) { + AppendWithPrecision(*metric.stats.mean, 8, value_stream); + } else { + value_stream << "-"; + } + value_stream << ", stddev="; + if (metric.stats.stddev.has_value()) { + AppendWithPrecision(*metric.stats.stddev, 8, value_stream); + } else { + value_stream << "-"; + } + value_stream << "} " << ToString(metric.unit) << " (" + << ToString(metric.improvement_direction) << ")"; + + fprintf(output_, "RESULT: %s\n", value_stream.str().c_str()); + } + + FILE* const output_; +}; + } // namespace /* @@ -166,7 +262,7 @@ int main(int argc, char* argv[]) { *webrtc::test::GetGlobalMetricsLogger()); std::vector> exporters; - exporters.push_back(std::make_unique()); + exporters.push_back(std::make_unique()); std::string chartjson_result_file = absl::GetFlag(FLAGS_chartjson_result_file); if (!chartjson_result_file.empty()) { diff --git a/rtc_tools/frame_analyzer/linear_least_squares.cc b/rtc_tools/frame_analyzer/linear_least_squares.cc index 93a6f90e69..e99c13e07a 100644 --- a/rtc_tools/frame_analyzer/linear_least_squares.cc +++ b/rtc_tools/frame_analyzer/linear_least_squares.cc @@ -10,14 +10,13 @@ #include "rtc_tools/frame_analyzer/linear_least_squares.h" -#include - +#include #include #include -#include #include -#include #include +#include +#include #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/rtc_tools/frame_analyzer/linear_least_squares.h b/rtc_tools/frame_analyzer/linear_least_squares.h index 5b5a7837d4..e33deaa593 100644 --- a/rtc_tools/frame_analyzer/linear_least_squares.h +++ b/rtc_tools/frame_analyzer/linear_least_squares.h @@ -11,8 +11,7 @@ #ifndef RTC_TOOLS_FRAME_ANALYZER_LINEAR_LEAST_SQUARES_H_ #define RTC_TOOLS_FRAME_ANALYZER_LINEAR_LEAST_SQUARES_H_ -#include - +#include #include #include #include diff --git a/rtc_tools/frame_analyzer/linear_least_squares_unittest.cc b/rtc_tools/frame_analyzer/linear_least_squares_unittest.cc index d4a23e87a6..186d07ad20 100644 --- a/rtc_tools/frame_analyzer/linear_least_squares_unittest.cc +++ b/rtc_tools/frame_analyzer/linear_least_squares_unittest.cc @@ -10,7 +10,7 @@ #include "rtc_tools/frame_analyzer/linear_least_squares.h" -#include +#include #include "test/gtest.h" diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis.cc b/rtc_tools/frame_analyzer/reference_less_video_analysis.cc index fca89a8f2f..1ea40a2885 100644 --- a/rtc_tools/frame_analyzer/reference_less_video_analysis.cc +++ b/rtc_tools/frame_analyzer/reference_less_video_analysis.cc @@ -7,9 +7,8 @@ * 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 "absl/flags/flag.h" diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc index a0bc848f5d..4de4bfb031 100644 --- a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc +++ b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.cc @@ -9,13 +9,16 @@ */ #include "rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h" -#include - +#include +#include #include +#include #include +#include "api/scoped_refptr.h" #include "api/video/video_frame_buffer.h" #include "rtc_tools/frame_analyzer/video_quality_analysis.h" +#include "rtc_tools/video_file_reader.h" #define STATS_LINE_LENGTH 28 #define PSNR_FREEZE_THRESHOLD 47 diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h index b9f828101b..7b3f44c67a 100644 --- a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h +++ b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h @@ -11,8 +11,7 @@ #ifndef RTC_TOOLS_FRAME_ANALYZER_REFERENCE_LESS_VIDEO_ANALYSIS_LIB_H_ #define RTC_TOOLS_FRAME_ANALYZER_REFERENCE_LESS_VIDEO_ANALYSIS_LIB_H_ -#include - +#include #include #include diff --git a/rtc_tools/frame_analyzer/video_color_aligner.cc b/rtc_tools/frame_analyzer/video_color_aligner.cc index 54f7fd4de9..b4515883a0 100644 --- a/rtc_tools/frame_analyzer/video_color_aligner.cc +++ b/rtc_tools/frame_analyzer/video_color_aligner.cc @@ -10,18 +10,21 @@ #include "rtc_tools/frame_analyzer/video_color_aligner.h" -#include - #include +#include #include +#include #include #include #include "api/array_view.h" #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_tools/frame_analyzer/linear_least_squares.h" +#include "rtc_tools/video_file_reader.h" #include "third_party/libyuv/include/libyuv/planar_functions.h" #include "third_party/libyuv/include/libyuv/scale.h" diff --git a/rtc_tools/frame_analyzer/video_color_aligner_unittest.cc b/rtc_tools/frame_analyzer/video_color_aligner_unittest.cc index f175a4e23b..d621a0ab8e 100644 --- a/rtc_tools/frame_analyzer/video_color_aligner_unittest.cc +++ b/rtc_tools/frame_analyzer/video_color_aligner_unittest.cc @@ -10,9 +10,11 @@ #include "rtc_tools/frame_analyzer/video_color_aligner.h" -#include +#include +#include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/video_frame_buffer.h" #include "rtc_tools/frame_analyzer/video_quality_analysis.h" #include "rtc_tools/video_file_reader.h" #include "test/gtest.h" diff --git a/rtc_tools/frame_analyzer/video_geometry_aligner.cc b/rtc_tools/frame_analyzer/video_geometry_aligner.cc index c029a0c342..c626536c72 100644 --- a/rtc_tools/frame_analyzer/video_geometry_aligner.cc +++ b/rtc_tools/frame_analyzer/video_geometry_aligner.cc @@ -10,12 +10,17 @@ #include "rtc_tools/frame_analyzer/video_geometry_aligner.h" +#include +#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_tools/frame_analyzer/video_quality_analysis.h" +#include "rtc_tools/video_file_reader.h" #include "third_party/libyuv/include/libyuv/scale.h" namespace webrtc { diff --git a/rtc_tools/frame_analyzer/video_geometry_aligner.h b/rtc_tools/frame_analyzer/video_geometry_aligner.h index 73a80bca7f..ab43b383a9 100644 --- a/rtc_tools/frame_analyzer/video_geometry_aligner.h +++ b/rtc_tools/frame_analyzer/video_geometry_aligner.h @@ -11,6 +11,7 @@ #ifndef RTC_TOOLS_FRAME_ANALYZER_VIDEO_GEOMETRY_ALIGNER_H_ #define RTC_TOOLS_FRAME_ANALYZER_VIDEO_GEOMETRY_ALIGNER_H_ +#include "api/scoped_refptr.h" #include "api/video/video_frame_buffer.h" #include "rtc_tools/video_file_reader.h" diff --git a/rtc_tools/frame_analyzer/video_geometry_aligner_unittest.cc b/rtc_tools/frame_analyzer/video_geometry_aligner_unittest.cc index 4cc5af8518..c0aae85a50 100644 --- a/rtc_tools/frame_analyzer/video_geometry_aligner_unittest.cc +++ b/rtc_tools/frame_analyzer/video_geometry_aligner_unittest.cc @@ -10,9 +10,12 @@ #include "rtc_tools/frame_analyzer/video_geometry_aligner.h" +#include #include +#include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/video_frame_buffer.h" #include "rtc_tools/frame_analyzer/video_quality_analysis.h" #include "rtc_tools/video_file_reader.h" #include "test/gtest.h" diff --git a/rtc_tools/frame_analyzer/video_quality_analysis.cc b/rtc_tools/frame_analyzer/video_quality_analysis.cc index 36dc933506..67a72b959e 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis.cc +++ b/rtc_tools/frame_analyzer/video_quality_analysis.cc @@ -11,13 +11,17 @@ #include "rtc_tools/frame_analyzer/video_quality_analysis.h" #include -#include #include +#include +#include #include "api/numerics/samples_stats_counter.h" +#include "api/scoped_refptr.h" #include "api/test/metrics/metric.h" +#include "api/test/metrics/metrics_logger.h" +#include "api/video/video_frame_buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/logging.h" +#include "rtc_tools/video_file_reader.h" #include "third_party/libyuv/include/libyuv/compare.h" namespace webrtc { diff --git a/rtc_tools/frame_analyzer/video_quality_analysis.h b/rtc_tools/frame_analyzer/video_quality_analysis.h index 0231aea654..0d58f2bc4c 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis.h +++ b/rtc_tools/frame_analyzer/video_quality_analysis.h @@ -11,8 +11,7 @@ #ifndef RTC_TOOLS_FRAME_ANALYZER_VIDEO_QUALITY_ANALYSIS_H_ #define RTC_TOOLS_FRAME_ANALYZER_VIDEO_QUALITY_ANALYSIS_H_ -#include - +#include #include #include diff --git a/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc b/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc index 7ad8ec1a03..1c4ef87487 100644 --- a/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc +++ b/rtc_tools/frame_analyzer/video_quality_analysis_unittest.cc @@ -9,6 +9,8 @@ */ #include "rtc_tools/frame_analyzer/video_quality_analysis.h" +#include +#include #include #include diff --git a/rtc_tools/frame_analyzer/video_temporal_aligner.cc b/rtc_tools/frame_analyzer/video_temporal_aligner.cc index 84afee1750..9fe606ac83 100644 --- a/rtc_tools/frame_analyzer/video_temporal_aligner.cc +++ b/rtc_tools/frame_analyzer/video_temporal_aligner.cc @@ -19,9 +19,11 @@ #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_tools/frame_analyzer/video_quality_analysis.h" +#include "rtc_tools/video_file_reader.h" namespace webrtc { namespace test { diff --git a/rtc_tools/frame_analyzer/video_temporal_aligner.h b/rtc_tools/frame_analyzer/video_temporal_aligner.h index 8e5cf54460..cd635c3918 100644 --- a/rtc_tools/frame_analyzer/video_temporal_aligner.h +++ b/rtc_tools/frame_analyzer/video_temporal_aligner.h @@ -11,8 +11,7 @@ #ifndef RTC_TOOLS_FRAME_ANALYZER_VIDEO_TEMPORAL_ALIGNER_H_ #define RTC_TOOLS_FRAME_ANALYZER_VIDEO_TEMPORAL_ALIGNER_H_ -#include - +#include #include #include "api/scoped_refptr.h" diff --git a/rtc_tools/frame_analyzer/video_temporal_aligner_unittest.cc b/rtc_tools/frame_analyzer/video_temporal_aligner_unittest.cc index 0fe03e8924..c05504a327 100644 --- a/rtc_tools/frame_analyzer/video_temporal_aligner_unittest.cc +++ b/rtc_tools/frame_analyzer/video_temporal_aligner_unittest.cc @@ -11,7 +11,9 @@ #include "rtc_tools/frame_analyzer/video_temporal_aligner.h" #include +#include +#include "api/scoped_refptr.h" #include "rtc_tools/frame_analyzer/video_quality_analysis.h" #include "rtc_tools/video_file_reader.h" #include "test/gtest.h" diff --git a/rtc_tools/network_tester/BUILD.gn b/rtc_tools/network_tester/BUILD.gn index 0947186878..4fa98d73a2 100644 --- a/rtc_tools/network_tester/BUILD.gn +++ b/rtc_tools/network_tester/BUILD.gn @@ -39,10 +39,12 @@ if (rtc_enable_protobuf) { deps = [ ":network_tester_config_proto", ":network_tester_packet_proto", + "../../api:scoped_refptr", "../../api:sequence_checker", "../../api/task_queue", "../../api/task_queue:default_task_queue_factory", "../../api/task_queue:pending_task_safety_flag", + "../../api/units:time_delta", "../../api/units:timestamp", "../../p2p:basic_packet_socket_factory", "../../rtc_base:async_packet_socket", @@ -87,6 +89,7 @@ if (rtc_enable_protobuf) { "../../rtc_base:gunit_helpers", "../../rtc_base:random", "../../rtc_base:threading", + "../../rtc_base:timeutils", "../../test:fileutils", "../../test:test_support", "../../test:wait_until", diff --git a/rtc_tools/network_tester/config_reader.cc b/rtc_tools/network_tester/config_reader.cc index 5ee1676705..fc657a6c7e 100644 --- a/rtc_tools/network_tester/config_reader.cc +++ b/rtc_tools/network_tester/config_reader.cc @@ -10,7 +10,9 @@ #include "rtc_tools/network_tester/config_reader.h" #include +#include #include +#include #include #include "rtc_base/checks.h" diff --git a/rtc_tools/network_tester/config_reader.h b/rtc_tools/network_tester/config_reader.h index 936da828e4..18dbd80c26 100644 --- a/rtc_tools/network_tester/config_reader.h +++ b/rtc_tools/network_tester/config_reader.h @@ -11,7 +11,6 @@ #ifndef RTC_TOOLS_NETWORK_TESTER_CONFIG_READER_H_ #define RTC_TOOLS_NETWORK_TESTER_CONFIG_READER_H_ -#include #include #include diff --git a/rtc_tools/network_tester/jni.cc b/rtc_tools/network_tester/jni.cc index a0950f143d..8fbe05465c 100644 --- a/rtc_tools/network_tester/jni.cc +++ b/rtc_tools/network_tester/jni.cc @@ -9,14 +9,16 @@ */ #include -#undef JNIEXPORT -#define JNIEXPORT __attribute__((visibility("default"))) + +#include #include -#include "rtc_base/logging.h" #include "rtc_base/thread.h" #include "rtc_tools/network_tester/test_controller.h" +#undef JNIEXPORT +#define JNIEXPORT __attribute__((visibility("default"))) + extern "C" JNIEXPORT jlong JNICALL Java_com_google_media_networktester_NetworkTester_CreateTestController( JNIEnv* jni, diff --git a/rtc_tools/network_tester/network_tester_unittest.cc b/rtc_tools/network_tester/network_tester_unittest.cc index c9fb87fec2..392b877ff0 100644 --- a/rtc_tools/network_tester/network_tester_unittest.cc +++ b/rtc_tools/network_tester/network_tester_unittest.cc @@ -14,6 +14,8 @@ #include "api/test/rtc_error_matchers.h" #include "rtc_base/random.h" +#include "rtc_base/thread.h" +#include "rtc_base/time_utils.h" #include "rtc_tools/network_tester/test_controller.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/rtc_tools/network_tester/packet_logger.cc b/rtc_tools/network_tester/packet_logger.cc index eef8030981..b4c1635abe 100644 --- a/rtc_tools/network_tester/packet_logger.cc +++ b/rtc_tools/network_tester/packet_logger.cc @@ -9,6 +9,7 @@ */ #include "rtc_tools/network_tester/packet_logger.h" +#include #include #include "rtc_base/checks.h" diff --git a/rtc_tools/network_tester/packet_sender.cc b/rtc_tools/network_tester/packet_sender.cc index abc2240408..7ecfa97477 100644 --- a/rtc_tools/network_tester/packet_sender.cc +++ b/rtc_tools/network_tester/packet_sender.cc @@ -11,13 +11,19 @@ #include "rtc_tools/network_tester/packet_sender.h" #include +#include +#include #include +#include #include #include #include "absl/functional/any_invocable.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 "rtc_base/time_utils.h" #include "rtc_tools/network_tester/config_reader.h" #include "rtc_tools/network_tester/test_controller.h" diff --git a/rtc_tools/network_tester/packet_sender.h b/rtc_tools/network_tester/packet_sender.h index 84df00e513..b338688107 100644 --- a/rtc_tools/network_tester/packet_sender.h +++ b/rtc_tools/network_tester/packet_sender.h @@ -11,13 +11,16 @@ #ifndef RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_ #define RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_ -#include +#include +#include #include +#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_factory.h" +#include "api/task_queue/task_queue_base.h" #include "rtc_base/system/no_unique_address.h" +#include "rtc_base/thread_annotations.h" #ifdef WEBRTC_NETWORK_TESTER_PROTO #include "rtc_tools/network_tester/network_tester_packet.pb.h" diff --git a/rtc_tools/network_tester/server.cc b/rtc_tools/network_tester/server.cc index 1c88ed5847..0f3d8327c0 100644 --- a/rtc_tools/network_tester/server.cc +++ b/rtc_tools/network_tester/server.cc @@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include "rtc_base/null_socket_server.h" #include "rtc_base/thread.h" #include "rtc_tools/network_tester/test_controller.h" diff --git a/rtc_tools/network_tester/test_controller.h b/rtc_tools/network_tester/test_controller.h index 0e99ade343..92f99942e8 100644 --- a/rtc_tools/network_tester/test_controller.h +++ b/rtc_tools/network_tester/test_controller.h @@ -11,15 +11,15 @@ #ifndef RTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ #define RTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ -#include -#include - #include +#include #include #include #include +#include "api/scoped_refptr.h" #include "api/sequence_checker.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "p2p/base/basic_packet_socket_factory.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/network/received_packet.h" diff --git a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc index 38ff935a75..59aaf437b1 100644 --- a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc +++ b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc @@ -8,10 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include #include +#include +#include #include #include "absl/flags/flag.h" diff --git a/rtc_tools/rtc_event_log_to_text/converter.cc b/rtc_tools/rtc_event_log_to_text/converter.cc index 8a55f69faf..1327f241a9 100644 --- a/rtc_tools/rtc_event_log_to_text/converter.cc +++ b/rtc_tools/rtc_event_log_to_text/converter.cc @@ -10,8 +10,7 @@ #include "rtc_tools/rtc_event_log_to_text/converter.h" -#include - +#include #include #include #include diff --git a/rtc_tools/rtc_event_log_to_text/converter.h b/rtc_tools/rtc_event_log_to_text/converter.h index fbcee7c196..04bbea997f 100644 --- a/rtc_tools/rtc_event_log_to_text/converter.h +++ b/rtc_tools/rtc_event_log_to_text/converter.h @@ -11,8 +11,7 @@ #ifndef RTC_TOOLS_RTC_EVENT_LOG_TO_TEXT_CONVERTER_H_ #define RTC_TOOLS_RTC_EVENT_LOG_TO_TEXT_CONVERTER_H_ -#include - +#include #include #include "absl/base/attributes.h" diff --git a/rtc_tools/rtc_event_log_to_text/main.cc b/rtc_tools/rtc_event_log_to_text/main.cc index d37374a2f0..8c3fef6f37 100644 --- a/rtc_tools/rtc_event_log_to_text/main.cc +++ b/rtc_tools/rtc_event_log_to_text/main.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.cc b/rtc_tools/rtc_event_log_visualizer/alerts.cc index 9137d0b807..6bb0d4a289 100644 --- a/rtc_tools/rtc_event_log_visualizer/alerts.cc +++ b/rtc_tools/rtc_event_log_visualizer/alerts.cc @@ -10,10 +10,9 @@ #include "rtc_tools/rtc_event_log_visualizer/alerts.h" -#include - #include #include +#include #include #include #include diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.h b/rtc_tools/rtc_event_log_visualizer/alerts.h index d421ceb95f..b7d5f12ba6 100644 --- a/rtc_tools/rtc_event_log_visualizer/alerts.h +++ b/rtc_tools/rtc_event_log_visualizer/alerts.h @@ -11,8 +11,7 @@ #ifndef RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ALERTS_H_ #define RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ALERTS_H_ -#include - +#include #include #include #include diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc index a50e0fbf53..fa93031ff1 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings.cc @@ -22,7 +22,6 @@ #include "api/units/time_delta.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" #include "rtc_base/numerics/safe_conversions.h" -#include "rtc_base/protobuf_utils.h" #include "rtc_tools/rtc_event_log_visualizer/analyzer.h" #include "rtc_tools/rtc_event_log_visualizer/analyzer_common.h" #include "rtc_tools/rtc_event_log_visualizer/plot_base.h" diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc index cb9f76a2e0..8b536cc78a 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc @@ -17,7 +17,6 @@ #include #include -#include "rtc_base/protobuf_utils.h" #include "rtc_base/system/file_wrapper.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc index a410985040..7748a597ff 100644 --- a/rtc_tools/rtc_event_log_visualizer/main.cc +++ b/rtc_tools/rtc_event_log_visualizer/main.cc @@ -8,8 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include #include #include diff --git a/rtc_tools/rtp_generator/configs/vp8.json b/rtc_tools/rtp_generator/configs/vp8.json deleted file mode 100644 index 65402fb846..0000000000 --- a/rtc_tools/rtp_generator/configs/vp8.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "video_streams": [ - { - "duration_ms": 10000, - "video_width": 640, - "video_height": 480, - "video_fps": 24, - "rtp" : { - "payload_name" : "VP8" - } - } - ] -} diff --git a/rtc_tools/rtp_generator/configs/vp9.json b/rtc_tools/rtp_generator/configs/vp9.json deleted file mode 100644 index fd780d8151..0000000000 --- a/rtc_tools/rtp_generator/configs/vp9.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "video_streams": [ - { - "duration_ms": 10000, - "video_width": 640, - "video_height": 480, - "video_fps": 24, - "rtp" : { - "payload_name" : "VP9" - } - } - ] -} diff --git a/rtc_tools/rtp_generator/main.cc b/rtc_tools/rtp_generator/main.cc deleted file mode 100644 index 7c4fcdfba6..0000000000 --- a/rtc_tools/rtp_generator/main.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include - -#include - -#include "absl/flags/flag.h" -#include "absl/flags/parse.h" -#include "absl/flags/usage.h" -#include "rtc_tools/rtp_generator/rtp_generator.h" - -ABSL_FLAG(std::string, input_config, "", "JSON file with config"); -ABSL_FLAG(std::string, output_rtpdump, "", "Where to store the rtpdump"); - -int main(int argc, char* argv[]) { - absl::SetProgramUsageMessage( - "Generates custom configured rtpdumps for the purpose of testing.\n" - "Example Usage:\n" - "./rtp_generator --input_config=sender_config.json\n" - " --output_rtpdump=my.rtpdump\n"); - absl::ParseCommandLine(argc, argv); - - const std::string config_path = absl::GetFlag(FLAGS_input_config); - const std::string rtp_dump_path = absl::GetFlag(FLAGS_output_rtpdump); - - if (rtp_dump_path.empty() || config_path.empty()) { - return EXIT_FAILURE; - } - - std::optional options = - webrtc::ParseRtpGeneratorOptionsFromFile(config_path); - if (!options.has_value()) { - return EXIT_FAILURE; - } - - webrtc::RtpGenerator rtp_generator(*options); - rtp_generator.GenerateRtpDump(rtp_dump_path); - - return EXIT_SUCCESS; -} diff --git a/rtc_tools/rtp_generator/rtp_generator.cc b/rtc_tools/rtp_generator/rtp_generator.cc deleted file mode 100644 index 3152bc1834..0000000000 --- a/rtc_tools/rtp_generator/rtp_generator.cc +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "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_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/video_encoder_config.h" - -namespace webrtc { -namespace { - -// Payload types. -constexpr int kPayloadTypeVp8 = 125; -constexpr int kPayloadTypeVp9 = 124; -constexpr int kPayloadTypeH264 = 123; -constexpr int kFakeVideoSendPayloadType = 122; - -// Defaults -constexpr int kDefaultSsrc = 1337; -constexpr int kMaxConfigBufferSize = 8192; - -// Utility function to validate a correct codec type has been passed in. -bool IsValidCodecType(const std::string& codec_name) { - return kVp8CodecName == codec_name || kVp9CodecName == codec_name || - kH264CodecName == codec_name; -} - -// Utility function to return some base payload type for a codec_name. -int GetDefaultTypeForPayloadName(const std::string& codec_name) { - if (kVp8CodecName == codec_name) { - return kPayloadTypeVp8; - } - if (kVp9CodecName == codec_name) { - return kPayloadTypeVp9; - } - if (kH264CodecName == codec_name) { - return kPayloadTypeH264; - } - return kFakeVideoSendPayloadType; -} - -// Creates a single VideoSendStream configuration. -std::optional -ParseVideoSendStreamConfig(const Json::Value& json) { - RtpGeneratorOptions::VideoSendStreamConfig config; - - // Parse video source settings. - if (!GetIntFromJsonObject(json, "duration_ms", &config.duration_ms)) { - RTC_LOG(LS_WARNING) << "duration_ms not specified using default: " - << config.duration_ms; - } - if (!GetIntFromJsonObject(json, "video_width", &config.video_width)) { - RTC_LOG(LS_WARNING) << "video_width not specified using default: " - << config.video_width; - } - if (!GetIntFromJsonObject(json, "video_height", &config.video_height)) { - RTC_LOG(LS_WARNING) << "video_height not specified using default: " - << config.video_height; - } - if (!GetIntFromJsonObject(json, "video_fps", &config.video_fps)) { - RTC_LOG(LS_WARNING) << "video_fps not specified using default: " - << config.video_fps; - } - if (!GetIntFromJsonObject(json, "num_squares", &config.num_squares)) { - RTC_LOG(LS_WARNING) << "num_squares not specified using default: " - << config.num_squares; - } - - // Parse RTP settings for this configuration. - config.rtp.ssrcs.push_back(kDefaultSsrc); - Json::Value rtp_json; - if (!GetValueFromJsonObject(json, "rtp", &rtp_json)) { - RTC_LOG(LS_ERROR) << "video_streams must have an rtp section"; - return std::nullopt; - } - if (!GetStringFromJsonObject(rtp_json, "payload_name", - &config.rtp.payload_name)) { - RTC_LOG(LS_ERROR) << "rtp.payload_name must be specified"; - return std::nullopt; - } - if (!IsValidCodecType(config.rtp.payload_name)) { - RTC_LOG(LS_ERROR) << "rtp.payload_name must be VP8,VP9 or H264"; - return std::nullopt; - } - - config.rtp.payload_type = - GetDefaultTypeForPayloadName(config.rtp.payload_name); - if (!GetIntFromJsonObject(rtp_json, "payload_type", - &config.rtp.payload_type)) { - RTC_LOG(LS_WARNING) - << "rtp.payload_type not specified using default for codec type" - << config.rtp.payload_type; - } - - return config; -} - -} // namespace - -std::optional ParseRtpGeneratorOptionsFromFile( - const std::string& options_file) { - if (!test::FileExists(options_file)) { - RTC_LOG(LS_ERROR) << " configuration file does not exist"; - return std::nullopt; - } - - // Read the configuration file from disk. - FileWrapper config_file = FileWrapper::OpenReadOnly(options_file); - std::vector raw_json_buffer(kMaxConfigBufferSize, 0); - size_t bytes_read = - config_file.Read(raw_json_buffer.data(), raw_json_buffer.size() - 1); - if (bytes_read == 0) { - RTC_LOG(LS_ERROR) << "Unable to read the configuration file."; - return std::nullopt; - } - - // Parse the file as JSON - Json::CharReaderBuilder builder; - Json::Value json; - std::string error_message; - std::unique_ptr json_reader(builder.newCharReader()); - if (!json_reader->parse(raw_json_buffer.data(), - raw_json_buffer.data() + raw_json_buffer.size(), - &json, &error_message)) { - RTC_LOG(LS_ERROR) << "Unable to parse the corpus config json file. Error:" - << error_message; - return std::nullopt; - } - - RtpGeneratorOptions gen_options; - for (const auto& video_stream_json : json["video_streams"]) { - std::optional - video_stream_config = ParseVideoSendStreamConfig(video_stream_json); - if (!video_stream_config.has_value()) { - RTC_LOG(LS_ERROR) << "Unable to parse the corpus config json file"; - return std::nullopt; - } - gen_options.video_streams.push_back(*video_stream_config); - } - return gen_options; -} - -RtpGenerator::RtpGenerator(const RtpGeneratorOptions& options) - : options_(options), - env_(CreateEnvironment()), - video_encoder_factory_( - std::make_unique< - VideoEncoderFactoryTemplate>()), - video_decoder_factory_( - std::make_unique< - VideoDecoderFactoryTemplate>()), - video_bitrate_allocator_factory_( - CreateBuiltinVideoBitrateAllocatorFactory()), - call_(Call::Create(CallConfig(env_))) { - constexpr int kMinBitrateBps = 30000; // 30 Kbps - constexpr int kMaxBitrateBps = 2500000; // 2.5 Mbps - - int stream_count = 0; - VideoEncoder::EncoderInfo encoder_info; - for (const auto& send_config : options.video_streams) { - VideoSendStream::Config video_config(this); - video_config.encoder_settings.encoder_factory = - video_encoder_factory_.get(); - video_config.encoder_settings.bitrate_allocator_factory = - video_bitrate_allocator_factory_.get(); - video_config.rtp = send_config.rtp; - // Update some required to be unique values. - stream_count++; - video_config.rtp.mid = "mid-" + std::to_string(stream_count); - - // Configure the video encoder configuration. - VideoEncoderConfig encoder_config; - encoder_config.content_type = - VideoEncoderConfig::ContentType::kRealtimeVideo; - encoder_config.codec_type = - PayloadStringToCodecType(video_config.rtp.payload_name); - if (video_config.rtp.payload_name == kVp8CodecName) { - VideoCodecVP8 settings = VideoEncoder::GetDefaultVp8Settings(); - encoder_config.encoder_specific_settings = - make_ref_counted( - settings); - } else if (video_config.rtp.payload_name == kVp9CodecName) { - VideoCodecVP9 settings = VideoEncoder::GetDefaultVp9Settings(); - encoder_config.encoder_specific_settings = - make_ref_counted( - settings); - } else if (video_config.rtp.payload_name == kH264CodecName) { - encoder_config.encoder_specific_settings = nullptr; - } - encoder_config.video_format.name = video_config.rtp.payload_name; - encoder_config.min_transmit_bitrate_bps = 0; - encoder_config.max_bitrate_bps = kMaxBitrateBps; - encoder_config.content_type = - VideoEncoderConfig::ContentType::kRealtimeVideo; - - // Configure the simulcast layers. - encoder_config.number_of_streams = video_config.rtp.ssrcs.size(); - encoder_config.bitrate_priority = 1.0; - encoder_config.simulcast_layers.resize(encoder_config.number_of_streams); - for (size_t i = 0; i < encoder_config.number_of_streams; ++i) { - encoder_config.simulcast_layers[i].active = true; - encoder_config.simulcast_layers[i].min_bitrate_bps = kMinBitrateBps; - encoder_config.simulcast_layers[i].max_bitrate_bps = kMaxBitrateBps; - encoder_config.simulcast_layers[i].max_framerate = send_config.video_fps; - } - - // Setup the fake video stream for this. - std::unique_ptr frame_generator = - std::make_unique( - &env_.clock(), - test::CreateSquareFrameGenerator(send_config.video_width, - send_config.video_height, - std::nullopt, std::nullopt), - send_config.video_fps, env_.task_queue_factory()); - frame_generator->Init(); - - VideoSendStream* video_send_stream = call_->CreateVideoSendStream( - std::move(video_config), std::move(encoder_config)); - 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); - } -} - -RtpGenerator::~RtpGenerator() { - for (VideoSendStream* send_stream : video_send_streams_) { - call_->DestroyVideoSendStream(send_stream); - } -} - -void RtpGenerator::GenerateRtpDump(const std::string& rtp_dump_path) { - rtp_dump_writer_.reset(test::RtpFileWriter::Create( - test::RtpFileWriter::kRtpDump, rtp_dump_path)); - - call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); - for (VideoSendStream* send_stream : video_send_streams_) { - send_stream->Start(); - } - - // Spinlock until all the durations end. - WaitUntilAllVideoStreamsFinish(); - - call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkDown); -} - -bool RtpGenerator::SendRtp(ArrayView packet, - 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, - const PacketOptions& /* options */) { - test::RtpPacket rtcp_packet = DataToRtpPacket(packet.data(), packet.size()); - rtp_dump_writer_->WritePacket(&rtcp_packet); - return true; -} - -int RtpGenerator::GetMaxDuration() const { - int max_end_ms = 0; - for (const auto& video_stream : options_.video_streams) { - max_end_ms = std::max(video_stream.duration_ms, max_end_ms); - } - return max_end_ms; -} - -void RtpGenerator::WaitUntilAllVideoStreamsFinish() { - // Find the maximum duration required by the streams. - start_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds(); - int64_t max_end_ms = start_ms_ + GetMaxDuration(); - - int64_t current_time = 0; - do { - int64_t min_wait_time = 0; - current_time = Clock::GetRealTimeClock()->TimeInMilliseconds(); - // Stop any streams that are no longer active. - for (size_t i = 0; i < options_.video_streams.size(); ++i) { - const int64_t end_ms = start_ms_ + options_.video_streams[i].duration_ms; - if (current_time > end_ms) { - video_send_streams_[i]->Stop(); - } else { - min_wait_time = std::min(min_wait_time, end_ms - current_time); - } - } - Thread::Current()->SleepMs(min_wait_time); - } while (current_time < max_end_ms); -} - -test::RtpPacket RtpGenerator::DataToRtpPacket(const uint8_t* packet, - size_t packet_len) { - 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 = - Clock::GetRealTimeClock()->TimeInMilliseconds() - start_ms_; - return rtp_packet; -} - -} // namespace webrtc diff --git a/rtc_tools/rtp_generator/rtp_generator.h b/rtc_tools/rtp_generator/rtp_generator.h deleted file mode 100644 index 4510b06e91..0000000000 --- a/rtc_tools/rtp_generator/rtp_generator.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef 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/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" -#include "call/rtp_config.h" -#include "call/video_send_stream.h" -#include "media/engine/webrtc_video_engine.h" -#include "test/frame_generator_capturer.h" -#include "test/rtp_file_reader.h" -#include "test/rtp_file_writer.h" - -namespace webrtc { - -// Specifies all the configurable options to pass to the corpus generator. -// If modified please update the JSON parser as well as all. -struct RtpGeneratorOptions { - struct VideoSendStreamConfig { - // The time to record the RtpDump for. - int duration_ms = 10000; - // The video resolution width. - int video_width = 640; - // The video resolution height. - int video_height = 480; - // The video fps. - int video_fps = 24; - // The number of squares to render. - int num_squares = 128; - // The individual RTP configuration. - RtpConfig rtp; - }; - // Multiple senders can be active at once on an rtp channel. - std::vector video_streams; -}; - -// Attempts to parse RtpGeneratorOptions from a JSON file. Any failures -// will result in std::nullopt. -std::optional ParseRtpGeneratorOptionsFromFile( - const std::string& options_file); - -// The RtpGenerator allows generating of corpus material intended to be -// used by fuzzers. It accepts a simple Json configuration file that allows the -// user to configure the codec, extensions and error correction mechanisms. It -// will then proceed to generate an rtpdump for the specified duration using -// that configuration that can be replayed by the video_replayer. The receiver -// configuration JSON will also be output and can be replayed as follows: -// ./rtp_generator --config_file sender_config --output_rtpdump my.rtpdump -// --output_config receiver_config.json -// ./video_replay --config_file receiver_config.json --output_file my.rtpdump -// -// It achieves this by creating a VideoStreamSender, configuring it as requested -// by the user and then intercepting all outgoing RTP packets and writing them -// to a file instead of out of the network. It then uses this sender -// configuration to generate a mirror receiver configuration that can be read by -// the video_replay program. -class RtpGenerator final : public Transport { - public: - // Construct a new RtpGenerator using the specified options. - explicit RtpGenerator(const RtpGeneratorOptions& options); - - RtpGenerator() = delete; - RtpGenerator(const RtpGenerator&) = delete; - RtpGenerator& operator=(const RtpGenerator&) = delete; - - // Cleans up the VideoSendStream. - ~RtpGenerator() override; - // Generates an rtp_dump that is written out to - void GenerateRtpDump(const std::string& rtp_dump_path); - - private: - // Transport implementation - // Captured RTP packets are written to the RTPDump file instead of over the - // network. - bool SendRtp(ArrayView packet, - const PacketOptions& options) override; - // RTCP packets are ignored for now. - bool SendRtcp(ArrayView packet, - const PacketOptions& options) override; - // Returns the maximum duration - int GetMaxDuration() const; - // Waits until all video streams have finished. - void WaitUntilAllVideoStreamsFinish(); - // Converts packet data into an RtpPacket. - test::RtpPacket DataToRtpPacket(const uint8_t* packet, size_t packet_len); - - const RtpGeneratorOptions options_; - const Environment env_; - std::unique_ptr video_encoder_factory_; - std::unique_ptr video_decoder_factory_; - std::unique_ptr - video_bitrate_allocator_factory_; - std::unique_ptr call_; - std::unique_ptr rtp_dump_writer_; - std::vector> frame_generators_; - std::vector video_send_streams_; - std::vector durations_ms_; - uint32_t start_ms_ = 0; -}; - -} // namespace webrtc - -#endif // RTC_TOOLS_RTP_GENERATOR_RTP_GENERATOR_H_ diff --git a/rtc_tools/sanitizers_unittest.cc b/rtc_tools/sanitizers_unittest.cc index 3169ead502..64974cfa99 100644 --- a/rtc_tools/sanitizers_unittest.cc +++ b/rtc_tools/sanitizers_unittest.cc @@ -8,16 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - -#include -#include - -#include "rtc_base/checks.h" -#include "rtc_base/null_socket_server.h" -#include "rtc_base/thread.h" -#include "test/gtest.h" +#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep + +#include "rtc_base/checks.h" // IWYU pragma: keep +#include "rtc_base/null_socket_server.h" // IWYU pragma: keep +#include "rtc_base/thread.h" // IWYU pragma: keep +#include "test/gtest.h" // IWYU pragma: keep namespace webrtc { diff --git a/rtc_tools/unpack_aecdump/unpack.cc b/rtc_tools/unpack_aecdump/unpack.cc index ce0762b198..ede55a50c2 100644 --- a/rtc_tools/unpack_aecdump/unpack.cc +++ b/rtc_tools/unpack_aecdump/unpack.cc @@ -13,20 +13,21 @@ // The debug files are dumped as protobuf blobs. For analysis, it's necessary // to unpack the file into its component parts: audio and other data. -#include -#include -#include -#include - +#include +#include +#include +#include +#include #include #include +#include #include #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "api/audio/audio_view.h" #include "api/function_view.h" #include "common_audio/channel_buffer.h" -#include "common_audio/include/audio_util.h" #include "common_audio/wav_file.h" #include "modules/audio_processing/test/protobuf_utils.h" #include "rtc_base/checks.h" diff --git a/rtc_tools/video_encoder/encoded_image_file_writer.cc b/rtc_tools/video_encoder/encoded_image_file_writer.cc index 66207ddaa7..5b1b12f3b6 100644 --- a/rtc_tools/video_encoder/encoded_image_file_writer.cc +++ b/rtc_tools/video_encoder/encoded_image_file_writer.cc @@ -9,8 +9,20 @@ */ #include "rtc_tools/video_encoder/encoded_image_file_writer.h" +#include +#include +#include + +#include "api/video/encoded_image.h" +#include "api/video/video_frame_type.h" +#include "api/video_codecs/scalability_mode.h" +#include "api/video_codecs/video_codec.h" #include "modules/video_coding/svc/scalability_mode_util.h" +#include "modules/video_coding/utility/ivf_file_writer.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/strings/string_builder.h" +#include "rtc_base/system/file_wrapper.h" namespace webrtc { namespace test { diff --git a/rtc_tools/video_encoder/encoded_image_file_writer.h b/rtc_tools/video_encoder/encoded_image_file_writer.h index abe01b61b2..927e679e93 100644 --- a/rtc_tools/video_encoder/encoded_image_file_writer.h +++ b/rtc_tools/video_encoder/encoded_image_file_writer.h @@ -15,7 +15,8 @@ #include #include -#include "modules/video_coding/include/video_codec_interface.h" +#include "api/video/encoded_image.h" +#include "api/video_codecs/video_codec.h" #include "modules/video_coding/utility/ivf_file_writer.h" namespace webrtc { diff --git a/rtc_tools/video_file_reader.cc b/rtc_tools/video_file_reader.cc index 70e17ca7fa..1d2e87e722 100644 --- a/rtc_tools/video_file_reader.cc +++ b/rtc_tools/video_file_reader.cc @@ -10,14 +10,19 @@ #include "rtc_tools/video_file_reader.h" +#include +#include #include +#include #include #include #include #include "absl/strings/match.h" #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/logging.h" #include "rtc_base/string_encode.h" diff --git a/rtc_tools/video_file_reader.h b/rtc_tools/video_file_reader.h index 0ff0af3a6d..3e8293b545 100644 --- a/rtc_tools/video_file_reader.h +++ b/rtc_tools/video_file_reader.h @@ -10,8 +10,7 @@ #ifndef RTC_TOOLS_VIDEO_FILE_READER_H_ #define RTC_TOOLS_VIDEO_FILE_READER_H_ -#include - +#include #include #include #include diff --git a/rtc_tools/video_file_reader_unittest.cc b/rtc_tools/video_file_reader_unittest.cc index cd81dd1785..3a5bb630be 100644 --- a/rtc_tools/video_file_reader_unittest.cc +++ b/rtc_tools/video_file_reader_unittest.cc @@ -10,10 +10,11 @@ #include "rtc_tools/video_file_reader.h" -#include - +#include #include +#include "api/scoped_refptr.h" +#include "api/video/video_frame_buffer.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" diff --git a/rtc_tools/video_file_writer.cc b/rtc_tools/video_file_writer.cc index 57628a207f..2a1bc67cc6 100644 --- a/rtc_tools/video_file_writer.cc +++ b/rtc_tools/video_file_writer.cc @@ -10,14 +10,16 @@ #include "rtc_tools/video_file_writer.h" -#include - +#include #include #include #include "absl/strings/match.h" +#include "api/scoped_refptr.h" #include "api/video/video_frame_buffer.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_tools/video_file_reader.h" namespace webrtc { namespace test { diff --git a/rtc_tools/video_file_writer_unittest.cc b/rtc_tools/video_file_writer_unittest.cc index 7c8b65df8d..dd4a36d709 100644 --- a/rtc_tools/video_file_writer_unittest.cc +++ b/rtc_tools/video_file_writer_unittest.cc @@ -10,11 +10,10 @@ #include "rtc_tools/video_file_writer.h" -#include - #include #include +#include "api/scoped_refptr.h" #include "api/video/video_frame_buffer.h" #include "rtc_tools/video_file_reader.h" #include "test/gtest.h" diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index d281a8c316..0eb2163f08 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include +#include #include #include #include diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 0d4c83800b..fb33a23a07 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -46,6 +46,7 @@ rtc_library("sdk_tests") { sources = [ "media_constraints_unittest.cc" ] deps = [ ":media_constraints", + "../api:libjingle_peerconnection_api", "../test:test_support", ] } @@ -184,6 +185,27 @@ if (is_ios || is_mac) { } } + rtc_library("core_audio_helpers_objc") { + sources = [ + "objc/helpers/AudioTimeStamp+Nanoseconds.h", + "objc/helpers/AudioTimeStamp+Nanoseconds.mm", + ] + + deps = [ + ":base_objc", + "../rtc_base:checks", + ] + + frameworks = [ "CoreAudio.framework" ] + + configs += [ + "..:common_objc", + ":used_from_extension", + ] + + public_configs = [ ":common_config_objc" ] + } + if (!build_with_chromium) { rtc_library("callback_logger_objc") { sources = [ @@ -232,10 +254,6 @@ 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", @@ -248,7 +266,6 @@ if (is_ios || is_mac) { "../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", @@ -312,6 +329,7 @@ if (is_ios || is_mac) { ":audio_objc", ":audio_session_observer", ":base_objc", + ":core_audio_helpers_objc", "../api:array_view", "../api:scoped_refptr", "../api:sequence_checker", @@ -320,7 +338,6 @@ if (is_ios || is_mac) { "../api/task_queue", "../api/task_queue:pending_task_safety_flag", "../modules/audio_device:audio_device_buffer", - "../modules/audio_device:audio_device_config", "../modules/audio_device:audio_device_generic", "../rtc_base:buffer", "../rtc_base:checks", @@ -503,6 +520,7 @@ if (is_ios || is_mac) { deps = [ ":audio_device_api_objc", + ":core_audio_helpers_objc", "../api:array_view", "../api:make_ref_counted", "../api:refcountedbase", @@ -1094,6 +1112,7 @@ if (is_ios || is_mac) { ":videorendereradapter_objc", ":videosource_objc", ":videotoolbox_objc", + "../api:create_modular_peer_connection_factory", "../api:dtmf_sender_interface", "../api:enable_media", "../api:field_trials_view", @@ -1112,6 +1131,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", "../api/environment:environment_factory", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue:default_task_queue_factory", diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index 1d680923e5..f3db81c780 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -136,11 +136,13 @@ if (is_android) { ] deps = [ + ":internal_jni", ":libjingle_peerconnection_jni", ":libjingle_peerconnection_metrics_default_jni", ":native_api_jni", ":video_egl_jni", "../../pc:libjingle_peerconnection", + "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:ssl_adapter", "//third_party/jni_zero", @@ -698,13 +700,17 @@ if (current_os == "linux" || is_android) { ":generated_video_jni", ":native_api_jni", ":videoframe_jni", + "../../api:array_view", "../../api:libjingle_peerconnection_api", + "../../api:make_ref_counted", "../../api:media_stream_interface", + "../../api:scoped_refptr", "../../api:sequence_checker", "../../api/environment", "../../api/task_queue", "../../api/video:encoded_image", "../../api/video:render_resolution", + "../../api/video:video_bitrate_allocation", "../../api/video:video_frame", "../../api/video:video_frame_type", "../../api/video:video_rtp_headers", @@ -718,6 +724,7 @@ if (current_os == "linux" || is_android) { "../../modules/video_coding/svc:scalable_video_controller", "../../rtc_base:checks", "../../rtc_base:logging", + "../../rtc_base:macromagic", "../../rtc_base:race_checker", "../../rtc_base:refcount", "../../rtc_base:safe_conversions", @@ -814,6 +821,7 @@ if (current_os == "linux" || is_android) { ":native_api_stacktrace", "..:media_constraints", "../../api:audio_options_api", + "../../api:create_modular_peer_connection_factory", "../../api:dtmf_sender_interface", "../../api:enable_media", "../../api:fec_controller_api", @@ -908,6 +916,7 @@ if (current_os == "linux" || is_android) { deps = [ ":base_jni", ":generated_libvpx_vp8_jni", + ":native_api_jni", ":video_jni", "../../api/environment", "../../modules/video_coding:webrtc_vp8", @@ -921,6 +930,7 @@ if (current_os == "linux" || is_android) { deps = [ ":base_jni", ":generated_libvpx_vp9_jni", + ":native_api_jni", ":video_jni", "../../api/environment", "../../modules/video_coding:webrtc_vp9", @@ -934,6 +944,7 @@ if (current_os == "linux" || is_android) { deps = [ ":base_jni", ":generated_libaom_av1_encoder_jni", + ":native_api_jni", ":video_jni", "../../api/environment", "../../modules/video_coding/codecs/av1:libaom_av1_encoder", @@ -989,7 +1000,6 @@ if (current_os == "linux" || is_android) { "native_api/jni/class_loader.cc", "native_api/jni/java_types.cc", "native_api/jni/jvm.cc", - "src/jni/jni_generator_helper.h", ] public = [ @@ -1104,7 +1114,9 @@ if (current_os == "linux" || is_android) { ":base_jni", ":peerconnection_jni", "../../api:libjingle_peerconnection_api", + "../../api:scoped_refptr", "../../api/video_codecs:video_codecs_api", + "../../rtc_base:socket_factory", "../../rtc_base:threading", ] } @@ -1143,6 +1155,7 @@ if (current_os == "linux" || is_android) { ":videoframe_jni", "../../api:libjingle_peerconnection_api", "../../api:media_stream_interface", + "../../api:scoped_refptr", "../../api/video:video_frame", "../../api/video:video_rtp_headers", "../../rtc_base:refcount", @@ -1348,19 +1361,16 @@ if (current_os == "linux" || is_android) { "java/util/ArrayList.class", "java/lang/Enum.class", ] - 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" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } # Generated JNI for public JNI targets, matching order of targets @@ -1374,7 +1384,6 @@ if (current_os == "linux" || is_android) { "src/java/org/webrtc/JniCommon.java", ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_video_jni") { @@ -1404,13 +1413,11 @@ if (current_os == "linux" || is_android) { "src/java/org/webrtc/WrappedNativeI420Buffer.java", ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_video_egl_jni") { sources = [ "src/java/org/webrtc/EglBase10Impl.java" ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_libvpx_vp8_jni") { @@ -1420,7 +1427,6 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_libvpx_vp9_jni") { @@ -1430,21 +1436,18 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_libaom_av1_encoder_jni") { sources = [ "api/org/webrtc/LibaomAv1Encoder.java" ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_dav1d_jni") { sources = [ "api/org/webrtc/Dav1dDecoder.java" ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_swcodecs_jni") { @@ -1454,13 +1457,11 @@ if (current_os == "linux" || is_android) { ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_rtcerror_jni") { sources = [ "src/java/org/webrtc/RtcError.java" ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_peerconnection_jni") { @@ -1497,13 +1498,11 @@ if (current_os == "linux" || is_android) { "api/org/webrtc/TurnCustomizer.java", ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_java_audio_jni") { sources = [ "api/org/webrtc/audio/JavaAudioDeviceModule.java" ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_builtin_audio_codecs_jni") { @@ -1512,7 +1511,6 @@ if (current_os == "linux" || is_android) { "api/org/webrtc/BuiltinAudioEncoderFactoryFactory.java", ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } # Generated JNI for native API targets @@ -1524,20 +1522,17 @@ if (current_os == "linux" || is_android) { "src/java/org/webrtc/WebRtcClassLoader.java", ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } # Generated JNI for internal targets. generate_jni("generated_logging_jni") { sources = [ "src/java/org/webrtc/JNILogging.java" ] - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_audio_device_module_base_jni") { sources = [ "src/java/org/webrtc/audio/WebRtcAudioManager.java" ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } generate_jni("generated_java_audio_device_module_native_jni") { @@ -1546,7 +1541,6 @@ if (current_os == "linux" || is_android) { "src/java/org/webrtc/audio/WebRtcAudioTrack.java", ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } } @@ -1642,10 +1636,12 @@ if (is_android) { deps = [ ":instrumentationtests_jni", + ":internal_jni", ":libjingle_peerconnection_jni", ":libjingle_peerconnection_metrics_default_jni", ":native_api_jni", "../../pc:libjingle_peerconnection", + "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:ssl_adapter", ] @@ -1682,6 +1678,7 @@ if (is_android) { ":native_api_jni", "../../rtc_base:checks", "../../rtc_base:logging", + "//third_party/jni_zero", ] } @@ -1716,6 +1713,7 @@ if (is_android) { ":native_api_video", ":opensles_audio_device_module", ":video_jni", + "../../api:create_modular_peer_connection_factory", "../../api:enable_media_with_defaults", "../../api:field_trials_view", "../../api:libjingle_peerconnection_api", @@ -1745,8 +1743,8 @@ if (is_android) { "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:inline", + "../../test:create_test_field_trials", "../../test:fileutils", - "../../test:scoped_key_value_config", "../../test:test_support", "../../testing/gtest", "//third_party/abseil-cpp/absl/memory", @@ -1790,7 +1788,6 @@ if (is_android) { "native_unittests/org/webrtc/PeerConnectionFactoryInitializationHelper.java", ] namespace = "webrtc::jni" - jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } robolectric_binary("android_sdk_junit_tests") { diff --git a/sdk/android/api/org/webrtc/IceCandidate.java b/sdk/android/api/org/webrtc/IceCandidate.java index 9278f1bef6..20b62387a0 100644 --- a/sdk/android/api/org/webrtc/IceCandidate.java +++ b/sdk/android/api/org/webrtc/IceCandidate.java @@ -59,6 +59,11 @@ String getSdp() { return sdp; } + @CalledByNative + int getSdpMLineIndex() { + return sdpMLineIndex; + } + /** equals() checks sdpMid, sdpMLineIndex, and sdp for equality. */ @Override public boolean equals(@Nullable Object object) { diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java index 7523dcadfb..9d06d81c73 100644 --- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java +++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java @@ -95,6 +95,9 @@ public static class Builder { this.applicationContext = applicationContext; } + // Deprecated, use PeerConnectionFactory.Builder.setFieldTrials instead. + // TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026. + @Deprecated public Builder setFieldTrials(String fieldTrials) { this.fieldTrials = fieldTrials; return this; @@ -341,7 +344,8 @@ public static void shutdownInternalTracer() { // Field trial initialization. Must be called before PeerConnectionFactory // is created. - // Deprecated, use PeerConnectionFactory.initialize instead. + // Deprecated, use PeerConnectionFactory.Builder.setFieldTrials instead. + // TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026. @Deprecated public static void initializeFieldTrials(String fieldTrialsInitString) { nativeInitializeFieldTrials(fieldTrialsInitString); diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java index 33807af2f4..366162fb8c 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java @@ -1129,6 +1129,50 @@ public void testDataChannelOnlySession() throws Exception { System.gc(); } + @Test + @MediumTest + public void testSetConfigurationUnchangedAfterSetLocalDescription() throws Exception { + PeerConnectionFactory factory = PeerConnectionFactory.builder().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); + + // Create a data channel and set local description to kick off the ICE candidate gathering. + offeringExpectations.expectRenegotiationNeeded(); + DataChannel offeringDC = offeringPC.createDataChannel("offeringDC", new DataChannel.Init()); + assertEquals("offeringDC", offeringDC.label()); + + offeringExpectations.setDataChannel(offeringDC); + SdpObserverLatch sdpLatch = new SdpObserverLatch(); + offeringPC.createOffer(sdpLatch, new MediaConstraints()); + assertTrue(sdpLatch.await()); + SessionDescription offerSdp = sdpLatch.getSdp(); + assertEquals(offerSdp.type, SessionDescription.Type.OFFER); + assertFalse(offerSdp.description.isEmpty()); + + sdpLatch = new SdpObserverLatch(); + offeringExpectations.expectSignalingChange(SignalingState.HAVE_LOCAL_OFFER); + offeringPC.setLocalDescription(sdpLatch, offerSdp); + assertTrue(sdpLatch.await()); + assertNull(sdpLatch.getSdp()); + + assertEquals(offeringPC.getLocalDescription().type, offerSdp.type); + + // Wait until we satisfy all expectations in the setup. + assertTrue(offeringExpectations.waitForAllExpectationsToBeSatisfied(DEFAULT_TIMEOUT_SECONDS)); + + // Setting the unchanged configuration after setting local offer should work. + assertTrue(offeringPC.setConfiguration(rtcConfig)); + } + @Test @MediumTest public void testSurfaceIceCandidatesBeforeIceGatheringStateComplete() throws Exception { @@ -1242,6 +1286,7 @@ public void testSurfaceIceCandidatesWhenIceTransportTypeChanged() throws Excepti PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(Collections.emptyList()); rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN; + rtcConfig.cryptoOptions = CryptoOptions.builder().createCryptoOptions(); // NONE would prevent any candidate being signaled to the PC. rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.NONE; // We must have the continual gathering enabled to allow the surfacing of candidates on the ICE 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 06a66df61c..99166533b7 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 @@ -19,13 +19,8 @@ #include "api/scoped_refptr.h" #include "rtc_base/logging.h" #include "rtc_base/ref_count.h" - -#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO) -#include "sdk/android/src/jni/audio_device/aaudio_player.h" -#include "sdk/android/src/jni/audio_device/aaudio_recorder.h" -#endif - #include "sdk/android/native_api/jni/application_context_provider.h" +#include "sdk/android/native_api/jni/jvm.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/audio_device/opensles_player.h" @@ -34,6 +29,11 @@ #include "system_wrappers/include/metrics.h" #include "third_party/jni_zero/jni_zero.h" +#if defined(WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO) +#include "sdk/android/src/jni/audio_device/aaudio_player.h" +#include "sdk/android/src/jni/audio_device/aaudio_recorder.h" +#endif + namespace webrtc { namespace { diff --git a/sdk/android/native_api/jni/java_types.h b/sdk/android/native_api/jni/java_types.h index 7e39160a0a..83bf93d9b2 100644 --- a/sdk/android/native_api/jni/java_types.h +++ b/sdk/android/native_api/jni/java_types.h @@ -19,8 +19,9 @@ #include +#include +#include #include -#include #include #include #include @@ -29,6 +30,7 @@ #include "api/sequence_checker.h" #include "rtc_base/checks.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" +#include "third_party/jni_zero/jni_zero.h" // Abort the process if `jni` has a Java exception pending. // This macros uses the comma operator to execute ExceptionDescribe diff --git a/sdk/android/native_api/jni/scoped_java_ref.h b/sdk/android/native_api/jni/scoped_java_ref.h index 07f7d9bfe7..09b85727d8 100644 --- a/sdk/android/native_api/jni/scoped_java_ref.h +++ b/sdk/android/native_api/jni/scoped_java_ref.h @@ -16,9 +16,6 @@ #include -#include - -#include "sdk/android/native_api/jni/jvm.h" #include "third_party/jni_zero/jni_zero.h" 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 c2208a06be..74ac367453 100644 --- a/sdk/android/native_api/peerconnection/peer_connection_factory.cc +++ b/sdk/android/native_api/peerconnection/peer_connection_factory.cc @@ -14,6 +14,10 @@ #include #include +#include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" +#include "rtc_base/socket_factory.h" +#include "rtc_base/thread.h" #include "sdk/android/src/jni/pc/peer_connection_factory.h" namespace webrtc { diff --git a/sdk/android/native_api/peerconnection/peer_connection_factory.h b/sdk/android/native_api/peerconnection/peer_connection_factory.h index e249f0f92a..1f5d845fd5 100644 --- a/sdk/android/native_api/peerconnection/peer_connection_factory.h +++ b/sdk/android/native_api/peerconnection/peer_connection_factory.h @@ -16,6 +16,8 @@ #include #include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" +#include "rtc_base/socket_factory.h" #include "rtc_base/thread.h" namespace webrtc { diff --git a/sdk/android/native_api/video/video_source.h b/sdk/android/native_api/video/video_source.h index abf22ae974..7f6779d458 100644 --- a/sdk/android/native_api/video/video_source.h +++ b/sdk/android/native_api/video/video_source.h @@ -14,6 +14,7 @@ #include #include "api/media_stream_interface.h" +#include "api/scoped_refptr.h" #include "rtc_base/thread.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" diff --git a/sdk/android/native_api/video/wrapper.h b/sdk/android/native_api/video/wrapper.h index bb1dd8bfbf..9a829b61b0 100644 --- a/sdk/android/native_api/video/wrapper.h +++ b/sdk/android/native_api/video/wrapper.h @@ -15,8 +15,8 @@ #include -#include "api/media_stream_interface.h" #include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { diff --git a/sdk/android/native_unittests/DEPS b/sdk/android/native_unittests/DEPS index 7825103fb4..7ea7d6a86b 100644 --- a/sdk/android/native_unittests/DEPS +++ b/sdk/android/native_unittests/DEPS @@ -2,4 +2,5 @@ include_rules = [ "+modules/audio_device/include/audio_device.h", "+modules/audio_device/include/mock_audio_transport.h", "+system_wrappers/include", + "+third_party/jni_zero", ] diff --git a/sdk/android/native_unittests/android_network_monitor_unittest.cc b/sdk/android/native_unittests/android_network_monitor_unittest.cc index defbf9e936..1544049524 100644 --- a/sdk/android/native_unittests/android_network_monitor_unittest.cc +++ b/sdk/android/native_unittests/android_network_monitor_unittest.cc @@ -15,8 +15,8 @@ #include "rtc_base/thread.h" #include "sdk/android/native_api/jni/application_context_provider.h" #include "sdk/android/src/jni/jni_helpers.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" namespace webrtc { namespace test { @@ -71,7 +71,7 @@ class AndroidNetworkMonitorTest : public ::testing::Test { } protected: - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_ = CreateTestFieldTrials(); webrtc::AutoThread main_thread_; std::unique_ptr network_monitor_; }; @@ -115,9 +115,8 @@ TEST_F(AndroidNetworkMonitorTest, TestFindNetworkHandleUsingFullIpv6Address) { TEST_F(AndroidNetworkMonitorTest, TestFindNetworkHandleIgnoringIpv6TemporaryPart) { - ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-FindNetworkHandleWithoutIpv6TemporaryPart/Enabled/"); + field_trials_.Set("WebRTC-FindNetworkHandleWithoutIpv6TemporaryPart", + "Enabled"); // Start() updates the states introduced by the field trial. network_monitor_->Start(); jni::NetworkHandle ipv6_handle = 200; @@ -171,8 +170,7 @@ TEST_F(AndroidNetworkMonitorTest, TestFindNetworkHandleUsingIfName) { } TEST_F(AndroidNetworkMonitorTest, TestUnderlyingVpnType) { - ScopedKeyValueConfig field_trials(field_trials_, - "WebRTC-BindUsingInterfaceName/Enabled/"); + field_trials_.Set("WebRTC-BindUsingInterfaceName", "Enabled"); jni::NetworkHandle ipv4_handle = 100; webrtc::IPAddress ipv4_address(kTestIpv4Address); jni::NetworkInformation net_info = diff --git a/sdk/android/native_unittests/codecs/wrapper_unittest.cc b/sdk/android/native_unittests/codecs/wrapper_unittest.cc index ce9f94ff03..1d8d255fc7 100644 --- a/sdk/android/native_unittests/codecs/wrapper_unittest.cc +++ b/sdk/android/native_unittests/codecs/wrapper_unittest.cc @@ -17,6 +17,8 @@ #include "api/environment/environment_factory.h" #include "media/base/media_constants.h" #include "sdk/android/generated_native_unittests_jni/CodecsWrapperTestHelper_jni.h" +#include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" #include "sdk/android/src/jni/video_encoder_wrapper.h" #include "test/gtest.h" diff --git a/sdk/android/native_unittests/java_types_unittest.cc b/sdk/android/native_unittests/java_types_unittest.cc index 9e99001d19..1762eb5eee 100644 --- a/sdk/android/native_unittests/java_types_unittest.cc +++ b/sdk/android/native_unittests/java_types_unittest.cc @@ -14,6 +14,7 @@ #include #include "sdk/android/generated_native_unittests_jni/JavaTypesTestHelper_jni.h" +#include "sdk/android/native_api/jni/jvm.h" #include "test/gtest.h" namespace webrtc { 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 f5d8470ddb..d789828628 100644 --- a/sdk/android/native_unittests/peerconnection/peer_connection_factory_unittest.cc +++ b/sdk/android/native_unittests/peerconnection/peer_connection_factory_unittest.cc @@ -15,6 +15,7 @@ #include #include +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" #include "api/peer_connection_interface.h" diff --git a/sdk/android/native_unittests/test_jni_onload.cc b/sdk/android/native_unittests/test_jni_onload.cc index 91b2f2ea4a..b7846b6250 100644 --- a/sdk/android/native_unittests/test_jni_onload.cc +++ b/sdk/android/native_unittests/test_jni_onload.cc @@ -12,11 +12,10 @@ #undef JNIEXPORT #define JNIEXPORT __attribute__((visibility("default"))) -#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "sdk/android/native_api/base/init.h" -#include "sdk/android/native_api/jni/java_types.h" #include "test/android/native_test_launcher.h" // nogncheck +#include "third_party/jni_zero/jni_zero.h" // This is called by the VM when the shared library is first loaded. JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { diff --git a/sdk/android/native_unittests/video/video_source_unittest.cc b/sdk/android/native_unittests/video/video_source_unittest.cc index 71568a5ef4..ee6df18994 100644 --- a/sdk/android/native_unittests/video/video_source_unittest.cc +++ b/sdk/android/native_unittests/video/video_source_unittest.cc @@ -14,6 +14,7 @@ #include "api/video/video_sink_interface.h" #include "sdk/android/generated_native_unittests_jni/JavaVideoSourceTestHelper_jni.h" +#include "sdk/android/native_api/jni/jvm.h" #include "test/gtest.h" namespace webrtc { diff --git a/sdk/android/src/jni/OWNERS b/sdk/android/src/jni/OWNERS index 6d01899f22..557373424b 100644 --- a/sdk/android/src/jni/OWNERS +++ b/sdk/android/src/jni/OWNERS @@ -2,6 +2,3 @@ per-file androidhistogram.cc=xalep@webrtc.org per-file androidmetrics.cc=xalep@webrtc.org per-file androidvideotracksource.*=xalep@webrtc.org per-file androidvideotracksource.cc=xalep@webrtc.org - -per-file jni_generator_helper.cc=file://infra/OWNERS -per-file jni_generator_helper.h=file://infra/OWNERS diff --git a/sdk/android/src/jni/android_network_monitor.h b/sdk/android/src/jni/android_network_monitor.h index 8b2d397312..b4b8a32fc1 100644 --- a/sdk/android/src/jni/android_network_monitor.h +++ b/sdk/android/src/jni/android_network_monitor.h @@ -187,12 +187,4 @@ class AndroidNetworkMonitorFactory : public NetworkMonitorFactory { } // namespace jni } // namespace webrtc -// TODO(magjed): Remove once external clients are updated. -namespace webrtc_jni { - -using webrtc::jni::AndroidNetworkMonitor; -using webrtc::jni::AndroidNetworkMonitorFactory; - -} // namespace webrtc_jni - #endif // SDK_ANDROID_SRC_JNI_ANDROID_NETWORK_MONITOR_H_ diff --git a/sdk/android/src/jni/android_video_track_source.cc b/sdk/android/src/jni/android_video_track_source.cc index dc5fd3d4dc..93faf3a39e 100644 --- a/sdk/android/src/jni/android_video_track_source.cc +++ b/sdk/android/src/jni/android_video_track_source.cc @@ -14,6 +14,7 @@ #include "rtc_base/logging.h" #include "sdk/android/generated_video_jni/NativeAndroidVideoTrackSource_jni.h" +#include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/video_frame.h" namespace webrtc { diff --git a/sdk/android/src/jni/android_video_track_source.h b/sdk/android/src/jni/android_video_track_source.h index 58fe8dbf83..912596de9a 100644 --- a/sdk/android/src/jni/android_video_track_source.h +++ b/sdk/android/src/jni/android_video_track_source.h @@ -13,12 +13,13 @@ #include -#include "common_video/libyuv/include/webrtc_libyuv.h" +#include +#include + #include "media/base/adapted_video_track_source.h" -#include "rtc_base/checks.h" #include "rtc_base/thread.h" #include "rtc_base/timestamp_aligner.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/audio_device/audio_record_jni.h b/sdk/android/src/jni/audio_device/audio_record_jni.h index 3eff2d488c..fa39318d36 100644 --- a/sdk/android/src/jni/audio_device/audio_record_jni.h +++ b/sdk/android/src/jni/audio_device/audio_record_jni.h @@ -13,12 +13,14 @@ #include -#include +#include +#include #include "api/audio/audio_device_defines.h" #include "api/sequence_checker.h" #include "modules/audio_device/audio_device_buffer.h" #include "sdk/android/src/jni/audio_device/audio_device_module.h" +#include "third_party/jni_zero/jni_zero.h" namespace webrtc { diff --git a/sdk/android/src/jni/encoded_image.h b/sdk/android/src/jni/encoded_image.h index 2e892861ae..e73bd567e9 100644 --- a/sdk/android/src/jni/encoded_image.h +++ b/sdk/android/src/jni/encoded_image.h @@ -13,6 +13,7 @@ #include +#include #include #include "api/video/video_frame_type.h" diff --git a/sdk/android/src/jni/h264_utils.cc b/sdk/android/src/jni/h264_utils.cc index b997a4c594..78084d607a 100644 --- a/sdk/android/src/jni/h264_utils.cc +++ b/sdk/android/src/jni/h264_utils.cc @@ -10,6 +10,7 @@ #include "api/video_codecs/h264_profile_level_id.h" #include "sdk/android/generated_video_jni/H264Utils_jni.h" +#include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/video_codec_info.h" #include "third_party/jni_zero/jni_zero.h" diff --git a/sdk/android/src/jni/jni_generator_helper.h b/sdk/android/src/jni/jni_generator_helper.h deleted file mode 100644 index 227dfb4331..0000000000 --- a/sdk/android/src/jni/jni_generator_helper.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2017 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -// Do not include this file directly. It's intended to be used only by the JNI -// generation script. We are exporting types in strange namespaces in order to -// be compatible with the generated code targeted for Chromium. - -#ifndef SDK_ANDROID_SRC_JNI_JNI_GENERATOR_HELPER_H_ -#define SDK_ANDROID_SRC_JNI_JNI_GENERATOR_HELPER_H_ - -#include - -#include - -#include "third_party/jni_zero/jni_zero_internal.h" - -#define JNI_REGISTRATION_EXPORT __attribute__((visibility("default"))) - -#if defined(WEBRTC_ARCH_X86) -// Dalvik JIT generated code doesn't guarantee 16-byte stack alignment on -// x86 - use force_align_arg_pointer to realign the stack at the JNI -// boundary. crbug.com/655248 -#define JNI_GENERATOR_EXPORT \ - __attribute__((force_align_arg_pointer)) extern "C" JNIEXPORT JNICALL -#else -#define JNI_GENERATOR_EXPORT extern "C" JNIEXPORT JNICALL -#endif - -// Re-export helpers in the old jni_generator namespace. -// TODO(b/319078685): Remove once all uses of the jni_generator has been -// updated. -namespace jni_generator { -using jni_zero::internal::kJniStackMarkerValue; - -// TODO(b/319078685): Remove JniJavaCallContextUnchecked once all uses of the -// jni_generator has been updated. -struct JniJavaCallContextUnchecked { - inline JniJavaCallContextUnchecked() { -// TODO(ssid): Implement for other architectures. -#if defined(__arm__) || defined(__aarch64__) - // This assumes that this method does not increment the stack pointer. - asm volatile("mov %0, sp" : "=r"(sp)); -#else - sp = 0; -#endif - } - - // Force no inline to reduce code size. - template - void Init(JNIEnv* env, - jclass clazz, - const char* method_name, - const char* jni_signature, - std::atomic* atomic_method_id) { - env1 = env; - - // Make sure compiler doesn't optimize out the assignment. - memcpy(&marker, &kJniStackMarkerValue, sizeof(kJniStackMarkerValue)); - // Gets PC of the calling function. - pc = reinterpret_cast(__builtin_return_address(0)); - - method_id = jni_zero::MethodID::LazyGet( - env, clazz, method_name, jni_signature, atomic_method_id); - } - - ~JniJavaCallContextUnchecked() { - // Reset so that spurious marker finds are avoided. - memset(&marker, 0, sizeof(marker)); - } - - uint64_t marker; - uintptr_t sp; - uintptr_t pc; - - JNIEnv* env1; - jmethodID method_id; -}; - -// TODO(b/319078685): Remove JniJavaCallContextChecked once all uses of the -// jni_generator has been updated. -// Context about the JNI call with exception unchecked to be stored in stack. -struct JniJavaCallContextChecked { - // Force no inline to reduce code size. - template - void Init(JNIEnv* env, - jclass clazz, - const char* method_name, - const char* jni_signature, - std::atomic* atomic_method_id) { - base.Init(env, clazz, method_name, jni_signature, atomic_method_id); - // Reset `pc` to correct caller. - base.pc = reinterpret_cast(__builtin_return_address(0)); - } - - ~JniJavaCallContextChecked() { jni_zero::CheckException(base.env1); } - - JniJavaCallContextUnchecked base; -}; - -static_assert(sizeof(JniJavaCallContextChecked) == - sizeof(JniJavaCallContextUnchecked), - "Stack unwinder cannot work with structs of different sizes."); - -} // namespace jni_generator - -#endif // SDK_ANDROID_SRC_JNI_JNI_GENERATOR_HELPER_H_ diff --git a/sdk/android/src/jni/jni_helpers.h b/sdk/android/src/jni/jni_helpers.h index 4e5781027a..d86c8fa4ad 100644 --- a/sdk/android/src/jni/jni_helpers.h +++ b/sdk/android/src/jni/jni_helpers.h @@ -16,9 +16,8 @@ #include -#include - #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" #include "sdk/android/src/jni/jvm.h" @@ -70,12 +69,4 @@ class ScopedLocalRefFrame { } // namespace jni } // namespace webrtc -// TODO(magjed): Remove once external clients are updated. -namespace webrtc_jni { - -using webrtc::AttachCurrentThreadIfNeeded; -using webrtc::jni::InitGlobalJniVariables; - -} // namespace webrtc_jni - #endif // SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ diff --git a/sdk/android/src/jni/jni_onload.cc b/sdk/android/src/jni/jni_onload.cc index 6945e7601f..05875b1b14 100644 --- a/sdk/android/src/jni/jni_onload.cc +++ b/sdk/android/src/jni/jni_onload.cc @@ -9,13 +9,15 @@ */ #include -#undef JNIEXPORT -#define JNIEXPORT __attribute__((visibility("default"))) +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/ssl_adapter.h" #include "sdk/android/native_api/jni/class_loader.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/src/jni/jvm.h" + +#undef JNIEXPORT +#define JNIEXPORT __attribute__((visibility("default"))) namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/libaom_av1_encoder.cc b/sdk/android/src/jni/libaom_av1_encoder.cc index 9ed4abf5d6..fa4f21c35f 100644 --- a/sdk/android/src/jni/libaom_av1_encoder.cc +++ b/sdk/android/src/jni/libaom_av1_encoder.cc @@ -14,7 +14,7 @@ #include "api/environment/environment.h" #include "sdk/android/generated_libaom_av1_encoder_jni/LibaomAv1Encoder_jni.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/java_types.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/native_capturer_observer.h b/sdk/android/src/jni/native_capturer_observer.h index ac4c221f53..fe2f111641 100644 --- a/sdk/android/src/jni/native_capturer_observer.h +++ b/sdk/android/src/jni/native_capturer_observer.h @@ -13,6 +13,7 @@ #include +#include "api/scoped_refptr.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" #include "sdk/android/src/jni/android_video_track_source.h" diff --git a/sdk/android/src/jni/nv12_buffer.cc b/sdk/android/src/jni/nv12_buffer.cc index be3e3353fd..ae62874ebb 100644 --- a/sdk/android/src/jni/nv12_buffer.cc +++ b/sdk/android/src/jni/nv12_buffer.cc @@ -10,12 +10,12 @@ #include +#include #include -#include "rtc_base/checks.h" #include "sdk/android/generated_video_jni/NV12Buffer_jni.h" #include "third_party/jni_zero/jni_zero.h" -#include "third_party/libyuv/include/libyuv/convert.h" +#include "third_party/libyuv/include/libyuv/planar_functions.h" #include "third_party/libyuv/include/libyuv/scale.h" namespace webrtc { diff --git a/sdk/android/src/jni/nv21_buffer.cc b/sdk/android/src/jni/nv21_buffer.cc index e5c638ffad..5fb9a4e909 100644 --- a/sdk/android/src/jni/nv21_buffer.cc +++ b/sdk/android/src/jni/nv21_buffer.cc @@ -10,14 +10,12 @@ #include -#include +#include #include "common_video/libyuv/include/webrtc_libyuv.h" #include "rtc_base/checks.h" #include "sdk/android/generated_video_jni/NV21Buffer_jni.h" #include "third_party/jni_zero/jni_zero.h" -#include "third_party/libyuv/include/libyuv/convert.h" -#include "third_party/libyuv/include/libyuv/scale.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/pc/ice_candidate.cc b/sdk/android/src/jni/pc/ice_candidate.cc index 0187927454..356a8ebc8e 100644 --- a/sdk/android/src/jni/pc/ice_candidate.cc +++ b/sdk/android/src/jni/pc/ice_candidate.cc @@ -12,6 +12,7 @@ #include +#include "api/jsep.h" #include "pc/webrtc_sdp.h" #include "sdk/android/generated_peerconnection_jni/IceCandidate_jni.h" #include "sdk/android/native_api/jni/java_types.h" @@ -37,17 +38,15 @@ ScopedJavaLocalRef CreateJavaIceCandidate(JNIEnv* env, } // namespace -Candidate JavaToNativeCandidate(JNIEnv* jni, - const JavaRef& j_candidate) { +std::unique_ptr JavaToNativeCandidate( + JNIEnv* jni, + const JavaRef& j_candidate) { std::string sdp_mid = JavaToStdString(jni, Java_IceCandidate_getSdpMid(jni, j_candidate)); std::string sdp = JavaToStdString(jni, Java_IceCandidate_getSdp(jni, j_candidate)); - Candidate candidate; - if (!SdpDeserializeCandidate(sdp_mid, sdp, &candidate, NULL)) { - RTC_LOG(LS_ERROR) << "SdpDescrializeCandidate failed with sdp " << sdp; - } - return candidate; + int sdp_mline_index = Java_IceCandidate_getSdpMLineIndex(jni, j_candidate); + return IceCandidate::Create(sdp_mid, sdp_mline_index, sdp, nullptr); } ScopedJavaLocalRef NativeToJavaCandidate(JNIEnv* env, diff --git a/sdk/android/src/jni/pc/ice_candidate.h b/sdk/android/src/jni/pc/ice_candidate.h index 608e8dcfe3..a499ef29df 100644 --- a/sdk/android/src/jni/pc/ice_candidate.h +++ b/sdk/android/src/jni/pc/ice_candidate.h @@ -23,8 +23,9 @@ namespace webrtc { namespace jni { -Candidate JavaToNativeCandidate(JNIEnv* jni, - const JavaRef& j_candidate); +std::unique_ptr JavaToNativeCandidate( + JNIEnv* jni, + const JavaRef& j_candidate); ScopedJavaLocalRef NativeToJavaCandidate(JNIEnv* env, const Candidate& candidate); diff --git a/sdk/android/src/jni/pc/media_stream.h b/sdk/android/src/jni/pc/media_stream.h index e27da820fb..8ebf709264 100644 --- a/sdk/android/src/jni/pc/media_stream.h +++ b/sdk/android/src/jni/pc/media_stream.h @@ -16,8 +16,9 @@ #include #include "api/media_stream_interface.h" +#include "api/scoped_refptr.h" #include "pc/media_stream_observer.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/pc/owned_factory_and_threads.h b/sdk/android/src/jni/pc/owned_factory_and_threads.h index 11c431bec9..4b22cb95ad 100644 --- a/sdk/android/src/jni/pc/owned_factory_and_threads.h +++ b/sdk/android/src/jni/pc/owned_factory_and_threads.h @@ -11,12 +11,12 @@ #ifndef SDK_ANDROID_SRC_JNI_PC_OWNED_FACTORY_AND_THREADS_H_ #define SDK_ANDROID_SRC_JNI_PC_OWNED_FACTORY_AND_THREADS_H_ -#include #include -#include #include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" +#include "rtc_base/socket_factory.h" #include "rtc_base/thread.h" namespace webrtc { diff --git a/sdk/android/src/jni/pc/peer_connection.cc b/sdk/android/src/jni/pc/peer_connection.cc index bdf8a8176b..aaa4d45778 100644 --- a/sdk/android/src/jni/pc/peer_connection.cc +++ b/sdk/android/src/jni/pc/peer_connection.cc @@ -705,9 +705,16 @@ static jboolean JNI_PeerConnection_RemoveIceCandidates( JNIEnv* jni, const jni_zero::JavaParamRef& j_pc, const jni_zero::JavaParamRef& j_candidates) { - std::vector candidates = - JavaToNativeVector(jni, j_candidates, &JavaToNativeCandidate); - return ExtractNativePC(jni, j_pc)->RemoveIceCandidates(candidates); + std::vector> candidates_owned = + JavaToNativeVector>( + jni, j_candidates, &JavaToNativeCandidate); + bool ret = false; + for (const auto& c : candidates_owned) { + if (ExtractNativePC(jni, j_pc)->RemoveIceCandidate(c.get())) { + ret = true; + } + } + return ret; } static jboolean JNI_PeerConnection_AddLocalStream( diff --git a/sdk/android/src/jni/pc/peer_connection_factory.cc b/sdk/android/src/jni/pc/peer_connection_factory.cc index d34f8c0d4d..910ad58c34 100644 --- a/sdk/android/src/jni/pc/peer_connection_factory.cc +++ b/sdk/android/src/jni/pc/peer_connection_factory.cc @@ -28,6 +28,7 @@ #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_options.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media.h" #include "api/environment/environment.h" #include "api/fec_controller.h" @@ -198,6 +199,8 @@ static void JNI_PeerConnectionFactory_InitializeAndroidGlobals(JNIEnv* jni) { } } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" static void JNI_PeerConnectionFactory_InitializeFieldTrials( JNIEnv* jni, const jni_zero::JavaParamRef& j_trials_init_string) { @@ -214,6 +217,7 @@ static void JNI_PeerConnectionFactory_InitializeFieldTrials( RTC_LOG(LS_INFO) << "initializeFieldTrials: " << *field_trials_init_string; field_trial::InitFieldTrialsFromString(field_trials_init_string->c_str()); } +#pragma clang diagnostic pop static void JNI_PeerConnectionFactory_InitializeInternalTracer(JNIEnv* jni) { tracing::SetupInternalTracer(); @@ -374,7 +378,10 @@ JNI_PeerConnectionFactory_CreatePeerConnectionFactory( static void JNI_PeerConnectionFactory_FreeFactory(JNIEnv*, jlong j_p) { delete reinterpret_cast(j_p); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" field_trial::InitFieldTrialsFromString(nullptr); +#pragma clang diagnostic pop GetStaticObjects().field_trials_init_string = nullptr; } diff --git a/sdk/android/src/jni/pc/peer_connection_factory.h b/sdk/android/src/jni/pc/peer_connection_factory.h index 22da8851ad..f09c904e4e 100644 --- a/sdk/android/src/jni/pc/peer_connection_factory.h +++ b/sdk/android/src/jni/pc/peer_connection_factory.h @@ -13,7 +13,11 @@ #include +#include + #include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" +#include "rtc_base/socket_factory.h" #include "rtc_base/thread.h" namespace webrtc { diff --git a/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.cc b/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.cc index b96968bab9..3017a0f7af 100644 --- a/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.cc +++ b/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.cc @@ -19,6 +19,7 @@ #include "sdk/android/generated_peerconnection_jni/RTCStatsReport_jni.h" #include "sdk/android/generated_peerconnection_jni/RTCStats_jni.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.h b/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.h index 98d08ce140..281575498e 100644 --- a/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.h +++ b/sdk/android/src/jni/pc/rtc_stats_collector_callback_wrapper.h @@ -13,8 +13,10 @@ #include -#include "api/peer_connection_interface.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "api/scoped_refptr.h" +#include "api/stats/rtc_stats_collector_callback.h" +#include "api/stats/rtc_stats_report.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/pc/rtp_receiver.h b/sdk/android/src/jni/pc/rtp_receiver.h index 20bc05d53a..787aee16b9 100644 --- a/sdk/android/src/jni/pc/rtp_receiver.h +++ b/sdk/android/src/jni/pc/rtp_receiver.h @@ -14,6 +14,7 @@ #include #include "api/rtp_receiver_interface.h" +#include "api/scoped_refptr.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { diff --git a/sdk/android/src/jni/pc/rtp_sender.h b/sdk/android/src/jni/pc/rtp_sender.h index 5d8a40cb37..8bda4ea009 100644 --- a/sdk/android/src/jni/pc/rtp_sender.h +++ b/sdk/android/src/jni/pc/rtp_sender.h @@ -14,6 +14,7 @@ #include #include "api/rtp_sender_interface.h" +#include "api/scoped_refptr.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { diff --git a/sdk/android/src/jni/pc/rtp_transceiver.h b/sdk/android/src/jni/pc/rtp_transceiver.h index 090c5f2180..efe7dd93ec 100644 --- a/sdk/android/src/jni/pc/rtp_transceiver.h +++ b/sdk/android/src/jni/pc/rtp_transceiver.h @@ -14,6 +14,7 @@ #include #include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { diff --git a/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.cc b/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.cc index 9bd7042b4e..2b1421d27d 100644 --- a/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.cc +++ b/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.cc @@ -13,6 +13,7 @@ #include "sdk/android/generated_peerconnection_jni/SSLCertificateVerifier_jni.h" #include "sdk/android/native_api/jni/class_loader.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.h b/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.h index 7bd712cda9..7741536941 100644 --- a/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.h +++ b/sdk/android/src/jni/pc/ssl_certificate_verifier_wrapper.h @@ -13,10 +13,8 @@ #include -#include - #include "rtc_base/ssl_certificate.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/pc/video.cc b/sdk/android/src/jni/pc/video.cc index 1aa7c3f231..38fb1bedc9 100644 --- a/sdk/android/src/jni/pc/video.cc +++ b/sdk/android/src/jni/pc/video.cc @@ -12,12 +12,12 @@ #include -#include - +#include "api/make_ref_counted.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" -#include "rtc_base/logging.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/src/jni/android_video_track_source.h" #include "sdk/android/src/jni/video_decoder_factory_wrapper.h" #include "sdk/android/src/jni/video_encoder_factory_wrapper.h" diff --git a/sdk/android/src/jni/pc/video.h b/sdk/android/src/jni/pc/video.h index 1b8b5de6c1..3386cb9288 100644 --- a/sdk/android/src/jni/pc/video.h +++ b/sdk/android/src/jni/pc/video.h @@ -13,7 +13,6 @@ #include -#include "api/scoped_refptr.h" #include "rtc_base/thread.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" diff --git a/sdk/android/src/jni/scoped_java_ref_counted.cc b/sdk/android/src/jni/scoped_java_ref_counted.cc index fa3e82fe25..77ccba7e3d 100644 --- a/sdk/android/src/jni/scoped_java_ref_counted.cc +++ b/sdk/android/src/jni/scoped_java_ref_counted.cc @@ -12,6 +12,7 @@ #include "rtc_base/checks.h" #include "sdk/android/generated_base_jni/RefCounted_jni.h" +#include "sdk/android/native_api/jni/jvm.h" #define CHECK_EXCEPTION(jni) \ RTC_CHECK(!jni->ExceptionCheck()) \ diff --git a/sdk/android/src/jni/video_codec_info.h b/sdk/android/src/jni/video_codec_info.h index 07b073086a..d4755ec228 100644 --- a/sdk/android/src/jni/video_codec_info.h +++ b/sdk/android/src/jni/video_codec_info.h @@ -14,7 +14,7 @@ #include #include "api/video_codecs/sdp_video_format.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/video_decoder_factory_wrapper.cc b/sdk/android/src/jni/video_decoder_factory_wrapper.cc index 1f6f4a0b8d..0e06cd2863 100644 --- a/sdk/android/src/jni/video_decoder_factory_wrapper.cc +++ b/sdk/android/src/jni/video_decoder_factory_wrapper.cc @@ -16,6 +16,7 @@ #include "rtc_base/logging.h" #include "sdk/android/generated_video_jni/VideoDecoderFactory_jni.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" #include "sdk/android/src/jni/video_codec_info.h" #include "sdk/android/src/jni/video_decoder_wrapper.h" diff --git a/sdk/android/src/jni/video_decoder_factory_wrapper.h b/sdk/android/src/jni/video_decoder_factory_wrapper.h index 689e829128..b4c347ac85 100644 --- a/sdk/android/src/jni/video_decoder_factory_wrapper.h +++ b/sdk/android/src/jni/video_decoder_factory_wrapper.h @@ -13,9 +13,14 @@ #include +#include +#include + #include "api/environment/environment.h" +#include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_decoder.h" #include "api/video_codecs/video_decoder_factory.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/video_decoder_fallback.cc b/sdk/android/src/jni/video_decoder_fallback.cc index a6d9f3bdca..ff6888a365 100644 --- a/sdk/android/src/jni/video_decoder_fallback.cc +++ b/sdk/android/src/jni/video_decoder_fallback.cc @@ -10,10 +10,14 @@ #include +#include +#include + #include "api/environment/environment.h" +#include "api/video_codecs/video_decoder.h" #include "api/video_codecs/video_decoder_software_fallback_wrapper.h" #include "sdk/android/generated_video_jni/VideoDecoderFallback_jni.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/video_decoder_wrapper.h" #include "third_party/jni_zero/jni_zero.h" diff --git a/sdk/android/src/jni/video_decoder_wrapper.cc b/sdk/android/src/jni/video_decoder_wrapper.cc index 60e2d642f8..f8d1161634 100644 --- a/sdk/android/src/jni/video_decoder_wrapper.cc +++ b/sdk/android/src/jni/video_decoder_wrapper.cc @@ -25,7 +25,9 @@ #include "sdk/android/generated_video_jni/VideoDecoderWrapper_jni.h" #include "sdk/android/generated_video_jni/VideoDecoder_jni.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" #include "sdk/android/src/jni/encoded_image.h" +#include "sdk/android/src/jni/jni_helpers.h" #include "sdk/android/src/jni/video_codec_status.h" #include "sdk/android/src/jni/video_frame.h" diff --git a/sdk/android/src/jni/video_decoder_wrapper.h b/sdk/android/src/jni/video_decoder_wrapper.h index 48298906ff..e1a4fa7afd 100644 --- a/sdk/android/src/jni/video_decoder_wrapper.h +++ b/sdk/android/src/jni/video_decoder_wrapper.h @@ -14,17 +14,24 @@ #include #include +#include #include +#include +#include +#include #include "api/sequence_checker.h" +#include "api/video/encoded_image.h" #include "api/video_codecs/video_decoder.h" #include "common_video/h264/h264_bitstream_parser.h" +#include "rtc_base/race_checker.h" +#include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" + #ifdef RTC_ENABLE_H265 #include "common_video/h265/h265_bitstream_parser.h" #endif -#include "rtc_base/race_checker.h" -#include "rtc_base/synchronization/mutex.h" -#include "sdk/android/src/jni/jni_helpers.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/video_encoder_factory_wrapper.cc b/sdk/android/src/jni/video_encoder_factory_wrapper.cc index 709fa5894e..3bc25ed5c0 100644 --- a/sdk/android/src/jni/video_encoder_factory_wrapper.cc +++ b/sdk/android/src/jni/video_encoder_factory_wrapper.cc @@ -16,6 +16,7 @@ #include "sdk/android/generated_video_jni/VideoEncoderFactory_jni.h" #include "sdk/android/native_api/jni/class_loader.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" #include "sdk/android/src/jni/video_codec_info.h" #include "sdk/android/src/jni/video_encoder_wrapper.h" diff --git a/sdk/android/src/jni/video_encoder_factory_wrapper.h b/sdk/android/src/jni/video_encoder_factory_wrapper.h index 9b383a88e9..3c5137a438 100644 --- a/sdk/android/src/jni/video_encoder_factory_wrapper.h +++ b/sdk/android/src/jni/video_encoder_factory_wrapper.h @@ -13,12 +13,14 @@ #include +#include #include #include "api/environment/environment.h" #include "api/video_codecs/sdp_video_format.h" +#include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_factory.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/video_encoder_fallback.cc b/sdk/android/src/jni/video_encoder_fallback.cc index ab539ba701..72b477ddc9 100644 --- a/sdk/android/src/jni/video_encoder_fallback.cc +++ b/sdk/android/src/jni/video_encoder_fallback.cc @@ -10,10 +10,14 @@ #include +#include +#include + #include "api/environment/environment.h" +#include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_software_fallback_wrapper.h" #include "sdk/android/generated_video_jni/VideoEncoderFallback_jni.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/video_encoder_wrapper.h" #include "third_party/jni_zero/jni_zero.h" diff --git a/sdk/android/src/jni/video_encoder_wrapper.cc b/sdk/android/src/jni/video_encoder_wrapper.cc index 6f70b743c8..8799fdf606 100644 --- a/sdk/android/src/jni/video_encoder_wrapper.cc +++ b/sdk/android/src/jni/video_encoder_wrapper.cc @@ -25,7 +25,9 @@ #include "sdk/android/generated_video_jni/VideoEncoder_jni.h" #include "sdk/android/native_api/jni/class_loader.h" #include "sdk/android/native_api/jni/java_types.h" +#include "sdk/android/native_api/jni/jvm.h" #include "sdk/android/src/jni/encoded_image.h" +#include "sdk/android/src/jni/jni_helpers.h" #include "sdk/android/src/jni/video_codec_status.h" #include "sdk/android/src/jni/video_frame.h" diff --git a/sdk/android/src/jni/video_encoder_wrapper.h b/sdk/android/src/jni/video_encoder_wrapper.h index 4998441f33..2dec560783 100644 --- a/sdk/android/src/jni/video_encoder_wrapper.h +++ b/sdk/android/src/jni/video_encoder_wrapper.h @@ -13,21 +13,30 @@ #include +#include +#include #include #include #include -#include #include +#include "api/array_view.h" +#include "api/video/encoded_image.h" +#include "api/video/video_bitrate_allocation.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 "common_video/h264/h264_bitstream_parser.h" -#ifdef RTC_ENABLE_H265 -#include "common_video/h265/h265_bitstream_parser.h" -#endif #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" #include "modules/video_coding/svc/scalable_video_controller_no_layering.h" #include "rtc_base/synchronization/mutex.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "rtc_base/thread_annotations.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" + +#ifdef RTC_ENABLE_H265 +#include "common_video/h265/h265_bitstream_parser.h" +#endif namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/video_frame.h b/sdk/android/src/jni/video_frame.h index 6335beca90..7f3f439506 100644 --- a/sdk/android/src/jni/video_frame.h +++ b/sdk/android/src/jni/video_frame.h @@ -13,9 +13,12 @@ #include +#include + +#include "api/scoped_refptr.h" #include "api/video/video_frame.h" #include "api/video/video_frame_buffer.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/video_sink.cc b/sdk/android/src/jni/video_sink.cc index 14321084d0..1855eb80e1 100644 --- a/sdk/android/src/jni/video_sink.cc +++ b/sdk/android/src/jni/video_sink.cc @@ -11,6 +11,7 @@ #include "sdk/android/src/jni/video_sink.h" #include "sdk/android/generated_video_jni/VideoSink_jni.h" +#include "sdk/android/native_api/jni/jvm.h" #include "sdk/android/src/jni/video_frame.h" namespace webrtc { diff --git a/sdk/android/src/jni/video_sink.h b/sdk/android/src/jni/video_sink.h index 5960a63c21..aa0b234e55 100644 --- a/sdk/android/src/jni/video_sink.h +++ b/sdk/android/src/jni/video_sink.h @@ -13,8 +13,9 @@ #include -#include "api/media_stream_interface.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "sdk/android/native_api/jni/scoped_java_ref.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/video_track.cc b/sdk/android/src/jni/video_track.cc index 0e11b27340..1b85188834 100644 --- a/sdk/android/src/jni/video_track.cc +++ b/sdk/android/src/jni/video_track.cc @@ -11,6 +11,9 @@ #include #include "api/media_stream_interface.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video/video_source_interface.h" #include "sdk/android/generated_video_jni/VideoTrack_jni.h" #include "sdk/android/src/jni/jni_helpers.h" #include "sdk/android/src/jni/video_sink.h" diff --git a/sdk/android/src/jni/vp8_codec.cc b/sdk/android/src/jni/vp8_codec.cc index c987f0f8ea..546ab8f564 100644 --- a/sdk/android/src/jni/vp8_codec.cc +++ b/sdk/android/src/jni/vp8_codec.cc @@ -14,7 +14,7 @@ #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "sdk/android/generated_libvpx_vp8_jni/LibvpxVp8Decoder_jni.h" #include "sdk/android/generated_libvpx_vp8_jni/LibvpxVp8Encoder_jni.h" -#include "sdk/android/src/jni/jni_helpers.h" +#include "sdk/android/native_api/jni/java_types.h" namespace webrtc { namespace jni { diff --git a/sdk/android/src/jni/vp9_codec.cc b/sdk/android/src/jni/vp9_codec.cc index dcce5bb5e8..f4e7e5ba23 100644 --- a/sdk/android/src/jni/vp9_codec.cc +++ b/sdk/android/src/jni/vp9_codec.cc @@ -14,6 +14,7 @@ #include "modules/video_coding/codecs/vp9/include/vp9.h" #include "sdk/android/generated_libvpx_vp9_jni/LibvpxVp9Decoder_jni.h" #include "sdk/android/generated_libvpx_vp9_jni/LibvpxVp9Encoder_jni.h" +#include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/jni_helpers.h" namespace webrtc { diff --git a/sdk/android/src/jni/wrapped_native_i420_buffer.h b/sdk/android/src/jni/wrapped_native_i420_buffer.h index 12750af661..d542ce4993 100644 --- a/sdk/android/src/jni/wrapped_native_i420_buffer.h +++ b/sdk/android/src/jni/wrapped_native_i420_buffer.h @@ -13,6 +13,7 @@ #include +#include "api/scoped_refptr.h" #include "api/video/video_frame_buffer.h" #include "sdk/android/native_api/jni/scoped_java_ref.h" diff --git a/sdk/android/src/jni/yuv_helper.cc b/sdk/android/src/jni/yuv_helper.cc index 3197d5e1ef..1650296f9e 100644 --- a/sdk/android/src/jni/yuv_helper.cc +++ b/sdk/android/src/jni/yuv_helper.cc @@ -10,11 +10,14 @@ #include +#include + #include "sdk/android/generated_video_jni/YuvHelper_jni.h" -#include "sdk/android/src/jni/jni_helpers.h" #include "third_party/jni_zero/jni_zero.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/rotate.h" namespace webrtc { namespace jni { diff --git a/sdk/media_constraints.h b/sdk/media_constraints.h index c1d94234f2..e72588c49e 100644 --- a/sdk/media_constraints.h +++ b/sdk/media_constraints.h @@ -16,8 +16,8 @@ #ifndef SDK_MEDIA_CONSTRAINTS_H_ #define SDK_MEDIA_CONSTRAINTS_H_ -#include - +#include +#include #include #include #include diff --git a/sdk/media_constraints_unittest.cc b/sdk/media_constraints_unittest.cc index 5e6b157e3a..1b0af08ab7 100644 --- a/sdk/media_constraints_unittest.cc +++ b/sdk/media_constraints_unittest.cc @@ -10,6 +10,7 @@ #include "sdk/media_constraints.h" +#include "api/peer_connection_interface.h" #include "test/gtest.h" namespace webrtc { diff --git a/sdk/objc/api/peerconnection/RTCDtmfSender.mm b/sdk/objc/api/peerconnection/RTCDtmfSender.mm index 524245061f..56b43efbab 100644 --- a/sdk/objc/api/peerconnection/RTCDtmfSender.mm +++ b/sdk/objc/api/peerconnection/RTCDtmfSender.mm @@ -14,6 +14,7 @@ #import "helpers/NSString+StdString.h" #include "api/scoped_refptr.h" +#include "rtc_base/checks.h" #include "rtc_base/time_utils.h" @implementation RTC_OBJC_TYPE (RTCDtmfSender) { diff --git a/sdk/objc/api/peerconnection/RTCFieldTrials.h b/sdk/objc/api/peerconnection/RTCFieldTrials.h index a61a2b3f98..8f924074c6 100644 --- a/sdk/objc/api/peerconnection/RTCFieldTrials.h +++ b/sdk/objc/api/peerconnection/RTCFieldTrials.h @@ -28,5 +28,7 @@ RTC_EXTERN NSString *const kRTCFieldTrialEnabledValue; * values. See above for valid keys and values. Must be called before any other * call into WebRTC. See: webrtc/system_wrappers/include/field_trial.h */ +// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026. +RTC_OBJC_DEPRECATED("Pass field trials when building PeerConnectionFactory") RTC_EXTERN void RTCInitFieldTrialDictionary( NSDictionary *fieldTrials); diff --git a/sdk/objc/api/peerconnection/RTCFieldTrials.mm b/sdk/objc/api/peerconnection/RTCFieldTrials.mm index 80619b3291..8e38fab7f2 100644 --- a/sdk/objc/api/peerconnection/RTCFieldTrials.mm +++ b/sdk/objc/api/peerconnection/RTCFieldTrials.mm @@ -58,5 +58,8 @@ void RTCInitFieldTrialDictionary( RTCLogError(@"Failed to convert field trial string."); return; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" webrtc::field_trial::InitFieldTrialsFromString(gFieldTrialInitString); +#pragma clang diagnostic pop } diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index 7b6b3bfc27..dbac2ab2d5 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -636,19 +636,13 @@ - (void)addIceCandidate:(RTC_OBJC_TYPE(RTCIceCandidate) *)candidate } - (void)removeIceCandidates: (NSArray *)iceCandidates { - std::vector candidates; for (RTC_OBJC_TYPE(RTCIceCandidate) * iceCandidate in iceCandidates) { - std::unique_ptr candidate( + std::unique_ptr candidate( iceCandidate.nativeCandidate); if (candidate) { - candidates.push_back(candidate->candidate()); - // Need to fill the transport name from the sdp_mid. - candidates.back().set_transport_name(candidate->sdp_mid()); + _peerConnection->RemoveIceCandidate(candidate.get()); } } - if (!candidates.empty()) { - _peerConnection->RemoveIceCandidates(candidates); - } } - (void)addStream:(RTC_OBJC_TYPE(RTCMediaStream) *)stream { diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 19fde517d7..4a915f7ebf 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -35,6 +35,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/create_modular_peer_connection_factory.h" #include "api/enable_media.h" #include "api/environment/environment_factory.h" #include "api/rtc_event_log/rtc_event_log_factory.h" diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm index 3e18fd1c57..0bfad821df 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm @@ -19,7 +19,7 @@ #include "sdk/objc/native/api/video_encoder_factory.h" #if defined(WEBRTC_IOS) -#include "api/environment/environment_factory.h" +#include "api/environment/environment.h" #import "sdk/objc/native/api/audio_device_module.h" #endif @@ -43,8 +43,9 @@ + (RTCPeerConnectionFactoryBuilder *)defaultBuilder { [builder setVideoDecoderFactory:std::move(videoDecoderFactory)]; #if defined(WEBRTC_IOS) - [builder setAudioDeviceModule:webrtc::CreateAudioDeviceModule( - webrtc::CreateEnvironment())]; + [builder setAudioDeviceModuleBuilder:^(const webrtc::Environment &env) { + return webrtc::CreateAudioDeviceModule(env); + }]; #endif return builder; } diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h index 8d2c47365c..81d9a3f4fe 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h @@ -14,6 +14,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.h" #include "api/field_trials_view.h" #include "api/scoped_refptr.h" #include "api/video_codecs/video_decoder_factory.h" @@ -44,6 +45,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)setAudioDeviceModule: (webrtc::scoped_refptr)audioDeviceModule; +- (void)setAudioDeviceModuleBuilder: + (webrtc::scoped_refptr (^)( + const webrtc::Environment &))audioDeviceModuleBuilder; + - (void)setAudioProcessingModule: (webrtc::scoped_refptr)audioProcessingModule; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm index 6e2f7c4ef2..03007ac686 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm @@ -20,6 +20,8 @@ #include "api/video_codecs/video_encoder_factory.h" @implementation RTCPeerConnectionFactoryBuilder { + webrtc::scoped_refptr (^_audioDeviceModuleBuilder)( + const webrtc::Environment &); webrtc::PeerConnectionFactoryDependencies _dependencies; } @@ -28,6 +30,12 @@ + (RTCPeerConnectionFactoryBuilder *)builder { } - (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)createPeerConnectionFactory { + if (_audioDeviceModuleBuilder != nil) { + if (!_dependencies.env.has_value()) { + _dependencies.env = webrtc::CreateEnvironment(); + } + _dependencies.adm = _audioDeviceModuleBuilder(*_dependencies.env); + } return [[RTC_OBJC_TYPE(RTCPeerConnectionFactory) alloc] initWithMediaAndDependencies:_dependencies]; } @@ -58,7 +66,15 @@ - (void)setAudioDecoderFactory: - (void)setAudioDeviceModule: (webrtc::scoped_refptr)audioDeviceModule { - _dependencies.adm = std::move(audioDeviceModule); + _audioDeviceModuleBuilder = ^(const webrtc::Environment &) { + return audioDeviceModule; + }; +} + +- (void)setAudioDeviceModuleBuilder: + (webrtc::scoped_refptr (^)( + const webrtc::Environment &))audioDeviceModuleBuilder { + _audioDeviceModuleBuilder = audioDeviceModuleBuilder; } - (void)setAudioProcessingModule: diff --git a/sdk/objc/components/audio/RTCAudioSessionConfiguration.m b/sdk/objc/components/audio/RTCAudioSessionConfiguration.m index 74de6b5ce2..f2e255bdcc 100644 --- a/sdk/objc/components/audio/RTCAudioSessionConfiguration.m +++ b/sdk/objc/components/audio/RTCAudioSessionConfiguration.m @@ -60,7 +60,7 @@ - (instancetype)init { // nonmixable, hence activating the session will interrupt any other // audio sessions which are also nonmixable. _category = AVAudioSessionCategoryPlayAndRecord; - _categoryOptions = AVAudioSessionCategoryOptionAllowBluetooth; + _categoryOptions = AVAudioSessionCategoryOptionAllowBluetoothHFP; // Specify mode for two-way voice communication (e.g. VoIP). _mode = AVAudioSessionModeVoiceChat; diff --git a/sdk/objc/helpers/AudioTimeStamp+Nanoseconds.h b/sdk/objc/helpers/AudioTimeStamp+Nanoseconds.h new file mode 100644 index 0000000000..46233d8223 --- /dev/null +++ b/sdk/objc/helpers/AudioTimeStamp+Nanoseconds.h @@ -0,0 +1,16 @@ +/* + * 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. + */ + +#import + +#include + +std::optional AudioTimeStampGetNanoseconds( + const AudioTimeStamp* timeStamp); diff --git a/sdk/objc/helpers/AudioTimeStamp+Nanoseconds.mm b/sdk/objc/helpers/AudioTimeStamp+Nanoseconds.mm new file mode 100644 index 0000000000..dd64e75138 --- /dev/null +++ b/sdk/objc/helpers/AudioTimeStamp+Nanoseconds.mm @@ -0,0 +1,51 @@ +/* + * 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. + */ + +#import "AudioTimeStamp+Nanoseconds.h" + +#include +#include "rtc_base/checks.h" + +std::optional AudioTimeStampGetNanoseconds( + const AudioTimeStamp* timeStamp) { + if (!timeStamp || ((timeStamp->mFlags & kAudioTimeStampHostTimeValid) == 0) || + timeStamp->mHostTime == 0) { + return std::nullopt; + } + + static mach_timebase_info_data_t mach_timebase; + if (mach_timebase.denom == 0) { + if (mach_timebase_info(&mach_timebase) != KERN_SUCCESS) { + RTC_DCHECK_NOTREACHED() << "mach_timebase_info bad return code"; + return std::nullopt; + } + } + + if (mach_timebase.denom == 0 || mach_timebase.numer == 0) { + RTC_DCHECK_NOTREACHED() << "mach_timebase_info provided bad data"; + return std::nullopt; + } + + uint64_t time_scaled = 0; + if (__builtin_umulll_overflow( + timeStamp->mHostTime, mach_timebase.numer, &time_scaled)) { + RTC_DCHECK_NOTREACHED() << "numeric overflow computing scaled host time"; + return std::nullopt; + } + + uint64_t nanoseconds = time_scaled / mach_timebase.denom; + if (nanoseconds > + static_cast(std::numeric_limits::max())) { + RTC_DCHECK_NOTREACHED() << "numeric overflow computing nanoseconds"; + return std::nullopt; + } + + return static_cast(nanoseconds); +} diff --git a/sdk/objc/helpers/scoped_cftyperef.h b/sdk/objc/helpers/scoped_cftyperef.h index 435741e943..9289ee4eaa 100644 --- a/sdk/objc/helpers/scoped_cftyperef.h +++ b/sdk/objc/helpers/scoped_cftyperef.h @@ -114,15 +114,5 @@ static ScopedCFTypeRef ScopedCF(T cftype) { } // 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::AdoptCF; -using ::webrtc::RetainPolicy; -using ::webrtc::ScopedCF; -using ::webrtc::ScopedCFTypeRef; -} // namespace rtc -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // SDK_OBJC_HELPERS_SCOPED_CFTYPEREF_H_ diff --git a/sdk/objc/native/api/audio_device_module.h b/sdk/objc/native/api/audio_device_module.h index 8f788e7452..e49c25bb37 100644 --- a/sdk/objc/native/api/audio_device_module.h +++ b/sdk/objc/native/api/audio_device_module.h @@ -32,11 +32,6 @@ scoped_refptr CreateAudioDeviceModule( bool bypass_voice_processing = false, AudioSourceSink* audioSink = nullptr); -[[deprecated("Pass `env` explicitly instead of relying on the default")]] -scoped_refptr CreateAudioDeviceModule( - bool bypass_voice_processing = false, - AudioSourceSink* audioSink = nullptr); - // If `muted_speech_event_handler` is exist, audio unit will catch speech // activity while muted. // Provide `error_handler` to receive callbacks on errors such as microphone @@ -48,13 +43,6 @@ scoped_refptr CreateMutedDetectAudioDeviceModule( 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, - AudioSourceSink* audioSink = nullptr); - } // namespace webrtc -#endif // SDK_OBJC_NATIVE_API_AUDIO_DEVICE_MODULE_H_ \ No newline at end of file +#endif // SDK_OBJC_NATIVE_API_AUDIO_DEVICE_MODULE_H_ diff --git a/sdk/objc/native/api/audio_device_module.mm b/sdk/objc/native/api/audio_device_module.mm index 9ddbd728c1..b055637c4e 100644 --- a/sdk/objc/native/api/audio_device_module.mm +++ b/sdk/objc/native/api/audio_device_module.mm @@ -11,7 +11,6 @@ #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" @@ -34,17 +33,6 @@ audioSink); } -scoped_refptr CreateAudioDeviceModule( - bool bypass_voice_processing, webrtc::AudioSourceSink* audioSink) { - RTC_DLOG(LS_INFO) << __FUNCTION__; - return make_ref_counted( - CreateEnvironment(), - bypass_voice_processing, - /*muted_speech_event_handler=*/nullptr, - /*error_handler=*/nullptr, - audioSink); -} - scoped_refptr CreateMutedDetectAudioDeviceModule( const Environment& env, AudioDeviceModule::MutedSpeechEventHandler muted_speech_event_handler, @@ -56,17 +44,4 @@ 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 \ No newline at end of file +} // 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 06aaf072f5..00abebdbb4 100644 --- a/sdk/objc/native/src/audio/audio_device_ios.h +++ b/sdk/objc/native/src/audio/audio_device_ios.h @@ -338,9 +338,6 @@ class AudioDeviceIOS : public AudioDeviceGeneric, std::atomic total_playout_delay_ms_; std::atomic hw_output_latency_; int last_hw_output_latency_update_sample_count_; - // Ratio between mach tick units and nanosecond. Used to change mach tick - // units to nanoseconds. - double machTickUnitsToNanoseconds_; }; } // namespace ios_adm } // namespace webrtc diff --git a/sdk/objc/native/src/audio/audio_device_ios.mm b/sdk/objc/native/src/audio/audio_device_ios.mm index f2425589fc..fc6b239b30 100644 --- a/sdk/objc/native/src/audio/audio_device_ios.mm +++ b/sdk/objc/native/src/audio/audio_device_ios.mm @@ -33,6 +33,7 @@ #import "components/audio/RTCAudioSession.h" #import "components/audio/RTCAudioSessionConfiguration.h" #import "components/audio/RTCNativeAudioSessionDelegateAdapter.h" +#import "helpers/AudioTimeStamp+Nanoseconds.h" #import "audio_source_sink.h" @@ -132,9 +133,6 @@ static void LogDeviceInfo() { audio_session_observer_ = [[RTCNativeAudioSessionDelegateAdapter alloc] initWithObserver:this]; - mach_timebase_info_data_t tinfo; - mach_timebase_info(&tinfo); - machTickUnitsToNanoseconds_ = (double)tinfo.numer / tinfo.denom; } AudioDeviceIOS::~AudioDeviceIOS() { @@ -419,8 +417,8 @@ static void LogDeviceInfo() { // Get audio timestamp for the audio. // The timestamp will not have NTP time epoch, but that will be addressed by // the TimeStampAligner in AudioDeviceBuffer::SetRecordedBuffer(). - SInt64 capture_timestamp_ns = - time_stamp->mHostTime * machTickUnitsToNanoseconds_; + std::optional capture_timestamp_ns = + AudioTimeStampGetNanoseconds(time_stamp); // Allocate AudioBuffers to be used as storage for the received audio. // The AudioBufferList structure works as a placeholder for the 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 f70d9b812c..41ef75c789 100644 --- a/sdk/objc/native/src/audio/audio_device_module_ios.mm +++ b/sdk/objc/native/src/audio/audio_device_module_ios.mm @@ -13,7 +13,6 @@ #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" #include "rtc_base/logging.h" diff --git a/sdk/objc/native/src/objc_audio_device.mm b/sdk/objc/native/src/objc_audio_device.mm index d17dd63811..3044de9c9d 100644 --- a/sdk/objc/native/src/objc_audio_device.mm +++ b/sdk/objc/native/src/objc_audio_device.mm @@ -13,6 +13,7 @@ #include #import "components/audio/RTCAudioDevice.h" +#import "helpers/AudioTimeStamp+Nanoseconds.h" #include "modules/audio_device/fine_audio_buffer.h" #include "objc_audio_device_delegate.h" #include "rtc_base/logging.h" @@ -449,7 +450,8 @@ record_fine_audio_buffer_->DeliverRecordedData( webrtc::ArrayView( static_cast(audio_buffer->mData), num_frames), - cached_recording_delay_ms_.load()); + cached_recording_delay_ms_.load(), + AudioTimeStampGetNanoseconds(time_stamp)); return noErr; } RTC_DCHECK(render_block != nullptr) @@ -492,7 +494,9 @@ // Use the FineAudioBuffer instance to convert between native buffer size // and the 10ms buffer size used by WebRTC. record_fine_audio_buffer_->DeliverRecordedData( - record_audio_buffer_, cached_recording_delay_ms_.load()); + record_audio_buffer_, + cached_recording_delay_ms_.load(), + AudioTimeStampGetNanoseconds(time_stamp)); return noErr; } diff --git a/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm b/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm index 929490b0ba..115b5e200e 100644 --- a/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm +++ b/sdk/objc/unittests/RTCPeerConnectionFactoryBuilderTest.mm @@ -51,6 +51,27 @@ - (void)testBuilder { OCMVerifyAll(factoryMock); } +- (void)testAudioDeviceModuleBuilder { + 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:default_deps]); + RTCPeerConnectionFactoryBuilder* builder = + [RTCPeerConnectionFactoryBuilder builder]; + __block int calledAdmBuilder = 0; + [builder setAudioDeviceModuleBuilder:^(const webrtc::Environment& env) { + calledAdmBuilder++; + return webrtc::scoped_refptr(nullptr); + }]; + RTC_OBJC_TYPE(RTCPeerConnectionFactory)* peerConnectionFactory = + [builder createPeerConnectionFactory]; + EXPECT_TRUE(peerConnectionFactory != nil); + EXPECT_EQ(calledAdmBuilder, 1); + OCMVerifyAll(factoryMock); +} + - (void)testDefaultComponentsBuilder { id factoryMock = OCMStrictClassMock([RTC_OBJC_TYPE(RTCPeerConnectionFactory) class]); diff --git a/sdk/objc/unittests/objc_video_encoder_factory_tests.mm b/sdk/objc/unittests/objc_video_encoder_factory_tests.mm index 91dcff7b0c..12b9c99cb8 100644 --- a/sdk/objc/unittests/objc_video_encoder_factory_tests.mm +++ b/sdk/objc/unittests/objc_video_encoder_factory_tests.mm @@ -67,10 +67,11 @@ - (instancetype)initWithScalabilityMode:(NSString *)scalabilityMode isPowerEfficient:(bool)isPowerEfficient NS_DESIGNATED_INITIALIZER; @end -@implementation RTCVideoEncoderFactoryFake -NSString *_scalabilityMode; -bool _isPowerEfficient; +@implementation RTCVideoEncoderFactoryFake { + NSString *_scalabilityMode; + bool _isPowerEfficient; +} - (instancetype)initWithScalabilityMode:(NSString *)scalabilityMode { return [self initWithScalabilityMode:scalabilityMode isPowerEfficient:false]; diff --git a/stats/rtc_stats_report.cc b/stats/rtc_stats_report.cc index 7da54e4863..df45041c7b 100644 --- a/stats/rtc_stats_report.cc +++ b/stats/rtc_stats_report.cc @@ -41,7 +41,7 @@ RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++(int) { } const RTCStats& RTCStatsReport::ConstIterator::operator*() const { - return *it_->second.get(); + return *it_->second; } const RTCStats* RTCStatsReport::ConstIterator::operator->() const { diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 8222263e1f..52efbf7c09 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -24,8 +24,10 @@ rtc_library("system_wrappers") { libs = [] deps = [ "../api:array_view", + "../api/units:time_delta", "../api/units:timestamp", "../rtc_base:checks", + "../rtc_base:divide_round", "../rtc_base:logging", "../rtc_base:rtc_numerics", "../rtc_base:safe_conversions", @@ -45,8 +47,10 @@ rtc_library("system_wrappers") { rtc_library("field_trial") { visibility = [ "*" ] poisonous = [ "environment_construction" ] - public = [ "include/field_trial.h" ] - sources = [ "source/field_trial.cc" ] + sources = [ + "include/field_trial.h", + "source/field_trial.cc", + ] if (rtc_exclude_field_trial_default) { defines = [ "WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT" ] } @@ -63,12 +67,15 @@ rtc_library("field_trial") { rtc_library("metrics") { visibility = [ "*" ] - public = [ "include/metrics.h" ] - sources = [ "source/metrics.cc" ] + sources = [ + "include/metrics.h", + "source/metrics.cc", + ] if (rtc_exclude_metrics_default) { defines = [ "WEBRTC_EXCLUDE_METRICS_DEFAULT" ] } deps = [ + "../api/units:time_delta", "../rtc_base:checks", "../rtc_base:macromagic", "../rtc_base:stringutils", @@ -93,6 +100,7 @@ if (rtc_include_tests && !build_with_chromium) { ":metrics", ":system_wrappers", "../api/units:time_delta", + "../api/units:timestamp", "../rtc_base:checks", "../rtc_base:random", "../rtc_base:stringutils", diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h index ec4bae0aed..5f1c665cfe 100644 --- a/system_wrappers/include/clock.h +++ b/system_wrappers/include/clock.h @@ -11,12 +11,12 @@ #ifndef SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ #define SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ -#include - #include -#include +#include +#include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "rtc_base/numerics/divide_round.h" #include "rtc_base/system/rtc_export.h" #include "system_wrappers/include/ntp_time.h" diff --git a/system_wrappers/include/field_trial.h b/system_wrappers/include/field_trial.h index 8d0ad258c1..3647c358fb 100644 --- a/system_wrappers/include/field_trial.h +++ b/system_wrappers/include/field_trial.h @@ -14,48 +14,13 @@ #include #include "absl/strings/string_view.h" -#include "rtc_base/containers/flat_set.h" // Field trials allow webrtc clients (such as Chrome) to turn on feature code // in binaries out in the field and gather information with that. // -// By default WebRTC provides an implementation of field trials that can be -// found in system_wrappers/source/field_trial.cc. If clients want to provide -// a custom version, they will have to: -// -// 1. Compile WebRTC defining the preprocessor macro -// WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT (if GN is used this can be achieved -// by setting the GN arg rtc_exclude_field_trial_default to true). -// 2. Provide an implementation of: -// std::string webrtc::field_trial::FindFullName(absl::string_view trial). -// -// They are designed to wire up directly to chrome field trials and to speed up -// developers by reducing the need to wire APIs to control whether a feature is -// on/off. E.g. to experiment with a new method that could lead to a different -// trade-off between CPU/bandwidth: -// -// 1 - Develop the feature with default behaviour off: -// -// if (FieldTrial::FindFullName("WebRTCExperimentMethod2") == "Enabled") -// method2(); -// else -// method1(); -// -// 2 - Once the changes are rolled to chrome, the new code path can be -// controlled as normal chrome field trials. -// -// 3 - Evaluate the new feature and clean the code paths. -// -// Notes: -// - NOT every feature is a candidate to be controlled by this mechanism as -// it may require negotiation between involved parties (e.g. SDP). -// -// TODO(andresp): since chrome --force-fieldtrials does not marks the trial -// as active it does not get propagated to the renderer process. For now one -// needs to push a config with start_active:true or run a local finch -// server. -// -// TODO(andresp): find out how to get bots to run tests with trials enabled. +// Field trials interface provided in this file is deprecated. +// Please use `api/field_trials.h` to create field trials. +// Please use `api/field_trials_view.h` to query field trials. namespace webrtc { namespace field_trial { @@ -64,30 +29,26 @@ namespace field_trial { // if the trial does not exists. // // Note: To keep things tidy append all the trial names with WebRTC. +// TODO: bugs.webrtc.org/42220378 - Remove from api after August 1, 2025. +[[deprecated]] std::string FindFullName(absl::string_view name); -// Convenience method, returns true iff FindFullName(name) return a string that -// starts with "Enabled". -// TODO(tommi): Make sure all implementations support this. -inline bool IsEnabled(absl::string_view name) { - return FindFullName(name).find("Enabled") == 0; -} - -// Convenience method, returns true iff FindFullName(name) return a string that -// starts with "Disabled". -inline bool IsDisabled(absl::string_view name) { - return FindFullName(name).find("Disabled") == 0; -} - // Optionally initialize field trial from a string. // This method can be called at most once before any other call into webrtc. // E.g. before the peer connection factory is constructed. // Note: trials_string must never be destroyed. +// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026. +[[deprecated( + "Create FieldTrials and pass is where FieldTrialsView is expected")]] void InitFieldTrialsFromString(const char* trials_string); +// TODO: bugs.webrtc.org/42220378 - Remove from api after September 1, 2025. +[[deprecated("Propagate and query FieldTrialsView interface")]] const char* GetFieldTrialString(); // Validates the given field trial string. +// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026. +[[deprecated("Use FieldTrials::Create to validate field trial string")]] bool FieldTrialsStringIsValid(absl::string_view trials_string); // Merges two field trial strings. @@ -95,21 +56,11 @@ bool FieldTrialsStringIsValid(absl::string_view trials_string); // If a key (trial) exists twice with conflicting values (groups), the value // in 'second' takes precedence. // Shall only be called with valid FieldTrial strings. +// TODO: bugs.webrtc.org/42220378 - Delete after January 1, 2026. +[[deprecated("Use FieldTrials::Merge")]] std::string MergeFieldTrialsStrings(absl::string_view first, absl::string_view second); -// This helper allows to temporary "register" a field trial within the current -// scope. This is only useful for tests that use the global field trial string, -// otherwise you can use `webrtc::FieldTrialsRegistry`. -// -// If you want to isolate changes to the global field trial string itself within -// the current scope you should use `webrtc::test::ScopedFieldTrials`. -class FieldTrialsAllowedInScopeForTesting { - public: - explicit FieldTrialsAllowedInScopeForTesting(flat_set keys); - ~FieldTrialsAllowedInScopeForTesting(); -}; - } // namespace field_trial } // namespace webrtc diff --git a/system_wrappers/include/metrics.h b/system_wrappers/include/metrics.h index a447cce461..6c65dbf43d 100644 --- a/system_wrappers/include/metrics.h +++ b/system_wrappers/include/metrics.h @@ -11,14 +11,14 @@ #ifndef SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ #define SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ -#include - #include // IWYU pragma: keep +#include #include #include #include #include "absl/strings/string_view.h" +#include "api/units/time_delta.h" #include "rtc_base/checks.h" #include "rtc_base/string_utils.h" @@ -393,7 +393,7 @@ namespace webrtc { namespace metrics { // Time that should have elapsed for stats that are gathered once per call. -constexpr int kMinRunTimeInSeconds = 10; +inline constexpr TimeDelta kMinRunTime = TimeDelta::Seconds(10); class Histogram; diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc index 0fe5abc71d..9290d19f4d 100644 --- a/system_wrappers/source/clock.cc +++ b/system_wrappers/source/clock.cc @@ -10,7 +10,14 @@ #include "system_wrappers/include/clock.h" +#include +#include + +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "rtc_base/checks.h" #include "rtc_base/time_utils.h" +#include "system_wrappers/include/ntp_time.h" namespace webrtc { namespace { diff --git a/system_wrappers/source/clock_unittest.cc b/system_wrappers/source/clock_unittest.cc index e50b789e53..51bfe0db5a 100644 --- a/system_wrappers/source/clock_unittest.cc +++ b/system_wrappers/source/clock_unittest.cc @@ -10,7 +10,11 @@ #include "system_wrappers/include/clock.h" +#include + #include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "system_wrappers/include/ntp_time.h" #include "test/gtest.h" namespace webrtc { diff --git a/system_wrappers/source/field_trial.cc b/system_wrappers/source/field_trial.cc index 5efa01c9ef..569e6cb5eb 100644 --- a/system_wrappers/source/field_trial.cc +++ b/system_wrappers/source/field_trial.cc @@ -9,20 +9,21 @@ #include "system_wrappers/include/field_trial.h" -#include - +#include #include #include #include +#include -#include "absl/algorithm/container.h" +#include "absl/algorithm/container.h" // IWYU pragma: keep #include "absl/strings/string_view.h" -#include "experiments/registered_field_trials.h" #include "rtc_base/checks.h" -#include "rtc_base/containers/flat_set.h" #include "rtc_base/logging.h" #include "rtc_base/string_encode.h" +// Generated file. +#include "experiments/registered_field_trials.h" // IWYU pragma: keep + // Simple field trial implementation, which allows client to // specify desired flags in InitFieldTrialsFromString. namespace webrtc { @@ -34,11 +35,6 @@ namespace { constexpr char kPersistentStringSeparator = '/'; -flat_set& TestKeys() { - static auto* test_keys = new flat_set(); - return *test_keys; -} - // Validates the given field trial string. // E.g.: // "WebRTC-experimentFoo/Enabled/WebRTC-experimentBar/Enabled100kbps/" @@ -117,13 +113,10 @@ std::string MergeFieldTrialsStrings(absl::string_view first, #ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT std::string FindFullName(absl::string_view name) { #if WEBRTC_STRICT_FIELD_TRIALS == 1 - RTC_DCHECK(absl::c_linear_search(kRegisteredFieldTrials, name) || - TestKeys().contains(name)) + RTC_DCHECK(absl::c_linear_search(kRegisteredFieldTrials, name)) << name << " is not registered, see g3doc/field-trials.md."; #elif WEBRTC_STRICT_FIELD_TRIALS == 2 - RTC_LOG_IF(LS_WARNING, - !(absl::c_linear_search(kRegisteredFieldTrials, name) || - TestKeys().contains(name))) + RTC_LOG_IF(LS_WARNING, !absl::c_linear_search(kRegisteredFieldTrials, name)) << name << " is not registered, see g3doc/field-trials.md."; #endif @@ -173,14 +166,5 @@ const char* GetFieldTrialString() { return trials_init_string; } -FieldTrialsAllowedInScopeForTesting::FieldTrialsAllowedInScopeForTesting( - flat_set keys) { - TestKeys() = std::move(keys); -} - -FieldTrialsAllowedInScopeForTesting::~FieldTrialsAllowedInScopeForTesting() { - TestKeys().clear(); -} - } // namespace field_trial } // namespace webrtc diff --git a/system_wrappers/source/field_trial_unittest.cc b/system_wrappers/source/field_trial_unittest.cc index ada6313e67..2e87dc7587 100644 --- a/system_wrappers/source/field_trial_unittest.cc +++ b/system_wrappers/source/field_trial_unittest.cc @@ -15,8 +15,10 @@ namespace webrtc { namespace field_trial { -#if GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID) && \ - !defined(WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT) +#if GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + TEST(FieldTrialValidationTest, AcceptsValidInputs) { InitFieldTrialsFromString(""); InitFieldTrialsFromString("Audio/Enabled/"); @@ -100,8 +102,8 @@ TEST(FieldTrialMergingTest, HandlesEmptyInput) { EXPECT_EQ(MergeFieldTrialsStrings("Audio/Enabled/", ""), "Audio/Enabled/"); EXPECT_EQ(MergeFieldTrialsStrings("", ""), ""); } +#pragma clang diagnostic pop #endif // GTEST_HAS_DEATH_TEST && RTC_DCHECK_IS_ON && !defined(WEBRTC_ANDROID) - // && !defined(WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT) } // namespace field_trial } // namespace webrtc diff --git a/system_wrappers/source/metrics_default_unittest.cc b/system_wrappers/source/metrics_default_unittest.cc index be612e730b..bc4d7c83dd 100644 --- a/system_wrappers/source/metrics_default_unittest.cc +++ b/system_wrappers/source/metrics_default_unittest.cc @@ -22,8 +22,8 @@ namespace webrtc { namespace { -const int kSample = 22; -const char kName[] = "Name"; +constexpr int kSample = 22; +constexpr char kName[] = "Name"; int NumSamples(absl::string_view name, const std::map +#include + #include "absl/strings/string_view.h" +#include "rtc_base/checks.h" #include "test/gmock.h" #include "test/gtest.h" @@ -21,7 +25,7 @@ using ::testing::Pair; #if RTC_METRICS_ENABLED namespace webrtc { namespace { -const int kSample = 22; +constexpr int kSample = 22; void AddSparseSample(absl::string_view name, int sample) { RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample); diff --git a/system_wrappers/source/ntp_time_unittest.cc b/system_wrappers/source/ntp_time_unittest.cc index 40027a3660..8c0bd1b5b1 100644 --- a/system_wrappers/source/ntp_time_unittest.cc +++ b/system_wrappers/source/ntp_time_unittest.cc @@ -10,6 +10,9 @@ #include "system_wrappers/include/ntp_time.h" +#include +#include +#include #include #include "system_wrappers/include/clock.h" diff --git a/test/BUILD.gn b/test/BUILD.gn index 61c56738f6..9edc60ad74 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -154,6 +154,7 @@ rtc_library("create_test_field_trials") { sources = [ "create_test_field_trials.h" ] deps = [ "../api:field_trials", + "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -211,7 +212,6 @@ rtc_library("video_test_common") { ":create_frame_generator_capturer", ":fileutils", ":frame_utils", - ":scoped_key_value_config", ":test_video_capturer", "../api:array_view", "../api:create_frame_generator", @@ -305,7 +305,6 @@ if (!build_with_chromium) { "vcm_capturer.h", ] deps += [ - ":scoped_key_value_config", "../api:scoped_refptr", "../modules/video_capture:video_capture_module", "../rtc_base:checks", @@ -342,44 +341,6 @@ rtc_library("rtp_test_utils") { ] } -rtc_library("field_trial") { - testonly = true - visibility = [ "*" ] - sources = [ - "field_trial.cc", - "field_trial.h", - ] - - deps = [ - "../rtc_base:checks", - "../system_wrappers:field_trial", - "//third_party/abseil-cpp/absl/strings:string_view", - ] -} - -rtc_library("explicit_key_value_config") { - sources = [ "explicit_key_value_config.h" ] - - deps = [ "../api:field_trials" ] -} - -rtc_library("scoped_key_value_config") { - testonly = true - visibility = [ "*" ] - sources = [ - "scoped_key_value_config.cc", - "scoped_key_value_config.h", - ] - - deps = [ - ":field_trial", - "../api:field_trials_registry", - "../rtc_base:checks", - "../system_wrappers:field_trial", - "//third_party/abseil-cpp/absl/strings:string_view", - ] -} - rtc_library("perf_test") { visibility = [ "*" ] testonly = true @@ -413,7 +374,7 @@ rtc_library("perf_test") { } } -if (is_ios) { +if (is_ios && !build_with_chromium) { rtc_library("test_support_objc") { testonly = true visibility = [ @@ -492,7 +453,7 @@ rtc_source_set("test_support") { "gtest.h", ] - if (is_ios) { + if (is_ios && !build_with_chromium) { public_deps += # no-presubmit-check TODO(webrtc:8603) [ ":test_support_objc" ] } @@ -618,7 +579,6 @@ if (rtc_include_tests) { ] deps = [ - ":field_trial", ":fileutils", ":perf_test", ":resources_dir_flag", @@ -636,7 +596,6 @@ if (rtc_include_tests) { "../rtc_base:logging", "../rtc_base:ssl_adapter", "../rtc_base:threading", - "../system_wrappers:field_trial", "../system_wrappers:metrics", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/memory", @@ -735,7 +694,6 @@ if (rtc_include_tests) { ":rtc_expect_death", ":rtp_test_utils", ":run_loop", - ":scoped_key_value_config", ":test_main", ":test_support", ":test_support_test_artifacts", @@ -809,7 +767,7 @@ if (rtc_include_tests) { "pc/e2e/analyzer/video/dvqa:dvqa_unittests", "peer_scenario/tests", "scenario:scenario_unittests", - "time_controller:time_controller", + "time_controller", "time_controller:time_controller_unittests", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/strings:string_view", @@ -1287,13 +1245,7 @@ if (!build_with_chromium) { "test_flags.h", ] - # TODO: bugs.webrtc.org/419453427 - remove dependency on - # `create_test_field_trials` when force_fieldtrials flags declaration - # is removed from the header. - deps = [ - ":create_test_field_trials", - "//third_party/abseil-cpp/absl/flags:flag", - ] + deps = [ "//third_party/abseil-cpp/absl/flags:flag" ] } rtc_library("test_common") { @@ -1309,6 +1261,7 @@ if (!build_with_chromium) { ] deps = [ + ":create_test_field_trials", ":direct_transport", ":encoder_settings", ":fake_video_codecs", @@ -1316,7 +1269,6 @@ if (!build_with_chromium) { ":frame_generator_capturer", ":mock_transport", ":run_loop", - ":scoped_key_value_config", ":test_flags", ":test_support", ":test_video_capturer", @@ -1326,6 +1278,7 @@ if (!build_with_chromium) { "../api:array_view", "../api:create_frame_generator", "../api:fec_controller_api", + "../api:field_trials", "../api:frame_generator_api", "../api:network_state_predictor_api", "../api:rtp_headers", @@ -1417,7 +1370,7 @@ if (!build_with_chromium && is_android) { ":native_test_jni", "//testing/gtest", "//third_party/abseil-cpp/absl/strings", - "//third_party/jni_zero:jni_zero", + "//third_party/jni_zero", ] } @@ -1482,7 +1435,7 @@ rtc_library("video_codec_tester") { "../api:scoped_refptr", "../api/environment", "../api/environment:environment_factory", - "../api/numerics:numerics", + "../api/numerics", "../api/test/metrics:metric", "../api/test/metrics:metrics_logger", "../api/test/video:video_frame_writer", diff --git a/test/DEPS b/test/DEPS index 17e2ff44f3..331fbadcbc 100644 --- a/test/DEPS +++ b/test/DEPS @@ -42,9 +42,6 @@ specific_include_rules = { ".*mdns_parser_fuzzer\.cc": [ "+p2p/base/mdns_message.h", ], - ".*pseudotcp_parser_fuzzer\.cc": [ - "+p2p/base/pseudo_tcp.h", - ], ".*stun_parser_fuzzer\.cc": [ "+p2p/base/stun.h", ], diff --git a/test/call_test.cc b/test/call_test.cc index 9f6f5b911f..01175420b7 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -58,6 +58,7 @@ #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" #include "rtc_base/task_queue_for_test.h" +#include "test/create_test_field_trials.h" #include "test/encoder_settings.h" #include "test/fake_decoder.h" #include "test/fake_encoder.h" @@ -73,7 +74,7 @@ namespace webrtc { namespace test { CallTest::CallTest(absl::string_view field_trials) - : field_trials_(field_trials), + : field_trials_(CreateTestFieldTrials(field_trials)), env_(CreateEnvironment(&field_trials_)), send_env_(env_), recv_env_(env_), @@ -585,7 +586,7 @@ void CallTest::CreateVideoSendStreams() { // We currently only support testing external fec controllers with a single // VideoSendStream. - if (fec_controller_factory_.get()) { + if (fec_controller_factory_) { RTC_DCHECK_LE(video_send_configs_.size(), 1); } @@ -605,7 +606,7 @@ void CallTest::CreateVideoSendStreams() { video_send_streams_.resize(video_send_configs_.size(), nullptr); for (size_t i : streams_creation_order) { - if (fec_controller_factory_.get()) { + if (fec_controller_factory_) { video_send_streams_[i] = sender_call_->CreateVideoSendStream( video_send_configs_[i].Copy(), video_encoder_configs_[i].Copy(), fec_controller_factory_->CreateFecController(send_env_)); diff --git a/test/call_test.h b/test/call_test.h index d8cae8c452..1e70141f83 100644 --- a/test/call_test.h +++ b/test/call_test.h @@ -27,6 +27,7 @@ #include "api/call/transport.h" #include "api/environment/environment.h" #include "api/fec_controller.h" +#include "api/field_trials.h" #include "api/media_types.h" #include "api/network_state_predictor.h" #include "api/rtc_event_log/rtc_event_log.h" @@ -58,7 +59,6 @@ #include "test/gtest.h" #include "test/rtp_rtcp_observer.h" #include "test/run_loop.h" -#include "test/scoped_key_value_config.h" #include "test/test_video_capturer.h" #include "video/config/video_encoder_config.h" @@ -76,6 +76,7 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface { protected: const Environment& env() const { return env_; } + FieldTrials& field_trials() { return field_trials_; } void SetSendEventLog(std::unique_ptr event_log); void SetRecvEventLog(std::unique_ptr event_log); @@ -215,7 +216,7 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface { void OnRtpPacket(const RtpPacketReceived& packet) override; test::RunLoop loop_; - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_; Environment env_; Environment send_env_; Environment recv_env_; diff --git a/test/create_test_field_trials.h b/test/create_test_field_trials.h index 10e40f595f..fd78ec925e 100644 --- a/test/create_test_field_trials.h +++ b/test/create_test_field_trials.h @@ -10,6 +10,9 @@ #ifndef TEST_CREATE_TEST_FIELD_TRIALS_H_ #define TEST_CREATE_TEST_FIELD_TRIALS_H_ +#include + +#include "absl/base/nullability.h" #include "absl/strings/string_view.h" #include "api/field_trials.h" @@ -20,9 +23,15 @@ namespace webrtc { // the command line flag. // Crashes if command line flag or the `s` are not a valid field trial string. // -// The intention of this function is to be the default source of field trials +// The intention of these functions is to be the default source of field trials // in tests so that tests always use the command line flag. +// The behavior of these two functions is identical, they differ only in the +// return types for convenience. FieldTrials CreateTestFieldTrials(absl::string_view s = ""); +inline absl_nonnull std::unique_ptr CreateTestFieldTrialsPtr( + absl::string_view s = "") { + return std::make_unique(CreateTestFieldTrials(s)); +} } // namespace webrtc diff --git a/test/explicit_key_value_config.h b/test/explicit_key_value_config.h deleted file mode 100644 index 0766447853..0000000000 --- a/test/explicit_key_value_config.h +++ /dev/null @@ -1,25 +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. - */ - -#ifndef TEST_EXPLICIT_KEY_VALUE_CONFIG_H_ -#define TEST_EXPLICIT_KEY_VALUE_CONFIG_H_ - -#include "api/field_trials.h" - -namespace webrtc { -namespace test { - -// TODO: bugs.webrtc.org/42220378 - Use `FieldTrials` directly. -using ExplicitKeyValueConfig = FieldTrials; - -} // namespace test -} // namespace webrtc - -#endif // TEST_EXPLICIT_KEY_VALUE_CONFIG_H_ diff --git a/test/field_trial.cc b/test/field_trial.cc deleted file mode 100644 index 5267d7a457..0000000000 --- a/test/field_trial.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "test/field_trial.h" - -#include - -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" - -namespace webrtc { -namespace test { - -ScopedFieldTrials::ScopedFieldTrials(absl::string_view config) - : current_field_trials_(config), - previous_field_trials_(field_trial::GetFieldTrialString()) { - RTC_CHECK( - field_trial::FieldTrialsStringIsValid(current_field_trials_.c_str())) - << "Invalid field trials string: " << current_field_trials_; - field_trial::InitFieldTrialsFromString(current_field_trials_.c_str()); -} - -ScopedFieldTrials::~ScopedFieldTrials() { - RTC_CHECK(field_trial::FieldTrialsStringIsValid(previous_field_trials_)) - << "Invalid field trials string: " << previous_field_trials_; - field_trial::InitFieldTrialsFromString(previous_field_trials_); -} - -} // namespace test -} // namespace webrtc diff --git a/test/field_trial.h b/test/field_trial.h deleted file mode 100644 index 516faa0513..0000000000 --- a/test/field_trial.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef TEST_FIELD_TRIAL_H_ -#define TEST_FIELD_TRIAL_H_ - -#include - -#include "absl/strings/string_view.h" - -namespace webrtc { -namespace test { - -// This class is used to override field-trial configs within specific tests. -// After this class goes out of scope previous field trials will be restored. -class ScopedFieldTrials { - public: - explicit ScopedFieldTrials(absl::string_view config); - ScopedFieldTrials(const ScopedFieldTrials&) = delete; - ScopedFieldTrials& operator=(const ScopedFieldTrials&) = delete; - ~ScopedFieldTrials(); - - private: - std::string current_field_trials_; - const char* previous_field_trials_; -}; - -} // namespace test -} // namespace webrtc - -#endif // TEST_FIELD_TRIAL_H_ diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index 3c2038d64b..6bdaf144fb 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -242,13 +242,13 @@ webrtc_fuzzer_test("rtcp_receiver_fuzzer") { sources = [ "rtcp_receiver_fuzzer.cc" ] deps = [ "../../api:array_view", + "../../api:field_trials", "../../api/environment", "../../api/environment:environment_factory", "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../rtc_base:checks", "../../system_wrappers", - "../../test:explicit_key_value_config", ] seed_corpus = "corpora/rtcp-corpus" } @@ -270,7 +270,7 @@ webrtc_fuzzer_test("rtp_packetizer_av1_fuzzer") { deps = [ "../../api:array_view", "../../api/video:video_frame_type", - "../../modules/rtp_rtcp:rtp_rtcp", + "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../rtc_base:checks", ] @@ -281,7 +281,7 @@ webrtc_fuzzer_test("rtp_format_h264_fuzzer") { deps = [ "../../api:array_view", "../../api/video:video_frame_type", - "../../modules/rtp_rtcp:rtp_rtcp", + "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../modules/video_coding:codec_globals_headers", "../../rtc_base:checks", @@ -293,7 +293,7 @@ webrtc_fuzzer_test("rtp_format_vp8_fuzzer") { deps = [ "../../api:array_view", "../../api/video:video_frame_type", - "../../modules/rtp_rtcp:rtp_rtcp", + "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../modules/video_coding:codec_globals_headers", "../../rtc_base:checks", @@ -305,7 +305,7 @@ webrtc_fuzzer_test("rtp_format_vp9_fuzzer") { deps = [ "../../api:array_view", "../../api/video:video_frame_type", - "../../modules/rtp_rtcp:rtp_rtcp", + "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../modules/video_coding:codec_globals_headers", "../../rtc_base:checks", @@ -523,14 +523,6 @@ webrtc_fuzzer_test("stun_validator_fuzzer") { dict = "corpora/stun.tokens" } -webrtc_fuzzer_test("pseudotcp_parser_fuzzer") { - sources = [ "pseudotcp_parser_fuzzer.cc" ] - deps = [ - "../../p2p:pseudo_tcp", - "../../rtc_base:threading", - ] -} - rtc_library("audio_processing_fuzzer_helper") { testonly = true sources = [ @@ -691,8 +683,8 @@ webrtc_fuzzer_test("rtp_frame_reference_finder_fuzzer") { "../../api/video:video_rtp_headers", "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_video_header", + "../../modules/video_coding", "../../modules/video_coding:codec_globals_headers", - "../../modules/video_coding:video_coding", "../../system_wrappers", ] } @@ -702,10 +694,10 @@ webrtc_fuzzer_test("frame_buffer_fuzzer") { deps = [ ":fuzz_data_helper", "../../api:array_view", + "../../api:field_trials", "../../api/video:encoded_frame", "../../api/video:frame_buffer", "../../rtc_base:rtc_numerics", - "../../test:scoped_key_value_config", ] } @@ -854,7 +846,6 @@ group("fuzzers") { ":h264_depacketizer_fuzzer", ":neteq_rtp_fuzzer", ":neteq_signal_fuzzer", - ":pseudotcp_parser_fuzzer", ":receive_side_congestion_controller_fuzzer", ":residual_echo_detector_fuzzer", ":rtcp_receiver_fuzzer", diff --git a/test/fuzzers/corpora/README b/test/fuzzers/corpora/README index cc87025ff6..25b4b4176c 100644 --- a/test/fuzzers/corpora/README +++ b/test/fuzzers/corpora/README @@ -30,8 +30,6 @@ prefixed by the byte 0xff. Some of the rtp fuzzers need to decide which header extensions to enable, and the first byte of the fuzz data is used for this. -### PseudoTCP ### -Very small corpus minimised from the unit tests. ### SCTP ### This corpus was extracted from a few manually recorder wireshark dumps. diff --git a/test/fuzzers/frame_buffer_fuzzer.cc b/test/fuzzers/frame_buffer_fuzzer.cc index c86499f0fd..98e8d5a550 100644 --- a/test/fuzzers/frame_buffer_fuzzer.cc +++ b/test/fuzzers/frame_buffer_fuzzer.cc @@ -14,11 +14,11 @@ #include #include "api/array_view.h" +#include "api/field_trials.h" #include "api/video/encoded_frame.h" #include "api/video/frame_buffer.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" #include "test/fuzzers/fuzz_data_helper.h" -#include "test/scoped_key_value_config.h" namespace webrtc { namespace { @@ -37,7 +37,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) { return; } - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials(""); FrameBuffer buffer(/*max_frame_slots=*/100, /*max_decode_history=*/1000, field_trials); test::FuzzDataHelper helper(webrtc::MakeArrayView(data, size)); diff --git a/test/fuzzers/pseudotcp_parser_fuzzer.cc b/test/fuzzers/pseudotcp_parser_fuzzer.cc deleted file mode 100644 index fb2ae2502a..0000000000 --- a/test/fuzzers/pseudotcp_parser_fuzzer.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include -#include - -#include "p2p/base/pseudo_tcp.h" -#include "rtc_base/thread.h" - -namespace webrtc { -class FakeIPseudoTcpNotify : public webrtc::IPseudoTcpNotify { - public: - void OnTcpOpen(webrtc::PseudoTcp* tcp) {} - void OnTcpReadable(webrtc::PseudoTcp* tcp) {} - void OnTcpWriteable(webrtc::PseudoTcp* tcp) {} - void OnTcpClosed(webrtc::PseudoTcp* tcp, uint32_t error) {} - - webrtc::IPseudoTcpNotify::WriteResult TcpWritePacket(webrtc::PseudoTcp* tcp, - const char* buffer, - size_t len) { - return webrtc::IPseudoTcpNotify::WriteResult::WR_SUCCESS; - } -}; - -struct Environment { - explicit Environment(webrtc::IPseudoTcpNotify* notifier) - : ptcp(notifier, 0) {} - - // We need the thread to avoid some uninteresting crashes, since the - // production code expects there to be a thread object available. - webrtc::AutoThread thread; - webrtc::PseudoTcp ptcp; -}; - -Environment* env = new Environment(new FakeIPseudoTcpNotify()); - -void FuzzOneInput(const uint8_t* data, size_t size) { - env->ptcp.NotifyPacket(reinterpret_cast(data), size); -} -} // namespace webrtc diff --git a/test/fuzzers/rtcp_receiver_fuzzer.cc b/test/fuzzers/rtcp_receiver_fuzzer.cc index 0212afe388..98fdbfc45b 100644 --- a/test/fuzzers/rtcp_receiver_fuzzer.cc +++ b/test/fuzzers/rtcp_receiver_fuzzer.cc @@ -14,12 +14,12 @@ #include "api/array_view.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "modules/rtp_rtcp/include/report_block_data.h" #include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" #include "modules/rtp_rtcp/source/rtcp_receiver.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "system_wrappers/include/clock.h" -#include "test/explicit_key_value_config.h" namespace webrtc { namespace { @@ -45,8 +45,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) { if (size > kMaxInputLenBytes) { return; } - test::ExplicitKeyValueConfig field_trials( - "WebRTC-RFC8888CongestionControlFeedback/Enabled/"); + FieldTrials field_trials("WebRTC-RFC8888CongestionControlFeedback/Enabled/"); NullModuleRtpRtcp rtp_rtcp_module; SimulatedClock clock(1234); diff --git a/test/ios/test_support.h b/test/ios/test_support.h index 77ad8e849c..0f1cb9f6d0 100644 --- a/test/ios/test_support.h +++ b/test/ios/test_support.h @@ -25,7 +25,6 @@ void InitTestSuite(int (*test_suite)(void), int argc, char* argv[], bool save_chartjson_result, - bool export_perf_results_new_api, std::string webrtc_test_metrics_output_path, std::optional> metrics_to_plot); diff --git a/test/ios/test_support.mm b/test/ios/test_support.mm index 56a2754b9b..aca688c24c 100644 --- a/test/ios/test_support.mm +++ b/test/ios/test_support.mm @@ -45,7 +45,6 @@ static int g_argc; static char **g_argv; static bool g_write_perf_output; -static bool g_export_perf_results_new_api; static std::string g_webrtc_test_metrics_output_path; static std::optional g_is_xctest; static std::optional> g_metrics_to_plot; @@ -101,63 +100,37 @@ - (int)runGoogleTests { NSArray *outputDirectories = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); std::vector> exporters; - if (g_export_perf_results_new_api) { - exporters.push_back( - std::make_unique()); - if (g_write_perf_output) { - // Stores data into a proto file under the app's document directory. - NSString *fileName = @"perftest-output.pb"; - if ([outputDirectories count] != 0) { - NSString *outputPath = - [outputDirectories[0] stringByAppendingPathComponent:fileName]; - - exporters.push_back( - std::make_unique( - [NSString stdStringForString:outputPath])); - } + exporters.push_back(std::make_unique()); + if (g_write_perf_output) { + // Stores data into a proto file under the app's document directory. + NSString *fileName = @"perftest-output.pb"; + if ([outputDirectories count] != 0) { + NSString *outputPath = + [outputDirectories[0] stringByAppendingPathComponent:fileName]; + + exporters.push_back( + std::make_unique( + [NSString stdStringForString:outputPath])); } - if (!g_webrtc_test_metrics_output_path.empty()) { - RTC_CHECK_EQ(g_webrtc_test_metrics_output_path.find('/'), - std::string::npos) - << "On iOS, --webrtc_test_metrics_output_path must only be a file " - "name."; - if ([outputDirectories count] != 0) { - NSString *fileName = [NSString - stringWithCString:g_webrtc_test_metrics_output_path.c_str() - encoding:[NSString defaultCStringEncoding]]; - NSString *outputPath = - [outputDirectories[0] stringByAppendingPathComponent:fileName]; - exporters.push_back( - std::make_unique( - webrtc::test::MetricsSetProtoFileExporter::Options( - [NSString stdStringForString:outputPath]))); - } + } + if (!g_webrtc_test_metrics_output_path.empty()) { + RTC_CHECK_EQ(g_webrtc_test_metrics_output_path.find('/'), std::string::npos) + << "On iOS, --webrtc_test_metrics_output_path must only be a file " + "name."; + if ([outputDirectories count] != 0) { + NSString *fileName = + [NSString stringWithCString:g_webrtc_test_metrics_output_path.c_str() + encoding:[NSString defaultCStringEncoding]]; + NSString *outputPath = + [outputDirectories[0] stringByAppendingPathComponent:fileName]; + exporters.push_back( + std::make_unique( + webrtc::test::MetricsSetProtoFileExporter::Options( + [NSString stdStringForString:outputPath]))); } - } else { - exporters.push_back( - std::make_unique()); } webrtc::test::ExportPerfMetric(*webrtc::test::GetGlobalMetricsLogger(), std::move(exporters)); - if (!g_export_perf_results_new_api) { - if (g_write_perf_output) { - // Stores data into a proto file under the app's document directory. - NSString *fileName = @"perftest-output.pb"; - if ([outputDirectories count] != 0) { - NSString *outputPath = - [outputDirectories[0] stringByAppendingPathComponent:fileName]; - - if (!webrtc::test::WritePerfResults( - [NSString stdStringForString:outputPath])) { - return 1; - } - } - } - if (g_metrics_to_plot) { - webrtc::test::PrintPlottableResults(*g_metrics_to_plot); - } - } - return exitStatus; } @@ -191,14 +164,12 @@ void InitTestSuite(int (*test_suite)(void), int argc, char *argv[], bool write_perf_output, - bool export_perf_results_new_api, std::string webrtc_test_metrics_output_path, std::optional> metrics_to_plot) { g_test_suite = test_suite; g_argc = argc; g_argv = argv; g_write_perf_output = write_perf_output; - g_export_perf_results_new_api = export_perf_results_new_api; g_webrtc_test_metrics_output_path = webrtc_test_metrics_output_path; g_metrics_to_plot = std::move(metrics_to_plot); } diff --git a/test/network/BUILD.gn b/test/network/BUILD.gn index 870b56769e..d707ccf187 100644 --- a/test/network/BUILD.gn +++ b/test/network/BUILD.gn @@ -105,6 +105,7 @@ if (rtc_include_tests && !build_with_chromium) { "..:test_support", "..:wait_until", "../../api:audio_options_api", + "../../api:create_modular_peer_connection_factory", "../../api:enable_media_with_defaults", "../../api:libjingle_peerconnection_api", "../../api:media_stream_interface", @@ -198,9 +199,9 @@ if (rtc_include_tests) { "../../api:network_emulation_manager_api", "../../api:rtp_parameters", "../../api:simulated_network_api", - "../../api/environment:environment", + "../../api/environment", "../../api/environment:environment_factory", - "../../api/rtc_event_log:rtc_event_log", + "../../api/rtc_event_log", "../../api/rtc_event_log:rtc_event_log_factory", "../../api/transport:network_control", "../../api/transport:test_feedback_generator_interface", @@ -224,7 +225,7 @@ if (rtc_include_tests) { "../../api:create_network_emulation_manager", "../../api:network_emulation_manager_api", "../../api:simulated_network_api", - "../../api/rtc_event_log:rtc_event_log", + "../../api/rtc_event_log", "../../api/transport:test_feedback_generator", "../../api/transport:test_feedback_generator_interface", "../../api/units:time_delta", @@ -261,6 +262,7 @@ rtc_library("simulated_network") { deps = [ "../../api:sequence_checker", "../../api:simulated_network_api", + "../../api/test/network_emulation:network_queue", "../../api/units:data_rate", "../../api/units:data_size", "../../api/units:time_delta", @@ -283,7 +285,9 @@ if (rtc_include_tests) { ":simulated_network", "..:test_support", "../../api:simulated_network_api", + "../../api/test/network_emulation:network_queue", "../../api/units:data_rate", + "../../api/units:data_size", "../../api/units:time_delta", "../../api/units:timestamp", ] diff --git a/test/network/network_emulation_pc_unittest.cc b/test/network/network_emulation_pc_unittest.cc index 5e62cc383c..086e230d8c 100644 --- a/test/network/network_emulation_pc_unittest.cc +++ b/test/network/network_emulation_pc_unittest.cc @@ -13,6 +13,7 @@ #include #include "api/audio_options.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" diff --git a/test/network/simulated_network.cc b/test/network/simulated_network.cc index da0751f048..f1fa413192 100644 --- a/test/network/simulated_network.cc +++ b/test/network/simulated_network.cc @@ -14,11 +14,14 @@ #include #include #include +#include #include #include #include #include "absl/functional/any_invocable.h" +#include "api/test/network_emulation/leaky_bucket_network_queue.h" +#include "api/test/network_emulation/network_queue.h" #include "api/test/simulated_network.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -56,17 +59,33 @@ Timestamp CalculateArrivalTime(Timestamp start_time, } // namespace -SimulatedNetwork::SimulatedNetwork(Config config, uint64_t random_seed) - : random_(random_seed), bursting_(false), last_enqueue_time_us_(0) { +SimulatedNetwork::SimulatedNetwork(Config config, + uint64_t random_seed, + std::unique_ptr queue) + : queue_(std::move(queue)), random_(random_seed) { SetConfig(config); } +SimulatedNetwork::SimulatedNetwork(Config config, uint64_t random_seed) + : SimulatedNetwork(config, + random_seed, + std::make_unique()) {} + SimulatedNetwork::~SimulatedNetwork() = default; void SimulatedNetwork::SetConfig(const Config& config) { - MutexLock lock(&config_lock_); - config_state_.config = config; // Shallow copy of the struct. + MutexLock lock(&lock_); + SetConfigLocked(config); +} + +void SimulatedNetwork::SetConfigLocked(const Config& config) { + queue_->SetMaxPacketCapacity( + /*max_length=*/config.queue_length_packets > 0 + ? config.queue_length_packets - 1 // -1 to account for the + // packet in the capacity link. + : NetworkQueue::kMaxPacketCapacity); + config_state_.config = config; // Shallow copy of the struct. double prob_loss = config.loss_percent / 100.0; if (config_state_.config.avg_burst_loss_length == -1) { // Uniform loss @@ -93,21 +112,25 @@ void SimulatedNetwork::SetConfig(const BuiltInNetworkBehaviorConfig& new_config, Timestamp config_update_time) { RTC_DCHECK_RUNS_SERIALIZED(&process_checker_); - if (!capacity_link_.empty()) { - // Calculate and update how large portion of the packet first in the - // capacity link is left to to send at time `config_update_time`. - const BuiltInNetworkBehaviorConfig& current_config = - GetConfigState().config; - TimeDelta duration_with_current_config = - config_update_time - capacity_link_.front().last_update_time; - RTC_DCHECK_GE(duration_with_current_config, TimeDelta::Zero()); - capacity_link_.front().bits_left_to_send -= std::min( - duration_with_current_config.ms() * current_config.link_capacity.kbps(), - capacity_link_.front().bits_left_to_send); - capacity_link_.front().last_update_time = config_update_time; - } - SetConfig(new_config); - UpdateCapacityQueue(GetConfigState(), config_update_time); + { + MutexLock lock(&lock_); + if (capacity_link_.has_value()) { + // Calculate and update how large portion of the packet first in the + // capacity link is left to to send at time `config_update_time`. + const BuiltInNetworkBehaviorConfig& current_config = config_state_.config; + TimeDelta duration_with_current_config = + config_update_time - capacity_link_->last_update_time; + RTC_DCHECK_GE(duration_with_current_config, TimeDelta::Zero()); + capacity_link_->bits_left_to_send -= + std::min(duration_with_current_config.ms() * + current_config.link_capacity.kbps(), + capacity_link_->bits_left_to_send); + capacity_link_->last_update_time = config_update_time; + } + SetConfigLocked(new_config); + UpdateCapacityLink(config_state_, config_update_time); + }; + if (UpdateNextProcessTime() && next_process_time_changed_callback_) { next_process_time_changed_callback_(); } @@ -115,18 +138,17 @@ void SimulatedNetwork::SetConfig(const BuiltInNetworkBehaviorConfig& new_config, void SimulatedNetwork::UpdateConfig( std::function config_modifier) { - MutexLock lock(&config_lock_); + MutexLock lock(&lock_); config_modifier(&config_state_.config); } void SimulatedNetwork::PauseTransmissionUntil(int64_t until_us) { - MutexLock lock(&config_lock_); + MutexLock lock(&lock_); config_state_.pause_transmission_until_us = until_us; } bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { RTC_DCHECK_RUNS_SERIALIZED(&process_checker_); - // Check that old packets don't get enqueued, the SimulatedNetwork expect that // the packets' send time is monotonically increasing. The tolerance for // non-monotonic enqueue events is 0.5 ms because on multi core systems @@ -137,35 +159,34 @@ bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { // At the moment, we see more than 130ms between non-monotonic events, which // is more than expected. // RTC_DCHECK_GE(packet.send_time_us - last_enqueue_time_us_, -2000); + last_enqueue_time_us_ = packet.send_time_us; - ConfigState state = GetConfigState(); + MutexLock lock(&lock_); // If the network config requires packet overhead, let's apply it as early as // possible. - packet.size += state.config.packet_overhead; + packet.size += config_state_.config.packet_overhead; - // If `queue_length_packets` is 0, the queue size is infinite. - if (state.config.queue_length_packets > 0 && - capacity_link_.size() >= state.config.queue_length_packets) { - // Too many packet on the link, drop this one. - return false; + Timestamp enqueue_time = packet.send_time(); + bool packet_enqueued = queue_->EnqueuePacket(packet); + // A packet can not enter the narrow section before the last packet has exit. + if (capacity_link_.has_value()) { + // A packet is already in the capacity link. Wait until it exits. + return packet_enqueued; + } + PacketInFlightInfo next_packet = packet; + if (!queue_->empty()) { + next_packet = *queue_->DequeuePacket(enqueue_time); } + Timestamp arrival_time = CalculateArrivalTime( + std::max(next_packet.send_time(), last_capacity_link_exit_time_), + packet.size * 8, config_state_.config.link_capacity); - // Note that arrival time will be updated when previous packets are dequeued - // from the capacity link. - // A packet can not enter the narrow section before the last packet has exit. - Timestamp enqueue_time = Timestamp::Micros(packet.send_time_us); - Timestamp arrival_time = - capacity_link_.empty() - ? CalculateArrivalTime( - std::max(enqueue_time, last_capacity_link_exit_time_), - packet.size * 8, state.config.link_capacity) - : Timestamp::PlusInfinity(); - capacity_link_.push( - {.packet = packet, - .last_update_time = enqueue_time, - .bits_left_to_send = 8 * static_cast(packet.size), - .arrival_time = arrival_time}); + capacity_link_ = { + .packet = next_packet, + .last_update_time = enqueue_time, + .bits_left_to_send = 8 * static_cast(next_packet.size), + .arrival_time = arrival_time}; // Only update `next_process_time_` if not already set. Otherwise, // next_process_time_ is calculated when a packet is dequeued. Note that this @@ -174,11 +195,8 @@ bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { // config.delay_standard_deviation_ms is set. // TODO(bugs.webrtc.org/14525): Consider preventing this. if (next_process_time_.IsInfinite() && arrival_time.IsFinite()) { - RTC_DCHECK_EQ(capacity_link_.size(), 1); next_process_time_ = arrival_time; } - - last_enqueue_time_us_ = packet.send_time_us; return true; } @@ -190,24 +208,20 @@ std::optional SimulatedNetwork::NextDeliveryTimeUs() const { return std::nullopt; } -void SimulatedNetwork::UpdateCapacityQueue(ConfigState state, - Timestamp time_now) { - // Only the first packet in capacity_link_ have a calculated arrival time - // (when packet leave the narrow section), and time when it entered the narrow - // section. Also, the configuration may have changed. Thus we need to - // calculate the arrival time again before maybe moving the packet to the - // delay link. - if (!capacity_link_.empty()) { - capacity_link_.front().last_update_time = std::max( - capacity_link_.front().last_update_time, last_capacity_link_exit_time_); - capacity_link_.front().arrival_time = CalculateArrivalTime( - capacity_link_.front().last_update_time, - capacity_link_.front().bits_left_to_send, state.config.link_capacity); +void SimulatedNetwork::UpdateCapacityLink(ConfigState state, + Timestamp time_now) { + RTC_DCHECK_RUNS_SERIALIZED(&process_checker_); + if (capacity_link_.has_value()) { + // Recalculate the arrival time of the packet currently in the capacity link + // since it may have changed if the capacity has changed. + capacity_link_->last_update_time = std::max( + capacity_link_->last_update_time, last_capacity_link_exit_time_); + capacity_link_->arrival_time = CalculateArrivalTime( + capacity_link_->last_update_time, capacity_link_->bits_left_to_send, + state.config.link_capacity); } - // The capacity link is empty or the first packet is not expected to exit yet. - if (capacity_link_.empty() || - time_now < capacity_link_.front().arrival_time) { + if (!capacity_link_.has_value() || time_now < capacity_link_->arrival_time) { return; } bool reorder_packets = false; @@ -215,9 +229,9 @@ void SimulatedNetwork::UpdateCapacityQueue(ConfigState state, do { // Time to get this packet (the original or just updated arrival_time is // smaller or equal to time_now_us). - PacketInfo packet = capacity_link_.front(); + PacketInfo packet = *capacity_link_; RTC_DCHECK(packet.arrival_time.IsFinite()); - capacity_link_.pop(); + capacity_link_ = std::nullopt; // If the network is paused, the pause will be implemented as an extra delay // to be spent in the `delay_link_` queue. @@ -227,8 +241,8 @@ void SimulatedNetwork::UpdateCapacityQueue(ConfigState state, } // Store the original arrival time, before applying packet loss or extra - // delay. This is needed to know when it is the first available time the - // next packet in the `capacity_link_` queue can start transmitting. + // delay. This is needed to know when it is possible for the next packet + // in the queue to start transmitting. last_capacity_link_exit_time_ = packet.arrival_time; // Drop packets at an average rate of `state.config.loss_percent` with @@ -265,19 +279,24 @@ void SimulatedNetwork::UpdateCapacityQueue(ConfigState state, delay_link_.emplace_back(packet); // If there are no packets in the queue, there is nothing else to do. - if (capacity_link_.empty()) { + std::optional peek_packet = queue_->PeekNextPacket(); + if (!peek_packet) { break; } - // If instead there is another packet in the `capacity_link_` queue, let's - // calculate its arrival_time based on the latest config (which might - // have been changed since it was enqueued). - Timestamp next_start = std::max(last_capacity_link_exit_time_, - capacity_link_.front().last_update_time); - capacity_link_.front().arrival_time = - CalculateArrivalTime(next_start, capacity_link_.front().packet.size * 8, - state.config.link_capacity); + // It is possible that the next packet in the queue has a send time (at + // least in tests) after the previous packet left the capacity link. + Timestamp next_start = + std::max(last_capacity_link_exit_time_, peek_packet->send_time()); + std::optional next_packet = + queue_->DequeuePacket(next_start); + capacity_link_ = { + .packet = *next_packet, + .last_update_time = next_start, + .bits_left_to_send = 8 * static_cast(next_packet->size), + .arrival_time = CalculateArrivalTime(next_start, next_packet->size * 8, + state.config.link_capacity)}; // And if the next packet in the queue needs to exit, let's dequeue it. - } while (capacity_link_.front().arrival_time <= time_now); + } while (capacity_link_->arrival_time <= time_now); if (state.config.allow_reordering && reorder_packets) { // Packets arrived out of order and since the network config allows @@ -290,19 +309,19 @@ void SimulatedNetwork::UpdateCapacityQueue(ConfigState state, } } -SimulatedNetwork::ConfigState SimulatedNetwork::GetConfigState() const { - MutexLock lock(&config_lock_); - return config_state_; -} - std::vector SimulatedNetwork::DequeueDeliverablePackets( int64_t receive_time_us) { RTC_DCHECK_RUNS_SERIALIZED(&process_checker_); Timestamp receive_time = Timestamp::Micros(receive_time_us); - UpdateCapacityQueue(GetConfigState(), receive_time); + MutexLock lock(&lock_); + UpdateCapacityLink(config_state_, receive_time); std::vector packets_to_deliver; + for (const PacketInFlightInfo& packet : queue_->DequeueDroppedPackets()) { + packets_to_deliver.emplace_back(packet, PacketDeliveryInfo::kNotReceived); + } + // Check the extra delay queue. while (!delay_link_.empty() && receive_time >= delay_link_.front().arrival_time) { @@ -331,8 +350,8 @@ bool SimulatedNetwork::UpdateNextProcessTime() { break; } } - if (next_process_time_.IsInfinite() && !capacity_link_.empty()) { - next_process_time_ = capacity_link_.front().arrival_time; + if (next_process_time_.IsInfinite() && capacity_link_.has_value()) { + next_process_time_ = capacity_link_->arrival_time; } return next_process_time != next_process_time_; } diff --git a/test/network/simulated_network.h b/test/network/simulated_network.h index 7abf7edca8..80e40e6245 100644 --- a/test/network/simulated_network.h +++ b/test/network/simulated_network.h @@ -15,12 +15,13 @@ #include #include #include +#include #include -#include #include #include "absl/functional/any_invocable.h" #include "api/sequence_checker.h" +#include "api/test/network_emulation/network_queue.h" #include "api/test/simulated_network.h" #include "api/units/timestamp.h" #include "rtc_base/race_checker.h" @@ -39,11 +40,15 @@ namespace webrtc { // packet through at the time with a limited capacity. // - Extra delay with or without packets reorder // - Packet overhead -// - Queue max capacity +// Per default a simple leaky bucket queue is used that allows setting a max +// capacity. But more advanced AQM can be used. class RTC_EXPORT SimulatedNetwork : public SimulatedNetworkInterface { public: using Config = BuiltInNetworkBehaviorConfig; explicit SimulatedNetwork(Config config, uint64_t random_seed = 1); + SimulatedNetwork(Config config, + uint64_t random_seed, + std::unique_ptr queue); ~SimulatedNetwork() override; // Sets a new configuration. This will affect packets that will be sent with @@ -107,27 +112,27 @@ class RTC_EXPORT SimulatedNetwork : public SimulatedNetworkInterface { // Moves packets from capacity- to delay link. // If `previouse_config` is set, it is the config that was used until // `time_now_us` - void UpdateCapacityQueue(ConfigState state, Timestamp time_now) - RTC_RUN_ON(&process_checker_); - ConfigState GetConfigState() const; + void UpdateCapacityLink(ConfigState state, Timestamp time_now) + RTC_EXCLUSIVE_LOCKS_REQUIRED(&lock_); + void SetConfigLocked(const Config& config) + RTC_EXCLUSIVE_LOCKS_REQUIRED(&lock_); - mutable Mutex config_lock_; + // A note about threads: + // Some tests run the SimulatedNetwork on multiple threads. FakeNetworkPipe + // may call several methods on separate threads. Other tests call SetConfig + // on a thread other than the the other methods. + mutable Mutex lock_; // Guards the data structures involved in delay and loss processing, such as // the packet queues. RaceChecker process_checker_; - // Models the capacity of the network by rejecting packets if the queue is - // full and keeping them in the queue until they are ready to exit (according - // to the link capacity, which cannot be violated, e.g. a 1 kbps link will - // only be able to deliver 1000 bits per second). - // - // Invariant: - // The head of the `capacity_link_` has arrival_time correctly set to the - // time when the packet is supposed to be delivered (without accounting - // potential packet loss or potential extra delay and without accounting for a - // new configuration of the network, which requires a re-computation of the - // arrival_time). - std::queue capacity_link_ RTC_GUARDED_BY(process_checker_); + + // Queue of packets that have not yet entered the capacity link. + std::unique_ptr queue_ RTC_GUARDED_BY(lock_); + // Models the capacity of the network. There can only be one packet at the + // time in the capacity link. The time spend in the capacity link depends on + // the link capacity. + std::optional capacity_link_ RTC_GUARDED_BY(process_checker_); // Models the extra delay of the network (see `queue_delay_ms` // and `delay_standard_deviation_ms` in BuiltInNetworkBehaviorConfig), packets // in the `delay_link_` have technically already left the network and don't @@ -141,11 +146,11 @@ class RTC_EXPORT SimulatedNetwork : public SimulatedNetworkInterface { absl::AnyInvocable next_process_time_changed_callback_ RTC_GUARDED_BY(process_checker_) = nullptr; - ConfigState config_state_ RTC_GUARDED_BY(config_lock_); + ConfigState config_state_ RTC_GUARDED_BY(lock_); Random random_ RTC_GUARDED_BY(process_checker_); // Are we currently dropping a burst of packets? - bool bursting_; + bool bursting_ = false; // The send time of the last enqueued packet, this is only used to check that // the send time of enqueued packets is monotonically increasing. diff --git a/test/network/simulated_network_unittest.cc b/test/network/simulated_network_unittest.cc index 9c59ded933..ac402621ff 100644 --- a/test/network/simulated_network_unittest.cc +++ b/test/network/simulated_network_unittest.cc @@ -11,11 +11,15 @@ #include #include +#include #include +#include #include +#include "api/test/network_emulation/leaky_bucket_network_queue.h" #include "api/test/simulated_network.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 "test/gmock.h" @@ -25,8 +29,10 @@ namespace webrtc { namespace { using ::testing::ElementsAre; +using ::testing::Field; using ::testing::MockFunction; using ::testing::SizeIs; +using ::testing::UnorderedElementsAre; PacketInFlightInfo PacketWithSize(size_t size) { return PacketInFlightInfo(/*size=*/size, /*send_time_us=*/0, /*packet_id=*/1); @@ -106,6 +112,20 @@ TEST(SimulatedNetworkTest, EnqueueFailsWhenQueueLengthIsReached) { /*packet_id=*/3))); } +TEST(SimulatedNetworkTest, CanChangeQueueLength) { + SimulatedNetwork network = + SimulatedNetwork({.link_capacity = DataRate::KilobitsPerSec(1)}); + ASSERT_TRUE(network.EnqueuePacket( + PacketInFlightInfo(/*size=*/125, /*send_time_us=*/0, /*packet_id=*/1))); + ASSERT_TRUE(network.EnqueuePacket( + PacketInFlightInfo(/*size=*/125, /*send_time_us=*/0, /*packet_id=*/2))); + + network.SetConfig({.queue_length_packets = 1, + .link_capacity = DataRate::KilobitsPerSec(1)}); + EXPECT_FALSE(network.EnqueuePacket( + PacketInFlightInfo(/*size=*/125, /*send_time_us=*/0, /*packet_id=*/3))); +} + TEST(SimulatedNetworkTest, PacketOverhead) { // A packet of 125 bytes that gets enqueued on a network with 1 kbps capacity // should be ready to exit the network in 1 second, but since there is an @@ -462,7 +482,7 @@ TEST(SimulatedNetworkTest, QueueDelayMsWithStandardDeviationAndReorderAllowed) { /*receive_time_us=*/TimeDelta::Seconds(5).us()); ASSERT_EQ(delivered_packets.size(), 4ul); - // And they have been reordered accorting to the applied extra delay. + // And they have been reordered according to the applied extra delay. EXPECT_EQ(delivered_packets[0].packet_id, 3ul); EXPECT_EQ(delivered_packets[1].packet_id, 1ul); EXPECT_GE(delivered_packets[1].receive_time_us, @@ -561,18 +581,17 @@ TEST(SimulatedNetworkTest, PacketLossBurst) { EXPECT_EQ(delivered_packets.size(), 20ul); // Results in a burst of lost packets after the first packet lost. - // With the current random seed, the first 12 are not lost, while the - // last 8 are. - int current_packet = 0; + // With the current random seed, at least 5 packets are lost. + int num_lost_packets = 0; for (const auto& packet : delivered_packets) { - if (current_packet < 12) { - EXPECT_NE(packet.receive_time_us, PacketDeliveryInfo::kNotReceived); - current_packet++; - } else { + if (packet.receive_time_us == PacketDeliveryInfo::kNotReceived) { + num_lost_packets++; + } + if (num_lost_packets > 0) { EXPECT_EQ(packet.receive_time_us, PacketDeliveryInfo::kNotReceived); - current_packet++; } } + EXPECT_GT(num_lost_packets, 5); } TEST(SimulatedNetworkTest, PauseTransmissionUntil) { @@ -668,6 +687,31 @@ TEST(SimulatedNetworkTest, EnqueuePacketWithSubSecondNonMonotonicBehaviour) { EXPECT_EQ(delivered_packets[0].receive_time_us, TimeDelta::Seconds(3).us()); } +TEST(SimulatedNetworkTest, CanUseInjectedQueueAndDropPacketsAtQueueHead) { + auto queue = std::make_unique(); + LeakyBucketNetworkQueue* queue_ptr = queue.get(); + SimulatedNetwork network = + SimulatedNetwork({.link_capacity = DataRate::KilobitsPerSec(1)}, + /*random_seed=*/1, std::move(queue)); + ASSERT_TRUE(network.EnqueuePacket(PacketInFlightInfo( + DataSize::Bytes(125), Timestamp::Seconds(1), /*packet_id=*/0))); + ASSERT_TRUE(network.EnqueuePacket(PacketInFlightInfo( + DataSize::Bytes(125), Timestamp::Seconds(1), /*packet_id=*/1))); + + // packet 0 is already sent, packet 1 is in the queue and will be dropped. + queue_ptr->DropOldestPacket(); + + std::vector delivered_packets = + network.DequeueDeliverablePackets(network.NextDeliveryTimeUs().value()); + ASSERT_EQ(delivered_packets.size(), 2ul); + EXPECT_THAT( + delivered_packets, + UnorderedElementsAre(Field(&PacketDeliveryInfo::packet_id, 0), + AllOf(Field(&PacketDeliveryInfo::packet_id, 1), + Field(&PacketDeliveryInfo::receive_time_us, + PacketDeliveryInfo::kNotReceived)))); +} + // TODO(bugs.webrtc.org/14525): Re-enable when the DCHECK will be uncommented // and the non-monotonic events on real time clock tests is solved/understood. // TEST(SimulatedNetworkDeathTest, EnqueuePacketExpectMonotonicSendTime) { diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 4c23f1574c..3a32fd0dfd 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -106,6 +106,7 @@ if (!build_with_chromium) { ":echo_emulation", ":test_peer", "../..:copy_to_file_audio_capturer", + "../../../api:create_modular_peer_connection_factory", "../../../api:enable_media_with_defaults", "../../../api:libjingle_peerconnection_api", "../../../api:scoped_refptr", @@ -345,7 +346,6 @@ if (!build_with_chromium) { "../../../rtc_base:logging", "../../../rtc_base:rtc_event", "../../../system_wrappers:field_trial", - "../../../test:field_trial", "../../../test:fileutils", "../../../test:test_support", "analyzer/video:default_video_quality_analyzer", diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index c5a6d066cd..6fc07c7903 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -643,7 +643,7 @@ void PeerConnectionE2EQualityTest::ExchangeOfferAnswer( SignalingInterceptor* signaling_interceptor) { std::string log_output; - auto offer = alice_->CreateOffer(); + std::unique_ptr offer = alice_->CreateOffer(); RTC_CHECK(offer); offer->ToString(&log_output); RTC_LOG(LS_INFO) << "Original offer: " << log_output; @@ -660,7 +660,7 @@ void PeerConnectionE2EQualityTest::ExchangeOfferAnswer( bool set_remote_offer = bob_->SetRemoteDescription(std::move(patch_result.remote_sdp)); RTC_CHECK(set_remote_offer); - auto answer = bob_->CreateAnswer(); + std::unique_ptr answer = bob_->CreateAnswer(); RTC_CHECK(answer); answer->ToString(&log_output); RTC_LOG(LS_INFO) << "Original answer: " << log_output; diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index ca78fa4be6..981e38d929 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -19,6 +19,7 @@ #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/audio/audio_device.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn index 8edf94aeda..d644ea3a67 100644 --- a/test/peer_scenario/BUILD.gn +++ b/test/peer_scenario/BUILD.gn @@ -27,11 +27,11 @@ if (rtc_include_tests) { "..:fake_video_codecs", "..:fileutils", "..:frame_generator_capturer", - "..:scoped_key_value_config", "..:test_support", "../../api:array_view", "../../api:audio_options_api", "../../api:candidate", + "../../api:create_modular_peer_connection_factory", "../../api:enable_media_with_defaults", "../../api:field_trials", "../../api:libjingle_peerconnection_api", diff --git a/test/peer_scenario/peer_scenario_client.cc b/test/peer_scenario/peer_scenario_client.cc index 417cada52f..6fb8989c5f 100644 --- a/test/peer_scenario/peer_scenario_client.cc +++ b/test/peer_scenario/peer_scenario_client.cc @@ -22,6 +22,7 @@ #include "absl/memory/memory.h" #include "api/audio_options.h" #include "api/candidate.h" +#include "api/create_modular_peer_connection_factory.h" #include "api/data_channel_interface.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment.h" @@ -460,7 +461,7 @@ void PeerScenarioClient::SetSdpAnswer( CreateSessionDescription(SdpType::kAnswer, remote_answer), make_ref_counted( [remote_answer, done_handler](RTCError) { - auto answer = + std::unique_ptr answer = CreateSessionDescription(SdpType::kAnswer, remote_answer); done_handler(*answer); })); diff --git a/test/peer_scenario/scenario_connection.cc b/test/peer_scenario/scenario_connection.cc index 4787b9036d..50e3783c46 100644 --- a/test/peer_scenario/scenario_connection.cc +++ b/test/peer_scenario/scenario_connection.cc @@ -135,7 +135,7 @@ ScenarioIceConnectionImpl::ScenarioIceConnectionImpl( CreateRandomString(ICE_PWD_LENGTH), IceMode::ICEMODE_FULL, ConnectionRole::CONNECTIONROLE_PASSIVE, - SSLFingerprint::CreateFromCertificate(*certificate_.get()).get()), + SSLFingerprint::CreateFromCertificate(*certificate_).get()), network_manager_(manager_->ReleaseNetworkManager()), packet_socket_factory_(manager_->socket_factory()), port_allocator_( diff --git a/test/peer_scenario/signaling_route.cc b/test/peer_scenario/signaling_route.cc index 7fe3b859e0..f2dc16d12c 100644 --- a/test/peer_scenario/signaling_route.cc +++ b/test/peer_scenario/signaling_route.cc @@ -69,7 +69,8 @@ void StartSdpNegotiation( std::function exchange_finished) { caller->CreateAndSetSdp(munge_offer, [=](std::string sdp_offer) { if (modify_offer) { - auto offer = CreateSessionDescription(SdpType::kOffer, sdp_offer); + std::unique_ptr offer = + CreateSessionDescription(SdpType::kOffer, sdp_offer); modify_offer(offer.get()); RTC_CHECK(offer->ToString(&sdp_offer)); } diff --git a/test/peer_scenario/tests/BUILD.gn b/test/peer_scenario/tests/BUILD.gn index 85a30dee65..b4c18009a5 100644 --- a/test/peer_scenario/tests/BUILD.gn +++ b/test/peer_scenario/tests/BUILD.gn @@ -30,6 +30,7 @@ if (rtc_include_tests) { "../../../api:rtp_transceiver_direction", "../../../api:scoped_refptr", "../../../api/test/network_emulation", + "../../../api/test/network_emulation:network_queue", "../../../api/transport:ecn_marking", "../../../api/units:data_rate", "../../../api/units:time_delta", diff --git a/test/peer_scenario/tests/l4s_test.cc b/test/peer_scenario/tests/l4s_test.cc index f65a24fff9..5aad1f86a8 100644 --- a/test/peer_scenario/tests/l4s_test.cc +++ b/test/peer_scenario/tests/l4s_test.cc @@ -17,6 +17,7 @@ #include "api/scoped_refptr.h" #include "api/stats/rtc_stats_report.h" #include "api/stats/rtcstats_objects.h" +#include "api/test/network_emulation/dual_pi2_network_queue.h" #include "api/test/network_emulation/network_emulation_interfaces.h" #include "api/transport/ecn_marking.h" #include "api/units/data_rate.h" @@ -191,7 +192,7 @@ TEST(L4STest, DISABLED_NegotiateAndUseCcfbIfEnabled) { EXPECT_EQ(ret_node_feedback_counter.FeedbackAccordingToTransportCc(), 0); } -TEST(L4STest, CallerAdaptToLinkCapacityWithoutEcn) { +TEST(L4STest, CallerAdaptToLinkCapacityOnNetworkWithoutEcn) { PeerScenario s(*test_info_); PeerScenarioClient::Config config; @@ -213,7 +214,56 @@ TEST(L4STest, CallerAdaptToLinkCapacityWithoutEcn) { auto signaling = s.ConnectSignaling(caller, callee, {caller_to_callee}, {callee_to_caller}); PeerScenarioClient::VideoSendTrackConfig video_conf; - video_conf.generator.squares_video->framerate = 15; + video_conf.generator.squares_video->framerate = 30; + video_conf.generator.squares_video->width = 640; + video_conf.generator.squares_video->height = 360; + caller->CreateVideo("VIDEO_1", video_conf); + + signaling.StartIceSignaling(); + std::atomic offer_exchange_done(false); + signaling.NegotiateSdp([&](const SessionDescriptionInterface& answer) { + offer_exchange_done = true; + }); + s.WaitAndProcess(&offer_exchange_done); + s.ProcessMessages(TimeDelta::Seconds(3)); + DataRate available_bwe = + GetAvailableSendBitrate(GetStatsAndProcess(s, caller)); + EXPECT_GT(available_bwe.kbps(), 450); + EXPECT_LT(available_bwe.kbps(), 610); +} + +// Note - this test only test that the +// caller adapt to the link capacity. It does not test that the caller uses ECN +// to adapt even though the network can mark packets with CE. +// TODO: bugs.webrtc.org/42225697 - actually test that the caller adapt to ECN +// marking. +TEST(L4STest, CallerAdaptToLinkCapacityOnNetworkWithEcn) { + PeerScenario s(*test_info_); + PeerScenarioClient::Config config; + config.field_trials.Set("WebRTC-RFC8888CongestionControlFeedback", "Enabled"); + + PeerScenarioClient* caller = s.CreateClient(config); + PeerScenarioClient* callee = s.CreateClient(config); + + DualPi2NetworkQueueFactory dual_pi_factory({}); + auto caller_to_callee = s.net() + ->NodeBuilder() + .queue_factory(dual_pi_factory) + .capacity(DataRate::KilobitsPerSec(600)) + .Build() + .node; + auto callee_to_caller = s.net()->NodeBuilder().Build().node; + s.net()->CreateRoute(caller->endpoint(), {caller_to_callee}, + callee->endpoint()); + s.net()->CreateRoute(callee->endpoint(), {callee_to_caller}, + caller->endpoint()); + + auto signaling = s.ConnectSignaling(caller, callee, {caller_to_callee}, + {callee_to_caller}); + PeerScenarioClient::VideoSendTrackConfig video_conf; + video_conf.generator.squares_video->framerate = 30; + video_conf.generator.squares_video->width = 640; + video_conf.generator.squares_video->height = 360; caller->CreateVideo("VIDEO_1", video_conf); signaling.StartIceSignaling(); @@ -225,7 +275,7 @@ TEST(L4STest, CallerAdaptToLinkCapacityWithoutEcn) { s.ProcessMessages(TimeDelta::Seconds(3)); DataRate available_bwe = GetAvailableSendBitrate(GetStatsAndProcess(s, caller)); - EXPECT_GT(available_bwe.kbps(), 500); + EXPECT_GT(available_bwe.kbps(), 450); EXPECT_LT(available_bwe.kbps(), 610); } diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn index 7616dc237d..4b6f8f54f9 100644 --- a/test/scenario/BUILD.gn +++ b/test/scenario/BUILD.gn @@ -222,7 +222,6 @@ if (rtc_include_tests && !build_with_chromium) { "../../rtc_base:rtc_stats_counters", "../../system_wrappers", "../../system_wrappers:field_trial", - "../../test:field_trial", "../../test:test_support", "../../test:video_test_constants", "../logging:log_writer", diff --git a/test/scenario/call_client.cc b/test/scenario/call_client.cc index 332facbe15..0b8850259c 100644 --- a/test/scenario/call_client.cc +++ b/test/scenario/call_client.cc @@ -291,11 +291,6 @@ DataRate CallClient::target_rate() const { return network_controller_factory_.GetUpdate().target_rate->target_rate; } -DataRate CallClient::stable_target_rate() const { - return network_controller_factory_.GetUpdate() - .target_rate->stable_target_rate; -} - DataRate CallClient::padding_rate() const { return network_controller_factory_.GetUpdate().pacer_config->pad_rate(); } diff --git a/test/scenario/call_client.h b/test/scenario/call_client.h index 9691ef3073..a3c9c40056 100644 --- a/test/scenario/call_client.h +++ b/test/scenario/call_client.h @@ -131,7 +131,6 @@ class CallClient : public EmulatedNetworkReceiverInterface { return DataRate::BitsPerSec(GetStats().send_bandwidth_bps); } DataRate target_rate() const; - DataRate stable_target_rate() const; DataRate padding_rate() const; void UpdateBitrateConstraints(const BitrateConstraints& constraints); void SetRemoteBitrate(DataRate bitrate); diff --git a/test/scoped_key_value_config.cc b/test/scoped_key_value_config.cc deleted file mode 100644 index 3e0497730b..0000000000 --- a/test/scoped_key_value_config.cc +++ /dev/null @@ -1,128 +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/scoped_key_value_config.h" - -#include -#include -#include -#include - -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" - -namespace { - -// This part is copied from system_wrappers/field_trial.cc. -void InsertIntoMap( - std::map>& key_value_map, - 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()); -} - -} // namespace - -namespace webrtc { -namespace test { - -ScopedKeyValueConfig::ScopedKeyValueConfig() - : ScopedKeyValueConfig(nullptr, "") {} - -ScopedKeyValueConfig::ScopedKeyValueConfig(absl::string_view s) - : ScopedKeyValueConfig(nullptr, s) {} - -ScopedKeyValueConfig::ScopedKeyValueConfig(ScopedKeyValueConfig& parent, - absl::string_view s) - : ScopedKeyValueConfig(&parent, s) {} - -ScopedKeyValueConfig::ScopedKeyValueConfig(ScopedKeyValueConfig* parent, - absl::string_view s) - : parent_(parent), leaf_(nullptr) { - InsertIntoMap(key_value_map_, s); - - if (!s.empty()) { - // Also store field trials in global string (until we get rid of it). - scoped_field_trials_ = std::make_unique(s); - } - - if (parent == nullptr) { - // We are root, set leaf_. - leaf_ = this; - } else { - // Link root to new leaf. - GetRoot(parent)->leaf_ = this; - RTC_DCHECK(leaf_ == nullptr); - } -} - -ScopedKeyValueConfig::~ScopedKeyValueConfig() { - if (parent_) { - GetRoot(parent_)->leaf_ = parent_; - } -} - -ScopedKeyValueConfig* ScopedKeyValueConfig::GetRoot(ScopedKeyValueConfig* n) { - while (n->parent_ != nullptr) { - n = n->parent_; - } - return n; -} - -std::string ScopedKeyValueConfig::GetValue(absl::string_view key) const { - if (parent_ == nullptr) { - return leaf_->LookupRecurse(key); - } else { - return LookupRecurse(key); - } -} - -std::string ScopedKeyValueConfig::LookupRecurse(absl::string_view key) const { - auto it = key_value_map_.find(key); - if (it != key_value_map_.end()) - return it->second; - - if (parent_) { - return parent_->LookupRecurse(key); - } - - // 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 field_trial::FindFullName(std::string(key)); -} - -} // namespace test -} // namespace webrtc diff --git a/test/scoped_key_value_config.h b/test/scoped_key_value_config.h deleted file mode 100644 index c0023f8228..0000000000 --- a/test/scoped_key_value_config.h +++ /dev/null @@ -1,54 +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. - */ - -#ifndef TEST_SCOPED_KEY_VALUE_CONFIG_H_ -#define TEST_SCOPED_KEY_VALUE_CONFIG_H_ - -#include -#include -#include -#include - -#include "absl/strings/string_view.h" -#include "api/field_trials_registry.h" -#include "test/field_trial.h" - -namespace webrtc { -namespace test { - -class ScopedKeyValueConfig : public FieldTrialsRegistry { - public: - virtual ~ScopedKeyValueConfig(); - ScopedKeyValueConfig(); - explicit ScopedKeyValueConfig(absl::string_view s); - ScopedKeyValueConfig(ScopedKeyValueConfig& parent, absl::string_view s); - - private: - ScopedKeyValueConfig(ScopedKeyValueConfig* parent, absl::string_view s); - ScopedKeyValueConfig* GetRoot(ScopedKeyValueConfig* n); - std::string GetValue(absl::string_view key) const override; - std::string LookupRecurse(absl::string_view key) const; - - ScopedKeyValueConfig* const parent_; - - // The leaf in a list of stacked ScopedKeyValueConfig. - // Only set on root (e.g with parent_ == nullptr). - const ScopedKeyValueConfig* leaf_; - - // Unlike std::less, std::less<> is transparent and allows - // heterogeneous lookup directly with absl::string_view. - std::map> key_value_map_; - std::unique_ptr scoped_field_trials_; -}; - -} // namespace test -} // namespace webrtc - -#endif // TEST_SCOPED_KEY_VALUE_CONFIG_H_ diff --git a/test/test_flags.cc b/test/test_flags.cc index b53e60dc6b..6e5b9f7f45 100644 --- a/test/test_flags.cc +++ b/test/test_flags.cc @@ -38,11 +38,6 @@ ABSL_FLAG(std::string, "MetricsSet as a root proto. On iOS, this MUST be a file name " "and the file will be stored under NSDocumentDirectory."); -ABSL_FLAG(bool, - export_perf_results_new_api, - false, - "Tells to initialize new API for exporting performance metrics"); - ABSL_FLAG(bool, webrtc_quick_perf_test, false, diff --git a/test/test_flags.h b/test/test_flags.h index 1eab5babfd..6635c9109f 100644 --- a/test/test_flags.h +++ b/test/test_flags.h @@ -15,15 +15,9 @@ #include "absl/flags/declare.h" -// TODO: bugs.webrtc.org/419453427 - Remove this flag declaration from the -// header when tests are migrated to use this flag through the -// CreateTestFieldTrials function bypassing global field trials string. -ABSL_DECLARE_FLAG(std::string, force_fieldtrials); - ABSL_DECLARE_FLAG(std::vector, plot); ABSL_DECLARE_FLAG(std::string, isolated_script_test_perf_output); ABSL_DECLARE_FLAG(std::string, webrtc_test_metrics_output_path); -ABSL_DECLARE_FLAG(bool, export_perf_results_new_api); ABSL_DECLARE_FLAG(bool, webrtc_quick_perf_test); #endif // TEST_TEST_FLAGS_H_ diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc index c665cc731c..41b54701f1 100644 --- a/test/test_main_lib.cc +++ b/test/test_main_lib.cc @@ -28,18 +28,15 @@ #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/event_tracer.h" #include "rtc_base/logging.h" #include "rtc_base/ssl_adapter.h" #include "rtc_base/ssl_stream_adapter.h" -#include "system_wrappers/include/field_trial.h" #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" #if defined(RTC_USE_PERFETTO) @@ -142,10 +139,6 @@ class TestMainImpl : public TestMain { LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs) || absl::GetFlag(FLAGS_verbose)); - // InitFieldTrialsFromString stores the char*, so the char array must - // outlive the application. - field_trials_ = absl::GetFlag(FLAGS_force_fieldtrials); - field_trial::InitFieldTrialsFromString(field_trials_.c_str()); metrics::Enable(); #if defined(WEBRTC_WIN) @@ -193,7 +186,6 @@ class TestMainImpl : public TestMain { #if defined(WEBRTC_IOS) test::InitTestSuite(RUN_ALL_TESTS, argc, argv, absl::GetFlag(FLAGS_write_perf_output_on_ios), - absl::GetFlag(FLAGS_export_perf_results_new_api), absl::GetFlag(FLAGS_webrtc_test_metrics_output_path), metrics_to_plot); test::RunTestsFromIOSApp(); @@ -202,21 +194,16 @@ class TestMainImpl : public TestMain { int exit_code = RUN_ALL_TESTS(); std::vector> exporters; - 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( - test::MetricsSetProtoFileExporter::Options( - absl::GetFlag(FLAGS_webrtc_test_metrics_output_path)))); - } - if (!absl::GetFlag(FLAGS_isolated_script_test_perf_output).empty()) { - exporters.push_back( - std::make_unique( - absl::GetFlag(FLAGS_isolated_script_test_perf_output))); - } - } else { + exporters.push_back(std::make_unique()); + if (!absl::GetFlag(FLAGS_webrtc_test_metrics_output_path).empty()) { + 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( - std::make_unique()); + std::make_unique( + absl::GetFlag(FLAGS_isolated_script_test_perf_output))); } // Log number of tests that should be run, are disabled or skipped and total // number. @@ -244,18 +231,6 @@ class TestMainImpl : public TestMain { 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 (!test::WritePerfResults(perf_output_file)) { - return 1; - } - } - if (metrics_to_plot) { - test::PrintPlottableResults(*metrics_to_plot); - } - } std::string result_filename = absl::GetFlag(FLAGS_isolated_script_test_output); diff --git a/test/test_main_lib.h b/test/test_main_lib.h index 2233171c60..28af261eb0 100644 --- a/test/test_main_lib.h +++ b/test/test_main_lib.h @@ -11,7 +11,6 @@ #define TEST_TEST_MAIN_LIB_H_ #include -#include namespace webrtc { @@ -34,8 +33,6 @@ class TestMain { protected: TestMain() = default; - - std::string field_trials_; }; } // namespace webrtc diff --git a/test/testsupport/video_frame_writer_unittest.cc b/test/testsupport/video_frame_writer_unittest.cc index 2c32409f4c..9c858a1900 100644 --- a/test/testsupport/video_frame_writer_unittest.cc +++ b/test/testsupport/video_frame_writer_unittest.cc @@ -32,15 +32,15 @@ namespace webrtc { namespace test { namespace { -const size_t kFrameWidth = 50; -const size_t kFrameHeight = 20; -const size_t kFrameLength = 3 * kFrameWidth * kFrameHeight / 2; // I420. -const size_t kFrameRate = 30; +constexpr size_t kFrameWidth = 50; +constexpr size_t kFrameHeight = 20; +constexpr size_t kFrameLength = 3 * kFrameWidth * kFrameHeight / 2; // I420. +constexpr size_t kFrameRate = 30; // Size of header: "YUV4MPEG2 W50 H20 F30:1 C420\n" -const size_t kFileHeaderSize = 29; +constexpr size_t kFileHeaderSize = 29; // Size of header: "FRAME\n" -const size_t kFrameHeaderSize = 6; +constexpr size_t kFrameHeaderSize = 6; scoped_refptr CreateI420Buffer(int width, int height) { scoped_refptr buffer(I420Buffer::Create(width, height)); diff --git a/test/testsupport/y4m_frame_writer_unittest.cc b/test/testsupport/y4m_frame_writer_unittest.cc index f2acc00777..af287e6558 100644 --- a/test/testsupport/y4m_frame_writer_unittest.cc +++ b/test/testsupport/y4m_frame_writer_unittest.cc @@ -24,10 +24,10 @@ namespace webrtc { namespace test { namespace { -const size_t kFrameWidth = 50; -const size_t kFrameHeight = 20; -const size_t kFrameLength = 3 * kFrameWidth * kFrameHeight / 2; // I420. -const size_t kFrameRate = 30; +constexpr size_t kFrameWidth = 50; +constexpr size_t kFrameHeight = 20; +constexpr size_t kFrameLength = 3 * kFrameWidth * kFrameHeight / 2; // I420. +constexpr size_t kFrameRate = 30; const std::string kFileHeader = "YUV4MPEG2 W50 H20 F30:1 C420\n"; const std::string kFrameHeader = "FRAME\n"; diff --git a/test/testsupport/yuv_frame_reader.cc b/test/testsupport/yuv_frame_reader.cc index b3383295e3..eff940049b 100644 --- a/test/testsupport/yuv_frame_reader.cc +++ b/test/testsupport/yuv_frame_reader.cc @@ -54,7 +54,7 @@ scoped_refptr Scale(scoped_refptr buffer, } scoped_refptr scaled( I420Buffer::Create(resolution.width, resolution.height)); - scaled->ScaleFrom(*buffer.get()); + scaled->ScaleFrom(*buffer); return scaled; } } // namespace diff --git a/test/testsupport/yuv_frame_writer_unittest.cc b/test/testsupport/yuv_frame_writer_unittest.cc index 63c3cd14e3..19a259ec4b 100644 --- a/test/testsupport/yuv_frame_writer_unittest.cc +++ b/test/testsupport/yuv_frame_writer_unittest.cc @@ -24,9 +24,9 @@ namespace webrtc { namespace test { namespace { -const size_t kFrameWidth = 50; -const size_t kFrameHeight = 20; -const size_t kFrameLength = 3 * kFrameWidth * kFrameHeight / 2; // I420. +constexpr size_t kFrameWidth = 50; +constexpr size_t kFrameHeight = 20; +constexpr size_t kFrameLength = 3 * kFrameWidth * kFrameHeight / 2; // I420. } // namespace class YuvFrameWriterTest : public ::testing::Test { diff --git a/test/time_controller/simulated_time_controller.cc b/test/time_controller/simulated_time_controller.cc index 69851570d4..31b8701fcd 100644 --- a/test/time_controller/simulated_time_controller.cc +++ b/test/time_controller/simulated_time_controller.cc @@ -231,14 +231,4 @@ void GlobalSimulatedTimeController::SkipForwardBy(TimeDelta duration) { global_clock_.AdvanceTime(duration); } -void GlobalSimulatedTimeController::Register( - sim_time_impl::SimulatedSequenceRunner* runner) { - impl_.Register(runner); -} - -void GlobalSimulatedTimeController::Unregister( - sim_time_impl::SimulatedSequenceRunner* runner) { - impl_.Unregister(runner); -} - } // namespace webrtc diff --git a/test/time_controller/simulated_time_controller.h b/test/time_controller/simulated_time_controller.h index b934941fc6..7db48832f0 100644 --- a/test/time_controller/simulated_time_controller.h +++ b/test/time_controller/simulated_time_controller.h @@ -151,17 +151,6 @@ class GlobalSimulatedTimeController : public TimeController { // Useful for simulating contention on destination queues. void SkipForwardBy(TimeDelta duration); - // Makes the simulated time controller aware of a custom - // SimulatedSequenceRunner. - // TODO(bugs.webrtc.org/11581): remove method once the ModuleRtpRtcpImpl2 unit - // test stops using it. - void Register(sim_time_impl::SimulatedSequenceRunner* runner); - // Removes a previously installed custom SimulatedSequenceRunner from the - // simulated time controller. - // TODO(bugs.webrtc.org/11581): remove method once the ModuleRtpRtcpImpl2 unit - // test stops using it. - void Unregister(sim_time_impl::SimulatedSequenceRunner* runner); - private: ScopedBaseFakeClock global_clock_; // Provides simulated CurrentNtpInMilliseconds() diff --git a/test/video_codec_tester_unittest.cc b/test/video_codec_tester_unittest.cc index ff863e0ab4..86fea7c874 100644 --- a/test/video_codec_tester_unittest.cc +++ b/test/video_codec_tester_unittest.cc @@ -85,8 +85,8 @@ using Stream = VideoCodecTester::VideoCodecStats::Stream; constexpr int kWidth = 2; constexpr int kHeight = 2; -const DataRate kBitrate = DataRate::BytesPerSec(100); -const Frequency kFramerate = Frequency::Hertz(30); +constexpr DataRate kBitrate = DataRate::BytesPerSec(100); +constexpr Frequency kFramerate = Frequency::Hertz(30); constexpr Frequency k90kHz = Frequency::Hertz(90000); scoped_refptr CreateYuvBuffer(uint8_t y = 0, diff --git a/tools_webrtc/android/build_aar.py b/tools_webrtc/android/build_aar.py index e394f75883..2fbce97c60 100755 --- a/tools_webrtc/android/build_aar.py +++ b/tools_webrtc/android/build_aar.py @@ -26,14 +26,14 @@ import argparse import logging import os -import shutil +import pathlib import subprocess import sys -import tempfile import zipfile SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir)) +DEFAULT_BUILD_DIR = os.path.join(SRC_DIR, 'out_aar') DEFAULT_ARCHS = ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'] NEEDED_SO_FILES = ['libjingle_peerconnection_so.so'] JAR_FILE = 'lib.java/sdk/android/libwebrtc.jar' @@ -55,6 +55,7 @@ def _ParseArgs(): parser.add_argument( '--build-dir', type=os.path.abspath, + default=DEFAULT_BUILD_DIR, help='Build dir. By default will create and use temporary dir.') parser.add_argument('--output', default='libwebrtc.aar', @@ -230,18 +231,17 @@ def GenerateLicenses(output_dir, build_dir, archs): builder.generate_license_text(output_dir) -def BuildAar(archs, +def BuildAar(build_dir, + archs, output_file, use_remoteexec=False, extra_gn_args=None, - ext_build_dir=None, extra_gn_switches=None, extra_ninja_switches=None, unstripped=False): extra_gn_args = extra_gn_args or [] extra_gn_switches = extra_gn_switches or [] extra_ninja_switches = extra_ninja_switches or [] - build_dir = ext_build_dir if ext_build_dir else tempfile.mkdtemp() for arch in archs: Build(build_dir, arch, use_remoteexec, extra_gn_args, @@ -256,17 +256,19 @@ def BuildAar(archs, license_dir = os.path.dirname(os.path.realpath(output_file)) GenerateLicenses(license_dir, build_dir, archs) - if not ext_build_dir: - shutil.rmtree(build_dir, True) - def main(): args = _ParseArgs() logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) - BuildAar(args.arch, args.output, args.use_remoteexec, args.extra_gn_args, - args.build_dir, args.extra_gn_switches, args.extra_ninja_switches, - args.use_unstripped_libs) + if not pathlib.Path(args.build_dir).is_relative_to(SRC_DIR): + logging.error('--build-dir must be under %s.', SRC_DIR) + return 1 + + return BuildAar(args.build_dir, args.arch, args.output, + args.use_remoteexec, args.extra_gn_args, + args.extra_gn_switches, args.extra_ninja_switches, + args.use_unstripped_libs) if __name__ == '__main__': diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 7165f8fdd6..3406f3fc30 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -90,7 +90,11 @@ def FindRootPath(): GCS_OBJECTS_ERROR = ( 'The number of objects in %s is different between ' - 'Chromium\'s DEPS and WebRTC\'s DEPS. They must be the same.') + 'Chromium\'s DEPS and WebRTC\'s DEPS. They must be the same.\n' + 'Old: %s\nNew: %s\n' + 'Manually update the DEPS file and add appropriate conditions for any new ' + 'objects. Note that the order of objects matter and must be the same as in ' + 'Chromium.') sys.path.append(os.path.join(CHECKOUT_ROOT_DIR, 'build')) import find_depot_tools @@ -326,11 +330,12 @@ def AddVersionEntry(vars_subdict): 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: + old_object_names = [x['object_name'] for x in old_pkg.objects] + new_object_names = [x['object_name'] for x in new_pkg.objects] + assert len(old_pkg.objects) == len( + new_pkg.objects), (GCS_OBJECTS_ERROR % + (path, old_object_names, new_object_names)) + if old_object_names != new_object_names: objects = [ ','.join([ o['object_name'], o['sha256sum'], @@ -339,8 +344,8 @@ def _FindChangedGcsPackage(path, old_pkg, new_pkg): ]) for o in new_pkg.objects ] setdep_arg = '%s@%s' % (path, '?'.join(objects)) - yield ChangedGcsPackage(path, setdep_arg, current_version_str, - new_version_str) + yield ChangedGcsPackage(path, setdep_arg, ','.join(old_object_names), + ','.join(new_object_names)) def _FindChangedCipdPackages(path, old_pkgs, new_pkgs): diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py index 24c5c27444..8118513dba 100755 --- a/tools_webrtc/ios/build_ios_libs.py +++ b/tools_webrtc/ios/build_ios_libs.py @@ -15,6 +15,7 @@ import argparse import logging import os +import pathlib import shutil import subprocess import sys @@ -228,6 +229,10 @@ def main(): logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) + if not pathlib.Path(args.output_dir).is_relative_to(SRC_DIR): + logging.error('--output-dir must be under %s.', SRC_DIR) + return 1 + if args.clean: _CleanArtifacts(args.output_dir) return 0 diff --git a/tools_webrtc/iwyu/apply_include_cleaner.py b/tools_webrtc/iwyu/apply_include_cleaner.py index 25fc3613ad..ad89a526a0 100755 --- a/tools_webrtc/iwyu/apply_include_cleaner.py +++ b/tools_webrtc/iwyu/apply_include_cleaner.py @@ -40,6 +40,7 @@ import argparse import re import pathlib +import os import subprocess import sys from typing import Tuple @@ -54,10 +55,12 @@ _GTEST_KEY = '"gtest/gtest.h"' _GTEST_VALUE = '"test/gtest.h"' _IWYU_MAPPING = { + # Literal matches not followed e.g. by IWYU pragma. '"gmock/gmock.h"': '"test/gmock.h"', _GTEST_KEY: _GTEST_VALUE, '': '"rtc_base/net_helpers.h"', - +} +_IWYU_THIRD_PARTY = { # IWYU does not refer to the complete third_party/ path. '"libyuv/': '"third_party/libyuv/include/libyuv/', '"aom/': '"third_party/libaom/source/libaom/aom/', @@ -67,14 +70,41 @@ # Supported file suffices. _SUFFICES = [".cc", ".h"] -# Ignored headers, used with `clang-include-cleaner --ignore-headers=` +# Ignored headers, regexps used with `clang-include-cleaner --ignore-headers=` _IGNORED_HEADERS = [ - ".pb.h", # generated protobuf files. - "pipewire/.*.h", # pipewire. - "spa/.*.h", # pipewire. - "openssl/.*.h", # openssl/boringssl. + "\\.pb\\.h", # generated protobuf files. + "pipewire\\/.*\\.h", # pipewire. + "spa\\/.*\\.h", # pipewire. + "glib\\.h", # glib. + "glibconfig\\.h", # glib. + "glib-object\\.h", # glib. + "gio\\/.*\\.h", # glib. + "openssl\\/.*\\.h", # openssl/boringssl. + "alsa\\/.*\\.h", # ALSA. + "pulse\\/.*\\.h", # PulseAudio. + "bits\\/.*\\.h", # pthreads. + "jpeglibmangler\\.h", # libjpeg. + "libavcodec\\/.*\\.h", # ffmpeg. + "libavutil\\/.*\\.h", # ffmpeg. ] +_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +_SRC_DIR = os.path.abspath(os.path.join(_SCRIPT_DIR, os.pardir, os.pardir)) +sys.path.append(os.path.join(_SRC_DIR, "build")) +import find_depot_tools + +_GN_BINARY_PATH = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, "gn.py") + + +# Check that the file is part of a build target on this platform. +def _is_built(filename, work_dir): + gn_cmd = (_GN_BINARY_PATH, "refs", "-C", work_dir, filename) + gn_result = subprocess.run(gn_cmd, + capture_output=True, + text=True, + check=False) + return gn_result.returncode == 0 + def _parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser( description="Runs the include-cleaner tool on a list of files", @@ -184,6 +214,12 @@ def _modified_content(content: str) -> str: modified_content, flags=re.MULTILINE) for key, value in _IWYU_MAPPING.items(): + # These must be exact matches, e.g. not having a trailing IWYU pragma. + modified_content = re.sub(rf'^#include {re.escape(key)}$', + f'#include {value}', + modified_content, + flags=re.MULTILINE) + for key, value in _IWYU_THIRD_PARTY.items(): modified_content = re.sub(rf'^#include {re.escape(key)}', f'#include {value}', modified_content, @@ -191,7 +227,6 @@ def _modified_content(content: str) -> str: return modified_content - # Transitioning the cmd type to tuple to prevent modification of # the original command from the callsite in main... def apply_include_cleaner_to_file(file_path: pathlib.Path, should_modify: bool, @@ -266,6 +301,10 @@ def main() -> None: for file in args.files: if not file.suffix in _SUFFICES: continue + if not _is_built(file, args.work_dir): + print( + f"Skipping include cleaner as {file} is not referenced by GN.") + continue changes_generated = bool( apply_include_cleaner_to_file(file, should_modify, tuple(cmd)) or changes_generated) diff --git a/tools_webrtc/iwyu/apply_include_cleaner_test.py b/tools_webrtc/iwyu/apply_include_cleaner_test.py index c3415910a2..3248bf5a33 100755 --- a/tools_webrtc/iwyu/apply_include_cleaner_test.py +++ b/tools_webrtc/iwyu/apply_include_cleaner_test.py @@ -44,6 +44,17 @@ def test_content_modification(self, mock_subprocess): file.write_text.assert_called_once_with( '#include "third_party/libyuv/include/libyuv/something.h"') + @mock.patch('subprocess.run', + return_value=mock.Mock(stdout=_OUTPUT, returncode=0)) + def test_pragma_no_modification(self, mock_subprocess): + file = mock.Mock() + file.read_text.return_value = '#include // IWYU' + output = apply_include_cleaner.apply_include_cleaner_to_file( + file, should_modify=True, cmd=[]) + self.assertEqual(output, self._OUTPUT) + mock_subprocess.assert_called_once() + file.write_text.assert_not_called() + @mock.patch('subprocess.run', return_value=mock.Mock(stdout=f'+ {_GTEST_KEY}\n', returncode=0)) diff --git a/tools_webrtc/mb/mb_config.pyl b/tools_webrtc/mb/mb_config.pyl index 8c3e8f97e5..0373d126e9 100644 --- a/tools_webrtc/mb/mb_config.pyl +++ b/tools_webrtc/mb/mb_config.pyl @@ -127,8 +127,7 @@ 'Perf Android32 (R Pixel5)': 'release_bot_x64', 'Perf Android64 (R Pixel5)': 'release_bot_x64', 'Perf Fuchsia': 'release_bot_x64_fuchsia', - 'Perf Linux Bionic': 'release_bot_x64', - 'Perf Linux Trusty': 'release_bot_x64', + 'Perf Linux': 'release_bot_x64', 'Perf Mac 11': 'release_bot_x64', 'Perf Mac M1 Arm64 12': 'release_bot_x64', 'Perf Win 10': 'release_bot_x64', @@ -526,7 +525,6 @@ 'debug', 'remoteexec', 'strict_field_trials', - 'disallow_deprecated_namespaces' ], }, 'debug_static_bot': { @@ -535,16 +533,11 @@ 'minimal_symbols', 'remoteexec', 'strict_field_trials', - 'disallow_deprecated_namespaces', ], }, 'disable_trace_events': { 'gn_args': 'rtc_disable_trace_events=true', }, - # TODO(b/42232595): Remove once the GN flag is removed. - 'disallow_deprecated_namespaces': { - 'gn_args': 'rtc_allow_deprecated_namespaces=false' - }, 'dummy_audio_file_devices': { 'gn_args': 'rtc_use_dummy_audio_file_devices=true', }, @@ -627,7 +620,6 @@ 'pure_release_bot', 'dcheck_always_on', 'strict_field_trials', - 'disallow_deprecated_namespaces', ], }, 'remoteexec': { diff --git a/tools_webrtc/ubsan/suppressions.txt b/tools_webrtc/ubsan/suppressions.txt index 2ece795570..972fb54fbc 100644 --- a/tools_webrtc/ubsan/suppressions.txt +++ b/tools_webrtc/ubsan/suppressions.txt @@ -10,11 +10,6 @@ src:*/third_party/ffmpeg/libavcodec/* src:*/third_party/openh264/* -# TODO(bugs.webrtc.org/11110). -# Remove those once upstream code has been cleaned. -src:*/third_party/abseil-cpp/absl/debugging/* -src:*/third_party/libvpx/source/libvpx/vp8/* - ############################################################################# # Ignore system libraries. src:*/usr/* diff --git a/tools_webrtc/ubsan/vptr_suppressions.txt b/tools_webrtc/ubsan/vptr_suppressions.txt index 617ba88f98..30789569ec 100644 --- a/tools_webrtc/ubsan/vptr_suppressions.txt +++ b/tools_webrtc/ubsan/vptr_suppressions.txt @@ -20,8 +20,3 @@ src:*/third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc src:*/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc src:*/third_party/protobuf/src/google/protobuf/descriptor.pb.cc -############################################################################# -# UBsan goes into an infinite recursion when __dynamic_cast instrumented with -# "vptr". See crbug.com/609786. - -src:*/third_party/libc\+\+abi/trunk/src/private_typeinfo.cpp diff --git a/video/BUILD.gn b/video/BUILD.gn index af02a74467..b9bbf1c3b9 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -448,8 +448,8 @@ rtc_library("video_stream_encoder_impl") { "../api:sequence_checker", "../api/adaptation:resource_adaptation_api", "../api/environment", + "../api/task_queue", "../api/task_queue:pending_task_safety_flag", - "../api/task_queue:task_queue", "../api/units:data_rate", "../api/units:data_size", "../api/units:time_delta", @@ -724,12 +724,9 @@ if (rtc_include_tests) { "../api/video_codecs:video_codecs_api", "../rtc_base:checks", "../rtc_base:logging", - "../system_wrappers:field_trial", - "../test:field_trial", "../test:run_test", "../test:run_test_interface", "../test:test_common", - "../test:test_flags", "../test:test_renderer", "../test:test_support", "//testing/gtest", @@ -768,12 +765,9 @@ if (rtc_include_tests) { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:stringutils", - "../system_wrappers:field_trial", - "../test:field_trial", "../test:run_test", "../test:run_test_interface", "../test:test_common", - "../test:test_flags", "../test:test_renderer", "../test:test_support", "//third_party/abseil-cpp/absl/flags:flag", @@ -795,12 +789,9 @@ if (rtc_include_tests) { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:stringutils", - "../system_wrappers:field_trial", - "../test:field_trial", "../test:run_test", "../test:run_test_interface", "../test:test_common", - "../test:test_flags", "../test:test_renderer", "../test:test_support", "//testing/gtest", @@ -889,6 +880,7 @@ if (rtc_include_tests) { "../api:fake_frame_decryptor", "../api:fake_frame_encryptor", "../api:fec_controller_api", + "../api:field_trials", "../api:field_trials_view", "../api:frame_generator_api", "../api:frame_transformer_interface", @@ -1028,21 +1020,18 @@ if (rtc_include_tests) { "../rtc_base/experiments:rate_control_settings", "../rtc_base/synchronization:mutex", "../system_wrappers", - "../system_wrappers:field_trial", "../system_wrappers:metrics", + "../test:create_test_field_trials", "../test:direct_transport", "../test:encoder_settings", - "../test:explicit_key_value_config", "../test:fake_encoded_frame", "../test:fake_video_codecs", - "../test:field_trial", "../test:frame_generator_capturer", "../test:frame_utils", "../test:mock_transport", "../test:null_transport", "../test:rtp_test_utils", "../test:run_loop", - "../test:scoped_key_value_config", "../test:test_common", "../test:test_support", "../test:video_test_common", diff --git a/video/adaptation/BUILD.gn b/video/adaptation/BUILD.gn index 1337140c8f..389a11e737 100644 --- a/video/adaptation/BUILD.gn +++ b/video/adaptation/BUILD.gn @@ -38,7 +38,7 @@ rtc_library("video_adaptation") { "../../api:sequence_checker", "../../api/adaptation:resource_adaptation_api", "../../api/environment", - "../../api/task_queue:task_queue", + "../../api/task_queue", "../../api/units:data_rate", "../../api/units:data_size", "../../api/units:time_delta", @@ -67,7 +67,7 @@ rtc_library("video_adaptation") { "../../rtc_base/synchronization:mutex", "../../rtc_base/system:no_unique_address", "../../rtc_base/task_utils:repeating_task", - "../../system_wrappers:system_wrappers", + "../../system_wrappers", "../../video:video_stream_encoder_interface", "../../video/config:encoder_config", "//third_party/abseil-cpp/absl/algorithm:container", @@ -96,7 +96,7 @@ if (rtc_include_tests) { "../../api/adaptation:resource_adaptation_api", "../../api/environment", "../../api/environment:environment_factory", - "../../api/task_queue:task_queue", + "../../api/task_queue", "../../api/units:time_delta", "../../api/units:timestamp", "../../api/video:encoded_image", @@ -119,7 +119,7 @@ if (rtc_include_tests) { "../../rtc_base:timeutils", "../../test:rtc_expect_death", "../../test:test_support", - "../../test/time_controller:time_controller", + "../../test/time_controller", "../config:encoder_config", "//third_party/abseil-cpp/absl/functional:any_invocable", ] diff --git a/video/adaptation/overuse_frame_detector.cc b/video/adaptation/overuse_frame_detector.cc index 000f4bfb98..5aed5ed3c0 100644 --- a/video/adaptation/overuse_frame_detector.cc +++ b/video/adaptation/overuse_frame_detector.cc @@ -10,11 +10,10 @@ #include "video/adaptation/overuse_frame_detector.h" -#include -#include - #include +#include #include +#include #include #include #include diff --git a/video/adaptation/overuse_frame_detector_unittest.cc b/video/adaptation/overuse_frame_detector_unittest.cc index b836cc3844..30fa879b66 100644 --- a/video/adaptation/overuse_frame_detector_unittest.cc +++ b/video/adaptation/overuse_frame_detector_unittest.cc @@ -36,11 +36,11 @@ using ::testing::_; using ::testing::InvokeWithoutArgs; namespace { -const int kWidth = 640; -const int kHeight = 480; +constexpr int kWidth = 640; +constexpr int kHeight = 480; // Corresponds to load of 15% -const int kFrameIntervalUs = 33 * kNumMicrosecsPerMillisec; -const int kProcessTimeUs = 5 * kNumMicrosecsPerMillisec; +constexpr int kFrameIntervalUs = 33 * kNumMicrosecsPerMillisec; +constexpr int kProcessTimeUs = 5 * kNumMicrosecsPerMillisec; } // namespace class MockCpuOveruseObserver : public OveruseFrameDetectorObserverInterface { diff --git a/video/adaptation/video_stream_encoder_resource_manager.cc b/video/adaptation/video_stream_encoder_resource_manager.cc index 437f50f69e..d486cad408 100644 --- a/video/adaptation/video_stream_encoder_resource_manager.cc +++ b/video/adaptation/video_stream_encoder_resource_manager.cc @@ -10,10 +10,9 @@ #include "video/adaptation/video_stream_encoder_resource_manager.h" -#include - #include #include +#include #include #include #include diff --git a/video/buffered_frame_decryptor_unittest.cc b/video/buffered_frame_decryptor_unittest.cc index f037d62e23..bbe975ff34 100644 --- a/video/buffered_frame_decryptor_unittest.cc +++ b/video/buffered_frame_decryptor_unittest.cc @@ -17,6 +17,7 @@ #include #include "api/crypto/frame_decryptor_interface.h" +#include "api/field_trials.h" #include "api/make_ref_counted.h" #include "api/rtp_packet_infos.h" #include "api/scoped_refptr.h" @@ -28,9 +29,9 @@ #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/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" using ::testing::Return; @@ -107,7 +108,7 @@ class BufferedFrameDecryptorTest : public ::testing::Test, static const size_t kMaxStashedFrames; - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_ = CreateTestFieldTrials(); std::vector fake_packet_data_; scoped_refptr mock_frame_decryptor_; std::unique_ptr buffered_frame_decryptor_; diff --git a/video/call_stats2.cc b/video/call_stats2.cc index 8dd9ce98dd..1d9bb46a55 100644 --- a/video/call_stats2.cc +++ b/video/call_stats2.cc @@ -165,7 +165,7 @@ void CallStats::UpdateHistograms() { int64_t elapsed_sec = (clock_->TimeInMilliseconds() - time_of_first_rtt_ms_) / 1000; - if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { + if (elapsed_sec >= metrics::kMinRunTime.seconds()) { int64_t avg_rtt_ms = (sum_avg_rtt_ms_ + num_avg_rtt_ / 2) / num_avg_rtt_; RTC_HISTOGRAM_COUNTS_10000( "WebRTC.Video.AverageRoundTripTimeInMilliseconds", avg_rtt_ms); diff --git a/video/call_stats2_unittest.cc b/video/call_stats2_unittest.cc index d2cc56f5e0..06c98579af 100644 --- a/video/call_stats2_unittest.cc +++ b/video/call_stats2_unittest.cc @@ -295,8 +295,7 @@ TEST_F(CallStats2Test, ProducesHistogramMetrics) { AsyncSimulateRttUpdate(kRtt); loop_.Run(); - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * - CallStats::kUpdateInterval.ms()); + fake_clock_.AdvanceTime(metrics::kMinRunTime); AsyncSimulateRttUpdate(kRtt); loop_.Run(); diff --git a/video/config/BUILD.gn b/video/config/BUILD.gn index d48bb4931c..4305e2832f 100644 --- a/video/config/BUILD.gn +++ b/video/config/BUILD.gn @@ -74,6 +74,7 @@ if (rtc_include_tests) { deps = [ ":encoder_config", ":streams_config", + "../../api:field_trials", "../../api:field_trials_view", "../../api:make_ref_counted", "../../api/units:data_rate", @@ -85,7 +86,7 @@ if (rtc_include_tests) { "../../media:media_constants", "../../rtc_base:safe_conversions", "../../rtc_base/experiments:min_video_bitrate_experiment", - "../../test:explicit_key_value_config", + "../../test:create_test_field_trials", "../../test:test_support", "//third_party/abseil-cpp/absl/strings:string_view", ] diff --git a/video/config/encoder_stream_factory.h b/video/config/encoder_stream_factory.h index 430e3c089e..937171d9c2 100644 --- a/video/config/encoder_stream_factory.h +++ b/video/config/encoder_stream_factory.h @@ -66,12 +66,5 @@ class EncoderStreamFactory } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::EncoderStreamFactory; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // VIDEO_CONFIG_ENCODER_STREAM_FACTORY_H_ diff --git a/video/config/encoder_stream_factory_unittest.cc b/video/config/encoder_stream_factory_unittest.cc index 5c93527282..9b44930686 100644 --- a/video/config/encoder_stream_factory_unittest.cc +++ b/video/config/encoder_stream_factory_unittest.cc @@ -17,6 +17,7 @@ #include #include "absl/strings/string_view.h" +#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/make_ref_counted.h" #include "api/video/resolution.h" @@ -27,14 +28,13 @@ #include "call/adaptation/video_source_restrictions.h" #include "rtc_base/experiments/min_video_bitrate_experiment.h" #include "rtc_base/numerics/safe_conversions.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "video/config/video_encoder_config.h" namespace webrtc { namespace { -using test::ExplicitKeyValueConfig; using ::testing::Combine; using ::testing::ElementsAre; using ::testing::IsEmpty; @@ -92,7 +92,7 @@ std::vector CreateEncoderStreams( } // namespace TEST(EncoderStreamFactory, SinglecastScaleResolutionDownTo) { - ExplicitKeyValueConfig field_trials(""); + FieldTrials field_trials = CreateTestFieldTrials(); VideoEncoderConfig encoder_config; encoder_config.number_of_streams = 1; encoder_config.simulcast_layers.resize(1); @@ -108,7 +108,7 @@ TEST(EncoderStreamFactory, SinglecastScaleResolutionDownTo) { } TEST(EncoderStreamFactory, SinglecastScaleResolutionDownToWithAdaptation) { - ExplicitKeyValueConfig field_trials(""); + FieldTrials field_trials = CreateTestFieldTrials(); VideoSourceRestrictions restrictions( /* max_pixels_per_frame= */ (320 * 320), /* target_pixels_per_frame= */ std::nullopt, @@ -129,7 +129,7 @@ TEST(EncoderStreamFactory, SinglecastScaleResolutionDownToWithAdaptation) { } TEST(EncoderStreamFactory, SimulcastScaleResolutionDownToUnrestricted) { - ExplicitKeyValueConfig field_trials(""); + FieldTrials field_trials = CreateTestFieldTrials(); VideoEncoderConfig encoder_config; encoder_config.number_of_streams = 3; encoder_config.simulcast_layers.resize(3); @@ -149,7 +149,7 @@ TEST(EncoderStreamFactory, SimulcastScaleResolutionDownToUnrestricted) { } TEST(EncoderStreamFactory, SimulcastScaleResolutionDownToWith360pRestriction) { - ExplicitKeyValueConfig field_trials(""); + FieldTrials field_trials = CreateTestFieldTrials(); VideoSourceRestrictions restrictions( /* max_pixels_per_frame= */ (640 * 360), /* target_pixels_per_frame= */ std::nullopt, @@ -174,7 +174,7 @@ TEST(EncoderStreamFactory, SimulcastScaleResolutionDownToWith360pRestriction) { } TEST(EncoderStreamFactory, SimulcastScaleResolutionDownToWith90pRestriction) { - ExplicitKeyValueConfig field_trials(""); + FieldTrials field_trials = CreateTestFieldTrials(); VideoSourceRestrictions restrictions( /* max_pixels_per_frame= */ (160 * 90), /* target_pixels_per_frame= */ std::nullopt, @@ -200,7 +200,7 @@ TEST(EncoderStreamFactory, SimulcastScaleResolutionDownToWith90pRestriction) { TEST(EncoderStreamFactory, ReverseSimulcastScaleResolutionDownToWithRestriction) { - ExplicitKeyValueConfig field_trials(""); + FieldTrials field_trials = CreateTestFieldTrials(); VideoSourceRestrictions restrictions( /* max_pixels_per_frame= */ (640 * 360), /* target_pixels_per_frame= */ std::nullopt, @@ -235,8 +235,8 @@ TEST(EncoderStreamFactory, BitratePriority) { encoder_config.simulcast_layers.resize(encoder_config.number_of_streams); encoder_config.bitrate_priority = kBitratePriority; auto streams = CreateEncoderStreams( - /*field_trials=*/ExplicitKeyValueConfig(""), - {.width = 640, .height = 360}, encoder_config); + /*field_trials=*/CreateTestFieldTrials(), {.width = 640, .height = 360}, + encoder_config); ASSERT_THAT(streams, SizeIs(2)); EXPECT_EQ(streams[0].bitrate_priority, kBitratePriority); EXPECT_FALSE(streams[1].bitrate_priority); @@ -248,7 +248,7 @@ TEST(EncoderStreamFactory, SetsMinBitrateToDefaultValue) { VideoEncoderConfig encoder_config; encoder_config.number_of_streams = 2; encoder_config.simulcast_layers.resize(encoder_config.number_of_streams); - auto streams = factory->CreateEncoderStreams(ExplicitKeyValueConfig(""), 1920, + auto streams = factory->CreateEncoderStreams(CreateTestFieldTrials(), 1920, 1080, encoder_config); ASSERT_THAT(streams, Not(IsEmpty())); EXPECT_EQ(streams[0].min_bitrate_bps, kDefaultMinVideoBitrateBps); @@ -261,7 +261,7 @@ TEST(EncoderStreamFactory, SetsMinBitrateToExperimentalValue) { encoder_config.number_of_streams = 2; encoder_config.simulcast_layers.resize(encoder_config.number_of_streams); auto streams = factory->CreateEncoderStreams( - ExplicitKeyValueConfig("WebRTC-Video-MinVideoBitrate/Enabled,br:1kbps/"), + CreateTestFieldTrials("WebRTC-Video-MinVideoBitrate/Enabled,br:1kbps/"), 1920, 1080, encoder_config); ASSERT_THAT(streams, Not(IsEmpty())); EXPECT_NE(streams[0].min_bitrate_bps, kDefaultMinVideoBitrateBps); @@ -291,7 +291,7 @@ std::vector CreateStreamResolutions( encoder_config.legacy_conference_mode = true; } return GetStreamResolutions( - CreateEncoderStreams(ExplicitKeyValueConfig(test_params.field_trials), + CreateEncoderStreams(CreateTestFieldTrials(test_params.field_trials), test_params.resolution, encoder_config)); } @@ -392,7 +392,7 @@ TEST_P(EncoderStreamFactoryOverrideStreamSettingsTest, OverrideStreamSettings) { encoder_config.simulcast_layers = test_params.requested_streams; encoder_config.content_type = test_params.content_type; auto streams = - CreateEncoderStreams(ExplicitKeyValueConfig(test_params.field_trials), + CreateEncoderStreams(CreateTestFieldTrials(test_params.field_trials), test_params.input_resolution, encoder_config); ASSERT_EQ(streams.size(), test_params.expected_streams.size()); for (size_t i = 0; i < streams.size(); ++i) { @@ -496,7 +496,7 @@ TEST(EncoderStreamFactory, VP9TemporalLayerCountTransferToStreamSettings) { encoder_config.number_of_streams = 1; encoder_config.simulcast_layers.resize(1); encoder_config.simulcast_layers[0].num_temporal_layers = 3; - auto streams = CreateEncoderStreams(ExplicitKeyValueConfig(""), {1280, 720}, + auto streams = CreateEncoderStreams(CreateTestFieldTrials(), {1280, 720}, encoder_config); ASSERT_THAT(streams, SizeIs(1)); EXPECT_EQ(streams[0].num_temporal_layers, 3); @@ -508,7 +508,7 @@ TEST(EncoderStreamFactory, AV1TemporalLayerCountTransferToStreamSettings) { encoder_config.number_of_streams = 1; encoder_config.simulcast_layers.resize(1); encoder_config.simulcast_layers[0].num_temporal_layers = 3; - auto streams = CreateEncoderStreams(ExplicitKeyValueConfig(""), {1280, 720}, + auto streams = CreateEncoderStreams(CreateTestFieldTrials(), {1280, 720}, encoder_config); ASSERT_THAT(streams, SizeIs(1)); EXPECT_EQ(streams[0].num_temporal_layers, 3); @@ -520,7 +520,7 @@ TEST(EncoderStreamFactory, H264TemporalLayerCountTransferToStreamSettings) { encoder_config.number_of_streams = 1; encoder_config.simulcast_layers.resize(1); encoder_config.simulcast_layers[0].num_temporal_layers = 3; - auto streams = CreateEncoderStreams(ExplicitKeyValueConfig(""), {1280, 720}, + auto streams = CreateEncoderStreams(CreateTestFieldTrials(), {1280, 720}, encoder_config); ASSERT_THAT(streams, SizeIs(1)); EXPECT_EQ(streams[0].num_temporal_layers, std::nullopt); @@ -533,7 +533,7 @@ TEST(EncoderStreamFactory, H265TemporalLayerCountTransferToStreamSettings) { encoder_config.number_of_streams = 1; encoder_config.simulcast_layers.resize(1); encoder_config.simulcast_layers[0].num_temporal_layers = 3; - auto streams = CreateEncoderStreams(ExplicitKeyValueConfig(""), {1280, 720}, + auto streams = CreateEncoderStreams(CreateTestFieldTrials(), {1280, 720}, encoder_config); ASSERT_THAT(streams, SizeIs(1)); EXPECT_EQ(streams[0].num_temporal_layers, 3); @@ -550,7 +550,7 @@ TEST(EncoderStreamFactory, VP9SetsMaxBitrateToConfiguredEncodingValue) { encoder_config.number_of_streams = 1; encoder_config.simulcast_layers.resize(3); encoder_config.simulcast_layers[0].max_bitrate_bps = 5000000; - auto streams = CreateEncoderStreams(ExplicitKeyValueConfig(""), {1280, 720}, + auto streams = CreateEncoderStreams(CreateTestFieldTrials(), {1280, 720}, encoder_config); ASSERT_THAT(streams, SizeIs(1)); EXPECT_EQ(streams[0].max_bitrate_bps, 5000000); diff --git a/video/config/simulcast.cc b/video/config/simulcast.cc index 8cca79a413..15ee2118d1 100644 --- a/video/config/simulcast.cc +++ b/video/config/simulcast.cc @@ -10,15 +10,13 @@ #include "video/config/simulcast.h" -#include -#include - #include +#include +#include #include #include #include -#include "absl/strings/match.h" #include "api/array_view.h" #include "api/field_trials_view.h" #include "api/units/data_rate.h" @@ -132,8 +130,7 @@ constexpr DataRate Interpolate(const DataRate& a, // TODO(webrtc:12415): Flip this to a kill switch when this feature launches. bool EnableLowresBitrateInterpolation(const FieldTrialsView& trials) { - return absl::StartsWith( - trials.Lookup("WebRTC-LowresSimulcastBitrateInterpolation"), "Enabled"); + return trials.IsEnabled("WebRTC-LowresSimulcastBitrateInterpolation"); } int GetDefaultSimulcastTemporalLayers(VideoCodecType codec) { @@ -355,8 +352,7 @@ size_t LimitSimulcastLayerCount(size_t min_num_layers, int height, const FieldTrialsView& trials, VideoCodecType codec) { - if (!absl::StartsWith(trials.Lookup(kUseLegacySimulcastLayerLimitFieldTrial), - "Disabled")) { + if (!trials.IsDisabled(kUseLegacySimulcastLayerLimitFieldTrial)) { // Max layers from one higher resolution in kSimulcastFormats will be used // if the ratio (pixels_up - pixels) / (pixels_up - pixels_down) is less // than configured `max_ratio`. pixels_down is the selected index in diff --git a/video/config/simulcast.h b/video/config/simulcast.h index a8b9143ae7..0e36cddb91 100644 --- a/video/config/simulcast.h +++ b/video/config/simulcast.h @@ -52,15 +52,5 @@ std::vector GetSimulcastConfig( } // namespace webrtc -// Re-export symbols from the webrtc namespace for backwards compatibility. -// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. -#ifdef WEBRTC_ALLOW_DEPRECATED_NAMESPACES -namespace cricket { -using ::webrtc::BoostMaxSimulcastLayer; -using ::webrtc::GetSimulcastConfig; -using ::webrtc::GetTotalMaxBitrate; -using ::webrtc::LimitSimulcastLayerCount; -} // namespace cricket -#endif // WEBRTC_ALLOW_DEPRECATED_NAMESPACES #endif // VIDEO_CONFIG_SIMULCAST_H_ diff --git a/video/config/simulcast_unittest.cc b/video/config/simulcast_unittest.cc index 628e4ea131..6d8a15fb98 100644 --- a/video/config/simulcast_unittest.cc +++ b/video/config/simulcast_unittest.cc @@ -15,19 +15,19 @@ #include #include +#include "api/field_trials.h" #include "api/units/data_rate.h" #include "api/video/resolution.h" #include "api/video/video_codec_type.h" #include "api/video_codecs/video_codec.h" #include "media/base/media_constants.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "video/config/video_encoder_config.h" namespace webrtc { namespace { -using test::ExplicitKeyValueConfig; using ::testing::Combine; using ::testing::SizeIs; using ::testing::TestParamInfo; @@ -122,7 +122,7 @@ TEST(SimulcastTest, BandwidthAboveTotalMaxBitrateGivenToHighestStream) { } TEST(SimulcastTest, GetConfig) { - const ExplicitKeyValueConfig trials(""); + const FieldTrials trials = CreateTestFieldTrials(); const std::vector kExpected = GetSimulcastBitrates720p(); @@ -151,7 +151,7 @@ TEST(SimulcastTest, GetConfig) { } TEST(SimulcastTest, GetConfigH265) { - const ExplicitKeyValueConfig trials(""); + const FieldTrials trials = CreateTestFieldTrials(); const std::vector kExpected = GetH265SimulcastBitrates720p(); const size_t kMaxLayers = 3; @@ -180,8 +180,8 @@ TEST(SimulcastTest, GetConfigH265) { } TEST(SimulcastTest, GetConfigWithBaseHeavyVP8TL3RateAllocation) { - ExplicitKeyValueConfig trials( - "WebRTC-UseBaseHeavyVP8TL3RateAllocation/Enabled/"); + FieldTrials trials = + CreateTestFieldTrials("WebRTC-UseBaseHeavyVP8TL3RateAllocation/Enabled/"); const std::vector kExpected = GetSimulcastBitrates720p(); @@ -204,7 +204,7 @@ TEST(SimulcastTest, GetConfigWithBaseHeavyVP8TL3RateAllocation) { } TEST(SimulcastTest, GetConfigWithLimitedMaxLayers) { - ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); const size_t kMaxLayers = 2; std::vector streams = @@ -219,7 +219,7 @@ TEST(SimulcastTest, GetConfigWithLimitedMaxLayers) { } TEST(SimulcastTest, GetConfigForScreenshareSimulcast) { - ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); std::vector streams = GetSimulcastConfig( std::vector{{.width = 1400, .height = 800}, {.width = 1400, .height = 800}, @@ -241,7 +241,7 @@ TEST(SimulcastTest, GetConfigForScreenshareSimulcast) { } TEST(SimulcastTest, GetConfigForScreenshareSimulcastWithLimitedMaxLayers) { - ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); std::vector streams = GetSimulcastConfig( std::vector{{.width = 1400, .height = 800}}, kScreenshare, true, trials, kVideoCodecVP8); @@ -249,7 +249,7 @@ TEST(SimulcastTest, GetConfigForScreenshareSimulcastWithLimitedMaxLayers) { } TEST(SimulcastTest, AveragesBitratesForNonStandardResolution) { - ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); std::vector streams = GetSimulcastConfig(std::vector{{.width = 900, .height = 800}}, !kScreenshare, true, trials, kVideoCodecVP8); @@ -263,7 +263,7 @@ TEST(SimulcastTest, AveragesBitratesForNonStandardResolution) { } TEST(SimulcastTest, BitratesForCloseToStandardResolution) { - ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); const size_t kMaxLayers = 3; // Resolution very close to 720p in number of pixels @@ -289,8 +289,8 @@ TEST(SimulcastTest, BitratesForCloseToStandardResolution) { } TEST(SimulcastTest, MaxLayersWithRoundUpDisabled) { - ExplicitKeyValueConfig trials( - "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.0/"); + FieldTrials trials = + CreateTestFieldTrials("WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.0/"); const size_t kMinLayers = 1; const int kMaxLayers = 3; @@ -313,7 +313,7 @@ TEST(SimulcastTest, MaxLayersWithRoundUpDisabled) { TEST(SimulcastTest, MaxLayersWithDefaultRoundUpRatio) { // Default: "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.1/" - ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); const size_t kMinLayers = 1; const int kMaxLayers = 3; @@ -340,7 +340,7 @@ TEST(SimulcastTest, MaxLayersWithDefaultRoundUpRatio) { } TEST(SimulcastTest, MaxLayersWithRoundUpRatio) { - ExplicitKeyValueConfig trials( + FieldTrials trials = CreateTestFieldTrials( "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.13/"); const size_t kMinLayers = 1; @@ -360,7 +360,7 @@ TEST(SimulcastTest, MaxLayersWithRoundUpRatio) { TEST(SimulcastTest, BitratesInterpolatedForResBelow180p) { // TODO(webrtc:12415): Remove when feature launches. - ExplicitKeyValueConfig trials( + FieldTrials trials = CreateTestFieldTrials( "WebRTC-LowresSimulcastBitrateInterpolation/Enabled/"); const size_t kMaxLayers = 3; @@ -378,7 +378,7 @@ TEST(SimulcastTest, BitratesInterpolatedForResBelow180p) { TEST(SimulcastTest, BitratesConsistentForVerySmallRes) { // TODO(webrtc:12415): Remove when feature launches. - ExplicitKeyValueConfig trials( + FieldTrials trials = CreateTestFieldTrials( "WebRTC-LowresSimulcastBitrateInterpolation/Enabled/"); std::vector streams = @@ -395,7 +395,7 @@ TEST(SimulcastTest, BitratesConsistentForVerySmallRes) { TEST(SimulcastTest, BitratesNotInterpolatedForResBelow180pWhenDisabledTrialSet) { - ExplicitKeyValueConfig trials( + FieldTrials trials = CreateTestFieldTrials( "WebRTC-LowresSimulcastBitrateInterpolation/Disabled/"); const size_t kMaxLayers = 3; @@ -424,7 +424,7 @@ using BitrateLimitsTest = TEST_P(BitrateLimitsTest, VerifyBitrateLimits) { const auto codec_type = std::get(GetParam()); const auto test_params = std::get(GetParam()); - ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); std::vector streams = GetSimulcastConfig( CreateResolutions(test_params.width, test_params.height, /*num_streams=*/3), @@ -499,7 +499,7 @@ INSTANTIATE_TEST_SUITE_P( // Test that for H.265, the simulcast layers are created with the correct // default temporal layers, before that is overrided by application settings. TEST(SimulcastTest, GetConfigForH265) { - const ExplicitKeyValueConfig trials(""); + FieldTrials trials = CreateTestFieldTrials(); const size_t kMaxLayers = 3; std::vector streams = diff --git a/video/corruption_detection/BUILD.gn b/video/corruption_detection/BUILD.gn index eb24a228c7..5aaa28364f 100644 --- a/video/corruption_detection/BUILD.gn +++ b/video/corruption_detection/BUILD.gn @@ -32,6 +32,7 @@ rtc_library("frame_instrumentation_evaluation") { "../../api:array_view", "../../api:scoped_refptr", "../../api/video:video_frame", + "../../api/video:video_rtp_headers", "../../common_video:frame_instrumentation_data", "../../rtc_base:checks", "../../rtc_base:logging", @@ -101,6 +102,7 @@ rtc_library("halton_frame_sampler") { ] deps = [ ":halton_sequence", + ":video_frame_sampler", "../../api:scoped_refptr", "../../api/video:video_frame", "../../rtc_base:checks", @@ -109,6 +111,18 @@ rtc_library("halton_frame_sampler") { ] } +rtc_library("video_frame_sampler") { + sources = [ + "video_frame_sampler.cc", + "video_frame_sampler.h", + ] + deps = [ + "../../api:scoped_refptr", + "../../api/video:video_frame", + "../../rtc_base:checks", + ] +} + rtc_library("halton_sequence") { sources = [ "halton_sequence.cc", @@ -126,8 +140,8 @@ rtc_library("utils") { "../../api:scoped_refptr", "../../api/video:video_frame", "../../rtc_base:checks", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/strings:strings", ] } @@ -149,6 +163,7 @@ if (rtc_include_tests) { ":frame_instrumentation_evaluation", "../../api:scoped_refptr", "../../api/video:video_frame", + "../../api/video:video_rtp_headers", "../../common_video:frame_instrumentation_data", "../../test:test_support", ] @@ -201,6 +216,19 @@ if (rtc_include_tests) { sources = [ "halton_frame_sampler_unittest.cc" ] deps = [ ":halton_frame_sampler", + ":video_frame_sampler", + "../../api:array_view", + "../../api:scoped_refptr", + "../../api/video:video_frame", + "../../test:test_support", + ] + } + + rtc_library("video_frame_sampler_unittest") { + testonly = true + sources = [ "video_frame_sampler_unittest.cc" ] + deps = [ + ":video_frame_sampler", "../../api:scoped_refptr", "../../api/video:video_frame", "../../test:test_support", @@ -238,6 +266,7 @@ if (rtc_include_tests) { ":halton_frame_sampler_unittest", ":halton_sequence_unittest", ":utils_unittest", + ":video_frame_sampler_unittest", ] } } diff --git a/video/corruption_detection/evaluation/BUILD.gn b/video/corruption_detection/evaluation/BUILD.gn index d0b2afb6f2..c0a1277cda 100644 --- a/video/corruption_detection/evaluation/BUILD.gn +++ b/video/corruption_detection/evaluation/BUILD.gn @@ -8,6 +8,22 @@ import("../../../webrtc.gni") +rtc_library("file_based_decoder") { + testonly = true + sources = [ "file_based_decoder.h" ] + deps = [ "//third_party/abseil-cpp/absl/strings:string_view" ] +} + +rtc_library("file_based_encoder") { + testonly = true + sources = [ "file_based_encoder.h" ] + deps = [ + ":test_clip", + "../../../api/units:data_rate", + "../../../api/video:video_frame", + ] +} + rtc_library("picture_pair_provider") { testonly = true sources = [ "picture_pair_provider.h" ] diff --git a/video/corruption_detection/evaluation/file_based_decoder.h b/video/corruption_detection/evaluation/file_based_decoder.h new file mode 100644 index 0000000000..2a7dab54d3 --- /dev/null +++ b/video/corruption_detection/evaluation/file_based_decoder.h @@ -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. + */ + +#ifndef VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_DECODER_H_ +#define VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_DECODER_H_ + +#include + +#include "absl/strings/string_view.h" + +namespace webrtc { + +// Decodes the video given in `encoded_file_path` if possible. The user cannot +// reach the individual frames. However, the user should be able to reach the +// decoded file from the decoded file path returned by `Decode` if successful. +// The decoded file is in Y4M format. +class FileBasedDecoder { + public: + FileBasedDecoder() = default; + virtual ~FileBasedDecoder() = default; + + // Decodes the encoded file at `encoded_file_path` to a Y4M file. Returns the + // path to the decoded file if successful. + virtual std::string Decode(absl::string_view encoded_file_path) = 0; +}; + +} // namespace webrtc + +#endif // VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_DECODER_H_ diff --git a/video/corruption_detection/evaluation/file_based_encoder.h b/video/corruption_detection/evaluation/file_based_encoder.h new file mode 100644 index 0000000000..78d187e78c --- /dev/null +++ b/video/corruption_detection/evaluation/file_based_encoder.h @@ -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. + */ + +#ifndef VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_ENCODER_H_ +#define VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_ENCODER_H_ + +#include + +#include "api/units/data_rate.h" +#include "api/video/video_codec_type.h" +#include "video/corruption_detection/evaluation/test_clip.h" + +namespace webrtc { + +// An encoder that encodes a raw video clip specified by `clip` given in a Y4M +// or YUV file. The user cannot reach individual frames. However, the user +// should be able to reach the encoded file from the encoded file path returned +// by `Encode` if successful. +class FileBasedEncoder { + public: + FileBasedEncoder() = default; + virtual ~FileBasedEncoder() = default; + + // Encodes the raw video clip specified by `clip` given in a Y4M or YUV file. + // Creates an encoded file where the encoded frames are stored. The encoded + // path is returned if successful. + virtual std::string Encode(const TestClip& clip, DataRate bitrate) = 0; + + // Returns the used codec for encoding. + virtual VideoCodecType GetCodec() const = 0; +}; + +} // namespace webrtc + +#endif // VIDEO_CORRUPTION_DETECTION_EVALUATION_FILE_BASED_ENCODER_H_ diff --git a/video/corruption_detection/evaluation/picture_pair_provider.h b/video/corruption_detection/evaluation/picture_pair_provider.h index df04295f78..8164406e46 100644 --- a/video/corruption_detection/evaluation/picture_pair_provider.h +++ b/video/corruption_detection/evaluation/picture_pair_provider.h @@ -15,7 +15,6 @@ #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 { diff --git a/video/corruption_detection/evaluation/test_clip.h b/video/corruption_detection/evaluation/test_clip.h index 863cc24727..7fda3d7e67 100644 --- a/video/corruption_detection/evaluation/test_clip.h +++ b/video/corruption_detection/evaluation/test_clip.h @@ -15,7 +15,6 @@ #include "absl/strings/string_view.h" #include "api/video_codecs/video_codec.h" -#include "test/testsupport/file_utils.h" namespace webrtc { diff --git a/video/corruption_detection/frame_instrumentation_evaluation.cc b/video/corruption_detection/frame_instrumentation_evaluation.cc index 60d8a9e774..61a14fef54 100644 --- a/video/corruption_detection/frame_instrumentation_evaluation.cc +++ b/video/corruption_detection/frame_instrumentation_evaluation.cc @@ -11,17 +11,14 @@ #include "video/corruption_detection/frame_instrumentation_evaluation.h" #include -#include #include #include "api/array_view.h" -#include "api/scoped_refptr.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" -#include "api/video/video_frame_buffer.h" #include "common_video/frame_instrumentation_data.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "video/corruption_detection/corruption_classifier.h" #include "video/corruption_detection/halton_frame_sampler.h" namespace webrtc { @@ -43,53 +40,49 @@ std::vector ConvertSampleValuesToFilteredSamples( } // namespace -std::optional GetCorruptionScore(const FrameInstrumentationData& data, - const VideoFrame& frame) { +FrameInstrumentationEvaluation::FrameInstrumentationEvaluation( + CorruptionScoreObserver* observer) + : observer_(observer), classifier_(/*scale_factor=*/3) { + RTC_CHECK(observer); +} + +void FrameInstrumentationEvaluation::OnInstrumentedFrame( + const FrameInstrumentationData& data, + const VideoFrame& frame, + VideoContentType content_type) { if (data.sample_values.empty()) { RTC_LOG(LS_WARNING) << "Samples are needed to calculate a corruption score."; - return std::nullopt; - } - - scoped_refptr frame_buffer_as_i420 = - frame.video_frame_buffer()->ToI420(); - if (!frame_buffer_as_i420) { - RTC_LOG(LS_ERROR) << "Failed to convert " - << VideoFrameBufferTypeToString( - frame.video_frame_buffer()->type()) - << " image to I420"; - return std::nullopt; + return; } - HaltonFrameSampler frame_sampler; - frame_sampler.SetCurrentIndex(data.sequence_index); + frame_sampler_.SetCurrentIndex(data.sequence_index); std::vector sample_coordinates = - frame_sampler.GetSampleCoordinatesForFrame(data.sample_values.size()); + frame_sampler_.GetSampleCoordinatesForFrame(data.sample_values.size()); if (sample_coordinates.empty()) { RTC_LOG(LS_ERROR) << "Failed to get sample coordinates for frame."; - return std::nullopt; + return; } - std::vector samples = - GetSampleValuesForFrame(frame_buffer_as_i420, sample_coordinates, - frame.width(), frame.height(), data.std_dev); + std::vector samples = GetSampleValuesForFrame( + frame, sample_coordinates, frame.width(), frame.height(), data.std_dev); if (samples.empty()) { RTC_LOG(LS_ERROR) << "Failed to get sample values for frame"; - return std::nullopt; + return; } std::vector data_samples = ConvertSampleValuesToFilteredSamples(data.sample_values, samples); if (data_samples.empty()) { RTC_LOG(LS_ERROR) << "Failed to convert sample values to filtered samples"; - return std::nullopt; + return; } - CorruptionClassifier classifier(3); + double score = classifier_.CalculateCorruptionProbability( + data_samples, samples, data.luma_error_threshold, + data.chroma_error_threshold); - return classifier.CalculateCorruptionProbability(data_samples, samples, - data.luma_error_threshold, - data.chroma_error_threshold); + observer_->OnCorruptionScore(score, content_type); } } // namespace webrtc diff --git a/video/corruption_detection/frame_instrumentation_evaluation.h b/video/corruption_detection/frame_instrumentation_evaluation.h index 8bd3e1c436..767eeff698 100644 --- a/video/corruption_detection/frame_instrumentation_evaluation.h +++ b/video/corruption_detection/frame_instrumentation_evaluation.h @@ -11,15 +11,39 @@ #ifndef VIDEO_CORRUPTION_DETECTION_FRAME_INSTRUMENTATION_EVALUATION_H_ #define VIDEO_CORRUPTION_DETECTION_FRAME_INSTRUMENTATION_EVALUATION_H_ -#include - +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "common_video/frame_instrumentation_data.h" +#include "video/corruption_detection/corruption_classifier.h" +#include "video/corruption_detection/halton_frame_sampler.h" namespace webrtc { -std::optional GetCorruptionScore(const FrameInstrumentationData& data, - const VideoFrame& frame); +class CorruptionScoreObserver { + public: + CorruptionScoreObserver() = default; + virtual ~CorruptionScoreObserver() = default; + + // Results of corruption detection for a single frame, with a likelihood score + // in the range [0.0, 1.0]. + virtual void OnCorruptionScore(double corruption_score, + VideoContentType content_type) = 0; +}; + +class FrameInstrumentationEvaluation { + public: + explicit FrameInstrumentationEvaluation(CorruptionScoreObserver* observer); + + void OnInstrumentedFrame(const FrameInstrumentationData& data, + const VideoFrame& frame, + VideoContentType frame_type); + + private: + CorruptionScoreObserver* const observer_; + + HaltonFrameSampler frame_sampler_; + CorruptionClassifier classifier_; +}; } // namespace webrtc diff --git a/video/corruption_detection/frame_instrumentation_evaluation_unittest.cc b/video/corruption_detection/frame_instrumentation_evaluation_unittest.cc index d82068deb2..983a757503 100644 --- a/video/corruption_detection/frame_instrumentation_evaluation_unittest.cc +++ b/video/corruption_detection/frame_instrumentation_evaluation_unittest.cc @@ -11,18 +11,29 @@ #include "video/corruption_detection/frame_instrumentation_evaluation.h" #include -#include #include #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "common_video/frame_instrumentation_data.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { namespace { +using ::testing::_; +using ::testing::AllOf; +using ::testing::Ge; +using ::testing::Le; + +class MockCorruptionScoreObserver : public CorruptionScoreObserver { + public: + MOCK_METHOD(void, OnCorruptionScore, (double, VideoContentType), (override)); +}; + scoped_refptr MakeI420FrameBufferWithDifferentPixelValues() { // Create an I420 frame of size 4x4. const int kDefaultLumaWidth = 4; @@ -52,9 +63,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional corruption_score = GetCorruptionScore(data, frame); - - EXPECT_FALSE(corruption_score.has_value()); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore).Times(0); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } TEST(FrameInstrumentationEvaluationTest, @@ -71,10 +83,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_DOUBLE_EQ(*corruption_score, 1.0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(1.0, VideoContentType::SCREENSHARE)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::SCREENSHARE); } TEST(FrameInstrumentationEvaluationTest, @@ -91,11 +103,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_LE(*corruption_score, 1); - EXPECT_GE(*corruption_score, 0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(AllOf(Ge(0.0), Le(1.0)), _)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } TEST(FrameInstrumentationEvaluationTest, @@ -114,11 +125,10 @@ TEST(FrameInstrumentationEvaluationTest, .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_LE(*corruption_score, 1); - EXPECT_GE(*corruption_score, 0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(AllOf(Ge(0.0), Le(1.0)), _)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } TEST(FrameInstrumentationEvaluationTest, ApplySequenceIndexWhenProvided) { @@ -136,11 +146,10 @@ TEST(FrameInstrumentationEvaluationTest, ApplySequenceIndexWhenProvided) { .set_video_frame_buffer(MakeI420FrameBufferWithDifferentPixelValues()) .build(); - std::optional corruption_score = GetCorruptionScore(data, frame); - - ASSERT_TRUE(corruption_score.has_value()); - EXPECT_LE(*corruption_score, 1); - EXPECT_GE(*corruption_score, 0); + MockCorruptionScoreObserver observer; + FrameInstrumentationEvaluation evaluator(&observer); + EXPECT_CALL(observer, OnCorruptionScore(AllOf(Ge(0.0), Le(1.0)), _)); + evaluator.OnInstrumentedFrame(data, frame, VideoContentType::UNSPECIFIED); } } // namespace diff --git a/video/corruption_detection/frame_instrumentation_generator.cc b/video/corruption_detection/frame_instrumentation_generator.cc index 6dc9f1cd88..ba1c60c338 100644 --- a/video/corruption_detection/frame_instrumentation_generator.cc +++ b/video/corruption_detection/frame_instrumentation_generator.cc @@ -19,12 +19,10 @@ #include #include "absl/algorithm/container.h" -#include "api/scoped_refptr.h" #include "api/video/corruption_detection_filter_settings.h" #include "api/video/encoded_image.h" #include "api/video/video_codec_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_codecs/video_codec.h" #include "common_video/frame_instrumentation_data.h" @@ -184,16 +182,6 @@ FrameInstrumentationGenerator::OnEncodedImage( return std::nullopt; } - scoped_refptr captured_frame_buffer_as_i420 = - captured_frame->video_frame_buffer()->ToI420(); - if (!captured_frame_buffer_as_i420) { - RTC_LOG(LS_ERROR) << "Failed to convert " - << VideoFrameBufferTypeToString( - captured_frame->video_frame_buffer()->type()) - << " image to I420."; - return std::nullopt; - } - FrameInstrumentationData data = { .sequence_index = sequence_index, .communicate_upper_bits = communicate_upper_bits, @@ -201,9 +189,8 @@ FrameInstrumentationGenerator::OnEncodedImage( .luma_error_threshold = filter_settings->luma_error_threshold, .chroma_error_threshold = filter_settings->chroma_error_threshold}; std::vector samples = GetSampleValuesForFrame( - captured_frame_buffer_as_i420, sample_coordinates, - encoded_image._encodedWidth, encoded_image._encodedHeight, - filter_settings->std_dev); + *captured_frame, sample_coordinates, encoded_image._encodedWidth, + encoded_image._encodedHeight, filter_settings->std_dev); data.sample_values.reserve(samples.size()); absl::c_transform(samples, std::back_inserter(data.sample_values), [](const FilteredSample& sample) { return sample.value; }); diff --git a/video/corruption_detection/frame_pair_corruption_score.cc b/video/corruption_detection/frame_pair_corruption_score.cc index fb7679fa11..0e2d7c9b82 100644 --- a/video/corruption_detection/frame_pair_corruption_score.cc +++ b/video/corruption_detection/frame_pair_corruption_score.cc @@ -16,7 +16,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.h" #include "api/video/video_frame_buffer.h" #include "rtc_base/checks.h" #include "video/corruption_detection/generic_mapping_functions.h" @@ -73,22 +73,24 @@ double FramePairCorruptionScorer::CalculateScore( halton_frame_sampler_.GetSampleCoordinatesForFrame(num_samples); RTC_DCHECK_EQ(halton_samples.size(), num_samples); - scoped_refptr reference_i420_buffer = - GetAsI420Buffer(reference_buffer.ToI420()); - scoped_refptr test_i420_buffer = - GetAsI420Buffer(test_buffer.ToI420()); + VideoFrame reference_frame = + VideoFrame::Builder() + .set_video_frame_buffer(reference_buffer.ToI420()) + .build(); + VideoFrame test_frame = VideoFrame::Builder() + .set_video_frame_buffer(test_buffer.ToI420()) + .build(); CorruptionDetectionFilterSettings filter_settings = GetCorruptionFilterSettings(qp, codec_type_); const std::vector filtered_reference_sample_values = - GetSampleValuesForFrame( - reference_i420_buffer, halton_samples, test_i420_buffer->width(), - test_i420_buffer->height(), filter_settings.std_dev); + GetSampleValuesForFrame(reference_frame, halton_samples, + test_frame.width(), test_frame.height(), + filter_settings.std_dev); const std::vector filtered_test_sample_values = - GetSampleValuesForFrame( - test_i420_buffer, halton_samples, test_i420_buffer->width(), - test_i420_buffer->height(), filter_settings.std_dev); + GetSampleValuesForFrame(test_frame, halton_samples, test_frame.width(), + test_frame.height(), filter_settings.std_dev); RTC_CHECK_EQ(filtered_reference_sample_values.size(), filtered_test_sample_values.size()); diff --git a/video/corruption_detection/halton_frame_sampler.cc b/video/corruption_detection/halton_frame_sampler.cc index 53545ed5cd..4efadcf15c 100644 --- a/video/corruption_detection/halton_frame_sampler.cc +++ b/video/corruption_detection/halton_frame_sampler.cc @@ -13,15 +13,19 @@ #include #include #include +#include #include #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/nv12_buffer.h" +#include "api/video/video_frame.h" #include "api/video/video_frame_buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_minmax.h" #include "video/corruption_detection/halton_sequence.h" +#include "video/corruption_detection/video_frame_sampler.h" namespace webrtc { namespace { @@ -98,20 +102,23 @@ void HaltonFrameSampler::SetCurrentIndex(int index) { } // Apply Gaussian filtering to the data. -double GetFilteredElement(int width, - int height, - int stride, - const uint8_t* data, +double GetFilteredElement(const VideoFrameSampler& frame_sampler, + VideoFrameSampler::ChannelType channel, int row, int column, double std_dev) { RTC_CHECK_GE(row, 0); - RTC_CHECK_LT(row, height); + RTC_CHECK_LT(row, frame_sampler.height(channel)); RTC_CHECK_GE(column, 0); - RTC_CHECK_LT(column, width); - RTC_CHECK_GE(stride, width); - RTC_CHECK_GT(std_dev, 0.0) - << "Standard deviation = 0 yields improper Gaussian weights."; + RTC_CHECK_LT(column, frame_sampler.width(channel)); + RTC_CHECK_GE(std_dev, 0.0); + + // `std_dev` being zero should ideally correspond to a very low QP value. In + // this case even a noisy pixel should be able to be encoded and transmitted + // correctly. Hence, the pixel value can be used as is. + if (std_dev == 0.0) { + return frame_sampler.GetSampleValue(channel, column, row); + } int max_distance = std::ceil(std::sqrt(-2.0 * std::log(kCutoff) * std::pow(std_dev, 2.0))) - @@ -127,13 +134,15 @@ double GetFilteredElement(int width, double element_sum = 0.0; double total_weight = 0.0; for (int r = std::max(row - max_distance, 0); - r < std::min(row + max_distance + 1, height); ++r) { + r < std::min(row + max_distance + 1, frame_sampler.height(channel)); + ++r) { for (int c = std::max(column - max_distance, 0); - c < std::min(column + max_distance + 1, width); ++c) { + c < std::min(column + max_distance + 1, frame_sampler.width(channel)); + ++c) { double weight = std::exp(-1.0 * (std::pow(row - r, 2) + std::pow(column - c, 2)) / (2.0 * std::pow(std_dev, 2))); - element_sum += data[r * stride + c] * weight; + element_sum += frame_sampler.GetSampleValue(channel, c, r) * weight; total_weight += weight; } } @@ -143,13 +152,13 @@ double GetFilteredElement(int width, } std::vector GetSampleValuesForFrame( - const scoped_refptr i420_frame_buffer, + const VideoFrame& frame, std::vector sample_coordinates, int scaled_width, int scaled_height, double std_dev_gaussian_blur) { // Validate input. - if (i420_frame_buffer == nullptr) { + if (frame.video_frame_buffer() == nullptr) { RTC_LOG(LS_WARNING) << "The framebuffer must not be nullptr"; return {}; } @@ -178,20 +187,51 @@ std::vector GetSampleValuesForFrame( << std_dev_gaussian_blur << ".\n"; return {}; } - if (scaled_width > i420_frame_buffer->width() || - scaled_height > i420_frame_buffer->height()) { + if (scaled_width > frame.width() || scaled_height > frame.height()) { RTC_LOG(LS_WARNING) << "Upscaling causes corruption. Therefore, only down-scaling is " "permissible."; return {}; } - // Scale the frame to the desired resolution: - // 1. Create a new buffer with the desired resolution. - // 2. Scale the old buffer to the size of the new buffer. - scoped_refptr scaled_i420_buffer = - I420Buffer::Create(scaled_width, scaled_height); - scaled_i420_buffer->ScaleFrom(*i420_frame_buffer); + VideoFrame scaled_frame = frame; + std::unique_ptr frame_sampler; + if (scaled_width == frame.width() && scaled_height == frame.height()) { + frame_sampler = VideoFrameSampler::Create(frame); + } else { + // Scale the frame to the desired resolution: + // 1. Create a new buffer with the desired resolution. + // 2. Scale the old buffer to the size of the new buffer. + if (frame.video_frame_buffer()->type() == VideoFrameBuffer::Type::kNV12) { + scoped_refptr scaled_buffer = + NV12Buffer::Create(scaled_width, scaled_height); + // Set crop width/height to full width/height so this is only a scaling + // operation, no cropping happening. + scaled_buffer->CropAndScaleFrom( + *frame.video_frame_buffer()->GetNV12(), /*offset_x=*/0, + /*offset_y=*/0, /*crop_width=*/frame.width(), + /*crop_height=*/frame.height()); + scaled_frame.set_video_frame_buffer(scaled_buffer); + } else { + scoped_refptr scaled_buffer = + I420Buffer::Create(scaled_width, scaled_height); + scoped_refptr buffer = + frame.video_frame_buffer()->ToI420(); + if (buffer == nullptr) { + RTC_LOG(LS_WARNING) << "Unable to convert frame to I420 format."; + return {}; + } + scaled_buffer->ScaleFrom(*buffer); + scaled_frame.set_video_frame_buffer(scaled_buffer); + } + frame_sampler = VideoFrameSampler::Create(scaled_frame); + } + if (frame_sampler == nullptr) { + RTC_LOG(LS_WARNING) << "Unable to create frame sampler for buffer type " + << VideoFrameBufferTypeToString( + frame.video_frame_buffer()->type()); + return {}; + } // Treat the planes as if they would have the following 2-dimensional layout: // +------+---+ @@ -204,9 +244,14 @@ std::vector GetSampleValuesForFrame( // as if they were taken from the above layout. We then need to translate the // coordinates back to the corresponding plane's corresponding 2D coordinates. // Then we find the filtered value that corresponds to those coordinates. + RTC_DCHECK_EQ(frame_sampler->width(VideoFrameSampler::ChannelType::U), + frame_sampler->width(VideoFrameSampler::ChannelType::V)) + << "Chroma channels are expected to be equal in resolution."; int width_merged_planes = - scaled_i420_buffer->width() + scaled_i420_buffer->ChromaWidth(); - int height_merged_planes = scaled_i420_buffer->height(); + frame_sampler->width(VideoFrameSampler::ChannelType::Y) + + frame_sampler->width(VideoFrameSampler::ChannelType::U); + int height_merged_planes = + frame_sampler->height(VideoFrameSampler::ChannelType::Y); // Fetch the sample value for all of the requested coordinates. std::vector filtered_samples; filtered_samples.reserve(sample_coordinates.size()); @@ -218,31 +263,28 @@ std::vector GetSampleValuesForFrame( // Map to plane coordinates and fetch the value. double value_for_coordinate; - if (column < scaled_i420_buffer->width()) { + if (column < frame_sampler->width(VideoFrameSampler::ChannelType::Y)) { // Y plane. - value_for_coordinate = GetFilteredElement( - scaled_i420_buffer->width(), scaled_i420_buffer->height(), - scaled_i420_buffer->StrideY(), scaled_i420_buffer->DataY(), row, - column, std_dev_gaussian_blur); + value_for_coordinate = + GetFilteredElement(*frame_sampler, VideoFrameSampler::ChannelType::Y, + row, column, std_dev_gaussian_blur); filtered_samples.push_back( {.value = value_for_coordinate, .plane = ImagePlane::kLuma}); - } else if (row < scaled_i420_buffer->ChromaHeight()) { + } else if (row < frame_sampler->height(VideoFrameSampler::ChannelType::U)) { // U plane. - column -= scaled_i420_buffer->width(); - value_for_coordinate = GetFilteredElement( - scaled_i420_buffer->ChromaWidth(), scaled_i420_buffer->ChromaHeight(), - scaled_i420_buffer->StrideU(), scaled_i420_buffer->DataU(), row, - column, std_dev_gaussian_blur); + column -= frame_sampler->width(VideoFrameSampler::ChannelType::Y); + value_for_coordinate = + GetFilteredElement(*frame_sampler, VideoFrameSampler::ChannelType::U, + row, column, std_dev_gaussian_blur); filtered_samples.push_back( {.value = value_for_coordinate, .plane = ImagePlane::kChroma}); } else { // V plane. - column -= scaled_i420_buffer->width(); - row -= scaled_i420_buffer->ChromaHeight(); - value_for_coordinate = GetFilteredElement( - scaled_i420_buffer->ChromaWidth(), scaled_i420_buffer->ChromaHeight(), - scaled_i420_buffer->StrideV(), scaled_i420_buffer->DataV(), row, - column, std_dev_gaussian_blur); + column -= frame_sampler->width(VideoFrameSampler::ChannelType::Y); + row -= frame_sampler->height(VideoFrameSampler::ChannelType::U); + value_for_coordinate = + GetFilteredElement(*frame_sampler, VideoFrameSampler::ChannelType::V, + row, column, std_dev_gaussian_blur); filtered_samples.push_back( {.value = value_for_coordinate, .plane = ImagePlane::kChroma}); } @@ -250,4 +292,15 @@ std::vector GetSampleValuesForFrame( return filtered_samples; } +[[deprecated]] std::vector GetSampleValuesForFrame( + scoped_refptr i420_frame_buffer, + std::vector sample_coordinates, + int scaled_width, + int scaled_height, + double std_dev_gaussian_blur) { + return GetSampleValuesForFrame( + VideoFrame::Builder().set_video_frame_buffer(i420_frame_buffer).build(), + sample_coordinates, scaled_width, scaled_height, std_dev_gaussian_blur); +} + } // namespace webrtc diff --git a/video/corruption_detection/halton_frame_sampler.h b/video/corruption_detection/halton_frame_sampler.h index ad2e1bd9f9..0026ee7336 100644 --- a/video/corruption_detection/halton_frame_sampler.h +++ b/video/corruption_detection/halton_frame_sampler.h @@ -16,8 +16,10 @@ #include #include "api/scoped_refptr.h" +#include "api/video/video_frame.h" #include "api/video/video_frame_buffer.h" #include "video/corruption_detection/halton_sequence.h" +#include "video/corruption_detection/video_frame_sampler.h" namespace webrtc { @@ -67,6 +69,15 @@ class HaltonFrameSampler { // 3. Apply the Gaussian filtering given by `std_dev_gaussian_blur`. // 4. Fetch the values at the scaled coordinates in the filtered frame. std::vector GetSampleValuesForFrame( + const VideoFrame& frame, + std::vector sample_coordinates, + int scaled_width, + int scaled_height, + double std_dev_gaussian_blur); + +// For backwards compatiblity only. +// TODO(bugs.webrtc.org/398100): Remove when downstream usage is gone. +[[deprecated]] std::vector GetSampleValuesForFrame( scoped_refptr i420_frame_buffer, std::vector sample_coordinates, int scaled_width, @@ -74,10 +85,8 @@ std::vector GetSampleValuesForFrame( double std_dev_gaussian_blur); // Returns the blurred value. The minimum half-kernel size is 3 pixels. -double GetFilteredElement(int width, - int height, - int stride, - const uint8_t* data, +double GetFilteredElement(const VideoFrameSampler& frame_sampler, + VideoFrameSampler::ChannelType channel, int row, int column, double std_dev); diff --git a/video/corruption_detection/halton_frame_sampler_unittest.cc b/video/corruption_detection/halton_frame_sampler_unittest.cc index 3fd899c912..9ee5ff0670 100644 --- a/video/corruption_detection/halton_frame_sampler_unittest.cc +++ b/video/corruption_detection/halton_frame_sampler_unittest.cc @@ -11,12 +11,17 @@ #include "video/corruption_detection/halton_frame_sampler.h" #include +#include +#include #include +#include "api/array_view.h" #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "api/video/video_frame.h" #include "test/gmock.h" #include "test/gtest.h" +#include "video/corruption_detection/video_frame_sampler.h" namespace webrtc { namespace { @@ -33,23 +38,18 @@ using ::testing::Not; using Coordinates = HaltonFrameSampler::Coordinates; // Defaults for sampling tests. -const int kDefaultScaledWidth = 4; -const int kDefaultScaledHeight = 4; -const double kDefaultStdDevGaussianBlur = 0.02; +constexpr int kDefaultScaledWidth = 4; +constexpr int kDefaultScaledHeight = 4; +constexpr double kDefaultStdDevGaussianBlur = 0.02; #if GTEST_HAS_DEATH_TEST // Defaults for blurring tests. -const int kDefaultWidth = 4; -const int kDefaultHeight = 4; -const int kDefaultStride = 4; -const uint8_t kDefaultData[kDefaultWidth * kDefaultHeight] = { - 20, 196, 250, 115, 139, 39, 99, 197, 21, 166, 254, 28, 227, 54, 64, 46}; -const int kDefaultRow = 3; -const int kDefaultColumn = 2; -const double kDefaultStdDev = 1.12; +constexpr int kDefaultRow = 3; +constexpr int kDefaultColumn = 2; +constexpr double kDefaultStdDev = 1.12; #endif // GTEST_HAS_DEATH_TEST -scoped_refptr MakeDefaultI420FrameBuffer() { +VideoFrame MakeDefaultFrame() { // Create an I420 frame of size 4x4. const int kDefaultLumaWidth = 4; const int kDefaultLumaHeight = 4; @@ -59,10 +59,20 @@ scoped_refptr MakeDefaultI420FrameBuffer() { const uint8_t kDefaultUContent[4] = {156, 203, 36, 128}; const uint8_t kDefaultVContent[4] = {112, 2, 0, 24}; - return I420Buffer::Copy(kDefaultLumaWidth, kDefaultLumaHeight, - kDefaultYContent, kDefaultLumaWidth, kDefaultUContent, - kDefaultChromaWidth, kDefaultVContent, - kDefaultChromaWidth); + return VideoFrame::Builder() + .set_video_frame_buffer(I420Buffer::Copy( + kDefaultLumaWidth, kDefaultLumaHeight, kDefaultYContent, + kDefaultLumaWidth, kDefaultUContent, kDefaultChromaWidth, + kDefaultVContent, kDefaultChromaWidth)) + .build(); +} + +VideoFrame MakeFrame(int width, + int height, + webrtc::ArrayView data) { + scoped_refptr buffer = I420Buffer::Create(width, height); + memcpy(buffer->MutableDataY(), data.data(), width * height); + return VideoFrame::Builder().set_video_frame_buffer(buffer).build(); } std::vector MakeDefaultSampleCoordinates() { @@ -76,7 +86,6 @@ std::vector MakeDefaultSampleCoordinates() { TEST(GaussianFilteringTest, ShouldReturnFilteredValueWhenInputIsValid) { const int kWidth = 8; const int kHeight = 8; - const int kStride = 8; const uint8_t kData[kWidth * kHeight] = { 219, 38, 75, 13, 77, 22, 108, 5, // 199, 105, 237, 3, 194, 63, 200, 95, // @@ -92,50 +101,51 @@ TEST(GaussianFilteringTest, ShouldReturnFilteredValueWhenInputIsValid) { // Resulting in a filter size of 3 pixels. const double kStdDev = 1; - EXPECT_THAT(GetFilteredElement(kWidth, kHeight, kStride, kData, kRow, kColumn, - kStdDev), + std::unique_ptr sampler = + VideoFrameSampler::Create(MakeFrame(kWidth, kHeight, kData)); + EXPECT_THAT(GetFilteredElement(*sampler, VideoFrameSampler::ChannelType::Y, + kRow, kColumn, kStdDev), DoubleEq(126.45897447350468)); } #if GTEST_HAS_DEATH_TEST +std::unique_ptr MakeDefaultSampler() { + return VideoFrameSampler::Create(MakeDefaultFrame()); +} + TEST(GaussianFilteringTest, ShouldCrashWhenRowIsNegative) { - EXPECT_DEATH( - GetFilteredElement(kDefaultWidth, kDefaultHeight, kDefaultStride, - kDefaultData, -1, kDefaultColumn, kDefaultStdDev), - _); + EXPECT_DEATH(GetFilteredElement(*MakeDefaultSampler(), + VideoFrameSampler::ChannelType::Y, -1, + kDefaultColumn, kDefaultStdDev), + _); } TEST(GaussianFilteringTest, ShouldCrashWhenRowIsOutOfRange) { - EXPECT_DEATH( - GetFilteredElement(kDefaultWidth, 4, kDefaultStride, kDefaultData, 4, - kDefaultColumn, kDefaultStdDev), - _); + EXPECT_DEATH(GetFilteredElement(*MakeDefaultSampler(), + VideoFrameSampler::ChannelType::Y, 4, + kDefaultColumn, kDefaultStdDev), + _); } TEST(GaussianFilteringTest, ShouldCrashWhenColumnIsNegative) { - EXPECT_DEATH( - GetFilteredElement(kDefaultWidth, kDefaultHeight, kDefaultStride, - kDefaultData, kDefaultRow, -1, kDefaultStdDev), - _); -} - -TEST(GaussianFilteringTest, ShouldCrashWhenColumnIsOutOfRange) { - EXPECT_DEATH(GetFilteredElement(4, kDefaultHeight, kDefaultStride, - kDefaultData, kDefaultRow, 4, kDefaultStdDev), + EXPECT_DEATH(GetFilteredElement(*MakeDefaultSampler(), + VideoFrameSampler::ChannelType::Y, + kDefaultRow, -1, kDefaultStdDev), _); } -TEST(GaussianFilteringTest, ShouldCrashWhenStrideIsSmallerThanWidth) { - EXPECT_DEATH(GetFilteredElement(4, kDefaultHeight, 3, kDefaultData, - kDefaultRow, kDefaultColumn, kDefaultStdDev), +TEST(GaussianFilteringTest, ShouldCrashWhenColumnIsOutOfRange) { + EXPECT_DEATH(GetFilteredElement(*MakeDefaultSampler(), + VideoFrameSampler::ChannelType::Y, + kDefaultRow, 4, kDefaultStdDev), _); } TEST(GaussianFilteringTest, ShouldCrashWhenStdDevIsNegative) { - EXPECT_DEATH( - GetFilteredElement(kDefaultWidth, kDefaultHeight, kDefaultStride, - kDefaultData, kDefaultRow, kDefaultColumn, -1.0), - _); + EXPECT_DEATH(GetFilteredElement(*MakeDefaultSampler(), + VideoFrameSampler::ChannelType::Y, + kDefaultRow, kDefaultColumn, -1.0), + _); } TEST(GaussianFilteringTest, RoundingErrorsShouldNotHappen) { @@ -144,8 +154,10 @@ TEST(GaussianFilteringTest, RoundingErrorsShouldNotHappen) { constexpr int kHeight = 128; constexpr double kStdDev = 40; const std::vector data(kWidth * kHeight, 255); + std::unique_ptr sampler = + VideoFrameSampler::Create(MakeFrame(kWidth, kHeight, data)); - EXPECT_THAT(GetFilteredElement(kWidth, kHeight, kHeight, data.data(), + EXPECT_THAT(GetFilteredElement(*sampler, VideoFrameSampler::ChannelType::Y, kWidth / 2, kHeight / 2, kStdDev), 255); } @@ -165,39 +177,23 @@ TEST(HaltonFrameSamplerTest, FrameIsNotSampledWhenTimestampsAreEqual) { #endif // GTEST_HAS_DEATH_TEST -TEST(HaltonFrameSamplerGaussianFilteringTest, - ShouldReturnEmptyListGivenInvalidInputNoFrameBuffer) { - const std::vector kDefaultSampleCoordinates = - MakeDefaultSampleCoordinates(); - - EXPECT_THAT(GetSampleValuesForFrame(nullptr, kDefaultSampleCoordinates, - kDefaultScaledWidth, kDefaultScaledHeight, - kDefaultStdDevGaussianBlur), - IsEmpty()); -} - TEST(HaltonFrameSamplerGaussianFilteringTest, ShouldReturnEmptyListGivenInvalidInputNoCoordinates) { - const scoped_refptr kDefaultI420Buffer = - MakeDefaultI420FrameBuffer(); - EXPECT_THAT( - GetSampleValuesForFrame(kDefaultI420Buffer, {}, kDefaultScaledWidth, + GetSampleValuesForFrame(MakeDefaultFrame(), {}, kDefaultScaledWidth, kDefaultScaledHeight, kDefaultStdDevGaussianBlur), IsEmpty()); } TEST(HaltonFrameSamplerGaussianFilteringTest, ShouldReturnEmptyListGivenInvalidInputOutOfRangeCoordinates) { - const scoped_refptr kDefaultI420Buffer = - MakeDefaultI420FrameBuffer(); const std::vector kSampleCoordinates = { {.row = 0.2, .column = 0.7}, {.row = 0.5, .column = 1.0}, {.row = 0.3, .column = 0.7}, {.row = 0.8, .column = 0.4}}; - EXPECT_THAT(GetSampleValuesForFrame(kDefaultI420Buffer, kSampleCoordinates, + EXPECT_THAT(GetSampleValuesForFrame(MakeDefaultFrame(), kSampleCoordinates, kDefaultScaledWidth, kDefaultScaledHeight, kDefaultStdDevGaussianBlur), IsEmpty()); @@ -205,49 +201,40 @@ TEST(HaltonFrameSamplerGaussianFilteringTest, TEST(HaltonFrameSamplerGaussianFilteringTest, ShouldReturnEmptyListGivenInvalidInputWidthZero) { - const scoped_refptr kDefaultI420Buffer = - MakeDefaultI420FrameBuffer(); const std::vector kDefaultSampleCoordinates = MakeDefaultSampleCoordinates(); EXPECT_THAT( - GetSampleValuesForFrame(kDefaultI420Buffer, kDefaultSampleCoordinates, 0, + GetSampleValuesForFrame(MakeDefaultFrame(), kDefaultSampleCoordinates, 0, kDefaultScaledHeight, kDefaultStdDevGaussianBlur), IsEmpty()); } TEST(HaltonFrameSamplerGaussianFilteringTest, ShouldReturnEmptyListGivenInvalidInputHeightZero) { - const scoped_refptr kDefaultI420Buffer = - MakeDefaultI420FrameBuffer(); const std::vector kDefaultSampleCoordinates = MakeDefaultSampleCoordinates(); EXPECT_THAT(GetSampleValuesForFrame( - kDefaultI420Buffer, kDefaultSampleCoordinates, + MakeDefaultFrame(), kDefaultSampleCoordinates, kDefaultScaledWidth, 0, kDefaultStdDevGaussianBlur), IsEmpty()); } TEST(HaltonFrameSamplerGaussianFilteringTest, ShouldReturnEmptyListGivenInvalidInputStdDevNegative) { - const scoped_refptr kDefaultI420Buffer = - MakeDefaultI420FrameBuffer(); const std::vector kDefaultSampleCoordinates = MakeDefaultSampleCoordinates(); EXPECT_THAT( - GetSampleValuesForFrame(kDefaultI420Buffer, kDefaultSampleCoordinates, + GetSampleValuesForFrame(MakeDefaultFrame(), kDefaultSampleCoordinates, kDefaultScaledWidth, kDefaultScaledHeight, -1.0), IsEmpty()); } TEST(HaltonFrameSamplerGaussianFilteringTest, ShouldReturnEmptyListWhenUpscaling) { - const scoped_refptr kDefaultI420Buffer = - MakeDefaultI420FrameBuffer(); - - EXPECT_THAT(GetSampleValuesForFrame(kDefaultI420Buffer, + EXPECT_THAT(GetSampleValuesForFrame(MakeDefaultFrame(), MakeDefaultSampleCoordinates(), /*scaled_width=*/8, /*scaled_height=*/8, kDefaultStdDevGaussianBlur), @@ -267,6 +254,8 @@ TEST(HaltonFrameSamplerGaussianFilteringTest, const scoped_refptr kI420Buffer = I420Buffer::Copy(kLumaWidth, kLumaHeight, kYContent, kLumaWidth, kUContent, kChromaWidth, kVContent, kChromaWidth); + VideoFrame frame = + VideoFrame::Builder().set_video_frame_buffer(kI420Buffer).build(); // Coordinates in all planes. const std::vector kSampleCoordinates = { @@ -283,7 +272,7 @@ TEST(HaltonFrameSamplerGaussianFilteringTest, const double kStdDevGaussianBlur = 0.02; EXPECT_THAT( - GetSampleValuesForFrame(kI420Buffer, kSampleCoordinates, kScaledWidth, + GetSampleValuesForFrame(frame, kSampleCoordinates, kScaledWidth, kScaledHeight, kStdDevGaussianBlur), ElementsAre(AllOf(Field(&FilteredSample::value, DoubleEq(156.0)), Field(&FilteredSample::plane, ImagePlane::kChroma)), @@ -308,6 +297,8 @@ TEST(HaltonFrameSamplerGaussianFilteringTest, const scoped_refptr kI420Buffer = I420Buffer::Copy(kLumaWidth, kLumaHeight, kYContent, kLumaWidth, kUContent, kChromaWidth, kVContent, kChromaWidth); + VideoFrame frame = + VideoFrame::Builder().set_video_frame_buffer(kI420Buffer).build(); // Coordinates in all planes. const std::vector kSampleCoordinates = { @@ -324,7 +315,7 @@ TEST(HaltonFrameSamplerGaussianFilteringTest, const double kStdDevGaussianBlur = 0.02; EXPECT_THAT( - GetSampleValuesForFrame(kI420Buffer, kSampleCoordinates, kScaledWidth, + GetSampleValuesForFrame(frame, kSampleCoordinates, kScaledWidth, kScaledHeight, kStdDevGaussianBlur), ElementsAre(AllOf(Field(&FilteredSample::value, DoubleEq(131.0)), Field(&FilteredSample::plane, ImagePlane::kChroma)), @@ -362,6 +353,8 @@ TEST(HaltonFrameSamplerGaussianFilteringTest, const scoped_refptr kI420Buffer = I420Buffer::Copy(kLumaWidth, kLumaHeight, kYContent, kLumaWidth, kUContent, kChromaWidth, kVContent, kChromaWidth); + VideoFrame frame = + VideoFrame::Builder().set_video_frame_buffer(kI420Buffer).build(); // Coordinates in all (YUV) planes. const std::vector kSampleCoordinates = { @@ -378,7 +371,7 @@ TEST(HaltonFrameSamplerGaussianFilteringTest, const double kStdDevGaussianBlur = 1; EXPECT_THAT( - GetSampleValuesForFrame(kI420Buffer, kSampleCoordinates, kScaledWidth, + GetSampleValuesForFrame(frame, kSampleCoordinates, kScaledWidth, kScaledHeight, kStdDevGaussianBlur), ElementsAre( AllOf(Field(&FilteredSample::value, DoubleEq(114.6804322931639)), diff --git a/video/corruption_detection/video_frame_sampler.cc b/video/corruption_detection/video_frame_sampler.cc new file mode 100644 index 0000000000..9fbce93b65 --- /dev/null +++ b/video/corruption_detection/video_frame_sampler.cc @@ -0,0 +1,143 @@ +/* + * 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 "video/corruption_detection/video_frame_sampler.h" + +#include +#include + +#include "api/scoped_refptr.h" +#include "api/video/video_frame.h" +#include "api/video/video_frame_buffer.h" +#include "rtc_base/checks.h" + +namespace webrtc { + +class I420FrameSampler : public VideoFrameSampler { + public: + explicit I420FrameSampler(scoped_refptr buffer) + : buffer_(buffer) {} + + uint8_t GetSampleValue(ChannelType channel, int col, int row) const override { + RTC_DCHECK_GE(col, 0); + RTC_DCHECK_GE(row, 0); + switch (channel) { + case ChannelType::Y: + RTC_DCHECK_LT(col, width(ChannelType::Y)); + RTC_DCHECK_LT(row, height(ChannelType::Y)); + return buffer_->DataY()[row * buffer_->StrideY() + col]; + case ChannelType::U: + RTC_DCHECK_LT(col, width(ChannelType::U)); + RTC_DCHECK_LT(row, height(ChannelType::U)); + return buffer_->DataU()[row * buffer_->StrideU() + col]; + case ChannelType::V: + RTC_DCHECK_LT(col, width(ChannelType::V)); + RTC_DCHECK_LT(row, height(ChannelType::V)); + return buffer_->DataV()[row * buffer_->StrideV() + col]; + } + } + + int width(ChannelType channel) const override { + switch (channel) { + case ChannelType::Y: + return buffer_->width(); + case ChannelType::U: + case ChannelType::V: + return buffer_->ChromaWidth(); + } + } + + int height(ChannelType channel) const override { + switch (channel) { + case ChannelType::Y: + return buffer_->height(); + case ChannelType::U: + case ChannelType::V: + return buffer_->ChromaHeight(); + } + } + + private: + const scoped_refptr buffer_; +}; + +class NV12FrameSampler : public VideoFrameSampler { + public: + explicit NV12FrameSampler(scoped_refptr buffer) + : buffer_(buffer) {} + + uint8_t GetSampleValue(ChannelType channel, int col, int row) const override { + RTC_DCHECK_GE(col, 0); + RTC_DCHECK_GE(row, 0); + switch (channel) { + case ChannelType::Y: + RTC_DCHECK_LT(col, width(ChannelType::Y)); + RTC_DCHECK_LT(row, height(ChannelType::Y)); + return buffer_->DataY()[row * buffer_->StrideY() + col]; + case ChannelType::U: + RTC_DCHECK_LT(col, width(ChannelType::U)); + RTC_DCHECK_LT(row, height(ChannelType::U)); + return buffer_->DataUV()[row * buffer_->StrideUV() + (col * 2)]; + case ChannelType::V: + RTC_DCHECK_LT(col, width(ChannelType::V)); + RTC_DCHECK_LT(row, height(ChannelType::V)); + return buffer_->DataUV()[row * buffer_->StrideUV() + (col * 2) + 1]; + } + } + + int width(ChannelType channel) const override { + switch (channel) { + case ChannelType::Y: + return buffer_->width(); + case ChannelType::U: + case ChannelType::V: + return buffer_->ChromaWidth(); + } + } + + int height(ChannelType channel) const override { + switch (channel) { + case ChannelType::Y: + return buffer_->height(); + case ChannelType::U: + case ChannelType::V: + return buffer_->ChromaHeight(); + } + } + + private: + const scoped_refptr buffer_; +}; + +std::unique_ptr VideoFrameSampler::Create( + const VideoFrame& frame) { + if (frame.video_frame_buffer() == nullptr) { + return nullptr; + } + switch (frame.video_frame_buffer()->type()) { + case VideoFrameBuffer::Type::kNV12: { + return std::make_unique( + scoped_refptr( + frame.video_frame_buffer()->GetNV12())); + } + case VideoFrameBuffer::Type::kI420: + case VideoFrameBuffer::Type::kI420A: + // Native I420 and I420A are used directly (Alpha channel ignored). + return std::make_unique( + scoped_refptr( + frame.video_frame_buffer()->GetI420())); + default: + // Conversion and copy to I420 from some other format. + return std::make_unique( + frame.video_frame_buffer()->ToI420()); + } +} + +} // namespace webrtc diff --git a/video/corruption_detection/video_frame_sampler.h b/video/corruption_detection/video_frame_sampler.h new file mode 100644 index 0000000000..8cea63acf0 --- /dev/null +++ b/video/corruption_detection/video_frame_sampler.h @@ -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. + */ + +#ifndef VIDEO_CORRUPTION_DETECTION_VIDEO_FRAME_SAMPLER_H_ +#define VIDEO_CORRUPTION_DETECTION_VIDEO_FRAME_SAMPLER_H_ + +#include +#include + +#include "api/video/video_frame.h" + +namespace webrtc { + +class VideoFrameSampler { + public: + static std::unique_ptr Create(const VideoFrame& frame); + virtual ~VideoFrameSampler() = default; + + enum class ChannelType { Y, U, V }; + virtual uint8_t GetSampleValue(ChannelType channel, + int col, + int row) const = 0; + virtual int width(ChannelType channel) const = 0; + virtual int height(ChannelType channel) const = 0; +}; + +} // namespace webrtc + +#endif // VIDEO_CORRUPTION_DETECTION_VIDEO_FRAME_SAMPLER_H_ diff --git a/video/corruption_detection/video_frame_sampler_unittest.cc b/video/corruption_detection/video_frame_sampler_unittest.cc new file mode 100644 index 0000000000..3a270e18b5 --- /dev/null +++ b/video/corruption_detection/video_frame_sampler_unittest.cc @@ -0,0 +1,334 @@ +/* + * 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 "video/corruption_detection/video_frame_sampler.h" + +#include +#include +#include + +#include "api/scoped_refptr.h" +#include "api/video/i420_buffer.h" +#include "api/video/i444_buffer.h" +#include "api/video/nv12_buffer.h" +#include "api/video/video_frame.h" +#include "test/gmock.h" +#include "test/gtest.h" + +using ::testing::_; + +namespace webrtc { + +scoped_refptr MakeSimpleI420FrameBuffer() { + // Create a simple I420 frame of size 4x4 with each sample having a unique + // value. An additional stride is used with a "poisoned" value of 99. + scoped_refptr buffer = I420Buffer::Create(/*width=*/4, + /*height=*/4, + /*stride_y=*/5, + /*stride_u=*/3, + /*stride_v=*/3); + const uint8_t kYContent[] = { + // clang-format off + 1, 2, 3, 4, 99, + 5, 6, 7, 8, 99, + 9, 10, 11, 12, 99, + 13, 14, 15, 16, 99 + // clang-format on + }; + memcpy(buffer->MutableDataY(), kYContent, sizeof(kYContent)); + + const uint8_t kUContent[] = { + // clang-format off + 17, 18, 99, + 19, 20, 99 + // clang-format on + }; + memcpy(buffer->MutableDataU(), kUContent, sizeof(kUContent)); + + const uint8_t kVContent[] = { + // clang-format off + 21, 22, 99, + 23, 24, 99 + // clang-format on + }; + memcpy(buffer->MutableDataV(), kVContent, sizeof(kVContent)); + + return buffer; +} + +scoped_refptr MakeSimpleI444FrameBuffer() { + // Create an I444 frame, with the same contents as `MakeSimpleI420FrameBuffer` + // just upscaled with nearest-neighbour. + scoped_refptr buffer = I444Buffer::Create(/*width=*/4, + /*height=*/4, + /*stride_y=*/5, + /*stride_u=*/5, + /*stride_v=*/5); + const uint8_t kYContent[] = { + // clang-format off + 1, 2, 3, 4, 99, + 5, 6, 7, 8, 99, + 9, 10, 11, 12, 99, + 13, 14, 15, 16, 99 + // clang-format on + }; + memcpy(buffer->MutableDataY(), kYContent, sizeof(kYContent)); + + const uint8_t kUContent[] = { + // clang-format off + 17, 17, 18, 18, 99, + 17, 17, 18, 18, 99, + 19, 19, 20, 20, 99, + 19, 19, 20, 20, 99 + // clang-format on + }; + memcpy(buffer->MutableDataU(), kUContent, sizeof(kUContent)); + + const uint8_t kVContent[] = { + // clang-format off + 21, 21, 22, 22, 99, + 21, 21, 22, 22, 99, + 23, 23, 24, 24, 99, + 23, 23, 24, 24, 99 + // clang-format on + }; + memcpy(buffer->MutableDataV(), kVContent, sizeof(kVContent)); + + return buffer; +} + +std::unique_ptr GetDefaultSampler() { + return VideoFrameSampler::Create( + VideoFrame::Builder() + .set_video_frame_buffer(MakeSimpleI420FrameBuffer()) + .build()); +} + +TEST(VideoFrameSampler, ParsesI420YChannel) { + std::unique_ptr sampler = GetDefaultSampler(); + int val = 1; + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + EXPECT_EQ( + sampler->GetSampleValue(VideoFrameSampler::ChannelType::Y, col, row), + val++); + } + } +} + +TEST(VideoFrameSampler, ParsesI420UChannel) { + std::unique_ptr sampler = GetDefaultSampler(); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 0, 0), + 17); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 1, 0), + 18); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 0, 1), + 19); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 1, 1), + 20); +} + +TEST(VideoFrameSampler, ParsesI420VChannel) { + std::unique_ptr sampler = GetDefaultSampler(); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 0, 0), + 21); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 1, 0), + 22); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 0, 1), + 23); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 1, 1), + 24); +} + +TEST(VideoFrameSampler, ReportsI420Resolution) { + std::unique_ptr sampler = GetDefaultSampler(); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::Y), 4); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::Y), 4); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::U), 2); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::U), 2); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::V), 2); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::V), 2); +} + +TEST(VideoFrameSampler, ParsesNV12YChannel) { + std::unique_ptr sampler = + VideoFrameSampler::Create(VideoFrame::Builder() + .set_video_frame_buffer(NV12Buffer::Copy( + *MakeSimpleI420FrameBuffer())) + .build()); + int val = 1; + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + EXPECT_EQ( + sampler->GetSampleValue(VideoFrameSampler::ChannelType::Y, col, row), + val++); + } + } +} + +TEST(VideoFrameSampler, ParsesNV12UChannel) { + std::unique_ptr sampler = + VideoFrameSampler::Create(VideoFrame::Builder() + .set_video_frame_buffer(NV12Buffer::Copy( + *MakeSimpleI420FrameBuffer())) + .build()); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 0, 0), + 17); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 1, 0), + 18); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 0, 1), + 19); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 1, 1), + 20); +} + +TEST(VideoFrameSampler, ParsesNV12VChannel) { + std::unique_ptr sampler = + VideoFrameSampler::Create(VideoFrame::Builder() + .set_video_frame_buffer(NV12Buffer::Copy( + *MakeSimpleI420FrameBuffer())) + .build()); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 0, 0), + 21); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 1, 0), + 22); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 0, 1), + 23); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 1, 1), + 24); +} + +TEST(VideoFrameSampler, ReportsNV12Resolution) { + std::unique_ptr sampler = + VideoFrameSampler::Create(VideoFrame::Builder() + .set_video_frame_buffer(NV12Buffer::Copy( + *MakeSimpleI420FrameBuffer())) + .build()); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::Y), 4); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::Y), 4); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::U), 2); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::U), 2); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::V), 2); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::V), 2); +} + +TEST(VideoFrameSampler, ParsesI444YChannel) { + // I444 will be converted to I420, but the Y channel should remain unchanged. + std::unique_ptr sampler = VideoFrameSampler::Create( + VideoFrame::Builder() + .set_video_frame_buffer(MakeSimpleI444FrameBuffer()) + .build()); + int val = 1; + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + EXPECT_EQ( + sampler->GetSampleValue(VideoFrameSampler::ChannelType::Y, col, row), + val++); + } + } +} + +TEST(VideoFrameSampler, ParsesI444UChannel) { + // I444 will be converted to I420, with U/V dowscaled by 2x. + std::unique_ptr sampler = VideoFrameSampler::Create( + VideoFrame::Builder() + .set_video_frame_buffer(MakeSimpleI444FrameBuffer()) + .build()); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 0, 0), + 17); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 1, 0), + 18); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 0, 1), + 19); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::U, 1, 1), + 20); +} + +TEST(VideoFrameSampler, ParsesI444VChannel) { + // I444 will be converted to I420, with U/V dowscaled by 2x. + std::unique_ptr sampler = VideoFrameSampler::Create( + VideoFrame::Builder() + .set_video_frame_buffer(MakeSimpleI444FrameBuffer()) + .build()); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 0, 0), + 21); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 1, 0), + 22); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 0, 1), + 23); + EXPECT_EQ(sampler->GetSampleValue(VideoFrameSampler::ChannelType::V, 1, 1), + 24); +} + +TEST(VideoFrameSampler, ReportsI444Resolution) { + // I444 will be converted to I420, with U/V dowscaled by 2x. + std::unique_ptr sampler = VideoFrameSampler::Create( + VideoFrame::Builder() + .set_video_frame_buffer(MakeSimpleI444FrameBuffer()) + .build()); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::Y), 4); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::Y), 4); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::U), 2); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::U), 2); + EXPECT_EQ(sampler->width(VideoFrameSampler::ChannelType::V), 2); + EXPECT_EQ(sampler->height(VideoFrameSampler::ChannelType::V), 2); +} + +#if GTEST_HAS_DEATH_TEST +TEST(VideoFrameSampler, RejectsNegativeColumn) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::Y, -1, 0), + _); +} + +TEST(VideoFrameSampler, RejectsNegativeRow) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::Y, 0, -1), + _); +} + +TEST(VideoFrameSampler, RejectsTooLargeYColumn) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::Y, 4, 0), + _); +} + +TEST(VideoFrameSampler, RejectsTooLargeYRow) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::Y, 5, 0), + _); +} + +TEST(VideoFrameSampler, RejectsTooLargeUColumn) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::U, 3, 0), + _); +} + +TEST(VideoFrameSampler, RejectsTooLargeURow) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::U, 2, 0), + _); +} + +TEST(VideoFrameSampler, RejectsTooLargeVColumn) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::V, 2, 0), + _); +} + +TEST(VideoFrameSampler, RejectsTooLargeVRow) { + EXPECT_DEATH(GetDefaultSampler()->GetSampleValue( + VideoFrameSampler::ChannelType::V, 2, 0), + _); +} +#endif // GTEST_HAS_DEATH_TEST + +} // namespace webrtc diff --git a/video/cpu_scaling_tests.cc b/video/cpu_scaling_tests.cc index 308a7d4ad8..ac553a962d 100644 --- a/video/cpu_scaling_tests.cc +++ b/video/cpu_scaling_tests.cc @@ -20,7 +20,6 @@ #include "rtc_base/checks.h" #include "rtc_base/event.h" #include "test/call_test.h" -#include "test/field_trial.h" #include "test/frame_generator_capturer.h" #include "test/gtest.h" #include "test/video_test_constants.h" @@ -37,14 +36,11 @@ constexpr int kFps = 28; class CpuOveruseTest : public test::CallTest { protected: CpuOveruseTest() - : field_trials_("WebRTC-ForceSimulatedOveruseIntervalMs/1-60000-60000/") { - } + : CallTest("WebRTC-ForceSimulatedOveruseIntervalMs/1-60000-60000/") {} void RunTestAndCheckForAdaptation( const DegradationPreference& degradation_preference, bool expect_adaptation); - - test::ScopedFieldTrials field_trials_; }; void CpuOveruseTest::RunTestAndCheckForAdaptation( diff --git a/video/decode_synchronizer_unittest.cc b/video/decode_synchronizer_unittest.cc index a725f51aa9..852a1305a9 100644 --- a/video/decode_synchronizer_unittest.cc +++ b/video/decode_synchronizer_unittest.cc @@ -10,8 +10,7 @@ #include "video/decode_synchronizer.h" -#include - +#include #include #include #include diff --git a/video/encoder_bitrate_adjuster_unittest.cc b/video/encoder_bitrate_adjuster_unittest.cc index 642664a253..8f935906ec 100644 --- a/video/encoder_bitrate_adjuster_unittest.cc +++ b/video/encoder_bitrate_adjuster_unittest.cc @@ -17,6 +17,7 @@ #include #include +#include "api/field_trials.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" @@ -29,8 +30,8 @@ #include "api/video_codecs/video_encoder.h" #include "rtc_base/checks.h" #include "rtc_base/time_utils.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" namespace webrtc { @@ -58,7 +59,7 @@ class EncoderBitrateAdjusterTest : public Test, target_framerate_fps_(kDefaultFrameRateFps), tl_pattern_idx_{}, sequence_idx_{}, - scoped_field_trial_(GetParam()) {} + field_trials_(CreateTestFieldTrials(GetParam())) {} protected: void SetUpAdjusterWithCodec(size_t num_spatial_layers, @@ -76,7 +77,7 @@ class EncoderBitrateAdjusterTest : public Test, } adjuster_ = std::make_unique( - codec_, scoped_field_trial_, *time_controller_.GetClock()); + codec_, field_trials_, *time_controller_.GetClock()); adjuster_->OnEncoderInfo(encoder_info_); current_adjusted_allocation_ = adjuster_->AdjustRateAllocation(VideoEncoder::RateControlParameters( @@ -263,7 +264,7 @@ class EncoderBitrateAdjusterTest : public Test, double target_framerate_fps_; int tl_pattern_idx_[kMaxSpatialLayers]; int sequence_idx_[kMaxSpatialLayers][kMaxTemporalStreams]; - test::ScopedKeyValueConfig scoped_field_trial_; + FieldTrials field_trials_; const std::vector kTlPatterns[kMaxTemporalStreams] = { {0}, diff --git a/video/end_to_end_tests/bandwidth_tests.cc b/video/end_to_end_tests/bandwidth_tests.cc index b073e6745d..e711e1dfbe 100644 --- a/video/end_to_end_tests/bandwidth_tests.cc +++ b/video/end_to_end_tests/bandwidth_tests.cc @@ -10,7 +10,6 @@ #include #include -#include #include #include "api/array_view.h" @@ -37,10 +36,8 @@ #include "rtc_base/task_queue_for_test.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/rtcp_packet_parser.h" #include "test/rtp_rtcp_observer.h" @@ -327,9 +324,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. - test::ScopedFieldTrials field_trials( - std::string(field_trial::GetFieldTrialString()) + - "WebRTC-VideoRateControl/bitrate_adjuster:false/"); + field_trials().Set("WebRTC-VideoRateControl", "bitrate_adjuster:false"); class EncoderRateStatsTest : public test::EndToEndTest, public test::FakeEncoder { public: diff --git a/video/end_to_end_tests/codec_tests.cc b/video/end_to_end_tests/codec_tests.cc index e4ae7fb079..2372a8a88e 100644 --- a/video/end_to_end_tests/codec_tests.cc +++ b/video/end_to_end_tests/codec_tests.cc @@ -32,7 +32,6 @@ #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/field_trial.h" #include "test/frame_generator_capturer.h" #include "test/gtest.h" #include "test/video_test_constants.h" @@ -216,13 +215,10 @@ TEST_F(CodecEndToEndTest, class EndToEndTestH264 : public test::CallTest, public ::testing::WithParamInterface { public: - EndToEndTestH264() : field_trial_(GetParam()) { + EndToEndTestH264() : CallTest(/*field_trials=*/GetParam()) { RegisterRtpExtension(RtpExtension(RtpExtension::kVideoRotationUri, kVideoRotationExtensionId)); } - - private: - test::ScopedFieldTrials field_trial_; }; INSTANTIATE_TEST_SUITE_P( diff --git a/video/end_to_end_tests/extended_reports_tests.cc b/video/end_to_end_tests/extended_reports_tests.cc index 2a37082f14..e193a14bd7 100644 --- a/video/end_to_end_tests/extended_reports_tests.cc +++ b/video/end_to_end_tests/extended_reports_tests.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include +#include #include #include #include @@ -34,7 +33,6 @@ #include "test/gtest.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" @@ -244,8 +242,7 @@ TEST_F(ExtendedReportsEndToEndTest, TEST_F(ExtendedReportsEndToEndTest, TestExtendedReportsWithoutRrtrWithTargetBitrateExplicitlySet) { - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-Target-Bitrate-Rtcp/Enabled/"); + field_trials().Set("WebRTC-Target-Bitrate-Rtcp", "Enabled"); RtcpXrObserver test(/*enable_rrtr=*/false, /*expect_target_bitrate=*/true, /*enable_zero_target_bitrate=*/false, VideoEncoderConfig::ContentType::kRealtimeVideo); diff --git a/video/end_to_end_tests/histogram_tests.cc b/video/end_to_end_tests/histogram_tests.cc index 65775f1a12..2fb2eb54bf 100644 --- a/video/end_to_end_tests/histogram_tests.cc +++ b/video/end_to_end_tests/histogram_tests.cc @@ -17,6 +17,7 @@ #include "api/environment/environment.h" #include "api/rtp_parameters.h" #include "api/test/video/function_video_encoder_factory.h" +#include "api/units/timestamp.h" #include "api/video/video_codec_type.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" @@ -94,12 +95,11 @@ void HistogramTest::VerifyHistogramStats(bool use_rtx, } bool MinMetricRunTimePassed() { - int64_t now_ms = Clock::GetRealTimeClock()->TimeInMilliseconds(); - if (!start_runtime_ms_) - start_runtime_ms_ = now_ms; + Timestamp now = Clock::GetRealTimeClock()->CurrentTime(); + if (!start_runtime_) + start_runtime_ = now; - int64_t elapsed_sec = (now_ms - *start_runtime_ms_) / 1000; - return elapsed_sec > metrics::kMinRunTimeInSeconds * 2; + return now - *start_runtime_ > metrics::kMinRunTime * 2; } bool MinNumberOfFramesReceived() const { @@ -168,7 +168,7 @@ void HistogramTest::VerifyHistogramStats(bool use_rtx, const bool use_fec_; const bool screenshare_; test::FunctionVideoEncoderFactory encoder_factory_; - std::optional start_runtime_ms_; + std::optional start_runtime_; int num_frames_received_ RTC_GUARDED_BY(&mutex_); } test(use_rtx, use_fec, screenshare); diff --git a/video/end_to_end_tests/multi_stream_tests.cc b/video/end_to_end_tests/multi_stream_tests.cc index 0a20b34b6f..369603ca8f 100644 --- a/video/end_to_end_tests/multi_stream_tests.cc +++ b/video/end_to_end_tests/multi_stream_tests.cc @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include - +#include +#include #include #include 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 786535a4aa..a3ac6102c5 100644 --- a/video/end_to_end_tests/resolution_bitrate_limits_tests.cc +++ b/video/end_to_end_tests/resolution_bitrate_limits_tests.cc @@ -30,7 +30,6 @@ #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" @@ -228,12 +227,11 @@ class InitEncodeTest : public test::EndToEndTest, }; TEST_P(ResolutionBitrateLimitsTest, LimitsApplied) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:921600," - "min_start_bitrate_bps:0," - "min_bitrate_bps:32000," - "max_bitrate_bps:3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:921600," + "min_start_bitrate_bps:0," + "min_bitrate_bps:32000," + "max_bitrate_bps:3333000"); InitEncodeTest test(env(), payload_name_, {{.active = true}}, // Expectations: @@ -272,12 +270,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, } TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, OneStreamLimitsAppliedForOneSpatialLayer) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:921600," - "min_start_bitrate_bps:0," - "min_bitrate_bps:32000," - "max_bitrate_bps:3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:921600," + "min_start_bitrate_bps:0," + "min_bitrate_bps:32000," + "max_bitrate_bps:3333000"); InitEncodeTest test( env(), "VP9", @@ -291,12 +288,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, OneStreamLimitsNotAppliedForMultipleSpatialLayers) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:21000|32000," - "max_bitrate_bps:2222000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:21000|32000," + "max_bitrate_bps:2222000|3333000"); InitEncodeTest test( env(), "VP9", @@ -324,12 +320,11 @@ TEST_P(ResolutionBitrateLimitsTest, EncodingsApplied) { } TEST_P(ResolutionBitrateLimitsTest, IntersectionApplied) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:921600," - "min_start_bitrate_bps:0," - "min_bitrate_bps:32000," - "max_bitrate_bps:3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:921600," + "min_start_bitrate_bps:0," + "min_bitrate_bps:32000," + "max_bitrate_bps:3333000"); InitEncodeTest test(env(), payload_name_, {{.active = true, @@ -343,12 +338,11 @@ TEST_P(ResolutionBitrateLimitsTest, IntersectionApplied) { } TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedMiddleActive) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:21000|32000," - "max_bitrate_bps:2222000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:21000|32000," + "max_bitrate_bps:2222000|3333000"); InitEncodeTest test(env(), payload_name_, {{.active = false}, {.active = true}, {.active = false}}, @@ -360,12 +354,11 @@ TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedMiddleActive) { } TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedMiddleActive) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:1111000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:1111000|3333000"); InitEncodeTest test(env(), payload_name_, {{.active = false, @@ -383,12 +376,11 @@ TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedMiddleActive) { } TEST_P(ResolutionBitrateLimitsTest, MinBitrateNotAboveEncodingMax) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:1111000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:1111000|3333000"); InitEncodeTest test( env(), payload_name_, @@ -404,12 +396,11 @@ TEST_P(ResolutionBitrateLimitsTest, MinBitrateNotAboveEncodingMax) { } TEST_P(ResolutionBitrateLimitsTest, MaxBitrateNotBelowEncodingMin) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:21000|22000," - "max_bitrate_bps:31000|32000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:21000|22000," + "max_bitrate_bps:31000|32000"); InitEncodeTest test( env(), payload_name_, @@ -464,12 +455,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, } TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedHighestActive) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:2222000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:2222000|3333000"); InitEncodeTest test(env(), payload_name_, {{.active = false}, {.active = false}, {.active = true}}, @@ -481,12 +471,11 @@ TEST_P(ResolutionBitrateLimitsTest, LimitsAppliedHighestActive) { } TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedHighestActive) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:555000|1111000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:555000|1111000"); InitEncodeTest test(env(), payload_name_, {{.active = false, @@ -506,12 +495,11 @@ TEST_P(ResolutionBitrateLimitsTest, EncodingMinMaxBitrateAppliedHighestActive) { } TEST_P(ResolutionBitrateLimitsTest, LimitsNotAppliedLowestActive) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:2222000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:2222000|3333000"); InitEncodeTest test(env(), payload_name_, {{.active = true}, {.active = false}}, @@ -527,12 +515,11 @@ TEST_P(ResolutionBitrateLimitsTest, LimitsNotAppliedLowestActive) { TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsAppliedForVp9OneSpatialLayer) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:2222000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:2222000|3333000"); InitEncodeTest test( env(), "VP9", @@ -547,12 +534,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsNotAppliedForVp9MultipleSpatialLayers) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:2222000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:2222000|3333000"); InitEncodeTest test( env(), "VP9", @@ -570,12 +556,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, OneStreamLimitsAppliedForAv1OneSpatialLayer) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:921600," - "min_start_bitrate_bps:0," - "min_bitrate_bps:32000," - "max_bitrate_bps:133000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:921600," + "min_start_bitrate_bps:0," + "min_bitrate_bps:32000," + "max_bitrate_bps:133000"); InitEncodeTest test( env(), "AV1", @@ -589,12 +574,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsAppliedForAv1SingleSpatialLayer) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:25000|80000," - "max_bitrate_bps:400000|1200000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:25000|80000," + "max_bitrate_bps:400000|1200000"); InitEncodeTest test( env(), "AV1", @@ -609,12 +593,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, EncodingMinMaxBitrateAppliedForAv1SingleSpatialLayer) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:921600," - "min_start_bitrate_bps:0," - "min_bitrate_bps:32000," - "max_bitrate_bps:99000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:921600," + "min_start_bitrate_bps:0," + "min_bitrate_bps:32000," + "max_bitrate_bps:99000"); InitEncodeTest test(env(), "AV1", {{.active = true, @@ -631,12 +614,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, LimitsNotAppliedForAv1MultipleSpatialLayers) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:20000|25000," - "max_bitrate_bps:900000|1333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:20000|25000," + "max_bitrate_bps:900000|1333000"); InitEncodeTest test( env(), "AV1", @@ -653,12 +635,11 @@ TEST_F(ResolutionBitrateLimitsWithScalabilityModeTest, } TEST_P(ResolutionBitrateLimitsTest, LimitsNotAppliedSimulcast) { - test::ScopedFieldTrials field_trials( - "WebRTC-GetEncoderInfoOverride/" - "frame_size_pixels:230400|921600," - "min_start_bitrate_bps:0|0," - "min_bitrate_bps:31000|32000," - "max_bitrate_bps:2222000|3333000/"); + field_trials().Set("WebRTC-GetEncoderInfoOverride", + "frame_size_pixels:230400|921600," + "min_start_bitrate_bps:0|0," + "min_bitrate_bps:31000|32000," + "max_bitrate_bps:2222000|3333000"); InitEncodeTest test(env(), payload_name_, {{.active = true}, {.active = true}}, diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc index 13008f9878..8afd8d3bd2 100644 --- a/video/end_to_end_tests/stats_tests.cc +++ b/video/end_to_end_tests/stats_tests.cc @@ -30,6 +30,7 @@ #include "api/test/video/function_video_encoder_factory.h" #include "api/transport/bitrate_settings.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_codecs/sdp_video_format.h" @@ -682,12 +683,11 @@ TEST_F(StatsEndToEndTest, VerifyNackStats) { } bool MinMetricRunTimePassed() { - int64_t now_ms = Clock::GetRealTimeClock()->TimeInMilliseconds(); - if (!start_runtime_ms_) - start_runtime_ms_ = now_ms; + Timestamp now = Clock::GetRealTimeClock()->CurrentTime(); + if (!start_runtime_) + start_runtime_ = now; - int64_t elapsed_sec = (now_ms - *start_runtime_ms_) / 1000; - return elapsed_sec > metrics::kMinRunTimeInSeconds; + return now - *start_runtime_ > metrics::kMinRunTime; } void ModifyVideoConfigs( @@ -719,7 +719,7 @@ TEST_F(StatsEndToEndTest, VerifyNackStats) { bool dropped_rtp_packet_requested_ RTC_GUARDED_BY(&mutex_) = false; std::vector receive_streams_; VideoSendStream* send_stream_ = nullptr; - std::optional start_runtime_ms_; + std::optional start_runtime_; TaskQueueBase* const task_queue_; scoped_refptr task_safety_flag_ = PendingTaskSafetyFlag::CreateDetached(); diff --git a/video/end_to_end_tests/transport_feedback_tests.cc b/video/end_to_end_tests/transport_feedback_tests.cc index 333cc0c534..06a4d6c8ad 100644 --- a/video/end_to_end_tests/transport_feedback_tests.cc +++ b/video/end_to_end_tests/transport_feedback_tests.cc @@ -40,7 +40,6 @@ #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" @@ -342,8 +341,7 @@ TEST_F(TransportFeedbackEndToEndTest, AudioVideoReceivesTransportFeedback) { TEST_F(TransportFeedbackEndToEndTest, StopsAndResumesMediaWhenCongestionWindowFull) { - test::ScopedFieldTrials override_field_trials( - "WebRTC-CongestionWindow/QueueSize:250/"); + field_trials().Set("WebRTC-CongestionWindow", "QueueSize:250"); class TransportFeedbackTester : public test::EndToEndTest { public: diff --git a/video/frame_cadence_adapter_unittest.cc b/video/frame_cadence_adapter_unittest.cc index 4bee5194cd..af97b7b8e9 100644 --- a/video/frame_cadence_adapter_unittest.cc +++ b/video/frame_cadence_adapter_unittest.cc @@ -18,6 +18,7 @@ #include #include "absl/functional/any_invocable.h" +#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/make_ref_counted.h" #include "api/metronome/test/fake_metronome.h" @@ -38,9 +39,9 @@ #include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" #include "system_wrappers/include/ntp_time.h" +#include "test/create_test_field_trials.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 { @@ -89,7 +90,7 @@ class MockCallback : public FrameCadenceAdapterInterface::Callback { }; TEST(FrameCadenceAdapterTest, CountsOutstandingFramesToProcess) { - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1)); MockCallback callback; auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); @@ -106,7 +107,7 @@ TEST(FrameCadenceAdapterTest, CountsOutstandingFramesToProcess) { } TEST(FrameCadenceAdapterTest, FrameRateFollowsRateStatisticsByDefault) { - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); GlobalSimulatedTimeController time_controller(Timestamp::Zero()); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); MockCallback callback; @@ -132,7 +133,7 @@ TEST(FrameCadenceAdapterTest, FrameRateFollowsRateStatisticsByDefault) { TEST(FrameCadenceAdapterTest, FrameRateFollowsMaxFpsWhenZeroHertzActivated) { GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); MockCallback callback; adapter->Initialize(&callback); @@ -150,7 +151,7 @@ TEST(FrameCadenceAdapterTest, FrameRateFollowsMaxFpsWhenZeroHertzActivated) { TEST(FrameCadenceAdapterTest, ZeroHertzAdapterSupportsMaxFpsChange) { GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); MockCallback callback; adapter->Initialize(&callback); @@ -174,7 +175,7 @@ TEST(FrameCadenceAdapterTest, ZeroHertzAdapterSupportsMaxFpsChange) { TEST(FrameCadenceAdapterTest, FrameRateFollowsRateStatisticsAfterZeroHertzDeactivated) { GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); MockCallback callback; adapter->Initialize(&callback); @@ -205,7 +206,7 @@ TEST(FrameCadenceAdapterTest, TEST(FrameCadenceAdapterTest, ForwardsFramesDelayed) { MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -234,7 +235,7 @@ TEST(FrameCadenceAdapterTest, ForwardsFramesDelayed) { TEST(FrameCadenceAdapterTest, DelayedProcessingUnderSlightContention) { GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); MockCallback callback; adapter->Initialize(&callback); @@ -256,7 +257,7 @@ TEST(FrameCadenceAdapterTest, DelayedProcessingUnderSlightContention) { TEST(FrameCadenceAdapterTest, DelayedProcessingUnderHeavyContention) { GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); MockCallback callback; adapter->Initialize(&callback); @@ -285,7 +286,7 @@ TEST(FrameCadenceAdapterTest, RepeatsFramesDelayed) { // not 0. MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(47892223)); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -339,7 +340,7 @@ TEST(FrameCadenceAdapterTest, // time. MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(4711)); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -372,7 +373,7 @@ TEST(FrameCadenceAdapterTest, StopsRepeatingFramesDelayed) { // At 3.5s, we receive this frame. MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -400,7 +401,7 @@ TEST(FrameCadenceAdapterTest, StopsRepeatingFramesDelayed) { TEST(FrameCadenceAdapterTest, RequestsRefreshFrameOnKeyFrameRequestWhenNew) { MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -418,7 +419,7 @@ TEST(FrameCadenceAdapterTest, RequestsRefreshFrameOnKeyFrameRequestWhenNew) { TEST(FrameCadenceAdapterTest, IgnoresKeyFrameRequestShortlyAfterFrame) { MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -433,7 +434,7 @@ TEST(FrameCadenceAdapterTest, IgnoresKeyFrameRequestShortlyAfterFrame) { TEST(FrameCadenceAdapterTest, RequestsRefreshFramesUntilArrival) { MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -459,7 +460,7 @@ TEST(FrameCadenceAdapterTest, RequestsRefreshFramesUntilArrival) { TEST(FrameCadenceAdapterTest, RequestsRefreshAfterFrameDrop) { MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -500,7 +501,7 @@ TEST(FrameCadenceAdapterTest, RequestsRefreshAfterFrameDrop) { TEST(FrameCadenceAdapterTest, OmitsRefreshAfterFrameDropWithTimelyFrameEntry) { MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -539,7 +540,7 @@ TEST(FrameCadenceAdapterTest, AcceptsUnconfiguredLayerFeedback) { // This is a regression test for bugs.webrtc.org/14417. MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Zero()); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( @@ -558,7 +559,7 @@ TEST(FrameCadenceAdapterTest, IgnoresDropInducedCallbacksPostDestruction) { GlobalSimulatedTimeController time_controller(Timestamp::Zero()); auto queue = time_controller.GetTaskQueueFactory()->CreateTaskQueue( "queue", TaskQueueFactory::Priority::NORMAL); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = FrameCadenceAdapterInterface::Create( time_controller.GetClock(), queue.get(), /*metronome=*/nullptr, /*worker_queue=*/nullptr, no_field_trials); @@ -587,7 +588,7 @@ TEST(FrameCadenceAdapterTest, EncodeFramesAreAlignedWithMetronomeTick) { auto worker_queue = time_controller.GetTaskQueueFactory()->CreateTaskQueue( "work_queue", TaskQueueFactory::Priority::NORMAL); test::FakeMetronome metronome(kTickPeriod); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = FrameCadenceAdapterInterface::Create( time_controller.GetClock(), queue.get(), &metronome, worker_queue.get(), no_field_trials); @@ -661,7 +662,7 @@ TEST(FrameCadenceAdapterTest, ShutdownUnderMetronome) { auto queue = time_controller.GetTaskQueueFactory()->CreateTaskQueue( "queue", TaskQueueFactory::Priority::NORMAL); test::FakeMetronome metronome(kTickPeriod); - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); auto adapter = FrameCadenceAdapterInterface::Create( time_controller.GetClock(), queue.get(), &metronome, TaskQueueBase::Current(), no_field_trials); @@ -704,7 +705,7 @@ class FrameCadenceAdapterSimulcastLayersParamTest int NumSpatialLayers() const { return GetParam(); } protected: - test::ScopedKeyValueConfig no_field_trials_; + FieldTrials no_field_trials_ = CreateTestFieldTrials(); MockCallback callback_; GlobalSimulatedTimeController time_controller_{Timestamp::Zero()}; const std::unique_ptr adapter_{ @@ -833,7 +834,7 @@ class ZeroHertzLayerQualityConvergenceTest : public ::testing::Test { } protected: - test::ScopedKeyValueConfig no_field_trials_; + FieldTrials no_field_trials_ = CreateTestFieldTrials(); MockCallback callback_; GlobalSimulatedTimeController time_controller_{Timestamp::Zero()}; std::unique_ptr adapter_{ @@ -1029,7 +1030,7 @@ TEST(FrameCadenceAdapterRealTimeTest, TimestampsDoNotDrift) { int64_t original_ntp_time_ms; int64_t original_timestamp_us; Event event; - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); queue->PostTask([&] { adapter = CreateAdapter(no_field_trials, clock); adapter->Initialize(&callback); @@ -1084,7 +1085,7 @@ TEST(FrameCadenceAdapterRealTimeTest, ScheduledRepeatAllowsForSlowEncode) { int frame_counter = 0; Event event; std::optional start_time; - test::ScopedKeyValueConfig no_field_trials; + FieldTrials no_field_trials = CreateTestFieldTrials(); queue->PostTask([&] { adapter = CreateAdapter(no_field_trials, clock); adapter->Initialize(&callback); diff --git a/video/frame_decode_timing_unittest.cc b/video/frame_decode_timing_unittest.cc index da7a098ad0..98bdd1cac9 100644 --- a/video/frame_decode_timing_unittest.cc +++ b/video/frame_decode_timing_unittest.cc @@ -10,10 +10,10 @@ #include "video/frame_decode_timing.h" -#include - +#include #include +#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -21,9 +21,9 @@ #include "rtc_base/checks.h" #include "rtc_base/containers/flat_map.h" #include "system_wrappers/include/clock.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" #include "video/video_receive_stream2.h" namespace webrtc { @@ -70,12 +70,13 @@ class FakeVCMTiming : public VCMTiming { class FrameDecodeTimingTest : public ::testing::Test { public: FrameDecodeTimingTest() - : clock_(Timestamp::Millis(1000)), + : field_trials_(CreateTestFieldTrials()), + clock_(Timestamp::Millis(1000)), timing_(&clock_, field_trials_), frame_decode_scheduler_(&clock_, &timing_) {} protected: - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_; SimulatedClock clock_; FakeVCMTiming timing_; FrameDecodeTiming frame_decode_scheduler_; diff --git a/video/quality_convergence_controller_unittest.cc b/video/quality_convergence_controller_unittest.cc index 4f7cf63b57..73b9a0c344 100644 --- a/video/quality_convergence_controller_unittest.cc +++ b/video/quality_convergence_controller_unittest.cc @@ -12,16 +12,17 @@ #include +#include "api/field_trials.h" #include "api/video/video_codec_type.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" namespace webrtc { namespace { constexpr int kVp8DefaultStaticQpThreshold = 15; TEST(QualityConvergenceController, Singlecast) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); QualityConvergenceController controller; controller.Initialize(1, /*encoder_min_qp=*/std::nullopt, kVideoCodecVP8, field_trials); @@ -35,7 +36,7 @@ TEST(QualityConvergenceController, Singlecast) { } TEST(QualityConvergenceController, Simulcast) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); QualityConvergenceController controller; controller.Initialize(2, /*encoder_min_qp=*/std::nullopt, kVideoCodecVP8, field_trials); @@ -65,7 +66,7 @@ TEST(QualityConvergenceController, Simulcast) { } TEST(QualityConvergenceController, InvalidLayerIndex) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); QualityConvergenceController controller; controller.Initialize(2, /*encoder_min_qp=*/std::nullopt, kVideoCodecVP8, field_trials); @@ -79,7 +80,7 @@ TEST(QualityConvergenceController, InvalidLayerIndex) { } TEST(QualityConvergenceController, UseMaxOfEncoderMinAndDefaultQpThresholds) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); QualityConvergenceController controller; controller.Initialize(1, kVp8DefaultStaticQpThreshold + 1, kVideoCodecVP8, field_trials); @@ -93,8 +94,8 @@ TEST(QualityConvergenceController, UseMaxOfEncoderMinAndDefaultQpThresholds) { } TEST(QualityConvergenceController, OverrideVp8StaticThreshold) { - test::ScopedKeyValueConfig field_trials( - "WebRTC-QCM-Static-VP8/static_qp_threshold:22/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-QCM-Static-VP8/static_qp_threshold:22/"); QualityConvergenceController controller; controller.Initialize(1, /*encoder_min_qp=*/std::nullopt, kVideoCodecVP8, field_trials); @@ -106,8 +107,8 @@ TEST(QualityConvergenceController, OverrideVp8StaticThreshold) { } TEST(QualityConvergenceMonitorSetup, OverrideVp9StaticThreshold) { - test::ScopedKeyValueConfig field_trials( - "WebRTC-QCM-Static-VP9/static_qp_threshold:44/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-QCM-Static-VP9/static_qp_threshold:44/"); QualityConvergenceController controller; controller.Initialize(1, /*encoder_min_qp=*/std::nullopt, kVideoCodecVP9, field_trials); @@ -119,8 +120,8 @@ TEST(QualityConvergenceMonitorSetup, OverrideVp9StaticThreshold) { } TEST(QualityConvergenceMonitorSetup, OverrideAv1StaticThreshold) { - test::ScopedKeyValueConfig field_trials( - "WebRTC-QCM-Static-AV1/static_qp_threshold:46/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-QCM-Static-AV1/static_qp_threshold:46/"); QualityConvergenceController controller; controller.Initialize(1, /*encoder_min_qp=*/std::nullopt, kVideoCodecAV1, field_trials); diff --git a/video/quality_convergence_monitor_unittest.cc b/video/quality_convergence_monitor_unittest.cc index c8da0a7d38..069b20181c 100644 --- a/video/quality_convergence_monitor_unittest.cc +++ b/video/quality_convergence_monitor_unittest.cc @@ -13,9 +13,10 @@ #include #include +#include "api/field_trials.h" #include "api/video/video_codec_type.h" +#include "test/create_test_field_trials.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" namespace webrtc { namespace { @@ -201,7 +202,7 @@ TEST(QualityConvergenceMonitorAlgorithm, // Test default values and that they can be overridden with field trials. TEST(QualityConvergenceMonitorSetup, DefaultParameters) { - test::ScopedKeyValueConfig field_trials; + FieldTrials field_trials = CreateTestFieldTrials(); auto monitor = QualityConvergenceMonitor::Create( kStaticQpThreshold, kVideoCodecVP8, field_trials); ASSERT_TRUE(monitor); @@ -237,7 +238,7 @@ TEST(QualityConvergenceMonitorSetup, DefaultParameters) { } TEST(QualityConvergenceMonitorSetup, OverrideVp8Parameters) { - test::ScopedKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-QCM-Dynamic-VP8/" "enabled:1,alpha:0.08,recent_length:6,past_length:4/"); @@ -253,7 +254,7 @@ TEST(QualityConvergenceMonitorSetup, OverrideVp8Parameters) { } TEST(QualityConvergenceMonitorSetup, OverrideVp9Parameters) { - test::ScopedKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-QCM-Dynamic-VP9/" "enabled:1,alpha:0.08,recent_length:6,past_length:4/"); @@ -269,7 +270,7 @@ TEST(QualityConvergenceMonitorSetup, OverrideVp9Parameters) { } TEST(QualityConvergenceMonitorSetup, OverrideAv1Parameters) { - test::ScopedKeyValueConfig field_trials( + FieldTrials field_trials = CreateTestFieldTrials( "WebRTC-QCM-Dynamic-AV1/" "enabled:1,alpha:0.10,recent_length:8,past_length:8/"); @@ -285,7 +286,8 @@ TEST(QualityConvergenceMonitorSetup, OverrideAv1Parameters) { } TEST(QualityConvergenceMonitorSetup, DisableVp9Dynamic) { - test::ScopedKeyValueConfig field_trials("WebRTC-QCM-Dynamic-VP9/enabled:0/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-QCM-Dynamic-VP9/enabled:0/"); auto monitor = QualityConvergenceMonitor::Create( kStaticQpThreshold, kVideoCodecVP9, field_trials); @@ -295,7 +297,8 @@ TEST(QualityConvergenceMonitorSetup, DisableVp9Dynamic) { } TEST(QualityConvergenceMonitorSetup, DisableAv1Dynamic) { - test::ScopedKeyValueConfig field_trials("WebRTC-QCM-Dynamic-AV1/enabled:0/"); + FieldTrials field_trials = + CreateTestFieldTrials("WebRTC-QCM-Dynamic-AV1/enabled:0/"); auto monitor = QualityConvergenceMonitor::Create( kStaticQpThreshold, kVideoCodecAV1, field_trials); diff --git a/video/quality_scaling_tests.cc b/video/quality_scaling_tests.cc index bc9b72b549..cd7e2d7c15 100644 --- a/video/quality_scaling_tests.cc +++ b/video/quality_scaling_tests.cc @@ -39,11 +39,11 @@ #include "modules/video_coding/codecs/vp9/include/vp9.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/encoder_info_settings.h" +#include "rtc_base/strings/string_builder.h" #include "test/call_test.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/video_encoder_config.h" @@ -78,8 +78,23 @@ void SetEncoderSpecific(VideoEncoderConfig* encoder_config, class QualityScalingTest : public test::CallTest { protected: - const std::string kPrefix = "WebRTC-Video-QualityScaling/Enabled-"; - const std::string kEnd = ",0,0,0.9995,0.9999,1/"; + struct QualityScalingParams { + int vp8_low = 0; + int vp8_high = 0; + int vp9_low = 0; + int vp9_high = 0; + int h264_low = 0; + int h264_high = 0; + }; + void SetQualityScalingTrialQP(QualityScalingParams p) { + StringBuilder sb; + sb << "Enabled-" << p.vp8_low << "," << p.vp8_high // + << "," << p.vp9_low << "," << p.vp9_high // + << "," << p.h264_low << "," << p.h264_high // + << ",0,0,0.9995,0.9999,1"; + field_trials().Set("WebRTC-Video-QualityScaling", sb.str()); + } + const std::optional kSinglecastLimits720pVp8 = EncoderInfoSettings::GetDefaultSinglecastBitrateLimitsForResolution( @@ -264,8 +279,7 @@ class UpscalingObserver TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,1,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 1}); DownscalingObserver test("VP8", {{.active = true}}, kHighStartBps, /*automatic_resize=*/true, @@ -275,8 +289,7 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,1,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 1}); DownscalingObserver test("VP8", {{.active = true}}, kHighStartBps, /*automatic_resize=*/false, @@ -286,8 +299,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForNormalQp_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test("VP8", {{.active = true}}, kHighStartBps, /*automatic_resize=*/true, @@ -297,8 +309,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForNormalQp_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test("VP8", {{.active = true}}, kLowStartBps, /*automatic_resize=*/true, @@ -308,11 +319,10 @@ TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrateAndThenUp) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedKeyValueConfig field_trials( - field_trials_, - kPrefix + "127,127,0,0,0,0" + kEnd + - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:230400|921600,fps:20|30,kbps:300|500/"); // should not affect + SetQualityScalingTrialQP({.vp8_low = 127, .vp8_high = 127}); + field_trials().Set( + "WebRTC-Video-BalancedDegradationSettings", + "pixels:230400|921600,fps:20|30,kbps:300|500"); // should not affect UpscalingObserver test("VP8", {{.active = true}}, kDefaultVgaMinStartBps - 1, /*automatic_resize=*/true, /*expect_upscale=*/true); @@ -321,10 +331,9 @@ TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrateAndThenUp) { TEST_F(QualityScalingTest, AdaptsDownAndThenUpWithBalanced) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedKeyValueConfig field_trials( - field_trials_, kPrefix + "127,127,0,0,0,0" + kEnd + - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:230400|921600,fps:20|30,kbps:300|499/"); + SetQualityScalingTrialQP({.vp8_low = 127, .vp8_high = 127}); + field_trials().Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:230400|921600,fps:20|30,kbps:300|499"); UpscalingObserver test("VP8", {{.active = true}}, kDefaultVgaMinStartBps - 1, /*automatic_resize=*/true, /*expect_upscale=*/true); @@ -334,10 +343,9 @@ TEST_F(QualityScalingTest, AdaptsDownAndThenUpWithBalanced) { TEST_F(QualityScalingTest, AdaptsDownButNotUpWithBalancedIfBitrateNotEnough) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedKeyValueConfig field_trials( - field_trials_, kPrefix + "127,127,0,0,0,0" + kEnd + - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:230400|921600,fps:20|30,kbps:300|500/"); + SetQualityScalingTrialQP({.vp8_low = 127, .vp8_high = 127}); + field_trials().Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:230400|921600,fps:20|30,kbps:300|500"); UpscalingObserver test("VP8", {{.active = true}}, kDefaultVgaMinStartBps - 1, /*automatic_resize=*/true, /*expect_upscale=*/false); @@ -347,8 +355,7 @@ TEST_F(QualityScalingTest, AdaptsDownButNotUpWithBalancedIfBitrateNotEnough) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_Simulcast) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test("VP8", {{.active = true}, {.active = true}}, kLowStartBps, @@ -359,8 +366,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_Simulcast) { TEST_F(QualityScalingTest, AdaptsDownForHighQp_HighestStreamActive_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,1,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 1}); DownscalingObserver test( "VP8", {{.active = false}, {.active = false}, {.active = true}}, @@ -373,8 +379,7 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_HighestStreamActive_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_HighestStreamActive_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test( "VP8", {{.active = false}, {.active = false}, {.active = true}}, @@ -386,8 +391,7 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, AdaptsDownButNotUpWithMinStartBitrateLimit) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "127,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 127, .vp8_high = 127}); UpscalingObserver test("VP8", {{.active = false}, {.active = true}}, kSinglecastLimits720pVp8->min_start_bitrate_bps - 1, @@ -397,8 +401,7 @@ TEST_F(QualityScalingTest, AdaptsDownButNotUpWithMinStartBitrateLimit) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test( "VP8", {{.active = false}, {.active = false}, {.active = true}}, @@ -411,9 +414,8 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfDefaultLimitsDisabled_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials( - field_trials_, kPrefix + "1,127,0,0,0,0" + kEnd + - "WebRTC-DefaultBitrateLimitsKillSwitch/Enabled/"); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); + field_trials().Set("WebRTC-DefaultBitrateLimitsKillSwitch", "Enabled"); DownscalingObserver test( "VP8", {{.active = false}, {.active = false}, {.active = true}}, @@ -426,8 +428,7 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_OneStreamSinglecastLimitsNotUsed_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test("VP8", {{.active = true}}, kSinglecastLimits720pVp8->min_start_bitrate_bps - 1, @@ -438,8 +439,7 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,1,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 1}); DownscalingObserver test( "VP8", {{.active = true}, {.active = false}, {.active = false}}, @@ -452,8 +452,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test( "VP8", {{.active = true}, {.active = false}, {.active = false}}, @@ -465,8 +464,7 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfScalingOff_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "1,127,0,0,0,0" + kEnd); + SetQualityScalingTrialQP({.vp8_low = 1, .vp8_high = 127}); DownscalingObserver test("VP8", {{.active = true}}, kLowStartBps, /*automatic_resize=*/false, @@ -476,8 +474,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfScalingOff_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,1,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 1}); DownscalingObserver test("VP9", {{.active = true}}, kHighStartBps, /*automatic_resize=*/true, @@ -487,9 +484,8 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp9) { TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials( - field_trials_, - kPrefix + "0,0,1,1,0,0" + kEnd + "WebRTC-VP9QualityScaler/Disabled/"); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 1}); + field_trials().Set("WebRTC-VP9QualityScaler", "Disabled"); DownscalingObserver test("VP9", {{.active = true}}, kHighStartBps, /*automatic_resize=*/true, @@ -499,8 +495,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp9) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,255,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 255}); DownscalingObserver test("VP9", {{.active = true}}, kLowStartBps, /*automatic_resize=*/true, @@ -519,8 +514,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighStartBitrate_Vp9) { TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,1,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 1}); DownscalingObserver test( "VP9", {{.active = true}, {.active = false}, {.active = false}}, @@ -533,8 +527,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp9) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,255,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 255}); DownscalingObserver test( "VP9", {{.active = true}, {.active = false}, {.active = false}}, @@ -546,8 +539,7 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, AdaptsDownForHighQp_MiddleStreamActive_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,1,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 1}); DownscalingObserver test( "VP9", {{.active = false}, {.active = true}, {.active = false}}, @@ -560,8 +552,7 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_MiddleStreamActive_Vp9) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_MiddleStreamActive_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,255,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 255}); DownscalingObserver test( "VP9", {{.active = false}, {.active = true}, {.active = false}}, @@ -573,8 +564,7 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,255,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 255}); DownscalingObserver test( "VP9", {{.active = false}, {.active = true}, {.active = false}}, @@ -587,8 +577,7 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp9) { TEST_F(QualityScalingTest, AdaptsDownButNotUpWithMinStartBitrateLimitWithScalabilityMode_VP9) { // qp_low:255, qp_high:255 -> kLowQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,255,255,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 255, .vp9_high = 255}); UpscalingObserver test( "VP9", @@ -602,8 +591,7 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnoughWithScalabilityMode_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,1,255,0,0" + kEnd); + SetQualityScalingTrialQP({.vp9_low = 1, .vp9_high = 255}); DownscalingObserver test( "VP9", @@ -619,8 +607,7 @@ TEST_F(QualityScalingTest, #if defined(WEBRTC_USE_H264) TEST_F(QualityScalingTest, AdaptsDownForHighQp_H264) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,0,0,1,1" + kEnd); + SetQualityScalingTrialQP({.h264_low = 1, .h264_high = 1}); DownscalingObserver test("H264", {{.active = true}}, kHighStartBps, /*automatic_resize=*/true, @@ -630,8 +617,7 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_H264) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_H264) { // qp_low:1, qp_high:51 -> kNormalQp - test::ScopedKeyValueConfig field_trials(field_trials_, - kPrefix + "0,0,0,0,1,51" + kEnd); + SetQualityScalingTrialQP({.h264_low = 1, .h264_high = 51}); DownscalingObserver test("H264", {{.active = true}}, kLowStartBps, /*automatic_resize=*/true, diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index b89ae42538..1ce49cad5f 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -90,7 +90,7 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t remote_ssrc, Clock* clock, TaskQueueBase* worker_thread) : clock_(clock), - start_ms_(clock->TimeInMilliseconds()), + start_(clock->CurrentTime()), remote_ssrc_(remote_ssrc), // 1000ms window, scale 1000 for ms to s. decode_fps_estimator_(1000, 1000), @@ -103,7 +103,6 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t remote_ssrc, last_content_type_(VideoContentType::UNSPECIFIED), last_codec_type_(kVideoCodecVP8), num_delayed_frames_rendered_(0), - sum_missed_render_deadline_ms_(0), timing_frame_info_counter_(kMovingMaxWindowMs), worker_thread_(worker_thread) { RTC_DCHECK(worker_thread); @@ -125,14 +124,14 @@ void ReceiveStatisticsProxy::UpdateHistograms( char log_stream_buf[8 * 1024]; SimpleStringBuilder log_stream(log_stream_buf); - int stream_duration_sec = (clock_->TimeInMilliseconds() - start_ms_) / 1000; + TimeDelta stream_duration = clock_->CurrentTime() - start_; if (stats_.frame_counts.key_frames > 0 || stats_.frame_counts.delta_frames > 0) { RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.ReceiveStreamLifetimeInSeconds", - stream_duration_sec); + stream_duration.seconds()); log_stream << "WebRTC.Video.ReceiveStreamLifetimeInSeconds " - << stream_duration_sec << '\n'; + << stream_duration.seconds() << '\n'; } log_stream << "Frames decoded " << stats_.frames_decoded << '\n'; @@ -145,7 +144,7 @@ void ReceiveStatisticsProxy::UpdateHistograms( << '\n'; } - if (fraction_lost && stream_duration_sec >= metrics::kMinRunTimeInSeconds) { + if (fraction_lost && stream_duration >= metrics::kMinRunTime) { RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", *fraction_lost); log_stream << "WebRTC.Video.ReceivedPacketsLostInPercent " << *fraction_lost @@ -155,7 +154,7 @@ void ReceiveStatisticsProxy::UpdateHistograms( if (first_decoded_frame_time_ms_) { const int64_t elapsed_ms = (clock_->TimeInMilliseconds() - *first_decoded_frame_time_ms_); - if (elapsed_ms >= metrics::kMinRunTimeInSeconds * kNumMillisecsPerSec) { + if (elapsed_ms >= metrics::kMinRunTime.ms()) { int decoded_fps = static_cast( (stats_.frames_decoded * 1000.0f / elapsed_ms) + 0.5f); RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.DecodedFramesPerSecond", @@ -171,8 +170,8 @@ void ReceiveStatisticsProxy::UpdateHistograms( if (num_delayed_frames_rendered_ > 0) { RTC_HISTOGRAM_COUNTS_1000( "WebRTC.Video.DelayedFramesToRenderer_AvgDelayInMs", - static_cast(sum_missed_render_deadline_ms_ / - num_delayed_frames_rendered_)); + (sum_missed_render_deadline_ / num_delayed_frames_rendered_) + .ms()); } } } @@ -335,7 +334,7 @@ void ReceiveStatisticsProxy::UpdateHistograms( // Don't report these 3 metrics unsliced, as more precise variants // are reported separately in this method. float flow_duration_sec = stats.flow_duration_ms / 1000.0; - if (flow_duration_sec >= metrics::kMinRunTimeInSeconds) { + if (flow_duration_sec >= metrics::kMinRunTime.seconds()) { int media_bitrate_kbps = static_cast(stats.total_media_bytes * 8 / flow_duration_sec / 1000); RTC_HISTOGRAM_COUNTS_SPARSE_10000( @@ -369,7 +368,7 @@ void ReceiveStatisticsProxy::UpdateHistograms( rtp_rtx_stats.Add(*rtx_stats); TimeDelta elapsed = rtp_rtx_stats.TimeSinceFirstPacket(clock_->CurrentTime()); - if (elapsed >= TimeDelta::Seconds(metrics::kMinRunTimeInSeconds)) { + if (elapsed >= metrics::kMinRunTime) { int64_t elapsed_sec = elapsed.seconds(); RTC_HISTOGRAM_COUNTS_10000( "WebRTC.Video.BitrateReceivedInKbps", @@ -745,10 +744,10 @@ void ReceiveStatisticsProxy::OnRenderedFrame( content_specific_stats->received_height.Add(frame_meta.height); // Consider taking stats_.render_delay_ms into account. - const int64_t time_until_rendering_ms = - frame_meta.render_time_ms() - frame_meta.decode_timestamp.ms(); - if (time_until_rendering_ms < 0) { - sum_missed_render_deadline_ms_ += -time_until_rendering_ms; + const TimeDelta time_until_rendering = + frame_meta.render_time - frame_meta.decode_timestamp; + if (time_until_rendering < TimeDelta::Zero()) { + sum_missed_render_deadline_ += -time_until_rendering; ++num_delayed_frames_rendered_; } diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h index 023f4fa5f2..111b7f3c45 100644 --- a/video/receive_statistics_proxy.h +++ b/video/receive_statistics_proxy.h @@ -22,6 +22,7 @@ #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" @@ -40,6 +41,7 @@ #include "rtc_base/rate_tracker.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" +#include "video/corruption_detection/frame_instrumentation_evaluation.h" #include "video/stats_counter.h" #include "video/video_quality_observer2.h" #include "video/video_stream_buffer_controller.h" @@ -55,7 +57,8 @@ struct VideoFrameMetaData; class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, public RtcpCnameCallback, - public RtcpPacketTypeCounterObserver { + public RtcpPacketTypeCounterObserver, + public CorruptionScoreObserver { public: ReceiveStatisticsProxy(uint32_t remote_ssrc, Clock* clock, @@ -115,7 +118,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, void OnCname(uint32_t ssrc, absl::string_view cname) override; void OnCorruptionScore(double corruption_score, - VideoContentType content_type); + VideoContentType content_type) override; // Implements RtcpPacketTypeCounterObserver. void RtcpPacketTypesCounterUpdated( @@ -165,7 +168,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, int64_t now_ms) const; Clock* const clock_; - const int64_t start_ms_; + const Timestamp start_; // Note: The `stats_.rtp_stats` member is not used or populated by this class. mutable VideoReceiveStreamInterface::Stats stats_ @@ -201,7 +204,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver, std::optional last_decoded_frame_time_ms_ RTC_GUARDED_BY(main_thread_); size_t num_delayed_frames_rendered_ RTC_GUARDED_BY(main_thread_); - int64_t sum_missed_render_deadline_ms_ RTC_GUARDED_BY(main_thread_); + TimeDelta sum_missed_render_deadline_ RTC_GUARDED_BY(main_thread_); // Mutable because calling Max() on MovingMaxCounter is not const. Yet it is // called from const GetStats(). mutable MovingMaxCounter timing_frame_info_counter_ diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc index 5e06231a38..b90d476860 100644 --- a/video/receive_statistics_proxy_unittest.cc +++ b/video/receive_statistics_proxy_unittest.cc @@ -40,7 +40,6 @@ #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" @@ -50,11 +49,11 @@ namespace internal { namespace { using ::testing::DoubleEq; -const TimeDelta kFreqOffsetProcessInterval = TimeDelta::Seconds(40); -const uint32_t kRemoteSsrc = 456; -const int kMinRequiredSamples = 200; -const int kWidth = 1280; -const int kHeight = 720; +constexpr TimeDelta kFreqOffsetProcessInterval = TimeDelta::Seconds(40); +constexpr uint32_t kRemoteSsrc = 456; +constexpr int kMinRequiredSamples = 200; +constexpr int kWidth = 1280; +constexpr int kHeight = 720; } // namespace // TODO(sakal): ReceiveStatisticsProxy is lacking unittesting. @@ -121,7 +120,6 @@ class ReceiveStatisticsProxyTest : public ::testing::Test { return VideoFrameMetaData(frame, Now()); } - test::ScopedKeyValueConfig field_trials_; GlobalSimulatedTimeController time_controller_; std::unique_ptr statistics_proxy_; }; @@ -139,8 +137,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) { TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReported) { const Frequency kFps = Frequency::Hertz(20); - const int kRequiredSamples = - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds) * kFps; + const int kRequiredSamples = metrics::kMinRunTime * kFps; VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kRequiredSamples; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), @@ -157,8 +154,7 @@ TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReported) { TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsNotReportedForTooFewSamples) { const Frequency kFps = Frequency::Hertz(20); - const int kRequiredSamples = - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds) * kFps; + const int kRequiredSamples = metrics::kMinRunTime * kFps; VideoFrame frame = CreateFrame(kWidth, kHeight); for (int i = 0; i < kRequiredSamples - 1; ++i) { statistics_proxy_->OnDecodedFrame(frame, std::nullopt, TimeDelta::Zero(), @@ -810,8 +806,7 @@ TEST_F(ReceiveStatisticsProxyTest, PacketLossHistogramIsUpdated) { SetUp(); // Min run time has passed. - time_controller_.AdvanceTime( - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds)); + time_controller_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_->UpdateHistograms(10, StreamDataCounters(), nullptr); EXPECT_METRIC_EQ( 1, metrics::NumSamples("WebRTC.Video.ReceivedPacketsLostInPercent")); @@ -1147,8 +1142,7 @@ TEST_F(ReceiveStatisticsProxyTest, ZeroDelayReportedIfFrameNotDelayed) { MetaData(CreateFrameWithRenderTime(Now()))); // Min run time has passed. - time_controller_.AdvanceTime( - TimeDelta::Seconds((metrics::kMinRunTimeInSeconds))); + time_controller_.AdvanceTime(metrics::kMinRunTime); FlushAndUpdateHistograms(std::nullopt, StreamDataCounters(), nullptr); EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.DelayedFramesToRenderer")); @@ -1170,8 +1164,7 @@ TEST_F(ReceiveStatisticsProxyTest, MetaData(CreateFrameWithRenderTime(Now()))); // Min run time has not passed. - time_controller_.AdvanceTime( - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds) - TimeDelta::Millis(1)); + time_controller_.AdvanceTime(metrics::kMinRunTime - TimeDelta::Millis(1)); statistics_proxy_->UpdateHistograms(std::nullopt, StreamDataCounters(), nullptr); EXPECT_METRIC_EQ(0, @@ -1188,8 +1181,7 @@ TEST_F(ReceiveStatisticsProxyTest, VideoFrameType::kVideoFrameKey); // Min run time has passed. No rendered frames. - time_controller_.AdvanceTime( - TimeDelta::Seconds((metrics::kMinRunTimeInSeconds))); + time_controller_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_->UpdateHistograms(std::nullopt, StreamDataCounters(), nullptr); EXPECT_METRIC_EQ(0, @@ -1209,8 +1201,7 @@ TEST_F(ReceiveStatisticsProxyTest, DelayReportedIfFrameIsDelayed) { MetaData(CreateFrameWithRenderTimeMs(Now().ms() - 1))); // Min run time has passed. - time_controller_.AdvanceTime( - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds)); + time_controller_.AdvanceTime(metrics::kMinRunTime); FlushAndUpdateHistograms(std::nullopt, StreamDataCounters(), nullptr); EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.DelayedFramesToRenderer")); @@ -1242,8 +1233,7 @@ TEST_F(ReceiveStatisticsProxyTest, AverageDelayOfDelayedFramesIsReported) { MetaData(CreateFrameWithRenderTimeMs(kNowMs + 1))); // Min run time has passed. - time_controller_.AdvanceTime( - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds)); + time_controller_.AdvanceTime(metrics::kMinRunTime); FlushAndUpdateHistograms(std::nullopt, StreamDataCounters(), nullptr); EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.DelayedFramesToRenderer")); @@ -1261,8 +1251,7 @@ TEST_F(ReceiveStatisticsProxyTest, StreamDataCounters data_counters; data_counters.first_packet_time = time_controller_.GetClock()->CurrentTime(); - time_controller_.AdvanceTime( - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds) - TimeDelta::Millis(1)); + time_controller_.AdvanceTime(metrics::kMinRunTime - TimeDelta::Millis(1)); RtcpPacketTypeCounter counter; statistics_proxy_->RtcpPacketTypesCounterUpdated(kRemoteSsrc, counter); @@ -1279,8 +1268,7 @@ TEST_F(ReceiveStatisticsProxyTest, TEST_F(ReceiveStatisticsProxyTest, RtcpHistogramsAreUpdated) { StreamDataCounters data_counters; data_counters.first_packet_time = time_controller_.GetClock()->CurrentTime(); - time_controller_.AdvanceTime( - TimeDelta::Seconds(metrics::kMinRunTimeInSeconds)); + time_controller_.AdvanceTime(metrics::kMinRunTime); const uint32_t kFirPackets = 100; const uint32_t kPliPackets = 200; @@ -1301,13 +1289,13 @@ TEST_F(ReceiveStatisticsProxyTest, RtcpHistogramsAreUpdated) { 1, metrics::NumSamples("WebRTC.Video.NackPacketsSentPerMinute")); EXPECT_METRIC_EQ( 1, metrics::NumEvents("WebRTC.Video.FirPacketsSentPerMinute", - kFirPackets * 60 / metrics::kMinRunTimeInSeconds)); + kFirPackets * 60 / metrics::kMinRunTime.seconds())); EXPECT_METRIC_EQ( 1, metrics::NumEvents("WebRTC.Video.PliPacketsSentPerMinute", - kPliPackets * 60 / metrics::kMinRunTimeInSeconds)); - EXPECT_METRIC_EQ( - 1, metrics::NumEvents("WebRTC.Video.NackPacketsSentPerMinute", - kNackPackets * 60 / metrics::kMinRunTimeInSeconds)); + kPliPackets * 60 / metrics::kMinRunTime.seconds())); + EXPECT_METRIC_EQ(1, metrics::NumEvents( + "WebRTC.Video.NackPacketsSentPerMinute", + kNackPackets * 60 / metrics::kMinRunTime.seconds())); } class ReceiveStatisticsProxyTestWithFreezeDuration @@ -1326,11 +1314,11 @@ class ReceiveStatisticsProxyTestWithFreezeDuration // the current one. // // Condition 1: 3 * avg_frame_duration > avg_frame_duration + 150 -const auto kFreezeDetectionCond1Freeze = std::make_tuple(150, 483, 1); -const auto kFreezeDetectionCond1NotFreeze = std::make_tuple(150, 482, 0); +constexpr auto kFreezeDetectionCond1Freeze = std::make_tuple(150, 483, 1); +constexpr auto kFreezeDetectionCond1NotFreeze = std::make_tuple(150, 482, 0); // Condition 2: 3 * avg_frame_duration < avg_frame_duration + 150 -const auto kFreezeDetectionCond2Freeze = std::make_tuple(30, 185, 1); -const auto kFreezeDetectionCond2NotFreeze = std::make_tuple(30, 184, 0); +constexpr auto kFreezeDetectionCond2Freeze = std::make_tuple(30, 185, 1); +constexpr auto kFreezeDetectionCond2NotFreeze = std::make_tuple(30, 184, 0); INSTANTIATE_TEST_SUITE_P(_, ReceiveStatisticsProxyTestWithFreezeDuration, diff --git a/video/render/BUILD.gn b/video/render/BUILD.gn index 6b235838fd..3f49506bb2 100644 --- a/video/render/BUILD.gn +++ b/video/render/BUILD.gn @@ -19,7 +19,7 @@ rtc_library("incoming_video_stream") { deps = [ ":video_render_frames", "../../api:sequence_checker", - "../../api/task_queue:task_queue", + "../../api/task_queue", "../../api/units:time_delta", "../../api/video:video_frame", "../../rtc_base:checks", diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index 66d213592d..f2715d3f5a 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -550,6 +550,8 @@ void RtpVideoStreamReceiver2::SetLastCorruptionDetectionIndex( const std::variant& frame_instrumentation_data, int spatial_idx) { + RTC_CHECK_GE(spatial_idx, 0); + RTC_CHECK_LT(spatial_idx, kMaxSpatialLayers); if (const auto* sync_data = std::get_if( &frame_instrumentation_data)) { last_corruption_detection_state_by_layer_[spatial_idx].sequence_index = @@ -677,6 +679,7 @@ bool RtpVideoStreamReceiver2::OnReceivedPayloadData( std::optional message = rtp_packet.GetExtension(); if (message.has_value() && spatial_id.has_value()) { + RTC_CHECK_GE(*spatial_id, 0); if (message->sample_values().empty()) { video_header.frame_instrumentation_data = ConvertCorruptionDetectionMessageToFrameInstrumentationSyncData( @@ -1319,15 +1322,15 @@ void RtpVideoStreamReceiver2::NotifyReceiverOfEmptyPacket( } } -bool RtpVideoStreamReceiver2::DeliverRtcp(const uint8_t* rtcp_packet, - size_t rtcp_packet_length) { +bool RtpVideoStreamReceiver2::DeliverRtcp( + ArrayView rtcp_packet) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); if (!receiving_) { return false; } - rtp_rtcp_->IncomingRtcpPacket(MakeArrayView(rtcp_packet, rtcp_packet_length)); + rtp_rtcp_->IncomingRtcpPacket((rtcp_packet)); std::optional rtt = rtp_rtcp_->LastRtt(); if (!rtt.has_value()) { diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index c4a3c7a68a..18ee7ffa46 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -20,6 +20,7 @@ #include #include +#include "api/array_view.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/environment/environment.h" #include "api/frame_transformer_interface.h" @@ -131,7 +132,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, // Produces the transport-related timestamps; current_delay_ms is left unset. std::optional GetSyncInfo() const; - bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length); + bool DeliverRtcp(ArrayView rtcp_packet); void FrameContinuous(int64_t seq_num); diff --git a/video/rtp_video_stream_receiver2_unittest.cc b/video/rtp_video_stream_receiver2_unittest.cc index 344060156a..970d63879e 100644 --- a/video/rtp_video_stream_receiver2_unittest.cc +++ b/video/rtp_video_stream_receiver2_unittest.cc @@ -63,7 +63,7 @@ #include "rtc_base/byte_buffer.h" #include "rtc_base/copy_on_write_buffer.h" #include "system_wrappers/include/ntp_time.h" -#include "test/explicit_key_value_config.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" @@ -74,7 +74,6 @@ namespace webrtc { namespace { -using test::ExplicitKeyValueConfig; using ::testing::_; using ::testing::DoubleNear; using ::testing::ElementsAre; @@ -83,7 +82,7 @@ using ::testing::Invoke; using ::testing::SizeIs; using ::testing::Values; -const uint8_t kH264StartCode[] = {0x00, 0x00, 0x00, 0x01}; +constexpr uint8_t kH264StartCode[] = {0x00, 0x00, 0x00, 0x01}; // Corruption detection metrics for testing. constexpr double kStd = 1.0; @@ -187,10 +186,9 @@ class RtpVideoStreamReceiver2Test : public ::testing::Test, RtpVideoStreamReceiver2Test() : RtpVideoStreamReceiver2Test("") {} explicit RtpVideoStreamReceiver2Test(std::string field_trials) : time_controller_(Timestamp::Millis(100)), - env_(CreateEnvironment( - std::make_unique(field_trials), - time_controller_.GetClock(), - time_controller_.GetTaskQueueFactory())), + env_(CreateEnvironment(CreateTestFieldTrialsPtr(field_trials), + time_controller_.GetClock(), + time_controller_.GetTaskQueueFactory())), task_queue_(time_controller_.GetTaskQueueFactory()->CreateTaskQueue( "RtpVideoStreamReceiver2Test", TaskQueueFactory::Priority::NORMAL)), @@ -1735,8 +1733,7 @@ TEST_P(RtpVideoStreamReceiver2TestPlayoutDelay, PlayoutDelay) { // Set playout delay on outgoing packet. EXPECT_TRUE(packet_to_send.SetExtension( TransmittedPlayoutDelay())); - uint8_t* payload = packet_to_send.AllocatePayload(payload_data.size()); - memcpy(payload, payload_data.data(), payload_data.size()); + packet_to_send.SetPayload(payload_data); RtpPacketReceived received_packet(&extension_map); received_packet.Parse(packet_to_send.data(), packet_to_send.size()); diff --git a/video/screenshare_loopback.cc b/video/screenshare_loopback.cc index cc78ee98ee..9ed3fee0d9 100644 --- a/video/screenshare_loopback.cc +++ b/video/screenshare_loopback.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include @@ -25,10 +24,8 @@ #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/gtest.h" #include "test/run_test.h" -#include "test/test_flags.h" #include "video/video_quality_test.h" using ::webrtc::BitrateConstraints; @@ -384,11 +381,6 @@ int main(int argc, char* argv[]) { webrtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs)); - // 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::test::RunTest(Loopback); return 0; } diff --git a/video/send_delay_stats_unittest.cc b/video/send_delay_stats_unittest.cc index 5bd0d98262..71803d887a 100644 --- a/video/send_delay_stats_unittest.cc +++ b/video/send_delay_stats_unittest.cc @@ -24,14 +24,14 @@ namespace webrtc { namespace { -const uint32_t kSsrc1 = 17; -const uint32_t kSsrc2 = 42; -const uint32_t kRtxSsrc1 = 18; -const uint32_t kRtxSsrc2 = 43; -const uint16_t kPacketId = 2345; -const TimeDelta kMaxPacketDelay = TimeDelta::Seconds(11); -const int kMinRequiredPeriodicSamples = 5; -const int kProcessIntervalMs = 2000; +constexpr uint32_t kSsrc1 = 17; +constexpr uint32_t kSsrc2 = 42; +constexpr uint32_t kRtxSsrc1 = 18; +constexpr uint32_t kRtxSsrc2 = 43; +constexpr uint16_t kPacketId = 2345; +constexpr TimeDelta kMaxPacketDelay = TimeDelta::Seconds(11); +constexpr int kMinRequiredPeriodicSamples = 5; +constexpr int kProcessIntervalMs = 2000; } // namespace class SendDelayStatsTest : public ::testing::Test { diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index e6858dfef9..d5a332d654 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -176,7 +176,7 @@ SendStatisticsProxy::SendStatisticsProxy( fallback_max_pixels_disabled_( GetFallbackMaxPixelsIfFieldTrialDisabled(field_trials)), content_type_(content_type), - start_ms_(clock->TimeInMilliseconds()), + start_(clock->CurrentTime()), encode_time_(kEncodeTimeWeigthFactor), quality_limitation_reason_tracker_(clock_), media_byte_rate_tracker_(kBucketSizeMs, kBucketCount), @@ -194,11 +194,11 @@ SendStatisticsProxy::~SendStatisticsProxy() { MutexLock lock(&mutex_); uma_container_->UpdateHistograms(rtp_config_, stats_); - int64_t elapsed_sec = (clock_->TimeInMilliseconds() - start_ms_) / 1000; + TimeDelta elapsed = clock_->CurrentTime() - start_; RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.SendStreamLifetimeInSeconds", - elapsed_sec); + elapsed.seconds()); - if (elapsed_sec >= metrics::kMinRunTimeInSeconds) + if (elapsed >= metrics::kMinRunTime) UpdateCodecTypeHistogram(payload_name_); } @@ -520,7 +520,7 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( if (first_rtp_stats_time_ms_ != -1) { quality_adapt_timer_.Stop(clock_->TimeInMilliseconds()); int64_t elapsed_sec = quality_adapt_timer_.total_ms / 1000; - if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { + if (elapsed_sec >= metrics::kMinRunTime.seconds()) { int quality_changes = current_stats.number_of_quality_adapt_changes - start_stats_.number_of_quality_adapt_changes; // Only base stats on changes during a call, discard initial changes. @@ -534,7 +534,7 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( } cpu_adapt_timer_.Stop(clock_->TimeInMilliseconds()); elapsed_sec = cpu_adapt_timer_.total_ms / 1000; - if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { + if (elapsed_sec >= metrics::kMinRunTime.seconds()) { int cpu_changes = current_stats.number_of_cpu_adapt_changes - start_stats_.number_of_cpu_adapt_changes; RTC_HISTOGRAMS_COUNTS_100(kIndex, @@ -546,7 +546,7 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( if (first_rtcp_stats_time_ms_ != -1) { int64_t elapsed_sec = (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; - if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { + if (elapsed_sec >= metrics::kMinRunTime.seconds()) { int fraction_lost = report_block_stats_.FractionLostInPercent(); if (fraction_lost != -1) { RTC_HISTOGRAMS_PERCENTAGE( @@ -596,14 +596,14 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( if (first_rtp_stats_time_ms_ != -1) { int64_t elapsed_sec = (clock_->TimeInMilliseconds() - first_rtp_stats_time_ms_) / 1000; - if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { + if (elapsed_sec >= metrics::kMinRunTime.seconds()) { RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "NumberOfPauseEvents", target_rate_updates_.pause_resume_events); log_stream << uma_prefix_ << "NumberOfPauseEvents " << target_rate_updates_.pause_resume_events << "\n"; int paused_time_percent = - paused_time_counter_.Percent(metrics::kMinRunTimeInSeconds * 1000); + paused_time_counter_.Percent(metrics::kMinRunTime.seconds() * 1000); if (paused_time_percent != -1) { RTC_HISTOGRAMS_PERCENTAGE(kIndex, uma_prefix_ + "PausedTimeInPercent", paused_time_percent); @@ -615,10 +615,11 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( if (fallback_info_.is_possible) { // Double interval since there is some time before fallback may occur. - const int kMinRunTimeMs = 2 * metrics::kMinRunTimeInSeconds * 1000; + const TimeDelta kMinRunTime = 2 * metrics::kMinRunTime; int64_t elapsed_ms = fallback_info_.elapsed_ms; - int fallback_time_percent = fallback_active_counter_.Percent(kMinRunTimeMs); - if (fallback_time_percent != -1 && elapsed_ms >= kMinRunTimeMs) { + int fallback_time_percent = + fallback_active_counter_.Percent(kMinRunTime.ms()); + if (fallback_time_percent != -1 && elapsed_ms >= kMinRunTime.ms()) { RTC_HISTOGRAMS_PERCENTAGE( kIndex, uma_prefix_ + "Encoder.ForcedSwFallbackTimeInPercent.Vp8", fallback_time_percent); diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h index 8e7a4f6492..41d899768f 100644 --- a/video/send_statistics_proxy.h +++ b/video/send_statistics_proxy.h @@ -309,7 +309,7 @@ class SendStatisticsProxy : public VideoStreamEncoderObserver, const std::optional fallback_max_pixels_disabled_; mutable Mutex mutex_; VideoEncoderConfig::ContentType content_type_ RTC_GUARDED_BY(mutex_); - const int64_t start_ms_; + const Timestamp start_; VideoSendStream::Stats stats_ RTC_GUARDED_BY(mutex_); ExpFilter encode_time_ RTC_GUARDED_BY(mutex_); QualityLimitationReasonTracker quality_limitation_reason_tracker_ diff --git a/video/send_statistics_proxy_unittest.cc b/video/send_statistics_proxy_unittest.cc index 07ef0fe36f..f10be203a3 100644 --- a/video/send_statistics_proxy_unittest.cc +++ b/video/send_statistics_proxy_unittest.cc @@ -20,6 +20,7 @@ #include #include "absl/algorithm/container.h" +#include "api/field_trials.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -41,9 +42,9 @@ #include "rtc_base/fake_clock.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/scoped_key_value_config.h" #include "video/config/video_encoder_config.h" #include "video/video_stream_encoder_observer.h" @@ -52,17 +53,17 @@ namespace { using ::testing::Optional; -const uint32_t kFirstSsrc = 17; -const uint32_t kSecondSsrc = 42; -const uint32_t kFirstRtxSsrc = 18; -const uint32_t kSecondRtxSsrc = 43; -const uint32_t kFlexFecSsrc = 55; -const int kFpsPeriodicIntervalMs = 2000; -const int kWidth = 640; -const int kHeight = 480; -const int kQpIdx0 = 21; -const int kQpIdx1 = 39; -const int kRtpClockRateHz = 90000; +constexpr uint32_t kFirstSsrc = 17; +constexpr uint32_t kSecondSsrc = 42; +constexpr uint32_t kFirstRtxSsrc = 18; +constexpr uint32_t kSecondRtxSsrc = 43; +constexpr uint32_t kFlexFecSsrc = 55; +constexpr int kFpsPeriodicIntervalMs = 2000; +constexpr int kWidth = 640; +constexpr int kHeight = 480; +constexpr int kQpIdx0 = 21; +constexpr int kQpIdx1 = 39; +constexpr int kRtpClockRateHz = 90000; const CodecSpecificInfo kDefaultCodecInfo = []() { CodecSpecificInfo codec_info; codec_info.codecType = kVideoCodecVP8; @@ -84,7 +85,7 @@ class SendStatisticsProxyTest : public ::testing::Test { public: SendStatisticsProxyTest() : SendStatisticsProxyTest("") {} explicit SendStatisticsProxyTest(const std::string& field_trials) - : override_field_trials_(field_trials), + : field_trials_(CreateTestFieldTrials(field_trials)), fake_clock_(Timestamp::Seconds(1234)), config_(GetTestConfig()) {} ~SendStatisticsProxyTest() override {} @@ -92,10 +93,9 @@ class SendStatisticsProxyTest : public ::testing::Test { protected: void SetUp() override { metrics::Reset(); - statistics_proxy_.reset( - new SendStatisticsProxy(&fake_clock_, GetTestConfig(), - VideoEncoderConfig::ContentType::kRealtimeVideo, - override_field_trials_)); + statistics_proxy_.reset(new SendStatisticsProxy( + &fake_clock_, GetTestConfig(), + VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials_)); expected_ = VideoSendStream::Stats(); for (const auto& ssrc : config_.rtp.ssrcs) { expected_.substreams[ssrc].type = @@ -196,7 +196,7 @@ class SendStatisticsProxyTest : public ::testing::Test { } } - test::ScopedKeyValueConfig override_field_trials_; + FieldTrials field_trials_; SimulatedClock fake_clock_; std::unique_ptr statistics_proxy_; VideoSendStream::Config config_; @@ -798,7 +798,7 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesNotReported_AdaptationNotEnabled) { // First RTP packet sent. UpdateDataCounters(kFirstSsrc); // Min runtime has passed. - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_.reset(); EXPECT_METRIC_EQ( 0, metrics::NumSamples("WebRTC.Video.AdaptChangesPerMinute.Cpu")); @@ -812,7 +812,7 @@ TEST_F(SendStatisticsProxyTest, AdaptChangesNotReported_MinRuntimeNotPassed) { // Enable adaptation. statistics_proxy_->UpdateAdaptationSettings(kScalingEnabled, kScalingEnabled); // Min runtime has not passed. - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1); + fake_clock_.AdvanceTime(metrics::kMinRunTime - TimeDelta::Millis(1)); statistics_proxy_.reset(); EXPECT_METRIC_EQ( 0, metrics::NumSamples("WebRTC.Video.AdaptChangesPerMinute.Cpu")); @@ -826,7 +826,7 @@ TEST_F(SendStatisticsProxyTest, ZeroAdaptChangesReported) { // Enable adaptation. statistics_proxy_->UpdateAdaptationSettings(kScalingEnabled, kScalingEnabled); // Min runtime has passed. - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_.reset(); EXPECT_METRIC_EQ( 1, metrics::NumSamples("WebRTC.Video.AdaptChangesPerMinute.Cpu")); @@ -1033,7 +1033,7 @@ TEST_F(SendStatisticsProxyTest, statistics_proxy_->OnSuspendChange(false); // Min runtime has passed but scaling not enabled. - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_.reset(); EXPECT_METRIC_EQ( 0, metrics::NumSamples("WebRTC.Video.AdaptChangesPerMinute.Cpu")); @@ -1863,7 +1863,7 @@ TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) { } TEST_F(SendStatisticsProxyTest, CodecTypeHistogramIsUpdated) { - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_.reset(); EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.Encoder.CodecType")); } @@ -1873,7 +1873,7 @@ TEST_F(SendStatisticsProxyTest, PauseEventHistogramIsUpdated) { UpdateDataCounters(kFirstSsrc); // Min runtime has passed. - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_.reset(); EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents")); EXPECT_METRIC_EQ(1, @@ -1886,7 +1886,7 @@ TEST_F(SendStatisticsProxyTest, UpdateDataCounters(kFirstSsrc); // Min runtime has not passed. - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1); + fake_clock_.AdvanceTime(metrics::kMinRunTime - TimeDelta::Millis(1)); statistics_proxy_.reset(); EXPECT_METRIC_EQ(0, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents")); EXPECT_METRIC_EQ(0, metrics::NumSamples("WebRTC.Video.PausedTimeInPercent")); @@ -1895,7 +1895,7 @@ TEST_F(SendStatisticsProxyTest, TEST_F(SendStatisticsProxyTest, PauseEventHistogramIsNotUpdatedIfNoMediaIsSent) { // First RTP packet not sent. - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_.reset(); EXPECT_METRIC_EQ(0, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents")); } @@ -1906,7 +1906,7 @@ TEST_F(SendStatisticsProxyTest, NoPauseEvent) { // No change. Video: 10000 ms, paused: 0 ms (0%). statistics_proxy_->OnSetEncoderTargetRate(50000); - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); statistics_proxy_->OnSetEncoderTargetRate(0); // VideoSendStream::Stop statistics_proxy_.reset(); @@ -1972,11 +1972,11 @@ TEST_F(SendStatisticsProxyTest, PausedTimeHistogramIsNotUpdatedIfMinRuntimeHasNotPassed) { // First RTP packet sent. UpdateDataCounters(kFirstSsrc); - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); + fake_clock_.AdvanceTime(metrics::kMinRunTime); // Min runtime has not passed. statistics_proxy_->OnSetEncoderTargetRate(50000); - fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1); + fake_clock_.AdvanceTime(metrics::kMinRunTime - TimeDelta::Millis(1)); statistics_proxy_->OnSetEncoderTargetRate(0); // VideoSendStream::Stop statistics_proxy_.reset(); @@ -2006,12 +2006,11 @@ TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8) { } TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8OneSsrc) { - test::ScopedKeyValueConfig field_trials; VideoSendStream::Config config(nullptr); config.rtp.ssrcs.push_back(kFirstSsrc); statistics_proxy_.reset(new SendStatisticsProxy( &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, - field_trials)); + field_trials_)); EncodedImage encoded_image; CodecSpecificInfo codec_info; @@ -2052,12 +2051,11 @@ TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9Svc) { } TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) { - test::ScopedKeyValueConfig field_trials; VideoSendStream::Config config(nullptr); config.rtp.ssrcs.push_back(kFirstSsrc); statistics_proxy_.reset(new SendStatisticsProxy( &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, - field_trials)); + field_trials_)); EncodedImage encoded_image; CodecSpecificInfo codec_info; @@ -2485,13 +2483,13 @@ TEST_F(SendStatisticsProxyTest, ResetsRtcpCountersOnContentChange) { proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); - fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); + fake_clock_.AdvanceTime(metrics::kMinRunTime); - counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds; - counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds; - counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds; - counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds; - counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds; + counters.nack_packets += 1 * metrics::kMinRunTime.seconds(); + counters.fir_packets += 2 * metrics::kMinRunTime.seconds(); + counters.pli_packets += 3 * metrics::kMinRunTime.seconds(); + counters.unique_nack_requests += 4 * metrics::kMinRunTime.seconds(); + counters.nack_requests += 5 * metrics::kMinRunTime.seconds(); proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); @@ -2529,13 +2527,13 @@ TEST_F(SendStatisticsProxyTest, ResetsRtcpCountersOnContentChange) { proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); - fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); + fake_clock_.AdvanceTime(metrics::kMinRunTime); - counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds; - counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds; - counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds; - counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds; - counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds; + counters.nack_packets += 1 * metrics::kMinRunTime.seconds(); + counters.fir_packets += 2 * metrics::kMinRunTime.seconds(); + counters.pli_packets += 3 * metrics::kMinRunTime.seconds(); + counters.unique_nack_requests += 4 * metrics::kMinRunTime.seconds(); + counters.nack_requests += 5 * metrics::kMinRunTime.seconds(); proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); @@ -2589,10 +2587,9 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsIsRtx) { } TEST_F(SendStatisticsProxyTest, GetStatsReportsIsFlexFec) { - test::ScopedKeyValueConfig field_trials; statistics_proxy_.reset(new SendStatisticsProxy( &fake_clock_, GetTestConfigWithFlexFec(), - VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials)); + VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials_)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); @@ -2609,10 +2606,9 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsIsFlexFec) { } TEST_F(SendStatisticsProxyTest, SendBitratesAreReportedWithFlexFecEnabled) { - test::ScopedKeyValueConfig field_trials; statistics_proxy_.reset(new SendStatisticsProxy( &fake_clock_, GetTestConfigWithFlexFec(), - VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials)); + VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials_)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); @@ -2818,12 +2814,11 @@ TEST_F(SendStatisticsProxyTest, RtxBitrateIsZeroWhenEnabledAndNoRtxDataIsSent) { } TEST_F(SendStatisticsProxyTest, RtxBitrateNotReportedWhenNotEnabled) { - test::ScopedKeyValueConfig field_trials; VideoSendStream::Config config(nullptr); config.rtp.ssrcs.push_back(kFirstSsrc); // RTX not configured. statistics_proxy_.reset(new SendStatisticsProxy( &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, - field_trials)); + field_trials_)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); @@ -2871,12 +2866,11 @@ TEST_F(SendStatisticsProxyTest, FecBitrateIsZeroWhenEnabledAndNoFecDataIsSent) { } TEST_F(SendStatisticsProxyTest, FecBitrateNotReportedWhenNotEnabled) { - test::ScopedKeyValueConfig field_trials; VideoSendStream::Config config(nullptr); config.rtp.ssrcs.push_back(kFirstSsrc); // FEC not configured. statistics_proxy_.reset(new SendStatisticsProxy( &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, - field_trials)); + field_trials_)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); diff --git a/video/stats_counter_unittest.cc b/video/stats_counter_unittest.cc index 9f67afc116..fba22bde19 100644 --- a/video/stats_counter_unittest.cc +++ b/video/stats_counter_unittest.cc @@ -17,8 +17,8 @@ namespace webrtc { namespace { -const int kDefaultProcessIntervalMs = 2000; -const uint32_t kStreamId = 123456; +constexpr int kDefaultProcessIntervalMs = 2000; +constexpr uint32_t kStreamId = 123456; class StatsCounterObserverImpl : public StatsCounterObserver { public: diff --git a/video/stream_synchronization.cc b/video/stream_synchronization.cc index eae9643884..82a882fce0 100644 --- a/video/stream_synchronization.cc +++ b/video/stream_synchronization.cc @@ -10,10 +10,9 @@ #include "video/stream_synchronization.h" -#include - #include #include +#include #include "rtc_base/logging.h" #include "system_wrappers/include/ntp_time.h" diff --git a/video/sv_loopback.cc b/video/sv_loopback.cc index 8f0f4572f5..11db963064 100644 --- a/video/sv_loopback.cc +++ b/video/sv_loopback.cc @@ -8,8 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - +#include #include #include #include @@ -24,10 +23,8 @@ #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/gtest.h" #include "test/run_test.h" -#include "test/test_flags.h" #include "video/video_quality_test.h" // Flags for video. @@ -703,11 +700,6 @@ int main(int argc, char* argv[]) { webrtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs)); - // 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::test::RunTest(webrtc::Loopback); return 0; } diff --git a/video/task_queue_frame_decode_scheduler_unittest.cc b/video/task_queue_frame_decode_scheduler_unittest.cc index a4a36629f4..64b10f0ea5 100644 --- a/video/task_queue_frame_decode_scheduler_unittest.cc +++ b/video/task_queue_frame_decode_scheduler_unittest.cc @@ -10,8 +10,7 @@ #include "video/task_queue_frame_decode_scheduler.h" -#include - +#include #include #include diff --git a/video/video_analyzer.cc b/video/video_analyzer.cc index f25fc3be72..f32b31e1d9 100644 --- a/video/video_analyzer.cc +++ b/video/video_analyzer.cc @@ -9,9 +9,8 @@ */ #include "video/video_analyzer.h" -#include - #include +#include #include #include #include diff --git a/video/video_loopback.cc b/video/video_loopback.cc index bee8b0c1d7..69126053e0 100644 --- a/video/video_loopback.cc +++ b/video/video_loopback.cc @@ -9,8 +9,7 @@ */ #include "video/video_loopback.h" -#include - +#include #include #include #include @@ -24,10 +23,8 @@ #include "api/video_codecs/video_codec.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "system_wrappers/include/field_trial.h" #include "test/gtest.h" #include "test/run_test.h" -#include "test/test_flags.h" #include "video/video_quality_test.h" // Flags common with screenshare loopback, with different default values. @@ -438,11 +435,6 @@ int RunLoopbackTest(int argc, char* argv[]) { LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs)); - // InitFieldTrialsFromString stores the char*, so the char array must outlive - // the application. - const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials); - field_trial::InitFieldTrialsFromString(field_trials.c_str()); - test::RunTest(Loopback); return 0; } diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 9386e7387c..ab7ef1c24b 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -9,9 +9,8 @@ */ #include "video/video_quality_test.h" -#include - #include +#include #include #include #include diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index c7c1c30175..6c3ebfa4d4 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -10,12 +10,10 @@ #include "video/video_receive_stream2.h" -#include -#include - #include #include #include +#include #include #include #include @@ -49,6 +47,7 @@ #include "api/video/recordable_encoded_frame.h" #include "api/video/render_resolution.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" @@ -267,6 +266,7 @@ VideoReceiveStream2::VideoReceiveStream2( max_wait_for_frame_(DetermineMaxWaitForFrame( TimeDelta::Millis(config_.rtp.nack.rtp_history_ms), false)), + frame_evaluator_(&stats_proxy_), decode_queue_(env_.task_queue_factory().CreateTaskQueue( "DecodingQueue", TaskQueueFactory::Priority::HIGH)) { @@ -349,9 +349,9 @@ void VideoReceiveStream2::SignalNetworkState(NetworkState state) { rtp_video_stream_receiver_.SignalNetworkState(state); } -bool VideoReceiveStream2::DeliverRtcp(const uint8_t* packet, size_t length) { +bool VideoReceiveStream2::DeliverRtcp(ArrayView packet) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - return rtp_video_stream_receiver_.DeliverRtcp(packet, length); + return rtp_video_stream_receiver_.DeliverRtcp(packet); } void VideoReceiveStream2::SetSync(Syncable* audio_syncable) { @@ -652,10 +652,13 @@ void VideoReceiveStream2::UpdateHistograms() { stats_proxy_.UpdateHistograms(fraction_lost, rtp_stats, nullptr); } -std::optional VideoReceiveStream2::CalculateCorruptionScore( +void VideoReceiveStream2::CalculateCorruptionScore( const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data) { - return GetCorruptionScore(frame_instrumentation_data, frame); + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type) { + RTC_DCHECK_RUN_ON(&decode_sequence_checker_); + frame_evaluator_.OnInstrumentedFrame(frame_instrumentation_data, frame, + content_type); } bool VideoReceiveStream2::SetBaseMinimumPlayoutDelayMs(int delay_ms) { @@ -700,7 +703,7 @@ void VideoReceiveStream2::OnFrame(const VideoFrame& video_frame) { int64_t sync_offset_ms; double estimated_freq_khz; if (rtp_stream_sync_.GetStreamSyncOffsetInMs( - frame_meta.rtp_timestamp, frame_meta.render_time_ms(), + frame_meta.rtp_timestamp, frame_meta.render_time.ms(), &video_playout_ntp_ms, &sync_offset_ms, &estimated_freq_khz)) { stats_proxy_.OnSyncOffsetUpdated(video_playout_ntp_ms, sync_offset_ms, estimated_freq_khz); diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h index aae2b3e239..9ac106fbe7 100644 --- a/video/video_receive_stream2.h +++ b/video/video_receive_stream2.h @@ -20,6 +20,7 @@ #include #include +#include "api/array_view.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/environment/environment.h" #include "api/frame_transformer_interface.h" @@ -33,6 +34,7 @@ #include "api/units/timestamp.h" #include "api/video/encoded_frame.h" #include "api/video/recordable_encoded_frame.h" +#include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "call/call.h" @@ -48,7 +50,7 @@ #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" -#include "rtc_base/time_utils.h" +#include "video/corruption_detection/frame_instrumentation_evaluation.h" #include "video/decode_synchronizer.h" #include "video/receive_statistics_proxy.h" #include "video/rtp_streams_synchronizer2.h" @@ -79,18 +81,14 @@ class CallStats; struct VideoFrameMetaData { VideoFrameMetaData(const webrtc::VideoFrame& frame, Timestamp now) : rtp_timestamp(frame.rtp_timestamp()), - timestamp_us(frame.timestamp_us()), + render_time(Timestamp::Micros(frame.timestamp_us())), ntp_time_ms(frame.ntp_time_ms()), width(frame.width()), height(frame.height()), decode_timestamp(now) {} - int64_t render_time_ms() const { - return timestamp_us / kNumMicrosecsPerMillisec; - } - const uint32_t rtp_timestamp; - const int64_t timestamp_us; + const Timestamp render_time; const int64_t ntp_time_ms; const int width; const int height; @@ -150,7 +148,7 @@ class VideoReceiveStream2 } void SignalNetworkState(NetworkState state); - bool DeliverRtcp(const uint8_t* packet, size_t length); + bool DeliverRtcp(ArrayView packet); void SetSync(Syncable* audio_syncable); @@ -257,9 +255,10 @@ class VideoReceiveStream2 RTC_RUN_ON(decode_sequence_checker_); void UpdateHistograms(); - std::optional CalculateCorruptionScore( + void CalculateCorruptionScore( const VideoFrame& frame, - const FrameInstrumentationData& frame_instrumentation_data) override; + const FrameInstrumentationData& frame_instrumentation_data, + VideoContentType content_type) override; const Environment env_; @@ -363,6 +362,9 @@ class VideoReceiveStream2 std::vector> buffered_encoded_frames_ RTC_GUARDED_BY(decode_sequence_checker_); + FrameInstrumentationEvaluation frame_evaluator_ + RTC_GUARDED_BY(decode_sequence_checker_); + // Used to signal destruction to potentially pending tasks. ScopedTaskSafety task_safety_; diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index b19e0017e3..ec7f76e333 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -294,8 +294,7 @@ class VideoReceiveStream2Test : public ::testing::TestWithParam { TEST_P(VideoReceiveStream2Test, CreateFrameFromH264FmtpSpropAndIdr) { constexpr uint8_t idr_nalu[] = {0x05, 0xFF, 0xFF, 0xFF}; RtpPacketToSend rtppacket(nullptr); - uint8_t* payload = rtppacket.AllocatePayload(sizeof(idr_nalu)); - memcpy(payload, idr_nalu, sizeof(idr_nalu)); + rtppacket.SetPayload(idr_nalu); rtppacket.SetMarker(true); rtppacket.SetSsrc(kRemoteSsrc); rtppacket.SetPayloadType(kH264PayloadType); @@ -460,8 +459,7 @@ TEST_P(VideoReceiveStream2Test, MaxCompositionDelaySetFromMaxPlayoutDelay) { TEST_P(VideoReceiveStream2Test, LazyDecoderCreation) { constexpr uint8_t idr_nalu[] = {0x05, 0xFF, 0xFF, 0xFF}; RtpPacketToSend rtppacket(nullptr); - uint8_t* payload = rtppacket.AllocatePayload(sizeof(idr_nalu)); - memcpy(payload, idr_nalu, sizeof(idr_nalu)); + rtppacket.SetPayload(idr_nalu); rtppacket.SetMarker(true); rtppacket.SetSsrc(kRemoteSsrc); rtppacket.SetPayloadType(kH264PayloadType); @@ -494,8 +492,7 @@ TEST_P(VideoReceiveStream2Test, LazyDecoderCreation) { TEST_P(VideoReceiveStream2Test, LazyDecoderCreationCodecSwitch) { constexpr uint8_t idr_nalu[] = {0x05, 0xFF, 0xFF, 0xFF}; RtpPacketToSend rtppacket(nullptr); - uint8_t* payload = rtppacket.AllocatePayload(sizeof(idr_nalu)); - memcpy(payload, idr_nalu, sizeof(idr_nalu)); + rtppacket.SetPayload(idr_nalu); rtppacket.SetMarker(true); rtppacket.SetSsrc(kRemoteSsrc); rtppacket.SetPayloadType(kH264PayloadType); @@ -528,8 +525,7 @@ TEST_P(VideoReceiveStream2Test, LazyDecoderCreationCodecSwitch) { // Switch to AV1. const uint8_t av1_key_obu[] = {0x18, 0x48, 0x01, 0xAA}; // \ OBU RtpPacketToSend av1_rtppacket(nullptr); - uint8_t* av1_payload = av1_rtppacket.AllocatePayload(sizeof(av1_key_obu)); - memcpy(av1_payload, av1_key_obu, sizeof(av1_key_obu)); + av1_rtppacket.SetPayload(av1_key_obu); av1_rtppacket.SetMarker(true); av1_rtppacket.SetSsrc(kRemoteSsrc); av1_rtppacket.SetPayloadType(kAv1PayloadType); diff --git a/video/video_send_stream_impl.cc b/video/video_send_stream_impl.cc index 9164f530ad..7b44410574 100644 --- a/video/video_send_stream_impl.cc +++ b/video/video_send_stream_impl.cc @@ -9,10 +9,9 @@ */ #include "video/video_send_stream_impl.h" -#include - #include #include +#include #include #include #include @@ -628,9 +627,9 @@ void VideoSendStreamImpl::GenerateKeyFrame( } } -void VideoSendStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) { +void VideoSendStreamImpl::DeliverRtcp(ArrayView packet) { RTC_DCHECK_RUN_ON(&thread_checker_); - rtp_video_sender_->DeliverRtcp(packet, length); + rtp_video_sender_->DeliverRtcp(packet); } bool VideoSendStreamImpl::started() { diff --git a/video/video_send_stream_impl.h b/video/video_send_stream_impl.h index a8e7858042..9885bd83f1 100644 --- a/video/video_send_stream_impl.h +++ b/video/video_send_stream_impl.h @@ -104,7 +104,7 @@ class VideoSendStreamImpl : public webrtc::VideoSendStream, video_stream_encoder_for_test = nullptr); ~VideoSendStreamImpl() override; - void DeliverRtcp(const uint8_t* packet, size_t length); + void DeliverRtcp(ArrayView packet); // webrtc::VideoSendStream implementation. void Start() override; diff --git a/video/video_send_stream_impl_unittest.cc b/video/video_send_stream_impl_unittest.cc index 216907d778..3f13e64387 100644 --- a/video/video_send_stream_impl_unittest.cc +++ b/video/video_send_stream_impl_unittest.cc @@ -20,9 +20,11 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_parameters.h" #include "api/task_queue/task_queue_base.h" @@ -45,11 +47,10 @@ #include "modules/rtp_rtcp/source/rtp_sequence_number_map.h" #include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/experiments/alr_experiment.h" -#include "test/field_trial.h" +#include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" -#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" #include "video/config/video_encoder_config.h" #include "video/send_delay_stats.h" @@ -83,14 +84,11 @@ using ::testing::Sequence; using ::testing::SizeIs; constexpr int64_t kDefaultInitialBitrateBps = 333000; -const double kDefaultBitratePriority = 0.5; +constexpr double kDefaultBitratePriority = 0.5; + +constexpr float kAlrProbingExperimentPaceMultiplier = 1.0f; +constexpr absl::string_view kAlrProbingExperimentValue = "1.0,2875,80,40,-60,3"; -const float kAlrProbingExperimentPaceMultiplier = 1.0f; -std::string GetAlrProbingExperimentString() { - return std::string( - AlrExperimentSettings::kScreenshareProbingBweExperimentName) + - "/1.0,2875,80,40,-60,3/"; -} class MockRtpVideoSender : public RtpVideoSenderInterface { public: MOCK_METHOD(void, SetSending, (bool sending), (override)); @@ -104,7 +102,7 @@ class MockRtpVideoSender : public RtpVideoSenderInterface { GetRtpPayloadStates, (), (const, override)); - MOCK_METHOD(void, DeliverRtcp, (const uint8_t*, size_t), (override)); + MOCK_METHOD(void, DeliverRtcp, (ArrayView), (override)); MOCK_METHOD(void, OnBitrateAllocationUpdated, (const VideoBitrateAllocation&), @@ -148,6 +146,7 @@ class VideoSendStreamImplTest : public ::testing::Test { protected: VideoSendStreamImplTest() : time_controller_(Timestamp::Seconds(1000)), + field_trials_(CreateTestFieldTrials()), config_(&transport_), send_delay_stats_(time_controller_.GetClock()), encoder_queue_(time_controller_.GetTaskQueueFactory()->CreateTaskQueue( @@ -218,7 +217,7 @@ class VideoSendStreamImplTest : public ::testing::Test { protected: GlobalSimulatedTimeController time_controller_; - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_; NiceMock transport_; NiceMock transport_controller_; NiceMock bitrate_allocator_; @@ -510,8 +509,7 @@ TEST_F(VideoSendStreamImplTest, UpdatesObserverOnConfigurationChangeWithAlr) { TEST_F(VideoSendStreamImplTest, UpdatesObserverOnConfigurationChangeWithSimulcastVideoHysteresis) { - test::ScopedKeyValueConfig hysteresis_experiment( - field_trials_, "WebRTC-VideoRateControl/video_hysteresis:1.25/"); + field_trials_.Set("WebRTC-VideoRateControl", "video_hysteresis:1.25"); config_.rtp.ssrcs.emplace_back(1); config_.rtp.ssrcs.emplace_back(2); @@ -567,7 +565,8 @@ TEST_F(VideoSendStreamImplTest, } TEST_F(VideoSendStreamImplTest, SetsScreensharePacingFactorWithFeedback) { - test::ScopedFieldTrials alr_experiment(GetAlrProbingExperimentString()); + field_trials_.Set(AlrExperimentSettings::kScreenshareProbingBweExperimentName, + kAlrProbingExperimentValue); constexpr int kId = 1; config_.rtp.extensions.emplace_back(RtpExtension::kTransportSequenceNumberUri, @@ -582,7 +581,8 @@ TEST_F(VideoSendStreamImplTest, SetsScreensharePacingFactorWithFeedback) { } TEST_F(VideoSendStreamImplTest, DoesNotSetPacingFactorWithoutFeedback) { - test::ScopedFieldTrials alr_experiment(GetAlrProbingExperimentString()); + field_trials_.Set(AlrExperimentSettings::kScreenshareProbingBweExperimentName, + kAlrProbingExperimentValue); auto vss_impl = CreateVideoSendStreamImpl( TestVideoEncoderConfig(VideoEncoderConfig::ContentType::kScreen)); EXPECT_CALL(transport_controller_, SetPacingFactor(_)).Times(0); @@ -851,8 +851,7 @@ TEST_F(VideoSendStreamImplTest, PriorityBitrateConfigInactiveByDefault) { } TEST_F(VideoSendStreamImplTest, PriorityBitrateConfigAffectsAV1) { - test::ScopedFieldTrials override_priority_bitrate( - "WebRTC-AV1-OverridePriorityBitrate/bitrate:20000/"); + field_trials_.Set("WebRTC-AV1-OverridePriorityBitrate", "bitrate:20000"); config_.rtp.payload_name = "AV1"; auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); EXPECT_CALL( @@ -879,8 +878,7 @@ TEST_F(VideoSendStreamImplTest, int min_transmit_bitrate_bps = 30000; - test::ScopedFieldTrials override_priority_bitrate( - "WebRTC-AV1-OverridePriorityBitrate/bitrate:20000/"); + field_trials_.Set("WebRTC-AV1-OverridePriorityBitrate", "bitrate:20000"); config_.rtp.payload_name = "AV1"; auto vss_impl = CreateVideoSendStreamImpl(TestVideoEncoderConfig()); EXPECT_CALL( diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 25b525486f..6868393601 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -22,10 +22,12 @@ #include #include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/fec_controller_override.h" +#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/make_ref_counted.h" #include "api/rtp_headers.h" @@ -105,7 +107,6 @@ #include "test/configurable_frame_size_encoder.h" #include "test/encoder_settings.h" #include "test/fake_encoder.h" -#include "test/field_trial.h" #include "test/frame_forwarder.h" #include "test/frame_generator_capturer.h" #include "test/frame_utils.h" @@ -114,7 +115,6 @@ #include "test/null_transport.h" #include "test/rtcp_packet_parser.h" #include "test/rtp_rtcp_observer.h" -#include "test/scoped_key_value_config.h" #include "test/video_encoder_proxy_factory.h" #include "test/video_test_constants.h" #include "video/config/video_encoder_config.h" @@ -733,10 +733,7 @@ TEST_F(VideoSendStreamTest, SupportsUlpfecWithoutExtensions) { class VideoSendStreamWithoutUlpfecTest : public test::CallTest { protected: VideoSendStreamWithoutUlpfecTest() - : field_trial_(field_trials_, "WebRTC-DisableUlpFecExperiment/Enabled/") { - } - - test::ScopedKeyValueConfig field_trial_; + : CallTest(/*field_trials=*/"WebRTC-DisableUlpFecExperiment/Enabled/") {} }; TEST_F(VideoSendStreamWithoutUlpfecTest, NoUlpfecIfDisabledThroughFieldTrial) { @@ -1770,9 +1767,9 @@ TEST_F(VideoSendStreamTest, DISABLED_RelayToDirectRoute) { static const int kStartBitrateBps = 300000; static const int kRelayBandwidthCapBps = 800000; static const int kMinPacketsToSend = 100; - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-Bwe-NetworkRouteConstraints/relay_cap:" + - std::to_string(kRelayBandwidthCapBps) + "bps/"); + field_trials().Set( + "WebRTC-Bwe-NetworkRouteConstraints", + "relay_cap:" + std::to_string(kRelayBandwidthCapBps) + "bps"); class RelayToDirectRouteTest : public test::EndToEndTest { public: @@ -2728,8 +2725,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. - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-VideoRateControl/bitrate_adjuster:false/"); + field_trials().Set("WebRTC-VideoRateControl", "bitrate_adjuster:false"); class EncoderBitrateThresholdObserver : public test::SendTest, public VideoBitrateAllocatorFactory, @@ -3889,15 +3885,13 @@ class PacingFactorObserver : public test::SendTest { const std::optional expected_pacing_factor_; }; -std::string GetAlrProbingExperimentString() { - return std::string( - AlrExperimentSettings::kScreenshareProbingBweExperimentName) + - "/1.0,2875,80,40,-60,3/"; -} -const float kAlrProbingExperimentPaceMultiplier = 1.0f; +constexpr absl::string_view kAlrProbingExperimentValue = "1.0,2875,80,40,-60,3"; +constexpr float kAlrProbingExperimentPaceMultiplier = 1.0f; TEST_F(VideoSendStreamTest, AlrConfiguredWhenSendSideOn) { - test::ScopedFieldTrials alr_experiment(GetAlrProbingExperimentString()); + field_trials().Set( + AlrExperimentSettings::kScreenshareProbingBweExperimentName, + kAlrProbingExperimentValue); // Send-side bwe on, use pacing factor from `kAlrProbingExperiment` above. PacingFactorObserver test_with_send_side(true, kAlrProbingExperimentPaceMultiplier); @@ -3905,7 +3899,9 @@ TEST_F(VideoSendStreamTest, AlrConfiguredWhenSendSideOn) { } TEST_F(VideoSendStreamTest, AlrNotConfiguredWhenSendSideOff) { - test::ScopedFieldTrials alr_experiment(GetAlrProbingExperimentString()); + field_trials().Set( + AlrExperimentSettings::kScreenshareProbingBweExperimentName, + kAlrProbingExperimentValue); // Send-side bwe off, use configuration should not be overridden. PacingFactorObserver test_without_send_side(false, std::nullopt); RunBaseTest(&test_without_send_side); diff --git a/video/video_stream_buffer_controller_unittest.cc b/video/video_stream_buffer_controller_unittest.cc index 681c934c45..e7e8dc1caa 100644 --- a/video/video_stream_buffer_controller_unittest.cc +++ b/video/video_stream_buffer_controller_unittest.cc @@ -10,9 +10,8 @@ #include "video/video_stream_buffer_controller.h" -#include - #include +#include #include #include #include @@ -22,6 +21,7 @@ #include #include +#include "api/field_trials.h" #include "api/metronome/test/fake_metronome.h" #include "api/units/frequency.h" #include "api/units/time_delta.h" @@ -32,10 +32,10 @@ #include "modules/video_coding/timing/timing.h" #include "rtc_base/checks.h" #include "system_wrappers/include/clock.h" +#include "test/create_test_field_trials.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" #include "video/decode_synchronizer.h" #include "video/task_queue_frame_decode_scheduler.h" @@ -139,7 +139,7 @@ class VideoStreamBufferControllerFixture public: VideoStreamBufferControllerFixture() : sync_decoding_(std::get<0>(GetParam())), - field_trials_(std::get<1>(GetParam())), + field_trials_(CreateTestFieldTrials(std::get<1>(GetParam()))), time_controller_(kClockStart), clock_(time_controller_.GetClock()), fake_metronome_(TimeDelta::Millis(16)), @@ -228,7 +228,7 @@ class VideoStreamBufferControllerFixture protected: const bool sync_decoding_; - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_; GlobalSimulatedTimeController time_controller_; Clock* const clock_; test::FakeMetronome fake_metronome_; diff --git a/video/video_stream_decoder2.cc b/video/video_stream_decoder2.cc index 02b3db821e..45379a087a 100644 --- a/video/video_stream_decoder2.cc +++ b/video/video_stream_decoder2.cc @@ -53,10 +53,6 @@ int32_t VideoStreamDecoder::OnFrameToRender(const FrameToRender& arguments) { receive_stats_callback_->OnDecodedFrame( arguments.video_frame, arguments.qp, arguments.decode_time, arguments.content_type, arguments.frame_type); - if (arguments.corruption_score.has_value()) { - receive_stats_callback_->OnCorruptionScore(*arguments.corruption_score, - arguments.content_type); - } incoming_video_stream_->OnFrame(arguments.video_frame); return 0; } diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 3f7ae8141f..7961f64b70 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -1526,7 +1526,7 @@ void VideoStreamEncoder::RequestEncoderSwitch() { } if (!preferred_fallback_encoder) { - if (env_.field_trials().IsEnabled( + if (!env_.field_trials().IsDisabled( kSwitchEncoderFollowCodecPreferenceOrderFieldTrial)) { encoder_fallback_requested_ = true; settings_.encoder_switch_request_callback->RequestEncoderFallback(); diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index d5c2634025..854984d0c8 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -28,6 +28,7 @@ #include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" +#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/location.h" #include "api/make_ref_counted.h" @@ -102,13 +103,13 @@ #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" +#include "test/create_test_field_trials.h" #include "test/encoder_settings.h" #include "test/fake_encoder.h" #include "test/frame_forwarder.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mappable_native_buffer.h" -#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" #include "test/video_encoder_nullable_proxy_factory.h" #include "test/video_encoder_proxy_factory.h" @@ -142,21 +143,21 @@ using ::testing::SizeIs; using ::testing::StrictMock; namespace { -const int kMinPixelsPerFrame = 320 * 180; -const int kQpLow = 1; -const int kQpHigh = 2; -const int kMinFramerateFps = 2; -const int kMinBalancedFramerateFps = 7; +constexpr int kMinPixelsPerFrame = 320 * 180; +constexpr int kQpLow = 1; +constexpr int kQpHigh = 2; +constexpr int kMinFramerateFps = 2; +constexpr int kMinBalancedFramerateFps = 7; constexpr TimeDelta kFrameTimeout = TimeDelta::Millis(100); -const size_t kMaxPayloadLength = 1440; -const DataRate kTargetBitrate = DataRate::KilobitsPerSec(1000); -const DataRate kLowTargetBitrate = DataRate::KilobitsPerSec(100); -const DataRate kStartBitrate = DataRate::KilobitsPerSec(600); -const DataRate kSimulcastTargetBitrate = DataRate::KilobitsPerSec(3150); -const int kMaxInitialFramedrop = 4; -const int kDefaultFramerate = 30; -const int64_t kFrameIntervalMs = kNumMillisecsPerSec / kDefaultFramerate; -const int64_t kProcessIntervalMs = 1000; +constexpr size_t kMaxPayloadLength = 1440; +constexpr DataRate kTargetBitrate = DataRate::KilobitsPerSec(1000); +constexpr DataRate kLowTargetBitrate = DataRate::KilobitsPerSec(100); +constexpr DataRate kStartBitrate = DataRate::KilobitsPerSec(600); +constexpr DataRate kSimulcastTargetBitrate = DataRate::KilobitsPerSec(3150); +constexpr int kMaxInitialFramedrop = 4; +constexpr int kDefaultFramerate = 30; +constexpr int64_t kFrameIntervalMs = kNumMillisecsPerSec / kDefaultFramerate; +constexpr int64_t kProcessIntervalMs = 1000; const VideoEncoder::ResolutionBitrateLimits kEncoderBitrateLimits540p(960 * 540, 100 * 1000, 100 * 1000, 2000 * 1000); const VideoEncoder::ResolutionBitrateLimits @@ -167,14 +168,14 @@ uint8_t kOptimalSps[] = {0, 0, 0, 1, H264::NaluType::kSps, 0x05, 0x03, 0xC7, 0xE0, 0x1B, 0x41, 0x10, 0x8D, 0x00}; -const uint8_t kCodedFrameVp8Qp25[] = { +constexpr uint8_t kCodedFrameVp8Qp25[] = { 0x10, 0x02, 0x00, 0x9d, 0x01, 0x2a, 0x10, 0x00, 0x10, 0x00, 0x02, 0x47, 0x08, 0x85, 0x85, 0x88, 0x85, 0x84, 0x88, 0x0c, 0x82, 0x00, 0x0c, 0x0d, 0x60, 0x00, 0xfe, 0xfc, 0x5c, 0xd0}; #ifdef RTC_ENABLE_H265 // Default value from encoder_info_settings.cc -const DataRate kDefaultH265Bitrate180p = DataRate::KilobitsPerSec(150); +constexpr DataRate kDefaultH265Bitrate180p = DataRate::KilobitsPerSec(150); #endif VideoFrame CreateSimpleNV12Frame() { @@ -753,15 +754,12 @@ class SimpleVideoStreamEncoderFactory { std::unique_ptr CreateWithEncoderQueue( std::unique_ptr zero_hertz_adapter, - std::unique_ptr encoder_queue, - const FieldTrialsView* field_trials = nullptr) { - Environment env = CreateEnvironment(&field_trials_, field_trials, - time_controller_.GetClock()); + std::unique_ptr encoder_queue) { auto result = std::make_unique( - env, + env_, /*number_of_cores=*/1, /*stats_proxy=*/stats_proxy_.get(), encoder_settings_, - std::make_unique(env, + std::make_unique(env_, /*stats_proxy=*/nullptr), std::move(zero_hertz_adapter), std::move(encoder_queue), VideoStreamEncoder::BitrateAllocationCallbackType:: @@ -789,6 +787,8 @@ class SimpleVideoStreamEncoderFactory { return &time_controller_; } + const Environment& env() { return env_; } + private: class NullEncoderSink : public VideoStreamEncoderInterface::EncoderSink { public: @@ -809,7 +809,7 @@ class SimpleVideoStreamEncoderFactory { } }; - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_ = CreateTestFieldTrials(); GlobalSimulatedTimeController time_controller_{Timestamp::Zero()}; Environment env_ = CreateEnvironment(&field_trials_, @@ -1694,7 +1694,7 @@ class VideoStreamEncoderTest : public ::testing::Test { int64_t CurrentTimeMs() { return clock()->CurrentTime().ms(); } protected: - test::ScopedKeyValueConfig field_trials_; + FieldTrials field_trials_ = CreateTestFieldTrials(); GlobalSimulatedTimeController time_controller_{Timestamp::Micros(1234)}; const Environment env_ = CreateEnvironment(&field_trials_, @@ -4589,10 +4589,8 @@ class BalancedDegradationTest : public VideoStreamEncoderTest { }; TEST_F(BalancedDegradationTest, AdaptDownTwiceIfMinFpsDiffLtThreshold) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:57600|129600|230400,fps:7|10|24,fps_diff:1|1|1/"); + field_trials_.Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:57600|129600|230400,fps:7|10|24,fps_diff:1|1|1"); SetupTest(); // Force input frame rate. @@ -4614,10 +4612,8 @@ TEST_F(BalancedDegradationTest, AdaptDownTwiceIfMinFpsDiffLtThreshold) { } TEST_F(BalancedDegradationTest, AdaptDownOnceIfFpsDiffGeThreshold) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:57600|129600|230400,fps:7|10|24,fps_diff:1|1|1/"); + field_trials_.Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:57600|129600|230400,fps:7|10|24,fps_diff:1|1|1"); SetupTest(); // Force input frame rate. @@ -4638,10 +4634,8 @@ TEST_F(BalancedDegradationTest, AdaptDownOnceIfFpsDiffGeThreshold) { } TEST_F(BalancedDegradationTest, AdaptDownUsesCodecSpecificFps) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:57600|129600|230400,fps:7|10|24,vp8_fps:8|11|22/"); + field_trials_.Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:57600|129600|230400,fps:7|10|24,vp8_fps:8|11|22"); SetupTest(); EXPECT_EQ(kVideoCodecVP8, video_encoder_config_.codec_type); @@ -4657,10 +4651,8 @@ TEST_F(BalancedDegradationTest, AdaptDownUsesCodecSpecificFps) { } TEST_F(BalancedDegradationTest, NoAdaptUpIfBwEstimateIsLessThanMinBitrate) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:57600|129600|230400,fps:7|10|14,kbps:0|0|425/"); + field_trials_.Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:57600|129600|230400,fps:7|10|14,kbps:0|0|425"); SetupTest(); const DataRate kMinBitrate = DataRate::KilobitsPerSec(425); @@ -4707,10 +4699,8 @@ TEST_F(BalancedDegradationTest, NoAdaptUpIfBwEstimateIsLessThanMinBitrate) { TEST_F(BalancedDegradationTest, InitialFrameDropAdaptsFpsAndResolutionInOneStep) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:57600|129600|230400,fps:7|24|24/"); + field_trials_.Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:57600|129600|230400,fps:7|24|24"); SetupTest(); OnBitrateUpdated(kLowTargetBitrate); @@ -4739,10 +4729,8 @@ TEST_F(BalancedDegradationTest, TEST_F(BalancedDegradationTest, NoAdaptUpInResolutionIfBwEstimateIsLessThanMinBitrate) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:57600|129600|230400,fps:7|10|14,kbps_res:0|0|435/"); + field_trials_.Set("WebRTC-Video-BalancedDegradationSettings", + "pixels:57600|129600|230400,fps:7|10|14,kbps_res:0|0|435"); SetupTest(); const DataRate kResolutionMinBitrate = DataRate::KilobitsPerSec(435); @@ -4794,10 +4782,9 @@ TEST_F(BalancedDegradationTest, TEST_F(BalancedDegradationTest, NoAdaptUpInFpsAndResolutionIfBwEstimateIsLessThanMinBitrate) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:57600|129600|230400,fps:7|10|14,kbps:0|0|425,kbps_res:0|0|435/"); + field_trials_.Set( + "WebRTC-Video-BalancedDegradationSettings", + "pixels:57600|129600|230400,fps:7|10|14,kbps:0|0|425,kbps_res:0|0|435"); SetupTest(); const DataRate kMinBitrate = DataRate::KilobitsPerSec(425); @@ -5693,10 +5680,9 @@ TEST_F(VideoStreamEncoderTest, TemporalLayersDisabledIfNotSupported) { } TEST_F(VideoStreamEncoderTest, VerifyBitrateAllocationForTwoStreams) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-QualityScalerSettings/" - "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2/"); + field_trials_.Set( + "WebRTC-Video-QualityScalerSettings", + "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2"); // Reset encoder for field trials to take effect. ConfigureEncoder(video_encoder_config_.Copy()); @@ -6000,10 +5986,9 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropOffWhenEncoderDisabledScaling) { } TEST_F(VideoStreamEncoderTest, InitialFrameDropActivatesWhenBweDrops) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-QualityScalerSettings/" - "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2/"); + field_trials_.Set( + "WebRTC-Video-QualityScalerSettings", + "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2"); // Reset encoder for field trials to take effect. ConfigureEncoder(video_encoder_config_.Copy()); const int kNotTooLowBitrateForFrameSizeBps = kTargetBitrate.bps() * 0.2; @@ -6041,10 +6026,9 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropActivatesWhenBweDrops) { TEST_F(VideoStreamEncoderTest, InitialFrameDropNotReactivatedWhenBweDropsWhenScalingDisabled) { - test::ScopedKeyValueConfig field_trials( - field_trials_, - "WebRTC-Video-QualityScalerSettings/" - "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2/"); + field_trials_.Set( + "WebRTC-Video-QualityScalerSettings", + "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2"); fake_encoder_.SetQualityScaling(false); ConfigureEncoder(video_encoder_config_.Copy()); const int kNotTooLowBitrateForFrameSizeBps = kTargetBitrate.bps() * 0.2; @@ -6370,8 +6354,7 @@ TEST_F(VideoStreamEncoderTest, } TEST_F(VideoStreamEncoderTest, DefaultMaxAndMinBitratesNotUsedIfDisabled) { - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-DefaultBitrateLimitsKillSwitch/Enabled/"); + field_trials_.Set("WebRTC-DefaultBitrateLimitsKillSwitch", "Enabled"); VideoEncoderConfig video_encoder_config; test::FillEncoderConfiguration(PayloadStringToCodecType("VP9"), 1, &video_encoder_config); @@ -6733,8 +6716,7 @@ TEST_P(VideoStreamEncoderInitialFrameDropperTest, TEST_F(VideoStreamEncoderTest, QualityScalerAdaptationsRemovedWhenQualityScalingDisabled) { - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-Video-QualityScaling/Disabled/"); + field_trials_.Set("WebRTC-Video-QualityScaling", "Disabled"); AdaptingFrameForwarder source(&time_controller_); source.set_adaptation_enabled(true); video_stream_encoder_->SetSource(&source, @@ -8252,6 +8234,9 @@ TEST_F(VideoStreamEncoderTest, SwitchEncoderOnInitFailureWithEncoderSelector) { TEST_F(VideoStreamEncoderTest, SwitchEncoderOnInitFailureWithoutEncoderSelector) { + field_trials_.Set("WebRTC-SwitchEncoderFollowCodecPreferenceOrder", + "Disabled"); + NiceMock video_encoder; StrictMock switch_callback; video_send_config_.encoder_settings.encoder_switch_request_callback = @@ -8347,9 +8332,6 @@ TEST_F(VideoStreamEncoderTest, NoPreferenceDefaultFallbackToVP8Disabled) { constexpr int kDontCare = 100; constexpr int kNumFrames = 8; - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-SwitchEncoderFollowCodecPreferenceOrder/Enabled/"); - NiceMock video_encoder; StrictMock switch_callback; video_send_config_.encoder_settings.encoder_switch_request_callback = @@ -8408,8 +8390,8 @@ TEST_F(VideoStreamEncoderTest, constexpr int kDontCare = 100; constexpr int kNumFrames = 8; - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-SwitchEncoderFollowCodecPreferenceOrder/Enabled/"); + field_trials_.Set("WebRTC-SwitchEncoderFollowCodecPreferenceOrder", + "Enabled"); NiceMock video_encoder; StrictMock switch_callback; @@ -8480,6 +8462,9 @@ TEST_F(VideoStreamEncoderTest, NoPreferenceDefaultFallbackToVP8Enabled) { constexpr int kSufficientBitrateToNotDrop = 1000; constexpr int kDontCare = 100; + field_trials_.Set("WebRTC-SwitchEncoderFollowCodecPreferenceOrder", + "Disabled"); + NiceMock video_encoder; StrictMock switch_callback; video_send_config_.encoder_settings.encoder_switch_request_callback = @@ -8847,8 +8832,7 @@ TEST_F(VideoStreamEncoderTest, QpAbsent_QpParsed) { } TEST_F(VideoStreamEncoderTest, QpAbsentParsingDisabled_QpAbsent) { - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-QpParsingKillSwitch/Enabled/"); + field_trials_.Set("WebRTC-QpParsingKillSwitch", "Enabled"); ResetEncoder("VP8", 1, 1, 1, false); @@ -9127,8 +9111,7 @@ TEST_F(VideoStreamEncoderTest, NormalComplexityWithMoreThanTwoCores) { TEST_F(VideoStreamEncoderTest, NormalComplexityWhenLowTierOptimizationsAreDisabled) { - test::ScopedKeyValueConfig field_trials( - field_trials_, "WebRTC-VP9-LowTierOptimizations/Disabled/"); + field_trials_.Set("WebRTC-VP9-LowTierOptimizations", "Disabled"); ResetEncoder("VP9", /*num_streams=*/1, /*num_temporal_layers=*/1, /*num_spatial_layers=*/1, @@ -9408,20 +9391,19 @@ class VideoStreamEncoderWithRealEncoderTest void SetUp() override { VideoStreamEncoderTest::SetUp(); - Environment env = CreateEnvironment(&field_trials_); std::unique_ptr encoder; switch (codec_type_) { case kVideoCodecVP8: - encoder = CreateVp8Encoder(env); + encoder = CreateVp8Encoder(env_); break; case kVideoCodecVP9: - encoder = CreateVp9Encoder(env); + encoder = CreateVp9Encoder(env_); break; case kVideoCodecAV1: - encoder = CreateLibaomAv1Encoder(env); + encoder = CreateLibaomAv1Encoder(env_); break; case kVideoCodecH264: - encoder = CreateH264Encoder(env); + encoder = CreateH264Encoder(env_); break; case kVideoCodecH265: // TODO(bugs.webrtc.org/13485): Use a fake encoder @@ -10158,19 +10140,18 @@ TEST(VideoStreamEncoderFrameCadenceTest, TEST(VideoStreamEncoderFrameCadenceTest, RequestsRefreshFrameForEarlyZeroHertzKeyFrameRequest) { SimpleVideoStreamEncoderFactory factory; - auto encoder_queue = - factory.GetTimeController()->GetTaskQueueFactory()->CreateTaskQueue( - "EncoderQueue", TaskQueueFactory::Priority::NORMAL); + auto encoder_queue = factory.env().task_queue_factory().CreateTaskQueue( + "EncoderQueue", TaskQueueFactory::Priority::NORMAL); - test::ScopedKeyValueConfig field_trials; auto adapter = FrameCadenceAdapterInterface::Create( - factory.GetTimeController()->GetClock(), encoder_queue.get(), - /*metronome=*/nullptr, /*worker_queue=*/nullptr, field_trials); + &factory.env().clock(), encoder_queue.get(), + /*metronome=*/nullptr, /*worker_queue=*/nullptr, + factory.env().field_trials()); FrameCadenceAdapterInterface* adapter_ptr = adapter.get(); MockVideoSourceInterface mock_source; auto video_stream_encoder = factory.CreateWithEncoderQueue( - std::move(adapter), std::move(encoder_queue), &field_trials); + std::move(adapter), std::move(encoder_queue)); video_stream_encoder->SetSource(&mock_source, DegradationPreference::MAINTAIN_FRAMERATE); diff --git a/webrtc.gni b/webrtc.gni index 103983dec4..112233b7d3 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -270,11 +270,6 @@ declare_args() { # When true, include the Perfetto library. rtc_use_perfetto = false - - # When true allows exports from deprecated namespaces. - # This will be set to false on Jun 23 2025. See bugs.webrtc.org/42232595 - # for details. - rtc_allow_deprecated_namespaces = true } if (!build_with_mozilla) { @@ -336,7 +331,7 @@ declare_args() { rtc_disable_metrics = false # Enables an experimental rust version of base64 for building and testing. - rtc_rusty_base64 = true + rtc_rusty_base64 = false } declare_args() { @@ -384,7 +379,6 @@ 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 diff --git a/webrtc_lib_link_test.cc b/webrtc_lib_link_test.cc index 997cc0f206..96d2e87f24 100644 --- a/webrtc_lib_link_test.cc +++ b/webrtc_lib_link_test.cc @@ -19,6 +19,7 @@ #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_modular_peer_connection_factory.h" #include "api/create_peerconnection_factory.h" #include "api/enable_media.h" #include "api/environment/environment_factory.h"