tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit d498f0667b928db1f58c7fbffe646cf55b161ff8
parent 26f6240f256bffe25ffe6027f6dc0116e0b3108f
Author: Michael Froman <mfroman@mozilla.com>
Date:   Wed,  8 Oct 2025 15:59:26 -0500

Bug 1993083 - Vendor libwebrtc from fe0a0c784e

Upstream commit: https://webrtc.googlesource.com/src/+/fe0a0c784efaaa213c681566682b89c4d26e474d
    Delete rtp_generator

    The binary crashes on start due to not adopting the thread correctly, so
    has likely not worked for a few years. Due to the lack of usage, this
    should be deleted.

    Bug: webrtc:427121262
    Change-Id: I08da505ebb9ddc8d0a28cccf6b7978dbfdc35024
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/397580
    Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
    Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
    Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45004}

Diffstat:
Mthird_party/libwebrtc/BUILD.gn | 1-
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0027.patch | 10+++++-----
Mthird_party/libwebrtc/moz-patch-stack/s0034.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0045.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0055.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0084.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0093.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0103.patch | 8++++----
Mthird_party/libwebrtc/moz-patch-stack/s0106.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0108.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0112.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0133.patch | 6+++---
Mthird_party/libwebrtc/rtc_tools/BUILD.gn | 68--------------------------------------------------------------------
Dthird_party/libwebrtc/rtc_tools/rtp_generator/configs/vp8.json | 13-------------
Dthird_party/libwebrtc/rtc_tools/rtp_generator/configs/vp9.json | 13-------------
Dthird_party/libwebrtc/rtc_tools/rtp_generator/main.cc | 48------------------------------------------------
Dthird_party/libwebrtc/rtc_tools/rtp_generator/rtp_generator.cc | 355-------------------------------------------------------------------------------
Dthird_party/libwebrtc/rtc_tools/rtp_generator/rtp_generator.h | 124-------------------------------------------------------------------------------
19 files changed, 34 insertions(+), 656 deletions(-)

diff --git a/third_party/libwebrtc/BUILD.gn b/third_party/libwebrtc/BUILD.gn @@ -70,7 +70,6 @@ if (!build_with_chromium && !build_with_mozilla) { "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", diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T20:58:11.051666+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T20:59:14.244732+00:00. # base of lastest vendoring -2875c08d16 +fe0a0c784e diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -116,7 +116,7 @@ index 1b112b34c0..18cf5d67f7 100644 # TODO(https://bugs.webrtc.org/14437): Remove this section if general # Chromium fix resolves the problem. diff --git a/BUILD.gn b/BUILD.gn -index d00f44d828..2e24ea6104 100644 +index c903beed96..a9cf2a6b1c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -33,7 +33,7 @@ if (is_android) { @@ -128,7 +128,7 @@ index d00f44d828..2e24ea6104 100644 # This target should (transitively) cause everything to be built; if you run # 'ninja default' and then 'ninja all', the second build should do no work. group("default") { -@@ -158,6 +158,10 @@ config("common_inherited_config") { +@@ -157,6 +157,10 @@ config("common_inherited_config") { defines += [ "WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT" ] } @@ -139,7 +139,7 @@ index d00f44d828..2e24ea6104 100644 if (!rtc_builtin_ssl_root_certificates) { defines += [ "WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS" ] } -@@ -500,9 +504,11 @@ config("common_config") { +@@ -499,9 +503,11 @@ config("common_config") { } } @@ -151,7 +151,7 @@ index d00f44d828..2e24ea6104 100644 if (!rtc_build_ssl) { config("external_ssl_library") { -@@ -565,6 +571,33 @@ if (!build_with_chromium) { +@@ -564,6 +570,33 @@ if (!build_with_chromium) { "sdk", "video", ] @@ -185,7 +185,7 @@ index d00f44d828..2e24ea6104 100644 if (rtc_include_builtin_audio_codecs) { deps += [ -@@ -577,6 +610,16 @@ if (!build_with_chromium) { +@@ -576,6 +609,16 @@ if (!build_with_chromium) { deps += [ "api/video:video_frame", "api/video:video_rtp_headers", diff --git a/third_party/libwebrtc/moz-patch-stack/s0034.patch b/third_party/libwebrtc/moz-patch-stack/s0034.patch @@ -20,10 +20,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e2 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index 2e24ea6104..f5e3ab55fb 100644 +index a9cf2a6b1c..efc744694d 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -443,12 +443,12 @@ config("common_config") { +@@ -442,12 +442,12 @@ config("common_config") { } } @@ -38,7 +38,7 @@ index 2e24ea6104..f5e3ab55fb 100644 defines += [ "WEBRTC_ARCH_ARM" ] if (arm_version >= 7) { defines += [ "WEBRTC_ARCH_ARM_V7" ] -@@ -458,7 +458,7 @@ config("common_config") { +@@ -457,7 +457,7 @@ config("common_config") { } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0045.patch b/third_party/libwebrtc/moz-patch-stack/s0045.patch @@ -18,10 +18,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb89 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index f5e3ab55fb..fa2a5501bf 100644 +index efc744694d..df103651c2 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -223,6 +223,9 @@ config("common_inherited_config") { +@@ -222,6 +222,9 @@ config("common_inherited_config") { if (is_linux || is_chromeos) { defines += [ "WEBRTC_LINUX" ] } diff --git a/third_party/libwebrtc/moz-patch-stack/s0055.patch b/third_party/libwebrtc/moz-patch-stack/s0055.patch @@ -11,10 +11,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca 2 files changed, 10 insertions(+) diff --git a/BUILD.gn b/BUILD.gn -index fa2a5501bf..8ff9c9280c 100644 +index df103651c2..8c481ad633 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -626,6 +626,10 @@ if (!build_with_chromium) { +@@ -625,6 +625,10 @@ if (!build_with_chromium) { ] } diff --git a/third_party/libwebrtc/moz-patch-stack/s0084.patch b/third_party/libwebrtc/moz-patch-stack/s0084.patch @@ -11,10 +11,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2185cab977988fd4a 3 files changed, 16 insertions(+) diff --git a/BUILD.gn b/BUILD.gn -index 8ff9c9280c..eda6322d13 100644 +index 8c481ad633..f7ac3da936 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -611,6 +611,7 @@ if (!build_with_chromium) { +@@ -610,6 +610,7 @@ if (!build_with_chromium) { if (build_with_mozilla) { deps += [ diff --git a/third_party/libwebrtc/moz-patch-stack/s0093.patch b/third_party/libwebrtc/moz-patch-stack/s0093.patch @@ -10,10 +10,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b050c455caa1d24a0 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index eda6322d13..603e90dd87 100644 +index f7ac3da936..7b3ea1ec50 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -283,6 +283,7 @@ config("rtc_prod_config") { +@@ -282,6 +282,7 @@ config("rtc_prod_config") { } group("tracing") { @@ -21,7 +21,7 @@ index eda6322d13..603e90dd87 100644 all_dependent_configs = [ "//third_party/perfetto/gn:public_config" ] if (rtc_use_perfetto) { if (build_with_chromium) { -@@ -299,6 +300,7 @@ group("tracing") { +@@ -298,6 +299,7 @@ group("tracing") { [ "//third_party/perfetto/include/perfetto/tracing" ] } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0103.patch b/third_party/libwebrtc/moz-patch-stack/s0103.patch @@ -75,7 +75,7 @@ index cdbd705ec2..4ee826ec58 100644 # The python interpreter to use by default. On Windows, this will look # for vpython3.exe and vpython3.bat. diff --git a/BUILD.gn b/BUILD.gn -index 603e90dd87..c0822c25c4 100644 +index 7b3ea1ec50..2e4ebfda99 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,15 +21,15 @@ @@ -98,7 +98,7 @@ index 603e90dd87..c0822c25c4 100644 import("//third_party/jni_zero/jni_zero.gni") } -@@ -538,7 +538,7 @@ if (!build_with_chromium) { +@@ -537,7 +537,7 @@ if (!build_with_chromium) { sources = [] complete_static_lib = true @@ -107,7 +107,7 @@ index 603e90dd87..c0822c25c4 100644 defines = [] deps = [ -@@ -850,7 +850,7 @@ rtc_static_library("dcsctp") { +@@ -849,7 +849,7 @@ rtc_static_library("dcsctp") { visibility = [ "//:default" ] sources = [] complete_static_lib = true @@ -116,7 +116,7 @@ index 603e90dd87..c0822c25c4 100644 defines = [] deps = [ "net/dcsctp/public:factory", -@@ -885,7 +885,7 @@ group("poison_software_video_codecs") { +@@ -884,7 +884,7 @@ group("poison_software_video_codecs") { if (!build_with_chromium) { # Write debug logs to gn_logs.txt. # This is also required for Siso builds. diff --git a/third_party/libwebrtc/moz-patch-stack/s0106.patch b/third_party/libwebrtc/moz-patch-stack/s0106.patch @@ -9,10 +9,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/90a33b06e51017d25 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn -index c0822c25c4..f35531cb4d 100644 +index 2e4ebfda99..8964d077bf 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -567,6 +567,7 @@ if (!build_with_chromium) { +@@ -566,6 +566,7 @@ if (!build_with_chromium) { "call", "common_audio", "common_video", @@ -20,7 +20,7 @@ index c0822c25c4..f35531cb4d 100644 "logging:rtc_event_log_api", "media", "modules", -@@ -847,7 +848,7 @@ if (rtc_include_tests && !build_with_chromium) { +@@ -846,7 +847,7 @@ if (rtc_include_tests && !build_with_chromium) { # Build target for standalone dcsctp rtc_static_library("dcsctp") { # Only the root target should depend on this. diff --git a/third_party/libwebrtc/moz-patch-stack/s0108.patch b/third_party/libwebrtc/moz-patch-stack/s0108.patch @@ -16,10 +16,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4527c41ef71d7683c 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index f35531cb4d..3b10d0740c 100644 +index 8964d077bf..123739a1ff 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -524,6 +524,9 @@ if (!rtc_build_ssl) { +@@ -523,6 +523,9 @@ if (!rtc_build_ssl) { "crypto", "ssl", ] @@ -29,7 +29,7 @@ index f35531cb4d..3b10d0740c 100644 } } -@@ -617,6 +620,7 @@ if (!build_with_chromium) { +@@ -616,6 +619,7 @@ if (!build_with_chromium) { "api/environment:environment_factory", "api/video:video_frame", "api/video:video_rtp_headers", diff --git a/third_party/libwebrtc/moz-patch-stack/s0112.patch b/third_party/libwebrtc/moz-patch-stack/s0112.patch @@ -10,10 +10,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/27c29807e6f46562d 1 file changed, 1 insertion(+) diff --git a/BUILD.gn b/BUILD.gn -index 3b10d0740c..0571aa8936 100644 +index 123739a1ff..ff12ae0545 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -617,6 +617,7 @@ if (!build_with_chromium) { +@@ -616,6 +616,7 @@ if (!build_with_chromium) { if (build_with_mozilla) { deps += [ diff --git a/third_party/libwebrtc/moz-patch-stack/s0133.patch b/third_party/libwebrtc/moz-patch-stack/s0133.patch @@ -9,10 +9,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/43de54a6e52daf0a0 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn -index 0571aa8936..64f86bedf1 100644 +index ff12ae0545..1ac89c4090 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -318,6 +318,17 @@ config("common_config") { +@@ -317,6 +317,17 @@ config("common_config") { cflags_objc = [] defines = [] @@ -30,7 +30,7 @@ index 0571aa8936..64f86bedf1 100644 if (rtc_enable_protobuf) { defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ] } else { -@@ -419,7 +430,7 @@ config("common_config") { +@@ -418,7 +429,7 @@ config("common_config") { # "-Wnested-externs", (C/Obj-C only) ] cflags_objc += [ "-Wstrict-prototypes" ] diff --git a/third_party/libwebrtc/rtc_tools/BUILD.gn b/third_party/libwebrtc/rtc_tools/BUILD.gn @@ -161,74 +161,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 diff --git a/third_party/libwebrtc/rtc_tools/rtp_generator/configs/vp8.json b/third_party/libwebrtc/rtc_tools/rtp_generator/configs/vp8.json @@ -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/third_party/libwebrtc/rtc_tools/rtp_generator/configs/vp9.json b/third_party/libwebrtc/rtc_tools/rtp_generator/configs/vp9.json @@ -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/third_party/libwebrtc/rtc_tools/rtp_generator/main.cc b/third_party/libwebrtc/rtc_tools/rtp_generator/main.cc @@ -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 <stdlib.h> - -#include <string> - -#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<webrtc::RtpGeneratorOptions> 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/third_party/libwebrtc/rtc_tools/rtp_generator/rtp_generator.cc b/third_party/libwebrtc/rtc_tools/rtp_generator/rtp_generator.cc @@ -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 <algorithm> -#include <cstddef> -#include <cstdint> -#include <cstring> -#include <memory> -#include <optional> -#include <string> -#include <utility> -#include <vector> - -#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<RtpGeneratorOptions::VideoSendStreamConfig> -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<RtpGeneratorOptions> 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<char> 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::CharReader> 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<RtpGeneratorOptions::VideoSendStreamConfig> - 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<LibvpxVp8EncoderTemplateAdapter, - LibvpxVp9EncoderTemplateAdapter, - LibaomAv1EncoderTemplateAdapter>>()), - video_decoder_factory_( - std::make_unique< - VideoDecoderFactoryTemplate<LibvpxVp8DecoderTemplateAdapter, - LibvpxVp9DecoderTemplateAdapter, - Dav1dDecoderTemplateAdapter>>()), - 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<VideoEncoderConfig::Vp8EncoderSpecificSettings>( - settings); - } else if (video_config.rtp.payload_name == kVp9CodecName) { - VideoCodecVP9 settings = VideoEncoder::GetDefaultVp9Settings(); - encoder_config.encoder_specific_settings = - make_ref_counted<VideoEncoderConfig::Vp9EncoderSpecificSettings>( - 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<test::FrameGeneratorCapturer> frame_generator = - std::make_unique<test::FrameGeneratorCapturer>( - &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<const uint8_t> 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<const uint8_t> 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/third_party/libwebrtc/rtc_tools/rtp_generator/rtp_generator.h b/third_party/libwebrtc/rtc_tools/rtp_generator/rtp_generator.h @@ -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 <cstddef> -#include <cstdint> -#include <memory> -#include <optional> -#include <string> -#include <vector> - -#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<VideoSendStreamConfig> video_streams; -}; - -// Attempts to parse RtpGeneratorOptions from a JSON file. Any failures -// will result in std::nullopt. -std::optional<RtpGeneratorOptions> 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<const uint8_t> packet, - const PacketOptions& options) override; - // RTCP packets are ignored for now. - bool SendRtcp(ArrayView<const uint8_t> 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<VideoEncoderFactory> video_encoder_factory_; - std::unique_ptr<VideoDecoderFactory> video_decoder_factory_; - std::unique_ptr<VideoBitrateAllocatorFactory> - video_bitrate_allocator_factory_; - std::unique_ptr<Call> call_; - std::unique_ptr<test::RtpFileWriter> rtp_dump_writer_; - std::vector<std::unique_ptr<test::FrameGeneratorCapturer>> frame_generators_; - std::vector<VideoSendStream*> video_send_streams_; - std::vector<uint32_t> durations_ms_; - uint32_t start_ms_ = 0; -}; - -} // namespace webrtc - -#endif // RTC_TOOLS_RTP_GENERATOR_RTP_GENERATOR_H_